mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 14:20:12 +00:00
Merge branch 'master' into update_react-leaflet
This commit is contained in:
@@ -126,6 +126,12 @@
|
||||
"sourceRepoURL": "https://github.com/bterlson/ecmarkup",
|
||||
"asOfVersion": "3.4.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "electron",
|
||||
"typingsPackageName": "electron",
|
||||
"sourceRepoURL": "https://github.com/electron/electron",
|
||||
"asOfVersion": "1.6.10"
|
||||
},
|
||||
{
|
||||
"libraryName": "electron-builder",
|
||||
"typingsPackageName": "electron-builder",
|
||||
|
||||
1
types/acl/index.d.ts
vendored
1
types/acl/index.d.ts
vendored
@@ -2,6 +2,7 @@
|
||||
// Project: https://github.com/optimalbits/node_acl
|
||||
// Definitions by: Qubo <https://github.com/tkQubo>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
/// <reference types="bluebird" />
|
||||
/// <reference types="node"/>
|
||||
|
||||
1
types/agenda/index.d.ts
vendored
1
types/agenda/index.d.ts
vendored
@@ -2,6 +2,7 @@
|
||||
// Project: https://github.com/rschmukler/agenda
|
||||
// Definitions by: Meir Gottlieb <https://github.com/meirgottlieb>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ appInsights = {
|
||||
trackDependency(id: string, method: string, absoluteUrl: string, pathName: string, totalTime: number, success: boolean, resultCode: number) { return null; },
|
||||
trackException(exception: Error, handledAt?: string, properties?: { [name: string]: string; }, measurements?: { [name: string]: number; }, severityLevel?: AI.SeverityLevel) { return null; },
|
||||
trackMetric(name: string, average: number, sampleCount?: number, min?: number, max?: number, properties?: { [name: string]: string; }) { return null; },
|
||||
trackTrace(message: string, properties?: { [name: string]: string; }) { return null; },
|
||||
trackTrace(message: string, properties?: { [name: string]: string; }, severityLevel?: AI.SeverityLevel) { return null; },
|
||||
flush() { return null; },
|
||||
setAuthenticatedUserContext(authenticatedUserId: string, accountId?: string) { return null; },
|
||||
clearAuthenticatedUserContext() { return null; },
|
||||
@@ -77,6 +77,7 @@ appInsights.trackException(new Error("sample error"), "handledAt", null, null);
|
||||
// trackTrace
|
||||
appInsights.trackTrace("message");
|
||||
appInsights.trackTrace("message", null);
|
||||
appInsights.trackTrace("message", { a: '1', b: '2' }, AI.SeverityLevel.Error);
|
||||
|
||||
// trackDependency
|
||||
appInsights.trackDependency("id", "POST", "http://example.com/test/abc", "/test/abc", null, true, null);
|
||||
@@ -117,7 +118,18 @@ const envelope = new Microsoft.ApplicationInsights.Telemetry.Common.Envelope(dat
|
||||
|
||||
context.track(envelope);
|
||||
|
||||
context.addTelemetryInitializer(telemetryEnvelope => false);
|
||||
context.addTelemetryInitializer(envelope => false);
|
||||
context.addTelemetryInitializer(envelope => { });
|
||||
|
||||
// a sample from: https://github.com/Microsoft/ApplicationInsights-JS/blob/master/API-reference.md#example
|
||||
context.addTelemetryInitializer(envelope => {
|
||||
let telemetryItem = envelope.data.baseData;
|
||||
if (envelope.name === Microsoft.ApplicationInsights.Telemetry.PageView.envelopeType) {
|
||||
telemetryItem.url = "URL CENSORED";
|
||||
}
|
||||
telemetryItem.properties = telemetryItem.properties || {};
|
||||
telemetryItem.properties["globalProperty"] = "boo";
|
||||
});
|
||||
|
||||
// track event
|
||||
const eventObj = new Microsoft.ApplicationInsights.Telemetry.Event("test", null, null);
|
||||
|
||||
6
types/applicationinsights-js/index.d.ts
vendored
6
types/applicationinsights-js/index.d.ts
vendored
@@ -572,6 +572,7 @@ declare module Microsoft.ApplicationInsights {
|
||||
isPerfAnalyzerEnabled?: boolean;
|
||||
url?: string;
|
||||
isStorageUseDisabled?: boolean;
|
||||
isBeaconApiDisabled?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -611,6 +612,7 @@ declare module Microsoft.ApplicationInsights {
|
||||
tags: {
|
||||
[name: string]: any;
|
||||
};
|
||||
data: any;
|
||||
}
|
||||
|
||||
interface ITelemetryContext {
|
||||
@@ -650,7 +652,7 @@ declare module Microsoft.ApplicationInsights {
|
||||
* Adds telemetry initializer to the collection. Telemetry initializers will be called one by one
|
||||
* before telemetry item is pushed for sending and in the order they were added.
|
||||
*/
|
||||
addTelemetryInitializer(telemetryInitializer: (envelope: Microsoft.ApplicationInsights.IEnvelope) => boolean): any;
|
||||
addTelemetryInitializer(telemetryInitializer: (envelope: Microsoft.ApplicationInsights.IEnvelope) => boolean | void): any;
|
||||
/**
|
||||
* Tracks telemetry object.
|
||||
*/
|
||||
@@ -763,7 +765,7 @@ declare module Microsoft.ApplicationInsights {
|
||||
* @param message A message string
|
||||
* @param properties map[string, string] - additional data used to filter traces in the portal. Defaults to empty.
|
||||
*/
|
||||
trackTrace(message: string, properties?: { [name: string]: string }): any;
|
||||
trackTrace(message: string, properties?: { [name: string]: string }, severityLevel?: AI.SeverityLevel): any;
|
||||
/**
|
||||
* Immediately send all queued telemetry.
|
||||
*/
|
||||
|
||||
@@ -188,6 +188,7 @@ str = cognitoUserPoolEvent.callerContext.clientId;
|
||||
str = cognitoUserPoolEvent.request.userAttributes["email"];
|
||||
str = cognitoUserPoolEvent.request.validationData["k1"];
|
||||
str = cognitoUserPoolEvent.request.codeParameter;
|
||||
str = cognitoUserPoolEvent.request.usernameParameter;
|
||||
b = cognitoUserPoolEvent.request.newDeviceUsed;
|
||||
cognitoUserPoolEvent.request.session[0].challengeName === "CUSTOM_CHALLENGE";
|
||||
cognitoUserPoolEvent.request.session[0].challengeName === "PASSWORD_VERIFIER";
|
||||
|
||||
1
types/aws-lambda/index.d.ts
vendored
1
types/aws-lambda/index.d.ts
vendored
@@ -142,6 +142,7 @@ interface CognitoUserPoolEvent {
|
||||
userAttributes: {[key: string]: string};
|
||||
validationData?: {[key: string]: string};
|
||||
codeParameter?: string;
|
||||
usernameParameter?: string;
|
||||
newDeviceUsed?: boolean;
|
||||
session?: {
|
||||
challengeName: "CUSTOM_CHALLENGE" | "PASSWORD_VERIFIER" | "SMS_MFA" | "DEVICE_SRP_AUTH" | "DEVICE_PASSWORD_VERIFIER" | "ADMIN_NO_SRP_AUTH";
|
||||
|
||||
@@ -1,45 +1,154 @@
|
||||
|
||||
import Boom = require('boom');
|
||||
import * as Hapi from 'hapi';
|
||||
|
||||
var bo = Boom.wrap(new Error('test'), 400, 'some message');
|
||||
var a: string = bo.output.headers['some header'];
|
||||
// 4xx and data type
|
||||
|
||||
Boom.create(500, 'Internal server error', { timestamp: Date.now() });
|
||||
const badRequestError = Boom.badRequest('message', {some: 'data'});
|
||||
badRequestError.data.some;
|
||||
const badRequestError2: Boom.BoomError = Boom.badImplementation('message');
|
||||
|
||||
Boom.badRequest('message', {some: 'data'});
|
||||
Boom.unauthorized('message', <string | string[]> 'scheme', {some: 'data'});
|
||||
Boom.unauthorized(null, <string | string[]> 'scheme', 'data');
|
||||
Boom.paymentRequired('message', {some: 'data'});
|
||||
Boom.forbidden('message', {some: 'data'});
|
||||
Boom.notFound('message', {some: 'data'});
|
||||
Boom.methodNotAllowed('message', {some: 'data'});
|
||||
Boom.notAcceptable('message', {some: 'data'});
|
||||
Boom.proxyAuthRequired('message', {some: 'data'});
|
||||
Boom.clientTimeout('message', {some: 'data'});
|
||||
Boom.conflict('message', {some: 'data'});
|
||||
Boom.resourceGone('message', {some: 'data'});
|
||||
Boom.lengthRequired('message', {some: 'data'});
|
||||
Boom.preconditionFailed('message', {some: 'data'});
|
||||
Boom.entityTooLarge('message', {some: 'data'});
|
||||
Boom.uriTooLong('message', {some: 'data'});
|
||||
Boom.unsupportedMediaType('message', {some: 'data'});
|
||||
Boom.rangeNotSatisfiable('message', {some: 'data'});
|
||||
Boom.expectationFailed('message', {some: 'data'});
|
||||
Boom.teapot('message', {some: 'data'});
|
||||
Boom.badData('message', {some: 'data'});
|
||||
Boom.locked('message', {some: 'data'});
|
||||
Boom.preconditionRequired('message', {some: 'data'});
|
||||
Boom.tooManyRequests('message', {some: 'data'});
|
||||
Boom.illegal('message', {some: 'data'});
|
||||
const unauthorizedError1 = Boom.unauthorized('message', 'scheme', {some: 'attribute'});
|
||||
unauthorizedError1.output.payload.attributes === { some: 'attribute', error: 'message' };
|
||||
unauthorizedError1.output.headers === { 'WWW-Authenticate': 'scheme some="attribute", error="message"' };
|
||||
|
||||
Boom.badImplementation('message', {some: 'data'});
|
||||
Boom.internal('message', {some: 'data'});
|
||||
Boom.notImplemented('message', {some: 'data'});
|
||||
Boom.badGateway('message', {some: 'data'});
|
||||
Boom.serverUnavailable('message', {some: 'data'});
|
||||
Boom.gatewayTimeout('message', {some: 'data'});
|
||||
const unauthorizedError2 = Boom.unauthorized('message', ['scheme']);
|
||||
unauthorizedError2.output.payload.attributes === undefined;
|
||||
unauthorizedError2.output.headers === { 'WWW-Authenticate': 'scheme' };
|
||||
|
||||
Boom.unauthorized() as Error;
|
||||
const unauthorizedError3 = Boom.unauthorized(null, 'scheme', 'attribute');
|
||||
unauthorizedError3.output.payload.attributes === 'attribute';
|
||||
unauthorizedError3.output.headers === { 'WWW-Authenticate': 'scheme attribute' };
|
||||
|
||||
const unauthorizedError4 = Boom.unauthorized(null, 'scheme', {some: 'attribute'});
|
||||
unauthorizedError4.output.payload.attributes === { some: 'attribute' };
|
||||
unauthorizedError4.output.headers === { 'WWW-Authenticate': 'scheme some="attribute"' };
|
||||
|
||||
const paymentRequiredError = Boom.paymentRequired('message', {some: 'data'});
|
||||
paymentRequiredError.data.some;
|
||||
const paymentRequiredError2: Boom.BoomError = Boom.paymentRequired('message');
|
||||
|
||||
const forbiddenError = Boom.forbidden('message', {some: 'data'});
|
||||
forbiddenError.data.some;
|
||||
const forbiddenError2: Boom.BoomError = Boom.forbidden('message');
|
||||
|
||||
const notFoundError = Boom.notFound('message', {some: 'data'});
|
||||
notFoundError.data.some;
|
||||
const notFoundError2: Boom.BoomError = Boom.notFound('message');
|
||||
|
||||
const methodNotAllowedError = Boom.methodNotAllowed('message', {some: 'data'});
|
||||
methodNotAllowedError.data.some;
|
||||
const methodNotAllowedError2: Boom.BoomError = Boom.methodNotAllowed('message');
|
||||
|
||||
const notAcceptableError = Boom.notAcceptable('message', {some: 'data'});
|
||||
notAcceptableError.data.some;
|
||||
const notAcceptableError2: Boom.BoomError = Boom.notAcceptable('message');
|
||||
|
||||
const proxyAuthRequiredError = Boom.proxyAuthRequired('message', {some: 'data'});
|
||||
proxyAuthRequiredError.data.some;
|
||||
const proxyAuthRequiredError2: Boom.BoomError = Boom.proxyAuthRequired('message');
|
||||
|
||||
const clientTimeoutError = Boom.clientTimeout('message', {some: 'data'});
|
||||
clientTimeoutError.data.some;
|
||||
const clientTimeoutError2: Boom.BoomError = 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.BoomError = Boom.resourceGone('message');
|
||||
|
||||
const lengthRequiredError = Boom.lengthRequired('message', {some: 'data'});
|
||||
lengthRequiredError.data.some;
|
||||
const lengthRequiredError2: Boom.BoomError = Boom.lengthRequired('message');
|
||||
|
||||
const preconditionFailedError = Boom.preconditionFailed('message', {some: 'data'});
|
||||
preconditionFailedError.data.some;
|
||||
const preconditionFailedError2: Boom.BoomError = Boom.preconditionFailed('message');
|
||||
|
||||
const entityTooLargeError = Boom.entityTooLarge('message', {some: 'data'});
|
||||
entityTooLargeError.data.some;
|
||||
const entityTooLargeError2: Boom.BoomError = Boom.lengthRequired('message');
|
||||
|
||||
const uriTooLongError = Boom.uriTooLong('message', {some: 'data'});
|
||||
uriTooLongError.data.some;
|
||||
const uriTooLongError2: Boom.BoomError = Boom.uriTooLong('message');
|
||||
|
||||
const unsupportedMediaTypeError = Boom.unsupportedMediaType('message', {some: 'data'});
|
||||
unsupportedMediaTypeError.data.some;
|
||||
const unsupportedMediaTypeError2: Boom.BoomError = Boom.unsupportedMediaType('message');
|
||||
|
||||
const rangeNotSatisfiableError = Boom.rangeNotSatisfiable('message', {some: 'data'});
|
||||
rangeNotSatisfiableError.data.some;
|
||||
const rangeNotSatisfiableError2: Boom.BoomError = Boom.rangeNotSatisfiable('message');
|
||||
|
||||
const expectationFailedError = Boom.expectationFailed('message', {some: 'data'});
|
||||
expectationFailedError.data.some;
|
||||
const expectationFailedError2: Boom.BoomError = Boom.expectationFailed('message');
|
||||
|
||||
const teapotError = Boom.teapot('message', {some: 'data'});
|
||||
teapotError.data.some;
|
||||
const teapotError2: Boom.BoomError = Boom.teapot('message');
|
||||
|
||||
const badDataError = Boom.badData('message', {some: 'data'});
|
||||
badDataError.data.some;
|
||||
const badDataError2: Boom.BoomError = Boom.badData('message');
|
||||
|
||||
const lockedError = Boom.locked('message', {some: 'data'});
|
||||
lockedError.data.some;
|
||||
const lockedError2: Boom.BoomError = Boom.locked('message');
|
||||
|
||||
const preconditionRequiredError = Boom.preconditionRequired('message', {some: 'data'});
|
||||
preconditionRequiredError.data.some;
|
||||
const preconditionRequiredError2: Boom.BoomError = Boom.preconditionRequired('message');
|
||||
|
||||
const tooManyRequestsError = Boom.tooManyRequests('message', {some: 'data'});
|
||||
tooManyRequestsError.data.some;
|
||||
const tooManyRequestsError2: Boom.BoomError = Boom.tooManyRequests('message');
|
||||
|
||||
const illegalError = Boom.illegal('message', {some: 'data'});
|
||||
illegalError.data.some;
|
||||
const illegalError2: Boom.BoomError = Boom.illegal('message');
|
||||
|
||||
// 5xx and data type
|
||||
|
||||
const badImplementationError = Boom.badImplementation('message', {some: 'data'});
|
||||
badImplementationError.data.some;
|
||||
const badImplementationError2: Boom.BoomError = Boom.badImplementation('message');
|
||||
|
||||
const internalError = Boom.internal('message', {some: 'data'});
|
||||
internalError.data.some;
|
||||
const internalError2: Boom.BoomError = Boom.internal('message');
|
||||
|
||||
const notImplementedError = Boom.notImplemented('message', {some: 'data'});
|
||||
notImplementedError.data.some;
|
||||
const notImplementedError2: Boom.BoomError = Boom.notImplemented('message');
|
||||
|
||||
const badGatewayError = Boom.badGateway('message', {some: 'data'});
|
||||
badGatewayError.data.some;
|
||||
const badGatewayError2: Boom.BoomError = Boom.badGateway('message');
|
||||
|
||||
const serverUnavailableError = Boom.serverUnavailable('message', {some: 'data'});
|
||||
serverUnavailableError.data.some;
|
||||
const serverUnavailableError2: Boom.BoomError = Boom.serverUnavailable('message');
|
||||
|
||||
const gatewayTimeoutError = Boom.gatewayTimeout('message', {some: 'data'});
|
||||
gatewayTimeoutError.data.some;
|
||||
const gatewayTimeoutError2: Boom.BoomError = Boom.gatewayTimeout('message');
|
||||
|
||||
// wrap and create
|
||||
|
||||
const wrappedError = Boom.wrap(new Error('test'), 400, 'some message');
|
||||
|
||||
const error1 = Boom.create(500, 'Internal server error', { timestamp: Date.now() });
|
||||
error1.data.timestamp;
|
||||
const error2: Boom.BoomError = Boom.create(500, 'Internal server error');
|
||||
|
||||
// type widen asserting
|
||||
|
||||
const unauthorizedError = Boom.unauthorized() as Error;
|
||||
|
||||
// status code and reformat
|
||||
|
||||
const error = Boom.badRequest('Cannot feed after midnight');
|
||||
error.output.statusCode = 499; // Assign a custom error code
|
||||
@@ -54,3 +163,30 @@ interface CustomPayload extends Boom.Payload {
|
||||
}
|
||||
|
||||
(error.output.payload as CustomPayload).custom = 'abc_123';
|
||||
|
||||
/**
|
||||
* Test assignment of custom error data:
|
||||
*/
|
||||
const errorWithData = Boom.badImplementation('', { custom1: 'test', customType: 'Custom1', isCustom: true } as CustomData1);
|
||||
const errorWithNoExplicitDataType: Boom.BoomError = errorWithData; // can assign to error without explicit data type
|
||||
const errorWithExplicitType: Boom.BoomError<CustomData> = errorWithData; // can assign to union data type
|
||||
const errorWithConcreteCustomData: Boom.BoomError<CustomData1> = errorWithData; // can assign to concrete data type
|
||||
// assignment to CustomData2 would not be possible
|
||||
// const errorWithConcreteCustomData2: Boom.BoomError<CustomData2> = errorWithData;
|
||||
|
||||
// Some complex error data types for testing purposes:
|
||||
interface CustomDataBase {
|
||||
isCustom: true;
|
||||
}
|
||||
|
||||
interface CustomData1 extends CustomDataBase {
|
||||
customType: 'Custom1';
|
||||
custom1: string;
|
||||
}
|
||||
|
||||
interface CustomData2 extends CustomDataBase {
|
||||
customType: 'Custom2';
|
||||
custom2: string;
|
||||
}
|
||||
|
||||
type CustomData = CustomData1 | CustomData2;
|
||||
|
||||
79
types/boom/index.d.ts
vendored
79
types/boom/index.d.ts
vendored
@@ -2,6 +2,7 @@
|
||||
// Project: http://github.com/hapijs/boom
|
||||
// Definitions by: Igor Rogatty <http://github.com/rogatty>, AJP <http://github.com/AJamesPhillips>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
export = Boom;
|
||||
|
||||
@@ -11,7 +12,7 @@ declare namespace 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 interface BoomError extends Error {
|
||||
export interface BoomError<Data = any> extends Error {
|
||||
/** isBoom - if true, indicates this is a Boom object instance. */
|
||||
isBoom: boolean;
|
||||
/** isServer - convenience bool indicating status code >= 500. */
|
||||
@@ -24,6 +25,8 @@ declare namespace Boom {
|
||||
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} */
|
||||
isMissing?: boolean;
|
||||
/** https://github.com/hapijs/boom#createstatuscode-message-data and https://github.com/hapijs/boom/blob/v4.3.0/lib/index.js#L99 */
|
||||
data: Data;
|
||||
}
|
||||
|
||||
export interface Output {
|
||||
@@ -34,6 +37,7 @@ declare namespace Boom {
|
||||
/** payload - the formatted object used as the response payload (stringified). Can be directly manipulated but any changes will be lost if reformat() is called. Any content allowed and by default includes the following content: */
|
||||
payload: Payload;
|
||||
}
|
||||
|
||||
export interface Payload {
|
||||
/** statusCode - the HTTP status code, derived from error.output.statusCode. */
|
||||
statusCode: number;
|
||||
@@ -41,6 +45,11 @@ declare namespace Boom {
|
||||
error: string;
|
||||
/** message - the error message derived from error.message. */
|
||||
message: string;
|
||||
/**
|
||||
* "Every key/value pair will be included ... in the response payload under the attributes key."
|
||||
* [see docs](https://github.com/hapijs/boom#boomunauthorizedmessage-scheme-attributes)
|
||||
*/
|
||||
attributes?: any;
|
||||
// Excluded this to aid typing of the other values. See tests for example casting to a custom interface to manipulate the payload
|
||||
// [anyContent: string]: any;
|
||||
}
|
||||
@@ -52,7 +61,7 @@ declare namespace Boom {
|
||||
* @param message optional message string. If the error already has a message, it adds the message as a prefix. Defaults to no message.
|
||||
* @see {@link https://github.com/hapijs/boom#wraperror-statuscode-message}
|
||||
*/
|
||||
export function wrap(error: Error, statusCode?: number, message?: string): BoomError;
|
||||
export function wrap(error: Error, statusCode?: number, message?: string): BoomError<null>;
|
||||
|
||||
/**
|
||||
* Generates an Error object with the boom decorations
|
||||
@@ -61,7 +70,7 @@ declare namespace Boom {
|
||||
* @param data additional error data set to error.data property.
|
||||
* @see {@link https://github.com/hapijs/boom#createstatuscode-message-data}
|
||||
*/
|
||||
export function create(statusCode: number, message?: string, data?: any): BoomError;
|
||||
export function create<Data = null>(statusCode: number, message?: string, data?: Data): BoomError<Data>;
|
||||
|
||||
// 4xx
|
||||
/**
|
||||
@@ -70,7 +79,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boombadrequestmessage-data}
|
||||
*/
|
||||
export function badRequest(message?: string, data?: any): BoomError;
|
||||
export function badRequest<Data = null>(message?: string, data?: Data): BoomError<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 401 Unauthorized error
|
||||
@@ -81,8 +90,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 | string[], attributes?: {[index: string]: string}): BoomError;
|
||||
export function unauthorized(message?: null, scheme?: string | string[], attributes?: string): BoomError;
|
||||
export function unauthorized(message?: string, scheme?: string, attributes?: {[index: string]: string}): BoomError<null>;
|
||||
export function unauthorized(message?: string, scheme?: string[]): BoomError<null>;
|
||||
export function unauthorized(message?: null, scheme?: string, attributes?: {[index: string]: string} | string): BoomError<null>;
|
||||
export function unauthorized(message?: null, scheme?: string[]): BoomError<null>;
|
||||
|
||||
/**
|
||||
* Returns a 402 Payment Required error
|
||||
@@ -90,7 +101,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boompaymentrequiredmessage-data}
|
||||
*/
|
||||
export function paymentRequired(message?: string, data?: any): BoomError;
|
||||
export function paymentRequired<Data = null>(message?: string, data?: Data): BoomError<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 403 Forbidden error
|
||||
@@ -98,7 +109,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomforbiddenmessage-data}
|
||||
*/
|
||||
export function forbidden(message?: string, data?: any): BoomError;
|
||||
export function forbidden<Data = null>(message?: string, data?: Data): BoomError<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 404 Not Found error
|
||||
@@ -106,7 +117,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomnotfoundmessage-data}
|
||||
*/
|
||||
export function notFound(message?: string, data?: any): BoomError;
|
||||
export function notFound<Data = null>(message?: string, data?: Data): BoomError<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 405 Method Not Allowed error
|
||||
@@ -115,7 +126,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(message?: string, data?: any, allow?: string | string[]): BoomError;
|
||||
export function methodNotAllowed<Data = null>(message?: string, data?: Data, allow?: string | string[]): BoomError<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 406 Not Acceptable error
|
||||
@@ -123,7 +134,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomnotacceptablemessage-data}
|
||||
*/
|
||||
export function notAcceptable(message?: string, data?: any): BoomError;
|
||||
export function notAcceptable<Data = null>(message?: string, data?: Data): BoomError<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 407 Proxy Authentication Required error
|
||||
@@ -131,7 +142,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomproxyauthrequiredmessage-data}
|
||||
*/
|
||||
export function proxyAuthRequired(message?: string, data?: any): BoomError;
|
||||
export function proxyAuthRequired<Data = null>(message?: string, data?: Data): BoomError<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 408 Request Time-out error
|
||||
@@ -139,7 +150,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomclienttimeoutmessage-data}
|
||||
*/
|
||||
export function clientTimeout(message?: string, data?: any): BoomError;
|
||||
export function clientTimeout<Data = null>(message?: string, data?: Data): BoomError<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 409 Conflict error
|
||||
@@ -147,7 +158,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomconflictmessage-data}
|
||||
*/
|
||||
export function conflict(message?: string, data?: any): BoomError;
|
||||
export function conflict<Data = null>(message?: string, data?: Data): BoomError<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 410 Gone error
|
||||
@@ -155,7 +166,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomresourcegonemessage-data}
|
||||
*/
|
||||
export function resourceGone(message?: string, data?: any): BoomError;
|
||||
export function resourceGone<Data = null>(message?: string, data?: Data): BoomError<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 411 Length Required error
|
||||
@@ -163,7 +174,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomlengthrequiredmessage-data}
|
||||
*/
|
||||
export function lengthRequired(message?: string, data?: any): BoomError;
|
||||
export function lengthRequired<Data = null>(message?: string, data?: Data): BoomError<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 412 Precondition Failed error
|
||||
@@ -171,7 +182,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boompreconditionfailedmessage-data}
|
||||
*/
|
||||
export function preconditionFailed(message?: string, data?: any): BoomError;
|
||||
export function preconditionFailed<Data = null>(message?: string, data?: Data): BoomError<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 413 Request Entity Too Large error
|
||||
@@ -179,7 +190,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomentitytoolargemessage-data}
|
||||
*/
|
||||
export function entityTooLarge(message?: string, data?: any): BoomError;
|
||||
export function entityTooLarge<Data = null>(message?: string, data?: Data): BoomError<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 414 Request-URI Too Large error
|
||||
@@ -187,7 +198,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomuritoolongmessage-data}
|
||||
*/
|
||||
export function uriTooLong(message?: string, data?: any): BoomError;
|
||||
export function uriTooLong<Data = null>(message?: string, data?: Data): BoomError<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 415 Unsupported Media Type error
|
||||
@@ -195,7 +206,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomunsupportedmediatypemessage-data}
|
||||
*/
|
||||
export function unsupportedMediaType(message?: string, data?: any): BoomError;
|
||||
export function unsupportedMediaType<Data = null>(message?: string, data?: Data): BoomError<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 416 Requested Range Not Satisfiable error
|
||||
@@ -203,7 +214,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomrangenotsatisfiablemessage-data}
|
||||
*/
|
||||
export function rangeNotSatisfiable(message?: string, data?: any): BoomError;
|
||||
export function rangeNotSatisfiable<Data = null>(message?: string, data?: Data): BoomError<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 417 Expectation Failed error
|
||||
@@ -211,7 +222,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomexpectationfailedmessage-data}
|
||||
*/
|
||||
export function expectationFailed(message?: string, data?: any): BoomError;
|
||||
export function expectationFailed<Data = null>(message?: string, data?: Data): BoomError<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 418 I'm a Teapot error
|
||||
@@ -219,7 +230,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomteapotmessage-data}
|
||||
*/
|
||||
export function teapot(message?: string, data?: any): BoomError;
|
||||
export function teapot<Data = null>(message?: string, data?: Data): BoomError<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 422 Unprocessable Entity error
|
||||
@@ -227,7 +238,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boombaddatamessage-data}
|
||||
*/
|
||||
export function badData(message?: string, data?: any): BoomError;
|
||||
export function badData<Data = null>(message?: string, data?: Data): BoomError<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 423 Locked error
|
||||
@@ -235,7 +246,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomlockedmessage-data}
|
||||
*/
|
||||
export function locked(message?: string, data?: any): BoomError;
|
||||
export function locked<Data = null>(message?: string, data?: Data): BoomError<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 428 Precondition Required error
|
||||
@@ -243,7 +254,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boompreconditionrequiredmessage-data}
|
||||
*/
|
||||
export function preconditionRequired(message?: string, data?: any): BoomError;
|
||||
export function preconditionRequired<Data = null>(message?: string, data?: Data): BoomError<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 429 Too Many Requests error
|
||||
@@ -251,7 +262,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomtoomanyrequestsmessage-data}
|
||||
*/
|
||||
export function tooManyRequests(message?: string, data?: any): BoomError;
|
||||
export function tooManyRequests<Data = null>(message?: string, data?: Data): BoomError<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 451 Unavailable For Legal Reasons error
|
||||
@@ -259,7 +270,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomillegalmessage-data}
|
||||
*/
|
||||
export function illegal(message?: string, data?: any): BoomError;
|
||||
export function illegal<Data = null>(message?: string, data?: Data): BoomError<Data>;
|
||||
|
||||
// 5xx
|
||||
/**
|
||||
@@ -269,7 +280,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boombadimplementationmessage-data---alias-internal}
|
||||
*/
|
||||
export function badImplementation(message?: string, data?: any): BoomError;
|
||||
export function badImplementation<Data = null>(message?: string, data?: Data): BoomError<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 500 Internal Server Error error
|
||||
@@ -278,7 +289,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boombadimplementationmessage-data---alias-internal}
|
||||
*/
|
||||
export function internal(message?: string, data?: any): BoomError;
|
||||
export function internal<Data = null>(message?: string, data?: Data): BoomError<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 501 Not Implemented error with your error message to the user
|
||||
@@ -286,7 +297,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomnotimplementedmessage-data}
|
||||
*/
|
||||
export function notImplemented(message?: string, data?: any): BoomError;
|
||||
export function notImplemented<Data = null>(message?: string, data?: Data): BoomError<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 502 Bad Gateway error with your error message to the user
|
||||
@@ -294,7 +305,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boombadgatewaymessage-data}
|
||||
*/
|
||||
export function badGateway(message?: string, data?: any): BoomError;
|
||||
export function badGateway<Data = null>(message?: string, data?: Data): BoomError<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 503 Service Unavailable error with your error message to the user
|
||||
@@ -302,7 +313,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomserverunavailablemessage-data}
|
||||
*/
|
||||
export function serverUnavailable(message?: string, data?: any): BoomError;
|
||||
export function serverUnavailable<Data = null>(message?: string, data?: Data): BoomError<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 504 Gateway Time-out error with your error message to the user
|
||||
@@ -310,5 +321,5 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomgatewaytimeoutmessage-data}
|
||||
*/
|
||||
export function gatewayTimeout(message?: string, data?: any): BoomError;
|
||||
export function gatewayTimeout<Data = null>(message?: string, data?: Data): BoomError<Data>;
|
||||
}
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
|
||||
import Logger = require('bunyan');
|
||||
|
||||
var ringBufferOptions: Logger.RingBufferOptions = {
|
||||
let ringBufferOptions: Logger.RingBufferOptions = {
|
||||
limit: 100
|
||||
};
|
||||
var ringBuffer: Logger.RingBuffer = new Logger.RingBuffer(ringBufferOptions);
|
||||
let ringBuffer: Logger.RingBuffer = new Logger.RingBuffer(ringBufferOptions);
|
||||
ringBuffer.write("hello");
|
||||
ringBuffer.end();
|
||||
ringBuffer.destroy();
|
||||
ringBuffer.destroySoon();
|
||||
|
||||
var level: number;
|
||||
let level: number;
|
||||
level = Logger.resolveLevel("trace");
|
||||
level = Logger.resolveLevel("debug");
|
||||
level = Logger.resolveLevel("info");
|
||||
@@ -24,7 +23,7 @@ level = Logger.resolveLevel(Logger.WARN);
|
||||
level = Logger.resolveLevel(Logger.ERROR);
|
||||
level = Logger.resolveLevel(Logger.FATAL);
|
||||
|
||||
var options: Logger.LoggerOptions = {
|
||||
let options: Logger.LoggerOptions = {
|
||||
name: 'test-logger',
|
||||
serializers: Logger.stdSerializers,
|
||||
streams: [{
|
||||
@@ -54,13 +53,13 @@ var options: Logger.LoggerOptions = {
|
||||
}]
|
||||
};
|
||||
|
||||
var log = Logger.createLogger(options);
|
||||
let log = Logger.createLogger(options);
|
||||
|
||||
var customSerializer = function(anything: any) {
|
||||
return { obj: anything};
|
||||
let customSerializer = (anything: any) => {
|
||||
return { obj: anything };
|
||||
};
|
||||
|
||||
log.addSerializers({anything: customSerializer});
|
||||
log.addSerializers({ anything: customSerializer });
|
||||
log.addSerializers(Logger.stdSerializers);
|
||||
log.addSerializers(
|
||||
{
|
||||
@@ -70,9 +69,9 @@ log.addSerializers(
|
||||
}
|
||||
);
|
||||
|
||||
var child = log.child({name: 'child'});
|
||||
let child = log.child({ name: 'child' });
|
||||
child.reopenFileStreams();
|
||||
log.addStream({path: '/dev/null'});
|
||||
log.addStream({ path: '/dev/null' });
|
||||
child.level(Logger.DEBUG);
|
||||
child.level('debug');
|
||||
child.levels(0, Logger.ERROR);
|
||||
@@ -80,9 +79,9 @@ child.levels(0, 'error');
|
||||
child.levels('stream1', Logger.FATAL);
|
||||
child.levels('stream1', 'fatal');
|
||||
|
||||
var buffer = new Buffer(0);
|
||||
var error = new Error('');
|
||||
var object = {
|
||||
let buffer = new Buffer(0);
|
||||
let error = new Error('');
|
||||
let object = {
|
||||
test: 123
|
||||
};
|
||||
|
||||
@@ -117,12 +116,11 @@ log.fatal(error);
|
||||
log.fatal(object);
|
||||
log.fatal('Hello, %s', 'world!');
|
||||
|
||||
var recursive: any = {
|
||||
let recursive: any = {
|
||||
hello: 'world',
|
||||
whats: {
|
||||
huh: recursive
|
||||
}
|
||||
}
|
||||
whats: {}
|
||||
};
|
||||
recursive.whats['huh'] = recursive;
|
||||
|
||||
JSON.stringify(recursive, Logger.safeCycles());
|
||||
|
||||
|
||||
241
types/bunyan/index.d.ts
vendored
241
types/bunyan/index.d.ts
vendored
@@ -1,4 +1,4 @@
|
||||
// Type definitions for node-bunyan
|
||||
// Type definitions for bunyan 1.8
|
||||
// Project: https://github.com/trentm/node-bunyan
|
||||
// Definitions by: Alex Mikhalev <https://github.com/amikhalev>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
@@ -10,21 +10,24 @@ import { EventEmitter } from 'events';
|
||||
declare class Logger extends EventEmitter {
|
||||
constructor(options: Logger.LoggerOptions);
|
||||
addStream(stream: Logger.Stream): void;
|
||||
addSerializers(serializers: Logger.Serializers | Logger.StdSerializers): void;
|
||||
child(options: Logger.LoggerOptions, simple?: boolean): Logger;
|
||||
child(obj: Object, simple?: boolean): Logger;
|
||||
addSerializers(serializers: Logger.Serializers): void;
|
||||
child(options: Object, simple?: boolean): Logger;
|
||||
reopenFileStreams(): void;
|
||||
|
||||
level(): string | number;
|
||||
level(value: number | string): void;
|
||||
levels(name: number | string, value: number | string): void;
|
||||
level(): number;
|
||||
level(value: Logger.LogLevel): void;
|
||||
levels(): number[];
|
||||
levels(name: number | string): number;
|
||||
levels(name: number | string, value: Logger.LogLevel): void;
|
||||
|
||||
fields: any;
|
||||
src: boolean;
|
||||
|
||||
/* tslint:disable:unified-signatures */
|
||||
|
||||
/**
|
||||
* Returns a boolean: is the `trace` level enabled?
|
||||
*
|
||||
*
|
||||
* This is equivalent to `log.isTraceEnabled()` or `log.isEnabledFor(TRACE)` in log4j.
|
||||
*/
|
||||
trace(): boolean;
|
||||
@@ -35,27 +38,25 @@ declare class Logger extends EventEmitter {
|
||||
* (including the stack) and sets `msg` to the exception
|
||||
* message or you can specify the `msg`.
|
||||
*/
|
||||
trace(error: Error, format?: any, ...params: any[]): void;
|
||||
|
||||
trace(buffer: Buffer, format?: any, ...params: any[]): void;
|
||||
|
||||
/**
|
||||
* Uses `util.format` for msg formatting.
|
||||
*/
|
||||
trace(format: string | number, ...params: any[]): void;
|
||||
trace(error: Error, ...params: any[]): void;
|
||||
|
||||
/**
|
||||
* The first field can optionally be a "fields" object, which
|
||||
* is merged into the log record.
|
||||
*
|
||||
*
|
||||
* To pass in an Error *and* other fields, use the `err`
|
||||
* field name for the Error instance.
|
||||
*/
|
||||
trace(obj: Object, format?: any, ...params: any[]): void;
|
||||
trace(obj: Object, ...params: any[]): void;
|
||||
|
||||
/**
|
||||
* Uses `util.format` for msg formatting.
|
||||
*/
|
||||
trace(format: any, ...params: any[]): void;
|
||||
|
||||
/**
|
||||
* Returns a boolean: is the `debug` level enabled?
|
||||
*
|
||||
*
|
||||
* This is equivalent to `log.isDebugEnabled()` or `log.isEnabledFor(DEBUG)` in log4j.
|
||||
*/
|
||||
debug(): boolean;
|
||||
@@ -66,27 +67,25 @@ declare class Logger extends EventEmitter {
|
||||
* (including the stack) and sets `msg` to the exception
|
||||
* message or you can specify the `msg`.
|
||||
*/
|
||||
debug(error: Error, format?: any, ...params: any[]): void;
|
||||
|
||||
debug(buffer: Buffer, format?: any, ...params: any[]): void;
|
||||
|
||||
/**
|
||||
* Uses `util.format` for msg formatting.
|
||||
*/
|
||||
debug(format: string | number, ...params: any[]): void;
|
||||
debug(error: Error, ...params: any[]): void;
|
||||
|
||||
/**
|
||||
* The first field can optionally be a "fields" object, which
|
||||
* is merged into the log record.
|
||||
*
|
||||
*
|
||||
* To pass in an Error *and* other fields, use the `err`
|
||||
* field name for the Error instance.
|
||||
*/
|
||||
debug(obj: Object, format?: any, ...params: any[]): void;
|
||||
debug(obj: Object, ...params: any[]): void;
|
||||
|
||||
/**
|
||||
* Uses `util.format` for msg formatting.
|
||||
*/
|
||||
debug(format: any, ...params: any[]): void;
|
||||
|
||||
/**
|
||||
* Returns a boolean: is the `info` level enabled?
|
||||
*
|
||||
*
|
||||
* This is equivalent to `log.isInfoEnabled()` or `log.isEnabledFor(INFO)` in log4j.
|
||||
*/
|
||||
info(): boolean;
|
||||
@@ -97,27 +96,25 @@ declare class Logger extends EventEmitter {
|
||||
* (including the stack) and sets `msg` to the exception
|
||||
* message or you can specify the `msg`.
|
||||
*/
|
||||
info(error: Error, format?: any, ...params: any[]): void;
|
||||
|
||||
info(buffer: Buffer, format?: any, ...params: any[]): void;
|
||||
|
||||
/**
|
||||
* Uses `util.format` for msg formatting.
|
||||
*/
|
||||
info(format: string | number, ...params: any[]): void;
|
||||
info(error: Error, ...params: any[]): void;
|
||||
|
||||
/**
|
||||
* The first field can optionally be a "fields" object, which
|
||||
* is merged into the log record.
|
||||
*
|
||||
*
|
||||
* To pass in an Error *and* other fields, use the `err`
|
||||
* field name for the Error instance.
|
||||
*/
|
||||
info(obj: Object, format?: any, ...params: any[]): void;
|
||||
info(obj: Object, ...params: any[]): void;
|
||||
|
||||
/**
|
||||
* Uses `util.format` for msg formatting.
|
||||
*/
|
||||
info(format: any, ...params: any[]): void;
|
||||
|
||||
/**
|
||||
* Returns a boolean: is the `warn` level enabled?
|
||||
*
|
||||
*
|
||||
* This is equivalent to `log.isWarnEnabled()` or `log.isEnabledFor(WARN)` in log4j.
|
||||
*/
|
||||
warn(): boolean;
|
||||
@@ -128,27 +125,25 @@ declare class Logger extends EventEmitter {
|
||||
* (including the stack) and sets `msg` to the exception
|
||||
* message or you can specify the `msg`.
|
||||
*/
|
||||
warn(error: Error, format?: any, ...params: any[]): void;
|
||||
|
||||
warn(buffer: Buffer, format?: any, ...params: any[]): void;
|
||||
|
||||
/**
|
||||
* Uses `util.format` for msg formatting.
|
||||
*/
|
||||
warn(format: string | number, ...params: any[]): void;
|
||||
warn(error: Error, ...params: any[]): void;
|
||||
|
||||
/**
|
||||
* The first field can optionally be a "fields" object, which
|
||||
* is merged into the log record.
|
||||
*
|
||||
*
|
||||
* To pass in an Error *and* other fields, use the `err`
|
||||
* field name for the Error instance.
|
||||
*/
|
||||
warn(obj: Object, format?: any, ...params: any[]): void;
|
||||
warn(obj: Object, ...params: any[]): void;
|
||||
|
||||
/**
|
||||
* Uses `util.format` for msg formatting.
|
||||
*/
|
||||
warn(format: any, ...params: any[]): void;
|
||||
|
||||
/**
|
||||
* Returns a boolean: is the `error` level enabled?
|
||||
*
|
||||
*
|
||||
* This is equivalent to `log.isErrorEnabled()` or `log.isEnabledFor(ERROR)` in log4j.
|
||||
*/
|
||||
error(): boolean;
|
||||
@@ -159,27 +154,25 @@ declare class Logger extends EventEmitter {
|
||||
* (including the stack) and sets `msg` to the exception
|
||||
* message or you can specify the `msg`.
|
||||
*/
|
||||
error(error: Error, format?: any, ...params: any[]): void;
|
||||
|
||||
error(buffer: Buffer, format?: any, ...params: any[]): void;
|
||||
|
||||
/**
|
||||
* Uses `util.format` for msg formatting.
|
||||
*/
|
||||
error(format: string | number, ...params: any[]): void;
|
||||
error(error: Error, ...params: any[]): void;
|
||||
|
||||
/**
|
||||
* The first field can optionally be a "fields" object, which
|
||||
* is merged into the log record.
|
||||
*
|
||||
*
|
||||
* To pass in an Error *and* other fields, use the `err`
|
||||
* field name for the Error instance.
|
||||
*/
|
||||
error(obj: Object, format?: any, ...params: any[]): void;
|
||||
error(obj: Object, ...params: any[]): void;
|
||||
|
||||
/**
|
||||
* Uses `util.format` for msg formatting.
|
||||
*/
|
||||
error(format: any, ...params: any[]): void;
|
||||
|
||||
/**
|
||||
* Returns a boolean: is the `fatal` level enabled?
|
||||
*
|
||||
*
|
||||
* This is equivalent to `log.isFatalEnabled()` or `log.isEnabledFor(FATAL)` in log4j.
|
||||
*/
|
||||
fatal(): boolean;
|
||||
@@ -190,90 +183,90 @@ declare class Logger extends EventEmitter {
|
||||
* (including the stack) and sets `msg` to the exception
|
||||
* message or you can specify the `msg`.
|
||||
*/
|
||||
fatal(error: Error, format?: any, ...params: any[]): void;
|
||||
|
||||
fatal(buffer: Buffer, format?: any, ...params: any[]): void;
|
||||
|
||||
/**
|
||||
* Uses `util.format` for msg formatting.
|
||||
*/
|
||||
fatal(format: string | number, ...params: any[]): void;
|
||||
fatal(error: Error, ...params: any[]): void;
|
||||
|
||||
/**
|
||||
* The first field can optionally be a "fields" object, which
|
||||
* is merged into the log record.
|
||||
*
|
||||
*
|
||||
* To pass in an Error *and* other fields, use the `err`
|
||||
* field name for the Error instance.
|
||||
*/
|
||||
fatal(obj: Object, format?: any, ...params: any[]): void;
|
||||
fatal(obj: Object, ...params: any[]): void;
|
||||
|
||||
/**
|
||||
* Uses `util.format` for msg formatting.
|
||||
*/
|
||||
fatal(format: any, ...params: any[]): void;
|
||||
|
||||
/* tslint:enable:unified-signatures */
|
||||
}
|
||||
|
||||
declare namespace Logger {
|
||||
const TRACE: number;
|
||||
const DEBUG: number;
|
||||
const INFO: number;
|
||||
const WARN: number;
|
||||
const ERROR: number;
|
||||
const FATAL: number;
|
||||
const TRACE: number;
|
||||
const DEBUG: number;
|
||||
const INFO: number;
|
||||
const WARN: number;
|
||||
const ERROR: number;
|
||||
const FATAL: number;
|
||||
|
||||
const stdSerializers: StdSerializers;
|
||||
type LogLevel = 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal' | number;
|
||||
|
||||
function createLogger(options: LoggerOptions): Logger;
|
||||
const stdSerializers: StdSerializers;
|
||||
|
||||
function safeCycles(): (key: string, value: any) => any;
|
||||
function createLogger(options: LoggerOptions): Logger;
|
||||
|
||||
function resolveLevel(value: number | string): number;
|
||||
function safeCycles(): (key: string, value: any) => any;
|
||||
|
||||
interface Stream {
|
||||
type?: string;
|
||||
level?: number | string;
|
||||
path?: string;
|
||||
stream?: NodeJS.WritableStream | Stream;
|
||||
closeOnExit?: boolean;
|
||||
period?: string;
|
||||
count?: number;
|
||||
}
|
||||
function resolveLevel(value: LogLevel): number;
|
||||
|
||||
interface LoggerOptions {
|
||||
name: string;
|
||||
streams?: Stream[];
|
||||
level?: string | number;
|
||||
stream?: NodeJS.WritableStream;
|
||||
serializers?: Serializers | StdSerializers;
|
||||
src?: boolean;
|
||||
[custom: string]: any;
|
||||
}
|
||||
interface Stream {
|
||||
type?: string;
|
||||
level?: LogLevel;
|
||||
path?: string;
|
||||
stream?: NodeJS.WritableStream | Stream;
|
||||
closeOnExit?: boolean;
|
||||
period?: string;
|
||||
count?: number;
|
||||
}
|
||||
|
||||
interface Serializer {
|
||||
(input:any): any;
|
||||
}
|
||||
interface LoggerOptions {
|
||||
name: string;
|
||||
streams?: Stream[];
|
||||
level?: LogLevel;
|
||||
stream?: NodeJS.WritableStream;
|
||||
serializers?: Serializers;
|
||||
src?: boolean;
|
||||
[custom: string]: any;
|
||||
}
|
||||
|
||||
interface Serializers {
|
||||
[key: string]: Serializer
|
||||
}
|
||||
type Serializer = (input: any) => any;
|
||||
|
||||
interface StdSerializers {
|
||||
err: Serializer;
|
||||
res: Serializer;
|
||||
req: Serializer;
|
||||
}
|
||||
interface Serializers {
|
||||
[key: string]: Serializer;
|
||||
}
|
||||
|
||||
interface RingBufferOptions {
|
||||
limit?: number;
|
||||
}
|
||||
interface StdSerializers extends Serializers {
|
||||
err: Serializer;
|
||||
res: Serializer;
|
||||
req: Serializer;
|
||||
}
|
||||
|
||||
class RingBuffer extends EventEmitter implements NodeJS.WritableStream {
|
||||
constructor(options: RingBufferOptions);
|
||||
interface RingBufferOptions {
|
||||
limit?: number;
|
||||
}
|
||||
|
||||
writable: boolean;
|
||||
records: any[];
|
||||
class RingBuffer extends EventEmitter implements NodeJS.WritableStream {
|
||||
constructor(options: RingBufferOptions);
|
||||
|
||||
write(record: any): boolean;
|
||||
end(record?: any): void;
|
||||
destroy(): void;
|
||||
destroySoon(): void;
|
||||
}
|
||||
writable: boolean;
|
||||
records: any[];
|
||||
|
||||
write(record: any): boolean;
|
||||
end(record?: any): void;
|
||||
destroy(): void;
|
||||
destroySoon(): void;
|
||||
}
|
||||
}
|
||||
|
||||
export = Logger;
|
||||
|
||||
7
types/bunyan/tslint.json
Normal file
7
types/bunyan/tslint.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
// ban-types needs to be disabled to support TypeScript <2.2
|
||||
"ban-types": false
|
||||
}
|
||||
}
|
||||
2
types/catbox/index.d.ts
vendored
2
types/catbox/index.d.ts
vendored
@@ -2,7 +2,7 @@
|
||||
// Project: https://github.com/hapijs/catbox
|
||||
// Definitions by: Jason Swearingen <http://github.com/jasonswearingen>, AJP <https://github.com/AJamesPhillips>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
import * as Boom from 'boom';
|
||||
|
||||
|
||||
@@ -401,3 +401,29 @@ var overlappingBarsResponsiveOptions: Array<Chartist.IResponsiveOptionTuple<Char
|
||||
];
|
||||
|
||||
new Chartist.Bar('.ct-chart', overlappingBarsData, overlappingBarsOptions, overlappingBarsResponsiveOptions);
|
||||
|
||||
new Chartist.Candle('.ct-chart', {
|
||||
labels: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
|
||||
series: [
|
||||
[5, 4, 3, 7],
|
||||
[3, 2, 9, 5],
|
||||
[5, 4, 3, 7],
|
||||
[3, 2, 9, 5],
|
||||
[5, 4, 3, 7],
|
||||
[3, 2, 9, 5],
|
||||
[3, 2, 9, 5]
|
||||
]
|
||||
}, {
|
||||
axisX: {
|
||||
labelOffset: {
|
||||
x: -10,
|
||||
y: 0
|
||||
}
|
||||
},
|
||||
axisY: {
|
||||
showGrid: false,
|
||||
labelInterpolationFnc: function (value: any) {
|
||||
return value + 12000;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
127
types/chartist/index.d.ts
vendored
127
types/chartist/index.d.ts
vendored
@@ -1,6 +1,6 @@
|
||||
// Type definitions for Chartist v0.9.5
|
||||
// Type definitions for Chartist v0.9.6
|
||||
// Project: https://github.com/gionkunz/chartist-js
|
||||
// Definitions by: Matt Gibbs <https://github.com/mtgibbs>
|
||||
// Definitions by: Matt Gibbs <https://github.com/mtgibbs>, Simon Pfeifer <https://github.com/psimonski>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare namespace Chartist {
|
||||
@@ -20,6 +20,7 @@ declare namespace Chartist {
|
||||
Pie: IChartistPieChart;
|
||||
Bar: IChartistBarChart;
|
||||
Line: IChartistLineChart;
|
||||
Candle: IChartistCandleChart;
|
||||
|
||||
FixedScaleAxis: IFixedScaleAxisStatic;
|
||||
AutoScaleAxis: IAutoScaleAxisStatic;
|
||||
@@ -138,6 +139,10 @@ declare namespace Chartist {
|
||||
new (target: any, data: IChartistData, options?: IBarChartOptions, responsiveOptions?: Array<IResponsiveOptionTuple<IBarChartOptions>>): IChartistBarChart;
|
||||
}
|
||||
|
||||
interface IChartistCandleChart extends IChartistBase<ICandleChartOptions> {
|
||||
new (target: any, data: IChartistData, options?: ICandleChartOptions, responsiveOptions?: Array<IResponsiveOptionTuple<ICandleChartOptions>>): IChartistCandleChart;
|
||||
}
|
||||
|
||||
interface IChartOptions {
|
||||
/**
|
||||
* If true the whole data is reversed including labels, the series order as well as the whole series data arrays.
|
||||
@@ -352,6 +357,124 @@ declare namespace Chartist {
|
||||
end?: string;
|
||||
}
|
||||
|
||||
interface ICandleChartOptions extends IChartOptions {
|
||||
|
||||
/**
|
||||
* Options for X-Axis
|
||||
*/
|
||||
axisX?: ICandleChartAxis;
|
||||
|
||||
/**
|
||||
* Options for Y-Axis
|
||||
*/
|
||||
axisY?: ICandleChartAxis;
|
||||
|
||||
/**
|
||||
* Specify a fixed width for the chart as a string (i.e. '100px' or '50%')
|
||||
*/
|
||||
width?: number | string;
|
||||
|
||||
/**
|
||||
* Specify a fixed height for the chart as a string (i.e. '100px' or '50%')
|
||||
*/
|
||||
height?: number | string;
|
||||
|
||||
/**
|
||||
* Overriding the natural high of the chart allows you to zoom in or limit the charts highest displayed value
|
||||
*/
|
||||
hight?: number | string;
|
||||
|
||||
/**
|
||||
* Overriding the natural low of the chart allows you to zoom in or limit the charts lowest displayed value
|
||||
*/
|
||||
low?: number | string;
|
||||
|
||||
/**
|
||||
* Width of candle body in pixel (IMO is 2 px best minimum value)
|
||||
*/
|
||||
candleWidth?: number | string;
|
||||
|
||||
/**
|
||||
* Width of candle wick in pixel (IMO is 1 px best minimum value)
|
||||
*/
|
||||
candleWickWidth?: number | string;
|
||||
|
||||
/**
|
||||
* Use calculated x-axis step length, depending on the number of quotes to display, as candle width. Otherwise the candleWidth is being used.
|
||||
*/
|
||||
useStepLengthAsCandleWidth?: boolean | string;
|
||||
|
||||
/**
|
||||
* Use 1/3 of candle body width as width for the candle wick, otherwise the candleWickWidth is being used.
|
||||
*/
|
||||
useOneThirdAsCandleWickWidth?: boolean | string;
|
||||
|
||||
/**
|
||||
* Padding of the chart drawing area to the container element and labels as a number or padding object {top: 5, right: 5, bottom: 5, left: 5}
|
||||
*/
|
||||
chartPadding?: IChartPadding | number;
|
||||
|
||||
/**
|
||||
* When set to true, the last grid line on the x-axis is not drawn and the chart elements will expand to the full available width of the chart. For the last label to be drawn correctly you might need to add chart padding or offset the last label with a draw event handler.
|
||||
*/
|
||||
fullWidth?: boolean | string;
|
||||
|
||||
/**
|
||||
* Override the class names that get used to generate the SVG structure of the chart
|
||||
*/
|
||||
classNames?: ICandleChartClasses;
|
||||
}
|
||||
|
||||
interface ICandleChartAxis {
|
||||
/**
|
||||
* The offset of the chart drawing area to the border of the container
|
||||
*/
|
||||
offset?: number;
|
||||
/**
|
||||
* Position where labels are placed. Can be set to `start` or `end` where `start` is equivalent to left or top on vertical axis and `end` is equivalent to right or bottom on horizontal axis.
|
||||
*/
|
||||
position?: string;
|
||||
/**
|
||||
* Allows you to correct label positioning on this axis by positive or negative x and y offset.
|
||||
*/
|
||||
labelOffset?: {
|
||||
x?: number;
|
||||
y?: number;
|
||||
};
|
||||
/**
|
||||
* If labels should be shown or not
|
||||
*/
|
||||
showLabel?: boolean;
|
||||
/**
|
||||
* If the axis grid should be drawn or not
|
||||
*/
|
||||
showGrid?: boolean;
|
||||
/**
|
||||
* Interpolation function that allows you to intercept the value from the axis label
|
||||
*/
|
||||
labelInterpolationFnc?: Function;
|
||||
/**
|
||||
* Set the axis type to be used to project values on this axis. If not defined, Chartist.StepAxis will be used for the X-Axis, where the ticks option will be set to the labels in the data and the stretch option will be set to the global fullWidth option. This type can be changed to any axis constructor available (e.g. Chartist.FixedScaleAxis), where all axis options should be present here.
|
||||
*/
|
||||
type?: any;
|
||||
}
|
||||
|
||||
interface ICandleChartClasses {
|
||||
chart?: string;
|
||||
label?: string;
|
||||
labelGroup?: string;
|
||||
series?: string;
|
||||
candlePositive?: string;
|
||||
candleNegative?: string,
|
||||
grid?: string,
|
||||
gridGroup?: string,
|
||||
gridBackground?: string,
|
||||
vertical?: string,
|
||||
horizontal?: string,
|
||||
start?: string,
|
||||
end?: string,
|
||||
}
|
||||
|
||||
interface ChartistSvgStatic {
|
||||
new (name: HTMLElement | string, attributes: Object, className?: string, parent?: Object, insertFirst?: boolean): IChartistSvg;
|
||||
|
||||
|
||||
1
types/connect-mongo/index.d.ts
vendored
1
types/connect-mongo/index.d.ts
vendored
@@ -2,6 +2,7 @@
|
||||
// Project: https://github.com/kcbanner/connect-mongo
|
||||
// Definitions by: Mizuki Yamamoto <https://github.com/Syati>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
/// <reference types="express-session" />
|
||||
|
||||
|
||||
2
types/convict/index.d.ts
vendored
2
types/convict/index.d.ts
vendored
@@ -1,4 +1,4 @@
|
||||
// Type definitions for node-convict v3.0.0
|
||||
// Type definitions for convict 3.0
|
||||
// Project: https://github.com/mozilla/node-convict
|
||||
// Definitions by: Wim Looman <https://github.com/Nemo157>, Vesa Poikajärvi <https://github.com/vesse>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
@@ -104,7 +104,7 @@ function zoomedCanvas(this: HTMLCanvasElement, d: CanvasDatum) {
|
||||
|
||||
let canvasZoom: d3Zoom.ZoomBehavior<HTMLCanvasElement, CanvasDatum>;
|
||||
|
||||
canvasZoom = d3Zoom.zoom()
|
||||
canvasZoom = d3Zoom.zoom<HTMLCanvasElement, CanvasDatum>()
|
||||
.scaleExtent([1 / 2, 4])
|
||||
.on('zoom', zoomedCanvas);
|
||||
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
|
||||
|
||||
import mongoose = require('mongoose');
|
||||
// import mongoose = require('mongoose');
|
||||
import express = require('express');
|
||||
import jSend = require('easy-jsend');
|
||||
|
||||
var schema = new mongoose.Schema({
|
||||
name: {type: String}
|
||||
});
|
||||
// var schema = new mongoose.Schema({
|
||||
// name: {type: String}
|
||||
// });
|
||||
|
||||
var Model = mongoose.model('model', schema);
|
||||
// var Model = mongoose.model('model', schema);
|
||||
var Model = {};
|
||||
|
||||
jSend.init({partial: true});
|
||||
|
||||
|
||||
1747
types/ej.web.all/index.d.ts
vendored
1747
types/ej.web.all/index.d.ts
vendored
File diff suppressed because it is too large
Load Diff
@@ -1,2 +0,0 @@
|
||||
[*.ts]
|
||||
indent_style = tab
|
||||
6147
types/electron/index.d.ts
vendored
6147
types/electron/index.d.ts
vendored
File diff suppressed because it is too large
Load Diff
@@ -1,5 +0,0 @@
|
||||
import electron = require('electron');
|
||||
import child_process = require('child_process');
|
||||
|
||||
// TODO
|
||||
child_process.spawn(electron as any);
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,311 +0,0 @@
|
||||
|
||||
import {
|
||||
ipcRenderer,
|
||||
remote,
|
||||
webFrame,
|
||||
clipboard,
|
||||
crashReporter,
|
||||
nativeImage,
|
||||
screen,
|
||||
shell
|
||||
} from 'electron';
|
||||
|
||||
import * as fs from 'fs';
|
||||
|
||||
// In renderer process (web page).
|
||||
// https://github.com/atom/electron/blob/master/docs/api/ipc-renderer.md
|
||||
console.log(ipcRenderer.sendSync('synchronous-message', 'ping')); // prints "pong"
|
||||
|
||||
ipcRenderer.on('asynchronous-reply', (event: Electron.IpcRendererEvent, arg: any) => {
|
||||
console.log(arg); // prints "pong"
|
||||
event.sender.send('another-message', 'Hello World!');
|
||||
});
|
||||
|
||||
ipcRenderer.send('asynchronous-message', 'ping');
|
||||
|
||||
// remote
|
||||
// https://github.com/atom/electron/blob/master/docs/api/remote.md
|
||||
|
||||
var BrowserWindow = remote.BrowserWindow;
|
||||
var win = new BrowserWindow({ width: 800, height: 600 });
|
||||
win.loadURL('https://github.com');
|
||||
|
||||
remote.getCurrentWindow().on('close', () => {
|
||||
// blabla...
|
||||
});
|
||||
|
||||
remote.getCurrentWindow().capturePage(buf => {
|
||||
fs.writeFile('/tmp/screenshot.png', buf, err => {
|
||||
console.log(err);
|
||||
});
|
||||
});
|
||||
|
||||
remote.getCurrentWebContents().print();
|
||||
|
||||
remote.getCurrentWindow().capturePage(buf => {
|
||||
remote.require('fs').writeFile('/tmp/screenshot.png', buf, (err: Error) => {
|
||||
console.log(err);
|
||||
});
|
||||
});
|
||||
|
||||
// web-frame
|
||||
// https://github.com/atom/electron/blob/master/docs/api/web-frame.md
|
||||
|
||||
webFrame.setZoomFactor(2);
|
||||
console.log(webFrame.getZoomFactor());
|
||||
|
||||
webFrame.setZoomLevel(200);
|
||||
console.log(webFrame.getZoomLevel());
|
||||
|
||||
webFrame.setVisualZoomLevelLimits(50, 200);
|
||||
webFrame.setLayoutZoomLevelLimits(50, 200);
|
||||
|
||||
webFrame.setSpellCheckProvider('en-US', true, {
|
||||
spellCheck: text => {
|
||||
return !(require('spellchecker').isMisspelled(text));
|
||||
}
|
||||
});
|
||||
|
||||
webFrame.registerURLSchemeAsSecure('app');
|
||||
webFrame.registerURLSchemeAsBypassingCSP('app');
|
||||
webFrame.registerURLSchemeAsPrivileged('app');
|
||||
webFrame.registerURLSchemeAsPrivileged('app', {
|
||||
secure: true,
|
||||
supportFetchAPI: true,
|
||||
});
|
||||
|
||||
webFrame.insertText('text');
|
||||
|
||||
webFrame.executeJavaScript('JSON.stringify({})', false, (result) => {
|
||||
console.log(result);
|
||||
}).then((result: string) => console.log('OK:' + result));
|
||||
|
||||
console.log(webFrame.getResourceUsage());
|
||||
webFrame.clearCache();
|
||||
|
||||
// clipboard
|
||||
// https://github.com/atom/electron/blob/master/docs/api/clipboard.md
|
||||
|
||||
clipboard.writeText('Example String');
|
||||
clipboard.writeText('Example String', 'selection');
|
||||
console.log(clipboard.readText('selection'));
|
||||
console.log(clipboard.availableFormats());
|
||||
clipboard.clear();
|
||||
|
||||
clipboard.write({
|
||||
html: '<html></html>',
|
||||
text: 'Hello World!',
|
||||
bookmark: "Bookmark name",
|
||||
image: clipboard.readImage()
|
||||
});
|
||||
|
||||
// crash-reporter
|
||||
// https://github.com/atom/electron/blob/master/docs/api/crash-reporter.md
|
||||
|
||||
crashReporter.start({
|
||||
productName: 'YourName',
|
||||
companyName: 'YourCompany',
|
||||
submitURL: 'https://your-domain.com/url-to-submit',
|
||||
autoSubmit: true
|
||||
});
|
||||
|
||||
// desktopCapturer
|
||||
// https://github.com/atom/electron/blob/master/docs/api/desktop-capturer.md
|
||||
|
||||
var desktopCapturer = require('electron').desktopCapturer;
|
||||
|
||||
desktopCapturer.getSources({types: ['window', 'screen']}, function(error, sources) {
|
||||
if (error) throw error;
|
||||
for (var i = 0; i < sources.length; ++i) {
|
||||
if (sources[i].name == "Electron") {
|
||||
(navigator as any).webkitGetUserMedia({
|
||||
audio: false,
|
||||
video: {
|
||||
mandatory: {
|
||||
chromeMediaSource: 'desktop',
|
||||
chromeMediaSourceId: sources[i].id,
|
||||
minWidth: 1280,
|
||||
maxWidth: 1280,
|
||||
minHeight: 720,
|
||||
maxHeight: 720
|
||||
}
|
||||
}
|
||||
}, gotStream, getUserMediaError);
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function gotStream(stream: any) {
|
||||
(document.querySelector('video') as HTMLVideoElement).src = URL.createObjectURL(stream);
|
||||
}
|
||||
|
||||
function getUserMediaError(error: Error) {
|
||||
console.log('getUserMediaError', error);
|
||||
}
|
||||
|
||||
// File object
|
||||
// https://github.com/atom/electron/blob/master/docs/api/file-object.md
|
||||
|
||||
/*
|
||||
<div id="holder">
|
||||
Drag your file here
|
||||
</div>
|
||||
*/
|
||||
|
||||
var holder = document.getElementById('holder');
|
||||
|
||||
holder.ondragover = function () {
|
||||
return false;
|
||||
};
|
||||
|
||||
holder.ondragleave = holder.ondragend = function () {
|
||||
return false;
|
||||
};
|
||||
|
||||
holder.ondrop = function (e) {
|
||||
e.preventDefault();
|
||||
var file = e.dataTransfer.files[0];
|
||||
console.log('File you dragged here is', file.path);
|
||||
return false;
|
||||
};
|
||||
|
||||
// nativeImage
|
||||
// https://github.com/atom/electron/blob/master/docs/api/native-image.md
|
||||
|
||||
var Tray = remote.Tray;
|
||||
var appIcon2 = new Tray('/Users/somebody/images/icon.png');
|
||||
var window2 = new BrowserWindow({ icon: '/Users/somebody/images/window.png' });
|
||||
var image = clipboard.readImage();
|
||||
var appIcon3 = new Tray(image);
|
||||
var appIcon4 = new Tray('/Users/somebody/images/icon.png');
|
||||
|
||||
// https://github.com/electron/electron/blob/master/docs/api/process.md
|
||||
|
||||
// preload.js
|
||||
var _setImmediate = setImmediate;
|
||||
var _clearImmediate = clearImmediate;
|
||||
process.once('loaded', function() {
|
||||
global.setImmediate = _setImmediate;
|
||||
global.clearImmediate = _clearImmediate;
|
||||
});
|
||||
|
||||
// screen
|
||||
// https://github.com/atom/electron/blob/master/docs/api/screen.md
|
||||
|
||||
var app = remote.app;
|
||||
|
||||
var mainWindow: Electron.BrowserWindow = null;
|
||||
|
||||
app.on('ready', () => {
|
||||
var size = screen.getPrimaryDisplay().workAreaSize;
|
||||
mainWindow = new BrowserWindow({ width: size.width, height: size.height });
|
||||
});
|
||||
|
||||
app.on('ready', () => {
|
||||
var displays = screen.getAllDisplays();
|
||||
var externalDisplay: any = null;
|
||||
for (var i in displays) {
|
||||
if (displays[i].bounds.x > 0 || displays[i].bounds.y > 0) {
|
||||
externalDisplay = displays[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (externalDisplay) {
|
||||
mainWindow = new BrowserWindow({
|
||||
x: externalDisplay.bounds.x + 50,
|
||||
y: externalDisplay.bounds.y + 50,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// shell
|
||||
// https://github.com/atom/electron/blob/master/docs/api/shell.md
|
||||
|
||||
shell.openExternal('https://github.com');
|
||||
|
||||
// <webview>
|
||||
// https://github.com/atom/electron/blob/master/docs/api/web-view-tag.md
|
||||
|
||||
var webview = document.createElement('webview');
|
||||
webview.loadURL('https://github.com');
|
||||
|
||||
webview.addEventListener('console-message', function(e) {
|
||||
console.log('Guest page logged a message:', e.message);
|
||||
});
|
||||
|
||||
webview.addEventListener('found-in-page', function(e) {
|
||||
if (e.result.finalUpdate) {
|
||||
webview.stopFindInPage("keepSelection");
|
||||
}
|
||||
});
|
||||
|
||||
var requestId = webview.findInPage("test");
|
||||
|
||||
webview.addEventListener('new-window', function(e) {
|
||||
require('electron').shell.openExternal(e.url);
|
||||
});
|
||||
|
||||
webview.addEventListener('close', function() {
|
||||
webview.src = 'about:blank';
|
||||
});
|
||||
|
||||
// In embedder page.
|
||||
webview.addEventListener('ipc-message', function(event) {
|
||||
console.log(event.channel); // Prints "pong"
|
||||
});
|
||||
webview.send('ping');
|
||||
webview.capturePage((image) => { console.log(image); });
|
||||
|
||||
{
|
||||
const opened: boolean = webview.isDevToolsOpened();
|
||||
const focused: boolean = webview.isDevToolsFocused();
|
||||
const focused2: boolean = webview.getWebContents().isFocused();
|
||||
}
|
||||
|
||||
// In guest page.
|
||||
ipcRenderer.on('ping', function() {
|
||||
ipcRenderer.sendToHost('pong');
|
||||
});
|
||||
|
||||
|
||||
// showOpenDialog
|
||||
// https://electron.atom.io/docs/api/dialog/#dialogshowopendialogbrowserwindow-options-callback
|
||||
|
||||
remote.dialog.showOpenDialog({ title: 'foo' });
|
||||
remote.dialog.showOpenDialog(win, {}, fileNames => fileNames);
|
||||
remote.dialog.showOpenDialog(win, {
|
||||
title: 'foo',
|
||||
defaultPath: '/bar',
|
||||
buttonLabel: 'foo bar',
|
||||
filters: [
|
||||
{name: 'Images', extensions: ['jpg', 'png', 'gif']},
|
||||
{name: 'Movies', extensions: ['mkv', 'avi', 'mp4']},
|
||||
{name: 'Custom File Type', extensions: ['as']},
|
||||
{name: 'All Files', extensions: ['*']}
|
||||
],
|
||||
properties: ['openFile', 'openDirectory', 'multiSelections', 'showHiddenFiles', 'createDirectory', 'promptToCreate', 'noResolveAliases'],
|
||||
normalizeAccessKeys: true,
|
||||
message: 'foo message',
|
||||
});
|
||||
|
||||
// showSaveDialog
|
||||
// https://electron.atom.io/docs/api/dialog/#dialogshowsavedialogbrowserwindow-options-callback
|
||||
|
||||
remote.dialog.showSaveDialog({ title: 'foo' });
|
||||
remote.dialog.showSaveDialog(win, {}, fileNames => fileNames);
|
||||
remote.dialog.showSaveDialog(win, {
|
||||
title: 'foo',
|
||||
defaultPath: '/bar',
|
||||
buttonLabel: 'foo bar',
|
||||
filters: [
|
||||
{name: 'Images', extensions: ['jpg', 'png', 'gif']},
|
||||
{name: 'Movies', extensions: ['mkv', 'avi', 'mp4']},
|
||||
{name: 'Custom File Type', extensions: ['as']},
|
||||
{name: 'All Files', extensions: ['*']}
|
||||
],
|
||||
message: 'foo message',
|
||||
nameFieldLabel: 'foo name',
|
||||
showsTagField: true
|
||||
});
|
||||
35
types/enhanced-resolve/index.d.ts
vendored
35
types/enhanced-resolve/index.d.ts
vendored
@@ -1,6 +1,6 @@
|
||||
// Type definitions for enhanced-resolve v3.0.0
|
||||
// Project: http://github.com/webpack/enhanced-resolve.git
|
||||
// Definitions by: e-cloud <https://github.com/e-cloud>
|
||||
// Definitions by: e-cloud <https://github.com/e-cloud>, Onigoetz <https://github.com/onigoetz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
import fs = require('fs');
|
||||
import {
|
||||
ResolveResult,
|
||||
LoggingCallbackWrapper,
|
||||
ResolverRequest,
|
||||
ResolveContext,
|
||||
@@ -19,31 +18,35 @@ import Resolver = require('./lib/Resolver');
|
||||
import Tapable = require('tapable');
|
||||
|
||||
declare namespace Resolve {
|
||||
function sync(path: string, request: string): ResolveResult;
|
||||
function sync(context: ResolveContext, path: string, request: string): ResolveResult;
|
||||
function sync(path: string, request: string): string;
|
||||
function sync(context: ResolveContext, path: string, request: string): string;
|
||||
|
||||
function context(path: string, request: string, callback: LoggingCallbackWrapper): void;
|
||||
function context(context: ResolveContext, path: string, request: string, callback: LoggingCallbackWrapper): void;
|
||||
|
||||
namespace context {
|
||||
function sync(path: string, request: string): ResolveResult;
|
||||
function sync(context: ResolveContext, path: string, request: string): ResolveResult;
|
||||
function sync(path: string, request: string): string;
|
||||
function sync(context: ResolveContext, path: string, request: string): string;
|
||||
}
|
||||
|
||||
function loader(path: string, request: string, callback: LoggingCallbackWrapper): void;
|
||||
function loader(context: ResolveContext, path: string, request: string, callback: LoggingCallbackWrapper): void;
|
||||
|
||||
namespace context {
|
||||
function sync(path: string, request: string): ResolveResult;
|
||||
function sync(context: ResolveContext, path: string, request: string): ResolveResult;
|
||||
namespace loader {
|
||||
function sync(path: string, request: string): string;
|
||||
function sync(context: ResolveContext, path: string, request: string): string;
|
||||
}
|
||||
|
||||
function create(path: string, request: string, callback: LoggingCallbackWrapper): void;
|
||||
function create(context: ResolveContext, path: string, request: string, callback: LoggingCallbackWrapper): void;
|
||||
function create(options: ResolverFactory.ResolverOption): {
|
||||
(path: string, request: string, callback: LoggingCallbackWrapper): void;
|
||||
(context: ResolveContext, path: string, request: string, callback: LoggingCallbackWrapper): void;
|
||||
}
|
||||
|
||||
export namespace create {
|
||||
function sync(path: string, request: string): ResolveResult;
|
||||
function sync(context: ResolveContext, path: string, request: string): ResolveResult;
|
||||
function sync(options: ResolverFactory.ResolverOption): {
|
||||
(path: string, request: string): string;
|
||||
(context: ResolveContext, path: string, request: string): string;
|
||||
}
|
||||
}
|
||||
|
||||
export namespace ResolverFactory {
|
||||
@@ -54,8 +57,8 @@ declare namespace Resolve {
|
||||
descriptionFiles?: string[];
|
||||
enforceExtension?: boolean;
|
||||
enforceModuleExtension?: boolean;
|
||||
extensions: string[];
|
||||
fileSystem: AbstractInputFileSystem;
|
||||
extensions?: string[];
|
||||
fileSystem?: AbstractInputFileSystem;
|
||||
mainFields?: string[];
|
||||
mainFiles?: string[];
|
||||
moduleExtensions?: string[];
|
||||
@@ -70,7 +73,7 @@ declare namespace Resolve {
|
||||
interface AliasItem {
|
||||
alias: string;
|
||||
name: string;
|
||||
onlyModule: boolean;
|
||||
onlyModule?: boolean;
|
||||
}
|
||||
function createResolver(options: ResolverOption): Resolver;
|
||||
}
|
||||
|
||||
3
types/enhanced-resolve/lib/Resolver.d.ts
vendored
3
types/enhanced-resolve/lib/Resolver.d.ts
vendored
@@ -2,7 +2,6 @@
|
||||
import Tapable = require('tapable');
|
||||
import {
|
||||
ResolveParseResult,
|
||||
ResolveResult,
|
||||
ResolverRequest,
|
||||
LoggingCallbackWrapper,
|
||||
AbstractInputFileSystem,
|
||||
@@ -14,7 +13,7 @@ declare class Resolver extends Tapable {
|
||||
|
||||
constructor(fileSystem: AbstractInputFileSystem);
|
||||
|
||||
resolveSync(context: ResolveContext, path: string, request: string): ResolveResult;
|
||||
resolveSync(context: ResolveContext, path: string, request: string): string;
|
||||
|
||||
resolve(context: ResolveContext, path: string, request: string, callback: LoggingCallbackWrapper): any;
|
||||
|
||||
|
||||
5
types/enhanced-resolve/lib/common-types.d.ts
vendored
5
types/enhanced-resolve/lib/common-types.d.ts
vendored
@@ -23,11 +23,6 @@ export interface ResolveContext {
|
||||
issuer?: string;
|
||||
}
|
||||
|
||||
export interface ResolveResult {
|
||||
path: boolean | string;
|
||||
query: string;
|
||||
}
|
||||
|
||||
export interface ResolverRequest {
|
||||
context: ResolveContext;
|
||||
descriptionFileData?: DescriptionFileData;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import resolve = require('enhanced-resolve');
|
||||
import { ResolveResult, AbstractInputFileSystem } from 'enhanced-resolve/lib/common-types'
|
||||
import { AbstractInputFileSystem } from 'enhanced-resolve/lib/common-types'
|
||||
import Resolver = require('enhanced-resolve/lib/Resolver')
|
||||
|
||||
resolve('lib', 'string', function (err) { });
|
||||
@@ -20,19 +20,30 @@ const nfs = new resolve.NodeJsInputFileSystem();
|
||||
|
||||
const cfs = new resolve.CachedInputFileSystem(nfs, 4);
|
||||
|
||||
let result: ResolveResult
|
||||
let result: string
|
||||
|
||||
result = resolve.sync(context, 'path', 'string');
|
||||
result = resolve.sync('path', 'string');
|
||||
|
||||
|
||||
// Context
|
||||
|
||||
resolve.context('lib', 'string', function (err) { });
|
||||
resolve.context(context, 'path', 'string', function () { });
|
||||
|
||||
result = resolve.context.sync(context, 'path', 'string');
|
||||
result = resolve.context.sync('path', 'string');
|
||||
|
||||
resolve.create('lib', 'string', function (err) { });
|
||||
resolve.create(context, 'path', 'string', function () { });
|
||||
// Loader
|
||||
|
||||
result = resolve.create.sync(context, 'path', 'string');
|
||||
result = resolve.create.sync('path', 'string');
|
||||
resolve.loader('lib', 'string', function (err) { });
|
||||
resolve.loader(context, 'path', 'string', function () { });
|
||||
|
||||
result = resolve.loader.sync(context, 'path', 'string');
|
||||
result = resolve.loader.sync('path', 'string');
|
||||
|
||||
// Create
|
||||
|
||||
resolve.create({extensions: [".js", ".json", ".node"]})(context, 'path', 'string', function () { });
|
||||
|
||||
result = resolve.create.sync({mainFields: ["loader", "main"]})(context, 'path', 'string');
|
||||
|
||||
6
types/express-brute-mongo/index.d.ts
vendored
6
types/express-brute-mongo/index.d.ts
vendored
@@ -2,9 +2,9 @@
|
||||
// Project: https://github.com/auth0/express-brute-mongo
|
||||
// Definitions by: Cyril Schumacher <https://github.com/cyrilschumacher/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
|
||||
|
||||
import { Collection } from "mongodb";
|
||||
|
||||
/**
|
||||
* @summary MongoDB store adapter.
|
||||
@@ -17,5 +17,5 @@ export = class MongoStore {
|
||||
* @param {Function} getCollection The collection.
|
||||
* @param {Object} options The otpions.
|
||||
*/
|
||||
constructor(getCollection: (collection: any) => void, options?: Object);
|
||||
constructor(getCollection: (collection: (c: Collection) => void) => void, options?: Object);
|
||||
}
|
||||
|
||||
9
types/express-rate-limit/index.d.ts
vendored
9
types/express-rate-limit/index.d.ts
vendored
@@ -1,4 +1,4 @@
|
||||
// Type definitions for express-rate-limit 2.6
|
||||
// Type definitions for express-rate-limit 2.8
|
||||
// Project: https://github.com/nfriedly/express-rate-limit
|
||||
// Definitions by: Cyril Schumacher <https://github.com/cyrilschumacher>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
@@ -17,14 +17,15 @@ declare namespace RateLimit {
|
||||
interface Options {
|
||||
delayAfter?: number;
|
||||
delayMs?: number;
|
||||
handlers?(): any;
|
||||
handlers?(req?: express.Request, res?: express.Response, next?: express.NextFunction): any;
|
||||
headers?: boolean;
|
||||
keyGenerator?(): string;
|
||||
keyGenerator?(req?: express.Request, res?: express.Response): string;
|
||||
max?: number;
|
||||
message?: string;
|
||||
skip?(): boolean;
|
||||
skip?(req?: express.Request, res?: express.Response): boolean;
|
||||
statusCode?: number;
|
||||
store?: Store;
|
||||
onLimitReached?(req?: express.Request, res?: express.Response, optionsUsed?: Options): void;
|
||||
windowMs?: number;
|
||||
}
|
||||
}
|
||||
|
||||
3
types/express-serve-static-core/index.d.ts
vendored
3
types/express-serve-static-core/index.d.ts
vendored
@@ -1,6 +1,6 @@
|
||||
// Type definitions for Express 4.x
|
||||
// Project: http://expressjs.com
|
||||
// Definitions by: Boris Yankov <https://github.com/borisyankov/>, Michał Lytek <https://github.com/19majkel94>
|
||||
// Definitions by: Boris Yankov <https://github.com/borisyankov/>, Michał Lytek <https://github.com/19majkel94>, Kacper Polak <https://github.com/kacepe>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// This extracts the core definitions from express to prevent a circular dependency between express and serve-static
|
||||
/// <reference types="node" />
|
||||
@@ -475,7 +475,6 @@ interface MediaType {
|
||||
}
|
||||
|
||||
interface Send {
|
||||
(status: number, body?: any): Response;
|
||||
(body?: any): Response;
|
||||
}
|
||||
|
||||
|
||||
1
types/gridfs-stream/index.d.ts
vendored
1
types/gridfs-stream/index.d.ts
vendored
@@ -2,6 +2,7 @@
|
||||
// Project: https://github.com/aheckmann/gridfs-stream
|
||||
// Definitions by: Lior Mualem <https://github.com/liorm/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
|
||||
2
types/h2o2/index.d.ts
vendored
2
types/h2o2/index.d.ts
vendored
@@ -2,7 +2,7 @@
|
||||
// Project: https://github.com/hapijs/catbox
|
||||
// Definitions by: Jason Swearingen <http://github.com/jasonswearingen>, AJP <https://github.com/AJamesPhillips>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
|
||||
2
types/hapi-auth-basic/index.d.ts
vendored
2
types/hapi-auth-basic/index.d.ts
vendored
@@ -2,7 +2,7 @@
|
||||
// Project: https://github.com/hapijs/hapi-auth-basic
|
||||
// Definitions by: AJP <https://github.com/AJamesPhillips>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
import * as Hapi from 'hapi';
|
||||
|
||||
|
||||
1
types/hapi-decorators/index.d.ts
vendored
1
types/hapi-decorators/index.d.ts
vendored
@@ -2,6 +2,7 @@
|
||||
// Project: https://github.com/knownasilya/hapi-decorators
|
||||
// Definitions by: Ken Howard <http://github.com/kenhowardpdx>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
import * as hapi from 'hapi';
|
||||
import * as Joi from 'joi';
|
||||
|
||||
168
types/hapi/index.d.ts
vendored
168
types/hapi/index.d.ts
vendored
@@ -2,7 +2,7 @@
|
||||
// Project: https://github.com/hapijs/hapi
|
||||
// Definitions by: Jason Swearingen <http://github.com/jasonswearingen>, AJP <https://github.com/AJamesPhillips>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
/* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
|
||||
+ +
|
||||
@@ -1256,13 +1256,14 @@ export interface RoutingTableEntry {
|
||||
|
||||
/**
|
||||
* [See docs](https://hapijs.com/api/16.1.1#servertablehost) > return value
|
||||
* For source [See source](https://github.com/hapijs/hapi/blob/v16.1.1/lib/route.js#L71)
|
||||
*/
|
||||
export interface Route {
|
||||
/**
|
||||
* the route config with defaults applied.
|
||||
* TODO check type of RouteConfiguration here is correct
|
||||
*/
|
||||
settings: RouteConfiguration;
|
||||
settings: RouteAdditionalConfigurationOptions;
|
||||
/**
|
||||
* the HTTP method in lower case.
|
||||
* TODO, check if it can contain 'head' or not.
|
||||
@@ -1270,6 +1271,18 @@ export interface Route {
|
||||
method: HTTP_METHODS_PARTIAL_lowercase;
|
||||
/** the route path. */
|
||||
path: string;
|
||||
|
||||
params: string[];
|
||||
|
||||
connection: ServerConnection;
|
||||
|
||||
fingerprint: string;
|
||||
|
||||
plugin?: any;
|
||||
|
||||
public: RoutePublicInterface;
|
||||
|
||||
server: Server;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1310,7 +1323,7 @@ export interface RoutePrerequisiteObjects {
|
||||
/**
|
||||
* For context see RouteAdditionalConfigurationOptions > response
|
||||
*/
|
||||
export interface RouteResponseConfigurationObject {
|
||||
export interface RouteResponseConfigurationObject<ValidationOptions = JoiValidationOptions> {
|
||||
/** the default HTTP status code when the payload is empty. Value can be 200 or 204. Note that a 200 status code is converted to a 204 only at the time or response transmission (the response status code will remain 200 throughout the request lifecycle unless manually set). Defaults to 200. */
|
||||
emptyStatusCode?: number;
|
||||
/**
|
||||
@@ -1326,16 +1339,20 @@ export interface RouteResponseConfigurationObject {
|
||||
failAction?: 'error' | 'log' | ((request: Request, reply: ReplyWithContinue, source: string, error: Boom.BoomError) => void);
|
||||
/** if true, applies the validation rule changes to the response payload. Defaults to false. */
|
||||
modify?: boolean;
|
||||
/** options to pass to Joi. Useful to set global options such as stripUnknown or abortEarly (the complete list is available [here](https://github.com/hapijs/joi/blob/master/API.md#validatevalue-schema-options-callback) ). Defaults to no options. */
|
||||
options?: JoiValidationOptions;
|
||||
/**
|
||||
* options to pass to Joi. Useful to set global options such as stripUnknown or abortEarly (the complete list is available [here](https://github.com/hapijs/joi/blob/master/API.md#validatevalue-schema-options-callback) ).
|
||||
* If a custom validation function (see `schema` or `status` below) is defined then `options` can an arbitrary object that will be passed to this function as the second parameter.
|
||||
* Defaults to no options.
|
||||
*/
|
||||
options?: ValidationOptions;
|
||||
/** if false, payload range support is disabled. Defaults to true. */
|
||||
ranges?: boolean;
|
||||
/** the percent of response payloads validated (0 - 100). Set to 0 to disable all validation. Defaults to 100 (all response payloads). */
|
||||
sample?: number;
|
||||
/** the default response payload validation rules (for all non-error responses) */
|
||||
schema?: RouteResponseConfigurationScheme;
|
||||
schema?: RouteResponseConfigurationScheme<ValidationOptions>;
|
||||
/** HTTP status-code-specific payload validation rules. The status key is set to an object where each key is a 3 digit HTTP status code and the value has the same definition as schema. If a response status code is not present in the status object, the schema definition is used, except for errors which are not validated by default. */
|
||||
status?: Dictionary<RouteResponseConfigurationScheme>;
|
||||
status?: Dictionary<RouteResponseConfigurationScheme<ValidationOptions>>;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1343,27 +1360,54 @@ export interface RouteResponseConfigurationObject {
|
||||
* * true - any payload allowed (no validation performed). This is the default.
|
||||
* * false - no payload allowed.
|
||||
* * a Joi validation object. This will receive the request's headers, params, query, payload, and auth credentials and isAuthenticated flags as context.
|
||||
* * a validation function using the signature function(value, options, next) where:
|
||||
* * value - the object containing the response object.
|
||||
* * options - the server validation options, merged with an object containing the request's headers, params, payload, and auth credentials object and isAuthenticated flag.
|
||||
* * next(err) - the callback function called when validation is completed.
|
||||
* * a validation function
|
||||
*
|
||||
* TODO check JoiValidationObject is correct for "a Joi validation object"
|
||||
*
|
||||
* For context see RouteAdditionalConfigurationOptions > response > schema
|
||||
* and
|
||||
* For context see RouteAdditionalConfigurationOptions > response > status
|
||||
*/
|
||||
export type RouteResponseConfigurationScheme = boolean | JoiValidationObject | ValidationFunctionForRouteResponse;
|
||||
export type RouteResponseConfigurationScheme<ValidationOptions> = boolean | JoiValidationObject | ValidationFunctionForRouteResponse<ValidationOptions>;
|
||||
|
||||
/**
|
||||
* see RouteResponseConfigurationScheme
|
||||
*
|
||||
* TODO check `value: Response` is correct as it says "**the object containing** the response object." not just "the response object".
|
||||
* TODO check `options: JoiValidationOptions` is correct
|
||||
* Also see ValidationFunctionForRouteValidate
|
||||
* a validation function using the signature function(value, options, next) where:
|
||||
* * value - the value of the response passed to `reply(value)` in the handler.
|
||||
* * options - the server validation options, merged with an object containing the request's headers, params, payload, and auth credentials object and `isAuthenticated` flag.
|
||||
* * next([err, [value]]) - the callback function called when validation is completed. `value` will be used as the response value when `err` is falsy, when `value` is not `undefined`, and when `route.settings.response.modify` is `true`. If the response is already a `Boom` error it will be set as its `message` value.
|
||||
*/
|
||||
export interface ValidationFunctionForRouteResponse {
|
||||
(value: Response, options: JoiValidationOptions, next: ContinuationFunction): void;
|
||||
export interface ValidationFunctionForRouteResponse<ValidationOptions = {}> {
|
||||
(value: any, options: RouteResponseValidationContext & ValidationOptions, next: ContinuationValueFunction): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* A context for route input validation via a Joi schema or validation function.
|
||||
*
|
||||
* This object is merged with the route response options and passed into the validation function.
|
||||
*
|
||||
* See https://github.com/hapijs/hapi/blob/v16.1.1/lib/validation.js#L217
|
||||
*/
|
||||
export interface RouteResponseValidationContext {
|
||||
context: {
|
||||
/** The request headers */
|
||||
headers: Dictionary<string>;
|
||||
/** The request path parameters */
|
||||
params: any;
|
||||
/** The request query parameters */
|
||||
query: any;
|
||||
/** The request payload parameters */
|
||||
payload: any;
|
||||
|
||||
/** Partial request authentication information */
|
||||
auth: {
|
||||
/** true if the request has been successfully authenticated, otherwise false. */
|
||||
isAuthenticated: boolean;
|
||||
/** the credential object received during the authentication process. The presence of an object does not mean successful authentication. */
|
||||
credentials: AuthenticatedCredentials;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1399,7 +1443,7 @@ export interface RouteSecurityConfigurationObject {
|
||||
* For context see RouteAdditionalConfigurationOptions > validate
|
||||
* TODO check JoiValidationObject is correct for "a Joi validation object"
|
||||
*/
|
||||
export interface RouteValidationConfigurationObject {
|
||||
export interface RouteValidationConfigurationObject<ValidationOptions = JoiValidationOptions> {
|
||||
/**
|
||||
* validation rules for incoming request headers (note that all header field names must be in lowercase to match the headers normalized by node). Values allowed:
|
||||
* * true - any headers allowed (no validation performed). This is the default.
|
||||
@@ -1408,25 +1452,25 @@ export interface RouteValidationConfigurationObject {
|
||||
* * a validation function using the signature function(value, options, next) where:
|
||||
* * value - the object containing the request headers.
|
||||
* * options - the server validation options.
|
||||
* * next(err, value) - the callback function called when validation is completed.
|
||||
* * next(err, value) - the callback function called when validation is completed. `value` will be used as the `headers` value when `err` is falsy. If `next` is called with `undefined` or no arguments then the original value of `value` will be used.
|
||||
*/
|
||||
headers?: boolean | JoiValidationObject | ValidationFunctionForRouteValidate;
|
||||
headers?: boolean | JoiValidationObject | ValidationFunctionForRouteInput<ValidationOptions>;
|
||||
/**
|
||||
* validation rules for incoming request path parameters, after matching the path against the route and extracting any parameters then stored in request.params. Values allowed:
|
||||
* Same as `headers`, see above.
|
||||
*/
|
||||
params?: boolean | JoiValidationObject | ValidationFunctionForRouteValidate;
|
||||
params?: boolean | JoiValidationObject | ValidationFunctionForRouteInput<ValidationOptions>;
|
||||
/**
|
||||
* validation rules for an incoming request URI query component (the key-value part of the URI between '?' and '#'). The query is parsed into its individual key-value pairs and stored in request.query prior to validation. Values allowed:
|
||||
* Same as `headers`, see above.
|
||||
*/
|
||||
query?: boolean | JoiValidationObject | ValidationFunctionForRouteValidate;
|
||||
query?: boolean | JoiValidationObject | ValidationFunctionForRouteInput<ValidationOptions>;
|
||||
/**
|
||||
* validation rules for an incoming request payload (request body). Values allowed:
|
||||
* Same as `headers`, see above, with the addition that:
|
||||
* * a Joi validation object. Note that empty payloads are represented by a null value. If a validation schema is provided and empty payload are supported, it must be explicitly defined by setting the payload value to a joi schema with null allowed (e.g. Joi.object({ /* keys here * / }).allow(null)).
|
||||
*/
|
||||
payload?: boolean | JoiValidationObject | ValidationFunctionForRouteValidate;
|
||||
payload?: boolean | JoiValidationObject | ValidationFunctionForRouteInput<ValidationOptions>;
|
||||
/** an optional object with error fields copied into every validation error response. */
|
||||
errorFields?: any;
|
||||
/**
|
||||
@@ -1437,24 +1481,46 @@ export interface RouteValidationConfigurationObject {
|
||||
* * a custom error handler function with the signature function(request, reply, source, error) see RouteFailFunction
|
||||
*/
|
||||
failAction?: 'error' | 'log' | 'ignore' | RouteFailFunction;
|
||||
/** options to pass to Joi. Useful to set global options such as stripUnknown or abortEarly (the complete list is [available here](https://github.com/hapijs/joi/blob/master/API.md#validatevalue-schema-options-callback)). Defaults to no options. */
|
||||
options?: JoiValidationOptions;
|
||||
/**
|
||||
* options to pass to Joi. Useful to set global options such as stripUnknown or abortEarly (the complete list is [available here](https://github.com/hapijs/joi/blob/master/API.md#validatevalue-schema-options-callback)).
|
||||
* If a custom validation function (see `headers`, `params`, `query`, or `payload` above) is defined then `options` can an arbitrary object that will be passed to this function as the second parameter.
|
||||
* Defaults to no options.
|
||||
*/
|
||||
options?: ValidationOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* a validation function using the signature function(value, options, next) where:
|
||||
* For context see RouteAdditionalConfigurationOptions > validate (IRouteValidationConfigurationObject)
|
||||
* For context see RouteAdditionalConfigurationOptions > validate (RouteValidationConfigurationObject)
|
||||
*
|
||||
* TODO check `value: Response` is correct as it says "**the object containing** the response object." not just "the response object".
|
||||
* TODO check `options: JoiValidationOptions` is correct
|
||||
* TODO type of the returned value?
|
||||
* Also see ValidationFunctionForRouteResponse
|
||||
* @param value - the object containing the request headers.
|
||||
* @param value - the object containing the request headers, query, path params or payload.
|
||||
* @param options - the server validation options.
|
||||
* @param next(err, value) - the callback function called when validation is completed.
|
||||
* @param next([err, [value]]) - the callback function called when validation is completed.
|
||||
*/
|
||||
export interface ValidationFunctionForRouteValidate {
|
||||
(value: Response, options: JoiValidationOptions, next: ContinuationValueFunction): void;
|
||||
export interface ValidationFunctionForRouteInput<ValidationOptions = {}> {
|
||||
(value: any, options: RouteInputValidationContext & ValidationOptions, next: ContinuationValueFunction): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* A context for route input validation via a Joi schema or validation function.
|
||||
*
|
||||
* This object is merged with the route validation options and passed into the validation function.
|
||||
*
|
||||
* See https://github.com/hapijs/hapi/blob/v16.1.1/lib/validation.js#L122
|
||||
*/
|
||||
export interface RouteInputValidationContext {
|
||||
context: {
|
||||
// These are only set when *not* validating the respective source (e.g. params, query and payload are set when validating headers):
|
||||
// See https://github.com/hapijs/hapi/blob/v16.1.1/lib/validation.js#L132
|
||||
headers?: Dictionary<string>;
|
||||
params?: any;
|
||||
query?: any;
|
||||
payload?: any;
|
||||
|
||||
/** The request authentication information */
|
||||
auth: RequestAuthenticationInformation;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1565,8 +1631,8 @@ export interface ServerConnection {
|
||||
/** Described in server.inject [See docs](https://hapijs.com/api/16.1.1#serverinjectoptions-callback) */
|
||||
inject(options: string | InjectedRequestOptions, callback: (res: InjectedResponseObject) => void): void;
|
||||
inject(options: string | InjectedRequestOptions, ): Promise<InjectedResponseObject>;
|
||||
/** Described in server.table [See docs](https://hapijs.com/api/16.1.1#servertablehost) */
|
||||
table(host?: string): RoutingTableEntry;
|
||||
/** Mentioned but not documented under server.connections [See docs](https://hapijs.com/api/16.1.1#serverconnections) */
|
||||
table(host?: string): Route[];
|
||||
/** Described in server.table [See docs](https://hapijs.com/api/16.1.1#serverlookupid) */
|
||||
lookup(id: string): RoutePublicInterface | null;
|
||||
/** Described in server.table [See docs](https://hapijs.com/api/16.1.1#servermatchmethod-path-host) */
|
||||
@@ -1795,18 +1861,7 @@ export class Request extends Podium {
|
||||
/** application-specific state. Provides a safe place to store application data without potential conflicts with the framework. Should not be used by plugins which should use plugins[name]. */
|
||||
app: any;
|
||||
/** authentication information */
|
||||
auth: {
|
||||
/** true if the request has been successfully authenticated, otherwise false. */
|
||||
isAuthenticated: boolean;
|
||||
/** the credential object received during the authentication process. The presence of an object does not mean successful authentication. */
|
||||
credentials: any;
|
||||
/** an artifact object received from the authentication strategy and used in authentication-related actions. */
|
||||
artifacts: any;
|
||||
/** the route authentication mode. */
|
||||
mode: string;
|
||||
/** the authentication error is failed and mode set to 'try'. */
|
||||
error: Error;
|
||||
};
|
||||
auth: RequestAuthenticationInformation;
|
||||
/** the connection the request was received by. */
|
||||
connection: ServerConnection;
|
||||
/** the node domain object used to protect against exceptions thrown in extensions, handlers and route prerequisites. Can be used to manually bind callback functions otherwise bound to other domains. Set to null when the server useDomains options is false. */
|
||||
@@ -1964,6 +2019,19 @@ export class Request extends Podium {
|
||||
// [index: string]: any;
|
||||
}
|
||||
|
||||
export interface RequestAuthenticationInformation {
|
||||
/** true if the request has been successfully authenticated, otherwise false. */
|
||||
isAuthenticated: boolean;
|
||||
/** the credential object received during the authentication process. The presence of an object does not mean successful authentication. */
|
||||
credentials: any;
|
||||
/** an artifact object received from the authentication strategy and used in authentication-related actions. */
|
||||
artifacts: any;
|
||||
/** the route authentication mode. */
|
||||
mode: string;
|
||||
/** the authentication error is failed and mode set to 'try'. */
|
||||
error: Error;
|
||||
}
|
||||
|
||||
export type HTTP_METHODS_PARTIAL_lowercase = 'get' | 'post' | 'put' | 'patch' | 'delete' | 'options';
|
||||
export type HTTP_METHODS_PARTIAL = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS' | HTTP_METHODS_PARTIAL_lowercase;
|
||||
export type HTTP_METHODS = 'HEAD' | 'head' | HTTP_METHODS_PARTIAL;
|
||||
@@ -2049,7 +2117,7 @@ export interface RequestHandler<T> {
|
||||
|
||||
/**
|
||||
* Used by server extension points
|
||||
* err can be BoomError or Error that will be wrapped as a BoomError
|
||||
* err can be `Boom` error or Error that will be wrapped as a `Boom` error
|
||||
* For source [See code](https://github.com/hapijs/hapi/blob/v16.1.1/lib/reply.js#L109-L118)
|
||||
* For source [See code](https://github.com/hapijs/hapi/blob/v16.1.1/lib/response.js#L60-L65)
|
||||
*/
|
||||
@@ -2061,7 +2129,9 @@ export interface ContinuationFunction {
|
||||
* TODO Can value be typed with a useful generic?
|
||||
*/
|
||||
export interface ContinuationValueFunction {
|
||||
(err: Boom.BoomError, value: any): void;
|
||||
(err: Boom.BoomError): void;
|
||||
(err: null | undefined, value: any): void;
|
||||
(): void;
|
||||
}
|
||||
|
||||
/* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
|
||||
|
||||
@@ -18,3 +18,5 @@ const table = connection.table();
|
||||
}
|
||||
]
|
||||
*/
|
||||
|
||||
table.map(({method, path, settings: {description}}) => { });
|
||||
|
||||
57
types/hapi/test/continuation/errors.ts
Normal file
57
types/hapi/test/continuation/errors.ts
Normal file
@@ -0,0 +1,57 @@
|
||||
|
||||
import * as Hapi from 'hapi';
|
||||
import * as Boom from 'boom';
|
||||
|
||||
// Assignment of a typical function to ContinuationValueFunction is possible
|
||||
const handleError: Hapi.ContinuationValueFunction = (err?: Boom.BoomError | null, value?: any) => {
|
||||
if (!err || !err.data.isCustom === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
// assignment is possible due to default generic Data = any
|
||||
const customError: Boom.BoomError<CustomData> = err;
|
||||
|
||||
// Discriminated union type works:
|
||||
switch (customError.data.customType) {
|
||||
case 'Custom1':
|
||||
customError.data.custom1;
|
||||
break;
|
||||
case 'Custom2':
|
||||
customError.data.custom2;
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
// Accepts a simple Boom error
|
||||
handleError(Boom.badData());
|
||||
|
||||
// Accepts an error with custom data
|
||||
const errorWithData = Boom.badImplementation('', { custom1: 'test', customType: <'Custom1'>'Custom1', isCustom: <true>true });
|
||||
handleError(errorWithData);
|
||||
|
||||
// Accepts an error with a more explicit type
|
||||
const errorWithExplicitType: Boom.BoomError<CustomData> = errorWithData;
|
||||
handleError(errorWithExplicitType);
|
||||
|
||||
// Accepts an error with an even more explicit type
|
||||
const errorWithConcreteCustomData: Boom.BoomError<CustomData1> = errorWithData; // assignment to CustomData2 would not be possible
|
||||
handleError(errorWithConcreteCustomData);
|
||||
|
||||
/**
|
||||
* Some complex error data types:
|
||||
*/
|
||||
interface CustomDataBase {
|
||||
isCustom: true;
|
||||
}
|
||||
|
||||
interface CustomData1 extends CustomDataBase {
|
||||
customType: 'Custom1';
|
||||
custom1: string;
|
||||
}
|
||||
|
||||
interface CustomData2 extends CustomDataBase {
|
||||
customType: 'Custom2';
|
||||
custom2: string;
|
||||
}
|
||||
|
||||
type CustomData = CustomData1 | CustomData2;
|
||||
@@ -13,8 +13,52 @@ const validate: Hapi.RouteValidationConfigurationObject = {
|
||||
query: {
|
||||
providerId: Joi.string(),
|
||||
},
|
||||
options: {
|
||||
abortEarly: true,
|
||||
},
|
||||
};
|
||||
|
||||
const config: Hapi.RouteAdditionalConfigurationOptions = {
|
||||
let config: Hapi.RouteAdditionalConfigurationOptions = {
|
||||
validate,
|
||||
response: {
|
||||
schema: Joi.object(),
|
||||
},
|
||||
};
|
||||
|
||||
interface CustomValidationOptions {
|
||||
myOption: number;
|
||||
}
|
||||
|
||||
const inputValidationFunction: Hapi.ValidationFunctionForRouteInput<CustomValidationOptions> = (value, options, next) => {
|
||||
options.myOption; // check custom options
|
||||
options.context.auth.artifacts; // check context
|
||||
next(null, value); // check with value
|
||||
next(); // check without value
|
||||
};
|
||||
|
||||
const validateWithFunctions: Hapi.RouteValidationConfigurationObject<CustomValidationOptions> = {
|
||||
params: inputValidationFunction,
|
||||
headers: inputValidationFunction,
|
||||
payload: inputValidationFunction,
|
||||
query: inputValidationFunction,
|
||||
options: {
|
||||
myOption: 18
|
||||
}
|
||||
};
|
||||
|
||||
const responseValidationFunction: Hapi.ValidationFunctionForRouteResponse<CustomValidationOptions> = (value, options, next) => {
|
||||
options.myOption; // check custom options
|
||||
options.context.auth.isAuthenticated; // check context
|
||||
next(null, value); // check with value
|
||||
next(); // check without value
|
||||
};
|
||||
|
||||
config = {
|
||||
validate: validateWithFunctions,
|
||||
response: <Hapi.RouteResponseConfigurationObject<CustomValidationOptions>>{
|
||||
schema: responseValidationFunction,
|
||||
options: {
|
||||
myOption: 18
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"test/connection/table.ts",
|
||||
"test/continuation/errors.ts",
|
||||
"test/getting-started/01-creating-a-server.ts",
|
||||
"test/getting-started/02-adding-routes.ts",
|
||||
"test/getting-started/03-serving-static-content.ts",
|
||||
|
||||
123
types/heredatalens/heredatalens-tests.ts
Normal file
123
types/heredatalens/heredatalens-tests.ts
Normal file
@@ -0,0 +1,123 @@
|
||||
/**
|
||||
* Typescript definition tests for heredatalens
|
||||
*
|
||||
* Note: These tests are intended to test the definitions only
|
||||
* in the sense of typing and call signature consistency. They
|
||||
* are not intended as functional tests.
|
||||
*/
|
||||
|
||||
let serviceOptions: H.datalens.Service.Options = {
|
||||
subDomain: 'sub',
|
||||
version: 'version',
|
||||
access_token: 'token',
|
||||
refresh_token: 'token',
|
||||
domainSharding: ['a', 'b'],
|
||||
baseUrl: 'url'
|
||||
};
|
||||
|
||||
let queryTileProviderTileParamNames: H.datalens.QueryTileProvider.TileParamNames = {
|
||||
x: 'x',
|
||||
y: 'y',
|
||||
z: 'z'
|
||||
};
|
||||
|
||||
let queryTileProviderOptions: H.datalens.QueryTileProvider.Options = {
|
||||
queryId: 'id',
|
||||
queryParams: 'params',
|
||||
tileParamNames: queryTileProviderTileParamNames
|
||||
};
|
||||
|
||||
let service: H.datalens.Service = new H.datalens.Service(serviceOptions);
|
||||
service.request('method', 'endpoint', 'params', 'body', (result: any) => {}, (error: any) => {}).then((data: any) => {});
|
||||
service.fetchQueryData('id', 'params', (result: any) => {}, (error: any) => {}).then((data: any) => {});
|
||||
service.fetchQueryStats('id', 'query', (result: any) => {}, (error: any) => {}).then((data: any) => {});
|
||||
service.fetchLayer('name', 'params', (result: any) => {}, (error: any) => {}).then((data: any) => {});
|
||||
service.fetchLayerTile('name', 1, 2, 3, 'params', (result: any) => {}, (error: any) => {}).then((data: any) => {});
|
||||
service.setTokens('token', 'refresh_token');
|
||||
service.configure('app_id', 'app_code', true, true, new H.service.Url('scheme', 'host'));
|
||||
|
||||
let queryTileProvider = new H.datalens.QueryTileProvider(service, queryTileProviderOptions);
|
||||
queryTileProvider.setQueryId('some id');
|
||||
queryTileProvider.setQueryParams('some params');
|
||||
queryTileProvider.setTileParamNames(queryTileProviderTileParamNames);
|
||||
|
||||
let provider = new H.datalens.Provider({ columns: ['1', '2'], rows: [[], []]});
|
||||
provider.getData();
|
||||
provider.setData({ columns: ['3', '4'], rows: [[], []]});
|
||||
|
||||
let queryProviderOptions: H.datalens.QueryProvider.Options = {
|
||||
queryId: 'id',
|
||||
queryParams: 'params'
|
||||
};
|
||||
let queryProvider = new H.datalens.QueryProvider({ columns: ['1', '2'], rows: [[], []]}, queryProviderOptions);
|
||||
queryProvider.setQueryId('id');
|
||||
queryProvider.setQueryParams('params');
|
||||
queryProvider.reload();
|
||||
queryProvider.getData();
|
||||
queryProvider.setData({ columns: ['3', '4'], rows: [[], []]});
|
||||
|
||||
let rasterLayerOptions: H.datalens.RasterLayer.Options = {
|
||||
dataToRows: (): H.datalens.RasterLayer.Row[] => [],
|
||||
rowToTilePoint: (): H.datalens.RasterLayer.TilePoint => ({ x: 1, y: 2 }),
|
||||
buffer: (): number => 1,
|
||||
renderTile: () => {}
|
||||
};
|
||||
|
||||
let rasterLayer = new H.datalens.RasterLayer();
|
||||
rasterLayer.redraw();
|
||||
|
||||
let heatmapLayerOptions: H.datalens.HeatmapLayer.Options = {
|
||||
dataToRows: (): H.datalens.HeatmapLayer.Row[] => [],
|
||||
rowToTilePoint: (): H.datalens.HeatmapLayer.TilePoint => ({ x: 1, y: 2, value: 5, count: 5 }),
|
||||
bandwidth: 5,
|
||||
valueRange: (): number[] => [],
|
||||
countRange: (): number[] => [],
|
||||
colorScale: (): string => '2',
|
||||
alphaScale: (): number => 1,
|
||||
aggregation: H.datalens.HeatmapLayer.Aggregation.SUM,
|
||||
inputScale: H.datalens.HeatmapLayer.InputScale.LINEAR
|
||||
};
|
||||
|
||||
let heatmapLayer = new H.datalens.HeatmapLayer(queryTileProvider, heatmapLayerOptions);
|
||||
heatmapLayer.getOptionsPerZoom(5);
|
||||
heatmapLayer.dispose();
|
||||
heatmapLayer.redraw();
|
||||
|
||||
let objectLayerOptions: H.datalens.ObjectLayer.Options = {
|
||||
dataToRows: (): H.datalens.ObjectLayer.Row[] => [],
|
||||
rowToMapObject: (): H.map.Object => new H.map.Object(),
|
||||
rowToStyle: (): H.datalens.ObjectLayer.ObjectStyleOptions => ({ icon: new H.map.Icon('x'), style: {}, arrows: {}, zIndex: 1 }),
|
||||
dataDomains: 2,
|
||||
clustering: { rowToDataPoint: (): H.clustering.DataPoint => ({ lat: 12.1, lng: 1.12, alt: 5, ctx: H.geo.AltitudeContext.GL, wt: 2, data: {} }),
|
||||
options: (): H.clustering.Provider.ClusteringOptions => ({}) }
|
||||
};
|
||||
|
||||
let objectLayer = new H.datalens.ObjectLayer(provider, objectLayerOptions);
|
||||
objectLayer.redraw();
|
||||
objectLayer.updateObjectStyle(new H.map.Object(), { icon: new H.map.Icon('x'), style: {}, arrows: {}, zIndex: 1 });
|
||||
|
||||
let rawDataProviderOptions: H.datalens.RawDataProvider.Options = {
|
||||
dataUrl: 'url',
|
||||
dataToFeatures: (): H.datalens.RawDataProvider.Feature[] => [],
|
||||
featuresToRows: (): H.datalens.ObjectLayer.Row[] => []
|
||||
};
|
||||
|
||||
let rawDataProvider = new H.datalens.RawDataProvider(rawDataProviderOptions);
|
||||
|
||||
let spatialTileProviderOptions: H.datalens.SpatialTileProvider.Options = {
|
||||
layerName: 'name',
|
||||
queryParams: 'params'
|
||||
};
|
||||
|
||||
let spatialProvider: H.datalens.SpatialTileProvider = new H.datalens.SpatialTileProvider(service, spatialTileProviderOptions);
|
||||
|
||||
let spatialLayerOptions: H.datalens.SpatialLayer.Options = {
|
||||
dataToRows: (): H.datalens.SpatialLayer.Row[] => [],
|
||||
rowToSpatialId: (): string => 'asd',
|
||||
featureToSpatialId: (): string => 'asd',
|
||||
rowToStyle: (): any => { return; },
|
||||
defaultStyle: (): any => { return; },
|
||||
transformFeature: 1
|
||||
};
|
||||
|
||||
let spatialLayer = new H.datalens.SpatialLayer(provider, spatialProvider, spatialLayerOptions);
|
||||
947
types/heredatalens/index.d.ts
vendored
Normal file
947
types/heredatalens/index.d.ts
vendored
Normal file
@@ -0,0 +1,947 @@
|
||||
// Type definitions for HERE Data Lens API for JavaScript 2.3
|
||||
// Project: https://developer.here.com/
|
||||
// Definitions by: Bernd Hacker <https://github.com/denyo>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="heremaps" />
|
||||
|
||||
declare namespace H {
|
||||
/**
|
||||
* Data Lens REST API connector for HERE Maps API
|
||||
* Data Lens JavaScript API is a module for HERE Maps API.
|
||||
* It connects Data Lens REST API and provides data-driven styling of data on a map.
|
||||
*/
|
||||
namespace datalens {
|
||||
/**
|
||||
* HERE Maps API and Data Lens JavaScript API can be used to visualize data from different network sources.
|
||||
* For each network source type, a service class is required. The service also stores API connection credentials.
|
||||
* The service instance must be configured with a H.service.Platform instance.
|
||||
*/
|
||||
class Service implements H.service.IConfigurable {
|
||||
/**
|
||||
* Constructor
|
||||
* @param options {H.datalens.Service.Options=} - Overrides the configuration from the H.service.Platform instance
|
||||
*/
|
||||
constructor(options?: H.datalens.Service.Options);
|
||||
|
||||
/**
|
||||
* This method makes an HTTP request to the Data Lens REST API.
|
||||
* It makes any CRUD request (GET, PUT, POST, DELETE).
|
||||
* This method can be used when implementing a custom provider or implementing data management.
|
||||
* Otherwise existing providers are used to get data from the Data Lens REST API.
|
||||
* @param method {string} - Any HTTP method (GET, PUT, POST, etc.)
|
||||
* @param endpoint {string} - The REST API endpoint
|
||||
* @param params {any=} - URL parameters
|
||||
* @param body {any=} - The payload of the request
|
||||
* @param onResult {function(any)=} - Callback called on a successful request with response data
|
||||
* @param onError {function(Error)=} - Callback called on an unsuccessful request with the Error object
|
||||
* @returns {Promise<any>} - Response Promise
|
||||
*/
|
||||
request(method: string, endpoint: string, params?: any, body?: any, onResult?: (result: any) => void, onError?: (error: any) => void): Promise<any>;
|
||||
|
||||
/**
|
||||
* This method fetches query data for a given query ID.
|
||||
* This method can be used when implementing a custom provider.
|
||||
* Otherwise existing providers are used to get data from the Data Lens REST API.
|
||||
* @param queryId {string} - The ID of the Data Lens REST API query
|
||||
* @param params {any=} - Query dynamic parameters
|
||||
* @param onResult {function(any)=} - Callback called on a successful request with response data
|
||||
* @param onError {function(Error)=} - Callback called on an unsuccessful request with the Error object
|
||||
* @returns {Promise<any>} - Response Promise
|
||||
*/
|
||||
fetchQueryData(queryId: string, params?: any, onResult?: (result: any) => void, onError?: (error: any) => void): Promise<any>;
|
||||
|
||||
/**
|
||||
* This method fetches statistical data for the Data Lens query (eg minimum and maximum values for the query metric).
|
||||
* It can be used to define visualization boundaries, scales and legends.
|
||||
* @param queryId {string} - The ID of the Data Lens REST API query
|
||||
* @param statsQuery {any} - A JSON object which defines a statistics query for the Data Lens query
|
||||
* @param onResult {function(any)=} - Callback called on a successful request with response data
|
||||
* @param onError {function(Error)=} - Callback called on an unsuccessful request with the Error object
|
||||
* @returns {Promise<any>} - Response Promise
|
||||
*/
|
||||
fetchQueryStats(queryId: string, statsQuery: any, onResult?: (result: any) => void, onError?: (error: any) => void): Promise<any>;
|
||||
|
||||
/**
|
||||
* This method fetches a layer of geometries (eg buildings or administrative boundaries).
|
||||
* @param layerName {string} - The name of the layer
|
||||
* @param params {any=} - URL parameters (eg bounding box)
|
||||
* @param onResult {function(any)=} - Callback called on a successful request with response data
|
||||
* @param onError {function(Error)=} - Callback called on an unsuccessful request with the Error object
|
||||
* @returns {Promise<any>} - Response Promise
|
||||
*/
|
||||
fetchLayer(layerName: string, params?: any, onResult?: (result: any) => void, onError?: (error: any) => void): Promise<any>;
|
||||
|
||||
/**
|
||||
* This method fetches vector tile data from the layer.
|
||||
* @param layerName {string}
|
||||
* @param x {H.datalens.QueryTileProvider.X} - Tile columns
|
||||
* @param y {H.datalens.QueryTileProvider.Y} - Tile row
|
||||
* @param z {H.datalens.QueryTileProvider.Zoom} - zoom level
|
||||
* @param params {any=} - URL parameters (eg bounding box)
|
||||
* @param onResult {function(any)=} - Callback called on a successful request with response data
|
||||
* @param onError {function(Error)=} - Callback called on an unsuccessful request with the Error object
|
||||
* @returns {Promise<Uint8Array>} - Typed array with tile data
|
||||
*/
|
||||
fetchLayerTile(layerName: string, x: H.datalens.QueryTileProvider.X, y: H.datalens.QueryTileProvider.Y, z: H.datalens.QueryTileProvider.Zoom,
|
||||
params?: any, onResult?: (result: any) => void, onError?: (error: any) => void): Promise<Uint8Array>;
|
||||
|
||||
/**
|
||||
* Sets the access and refresh tokens used to authenticate all requests against the Data Lens REST API.
|
||||
* Use this method to implement custom authentication to the Data Lens REST API.
|
||||
* @param accessToken {string} - The token used to authenticate all requests
|
||||
* @param refreshToken {string} - The token used to fetch a new access token after the previous access token has expired.
|
||||
* When refreshToken is provided, Service will automatically update the expired accessToken.
|
||||
*/
|
||||
setTokens(accessToken: string, refreshToken: string): void;
|
||||
|
||||
/**
|
||||
* This method implements H.service.IConfigurable interface. It is called by the H.service.Platform instance.
|
||||
* @param appId {string} - The appId
|
||||
* @param appCode {string} - The appCode
|
||||
* @param useHTTPS {boolean} - A flag to use HTTPS or not
|
||||
* @param useCIT {boolean} - A flag to use the staging server (CIT) or not
|
||||
* @param baseUrl {H.service.Url=} - The base URL for all requests to the Data Lens REST API
|
||||
* @returns {H.datalens.Service}
|
||||
*/
|
||||
configure(appId: string, appCode: string, useHTTPS: boolean, useCIT: boolean, baseUrl?: H.service.Url): H.datalens.Service;
|
||||
}
|
||||
|
||||
namespace Service {
|
||||
/**
|
||||
* Overrides the H.datalens.Service configuration
|
||||
* Normally the H.datalens.Service instance is configured with the H.service.Platform instance.
|
||||
* This configuration can be overridden by specifying these options.
|
||||
* It can be useful when the Data Lens environment is different from the HERE Platform environment.
|
||||
* @property subDomain {string=} - Subdomain of the Data Lens REST API URL
|
||||
* @property version {string=} - Pathname prefix of the Data Lens REST API endpoints
|
||||
* @property access_token {string=} - The token used to authenticate all requests
|
||||
* @property refresh_token {string=} - The token used to fetch a new access token after the previous access token has expired.
|
||||
* When refresh_token is provided, Service will automatically update the expired access_token.
|
||||
* @property domainSharding {string[]=} - To increase the number of simultaneous requests to the Data Lens REST API, domain sharding is used.
|
||||
* This option can be used when the Data Lens environment does not support domain sharding.
|
||||
* @property baseUrl {string=} - Defines an alternative host for the Data Lens REST API URL
|
||||
*/
|
||||
interface Options {
|
||||
subDomain?: string;
|
||||
version?: string;
|
||||
access_token?: string;
|
||||
refresh_token?: string;
|
||||
domainSharding?: string[];
|
||||
baseUrl?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* The format of Data Lens query data.
|
||||
* The Data Lens query data has a table-like structure with named columns and rows.
|
||||
* @property columns {string[]} - Column names
|
||||
* @property rows {Array<Array>} - Rows of data
|
||||
*/
|
||||
interface Data {
|
||||
columns: string[];
|
||||
rows: [any[]]; // rows : { Array.<Array> }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Providers define interfaces for layers to access data.
|
||||
* The input data can be stored locally or loaded from the network. Data can be loaded by tiles or in one chunk.
|
||||
* This provider allows you to supply data stored locally or fetched using external tools.
|
||||
*/
|
||||
class Provider extends H.map.provider.Provider {
|
||||
/**
|
||||
* Constructor
|
||||
* @param data {H.datalens.Service.Data=} - JSON object
|
||||
* @param options {H.map.provider.Provider.Options=} - Configures data accessibility parameters
|
||||
*/
|
||||
constructor(data?: H.datalens.Service.Data, options?: H.map.provider.Provider.Options);
|
||||
|
||||
/**
|
||||
* Updates the provider data. When data is updated, the update event is triggered so that the consuming layers are redrawn.
|
||||
* @param data {H.datalens.Service.Data} - JSON object
|
||||
*/
|
||||
setData(data: H.datalens.Service.Data): void;
|
||||
|
||||
/**
|
||||
* Retrieves the provider data.
|
||||
* @returns {H.datalens.Service.Data} - JSON object
|
||||
*/
|
||||
getData(): H.datalens.Service.Data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines the source of the data for layers from a Data Lens query.
|
||||
* Providers define interfaces for layers to access data. The input data can be stored locally or loaded from the network.
|
||||
* Data can be loaded by tiles or in one chunk. This provider loads query data with the Data Lens REST API.
|
||||
* Note that this provider must be used only for non-tiled queries.
|
||||
*/
|
||||
class QueryProvider extends H.datalens.Provider {
|
||||
/**
|
||||
* Constructor
|
||||
* @param service {H.datalens.Service} - Data Lens REST API service
|
||||
* @param options {H.datalens.QueryProvider.Options=} - Configures source query and data accessibility parameters
|
||||
*/
|
||||
constructor(data: H.datalens.Service.Data, options?: H.map.provider.Provider.Options);
|
||||
|
||||
/**
|
||||
* Updates the query ID to be used in the next call of the Data Lens REST API.
|
||||
* Note that new data will be fetched only after the reload method is called.
|
||||
* @param queryId {string}
|
||||
*/
|
||||
setQueryId(queryId: string): void;
|
||||
|
||||
/**
|
||||
* Updates the query's dynamic parameters to be used in the next call of the Data Lens REST API.
|
||||
* Note that new data will be fetched only after the reload method is called.
|
||||
* This method is normally used when updating your visualization.
|
||||
* @param queryParams {any|null} - Query dynamic parameters
|
||||
*/
|
||||
setQueryParams(queryParams: any|null): void;
|
||||
|
||||
/**
|
||||
* Fetches new data from the Data Lens REST API.
|
||||
* When data is fetched, the update event is triggered so that the consuming layers are redrawn.
|
||||
*/
|
||||
reload(): void;
|
||||
|
||||
/**
|
||||
* Updates the provider data.
|
||||
* When data is updated, the update event is triggered so that the consuming layers are redrawn.
|
||||
* @param data {H.datalens.Service.Data} - JSON object
|
||||
*/
|
||||
setData(data: H.datalens.Service.Data): void;
|
||||
|
||||
/**
|
||||
* Retrieves the provider data.
|
||||
* @returns {H.datalens.Service.Data} - JSON object
|
||||
*/
|
||||
getData(): H.datalens.Service.Data;
|
||||
}
|
||||
|
||||
namespace QueryProvider {
|
||||
/**
|
||||
* Configures source query and data accessibility parameters for H.datalens.QueryProvider
|
||||
* Specifies the query credentials and dynamic parameters required for fetching query data with the Data Lens REST API. Other options from H.datalens.Provider.Options are available.
|
||||
* @property queryId {string} - The ID of the Data Lens REST API query
|
||||
* @property queryParams {any=} - The query's dynamic parameters. The dynamic parameters can be used to filter data provided by the query.
|
||||
*/
|
||||
interface Options {
|
||||
queryId: string;
|
||||
queryParams?: any;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Providers define interfaces for layers to access data.
|
||||
* The input data can be stored locally or loaded from the network. Data can be loaded by tiles or in one chunk.
|
||||
* This provider loads tiled query data with the Data Lens REST API. Tiled queries are used to load data only for the current viewport.
|
||||
* This optimizes memory and network usage and enables progressive rendering.
|
||||
*/
|
||||
class QueryTileProvider extends H.map.provider.RemoteTileProvider {
|
||||
/**
|
||||
* Constructor
|
||||
* @param service {H.datalens.Service} - Data Lens REST API service
|
||||
* @param options {H.datalens.QueryTileProvider.Options} - Configures source query and data accessibility parameters
|
||||
*/
|
||||
constructor(service: H.datalens.Service, options: H.datalens.QueryTileProvider.Options);
|
||||
|
||||
/**
|
||||
* Updates the query ID to be used in the next call of the Data Lens REST API.
|
||||
* Note that new data will be fetched only after the reload method is called.
|
||||
* @param queryId {string}
|
||||
*/
|
||||
setQueryId(queryId: string): void;
|
||||
|
||||
/**
|
||||
* Updates the query's dynamic parameters to be used in the next call of the Data Lens REST API.
|
||||
* Note that new data will be fetched only after the reload method is called. This method is normally used when updating your visualization.
|
||||
* @param queryParams {any|null}
|
||||
*/
|
||||
setQueryParams(queryParams: any|null): void;
|
||||
|
||||
/**
|
||||
* Updates the names of the dynamic parameters that defines tiles. This method is only needed when the query ID is updated.
|
||||
* Note that new data will be fetched only after the reload method is called.
|
||||
* @param tileParamNames {H.datalens.QueryTileProvider.TileParamNames} - Names of the URI parameters that control the x/y/z of a tiled query
|
||||
*/
|
||||
setTileParamNames(tileParamNames: H.datalens.QueryTileProvider.TileParamNames): void;
|
||||
}
|
||||
|
||||
namespace QueryTileProvider {
|
||||
/**
|
||||
* Represents the names of the URI parameters that control the x/y/z of tiled query.
|
||||
* When defining the Data Lens query, dynamic parameters that control tiling can be arbitrarily named.
|
||||
* Names of these parameters must be specified to fetch tiles.
|
||||
* @property x {string} - Name of the dynamic parameter that defines tile column
|
||||
* @property y {string} - Name of the dynamic parameter that defines tile row
|
||||
* @property z {string} - Name of the dynamic parameter that defines zoom level
|
||||
*/
|
||||
interface TileParamNames {
|
||||
x: string;
|
||||
y: string;
|
||||
z: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures source query and data accessibility parameters for H.datalens.QueryTileProvider
|
||||
* Specifies the query credentials and dynamic parameters required for fetching tiled query data with the Data Lens REST API.
|
||||
* Other options from H.datalens.Provider.Options are available.
|
||||
* @property tileParamNames {H.datalens.QueryTileProvider.TileParamNames=} - Names of the URI parameters that control the x/y/z of a tiled query
|
||||
* @property queryId {string} - The ID for the Data Lens REST API query
|
||||
* @property queryParams {any=} - The query's dynamic parameters. The dynamic parameters can be used to filter data provided by the query.
|
||||
*/
|
||||
interface Options {
|
||||
tileParamNames: H.datalens.QueryTileProvider.TileParamNames;
|
||||
queryId: string;
|
||||
queryParams?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tile X coordinate (column)
|
||||
* Coordinate in XYZ tile numbering scheme.
|
||||
*/
|
||||
type X = number;
|
||||
|
||||
/**
|
||||
* Tile Y coordinate (row)
|
||||
* Coordinate in XYZ tile numbering scheme.
|
||||
*/
|
||||
type Y = number;
|
||||
|
||||
/**
|
||||
* Zoom level
|
||||
* Coordinate in XYZ tile numbering scheme. May vary within range 1 to 20.
|
||||
*/
|
||||
type Zoom = number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides pixel-wise rendering of data.
|
||||
* Layer used when you need to visualize more than 10k points. The layer requires source data to be located in pixel coordinates.
|
||||
* The rendering is implemented by drawing directly on a canvas. The layer is often used together with a Data Lens query which groups rows by pixels.
|
||||
* This reduces the amount of data delivered to the client.
|
||||
*/
|
||||
class RasterLayer extends H.map.layer.TileLayer {
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
constructor();
|
||||
|
||||
/**
|
||||
* Default value for dataToRows callback option.
|
||||
* It represents each row as an object where property names correspond to data column names.
|
||||
*/
|
||||
static defaultDataToRows: any;
|
||||
|
||||
/**
|
||||
* Force re-rendering of the layer.
|
||||
* In the case where the callbacks passed to the layer options are not pure functions, you can call this method to force re-rendering.
|
||||
*/
|
||||
redraw(): void;
|
||||
|
||||
/**
|
||||
* This is a default implementation of renderTile callback. This method represents each point as a black 1x1 pixel square.
|
||||
* @param points {Array<H.datalens.RasterLayer.TilePoint>} - Input data points within a tile
|
||||
* @param canvas {HTMLCanvasElement} - The target canvas
|
||||
*/
|
||||
static defaultRenderTile(points: H.datalens.RasterLayer.TilePoint[], canvas: HTMLCanvasElement): void;
|
||||
}
|
||||
|
||||
namespace RasterLayer {
|
||||
/**
|
||||
* Defines data processing and rendering options for RasterLayer.
|
||||
* The initial step of rendering is to split the tile data by rows, where each row represents a bucket.
|
||||
* By default this step is processed with H.datalens.RasterLayer.defaultDataToRows.
|
||||
* This behavior can be changed by defining the dataToRows callback.
|
||||
* To collect the rows for a tile including buffer, the rows must be translated to H.datalens.RasterLayer.TilePoint.
|
||||
* This translation must be specified with the rowToTilePoint callback. The final rendering on the tile canvas must be defined in renderTile.
|
||||
* @property dataToRows {function(H.datalens.Service.Data, H.datalens.QueryTileProvider.X, H.datalens.QueryTileProvider.Y, H.datalens.QueryTileProvider.Zoom)=} -
|
||||
* Defines how the input tile data is split by rows. You can specify this callback to define client-side aggregation and filtering. This callback is called for each tile.
|
||||
* @property rowToTilePoint {function(H.datalens.RasterLayer.Row, H.datalens.RasterLayer.X, H.datalens.RasterLayer.Y)=} -
|
||||
* Defines how the row is translated to the H.datalens.RasterLayer.TilePoint. This callback is called for each row that is returned from dataToRows.
|
||||
* @property buffer {function(H.datalens.QueryTileProvider.Zoom)=} - Defines the buffer as a function of the zoom level.
|
||||
* The buffer is a value (in pixels) that defines an extra area around each tile to capture data points from.
|
||||
* This is done to avoid drawing edges between tiles. For example, if data points represented with circles with a maximum radius of 10 pixels, then the buffer must be 10 pixels.
|
||||
* @property renderTile {function(Array<H.datalens.RasterLayer.TilePoint>, HTMLCanvasElement, H.datalens.QueryTileProvider.Zoom)=} -
|
||||
* Defines how tile data is represented on a canvas. Input points for each tile are collected with respect to the buffer.
|
||||
* For progressive rendering this callback may be called more than once for the tile.
|
||||
*/
|
||||
interface Options {
|
||||
dataToRows?(data: H.datalens.Service.Data, x: H.datalens.QueryTileProvider.X, y: H.datalens.QueryTileProvider.Y, zoom: H.datalens.QueryTileProvider.Zoom):
|
||||
H.datalens.RasterLayer.Row[];
|
||||
rowToTilePoint?(row: H.datalens.RasterLayer.Row, x: H.datalens.RasterLayer.X, y: H.datalens.RasterLayer.Y): H.datalens.RasterLayer.TilePoint;
|
||||
buffer?(zoom: H.datalens.QueryTileProvider.Zoom): number;
|
||||
renderTile?(points: H.datalens.RasterLayer.TilePoint[], canvas: HTMLCanvasElement, zoom: H.datalens.QueryTileProvider.Zoom): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines the input data format for heat map rendering.
|
||||
* To collect data rows for each tile with respect to the buffer, each row must be represented as a point within the map tile.
|
||||
* @property x {number} - Row relative to tile
|
||||
* @property y {number} - Column relative to tile
|
||||
* @property data {H.datalens.RasterLayer.Row=} - Reference to source data row
|
||||
*/
|
||||
interface TilePoint {
|
||||
x: number;
|
||||
y: number;
|
||||
data?: H.datalens.RasterLayer.Row;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tile X coordinate (column)
|
||||
* Coordinate in XYZ tile numbering scheme.
|
||||
*/
|
||||
type X = number;
|
||||
|
||||
/**
|
||||
* Tile Y coordinate (row)
|
||||
* Coordinate in XYZ tile numbering scheme.
|
||||
*/
|
||||
type Y = number;
|
||||
|
||||
/**
|
||||
* Slice of data (eg Data Lens query data row) that represents a data point.
|
||||
* Each row is transformed into TilePoint and passed to renderTile callback. By default each row is an Object where property names correspond to data column names.
|
||||
* This representation can be changed with the dataToRows callback.
|
||||
*/
|
||||
type Row = number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides functionality of value-based heat map with density alpha mask.
|
||||
* Layer support different types of blending, including weighted average. Also it allows to apply alpha mask calculated by density.
|
||||
* In most cases, the layer consumes data grouped by 1x1 pixels buckets. For proper averaging it requires aggregated value and count (number of rows in bucket) for each bucket.
|
||||
* Blending of buckets is implemented via kernel density estimation (KDE) with a Gaussian kernel.
|
||||
*/
|
||||
class HeatmapLayer extends H.datalens.RasterLayer {
|
||||
/**
|
||||
* Constructor
|
||||
* @param provider {H.datalens.QueryTileProvider} - Source of tiled data
|
||||
* @param options {H.datalens.HeatmapLayer.Options} - Configuration for data processing and rendering
|
||||
*/
|
||||
constructor(provider: H.datalens.QueryTileProvider, options: H.datalens.HeatmapLayer.Options);
|
||||
|
||||
/**
|
||||
* Default value for dataToRows callback option. It represents each row as an object where property names correspond to data column names.
|
||||
* @param data {H.datalens.Service.Data}
|
||||
* @param x {H.datalens.QueryTileProvider.X}
|
||||
* @param y {H.datalens.QueryTileProvider.Y}
|
||||
* @param zoom {H.datalens.QueryTileProvider.Zoom}
|
||||
* @returns {Array<H.datalens.HeatmapLayer.Row>}
|
||||
*/
|
||||
static defaultDataToRows: (data: H.datalens.Service.Data, x: H.datalens.QueryTileProvider.X, y: H.datalens.QueryTileProvider.Y, zoom: H.datalens.QueryTileProvider.Zoom) =>
|
||||
H.datalens.HeatmapLayer.Row[];
|
||||
|
||||
/**
|
||||
* Set of possible values for the inputScale option
|
||||
* @type {H.datalens.HeatmapLayer.InputScale}
|
||||
*/
|
||||
static inputScale: H.datalens.HeatmapLayer.InputScale;
|
||||
|
||||
/**
|
||||
* Set of possible values for the aggregation option
|
||||
* @type {H.datalens.HeatmapLayer.Aggregation}
|
||||
*/
|
||||
static aggregation: H.datalens.HeatmapLayer.Aggregation;
|
||||
|
||||
/**
|
||||
* @param zoom {number} - zoom level
|
||||
* @return {H.datalens.HeatmapLayer.Options}
|
||||
*/
|
||||
getOptionsPerZoom(zoom: number): H.datalens.HeatmapLayer.Options;
|
||||
|
||||
/**
|
||||
* Removes listeners, and references to memory consuming objects, from this layer. Call this method when you no longer need the layer.
|
||||
*/
|
||||
dispose(): void;
|
||||
|
||||
/**
|
||||
* Force re-rendering of the layer. In the case where the callbacks passed to the layer options are not pure functions, you can call this method to force re-rendering.
|
||||
*/
|
||||
redraw(): void;
|
||||
}
|
||||
|
||||
namespace HeatmapLayer {
|
||||
/**
|
||||
* Defines data processing and rendering options for HeatmapLayer.
|
||||
* The data processing flow of HeatmapLayer is similar to RasterLayer. The initial step of rendering is to split the tile data by rows, where each row represents a bucket.
|
||||
* By default this step is processed with H.datalens.HeatmapLayer.defaultDataToRows. This behavior can be changed by defining the dataToRows callback.
|
||||
* To collect the rows for a tile including buffer, the rows must be translated to H.datalens.HeatmapLayer.TilePoint. This translation must be specified with the rowToTilePoint callback.
|
||||
* Other options define the blending options for the heat map.
|
||||
* @property dataToRows {function(H.datalens.Service.Data, H.datalens.QueryTileProvider.X, H.datalens.QueryTileProvider.Y, H.datalens.QueryTileProvider.Zoom)=} -
|
||||
* Defines how the input tile data is split by rows. You can specify this callback to define client-side aggregation and filtering. This callback is called for each tile.
|
||||
* @property rowToTilePoint {function(H.datalens.HeatmapLayer.Row, H.datalens.HeatmapLayer.X, H.datalens.HeatmapLayer.Y)=} -
|
||||
* Defines how the row is translated to the H.datalens.HeatmapLayer.TilePoint. This callback is called for each row that is returned from dataToRows.
|
||||
* @property bandwidth {H.datalens.HeatmapLayer~Bandwidth | H.datalens.HeatmapLayer~BandwidthStop | Array.<H.datalens.HeatmapLayer~BandwidthStop> |
|
||||
* H.datalens.HeatmapLayer~BandwidthCallback=} - Describes the bandwidth behavior in relation to current zoom level A numeric value sets it static across all levels
|
||||
* An Object with zoom, value and optional zoomIncrementFactor (1 equals doubling on every zoom increment) defines a behavior across all zoom levels
|
||||
* An Array of one or more zoom, value objects describes the behavior between the two defined levels and extrapolates the implied change outside of the defined range
|
||||
* Alternatively defines the level of smoothing as a function of the zoom level. The callback must return a value in pixels.
|
||||
* The cut-off of the Gaussian kernel is defined as 3 * bandwidth , a multiple (default 3) of bandwidth.
|
||||
* @property valueRange {function(H.datalens.QueryTileProvider.Zoom)} - Defines the range for the color scale as a function of the zoom level.
|
||||
* The returned value must be an array of 2 numbers.
|
||||
* @property countRange {function(H.datalens.QueryTileProvider.Zoom)} - Defines the range for the density alpha mask as a function of the zoom level.
|
||||
* When defined, the density alpha mask is applied. The returned value must be an array of 2 numbers.
|
||||
* @property colorScale {function(number)} - Defines a color palette as a function of the normalized value. You can use D3.js library scale functions with the domain [0, 1].
|
||||
* @property alphaScale {function(number)} - Defines the alpha mask value as a function of the normalized count.
|
||||
* You can use D3.js library scale functions with the domain [0, 1] and the range [0, 1].
|
||||
* @property aggregation {H.datalens.HeatmapLayer.Aggregation} - Specifies which type of aggregation was applied (eg. type of aggregation function for bucket in the Data Lens query).
|
||||
* Possible values are SUM or AVERAGE. If the aggregation type is AVERAGE , then an averaged heat map is rendered.
|
||||
* @property inputScale {H.datalens.HeatmapLayer.InputScale} - Defines the scale (eg logarithmic scale) of the TilePoint value.
|
||||
* Note: if the value is not in a linear scale, then the aggregation in the source query must be defined with respect to the scale type.
|
||||
* For example, before applying the average aggregation function in a query, the value must be transformed to the linear scale. This guarantees correct linear averaging of values.
|
||||
*/
|
||||
interface Options {
|
||||
dataToRows?(data: H.datalens.Service.Data, x: H.datalens.QueryTileProvider.X, y: H.datalens.QueryTileProvider.Y, zoom: H.datalens.QueryTileProvider.Zoom):
|
||||
H.datalens.HeatmapLayer.Row[];
|
||||
rowToTilePoint(row: H.datalens.HeatmapLayer.Row, x: H.datalens.HeatmapLayer.X, y: H.datalens.HeatmapLayer.Y): H.datalens.HeatmapLayer.TilePoint;
|
||||
bandwidth?: H.datalens.HeatmapLayer.Bandwidth | H.datalens.HeatmapLayer.BandwidthStop | H.datalens.HeatmapLayer.BandwidthStop[] | H.datalens.HeatmapLayer.BandwidthCallback;
|
||||
valueRange?(zoom: H.datalens.QueryTileProvider.Zoom): number[];
|
||||
countRange?(zoom: H.datalens.QueryTileProvider.Zoom): number[];
|
||||
colorScale?(scale: number): string;
|
||||
alphaScale?(scale: number): number;
|
||||
aggregation?: H.datalens.HeatmapLayer.Aggregation;
|
||||
inputScale?: H.datalens.HeatmapLayer.InputScale;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tile X coordinate (column)
|
||||
* Coordinate in XYZ tile numbering scheme.
|
||||
*/
|
||||
type X = number;
|
||||
|
||||
/**
|
||||
* Tile Y coordinate (row)
|
||||
* Coordinate in XYZ tile numbering scheme.
|
||||
*/
|
||||
type Y = number;
|
||||
|
||||
/**
|
||||
* Slice of data (eg Data Lens query data row) that represents a data point.
|
||||
* Each row is transformed into TilePoint and then rendered on a heat map. By default each row is an Object where property names correspond to data column names.
|
||||
* This representation can be changed with the dataToRows callback.
|
||||
*/
|
||||
interface Row {
|
||||
tx?: number;
|
||||
ty?: number;
|
||||
count?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines a constant for the bandwidth
|
||||
* A number that sets a constant for the bandwidth across all zoom levels.
|
||||
*/
|
||||
type Bandwidth = number;
|
||||
|
||||
/**
|
||||
* Sets the bandwidth for a given zoom level and uses this to calculate the increment or decrement of the bandwidth at other zoom levels
|
||||
* This object defines the behavior of the bandwidth value across all zoom levels, initialized by a reference zoom level and its value at that level.
|
||||
* The default behavior with zoomIncrementFactor = 1 doubles the bandwidth with every increasing zoom level and halves it on every decrease in zoom level.
|
||||
* For example, a bandwidth of 10@zoom1 turns to 20@zoom2 and 5@zoom0. A zoomIncrementFactor of 0 effectively equals the bandwidth number, ignoring the provided zoom level.
|
||||
* A zoomIncrementFactor of 0.5 mean a bandwidth increase of 50% compared to a factor of 1. So a bandwidth of 10@zoom1 computes to 15@zoom2.
|
||||
*/
|
||||
interface BandwidthStop {
|
||||
zoom: number;
|
||||
value: number;
|
||||
zoomIncrementFactor?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: this is missing in the documentation: https://developer.here.com/visualization/documentation/datalens/h-datalens-heatmaplayer-options.html
|
||||
*/
|
||||
type BandwidthCallback = () => void;
|
||||
|
||||
/**
|
||||
* Defines the input data format for heat map rendering.
|
||||
* For heat map rendering, each row of data must be represented as a point within the map tile.
|
||||
* @property x {number} - Row relative to tile
|
||||
* @property y {number} - Column relative to tile
|
||||
* @property value {number} - Value at the point (eg aggregated bucket value)
|
||||
* @property count {number} - Number of contributors to the value at the point (eg number of rows in a bucket)
|
||||
* @property data {H.datalens.HeatmapLayer.Row} - Reference to source data row
|
||||
*/
|
||||
interface TilePoint {
|
||||
x: number;
|
||||
y: number;
|
||||
value: number;
|
||||
count: number;
|
||||
data?: H.datalens.HeatmapLayer.Row;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set of possible values for the aggregation option.
|
||||
* If the heat map input data is buckets, then different types of aggregation can be applied to the rows in a bucket.
|
||||
* The aggregation type is required for proper blending mode of the heat map. For the AVERAGE aggregation type, an averaged heat map is rendered.
|
||||
* @property SUM {string} - Specifies that the sum aggregation was applied to the bucket value
|
||||
* @property AVERAGE {string} - Specifies that the average aggregation was applied to the bucket value
|
||||
*/
|
||||
enum Aggregation {
|
||||
SUM,
|
||||
AVERAGE
|
||||
}
|
||||
|
||||
/**
|
||||
* Set of possible values for the inputScale option.
|
||||
* The input scale is required for proper heat map blending. If the input scale is not linear, then the TilePoint.value is converted to linear scale before calculating the sum or average.
|
||||
* @property DB {string} - Decibel (dB) scale
|
||||
* @property LINEAR {string} - Linear scale
|
||||
* @property LOG {string} - Logarithmic scale
|
||||
*/
|
||||
enum InputScale {
|
||||
DB,
|
||||
LINEAR,
|
||||
LOG
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Presents data as points or spatial map objects with data-driven styles and client-side clustering.
|
||||
* Applicable for drawing interactive map objects like markers, polygons, circles and other instances of H.map.Object. Source of data can be either tiled or not tiled.
|
||||
* Styles for objects can be parametrized with data rows and zoom level. Allows to create data-driven icons for markers like donuts or bars.
|
||||
* Also enables clustering and data domains for visualizing up to 100k points or more.
|
||||
*/
|
||||
class ObjectLayer extends H.map.layer.ObjectLayer {
|
||||
/**
|
||||
* Constructor
|
||||
* @param provider {H.map.provider.RemoteTileProvider | H.datalens.Provider | H.datalens.QueryProvider | H.datalens.QueryTileProvider} - Data source (tiled or not)
|
||||
* @param options {H.datalens.ObjectLayer.Options} - Defines data processing, clustering and data-driven styling
|
||||
*/
|
||||
constructor(provider: H.map.provider.RemoteTileProvider | H.datalens.Provider | H.datalens.QueryProvider | H.datalens.QueryTileProvider, options: H.datalens.ObjectLayer.Options);
|
||||
|
||||
/**
|
||||
* Default value for dataToRows callback option. It represents each row as an object where property names correspond to data column names.
|
||||
* @property data {H.datalens.Service.Data}
|
||||
* @returns {Array<H.datalens.ObjectLayer.Row>}
|
||||
*/
|
||||
static defaultDataToRows(data: H.datalens.Service.Data): H.datalens.ObjectLayer.Row[];
|
||||
|
||||
/**
|
||||
* A factory method for data-driven icons. The method allows you to build an icon from SVG markup or JsonML object. Provides caching of icons with the same markup.
|
||||
* @param svg {string | Array} - SVG presented as markup or JsonML Array
|
||||
* @param options {H.map.Icon.Options} - Icon options (eg size and anchor). Note that the default anchor is in the middle.
|
||||
* @param options.size {H.math.ISize | number} - When the icon is a square, you can define the size as a number in pixels
|
||||
* @returns {H.map.Icon} - Icon which can be used for marker or cluster
|
||||
*/
|
||||
static createIcon(svg: string | any[], options?: H.map.Icon.Options): H.map.Icon;
|
||||
|
||||
/**
|
||||
* Returns cache of icons created with the createIcon method. Can be used to clean the icon cache.
|
||||
* @return {H.util.Cache} - Icon cache
|
||||
*/
|
||||
static getIconCache(): H.util.Cache;
|
||||
|
||||
/**
|
||||
* Force re-rendering of the layer. In the case where the callbacks passed to the layer options are not pure functions, you can call this method to force re-rendering.
|
||||
*/
|
||||
redraw(): void;
|
||||
|
||||
/**
|
||||
* Recalculates the style and applies it to the map object based on the new StyleState
|
||||
* @param object {H.map.Object} - Map object
|
||||
* @param state {H.datalens.ObjectLayer.StyleState} - New state
|
||||
*/
|
||||
updateObjectStyle(any: H.map.Object, state: H.datalens.ObjectLayer.StyleState): void;
|
||||
}
|
||||
|
||||
namespace ObjectLayer {
|
||||
/**
|
||||
* Defines data processing and data-driven styling for ObjectLayer
|
||||
* The initial step of rendering is to split the tile data by rows, where each row represents a bucket.
|
||||
* By default this step is processed with H.datalens.ObjectLayer.defaultDataToRows. This behavior can be changed by defining the dataToRows callback.
|
||||
* In the next step each row must be presented as a map object with the rowToMapObject callback. Data-driven styling can be provided with the rowToStyle callback.
|
||||
* @property dataToRows {function(H.datalens.Service.Data)=} - Defines how the input data is split by rows. You can specify this callback to define client-side aggregation and filtering.
|
||||
* @property rowToMapObject {function(H.datalens.ObjectLayer.Row, H.datalens.QueryTileProvider.Zoom)} - Defines how each row is presented on the map (eg marker, polygon)
|
||||
* @property rowToStyle {function(H.datalens.ObjectLayer.Row, H.datalens.QueryTileProvider.Zoom, H.datalens.ObjectLayer.StyleState)=} -
|
||||
* Defines map object style and icon according to data row and zoom level. Also it can define different styles depending on the StyleState (eg hovered, selected).
|
||||
* @property dataDomains {H.datalens.ObjectLayer.DataDomains=} - Defines quantization of data for improving data-driven styling performance
|
||||
* @property clustering {H.datalens.ObjectLayer.Clustering=} - When present, client-side clustering is applied
|
||||
*/
|
||||
interface Options {
|
||||
dataToRows?(data: H.datalens.Service.Data): H.datalens.ObjectLayer.Row[];
|
||||
rowToMapObject(row: H.datalens.ObjectLayer.Row, z: H.datalens.QueryTileProvider.Zoom): H.map.Object;
|
||||
rowToStyle?(row: H.datalens.ObjectLayer.Row, z: H.datalens.QueryTileProvider.Zoom, styleState: H.datalens.ObjectLayer.StyleState): H.datalens.ObjectLayer.ObjectStyleOptions;
|
||||
dataDomains?: H.datalens.ObjectLayer.DataDomains;
|
||||
clustering?: H.datalens.ObjectLayer.Clustering;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines client-side clustering in the ObjectLayer.
|
||||
* When the clustering option is provided, rows returned from dataToRows go to the clustering.rowToDataPoint callback to be transformed to data points.
|
||||
* Then, the data points are clustered according to clustering.options. Clustering produces clusters and noise points (data points that are not clustered).
|
||||
* Clusters and noise points must be presented as map objects with the rowToMapObject callback and can be styled with the rowToStyle callback.
|
||||
* @property rowToDataPoint {H.datalens.ObjectLayer.Row} - Defines data points from rows
|
||||
* @property options {function(H.datalens.QueryTileProvider.Zoom)} - Defines clustering options as a function of the zoom level
|
||||
*/
|
||||
interface Clustering {
|
||||
rowToDataPoint(row: H.datalens.ObjectLayer.Row): H.clustering.DataPoint;
|
||||
options(zoom: H.datalens.QueryTileProvider.Zoom): H.clustering.Provider.ClusteringOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Slice of data (eg Data Lens query data row) that represents a data point.
|
||||
* Each row is translated to map objects with the rowToMapObject callback. By default each row is an Object where property names correspond to data column names.
|
||||
* This representation can be changed with the dataToRows callback.
|
||||
*/
|
||||
interface Row {
|
||||
getPosition(): H.geo.Point;
|
||||
lat: number;
|
||||
lng: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* User defined modification of a data-driven style
|
||||
* StyleState appears as a parameter in the rowToStyle callback. By default it is 'DEFAULT_STATE'. To change StyleState, use the ObjectLayer.updateObjectStyle method.
|
||||
*/
|
||||
type StyleState = any;
|
||||
|
||||
/**
|
||||
* Output from the rowToStyle callback.
|
||||
* Defines the styles or the icon that is applied to the map object.
|
||||
* @property icon {H.map.Icon} - Marker icon
|
||||
* @property style {H.map.SpatialStyle.Options} - Spatial style
|
||||
* @property arrows {H.map.ArrowStyle.Options} - Style of arrows to render along a polyline
|
||||
* @property zIndex {number} - The z-index value of the map object, default is 0
|
||||
*/
|
||||
interface ObjectStyleOptions {
|
||||
icon: H.map.Icon;
|
||||
style: H.map.SpatialStyle.Options;
|
||||
arrows: H.map.ArrowStyle.Options;
|
||||
zIndex: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Input data quantization domain, used to optimize styling performance.
|
||||
* The option must have properties corresponding to the properties of H.datalens.ObjectLayer.Row. Values must be represented as an Array of Numbers that defines the quantization domain.
|
||||
* When provided, the input data will be quantized, and rowToStyle will be called only for quantized values.
|
||||
*/
|
||||
type DataDomains = any;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines how to load data from a raw data file
|
||||
* This provider defines the interface for loading data, such as geometries or coordinates, from a local or remote data file in GeoJSON or CSV format
|
||||
*/
|
||||
class RawDataProvider extends H.map.provider.RemoteTileProvider {
|
||||
/**
|
||||
* Constructor
|
||||
* @param options {H.datalens.RawDataProvider.Options} - Configures options
|
||||
*/
|
||||
constructor(options: H.datalens.RawDataProvider.Options);
|
||||
|
||||
/**
|
||||
* Updates the data url. Note that new data will be fetched only after the reload method is called.
|
||||
* @param dataUrl {string}
|
||||
*/
|
||||
setDataUrl(dataUrl: string): void;
|
||||
}
|
||||
|
||||
namespace RawDataProvider {
|
||||
/**
|
||||
* Defines options for RawDataProvider
|
||||
* Options for RawDataProvider
|
||||
* @property dataUrl - The data url to fetch
|
||||
* @property dataToFeatures {function(any)=} - Defines how the input data is mapped to an array of GeoJSON features
|
||||
* @property featuresToRows {function(Array<H.datalens.RawDataProvider.Feature>, H.datalens.QueryTileProvider.X, H.datalens.QueryTileProvider.Y, H.datalens.QueryTileProvider.Zoom,
|
||||
* H.datalens.RawDataProvider.TileSize, H.datalens.RawDataProvider.Helpers)=} -
|
||||
* Defines how GeoJSON features on a tile should be mapped to data rows, which are inputs to layers such as ObjectLayer and HeatmapLayer
|
||||
*/
|
||||
interface Options {
|
||||
dataUrl?: string;
|
||||
dataToFeatures?(obj: any): H.datalens.RawDataProvider.Feature[];
|
||||
featuresToRows?(features: H.datalens.RawDataProvider.Feature[], x: H.datalens.QueryTileProvider.X, y: H.datalens.QueryTileProvider.Y, z: H.datalens.QueryTileProvider.Zoom,
|
||||
tileSize: H.datalens.RawDataProvider.TileSize, helpers: H.datalens.RawDataProvider.Helpers): H.datalens.ObjectLayer.Row[];
|
||||
}
|
||||
|
||||
/**
|
||||
* A GeoJSON feature
|
||||
* A GeoJSON feature object which conforms to the standard GeoJSON spec
|
||||
*/
|
||||
type Feature = any;
|
||||
|
||||
/**
|
||||
* Tile size
|
||||
* The tile size in pixels.
|
||||
*/
|
||||
type TileSize = any;
|
||||
|
||||
/**
|
||||
* A helper class used in the worker thread
|
||||
* This helper class provides convenience functions you can use in the worker thread
|
||||
* @property latLngToPixel {function(H.datalens.RawDataProvider.Latitude, H.datalens.RawDataProvider.Longitude, H.datalens.QueryTileProvider.Zoom, H.datalens.RawDataProvider.TileSize)=} -
|
||||
* Translates geographical coordinates (latitude, longitude) to world pixel coordinates.
|
||||
* @property pixelToLatLng {function(H.datalens.RawDataProvider.PX, H.datalens.RawDataProvider.PY, H.datalens.QueryTileProvider.Zoom, H.datalens.RawDataProvider.TileSize)=} -
|
||||
* Translates world pixel coordinates to geographical coordinates (latitude, longitude).
|
||||
* @property parseCSV {function(any)=} - Takes CSV data as input, parses it, and return the parsed result.
|
||||
*/
|
||||
interface Helpers {
|
||||
latLngToPixel?(latitude: H.datalens.RawDataProvider.Latitude, longitude: H.datalens.RawDataProvider.Longitude, z: H.datalens.QueryTileProvider.Zoom,
|
||||
tileSize: H.datalens.RawDataProvider.TileSize): H.datalens.RawDataProvider.PixelCoordinates;
|
||||
pixelToLatLng?(x: H.datalens.RawDataProvider.PX, y: H.datalens.RawDataProvider.PY, z: H.datalens.QueryTileProvider.Zoom, tileSize: H.datalens.RawDataProvider.TileSize):
|
||||
H.datalens.RawDataProvider.GeoCoordinates;
|
||||
parseCSV?(obj: any): any[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Geographic coordinates
|
||||
* A geographic coordinates pair [lat, lng]
|
||||
*/
|
||||
type GeoCoordinates = [number, number];
|
||||
|
||||
/**
|
||||
* Latitude coordinate
|
||||
* The latitude in the geographic coordinates pair
|
||||
*/
|
||||
type Latitude = number;
|
||||
|
||||
/**
|
||||
* Longitude coordinate
|
||||
* The longitude in the geographic coordinates pair
|
||||
*/
|
||||
type Longitude = number;
|
||||
|
||||
/**
|
||||
* Pixel coordinates
|
||||
* Pixel coordinates [px, py] pair
|
||||
*/
|
||||
type PixelCoordinates = [number, number];
|
||||
|
||||
/**
|
||||
* Pixel coordinate in the x direction
|
||||
* The x coordinate of the pixel coordinates pair [px, py]
|
||||
*/
|
||||
type PX = number;
|
||||
|
||||
/**
|
||||
* Pixel coordinate in the y direction
|
||||
* The y coordinate of the pixel coordinates pair [px, py]
|
||||
*/
|
||||
type PY = number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders vector tiles using data-driven styles
|
||||
* This layer binds the spatial data and user data, all provided by the Data Lens REST API. The layer renders geometry features using data-driven styles.
|
||||
*/
|
||||
class SpatialLayer extends H.map.layer.TileLayer {
|
||||
/**
|
||||
* Constructor
|
||||
* @param dataProvider {H.datalens.Provider} - Source of tiled data (pass in null if data come from feature properties)
|
||||
* @param spatialProvider {H.datalens.SpatialTileProvider} - Source of geometry data
|
||||
* @param options {H.datalens.SpatialLayer.Options} - Configuration for data processing and rendering
|
||||
*/
|
||||
constructor(dataProvider: H.datalens.Provider, spatialProvider: H.datalens.SpatialTileProvider, options: H.datalens.SpatialLayer.Options);
|
||||
|
||||
static DEFAULT_STATE: any;
|
||||
static Spatial: any;
|
||||
|
||||
/**
|
||||
* Default value for dataToRows callback option. It represents each row as an object where property names correspond to data column names.
|
||||
*/
|
||||
static defaultDataToRows: any;
|
||||
|
||||
/**
|
||||
* Forces re-rendering of the layer. When the callbacks passed to the layer options are not pure functions, you can call this method to force re-rendering.
|
||||
*/
|
||||
redraw(): void;
|
||||
|
||||
/**
|
||||
* This method changes the state of a map object; for example, style on mouse event.
|
||||
* @param {H.map.Object} spatial
|
||||
* @param {H.datalens.SpatialLayer.StyleState} state
|
||||
*/
|
||||
updateSpatialStyle(spatial: H.map.Object, state: H.datalens.SpatialLayer.StyleState): void;
|
||||
}
|
||||
|
||||
namespace SpatialLayer {
|
||||
/**
|
||||
* Defines data processing and rendering options for SpatialLayer
|
||||
* The initial step of rendering is to split the tile data by rows, where each row represents a bucket.
|
||||
* By default this step is processed with H.datalens.SpatialLayer.defaultDataToRows. This behavior can be changed by defining the dataToRows callback.
|
||||
* @property dataToRows {function(H.datalens.Service.Data, H.datalens.QueryTileProvider.X, H.datalens.QueryTileProvider.Y, H.datalens.QueryTileProvider.Zoom)=} -
|
||||
* Defines how the input tile data is split by rows. You can specify this callback to define client-side aggregation and filtering. This callback is called for each tile.
|
||||
* @property rowToSpatialId {function(H.datalens.SpatialLayer.Row)} -
|
||||
* Defines how to get the spatial ID from a data row. This callback is called for each row that is returned from dataToRows.
|
||||
* @property featureToSpatialId {function(H.datalens.SpatialLayer.Feature)} -
|
||||
* Defines how to get the spatial ID from a geometry feature. This callback is called for each geometry feature in the vector tile.
|
||||
* @property rowToStyle {function(H.datalens.SpatialLayer.Row, H.datalens.QueryTileProvider.Zoom, H.datalens.SpatialLayer.StyleState)} -
|
||||
* Defines how the row is translated to map object style. This callback is called for each row that is returned from dataToRows.
|
||||
* @property defaultStyle {function(H.datalens.QueryTileProvider.Zoom, H.datalens.SpatialLayer.StyleState)} - Defines the default map object style.
|
||||
* @property transformFeature {H.datalens.SpatialLayer.transformFeature} - Defines how to transform the features.
|
||||
*/
|
||||
interface Options {
|
||||
dataToRows?(data: H.datalens.Service.Data, x: H.datalens.QueryTileProvider.X, y: H.datalens.QueryTileProvider.Y, z: H.datalens.QueryTileProvider.Zoom):
|
||||
H.datalens.SpatialLayer.Row[];
|
||||
rowToSpatialId(row: H.datalens.SpatialLayer.Row): string;
|
||||
featureToSpatialId(feature: H.datalens.SpatialLayer.Feature): string;
|
||||
rowToStyle(row: H.datalens.SpatialLayer.Row, z: H.datalens.QueryTileProvider.Zoom, styleState: H.datalens.SpatialLayer.StyleState): any;
|
||||
defaultStyle(z: H.datalens.QueryTileProvider.Zoom, styleState: H.datalens.SpatialLayer.StyleState): any;
|
||||
transformFeature: H.datalens.SpatialLayer.transformFeature;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines modification of a data-driven style
|
||||
* StyleState appears as a parameter in the rowToStyle callback. By default it is 'DEFAULT_STATE'. To change StyleState, use the SpatialLayer.updateSpatialStyle method.
|
||||
*/
|
||||
type StyleState = any;
|
||||
|
||||
/**
|
||||
* Defines a slice of data (eg Data Lens query data row) that represents a data point
|
||||
* By default each row is an object where property names correspond to data column names. This representation can be changed with the dataToRows callback.
|
||||
*/
|
||||
type Row = any;
|
||||
|
||||
/**
|
||||
* Defines a geometry in the vector tile
|
||||
* Each geometry is described by various properties, including a unique identifier which must be used to map the geometry to user data.
|
||||
*/
|
||||
type Feature = any;
|
||||
|
||||
/**
|
||||
* TODO: missing in documentation: https://developer.here.com/visualization/documentation/datalens/h-datalens-spatiallayer-options.html
|
||||
*/
|
||||
type transformFeature = any;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies how to access layer data (shapes, geometries) using the Data Lens REST API.
|
||||
* This provider defines the interface for accessing shape layers via the Data Lens REST API. The input data is provided as vector tiles in the MapBox format (Protobuf).
|
||||
* Data is loaded by tiles.
|
||||
*/
|
||||
class SpatialTileProvider extends H.map.provider.RemoteTileProvider {
|
||||
/**
|
||||
* Constructor
|
||||
* @param service {H.datalens.Service} - Data Lens REST API service
|
||||
* @param options {H.datalens.SpatialTileProvider.Options} - Configures layer name
|
||||
*/
|
||||
constructor(service: H.datalens.Service, options: H.datalens.SpatialTileProvider.Options);
|
||||
|
||||
static VectorTile: any;
|
||||
|
||||
/**
|
||||
* Updates the layer name to be used in the next call of the Data Lens REST API. Note that new data will be fetched only after the reload method is called.
|
||||
* @param {string} layerName
|
||||
*/
|
||||
setLayerName(layerName: string): void;
|
||||
|
||||
/**
|
||||
* Updates the query's dynamic parameters to be used in the next call of the Data Lens REST API. Note that new data will be fetched only after the reload method is called.
|
||||
* This method is normally used when updating your visualization.
|
||||
* @param {any|null} queryParams
|
||||
*/
|
||||
setQueryParams(queryParams: any | null): void;
|
||||
}
|
||||
|
||||
namespace SpatialTileProvider {
|
||||
/**
|
||||
* Defines layer name and data accessibility parameters for H.datalens.SpatialTileProvider
|
||||
* This defines the layer name and dynamic parameters required for fetching tiled geometry data with the Data Lens REST API. Other options from H.datalens.Provider.Options are available.
|
||||
* @property layerName {string} - The name of the layer to fetch with the Data Lens REST API query
|
||||
* @property queryParams {any} - The query's dynamic parameters. The dynamic parameters can be used to filter data provided by the query.
|
||||
*/
|
||||
interface Options {
|
||||
layerName: string;
|
||||
queryParams?: any;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
@@ -18,8 +18,6 @@
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"test/index.ts",
|
||||
"test/main.ts",
|
||||
"test/renderer.ts"
|
||||
"heredatalens-tests.ts"
|
||||
]
|
||||
}
|
||||
3
types/heredatalens/tslint.json
Normal file
3
types/heredatalens/tslint.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
@@ -134,7 +134,10 @@ fooStream = _<Foo>((push, next) => {
|
||||
|
||||
fooStream = _(fooStream);
|
||||
fooStream = _<Foo>(readable);
|
||||
fooStream = _<Foo>(emitter);
|
||||
fooStream = _<Foo>(str, emitter);
|
||||
fooStream = _<Foo>(str, emitter, num);
|
||||
fooStream = _<Foo>(str, emitter, strArr);
|
||||
fooStream = _<Foo>(str, emitter, f);
|
||||
|
||||
fooStream = _(fooStreamThen);
|
||||
fooStream = _(fooThen);
|
||||
@@ -210,6 +213,9 @@ _.log(str, num, foo);
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
f = _.wrapCallback(func);
|
||||
f = _.wrapCallback(func, num);
|
||||
f = _.wrapCallback(func, strArr);
|
||||
f = _.wrapCallback(func, fn);
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
|
||||
36
types/highland/index.d.ts
vendored
36
types/highland/index.d.ts
vendored
@@ -1,6 +1,7 @@
|
||||
// Type definitions for Highland 1.14.0
|
||||
// Type definitions for Highland 2.10.5
|
||||
// Project: http://highlandjs.org/
|
||||
// Definitions by: Bart van der Schoor <https://github.com/Bartvds/>
|
||||
// Hugo Wood <https://github.com/hgwood/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
@@ -48,6 +49,17 @@ interface HighlandStatic {
|
||||
* event emitter as the two arguments to the constructor and the first
|
||||
* argument emitted to the event handler will be written to the new Stream.
|
||||
*
|
||||
* You can pass a mapping hint as the third argument, which specifies how
|
||||
* event arguments are pushed into the stream. If no mapping hint is
|
||||
* provided, only the first value emitted with the event to the will be
|
||||
* pushed onto the Stream.
|
||||
*
|
||||
* If mappingHint is a number, an array of that length will be pushed onto
|
||||
* the stream, containing exactly that many parameters from the event. If
|
||||
* it's an array, it's used as keys to map the arguments into an object which
|
||||
* is pushed to the tream. If it is a function, it's called with the event
|
||||
* arguments, and the returned value is pushed.
|
||||
*
|
||||
* **Promise -** Accepts an ES6 / jQuery style promise and returns a
|
||||
* Highland Stream which will emit a single value (or an error).
|
||||
*
|
||||
@@ -63,7 +75,7 @@ interface HighlandStatic {
|
||||
|
||||
<R>(xs: Highland.Stream<R>): Highland.Stream<R>;
|
||||
<R>(xs: NodeJS.ReadableStream): Highland.Stream<R>;
|
||||
<R>(xs: NodeJS.EventEmitter): Highland.Stream<R>;
|
||||
<R>(eventName: string, xs: NodeJS.EventEmitter, mappingHint?: Highland.MappingHint): Highland.Stream<R>;
|
||||
|
||||
// moar (promise for everything?)
|
||||
<R>(xs: Highland.Thenable<Highland.Stream<R>>): Highland.Stream<R>;
|
||||
@@ -298,16 +310,28 @@ interface HighlandStatic {
|
||||
/**
|
||||
* Wraps a node-style async function which accepts a callback, transforming
|
||||
* it to a function which accepts the same arguments minus the callback and
|
||||
* returns a Highland Stream instead. Only the first argument to the
|
||||
* callback (or an error) will be pushed onto the Stream.
|
||||
* returns a Highland Stream instead. The wrapped function keeps its context,
|
||||
* so you can safely use it as a method without binding (see the second
|
||||
* example below).
|
||||
*
|
||||
* wrapCallback also accepts an optional mappingHint, which specifies how
|
||||
* callback arguments are pushed to the stream. This can be used to handle
|
||||
* non-standard callback protocols that pass back more than one value.
|
||||
*
|
||||
* mappingHint can be a function, number, or array. See the documentation on
|
||||
* EventEmitter Stream Objects for details on the mapping hint. If
|
||||
* mappingHint is a function, it will be called with all but the first
|
||||
* argument that is passed to the callback. The first is still assumed to be
|
||||
* the error argument.
|
||||
*
|
||||
* @id wrapCallback
|
||||
* @section Utils
|
||||
* @name _.wrapCallback(f)
|
||||
* @param {Function} f - the node-style function to wrap
|
||||
* @param {Array | Function | Number} [mappingHint] - how to pass the arguments to the callback
|
||||
* @api public
|
||||
*/
|
||||
wrapCallback(f: Function): Function;
|
||||
wrapCallback(f: Function, mappingHint?: Highland.MappingHint): (...args: any[]) => Highland.Stream<any>;
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
@@ -1009,6 +1033,8 @@ declare namespace Highland {
|
||||
*/
|
||||
latest(): Stream<R>;
|
||||
}
|
||||
|
||||
type MappingHint = number | string[] | Function;
|
||||
}
|
||||
|
||||
declare var highland:HighlandStatic;
|
||||
|
||||
42
types/http-aws-es/http-aws-es-tests.ts
Normal file
42
types/http-aws-es/http-aws-es-tests.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import { EnvironmentCredentials } from "aws-sdk/lib/core";
|
||||
import { Client } from "elasticsearch";
|
||||
import HttpAmazonESConnector = require("http-aws-es");
|
||||
|
||||
new Client({
|
||||
amazonES: {
|
||||
accessKey: "AKID",
|
||||
region: "us-east-1",
|
||||
secretKey: "secret",
|
||||
},
|
||||
connectionClass: HttpAmazonESConnector,
|
||||
host: "https://amazon-es-host.us-east-1.es.amazonaws.com",
|
||||
});
|
||||
|
||||
new Client({
|
||||
amazonES: {
|
||||
accessKey: "AKID",
|
||||
region: "us-east-1",
|
||||
secretKey: "secret",
|
||||
},
|
||||
connectionClass: require("http-aws-es"),
|
||||
host: "https://amazon-es-host.us-east-1.es.amazonaws.com",
|
||||
});
|
||||
|
||||
const myCredentials = new EnvironmentCredentials("AWS");
|
||||
new Client({
|
||||
amazonES: {
|
||||
credentials: myCredentials,
|
||||
region: "us-east-1",
|
||||
},
|
||||
connectionClass: HttpAmazonESConnector,
|
||||
host: "https://amazon-es-host.us-east-1.es.amazonaws.com",
|
||||
});
|
||||
|
||||
new Client({
|
||||
amazonES: {
|
||||
credentials: myCredentials,
|
||||
region: "us-east-1",
|
||||
},
|
||||
connectionClass: require("http-aws-es"),
|
||||
host: "https://amazon-es-host.us-east-1.es.amazonaws.com",
|
||||
});
|
||||
25
types/http-aws-es/index.d.ts
vendored
Normal file
25
types/http-aws-es/index.d.ts
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
// Type definitions for http-aws-es 1.1
|
||||
// Project: https://github.com/TheDeveloper/http-aws-es#readme
|
||||
// Definitions by: Marco Gonzalez <https://github.com/marcogrcr>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
import * as e from "elasticsearch";
|
||||
import { Credentials } from "aws-sdk/lib/core";
|
||||
|
||||
declare module "elasticsearch" {
|
||||
interface AmazonESOptions {
|
||||
accessKey?: string;
|
||||
credentials?: Credentials;
|
||||
region: string;
|
||||
secretKey?: string;
|
||||
}
|
||||
|
||||
interface ConfigOptions {
|
||||
amazonES?: AmazonESOptions;
|
||||
}
|
||||
}
|
||||
|
||||
declare const HttpAmazonESConnector: any;
|
||||
export = HttpAmazonESConnector;
|
||||
5
types/http-aws-es/package.json
Normal file
5
types/http-aws-es/package.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"aws-sdk": "^2.7.0"
|
||||
}
|
||||
}
|
||||
22
types/http-aws-es/tsconfig.json
Normal file
22
types/http-aws-es/tsconfig.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"http-aws-es-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/http-aws-es/tslint.json
Normal file
1
types/http-aws-es/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
1
types/inert/index.d.ts
vendored
1
types/inert/index.d.ts
vendored
@@ -2,6 +2,7 @@
|
||||
// Project: https://github.com/hapijs/inert/
|
||||
// Definitions by: Steve Ognibene <http://github.com/nycdotnet>, AJP <https://github.com/AJamesPhillips>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
import * as hapi from 'hapi';
|
||||
|
||||
|
||||
7
types/jest-matchers/index.d.ts
vendored
Normal file
7
types/jest-matchers/index.d.ts
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
// Type definitions for jest-matchers 20.0
|
||||
// Project: https://github.com/facebook/jest#readme
|
||||
// Definitions by: Joscha Feth <https://github.com/joscha>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="jest" />
|
||||
export = expect;
|
||||
3
types/jest-matchers/jest-matchers-tests.ts
Normal file
3
types/jest-matchers/jest-matchers-tests.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import * as expect from 'jest-matchers';
|
||||
|
||||
expect('x').toEqual('x');
|
||||
22
types/jest-matchers/tsconfig.json
Normal file
22
types/jest-matchers/tsconfig.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"jest-matchers-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/jest-matchers/tslint.json
Normal file
1
types/jest-matchers/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
4
types/jquery.pnotify/index.d.ts
vendored
4
types/jquery.pnotify/index.d.ts
vendored
@@ -133,6 +133,10 @@ interface PNotifyOptions {
|
||||
* Whether to escape the content of the text. (Not allow HTML.)
|
||||
*/
|
||||
text_escape?: boolean;
|
||||
/**
|
||||
* Support for PNotifyconfirm options
|
||||
*/
|
||||
confirm?: PNotifyconfirm
|
||||
/**
|
||||
* What styling classes to use. (Can be either "brighttheme", "jqueryui", "bootstrap2", "bootstrap3", "fontawesome" or a custom style object)
|
||||
*/
|
||||
|
||||
6
types/jwt-decode/index.d.ts
vendored
6
types/jwt-decode/index.d.ts
vendored
@@ -1,12 +1,12 @@
|
||||
// Type definitions for jwt-decode v1.4.0
|
||||
// Type definitions for jwt-decode v2.2.0
|
||||
// Project: https://github.com/auth0/jwt-decode
|
||||
// Definitions by: Giedrius Grabauskas <https://github.com/QuatroDevOfficial/>
|
||||
// Definitions by: Giedrius Grabauskas <https://github.com/QuatroDevOfficial/>, Mads Madsen <https://github.com/madsmadsen>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
|
||||
declare namespace JwtDecode {
|
||||
interface JwtDecodeStatic {
|
||||
(token: string): any;
|
||||
(token: string, options?: { header: boolean }): any;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,4 +9,10 @@ interface TokenDto {
|
||||
iat: number;
|
||||
}
|
||||
|
||||
let decodedToken = jwtDecode(token) as TokenDto;
|
||||
interface TokenHeaderDto {
|
||||
typ: string;
|
||||
alg: string;
|
||||
}
|
||||
|
||||
let decodedTokenPayload = jwtDecode(token) as TokenDto;
|
||||
let decodedTokenHeader = jwtDecode(token, { header: true }) as TokenHeaderDto;
|
||||
131
types/massive/index.d.ts
vendored
131
types/massive/index.d.ts
vendored
@@ -1,105 +1,42 @@
|
||||
// Type definitions for massive-js 2.2
|
||||
// Project: https://github.com/robconery/massive-js
|
||||
// Type definitions for massive 3.x
|
||||
// Project: https://github.com/dmfay/massive-js.git
|
||||
// Definitions by: Pascal Birchler <https://github.com/swissspidy>
|
||||
// Clarence Ho <https://github.com/clarenceh>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
export namespace massive {
|
||||
interface ConnectionOptions {
|
||||
connectionString?: string;
|
||||
db?: string;
|
||||
}
|
||||
/// <reference types="node" />
|
||||
|
||||
interface Doc {
|
||||
findDoc(context: any, callback: ResultCallback): void;
|
||||
searchDoc(
|
||||
options: { keys: string[], term: string },
|
||||
callback: ResultCallback): void;
|
||||
saveDoc(context: string, callback: ResultCallback): void;
|
||||
destroy(context: any, callback: ResultCallback): void;
|
||||
}
|
||||
export = massive;
|
||||
|
||||
interface QueryFile {
|
||||
schema: string;
|
||||
name: string;
|
||||
db: Massive;
|
||||
delimitedName: string;
|
||||
delimitedSchema: string;
|
||||
fullname: string;
|
||||
delimitedFullName: string;
|
||||
sql: string;
|
||||
filePath: string;
|
||||
}
|
||||
declare function massive(
|
||||
connection: object | string,
|
||||
loaderConfig?: object,
|
||||
driverConfig?: object): Promise<massive.Database>;
|
||||
|
||||
interface QueryFunction {
|
||||
find(params: any|any[], callback: ResultCallback): void;
|
||||
}
|
||||
declare namespace massive {
|
||||
interface ConnectionInfo {
|
||||
user?: string;
|
||||
database?: string;
|
||||
password?: string | null;
|
||||
port?: number;
|
||||
host?: string;
|
||||
ssl?: boolean;
|
||||
application_name?: string;
|
||||
fallback_application_name?: boolean;
|
||||
}
|
||||
|
||||
interface QueryArguments {
|
||||
sql: string;
|
||||
options: any;
|
||||
params: any;
|
||||
next: ResultCallback;
|
||||
}
|
||||
interface Database {
|
||||
attach(ctor: any, ...sources: any[]): Promise<any>;
|
||||
detach(entity: string, collection: string): void;
|
||||
reload(): void;
|
||||
query(query: any, params: any, options: any): Promise<any>;
|
||||
saveDoc(collection: any, doc: any): any;
|
||||
createDocumentTable(path: any): Promise<any>;
|
||||
getObject(path: any, collection: any): object;
|
||||
dropTable(table: string, options: any): void;
|
||||
createSchema(schemaName: string): void;
|
||||
dropSchema(schemaName: string, options: any): void;
|
||||
[name: string]: any;
|
||||
}
|
||||
}
|
||||
|
||||
export interface Massive {
|
||||
custom: any;
|
||||
comment: Table;
|
||||
friendship: Table;
|
||||
participation: Table;
|
||||
person: Table;
|
||||
practice: Table;
|
||||
practicesession: Table;
|
||||
sport: Table;
|
||||
testdata(callback: ResultCallback): void;
|
||||
team: Table;
|
||||
teammember: Table;
|
||||
teamsport: Table;
|
||||
scriptsDir: string;
|
||||
connectionString: string;
|
||||
query(): void;
|
||||
stream(): void;
|
||||
executeSqlFile(args: any, next: ResultCallback): void;
|
||||
end(): void;
|
||||
tables: Array<massive.Doc|Table>;
|
||||
views: any[];
|
||||
queryFiles: massive.QueryFile[];
|
||||
schemas: any[];
|
||||
functions: any[];
|
||||
allowedSchemas: string;
|
||||
blacklist: string;
|
||||
exceptions: string;
|
||||
excludeFunctions: boolean;
|
||||
functionBlacklist: string;
|
||||
}
|
||||
|
||||
export type ResultCallback = (err: Error, res: any) => void;
|
||||
export type ConnectCallback = (err: Error, db: Massive) => void;
|
||||
|
||||
export interface QueryOptions {
|
||||
limit?: number;
|
||||
order?: string;
|
||||
offset?: number;
|
||||
columns?: string[];
|
||||
}
|
||||
|
||||
export interface Table {
|
||||
count(context: any, callback: ResultCallback): void;
|
||||
find(context: any, callback: ResultCallback): void;
|
||||
find(context: any, options: QueryOptions, callback: ResultCallback): void;
|
||||
findOne(context: any, callback: ResultCallback): void;
|
||||
findOne(context: any, options: QueryOptions, callback: ResultCallback): void;
|
||||
insert(context: any, callback: ResultCallback): void;
|
||||
save(context: any, callback: ResultCallback): void;
|
||||
update(context: any, callback: ResultCallback): void;
|
||||
update(context: any, data: any, callback: ResultCallback): void;
|
||||
destroy(context: any, callback: ResultCallback): void;
|
||||
}
|
||||
|
||||
export function connectSync(options: massive.ConnectionOptions): Massive;
|
||||
|
||||
export function connect(options: massive.ConnectionOptions, callback: ConnectCallback): void;
|
||||
|
||||
export function run(context: string, filter: number|number[], callback: ResultCallback): void;
|
||||
|
||||
export function saveDoc(name: string, data: any, callback: ResultCallback): void;
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
import * as Massive from 'massive';
|
||||
import massive = require('massive');
|
||||
|
||||
Massive.connect({connectionString: 'foo'}, (err: Error, db: Massive.Massive) => {});
|
||||
let dbconn: massive.Database;
|
||||
|
||||
Massive.run('foo', 123, (err: Error, db: Massive.Massive) => {});
|
||||
massive('postgres://app:password@localhost:5432/app').then( db => {
|
||||
console.log(`DB connected successfully`);
|
||||
dbconn = db;
|
||||
}).catch(err => {
|
||||
console.error(`Error connecting DB`);
|
||||
});
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es5"
|
||||
"es2015"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
@@ -19,4 +19,4 @@
|
||||
"index.d.ts",
|
||||
"massive-tests.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -319,8 +319,8 @@ class DeepDownTheTree extends React.Component<{} & {muiTheme: MuiTheme}, {}> {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const MuiThemeableFunction = muiThemeable()((props: {label: string, muiTheme?: MuiTheme}) => {
|
||||
type Props = { label: string, muiTheme?: MuiTheme };
|
||||
const MuiThemeableFunction = muiThemeable()<React.StatelessComponent<Props>, Props>(props => {
|
||||
return (
|
||||
<span style={{color: props.muiTheme.palette.textColor}}>
|
||||
Applied the Theme to functional component: {props.label}.
|
||||
|
||||
3
types/materialize-css/index.d.ts
vendored
3
types/materialize-css/index.d.ts
vendored
@@ -316,8 +316,9 @@ declare namespace Materialize {
|
||||
* The string function call that you want to make when the user scrolls to the threshold.
|
||||
* It will only be called once.
|
||||
* Example: 'console.log("hello, world!")';
|
||||
* or callback: () => { console.log('hello world'); }
|
||||
*/
|
||||
callback?: string;
|
||||
callback?: string | (() => void);
|
||||
}
|
||||
|
||||
interface TabOptions {
|
||||
|
||||
4
types/meteor/index.d.ts
vendored
4
types/meteor/index.d.ts
vendored
@@ -1511,6 +1511,8 @@ declare module Mongo {
|
||||
new (hexString?: string): ObjectID;
|
||||
}
|
||||
interface ObjectID { }
|
||||
|
||||
function setConnectionOptions(options: any): void;
|
||||
}
|
||||
|
||||
declare module "meteor/mongo" {
|
||||
@@ -1620,6 +1622,8 @@ declare module "meteor/mongo" {
|
||||
new (hexString?: string): ObjectID;
|
||||
}
|
||||
interface ObjectID { }
|
||||
|
||||
function setConnectionOptions(options: any): void;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
106
types/mongodb/index.d.ts
vendored
106
types/mongodb/index.d.ts
vendored
@@ -2,6 +2,7 @@
|
||||
// Project: https://github.com/mongodb/node-mongodb-native/tree/2.2
|
||||
// Definitions by: Federico Caselli <https://github.com/CaselIT>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
// Documentation : http://mongodb.github.io/node-mongodb-native/2.2/api/
|
||||
|
||||
@@ -47,12 +48,12 @@ export interface MongoClientOptions extends
|
||||
SocketOptions,
|
||||
SSLOptions,
|
||||
HighAvailabilityOptions {
|
||||
// The logging level (error/warn/info/debug)
|
||||
loggerLevel?: string;
|
||||
// Custom logger object
|
||||
logger?: Object;
|
||||
// Default: false;
|
||||
validateOptions?: Object;
|
||||
// The logging level (error/warn/info/debug)
|
||||
loggerLevel?: string;
|
||||
// Custom logger object
|
||||
logger?: Object;
|
||||
// Default: false;
|
||||
validateOptions?: Object;
|
||||
}
|
||||
|
||||
export interface SSLOptions {
|
||||
@@ -92,7 +93,7 @@ export class ReadPreference {
|
||||
constructor(mode: string, tags: Object);
|
||||
mode: string;
|
||||
tags: any;
|
||||
options: { maxStalenessSeconds?: number}; // Max Secondary Read Stalleness in Seconds
|
||||
options: { maxStalenessSeconds?: number }; // Max Secondary Read Stalleness in Seconds
|
||||
static PRIMARY: string;
|
||||
static PRIMARY_PREFERRED: string;
|
||||
static SECONDARY: string;
|
||||
@@ -104,7 +105,7 @@ export class ReadPreference {
|
||||
|
||||
// http://mongodb.github.io/node-mongodb-native/2.2/api/Db.html
|
||||
export interface DbCreateOptions {
|
||||
|
||||
|
||||
// If the database authentication is dependent on another databaseName.
|
||||
authSource?: string;
|
||||
// Default: null;https://docs.mongodb.com/manual/reference/write-concern/#write-concern
|
||||
@@ -169,14 +170,14 @@ export interface ServerOptions extends SSLOptions {
|
||||
}
|
||||
|
||||
// http://mongodb.github.io/node-mongodb-native/2.2/api/Mongos.html
|
||||
export interface MongosOptions extends SSLOptions, HighAvailabilityOptions{
|
||||
export interface MongosOptions extends SSLOptions, HighAvailabilityOptions {
|
||||
// Default: 15; Cutoff latency point in MS for MongoS proxy selection
|
||||
acceptableLatencyMS?: number;
|
||||
socketOptions?: SocketOptions;
|
||||
}
|
||||
|
||||
// http://mongodb.github.io/node-mongodb-native/2.2/api/ReplSet.html
|
||||
export interface ReplSetOptions extends SSLOptions, HighAvailabilityOptions {
|
||||
export interface ReplSetOptions extends SSLOptions, HighAvailabilityOptions {
|
||||
// The max staleness to secondary reads (values under 10 seconds cannot be guaranteed);
|
||||
maxStalenessSeconds?: number;
|
||||
// The name of the replicaset to connect to.
|
||||
@@ -214,20 +215,20 @@ export class Db extends EventEmitter {
|
||||
close(forceClose?: boolean): Promise<void>;
|
||||
close(forceClose: boolean, callback: MongoCallback<void>): void;
|
||||
// http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#collection
|
||||
collection(name: string): Collection;
|
||||
collection(name: string, callback: MongoCallback<Collection>): Collection;
|
||||
collection(name: string, options: DbCollectionOptions, callback: MongoCallback<Collection>): Collection;
|
||||
collection<TSchema = Default>(name: string): Collection<TSchema>;
|
||||
collection<TSchema = Default>(name: string, callback: MongoCallback<Collection<TSchema>>): Collection<TSchema>;
|
||||
collection<TSchema = Default>(name: string, options: DbCollectionOptions, callback: MongoCallback<Collection<TSchema>>): Collection<TSchema>;
|
||||
//http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#collections
|
||||
collections(): Promise<Collection[]>;
|
||||
collections(callback: MongoCallback<Collection[]>): void;
|
||||
collections(): Promise<Collection<Default>[]>;
|
||||
collections(callback: MongoCallback<Collection<Default>[]>): void;
|
||||
//http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#command
|
||||
command(command: Object, callback: MongoCallback<any>): void;
|
||||
command(command: Object, options?: { readPreference: ReadPreference | string }): Promise<any>;
|
||||
command(command: Object, options: { readPreference: ReadPreference | string }, callback: MongoCallback<any>): void;
|
||||
//http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#createCollection
|
||||
createCollection(name: string, callback: MongoCallback<Collection>): void;
|
||||
createCollection(name: string, options?: CollectionCreateOptions): Promise<Collection>;
|
||||
createCollection(name: string, options: CollectionCreateOptions, callback: MongoCallback<Collection>): void;
|
||||
createCollection<TSchema = Default>(name: string, callback: MongoCallback<Collection<TSchema>>): void;
|
||||
createCollection<TSchema = Default>(name: string, options?: CollectionCreateOptions): Promise<Collection<TSchema>>;
|
||||
createCollection<TSchema = Default>(name: string, options: CollectionCreateOptions, callback: MongoCallback<Collection<TSchema>>): void;
|
||||
//http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#createIndex
|
||||
createIndex(name: string, fieldOrSpec: string | Object, callback: MongoCallback<any>): void;
|
||||
createIndex(name: string, fieldOrSpec: string | Object, options?: IndexOptions): Promise<any>;
|
||||
@@ -269,9 +270,9 @@ export class Db extends EventEmitter {
|
||||
removeUser(username: string, options?: { w?: number | string, wtimeout?: number, j?: boolean }): Promise<any>;
|
||||
removeUser(username: string, options: { w?: number | string, wtimeout?: number, j?: boolean }, callback: MongoCallback<any>): void;
|
||||
// http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#renameCollection
|
||||
renameCollection(fromCollection: string, toCollection: string, callback: MongoCallback<Collection>): void;
|
||||
renameCollection(fromCollection: string, toCollection: string, options?: { dropTarget?: boolean }): Promise<Collection>;
|
||||
renameCollection(fromCollection: string, toCollection: string, options: { dropTarget?: boolean }, callback: MongoCallback<Collection>): void;
|
||||
renameCollection<TSchema = Default>(fromCollection: string, toCollection: string, callback: MongoCallback<Collection<TSchema>>): void;
|
||||
renameCollection<TSchema = Default>(fromCollection: string, toCollection: string, options?: { dropTarget?: boolean }): Promise<Collection<TSchema>>;
|
||||
renameCollection<TSchema = Default>(fromCollection: string, toCollection: string, options: { dropTarget?: boolean }, callback: MongoCallback<Collection<TSchema>>): void;
|
||||
//http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#stats
|
||||
stats(callback: MongoCallback<any>): void;
|
||||
stats(options?: { scale?: number }): Promise<any>;
|
||||
@@ -442,7 +443,7 @@ export interface FSyncOptions {
|
||||
}
|
||||
|
||||
// Documentation : http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html
|
||||
export interface Collection {
|
||||
export interface Collection<TSchema = Default> {
|
||||
// Get the collection name.
|
||||
collectionName: string;
|
||||
// Get the full collection namespace.
|
||||
@@ -454,10 +455,8 @@ export interface Collection {
|
||||
// Get current index hint for collection.
|
||||
hint: any;
|
||||
//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#aggregate
|
||||
aggregate(pipeline: Object[], callback: MongoCallback<any>): AggregationCursor<any>;
|
||||
aggregate(pipeline: Object[], options?: CollectionAggregationOptions, callback?: MongoCallback<any>): AggregationCursor<any>;
|
||||
aggregate<T>(pipeline: Object[], callback: MongoCallback<any>): AggregationCursor<T>;
|
||||
aggregate<T>(pipeline: Object[], options?: CollectionAggregationOptions, callback?: MongoCallback<any>): AggregationCursor<T>;
|
||||
aggregate<T = TSchema>(pipeline: Object[], callback: MongoCallback<T[]>): AggregationCursor<T>;
|
||||
aggregate<T = TSchema>(pipeline: Object[], options?: CollectionAggregationOptions, callback?: MongoCallback<T[]>): AggregationCursor<T>;
|
||||
//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#bulkWrite
|
||||
bulkWrite(operations: Object[], callback: MongoCallback<BulkWriteOpResultObject>): void;
|
||||
bulkWrite(operations: Object[], options?: CollectionBluckWriteOptions): Promise<BulkWriteOpResultObject>;
|
||||
@@ -496,26 +495,25 @@ export interface Collection {
|
||||
dropIndexes(): Promise<any>;
|
||||
dropIndexes(callback?: MongoCallback<any>): void;
|
||||
//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#find
|
||||
find(query?: Object): Cursor<any>;
|
||||
find<T>(query?: Object): Cursor<T>;
|
||||
find<T = TSchema>(query?: Object): Cursor<T>;
|
||||
/** @deprecated */
|
||||
find(query: Object, fields?: Object, skip?: number, limit?: number, timeout?: number): Cursor<any>;
|
||||
find<T = TSchema>(query: Object, fields?: Object, skip?: number, limit?: number, timeout?: number): Cursor<T>;
|
||||
//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#findOne
|
||||
findOne(filter: Object, callback: MongoCallback<any>): void;
|
||||
findOne(filter: Object, options?: FindOneOptions): Promise<any>;
|
||||
findOne(filter: Object, options: FindOneOptions, callback: MongoCallback<any>): void;
|
||||
findOne<T = TSchema>(filter: Object, callback: MongoCallback<T>): void;
|
||||
findOne<T = TSchema>(filter: Object, options?: FindOneOptions): Promise<T>;
|
||||
findOne<T = TSchema>(filter: Object, options: FindOneOptions, callback: MongoCallback<T>): void;
|
||||
//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#findOneAndDelete
|
||||
findOneAndDelete(filter: Object, callback: MongoCallback<FindAndModifyWriteOpResultObject>): void;
|
||||
findOneAndDelete(filter: Object, options?: { projection?: Object, sort?: Object, maxTimeMS?: number }): Promise<FindAndModifyWriteOpResultObject>;
|
||||
findOneAndDelete(filter: Object, options: { projection?: Object, sort?: Object, maxTimeMS?: number }, callback: MongoCallback<FindAndModifyWriteOpResultObject>): void;
|
||||
findOneAndDelete(filter: Object, callback: MongoCallback<FindAndModifyWriteOpResultObject<TSchema>>): void;
|
||||
findOneAndDelete(filter: Object, options?: { projection?: Object, sort?: Object, maxTimeMS?: number }): Promise<FindAndModifyWriteOpResultObject<TSchema>>;
|
||||
findOneAndDelete(filter: Object, options: { projection?: Object, sort?: Object, maxTimeMS?: number }, callback: MongoCallback<FindAndModifyWriteOpResultObject<TSchema>>): void;
|
||||
//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#findOneAndReplace
|
||||
findOneAndReplace(filter: Object, replacement: Object, callback: MongoCallback<FindAndModifyWriteOpResultObject>): void;
|
||||
findOneAndReplace(filter: Object, replacement: Object, options?: FindOneAndReplaceOption): Promise<FindAndModifyWriteOpResultObject>;
|
||||
findOneAndReplace(filter: Object, replacement: Object, options: FindOneAndReplaceOption, callback: MongoCallback<FindAndModifyWriteOpResultObject>): void;
|
||||
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;
|
||||
//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#findOneAndUpdate
|
||||
findOneAndUpdate(filter: Object, update: Object, callback: MongoCallback<FindAndModifyWriteOpResultObject>): void;
|
||||
findOneAndUpdate(filter: Object, update: Object, options?: FindOneAndReplaceOption): Promise<FindAndModifyWriteOpResultObject>;
|
||||
findOneAndUpdate(filter: Object, update: Object, options: FindOneAndReplaceOption, callback: MongoCallback<FindAndModifyWriteOpResultObject>): void;
|
||||
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;
|
||||
//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#geoHaystackSearch
|
||||
geoHaystackSearch(x: number, y: number, callback: MongoCallback<any>): void;
|
||||
geoHaystackSearch(x: number, y: number, options?: GeoHaystackSearchOptions): Promise<any>;
|
||||
@@ -584,9 +582,9 @@ export interface Collection {
|
||||
/** @deprecated Use use deleteOne, deleteMany or bulkWrite */
|
||||
remove(selector: Object, options?: CollectionOptions & { single?: boolean }, callback?: MongoCallback<WriteOpResult>): void;
|
||||
//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#rename
|
||||
rename(newName: string, callback: MongoCallback<Collection>): void;
|
||||
rename(newName: string, options?: { dropTarget?: boolean }): Promise<Collection>;
|
||||
rename(newName: string, options: { dropTarget?: boolean }, callback: MongoCallback<Collection>): void;
|
||||
rename(newName: string, callback: MongoCallback<Collection<TSchema>>): void;
|
||||
rename(newName: string, options?: { dropTarget?: boolean }): Promise<Collection<TSchema>>;
|
||||
rename(newName: string, options: { dropTarget?: boolean }, callback: MongoCallback<Collection<TSchema>>): void;
|
||||
//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#replaceOne
|
||||
replaceOne(filter: Object, doc: Object, callback: MongoCallback<UpdateWriteOpResult>): void;
|
||||
replaceOne(filter: Object, doc: Object, options?: ReplaceOneOptions): Promise<UpdateWriteOpResult>;
|
||||
@@ -743,9 +741,9 @@ export interface DeleteWriteOpResultObject {
|
||||
}
|
||||
|
||||
//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#~findAndModifyWriteOpResult
|
||||
export interface FindAndModifyWriteOpResultObject {
|
||||
export interface FindAndModifyWriteOpResultObject<TSchema = Default> {
|
||||
//Document returned from findAndModify command.
|
||||
value?: any;
|
||||
value?: TSchema;
|
||||
//The raw lastErrorObject returned from the command.
|
||||
lastErrorObject?: any;
|
||||
//Is 1 if the command executed correctly.
|
||||
@@ -996,8 +994,10 @@ export interface WriteOpResult {
|
||||
//http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#~resultCallback
|
||||
export type CursorResult = any | void | boolean;
|
||||
|
||||
type Default = { [key: string]: any };
|
||||
|
||||
//http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html
|
||||
export class Cursor<T> extends Readable {
|
||||
export class Cursor<T = Default> extends Readable {
|
||||
|
||||
sortValue: string;
|
||||
timeout: boolean;
|
||||
@@ -1048,8 +1048,8 @@ export class Cursor<T> extends Readable {
|
||||
// http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#min
|
||||
min(min: number): Cursor<T>;
|
||||
// http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#next
|
||||
next(): Promise<CursorResult>;
|
||||
next(callback: MongoCallback<CursorResult>): void;
|
||||
next(): Promise<T>;
|
||||
next(callback: MongoCallback<T>): void;
|
||||
//http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#project
|
||||
project(value: Object): Cursor<T>;
|
||||
//http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#read
|
||||
@@ -1101,7 +1101,7 @@ export interface EndCallback {
|
||||
//http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#~resultCallback
|
||||
export type AggregationCursorResult = any | void;
|
||||
//http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html
|
||||
export class AggregationCursor<T> extends Readable {
|
||||
export class AggregationCursor<T = Default> extends Readable {
|
||||
// http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#batchSize
|
||||
batchSize(value: number): AggregationCursor<T>;
|
||||
// http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#clone
|
||||
@@ -1127,8 +1127,8 @@ export class AggregationCursor<T> extends Readable {
|
||||
// http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#maxTimeMS
|
||||
maxTimeMS(value: number): AggregationCursor<T>;
|
||||
// http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#next
|
||||
next(): Promise<AggregationCursorResult>;
|
||||
next(callback: MongoCallback<AggregationCursorResult>): void;
|
||||
next(): Promise<T>;
|
||||
next(callback: MongoCallback<T>): void;
|
||||
// http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#out
|
||||
out(destination: string): AggregationCursor<T>;
|
||||
//http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#project
|
||||
@@ -1237,7 +1237,7 @@ export interface GridFSBucketOpenUploadStreamOptions {
|
||||
|
||||
// https://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucketReadStream.html
|
||||
export class GridFSBucketReadStream extends Readable {
|
||||
constructor(chunks: Collection, files: Collection, readPreference: Object, filter: Object, options?: GridFSBucketReadStreamOptions);
|
||||
constructor(chunks: Collection<any>, files: Collection<any>, readPreference: Object, filter: Object, options?: GridFSBucketReadStreamOptions);
|
||||
}
|
||||
|
||||
// https://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucketReadStream.html
|
||||
|
||||
@@ -53,7 +53,7 @@ let options = {
|
||||
});
|
||||
|
||||
{
|
||||
let cursor: mongodb.Cursor <any>;
|
||||
let cursor: mongodb.Cursor;
|
||||
cursor = collection.find();
|
||||
cursor = cursor.addCursorFlag('',true);
|
||||
cursor = cursor.addQueryModifier('',true);
|
||||
@@ -81,14 +81,16 @@ let options = {
|
||||
// Collection .findM<T>() & .agggregate<T>() generic tests
|
||||
{
|
||||
let bag : {cost: number, color: string};
|
||||
type bag = typeof bag;
|
||||
type bag = typeof bag;
|
||||
let cursor: mongodb.Cursor<bag> = collection.find<bag>({color: 'black'})
|
||||
cursor.toArray(function (err,r) { r[0].cost} );
|
||||
cursor.forEach(function (bag ) { bag.color }, () => {});
|
||||
collection.findOne({ color: 'white' }).then(() => { })
|
||||
collection.findOne<bag>({ color: 'white' }).then(b => { b.cost; })
|
||||
}
|
||||
{
|
||||
let payment: {total: number};
|
||||
type payment = typeof payment;
|
||||
type payment = typeof payment;
|
||||
let cursor: mongodb.AggregationCursor<payment> = collection.aggregate<payment>([{}])
|
||||
}
|
||||
})
|
||||
|
||||
2
types/mongoose-auto-increment/index.d.ts
vendored
2
types/mongoose-auto-increment/index.d.ts
vendored
@@ -2,7 +2,7 @@
|
||||
// Project: https://github.com/codetunnel/mongoose-auto-increment
|
||||
// Definitions by: Aya Morisawa <https://github.com/AyaMorisawa>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
import { Connection, Schema, Mongoose } from 'mongoose';
|
||||
|
||||
|
||||
2
types/mongoose-deep-populate/index.d.ts
vendored
2
types/mongoose-deep-populate/index.d.ts
vendored
@@ -2,7 +2,7 @@
|
||||
// Project: https://github.com/buunguyen/mongoose-deep-populate
|
||||
// Definitions by: Aya Morisawa <https://github.com/AyaMorisawa>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
import { Mongoose, Schema } from 'mongoose';
|
||||
|
||||
|
||||
2
types/mongoose-mock/index.d.ts
vendored
2
types/mongoose-mock/index.d.ts
vendored
@@ -2,7 +2,7 @@
|
||||
// Project: https://github.com/JohanObrink/mongoose-mock
|
||||
// Definitions by: jt000 <https://github.com/jt000>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
import mongoose = require('mongoose');
|
||||
|
||||
|
||||
1
types/mongoose-paginate/index.d.ts
vendored
1
types/mongoose-paginate/index.d.ts
vendored
@@ -2,6 +2,7 @@
|
||||
// Project: https://github.com/edwardhotchkiss/mongoose-paginate
|
||||
// Definitions by: Linus Brolin <https://github.com/linusbrolin/>, simonxca <https://github.com/simonxca/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
/// <reference types="mongoose" />
|
||||
|
||||
|
||||
1
types/mongoose-promise/index.d.ts
vendored
1
types/mongoose-promise/index.d.ts
vendored
@@ -2,6 +2,7 @@
|
||||
// Project: http://mongoosejs.com/
|
||||
// Definitions by: simonxca <https://github.com/simonxca/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
/// <reference types="mongoose" />
|
||||
/// <reference types="mpromise" />
|
||||
|
||||
1
types/mongoose-sequence/index.d.ts
vendored
1
types/mongoose-sequence/index.d.ts
vendored
@@ -2,6 +2,7 @@
|
||||
// Project: https://github.com/ramiel/mongoose-sequence
|
||||
// Definitions by: Linus Brolin <https://github.com/linusbrolin/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
/// <reference types="mongoose" />
|
||||
|
||||
|
||||
60
types/mongoose/index.d.ts
vendored
60
types/mongoose/index.d.ts
vendored
@@ -2,7 +2,7 @@
|
||||
// Project: http://mongoosejs.com/
|
||||
// Definitions by: simonxca <https://github.com/simonxca/>, horiuchi <https://github.com/horiuchi/>, sindrenm <https://github.com/sindrenm>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
/// <reference types="mongodb" />
|
||||
/// <reference types="node" />
|
||||
@@ -1476,33 +1476,33 @@ declare module "mongoose" {
|
||||
* @param criteria mongodb selector
|
||||
* @param projection optional fields to return
|
||||
*/
|
||||
findOne(callback?: (err: any, res: DocType) => void): DocumentQuery<DocType, DocType>;
|
||||
findOne(callback?: (err: any, res: DocType | null) => void): DocumentQuery<DocType | null, DocType>;
|
||||
findOne(criteria: Object,
|
||||
callback?: (err: any, res: DocType) => void): DocumentQuery<DocType, DocType>;
|
||||
callback?: (err: any, res: DocType | null) => void): DocumentQuery<DocType | null, DocType>;
|
||||
|
||||
/**
|
||||
* Issues a mongodb findAndModify remove command.
|
||||
* Finds a matching document, removes it, passing the found document (if any) to the
|
||||
* callback. Executes immediately if callback is passed.
|
||||
*/
|
||||
findOneAndRemove(callback?: (error: any, doc: DocType, result: any) => void): DocumentQuery<DocType, DocType>;
|
||||
findOneAndRemove(callback?: (error: any, doc: DocType | null, result: any) => void): DocumentQuery<DocType | null, DocType>;
|
||||
findOneAndRemove(conditions: Object,
|
||||
callback?: (error: any, doc: DocType, result: any) => void): DocumentQuery<DocType, DocType>;
|
||||
callback?: (error: any, doc: DocType | null, result: any) => void): DocumentQuery<DocType | null, DocType>;
|
||||
findOneAndRemove(conditions: Object, options: QueryFindOneAndRemoveOptions,
|
||||
callback?: (error: any, doc: DocType, result: any) => void): DocumentQuery<DocType, DocType>;
|
||||
callback?: (error: any, doc: DocType | null, result: any) => void): DocumentQuery<DocType | null, DocType>;
|
||||
|
||||
/**
|
||||
* Issues a mongodb findAndModify update command.
|
||||
* Finds a matching document, updates it according to the update arg, passing any options, and returns
|
||||
* the found document (if any) to the callback. The query executes immediately if callback is passed.
|
||||
*/
|
||||
findOneAndUpdate(callback?: (err: any, doc: DocType) => void): DocumentQuery<DocType, DocType>;
|
||||
findOneAndUpdate(callback?: (err: any, doc: DocType | null) => void): DocumentQuery<DocType | null, DocType>;
|
||||
findOneAndUpdate(update: Object,
|
||||
callback?: (err: any, doc: DocType) => void): DocumentQuery<DocType, DocType>;
|
||||
callback?: (err: any, doc: DocType | null) => void): DocumentQuery<DocType | null, DocType>;
|
||||
findOneAndUpdate(query: Object | Query<any>, update: Object,
|
||||
callback?: (err: any, doc: DocType) => void): DocumentQuery<DocType, DocType>;
|
||||
callback?: (err: any, doc: DocType | null) => void): DocumentQuery<DocType | null, DocType>;
|
||||
findOneAndUpdate(query: Object | Query<any>, update: Object, options: QueryFindOneAndUpdateOptions,
|
||||
callback?: (err: any, doc: DocType) => void): DocumentQuery<DocType, DocType>;
|
||||
callback?: (err: any, doc: DocType | null) => void): DocumentQuery<DocType | null, DocType>;
|
||||
|
||||
/**
|
||||
* Specifies a $geometry condition. geometry() must come after either intersects() or within().
|
||||
@@ -2334,11 +2334,11 @@ declare module "mongoose" {
|
||||
* @param projection optional fields to return
|
||||
*/
|
||||
findById(id: Object | string | number,
|
||||
callback?: (err: any, res: T) => void): DocumentQuery<T, T>;
|
||||
callback?: (err: any, res: T | null) => void): DocumentQuery<T | null, T>;
|
||||
findById(id: Object | string | number, projection: Object,
|
||||
callback?: (err: any, res: T) => void): DocumentQuery<T, T>;
|
||||
callback?: (err: any, res: T | null) => void): DocumentQuery<T | null, T>;
|
||||
findById(id: Object | string | number, projection: Object, options: Object,
|
||||
callback?: (err: any, res: T) => void): DocumentQuery<T, T>;
|
||||
callback?: (err: any, res: T | null) => void): DocumentQuery<T | null, T>;
|
||||
|
||||
model(name: string): Model<T>;
|
||||
|
||||
@@ -2395,9 +2395,9 @@ declare module "mongoose" {
|
||||
*/
|
||||
find(callback?: (err: any, res: T[]) => void): DocumentQuery<T[], T>;
|
||||
find(conditions: Object, callback?: (err: any, res: T[]) => void): DocumentQuery<T[], T>;
|
||||
find(conditions: Object, projection: Object,
|
||||
find(conditions: Object, projection?: Object | null,
|
||||
callback?: (err: any, res: T[]) => void): DocumentQuery<T[], T>;
|
||||
find(conditions: Object, projection: Object, options: Object,
|
||||
find(conditions: Object, projection?: Object | null, options?: Object | null,
|
||||
callback?: (err: any, res: T[]) => void): DocumentQuery<T[], T>;
|
||||
|
||||
|
||||
@@ -2409,27 +2409,27 @@ declare module "mongoose" {
|
||||
* Executes immediately if callback is passed, else a Query object is returned.
|
||||
* @param id value of _id to query by
|
||||
*/
|
||||
findByIdAndRemove(): DocumentQuery<T, T>;
|
||||
findByIdAndRemove(): DocumentQuery<T | null, T>;
|
||||
findByIdAndRemove(id: Object | number | string,
|
||||
callback?: (err: any, res: T) => void): DocumentQuery<T, T>;
|
||||
callback?: (err: any, res: T | null) => void): DocumentQuery<T | null, T>;
|
||||
findByIdAndRemove(id: Object | number | string, options: {
|
||||
/** if multiple docs are found by the conditions, sets the sort order to choose which doc to update */
|
||||
sort?: Object;
|
||||
/** sets the document fields to return */
|
||||
select?: Object;
|
||||
}, callback?: (err: any, res: T) => void): DocumentQuery<T, T>;
|
||||
}, callback?: (err: any, res: T | null) => void): DocumentQuery<T | null, T>;
|
||||
|
||||
/**
|
||||
* Issues a mongodb findAndModify update command by a document's _id field. findByIdAndUpdate(id, ...)
|
||||
* is equivalent to findOneAndUpdate({ _id: id }, ...).
|
||||
* @param id value of _id to query by
|
||||
*/
|
||||
findByIdAndUpdate(): DocumentQuery<T, T>;
|
||||
findByIdAndUpdate(): DocumentQuery<T | null, T>;
|
||||
findByIdAndUpdate(id: Object | number | string, update: Object,
|
||||
callback?: (err: any, res: T) => void): DocumentQuery<T, T>;
|
||||
callback?: (err: any, res: T | null) => void): DocumentQuery<T | null, T>;
|
||||
findByIdAndUpdate(id: Object | number | string, update: Object,
|
||||
options: ModelFindByIdAndUpdateOptions,
|
||||
callback?: (err: any, res: T) => void): DocumentQuery<T, T>;
|
||||
callback?: (err: any, res: T | null) => void): DocumentQuery<T | null, T>;
|
||||
|
||||
/**
|
||||
* Finds one document.
|
||||
@@ -2437,20 +2437,20 @@ declare module "mongoose" {
|
||||
* @param projection optional fields to return
|
||||
*/
|
||||
findOne(conditions?: Object,
|
||||
callback?: (err: any, res: T) => void): DocumentQuery<T, T>;
|
||||
callback?: (err: any, res: T | null) => void): DocumentQuery<T | null, T>;
|
||||
findOne(conditions: Object, projection: Object,
|
||||
callback?: (err: any, res: T) => void): DocumentQuery<T, T>;
|
||||
callback?: (err: any, res: T | null) => void): DocumentQuery<T | null, T>;
|
||||
findOne(conditions: Object, projection: Object, options: Object,
|
||||
callback?: (err: any, res: T) => void): DocumentQuery<T, T>;
|
||||
callback?: (err: any, res: T | null) => void): DocumentQuery<T | null, T>;
|
||||
|
||||
/**
|
||||
* Issue a mongodb findAndModify remove command.
|
||||
* Finds a matching document, removes it, passing the found document (if any) to the callback.
|
||||
* Executes immediately if callback is passed else a Query object is returned.
|
||||
*/
|
||||
findOneAndRemove(): DocumentQuery<T, T>;
|
||||
findOneAndRemove(): DocumentQuery<T | null, T>;
|
||||
findOneAndRemove(conditions: Object,
|
||||
callback?: (err: any, res: T) => void): DocumentQuery<T, T>;
|
||||
callback?: (err: any, res: T | null) => void): DocumentQuery<T | null, T>;
|
||||
findOneAndRemove(conditions: Object, options: {
|
||||
/**
|
||||
* if multiple docs are found by the conditions, sets the sort order to choose
|
||||
@@ -2461,7 +2461,7 @@ declare module "mongoose" {
|
||||
maxTimeMS?: number;
|
||||
/** sets the document fields to return */
|
||||
select?: Object;
|
||||
}, callback?: (err: any, res: T) => void): DocumentQuery<T, T>;
|
||||
}, callback?: (err: any, res: T | null) => void): DocumentQuery<T | null, T>;
|
||||
|
||||
/**
|
||||
* Issues a mongodb findAndModify update command.
|
||||
@@ -2469,12 +2469,12 @@ declare module "mongoose" {
|
||||
* and returns the found document (if any) to the callback. The query executes immediately
|
||||
* if callback is passed else a Query object is returned.
|
||||
*/
|
||||
findOneAndUpdate(): DocumentQuery<T, T>;
|
||||
findOneAndUpdate(): DocumentQuery<T | null, T>;
|
||||
findOneAndUpdate(conditions: Object, update: Object,
|
||||
callback?: (err: any, res: T) => void): DocumentQuery<T, T>;
|
||||
callback?: (err: any, res: T | null) => void): DocumentQuery<T | null, T>;
|
||||
findOneAndUpdate(conditions: Object, update: Object,
|
||||
options: ModelFindOneAndUpdateOptions,
|
||||
callback?: (err: any, res: T) => void): DocumentQuery<T, T>;
|
||||
callback?: (err: any, res: T | null) => void): DocumentQuery<T | null, T>;
|
||||
|
||||
/**
|
||||
* geoNear support for Mongoose
|
||||
|
||||
@@ -71,7 +71,7 @@ mongoose.version.toLowerCase();
|
||||
* section querystream.js
|
||||
* http://mongoosejs.com/docs/api.html#querystream-js
|
||||
*/
|
||||
var querystream: mongoose.QueryStream;
|
||||
var querystream = <mongoose.QueryStream> {};
|
||||
querystream.destroy(new Error());
|
||||
querystream.pause();
|
||||
querystream.pipe(process.stdout, {end: true}).end();
|
||||
@@ -81,7 +81,7 @@ querystream.readable;
|
||||
/* inherited properties */
|
||||
querystream.getMaxListeners();
|
||||
/* practical examples */
|
||||
var QSModel: typeof mongoose.Model;
|
||||
var QSModel = <typeof mongoose.Model> {};
|
||||
var QSStream: mongoose.QueryStream = QSModel.find().stream();
|
||||
QSStream.on('data', function (doc: any) {
|
||||
doc.save();
|
||||
@@ -97,7 +97,7 @@ QSModel.where('created').gte(20000).stream().pipe(process.stdout);
|
||||
* section drivers/node-mongodb-native/collection.js
|
||||
* http://mongoosejs.com/docs/api.html#drivers-node-mongodb-native-collection-js
|
||||
*/
|
||||
var coll1: mongoose.Collection;
|
||||
var coll1 = <mongoose.Collection> {};
|
||||
coll1.$format(999).toLowerCase();
|
||||
coll1.$print('name', 'i', [1, 2, 3]);
|
||||
coll1.getIndexes();
|
||||
@@ -109,7 +109,7 @@ coll1.ensureIndex();
|
||||
coll1.find({});
|
||||
coll1.insert({}, {});
|
||||
|
||||
var coll2 = new mongoose.Collection('', new mongoose.Connection(null));
|
||||
var coll2 = new mongoose.Collection('', new mongoose.Connection(mongoose));
|
||||
coll2.$format(999).toLowerCase();
|
||||
/* inherited properties */
|
||||
coll2.initializeOrderedBulkOp;
|
||||
@@ -155,7 +155,7 @@ conn1.addListener('close', cb);
|
||||
* section error/validation.js
|
||||
* http://mongoosejs.com/docs/api.html#error-validation-js
|
||||
*/
|
||||
var validationError: mongoose.ValidationError;
|
||||
var validationError = <mongoose.ValidationError> {};
|
||||
validationError.toString().toLowerCase();
|
||||
/* inherited properties */
|
||||
validationError.stack;
|
||||
@@ -178,7 +178,7 @@ mongoose.Error.Messages.hasOwnProperty('');
|
||||
* section querycursor.js
|
||||
* http://mongoosejs.com/docs/api.html#querycursor-js
|
||||
*/
|
||||
var querycursor: mongoose.QueryCursor<any>;
|
||||
var querycursor = <mongoose.QueryCursor<any>> {};
|
||||
querycursor.close(function (error, result) {
|
||||
result.execPopulate();
|
||||
}).catch(cb);
|
||||
@@ -267,8 +267,10 @@ schema.method('name', cb).method({
|
||||
schema.path('a', mongoose.Schema.Types.Buffer).path('a');
|
||||
schema.pathType('m1').toLowerCase();
|
||||
schema.plugin(function (schema, opts) {
|
||||
schema.get('path');
|
||||
opts.hasOwnProperty('');
|
||||
schema.get('path');
|
||||
if (opts) {
|
||||
opts.hasOwnProperty('');
|
||||
}
|
||||
}).plugin(cb, {opts: true});
|
||||
|
||||
schema
|
||||
@@ -426,7 +428,7 @@ new mongoose.Schema({
|
||||
* section document.js
|
||||
* http://mongoosejs.com/docs/api.html#document-js
|
||||
*/
|
||||
var doc: mongoose.MongooseDocument;
|
||||
var doc = <mongoose.MongooseDocument> {};
|
||||
doc.$isDefault('path').valueOf();
|
||||
doc.depopulate('path');
|
||||
doc.equals(doc).valueOf();
|
||||
@@ -483,7 +485,9 @@ var MyModel = mongoose.model('test', new mongoose.Schema({
|
||||
doc = new MyModel();
|
||||
doc.$isDefault('name');
|
||||
MyModel.findOne().populate('author').exec(function (err, doc) {
|
||||
doc.depopulate('author');
|
||||
if (doc) {
|
||||
doc.depopulate('author');
|
||||
}
|
||||
});
|
||||
doc.populate('path');
|
||||
doc.populate({path: 'hello'});
|
||||
@@ -540,7 +544,7 @@ interface MySubEntity extends mongoose.Types.Subdocument {
|
||||
interface MyEntity extends mongoose.Document {
|
||||
sub: mongoose.Types.Array<MySubEntity>
|
||||
}
|
||||
var myEntity: MyEntity;
|
||||
var myEntity = <MyEntity> {};
|
||||
var subDocArray = _.filter(myEntity.sub, function (sd) {
|
||||
sd.property1;
|
||||
sd.property2.toLowerCase();
|
||||
@@ -570,7 +574,7 @@ interface MySubEntity1 extends mongoose.Types.Subdocument {
|
||||
interface MyEntity1 extends mongoose.Document {
|
||||
sub: mongoose.Types.DocumentArray<MySubEntity>
|
||||
}
|
||||
var newEnt: MyEntity1;
|
||||
var newEnt = <MyEntity1> {};
|
||||
var newSub: MySubEntity1 = newEnt.sub.create({ property1: "example", property2: "example" });
|
||||
|
||||
/*
|
||||
@@ -645,7 +649,7 @@ embeddedDocument.execPopulate();
|
||||
* section query.js
|
||||
* http://mongoosejs.com/docs/api.html#query-js
|
||||
*/
|
||||
var query: mongoose.Query<mongoose.MongooseDocument[]>;
|
||||
var query = <mongoose.Query<mongoose.MongooseDocument[]>> {};
|
||||
query.$where('').$where(cb);
|
||||
query.all(99).all('path', 99);
|
||||
query.and([{ color: 'green' }, { status: 'ok' }]).and([]);
|
||||
@@ -877,7 +881,7 @@ schemaArray.sparse(true);
|
||||
* section schema/string.js
|
||||
* http://mongoosejs.com/docs/api.html#schema-string-js
|
||||
*/
|
||||
var MongoDocument: mongoose.Document;
|
||||
var MongoDocument = <mongoose.Document> {};
|
||||
var schemastring: mongoose.Schema.Types.String = new mongoose.Schema.Types.String('hello');
|
||||
schemastring.checkRequired(234, MongoDocument).valueOf();
|
||||
schemastring.enum(['hi', 'a', 'b']).enum('hi').enum({});
|
||||
@@ -1161,7 +1165,9 @@ mongoose.model('')
|
||||
.findOne({})
|
||||
.exec()
|
||||
.then(function (arg) {
|
||||
arg.save;
|
||||
if (arg) {
|
||||
arg.save;
|
||||
}
|
||||
return 1;
|
||||
}).then(function (num) {
|
||||
num.toFixed;
|
||||
@@ -1172,7 +1178,9 @@ mongoose.model('')
|
||||
str.toLowerCase
|
||||
return (mongoose.model('')).findOne({}).exec();
|
||||
}).then(function (arg) {
|
||||
arg.save;
|
||||
if (arg) {
|
||||
arg.save;
|
||||
}
|
||||
return 1;
|
||||
}).catch(function (err) {
|
||||
return 1;
|
||||
@@ -1188,7 +1196,9 @@ mongoose.model('')
|
||||
|
||||
mongoose.model('').findOne({})
|
||||
.then(function (arg) {
|
||||
arg.save;
|
||||
if (arg) {
|
||||
arg.save;
|
||||
}
|
||||
return 2;
|
||||
}).then(function (num) {
|
||||
num.toFixed;
|
||||
@@ -1237,6 +1247,9 @@ MongoModel.find({}).$where('indexOf("val") !== -1').exec(function (err, docs) {
|
||||
});
|
||||
MongoModel.findById(999, function (err, doc) {
|
||||
var handleSave = function(err: Error, product: mongoose.Document, numAffected: number) {};
|
||||
if (!doc) {
|
||||
return;
|
||||
}
|
||||
doc.increment();
|
||||
doc.save(handleSave).then(cb).catch(cb);
|
||||
doc.save({ validateBeforeSave: false }, handleSave).then(cb).catch(cb);
|
||||
@@ -1256,7 +1269,9 @@ var mongoModel = new MongoModel();
|
||||
mongoModel.remove(function (err, product) {
|
||||
if (err) throw(err);
|
||||
MongoModel.findById(product._id, function (err, product) {
|
||||
product.remove();
|
||||
if (product) {
|
||||
product.remove();
|
||||
}
|
||||
});
|
||||
});
|
||||
mongoModel.save().then(function (product) {
|
||||
@@ -1304,11 +1319,15 @@ MongoModel.find({ name: /john/i }, null, { skip: 10 }).exec(function (err, docs)
|
||||
MongoModel.findById(999, function (err, adventure) {});
|
||||
MongoModel.findById(999).exec(cb);
|
||||
MongoModel.findById(999, 'name length', function (err, adventure) {
|
||||
adventure.save();
|
||||
if (adventure) {
|
||||
adventure.save();
|
||||
}
|
||||
});
|
||||
MongoModel.findById(999, 'name length').exec(cb);
|
||||
MongoModel.findById(999, '-length').exec(function (err, adventure) {
|
||||
adventure.addListener('click', cb);
|
||||
if (adventure) {
|
||||
adventure.addListener('click', cb);
|
||||
}
|
||||
});
|
||||
MongoModel.findById(999, 'name', { lean: true }, function (err, doc) {});
|
||||
MongoModel.findById(999, 'name').lean().exec(function (err, doc) {});
|
||||
@@ -1372,6 +1391,9 @@ MongoModel.mapReduce({
|
||||
console.log(docs);
|
||||
}).then(null, cb);
|
||||
MongoModel.findById(999, function (err, user) {
|
||||
if (!user) {
|
||||
return;
|
||||
}
|
||||
var opts = [
|
||||
{ path: 'company', match: { x: 1 }, select: 'name' }
|
||||
, { path: 'notes', options: { limit: 10 }, model: 'override' }
|
||||
@@ -1425,7 +1447,9 @@ mongoModel.addListener('event', cb);
|
||||
MongoModel.findOne({ title: /timex/i })
|
||||
.populate('_creator', 'name')
|
||||
.exec(function (err, story) {
|
||||
story.execPopulate();
|
||||
if (story) {
|
||||
story.execPopulate();
|
||||
}
|
||||
});
|
||||
MongoModel.find({
|
||||
id: 999
|
||||
@@ -1460,6 +1484,9 @@ var LocModel = mongoose.model<Location>("Location", locationSchema);
|
||||
LocModel.findById(999)
|
||||
.select("-reviews -rating")
|
||||
.exec(function (err, location) {
|
||||
if (!location) {
|
||||
return;
|
||||
}
|
||||
location.name = 'blah';
|
||||
location.address = 'blah';
|
||||
location.reviews.forEach(review => {});
|
||||
@@ -1496,18 +1523,35 @@ LocModel.distinct('')
|
||||
.then(cb).catch(cb);
|
||||
LocModel.findByIdAndRemove()
|
||||
.exec(function (err, doc) {
|
||||
if (!doc) {
|
||||
return;
|
||||
}
|
||||
doc.addListener;
|
||||
doc.openingTimes;
|
||||
});
|
||||
LocModel.findByIdAndUpdate()
|
||||
.select({})
|
||||
.exec(function (err, location) {
|
||||
location.reviews;
|
||||
if (location) {
|
||||
location.reviews;
|
||||
}
|
||||
});
|
||||
LocModel.findOne({}, function (err, doc) { doc.openingTimes; });
|
||||
LocModel.findOne({}, function (err, doc) {
|
||||
if (doc) {
|
||||
doc.openingTimes;
|
||||
}
|
||||
});
|
||||
LocModel.findOneAndRemove()
|
||||
.exec(function (err, location) { location.name; });
|
||||
LocModel.findOneAndUpdate().exec().then(function (arg) { arg.openingTimes; });
|
||||
.exec(function (err, location) {
|
||||
if (location) {
|
||||
location.name;
|
||||
}
|
||||
});
|
||||
LocModel.findOneAndUpdate().exec().then(function (arg) {
|
||||
if (arg) {
|
||||
arg.openingTimes;
|
||||
}
|
||||
});
|
||||
LocModel.geoSearch({}, {
|
||||
near: [1, 2],
|
||||
maxDistance: 22
|
||||
@@ -1528,7 +1572,7 @@ interface ModelStruct {
|
||||
model: MyModel;
|
||||
method1: (callback: (model: MyModel, doc: MyDocument) => void) => MyModel;
|
||||
}
|
||||
var modelStruct1: ModelStruct;
|
||||
var modelStruct1 = <ModelStruct> {};
|
||||
var myModel1: MyModel;
|
||||
var myDocument1: MyDocument;
|
||||
modelStruct1.method1(function (myModel1, myDocument1) {
|
||||
@@ -1555,8 +1599,8 @@ final2.method;interface ibase extends mongoose.Document {
|
||||
interface extended extends ibase {
|
||||
email: string;
|
||||
}
|
||||
const base: mongoose.Model<ibase> = mongoose.model<ibase>('testfour', null)
|
||||
const extended: mongoose.Model<extended> = base.discriminator<extended>('extendedS', null);
|
||||
const base: mongoose.Model<ibase> = mongoose.model<ibase>('testfour')
|
||||
const extended: mongoose.Model<extended> = base.discriminator<extended>('extendedS', schema);
|
||||
const x = new extended({
|
||||
username: 'hi', // required in baseSchema
|
||||
email: 'beddiw', // required in extededSchema
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": false,
|
||||
"strictNullChecks": false,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
|
||||
2
types/moxios/index.d.ts
vendored
2
types/moxios/index.d.ts
vendored
@@ -189,4 +189,4 @@ declare let moxios: {
|
||||
wait(fn: () => void, delay?: number): void;
|
||||
};
|
||||
|
||||
export default moxios;
|
||||
export = moxios;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// from https://github.com/mzabriskie/moxios/blob/master/test.js
|
||||
import {equal, notEqual, deepEqual} from 'power-assert'; // compatible with 'assert';
|
||||
import axios from 'axios';
|
||||
import moxios from 'moxios';
|
||||
import * as moxios from 'moxios';
|
||||
|
||||
declare const sinon: any;
|
||||
declare const describe: any;
|
||||
|
||||
12
types/multiplexjs/index.d.ts
vendored
12
types/multiplexjs/index.d.ts
vendored
@@ -448,9 +448,9 @@ declare namespace multiplex {
|
||||
|
||||
/**
|
||||
* Performs the specified action on each element of the List.
|
||||
* @param action The action function to perform on each element of the List.
|
||||
* @param action The action function to perform on each element of an List; the second parameter of the function represents the index of the source element.
|
||||
*/
|
||||
forEach(action: (item: T) => void): void
|
||||
forEach(action: (item: T, index: number) => void): void
|
||||
|
||||
|
||||
/**
|
||||
@@ -1741,14 +1741,6 @@ declare namespace multiplex {
|
||||
*/
|
||||
firstOrDefault(predicate: (item: T) => boolean, defaultValue: T): T
|
||||
|
||||
|
||||
/**
|
||||
* Performs the specified action on each element of an Enumerable.
|
||||
* @param action The action function to perform on each element of an Enumerable.
|
||||
*/
|
||||
forEach(action: (item: T) => void): void
|
||||
|
||||
|
||||
/**
|
||||
* Performs the specified action on each element of an Enumerable.
|
||||
* @param action The action function to perform on each element of an Enumerable; the second parameter of the function represents the index of the source element.
|
||||
|
||||
1
types/nes/index.d.ts
vendored
1
types/nes/index.d.ts
vendored
@@ -2,6 +2,7 @@
|
||||
// Project: https://github.com/hapijs/nes
|
||||
// Definitions by: Ivo Stratev <https://github.com/NoHomey>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
/* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
|
||||
+ +
|
||||
|
||||
1
types/node/index.d.ts
vendored
1
types/node/index.d.ts
vendored
@@ -3818,6 +3818,7 @@ declare module "util" {
|
||||
export function isSymbol(object: any): object is symbol;
|
||||
export function isUndefined(object: any): object is undefined;
|
||||
export function deprecate(fn: Function, message: string): Function;
|
||||
export function promisify(fn: Function): Function;
|
||||
}
|
||||
|
||||
declare module "assert" {
|
||||
|
||||
5
types/numeral/index.d.ts
vendored
5
types/numeral/index.d.ts
vendored
@@ -22,6 +22,7 @@ interface NumeralJSLocale {
|
||||
};
|
||||
}
|
||||
|
||||
type RoundingFunction = (value: number) => number;
|
||||
|
||||
// http://numeraljs.com/#custom-formats
|
||||
interface NumeralJsFormat {
|
||||
@@ -29,7 +30,7 @@ interface NumeralJsFormat {
|
||||
format: RegExp,
|
||||
unformat: RegExp,
|
||||
},
|
||||
format: (value: any, format: string, roundingFunction: Function) => string,
|
||||
format: (value: any, format: string, roundingFunction: RoundingFunction) => string,
|
||||
unformat: (value: string) => number
|
||||
}
|
||||
|
||||
@@ -60,7 +61,7 @@ interface Numeral {
|
||||
nullFormat(format: string): void;
|
||||
defaultFormat(format: string): void;
|
||||
clone(): Numeral;
|
||||
format(inputString?: string): string;
|
||||
format(inputString?: string, roundingFunction?: RoundingFunction): string;
|
||||
formatCurrency(inputString?: string): string;
|
||||
unformat(inputString: string): number;
|
||||
value(): number;
|
||||
|
||||
@@ -6,6 +6,9 @@ var valueFormat: string = numeral(1000).format('0,0');
|
||||
var valueUnformat: number = numeral().unformat('($10,000.00)');
|
||||
// '-10000'
|
||||
|
||||
var valueFormatFloor: string = numeral(1.357).format('0.00', Math.floor);
|
||||
// '1.35'
|
||||
|
||||
var value3: Numeral = numeral(1000);
|
||||
var added: Numeral = value3.add(10);
|
||||
// 1010
|
||||
|
||||
9
types/o.js/index.d.ts
vendored
9
types/o.js/index.d.ts
vendored
@@ -1,6 +1,6 @@
|
||||
// Type definitions for o.js v0.2.2
|
||||
// Type definitions for o.js v0.3.3
|
||||
// Project: https://github.com/janhommes/o.js
|
||||
// Definitions by: Matteo Antony Mistretta <https://github.com/IceOnFire>, Brad Zacher <https://github.com/bradzacher>
|
||||
// Definitions by: Matteo Antony Mistretta <https://github.com/IceOnFire>, Brad Zacher <https://github.com/bradzacher>, Jan Hommes <https://github.com/janhommes>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare module 'o.js' {
|
||||
@@ -8,13 +8,14 @@ declare module 'o.js' {
|
||||
|
||||
interface Options {
|
||||
endpoint : string
|
||||
json ?: boolean
|
||||
format ?: string
|
||||
autoFormat ?: boolean
|
||||
version ?: number
|
||||
strictMode ?: boolean
|
||||
start ?: () => any
|
||||
ready ?: () => any
|
||||
error ?: () => any
|
||||
headers ?: string[]
|
||||
headers ?: { name: string, value: string }[]
|
||||
username ?: string
|
||||
password ?: string
|
||||
isAsync ?: boolean
|
||||
|
||||
@@ -129,7 +129,7 @@ o().config({
|
||||
});
|
||||
// after you have set an endpoint, you can shorten your queries:
|
||||
o('Products').get<Product>(function(data) {
|
||||
//same result like the first exmple on this page
|
||||
//same result like the first example on this page
|
||||
});
|
||||
|
||||
|
||||
@@ -137,13 +137,14 @@ o('Products').get<Product>(function(data) {
|
||||
//basic config
|
||||
o().config({
|
||||
endpoint:null, // your odata endpoint for the service
|
||||
json:true, // currently only json is supported
|
||||
format:'json', // currently only json is supported
|
||||
autoFormat: false,
|
||||
version:4, // oData version (currently supported version 4. However most also work with version 3.)
|
||||
strictMode:true, // strict mode throws exception, non strict mode only logs them
|
||||
start:null, // a function which is executed on loading
|
||||
ready:null, // a function which is executed on ready
|
||||
error:null, // a function which is executed on error
|
||||
headers:[], // a array of additional headers e.g.: [{name:'headername',value:'headervalue'}]
|
||||
headers:[{name: '', value: ''}], // a array of additional headers e.g.: [{name:'headername',value:'headervalue'}]
|
||||
username:null, // a basic auth username
|
||||
password:null, // a basic auth password
|
||||
isAsync:true //set this to false to make synced (a)jax calls. (dosn't work with basic auth!)
|
||||
|
||||
2
types/observe-js/index.d.ts
vendored
2
types/observe-js/index.d.ts
vendored
@@ -102,7 +102,7 @@ declare namespace observejs {
|
||||
}
|
||||
|
||||
interface ArrayObserver_instance extends Observable {
|
||||
open(onChange:(splices:Array<splice>)=>any):void
|
||||
open(onChange: (splices: Array<splice>, oldSplices: Array<splice>) => any): void
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
84
types/odata/index.d.ts
vendored
Normal file
84
types/odata/index.d.ts
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
// Type definitions for odata v0.3.3
|
||||
// Project: https://github.com/janhommes/odata
|
||||
// Definitions by: Jan Hommes <https://github.com/janhommes>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare module 'odata' {
|
||||
import Q = require("q");
|
||||
|
||||
interface Options {
|
||||
endpoint : string
|
||||
format ?: string
|
||||
autoFormat ?: boolean
|
||||
version ?: number
|
||||
strictMode ?: boolean
|
||||
start ?: () => any
|
||||
ready ?: () => any
|
||||
error ?: () => any
|
||||
headers ?: { name: string, value: string }[]
|
||||
username ?: string
|
||||
password ?: string
|
||||
isAsync ?: boolean
|
||||
}
|
||||
|
||||
interface OHandler<T> {
|
||||
inlinecount : number
|
||||
data : T
|
||||
|
||||
config<T>(options ?: Options) : OHandler<T>
|
||||
progress<T>(callback : () => any) : OHandler<T>
|
||||
|
||||
get<T>(callback ?: (data : T) => void) : Q.Promise<OHandler<T>>
|
||||
save<T>(callback ?: (data : T) => void) : Q.Promise<OHandler<T>>
|
||||
|
||||
post<T>(params : any) : OHandler<T>
|
||||
patch<T>(params : any) : OHandler<T>
|
||||
put<T>(params : any) : OHandler<T>
|
||||
remove<T>(params ?: any) : OHandler<T>
|
||||
|
||||
routes<T>(path : string, callback ?: (data : T) => void) : OHandler<T>
|
||||
route<T>(path : string, callback ?: (data : T) => void) : OHandler<T>
|
||||
triggerRoute(hash : string) : OHandler<T>
|
||||
beforeRouting(callback : (routeParams : any) => boolean) : OHandler<T>
|
||||
|
||||
isEndpoint() : boolean
|
||||
loading<T>(startFn : () => any | boolean, endFn : () => any) : OHandler<T>
|
||||
|
||||
find<T>(selector : string|number) : OHandler<T>
|
||||
|
||||
top<T>(quantity : number) : OHandler<T>
|
||||
take<T>(quantity : number) : OHandler<T>
|
||||
skip<T>(quantity : number) : OHandler<T>
|
||||
first<T>() : OHandler<T>
|
||||
|
||||
include<T>(column : string, data : string) : OHandler<T>
|
||||
exclude<T>(column : string, data : string) : OHandler<T>
|
||||
filterByList<T>(column : string, data : string) : OHandler<T>
|
||||
|
||||
filter<T>(filter : string) : OHandler<T>
|
||||
where<T>(filter : string) : OHandler<T>
|
||||
any<T>(filter : string, resource : string) : OHandler<T>
|
||||
search<T>(columns : string[], term : string) : OHandler<T>
|
||||
|
||||
orderBy<T>(column : string, direction ?: boolean) : OHandler<T>
|
||||
orderByDesc<T>(column : string) : OHandler<T>
|
||||
select<T>(selectStr : string) : OHandler<T>
|
||||
|
||||
count<T>() : OHandler<T>
|
||||
inlineCount<T>(paramName ?: string) : OHandler<T>
|
||||
|
||||
batch<T>(resource : string) : OHandler<T>
|
||||
expand<T>(resource : string) : OHandler<T>
|
||||
ref<T>(resource : string, id : string | number) : OHandler<T>
|
||||
removeRef<T>(resource : string, id : string | number) : OHandler<T>
|
||||
deleteRef<T>(resource : string, id : string | number) : OHandler<T>
|
||||
}
|
||||
|
||||
interface OFn<T> extends OHandler<T> {
|
||||
(options ?: string | Options) : OHandler<T>
|
||||
}
|
||||
|
||||
var o : OFn<{}>;
|
||||
|
||||
export = o
|
||||
}
|
||||
151
types/odata/odata-tests.ts
Normal file
151
types/odata/odata-tests.ts
Normal file
@@ -0,0 +1,151 @@
|
||||
import * as o from 'odata';
|
||||
import * as Q from "q";
|
||||
|
||||
interface Product {
|
||||
ID : number;
|
||||
Name : string;
|
||||
Description : string;
|
||||
ReleaseDate : string;
|
||||
DiscontinuedDate : Date;
|
||||
Rating: number;
|
||||
Price: number;
|
||||
}
|
||||
interface Category {
|
||||
ID : number;
|
||||
Name : string;
|
||||
}
|
||||
|
||||
// copy pasta all the examples from the readme!
|
||||
|
||||
o('http://services.odata.org/V4/OData/OData.svc/Products')
|
||||
.get<Product>(function(data) {
|
||||
console.log(data); //returns an array of Product data
|
||||
});
|
||||
|
||||
|
||||
|
||||
o('http://services.odata.org/V4/OData/OData.svc/Products')
|
||||
.take(5)
|
||||
.skip(2)
|
||||
.get<Product>(function(data) {
|
||||
console.log(data); //An array of 5 products skiped by 2
|
||||
});
|
||||
|
||||
|
||||
|
||||
o('http://services.odata.org/V4/OData/OData.svc/Products')
|
||||
.find(':0')
|
||||
.route<Product>('Product/Detail/:0/:1',function(data) {
|
||||
console.log('Route Product/Detail/'+this.param[0]+'/'+this.param[1]+' triggered. Result:');
|
||||
console.log(data);
|
||||
});
|
||||
|
||||
|
||||
|
||||
var oHandler = o('http://services.odata.org/V4/OData/OData.svc/Products');
|
||||
//do somehtting
|
||||
oHandler.find(1);
|
||||
// do some more................
|
||||
//get the data
|
||||
oHandler.get<Product>(function(data) {
|
||||
console.log(data);
|
||||
//or the saved var also contains the data:
|
||||
console.log(oHandler.data);
|
||||
});
|
||||
|
||||
|
||||
|
||||
Q.all<any>([
|
||||
o('http://services.odata.org/V4/OData/OData.svc/Products(4)').get<Product>(),
|
||||
o('http://services.odata.org/V4/OData/OData.svc/Categories').take(2).get<Category[]>()
|
||||
]).then(function(oHandlerArray) {
|
||||
//The oHandler array contains the Product oHandler and the Group oHandler:
|
||||
console.log(oHandlerArray[0].data); // 1 Product with id 4
|
||||
console.log(oHandlerArray[1].data.length); // 2 Categories
|
||||
});
|
||||
|
||||
|
||||
|
||||
o('http://services.odata.org/V4/OData/OData.svc/Products(2)')
|
||||
.get<Product>()
|
||||
.then(function(oHandler) {
|
||||
console.log(oHandler.data);
|
||||
}).fail(function(ex) {
|
||||
console.log(ex);
|
||||
});
|
||||
|
||||
|
||||
|
||||
o('http://services.odata.org/V4/OData/OData.svc/Products')
|
||||
.post({Name:'Example 1',Description:'a'})
|
||||
.post({Name:'Example 2',Description:'b'})
|
||||
.save<Product>(function(data) {
|
||||
console.log("Two Products added");
|
||||
});
|
||||
|
||||
|
||||
|
||||
o('http://services.odata.org/V4/OData/OData.svc/Products(1)')
|
||||
.patch({Name:'NewName'})
|
||||
.save<Product>(function(data) {
|
||||
console.log("Product Name changed");
|
||||
});
|
||||
|
||||
|
||||
|
||||
o('http://services.odata.org/V4/OData/OData.svc/Products(1)')
|
||||
.remove()
|
||||
.save<Product>(function(data) {
|
||||
console.log("Product deleted");
|
||||
});
|
||||
|
||||
|
||||
|
||||
o('http://services.odata.org/V4/OData/OData.svc/Products(1)')
|
||||
.ref('Categories', 2)
|
||||
.save<Product>(function(data) {
|
||||
console.log("Product(1) associated with Categories(2)");
|
||||
});
|
||||
|
||||
|
||||
|
||||
o('http://services.odata.org/V4/OData/OData.svc/Products')
|
||||
.find(2)
|
||||
.get<Product>()
|
||||
.then(function(oHandler) {
|
||||
oHandler.data.Name="NewName";
|
||||
return(o.save<Product>());
|
||||
}).then(function(oHandler) {
|
||||
console.log(oHandler.data.Name); //NewName
|
||||
}).fail(function(ex) {
|
||||
console.log("error");
|
||||
});
|
||||
|
||||
|
||||
|
||||
// set an endpoint
|
||||
o().config({
|
||||
endpoint:'http://services.odata.org/V4/OData/OData.svc'
|
||||
});
|
||||
// after you have set an endpoint, you can shorten your queries:
|
||||
o('Products').get<Product>(function(data) {
|
||||
//same result like the first example on this page
|
||||
});
|
||||
|
||||
|
||||
|
||||
//basic config
|
||||
o().config({
|
||||
endpoint:null, // your odata endpoint for the service
|
||||
format: 'json',
|
||||
autoFormat:false, // currently only json is supported
|
||||
version:4, // oData version (currently supported version 4. However most also work with version 3.)
|
||||
strictMode:true, // strict mode throws exception, non strict mode only logs them
|
||||
start:null, // a function which is executed on loading
|
||||
ready:null, // a function which is executed on ready
|
||||
error:null, // a function which is executed on error
|
||||
headers:[{name: '', value: ''}], // a array of additional headers e.g.: [{name:'headername',value:'headervalue'}]
|
||||
username:null, // a basic auth username
|
||||
password:null, // a basic auth password
|
||||
isAsync:true //set this to false to make synced (a)jax calls. (dosn't work with basic auth!)
|
||||
});
|
||||
26
types/odata/tsconfig.json
Normal file
26
types/odata/tsconfig.json
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": false,
|
||||
"strictNullChecks": false,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"paths": {
|
||||
"q": [ "q/v0" ]
|
||||
},
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"odata-tests.ts"
|
||||
]
|
||||
}
|
||||
391
types/paper/index.d.ts
vendored
391
types/paper/index.d.ts
vendored
@@ -3,6 +3,8 @@
|
||||
// Definitions by: Clark Stevenson <http://github.com/clark-stevenson>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
type NativeMouseEvent = MouseEvent;
|
||||
|
||||
declare module 'paper' {
|
||||
|
||||
/**
|
||||
@@ -285,7 +287,7 @@ declare module 'paper' {
|
||||
* Transforms a point and returns the result.
|
||||
* @param point - the point to be transformed
|
||||
*/
|
||||
transform(point: Point): Point;
|
||||
transform(point: Point): Matrix;
|
||||
|
||||
/**
|
||||
* Transforms an array of coordinates by this matrix and stores the results into the destination array, which is also returned.
|
||||
@@ -299,7 +301,7 @@ declare module 'paper' {
|
||||
* Inverse transforms a point and returns the result.
|
||||
* @param point - the point to be transformed
|
||||
*/
|
||||
inverseTransform(point: Point): Point;
|
||||
inverseTransform(point: Point): Matrix;
|
||||
|
||||
/**
|
||||
* Attempts to decompose the affine transformation described by this matrix into scaling, rotation and shearing, and returns an object with these properties if it succeeded, null otherwise.
|
||||
@@ -550,6 +552,36 @@ declare module 'paper' {
|
||||
*/
|
||||
abs(): Point;
|
||||
|
||||
/*
|
||||
* Returns a new point
|
||||
* @param point - The point you want to add with
|
||||
*/
|
||||
add(point: Point): Point;
|
||||
add(point: number[]): Point;
|
||||
|
||||
/*
|
||||
* Returns a new point
|
||||
* @param point - The point you want to subtract with
|
||||
*/
|
||||
subtract(point: Point): Point;
|
||||
subtract(point: number[]): Point;
|
||||
|
||||
/*
|
||||
* Returns the new multiplied point
|
||||
* @param point - The point you want to multiply with
|
||||
*/
|
||||
multiply(point: Point): Point;
|
||||
multiply(point: number[]): Point;
|
||||
multiply(point: number): Point;
|
||||
|
||||
/*
|
||||
* Returns the new divided point
|
||||
* @param point - The point you want to divide with
|
||||
*/
|
||||
divide(point: Point): Point;
|
||||
divide(point: number[]): Point;
|
||||
divide(point: number): Point;
|
||||
|
||||
}
|
||||
/**
|
||||
* A Rectangle specifies an area that is enclosed by it's top-left point (x, y), its width, and its height. It should not be confused with a rectangular path, it is not an item.
|
||||
@@ -894,6 +926,22 @@ declare module 'paper' {
|
||||
*/
|
||||
abs(): Size;
|
||||
|
||||
/*
|
||||
* Returns the new multiplied size
|
||||
* @param point - The size you want to multiply with
|
||||
*/
|
||||
multiply(point: Size): Size;
|
||||
multiply(point: number[]): Size;
|
||||
multiply(point: number): Size;
|
||||
|
||||
/*
|
||||
* Returns the new divided size
|
||||
* @param point - The size you want to divide with
|
||||
*/
|
||||
divide(point: Size): Size;
|
||||
divide(point: number[]): Size;
|
||||
divide(point: number): Size;
|
||||
|
||||
}
|
||||
export interface IFrameEvent {
|
||||
|
||||
@@ -1223,6 +1271,11 @@ declare module 'paper' {
|
||||
*/
|
||||
fillColor: Color | string;
|
||||
|
||||
/**
|
||||
* The fill rule.
|
||||
*/
|
||||
fillRule: string;
|
||||
|
||||
/**
|
||||
* The color the item is highlighted with when selected. If the item does not specify its own color, the color defined by its layer is used instead.
|
||||
*/
|
||||
@@ -1432,6 +1485,20 @@ declare module 'paper' {
|
||||
*/
|
||||
insertBelow(item: Item): Item;
|
||||
|
||||
/**
|
||||
* Moves this item above the specified item. Returns true if the item
|
||||
* was moved.
|
||||
* @param item - the item above which it should be moved
|
||||
*/
|
||||
moveAbove(item: Item): boolean;
|
||||
|
||||
/**
|
||||
* Moves this item below the specified item. Returns true if the item
|
||||
* was moved.
|
||||
* @param item - the item below which it should be moved
|
||||
*/
|
||||
moveBelow(item: Item): boolean;
|
||||
|
||||
/**
|
||||
* Sends this item to the back of all other items within the same parent.
|
||||
*/
|
||||
@@ -1551,7 +1618,7 @@ declare module 'paper' {
|
||||
* Translates (moves) the item by the given offset point.
|
||||
* @param delta - the offset to translate the item by
|
||||
*/
|
||||
translate(delta: number): Point;
|
||||
translate(delta: Point): Point;
|
||||
|
||||
/**
|
||||
* Rotates the item by a given angle around the given point.
|
||||
@@ -1561,6 +1628,11 @@ declare module 'paper' {
|
||||
*/
|
||||
rotate(angle: number, center?: Point): void;
|
||||
|
||||
/**
|
||||
* Gets the current rotation of the item.
|
||||
*/
|
||||
getRotation(): number;
|
||||
|
||||
/**
|
||||
* Scales the item by the given value from its center point, or optionally from a supplied point.
|
||||
* @param scale - the scale factor
|
||||
@@ -1883,6 +1955,7 @@ declare module 'paper' {
|
||||
* @param position [optional] - the center position at which the raster item is placed
|
||||
*/
|
||||
constructor(source?: HTMLImageElement | HTMLCanvasElement | string, position?: Point);
|
||||
constructor(config: any);
|
||||
|
||||
/**
|
||||
* The size of the raster in pixels.
|
||||
@@ -2105,7 +2178,7 @@ declare module 'paper' {
|
||||
* @param handle2 - The second control point handle for the curve
|
||||
* @param to - The end control point of the curve
|
||||
*/
|
||||
cublicCurveTo(handle1: Point, handle2: Point, to: Point): void;
|
||||
cubicCurveTo(handle1: Point, handle2: Point, to: Point): void;
|
||||
|
||||
/**
|
||||
* Adds a quadratic bezier curve to the path, defined by a handle and a to point.
|
||||
@@ -2168,7 +2241,7 @@ declare module 'paper' {
|
||||
* @param handle2 -
|
||||
* @param to -
|
||||
*/
|
||||
cublicCurveBy(handle1: Point, handle2: Point, to: Point): void;
|
||||
cubicCurveBy(handle1: Point, handle2: Point, to: Point): void;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -2227,118 +2300,11 @@ declare module 'paper' {
|
||||
*/
|
||||
export class Path extends PathItem {
|
||||
|
||||
/**
|
||||
* Creates a linear path item from two points describing a line.
|
||||
* @param from - the line's starting point
|
||||
* @param to - the line's ending point
|
||||
*/
|
||||
static Line(from: Point, to: Point): Path;
|
||||
|
||||
/**
|
||||
* Creates a linear path item from the properties described by an object literal.
|
||||
* @param object - an object literal containing properties describing the path's attributes
|
||||
*/
|
||||
static Line(object: any): Path;
|
||||
|
||||
/**
|
||||
* Creates a circular path item.
|
||||
* @param center - the center point of the circle
|
||||
* @param radius - the radius of the circle
|
||||
*/
|
||||
static Circle(center: Point, radius: number): Path;
|
||||
|
||||
/**
|
||||
* Creates a circular path item from the properties described by an object literal.
|
||||
* @param object - an object literal containing properties describing the path's attributes
|
||||
*/
|
||||
static Circle(object: any): Path;
|
||||
|
||||
/**
|
||||
* Creates a rectangular path item, with optionally rounded corners.
|
||||
* @param rectangle - the rectangle object describing the geometry of the rectangular path to be created.
|
||||
* @param radius [optional] - the size of the rounded corners default: null
|
||||
*/
|
||||
static Rectangle(rectangle: Rectangle, radius?: number): Path;
|
||||
|
||||
/**
|
||||
* Creates a rectangular path item from a point and a size object.
|
||||
* @param point - the rectangle's top-left corner.
|
||||
* @param size - the rectangle's size.
|
||||
*/
|
||||
static Rectangle(point: Point, size: Size): Path;
|
||||
|
||||
/**
|
||||
* Creates a rectangular path item from the passed points. These do not necessarily need to be the top left and bottom right corners, the constructor figures out how to fit a rectangle between them.
|
||||
* @param from - the first point defining the rectangle
|
||||
* @param to - the second point defining the rectangle
|
||||
*/
|
||||
static Rectangle(from: Point, to: Point): Path;
|
||||
|
||||
/**
|
||||
* Creates a rectangular path item from the properties described by an object literal.
|
||||
* @param object - an object literal containing properties describing the path's attributes
|
||||
*/
|
||||
static Rectangle(object: any): Path;
|
||||
|
||||
/**
|
||||
* Creates an elliptical path item.
|
||||
* @param rectangle - the rectangle circumscribing the ellipse
|
||||
*/
|
||||
static Ellipse(rectangle: Rectangle): Path;
|
||||
|
||||
/**
|
||||
* Creates an elliptical path item from the properties described by an object literal.
|
||||
* @param object - an object literal containing properties describing the path's attributes
|
||||
*/
|
||||
static Ellipse(object: any): Path;
|
||||
/**
|
||||
* Creates a circular arc path item
|
||||
* @param from - the starting point of the circular arc
|
||||
* @param through - the point the arc passes through
|
||||
* @param to - the end point of the arc
|
||||
*/
|
||||
static Arc(from: Point, through: Point, to: Point): Path;
|
||||
|
||||
/**
|
||||
* Creates an circular arc path item from the properties described by an object literal.
|
||||
* @param object - an object literal containing properties describing the path's attributes
|
||||
*/
|
||||
static Arc(object: any): Path;
|
||||
|
||||
/**
|
||||
* Creates a regular polygon shaped path item.
|
||||
* @param center - the center point of the polygon
|
||||
* @param sides - the number of sides of the polygon
|
||||
* @param radius - the radius of the polygon
|
||||
*/
|
||||
static RegularPolygon(center: Point, sides: number, radius: number): Path;
|
||||
|
||||
/**
|
||||
* Creates a regular polygon shaped path item from the properties described by an object literal.
|
||||
* @param object - an object literal containing properties describing the path's attributes
|
||||
*/
|
||||
static RegularPolygon(object: any): Path;
|
||||
|
||||
/**
|
||||
* Creates a star shaped path item. The largest of radius1 and radius2 will be the outer radius of the star. The smallest of radius1 and radius2 will be the inner radius.
|
||||
* @param center - the center point of the star
|
||||
* @param points - the number of points of the star
|
||||
* @param radius1
|
||||
* @param radius2
|
||||
*/
|
||||
static Star(center: Point, points: number, radius1: number, radius2: number): Path;
|
||||
|
||||
/**
|
||||
* Creates a star shaped path item from the properties described by an object literal.
|
||||
* @param object - an object literal containing properties describing the path's attributes
|
||||
*/
|
||||
static Star(object: any): Path;
|
||||
|
||||
/**
|
||||
* Creates a new path item and places it at the top of the active layer.
|
||||
* @param segments [optional] - An array of segments (or points to be converted to segments) that will be added to the path
|
||||
*/
|
||||
constructor(segments?: Segment[]| Point[]);
|
||||
constructor(segments?: Segment[] | Point[]);
|
||||
|
||||
/**
|
||||
* Creates a new path item from an object description and places it at the top of the active layer.
|
||||
@@ -2574,6 +2540,130 @@ declare module 'paper' {
|
||||
|
||||
|
||||
}
|
||||
module Path {
|
||||
export class Line extends Path {
|
||||
/**
|
||||
* Creates a linear path item from two points describing a line.
|
||||
* @param from - the line's starting point
|
||||
* @param to - the line's ending point
|
||||
*/
|
||||
constructor(from: Point, to: Point);
|
||||
|
||||
/**
|
||||
* Creates a linear path item from the properties described by an object literal.
|
||||
* @param object - an object literal containing properties describing the path's attributes
|
||||
*/
|
||||
constructor(object: any);
|
||||
}
|
||||
|
||||
export class Circle extends Path {
|
||||
/**
|
||||
* Creates a circular path item.
|
||||
* @param center - the center point of the circle
|
||||
* @param radius - the radius of the circle
|
||||
*/
|
||||
constructor(center: Point, radius: number);
|
||||
|
||||
/**
|
||||
* Creates a circular path item from the properties described by an object literal.
|
||||
* @param object - an object literal containing properties describing the path's attributes
|
||||
*/
|
||||
constructor(object: any);
|
||||
}
|
||||
|
||||
export class Rectangle extends Path {
|
||||
/**
|
||||
* Creates a rectangular path item, with optionally rounded corners.
|
||||
* @param rectangle - the rectangle object describing the geometry of the rectangular path to be created.
|
||||
* @param radius [optional] - the size of the rounded corners default: null
|
||||
*/
|
||||
constructor(rectangle: Rectangle, radius?: number);
|
||||
|
||||
/**
|
||||
* Creates a rectangular path item from a point and a size object.
|
||||
* @param point - the rectangle's top-left corner.
|
||||
* @param size - the rectangle's size.
|
||||
*/
|
||||
constructor(point: Point, size: Size);
|
||||
|
||||
/**
|
||||
* Creates a rectangular path item from the passed points. These do not necessarily need to be the top left and bottom right corners, the constructor figures out how to fit a rectangle between them.
|
||||
* @param from - the first point defining the rectangle
|
||||
* @param to - the second point defining the rectangle
|
||||
*/
|
||||
constructor(from: Point, to: Point);
|
||||
|
||||
/**
|
||||
* Creates a rectangular path item from the properties described by an object literal.
|
||||
* @param object - an object literal containing properties describing the path's attributes
|
||||
*/
|
||||
constructor(object: any);
|
||||
}
|
||||
|
||||
export class Ellipse extends Path {
|
||||
/**
|
||||
* Creates an elliptical path item.
|
||||
* @param rectangle - the rectangle circumscribing the ellipse
|
||||
*/
|
||||
constructor(rectangle: Rectangle);
|
||||
|
||||
/**
|
||||
* Creates an elliptical path item from the properties described by an object literal.
|
||||
* @param object - an object literal containing properties describing the path's attributes
|
||||
*/
|
||||
constructor(object: any);
|
||||
}
|
||||
|
||||
export class Arc extends Path {
|
||||
/**
|
||||
* Creates a circular arc path item
|
||||
* @param from - the starting point of the circular arc
|
||||
* @param through - the point the arc passes through
|
||||
* @param to - the end point of the arc
|
||||
*/
|
||||
constructor(from: Point, through: Point, to: Point);
|
||||
|
||||
/**
|
||||
* Creates an circular arc path item from the properties described by an object literal.
|
||||
* @param object - an object literal containing properties describing the path's attributes
|
||||
*/
|
||||
constructor(object: any);
|
||||
}
|
||||
|
||||
export class RegularPolygon extends Path {
|
||||
/**
|
||||
* Creates a regular polygon shaped path item.
|
||||
* @param center - the center point of the polygon
|
||||
* @param sides - the number of sides of the polygon
|
||||
* @param radius - the radius of the polygon
|
||||
*/
|
||||
constructor(center: Point, sides: number, radius: number);
|
||||
|
||||
/**
|
||||
* Creates a regular polygon shaped path item from the properties described by an object literal.
|
||||
* @param object - an object literal containing properties describing the path's attributes
|
||||
*/
|
||||
constructor(object: any);
|
||||
}
|
||||
|
||||
export class Star extends Path {
|
||||
/**
|
||||
* Creates a star shaped path item. The largest of radius1 and radius2 will be the outer radius of the star. The smallest of radius1 and radius2 will be the inner radius.
|
||||
* @param center - the center point of the star
|
||||
* @param points - the number of points of the star
|
||||
* @param radius1
|
||||
* @param radius2
|
||||
*/
|
||||
constructor(center: Point, points: number, radius1: number, radius2: number);
|
||||
|
||||
/**
|
||||
* Creates a star shaped path item from the properties described by an object literal.
|
||||
* @param object - an object literal containing properties describing the path's attributes
|
||||
*/
|
||||
constructor(object: any);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A compound path contains two or more paths, holes are drawn where the paths overlap. All the paths in a compound path take on the style of the backmost path and can be accessed through its item.children list.
|
||||
*/
|
||||
@@ -4005,4 +4095,79 @@ declare module 'paper' {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* A Javascript MouseEvent wrapper
|
||||
*/
|
||||
export class MouseEvent extends Event {
|
||||
constructor(type: string, event: NativeMouseEvent, point: Point, target: Item, delta: Point)
|
||||
|
||||
/**
|
||||
* The JavaScript mouse event
|
||||
*/
|
||||
event: NativeMouseEvent;
|
||||
|
||||
/**
|
||||
* The position of the mouse in project coordinates when the event was
|
||||
* fired.
|
||||
*/
|
||||
point: Point;
|
||||
|
||||
/**
|
||||
* The last event's position of the mouse in project coordinates when
|
||||
* the event was fired.
|
||||
*/
|
||||
lastPoint: Point;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
delta: Point;
|
||||
|
||||
/**
|
||||
* The item that dispatched the event. It is different from
|
||||
* currentTarget when the event handler is called during the bubbling
|
||||
* phase of the event.
|
||||
*/
|
||||
target: Item;
|
||||
|
||||
/**
|
||||
* The current target for the event, as the event traverses the scene
|
||||
* graph. It always refers to the element the event handler has been
|
||||
* attached to as opposed to target which identifies the element on
|
||||
* which the event occurred.
|
||||
*/
|
||||
currentTarget: Item;
|
||||
|
||||
/**
|
||||
* Type of mouse event
|
||||
*/
|
||||
type: 'mousedown' | 'mouseup' | 'mousedrag' | 'click' | 'doubleclick' | 'mousemove' | 'mouseenter' | 'mouseleave';
|
||||
|
||||
/**
|
||||
* The time at which the event was created, in milliseconds since the
|
||||
* epoch.
|
||||
*/
|
||||
timeStamp(): number;
|
||||
|
||||
/**
|
||||
* Cancels the event if it is cancelable, without stopping further
|
||||
* propagation of the event.
|
||||
*/
|
||||
preventDefault(): void;
|
||||
|
||||
/**
|
||||
* Prevents further propagation of the current event.
|
||||
*/
|
||||
stopPropagation(): void;
|
||||
|
||||
/**
|
||||
* Cancels the event if it is cancelable, and stops stopping further
|
||||
* propagation of the event. This is has the same effect as calling
|
||||
* both stopPropagation() and preventDefault().
|
||||
*
|
||||
* Any handler can also return false to indicate that stop() should be
|
||||
* called right after.
|
||||
*/
|
||||
stop(): void;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ var canvas = document.createElement('canvas')
|
||||
paper.setup(canvas);
|
||||
|
||||
// Circle
|
||||
var path = paper.Path.Circle({
|
||||
var path = new paper.Path.Circle({
|
||||
center: [80, 50],
|
||||
radius: 35,
|
||||
fillColor: 'red'
|
||||
|
||||
@@ -198,7 +198,7 @@ function test_file() {
|
||||
// The file either could n ot be read, or could not be saved to Parse.
|
||||
});
|
||||
|
||||
Parse.Cloud.httpRequest({ url: file.url() }).then((response: Parse.Promise<Parse.Cloud.HttpResponse>) => {
|
||||
Parse.Cloud.httpRequest({ url: file.url() }).then((response: Parse.Cloud.HttpResponse) => {
|
||||
// result
|
||||
});
|
||||
|
||||
|
||||
1
types/passport-local-mongoose/index.d.ts
vendored
1
types/passport-local-mongoose/index.d.ts
vendored
@@ -2,6 +2,7 @@
|
||||
// Project: https://github.com/saintedlama/passport-local-mongoose
|
||||
// Definitions by: Linus Brolin <https://github.com/linusbrolin/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
/// <reference types="mongoose" />
|
||||
/// <reference types="passport-local" />
|
||||
|
||||
@@ -31,13 +31,13 @@ interface User extends PassportLocalDocument {
|
||||
last: Date;
|
||||
}
|
||||
|
||||
const UserSchema: PassportLocalSchema = new Schema({
|
||||
const UserSchema = new Schema({
|
||||
username: String,
|
||||
hash: String,
|
||||
salt: String,
|
||||
attempts: Number,
|
||||
last: Date
|
||||
});
|
||||
}) as PassportLocalSchema;
|
||||
|
||||
let options: PassportLocalOptions = <PassportLocalOptions>{};
|
||||
options.iterations = 25000;
|
||||
|
||||
764
types/pixi.js/index.d.ts
vendored
764
types/pixi.js/index.d.ts
vendored
File diff suppressed because it is too large
Load Diff
@@ -24,7 +24,7 @@ function basics() {
|
||||
private renderer: PIXI.WebGLRenderer;
|
||||
constructor() {
|
||||
// Renderer should allow options from both WebGLRenderer and underlying SystemRenderer
|
||||
this.renderer = new PIXI.WebGLRenderer(0, 0, { backgroundColor : 0x272d37, forceFXAA: true });
|
||||
this.renderer = new PIXI.WebGLRenderer(0, 0, { backgroundColor: 0x272d37, forceFXAA: true });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1507,7 +1507,8 @@ function filters() {
|
||||
maggot.position.y = Math.random() * bounds.height;
|
||||
|
||||
maggot.scale.set(1 + Math.random() * 0.3);
|
||||
maggot.original = maggot.scale.clone();
|
||||
//tslint:disable-next-line:whitespace
|
||||
maggot.original = (<PIXI.Point>maggot.scale).clone();
|
||||
this.maggots.push(maggot);
|
||||
}
|
||||
|
||||
|
||||
@@ -170,7 +170,7 @@ function test_addContainer()
|
||||
|
||||
function test_on_EventType1(){
|
||||
var quillEditor = new Quill('#editor');
|
||||
quillEditor.on('text-change', (newDelta, oldDelta, source)=>{
|
||||
quillEditor.on('text-change', <T>(newDelta: T, oldDelta: T, source: string)=>{
|
||||
// happened
|
||||
});
|
||||
|
||||
|
||||
46
types/ramda/index.d.ts
vendored
46
types/ramda/index.d.ts
vendored
@@ -1,6 +1,10 @@
|
||||
// Type definitions for ramda
|
||||
// Project: https://github.com/donnut/typescript-ramda
|
||||
// Definitions by: Erwin Poeze <https://github.com/donnut>, Matt DeKrey <https://github.com/mdekrey>, Liam Goodacre <https://github.com/LiamGoodacre>, Matt Dziuban <https://github.com/mrdziuban>
|
||||
// Definitions by: Erwin Poeze <https://github.com/donnut>
|
||||
// Matt DeKrey <https://github.com/mdekrey>
|
||||
// Liam Goodacre <https://github.com/LiamGoodacre>
|
||||
// Matt Dziuban <https://github.com/mrdziuban>
|
||||
// Stephen King <https://github.com/sbking>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
@@ -75,6 +79,41 @@ declare namespace R {
|
||||
}
|
||||
|
||||
// @see https://gist.github.com/donnut/fd56232da58d25ceecf1, comment by @albrow
|
||||
interface CurriedTypeGuard2<T1, T2, R extends T2> {
|
||||
(t1: T1): (t2: T2) => t2 is R;
|
||||
(t1: T1, t2: T2): t2 is R;
|
||||
}
|
||||
|
||||
interface CurriedTypeGuard3<T1, T2, T3, R extends T3> {
|
||||
(t1: T1): CurriedTypeGuard2<T2, T3, R>;
|
||||
(t1: T1, t2: T2): (t3: T3) => t3 is R;
|
||||
(t1: T1, t2: T2, t3: T3): t3 is R;
|
||||
}
|
||||
|
||||
interface CurriedTypeGuard4<T1, T2, T3, T4, R extends T4> {
|
||||
(t1: T1): CurriedTypeGuard3<T2, T3, T4, R>;
|
||||
(t1: T1, t2: T2): CurriedTypeGuard2<T3, T4, R>;
|
||||
(t1: T1, t2: T2, t3: T3): (t4: T4) => t4 is R;
|
||||
(t1: T1, t2: T2, t3: T3, t4: T4): t4 is R;
|
||||
}
|
||||
|
||||
interface CurriedTypeGuard5<T1, T2, T3, T4, T5, R extends T5> {
|
||||
(t1: T1): CurriedTypeGuard4<T2, T3, T4, T5, R>;
|
||||
(t1: T1, t2: T2): CurriedTypeGuard3<T3, T4, T5, R>;
|
||||
(t1: T1, t2: T2, t3: T3): CurriedTypeGuard2<T4, T5, R>;
|
||||
(t1: T1, t2: T2, t3: T3, t4: T4): (t5: T5) => t5 is R;
|
||||
(t1: T1, t2: T2, t3: T3, t4: T4, t5: T5): t5 is R;
|
||||
}
|
||||
|
||||
interface CurriedTypeGuard6<T1, T2, T3, T4, T5, T6, R extends T6> {
|
||||
(t1: T1): CurriedTypeGuard5<T2, T3, T4, T5, T6, R>;
|
||||
(t1: T1, t2: T2): CurriedTypeGuard4<T3, T4, T5, T6, R>;
|
||||
(t1: T1, t2: T2, t3: T3): CurriedTypeGuard3<T4, T5, T6, R>;
|
||||
(t1: T1, t2: T2, t3: T3, t4: T4): CurriedTypeGuard2<T5, T6, R>;
|
||||
(t1: T1, t2: T2, t3: T3, t4: T4, t5: T5): (t6: T6) => t6 is R;
|
||||
(t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6): t6 is R;
|
||||
}
|
||||
|
||||
interface CurriedFunction2<T1, T2, R> {
|
||||
(t1: T1): (t2: T2) => R;
|
||||
(t1: T1, t2: T2): R;
|
||||
@@ -392,6 +431,11 @@ declare namespace R {
|
||||
* Returns a curried equivalent of the provided function. The curried function has two unusual capabilities.
|
||||
* First, its arguments needn't be provided one at a time.
|
||||
*/
|
||||
curry<T1, T2, TResult extends T2>(fn: (a: T1, b: T2) => b is TResult): CurriedTypeGuard2<T1,T2, TResult>
|
||||
curry<T1, T2, T3, TResult extends T3>(fn: (a: T1, b: T2, c: T3) => c is TResult): CurriedTypeGuard3<T1,T2, T3, TResult>
|
||||
curry<T1, T2, T3, T4, TResult extends T4>(fn: (a: T1, b: T2, c: T3, d: T4) => d is TResult): CurriedTypeGuard4<T1,T2, T3, T4, TResult>
|
||||
curry<T1, T2, T3, T4, T5, TResult extends T5>(fn: (a: T1, b: T2, c: T3, d: T4, e: T5) => e is TResult): CurriedTypeGuard5<T1,T2, T3, T4, T5, TResult>
|
||||
curry<T1, T2, T3, T4, T5, T6, TResult extends T6>(fn: (a: T1, b: T2, c: T3, d: T4, e: T5, f: T6) => f is TResult): CurriedTypeGuard6<T1,T2, T3, T4, T5, T6, TResult>
|
||||
curry<T1, T2, TResult>(fn: (a: T1, b: T2) => TResult): CurriedFunction2<T1,T2, TResult>
|
||||
curry<T1, T2, T3, TResult>(fn: (a: T1, b: T2, c: T3) => TResult): CurriedFunction3<T1,T2, T3, TResult>
|
||||
curry<T1, T2, T3, T4, TResult>(fn: (a: T1, b: T2, c: T3, d: T4) => TResult): CurriedFunction4<T1,T2, T3, T4, TResult>
|
||||
|
||||
@@ -86,6 +86,25 @@ class F2 {
|
||||
var z2:number = addTwoNumbersCurried(2,3);
|
||||
}
|
||||
|
||||
() => {
|
||||
interface Car { speed?: number; }
|
||||
interface FastCar { speed: number; }
|
||||
|
||||
const typeGuard = function(a: number, b: number, c: number, d: number, e: number, car: Car): car is FastCar {
|
||||
return car.speed !== undefined;
|
||||
}
|
||||
const typeGuardCurried = R.curry(typeGuard);
|
||||
|
||||
const drive = function(fastCar: FastCar) {};
|
||||
|
||||
const cars: Car[] = [{ speed: 65 }, {}];
|
||||
for (const car of cars) {
|
||||
if (typeGuardCurried(1)(2)(3)(4)(5)(car)) {
|
||||
drive(car);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
() => {
|
||||
const addFour = (a:number) => (b:number) => (c:number) => (d:number) => a + b + c + d;
|
||||
const uncurriedAddFour = R.uncurryN<number>(4, addFour);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user