mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 06:47:03 +00:00
Merge remote-tracking branch 'upstream/master' into AlexJ-TableFlip
This commit is contained in:
File diff suppressed because it is too large
Load Diff
Vendored
+419
-215
@@ -1,10 +1,9 @@
|
||||
// Type definitions for Angular JS (ngMock, ngMockE2E module) 1.5
|
||||
// Type definitions for Angular JS (ngMock, ngMockE2E module) 1.6
|
||||
// Project: http://angularjs.org
|
||||
// Definitions by: Diego Vilar <https://github.com/diegovilar>, Tony Curtis <https://github.com/daltin>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
// TypeScript Version: 2.4
|
||||
|
||||
/// <reference types="angular" />
|
||||
/// <reference path="mocks.d.ts" />
|
||||
|
||||
import * as angular from 'angular';
|
||||
@@ -13,7 +12,6 @@ import * as angular from 'angular';
|
||||
// ngMock module (angular-mocks.js)
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
declare module 'angular' {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// AngularStatic
|
||||
// We reopen it to add the MockStatic definition
|
||||
@@ -23,27 +21,27 @@ declare module 'angular' {
|
||||
}
|
||||
|
||||
// see https://docs.angularjs.org/api/ngMock/function/angular.mock.inject
|
||||
// Depending on context, it might return a function, however having `void | (() => void)`
|
||||
// as a return type seems to be not useful. E.g. it requires type assertions in `beforeEach(inject(...))`.
|
||||
interface IInjectStatic {
|
||||
(...fns: Function[]): any;
|
||||
(...inlineAnnotatedConstructor: any[]): any; // this overload is undocumented, but works
|
||||
strictDi(val?: boolean): void;
|
||||
(...fns: Array<Injectable<(...args: any[]) => void>>): any; // void | (() => void);
|
||||
strictDi(val?: boolean): any; // void | (() => void);
|
||||
}
|
||||
|
||||
interface IMockStatic {
|
||||
// see https://docs.angularjs.org/api/ngMock/function/angular.mock.dump
|
||||
dump(obj: any): string;
|
||||
|
||||
inject: IInjectStatic
|
||||
inject: IInjectStatic;
|
||||
|
||||
// see https://docs.angularjs.org/api/ngMock/function/angular.mock.module
|
||||
module: {
|
||||
(...modules: any[]): any;
|
||||
sharedInjector(): void;
|
||||
}
|
||||
};
|
||||
|
||||
// see https://docs.angularjs.org/api/ngMock/type/angular.mock.TzDate
|
||||
TzDate(offset: number, timestamp: number): Date;
|
||||
TzDate(offset: number, timestamp: string): Date;
|
||||
TzDate(offset: number, timestamp: number | string): Date;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
@@ -62,7 +60,6 @@ declare module 'angular' {
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface ITimeoutService {
|
||||
flush(delay?: number): void;
|
||||
flushNext(expectedDelay?: number): void;
|
||||
verifyNoPendingTasks(): void;
|
||||
}
|
||||
|
||||
@@ -96,9 +93,11 @@ declare module 'angular' {
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IControllerService {
|
||||
// Although the documentation doesn't state this, locals are optional
|
||||
<T>(controllerConstructor: new (...args: any[]) => T, locals?: any, bindings?: any): T;
|
||||
<T>(controllerConstructor: (...args: any[]) => T, locals?: any, bindings?: any): T;
|
||||
<T>(controllerName: string, locals?: any, bindings?: any): T;
|
||||
<T>(
|
||||
controllerConstructor: (new (...args: any[]) => T) | ((...args: any[]) => T) | string,
|
||||
locals?: any,
|
||||
bindings?: any
|
||||
): T;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
@@ -108,268 +107,473 @@ declare module 'angular' {
|
||||
interface IComponentControllerService {
|
||||
// TBinding is an interface exposed by a component as per John Papa's style guide
|
||||
// https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#accessible-members-up-top
|
||||
<T, TBinding>(componentName: string, locals: { $scope?: IScope, [key: string]: any }, bindings?: TBinding, ident?: string): T;
|
||||
<T, TBinding>(
|
||||
componentName: string,
|
||||
locals: { $scope?: IScope; [key: string]: any },
|
||||
bindings?: TBinding,
|
||||
ident?: string
|
||||
): T;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// HttpBackendService
|
||||
// see https://docs.angularjs.org/api/ngMock/service/$httpBackend
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IHttpBackendService {
|
||||
/**
|
||||
* Flushes pending requests using the trained responses. Requests are flushed in the order they were made, but it is also possible to skip one or more requests (for example to have them flushed later). This is useful for simulating scenarios where responses arrive from the server in any order.
|
||||
*
|
||||
* If there are no pending requests to flush when the method is called, an exception is thrown (as this is typically a sign of programming error).
|
||||
* @param count Number of responses to flush. If undefined/null, all pending requests (starting after `skip`) will be flushed.
|
||||
* @param skip Number of pending requests to skip. For example, a value of 5 would skip the first 5 pending requests and start flushing from the 6th onwards. _(default: 0)_
|
||||
*/
|
||||
* Flushes pending requests using the trained responses. Requests are flushed in the order they
|
||||
* were made, but it is also possible to skip one or more requests (for example to have them
|
||||
* flushed later). This is useful for simulating scenarios where responses arrive from the server
|
||||
* in any order.
|
||||
*
|
||||
* If there are no pending requests to flush when the method is called, an exception is thrown (as
|
||||
* this is typically a sign of programming error).
|
||||
*
|
||||
* @param count Number of responses to flush. If undefined/null, all pending requests (starting
|
||||
* after `skip`) will be flushed.
|
||||
* @param skip Number of pending requests to skip. For example, a value of 5 would skip the first 5 pending requests and start flushing from the 6th onwards. _(default: 0)_
|
||||
*/
|
||||
flush(count?: number, skip?: number): void;
|
||||
|
||||
/**
|
||||
* Resets all request expectations, but preserves all backend definitions.
|
||||
*/
|
||||
* Resets all request expectations, but preserves all backend definitions.
|
||||
*/
|
||||
resetExpectations(): void;
|
||||
|
||||
/**
|
||||
* Verifies that all of the requests defined via the expect api were made. If any of the requests were not made, verifyNoOutstandingExpectation throws an exception.
|
||||
* @param digest Do digest before checking expectation. Pass anything except false to trigger digest. NOTE this flag is purposely undocumented by Angular, which means it's not to be used in normal client code.
|
||||
*/
|
||||
* Verifies that all of the requests defined via the `expect` api were made. If any of the
|
||||
* requests were not made, verifyNoOutstandingExpectation throws an exception.
|
||||
* @param digest Do digest before checking expectation. Pass anything except false to trigger digest.
|
||||
* NOTE: this flag is purposely undocumented by Angular, which means it's not to be used in normal client code.
|
||||
*/
|
||||
verifyNoOutstandingExpectation(digest?: boolean): void;
|
||||
|
||||
/**
|
||||
* Verifies that there are no outstanding requests that need to be flushed.
|
||||
*/
|
||||
* Verifies that there are no outstanding requests that need to be flushed.
|
||||
*/
|
||||
verifyNoOutstandingRequest(): void;
|
||||
|
||||
/**
|
||||
* Creates a new request expectation.
|
||||
* Throws a preformatted error if expectation(s) don't match supplied string, regular expression, object, or if function returns false.
|
||||
* Returns an object with respond method that controls how a matched request is handled.
|
||||
* @param method HTTP method.
|
||||
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
||||
* @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation.
|
||||
* @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
|
||||
* @param keys Array of keys to assign to regex matches in the request url.
|
||||
*/
|
||||
expect(method: string, url: string | RegExp | ((url: string) => boolean), data?: string | RegExp | Object | ((data: string) => boolean), headers?: Object | ((object: Object) => boolean), keys?: Object[]): mock.IRequestHandler;
|
||||
/**
|
||||
* Creates a new request expectation.
|
||||
* Throws a preformatted error if expectation(s) don't match supplied string, regular expression, object, or if function returns false.
|
||||
* Returns an object with respond method that controls how a matched request is handled.
|
||||
* @param method HTTP method.
|
||||
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
||||
* @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation.
|
||||
* @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
|
||||
* @param keys Array of keys to assign to regex matches in the request url.
|
||||
*/
|
||||
expect(
|
||||
method: string,
|
||||
url: string | RegExp | ((url: string) => boolean),
|
||||
data?: string | RegExp | object | ((data: string) => boolean),
|
||||
headers?: mock.IHttpHeaders | ((headers: mock.IHttpHeaders) => boolean),
|
||||
keys?: string[]
|
||||
): mock.IRequestHandler;
|
||||
|
||||
/**
|
||||
* Creates a new request expectation for DELETE requests.
|
||||
* Throws a preformatted error if expectation(s) don't match supplied string, regular expression, object, or if function returns false.
|
||||
* Returns an object with respond method that controls how a matched request is handled.
|
||||
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url is as expected.
|
||||
* @param headers HTTP headers object to be compared with the HTTP headers in the request.
|
||||
* @param keys Array of keys to assign to regex matches in the request url.
|
||||
*/
|
||||
expectDELETE(url: string | RegExp | ((url: string) => boolean), headers?: Object, keys?: Object[]): mock.IRequestHandler;
|
||||
/**
|
||||
* Creates a new request expectation for DELETE requests.
|
||||
* Throws a preformatted error if expectation(s) don't match supplied string, regular expression, object, or if function returns false.
|
||||
* Returns an object with respond method that controls how a matched request is handled.
|
||||
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url is as expected.
|
||||
* @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
|
||||
* @param keys Array of keys to assign to regex matches in the request url.
|
||||
*/
|
||||
expectDELETE(
|
||||
url: string | RegExp | ((url: string) => boolean),
|
||||
headers?: mock.IHttpHeaders | ((headers: mock.IHttpHeaders) => boolean),
|
||||
keys?: string[]
|
||||
): mock.IRequestHandler;
|
||||
|
||||
/**
|
||||
* Creates a new request expectation for GET requests.
|
||||
* Throws a preformatted error if expectation(s) don't match supplied string, regular expression, object, or if function returns false.
|
||||
* Returns an object with respond method that controls how a matched request is handled.
|
||||
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
||||
* @param headers HTTP headers object to be compared with the HTTP headers in the request.
|
||||
* @param keys Array of keys to assign to regex matches in the request url.
|
||||
*/
|
||||
expectGET(url: string | RegExp | ((url: string) => boolean), headers?: Object, keys?: Object[]): mock.IRequestHandler;
|
||||
/**
|
||||
* Creates a new request expectation for GET requests.
|
||||
* Throws a preformatted error if expectation(s) don't match supplied string, regular expression, object, or if function returns false.
|
||||
* Returns an object with respond method that controls how a matched request is handled.
|
||||
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
||||
* @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
|
||||
* @param keys Array of keys to assign to regex matches in the request url.
|
||||
*/
|
||||
expectGET(
|
||||
url: string | RegExp | ((url: string) => boolean),
|
||||
headers?: mock.IHttpHeaders | ((headers: mock.IHttpHeaders) => boolean),
|
||||
keys?: string[]
|
||||
): mock.IRequestHandler;
|
||||
|
||||
/**
|
||||
* Creates a new request expectation for HEAD requests.
|
||||
* Throws a preformatted error if expectation(s) don't match supplied string, regular expression, object, or if function returns false.
|
||||
* Returns an object with respond method that controls how a matched request is handled.
|
||||
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
||||
* @param headers HTTP headers object to be compared with the HTTP headers in the request.
|
||||
* @param keys Array of keys to assign to regex matches in the request url.
|
||||
*/
|
||||
/**
|
||||
* Creates a new request expectation for HEAD requests.
|
||||
* Throws a preformatted error if expectation(s) don't match supplied string, regular expression, object, or if function returns false.
|
||||
* Returns an object with respond method that controls how a matched request is handled.
|
||||
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
||||
* @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
|
||||
* @param keys Array of keys to assign to regex matches in the request url.
|
||||
*/
|
||||
|
||||
expectHEAD(url: string | RegExp | ((url: string) => boolean), headers?: Object, keys?: Object[]): mock.IRequestHandler;
|
||||
expectHEAD(
|
||||
url: string | RegExp | ((url: string) => boolean),
|
||||
headers?: mock.IHttpHeaders | ((headers: mock.IHttpHeaders) => boolean),
|
||||
keys?: string[]
|
||||
): mock.IRequestHandler;
|
||||
|
||||
/**
|
||||
* Creates a new request expectation for JSONP requests.
|
||||
* Throws a preformatted error if expectation(s) don't match supplied string, regular expression, or if function returns false.
|
||||
* Returns an object with respond method that controls how a matched request is handled.
|
||||
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
||||
* @param keys Array of keys to assign to regex matches in the request url.
|
||||
*/
|
||||
expectJSONP(url: string | RegExp | ((url: string) => boolean), keys?: Object[]): mock.IRequestHandler;
|
||||
/**
|
||||
* Creates a new request expectation for JSONP requests.
|
||||
* Throws a preformatted error if expectation(s) don't match supplied string, regular expression, or if function returns false.
|
||||
* Returns an object with respond method that controls how a matched request is handled.
|
||||
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
||||
* @param keys Array of keys to assign to regex matches in the request url.
|
||||
*/
|
||||
expectJSONP(
|
||||
url: string | RegExp | ((url: string) => boolean),
|
||||
keys?: string[]
|
||||
): mock.IRequestHandler;
|
||||
|
||||
/**
|
||||
* Creates a new request expectation for PATCH requests.
|
||||
* Throws a preformatted error if expectation(s) don't match supplied string, regular expression, object, or if function returns false.
|
||||
* Returns an object with respond method that controls how a matched request is handled.
|
||||
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
||||
* @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation.
|
||||
* @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
|
||||
* @param keys Array of keys to assign to regex matches in the request url.
|
||||
*/
|
||||
expectPATCH(url: string | RegExp | ((url: string) => boolean), data?: string | RegExp | Object | ((data: string) => boolean), headers?: Object, keys?: Object[]): mock.IRequestHandler;
|
||||
/**
|
||||
* Creates a new request expectation for PATCH requests.
|
||||
* Throws a preformatted error if expectation(s) don't match supplied string, regular expression, object, or if function returns false.
|
||||
* Returns an object with respond method that controls how a matched request is handled.
|
||||
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
||||
* @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation.
|
||||
* @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
|
||||
* @param keys Array of keys to assign to regex matches in the request url.
|
||||
*/
|
||||
expectPATCH(
|
||||
url: string | RegExp | ((url: string) => boolean),
|
||||
data?: string | RegExp | object | ((data: string) => boolean),
|
||||
headers?: mock.IHttpHeaders | ((headers: mock.IHttpHeaders) => boolean),
|
||||
keys?: string[]
|
||||
): mock.IRequestHandler;
|
||||
|
||||
/**
|
||||
* Creates a new request expectation for POST requests.
|
||||
* Throws a preformatted error if expectation(s) don't match supplied string, regular expression, object, or if function returns false.
|
||||
* Returns an object with respond method that controls how a matched request is handled.
|
||||
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
||||
* @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation.
|
||||
* @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
|
||||
* @param keys Array of keys to assign to regex matches in the request url.
|
||||
*/
|
||||
expectPOST(url: string | RegExp | ((url: string) => boolean), data?: string | RegExp | Object | ((data: string) => boolean), headers?: Object, keys?: Object[]): mock.IRequestHandler;
|
||||
/**
|
||||
* Creates a new request expectation for POST requests.
|
||||
* Throws a preformatted error if expectation(s) don't match supplied string, regular expression, object, or if function returns false.
|
||||
* Returns an object with respond method that controls how a matched request is handled.
|
||||
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
||||
* @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation.
|
||||
* @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
|
||||
* @param keys Array of keys to assign to regex matches in the request url.
|
||||
*/
|
||||
expectPOST(
|
||||
url: string | RegExp | ((url: string) => boolean),
|
||||
data?: string | RegExp | object | ((data: string) => boolean),
|
||||
headers?: mock.IHttpHeaders | ((headers: mock.IHttpHeaders) => boolean),
|
||||
keys?: string[]
|
||||
): mock.IRequestHandler;
|
||||
|
||||
/**
|
||||
* Creates a new request expectation for PUT requests.
|
||||
* Throws a preformatted error if expectation(s) don't match supplied string, regular expression, object, or if function returns false.
|
||||
* Returns an object with respond method that controls how a matched request is handled.
|
||||
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
||||
* @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation.
|
||||
* @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
|
||||
* @param keys Array of keys to assign to regex matches in the request url.
|
||||
*/
|
||||
expectPUT(url: string | RegExp | ((url: string) => boolean), data?: string | RegExp | Object | ((data: string) => boolean), headers?: Object, keys?: Object[]): mock.IRequestHandler;
|
||||
/**
|
||||
* Creates a new request expectation for PUT requests.
|
||||
* Throws a preformatted error if expectation(s) don't match supplied string, regular expression, object, or if function returns false.
|
||||
* Returns an object with respond method that controls how a matched request is handled.
|
||||
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
||||
* @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation.
|
||||
* @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
|
||||
* @param keys Array of keys to assign to regex matches in the request url.
|
||||
*/
|
||||
expectPUT(
|
||||
url: string | RegExp | ((url: string) => boolean),
|
||||
data?: string | RegExp | object | ((data: string) => boolean),
|
||||
headers?: mock.IHttpHeaders | ((headers: mock.IHttpHeaders) => boolean),
|
||||
keys?: string[]
|
||||
): mock.IRequestHandler;
|
||||
|
||||
/**
|
||||
* Creates a new backend definition.
|
||||
* Returns an object with respond method that controls how a matched request is handled.
|
||||
* @param method HTTP method.
|
||||
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
||||
* @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation.
|
||||
* @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
|
||||
* @param keys Array of keys to assign to regex matches in the request url.
|
||||
*/
|
||||
when(method: string, url: string | RegExp | ((url: string) => boolean), data?: string | RegExp | Object | ((data: string) => boolean), headers?: Object | ((object: Object) => boolean), keys?: Object[]): mock.IRequestHandler;
|
||||
/**
|
||||
* Creates a new request expectation that compares only with the requested route.
|
||||
* This method offers colon delimited matching of the url path, ignoring the query string.
|
||||
* This allows declarations similar to how application routes are configured with `$routeProvider`.
|
||||
* As this method converts the definition url to regex, declaration order is important.
|
||||
* @param method HTTP method
|
||||
* @param url HTTP url string that supports colon param matching
|
||||
*/
|
||||
expectRoute(method: string, url: string): mock.IRequestHandler;
|
||||
|
||||
/**
|
||||
* Creates a new backend definition for DELETE requests.
|
||||
* Returns an object with respond method that controls how a matched request is handled.
|
||||
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
||||
* @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
|
||||
* @param keys Array of keys to assign to regex matches in the request url.
|
||||
*/
|
||||
whenDELETE(url: string | RegExp | ((url: string) => boolean), headers?: Object | ((object: Object) => boolean), keys?: Object[]): mock.IRequestHandler;
|
||||
/**
|
||||
* Creates a new backend definition.
|
||||
* Returns an object with respond method that controls how a matched request is handled.
|
||||
* @param method HTTP method.
|
||||
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
||||
* @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation.
|
||||
* @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
|
||||
* @param keys Array of keys to assign to regex matches in the request url.
|
||||
*/
|
||||
when(
|
||||
method: string,
|
||||
url: string | RegExp | ((url: string) => boolean),
|
||||
data?: string | RegExp | object | ((data: string) => boolean),
|
||||
headers?: mock.IHttpHeaders | ((headers: mock.IHttpHeaders) => boolean),
|
||||
keys?: string[]
|
||||
): mock.IRequestHandler;
|
||||
|
||||
/**
|
||||
* Creates a new backend definition for GET requests.
|
||||
* Returns an object with respond method that controls how a matched request is handled.
|
||||
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
||||
* @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
|
||||
* @param keys Array of keys to assign to regex matches in request url described above
|
||||
* @param keys Array of keys to assign to regex matches in the request url.
|
||||
*/
|
||||
whenGET(url: string | RegExp | ((url: string) => boolean), headers?: Object | ((object: Object) => boolean), keys?: Object[]): mock.IRequestHandler;
|
||||
/**
|
||||
* Creates a new backend definition for DELETE requests.
|
||||
* Returns an object with respond method that controls how a matched request is handled.
|
||||
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
||||
* @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
|
||||
* @param keys Array of keys to assign to regex matches in the request url.
|
||||
*/
|
||||
whenDELETE(
|
||||
url: string | RegExp | ((url: string) => boolean),
|
||||
headers?: mock.IHttpHeaders | ((headers: mock.IHttpHeaders) => boolean),
|
||||
keys?: string[]
|
||||
): mock.IRequestHandler;
|
||||
|
||||
/**
|
||||
* Creates a new backend definition for HEAD requests.
|
||||
* Returns an object with respond method that controls how a matched request is handled.
|
||||
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
||||
* @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
|
||||
* @param keys Array of keys to assign to regex matches in the request url.
|
||||
*/
|
||||
whenHEAD(url: string | RegExp | ((url: string) => boolean), headers?: Object | ((object: Object) => boolean), keys?: Object[]): mock.IRequestHandler;
|
||||
/**
|
||||
* Creates a new backend definition for GET requests.
|
||||
* Returns an object with respond method that controls how a matched request is handled.
|
||||
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
||||
* @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
|
||||
* @param keys Array of keys to assign to regex matches in request url described above
|
||||
* @param keys Array of keys to assign to regex matches in the request url.
|
||||
*/
|
||||
whenGET(
|
||||
url: string | RegExp | ((url: string) => boolean),
|
||||
headers?: mock.IHttpHeaders | ((headers: mock.IHttpHeaders) => boolean),
|
||||
keys?: string[]
|
||||
): mock.IRequestHandler;
|
||||
|
||||
/**
|
||||
* Creates a new backend definition for JSONP requests.
|
||||
* Returns an object with respond method that controls how a matched request is handled.
|
||||
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
||||
* @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
|
||||
* @param keys Array of keys to assign to regex matches in the request url.
|
||||
*/
|
||||
whenJSONP(url: string | RegExp | ((url: string) => boolean), keys?: Object[]): mock.IRequestHandler;
|
||||
/**
|
||||
* Creates a new backend definition for HEAD requests.
|
||||
* Returns an object with respond method that controls how a matched request is handled.
|
||||
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
||||
* @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
|
||||
* @param keys Array of keys to assign to regex matches in the request url.
|
||||
*/
|
||||
whenHEAD(
|
||||
url: string | RegExp | ((url: string) => boolean),
|
||||
headers?: mock.IHttpHeaders | ((headers: mock.IHttpHeaders) => boolean),
|
||||
keys?: string[]
|
||||
): mock.IRequestHandler;
|
||||
|
||||
/**
|
||||
* Creates a new backend definition for PATCH requests.
|
||||
* Returns an object with respond method that controls how a matched request is handled.
|
||||
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
||||
* @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation.
|
||||
* @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
|
||||
* @param keys Array of keys to assign to regex matches in the request url.
|
||||
*/
|
||||
whenPATCH(url: string | RegExp | ((url: string) => boolean), data?: string | RegExp | Object | ((data: string) => boolean), headers?: Object | ((object: Object) => boolean), keys?: Object[]): mock.IRequestHandler;
|
||||
/**
|
||||
* Creates a new backend definition for JSONP requests.
|
||||
* Returns an object with respond method that controls how a matched request is handled.
|
||||
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
||||
* @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
|
||||
* @param keys Array of keys to assign to regex matches in the request url.
|
||||
*/
|
||||
whenJSONP(
|
||||
url: string | RegExp | ((url: string) => boolean),
|
||||
keys?: string[]
|
||||
): mock.IRequestHandler;
|
||||
|
||||
/**
|
||||
* Creates a new backend definition for POST requests.
|
||||
* Returns an object with respond method that controls how a matched request is handled.
|
||||
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
||||
* @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation.
|
||||
* @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
|
||||
* @param keys Array of keys to assign to regex matches in the request url.
|
||||
*/
|
||||
whenPOST(url: string | RegExp | ((url: string) => boolean), data?: string | RegExp | Object | ((data: string) => boolean), headers?: Object | ((object: Object) => boolean), keys?: Object[]): mock.IRequestHandler;
|
||||
/**
|
||||
* Creates a new backend definition for PATCH requests.
|
||||
* Returns an object with respond method that controls how a matched request is handled.
|
||||
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
||||
* @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation.
|
||||
* @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
|
||||
* @param keys Array of keys to assign to regex matches in the request url.
|
||||
*/
|
||||
whenPATCH(
|
||||
url: string | RegExp | ((url: string) => boolean),
|
||||
data?: string | RegExp | object | ((data: string) => boolean),
|
||||
headers?: mock.IHttpHeaders | ((headers: mock.IHttpHeaders) => boolean),
|
||||
keys?: string[]
|
||||
): mock.IRequestHandler;
|
||||
|
||||
/**
|
||||
* Creates a new backend definition for PUT requests.
|
||||
* Returns an object with respond method that controls how a matched request is handled.
|
||||
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
||||
* @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation.
|
||||
* @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
|
||||
* @param keys Array of keys to assign to regex matches in the request url.
|
||||
*/
|
||||
whenPUT(url: string | RegExp | ((url: string) => boolean), data?: string | RegExp | Object | ((data: string) => boolean), headers?: Object | ((object: Object) => boolean), keys?: Object[]): mock.IRequestHandler;
|
||||
/**
|
||||
* Creates a new backend definition for POST requests.
|
||||
* Returns an object with respond method that controls how a matched request is handled.
|
||||
* @param url HTTP url string, regular expression or function that receives a url and returns true
|
||||
* if the url matches the current definition.
|
||||
* @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation.
|
||||
* @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
|
||||
* @param keys Array of keys to assign to regex matches in the request url.
|
||||
*/
|
||||
whenPOST(
|
||||
url: string | RegExp | ((url: string) => boolean),
|
||||
data?: string | RegExp | object | ((data: string) => boolean),
|
||||
headers?: mock.IHttpHeaders | ((headers: mock.IHttpHeaders) => boolean),
|
||||
keys?: string[]
|
||||
): mock.IRequestHandler;
|
||||
|
||||
/**
|
||||
* Creates a new backend definition for PUT requests.
|
||||
* Returns an object with respond method that controls how a matched request is handled.
|
||||
* @param url HTTP url string, regular expression or function that receives a url and returns true
|
||||
* if the url matches the current definition.
|
||||
* @param data HTTP request body or function that receives data string and returns true if the data
|
||||
* is as expected.
|
||||
* @param headers HTTP headers or function that receives http header object and returns true if the
|
||||
* headers match the current definition.
|
||||
* @param keys Array of keys to assign to regex matches in the request url.
|
||||
*/
|
||||
whenPUT(
|
||||
url: string | RegExp | ((url: string) => boolean),
|
||||
data?: string | RegExp | object | ((data: string) => boolean),
|
||||
headers?: mock.IHttpHeaders | ((headers: mock.IHttpHeaders) => boolean),
|
||||
keys?: string[]
|
||||
): mock.IRequestHandler;
|
||||
|
||||
/**
|
||||
* Creates a new backend definition that compares only with the requested route.
|
||||
* This method offers colon delimited matching of the url path, ignoring the query string.
|
||||
* This allows declarations similar to how application routes are configured with `$routeProvider`.
|
||||
* As this method converts the definition url to regex, declaration order is important.
|
||||
* @param method HTTP method.
|
||||
* @param url HTTP url string that supports colon param matching.
|
||||
*/
|
||||
whenRoute(method: string, url: string): mock.IRequestHandler;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// AnimateService
|
||||
// see https://docs.angularjs.org/api/ngMock/service/$animate
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
module animate {
|
||||
namespace animate {
|
||||
interface IAnimateService {
|
||||
|
||||
/**
|
||||
* This method will close all pending animations (both Javascript and CSS) and it will also flush any remaining animation frames and/or callbacks.
|
||||
* This method will close all pending animations (both Javascript and CSS) and it will also flush any remaining
|
||||
* animation frames and/or callbacks.
|
||||
*/
|
||||
closeAndFlush(): void;
|
||||
|
||||
/**
|
||||
* This method is used to flush the pending callbacks and animation frames to either start an animation or conclude an animation. Note that this will not actually close an actively running animation (see `closeAndFlush()` for that).
|
||||
* This method is used to flush the pending callbacks and animation frames to either start
|
||||
* an animation or conclude an animation. Note that this will not actually close an
|
||||
* actively running animation (see `closeAndFlush()`} for that).
|
||||
*/
|
||||
flush(): void;
|
||||
}
|
||||
}
|
||||
|
||||
export module mock {
|
||||
// returned interface by the the mocked HttpBackendService expect/when methods
|
||||
namespace mock {
|
||||
/** Object returned by the the mocked HttpBackendService expect/when methods */
|
||||
interface IRequestHandler {
|
||||
|
||||
/**
|
||||
* Controls the response for a matched request using a function to construct the response.
|
||||
* Returns the RequestHandler object for possible overrides.
|
||||
* @param func Function that receives the request HTTP method, url, data, headers, and an array of keys to regex matches in the request url and returns an array containing response status (number), data, headers, and status text.
|
||||
*/
|
||||
respond(func: ((method: string, url: string, data: string | Object, headers: Object, params?: any) => [number, string | Object, Object, string])): IRequestHandler;
|
||||
|
||||
/**
|
||||
* Controls the response for a matched request using supplied static data to construct the response.
|
||||
* Returns the RequestHandler object for possible overrides.
|
||||
* @param status HTTP status code to add to the response.
|
||||
* @param data Data to add to the response.
|
||||
* @param headers Headers object to add to the response.
|
||||
* @param responseText Response text to add to the response.
|
||||
*/
|
||||
respond(status: number, data: string | Object, headers?: Object, responseText?: string): IRequestHandler;
|
||||
|
||||
/**
|
||||
* Controls the response for a matched request using the HTTP status code 200 and supplied static data to construct the response.
|
||||
* Returns the RequestHandler object for possible overrides.
|
||||
* @param data Data to add to the response.
|
||||
* @param headers Headers object to add to the response.
|
||||
* @param responseText Response text to add to the response.
|
||||
*/
|
||||
respond(data: string | Object, headers?: Object, responseText?: string): IRequestHandler;
|
||||
|
||||
// Available when ngMockE2E is loaded
|
||||
/**
|
||||
* Any request matching a backend definition or expectation with passThrough handler will be passed through to the real backend (an XHR request will be made to the server.)
|
||||
*/
|
||||
* Controls the response for a matched request using a function to construct the response.
|
||||
* Returns the RequestHandler object for possible overrides.
|
||||
* @param func Function that receives the request HTTP method, url, data, headers, and an array of keys
|
||||
* to regex matches in the request url and returns an array containing response status (number), data,
|
||||
* headers, and status text.
|
||||
*/
|
||||
respond(
|
||||
func: ((
|
||||
method: string,
|
||||
url: string,
|
||||
data: string | object,
|
||||
headers: IHttpHeaders,
|
||||
params: { [key: string]: string }
|
||||
) => [number, string | object, IHttpHeaders, string])
|
||||
): IRequestHandler;
|
||||
|
||||
/**
|
||||
* Controls the response for a matched request using supplied static data to construct the response.
|
||||
* Returns the RequestHandler object for possible overrides.
|
||||
* @param status HTTP status code to add to the response.
|
||||
* @param data Data to add to the response.
|
||||
* @param headers Headers object to add to the response.
|
||||
* @param responseText Response text to add to the response.
|
||||
*/
|
||||
respond(
|
||||
status: number,
|
||||
data: string | object,
|
||||
headers?: IHttpHeaders,
|
||||
responseText?: string
|
||||
): IRequestHandler;
|
||||
|
||||
/**
|
||||
* Controls the response for a matched request using the HTTP status code 200 and supplied static data to construct the response.
|
||||
* Returns the RequestHandler object for possible overrides.
|
||||
* @param data Data to add to the response.
|
||||
* @param headers Headers object to add to the response.
|
||||
* @param responseText Response text to add to the response.
|
||||
*/
|
||||
respond(
|
||||
data: string | object,
|
||||
headers?: IHttpHeaders,
|
||||
responseText?: string
|
||||
): IRequestHandler;
|
||||
|
||||
/**
|
||||
* Any request matching a backend definition or expectation with passThrough handler will be
|
||||
* passed through to the real backend (an XHR request will be made to the server.)
|
||||
* Available when ngMockE2E is loaded
|
||||
*/
|
||||
passThrough(): IRequestHandler;
|
||||
}
|
||||
|
||||
interface IHttpHeaders {
|
||||
[headerName: string]: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* Contains additional event data used by the `browserTrigger` function when creating an event.
|
||||
*/
|
||||
interface IBrowserTriggerEventData {
|
||||
/**
|
||||
* [Event.bubbles](https://developer.mozilla.org/docs/Web/API/Event/bubbles).
|
||||
* Not applicable to all events.
|
||||
*/
|
||||
bubbles?: boolean;
|
||||
/**
|
||||
* [Event.cancelable](https://developer.mozilla.org/docs/Web/API/Event/cancelable).
|
||||
* Not applicable to all events.
|
||||
*/
|
||||
cancelable?: boolean;
|
||||
/**
|
||||
* [charCode](https://developer.mozilla.org/docs/Web/API/KeyboardEvent/charcode)
|
||||
* for keyboard events (keydown, keypress, and keyup).
|
||||
*/
|
||||
charcode?: number;
|
||||
/**
|
||||
* The elapsedTime for
|
||||
* [TransitionEvent](https://developer.mozilla.org/docs/Web/API/TransitionEvent)
|
||||
* and [AnimationEvent](https://developer.mozilla.org/docs/Web/API/AnimationEvent).
|
||||
*/
|
||||
elapsedTime?: number;
|
||||
/**
|
||||
* [keyCode](https://developer.mozilla.org/docs/Web/API/KeyboardEvent/keycode)
|
||||
* for keyboard events (keydown, keypress, and keyup).
|
||||
*/
|
||||
keycode?: number;
|
||||
/**
|
||||
* An array of possible modifier keys (ctrl, alt, shift, meta) for
|
||||
* [MouseEvent](https://developer.mozilla.org/docs/Web/API/MouseEvent) and
|
||||
* keyboard events (keydown, keypress, and keyup).
|
||||
*/
|
||||
keys?: Array<'ctrl' | 'alt' | 'shift' | 'meta'>;
|
||||
/**
|
||||
* The [relatedTarget](https://developer.mozilla.org/docs/Web/API/MouseEvent/relatedTarget)
|
||||
* for [MouseEvent](https://developer.mozilla.org/docs/Web/API/MouseEvent).
|
||||
*/
|
||||
relatedTarget?: Node;
|
||||
/**
|
||||
* [which](https://developer.mozilla.org/docs/Web/API/KeyboardEvent/which)
|
||||
* for keyboard events (keydown, keypress, and keyup).
|
||||
*/
|
||||
which?: number;
|
||||
/**
|
||||
* x-coordinates for [MouseEvent](https://developer.mozilla.org/docs/Web/API/MouseEvent)
|
||||
* and [TouchEvent](https://developer.mozilla.org/docs/Web/API/TouchEvent).
|
||||
*/
|
||||
x?: number;
|
||||
/**
|
||||
* y-coordinates for [MouseEvent](https://developer.mozilla.org/docs/Web/API/MouseEvent)
|
||||
* and [TouchEvent](https://developer.mozilla.org/docs/Web/API/TouchEvent).
|
||||
*/
|
||||
y?: number;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// functions attached to global object (window)
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//Use `angular.mock.module` instead of `module`, as `module` conflicts with commonjs.
|
||||
//declare var module: (...modules: any[]) => any;
|
||||
// Use `angular.mock.module` instead of `module`, as `module` conflicts with commonjs.
|
||||
// declare var module: (...modules: any[]) => any;
|
||||
declare global {
|
||||
export var inject: angular.IInjectStatic;
|
||||
const inject: angular.IInjectStatic;
|
||||
|
||||
/**
|
||||
* This is a global (window) function that is only available when the `ngMock` module is included.
|
||||
* It can be used to trigger a native browser event on an element, which is useful for unit testing.
|
||||
*
|
||||
* @param element Either a wrapped jQuery/jqLite node or a DOM element
|
||||
* @param eventType Optional event type. If none is specified, the function tries to determine
|
||||
* the right event type for the element, e.g. `change` for `input[text]`.
|
||||
* @param eventData An optional object which contains additional event data used when creating the event.
|
||||
*/
|
||||
function browserTrigger(
|
||||
element: JQuery | Element,
|
||||
eventType?: string,
|
||||
eventData?: angular.mock.IBrowserTriggerEventData
|
||||
): void;
|
||||
}
|
||||
|
||||
Vendored
+4
-4
@@ -1,14 +1,14 @@
|
||||
declare module "angular-mocks/ngMock" {
|
||||
var _: string;
|
||||
const _: string;
|
||||
export = _;
|
||||
}
|
||||
|
||||
declare module "angular-mocks/ngMockE2E" {
|
||||
var _: string;
|
||||
const _: string;
|
||||
export = _;
|
||||
}
|
||||
|
||||
declare module "angular-mocks/ngAnimateMock" {
|
||||
var _: string;
|
||||
const _: string;
|
||||
export = _;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,79 +1,10 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"adjacent-overload-signatures": false,
|
||||
"array-type": false,
|
||||
"arrow-return-shorthand": false,
|
||||
"ban-types": false,
|
||||
"callable-types": false,
|
||||
"comment-format": false,
|
||||
"dt-header": false,
|
||||
"eofline": false,
|
||||
"export-just-namespace": false,
|
||||
"import-spacing": false,
|
||||
"interface-name": false,
|
||||
"interface-over-type-literal": false,
|
||||
"jsdoc-format": false,
|
||||
"max-line-length": false,
|
||||
"member-access": false,
|
||||
"new-parens": false,
|
||||
"no-any-union": false,
|
||||
"no-boolean-literal-compare": false,
|
||||
"no-conditional-assignment": false,
|
||||
"no-consecutive-blank-lines": false,
|
||||
"no-construct": false,
|
||||
"no-declare-current-package": false,
|
||||
"no-duplicate-imports": false,
|
||||
"no-duplicate-variable": false,
|
||||
"no-empty-interface": false,
|
||||
"no-for-in-array": false,
|
||||
"no-inferrable-types": false,
|
||||
"no-internal-module": false,
|
||||
"no-irregular-whitespace": false,
|
||||
"no-mergeable-namespace": false,
|
||||
"no-misused-new": false,
|
||||
"no-namespace": false,
|
||||
"no-object-literal-type-assertion": false,
|
||||
"no-padding": false,
|
||||
"no-redundant-jsdoc": false,
|
||||
"no-redundant-jsdoc-2": false,
|
||||
"no-redundant-undefined": false,
|
||||
"no-reference-import": false,
|
||||
"no-relative-import-in-test": false,
|
||||
"no-self-import": false,
|
||||
"no-single-declare-module": false,
|
||||
"no-string-throw": false,
|
||||
"no-unnecessary-callback-wrapper": false,
|
||||
"no-unnecessary-class": false,
|
||||
"no-unnecessary-generics": false,
|
||||
"no-unnecessary-qualifier": false,
|
||||
"no-unnecessary-type-assertion": false,
|
||||
"no-useless-files": false,
|
||||
"no-var-keyword": false,
|
||||
"no-var-requires": false,
|
||||
"no-void-expression": false,
|
||||
"no-trailing-whitespace": false,
|
||||
"object-literal-key-quotes": false,
|
||||
"object-literal-shorthand": false,
|
||||
"one-line": false,
|
||||
"one-variable-per-declaration": false,
|
||||
"only-arrow-functions": false,
|
||||
"prefer-conditional-expression": false,
|
||||
"prefer-const": false,
|
||||
"prefer-declare-function": false,
|
||||
"prefer-for-of": false,
|
||||
"prefer-method-signature": false,
|
||||
"prefer-template": false,
|
||||
"radix": false,
|
||||
"semicolon": false,
|
||||
"space-before-function-paren": false,
|
||||
"space-within-parens": false,
|
||||
"strict-export-declare-modifiers": false,
|
||||
"trim-file": false,
|
||||
"triple-equals": false,
|
||||
"typedef-whitespace": false,
|
||||
"unified-signatures": false,
|
||||
"void-return": false,
|
||||
"whitespace": false
|
||||
}
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"callable-types": false,
|
||||
"interface-name": false,
|
||||
"no-declare-current-package": false,
|
||||
"no-unnecessary-generics": false,
|
||||
"only-arrow-functions": false
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+2
-2
@@ -772,7 +772,7 @@ export interface VoidTypeAnnotation extends Node {
|
||||
export interface JSXAttribute extends Node {
|
||||
type: "JSXAttribute";
|
||||
name: JSXIdentifier | JSXNamespacedName;
|
||||
value: JSXElement | StringLiteral | JSXExpressionContainer;
|
||||
value: JSXElement | StringLiteral | JSXExpressionContainer | null;
|
||||
}
|
||||
|
||||
export interface JSXClosingElement extends Node {
|
||||
@@ -1424,7 +1424,7 @@ export function objectTypeProperty(key?: Expression, value?: FlowTypeAnnotation)
|
||||
export function qualifiedTypeIdentifier(id?: Identifier, qualification?: Identifier | QualifiedTypeIdentifier): QualifiedTypeIdentifier;
|
||||
export function unionTypeAnnotation(types?: FlowTypeAnnotation[]): UnionTypeAnnotation;
|
||||
export function voidTypeAnnotation(): VoidTypeAnnotation;
|
||||
export function jSXAttribute(name?: JSXIdentifier | JSXNamespacedName, value?: JSXElement | StringLiteral | JSXExpressionContainer): JSXAttribute;
|
||||
export function jSXAttribute(name?: JSXIdentifier | JSXNamespacedName, value?: JSXElement | StringLiteral | JSXExpressionContainer | null): JSXAttribute;
|
||||
export function jSXClosingElement(name?: JSXIdentifier | JSXMemberExpression): JSXClosingElement;
|
||||
export function jSXElement(openingElement?: JSXOpeningElement, closingElement?: JSXClosingElement, children?: Array<JSXElement | JSXExpressionContainer | JSXText>, selfClosing?: boolean): JSXElement;
|
||||
export function jSXEmptyExpression(): JSXEmptyExpression;
|
||||
|
||||
Vendored
+1
-1
@@ -2,7 +2,7 @@
|
||||
// Project: https://github.com/wardbell/bardjs
|
||||
// Definitions by: Andrew Archibald <https://github.com/TepigMC>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
// TypeScript Version: 2.4
|
||||
|
||||
/// <reference types="angular" />
|
||||
/// <reference types="chai" />
|
||||
|
||||
Vendored
+12
-8
@@ -3,12 +3,16 @@
|
||||
// Definitions by: Leonid Logvinov <https://github.com/LogvinovLeon>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
interface BlockiesIcon {
|
||||
toDataURL(): string;
|
||||
}
|
||||
interface BlockiesConfig {
|
||||
seed: string;
|
||||
}
|
||||
declare function blockies(config: BlockiesConfig): BlockiesIcon;
|
||||
|
||||
declare function blockies(config?: blockies.BlockiesConfig): HTMLCanvasElement;
|
||||
export = blockies;
|
||||
|
||||
declare namespace blockies {
|
||||
interface BlockiesConfig {
|
||||
size?: number;
|
||||
scale?: number;
|
||||
seed?: string;
|
||||
color?: string;
|
||||
bgcolor?: string;
|
||||
spotcolor?: string;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": ["es6"],
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
|
||||
Vendored
+1
-1
@@ -354,7 +354,7 @@ export type TooltipEvent = "show.bs.tooltip" | "shown.bs.tooltip" | "hide.bs.too
|
||||
// --------------------------------------------------------------------------------------
|
||||
|
||||
declare global {
|
||||
interface JQuery<TElement extends Node = HTMLElement> extends Iterable<TElement> {
|
||||
interface JQuery<TElement = HTMLElement> {
|
||||
alert(action?: "close" | "dispose"): this;
|
||||
|
||||
button(action: "toggle" | "dispose"): this;
|
||||
|
||||
Vendored
+1
-1
@@ -182,7 +182,7 @@ export class ObjectID {
|
||||
* @param {number} time optional parameter allowing to pass in a second based timestamp.
|
||||
* @return {string} return the 12 byte id binary string.
|
||||
*/
|
||||
generate(time?: number): string;
|
||||
generate(time?: number): Buffer;
|
||||
/**
|
||||
* Returns the generation date (accurate up to the second) that this ID was generated.
|
||||
* @return {date} the generation date
|
||||
|
||||
@@ -24,7 +24,12 @@ let array = [ 1, 2, 3 ];
|
||||
chai.spy.on(array, 'push');
|
||||
|
||||
// or you can track multiple object's methods
|
||||
chai.spy.on(array, 'push', 'pop');
|
||||
chai.spy.on(array, ['push', 'pop']);
|
||||
|
||||
// or you can track multiple object's methods
|
||||
chai.spy.on(array, 'push', function(item) {
|
||||
array.push(item);
|
||||
});
|
||||
|
||||
array.push(5);
|
||||
|
||||
@@ -149,4 +154,20 @@ spy.should.not.have.been.called.above(3);
|
||||
expect(spy).to.have.been.called.below(3);
|
||||
expect(spy).to.not.have.been.called.lt(3);
|
||||
spy.should.have.been.called.lt(3);
|
||||
spy.should.not.have.been.called.below(3);
|
||||
spy.should.not.have.been.called.below(3);
|
||||
|
||||
// You can also create sandbox
|
||||
let sb = chai.spy.sandbox();
|
||||
|
||||
sb.on(array, 'pop', () => {
|
||||
return 1;
|
||||
})
|
||||
|
||||
let one = array.pop();
|
||||
expect(one).to.equal(1);
|
||||
|
||||
// Can restore methods in sandbox
|
||||
sb.restore();
|
||||
array.push(2);
|
||||
let two = array.pop();
|
||||
expect(two).to.equal(2);
|
||||
|
||||
Vendored
+108
-54
@@ -1,6 +1,8 @@
|
||||
// Type definitions for chai-spies
|
||||
// Type definitions for chai-spies 1.0.0
|
||||
// Project: https://github.com/chaijs/chai-spies
|
||||
// Definitions by: Ilya Kuznetsov <https://github.com/kuzn-ilya>
|
||||
// Harm van der Werf <https://github.com/harm-less>
|
||||
// Jouni Suorsa <https://github.com/jounisuo>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="chai" />
|
||||
@@ -21,7 +23,7 @@ declare namespace Chai {
|
||||
* ```ts
|
||||
* expect(spy).to.be.spy;
|
||||
* spy.should.be.spy;
|
||||
* ```
|
||||
* ```
|
||||
*/
|
||||
spy: Assertion;
|
||||
|
||||
@@ -32,7 +34,7 @@ declare namespace Chai {
|
||||
* expect(spy).to.have.been.called();
|
||||
* spy.should.have.been.called();
|
||||
* ```
|
||||
* Note that ```called``` can be used as a chainable method.
|
||||
* Note that ```called``` can be used as a chainable method.
|
||||
*/
|
||||
called: ChaiSpies.Called;
|
||||
|
||||
@@ -61,7 +63,32 @@ declare namespace Chai {
|
||||
}
|
||||
|
||||
declare namespace ChaiSpies {
|
||||
interface Sandbox {
|
||||
/**
|
||||
* #### chai.spy.on (function)
|
||||
*
|
||||
* Wraps an object method into spy. All calls will pass through to the original function.
|
||||
*
|
||||
* @param {Object} object
|
||||
* @param {String} methodNames names to spy on
|
||||
* @param {function} fn replacement function
|
||||
* @returns function to actually call
|
||||
*/
|
||||
on(object: Object, methodNames: string | string[], fn?: (parameters: any[]|any) => any): any;
|
||||
|
||||
/**
|
||||
* #### chai.spy.restore (function)
|
||||
*
|
||||
* Restores previously wrapped object's method.
|
||||
* Restores all spied objects of a sandbox if called without parameters.
|
||||
*
|
||||
* @function
|
||||
* @param {Object} [object]
|
||||
* @param {String|String[]} [methods] name or names
|
||||
* @return {Sandbox} Sandbox instance
|
||||
*/
|
||||
restore(object?: Object, methodNames?: string | string[]): void;
|
||||
}
|
||||
interface Spy {
|
||||
/**
|
||||
* #### chai.spy (function)
|
||||
@@ -72,9 +99,9 @@ declare namespace ChaiSpies {
|
||||
* var spy = chai.spy(original)
|
||||
* , e_spy = chai.spy();
|
||||
* ```
|
||||
* @param fn function to spy on. @default ```function () {}```
|
||||
* @param fn function to spy on. @default ```function () {}```
|
||||
* @returns function to actually call
|
||||
*/
|
||||
*/
|
||||
(): SpyFunc0Proxy<void>;
|
||||
<R>(fn: SpyFunc0<R>): SpyFunc0Proxy<R>;
|
||||
<A1, R>(fn: SpyFunc1<A1, R>): SpyFunc1Proxy<A1, R>;
|
||||
@@ -107,10 +134,11 @@ declare namespace ChaiSpies {
|
||||
* var spy = chai.spy.on(Array, 'isArray');
|
||||
* ```
|
||||
* @param {Object} object
|
||||
* @param {String} method name to spy on
|
||||
* @param {String} method names to spy on
|
||||
* @param {function} fn replacement function
|
||||
* @returns function to actually call
|
||||
*/
|
||||
on(object: Object, ...methodNames: string[]): any;
|
||||
*/
|
||||
on(object: Object, methodNames: string | string[], fn?: (parameters: any[]|any) => any): any;
|
||||
|
||||
/**
|
||||
* #### chai.spy.object (function)
|
||||
@@ -123,10 +151,24 @@ declare namespace ChaiSpies {
|
||||
* @param {String[]|Object} method names or method definitions
|
||||
* @returns object with spied methods
|
||||
*/
|
||||
object(name: string, methods: string[]): any;
|
||||
object(methods: string[]): any;
|
||||
object<T>(name: string, methods: T): T;
|
||||
object<T>(methods: T): T;
|
||||
object(name: string, methods: string[]): any;
|
||||
object(methods: string[]): any;
|
||||
object<T>(name: string, methods: T): T;
|
||||
object<T>(methods: T): T;
|
||||
|
||||
/**
|
||||
* #### chai.spy.restore (function)
|
||||
*
|
||||
* Restores spy assigned to DEFAULT sandbox
|
||||
*
|
||||
* Restores previously wrapped object's method.
|
||||
* Restores all spied objects of a sandbox if called without parameters.
|
||||
*
|
||||
* @param {Object} [object]
|
||||
* @param {String|String[]} [methods] name or names
|
||||
* @return {Sandbox} Sandbox instance
|
||||
*/
|
||||
restore(object?: Object, methodNames?: string | string[]): void;
|
||||
|
||||
/**
|
||||
* #### chai.spy.returns (function)
|
||||
@@ -141,6 +183,18 @@ declare namespace ChaiSpies {
|
||||
*/
|
||||
|
||||
returns<T>(value: T): SpyFunc0Proxy<T>;
|
||||
|
||||
/**
|
||||
* ### chai.spy.sandbox
|
||||
*
|
||||
* Creates a sandbox.
|
||||
*
|
||||
* Sandbox is a set of spies.
|
||||
* Sandbox allows to track methods on objects and restore original methods with on restore call.
|
||||
*
|
||||
* @returns {Sandbox}
|
||||
*/
|
||||
sandbox(): Sandbox;
|
||||
}
|
||||
|
||||
interface Called {
|
||||
@@ -158,12 +212,12 @@ declare namespace ChaiSpies {
|
||||
* spy.should.not.have.been.called.once;
|
||||
* ```
|
||||
*/
|
||||
once: Chai.Assertion;
|
||||
once: Chai.Assertion;
|
||||
|
||||
/**
|
||||
* ####.twice
|
||||
* Assert that a spy has been called exactly twice.
|
||||
* ```ts
|
||||
* ```ts
|
||||
* expect(spy).to.have.been.called.twice;
|
||||
* expect(spy).to.not.have.been.called.twice;
|
||||
* spy.should.have.been.called.twice;
|
||||
@@ -215,7 +269,7 @@ declare namespace ChaiSpies {
|
||||
* ```ts
|
||||
* expect(spy).to.have.been.called.above(3);
|
||||
* spy.should.not.have.been.called.above(3);
|
||||
* ```
|
||||
* ```
|
||||
*/
|
||||
above(n: number): Chai.Assertion;
|
||||
|
||||
@@ -225,7 +279,7 @@ declare namespace ChaiSpies {
|
||||
* ```ts
|
||||
* expect(spy).to.have.been.called.gt(3);
|
||||
* spy.should.not.have.been.called.gt(3);
|
||||
* ```
|
||||
* ```
|
||||
*/
|
||||
gt(n: number): Chai.Assertion;
|
||||
|
||||
@@ -235,7 +289,7 @@ declare namespace ChaiSpies {
|
||||
* ```ts
|
||||
* expect(spy).to.have.been.called.below(3);
|
||||
* spy.should.not.have.been.called.below(3);
|
||||
* ```
|
||||
* ```
|
||||
*/
|
||||
below(n: number): Chai.Assertion;
|
||||
|
||||
@@ -245,7 +299,7 @@ declare namespace ChaiSpies {
|
||||
* ```ts
|
||||
* expect(spy).to.have.been.called.lt(3);
|
||||
* spy.should.not.have.been.called.lt(3);
|
||||
* ```
|
||||
* ```
|
||||
*/
|
||||
lt(n: number): Chai.Assertion;
|
||||
}
|
||||
@@ -301,7 +355,7 @@ declare namespace ChaiSpies {
|
||||
* spy.should.have.been.called.with('foo');
|
||||
* ```
|
||||
* Will also pass for ```spy('foo', 'bar')``` and ```spy(); spy('foo')```.
|
||||
* If used with multiple arguments, assert that a spy has been called with all the given arguments at least once.
|
||||
* If used with multiple arguments, assert that a spy has been called with all the given arguments at least once.
|
||||
* ```ts
|
||||
* spy('foo', 'bar', 1);
|
||||
* expect(spy).to.have.been.called.with('bar', 'foo');
|
||||
@@ -389,7 +443,7 @@ declare namespace ChaiSpies {
|
||||
*
|
||||
* Resets __spy object parameters for instantiation and reuse
|
||||
* @returns proxy spy object
|
||||
*/
|
||||
*/
|
||||
reset(): this;
|
||||
}
|
||||
|
||||
@@ -397,77 +451,77 @@ declare namespace ChaiSpies {
|
||||
(): R;
|
||||
}
|
||||
|
||||
interface SpyFunc1<A1, R> {
|
||||
(a: A1): R;
|
||||
interface SpyFunc1<A1, R> {
|
||||
(a: A1): R;
|
||||
}
|
||||
|
||||
interface SpyFunc2<A1, A2, R> {
|
||||
(a: A1, b: A2): R;
|
||||
interface SpyFunc2<A1, A2, R> {
|
||||
(a: A1, b: A2): R;
|
||||
}
|
||||
|
||||
interface SpyFunc3<A1, A2, A3, R> {
|
||||
(a: A1, b: A2, c: A3): R;
|
||||
interface SpyFunc3<A1, A2, A3, R> {
|
||||
(a: A1, b: A2, c: A3): R;
|
||||
}
|
||||
|
||||
interface SpyFunc4<A1, A2, A3, A4, R> {
|
||||
(a: A1, b: A2, c: A3, d: A4): R;
|
||||
interface SpyFunc4<A1, A2, A3, A4, R> {
|
||||
(a: A1, b: A2, c: A3, d: A4): R;
|
||||
}
|
||||
|
||||
interface SpyFunc5<A1, A2, A3, A4, A5, R> {
|
||||
(a: A1, b: A2, c: A3, d: A4, e: A5): R;
|
||||
interface SpyFunc5<A1, A2, A3, A4, A5, R> {
|
||||
(a: A1, b: A2, c: A3, d: A4, e: A5): R;
|
||||
}
|
||||
|
||||
interface SpyFunc6<A1, A2, A3, A4, A5, A6, R> {
|
||||
(a: A1, b: A2, c: A3, d: A4, e: A5, f: A6): R;
|
||||
interface SpyFunc6<A1, A2, A3, A4, A5, A6, R> {
|
||||
(a: A1, b: A2, c: A3, d: A4, e: A5, f: A6): R;
|
||||
}
|
||||
|
||||
interface SpyFunc7<A1, A2, A3, A4, A5, A6, A7, R> {
|
||||
(a: A1, b: A2, c: A3, d: A4, e: A5, f: A6, g: A7): R;
|
||||
interface SpyFunc7<A1, A2, A3, A4, A5, A6, A7, R> {
|
||||
(a: A1, b: A2, c: A3, d: A4, e: A5, f: A6, g: A7): R;
|
||||
}
|
||||
|
||||
interface SpyFunc8<A1, A2, A3, A4, A5, A6, A7, A8, R> {
|
||||
(a: A1, b: A2, c: A3, d: A4, e: A5, f: A6, g: A7, h: A8): R;
|
||||
interface SpyFunc8<A1, A2, A3, A4, A5, A6, A7, A8, R> {
|
||||
(a: A1, b: A2, c: A3, d: A4, e: A5, f: A6, g: A7, h: A8): R;
|
||||
}
|
||||
|
||||
interface SpyFunc9<A1, A2, A3, A4, A5, A6, A7, A8, A9, R> {
|
||||
(a: A1, b: A2, c: A3, d: A4, e: A5, f: A6, g: A7, h: A8, i: A9): R;
|
||||
|
||||
interface SpyFunc9<A1, A2, A3, A4, A5, A6, A7, A8, A9, R> {
|
||||
(a: A1, b: A2, c: A3, d: A4, e: A5, f: A6, g: A7, h: A8, i: A9): R;
|
||||
}
|
||||
|
||||
interface SpyFunc10<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, R> {
|
||||
(a: A1, b: A2, c: A3, d: A4, e: A5, f: A6, g: A7, h: A8, i: A9, j: A10): R;
|
||||
|
||||
interface SpyFunc10<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, R> {
|
||||
(a: A1, b: A2, c: A3, d: A4, e: A5, f: A6, g: A7, h: A8, i: A9, j: A10): R;
|
||||
}
|
||||
|
||||
interface SpyFunc0Proxy<R> extends SpyFunc0<R>, Resetable {
|
||||
}
|
||||
|
||||
interface SpyFunc1Proxy<A1, R> extends SpyFunc1<A1, R>, Resetable {
|
||||
interface SpyFunc1Proxy<A1, R> extends SpyFunc1<A1, R>, Resetable {
|
||||
}
|
||||
|
||||
interface SpyFunc2Proxy<A1, A2, R> extends SpyFunc2<A1, A2, R>, Resetable {
|
||||
interface SpyFunc2Proxy<A1, A2, R> extends SpyFunc2<A1, A2, R>, Resetable {
|
||||
}
|
||||
|
||||
interface SpyFunc3Proxy<A1, A2, A3, R> extends SpyFunc3<A1, A2, A3, R>, Resetable {
|
||||
interface SpyFunc3Proxy<A1, A2, A3, R> extends SpyFunc3<A1, A2, A3, R>, Resetable {
|
||||
}
|
||||
|
||||
interface SpyFunc4Proxy<A1, A2, A3, A4, R> extends SpyFunc4<A1, A2, A3, A4, R>, Resetable {
|
||||
interface SpyFunc4Proxy<A1, A2, A3, A4, R> extends SpyFunc4<A1, A2, A3, A4, R>, Resetable {
|
||||
}
|
||||
|
||||
interface SpyFunc5Proxy<A1, A2, A3, A4, A5, R> extends SpyFunc5<A1, A2, A3, A4, A5, R>, Resetable {
|
||||
interface SpyFunc5Proxy<A1, A2, A3, A4, A5, R> extends SpyFunc5<A1, A2, A3, A4, A5, R>, Resetable {
|
||||
}
|
||||
|
||||
interface SpyFunc6Proxy<A1, A2, A3, A4, A5, A6, R> extends SpyFunc6<A1, A2, A3, A4, A5, A6, R>, Resetable {
|
||||
interface SpyFunc6Proxy<A1, A2, A3, A4, A5, A6, R> extends SpyFunc6<A1, A2, A3, A4, A5, A6, R>, Resetable {
|
||||
}
|
||||
|
||||
interface SpyFunc7Proxy<A1, A2, A3, A4, A5, A6, A7, R> extends SpyFunc7<A1, A2, A3, A4, A5, A6, A7, R>, Resetable {
|
||||
interface SpyFunc7Proxy<A1, A2, A3, A4, A5, A6, A7, R> extends SpyFunc7<A1, A2, A3, A4, A5, A6, A7, R>, Resetable {
|
||||
}
|
||||
|
||||
interface SpyFunc8Proxy<A1, A2, A3, A4, A5, A6, A7, A8, R> extends SpyFunc8<A1, A2, A3, A4, A5, A6, A7, A8, R>, Resetable {
|
||||
interface SpyFunc8Proxy<A1, A2, A3, A4, A5, A6, A7, A8, R> extends SpyFunc8<A1, A2, A3, A4, A5, A6, A7, A8, R>, Resetable {
|
||||
}
|
||||
|
||||
interface SpyFunc9Proxy<A1, A2, A3, A4, A5, A6, A7, A8, A9, R> extends SpyFunc9<A1, A2, A3, A4, A5, A6, A7, A8, A9, R>, Resetable {
|
||||
|
||||
interface SpyFunc9Proxy<A1, A2, A3, A4, A5, A6, A7, A8, A9, R> extends SpyFunc9<A1, A2, A3, A4, A5, A6, A7, A8, A9, R>, Resetable {
|
||||
}
|
||||
|
||||
interface SpyFunc10Proxy<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, R> extends SpyFunc10<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, R>, Resetable {
|
||||
|
||||
interface SpyFunc10Proxy<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, R> extends SpyFunc10<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, R>, Resetable {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import cosmiconfig, { CosmiconfigResult } from "cosmiconfig";
|
||||
import cosmiconfig = require("cosmiconfig");
|
||||
import { CosmiconfigResult } from "cosmiconfig";
|
||||
import * as path from "path";
|
||||
|
||||
const explorer = cosmiconfig("yourModuleName", {
|
||||
|
||||
Vendored
+52
-47
@@ -3,57 +3,62 @@
|
||||
// Definitions by: ozum <https://github.com/ozum>
|
||||
// szeck87 <https://github.com/szeck87>
|
||||
// saadq <https://github.com/saadq>
|
||||
// jinwoo <https://github.com/jinwoo>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
export interface Config {
|
||||
[key: string]: any;
|
||||
declare function cosmiconfig(moduleName: string, options?: cosmiconfig.ExplorerOptions): cosmiconfig.Explorer;
|
||||
|
||||
declare namespace cosmiconfig {
|
||||
interface Config {
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
type CosmiconfigResult = {
|
||||
config: Config;
|
||||
filepath: string;
|
||||
isEmpty?: boolean;
|
||||
} | null;
|
||||
|
||||
interface LoaderResult {
|
||||
config: Config | null;
|
||||
filepath: string;
|
||||
}
|
||||
|
||||
type SyncLoader = (filepath: string, content: string) => Config | null;
|
||||
type AsyncLoader = (filepath: string, content: string) => Config | null | Promise<object | null>;
|
||||
|
||||
interface LoaderEntry {
|
||||
sync?: SyncLoader;
|
||||
async?: AsyncLoader;
|
||||
}
|
||||
|
||||
interface Loaders {
|
||||
[key: string]: LoaderEntry;
|
||||
}
|
||||
|
||||
interface Explorer {
|
||||
search(searchFrom?: string): Promise<null | CosmiconfigResult>;
|
||||
searchSync(searchFrom?: string): null | CosmiconfigResult;
|
||||
load(loadPath: string): Promise<CosmiconfigResult>;
|
||||
loadSync(loadPath: string): CosmiconfigResult;
|
||||
clearLoadCache(): void;
|
||||
clearSearchCache(): void;
|
||||
clearCaches(): void;
|
||||
}
|
||||
|
||||
// These are the user options with defaults applied.
|
||||
interface ExplorerOptions {
|
||||
stopDir?: string;
|
||||
cache?: boolean;
|
||||
transform?: (result: CosmiconfigResult) => Promise<CosmiconfigResult> | CosmiconfigResult;
|
||||
packageProp?: string;
|
||||
loaders?: Loaders;
|
||||
searchPlaces?: string[];
|
||||
ignoreEmptySearchPlaces?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
export type CosmiconfigResult = {
|
||||
config: Config;
|
||||
filepath: string;
|
||||
isEmpty?: boolean;
|
||||
} | null;
|
||||
|
||||
export interface LoaderResult {
|
||||
config: Config | null;
|
||||
filepath: string;
|
||||
}
|
||||
|
||||
export type SyncLoader = (filepath: string, content: string) => Config | null;
|
||||
export type AsyncLoader = (filepath: string, content: string) => Config | null | Promise<object | null>;
|
||||
|
||||
export interface LoaderEntry {
|
||||
sync?: SyncLoader;
|
||||
async?: AsyncLoader;
|
||||
}
|
||||
|
||||
export interface Loaders {
|
||||
[key: string]: LoaderEntry;
|
||||
}
|
||||
|
||||
export interface Explorer {
|
||||
search(searchFrom?: string): Promise<null | CosmiconfigResult>;
|
||||
searchSync(searchFrom?: string): null | CosmiconfigResult;
|
||||
load(loadPath: string): Promise<CosmiconfigResult>;
|
||||
loadSync(loadPath: string): CosmiconfigResult;
|
||||
clearLoadCache(): void;
|
||||
clearSearchCache(): void;
|
||||
clearCaches(): void;
|
||||
}
|
||||
|
||||
// These are the user options with defaults applied.
|
||||
export interface ExplorerOptions {
|
||||
stopDir?: string;
|
||||
cache?: boolean;
|
||||
transform?: (result: CosmiconfigResult) => Promise<CosmiconfigResult> | CosmiconfigResult;
|
||||
packageProp?: string;
|
||||
loaders?: Loaders;
|
||||
searchPlaces?: string[];
|
||||
ignoreEmptySearchPlaces?: boolean;
|
||||
}
|
||||
|
||||
export default function cosmiconfig(moduleName: string, options?: ExplorerOptions): Explorer;
|
||||
export = cosmiconfig;
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
import * as CrossFilter from 'crossfilter';
|
||||
import * as d3 from "d3";
|
||||
import * as dc from "dc";
|
||||
|
||||
|
||||
interface IYelpData {
|
||||
city: string;
|
||||
review_count: number;
|
||||
|
||||
Vendored
-4
@@ -5,10 +5,6 @@
|
||||
// matthias jobst <https://github.com/MatthiasJobst>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
// this makes only sense together with d3 and crossfilter so you need the d3.d.ts and crossfilter.d.ts files
|
||||
|
||||
///<reference types="crossfilter" />
|
||||
|
||||
import * as d3 from "d3";
|
||||
|
||||
export = dc;
|
||||
|
||||
Vendored
+5
@@ -21,6 +21,11 @@ declare namespace dygraphs {
|
||||
* A per-series color definition. Used in conjunction with, and overrides, the colors option.
|
||||
*/
|
||||
color?: string;
|
||||
|
||||
/**
|
||||
* A function which plot data for this series on the chart.
|
||||
*/
|
||||
plotter?: any;
|
||||
|
||||
/**
|
||||
* Draw a small dot at each point, in addition to a line going through the point. This makes
|
||||
|
||||
Vendored
+1
-1
@@ -1173,7 +1173,7 @@ declare module 'ember' {
|
||||
* key. You can pass an optional second argument with the target value. Otherwise
|
||||
* this will match any property that evaluates to false.
|
||||
*/
|
||||
rejectBy(key: string, value?: string): NativeArray<T>;
|
||||
rejectBy(key: string, value?: any): NativeArray<T>;
|
||||
/**
|
||||
* Returns the first item in the array for which the callback returns true.
|
||||
* This method works similar to the `filter()` method defined in JavaScript 1.6
|
||||
|
||||
Vendored
+1
@@ -2222,6 +2222,7 @@ export interface VideoProps {
|
||||
translateY?: number;
|
||||
rotation?: number;
|
||||
ref?: Ref<PlaybackObject>;
|
||||
style?: StyleProp<ViewStyle>;
|
||||
}
|
||||
|
||||
export interface VideoState {
|
||||
|
||||
Vendored
+1
@@ -2202,6 +2202,7 @@ export interface VideoProps {
|
||||
translateY?: number;
|
||||
rotation?: number;
|
||||
ref?: Ref<PlaybackObject>;
|
||||
style?: StyleProp<ViewStyle>;
|
||||
}
|
||||
|
||||
export interface VideoState {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
declare var el: Element;
|
||||
declare var els: Element[];
|
||||
declare var els: HTMLElement[];
|
||||
declare var mixinFn: Function;
|
||||
|
||||
function TestComponent() {
|
||||
|
||||
@@ -60,6 +60,33 @@ map.fitBounds({
|
||||
top: 50
|
||||
});
|
||||
|
||||
/***** Pan map to bounds *****/
|
||||
map.panToBounds({
|
||||
north: 10,
|
||||
east: 10,
|
||||
west: 10,
|
||||
south: 10
|
||||
})
|
||||
|
||||
map.panToBounds({
|
||||
north: 10,
|
||||
east: 10,
|
||||
west: 10,
|
||||
south: 10
|
||||
}, 50)
|
||||
|
||||
map.panToBounds({
|
||||
east: 10,
|
||||
north: 10,
|
||||
south: 10,
|
||||
west: 10
|
||||
}, {
|
||||
bottom: 100,
|
||||
left: 150,
|
||||
right: 150,
|
||||
top: 50
|
||||
});
|
||||
|
||||
|
||||
/***** Data *****/
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -51,7 +51,7 @@ declare namespace google.maps {
|
||||
getZoom(): number;
|
||||
panBy(x: number, y: number): void;
|
||||
panTo(latLng: LatLng|LatLngLiteral): void;
|
||||
panToBounds(latLngBounds: LatLngBounds|LatLngBoundsLiteral): void;
|
||||
panToBounds(latLngBounds: LatLngBounds|LatLngBoundsLiteral, padding?: number|Padding): void;
|
||||
setCenter(latlng: LatLng|LatLngLiteral): void;
|
||||
setHeading(heading: number): void;
|
||||
setMapTypeId(mapTypeId: MapTypeId|string): void;
|
||||
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
export declare class Scroll<T> {
|
||||
|
||||
}
|
||||
Vendored
+85
@@ -0,0 +1,85 @@
|
||||
import {Company} from "intercom-client";
|
||||
|
||||
export type UserIdentifier = { "id": string } | { "user_id": string } | { "email": string }
|
||||
|
||||
export interface Avatar {
|
||||
"type": "avatar",
|
||||
"image_url": string | null
|
||||
}
|
||||
|
||||
export interface SocialProfile {
|
||||
"name": "Twitter",
|
||||
readonly "id": string | null,
|
||||
"username": string | null,
|
||||
"url": string | null
|
||||
}
|
||||
|
||||
export interface Segment {
|
||||
readonly "id": string
|
||||
}
|
||||
|
||||
export interface Tag {
|
||||
readonly "id": string
|
||||
}
|
||||
|
||||
export interface LocationData {
|
||||
"type": "location_data",
|
||||
"city_name": string | null,
|
||||
"continent_code": string | null,
|
||||
"country_code": string | null,
|
||||
"country_name": string | null,
|
||||
"latitude": number | null,
|
||||
"longitude": number | null,
|
||||
"postal_code": string | null,
|
||||
"region_name": string | null,
|
||||
"timezone": string | null
|
||||
}
|
||||
|
||||
export interface User {
|
||||
"type": "user" | "contact",
|
||||
readonly "id": string,
|
||||
"user_id": string | null,
|
||||
"email": string | null,
|
||||
"app_id"?: string,
|
||||
"phone": string | null,
|
||||
"name": string | null,
|
||||
readonly "updated_at": number,
|
||||
"last_seen_ip": string | null,
|
||||
"unsubscribed_from_emails": boolean,
|
||||
"last_request_at": number | null,
|
||||
"signed_up_at": number | null,
|
||||
readonly "created_at": number,
|
||||
"session_count": number,
|
||||
"user_agent_data": string | null,
|
||||
"pseudonym": string | null,
|
||||
"anonymous": boolean,
|
||||
"custom_attributes": {
|
||||
[key: string]: any
|
||||
},
|
||||
"avatar": Avatar,
|
||||
"location_data": LocationData | {},
|
||||
"social_profiles": {
|
||||
"type": "social_profile.list",
|
||||
"social_profiles": SocialProfile[]
|
||||
},
|
||||
"companies": {
|
||||
"type": "company.list",
|
||||
"companies": Company[]
|
||||
},
|
||||
"segments": {
|
||||
"type": "segment.list",
|
||||
"segments": Segment[]
|
||||
|
||||
},
|
||||
"tags": {
|
||||
"type": "tag.list",
|
||||
"tags": Tag[]
|
||||
}
|
||||
}
|
||||
|
||||
export interface List {
|
||||
"type": "user.list",
|
||||
"total_count": number,
|
||||
"users": User[],
|
||||
"pages": { "next"?: string, "page": number, "per_page": number, "total_pages": number }
|
||||
}
|
||||
Vendored
+33
-1
@@ -1,7 +1,10 @@
|
||||
// Type definitions for intercom-client 2.9
|
||||
// Project: https://github.com/intercom/intercom-node
|
||||
// Definitions by: Jinesh Shah <https://github.com/jineshshah36>
|
||||
// Definitions by: Jinesh Shah <https://github.com/jineshshah36>, Josef Hornych <https://github.com/peping>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.1
|
||||
import { List as UserList, User, UserIdentifier } from './User';
|
||||
import { Scroll } from './Scroll';
|
||||
|
||||
export interface IdentityVerificationOptions {
|
||||
secretKey: string;
|
||||
@@ -11,3 +14,32 @@ export interface IdentityVerificationOptions {
|
||||
export const IdentityVerification: {
|
||||
userHash(opts: IdentityVerificationOptions): string;
|
||||
};
|
||||
|
||||
export class Client {
|
||||
constructor(auth: { token: string } | { appId: string, appApiKey: string });
|
||||
constructor(username: string, password: string);
|
||||
|
||||
users: Users;
|
||||
}
|
||||
|
||||
export interface Company {
|
||||
readonly "id": string;
|
||||
}
|
||||
|
||||
export class Users {
|
||||
create(user: Partial<User>): Promise<User>;
|
||||
|
||||
update(user: UserIdentifier & Partial<User>): Promise<User>;
|
||||
|
||||
find(identifier: UserIdentifier): Promise<User>;
|
||||
|
||||
list(): Promise<UserList>;
|
||||
|
||||
listBy(params: {tag_id: string, segment_id: string}): Promise<UserList>;
|
||||
|
||||
scroll: Scroll<User>;
|
||||
|
||||
archive(): Promise<User>;
|
||||
|
||||
requestPermanentDeletion(): Promise<{id: number}>;
|
||||
}
|
||||
|
||||
Vendored
+13
-11
@@ -21,7 +21,7 @@ declare namespace Intercom_ {
|
||||
activator?: string;
|
||||
};
|
||||
company?: {
|
||||
id: string|number,
|
||||
id: string | number,
|
||||
name: string,
|
||||
created_at: number,
|
||||
plan?: string,
|
||||
@@ -33,16 +33,17 @@ declare namespace Intercom_ {
|
||||
}
|
||||
|
||||
type IntercomCommand = 'boot'
|
||||
|'shutdown'
|
||||
|'update'
|
||||
|'hide'
|
||||
|'show'
|
||||
|'showMessages'
|
||||
|'showNewMessage'
|
||||
|'onHide'
|
||||
|'onShow'
|
||||
|'onActivatorClick'
|
||||
|'trackEvent';
|
||||
| 'shutdown'
|
||||
| 'update'
|
||||
| 'hide'
|
||||
| 'show'
|
||||
| 'showMessages'
|
||||
| 'showNewMessage'
|
||||
| 'onHide'
|
||||
| 'onShow'
|
||||
| 'onUnreadCountChange'
|
||||
| 'onActivatorClick'
|
||||
| 'trackEvent';
|
||||
|
||||
interface IntercomStatic {
|
||||
(command: 'boot', param: IntercomSettings): void;
|
||||
@@ -51,6 +52,7 @@ declare namespace Intercom_ {
|
||||
(command: 'showNewMessage', param?: string): void;
|
||||
(command: 'onHide' | 'onShow' | 'onActivatorClick', param?: () => void): void;
|
||||
(command: 'trackEvent', tag?: string, metadata?: any): void;
|
||||
(command: 'onUnreadCountChange', cb: (unreadCount: number) => void): void;
|
||||
(command: IntercomCommand, param1?: any, param2?: any): void;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ Intercom('showMessages');
|
||||
Intercom('showNewMessage');
|
||||
Intercom('showNewMessage', 'pre-populated content');
|
||||
Intercom('onHide', () => { /* Do stuff */ });
|
||||
Intercom('onUnreadCountChange', (unreadCount: number) => { /* Do stuff */ });
|
||||
Intercom('onActivatorClick', () => { /* Do stuff */ });
|
||||
Intercom('trackEvent', 'invited-friend');
|
||||
|
||||
|
||||
Vendored
+2
-3
@@ -16,6 +16,7 @@
|
||||
/// <reference types="node" />
|
||||
|
||||
import Promise = require('bluebird');
|
||||
import tls = require('tls');
|
||||
|
||||
interface RedisStatic {
|
||||
new(port?: number, host?: string, options?: IORedis.RedisOptions): IORedis.Redis;
|
||||
@@ -827,9 +828,7 @@ declare namespace IORedis {
|
||||
*/
|
||||
autoResendUnfulfilledCommands?: boolean;
|
||||
lazyConnect?: boolean;
|
||||
tls?: {
|
||||
ca: Buffer;
|
||||
};
|
||||
tls?: tls.ConnectionOptions;
|
||||
sentinels?: Array<{ host: string; port: number; }>;
|
||||
name?: string;
|
||||
/**
|
||||
|
||||
@@ -29,7 +29,10 @@ new Redis({
|
||||
password: 'auth',
|
||||
db: 0,
|
||||
retryStrategy() { return false; },
|
||||
showFriendlyErrorStack: true
|
||||
showFriendlyErrorStack: true,
|
||||
tls: {
|
||||
servername: 'tlsservername'
|
||||
}
|
||||
});
|
||||
|
||||
const pub = new Redis();
|
||||
|
||||
Vendored
+10
@@ -209,6 +209,14 @@ declare namespace jest {
|
||||
readonly name: string;
|
||||
}
|
||||
|
||||
interface Each {
|
||||
(cases: any[]): (name: string, fn: (...args: any[]) => any) => void;
|
||||
(strings: TemplateStringsArray, ...placeholders: any[]): (
|
||||
name: string,
|
||||
fn: (arg: any) => any
|
||||
) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a test closure
|
||||
*/
|
||||
@@ -227,6 +235,7 @@ declare namespace jest {
|
||||
only: It;
|
||||
skip: It;
|
||||
concurrent: It;
|
||||
each: Each;
|
||||
}
|
||||
|
||||
interface Describe {
|
||||
@@ -234,6 +243,7 @@ declare namespace jest {
|
||||
(name: number | string | Function | FunctionLike, fn: EmptyFunction): void;
|
||||
only: Describe;
|
||||
skip: Describe;
|
||||
each: Each;
|
||||
}
|
||||
|
||||
interface MatcherUtils {
|
||||
|
||||
@@ -956,3 +956,103 @@ const testJestConfig = (defaults: jest.DefaultOptions) => {
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
// https://github.com/DefinitelyTyped/DefinitelyTyped/issues/26368
|
||||
|
||||
describe.each([[1, 1, 2], [1, 2, 3], [2, 1, 3]])(
|
||||
".add(%i, %i)",
|
||||
(a: number, b: number, expected: number) => {
|
||||
test(`returns ${expected}`, () => {
|
||||
expect(a + b).toBe(expected);
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
interface Case {
|
||||
a: number;
|
||||
b: number;
|
||||
expected: number;
|
||||
}
|
||||
|
||||
describe.each`
|
||||
a | b | expected
|
||||
${1} | ${1} | ${2}
|
||||
${1} | ${2} | ${3}
|
||||
${2} | ${1} | ${3}
|
||||
`("$a + $b", ({ a, b, expected }: Case) => {
|
||||
test(`returns ${expected}`, () => {
|
||||
expect(a + b).toBe(expected);
|
||||
});
|
||||
});
|
||||
|
||||
describe.only.each([[1, 1, 2], [1, 2, 3], [2, 1, 3]])(
|
||||
".add(%i, %i)",
|
||||
(a, b, expected) => {
|
||||
test(`returns ${expected}`, () => {
|
||||
expect(a + b).toBe(expected);
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
describe.only.each`
|
||||
a | b | expected
|
||||
${1} | ${1} | ${2}
|
||||
${1} | ${2} | ${3}
|
||||
${2} | ${1} | ${3}
|
||||
`("$a + $b", ({ a, b, expected }: Case) => {
|
||||
test(`returns ${expected}`, () => {
|
||||
expect(a + b).toBe(expected);
|
||||
});
|
||||
});
|
||||
|
||||
describe.skip.each([[1, 1, 2], [1, 2, 3], [2, 1, 3]])(
|
||||
".add(%i, %i)",
|
||||
(a, b, expected) => {
|
||||
test(`returns ${expected}`, () => {
|
||||
expect(a + b).toBe(expected);
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
describe.skip.each`
|
||||
a | b | expected
|
||||
${1} | ${1} | ${2}
|
||||
${1} | ${2} | ${3}
|
||||
${2} | ${1} | ${3}
|
||||
`("$a + $b", ({ a, b, expected }: Case) => {
|
||||
test(`returns ${expected}`, () => {
|
||||
expect(a + b).toBe(expected);
|
||||
});
|
||||
});
|
||||
|
||||
test.each([[1, 1, 2], [1, 2, 3], [2, 1, 3]])(
|
||||
".add(%i, %i)",
|
||||
(a, b, expected) => {
|
||||
expect(a + b).toBe(expected);
|
||||
}
|
||||
);
|
||||
|
||||
test.each`
|
||||
a | b | expected
|
||||
${1} | ${1} | ${2}
|
||||
${1} | ${2} | ${3}
|
||||
${2} | ${1} | ${3}
|
||||
`("returns $expected when $a is added $b", ({ a, b, expected }: Case) => {
|
||||
expect(a + b).toBe(expected);
|
||||
});
|
||||
|
||||
test.only.each([[1, 1, 2], [1, 2, 3], [2, 1, 3]])(
|
||||
".add(%i, %i)",
|
||||
(a, b, expected) => {
|
||||
expect(a + b).toBe(expected);
|
||||
}
|
||||
);
|
||||
|
||||
test.only.each`
|
||||
a | b | expected
|
||||
${1} | ${1} | ${2}
|
||||
${1} | ${2} | ${3}
|
||||
${2} | ${1} | ${3}
|
||||
`("returns $expected when $a is added $b", ({ a, b, expected }: Case) => {
|
||||
expect(a + b).toBe(expected);
|
||||
});
|
||||
|
||||
Vendored
+28
-7
@@ -1,4 +1,4 @@
|
||||
// Type definitions for joi v13.0.1
|
||||
// Type definitions for joi v13.3.0
|
||||
// Project: https://github.com/hapijs/joi
|
||||
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
|
||||
// Laurence Dougal Myers <https://github.com/laurence-myers>
|
||||
@@ -12,6 +12,7 @@
|
||||
// Anjun Wang <https://github.com/wanganjun>
|
||||
// Rafael Kallis <https://github.com/rafaelkallis>
|
||||
// Conan Lai <https://github.com/aconanlai>
|
||||
// Peter Thorson <https://github.com/zaphoyd>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.4
|
||||
|
||||
@@ -106,6 +107,13 @@ export interface EmailOptions {
|
||||
minDomainAtoms?: number;
|
||||
}
|
||||
|
||||
export interface HexOptions {
|
||||
/**
|
||||
* hex decoded representation must be byte aligned
|
||||
*/
|
||||
byteAligned: boolean;
|
||||
}
|
||||
|
||||
export interface IpOptions {
|
||||
/**
|
||||
* One or more IP address versions to validate against. Valid values: ipv4, ipv6, ipvfuture
|
||||
@@ -512,6 +520,11 @@ export interface NumberSchema extends AnySchema {
|
||||
* Requires the number to be negative.
|
||||
*/
|
||||
negative(): this;
|
||||
|
||||
/**
|
||||
* Requires the number to be a TCP port, so between 0 and 65535.
|
||||
*/
|
||||
port(): this;
|
||||
}
|
||||
|
||||
export interface StringSchema extends AnySchema {
|
||||
@@ -624,7 +637,7 @@ export interface StringSchema extends AnySchema {
|
||||
/**
|
||||
* Requires the string value to be a valid hexadecimal string.
|
||||
*/
|
||||
hex(): this;
|
||||
hex(options?: HexOptions): this;
|
||||
|
||||
/**
|
||||
* Requires the string value to be a valid hostname as per RFC1123.
|
||||
@@ -714,10 +727,15 @@ export interface ArraySchema extends AnySchema {
|
||||
export interface ObjectSchema extends AnySchema {
|
||||
|
||||
/**
|
||||
* Sets the allowed object keys.
|
||||
* Sets or extends the allowed object keys.
|
||||
*/
|
||||
keys(schema?: SchemaMap): this;
|
||||
|
||||
/**
|
||||
* Appends the allowed object keys. If schema is null, undefined, or {}, no changes will be applied.
|
||||
*/
|
||||
append(schema?: SchemaMap): this;
|
||||
|
||||
/**
|
||||
* Specifies the minimum number of keys in the object.
|
||||
*/
|
||||
@@ -966,7 +984,7 @@ export interface Rules<P extends object = any> {
|
||||
name: string;
|
||||
params?: ObjectSchema | {[key in keyof P]: SchemaLike; };
|
||||
setup?(this: ExtensionBoundSchema, params: P): Schema | void;
|
||||
validate?<R = any>(this: ExtensionBoundSchema, params: P, value: any, state: State, options: ValidationOptions): Err | R;
|
||||
validate?(this: ExtensionBoundSchema, params: P, value: any, state: State, options: ValidationOptions): any;
|
||||
description?: string | ((params: P) => string);
|
||||
}
|
||||
|
||||
@@ -974,8 +992,8 @@ export interface Extension {
|
||||
name: string;
|
||||
base?: Schema;
|
||||
language?: LanguageOptions;
|
||||
coerce?<R = any>(this: ExtensionBoundSchema, value: any, state: State, options: ValidationOptions): Err | R;
|
||||
pre?<R = any>(this: ExtensionBoundSchema, value: any, state: State, options: ValidationOptions): Err | R;
|
||||
coerce?(this: ExtensionBoundSchema, value: any, state: State, options: ValidationOptions): any;
|
||||
pre?(this: ExtensionBoundSchema, value: any, state: State, options: ValidationOptions): any;
|
||||
describe?(this: Schema, description: Description): Description;
|
||||
rules?: Rules[];
|
||||
}
|
||||
@@ -1101,10 +1119,13 @@ export function ref(key: string, options?: ReferenceOptions): Reference;
|
||||
export function isRef(ref: any): ref is Reference;
|
||||
|
||||
/**
|
||||
* Get a sub-schema of an existing schema based on a path. Path separator is a dot (.).
|
||||
* Get a sub-schema of an existing schema based on a `path` that can be either a string or an array
|
||||
* of strings For string values path separator is a dot (`.`)
|
||||
*/
|
||||
export function reach(schema: ObjectSchema, path: string): Schema;
|
||||
export function reach<T extends Schema>(schema: ObjectSchema, path: string): T;
|
||||
export function reach(schema: ObjectSchema, path: string[]): Schema;
|
||||
export function reach<T extends Schema>(schema: ObjectSchema, path: string[]): T;
|
||||
|
||||
/**
|
||||
* Creates a new Joi instance customized with the extension(s) you provide included.
|
||||
|
||||
+16
-4
@@ -96,6 +96,12 @@ emailOpts = { minDomainAtoms: num };
|
||||
|
||||
// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
|
||||
|
||||
let hexOpts: Joi.HexOptions = null;
|
||||
|
||||
hexOpts = { byteAligned: bool };
|
||||
|
||||
// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
|
||||
|
||||
let ipOpts: Joi.IpOptions = null;
|
||||
|
||||
ipOpts = { version: str };
|
||||
@@ -602,6 +608,7 @@ numSchema = numSchema.precision(num);
|
||||
numSchema = numSchema.multiple(num);
|
||||
numSchema = numSchema.positive();
|
||||
numSchema = numSchema.negative();
|
||||
numSchema = numSchema.port();
|
||||
|
||||
namespace common {
|
||||
numSchema = numSchema.allow(x);
|
||||
@@ -659,6 +666,9 @@ objSchema = Joi.object(schemaMap);
|
||||
objSchema = objSchema.keys();
|
||||
objSchema = objSchema.keys(schemaMap);
|
||||
|
||||
objSchema = objSchema.append();
|
||||
objSchema = objSchema.append(schemaMap);
|
||||
|
||||
objSchema = objSchema.min(num);
|
||||
objSchema = objSchema.max(num);
|
||||
objSchema = objSchema.length(num);
|
||||
@@ -801,6 +811,7 @@ strSchema = strSchema.guid();
|
||||
strSchema = strSchema.guid({ version: ['uuidv1', 'uuidv2', 'uuidv3', 'uuidv4', 'uuidv5'] } as Joi.GuidOptions);
|
||||
strSchema = strSchema.guid({ version: 'uuidv4' });
|
||||
strSchema = strSchema.hex();
|
||||
strSchema = strSchema.hex(hexOpts);
|
||||
strSchema = strSchema.hostname();
|
||||
strSchema = strSchema.isoDate();
|
||||
strSchema = strSchema.lowercase();
|
||||
@@ -969,6 +980,7 @@ description = Joi.describe(schema);
|
||||
description = schema.describe();
|
||||
|
||||
schema = Joi.reach(objSchema, '');
|
||||
schema = Joi.reach(objSchema, []);
|
||||
|
||||
const Joi2 = Joi.extend({ name: '', base: schema });
|
||||
|
||||
@@ -988,13 +1000,13 @@ const Joi3 = Joi.extend({
|
||||
{
|
||||
name: 'asd',
|
||||
params: {
|
||||
allowF: Joi.boolean().default(false),
|
||||
allowFalse: Joi.boolean().default(false),
|
||||
},
|
||||
setup(params) {
|
||||
const fIsAllowed = params.allowF;
|
||||
const fIsAllowed = params.allowFalse;
|
||||
},
|
||||
validate(params, value, state, options) {
|
||||
if (value === 'asd' || params.allowF && value === 'asdf') {
|
||||
validate(params, value: boolean, state, options) {
|
||||
if (value || params.allowFalse && !value) {
|
||||
return value;
|
||||
}
|
||||
return this.createError('asd', { v: value }, state, options);
|
||||
|
||||
Vendored
+47
-15
@@ -40,7 +40,7 @@ type _Event = Event;
|
||||
// Used by JQuery.Promise3 and JQuery.Promise
|
||||
type _Promise<T> = Promise<T>;
|
||||
|
||||
interface JQueryStatic<TElement extends Node = HTMLElement> {
|
||||
interface JQueryStatic<TElement = HTMLElement> {
|
||||
/**
|
||||
* @see {@link http://api.jquery.com/jquery.ajax/#jQuery-ajax1}
|
||||
* @deprecated Use jQuery.ajaxSetup(options)
|
||||
@@ -137,23 +137,53 @@ interface JQueryStatic<TElement extends Node = HTMLElement> {
|
||||
// HACK: The discriminator parameter handles the edge case of passing a Window object to JQueryStatic. It doesn't actually exist on the factory function.
|
||||
<FElement extends Node = HTMLElement>(window: Window, discriminator: boolean): JQueryStatic<FElement>;
|
||||
/**
|
||||
* Return a collection of matched elements either found in the DOM based on passed argument(s) or created
|
||||
* by passing an HTML string.
|
||||
*
|
||||
* @param element_elementArray A DOM element to wrap in a jQuery object.
|
||||
* An array containing a set of DOM elements to wrap in a jQuery object.
|
||||
* @see {@link https://api.jquery.com/jQuery/}
|
||||
* @since 1.0
|
||||
*/
|
||||
<T extends Element>(element_elementArray: T | ArrayLike<T>): JQuery<T>;
|
||||
/**
|
||||
* Return a collection of matched elements either found in the DOM based on passed argument(s) or created
|
||||
* by passing an HTML string.
|
||||
*
|
||||
* @param selection An existing jQuery object to clone.
|
||||
* @see {@link https://api.jquery.com/jQuery/}
|
||||
* @since 1.0
|
||||
*/
|
||||
<T>(selection: JQuery<T>): JQuery<T>;
|
||||
/**
|
||||
* Accepts a string containing a CSS selector which is then used to match a set of elements.
|
||||
*
|
||||
* Creates DOM elements on the fly from the provided string of raw HTML.
|
||||
*
|
||||
* Binds a function to be executed when the DOM has finished loading.
|
||||
*
|
||||
* @param selector_object_callback A string containing a selector expression
|
||||
* A DOM element to wrap in a jQuery object.
|
||||
* An array containing a set of DOM elements to wrap in a jQuery object.
|
||||
* A plain object to wrap in a jQuery object.
|
||||
* An existing jQuery object to clone.
|
||||
* A string of HTML to create on the fly. Note that this parses HTML, not XML.
|
||||
* The function to execute when the DOM is ready.
|
||||
* @see {@link https://api.jquery.com/jQuery/}
|
||||
* @since 1.0
|
||||
*/
|
||||
(selector_object_callback: JQuery.Selector | JQuery.htmlString | ((this: Document, $: JQueryStatic<TElement>) => void)): JQuery<TElement>; // tslint:disable-line:unified-signatures
|
||||
/**
|
||||
* Return a collection of matched elements either found in the DOM based on passed argument(s) or created by passing an HTML string.
|
||||
*
|
||||
* @param object A plain object to wrap in a jQuery object.
|
||||
* @see {@link https://api.jquery.com/jQuery/}
|
||||
* @since 1.0
|
||||
*/
|
||||
<T extends JQuery.PlainObject>(object: T): JQuery<T>;
|
||||
/**
|
||||
* Returns an empty jQuery set.
|
||||
*
|
||||
* @see {@link https://api.jquery.com/jQuery/}
|
||||
* @since 1.4
|
||||
*/
|
||||
(selector_object_callback?: JQuery.Selector | JQuery.htmlString | JQuery.TypeOrArray<Element> | JQuery |
|
||||
JQuery.PlainObject | Window |
|
||||
((this: Document, $: JQueryStatic<TElement>) => void)): JQuery<TElement>;
|
||||
(): JQuery<TElement>;
|
||||
/**
|
||||
* A multi-purpose callbacks list object that provides a powerful way to manage callback lists.
|
||||
*
|
||||
@@ -659,7 +689,7 @@ interface JQueryStatic<TElement extends Node = HTMLElement> {
|
||||
* @see {@link https://api.jquery.com/jQuery.map/}
|
||||
* @since 1.0
|
||||
*/
|
||||
map<T, R>(array: T[], callback: (elementOfArray: T, indexInArray: number) => R): R[];
|
||||
map<T, TReturn>(array: T[], callback: (this: Window, elementOfArray: T, indexInArray: number) => JQuery.TypeOrArray<TReturn> | null | undefined): TReturn[];
|
||||
/**
|
||||
* Translate all items in an array or object to new array of items.
|
||||
*
|
||||
@@ -671,7 +701,7 @@ interface JQueryStatic<TElement extends Node = HTMLElement> {
|
||||
* @see {@link https://api.jquery.com/jQuery.map/}
|
||||
* @since 1.6
|
||||
*/
|
||||
map<T, K extends keyof T, R>(obj: T, callback: (propertyOfObject: T[K], key: K) => R): R[];
|
||||
map<T, K extends keyof T, TReturn>(obj: T, callback: (this: Window, propertyOfObject: T[K], key: K) => JQuery.TypeOrArray<TReturn> | null | undefined): TReturn[];
|
||||
/**
|
||||
* Merge the contents of two arrays together into the first array.
|
||||
*
|
||||
@@ -3098,7 +3128,7 @@ interface JQueryStatic<TElement extends Node = HTMLElement> {
|
||||
when(...deferreds: any[]): JQuery.Promise<any, any, never>;
|
||||
}
|
||||
|
||||
interface JQuery<TElement extends Node = HTMLElement> extends Iterable<TElement> {
|
||||
interface JQuery<TElement = HTMLElement> extends Iterable<TElement> {
|
||||
/**
|
||||
* A string containing the jQuery version number.
|
||||
*
|
||||
@@ -4253,7 +4283,7 @@ interface JQuery<TElement extends Node = HTMLElement> extends Iterable<TElement>
|
||||
* @see {@link https://api.jquery.com/map/}
|
||||
* @since 1.2
|
||||
*/
|
||||
map(callback: (this: TElement, index: number, domElement: TElement) => any | any[] | null | undefined): this;
|
||||
map<TReturn>(callback: (this: TElement, index: number, domElement: TElement) => JQuery.TypeOrArray<TReturn> | null | undefined): JQuery<TReturn>;
|
||||
/**
|
||||
* Bind an event handler to the "mousedown" JavaScript event, or trigger that event on an element.
|
||||
*
|
||||
@@ -6363,7 +6393,9 @@ declare namespace JQuery {
|
||||
};
|
||||
|
||||
// Writable properties on XMLHttpRequest
|
||||
interface XHRFields extends Partial<Pick<XMLHttpRequest, 'onreadystatechange' | 'responseType' | 'timeout' | 'withCredentials' | 'msCaching'>> { }
|
||||
interface XHRFields extends Partial<Pick<XMLHttpRequest, 'onreadystatechange' | 'responseType' | 'timeout' | 'withCredentials'>> {
|
||||
msCaching?: string;
|
||||
}
|
||||
}
|
||||
|
||||
interface Transport {
|
||||
@@ -7922,9 +7954,9 @@ declare namespace JQuery {
|
||||
|
||||
// endregion
|
||||
|
||||
interface EventHandler<TCurrentTarget extends EventTarget, TData = null> extends EventHandlerBase<TCurrentTarget, JQuery.Event<TCurrentTarget, TData>> { }
|
||||
interface EventHandler<TCurrentTarget, TData = null> extends EventHandlerBase<TCurrentTarget, JQuery.Event<TCurrentTarget, TData>> { }
|
||||
|
||||
interface EventHandlerBase<TContext extends object, T> {
|
||||
interface EventHandlerBase<TContext, T> {
|
||||
// Extra parameters can be passed from trigger()
|
||||
(this: TContext, t: T, ...args: any[]): void | false | any;
|
||||
}
|
||||
|
||||
+218
-17
@@ -42,7 +42,7 @@ function JQueryStatic() {
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$([new HTMLElement()]);
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
// $ExpectType JQuery<{ foo: string; hello: string; }>
|
||||
$({ foo: 'bar', hello: 'world' });
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
@@ -58,6 +58,41 @@ function JQueryStatic() {
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$();
|
||||
|
||||
// https://github.com/DefinitelyTyped/DefinitelyTyped/issues/19597#issuecomment-378218432
|
||||
function issue_19597_378218432() {
|
||||
let myDiv = $(document.createElement('div'));
|
||||
// $ExpectType JQuery<HTMLDivElement>
|
||||
myDiv;
|
||||
myDiv.on('click', (evt) => {
|
||||
let target = evt.target;
|
||||
// $ExpectType HTMLDivElement
|
||||
target;
|
||||
});
|
||||
let myDiv1 = $<HTMLDivElement>(document.createElement('div'));
|
||||
|
||||
let myForcedDiv: JQuery<HTMLDivElement> = $(document.createElement('div')) as any;
|
||||
myForcedDiv.on('click', (evt) => {
|
||||
let target = evt.target; // HTMLDivElement
|
||||
// $ExpectType HTMLDivElement
|
||||
target;
|
||||
});
|
||||
let myDoc = $(document);
|
||||
// $ExpectType JQuery<Document>
|
||||
myDoc;
|
||||
myDoc.on('click', (evt) => {
|
||||
let target = evt.target;
|
||||
// $ExpectType Document
|
||||
target;
|
||||
});
|
||||
let myDocForced: JQuery<Document> = $(document);
|
||||
let myWindow = $(window);
|
||||
// $ExpectType JQuery<Window>
|
||||
myWindow;
|
||||
let myWindowForced: JQuery<Window> = $(window);
|
||||
// $ExpectType JQuery<Window>
|
||||
myWindowForced;
|
||||
}
|
||||
}
|
||||
|
||||
function ajaxSettings() {
|
||||
@@ -699,7 +734,9 @@ function JQueryStatic() {
|
||||
|
||||
function map() {
|
||||
// $ExpectType number[]
|
||||
$.map([1, 2, 3], (elementOfArray, indexInArray) => {
|
||||
$.map([1, 2, 3], function (elementOfArray, indexInArray) {
|
||||
// $ExpectType Window
|
||||
this;
|
||||
// $ExpectType number
|
||||
elementOfArray;
|
||||
// $ExpectType number
|
||||
@@ -708,11 +745,49 @@ function JQueryStatic() {
|
||||
return 200 + 10;
|
||||
});
|
||||
|
||||
// $ExpectType number[]
|
||||
$.map([1, 2, 3], function (elementOfArray, indexInArray) {
|
||||
// $ExpectType Window
|
||||
this;
|
||||
// $ExpectType number
|
||||
elementOfArray;
|
||||
// $ExpectType number
|
||||
indexInArray;
|
||||
|
||||
return [200, 10];
|
||||
});
|
||||
|
||||
// $ExpectType (number | null)[]
|
||||
$.map([1, 2, 3], function (elementOfArray, indexInArray) {
|
||||
// $ExpectType Window
|
||||
this;
|
||||
// $ExpectType number
|
||||
elementOfArray;
|
||||
// $ExpectType number
|
||||
indexInArray;
|
||||
|
||||
return [200, 10, null];
|
||||
});
|
||||
|
||||
// $ExpectType (number | undefined)[]
|
||||
$.map([1, 2, 3], function (elementOfArray, indexInArray) {
|
||||
// $ExpectType Window
|
||||
this;
|
||||
// $ExpectType number
|
||||
elementOfArray;
|
||||
// $ExpectType number
|
||||
indexInArray;
|
||||
|
||||
return [200, 10, undefined];
|
||||
});
|
||||
|
||||
// $ExpectType (false | 1)[]
|
||||
$.map({
|
||||
myProp: true,
|
||||
name: 'Rogers',
|
||||
}, (propertyOfObject, key) => {
|
||||
}, function (propertyOfObject, key) {
|
||||
// $ExpectType Window
|
||||
this;
|
||||
// $ExpectType string | boolean
|
||||
propertyOfObject;
|
||||
// $ExpectType "myProp" | "name"
|
||||
@@ -725,6 +800,67 @@ function JQueryStatic() {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
// $ExpectType (string | number | boolean)[]
|
||||
$.map({
|
||||
myProp: true,
|
||||
name: 'Rogers',
|
||||
}, function (propertyOfObject, key) {
|
||||
// $ExpectType Window
|
||||
this;
|
||||
// $ExpectType string | boolean
|
||||
propertyOfObject;
|
||||
// $ExpectType "myProp" | "name"
|
||||
key;
|
||||
|
||||
return [propertyOfObject, 24];
|
||||
});
|
||||
|
||||
// $ExpectType (false | 1)[]
|
||||
$.map({
|
||||
myProp: true,
|
||||
name: 'Rogers',
|
||||
anotherProp: 70,
|
||||
}, function (propertyOfObject, key) {
|
||||
// $ExpectType Window
|
||||
this;
|
||||
// $ExpectType string | number | boolean
|
||||
propertyOfObject;
|
||||
// $ExpectType "myProp" | "name" | "anotherProp"
|
||||
key;
|
||||
|
||||
switch (key) {
|
||||
case 'myProp':
|
||||
return 1;
|
||||
case 'name':
|
||||
return false;
|
||||
}
|
||||
|
||||
return null;
|
||||
});
|
||||
|
||||
// $ExpectType (false | 1)[]
|
||||
$.map({
|
||||
myProp: true,
|
||||
name: 'Rogers',
|
||||
anotherProp: 70,
|
||||
}, function (propertyOfObject, key) {
|
||||
// $ExpectType Window
|
||||
this;
|
||||
// $ExpectType string | number | boolean
|
||||
propertyOfObject;
|
||||
// $ExpectType "myProp" | "name" | "anotherProp"
|
||||
key;
|
||||
|
||||
switch (key) {
|
||||
case 'myProp':
|
||||
return 1;
|
||||
case 'name':
|
||||
return false;
|
||||
}
|
||||
|
||||
return undefined;
|
||||
});
|
||||
}
|
||||
|
||||
function merge() {
|
||||
@@ -2041,7 +2177,7 @@ function JQuery() {
|
||||
|
||||
function ajax() {
|
||||
function ajaxComplete() {
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
// $ExpectType JQuery<Document>
|
||||
$(document).ajaxComplete(function(event, jqXHR, ajaxOptions) {
|
||||
// $ExpectType Document
|
||||
this;
|
||||
@@ -2057,7 +2193,7 @@ function JQuery() {
|
||||
}
|
||||
|
||||
function ajaxError() {
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
// $ExpectType JQuery<Document>
|
||||
$(document).ajaxError(function(event, jqXHR, ajaxSettings, thrownError) {
|
||||
// $ExpectType Document
|
||||
this;
|
||||
@@ -2075,7 +2211,7 @@ function JQuery() {
|
||||
}
|
||||
|
||||
function ajaxSend() {
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
// $ExpectType JQuery<Document>
|
||||
$(document).ajaxSend(function(event, jqXHR, ajaxOptions) {
|
||||
// $ExpectType Document
|
||||
this;
|
||||
@@ -2091,7 +2227,7 @@ function JQuery() {
|
||||
}
|
||||
|
||||
function ajaxStart() {
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
// $ExpectType JQuery<Document>
|
||||
$(document).ajaxStart(function() {
|
||||
// $ExpectType Document
|
||||
this;
|
||||
@@ -2101,7 +2237,7 @@ function JQuery() {
|
||||
}
|
||||
|
||||
function ajaxStop() {
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
// $ExpectType JQuery<Document>
|
||||
$(document).ajaxStop(function() {
|
||||
// $ExpectType Document
|
||||
this;
|
||||
@@ -2111,7 +2247,7 @@ function JQuery() {
|
||||
}
|
||||
|
||||
function ajaxSuccess() {
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
// $ExpectType JQuery<Document>
|
||||
$(document).ajaxSuccess(function(event, jqXHR, ajaxOptions, data) {
|
||||
// $ExpectType Document
|
||||
this;
|
||||
@@ -5898,8 +6034,9 @@ function JQuery() {
|
||||
}
|
||||
|
||||
function contents() {
|
||||
// $ExpectType JQuery<HTMLElement | Comment | Text>
|
||||
$('p').contents();
|
||||
// TODO: Flaky test due to type ordering.
|
||||
// // $ExpectType JQuery<HTMLElement | Comment | Text>
|
||||
// $('p').contents();
|
||||
}
|
||||
|
||||
function end() {
|
||||
@@ -6131,7 +6268,7 @@ function JQuery() {
|
||||
}
|
||||
|
||||
function map() {
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
// $ExpectType JQuery<string>
|
||||
$('p').map(function(index, domElement) {
|
||||
// $ExpectType HTMLElement
|
||||
this;
|
||||
@@ -6143,7 +6280,7 @@ function JQuery() {
|
||||
return 'myVal';
|
||||
});
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
// $ExpectType JQuery<string>
|
||||
$('p').map(function(index, domElement) {
|
||||
// $ExpectType HTMLElement
|
||||
this;
|
||||
@@ -6155,7 +6292,7 @@ function JQuery() {
|
||||
return ['myVal1', 'myVal2'];
|
||||
});
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
// $ExpectType JQuery<string | null>
|
||||
$('p').map(function(index, domElement) {
|
||||
// $ExpectType HTMLElement
|
||||
this;
|
||||
@@ -6164,10 +6301,10 @@ function JQuery() {
|
||||
// $ExpectType HTMLElement
|
||||
domElement;
|
||||
|
||||
return null;
|
||||
return ['myVal1', 'myVal2', null];
|
||||
});
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
// $ExpectType JQuery<string | undefined>
|
||||
$('p').map(function(index, domElement) {
|
||||
// $ExpectType HTMLElement
|
||||
this;
|
||||
@@ -6176,8 +6313,72 @@ function JQuery() {
|
||||
// $ExpectType HTMLElement
|
||||
domElement;
|
||||
|
||||
return undefined;
|
||||
return ['myVal1', 'myVal2', undefined];
|
||||
});
|
||||
|
||||
// $ExpectType JQuery<string>
|
||||
$('p').map(function(index, domElement) {
|
||||
// $ExpectType HTMLElement
|
||||
this;
|
||||
// $ExpectType number
|
||||
index;
|
||||
// $ExpectType HTMLElement
|
||||
domElement;
|
||||
|
||||
let value: string;
|
||||
|
||||
if (index % 2 === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
value = 'myVal';
|
||||
|
||||
return value;
|
||||
});
|
||||
|
||||
// $ExpectType JQuery<string>
|
||||
$('p').map(function(index, domElement) {
|
||||
// $ExpectType HTMLElement
|
||||
this;
|
||||
// $ExpectType number
|
||||
index;
|
||||
// $ExpectType HTMLElement
|
||||
domElement;
|
||||
|
||||
let value: string;
|
||||
|
||||
if (index % 2 === 0) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
value = 'myVal';
|
||||
|
||||
return value;
|
||||
});
|
||||
|
||||
// // $ExpectType JQuery<never>
|
||||
// $('p').map(function(index, domElement) {
|
||||
// // $ExpectType HTMLElement
|
||||
// this;
|
||||
// // $ExpectType number
|
||||
// index;
|
||||
// // $ExpectType HTMLElement
|
||||
// domElement;
|
||||
//
|
||||
// return null;
|
||||
// });
|
||||
|
||||
// // $ExpectType JQuery<never>
|
||||
// $('p').map(function(index, domElement) {
|
||||
// // $ExpectType HTMLElement
|
||||
// this;
|
||||
// // $ExpectType number
|
||||
// index;
|
||||
// // $ExpectType HTMLElement
|
||||
// domElement;
|
||||
//
|
||||
// return undefined;
|
||||
// });
|
||||
}
|
||||
|
||||
function slice() {
|
||||
|
||||
@@ -3428,7 +3428,7 @@ function examples() {
|
||||
function map_0() {
|
||||
$('p')
|
||||
.append($('input').map(function() {
|
||||
return $(this).val();
|
||||
return $(this).val() as string;
|
||||
})
|
||||
.get()
|
||||
.join(', '));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import jq = require('jquery/dist/jquery.slim');
|
||||
|
||||
const $window = jq(window);
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
// $ExpectType JQuery<Window>
|
||||
$window;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import jq = require('jquery');
|
||||
|
||||
const $window = jq(window);
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
// $ExpectType JQuery<Window>
|
||||
$window;
|
||||
|
||||
class CanvasLayersDirective {
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
"no-empty-interface": false,
|
||||
"no-misused-new": false,
|
||||
"no-object-literal-type-assertion": false,
|
||||
"no-redundant-jsdoc-2": false,
|
||||
"no-unnecessary-generics": false,
|
||||
"no-unnecessary-qualifier": false,
|
||||
"no-unnecessary-type-assertion": false,
|
||||
|
||||
Vendored
+1
-1
@@ -4760,6 +4760,6 @@ declare namespace _ {
|
||||
zipObjectDeep: LodashZipObjectDeep;
|
||||
zipWith: LodashZipWith;
|
||||
__: lodash.__;
|
||||
placehodler: lodash.__;
|
||||
placeholder: lodash.__;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ async function main() {
|
||||
" interface LoDashFp {",
|
||||
...interfaceGroups.map(g => ` ${g.functionName}: ${g.interfaces[0].name};`),
|
||||
" __: lodash.__;",
|
||||
" placehodler: lodash.__;",
|
||||
" placeholder: lodash.__;",
|
||||
" }",
|
||||
"}",
|
||||
"",
|
||||
|
||||
Vendored
+1
-1
@@ -67,7 +67,7 @@ export declare class Element {
|
||||
|
||||
getText(): string;
|
||||
|
||||
getChildText(name: string, xmlns: any): string;
|
||||
getChildText(name: string, xmlns?: any): string;
|
||||
|
||||
/**
|
||||
* Return all direct descendents that are Elements.
|
||||
|
||||
@@ -2,6 +2,11 @@ import * as ltx from 'ltx';
|
||||
|
||||
ltx.parse('<document/>');
|
||||
|
||||
const getChildTextElement = ltx.parse('<test><child>body text</child></test>') as ltx.Element;
|
||||
if (getChildTextElement.getChildText('child') !== 'body text') {
|
||||
throw new Error("body does not match");
|
||||
}
|
||||
|
||||
const p = new ltx.Parser();
|
||||
|
||||
p.on('tree', (ignored: any) => {});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as materialize from "materialize-css";
|
||||
|
||||
const elem = document.querySelector('.whatever')!;
|
||||
const elem = document.querySelector('.whatever') as HTMLElement;
|
||||
|
||||
M.textareaAutoResize(elem);
|
||||
M.textareaAutoResize($(elem));
|
||||
|
||||
Vendored
+5
@@ -68,6 +68,11 @@ export declare interface Response {
|
||||
readonly names: Translations;
|
||||
};
|
||||
readonly postal?: { code: string };
|
||||
readonly isp?: {
|
||||
readonly isp: string;
|
||||
readonly autonomous_system_number: number;
|
||||
};
|
||||
readonly connection?: { connection_type: string };
|
||||
}
|
||||
|
||||
export declare interface Translations {
|
||||
|
||||
Vendored
+4
-7
@@ -1,12 +1,9 @@
|
||||
// Type definitions for memoize-one 3.1
|
||||
// Project: https://github.com/alexreardon/memoize-one#readme
|
||||
// Definitions by: Karol Majewski <https://github.com/karol-majewski>
|
||||
// Definitions by: Karol Majewski <https://github.com/karol-majewski>, Frank Li <https://github.com/franklixuefei>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export = memoizeOne;
|
||||
declare function memoizeOne<T extends (...args: any[]) => any>(resultFn: T, isEqual?: EqualityFn): T;
|
||||
export type EqualityFn = (a: any, b: any) => boolean;
|
||||
|
||||
declare function memoizeOne<T extends (...args: any[]) => any>(resultFn: T, isEqual?: memoizeOne.EqualityFn): T;
|
||||
|
||||
declare namespace memoizeOne {
|
||||
type EqualityFn = (a: any, b: any) => boolean;
|
||||
}
|
||||
export default memoizeOne;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import memoizeOne = require('memoize-one');
|
||||
import memoizeOne, { EqualityFn } from 'memoize-one';
|
||||
|
||||
declare function add(a: number, b: number): number ;
|
||||
declare function lousyEqualityFn(a: any, b: any): boolean;
|
||||
@@ -30,4 +30,4 @@ memoizeOne(add, (a: string, b: string) => 0); // $ExpectError
|
||||
/**
|
||||
* The `EqualityFn` type is publicly accessible.
|
||||
*/
|
||||
const simpleIsEqual: memoizeOne.EqualityFn = (x: number, y: number): boolean => (x === y);
|
||||
const simpleIsEqual: EqualityFn = (x: number, y: number): boolean => (x === y);
|
||||
|
||||
Vendored
+2
-1
@@ -1,4 +1,4 @@
|
||||
// Type definitions for microrouter 2.2
|
||||
// Type definitions for microrouter 3.1
|
||||
// Project: https://github.com/pedronauck/micro-router#readme
|
||||
// Definitions by: Mathieu Dutour <https://github.com/mathieudutour>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
@@ -21,6 +21,7 @@ export type AugmentedRequestHandler = (
|
||||
export type RouteHandler = (path: string, handler: AugmentedRequestHandler) => RequestHandler;
|
||||
|
||||
export function router(...routes: RequestHandler[]): RequestHandler;
|
||||
export function withNamespace(namespace: string): (...routes: RequestHandler[]) => RequestHandler;
|
||||
|
||||
export const get: RouteHandler;
|
||||
export const post: RouteHandler;
|
||||
|
||||
+6
-6
@@ -80,12 +80,12 @@ declare module "moment" {
|
||||
}
|
||||
|
||||
interface LocaleSpecification {
|
||||
durationLabelsLong: DurationLabelDef;
|
||||
durationLabelsStandard: DurationLabelDef;
|
||||
durationLabelsShort: DurationLabelDef;
|
||||
durationTimeTemplates: DurationTimeDef;
|
||||
durationLabelTypes: DurationLabelTypeDef[];
|
||||
durationPluralKey: (token: string, integerValue: number, decimalValue: number) => string;
|
||||
durationLabelsLong?: DurationLabelDef;
|
||||
durationLabelsStandard?: DurationLabelDef;
|
||||
durationLabelsShort?: DurationLabelDef;
|
||||
durationTimeTemplates?: DurationTimeDef;
|
||||
durationLabelTypes?: DurationLabelTypeDef[];
|
||||
durationPluralKey?: (token: string, integerValue: number, decimalValue: number) => string;
|
||||
}
|
||||
|
||||
type TemplateFunction = ((this: DurationFormatSettings) => string);
|
||||
|
||||
Vendored
+1
-1
@@ -1252,7 +1252,7 @@ export class Cursor<T = Default> extends Readable {
|
||||
/** http://mongodb.github.io/node-mongodb-native/3.0/api/Cursor.html#limit */
|
||||
limit(value: number): Cursor<T>;
|
||||
/** http://mongodb.github.io/node-mongodb-native/3.0/api/Cursor.html#map */
|
||||
map<U>(transform: (T) => U): Cursor<U>;
|
||||
map<U>(transform: (document: T) => U): Cursor<U>;
|
||||
/** http://mongodb.github.io/node-mongodb-native/3.0/api/Cursor.html#max */
|
||||
max(max: number): Cursor<T>;
|
||||
/** http://mongodb.github.io/node-mongodb-native/3.0/api/Cursor.html#maxAwaitTimeMS */
|
||||
|
||||
Vendored
+5
-5
@@ -39,7 +39,7 @@ declare namespace naver.maps {
|
||||
*/
|
||||
interface MapEventListener {
|
||||
eventName: string;
|
||||
listener: () => any;
|
||||
listener: (event: any) => any;
|
||||
listenerId: string;
|
||||
target: any;
|
||||
}
|
||||
@@ -1303,14 +1303,14 @@ declare namespace naver.maps {
|
||||
|
||||
function Event(): void;
|
||||
namespace Event {
|
||||
function addDOMListener(element: HTMLElement, eventName: string, listener: () => any): void;
|
||||
function addListener(target: any, eventName: string, listener: () => any): MapEventListener;
|
||||
function addDOMListener(element: HTMLElement, eventName: string, listener: (event: any) => any): void;
|
||||
function addListener(target: any, eventName: string, listener: (event: any) => any): MapEventListener;
|
||||
function clearInstanceListeners(target: any): void;
|
||||
function clearListeners(target: any, fromEventName: string): void;
|
||||
function forward(source: any, fromEventName: string, target: any, toEventName: string): MapEventListener;
|
||||
function hasListener(target: any, eventName: string): boolean;
|
||||
function once(target: any, eventName: string, listener: () => any): MapEventListener;
|
||||
function removeDOMListener(element: HTMLElement, eventName: string, listener: () => any): void;
|
||||
function once(target: any, eventName: string, listener: (event: any) => any): MapEventListener;
|
||||
function removeDOMListener(element: HTMLElement, eventName: string, listener: (event: any) => any): void;
|
||||
function removeDOMListener(listeners: DOMEventListener | DOMEventListener[]): void;
|
||||
function removeListener(listeners: MapEventListener | MapEventListener[]): void;
|
||||
function resumeDispatch(target: any, eventName: string): void;
|
||||
|
||||
Vendored
+25
-15
@@ -8,12 +8,11 @@ export interface EventChangeOptions {
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
export type PopStateCallback = (state: any) => boolean | undefined;
|
||||
|
||||
export type RouterCallback = () => void;
|
||||
export interface RouterProps {
|
||||
// router properties
|
||||
readonly components: {
|
||||
[key: string]: { Component: React.ComponentType<any>; err: any };
|
||||
};
|
||||
// url property fields
|
||||
readonly pathname: string;
|
||||
readonly route: string;
|
||||
readonly asPath?: string;
|
||||
@@ -27,39 +26,50 @@ export interface RouterProps {
|
||||
| string[];
|
||||
};
|
||||
|
||||
// router methods
|
||||
reload(route: string): Promise<void>;
|
||||
// property fields
|
||||
readonly components: {
|
||||
[key: string]: { Component: React.ComponentType<any>; err: any };
|
||||
};
|
||||
|
||||
// core method fields
|
||||
back(): void;
|
||||
beforePopState(cb: PopStateCallback): boolean;
|
||||
prefetch(url: string): Promise<React.ComponentType<any>>;
|
||||
push(
|
||||
url: string | UrlLike,
|
||||
as?: string | UrlLike,
|
||||
options?: EventChangeOptions,
|
||||
): Promise<boolean>;
|
||||
reload(route: string): Promise<void>;
|
||||
replace(
|
||||
url: string | UrlLike,
|
||||
as?: string | UrlLike,
|
||||
options?: EventChangeOptions,
|
||||
): Promise<boolean>;
|
||||
prefetch(url: string): Promise<React.ComponentType<any>>;
|
||||
|
||||
// router events
|
||||
// events
|
||||
onAppUpdated?(nextRoute: string): void;
|
||||
onRouteChangeStart?(url: string): void;
|
||||
onBeforeHistoryChange?(as: string): void;
|
||||
onHashChangeStart?(url: string): void;
|
||||
onHashChangeComplete?(url: string): void;
|
||||
onRouteChangeComplete?(url: string): void;
|
||||
onRouteChangeError?(error: any, url: string): void;
|
||||
onRouteChangeStart?(url: string): void;
|
||||
}
|
||||
|
||||
export interface SingletonRouter {
|
||||
router: RouterProps;
|
||||
export interface SingletonRouter extends RouterProps {
|
||||
router: RouterProps | null;
|
||||
readyCallbacks: RouterCallback[];
|
||||
ready(cb: RouterCallback): void;
|
||||
}
|
||||
|
||||
export interface WithRouterProps {
|
||||
router: SingletonRouter;
|
||||
}
|
||||
|
||||
export function withRouter<T extends {}>(
|
||||
Component: React.ComponentType<T & SingletonRouter>,
|
||||
Component: React.ComponentType<T & WithRouterProps>,
|
||||
): React.ComponentType<T>;
|
||||
|
||||
export const Singleton: SingletonRouter;
|
||||
export type ImperativeRouter = RouterProps;
|
||||
export default Singleton;
|
||||
declare const Router: SingletonRouter;
|
||||
export default Router;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import Router, * as r from "next/router";
|
||||
import Router, { withRouter, WithRouterProps } from "next/router";
|
||||
import * as React from "react";
|
||||
import * as qs from "querystring";
|
||||
|
||||
@@ -13,8 +13,8 @@ Router.ready(() => {
|
||||
|
||||
// Access readonly properties of the router.
|
||||
|
||||
Object.keys(Router.router.components).forEach(key => {
|
||||
const c = Router.router.components[key];
|
||||
Object.keys(Router.components).forEach(key => {
|
||||
const c = Router.components[key];
|
||||
c.err.isAnAny;
|
||||
|
||||
return <c.Component />;
|
||||
@@ -26,52 +26,78 @@ function split(routeLike: string) {
|
||||
});
|
||||
}
|
||||
|
||||
if (Router.router.asPath) {
|
||||
split(Router.router.asPath);
|
||||
split(Router.router.asPath);
|
||||
if (Router.asPath) {
|
||||
split(Router.asPath);
|
||||
split(Router.asPath);
|
||||
}
|
||||
|
||||
split(Router.router.pathname);
|
||||
split(Router.pathname);
|
||||
|
||||
const query = `?${qs.stringify(Router.router.query)}`;
|
||||
const query = `?${qs.stringify(Router.query)}`;
|
||||
|
||||
// Assign some callback methods.
|
||||
Router.router.onAppUpdated = (nextRoute: string) => console.log(nextRoute);
|
||||
Router.router.onRouteChangeStart = (url: string) =>
|
||||
Router.onAppUpdated = (nextRoute: string) => console.log(nextRoute);
|
||||
Router.onRouteChangeStart = (url: string) =>
|
||||
console.log("Route is starting to change.", url);
|
||||
Router.router.onBeforeHistoryChange = (as: string) =>
|
||||
Router.onBeforeHistoryChange = (as: string) =>
|
||||
console.log("History hasn't changed yet.", as);
|
||||
Router.router.onRouteChangeComplete = (url: string) =>
|
||||
Router.onRouteChangeComplete = (url: string) =>
|
||||
console.log("Route chaneg is complete.", url);
|
||||
Router.router.onRouteChangeError = (err: any, url: string) =>
|
||||
Router.onRouteChangeError = (err: any, url: string) =>
|
||||
console.log("Route is starting to change.", url, err);
|
||||
|
||||
// Call methods on the router itself.
|
||||
Router.router.reload("/route").then(() => console.log("route was reloaded"));
|
||||
Router.router.back();
|
||||
Router.reload("/route").then(() => console.log("route was reloaded"));
|
||||
Router.back();
|
||||
Router.beforePopState(({ url }) => !!url);
|
||||
|
||||
Router.router.push("/route").then((success: boolean) =>
|
||||
Router.push("/route").then((success: boolean) =>
|
||||
console.log("route push success: ", success),
|
||||
);
|
||||
Router.router.push("/route", "/asRoute").then((success: boolean) =>
|
||||
Router.push("/route", "/asRoute").then((success: boolean) =>
|
||||
console.log("route push success: ", success),
|
||||
);
|
||||
Router.router.push("/route", "/asRoute", { shallow: false }).then((success: boolean) =>
|
||||
Router.push("/route", "/asRoute", { shallow: false }).then((success: boolean) =>
|
||||
console.log("route push success: ", success),
|
||||
);
|
||||
|
||||
Router.router.replace("/route").then((success: boolean) =>
|
||||
Router.replace("/route").then((success: boolean) =>
|
||||
console.log("route replace success: ", success),
|
||||
);
|
||||
Router.router.replace("/route", "/asRoute").then((success: boolean) =>
|
||||
Router.replace("/route", "/asRoute").then((success: boolean) =>
|
||||
console.log("route replace success: ", success),
|
||||
);
|
||||
Router.router.replace("/route", "/asRoute", {
|
||||
Router.replace("/route", "/asRoute", {
|
||||
shallow: false,
|
||||
}).then((success: boolean) => console.log("route replace success: ", success));
|
||||
|
||||
Router.router.prefetch("/route").then(Component => {
|
||||
Router.prefetch("/route").then(Component => {
|
||||
const element = <Component />;
|
||||
});
|
||||
|
||||
r.withRouter(props => <div />);
|
||||
interface TestComponentProps {
|
||||
testValue: string;
|
||||
}
|
||||
|
||||
class TestComponent extends React.Component<TestComponentProps & WithRouterProps> {
|
||||
state = { ready: false };
|
||||
|
||||
constructor(props: TestComponentProps & WithRouterProps) {
|
||||
super(props);
|
||||
props.router.ready(() => {
|
||||
this.setState({ ready: true });
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
<h1>{this.state.ready ? 'Ready' : 'Not Ready'}</h1>
|
||||
<h2>Route: {this.props.router.route}</h2>
|
||||
<p>Another prop: {this.props.testValue}</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
withRouter(TestComponent);
|
||||
|
||||
Vendored
+11
-11
@@ -5807,19 +5807,19 @@ declare module "crypto" {
|
||||
verifyError: number;
|
||||
}
|
||||
export function getDiffieHellman(group_name: string): DiffieHellman;
|
||||
export function pbkdf2(password: string | Buffer, salt: string | Buffer, iterations: number, keylen: number, digest: string, callback: (err: Error, derivedKey: Buffer) => any): void;
|
||||
export function pbkdf2(password: string | Buffer, salt: string | Buffer, iterations: number, keylen: number, digest: string, callback: (err: Error | null, derivedKey: Buffer) => any): void;
|
||||
export function pbkdf2Sync(password: string | Buffer, salt: string | Buffer, iterations: number, keylen: number, digest: string): Buffer;
|
||||
export function randomBytes(size: number): Buffer;
|
||||
export function randomBytes(size: number, callback: (err: Error, buf: Buffer) => void): void;
|
||||
export function randomBytes(size: number, callback: (err: Error | null, buf: Buffer) => void): void;
|
||||
export function pseudoRandomBytes(size: number): Buffer;
|
||||
export function pseudoRandomBytes(size: number, callback: (err: Error, buf: Buffer) => void): void;
|
||||
export function pseudoRandomBytes(size: number, callback: (err: Error | null, buf: Buffer) => void): void;
|
||||
export function randomFillSync(buffer: Buffer | Uint8Array, offset?: number, size?: number): Buffer;
|
||||
export function randomFill(buffer: Buffer, callback: (err: Error, buf: Buffer) => void): void;
|
||||
export function randomFill(buffer: Uint8Array, callback: (err: Error, buf: Uint8Array) => void): void;
|
||||
export function randomFill(buffer: Buffer, offset: number, callback: (err: Error, buf: Buffer) => void): void;
|
||||
export function randomFill(buffer: Uint8Array, offset: number, callback: (err: Error, buf: Uint8Array) => void): void;
|
||||
export function randomFill(buffer: Buffer, offset: number, size: number, callback: (err: Error, buf: Buffer) => void): void;
|
||||
export function randomFill(buffer: Uint8Array, offset: number, size: number, callback: (err: Error, buf: Uint8Array) => void): void;
|
||||
export function randomFill(buffer: Buffer, callback: (err: Error | null, buf: Buffer) => void): void;
|
||||
export function randomFill(buffer: Uint8Array, callback: (err: Error | null, buf: Uint8Array) => void): void;
|
||||
export function randomFill(buffer: Buffer, offset: number, callback: (err: Error | null, buf: Buffer) => void): void;
|
||||
export function randomFill(buffer: Uint8Array, offset: number, callback: (err: Error | null, buf: Uint8Array) => void): void;
|
||||
export function randomFill(buffer: Buffer, offset: number, size: number, callback: (err: Error | null, buf: Buffer) => void): void;
|
||||
export function randomFill(buffer: Uint8Array, offset: number, size: number, callback: (err: Error | null, buf: Uint8Array) => void): void;
|
||||
export interface RsaPublicKey {
|
||||
key: string;
|
||||
padding?: number;
|
||||
@@ -5836,8 +5836,8 @@ declare module "crypto" {
|
||||
export function getCiphers(): string[];
|
||||
export function getCurves(): string[];
|
||||
export function getHashes(): string[];
|
||||
export interface ECDH {
|
||||
convertKey(key: string | Buffer /*| TypedArray*/ | DataView, curve: string, inputEncoding?: string, outputEncoding?: string, format?: string): Buffer | string;
|
||||
export class ECDH {
|
||||
static convertKey(key: string | Buffer /*| TypedArray*/ | DataView, curve: string, inputEncoding?: "latin1" | "hex" | "base64", outputEncoding?: "latin1" | "hex" | "base64", format?: "uncompressed" | "compressed" | "hybrid"): Buffer | string;
|
||||
generateKeys(): Buffer;
|
||||
generateKeys(encoding: HexBase64Latin1Encoding, format?: ECDHKeyFormat): string;
|
||||
computeSecret(other_public_key: Buffer): Buffer;
|
||||
|
||||
@@ -1151,6 +1151,19 @@ namespace crypto_tests {
|
||||
crypto.randomFill(arr, 2, (err: Error, buf: Uint8Array) => void {});
|
||||
crypto.randomFill(arr, 2, 3, (err: Error, buf: Uint8Array) => void {});
|
||||
}
|
||||
|
||||
{
|
||||
let key: string | Buffer = Buffer.from("buf");
|
||||
let curve = "secp256k1";
|
||||
let ret: string | Buffer = crypto.ECDH.convertKey(key, curve);
|
||||
key = "0xfff";
|
||||
ret = crypto.ECDH.convertKey(key, curve);
|
||||
ret = crypto.ECDH.convertKey(key, curve, "hex");
|
||||
ret = crypto.ECDH.convertKey(key, curve, "hex", "hex");
|
||||
ret = crypto.ECDH.convertKey(key, curve, "hex", "hex", "uncompressed");
|
||||
ret = crypto.ECDH.convertKey(key, curve, "hex", "hex", "compressed");
|
||||
ret = crypto.ECDH.convertKey(key, curve, "hex", "hex", "hybrid");
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
Vendored
+1
@@ -2,6 +2,7 @@
|
||||
// Project: https://github.com/nodemailer/nodemailer
|
||||
// Definitions by: Rogier Schouten <https://github.com/rogierschouten>
|
||||
// Piotr Roszatycki <https://github.com/dex4er>
|
||||
// Daniel Chao <https://github.com/bioball>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
|
||||
Vendored
+5
-7
@@ -1,14 +1,12 @@
|
||||
/// <reference types="node" />
|
||||
|
||||
import { EventEmitter } from 'events';
|
||||
import { Transport, TransportOptions } from '../..';
|
||||
|
||||
import { Transport, TransportOptions } from '..';
|
||||
import * as shared from '../shared';
|
||||
|
||||
import * as shared from './shared';
|
||||
|
||||
import Mail = require('./mailer');
|
||||
import MailMessage = require('./mailer/mail-message');
|
||||
import MimeNode = require('./mime-node');
|
||||
import Mail = require('../mailer');
|
||||
import MailMessage = require('../mailer/mail-message');
|
||||
import MimeNode = require('../mime-node');
|
||||
|
||||
declare namespace SendmailTransport {
|
||||
type MailOptions = Mail.Options;
|
||||
@@ -0,0 +1,7 @@
|
||||
/// <reference types="node" />
|
||||
|
||||
import { Transform } from 'stream';
|
||||
|
||||
declare class LeUnix extends Transform {}
|
||||
|
||||
export = LeUnix;
|
||||
@@ -0,0 +1,7 @@
|
||||
/// <reference types="node" />
|
||||
|
||||
import { Transform } from 'stream';
|
||||
|
||||
declare class LeWindows extends Transform {}
|
||||
|
||||
export = LeWindows;
|
||||
@@ -21,6 +21,8 @@ import SMTPTransport = require('nodemailer/lib/smtp-transport');
|
||||
import StreamTransport = require('nodemailer/lib/stream-transport');
|
||||
import wellKnown = require('nodemailer/lib/well-known');
|
||||
import XOAuth2 = require('nodemailer/lib/xoauth2');
|
||||
import LeWindows = require('nodemailer/lib/sendmail-transport/le-windows');
|
||||
import LeUnix = require('nodemailer/lib/sendmail-transport/le-unix');
|
||||
|
||||
import * as fs from 'fs';
|
||||
import * as stream from 'stream';
|
||||
@@ -722,6 +724,24 @@ function sendmail_test() {
|
||||
});
|
||||
}
|
||||
|
||||
// line ending transforms using windows-style newlines
|
||||
|
||||
function sendmail_line_endings_windows_test() {
|
||||
function process_le(mail: MailMessage) {
|
||||
const input = mail.message.createReadStream();
|
||||
input.pipe(new LeWindows());
|
||||
}
|
||||
}
|
||||
|
||||
// line ending transforms using unix-style newlines
|
||||
|
||||
function sendmail_line_endings_unix_test() {
|
||||
function process_le(mail: MailMessage) {
|
||||
const input = mail.message.createReadStream();
|
||||
input.pipe(new LeUnix());
|
||||
}
|
||||
}
|
||||
|
||||
// 5. SES transport
|
||||
|
||||
// Send a message using SES transport
|
||||
|
||||
@@ -31,7 +31,9 @@
|
||||
"lib/mime-funcs/mime-types.d.ts",
|
||||
"lib/mime-node.d.ts",
|
||||
"lib/qp.d.ts",
|
||||
"lib/sendmail-transport.d.ts",
|
||||
"lib/sendmail-transport/index.d.ts",
|
||||
"lib/sendmail-transport/le-unix.d.ts",
|
||||
"lib/sendmail-transport/le-windows.d.ts",
|
||||
"lib/ses-transport.d.ts",
|
||||
"lib/shared.d.ts",
|
||||
"lib/smtp-connection.d.ts",
|
||||
|
||||
Vendored
+144
-134
@@ -608,7 +608,7 @@ declare namespace Office {
|
||||
*
|
||||
* The initial page must be on the same domain as the parent page (the startAddress parameter). After the initial page loads, you can go to other domains.
|
||||
*
|
||||
* Any page calling office.context.ui.messageParent must also be on the same domain as the parent page.
|
||||
* Any page calling `office.context.ui.messageParent` must also be on the same domain as the parent page.
|
||||
*
|
||||
* The following design considerations apply to dialog boxes:
|
||||
*
|
||||
@@ -763,7 +763,7 @@ declare namespace Office {
|
||||
*/
|
||||
interface GetBindingDataOptions {
|
||||
/**
|
||||
* The expected shape of the selection. Use Office.CoercionType or text value. Default: The original, uncoerced type of the binding.
|
||||
* The expected shape of the selection. Use {@link Office.CoercionType} or text value. Default: The original, uncoerced type of the binding.
|
||||
*/
|
||||
coercionType?: Office.CoercionType | string
|
||||
/**
|
||||
@@ -807,8 +807,9 @@ declare namespace Office {
|
||||
*/
|
||||
interface SetBindingDataOptions {
|
||||
/**
|
||||
* Use only with binding type table and when a TableData object is passed for the data parameter. An array of objects that specify a range of columns, rows, or cells and specify, as key-value pairs, the cell formatting to apply to that range. Example: [{cells: Office.Table.Data, format: {fontColor: "yellow"}},
|
||||
{cells: {row: 3, column: 4}, format: {borderColor: "white", fontStyle: "bold"}}]
|
||||
* Use only with binding type table and when a TableData object is passed for the data parameter. An array of objects that specify a range of columns, rows, or cells and specify, as key-value pairs, the cell formatting to apply to that range.
|
||||
*
|
||||
* Example: `[{cells: Office.Table.Data, format: {fontColor: "yellow"}}, {cells: {row: 3, column: 4}, format: {borderColor: "white", fontStyle: "bold"}}]`
|
||||
*/
|
||||
cellFormat?: Array<RangeFormatConfiguration>
|
||||
/**
|
||||
@@ -832,7 +833,7 @@ declare namespace Office {
|
||||
*/
|
||||
startColumn?: number
|
||||
/**
|
||||
* For an inserted table, a list of key-value pairs that specify table formatting options, such as header row, total row, and banded rows. Example: {bandedRows: true, filterButton: false}
|
||||
* For an inserted table, a list of key-value pairs that specify table formatting options, such as header row, total row, and banded rows. Example: `{bandedRows: true, filterButton: false}`
|
||||
*/
|
||||
tableOptions?: object
|
||||
/**
|
||||
@@ -952,7 +953,7 @@ declare namespace Office {
|
||||
*/
|
||||
valueFormat?: Office.ValueFormat | string
|
||||
/**
|
||||
* Specify whether to get only the visible (that is, filtered-in) data or all the data. Useful when filtering data. Use Office.FilterType or string equivalent. This parameter is ignored in Word documents.
|
||||
* Specify whether to get only the visible (that is, filtered-in) data or all the data. Useful when filtering data. Use {@link Office.FilterType} or string equivalent. This parameter is ignored in Word documents.
|
||||
*/
|
||||
filterType?: Office.FilterType | string
|
||||
/**
|
||||
@@ -964,7 +965,7 @@ declare namespace Office {
|
||||
* Provides options for whether to select the location that is navigated to.
|
||||
*
|
||||
* @remarks
|
||||
* The behavior caused by the options.selectionMode option varies by host:
|
||||
* The behavior caused by the {@link Office.SelectionMode | options.selectionMode} option varies by host:
|
||||
*
|
||||
* In Excel: Office.SelectionMode.Selected selects all content in the binding, or named item. Office.SelectionMode.None for text bindings, selects the cell; for matrix bindings, table bindings, and named items, selects the first data cell (not first cell in header row for tables).
|
||||
*
|
||||
@@ -974,7 +975,7 @@ declare namespace Office {
|
||||
*/
|
||||
interface GoToByIdOptions {
|
||||
/**
|
||||
* Specifies whether the location specified by the id parameter is selected (highlighted). Use Office.SelectionMode or string equivalent. See the Remarks for more information.
|
||||
* Specifies whether the location specified by the id parameter is selected (highlighted). Use {@link Office.SelectionMode} or string equivalent. See the Remarks for more information.
|
||||
*/
|
||||
selectionMode?: Office.SelectionMode | string
|
||||
/**
|
||||
@@ -987,8 +988,9 @@ declare namespace Office {
|
||||
*/
|
||||
interface SetSelectedDataOptions {
|
||||
/**
|
||||
* Use only with binding type table and when a TableData object is passed for the data parameter. An array of objects that specify a range of columns, rows, or cells and specify, as key-value pairs, the cell formatting to apply to that range. Example: [{cells: Office.Table.Data, format: {fontColor: "yellow"}},
|
||||
{cells: {row: 3, column: 4}, format: {borderColor: "white", fontStyle: "bold"}}]
|
||||
* Use only with binding type table and when a TableData object is passed for the data parameter. An array of objects that specify a range of columns, rows, or cells and specify, as key-value pairs, the cell formatting to apply to that range.
|
||||
*
|
||||
* Example: `[{cells: Office.Table.Data, format: {fontColor: "yellow"}}, {cells: {row: 3, column: 4}, format: {borderColor: "white", fontStyle: "bold"}}]`
|
||||
*/
|
||||
cellFormat?: Array<RangeFormatConfiguration>
|
||||
/**
|
||||
@@ -996,7 +998,7 @@ declare namespace Office {
|
||||
*/
|
||||
coercionType?: Office.CoercionType | string
|
||||
/**
|
||||
* For an inserted table, a list of key-value pairs that specify table formatting options, such as header row, total row, and banded rows. Example: {bandedRows: true, filterButton: false}
|
||||
* For an inserted table, a list of key-value pairs that specify table formatting options, such as header row, total row, and banded rows. Example: `{bandedRows: true, filterButton: false}`
|
||||
*/
|
||||
tableOptions?: object
|
||||
/**
|
||||
@@ -1124,7 +1126,7 @@ declare namespace Office {
|
||||
* Specifies how to coerce data returned or set by the invoked method.
|
||||
*
|
||||
* @remarks
|
||||
* PowerPoint supports only Office.CoercionType.Text, Office.CoercionType.Image, and Office.CoercionType.SlideRange. Project supports only Office.CoercionType.Text.
|
||||
* PowerPoint supports only `Office.CoercionType.Text`, `Office.CoercionType.Image`, and `Office.CoercionType.SlideRange`. Project supports only `Office.CoercionType.Text`.
|
||||
*
|
||||
* Hosts: Access, Excel, Outlook, PowerPoint, Project, Word
|
||||
*/
|
||||
@@ -1158,7 +1160,7 @@ declare namespace Office {
|
||||
*/
|
||||
Ooxml,
|
||||
/**
|
||||
* Return a JSON object that contains an array of the ids, titles, and indexes of the selected slides.For example, {"slides":[{"id":257,"title":"Slide 2","index":2},{"id":256,"title":"Slide 1","index":1}]} for a selection of two slides.
|
||||
* Return a JSON object that contains an array of the ids, titles, and indexes of the selected slides.For example, `{"slides":[{"id":257,"title":"Slide 2","index":2},{"id":256,"title":"Slide 1","index":1}]}` for a selection of two slides.
|
||||
* @remarks
|
||||
* Only applies to data in PowerPoint when calling the Document.getSelectedData method to get the current slide or selected range of slides.
|
||||
*/
|
||||
@@ -1226,10 +1228,10 @@ declare namespace Office {
|
||||
Text,
|
||||
}
|
||||
/**
|
||||
* Specifies the kind of event that was raised. Returned by the type property of an EventNameEventArgs object.
|
||||
* Specifies the kind of event that was raised. Returned by the `type` property of an *EventName*EventArgs object.
|
||||
*
|
||||
* @remarks
|
||||
* Add-ins for Project support the Office.EventType.ResourceSelectionChanged, Office.EventType.TaskSelectionChanged, and Office.EventType.ViewSelectionChanged event types.
|
||||
* Add-ins for Project support the `Office.EventType.ResourceSelectionChanged`, `Office.EventType.TaskSelectionChanged`, and `Office.EventType.ViewSelectionChanged` event types.
|
||||
*
|
||||
* Hosts: Access, Excel, PowerPoint, Project, Word
|
||||
*/
|
||||
@@ -1417,6 +1419,8 @@ declare namespace Office {
|
||||
* The Binding object is never called directly. It is the abstract parent class of the objects that represent each type of binding: MatrixBinding, TableBinding, or TextBinding. All three of these objects inherit the getDataAsync and setDataAsync methods from the Binding object that enable to you interact with the data in the binding. They also inherit the id and type properties for querying those property values. Additionally, the MatrixBinding and TableBinding objects expose additional methods for matrix- and table-specific features, such as counting the number of rows and columns.
|
||||
*/
|
||||
interface Binding {
|
||||
|
||||
|
||||
/**
|
||||
* Get the Document object associated with the binding.
|
||||
*
|
||||
@@ -1511,9 +1515,9 @@ declare namespace Office {
|
||||
*/
|
||||
interface Bindings {
|
||||
/**
|
||||
* Gets a Document object that represents the document associated with this set of bindings.
|
||||
* Gets an {@link Office.Document} object that represents the document associated with this set of bindings.
|
||||
*
|
||||
*remarks
|
||||
* @remarks
|
||||
* Hosts: Access, Excel, Word
|
||||
*/
|
||||
document: Document;
|
||||
@@ -1531,14 +1535,14 @@ declare namespace Office {
|
||||
*
|
||||
* Note: In Excel, when specifying a table as a named item, you must fully qualify the name to include the worksheet name in the name of the table in this format: "Sheet1!Table1"
|
||||
*
|
||||
* For Word, the itemName parameter refers to the Title property of a Rich Text content control. (You can't bind to content controls other than the Rich Text content control.)
|
||||
* For Word, the itemName parameter refers to the Title property of a Rich Text content control. (You can't bind to content controls other than the Rich Text content control).
|
||||
*
|
||||
* By default, a content control has no Title value assigned. To assign a meaningful name in the Word UI, after inserting a Rich Text content control from the Controls group on the Developer tab of the ribbon, use the Properties command in the Controls group to display the Content Control Properties dialog box. Then set the Title property of the content control to the name you want to reference from your code.
|
||||
*
|
||||
* Note: In Word, if there are multiple Rich Text content controls with the same Title property value (name), and you try to bind to one these content controls with this method (by specifying its name as the itemName parameter), the operation will fail.
|
||||
*
|
||||
* @param itemName Name of the bindable object in the document. For Example 'MyExpenses' table in Excel."
|
||||
* @param bindingType The Office BindingType for the data. The method returns null if the selected object cannot be coerced into the specified type.
|
||||
* @param bindingType The {@link Office.BindingType} for the data. The method returns null if the selected object cannot be coerced into the specified type.
|
||||
* @param options Provides options for configuring the binding that is created.
|
||||
* @param callback Optional. A function that is invoked when the callback returns, whose only parameter is of type AsyncResult.
|
||||
*/
|
||||
@@ -1744,7 +1748,7 @@ declare namespace Office {
|
||||
setXmlAsync(xml: string, options?: AsyncContextOptions, callback?: (result: AsyncResult) => void): void;
|
||||
}
|
||||
/**
|
||||
* Represents a single CustomXMLPart in a CustomXMLParts collection.
|
||||
* Represents a single CustomXMLPart in an {@link Office.CustomXmlParts} collection.
|
||||
*
|
||||
* @remarks
|
||||
* Hosts: Word
|
||||
@@ -1771,7 +1775,7 @@ declare namespace Office {
|
||||
*/
|
||||
id: string;
|
||||
/**
|
||||
* Gets the set of namespace prefix mappings (CustomXMLPrefixMappings) used against the current CustomXMLPart.
|
||||
* Gets the set of namespace prefix mappings ({@link Office.CustomXmlPrefixMappings}) used against the current CustomXMLPart.
|
||||
*
|
||||
* @remarks
|
||||
* Hosts: Word
|
||||
@@ -1787,9 +1791,9 @@ declare namespace Office {
|
||||
*
|
||||
* You can add multiple event handlers for the specified eventType as long as the name of each event handler function is unique.
|
||||
*
|
||||
* @param eventType Specifies the type of event to add. Required. For a CustomXmlPart object event, the eventType parameter can be specified as Office.EventType.DataNodeDeleted, Office.EventType.DataNodeInserted, Office.EventType.DataNodeReplaced, or the corresponding text values of these enumerations.
|
||||
* @param eventType Specifies the type of event to add. Required. For a CustomXmlPart object event, the eventType parameter can be specified as `Office.EventType.DataNodeDeleted`, `Office.EventType.DataNodeInserted`, `Office.EventType.DataNodeReplaced`, or the corresponding text values of these enumerations.
|
||||
* @param handler The event handler function to add, whose only parameter is of type NodeDeletedEventArgs, NodeInsertedEventArgs, or NodeReplaceEventArgs. Required.
|
||||
* @param options Provides an option for preserving context data of any type, unchanged, for use in a callback..
|
||||
* @param options Provides an option for preserving context data of any type, unchanged, for use in a callback.
|
||||
* @param callback Optional. A function that is invoked when the callback returns, whose only parameter is of type AsyncResult.
|
||||
*/
|
||||
addHandlerAsync(eventType: EventType, handler: (result: any) => void, options?: AsyncContextOptions, callback?: (result: AsyncResult) => void): void;
|
||||
@@ -1838,7 +1842,7 @@ declare namespace Office {
|
||||
*
|
||||
* Available in Requirement set: CustomXmlParts
|
||||
*
|
||||
* @param eventType Specifies the type of event to remove. Required.For a CustomXmlPart object event, the eventType parameter can be specified as Office.EventType.DataNodeDeleted, Office.EventType.DataNodeInserted, Office.EventType.DataNodeReplaced, or the corresponding text values of these enumerations.
|
||||
* @param eventType Specifies the type of event to remove. Required.For a CustomXmlPart object event, the eventType parameter can be specified as `Office.EventType.DataNodeDeleted`, `Office.EventType.DataNodeInserted`, `Office.EventType.DataNodeReplaced`, or the corresponding text values of these enumerations.
|
||||
* @param options Provides options to determine which event handler or handlers are removed.
|
||||
* @param callback Optional. A function that is invoked when the callback returns, whose only parameter is of type AsyncResult.
|
||||
*/
|
||||
@@ -1875,7 +1879,7 @@ declare namespace Office {
|
||||
* Available in Requirement set: CustomXmlParts
|
||||
*
|
||||
* @param id The GUID of the custom XML part, including opening and closing braces.
|
||||
* @param options Provides an option for preserving context data of any type, unchanged, for use in a callback..
|
||||
* @param options Provides an option for preserving context data of any type, unchanged, for use in a callback.
|
||||
* @param callback Optional. A function that is invoked when the callback returns, whose only parameter is of type AsyncResult.
|
||||
*/
|
||||
getByIdAsync(id: string, options?: AsyncContextOptions, callback?: (result: AsyncResult) => void): void;
|
||||
@@ -1960,7 +1964,7 @@ declare namespace Office {
|
||||
* @remarks
|
||||
* Hosts: Access, Excel, Word
|
||||
*
|
||||
* You don't instantiate the Document object directly in your script. To call members of the Document object to interact with the current document or worksheet, use Office.context.document in your script.
|
||||
* You don't instantiate the Document object directly in your script. To call members of the Document object to interact with the current document or worksheet, use `Office.context.document` in your script.
|
||||
*/
|
||||
bindings: Bindings;
|
||||
/**
|
||||
@@ -2001,8 +2005,8 @@ declare namespace Office {
|
||||
*
|
||||
* You can add multiple event handlers for the specified eventType as long as the name of each event handler function is unique.
|
||||
*
|
||||
* @param eventType For a Document object event, the eventType parameter can be specified as Office.EventType.Document.SelectionChanged or Office.EventType.Document.ActiveViewChanged, or the corresponding text value of this enumeration.
|
||||
* @param handler The event handler function to add, whose only parameter is of type DocumentSelectionChangedEventArgs. Required.
|
||||
* @param eventType For a Document object event, the eventType parameter can be specified as `Office.EventType.Document.SelectionChanged` or `Office.EventType.Document.ActiveViewChanged`, or the corresponding text value of this enumeration.
|
||||
* @param handler The event handler function to add, whose only parameter is of type {@link Office.DocumentSelectionChangedEventArgs}. Required.
|
||||
* @param options Provides an option for preserving context data of any type, unchanged, for use in a callback.
|
||||
* @param callback Optional. A function that is invoked when the callback returns, whose only parameter is of type AsyncResult.
|
||||
*/
|
||||
@@ -2017,7 +2021,7 @@ declare namespace Office {
|
||||
*
|
||||
* Can trigger an event when the view changes.
|
||||
*
|
||||
* @param options Provides an option for preserving context data of any type, unchanged, for use in a callback..
|
||||
* @param options Provides an option for preserving context data of any type, unchanged, for use in a callback.
|
||||
* @param callback Optional. A function that is invoked when the callback returns, whose only parameter is of type AsyncResult.
|
||||
*/
|
||||
getActiveViewAsync(options?: AsyncContextOptions, callback?: (result: AsyncResult) => void): void;
|
||||
@@ -2031,15 +2035,15 @@ declare namespace Office {
|
||||
*
|
||||
* For add-ins running in Office host applications other than Office for iOS, the getFileAsync method supports getting files in slices of up to 4194304 bytes (4 MB). For add-ins running in Office for iOS apps, the getFileAsync method supports getting files in slices of up to 65536 (64 KB).
|
||||
*
|
||||
* The fileType parameter can be specified by using the FileType enumeration or text values. But the possible values vary with the host:
|
||||
* The fileType parameter can be specified by using the {@link Office.FileType} enumeration or text values. But the possible values vary with the host:
|
||||
*
|
||||
* Excel Online, Win32, Mac, and iOS: Office.FileType.Compressed
|
||||
* Excel Online, Win32, Mac, and iOS: `Office.FileType.Compressed`
|
||||
*
|
||||
* PowerPoint on Windows desktop, Mac, and iPad, and PowerPoint Online: Office.FileType.Compressed, Office.FileType.Pdf
|
||||
* PowerPoint on Windows desktop, Mac, and iPad, and PowerPoint Online: `Office.FileType.Compressed`, `Office.FileType.Pdf`
|
||||
*
|
||||
* Word on Windows desktop, Word on Mac, and Word Online: Office.FileType.Compressed, Office.FileType.Pdf, Office.FileType.Text
|
||||
* Word on Windows desktop, Word on Mac, and Word Online: `Office.FileType.Compressed`, `Office.FileType.Pdf`, `Office.FileType.Text`
|
||||
*
|
||||
* Word on iPad: Office.FileType.Compressed, Office.FileType.Text
|
||||
* Word on iPad: `Office.FileType.Compressed`, `Office.FileType.Text`
|
||||
*
|
||||
* @param fileType The format in which the file will be returned
|
||||
* @param options Provides options for setting the size of slices that the document will be divided into.
|
||||
@@ -2054,7 +2058,7 @@ declare namespace Office {
|
||||
*
|
||||
* Available in Requirement set: not in a set
|
||||
*
|
||||
* You get the file's URL with the url property ( asyncResult.value.url).
|
||||
* You get the file's URL with the url property (`asyncResult.value.url`).
|
||||
*
|
||||
* @param options Provides an option for preserving context data of any type, unchanged, for use in a callback.
|
||||
* @param callback A function that is invoked when the callback returns, whose only parameter is of type AsyncResult.
|
||||
@@ -2070,17 +2074,17 @@ declare namespace Office {
|
||||
*
|
||||
* The possible values for the coercionType parameter vary by the host:
|
||||
*
|
||||
* Excel, Excel Online, PowerPoint, PowerPoint Online, Word, and Word Online only: Office.CoercionType.Text (string)
|
||||
* Excel, Excel Online, PowerPoint, PowerPoint Online, Word, and Word Online only: `Office.CoercionType.Text` (string)
|
||||
*
|
||||
* Excel, Word, and Word Online only: Office.CoercionType.Matrix (array of arrays)
|
||||
* Excel, Word, and Word Online only: `Office.CoercionType.Matrix` (array of arrays)
|
||||
*
|
||||
* Access, Excel, Word, and Word Online only: Office.CoercionType.Table (TableData object)
|
||||
* Access, Excel, Word, and Word Online only: `Office.CoercionType.Table` (TableData object)
|
||||
*
|
||||
* Word only: Office.CoercionType.Html
|
||||
* Word only: `Office.CoercionType.Html`
|
||||
*
|
||||
* Word and Word Online only: Office.CoercionType.Ooxml (Office Open XML)
|
||||
* Word and Word Online only: `Office.CoercionType.Ooxml` (Office Open XML)
|
||||
*
|
||||
* PowerPoint and PowerPoint Online only: Office.CoercionType.SlideRange
|
||||
* PowerPoint and PowerPoint Online only: `Office.CoercionType.SlideRange`
|
||||
*
|
||||
* @param coercionType The type of data structure to return.
|
||||
* @param options Provides options for customizing what data is returned and how it is formatted.
|
||||
@@ -2120,7 +2124,7 @@ declare namespace Office {
|
||||
* Available in Requirement set: DocumentEvents
|
||||
*
|
||||
* @param eventType The event type. For document can be 'Document.SelectionChanged' or 'Document.ActiveViewChanged'.
|
||||
* @param options Provides options to determine which event handler or handlers are removed. *
|
||||
* @param options Provides options to determine which event handler or handlers are removed.
|
||||
* @param callback Optional. A function that is invoked when the callback returns, whose only parameter is of type AsyncResult.
|
||||
*/
|
||||
removeHandlerAsync(eventType: EventType, options?: RemoveHandlerOptions, callback?: (result: AsyncResult) => void): void;
|
||||
@@ -2146,7 +2150,7 @@ declare namespace Office {
|
||||
*
|
||||
* Office.CoercionType.Image: Excel, Word, PowerPoint
|
||||
*
|
||||
* @param data The data to be set. Either a string or CoercionType value, 2d array or TableData object.
|
||||
* @param data The data to be set. Either a string or {@link Office.CoercionType} value, 2d array or TableData object.
|
||||
* @param options Provides options for how to insert data to the selection.
|
||||
* @param callback Optional. A function that is invoked when the callback returns, whose only parameter is of type AsyncResult.
|
||||
*/
|
||||
@@ -2211,11 +2215,11 @@ declare namespace Office {
|
||||
*/
|
||||
interface DocumentSelectionChangedEventArgs {
|
||||
/**
|
||||
* Gets a Document object that represents the document that raised the SelectionChanged event.
|
||||
* Gets an {@link Office.Document} object that represents the document that raised the SelectionChanged event.
|
||||
*/
|
||||
document: Document;
|
||||
/**
|
||||
* Get an EventType enumeration value that identifies the kind of event that was raised.
|
||||
* Get an {@link Office.EventType} enumeration value that identifies the kind of event that was raised.
|
||||
*/
|
||||
type: EventType;
|
||||
}
|
||||
@@ -2326,15 +2330,15 @@ declare namespace Office {
|
||||
url: string
|
||||
}
|
||||
/**
|
||||
* Represents a binding in two dimensions of rows and columns.
|
||||
*
|
||||
* @remarks
|
||||
* Hosts: Excel, Word
|
||||
*
|
||||
* Available in Requirement set: MatrixBindings
|
||||
*
|
||||
* The MatrixBinding object inherits the id property, type property, getDataAsync method, and setDataAsync method from the Binding object.
|
||||
*/
|
||||
* Represents a binding in two dimensions of rows and columns.
|
||||
*
|
||||
* @remarks
|
||||
* Hosts: Excel, Word
|
||||
*
|
||||
* Available in Requirement set: MatrixBindings
|
||||
*
|
||||
* The MatrixBinding object inherits the id property, type property, getDataAsync method, and setDataAsync method from the Binding object.
|
||||
*/
|
||||
interface MatrixBinding extends Binding {
|
||||
/**
|
||||
* Gets the number of columns in the matrix data structure, as an integer value.
|
||||
@@ -2565,7 +2569,7 @@ declare namespace Office {
|
||||
*/
|
||||
interface Slice {
|
||||
/**
|
||||
* Gets the raw data of the file slice in Office.FileType.Text ("text") or Office.FileType.Compressed ("compressed") format as specified by the fileType parameter of the call to the Document.getFileAsync method.
|
||||
* Gets the raw data of the file slice in `Office.FileType.Text` ("text") or `Office.FileType.Compressed` ("compressed") format as specified by the fileType parameter of the call to the Document.getFileAsync method.
|
||||
*
|
||||
* @remarks
|
||||
* Files in the "compressed" format will return a byte array that can be transformed to a base64-encoded string if required.
|
||||
@@ -2764,7 +2768,7 @@ declare namespace Office {
|
||||
setTableOptionsAsync(tableOptions: any, options?: AsyncContextOptions, callback?: (result: AsyncResult) => void): void;
|
||||
}
|
||||
/**
|
||||
* Represents the data in a table or a TableBinding.
|
||||
* Represents the data in a table or a {@link Office.TableBinding}.
|
||||
*
|
||||
* @remarks
|
||||
* Hosts: Excel, Word
|
||||
@@ -2776,6 +2780,7 @@ declare namespace Office {
|
||||
constructor();
|
||||
/**
|
||||
* Gets or sets the headers of the table.
|
||||
*
|
||||
* @remarks
|
||||
* To specify headers, you must specify an array of arrays that corresponds to the structure of the table. For example, to specify headers for a two-column table you would set the header property to [['header1', 'header2']].
|
||||
*
|
||||
@@ -2792,6 +2797,7 @@ declare namespace Office {
|
||||
headers: any[];
|
||||
/**
|
||||
* Gets or sets the rows in the table. Returns an array of arrays that contains the data in the table. Returns an empty array ``, if there are no rows.
|
||||
*
|
||||
* @remarks
|
||||
* To specify rows, you must specify an array of arrays that corresponds to the structure of the table. For example, to specify two rows of string values in a two-column table you would set the rows property to [['a', 'b'], ['c', 'd']].
|
||||
*
|
||||
@@ -2835,7 +2841,7 @@ declare namespace Office {
|
||||
*
|
||||
* Available in Requirement set: TextBindings
|
||||
*
|
||||
* The TextBinding object inherits the id property, type property, getDataAsync method, and setDataAsync method from the Binding object. It does not implement any additional properties or methods of its own.
|
||||
* The TextBinding object inherits the id property, type property, getDataAsync method, and setDataAsync method from the {@link Office.Binding} object. It does not implement any additional properties or methods of its own.
|
||||
*/
|
||||
interface TextBinding extends Binding { }
|
||||
/**
|
||||
@@ -4948,15 +4954,15 @@ declare namespace Office {
|
||||
/**
|
||||
* The attachment is a file
|
||||
*/
|
||||
File,
|
||||
File = "file",
|
||||
/**
|
||||
* The attachment is an Exchange item
|
||||
*/
|
||||
Item,
|
||||
Item = "item",
|
||||
/**
|
||||
* The attachment is stored in a cloud location, such as OneDrive. The id property of the attachment contains a URL to the file.
|
||||
*/
|
||||
Cloud
|
||||
Cloud = "cloud"
|
||||
}
|
||||
/**
|
||||
* Specifies the day of week or type of day.
|
||||
@@ -5020,31 +5026,31 @@ declare namespace Office {
|
||||
/**
|
||||
* Specifies that the entity is a meeting suggestion.
|
||||
*/
|
||||
MeetingSuggestion,
|
||||
MeetingSuggestion = "meetingSuggestion",
|
||||
/**
|
||||
* Specifies that the entity is a task suggestion.
|
||||
*/
|
||||
TaskSuggestion,
|
||||
TaskSuggestion = "taskSuggestion",
|
||||
/**
|
||||
* Specifies that the entity is a postal address.
|
||||
*/
|
||||
Address,
|
||||
Address = "address",
|
||||
/**
|
||||
* Specifies that the entity is an SMTP email address.
|
||||
*/
|
||||
EmailAddress,
|
||||
EmailAddress = "emailAddress",
|
||||
/**
|
||||
* Specifies that the entity is an Internet URL.
|
||||
*/
|
||||
Url,
|
||||
Url = "url",
|
||||
/**
|
||||
* Specifies that the entity is a US phone number.
|
||||
*/
|
||||
PhoneNumber,
|
||||
PhoneNumber = "phoneNumber",
|
||||
/**
|
||||
* Specifies that the entity is a contact.
|
||||
*/
|
||||
Contact
|
||||
Contact = "contact"
|
||||
}
|
||||
/**
|
||||
* Specifies the notification message type for an appointment or message.
|
||||
@@ -5058,15 +5064,15 @@ declare namespace Office {
|
||||
/**
|
||||
* The notificationMessage is a progress indicator.
|
||||
*/
|
||||
ProgressIndicator,
|
||||
ProgressIndicator = "progressIndicator",
|
||||
/**
|
||||
* The notificationMessage is an informational message.
|
||||
*/
|
||||
InformationalMessage,
|
||||
InformationalMessage = "informationalMessage",
|
||||
/**
|
||||
* The notificationMessage is an error message.
|
||||
*/
|
||||
ErrorMessage
|
||||
ErrorMessage = "errorMessage"
|
||||
}
|
||||
/**
|
||||
* Specifies an item's type.
|
||||
@@ -5080,11 +5086,11 @@ declare namespace Office {
|
||||
/**
|
||||
* An email, meeting request, meeting response, or meeting cancellation.
|
||||
*/
|
||||
Message,
|
||||
Message = "message",
|
||||
/**
|
||||
* An appointment item.
|
||||
*/
|
||||
Appointment
|
||||
Appointment = "appointment"
|
||||
}
|
||||
/**
|
||||
* Specifies the month.
|
||||
@@ -5156,19 +5162,19 @@ declare namespace Office {
|
||||
/**
|
||||
* Specifies that the recipient is a distribution list containing a list of email addresses.
|
||||
*/
|
||||
DistributionList,
|
||||
DistributionList = "distributionList",
|
||||
/**
|
||||
* Specifies that the recipient is an SMTP email address that is on the Exchange server.
|
||||
*/
|
||||
User,
|
||||
User = "user",
|
||||
/**
|
||||
* Specifies that the recipient is an SMTP email address that is not on the Exchange server.
|
||||
*/
|
||||
ExternalUser,
|
||||
ExternalUser = "externalUser",
|
||||
/**
|
||||
* Specifies that the recipient is not one of the other recipient types.
|
||||
*/
|
||||
Other
|
||||
Other = "other"
|
||||
}
|
||||
/**
|
||||
* Specifies the time zone applied to the recurrence.
|
||||
@@ -5768,23 +5774,23 @@ declare namespace Office {
|
||||
/**
|
||||
* There has been no response from the attendee.
|
||||
*/
|
||||
None,
|
||||
None = "none",
|
||||
/**
|
||||
* The attendee is the meeting organizer.
|
||||
*/
|
||||
Organizer,
|
||||
Organizer = "organizer",
|
||||
/**
|
||||
* The meeting request was tentatively accepted by the attendee.
|
||||
*/
|
||||
Tentative,
|
||||
Tentative = "tentative",
|
||||
/**
|
||||
* The meeting request was accepted by the attendee.
|
||||
*/
|
||||
Accepted,
|
||||
Accepted = "accepted",
|
||||
/**
|
||||
* The meeting request was declined by the attendee.
|
||||
*/
|
||||
Declined
|
||||
Declined = "declined"
|
||||
}
|
||||
/**
|
||||
* Specifies the version of the REST API that corresponds to a REST-formatted item ID.
|
||||
@@ -5798,15 +5804,15 @@ declare namespace Office {
|
||||
/**
|
||||
* Version 1.0.
|
||||
*/
|
||||
v1_0,
|
||||
v1_0 = "v1.0",
|
||||
/**
|
||||
* Version 2.0.
|
||||
*/
|
||||
v2_0,
|
||||
v2_0 = "v2.0",
|
||||
/**
|
||||
* Beta.
|
||||
*/
|
||||
Beta
|
||||
Beta = "beta"
|
||||
}
|
||||
/**
|
||||
* Specifies the week of the month.
|
||||
@@ -6238,7 +6244,7 @@ declare namespace Office {
|
||||
/**
|
||||
* Represents a contact stored on the server. Read mode only.
|
||||
*
|
||||
* The list of contacts associated with an email message or appointment is returned in the contacts property of the Entities object that is returned by the getEntities or getEntitiesByType method of the active item.
|
||||
* The list of contacts associated with an email message or appointment is returned in the contacts property of the {@link Office.Entities} object that is returned by the getEntities or getEntitiesByType method of the active item.
|
||||
*
|
||||
* [Api set: Mailbox 1.0]
|
||||
*
|
||||
@@ -6528,7 +6534,7 @@ declare namespace Office {
|
||||
*
|
||||
* The getAsync method starts an asynchronous call to the Exchange server to get the from value of a message.
|
||||
*
|
||||
* The from value of the item is provided as an EmailAddressDetails in the asyncResult.value property.
|
||||
* The from value of the item is provided as an {@link Office.EmailAddressDetails} in the asyncResult.value property.
|
||||
*
|
||||
* [Api set: Mailbox Preview]
|
||||
*
|
||||
@@ -8686,9 +8692,9 @@ declare namespace Office {
|
||||
* Applicable Outlook mode: Read
|
||||
*
|
||||
* @param parameters A dictionary containing all values to be filled in for the user in the new form. All parameters are optional.
|
||||
* toRecipients: An array of strings containing the email addresses or an array containing an EmailAddressDetails object for each of the recipients on the To line. The array is limited to a maximum of 100 entries.
|
||||
* ccRecipients: An array of strings containing the email addresses or an array containing an EmailAddressDetails object for each of the recipients on the Cc line. The array is limited to a maximum of 100 entries.
|
||||
* bccRecipients: An array of strings containing the email addresses or an array containing an EmailAddressDetails object for each of the recipients on the Bcc line. The array is limited to a maximum of 100 entries.
|
||||
* toRecipients: An array of strings containing the email addresses or an array containing an {@link Office.EmailAddressDetails} object for each of the recipients on the To line. The array is limited to a maximum of 100 entries.
|
||||
* ccRecipients: An array of strings containing the email addresses or an array containing an {@link Office.EmailAddressDetails} object for each of the recipients on the Cc line. The array is limited to a maximum of 100 entries.
|
||||
* bccRecipients: An array of strings containing the email addresses or an array containing an {@link Office.EmailAddressDetails} object for each of the recipients on the Bcc line. The array is limited to a maximum of 100 entries.
|
||||
* subject: A string containing the subject of the message. The string is limited to a maximum of 255 characters.
|
||||
* htmlBody: The HTML body of the message. The body content is limited to a maximum size of 32 KB.
|
||||
* attachments: An array of JSON objects that are either file or item attachments.
|
||||
@@ -8823,7 +8829,7 @@ declare namespace Office {
|
||||
*
|
||||
* When you use the makeEwsRequestAsync method in mail apps running in Outlook versions earlier than version 15.0.4535.1004, you should set the encoding value to ISO-8859-1.
|
||||
*
|
||||
* <?xml version="1.0" encoding="iso-8859-1"?>
|
||||
* `<?xml version="1.0" encoding="iso-8859-1"?>`
|
||||
*
|
||||
* You do not need to set the encoding value when your mail app is running in Outlook on the web. You can determine whether your mail app is running in Outlook or Outlook on the web by using the mailbox.diagnostics.hostName property. You can determine what version of Outlook is running by using the mailbox.diagnostics.hostVersion property.
|
||||
*
|
||||
@@ -8898,7 +8904,7 @@ declare namespace Office {
|
||||
*/
|
||||
key?: string;
|
||||
/**
|
||||
* Specifies the Office.MailboxEnums.ItemNotificationMessageType of message. If type is ProgressIndicator or ErrorMessage, an icon is automatically supplied and the message is not persistent. Therefore the icon and persistent properties are not valid for these types of messages. Including them will result in an ArgumentException. If type is ProgressIndicator, the developer should remove or replace the progress indicator when the action is complete.
|
||||
* Specifies the {@link Office.MailboxEnums.ItemNotificationMessageType} of message. If type is ProgressIndicator or ErrorMessage, an icon is automatically supplied and the message is not persistent. Therefore the icon and persistent properties are not valid for these types of messages. Including them will result in an ArgumentException. If type is ProgressIndicator, the developer should remove or replace the progress indicator when the action is complete.
|
||||
*/
|
||||
type: Office.MailboxEnums.ItemNotificationMessageType;
|
||||
/**
|
||||
@@ -8944,8 +8950,11 @@ declare namespace Office {
|
||||
* Applicable Outlook mode: Compose or read
|
||||
*
|
||||
* In addition to this signature, the method also has the following signatures:
|
||||
*
|
||||
* addAsync(key: string, JSONmessage: NotificationMessageDetails): void;
|
||||
*
|
||||
* addAsync(key: string, JSONmessage: NotificationMessageDetails, options: AsyncContextOptions): void;
|
||||
*
|
||||
* addAsync(key: string, JSONmessage: NotificationMessageDetails, callback: (result: AsyncResult) => void): void;
|
||||
*
|
||||
*/
|
||||
@@ -9045,7 +9054,7 @@ declare namespace Office {
|
||||
* In addition to the main signature, this method also has these signatures:
|
||||
* removeAsync(key: string): void;
|
||||
* removeAsync(key: string, options: AsyncContextOptions): void;
|
||||
* removeAsync(key: string, callback: (result: AsyncResult) => void): void; *
|
||||
* removeAsync(key: string, callback: (result: AsyncResult) => void): void;
|
||||
*
|
||||
* @param key The key for the notification message to remove.
|
||||
* @param options Optional. An object literal that contains one or more of the following properties.
|
||||
@@ -9267,9 +9276,9 @@ declare namespace Office {
|
||||
*
|
||||
* - Strings containing SMTP email addresses
|
||||
*
|
||||
* - EmailUser objects
|
||||
* - {@link Office.EmailUser} objects
|
||||
*
|
||||
* - EmailAddressDetails objects
|
||||
* - {@link Office.EmailAddressDetails} objects
|
||||
*
|
||||
* [Api set: Mailbox 1.1]
|
||||
*
|
||||
@@ -9292,9 +9301,9 @@ declare namespace Office {
|
||||
*
|
||||
* - Strings containing SMTP email addresses
|
||||
*
|
||||
* - EmailUser objects
|
||||
* - {@link Office.EmailUser} objects
|
||||
*
|
||||
* - EmailAddressDetails objects
|
||||
* - {@link Office.EmailAddressDetails} objects
|
||||
*
|
||||
* [Api set: Mailbox 1.1]
|
||||
*
|
||||
@@ -9312,7 +9321,7 @@ declare namespace Office {
|
||||
/**
|
||||
* Gets a recipient list for an appointment or message.
|
||||
*
|
||||
* When the call completes, the asyncResult.value property will contain an array of EmailAddressDetails objects.
|
||||
* When the call completes, the asyncResult.value property will contain an array of{@link Office. EmailAddressDetails} objects.
|
||||
*
|
||||
* [Api set: Mailbox 1.1]
|
||||
*
|
||||
@@ -9332,7 +9341,7 @@ declare namespace Office {
|
||||
/**
|
||||
* Gets a recipient list for an appointment or message.
|
||||
*
|
||||
* When the call completes, the asyncResult.value property will contain an array of EmailAddressDetails objects.
|
||||
* When the call completes, the asyncResult.value property will contain an array of {@link Office.EmailAddressDetails} objects.
|
||||
*
|
||||
* [Api set: Mailbox 1.1]
|
||||
*
|
||||
@@ -9353,9 +9362,9 @@ declare namespace Office {
|
||||
*
|
||||
* - Strings containing SMTP email addresses
|
||||
*
|
||||
* - EmailUser objects
|
||||
* - {@link Office.EmailUser} objects
|
||||
*
|
||||
* - EmailAddressDetails objects
|
||||
* - {@link Office.EmailAddressDetails} objects
|
||||
*
|
||||
* [Api set: Mailbox 1.1]
|
||||
*
|
||||
@@ -9386,9 +9395,9 @@ declare namespace Office {
|
||||
*
|
||||
* - Strings containing SMTP email addresses
|
||||
*
|
||||
* - EmailUser objects
|
||||
* - {@link Office.EmailUser} objects
|
||||
*
|
||||
* - EmailAddressDetails objects
|
||||
* - {@link Office.EmailAddressDetails} objects
|
||||
*
|
||||
* [Api set: Mailbox 1.1]
|
||||
*
|
||||
@@ -9411,9 +9420,9 @@ declare namespace Office {
|
||||
*
|
||||
* - Strings containing SMTP email addresses
|
||||
*
|
||||
* - EmailUser objects
|
||||
* - {@link Office.EmailUser} objects
|
||||
*
|
||||
* - EmailAddressDetails objects
|
||||
* - {@link Office.EmailAddressDetails} objects
|
||||
*
|
||||
* [Api set: Mailbox 1.1]
|
||||
*
|
||||
@@ -9438,9 +9447,9 @@ declare namespace Office {
|
||||
*
|
||||
* - Strings containing SMTP email addresses
|
||||
*
|
||||
* - EmailUser objects
|
||||
* - {@link Office.EmailUser} objects
|
||||
*
|
||||
* - EmailAddressDetails objects
|
||||
* - {@link Office.EmailAddressDetails} objects
|
||||
*
|
||||
* [Api set: Mailbox 1.1]
|
||||
*
|
||||
@@ -10391,11 +10400,11 @@ declare namespace Office {
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
declare namespace OfficeExtension {
|
||||
/** An abstract proxy object that represents an object in an Office document. You create proxy objects from the context (or from other proxy objects), add commands to a queue to act on the object, and then synchronize the proxy object state with the document by calling "context.sync()". */
|
||||
/** An abstract proxy object that represents an object in an Office document. You create proxy objects from the context (or from other proxy objects), add commands to a queue to act on the object, and then synchronize the proxy object state with the document by calling `context.sync()`. */
|
||||
class ClientObject {
|
||||
/** The request context associated with the object */
|
||||
context: ClientRequestContext;
|
||||
/** Returns a boolean value for whether the corresponding object is a null object. You must call "context.sync()" before reading the isNullObject property. */
|
||||
/** Returns a boolean value for whether the corresponding object is a null object. You must call `context.sync()` before reading the isNullObject property. */
|
||||
isNullObject: boolean;
|
||||
}
|
||||
}
|
||||
@@ -10424,7 +10433,7 @@ declare namespace OfficeExtension {
|
||||
pendingStatements: string[];
|
||||
}
|
||||
|
||||
/** An abstract RequestContext object that facilitates requests to the host Office application. The "Excel.run" and "Word.run" methods provide a request context. */
|
||||
/** An abstract {@link Office.RequestContext} object that facilitates requests to the host Office application. The `Excel.run and `Word.run` methods provide a request context. */
|
||||
class ClientRequestContext {
|
||||
constructor(url?: string);
|
||||
|
||||
@@ -10434,23 +10443,24 @@ declare namespace OfficeExtension {
|
||||
/** Request headers */
|
||||
requestHeaders: { [name: string]: string };
|
||||
|
||||
/** Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. */
|
||||
/** Queues up a command to load the specified properties of the object. You must call `context.sync()` before reading the properties. */
|
||||
load(object: ClientObject, option?: string | string[] | LoadOption): void;
|
||||
|
||||
/**
|
||||
* Queues up a command to recursively load the specified properties of the object and its navigation properties.
|
||||
* You must call "context.sync()" before reading the properties.
|
||||
*
|
||||
* You must call `context.sync()` before reading the properties.
|
||||
*
|
||||
* @param object The object to be loaded.
|
||||
* @param options The key-value pairing of load options for the types, such as { "Workbook": "worksheets,tables", "Worksheet": "tables", "Tables": "name" }
|
||||
* @param options The key-value pairing of load options for the types, such as `{ "Workbook": "worksheets,tables", "Worksheet": "tables", "Tables": "name" }`
|
||||
* @param maxDepth The maximum recursive depth.
|
||||
*/
|
||||
loadRecursive(object: ClientObject, options: { [typeName: string]: string | string[] | LoadOption }, maxDepth?: number): void;
|
||||
|
||||
/** Adds a trace message to the queue. If the promise returned by "context.sync()" is rejected due to an error, this adds a ".traceMessages" array to the OfficeExtension.Error object, containing all trace messages that were executed. These messages can help you monitor the program execution sequence and detect the cause of the error. */
|
||||
/** Adds a trace message to the queue. If the promise returned by `context.sync()` is rejected due to an error, this adds a ".traceMessages" array to the OfficeExtension.Error object, containing all trace messages that were executed. These messages can help you monitor the program execution sequence and detect the cause of the error. */
|
||||
trace(message: string): void;
|
||||
|
||||
/** Synchronizes the state between JavaScript proxy objects and the Office document, by executing instructions queued on the request context and retrieving properties of loaded Office objects for use in your code.�This method returns a promise, which is resolved when the synchronization is complete. */
|
||||
/** Synchronizes the state between JavaScript proxy objects and the Office document, by executing instructions queued on the request context and retrieving properties of loaded Office objects for use in your code. This method returns a promise, which is resolved when the synchronization is complete. */
|
||||
sync<T>(passThroughValue?: T): Promise<T>;
|
||||
|
||||
/** Debug information */
|
||||
@@ -10473,9 +10483,9 @@ declare namespace OfficeExtension {
|
||||
}
|
||||
|
||||
declare namespace OfficeExtension {
|
||||
/** Contains the result for methods that return primitive types. The object's value property is retrieved from the document after "context.sync()" is invoked. */
|
||||
/** Contains the result for methods that return primitive types. The object's value property is retrieved from the document after `context.sync()` is invoked. */
|
||||
class ClientResult<T> {
|
||||
/** The value of the result that is retrieved from the document after "context.sync()" is invoked. */
|
||||
/** The value of the result that is retrieved from the document after `context.sync()` is invoked. */
|
||||
value: T;
|
||||
}
|
||||
}
|
||||
@@ -10527,7 +10537,7 @@ declare namespace OfficeExtension {
|
||||
fullStatements?: string[];
|
||||
}
|
||||
|
||||
/** The error object returned by "context.sync()", if a promise is rejected due to an error while processing the request. */
|
||||
/** The error object returned by `context.sync()`, if a promise is rejected due to an error while processing the request. */
|
||||
class Error {
|
||||
/** Error name: "OfficeExtension.Error".*/
|
||||
name: string;
|
||||
@@ -10537,9 +10547,9 @@ declare namespace OfficeExtension {
|
||||
stack: string;
|
||||
/** Error code string, such as "InvalidArgument". */
|
||||
code: string;
|
||||
/** Trace messages (if any) that were added via a "context.trace()" invocation before calling "context.sync()". If there was an error, this contains all trace messages that were executed before the error occurred. These messages can help you monitor the program execution sequence and detect the case of the error. */
|
||||
/** Trace messages (if any) that were added via a `context.trace()` invocation before calling `context.sync()`. If there was an error, this contains all trace messages that were executed before the error occurred. These messages can help you monitor the program execution sequence and detect the case of the error. */
|
||||
traceMessages: Array<string>;
|
||||
/** Debug info (useful for detailed logging of the error, i.e., via JSON.stringify(...)). */
|
||||
/** Debug info (useful for detailed logging of the error, i.e., via `JSON.stringify(...)`). */
|
||||
debugInfo: DebugInfo;
|
||||
/** Inner error, if applicable. */
|
||||
innerError: Error;
|
||||
@@ -10564,7 +10574,7 @@ declare namespace OfficeExtension {
|
||||
}
|
||||
|
||||
declare namespace OfficeExtension {
|
||||
/** A Promise object that represents a deferred interaction with the host Office application. The publicly-consumable OfficeExtension.Promise is available starting in ExcelApi 1.2 and WordApi 1.2. Promises can be chained via ".then", and errors can be caught via ".catch". Remember to always use a ".catch" on the outer promise, and to return intermediary promises so as not to break the promise chain. When a browser-provided native Promise implementation is available, OfficeExtension.Promise will switch to use the native Promise instead. */
|
||||
/** A Promise object that represents a deferred interaction with the host Office application. The publicly-consumable {@link Office.OfficeExtension.Promise} is available starting in ExcelApi 1.2 and WordApi 1.2. Promises can be chained via ".then", and errors can be caught via ".catch". Remember to always use a ".catch" on the outer promise, and to return intermediary promises so as not to break the promise chain. When a browser-provided native Promise implementation is available, OfficeExtension.Promise will switch to use the native Promise instead. */
|
||||
const Promise: Office.IPromiseConstructor;
|
||||
type IPromise<T> = Promise<T>;
|
||||
}
|
||||
@@ -10576,9 +10586,9 @@ declare namespace OfficeExtension {
|
||||
add(object: ClientObject): void;
|
||||
/** Track a new object for automatic adjustment based on surrounding changes in the document. Only some object types require this. If you are using an object across ".sync" calls and outside the sequential execution of a ".run" batch, and get an "InvalidObjectPath" error when setting a property or invoking a method on the object, you needed to have added the object to the tracked object collection when the object was first created. */
|
||||
add(objects: ClientObject[]): void;
|
||||
/** Release the memory associated with an object that was previously added to this collection. Having many tracked objects slows down the host application, so please remember to free any objects you add, once you're done using them. You will need to call "context.sync()" before the memory release takes effect. */
|
||||
/** Release the memory associated with an object that was previously added to this collection. Having many tracked objects slows down the host application, so please remember to free any objects you add, once you're done using them. You will need to call `context.sync()` before the memory release takes effect. */
|
||||
remove(object: ClientObject): void;
|
||||
/** Release the memory associated with an object that was previously added to this collection. Having many tracked objects slows down the host application, so please remember to free any objects you add, once you're done using them. You will need to call "context.sync()" before the memory release takes effect. */
|
||||
/** Release the memory associated with an object that was previously added to this collection. Having many tracked objects slows down the host application, so please remember to free any objects you add, once you're done using them. You will need to call `context.sync()` before the memory release takes effect. */
|
||||
remove(objects: ClientObject[]): void;
|
||||
}
|
||||
}
|
||||
@@ -10836,45 +10846,45 @@ declare namespace Excel {
|
||||
}
|
||||
/**
|
||||
* Executes a batch script that performs actions on the Excel object model, using a new RequestContext. When the promise is resolved, any tracked objects that were automatically allocated during execution will be released.
|
||||
* @param batch - A function that takes in a RequestContext and returns a promise (typically, just the result of "context.sync()"). The context parameter facilitates requests to the Excel application. Since the Office add-in and the Excel application run in two different processes, the RequestContext is required to get access to the Excel object model from the add-in.
|
||||
* @param batch - A function that takes in a RequestContext and returns a promise (typically, just the result of `context.sync()`). The context parameter facilitates requests to the Excel application. Since the Office add-in and the Excel application run in two different processes, the RequestContext is required to get access to the Excel object model from the add-in.
|
||||
*/
|
||||
function run<T>(batch: (context: Excel.RequestContext) => Promise<T>): Promise<T>;
|
||||
/**
|
||||
* Executes a batch script that performs actions on the Excel object model, using a new remote RequestContext. When the promise is resolved, any tracked objects that were automatically allocated during execution will be released.
|
||||
* @param requestInfo - The URL of the remote workbook and the request headers to be sent.
|
||||
* @param batch - A function that takes in a RequestContext and returns a promise (typically, just the result of "context.sync()"). The context parameter facilitates requests to the Excel application. Since the Office add-in and the Excel application run in two different processes, the RequestContext is required to get access to the Excel object model from the add-in.
|
||||
* @param batch - A function that takes in a RequestContext and returns a promise (typically, just the result of `context.sync()`). The context parameter facilitates requests to the Excel application. Since the Office add-in and the Excel application run in two different processes, the RequestContext is required to get access to the Excel object model from the add-in.
|
||||
*/
|
||||
function run<T>(requestInfo: OfficeExtension.RequestUrlAndHeaderInfo | Session, batch: (context: Excel.RequestContext) => Promise<T>): Promise<T>;
|
||||
/**
|
||||
* Executes a batch script that performs actions on the Excel object model, using the RequestContext of a previously-created object. When the promise is resolved, any tracked objects that were automatically allocated during execution will be released.
|
||||
* @param contextObject - A previously-created object. The batch will use the same RequestContext as the passed-in object, which means that any changes applied to the object will be picked up by "context.sync()".
|
||||
* @param batch - A function that takes in a RequestContext and returns a promise (typically, just the result of "context.sync()"). The context parameter facilitates requests to the Excel application. Since the Office add-in and the Excel application run in two different processes, the RequestContext is required to get access to the Excel object model from the add-in.
|
||||
* @param contextObject - A previously-created object. The batch will use the same RequestContext as the passed-in object, which means that any changes applied to the object will be picked up by `context.sync()`.
|
||||
* @param batch - A function that takes in a RequestContext and returns a promise (typically, just the result of `context.sync()`). The context parameter facilitates requests to the Excel application. Since the Office add-in and the Excel application run in two different processes, the RequestContext is required to get access to the Excel object model from the add-in.
|
||||
*/
|
||||
function run<T>(contextObject: OfficeExtension.ClientRequestContext, batch: (context: Excel.RequestContext) => Promise<T>): Promise<T>;
|
||||
/**
|
||||
* Executes a batch script that performs actions on the Excel object model, using the RequestContext of a previously-created API object. When the promise is resolved, any tracked objects that were automatically allocated during execution will be released.
|
||||
* @param object - A previously-created API object. The batch will use the same RequestContext as the passed-in object, which means that any changes applied to the object will be picked up by "context.sync()".
|
||||
* @param batch - A function that takes in a RequestContext and returns a promise (typically, just the result of "context.sync()"). The context parameter facilitates requests to the Excel application. Since the Office add-in and the Excel application run in two different processes, the RequestContext is required to get access to the Excel object model from the add-in.
|
||||
* @param object - A previously-created API object. The batch will use the same RequestContext as the passed-in object, which means that any changes applied to the object will be picked up by `context.sync()`.
|
||||
* @param batch - A function that takes in a RequestContext and returns a promise (typically, just the result of `context.sync()`). The context parameter facilitates requests to the Excel application. Since the Office add-in and the Excel application run in two different processes, the RequestContext is required to get access to the Excel object model from the add-in.
|
||||
*/
|
||||
function run<T>(object: OfficeExtension.ClientObject, batch: (context: Excel.RequestContext) => Promise<T>): Promise<T>;
|
||||
/**
|
||||
* Executes a batch script that performs actions on the Excel object model, using the remote RequestContext of a previously-created API object. When the promise is resolved, any tracked objects that were automatically allocated during execution will be released.
|
||||
* @param requestInfo - The URL of the remote workbook and the request headers to be sent.
|
||||
* @param object - A previously-created API object. The batch will use the same RequestContext as the passed-in object, which means that any changes applied to the object will be picked up by "context.sync()".
|
||||
* @param batch - A function that takes in a RequestContext and returns a promise (typically, just the result of "context.sync()"). The context parameter facilitates requests to the Excel application. Since the Office add-in and the Excel application run in two different processes, the RequestContext is required to get access to the Excel object model from the add-in.
|
||||
* @param object - A previously-created API object. The batch will use the same RequestContext as the passed-in object, which means that any changes applied to the object will be picked up by `context.sync()`.
|
||||
* @param batch - A function that takes in a RequestContext and returns a promise (typically, just the result of `context.sync()`). The context parameter facilitates requests to the Excel application. Since the Office add-in and the Excel application run in two different processes, the RequestContext is required to get access to the Excel object model from the add-in.
|
||||
*/
|
||||
function run<T>(requestInfo: OfficeExtension.RequestUrlAndHeaderInfo | Session, object: OfficeExtension.ClientObject, batch: (context: Excel.RequestContext) => Promise<T>): Promise<T>;
|
||||
/**
|
||||
* Executes a batch script that performs actions on the Excel object model, using the RequestContext of previously-created API objects.
|
||||
* @param objects - An array of previously-created API objects. The array will be validated to make sure that all of the objects share the same context. The batch will use this shared RequestContext, which means that any changes applied to these objects will be picked up by "context.sync()".
|
||||
* @param batch - A function that takes in a RequestContext and returns a promise (typically, just the result of "context.sync()"). The context parameter facilitates requests to the Excel application. Since the Office add-in and the Excel application run in two different processes, the RequestContext is required to get access to the Excel object model from the add-in.
|
||||
* @param objects - An array of previously-created API objects. The array will be validated to make sure that all of the objects share the same context. The batch will use this shared RequestContext, which means that any changes applied to these objects will be picked up by `context.sync()`.
|
||||
* @param batch - A function that takes in a RequestContext and returns a promise (typically, just the result of `context.sync()`). The context parameter facilitates requests to the Excel application. Since the Office add-in and the Excel application run in two different processes, the RequestContext is required to get access to the Excel object model from the add-in.
|
||||
*/
|
||||
function run<T>(objects: OfficeExtension.ClientObject[], batch: (context: Excel.RequestContext) => Promise<T>): Promise<T>;
|
||||
/**
|
||||
* Executes a batch script that performs actions on the Excel object model, using the remote RequestContext of previously-created API objects.
|
||||
* @param requestInfo - The URL of the remote workbook and the request headers to be sent.
|
||||
* @param objects - An array of previously-created API objects. The array will be validated to make sure that all of the objects share the same context. The batch will use this shared RequestContext, which means that any changes applied to these objects will be picked up by "context.sync()".
|
||||
* @param batch - A function that takes in a RequestContext and returns a promise (typically, just the result of "context.sync()"). The context parameter facilitates requests to the Excel application. Since the Office add-in and the Excel application run in two different processes, the RequestContext is required to get access to the Excel object model from the add-in.
|
||||
* @param objects - An array of previously-created API objects. The array will be validated to make sure that all of the objects share the same context. The batch will use this shared RequestContext, which means that any changes applied to these objects will be picked up by `context.sync()`.
|
||||
* @param batch - A function that takes in a RequestContext and returns a promise (typically, just the result of `context.sync()`). The context parameter facilitates requests to the Excel application. Since the Office add-in and the Excel application run in two different processes, the RequestContext is required to get access to the Excel object model from the add-in.
|
||||
*/
|
||||
function run<T>(requestInfo: OfficeExtension.RequestUrlAndHeaderInfo | Session, objects: OfficeExtension.ClientObject[], batch: (context: Excel.RequestContext) => Promise<T>): Promise<T>;
|
||||
/**
|
||||
|
||||
Vendored
+16
-2
@@ -160,15 +160,21 @@ export class Gpio extends NodeJS.EventEmitter {
|
||||
disableInterrupt(): Gpio;
|
||||
|
||||
/**
|
||||
* Enables alerts for the GPIO.
|
||||
* Enables alerts for the GPIO. Returns this.
|
||||
*/
|
||||
enableAlert(): Gpio;
|
||||
|
||||
/**
|
||||
* Disables aterts for the GPIO.
|
||||
* Disables aterts for the GPIO. Returns this.
|
||||
*/
|
||||
disableAlert(): Gpio;
|
||||
|
||||
/**
|
||||
* Sets a glitch filter on a GPIO. Returns this.
|
||||
* @param steady Time, in microseconds, during which the level must be stable. Maximum value: 300000
|
||||
*/
|
||||
glitchFilter(steady: number): Gpio;
|
||||
|
||||
/*----------------------*
|
||||
* mode
|
||||
*----------------------*/
|
||||
@@ -410,3 +416,11 @@ export function terminate(): void;
|
||||
* @param peripheral an unsigned integer specifying the peripheral for timing (CLOCK_PWM or CLOCK_PCM)
|
||||
*/
|
||||
export function configureClock(microseconds: number, peripheral: number): void;
|
||||
|
||||
/**
|
||||
* Configures pigpio to use the specified socket port.
|
||||
* The default setting is to use port 8888.
|
||||
* If configureSocketPort is called, it must be called before creating Gpio objects.
|
||||
* @param port an unsigned integer specifying the pigpio socket port number
|
||||
*/
|
||||
export function configureSocketPort(port: number): void;
|
||||
|
||||
@@ -5,6 +5,7 @@ import * as assert from 'assert';
|
||||
const Gpio = pigpio.Gpio;
|
||||
|
||||
pigpio.configureClock(1, pigpio.CLOCK_PWM);
|
||||
pigpio.configureSocketPort(23456);
|
||||
|
||||
const led = new Gpio(18, {
|
||||
mode: Gpio.OUTPUT,
|
||||
@@ -878,3 +879,37 @@ import * as assert from 'assert';
|
||||
clearInterval(iv);
|
||||
}, 2000);
|
||||
})();
|
||||
|
||||
(function gpio_glitch_filter(): void {
|
||||
const Gpio = pigpio.Gpio;
|
||||
const input = new Gpio(7, {
|
||||
mode: Gpio.INPUT,
|
||||
pullUpDown: Gpio.PUD_OFF,
|
||||
alert: true
|
||||
});
|
||||
const output = new Gpio(8, {
|
||||
mode: Gpio.OUTPUT
|
||||
});
|
||||
let count = 0;
|
||||
|
||||
output.digitalWrite(0);
|
||||
input.glitchFilter(50);
|
||||
input.on('alert', (level, tick) => {
|
||||
if (level === 1) {
|
||||
count++;
|
||||
console.log(' rising edge, count=' + count);
|
||||
}
|
||||
});
|
||||
|
||||
output.trigger(30, 1); // alert function should not be executed (blocked by glitchFilter)
|
||||
|
||||
setTimeout(() => {
|
||||
output.trigger(70, 1); // alert function should be executed
|
||||
}, 500);
|
||||
|
||||
setTimeout(() => {
|
||||
assert.strictEqual(count, 1, 'expected 1 alert function call instead of ' + count);
|
||||
console.log(" success...");
|
||||
process.exit(0);
|
||||
}, 1000);
|
||||
})();
|
||||
|
||||
Vendored
+663
-211
@@ -1,216 +1,668 @@
|
||||
// Type definitions for postmark 1.3
|
||||
// Type definitions for postmark 1.4
|
||||
// Project: http://wildbit.github.io/postmark.js
|
||||
// Definitions by: Ben Bayard <https://github.com/benbayard>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
interface PostmarkError {
|
||||
status: number;
|
||||
message: string;
|
||||
code: number;
|
||||
}
|
||||
|
||||
interface PostmarkMessageHeader {
|
||||
Name: string;
|
||||
Value: string;
|
||||
}
|
||||
|
||||
interface PostmarkAttachment {
|
||||
Content: string;
|
||||
Name: string;
|
||||
ContentType: string;
|
||||
}
|
||||
|
||||
interface Filter {
|
||||
count: number;
|
||||
offset: number;
|
||||
}
|
||||
|
||||
interface PostmarkMessageWithTemplate {
|
||||
To: string;
|
||||
From: string;
|
||||
Cc?: string;
|
||||
Bcc?: string;
|
||||
ReplyTo?: string;
|
||||
TemplateId?: string;
|
||||
TemplateModel?: any;
|
||||
Tag?: string;
|
||||
Subject?: string;
|
||||
TrackOpens?: boolean;
|
||||
TrackLinks?: string;
|
||||
Headers?: PostmarkMessageHeader[];
|
||||
}
|
||||
|
||||
interface PostmarkMessage {
|
||||
To: string;
|
||||
From: string;
|
||||
Cc?: string;
|
||||
Bcc?: string;
|
||||
ReplyTo?: string;
|
||||
Tag?: string;
|
||||
Subject?: string;
|
||||
HTMLBody?: string;
|
||||
TextBody?: string;
|
||||
TrackOpens?: boolean;
|
||||
TrackLinks?: string;
|
||||
Headers?: PostmarkMessageHeader[];
|
||||
Attachments?: PostmarkAttachment[];
|
||||
}
|
||||
|
||||
interface Sender {
|
||||
Color: string;
|
||||
RawEmailEnabled: boolean;
|
||||
SmtpApiActivated: boolean;
|
||||
DeliveryHookUrl: string;
|
||||
InboundHookUrl: string;
|
||||
BounceHookUrl: boolean;
|
||||
IncludeBounceContentInHook: boolean;
|
||||
OpenHookUrl: boolean;
|
||||
PostFirstOpenOnly: boolean;
|
||||
TrackOpens: boolean;
|
||||
TrackLinks: string;
|
||||
InboundDomain: string;
|
||||
InboundSpamThreshold: number;
|
||||
}
|
||||
|
||||
interface TemplateValidator<T extends object> {
|
||||
Subject: string;
|
||||
HtmlBody: string;
|
||||
TextBody: string;
|
||||
TestRenderModel?: T;
|
||||
InlineCssForHtmlTestRender?: boolean;
|
||||
}
|
||||
|
||||
type PostmarkCallback<T extends object = any> = ((e: PostmarkError, ret: T) => void) | undefined;
|
||||
|
||||
interface SimpleOptions {
|
||||
ssl: boolean;
|
||||
requestHost: string;
|
||||
}
|
||||
|
||||
interface Options extends SimpleOptions {
|
||||
requestFactory(
|
||||
options: SimpleOptions
|
||||
): (
|
||||
path?: string,
|
||||
type?: string,
|
||||
content?: PostmarkMessage,
|
||||
callback?: PostmarkCallback
|
||||
) => any;
|
||||
}
|
||||
|
||||
declare class Client {
|
||||
constructor(serverKey: string, options?: Partial<Options>);
|
||||
send(message: PostmarkMessage, callback: PostmarkCallback): void;
|
||||
sendEmailWithTemplate(
|
||||
message: PostmarkMessageWithTemplate,
|
||||
callback: PostmarkCallback
|
||||
): void;
|
||||
batch(message: PostmarkMessage[], callback: PostmarkCallback): void;
|
||||
sendEmail(message: PostmarkMessage, callback: PostmarkCallback): void;
|
||||
sendEmailBatch(message: PostmarkMessage[], callback: PostmarkCallback): void;
|
||||
getDeliveryStatistics(callback: PostmarkCallback): void;
|
||||
getBounces(filter: Partial<Filter>, callback: PostmarkCallback): void;
|
||||
getBounce(id: number, callback: PostmarkCallback): void;
|
||||
getBounceDump(id: number, callback: PostmarkCallback): void;
|
||||
activateBounce(id: number, callback: PostmarkCallback): void;
|
||||
getBounceTags(callback: PostmarkCallback): void;
|
||||
getServer(callback: PostmarkCallback): void;
|
||||
editServer<T extends keyof Sender>(options: Pick<Sender, T>, callback: PostmarkCallback): void;
|
||||
getOutboundMessages(filter: Partial<Filter>, callback: PostmarkCallback): void;
|
||||
getOutboundMessageDetails(id: number, callback: PostmarkCallback): void;
|
||||
getMessageOpens(filter: Partial<Filter>, callback: PostmarkCallback): void;
|
||||
getMessageOpensForSingleMessage(id: number, filter: Partial<Filter>, callback: PostmarkCallback): void;
|
||||
getInboundMessages(filter: Partial<Filter>, callback: PostmarkCallback): void;
|
||||
getInboundMessageDetails(id: number, callback: PostmarkCallback): void;
|
||||
bypassBlockedInboundMessage(id: number, callback: PostmarkCallback): void;
|
||||
retryInboundHookForMessage(id: number, callback: PostmarkCallback): void;
|
||||
getOuboundOverview(filter: Partial<Filter>, callback: PostmarkCallback): void;
|
||||
validateTemplate<T extends object>(templateObject: TemplateValidator<T>, callback: PostmarkCallback): void;
|
||||
}
|
||||
|
||||
interface CreateSignature {
|
||||
FromEmail: string;
|
||||
Name: string;
|
||||
ReplyToEmail?: string;
|
||||
ReturnPathDomain?: string;
|
||||
}
|
||||
|
||||
interface CreateServer {
|
||||
Name: string;
|
||||
Color?: string;
|
||||
RawEmailEnabled?: boolean;
|
||||
SmtpApiActivated?: boolean;
|
||||
DeliveryHookUrl?: string;
|
||||
InboundHookUrl?: string;
|
||||
BounceHookUrl?: string;
|
||||
IncludeBounceContentInHook?: boolean;
|
||||
OpenHookUrl?: string;
|
||||
PostFirstOpenOnly?: boolean;
|
||||
TrackOpens?: boolean;
|
||||
TrackLinks?: string;
|
||||
InboundDomain?: string;
|
||||
InboundSpamThreshold?: number;
|
||||
}
|
||||
|
||||
interface CreateDomain {
|
||||
Name: string;
|
||||
ReturnPathDomain?: string;
|
||||
}
|
||||
|
||||
declare class AdminClient {
|
||||
constructor(apiKey: string, options: Partial<Options>);
|
||||
listSenderSignatures(query: Partial<Filter>, callback: PostmarkCallback): void;
|
||||
createSenderSignature(options: CreateSignature, callback: PostmarkCallback): void;
|
||||
editSenderSignature<T extends keyof CreateSignature>(
|
||||
id: number,
|
||||
options: Partial<Pick<CreateSignature, T>>,
|
||||
callback: PostmarkCallback
|
||||
): void;
|
||||
deleteSenderSignature(id: number, callback: PostmarkCallback): void;
|
||||
resendSenderSignatureConfirmation(id: number, callback: PostmarkCallback): void;
|
||||
verifySenderSignatureSPF(id: number, callback: PostmarkCallback): void;
|
||||
requestNewDKIMForSenderSignature(id: number, callback: PostmarkCallback): void;
|
||||
getServer(id: number, callback: PostmarkCallback): void;
|
||||
createServer(options: CreateServer, callback: PostmarkCallback): void;
|
||||
editServer<T extends keyof CreateServer>(
|
||||
id: number,
|
||||
options: Pick<CreateServer, T>,
|
||||
callback: PostmarkCallback
|
||||
): void;
|
||||
deleteServer(id: number, callback: PostmarkCallback): void;
|
||||
listServers(query: Partial<Filter>, callback: PostmarkCallback): void;
|
||||
listDomains(query: Partial<Filter>, callback: PostmarkCallback): void;
|
||||
getDomain(id: number, callback: PostmarkCallback): void;
|
||||
createDomain(
|
||||
options: CreateDomain,
|
||||
callback: PostmarkCallback
|
||||
): void;
|
||||
editDomain<T extends keyof CreateDomain>(
|
||||
id: number,
|
||||
options: Pick<CreateDomain, T>,
|
||||
callback: PostmarkCallback
|
||||
): void;
|
||||
deleteDomain(id: number, callback: PostmarkCallback): void;
|
||||
verifyDomainSPF(id: number, callback: PostmarkCallback): void;
|
||||
rotateDKIMForDomain(id: number, callback: PostmarkCallback): void;
|
||||
}
|
||||
|
||||
interface ClientClass {
|
||||
new(serverKey: string, options: Partial<Options>): Client;
|
||||
}
|
||||
|
||||
interface AdminClientClass {
|
||||
new(apiKey: string, options: Partial<Options>): AdminClient;
|
||||
}
|
||||
|
||||
interface Postmark {
|
||||
(apiKey: string, options: Partial<Options>): void;
|
||||
defaults: Options;
|
||||
Client: ClientClass;
|
||||
AdminClient: AdminClientClass;
|
||||
}
|
||||
|
||||
declare var postmark: Postmark;
|
||||
// TypeScript Version: 2.4
|
||||
|
||||
export = postmark;
|
||||
|
||||
declare const postmark: Postmark.Postmark;
|
||||
declare namespace Postmark {
|
||||
const defaults: Options;
|
||||
|
||||
interface PostmarkError {
|
||||
status: number;
|
||||
message: string;
|
||||
code: number;
|
||||
}
|
||||
|
||||
interface PostmarkMessageHeader {
|
||||
Name: string;
|
||||
Value: string;
|
||||
}
|
||||
|
||||
interface PostmarkAttachment {
|
||||
Content: string;
|
||||
Name: string;
|
||||
ContentType: string;
|
||||
}
|
||||
|
||||
interface Filter {
|
||||
count?: number;
|
||||
offset?: number;
|
||||
}
|
||||
|
||||
interface PostmarkMessageWithTemplate {
|
||||
To: string;
|
||||
From: string;
|
||||
Cc?: string;
|
||||
Bcc?: string;
|
||||
ReplyTo?: string;
|
||||
TemplateId?: string;
|
||||
TemplateModel?: any;
|
||||
Tag?: string;
|
||||
Subject?: string;
|
||||
TrackOpens?: boolean;
|
||||
TrackLinks?: string;
|
||||
Headers?: PostmarkMessageHeader[];
|
||||
}
|
||||
|
||||
interface PostmarkMessage {
|
||||
To: string;
|
||||
From: string;
|
||||
Cc?: string;
|
||||
Bcc?: string;
|
||||
ReplyTo?: string;
|
||||
Tag?: string;
|
||||
Subject?: string;
|
||||
HTMLBody?: string;
|
||||
TextBody?: string;
|
||||
TrackOpens?: boolean;
|
||||
TrackLinks?: string;
|
||||
Headers?: PostmarkMessageHeader[];
|
||||
Attachments?: PostmarkAttachment[];
|
||||
}
|
||||
|
||||
interface Sender {
|
||||
Color: string;
|
||||
RawEmailEnabled: boolean;
|
||||
SmtpApiActivated: boolean;
|
||||
DeliveryHookUrl: string;
|
||||
InboundHookUrl: string;
|
||||
BounceHookUrl: boolean;
|
||||
IncludeBounceContentInHook: boolean;
|
||||
OpenHookUrl: boolean;
|
||||
PostFirstOpenOnly: boolean;
|
||||
TrackOpens: boolean;
|
||||
TrackLinks: string;
|
||||
InboundDomain: string;
|
||||
InboundSpamThreshold: number;
|
||||
}
|
||||
|
||||
interface TemplateValidator<T extends object> {
|
||||
Subject: string;
|
||||
HtmlBody: string;
|
||||
TextBody: string;
|
||||
TestRenderModel?: T;
|
||||
InlineCssForHtmlTestRender?: boolean;
|
||||
}
|
||||
|
||||
type PostmarkCallback<T extends object = any> = ((e: PostmarkError, ret: T) => undefined) | undefined;
|
||||
|
||||
interface SimpleOptions {
|
||||
ssl: boolean;
|
||||
requestHost: string;
|
||||
}
|
||||
|
||||
interface Options extends SimpleOptions {
|
||||
requestFactory(
|
||||
options: SimpleOptions
|
||||
): (
|
||||
path?: string,
|
||||
type?: string,
|
||||
content?: PostmarkMessage,
|
||||
callback?: PostmarkCallback
|
||||
) => any;
|
||||
}
|
||||
|
||||
class Client {
|
||||
constructor(serverKey: string, options?: Partial<Options>);
|
||||
|
||||
send(message: PostmarkMessage): Promise<SendStatus>;
|
||||
send(message: PostmarkMessage, callback: PostmarkCallback<SendStatus>): undefined;
|
||||
|
||||
sendEmailWithTemplate(message: PostmarkMessageWithTemplate): Promise<SendStatus>;
|
||||
sendEmailWithTemplate(message: PostmarkMessageWithTemplate, callback: PostmarkCallback<SendStatus>): undefined;
|
||||
|
||||
batch(message: PostmarkMessage[]): Promise<SendStatus[]>;
|
||||
batch(message: PostmarkMessage[], callback: PostmarkCallback<SendStatus[]>): undefined;
|
||||
|
||||
sendEmail(message: PostmarkMessage): Promise<SendStatus>;
|
||||
sendEmail(message: PostmarkMessage, callback: PostmarkCallback<SendStatus>): undefined;
|
||||
|
||||
sendEmailBatch(message: PostmarkMessage[]): Promise<SendStatus[]>;
|
||||
sendEmailBatch(message: PostmarkMessage[], callback: PostmarkCallback<SendStatus[]>): undefined;
|
||||
|
||||
// stats
|
||||
getDeliveryStatistics(): Promise<DeliveryStats>;
|
||||
getDeliveryStatistics(callback: PostmarkCallback<DeliveryStats>): undefined;
|
||||
|
||||
// bounces
|
||||
getBounces(filter: BounceFilter): Promise<BouncesResult>;
|
||||
getBounces(filter: BounceFilter, callback?: PostmarkCallback<BouncesResult>): undefined;
|
||||
|
||||
getBounce(id: number): Promise<Bounce>;
|
||||
getBounce(id: number, callback?: PostmarkCallback<Bounce>): undefined;
|
||||
|
||||
getBounceDump(id: number): Promise<BounceDump>;
|
||||
getBounceDump(id: number, callback?: PostmarkCallback<BounceDump>): undefined;
|
||||
|
||||
activateBounce(id: number): Promise<ActivatedBounceResult>;
|
||||
activateBounce(id: number, callback?: PostmarkCallback<ActivatedBounceResult>): undefined;
|
||||
|
||||
getBounceTags(): Promise<string[]>;
|
||||
getBounceTags(callback?: PostmarkCallback<string[]>): undefined;
|
||||
|
||||
// server
|
||||
getServer(): Promise<Server>;
|
||||
getServer(callback?: PostmarkCallback<Server>): undefined;
|
||||
|
||||
editServer(server: Partial<Server>): Promise<Server>;
|
||||
editServer(server: Partial<Server>, callback?: PostmarkCallback<Server>): undefined;
|
||||
|
||||
// message info
|
||||
getOutboundMessages(filter: OutboundMessageFilter): Promise<OutboundMessagesResult>;
|
||||
getOutboundMessages(filter: OutboundMessageFilter, callback?: PostmarkCallback<OutboundMessagesResult>): undefined;
|
||||
|
||||
getOutboundMessageDetails(id: number): Promise<OutboundMessage>;
|
||||
getOutboundMessageDetails(id: number, callback?: PostmarkCallback<OutboundMessage>): undefined;
|
||||
|
||||
getMessageOpens(filter: OpenMessageFilter): Promise<MessageOpensResult>;
|
||||
getMessageOpens(filter: OpenMessageFilter, callback?: PostmarkCallback<MessageOpensResult>): undefined;
|
||||
|
||||
getMessageOpensForSingleMessage(id: number, filter: Filter): Promise<MessageOpensResult>;
|
||||
getMessageOpensForSingleMessage(id: number, filter: Filter, callback?: PostmarkCallback<MessageOpensResult>): undefined;
|
||||
|
||||
getInboundMessages(filter: InboundMessageFilter): Promise<InboundMessagesResult>;
|
||||
getInboundMessages(filter: InboundMessageFilter, callback?: PostmarkCallback<InboundMessagesResult>): undefined;
|
||||
|
||||
getInboundMessageDetails(id: number): Promise<InboundMessage>;
|
||||
getInboundMessageDetails(id: number, callback?: PostmarkCallback<InboundMessage>): undefined;
|
||||
|
||||
bypassBlockedInboundMessage(id: number): Promise<GenericResult>;
|
||||
bypassBlockedInboundMessage(id: number, callback?: PostmarkCallback<GenericResult>): undefined;
|
||||
|
||||
getOuboundOverview(filter: BaseFilter): Promise<OutboundOverview>;
|
||||
getOuboundOverview(filter: BaseFilter, callback?: PostmarkCallback<OutboundOverview>): undefined;
|
||||
|
||||
retryInboundHookForMessage(id: number): Promise<GenericResult>;
|
||||
retryInboundHookForMessage(id: number, callback?: PostmarkCallback<GenericResult>): undefined;
|
||||
|
||||
// templates
|
||||
getTemplate(id: number): Promise<Template>;
|
||||
getTemplate(id: number, callback?: PostmarkCallback<Template>): undefined;
|
||||
|
||||
createTemplate(template: Partial<Template>): Promise<TemplateBase>;
|
||||
createTemplate(template: Partial<Template>, callback?: PostmarkCallback<TemplateBase>): undefined;
|
||||
|
||||
editTemplate(template: Partial<Template>): Promise<TemplateBase>;
|
||||
editTemplate(template: Partial<Template>, callback?: PostmarkCallback<TemplateBase>): undefined;
|
||||
|
||||
getTemplates(filter: Filter): Promise<TemplatesResult>;
|
||||
getTemplates(filter: Filter, callback?: PostmarkCallback<TemplatesResult>): undefined;
|
||||
|
||||
deleteTemplate(id: number): Promise<GenericResult>;
|
||||
deleteTemplate(id: number, callback?: PostmarkCallback<GenericResult>): undefined;
|
||||
|
||||
validateTemplate<T extends object>(templateObject: TemplateValidator<T>): Promise<TemplateValidationResult<T>>;
|
||||
validateTemplate<T extends object>(templateObject: TemplateValidator<T>, callback?: PostmarkCallback<TemplateValidationResult<T>>): undefined;
|
||||
}
|
||||
|
||||
interface CreateSignature extends UpdateSignature {
|
||||
FromEmail: string;
|
||||
}
|
||||
|
||||
interface CreateServer {
|
||||
Name: string;
|
||||
Color?: string;
|
||||
RawEmailEnabled?: boolean;
|
||||
SmtpApiActivated?: boolean;
|
||||
DeliveryHookUrl?: string;
|
||||
InboundHookUrl?: string;
|
||||
BounceHookUrl?: string;
|
||||
IncludeBounceContentInHook?: boolean;
|
||||
OpenHookUrl?: string;
|
||||
PostFirstOpenOnly?: boolean;
|
||||
TrackOpens?: boolean;
|
||||
TrackLinks?: string;
|
||||
InboundDomain?: string;
|
||||
InboundSpamThreshold?: number;
|
||||
}
|
||||
|
||||
interface CreateDomain {
|
||||
Name: string;
|
||||
ReturnPathDomain?: string;
|
||||
}
|
||||
|
||||
class AdminClient {
|
||||
constructor(apiKey: string, options: Partial<Options>);
|
||||
listSenderSignatures(query: Filter): Promise<SenderSignaturesResults>;
|
||||
listSenderSignatures(query: Filter, callback?: PostmarkCallback<SenderSignaturesResults>): undefined;
|
||||
|
||||
createSenderSignature(options: CreateSignature): Promise<SenderSignature>;
|
||||
createSenderSignature(options: CreateSignature, callback?: PostmarkCallback<SenderSignature>): undefined;
|
||||
|
||||
editSenderSignature(id: number, options: UpdateSignature): Promise<SenderSignature>;
|
||||
editSenderSignature(id: number, options: UpdateSignature, callback?: PostmarkCallback<SenderSignature>): undefined;
|
||||
|
||||
deleteSenderSignature(id: number): Promise<GenericResult>;
|
||||
deleteSenderSignature(id: number, callback?: PostmarkCallback<GenericResult>): undefined;
|
||||
|
||||
resendSenderSignatureConfirmation(id: number): Promise<GenericResult>;
|
||||
resendSenderSignatureConfirmation(id: number, callback?: PostmarkCallback<GenericResult>): undefined;
|
||||
|
||||
verifySenderSignatureSPF(id: number): Promise<SenderSignature>;
|
||||
verifySenderSignatureSPF(id: number, callback?: PostmarkCallback<SenderSignature>): undefined;
|
||||
|
||||
requestNewDKIMForSenderSignature(id: number): Promise<GenericResult>;
|
||||
requestNewDKIMForSenderSignature(id: number, callback?: PostmarkCallback<GenericResult>): undefined;
|
||||
|
||||
// servers
|
||||
getServer(id: number): Promise<Server>;
|
||||
getServer(id: number, callback?: PostmarkCallback<Server>): undefined;
|
||||
|
||||
createServer(options: CreateServer): Promise<Server>;
|
||||
createServer(options: CreateServer, callback?: PostmarkCallback<Server>): undefined;
|
||||
|
||||
editServer(id: number, options: Partial<CreateServer>): Promise<Server>;
|
||||
editServer(id: number, options: Partial<CreateServer>, callback?: PostmarkCallback<Server>): undefined;
|
||||
|
||||
deleteServer(id: number): Promise<GenericResult>;
|
||||
deleteServer(id: number, callback?: PostmarkCallback<GenericResult>): undefined;
|
||||
|
||||
listServers(query: ServerFilter): Promise<ServersResult>;
|
||||
listServers(query: ServerFilter, callback?: PostmarkCallback<ServersResult>): undefined;
|
||||
|
||||
// domains
|
||||
listDomains(query: Filter): Promise<DomainsResult>;
|
||||
listDomains(query: Filter, callback?: PostmarkCallback<DomainsResult>): undefined;
|
||||
|
||||
getDomain(id: number): Promise<Domain>;
|
||||
getDomain(id: number, callback?: PostmarkCallback<Domain>): undefined;
|
||||
|
||||
createDomain(options: CreateDomain): Promise<Domain>;
|
||||
createDomain(options: CreateDomain, callback?: PostmarkCallback<Domain>): undefined;
|
||||
|
||||
editDomain(id: number, options: Partial<CreateDomain>): Promise<Domain>;
|
||||
editDomain(id: number, options: Partial<CreateDomain>, callback?: PostmarkCallback<Domain>): undefined;
|
||||
|
||||
deleteDomain(id: number): Promise<GenericResult>;
|
||||
deleteDomain(id: number, callback?: PostmarkCallback<GenericResult>): undefined;
|
||||
|
||||
verifyDomainSPF(id: number): Promise<SenderSignature>;
|
||||
verifyDomainSPF(id: number, callback?: PostmarkCallback<SenderSignature>): undefined;
|
||||
|
||||
rotateDKIMForDomain(id: number): Promise<RotateDKIMResult>;
|
||||
rotateDKIMForDomain(id: number, callback?: PostmarkCallback<RotateDKIMResult>): undefined;
|
||||
}
|
||||
|
||||
interface ClientClass {
|
||||
new(serverKey: string, options: Partial<Options>): Client;
|
||||
}
|
||||
|
||||
interface AdminClientClass {
|
||||
new(apiKey: string, options: Partial<Options>): AdminClient;
|
||||
}
|
||||
|
||||
interface Postmark {
|
||||
(apiKey: string, options: Partial<Options>): Client;
|
||||
defaults: Options;
|
||||
Client: ClientClass;
|
||||
AdminClient: AdminClientClass;
|
||||
}
|
||||
|
||||
// server
|
||||
interface Server extends Sender {
|
||||
ID: number;
|
||||
ApiTokens: string[];
|
||||
ServerLink: string;
|
||||
Name: string;
|
||||
}
|
||||
|
||||
interface SendStatus {
|
||||
To: string;
|
||||
SubmittedAt: string;
|
||||
MessageID: string;
|
||||
ErrorCode: number;
|
||||
Message: string;
|
||||
}
|
||||
|
||||
// validation
|
||||
interface ValidationError {
|
||||
Message: string;
|
||||
Line: number;
|
||||
CharacterPosition: number;
|
||||
}
|
||||
|
||||
interface ValidationSet {
|
||||
ContentIsValid: boolean;
|
||||
ValidationErrors: ValidationError[];
|
||||
RenderedContent: string;
|
||||
}
|
||||
|
||||
interface TemplateValidator<T extends object> {
|
||||
Subject: string;
|
||||
HtmlBody: string;
|
||||
TextBody: string;
|
||||
TestRenderModel?: T;
|
||||
InlineCssForHtmlTestRender?: boolean;
|
||||
}
|
||||
|
||||
// templates
|
||||
interface TemplateBase {
|
||||
Name: string;
|
||||
TemplateId: number;
|
||||
Active: boolean;
|
||||
}
|
||||
|
||||
interface Template extends TemplateBase {
|
||||
Subject: string;
|
||||
HtmlBody: string;
|
||||
TextBody: string;
|
||||
AssociatedServerId: number;
|
||||
}
|
||||
|
||||
// filters
|
||||
interface BaseFilter extends Filter {
|
||||
tag?: string;
|
||||
todate?: string;
|
||||
fromdate?: string;
|
||||
}
|
||||
interface BounceFilter extends BaseFilter {
|
||||
type?: string;
|
||||
inactive?: boolean;
|
||||
emailFilter?: string;
|
||||
messageID?: string;
|
||||
}
|
||||
|
||||
interface OutboundMessageFilter extends BaseFilter {
|
||||
recipient?: string;
|
||||
fromemail?: string;
|
||||
status?: string;
|
||||
}
|
||||
|
||||
interface InboundMessageFilter extends OutboundMessageFilter {
|
||||
mailboxhash?: string;
|
||||
subject?: string;
|
||||
}
|
||||
|
||||
interface OpenMessageFilter extends BaseFilter {
|
||||
client_name?: string;
|
||||
client_company?: string;
|
||||
client_family?: string;
|
||||
os_name?: string;
|
||||
os_family?: string;
|
||||
os_company?: string;
|
||||
platform?: string;
|
||||
region?: string;
|
||||
city?: string;
|
||||
}
|
||||
|
||||
interface ServerFilter extends Filter {
|
||||
name?: string;
|
||||
}
|
||||
|
||||
// bounces
|
||||
interface Bounce {
|
||||
ID: number;
|
||||
Type: string;
|
||||
TypeCode: number;
|
||||
Name: string;
|
||||
Tag: string;
|
||||
MessageID: string;
|
||||
ServerID: number;
|
||||
Description: string;
|
||||
Details: string;
|
||||
Email: string;
|
||||
From: string;
|
||||
Subject: string;
|
||||
BouncedAt: string;
|
||||
DumpAvailable: boolean;
|
||||
Inactive: boolean;
|
||||
CanActivate: boolean;
|
||||
Content: string;
|
||||
}
|
||||
|
||||
interface BounceDump {
|
||||
Body: string;
|
||||
}
|
||||
|
||||
// tracking info
|
||||
interface VendorTrackingInfo {
|
||||
Name: string;
|
||||
Company: string;
|
||||
Family: string;
|
||||
}
|
||||
|
||||
interface GeoTrackingInfo {
|
||||
CountryISOCode: string;
|
||||
Country: string;
|
||||
RegionISOCode: string;
|
||||
Region: string;
|
||||
City: string;
|
||||
Zip: string;
|
||||
Coords: string;
|
||||
IP: string;
|
||||
}
|
||||
|
||||
interface BounceStats {
|
||||
Name: string;
|
||||
Count: number;
|
||||
Type: string | undefined;
|
||||
}
|
||||
|
||||
interface DeliveryStats {
|
||||
InactiveMails: number;
|
||||
Bounces: BounceStats[];
|
||||
}
|
||||
|
||||
interface MessageOpens {
|
||||
FirstOpen: boolean;
|
||||
Client: VendorTrackingInfo;
|
||||
OS: VendorTrackingInfo;
|
||||
Platform: string;
|
||||
UserAgent: string;
|
||||
ReadSeconds: number;
|
||||
Geo: GeoTrackingInfo;
|
||||
MessageID: string;
|
||||
ReceivedAt: string;
|
||||
Tag: string;
|
||||
Recipient: string;
|
||||
}
|
||||
|
||||
interface ExpandedEmail {
|
||||
Email: string;
|
||||
Name: string;
|
||||
}
|
||||
|
||||
// message events
|
||||
interface MessageEvents {
|
||||
Recipient: string;
|
||||
Type: string;
|
||||
ReceivedAt: string;
|
||||
Details: MessageEventDetails;
|
||||
}
|
||||
|
||||
interface MessageEventDetails {
|
||||
Summary?: string;
|
||||
BounceID?: string;
|
||||
Link?: string;
|
||||
ClickLocation?: string;
|
||||
DeliveryMessage?: string;
|
||||
DestinationServer?: string;
|
||||
DestinationIP?: string;
|
||||
}
|
||||
|
||||
// messages
|
||||
interface MessageBase {
|
||||
Tag: string;
|
||||
MessageID: string;
|
||||
From: string;
|
||||
Cc: string;
|
||||
Subject: string;
|
||||
Status: string;
|
||||
Attachments: PostmarkAttachment[];
|
||||
}
|
||||
|
||||
interface OutboundMessageBase extends MessageBase {
|
||||
To: ExpandedEmail[];
|
||||
Recipients: string[];
|
||||
ReceivedAt: string;
|
||||
TrackOpens: boolean;
|
||||
TrackLinks: string;
|
||||
}
|
||||
|
||||
interface OutboundMessage extends OutboundMessageBase {
|
||||
TextBody: string;
|
||||
HtmlBody: string;
|
||||
Body: string;
|
||||
MessageEvents: MessageEvents[];
|
||||
}
|
||||
|
||||
interface InboundMessageBase extends MessageBase {
|
||||
FromName: string;
|
||||
FromFull: ExpandedEmail;
|
||||
To: string;
|
||||
ToFull: ExpandedEmail[];
|
||||
CcFull: ExpandedEmail[];
|
||||
ReplyTo: string;
|
||||
OriginalRecipient: string;
|
||||
Date: string;
|
||||
MailboxHash: string;
|
||||
}
|
||||
|
||||
interface InboundMessage extends InboundMessageBase {
|
||||
TextBody: string;
|
||||
HtmlBody: string;
|
||||
Headers: PostmarkMessageHeader[];
|
||||
BlockedReason?: string;
|
||||
MessageEvents: MessageEvents[];
|
||||
}
|
||||
|
||||
// Results
|
||||
interface GenericResult {
|
||||
Message: string;
|
||||
ErrorCode?: number;
|
||||
}
|
||||
|
||||
interface PaginatedResult {
|
||||
TotalCount: number;
|
||||
}
|
||||
|
||||
interface ActivatedBounceResult extends GenericResult {
|
||||
Bounce: Bounce;
|
||||
}
|
||||
|
||||
interface BouncesResult extends PaginatedResult {
|
||||
Bounces: Bounce[];
|
||||
}
|
||||
|
||||
interface TemplatesResult extends PaginatedResult {
|
||||
Templates: TemplateBase[];
|
||||
}
|
||||
|
||||
interface MessageOpensResult extends PaginatedResult {
|
||||
Opens: MessageOpens[];
|
||||
}
|
||||
|
||||
interface OutboundMessagesResult extends PaginatedResult {
|
||||
Messages: OutboundMessageBase[];
|
||||
}
|
||||
|
||||
interface InboundMessagesResult extends PaginatedResult {
|
||||
InboundMessages: InboundMessageBase[];
|
||||
}
|
||||
|
||||
interface TemplateValidationResult<T extends object = any> {
|
||||
AllContentIsValid: boolean;
|
||||
HtmlBody: ValidationSet;
|
||||
TextBody: ValidationSet;
|
||||
Subject: ValidationSet;
|
||||
SuggestedTemplateModel: T;
|
||||
}
|
||||
|
||||
interface SenderSignaturesResults extends PaginatedResult {
|
||||
SenderSignatures: SenderSignatureBase[];
|
||||
}
|
||||
|
||||
interface ServersResult extends PaginatedResult {
|
||||
Servers: Server[];
|
||||
}
|
||||
|
||||
interface DomainsResult extends PaginatedResult {
|
||||
Domains: DomainBase[];
|
||||
}
|
||||
|
||||
// sender signature
|
||||
interface SenderSignatureBase {
|
||||
Domain: string;
|
||||
EmailAddress: string;
|
||||
Name: string;
|
||||
ReplyToEmailAddress: string;
|
||||
Confirmed: boolean;
|
||||
ID: number;
|
||||
}
|
||||
|
||||
interface SPFRecord {
|
||||
SPFHost: string;
|
||||
SPFTextValue: string;
|
||||
SPFVerified: boolean;
|
||||
}
|
||||
|
||||
interface DKIMKey {
|
||||
WeakDKIM: boolean;
|
||||
DKIMHost: string;
|
||||
DKIMVerified: boolean;
|
||||
DKIMTextValue: string;
|
||||
DKIMPendingHost: string;
|
||||
DKIMPendingTextValue: string;
|
||||
DKIMRevokedHost: string;
|
||||
DKIMRevokedTextValue: string;
|
||||
SafeToRemoveRevokedKeyFromDNS: boolean;
|
||||
DKIMUpdateStatus: string;
|
||||
}
|
||||
|
||||
interface VerificationDetails extends SPFRecord, DKIMKey {
|
||||
ReturnPathDomain: string;
|
||||
ReturnPathDomainCNAMEValue: string;
|
||||
}
|
||||
|
||||
interface SenderSignature extends SenderSignatureBase, VerificationDetails {
|
||||
ReturnPathDomainVerified: boolean;
|
||||
}
|
||||
|
||||
interface UpdateSignature {
|
||||
Name: string;
|
||||
ReplyToEmail?: string;
|
||||
ReturnPathDomain?: string;
|
||||
}
|
||||
|
||||
// domain
|
||||
interface DomainBase {
|
||||
ID: number;
|
||||
Name: string;
|
||||
SPFVerified: boolean;
|
||||
DKIMVerified: boolean;
|
||||
WeakDKIM: boolean;
|
||||
ReturnPathDomainVerified: boolean;
|
||||
}
|
||||
|
||||
interface Domain extends DomainBase, VerificationDetails {
|
||||
}
|
||||
|
||||
interface RotateDKIMResult extends DKIMKey {
|
||||
Name: string;
|
||||
ID: string;
|
||||
}
|
||||
|
||||
// outbound overview
|
||||
interface OutboundOverview {
|
||||
Sent: number;
|
||||
Bounced: number;
|
||||
SMTPApiErrors: number;
|
||||
BounceRate: number;
|
||||
SpamComplaints: number;
|
||||
SpamComplaintsRate: number;
|
||||
Opens: number;
|
||||
UniqueOpens: number;
|
||||
Tracked: number;
|
||||
WithLinkTracking: number;
|
||||
WithOpenTracking: number;
|
||||
TotalTrackedLinksSent: number;
|
||||
UniqueLinksClicked: number;
|
||||
TotalClicks: number;
|
||||
WithClientRecorded: number;
|
||||
WithPlatformRecorded: number;
|
||||
WithReadTimeRecorded: number;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ const templateValidator = {
|
||||
TextBody: '123535',
|
||||
};
|
||||
|
||||
declare function callback(err: any, data: any): void;
|
||||
declare function callback(err: any, data: any): undefined;
|
||||
|
||||
const client = new postmark.Client('124345', options);
|
||||
const adminClient = new postmark.AdminClient('1123235', options);
|
||||
@@ -40,16 +40,40 @@ client.retryInboundHookForMessage(1, callback);
|
||||
client.getOuboundOverview(filter, callback);
|
||||
client.validateTemplate(templateValidator, callback);
|
||||
|
||||
client.send(message).then(() => { });
|
||||
client.sendEmailWithTemplate(templateMessage).then(() => { });
|
||||
client.batch([message, message]).then(() => { });
|
||||
client.sendEmail(message).then(() => { });
|
||||
client.sendEmailBatch([message, message]).then(() => { });
|
||||
client.getDeliveryStatistics().then(() => { });
|
||||
client.getBounces(filter).then(() => { });
|
||||
client.getBounce(1).then(() => { });
|
||||
client.getBounceDump(1).then(() => { });
|
||||
client.activateBounce(1).then(() => { });
|
||||
client.getBounceTags().then(() => { });
|
||||
client.getServer().then(() => { });
|
||||
client.editServer(editSender).then(() => { });
|
||||
client.getOutboundMessages(filter).then(() => { });
|
||||
client.getOutboundMessageDetails(1).then(() => { });
|
||||
client.getMessageOpens(filter).then(() => { });
|
||||
client.getMessageOpensForSingleMessage(1, filter).then(() => { });
|
||||
client.getInboundMessages(filter).then(() => { });
|
||||
client.getInboundMessageDetails(1).then(() => { });
|
||||
client.bypassBlockedInboundMessage(1).then(() => { });
|
||||
client.retryInboundHookForMessage(1).then(() => { });
|
||||
client.getOuboundOverview(filter).then(() => { });
|
||||
client.validateTemplate(templateValidator).then(() => { });
|
||||
|
||||
adminClient.listSenderSignatures(filter, callback);
|
||||
adminClient.createSenderSignature({FromEmail: '', Name: ''}, callback);
|
||||
adminClient.editSenderSignature(0, {ReplyToEmail: '123'}, callback);
|
||||
adminClient.editSenderSignature(0, {Name: '123'}, callback);
|
||||
adminClient.deleteSenderSignature(0, callback);
|
||||
adminClient.resendSenderSignatureConfirmation(0, callback);
|
||||
adminClient.verifySenderSignatureSPF(0, callback);
|
||||
adminClient.requestNewDKIMForSenderSignature(0, callback);
|
||||
adminClient.getServer(0, callback);
|
||||
adminClient.createServer({Name: '123'}, callback);
|
||||
adminClient.editServer(0, {Color: 'black'}, callback);
|
||||
adminClient.editServer(0, {Name: 'black'}, callback);
|
||||
adminClient.deleteServer(0, callback);
|
||||
adminClient.listServers(filter, callback);
|
||||
adminClient.listDomains(filter, callback);
|
||||
@@ -59,3 +83,23 @@ adminClient.editDomain(0, {ReturnPathDomain: '/'}, callback);
|
||||
adminClient.deleteDomain(0, callback);
|
||||
adminClient.verifyDomainSPF(0, callback);
|
||||
adminClient.rotateDKIMForDomain(0, callback);
|
||||
|
||||
adminClient.listSenderSignatures(filter).then(() => { });
|
||||
adminClient.createSenderSignature({ FromEmail: '', Name: '' }).then(() => { });
|
||||
adminClient.editSenderSignature(0, { Name: 'somename', ReplyToEmail: '123' }).then(() => { });
|
||||
adminClient.deleteSenderSignature(0).then(() => { });
|
||||
adminClient.resendSenderSignatureConfirmation(0).then(() => { });
|
||||
adminClient.verifySenderSignatureSPF(0).then(() => { });
|
||||
adminClient.requestNewDKIMForSenderSignature(0).then(() => { });
|
||||
adminClient.getServer(0).then(() => { });
|
||||
adminClient.createServer({ Name: '123' }).then(() => { });
|
||||
adminClient.editServer(0, { Name: 'black' }).then(() => { });
|
||||
adminClient.deleteServer(0).then(() => { });
|
||||
adminClient.listServers(filter).then(() => { });
|
||||
adminClient.listDomains(filter).then(() => { });
|
||||
adminClient.getDomain(0).then(() => { });
|
||||
adminClient.createDomain({ Name: '1234' }).then(() => { });
|
||||
adminClient.editDomain(0, { ReturnPathDomain: '/' }).then(() => { });
|
||||
adminClient.deleteDomain(0).then(() => { });
|
||||
adminClient.verifyDomainSPF(0).then(() => { });
|
||||
adminClient.rotateDKIMForDomain(0).then(() => { });
|
||||
|
||||
Vendored
+83
-64
@@ -169,62 +169,7 @@ export interface AreaPathProps extends AreaBaseProps {
|
||||
|
||||
export class AreaPath extends React.Component<AreaPathProps> { }
|
||||
|
||||
export interface AreaTextProps extends AreaBaseProps {
|
||||
style?: {
|
||||
/**
|
||||
* The background color, specified as a CSS color string.
|
||||
*/
|
||||
backgroundColor?: string;
|
||||
/**
|
||||
* The text color, specified as a CSS color string.
|
||||
*/
|
||||
color?: string;
|
||||
/**
|
||||
* The font family (only if available on the system).
|
||||
*/
|
||||
fontFamily?: string;
|
||||
/**
|
||||
* The font size (in pt).
|
||||
*/
|
||||
fontSize?: number;
|
||||
/**
|
||||
* Whether an italic font should be used.
|
||||
*/
|
||||
fontStyle?: 'normal' | 'oblique' | 'italic';
|
||||
/**
|
||||
* Whether a bold font should be used (and the amount).
|
||||
*/
|
||||
fontWeight?: 'minimum' | 'thin' | 'ultraLight' | 'light' | 'book' | 'normal' | 'medium' | 'semiBold' | 'bold' | 'ultraBold' | 'heavy' | 'ultraHeavy' | 'maximum' | number;
|
||||
/**
|
||||
* Wheter the text should be aligned to the left, center or right.
|
||||
*
|
||||
* **Works only on a top level text component, not it's children!**
|
||||
*/
|
||||
textAlign?: 'left' | 'center' | 'right';
|
||||
/**
|
||||
* How wide or narrow the characters should be.
|
||||
*/
|
||||
textStretch?: 'ultraCondensed' | 'extraCondensed' | 'condensed' | 'semiCondensed' | 'normal' | 'semiExpanded' | 'expanded' | 'extraExpanded' | 'ultraExpanded';
|
||||
/**
|
||||
* The text underline style.
|
||||
*/
|
||||
textUnderline?: 'none' | 'single' | 'double' | 'suggestion';
|
||||
/**
|
||||
* The text underline color.
|
||||
*
|
||||
* A color string | 'spelling' | 'grammar' | 'auxiliary'
|
||||
*/
|
||||
textUnderlineColor?: 'spelling' | 'grammar' | 'auxiliary' | string;
|
||||
};
|
||||
/**
|
||||
* The x coordinate of the text's top left corner. (Only in a top level text component.)
|
||||
*/
|
||||
x?: number | string;
|
||||
/**
|
||||
* The y coordinate of the text's top left corner. (Only in a top level text component.)
|
||||
*/
|
||||
y?: number | string;
|
||||
}
|
||||
export interface AreaTextProps extends StyledTextProps, AreaBaseProps { }
|
||||
|
||||
export class AreaText extends React.Component<AreaTextProps> { }
|
||||
|
||||
@@ -601,25 +546,33 @@ export interface PickerProps extends GridChildrenProps, Label, Stretchy {
|
||||
/**
|
||||
* When a *non-editable* Picker is changed. The current selection is passed as an argument.
|
||||
*/
|
||||
onSelect?: (selection: string) => void;
|
||||
onSelect?: (selection: number) => void;
|
||||
/**
|
||||
* What element is selected if the picker *is not* editable.
|
||||
*/
|
||||
selected?: boolean;
|
||||
selected?: number;
|
||||
/**
|
||||
* What text is selected/typed if the picker *is* editable.
|
||||
*/
|
||||
text?: boolean;
|
||||
text?: string;
|
||||
/**
|
||||
* Whether the Picker can be seen.
|
||||
*/
|
||||
visible?: boolean;
|
||||
}
|
||||
|
||||
export interface PickerItemProps {
|
||||
children: string;
|
||||
}
|
||||
|
||||
export class PickerItem extends React.Component<PickerItemProps> { }
|
||||
|
||||
/**
|
||||
* A drop down menu where the user can pick different values.
|
||||
*/
|
||||
export class Picker extends React.Component<PickerProps> { }
|
||||
export class Picker extends React.Component<PickerProps> {
|
||||
static Item: typeof PickerItem;
|
||||
}
|
||||
|
||||
export interface ProgressBarProps extends GridChildrenProps, Label, Stretchy {
|
||||
/**
|
||||
@@ -764,6 +717,65 @@ export interface Stretchy {
|
||||
stretchy?: boolean;
|
||||
}
|
||||
|
||||
export interface StyledTextProps {
|
||||
style?: {
|
||||
/**
|
||||
* The background color, specified as a CSS color string.
|
||||
*/
|
||||
backgroundColor?: string;
|
||||
/**
|
||||
* The text color, specified as a CSS color string.
|
||||
*/
|
||||
color?: string;
|
||||
/**
|
||||
* The font family (only if available on the system).
|
||||
*/
|
||||
fontFamily?: string;
|
||||
/**
|
||||
* The font size (in pt).
|
||||
*/
|
||||
fontSize?: number;
|
||||
/**
|
||||
* Whether an italic font should be used.
|
||||
*/
|
||||
fontStyle?: 'normal' | 'oblique' | 'italic';
|
||||
/**
|
||||
* Whether a bold font should be used (and the amount).
|
||||
*/
|
||||
fontWeight?: 'minimum' | 'thin' | 'ultraLight' | 'light' | 'book' | 'normal' | 'medium' | 'semiBold' | 'bold' | 'ultraBold' | 'heavy' | 'ultraHeavy' | 'maximum' | number;
|
||||
/**
|
||||
* Wheter the text should be aligned to the left, center or right.
|
||||
*
|
||||
* **Works only on a top level text component, not it's children!**
|
||||
*/
|
||||
textAlign?: 'left' | 'center' | 'right';
|
||||
/**
|
||||
* How wide or narrow the characters should be.
|
||||
*/
|
||||
textStretch?: 'ultraCondensed' | 'extraCondensed' | 'condensed' | 'semiCondensed' | 'normal' | 'semiExpanded' | 'expanded' | 'extraExpanded' | 'ultraExpanded';
|
||||
/**
|
||||
* The text underline style.
|
||||
*/
|
||||
textUnderline?: 'none' | 'single' | 'double' | 'suggestion';
|
||||
/**
|
||||
* The text underline color.
|
||||
*
|
||||
* A color string | 'spelling' | 'grammar' | 'auxiliary'
|
||||
*/
|
||||
textUnderlineColor?: 'spelling' | 'grammar' | 'auxiliary' | string;
|
||||
};
|
||||
/**
|
||||
* The x coordinate of the text's top left corner. (Only in a top level text component.)
|
||||
*/
|
||||
x?: number | string;
|
||||
/**
|
||||
* The y coordinate of the text's top left corner. (Only in a top level text component.)
|
||||
*/
|
||||
y?: number | string;
|
||||
}
|
||||
|
||||
export class StyledText extends React.Component<StyledTextProps> { }
|
||||
|
||||
export interface TabProps extends GridChildrenProps {
|
||||
/**
|
||||
* Whether the Tab is enabled.
|
||||
@@ -896,17 +908,16 @@ export class Window extends React.Component<WindowProps> { }
|
||||
export function render(element: JSX.Element): void;
|
||||
|
||||
/**
|
||||
* A method to display an alert, or a dialog to save or open a file.
|
||||
* A method to display an alert.
|
||||
* @param type What type the dialog is. The current types are:
|
||||
* - Message - a simple message
|
||||
* - Error - an error message
|
||||
* - Open - open a file
|
||||
* - Save - save a file
|
||||
* @param options Options for the title and description if it is a Message or Error.
|
||||
* Required one of title and description (if it is Message or Error)
|
||||
* @param options Options for the title and descript.
|
||||
*/
|
||||
export function Dialog(
|
||||
type: 'Message' | 'Error' | 'Open' | 'Save',
|
||||
type: 'Message' | 'Error',
|
||||
options?: {
|
||||
title: string,
|
||||
description?: string
|
||||
@@ -915,3 +926,11 @@ export function Dialog(
|
||||
description: string
|
||||
}
|
||||
): void;
|
||||
|
||||
/**
|
||||
* A dialog to save or open a file. Returns chosen file path.
|
||||
* @param type What type the dialog is. The current types are:
|
||||
* - Open - open a file
|
||||
* - Save - save a file
|
||||
*/
|
||||
export function Dialog(type: 'Open' | 'Save'): string;
|
||||
|
||||
Vendored
+3
-1
@@ -1,14 +1,16 @@
|
||||
// Type definitions for query-string 5.1
|
||||
// Type definitions for query-string 6.1
|
||||
// Project: https://github.com/sindresorhus/query-string
|
||||
// Definitions by: Sam Verschueren <https://github.com/SamVerschueren>
|
||||
// Tanguy Krotoff <https://github.com/tkrotoff>
|
||||
// HuHuanming <https://github.com/huhuanming>
|
||||
// Madara Uchiha <https://github.com/MadaraUchiha>
|
||||
// Josh Holmer <https://github.com/shssoichiro>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
export interface ParseOptions {
|
||||
arrayFormat?: 'bracket' | 'index' | 'none';
|
||||
decode?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -24,6 +24,7 @@ import * as queryString from 'query-string';
|
||||
let fooBar: { foo: 'bar' };
|
||||
fooBar = queryString.parse('?foo=bar');
|
||||
fooBar = queryString.parse('#foo=bar');
|
||||
fooBar = queryString.parse('?foo=bar%20baz', { decode: true });
|
||||
|
||||
let fooBarBaz: { foo: ['bar', 'baz'] };
|
||||
fooBarBaz = queryString.parse('&foo=bar&foo=baz');
|
||||
|
||||
Vendored
+1
@@ -12,6 +12,7 @@
|
||||
// Karol Janyst <https://github.com/LKay>
|
||||
// Aaron Beall <https://github.com/aaronbeall>
|
||||
// Johann Rakotoharisoa <https://github.com/jrakotoharisoa>
|
||||
// Andrew Makarov <https://github.com/r3nya>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.6
|
||||
|
||||
|
||||
+3
-2
@@ -1,11 +1,12 @@
|
||||
import * as React from 'react';
|
||||
import { Button } from 'react-bootstrap';
|
||||
|
||||
declare namespace ToggleButton {
|
||||
export interface ToggleButtonProps extends React.HTMLProps<ToggleButton> {
|
||||
checked?: boolean;
|
||||
name?: string;
|
||||
value: number|string;
|
||||
value: number | string;
|
||||
}
|
||||
}
|
||||
declare class ToggleButton extends React.Component<ToggleButton.ToggleButtonProps> { }
|
||||
declare class ToggleButton extends React.Component<ToggleButton.ToggleButtonProps & Button.ButtonProps> { }
|
||||
export = ToggleButton;
|
||||
|
||||
+2
-1
@@ -1,4 +1,5 @@
|
||||
import * as React from 'react';
|
||||
import { ButtonGroup } from 'react-bootstrap';
|
||||
import { Omit } from "../index";
|
||||
|
||||
declare namespace ToggleButtonGroup {
|
||||
@@ -34,5 +35,5 @@ declare namespace ToggleButtonGroup {
|
||||
& Omit<React.HTMLProps<ToggleButtonGroup>, "defaultValue" | "type" | "value" | "onChange">;
|
||||
|
||||
}
|
||||
declare class ToggleButtonGroup extends React.Component<ToggleButtonGroup.ToggleButtonGroupProps> { }
|
||||
declare class ToggleButtonGroup extends React.Component<ToggleButtonGroup.ToggleButtonGroupProps & ButtonGroup.ButtonGroupProps> { }
|
||||
export = ToggleButtonGroup;
|
||||
|
||||
@@ -209,8 +209,8 @@ export class ReactBootstrapIndividualComponentsTest extends React.Component {
|
||||
<Table />
|
||||
<Tabs />
|
||||
<Thumbnail />
|
||||
<ToggleButton value="foo" />
|
||||
<ToggleButtonGroup type="checkbox" />
|
||||
<ToggleButton value="foo" bsSize="small" />
|
||||
<ToggleButtonGroup type="checkbox" bsSize="small" />
|
||||
<ToggleButtonGroup type="radio" name="foo" />
|
||||
<Tooltip />
|
||||
<Well />
|
||||
|
||||
@@ -1,18 +1,56 @@
|
||||
import * as React from 'react';
|
||||
import { Component, CSSProperties } from 'react';
|
||||
import {
|
||||
Button, ButtonToolbar, Modal, Well, ButtonGroup,
|
||||
DropdownButton, MenuItem, Panel, PanelGroup, ListGroup,
|
||||
ListGroupItem, Accordion, Tooltip,
|
||||
OverlayTrigger, Popover, ProgressBar,
|
||||
Nav, NavItem, Navbar, NavDropdown,
|
||||
Tabs, Tab, Pager, PageItem,
|
||||
Pagination, Alert, Carousel, SafeAnchor,
|
||||
Grid, Row, Col, Thumbnail, Image, ResponsiveEmbed,
|
||||
Label, Badge, Jumbotron, PageHeader,
|
||||
Glyphicon, Table, Form, FormGroup,
|
||||
ControlLabel, FormControl, HelpBlock,
|
||||
Radio, Checkbox, Media, InputGroup, ToggleButtonGroup,
|
||||
Button,
|
||||
ButtonToolbar,
|
||||
Modal,
|
||||
Well,
|
||||
ButtonGroup,
|
||||
DropdownButton,
|
||||
MenuItem,
|
||||
Panel,
|
||||
PanelGroup,
|
||||
ListGroup,
|
||||
ListGroupItem,
|
||||
Accordion,
|
||||
Tooltip,
|
||||
OverlayTrigger,
|
||||
Popover,
|
||||
ProgressBar,
|
||||
Nav,
|
||||
NavItem,
|
||||
Navbar,
|
||||
NavDropdown,
|
||||
Tabs,
|
||||
Tab,
|
||||
Pager,
|
||||
PageItem,
|
||||
Pagination,
|
||||
Alert,
|
||||
Carousel,
|
||||
SafeAnchor,
|
||||
Grid,
|
||||
Row,
|
||||
Col,
|
||||
Thumbnail,
|
||||
Image,
|
||||
ResponsiveEmbed,
|
||||
Label,
|
||||
Badge,
|
||||
Jumbotron,
|
||||
PageHeader,
|
||||
Glyphicon,
|
||||
Table,
|
||||
Form,
|
||||
FormGroup,
|
||||
ControlLabel,
|
||||
FormControl,
|
||||
HelpBlock,
|
||||
Radio,
|
||||
Checkbox,
|
||||
Media,
|
||||
InputGroup,
|
||||
ToggleButtonGroup,
|
||||
ToggleButton
|
||||
} from 'react-bootstrap';
|
||||
|
||||
@@ -1418,20 +1456,47 @@ export class ReactBootstrapTest extends Component {
|
||||
|
||||
<div>
|
||||
<ButtonToolbar>
|
||||
<ToggleButtonGroup type="checkbox" defaultValue={[1, 3]}>
|
||||
<ToggleButton value={1}>Checkbox 1 (pre-checked)</ToggleButton>
|
||||
<ToggleButton value={2}>Checkbox 2</ToggleButton>
|
||||
<ToggleButton value={3}>Checkbox 3 (pre-checked)</ToggleButton>
|
||||
<ToggleButtonGroup
|
||||
type="checkbox"
|
||||
defaultValue={[1, 3]}
|
||||
bsSize="small"
|
||||
>
|
||||
<ToggleButton value={1} bsSize="small" active>
|
||||
Checkbox 1 (pre-checked)
|
||||
</ToggleButton>
|
||||
<ToggleButton value={2}>
|
||||
Checkbox 2
|
||||
</ToggleButton>
|
||||
<ToggleButton value={3}>
|
||||
Checkbox 3 (pre-checked)
|
||||
</ToggleButton>
|
||||
</ToggleButtonGroup>
|
||||
</ButtonToolbar>
|
||||
|
||||
<ButtonToolbar>
|
||||
<ToggleButtonGroup type="radio" name="options" defaultValue={1}>
|
||||
<ToggleButton value={1}>
|
||||
<ToggleButtonGroup
|
||||
type="radio"
|
||||
name="options"
|
||||
defaultValue={1}
|
||||
>
|
||||
<ToggleButton
|
||||
value={1}
|
||||
bsSize="large"
|
||||
>
|
||||
Radio 1 (pre-checked)
|
||||
</ToggleButton>
|
||||
<ToggleButton value={2}>Radio 2</ToggleButton>
|
||||
<ToggleButton value={3}>Radio 3</ToggleButton>
|
||||
<ToggleButton
|
||||
value={2}
|
||||
bsSize="small"
|
||||
>
|
||||
Radio 2
|
||||
</ToggleButton>
|
||||
<ToggleButton
|
||||
value={3}
|
||||
bsSize="xsmall"
|
||||
>
|
||||
Radio 3
|
||||
</ToggleButton>
|
||||
</ToggleButtonGroup>
|
||||
</ButtonToolbar>
|
||||
</div>
|
||||
|
||||
Vendored
+48
-15
@@ -1088,10 +1088,11 @@ export interface TextInputFocusEventData {
|
||||
eventCount: number;
|
||||
}
|
||||
|
||||
export interface TextInputScrollEvent {
|
||||
nativeEvent: {
|
||||
contentOffset: { x: number; y: number; }
|
||||
}
|
||||
/**
|
||||
* @see TextInputProps.onScroll
|
||||
*/
|
||||
export interface TextInputScrollEventData {
|
||||
contentOffset: { x: number; y: number; }
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1232,7 +1233,7 @@ export interface TextInputProps
|
||||
*
|
||||
* May also contain other properties from ScrollEvent but on Android contentSize is not provided for performance reasons.
|
||||
*/
|
||||
onScroll?: (event: TextInputScrollEvent) => void;
|
||||
onScroll?: (e: NativeSyntheticEvent<TextInputScrollEventData>) => void;
|
||||
|
||||
/**
|
||||
* The string that will be rendered before text input has been entered
|
||||
@@ -1332,7 +1333,10 @@ interface TextInputState {
|
||||
declare class TextInputComponent extends React.Component<TextInputProps> {}
|
||||
declare const TextInputBase: Constructor<NativeMethodsMixin> & Constructor<TimerMixin> & typeof TextInputComponent;
|
||||
export class TextInput extends TextInputBase {
|
||||
State: TextInputState;
|
||||
/**
|
||||
* Access the current focus state.
|
||||
*/
|
||||
static State: TextInputState;
|
||||
|
||||
/**
|
||||
* Returns if the input is currently focused.
|
||||
@@ -3412,9 +3416,26 @@ interface ImagePropsAndroid {
|
||||
fadeDuration?: number;
|
||||
}
|
||||
|
||||
// See https://facebook.github.io/react-native/docs/image.html#source
|
||||
/**
|
||||
* @see https://facebook.github.io/react-native/docs/image.html#source
|
||||
*/
|
||||
export type ImageSourcePropType = ImageURISource | ImageURISource[] | ImageRequireSource;
|
||||
|
||||
/**
|
||||
* @see ImagePropsBase.onLoad
|
||||
*/
|
||||
interface ImageLoadEventDataAndroid {
|
||||
uri?: string;
|
||||
}
|
||||
|
||||
interface ImageLoadEventData extends ImageLoadEventDataAndroid {
|
||||
source: {
|
||||
height: number;
|
||||
width: number;
|
||||
url: string;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see https://facebook.github.io/react-native/docs/image.html
|
||||
*/
|
||||
@@ -3435,8 +3456,9 @@ export interface ImagePropsBase extends ImagePropsIOS, ImagePropsAndroid, Access
|
||||
|
||||
/**
|
||||
* Invoked when load completes successfully
|
||||
* { source: { url, height, width } }.
|
||||
*/
|
||||
onLoad?: () => void;
|
||||
onLoad?: (event: NativeSyntheticEvent<ImageLoadEventData>) => void;
|
||||
|
||||
/**
|
||||
* Invoked when load either succeeds or fails
|
||||
@@ -3887,6 +3909,13 @@ export interface SectionListProps<ItemT> extends ScrollViewProps {
|
||||
*/
|
||||
initialNumToRender?: number;
|
||||
|
||||
/**
|
||||
* Used to extract a unique key for a given item at the specified index. Key is used for caching
|
||||
* and as the react key to track item re-ordering. The default extractor checks `item.key`, then
|
||||
* falls back to using the index, like React does.
|
||||
*/
|
||||
keyExtractor?: (item: ItemT, index: number) => string;
|
||||
|
||||
/**
|
||||
* Called once when the scroll position gets within onEndReachedThreshold of the rendered content.
|
||||
*/
|
||||
@@ -3900,19 +3929,23 @@ export interface SectionListProps<ItemT> extends ScrollViewProps {
|
||||
*/
|
||||
onEndReachedThreshold?: number | null;
|
||||
|
||||
/**
|
||||
* Used to extract a unique key for a given item at the specified index. Key is used for caching
|
||||
* and as the react key to track item re-ordering. The default extractor checks `item.key`, then
|
||||
* falls back to using the index, like React does.
|
||||
*/
|
||||
keyExtractor?: (item: ItemT, index: number) => string;
|
||||
|
||||
/**
|
||||
* If provided, a standard RefreshControl will be added for "Pull to Refresh" functionality.
|
||||
* Make sure to also set the refreshing prop correctly.
|
||||
*/
|
||||
onRefresh?: (() => void) | null;
|
||||
|
||||
/**
|
||||
* Used to handle failures when scrolling to an index that has not been measured yet.
|
||||
* Recommended action is to either compute your own offset and `scrollTo` it, or scroll as far
|
||||
* as possible and then try again after more items have been rendered.
|
||||
*/
|
||||
onScrollToIndexFailed?: (info: {
|
||||
index: number,
|
||||
highestMeasuredFrameIndex: number,
|
||||
averageItemLength: number
|
||||
}) => void;
|
||||
|
||||
/**
|
||||
* Set this true while waiting for new data from a refresh.
|
||||
*/
|
||||
|
||||
@@ -24,6 +24,7 @@ import {
|
||||
Dimensions,
|
||||
Image,
|
||||
ImageStyle,
|
||||
ImageLoadEventData,
|
||||
InteractionManager,
|
||||
ListView,
|
||||
ListViewDataSource,
|
||||
@@ -55,7 +56,7 @@ import {
|
||||
StatusBar,
|
||||
NativeSyntheticEvent,
|
||||
GestureResponderEvent,
|
||||
TextInputScrollEvent,
|
||||
TextInputScrollEventData
|
||||
} from "react-native";
|
||||
|
||||
declare module "react-native" {
|
||||
@@ -150,6 +151,25 @@ const viewProperty = StyleSheet.flatten(viewStyle).backgroundColor;
|
||||
const textProperty = StyleSheet.flatten(textStyle).fontSize;
|
||||
const imageProperty = StyleSheet.flatten(imageStyle).resizeMode;
|
||||
|
||||
const testNativeSyntheticEvent = <T extends {}>(e: NativeSyntheticEvent<T>): void => {
|
||||
e.isDefaultPrevented();
|
||||
e.preventDefault();
|
||||
e.isPropagationStopped();
|
||||
e.stopPropagation();
|
||||
e.persist();
|
||||
e.cancelable;
|
||||
e.bubbles;
|
||||
e.currentTarget;
|
||||
e.defaultPrevented;
|
||||
e.eventPhase;
|
||||
e.isTrusted;
|
||||
e.nativeEvent;
|
||||
e.target;
|
||||
e.timeStamp;
|
||||
e.type;
|
||||
e.nativeEvent;
|
||||
}
|
||||
|
||||
class CustomView extends React.Component {
|
||||
render() {
|
||||
return <Text style={[StyleSheet.absoluteFill, { ...StyleSheet.absoluteFillObject }]}>Custom View</Text>;
|
||||
@@ -198,19 +218,14 @@ class Welcome extends React.Component {
|
||||
|
||||
export default Welcome;
|
||||
|
||||
// EventsTest
|
||||
export class EventsTest extends React.Component {
|
||||
onPressButton(e: GestureResponderEvent) {
|
||||
// TouchableNativeFeedbackTest
|
||||
export class TouchableNativeFeedbackTest extends React.Component {
|
||||
onPressButton = (e: GestureResponderEvent) => {
|
||||
e.persist();
|
||||
e.isPropagationStopped();
|
||||
e.isDefaultPrevented();
|
||||
}
|
||||
|
||||
onScroll(e: TextInputScrollEvent) {
|
||||
console.log(`x: ${ e.nativeEvent.contentOffset.x }`);
|
||||
console.log(`y: ${ e.nativeEvent.contentOffset.y }`);
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<TouchableNativeFeedback
|
||||
@@ -218,10 +233,6 @@ export class EventsTest extends React.Component {
|
||||
>
|
||||
<View style={{width: 150, height: 100, backgroundColor: 'red'}}>
|
||||
<Text style={{margin: 30}}>Button</Text>
|
||||
<TextInput
|
||||
multiline
|
||||
onScroll={this.onScroll}
|
||||
/>
|
||||
</View>
|
||||
</TouchableNativeFeedback>
|
||||
)
|
||||
@@ -229,7 +240,6 @@ export class EventsTest extends React.Component {
|
||||
}
|
||||
|
||||
// App State
|
||||
|
||||
function appStateListener(state: string) {
|
||||
console.log("New state: " + state);
|
||||
}
|
||||
@@ -245,7 +255,6 @@ function appStateIOSTest() {
|
||||
}
|
||||
|
||||
// ViewPagerAndroid
|
||||
|
||||
export class ViewPagerAndroidTest {
|
||||
render() {
|
||||
return (
|
||||
@@ -462,45 +471,52 @@ deviceEventEmitterStatic.addListener("keyboardWillShow", data => true);
|
||||
deviceEventEmitterStatic.addListener("keyboardWillShow", data => true, {});
|
||||
|
||||
|
||||
class TextInputRefTest extends React.Component<{}, {username: string}> {
|
||||
class TextInputTest extends React.Component<{}, {username: string}> {
|
||||
username: TextInput | null = null;
|
||||
|
||||
handleUsernameChange(text: string) {
|
||||
handleUsernameChange = (text: string) => {
|
||||
console.log(`text: ${ text }`);
|
||||
}
|
||||
|
||||
onScroll = (e: NativeSyntheticEvent<TextInputScrollEventData>) => {
|
||||
testNativeSyntheticEvent(e);
|
||||
console.log(`x: ${ e.nativeEvent.contentOffset.x }`);
|
||||
console.log(`y: ${ e.nativeEvent.contentOffset.y }`);
|
||||
}
|
||||
|
||||
handleOnBlur = (e: NativeSyntheticEvent<TextInputFocusEventData>) => {
|
||||
testNativeSyntheticEvent(e);
|
||||
}
|
||||
|
||||
handleOnFocus = (e: NativeSyntheticEvent<TextInputFocusEventData>) => {
|
||||
testNativeSyntheticEvent(e);
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<View>
|
||||
<Text onPress={() => this.username.focus()}>Username</Text>
|
||||
|
||||
<TextInput
|
||||
ref={input => this.username = input}
|
||||
value={this.state.username}
|
||||
onChangeText={this.handleUsernameChange.bind(this)}
|
||||
onChangeText={this.handleUsernameChange}
|
||||
/>
|
||||
|
||||
<TextInput
|
||||
multiline
|
||||
onScroll={this.onScroll}
|
||||
/>
|
||||
|
||||
<TextInput
|
||||
onBlur={this.handleOnBlur}
|
||||
onFocus={this.handleOnFocus}
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class TextInputFocusBlurEventTest extends React.Component {
|
||||
handleOnBlur(e: NativeSyntheticEvent<TextInputFocusEventData>) {
|
||||
}
|
||||
|
||||
handleOnFocus(e: NativeSyntheticEvent<TextInputFocusEventData>) {
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<View>
|
||||
<TextInput
|
||||
onBlur={(e: NativeSyntheticEvent<TextInputFocusEventData>) => this.handleOnBlur(e)}
|
||||
onFocus={(e: NativeSyntheticEvent<TextInputFocusEventData>) => this.handleOnFocus(e)}
|
||||
/>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
class StatusBarTest extends React.Component {
|
||||
render() {
|
||||
StatusBar.setBarStyle("dark-content", true);
|
||||
@@ -517,6 +533,26 @@ class StatusBarTest extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
export class ImageTest extends React.Component {
|
||||
onLoad(e: NativeSyntheticEvent<ImageLoadEventData>) {
|
||||
testNativeSyntheticEvent(e);
|
||||
console.log('height:', e.nativeEvent.source.height);
|
||||
console.log('width:', e.nativeEvent.source.width);
|
||||
console.log('url:', e.nativeEvent.source.url);
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<View>
|
||||
<Image
|
||||
source={{ uri: 'https://seeklogo.com/images/T/typescript-logo-B29A3F462D-seeklogo.com.png' }}
|
||||
onLoad={this.onLoad}
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class StylePropsTest extends React.PureComponent {
|
||||
render() {
|
||||
const uri = 'https://seeklogo.com/images/T/typescript-logo-B29A3F462D-seeklogo.com.png'
|
||||
|
||||
Vendored
+1
-1
@@ -576,7 +576,7 @@ export interface NavigationScreenProp<S, P = NavigationParams> {
|
||||
closeDrawer: () => any;
|
||||
toggleDrawer: () => any;
|
||||
getParam: <T extends keyof P>(param: T, fallback?: P[T]) => P[T];
|
||||
setParams: (newParams: P) => boolean;
|
||||
setParams: (newParams: Partial<P>) => boolean;
|
||||
addListener: (
|
||||
eventName: string,
|
||||
callback: NavigationEventCallback
|
||||
|
||||
@@ -489,3 +489,28 @@ const CustomHeaderStack = createStackNavigator({
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
interface ScreenProps {
|
||||
name: string;
|
||||
onPlay(): void;
|
||||
}
|
||||
|
||||
class SetParamsTest extends React.Component<NavigationScreenProps<ScreenProps>> {
|
||||
componentDidMount() {
|
||||
this.props.navigation.setParams({
|
||||
onPlay: this.onPlay
|
||||
});
|
||||
}
|
||||
|
||||
onPlay = () => {
|
||||
//
|
||||
}
|
||||
|
||||
render() {
|
||||
const name = this.props.navigation.getParam('name');
|
||||
|
||||
return (
|
||||
<Text>My name is {name}</Text>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+2
@@ -7,6 +7,7 @@
|
||||
// Rich Baird <https://github.com/richbai90>
|
||||
// Dan Torberg <https://github.com/caspeco-dan>
|
||||
// Peter Keuter <https://github.com/pkeuter>
|
||||
// Jamie Saunders <https://github.com/jrsaunde>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.6
|
||||
|
||||
@@ -832,6 +833,7 @@ export class Treemap extends React.Component<TreemapProps> { }
|
||||
export class Label extends React.Component<LabelProps> { }
|
||||
|
||||
export interface LabelProps {
|
||||
angle?: number;
|
||||
viewBox?: ViewBox | PolarViewBox;
|
||||
formatter?: LabelFormatter;
|
||||
value?: number | string;
|
||||
|
||||
@@ -192,7 +192,9 @@ class Component extends React.Component<{}, ComponentState> {
|
||||
<XAxis dataKey="name">
|
||||
<Label value="Pages of my website" offset={0} position="insideBottom" />
|
||||
</XAxis>
|
||||
<YAxis label='pv of page' />
|
||||
<YAxis>
|
||||
<Label value="pv of page" angle={90} />
|
||||
</YAxis>
|
||||
<Bar dataKey="pv" fill="#8884d8">
|
||||
<LabelList dataKey="name" position="insideTop" angle={45} />
|
||||
</Bar>
|
||||
|
||||
Vendored
+3
-3
@@ -26,7 +26,7 @@ export type JQueryAjaxSettingsBase =
|
||||
/**
|
||||
* Same as jQuery v3 `JQuery.EventHandlerBase`.
|
||||
*/
|
||||
export type JQueryEventHandlerBase<TContext extends object, T> =
|
||||
export type JQueryEventHandlerBase<TContext, T> =
|
||||
(this: TContext, t: T, ...args: any[]) => void | false;
|
||||
|
||||
/**
|
||||
@@ -221,7 +221,7 @@ export interface Options<Result = DataFormat | GroupedDataFormat, RemoteResult =
|
||||
// jQuery And Select2 Plugin
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
export interface Select2Plugin<TElement extends Node = HTMLElement> {
|
||||
export interface Select2Plugin<TElement = HTMLElement> {
|
||||
amd: { require: Require; };
|
||||
|
||||
defaults: {
|
||||
@@ -252,7 +252,7 @@ export interface Select2Plugin<TElement extends Node = HTMLElement> {
|
||||
}
|
||||
|
||||
declare global {
|
||||
interface JQuery<TElement extends Node = HTMLElement> {
|
||||
interface JQuery<TElement = HTMLElement> {
|
||||
select2: Select2Plugin<TElement>;
|
||||
data(key: "select2"): Select2;
|
||||
|
||||
|
||||
+36
@@ -149,6 +149,15 @@ export class Profile {
|
||||
* Configuration options for the FirefoxDriver.
|
||||
*/
|
||||
export class Options {
|
||||
/**
|
||||
* Specify additional command line arguments that should be used when starting
|
||||
* the Firefox browser.
|
||||
*
|
||||
* @param {...(string|!Array<string>)} args The arguments to include.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
addArguments(...args: string[]): Options;
|
||||
|
||||
/**
|
||||
* Sets the browser to be in headless mode.
|
||||
*
|
||||
@@ -156,6 +165,33 @@ export class Options {
|
||||
*/
|
||||
headless(): Options;
|
||||
|
||||
/**
|
||||
* Sets the initial window size when running in
|
||||
* {@linkplain #headless headless} mode.
|
||||
*
|
||||
* @param {{width: number, height: number}} size The desired window size.
|
||||
* @return {!Options} A self reference.
|
||||
* @throws {TypeError} if width or height is unspecified, not a number, or
|
||||
* less than or equal to 0.
|
||||
*/
|
||||
windowSize(size: { width: number, height: number }): Options;
|
||||
|
||||
/**
|
||||
* Add extensions that should be installed when starting Firefox.
|
||||
*
|
||||
* @param {...string} paths The paths to the extension XPI files to install.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
addExtensions(...paths: string[]): Options;
|
||||
|
||||
/**
|
||||
* @param {string} key the preference key.
|
||||
* @param {(string|number|boolean)} value the preference value.
|
||||
* @return {!Options} A self reference.
|
||||
* @throws {TypeError} if either the key or value has an invalid type.
|
||||
*/
|
||||
setPreference(key: string, value: string | number | boolean): Options;
|
||||
|
||||
/**
|
||||
* Sets the profile to use. The profile may be specified as a
|
||||
* {@link Profile} object or as the path to an existing Firefox profile to use
|
||||
|
||||
Vendored
+46
-1
@@ -2160,6 +2160,21 @@ export class Builder {
|
||||
*/
|
||||
setChromeOptions(options: chrome.Options): Builder;
|
||||
|
||||
/**
|
||||
* @return {chrome.Options} the Chrome specific options currently configured
|
||||
* for this builder.
|
||||
*/
|
||||
getChromeOptions(): chrome.Options;
|
||||
|
||||
/**
|
||||
* Sets the service builder to use for managing the chromedriver child process
|
||||
* when creating new Chrome sessions.
|
||||
*
|
||||
* @param {chrome.ServiceBuilder} service the service to use.
|
||||
* @return {!Builder} A self reference.
|
||||
*/
|
||||
setChromeService(service: chrome.ServiceBuilder): Builder;
|
||||
|
||||
/**
|
||||
* Sets the control flow that created drivers should execute actions in. If
|
||||
* the flow is never set, or is set to {@code null}, it will use the active
|
||||
@@ -2181,6 +2196,15 @@ export class Builder {
|
||||
*/
|
||||
setEdgeOptions(options: edge.Options): Builder;
|
||||
|
||||
/**
|
||||
* Sets the {@link edge.ServiceBuilder} to use to manage the
|
||||
* MicrosoftEdgeDriver child process when creating sessions locally.
|
||||
*
|
||||
* @param {edge.ServiceBuilder} service the service to use.
|
||||
* @return {!Builder} a self reference.
|
||||
*/
|
||||
setEdgeService(service: edge.ServiceBuilder): Builder;
|
||||
|
||||
/**
|
||||
* Sets whether native events should be used.
|
||||
* @param {boolean} enabled Whether to enable native events.
|
||||
@@ -2199,6 +2223,21 @@ export class Builder {
|
||||
*/
|
||||
setFirefoxOptions(options: firefox.Options): Builder;
|
||||
|
||||
/**
|
||||
* @return {firefox.Options} the Firefox specific options currently configured
|
||||
* for this instance.
|
||||
*/
|
||||
getFirefoxOptions(): firefox.Options;
|
||||
|
||||
/**
|
||||
* Sets the {@link firefox.ServiceBuilder} to use to manage the geckodriver
|
||||
* child process when creating Firefox sessions locally.
|
||||
*
|
||||
* @param {firefox.ServiceBuilder} service the service to use.
|
||||
* @return {!Builder} a self reference.
|
||||
*/
|
||||
setFirefoxService(service: firefox.ServiceBuilder): Builder;
|
||||
|
||||
/**
|
||||
* Set Internet Explorer specific {@linkplain ie.Options options} for drivers
|
||||
* created by this builder. Any proxy settings defined on the given options
|
||||
@@ -2246,7 +2285,13 @@ export class Builder {
|
||||
* @param {!safari.Options} options The Safari options to use.
|
||||
* @return {!Builder} A self reference.
|
||||
*/
|
||||
setSafari(options: safari.Options): Builder;
|
||||
setSafariOptions(options: safari.Options): Builder;
|
||||
|
||||
/**
|
||||
* @return {safari.Options} the Safari specific options currently configured
|
||||
* for this instance.
|
||||
*/
|
||||
getSafariOptions(): safari.Options;
|
||||
|
||||
/**
|
||||
* Sets how elements should be scrolled into view for interaction.
|
||||
|
||||
@@ -25,6 +25,12 @@ function TestFirefoxDriver() {
|
||||
function TestFirefoxOptions() {
|
||||
let options: firefox.Options = new firefox.Options();
|
||||
|
||||
options = options.addArguments('foo', 'bar');
|
||||
options = options.windowSize({ width: 320, height: 480 });
|
||||
options = options.addExtensions('foo', 'bar');
|
||||
options = options.setPreference('a', 1);
|
||||
options = options.setPreference('a', true);
|
||||
options = options.setPreference('a', '1');
|
||||
options = options.setBinary('binary');
|
||||
options = options.setBinary(new firefox.Binary());
|
||||
options = options.setLoggingPreferences(new webdriver.logging.Preferences());
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import * as webdriver from 'selenium-webdriver';
|
||||
import * as chrome from 'selenium-webdriver/chrome';
|
||||
import * as edge from 'selenium-webdriver/edge';
|
||||
import * as firefox from 'selenium-webdriver/firefox';
|
||||
import * as http from 'selenium-webdriver/http';
|
||||
import * as remote from 'selenium-webdriver/remote';
|
||||
import * as safari from 'selenium-webdriver/safari';
|
||||
import * as testing from 'selenium-webdriver/testing';
|
||||
|
||||
function TestBuilder() {
|
||||
@@ -18,16 +20,25 @@ function TestBuilder() {
|
||||
|
||||
builder = builder.setAlertBehavior('behavior');
|
||||
builder = builder.setChromeOptions(new chrome.Options());
|
||||
builder = builder.setChromeService(new chrome.ServiceBuilder());
|
||||
builder = builder.setControlFlow(new webdriver.promise.ControlFlow());
|
||||
builder = builder.setEdgeOptions(new edge.Options());
|
||||
builder = builder.setEdgeService(new edge.ServiceBuilder());
|
||||
builder = builder.setEnableNativeEvents(true);
|
||||
builder = builder.setFirefoxOptions(new firefox.Options());
|
||||
builder = builder.setFirefoxService(new firefox.ServiceBuilder());
|
||||
builder = builder.setLoggingPrefs(new webdriver.logging.Preferences());
|
||||
builder = builder.setLoggingPrefs({ key: 'value' });
|
||||
builder = builder.setProxy({ proxyType: 'type' });
|
||||
builder = builder.setSafariOptions(new safari.Options());
|
||||
builder = builder.setScrollBehavior(1);
|
||||
builder = builder.usingServer('http://someserver');
|
||||
builder = builder.withCapabilities(new webdriver.Capabilities());
|
||||
builder = builder.withCapabilities({ something: true });
|
||||
|
||||
const chromeOptions: chrome.Options = builder.getChromeOptions();
|
||||
const firefoxOptions: firefox.Options = builder.getFirefoxOptions();
|
||||
const safariOptions: safari.Options = builder.getSafariOptions();
|
||||
}
|
||||
|
||||
declare const promise: webdriver.promise.Promise<string>;
|
||||
|
||||
Vendored
+5
@@ -5262,6 +5262,11 @@ declare namespace sequelize {
|
||||
* Set to true or a string with the attribute name you want to use to enable.
|
||||
*/
|
||||
version?: boolean | string;
|
||||
|
||||
/**
|
||||
* Throws an error when no records found
|
||||
*/
|
||||
rejectOnError?: boolean | Error;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Vendored
+437
-422
@@ -1,8 +1,9 @@
|
||||
// Type definitions for shopify-buy 0.4.2
|
||||
// Type definitions for shopify-buy 1.4.0
|
||||
// Project: http://shopify.github.io/js-buy-sdk/api/
|
||||
// Definitions by: Martin Köhn <https://github.com/openminder>
|
||||
// Stephen Traiforos <https://github.com/straiforos>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
// TypeScript Version: 2.7
|
||||
|
||||
/**
|
||||
* The JS Buy SDK is a lightweight library that allows you to build ecommerce into any website.
|
||||
@@ -12,441 +13,455 @@
|
||||
* website or javascript application. This is helpful if you already have a website and need to add ecommerce
|
||||
* or only need a simple buy button on your site.
|
||||
*/
|
||||
|
||||
declare namespace ShopifyBuy {
|
||||
/**
|
||||
* Create a ShopClient. This is the main entry point to the SDK.
|
||||
export function buildClient(config: Config): Client;
|
||||
|
||||
export interface Client {
|
||||
product: ShopifyBuy.ProductResource;
|
||||
collection: ShopifyBuy.CollectionResource;
|
||||
checkout: ShopifyBuy.CheckoutResource;
|
||||
shop: ShopResource;
|
||||
image: Image;
|
||||
fetchNextPage<T extends GraphModel>(nextArray: T[]): T[];
|
||||
}
|
||||
|
||||
export interface Config {
|
||||
domain: string;
|
||||
storefrontAccessToken: string;
|
||||
}
|
||||
|
||||
export interface ProductResource {
|
||||
fetch(id: string): Promise<Product>;
|
||||
fetchAll(pageSizeopt?: number): Promise<Product[]>;
|
||||
fetchByHandle(handle: string): Promise<Product>;
|
||||
fetchMultiple(ids: string[]): Promise<Product[]>;
|
||||
fetchQuery(query: Query): Promise<Product[]>;
|
||||
|
||||
/**
|
||||
* Product Helper Namespace
|
||||
* @link https://shopify.github.io/js-buy-sdk/ProductResource.html
|
||||
*/
|
||||
variantForOptions(product: Product, options: Option): ProductVariant;
|
||||
}
|
||||
|
||||
export interface CollectionResource {
|
||||
fetch(id: string): Promise<Product[]>;
|
||||
fetchWithProducts(id: string): Promise<any[]>; // TODO fix to be a type: Docs: Fetches a single collection by ID on the shop, not including products.
|
||||
fetchAll(pageSizeopt?: number): Promise<any[]>; // TODO fix to be a type: Docs: Fetches all collections on the shop, not including products.
|
||||
fetchAllWithProducts(): Promise<any[]>; // TODO fix to be a type: DOC: Fetches all collections on the shop, including products.
|
||||
fetchWithProducts(id: string): Promise<any[]>; // TODO fix to be a type: DOC: Fetches all collections on the shop, including products.
|
||||
fetchByHandle(handle: string): Promise<any[]>; // TODO fix to be a type: DOC: Fetches a collection by handle on the shop. Assuming it does not give products
|
||||
fetchQuery(query: Query): Promise<any[]>; // TODO fix to be a type: DOC: Fetches a collection by handle on the shop. Assuming it does not give products
|
||||
}
|
||||
|
||||
export interface CheckoutResource {
|
||||
create(
|
||||
email?: string,
|
||||
lineItems?: LineItem[],
|
||||
shippingAddress?: Address,
|
||||
note?: string,
|
||||
customAttributes?: AttributeInput[]
|
||||
): Promise<Cart>;
|
||||
|
||||
fetch(id: string): Promise<Cart>;
|
||||
|
||||
addLineItems(checkoutId: string | number, lineItems: LineItem[]): Promise<Cart>;
|
||||
|
||||
/**
|
||||
* Remove all line items from cart
|
||||
*/
|
||||
clearLineItems(
|
||||
checkoutId: string | number,
|
||||
lineItems: LineItem[]
|
||||
): Promise<Cart>;
|
||||
|
||||
/**
|
||||
* Add items to cart. Updates cart's lineItems
|
||||
*/
|
||||
addVariants(item: Item, nextItem?: Array<Item>): Promise<Cart>;
|
||||
|
||||
/**
|
||||
* Remove a line item from cart based on line item id
|
||||
*/
|
||||
removeLineItem(
|
||||
checkoutId: string | number,
|
||||
lineItemIds: string[]
|
||||
): Promise<Cart>;
|
||||
|
||||
/**
|
||||
* Update a line item quantity based on line item id
|
||||
*/
|
||||
updateLineItem(
|
||||
checkoutId: string | number,
|
||||
lineItems: AttributeInput[]
|
||||
): Promise<Cart>;
|
||||
}
|
||||
|
||||
export interface ShopResource {
|
||||
fetchInfo(): Promise<Shop>;
|
||||
fetchPolicies(): Promise<Shop>;
|
||||
}
|
||||
|
||||
export interface Query {
|
||||
/**
|
||||
* query: title, collection_type, updated_at
|
||||
* TODO probably will remove before Defintely Typed PR,
|
||||
* as their community guidelines
|
||||
*/
|
||||
query: string;
|
||||
sortBy: string;
|
||||
after?: string;
|
||||
before?: string;
|
||||
first?: string;
|
||||
last?: string;
|
||||
reverse?: boolean;
|
||||
}
|
||||
|
||||
export interface Product extends GraphModel {
|
||||
/**
|
||||
* A product description.
|
||||
*/
|
||||
description: string;
|
||||
|
||||
/**
|
||||
* Product unique ID
|
||||
*/
|
||||
id: string | number;
|
||||
|
||||
/**
|
||||
* An Array of Objects that contain meta data about an image including src of the images.
|
||||
*/
|
||||
images: Array<Image>;
|
||||
|
||||
/**
|
||||
* All variants of a product.
|
||||
*/
|
||||
variants: Array<ProductVariant>;
|
||||
|
||||
/**
|
||||
* Get an array of Product Options. Product Options can be used to define
|
||||
* the currently selectedVariant from which you can get a checkout url (ProductVariant.checkoutUrl)
|
||||
* or can be added to a cart (Cart.createLineItemsFromVariants).
|
||||
*/
|
||||
options: Array<Option>;
|
||||
|
||||
/**
|
||||
* Retrieve variant for currently selected options. By default the first value in each option is selected
|
||||
* which means selectedVariant will never be null. With a selectedVariant you can
|
||||
* create checkout url (ProductVariant.checkoutUrl) or
|
||||
* it can be added to a cart (Cart.createLineItemsFromVariants).
|
||||
*/
|
||||
selectedVariant: ProductVariant;
|
||||
|
||||
/**
|
||||
* Retrieve image for currently selected variantImage.
|
||||
*/
|
||||
selectedVariantImage: Image;
|
||||
|
||||
/**
|
||||
* A read only Array of Strings represented currently selected option values. eg. ["Large", "Red"]
|
||||
*/
|
||||
selections: Array<string>;
|
||||
|
||||
/**
|
||||
* The product title
|
||||
*/
|
||||
title: string;
|
||||
}
|
||||
|
||||
export interface ProductVariant extends GraphModel {
|
||||
/**
|
||||
* Variant in stock. Always true if inventory tracking is disabled.
|
||||
*/
|
||||
available: boolean;
|
||||
|
||||
/**
|
||||
* Compare at price for variant. The compareAtPrice would be the price of the
|
||||
* product previously before the product went on sale.
|
||||
*/
|
||||
compareAtPrice: string;
|
||||
|
||||
/**
|
||||
* Price of variant, formatted according to shop currency format string. For instance "$10.00"
|
||||
*/
|
||||
formattedPrice: string;
|
||||
|
||||
/**
|
||||
* Variant weight in grams. If no weight is defined grams will be 0.
|
||||
*/
|
||||
grams: number;
|
||||
|
||||
/**
|
||||
* Variant unique ID
|
||||
*/
|
||||
id: string | number;
|
||||
|
||||
/**
|
||||
* Image for variant
|
||||
*/
|
||||
|
||||
image: Image;
|
||||
|
||||
/**
|
||||
* Image variants available for a variant.
|
||||
*/
|
||||
imageVariant: Array<ImageVariant>;
|
||||
|
||||
/**
|
||||
* Option values associated with this variant, ex {name: "color", value: "Blue"}
|
||||
*/
|
||||
optionValues: Array<OptionValue>;
|
||||
|
||||
/**
|
||||
* Price of the variant. The price will be in the following form: "10.00"
|
||||
*/
|
||||
price: string;
|
||||
|
||||
/**
|
||||
* ID of product variant belongs to
|
||||
*/
|
||||
productId: string | number;
|
||||
|
||||
/**
|
||||
* Title of product variant belongs to
|
||||
*/
|
||||
productTitle: string;
|
||||
|
||||
/**
|
||||
* Title of variant
|
||||
*/
|
||||
title: string;
|
||||
|
||||
/*
|
||||
* Get a checkout url for a specific product variant.
|
||||
* You can optionally pass a quantity.
|
||||
* If no quantity is passed then quantity will default to 1.
|
||||
*/
|
||||
checkoutUrl(quantitiy: number): string;
|
||||
}
|
||||
|
||||
export interface Option {
|
||||
/**
|
||||
* name of option (ex. "Size", "Color")
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* get/set the currently selected option value with one of the values from the Product Options/values array.
|
||||
* For instance if the option values array had the following ["Large", "Medium", "Small"] setting selected to be
|
||||
* "Large", "Medium", or "Small" would be valid any other value would throw an Error.
|
||||
*/
|
||||
selected: string;
|
||||
|
||||
/**
|
||||
* an Array possible values for option. For instance if this option
|
||||
* is a "Size" option an example value for values could be: ["Large", "Medium", "Small"]
|
||||
*/
|
||||
values: Array<OptionValue>;
|
||||
}
|
||||
|
||||
export interface OptionValue {
|
||||
name: string;
|
||||
option_id: string;
|
||||
value: any;
|
||||
}
|
||||
|
||||
export interface Collection {
|
||||
handle: string;
|
||||
body_html: string;
|
||||
image: Image;
|
||||
id: string;
|
||||
metafields: any[];
|
||||
published: boolean;
|
||||
published_at: string;
|
||||
published_scope: string;
|
||||
sort_order: string;
|
||||
template_suffix: string;
|
||||
title: string;
|
||||
updated_at: string;
|
||||
}
|
||||
|
||||
export interface Cart extends GraphModel {
|
||||
/**
|
||||
* Get checkout URL for current cart
|
||||
*/
|
||||
checkoutUrl: string;
|
||||
|
||||
/**
|
||||
* get ID for current cart
|
||||
*/
|
||||
id: string | number;
|
||||
|
||||
/**
|
||||
* Gets the total quantity of all line items. Example: you've added two variants
|
||||
* with quantities 3 and 2. lineItemCount will be 5.
|
||||
*/
|
||||
lineItemCount: number;
|
||||
|
||||
/**
|
||||
* Get an Array of CartLineItemModel's
|
||||
*/
|
||||
lineItems: LineItem[];
|
||||
|
||||
/**
|
||||
* Get current subtotal price for all line items.
|
||||
* Example: two items have been added to the cart that cost $1.25 then the subtotal will be 2.50
|
||||
*/
|
||||
subtotal: string;
|
||||
}
|
||||
|
||||
export interface LineItem extends GraphModel {
|
||||
/**
|
||||
* Compare at price for variant. The compareAtPrice would be the price of the product
|
||||
* previously before the product went on sale.
|
||||
* If no compareAtPrice is set then this value will be null. An example value: "5.00".
|
||||
*/
|
||||
compare_at_price: string;
|
||||
|
||||
/**
|
||||
* Variant's weight in grams. If no weight is set then 0 is returned.
|
||||
*/
|
||||
grams: number;
|
||||
|
||||
/**
|
||||
* A line item ID.
|
||||
*/
|
||||
id: string | number;
|
||||
|
||||
/**
|
||||
* Variant's image.
|
||||
*/
|
||||
image: Image;
|
||||
|
||||
/**
|
||||
* The total price for this line item. For instance if the variant costs 1.50 and you have a
|
||||
* quantity of 2 then line_price will be 3.00.
|
||||
*/
|
||||
line_price: string;
|
||||
|
||||
/**
|
||||
* Price of the variant. For example: "5.00".
|
||||
*/
|
||||
price: string;
|
||||
|
||||
/**
|
||||
* ID of variant's product.
|
||||
*/
|
||||
product_id: string | number;
|
||||
|
||||
/**
|
||||
* Count of variants to order.
|
||||
*/
|
||||
quantity: number;
|
||||
|
||||
/**
|
||||
* Product title of variant's parent product.
|
||||
*/
|
||||
title: string;
|
||||
|
||||
/**
|
||||
* ID of line item variant.
|
||||
*/
|
||||
variant_id: string | number;
|
||||
|
||||
/**
|
||||
* Title of variant.
|
||||
*/
|
||||
variant_title: string;
|
||||
}
|
||||
|
||||
export interface Item {
|
||||
variant: ProductVariant;
|
||||
quantity: number;
|
||||
}
|
||||
|
||||
export interface Address {
|
||||
address1: String;
|
||||
address2: String;
|
||||
city: String;
|
||||
company: String;
|
||||
country: String;
|
||||
firstName: String;
|
||||
lastName: String;
|
||||
phone: String;
|
||||
province: String;
|
||||
zip: String;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://help.shopify.com/api/custom-storefronts/storefront-api/reference/input_object/attributeinput
|
||||
* https://help.shopify.com/api/custom-storefronts/storefront-api/reference/input_object/checkoutlineitemupdateinput
|
||||
*/
|
||||
export function buildClient(configAttrs: Shopify.Config): Shopify.ShopClient
|
||||
export interface AttributeInput {
|
||||
key?: string;
|
||||
value?: string;
|
||||
id?: string | number;
|
||||
quantity?: number;
|
||||
variantId?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO Validate schema matches js-buy
|
||||
* Derived from REST API Docs: https://help.shopify.com/api/custom-storefronts/storefront-api/reference/object/shop#fields
|
||||
*/
|
||||
export interface Shop {
|
||||
|
||||
description: string;
|
||||
moneyFormat: string;
|
||||
name: string;
|
||||
/**
|
||||
* TODO Add types for the Shop properties below
|
||||
* PaymentSettings, ShopPolicy etc
|
||||
*/
|
||||
paymentSettings: any;
|
||||
primaryDomain: any;
|
||||
privacyPolicy: any;
|
||||
refundPolicy: any;
|
||||
termsOfService: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal Image description
|
||||
*/
|
||||
interface Image {
|
||||
id: string | number
|
||||
created_at: string
|
||||
position: number
|
||||
updated_at: string
|
||||
product_id: string
|
||||
src: string
|
||||
variant_ids: Array<string>
|
||||
export interface Image extends GraphModel {
|
||||
id: string | number;
|
||||
created_at: string;
|
||||
position: number;
|
||||
updated_at: string;
|
||||
product_id: string;
|
||||
src: string;
|
||||
variant_ids: Array<string>;
|
||||
}
|
||||
|
||||
interface ImageVariant {
|
||||
name: string,
|
||||
dimensions: string,
|
||||
src: string
|
||||
export interface ImageVariant extends Image {
|
||||
name: string;
|
||||
dimensions: string;
|
||||
src: string;
|
||||
/**
|
||||
* Returns src URL for new image size/variant
|
||||
* @param image The image you would like a different size for.
|
||||
* @param options Image Max width and height configuration.
|
||||
*/
|
||||
imageForSize(image: Image, options: ImageOptions): string;
|
||||
}
|
||||
|
||||
interface OptionValue {
|
||||
name: string,
|
||||
option_id: string | number,
|
||||
value: any
|
||||
export interface ImageOptions {
|
||||
maxWidth: number;
|
||||
maxHeight: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal BaseModel class
|
||||
*/
|
||||
class BaseModel {
|
||||
constructor(attrs: any, metaAttrs: any)
|
||||
let NO_IMAGE_URI: string;
|
||||
|
||||
attrs: any
|
||||
serializer: any
|
||||
adapter: any
|
||||
shopClient: any
|
||||
/*
|
||||
* Base Model for the higher level returned objects from the API using GraphQL
|
||||
*/
|
||||
export interface GraphModel {
|
||||
attrs?: any
|
||||
onlineStoreUrl?: string
|
||||
}
|
||||
|
||||
var NO_IMAGE_URI: string;
|
||||
|
||||
/**
|
||||
* This namespace contains all globally accessible classes
|
||||
*/
|
||||
export namespace Shopify {
|
||||
|
||||
/**
|
||||
* Base Shopify Client config object
|
||||
*/
|
||||
interface Config {
|
||||
/**
|
||||
* An API Key for your store. Documentation how to get an API Key:
|
||||
* https://help.shopify.com/api/sdks/js-buy-sdk/getting-started#api-key
|
||||
*/
|
||||
apiKey: string
|
||||
|
||||
/**
|
||||
* Typically will be 6 which is the Buy Button App Id. For more info on App Id see:
|
||||
* https://help.shopify.com/api/sdks/js-buy-sdk/getting-started#app-id
|
||||
*/
|
||||
appId: string
|
||||
|
||||
/**
|
||||
* Your shop's full myshopify.com domain. For example: embeds.myshopify.com
|
||||
*/
|
||||
domain: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Cart item, that should be added to the card
|
||||
*/
|
||||
interface CartModelItem {
|
||||
variant: Shopify.ProductVariantModel
|
||||
quantity: number
|
||||
}
|
||||
|
||||
/**
|
||||
* Shopify-Buy-SDK Client to handle products and cart
|
||||
*/
|
||||
class ShopClient {
|
||||
|
||||
/**
|
||||
* Config data to be used throughout all API interaction
|
||||
*/
|
||||
constructor(config?: Config)
|
||||
/**
|
||||
* Creates a CartModel instance.
|
||||
*/
|
||||
createCart(): Promise<CartModel>
|
||||
|
||||
/**
|
||||
* This function will return an Array of collections from your store
|
||||
*/
|
||||
fetchAllCollections(): Promise<Array<any>>
|
||||
|
||||
/**
|
||||
* This function will return an Array of products from your store
|
||||
*/
|
||||
fetchAllProducts(): Promise<Array<ProductModel>>
|
||||
|
||||
/**
|
||||
* Retrieve a previously created cart by its key.
|
||||
*/
|
||||
fetchCart(id: string): Promise<CartModel>
|
||||
|
||||
/**
|
||||
* Fetch one collection by its ID.
|
||||
*/
|
||||
fetchCollection(id: string | number): Promise<any>
|
||||
|
||||
/**
|
||||
* Fetch one product by its ID.
|
||||
*/
|
||||
fetchProduct(id: string | number): Promise<ProductModel>
|
||||
|
||||
/**
|
||||
* Fetches a list of collections matching a specified query.
|
||||
*/
|
||||
fetchQueryCollections(query?: any): Promise<Array<any>>
|
||||
|
||||
/**
|
||||
* Fetches a list of products matching a specified query.
|
||||
*/
|
||||
fetchQueryProducts(query?: any): Promise<Array<ProductModel>>
|
||||
|
||||
/**
|
||||
* This method looks up a reference in localStorage to the most recent cart.
|
||||
* If one is not found, creates one. If the cart the reference points to doesn't exist,
|
||||
* create one and store the new reference.
|
||||
*/
|
||||
fetchRecentCart(): Promise<CartModel>
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Class for products returned by fetch('product')
|
||||
*/
|
||||
class ProductModel extends BaseModel {
|
||||
|
||||
constructor()
|
||||
|
||||
/**
|
||||
* A product description.
|
||||
*/
|
||||
description: string
|
||||
|
||||
/**
|
||||
* Product unique ID
|
||||
*/
|
||||
id: string | number
|
||||
|
||||
/**
|
||||
* An Array of Objects that contain meta data about an image including src of the images.
|
||||
*/
|
||||
images: Array<Image>
|
||||
|
||||
/**
|
||||
* All variants of a product.
|
||||
*/
|
||||
variants: Array<ProductVariantModel>
|
||||
|
||||
/**
|
||||
* Get an array of ProductOptionModels. ProductOptionModels can be used to define
|
||||
* the currently selectedVariant from which you can get a checkout url (ProductVariantModel.checkoutUrl)
|
||||
* or can be added to a cart (CartModel.createLineItemsFromVariants).
|
||||
*/
|
||||
options: Array<ProductOptionModel>
|
||||
|
||||
/**
|
||||
* Retrieve variant for currently selected options. By default the first value in each option is selected
|
||||
* which means selectedVariant will never be null. With a selectedVariant you can
|
||||
* create checkout url (ProductVariantModel.checkoutUrl) or
|
||||
* it can be added to a cart (CartModel.createLineItemsFromVariants).
|
||||
*/
|
||||
selectedVariant: ProductVariantModel
|
||||
|
||||
/**
|
||||
* Retrieve image for currently selected variantImage.
|
||||
*/
|
||||
selectedVariantImage: Image
|
||||
|
||||
/**
|
||||
* A read only Array of Strings represented currently selected option values. eg. ["Large", "Red"]
|
||||
*/
|
||||
selections: Array<string>
|
||||
|
||||
/**
|
||||
* The product title
|
||||
*/
|
||||
title: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Model for product variant
|
||||
*/
|
||||
class ProductVariantModel extends BaseModel {
|
||||
|
||||
constructor()
|
||||
|
||||
/*
|
||||
* Get a checkout url for a specific product variant.
|
||||
* You can optionally pass a quantity.
|
||||
* If no quantity is passed then quantity will default to 1.
|
||||
*/
|
||||
checkoutUrl(quantitiy: number): string
|
||||
|
||||
/**
|
||||
* Variant in stock. Always true if inventory tracking is disabled.
|
||||
*/
|
||||
available: boolean
|
||||
|
||||
/**
|
||||
* Compare at price for variant. The compareAtPrice would be the price of the
|
||||
* product previously before the product went on sale.
|
||||
*/
|
||||
compareAtPrice: string
|
||||
|
||||
/**
|
||||
* Price of variant, formatted according to shop currency format string. For instance "$10.00"
|
||||
*/
|
||||
formattedPrice: string
|
||||
|
||||
/**
|
||||
* Variant weight in grams. If no weight is defined grams will be 0.
|
||||
*/
|
||||
grams: number
|
||||
|
||||
/**
|
||||
* Variant unique ID
|
||||
*/
|
||||
id: string | number
|
||||
|
||||
/**
|
||||
* Image for variant
|
||||
*/
|
||||
image: Image
|
||||
|
||||
/**
|
||||
* Image variants available for a variant.
|
||||
*/
|
||||
imageVariant: Array<ImageVariant>
|
||||
|
||||
/**
|
||||
* Option values associated with this variant, ex {name: "color", value: "Blue"}
|
||||
*/
|
||||
optionValues: Array<OptionValue>
|
||||
|
||||
/**
|
||||
* Price of the variant. The price will be in the following form: "10.00"
|
||||
*/
|
||||
price: string
|
||||
|
||||
/**
|
||||
* ID of product variant belongs to
|
||||
*/
|
||||
productId: string | number
|
||||
|
||||
/**
|
||||
* Title of product variant belongs to
|
||||
*/
|
||||
productTitle: string
|
||||
|
||||
/**
|
||||
* Title of variant
|
||||
*/
|
||||
title: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Class for product option
|
||||
*/
|
||||
class ProductOptionModel extends BaseModel {
|
||||
|
||||
constructor()
|
||||
|
||||
/**
|
||||
* name of option (ex. "Size", "Color")
|
||||
*/
|
||||
name: string
|
||||
|
||||
/**
|
||||
* get/set the currently selected option value with one of the values from the ProductOptionModel/values array.
|
||||
* For instance if the option values array had the following ["Large", "Medium", "Small"] setting selected to be
|
||||
* "Large", "Medium", or "Small" would be valid any other value would throw an Error.
|
||||
*/
|
||||
selected: string
|
||||
|
||||
/**
|
||||
* an Array possible values for option. For instance if this option
|
||||
* is a "Size" option an example value for values could be: ["Large", "Medium", "Small"]
|
||||
*/
|
||||
values: Array<any>
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Class for cart model
|
||||
*/
|
||||
class CartModel extends BaseModel {
|
||||
|
||||
constructor()
|
||||
|
||||
/**
|
||||
* Remove all line items from cart
|
||||
*/
|
||||
clearLineItems(): Promise<CartModel>
|
||||
|
||||
/**
|
||||
* Add items to cart. Updates cart's lineItems
|
||||
*/
|
||||
addVariants(item: CartModelItem, nextItem?: Array<CartModelItem>): Promise<CartModel>
|
||||
|
||||
/**
|
||||
* Add items to the cart. Updates cart's lineItems based on variants passed in.
|
||||
*/
|
||||
createLineItemsFromVariants(...items: CartModelItem[] ): Promise<CartModel>
|
||||
|
||||
/**
|
||||
* Remove a line item from cart based on line item id
|
||||
*/
|
||||
removeLineItem(id: string | number): Promise<CartModel>
|
||||
|
||||
/**
|
||||
* Update a line item quantity based on line item id
|
||||
*/
|
||||
updateLineItem(id: string | number, quantitiy: number): Promise<CartModel>
|
||||
|
||||
/**
|
||||
* Force update of cart model on server. This function will only be used in advanced
|
||||
* situations and does not need to be called explicitly to update line items.
|
||||
* It is automatically called after createLineItemsFromVariants, updateLineItem,
|
||||
* removeLineItem, and removeLineItem
|
||||
*/
|
||||
updateModel(): Promise<CartModel>
|
||||
|
||||
/**
|
||||
* Get checkout URL for current cart
|
||||
*/
|
||||
checkoutUrl: string
|
||||
|
||||
/**
|
||||
* get ID for current cart
|
||||
*/
|
||||
id: string | number
|
||||
|
||||
/**
|
||||
* Gets the total quantity of all line items. Example: you've added two variants
|
||||
* with quantities 3 and 2. lineItemCount will be 5.
|
||||
*/
|
||||
lineItemCount: number
|
||||
|
||||
/**
|
||||
* Get an Array of CartLineItemModel's
|
||||
*/
|
||||
lineItems: Array<CartLineItemModel>
|
||||
|
||||
/**
|
||||
* Get current subtotal price for all line items.
|
||||
* Example: two items have been added to the cart that cost $1.25 then the subtotal will be 2.50
|
||||
*/
|
||||
subtotal: string
|
||||
|
||||
}
|
||||
|
||||
class CartLineItemModel extends BaseModel {
|
||||
constructor()
|
||||
|
||||
/**
|
||||
* Compare at price for variant. The compareAtPrice would be the price of the product
|
||||
* previously before the product went on sale.
|
||||
* If no compareAtPrice is set then this value will be null. An example value: "5.00".
|
||||
*/
|
||||
compare_at_price: string
|
||||
|
||||
/**
|
||||
* Variant's weight in grams. If no weight is set then 0 is returned.
|
||||
*/
|
||||
grams: number
|
||||
|
||||
/**
|
||||
* A line item ID.
|
||||
*/
|
||||
id: string | number
|
||||
|
||||
/**
|
||||
* Variant's image.
|
||||
*/
|
||||
image: Image
|
||||
|
||||
/**
|
||||
* The total price for this line item. For instance if the variant costs 1.50 and you have a
|
||||
* quantity of 2 then line_price will be 3.00.
|
||||
*/
|
||||
line_price: string
|
||||
|
||||
/**
|
||||
* Price of the variant. For example: "5.00".
|
||||
*/
|
||||
price: string
|
||||
|
||||
/**
|
||||
* ID of variant's product.
|
||||
*/
|
||||
product_id: string | number
|
||||
|
||||
/**
|
||||
* Count of variants to order.
|
||||
*/
|
||||
quantity: number
|
||||
|
||||
/**
|
||||
* Product title of variant's parent product.
|
||||
*/
|
||||
title: string
|
||||
|
||||
/**
|
||||
* ID of line item variant.
|
||||
*/
|
||||
variant_id: string | number
|
||||
|
||||
/**
|
||||
* Title of variant.
|
||||
*/
|
||||
variant_title: string
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
declare module "shopify-buy" {
|
||||
export = ShopifyBuy
|
||||
export = ShopifyBuy;
|
||||
}
|
||||
|
||||
@@ -3,22 +3,21 @@
|
||||
/* Build new ShopifyBuy client
|
||||
============================================================ */
|
||||
let client = ShopifyBuy.buildClient({
|
||||
apiKey: 'bf081e860bc9dc1ce0654fdfbc20892d',
|
||||
domain: 'embeds',
|
||||
appId: '6'
|
||||
domain: 'buyapitypestest.myshopify.com',
|
||||
storefrontAccessToken: '9f30a6806b613e0cb551b7db59c5ca02'
|
||||
});
|
||||
|
||||
var product : ShopifyBuy.Shopify.ProductModel;
|
||||
var cart : ShopifyBuy.Shopify.CartModel;
|
||||
var product : ShopifyBuy.Product;
|
||||
var cart : ShopifyBuy.Cart;
|
||||
var cartLineItemCount : number;
|
||||
if(localStorage.getItem('lastCartId')) {
|
||||
client.fetchCart(localStorage.getItem('lastCartId')).then(function(remoteCart : ShopifyBuy.Shopify.CartModel) {
|
||||
client.checkout.fetch(localStorage.getItem('lastCartId')).then(function(remoteCart : ShopifyBuy.Cart) {
|
||||
cart = remoteCart;
|
||||
cartLineItemCount = cart.lineItems.length;
|
||||
renderCartItems();
|
||||
});
|
||||
} else {
|
||||
client.createCart().then(function (newCart : ShopifyBuy.Shopify.CartModel) {
|
||||
client.checkout.create().then(function (newCart : ShopifyBuy.Cart) {
|
||||
cart = newCart;
|
||||
localStorage.setItem('lastCartId', ""+cart.id);
|
||||
cartLineItemCount = 0;
|
||||
@@ -29,11 +28,11 @@ var previousFocusItem : any;
|
||||
|
||||
/* Fetch product and init
|
||||
============================================================ */
|
||||
client.fetchProduct('3614436099').then(function (fetchedProduct : ShopifyBuy.Shopify.ProductModel) {
|
||||
client.product.fetch('3614436099').then(function (fetchedProduct : ShopifyBuy.Product) {
|
||||
product = fetchedProduct;
|
||||
var selectedVariant : ShopifyBuy.Shopify.ProductVariantModel = product.selectedVariant;
|
||||
var selectedVariant : ShopifyBuy.ProductVariant = product.selectedVariant;
|
||||
var selectedVariantImage : any = product.selectedVariantImage;
|
||||
var currentOptions : ShopifyBuy.Shopify.ProductOptionModel[] = product.options;
|
||||
var currentOptions : ShopifyBuy.Option[] = product.options;
|
||||
|
||||
var variantSelectors = generateSelectors(product);
|
||||
$('.variant-selectors').html(""+variantSelectors);
|
||||
@@ -49,8 +48,8 @@ client.fetchProduct('3614436099').then(function (fetchedProduct : ShopifyBuy.Sho
|
||||
|
||||
/* Generate DOM elements for variant selectors
|
||||
============================================================ */
|
||||
function generateSelectors(product : ShopifyBuy.Shopify.ProductModel) {
|
||||
var elements = product.options.map(function(option : ShopifyBuy.Shopify.ProductOptionModel) {
|
||||
function generateSelectors(product : ShopifyBuy.Product) {
|
||||
var elements = product.options.map(function(option : ShopifyBuy.Option) {
|
||||
var optionsHtml = option.values.map(function(value : any) {
|
||||
return '<option value="' + value + '">' + value + '</option>';
|
||||
});
|
||||
@@ -121,16 +120,16 @@ function bindEventListeners() {
|
||||
|
||||
/* Variant option change handler
|
||||
============================================================ */
|
||||
function attachOnVariantSelectListeners(product : ShopifyBuy.Shopify.ProductModel) {
|
||||
function attachOnVariantSelectListeners(product : ShopifyBuy.Product) {
|
||||
$('.variant-selectors').on('change', 'select', function(event) {
|
||||
var $element : any = $(event.target);
|
||||
var name : string = $element.attr('name');
|
||||
var value : string = $element.val();
|
||||
product.options.filter(function(option : ShopifyBuy.Shopify.ProductOptionModel) {
|
||||
product.options.filter(function(option : ShopifyBuy.Option) {
|
||||
return option.name === name;
|
||||
})[0].selected = value;
|
||||
|
||||
var selectedVariant : ShopifyBuy.Shopify.ProductVariantModel = product.selectedVariant;
|
||||
var selectedVariant : ShopifyBuy.ProductVariant = product.selectedVariant;
|
||||
var selectedVariantImage : any = product.selectedVariantImage;
|
||||
updateProductTitle(product.title);
|
||||
updateVariantImage(selectedVariantImage);
|
||||
@@ -155,13 +154,13 @@ function updateVariantImage(image : any) {
|
||||
|
||||
/* Update product variant title based on selected variant
|
||||
============================================================ */
|
||||
function updateVariantTitle(variant : ShopifyBuy.Shopify.ProductVariantModel) {
|
||||
function updateVariantTitle(variant : ShopifyBuy.ProductVariant) {
|
||||
$('#buy-button-1 .variant-title').text(variant.title);
|
||||
}
|
||||
|
||||
/* Update product variant price based on selected variant
|
||||
============================================================ */
|
||||
function updateVariantPrice(variant : ShopifyBuy.Shopify.ProductVariantModel) {
|
||||
function updateVariantPrice(variant : ShopifyBuy.ProductVariant) {
|
||||
$('#buy-button-1 .variant-price').text('$' + variant.price);
|
||||
}
|
||||
|
||||
@@ -171,7 +170,7 @@ function buyButtonClickHandler(evt : any) {
|
||||
evt.preventDefault();
|
||||
var id : string | number = product.selectedVariant.id;
|
||||
var quantity : number;
|
||||
var cartLineItem : ShopifyBuy.Shopify.CartLineItemModel = findCartItemByVariantId(id);
|
||||
var cartLineItem : ShopifyBuy.LineItem = findCartItemByVariantId(id);
|
||||
|
||||
quantity = cartLineItem ? cartLineItem.quantity + 1 : 1;
|
||||
|
||||
@@ -183,11 +182,11 @@ function buyButtonClickHandler(evt : any) {
|
||||
/* Update product variant quantity in cart
|
||||
============================================================ */
|
||||
function updateQuantity(fn : Function, variantId : string | number) {
|
||||
var variant : ShopifyBuy.Shopify.ProductVariantModel = product.variants.filter(function (variant : ShopifyBuy.Shopify.ProductVariantModel) {
|
||||
var variant : ShopifyBuy.ProductVariant = product.variants.filter(function (variant : ShopifyBuy.ProductVariant) {
|
||||
return (variant.id === variantId);
|
||||
})[0];
|
||||
var quantity : number;
|
||||
var cartLineItem : ShopifyBuy.Shopify.CartLineItemModel = findCartItemByVariantId(variant.id);
|
||||
var cartLineItem : ShopifyBuy.LineItem = findCartItemByVariantId(variant.id);
|
||||
if (cartLineItem) {
|
||||
quantity = fn(cartLineItem.quantity);
|
||||
updateVariantInCart(cartLineItem, quantity);
|
||||
@@ -214,10 +213,10 @@ function incrementQuantity(variantId : string | number) {
|
||||
============================================================ */
|
||||
function fieldQuantityHandler(evt : any) {
|
||||
var variantId : string | number = parseInt($(this).closest('.cart-item').attr('data-variant-id'), 10);
|
||||
var variant : ShopifyBuy.Shopify.ProductVariantModel = product.variants.filter(function (variant : ShopifyBuy.Shopify.ProductVariantModel) {
|
||||
var variant : ShopifyBuy.ProductVariant = product.variants.filter(function (variant : ShopifyBuy.ProductVariant) {
|
||||
return (variant.id === variantId);
|
||||
})[0];
|
||||
var cartLineItem : ShopifyBuy.Shopify.CartLineItemModel = findCartItemByVariantId(variant.id);
|
||||
var cartLineItem : ShopifyBuy.LineItem = findCartItemByVariantId(variant.id);
|
||||
var quantity : number = evt.target.value;
|
||||
if (cartLineItem) {
|
||||
updateVariantInCart(cartLineItem, quantity);
|
||||
@@ -264,9 +263,9 @@ function findCartItemByVariantId(variantId : string | number) {
|
||||
|
||||
/* Determine action for variant adding/updating/removing
|
||||
============================================================ */
|
||||
function addOrUpdateVariant(variant : ShopifyBuy.Shopify.ProductVariantModel, quantity : number) {
|
||||
function addOrUpdateVariant(variant : ShopifyBuy.ProductVariant, quantity : number) {
|
||||
openCart();
|
||||
var cartLineItem : ShopifyBuy.Shopify.CartLineItemModel = findCartItemByVariantId(variant.id);
|
||||
var cartLineItem : ShopifyBuy.LineItem = findCartItemByVariantId(variant.id);
|
||||
|
||||
if (cartLineItem) {
|
||||
updateVariantInCart(cartLineItem, quantity);
|
||||
@@ -279,10 +278,14 @@ function addOrUpdateVariant(variant : ShopifyBuy.Shopify.ProductVariantModel, qu
|
||||
|
||||
/* Update details for item already in cart. Remove if necessary
|
||||
============================================================ */
|
||||
function updateVariantInCart(cartLineItem : ShopifyBuy.Shopify.CartLineItemModel, quantity : number) {
|
||||
function updateVariantInCart(cartLineItem : ShopifyBuy.LineItem, quantity : number) {
|
||||
var variantId : string | number = cartLineItem.variant_id;
|
||||
var cartLength : number = cart.lineItems.length;
|
||||
cart.updateLineItem(cartLineItem.id, quantity).then(function(updatedCart : ShopifyBuy.Shopify.CartModel) {
|
||||
let lineItemVariant: ShopifyBuy.AttributeInput = {
|
||||
id: cartLineItem.id,
|
||||
quantity
|
||||
};
|
||||
client.checkout.updateLineItem(cartLineItem.id, [lineItemVariant]).then(function(updatedCart : ShopifyBuy.Cart) {
|
||||
var $cartItem = $('.cart').find('.cart-item[data-variant-id="' + variantId + '"]');
|
||||
if (updatedCart.lineItems.length >= cartLength) {
|
||||
$cartItem.find('.cart-item__quantity').val(cartLineItem.quantity);
|
||||
@@ -306,11 +309,11 @@ function updateVariantInCart(cartLineItem : ShopifyBuy.Shopify.CartLineItemModel
|
||||
|
||||
/* Add 'quantity' amount of product 'variant' to cart
|
||||
============================================================ */
|
||||
function addVariantToCart(variant : ShopifyBuy.Shopify.ProductVariantModel, quantity : number) {
|
||||
function addVariantToCart(variant : ShopifyBuy.ProductVariant, quantity : number) {
|
||||
openCart();
|
||||
|
||||
cart.addVariants({ variant: variant, quantity: quantity }).then(function() {
|
||||
var cartItem : ShopifyBuy.Shopify.CartLineItemModel = cart.lineItems.filter(function (item : ShopifyBuy.Shopify.CartLineItemModel ) {
|
||||
client.checkout.addVariants({ variant: variant, quantity: quantity }).then(function() {
|
||||
var cartItem : ShopifyBuy.LineItem = cart.lineItems.filter(function (item : ShopifyBuy.LineItem ) {
|
||||
return (item.variant_id === variant.id);
|
||||
})[0];
|
||||
var $cartItem = renderCartItem(cartItem);
|
||||
@@ -331,7 +334,7 @@ function addVariantToCart(variant : ShopifyBuy.Shopify.ProductVariantModel, quan
|
||||
|
||||
/* Return required markup for single item rendering
|
||||
============================================================ */
|
||||
function renderCartItem(lineItem : ShopifyBuy.Shopify.CartLineItemModel) {
|
||||
function renderCartItem(lineItem : ShopifyBuy.LineItem) {
|
||||
var lineItemEmptyTemplate = $('#CartItemTemplate').html();
|
||||
var $lineItemTemplate = $(lineItemEmptyTemplate);
|
||||
var itemImage = lineItem.image.src;
|
||||
@@ -400,6 +403,6 @@ function updateCartTabButton() {
|
||||
|
||||
/* Set previously focused item for escape handler
|
||||
============================================================ */
|
||||
function setPreviousFocusItem(item : ShopifyBuy.Shopify.CartLineItemModel) {
|
||||
function setPreviousFocusItem(item : ShopifyBuy.LineItem) {
|
||||
previousFocusItem = item;
|
||||
}
|
||||
|
||||
Vendored
+10
-5
@@ -1,6 +1,11 @@
|
||||
// Type definitions for socket.io 1.4.4
|
||||
// Type definitions for socket.io 1.4.5
|
||||
// Project: http://socket.io/
|
||||
// Definitions by: PROGRE <https://github.com/progre>, Damian Connolly <https://github.com/divillysausages>, Florent Poujol <https://github.com/florentpoujol>, KentarouTakeda <https://github.com/KentarouTakeda>, Alexey Snigirev <https://github.com/gigi>
|
||||
// Definitions by: PROGRE <https://github.com/progre>
|
||||
// Damian Connolly <https://github.com/divillysausages>
|
||||
// Florent Poujol <https://github.com/florentpoujol>
|
||||
// KentarouTakeda <https://github.com/KentarouTakeda>
|
||||
// Alexey Snigirev <https://github.com/gigi>
|
||||
// Ezinwa Okpoechi <https://github.com/BrainMaestro>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
///<reference types="node" />
|
||||
@@ -127,7 +132,7 @@ declare namespace SocketIO {
|
||||
* Gets the allowed origins for requests
|
||||
* @default "*:*"
|
||||
*/
|
||||
origins(): string;
|
||||
origins(): string|string[];
|
||||
|
||||
/**
|
||||
* Sets the allowed origins for requests
|
||||
@@ -135,7 +140,7 @@ declare namespace SocketIO {
|
||||
* @default "*:*"
|
||||
* return This Server
|
||||
*/
|
||||
origins( v: string ): Server;
|
||||
origins( v: string|string[] ): Server;
|
||||
|
||||
/**
|
||||
* Attaches socket.io to a server
|
||||
@@ -299,7 +304,7 @@ declare namespace SocketIO {
|
||||
* Accepted origins
|
||||
* @default '*:*'
|
||||
*/
|
||||
origins?: string;
|
||||
origins?: string|string[];
|
||||
|
||||
/**
|
||||
* How many milliseconds without a pong packed to consider the connection closed (engine.io)
|
||||
|
||||
Vendored
+7
-6
@@ -9,6 +9,7 @@
|
||||
// Kensuke Hoshikawa <https://github.com/starhoshi>
|
||||
// Thomas Bruun <https://github.com/bruun>
|
||||
// Gal Talmor <https://github.com/galtalmor>
|
||||
// Hunter Tunnicliff <https://github.com/htunnicliff>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
@@ -738,7 +739,7 @@ declare namespace Stripe {
|
||||
* charge if a partial refund was issued), positive integer or zero.
|
||||
*/
|
||||
amount_refunded: number;
|
||||
|
||||
|
||||
/**
|
||||
* ID of the Connect application that created the charge. [Expandable]
|
||||
*/
|
||||
@@ -1994,7 +1995,7 @@ declare namespace Stripe {
|
||||
/**
|
||||
* The subscription that this invoice was prepared for, if any.
|
||||
*/
|
||||
subscription: string;
|
||||
subscription: string | subscriptions.ISubscription;
|
||||
|
||||
/**
|
||||
* Only set for upcoming invoices that preview prorations. The time used to calculate prorations.
|
||||
@@ -2302,7 +2303,7 @@ declare namespace Stripe {
|
||||
/**
|
||||
* The subscription that this invoice item has been created for, if any.
|
||||
*/
|
||||
subscription: string;
|
||||
subscription: string | subscriptions.ISubscription;
|
||||
}
|
||||
|
||||
interface InvoiceItemCreationOptions extends IDataOptionsWithMetadata {
|
||||
@@ -2389,7 +2390,7 @@ declare namespace Stripe {
|
||||
* currency) representing the total amount for the order.
|
||||
*/
|
||||
amount: number;
|
||||
|
||||
|
||||
/**
|
||||
* A positive integer in the smallest currency unit (that is, 100 cents for $1.00, or 1 for ¥1, Japanese Yen being a 0-decimal
|
||||
* currency) representing the total amount returned for the order thus far.
|
||||
@@ -5033,7 +5034,7 @@ declare namespace Stripe {
|
||||
* String representing the object’s type. Objects of the same type share the same value.
|
||||
*/
|
||||
object: "review";
|
||||
|
||||
|
||||
/**
|
||||
* The charge associated with this review. [Expandable]
|
||||
*/
|
||||
@@ -5073,7 +5074,7 @@ declare namespace Stripe {
|
||||
*/
|
||||
name: string;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class StripeResource {
|
||||
constructor(stripe: Stripe, urlData: any);
|
||||
|
||||
@@ -1018,6 +1018,10 @@ stripe.invoices.list({ customer: "cus_5rfJKDJkuxzh5Q", limit: 3 }).then(function
|
||||
// asynchronously called
|
||||
});
|
||||
|
||||
stripe.invoices.retrieve("in_15fvyXEe31JkLCeQH7QbgZZb", { expand: ["subscription"] }).then(function (invoice) {
|
||||
invoice.subscription
|
||||
})
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region Invoice Items tests
|
||||
|
||||
Vendored
+33
-8
@@ -490,6 +490,7 @@ export class OrthographicCamera extends Camera {
|
||||
|
||||
zoom: number;
|
||||
view: {
|
||||
enabled: boolean,
|
||||
fullWidth: number,
|
||||
fullHeight: number,
|
||||
offsetX: number,
|
||||
@@ -579,6 +580,7 @@ export class PerspectiveCamera extends Camera {
|
||||
|
||||
focus: number;
|
||||
view: {
|
||||
enabled: boolean,
|
||||
fullWidth: number,
|
||||
fullHeight: number,
|
||||
offsetX: number,
|
||||
@@ -5865,13 +5867,18 @@ export let UniformsLib: {
|
||||
diffuse: IUniform;
|
||||
opacity: IUniform;
|
||||
map: IUniform;
|
||||
offsetRepeat: IUniform;
|
||||
specularMap: IUniform;
|
||||
uvTransform: IUniform;
|
||||
alphaMap: IUniform;
|
||||
};
|
||||
specularmap: {
|
||||
specularMap: IUniform;
|
||||
};
|
||||
envmap: {
|
||||
envMap: IUniform;
|
||||
flipEnvMap: IUniform;
|
||||
reflectivity: IUniform;
|
||||
refractionRation: IUniform;
|
||||
refractionRatio: IUniform;
|
||||
maxMipLevel: IUniform;
|
||||
};
|
||||
aomap: {
|
||||
aoMap: IUniform;
|
||||
@@ -5881,7 +5888,9 @@ export let UniformsLib: {
|
||||
lightMap: IUniform;
|
||||
lightMapIntensity: IUniform;
|
||||
};
|
||||
emissivemap: { emissiveMap: IUniform };
|
||||
emissivemap: {
|
||||
emissiveMap: IUniform
|
||||
};
|
||||
bumpmap: {
|
||||
bumpMap: IUniform;
|
||||
bumpScale: IUniform;
|
||||
@@ -5895,8 +5904,15 @@ export let UniformsLib: {
|
||||
displacementScale: IUniform;
|
||||
displacementBias: IUniform;
|
||||
};
|
||||
roughnessmap: { roughnessMap: IUniform };
|
||||
metalnessmap: { metalnessMap: IUniform };
|
||||
roughnessmap: {
|
||||
roughnessMap: IUniform
|
||||
};
|
||||
metalnessmap: {
|
||||
metalnessMap: IUniform
|
||||
};
|
||||
gradientmap: {
|
||||
gradientMap: IUniform
|
||||
};
|
||||
fog: {
|
||||
fogDensity: IUniform;
|
||||
fogNear: IUniform;
|
||||
@@ -5951,7 +5967,7 @@ export let UniformsLib: {
|
||||
};
|
||||
pointShadowMap: IUniform;
|
||||
pointShadowMatrix: IUniform;
|
||||
hemisphereLigtts: {
|
||||
hemisphereLights: {
|
||||
value: any[];
|
||||
properties: {
|
||||
direction: {};
|
||||
@@ -5959,6 +5975,15 @@ export let UniformsLib: {
|
||||
groundColor: {};
|
||||
};
|
||||
};
|
||||
rectAreaLights: {
|
||||
value: any[];
|
||||
properties: {
|
||||
color: {};
|
||||
position: {};
|
||||
width: {};
|
||||
height: {};
|
||||
}
|
||||
}
|
||||
};
|
||||
points: {
|
||||
diffuse: IUniform;
|
||||
@@ -5966,7 +5991,7 @@ export let UniformsLib: {
|
||||
size: IUniform;
|
||||
scale: IUniform;
|
||||
map: IUniform;
|
||||
offsetRepeat: IUniform;
|
||||
uvTransform: IUniform;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
import UniversalRouter, { Params } from ".";
|
||||
import { PathFunctionOptions } from 'path-to-regexp';
|
||||
|
||||
export interface GenerateUrlsOptions extends PathFunctionOptions {
|
||||
/**
|
||||
* Provide a function to stringifyQueryParams option to generate URL with query string from unknown route params.
|
||||
*/
|
||||
stringifyQueryParams?: (params: Params) => string;
|
||||
}
|
||||
|
||||
/**
|
||||
* In most web applications it's much simpler to just use a string for hyperlinks.
|
||||
*/
|
||||
export default function generateUrls(router: UniversalRouter, options?: GenerateUrlsOptions): (routeName: string, params?: Params) => string;
|
||||
Vendored
+90
-37
@@ -1,32 +1,65 @@
|
||||
// Type definitions for universal-router 1.2
|
||||
// Type definitions for universal-router 6.0
|
||||
// Project: https://github.com/kriasoft/universal-router
|
||||
// Definitions by: Jack Moore <https://github.com/jtmthf>
|
||||
// Tomek Łaziuk <https://github.com/tlaziuk>
|
||||
// Lodin <https://github.com/Lodin>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
import pathToRegexp = require('path-to-regexp');
|
||||
|
||||
/**
|
||||
* Params is a key/value object that represents extracted URL paramters. Each
|
||||
* URL parameter resolves to a string.
|
||||
* Params is a key/value object that represents extracted URL paramters.
|
||||
* Each URL parameter resolves to a string.
|
||||
*/
|
||||
export interface Params {
|
||||
[key: string]: string;
|
||||
[_: string]: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* Context represents the context that is passed as the second argument
|
||||
* passed to resolve. By default, it only is require to contain a path, but
|
||||
* can be extended by the way of generics.
|
||||
* In addition to a URL path string, any arbitrary data can be passed to the `router.resolve()` method, that becomes available inside action functions.
|
||||
*/
|
||||
export interface Context {
|
||||
path: string;
|
||||
[_: string]: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* ActionContext is similar to Context, with the exception of an added params
|
||||
* object. ActionContext is passed as the first argument to the action
|
||||
* function.
|
||||
*/
|
||||
export interface ActionContext extends Context {
|
||||
params: Params;
|
||||
export interface PathnameContext extends Context {
|
||||
/**
|
||||
* URL which was transmitted to `router.resolve()`.
|
||||
*/
|
||||
pathname: string;
|
||||
}
|
||||
|
||||
export interface ActionContext<C extends Context, R = any> extends PathnameContext {
|
||||
/**
|
||||
* Current router instance.
|
||||
*/
|
||||
router: UniversalRouter<C, R>;
|
||||
/**
|
||||
* Matched route object.
|
||||
*/
|
||||
route: Route;
|
||||
/**
|
||||
* Middleware style function which can continue resolving.
|
||||
*/
|
||||
next: (resume?: boolean, parent?: Route, prevResult?: any) => Promise<R>;
|
||||
/**
|
||||
* Base URL path relative to the path of the current route.
|
||||
*/
|
||||
baseUrl: string;
|
||||
/**
|
||||
* Matched path.
|
||||
*/
|
||||
path: string;
|
||||
/**
|
||||
* Matched path params.
|
||||
*/
|
||||
params: Params;
|
||||
/**
|
||||
* An array of keys found in the path, see `path-to-regexp` documentation for details.
|
||||
* @see https://github.com/pillarjs/path-to-regexp
|
||||
*/
|
||||
keys: pathToRegexp.Key[];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -34,35 +67,55 @@ export interface ActionContext extends Context {
|
||||
* action function, and optional children which are an array of Route.
|
||||
*
|
||||
* @template C User context that is made union with ActionContext.
|
||||
* @template R Result that every action function resolves to. If the action
|
||||
* returns a Promise, R can be the type the Promise resolves to.
|
||||
* @template R Result that every action function resolves to. If the action returns a Promise, R can be the type the Promise resolves to.
|
||||
*/
|
||||
export interface Route<C, R> {
|
||||
path: string;
|
||||
action(ctx: ActionContext & C, params: Params): R | Promise<R> | void;
|
||||
children?: Routes<C, R>;
|
||||
export interface Route<C extends Context = any, R = any> {
|
||||
path?: string | RegExp | Array<string | RegExp>;
|
||||
/**
|
||||
* unique string
|
||||
*/
|
||||
name?: string;
|
||||
/**
|
||||
* automatically filled by the router
|
||||
*/
|
||||
parent?: Route | null;
|
||||
/**
|
||||
* array of route objects
|
||||
*/
|
||||
children?: Routes<C, R> | null;
|
||||
/**
|
||||
* action method should return anything except `null` or `undefined` to be resolved by router
|
||||
* otherwise router will throw `Page not found` error if all matched routes returned nothing
|
||||
*/
|
||||
action?: (context: ActionContext<C, R> & C, params: Params) => R | Promise<R> | void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Routes in an array of type Route.
|
||||
* @template C User context that is made union with ActionContext.
|
||||
* @template R Result that every action function resolves to. If the action
|
||||
* returns a Promise, R can be the type the Promise resolves to.
|
||||
* @template R Result that every action function resolves to. If the action returns a Promise, R can be the type the Promise resolves to.
|
||||
*/
|
||||
export type Routes<C, R> = Array<Route<C, R>>;
|
||||
export type Routes<C extends Context = Context, R = any> = Array<Route<C, R>>;
|
||||
|
||||
export interface Options<C extends Context = Context, R = any> {
|
||||
context?: C;
|
||||
baseUrl?: string;
|
||||
resolveRoute?: (context: ActionContext<C, R> & C, params: Params) => any;
|
||||
errorHandler?: (error: Error & { context: C, code: number }) => any;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve function that is given routes and a path or context object.
|
||||
* Returns a Promise that resolves to result of the action function of the
|
||||
* matched route.
|
||||
*
|
||||
* @template C User context that is made union with Context.
|
||||
* @template R Result that every action function resolves to. If the action
|
||||
* returns a Promise, R can be the type the Promise resolves to.
|
||||
*
|
||||
* @param routes - Single route or array of routes.
|
||||
* @param pathOrContext - path to resolve or
|
||||
* context object that contains the path along with other data.
|
||||
* @return - Result of matched action function wrapped in a Promsie.
|
||||
* @see https://github.com/kriasoft/universal-router/blob/v6.0.0/docs/api.md
|
||||
*/
|
||||
export function resolve<C, R>(routes: Routes<C, R> | Route<C, R>, pathOrContext: string | String | Context & C): Promise<R>;
|
||||
export default class UniversalRouter<C extends Context = Context, R = any> {
|
||||
constructor(routes: Routes<C, R> | Route<C, R>, options?: Options<C>)
|
||||
/**
|
||||
* Traverses the list of routes in the order they are defined until it finds the first route that matches provided URL path string
|
||||
* and whose action function returns anything other than null or undefined.
|
||||
*/
|
||||
resolve(pathnameOrContext: string | PathnameContext): Promise<R>;
|
||||
/**
|
||||
* `path-to-regexp` function
|
||||
*/
|
||||
static pathToRegexp: typeof pathToRegexp;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"path-to-regexp": "^2.2.0"
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,7 @@
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"generateUrls.d.ts",
|
||||
"universal-router-tests.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"ban-types": false
|
||||
}
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
|
||||
@@ -1,95 +1,74 @@
|
||||
import { ActionContext, Params, resolve } from "universal-router";
|
||||
import UniversalRouter from "universal-router";
|
||||
import generateUrls from "universal-router/generateUrls";
|
||||
|
||||
// Test 1
|
||||
const routes1 = [
|
||||
{
|
||||
path: "/one",
|
||||
action: () => "Page One"
|
||||
},
|
||||
{
|
||||
path: "/two",
|
||||
action: () => "Page Two"
|
||||
}
|
||||
];
|
||||
new UniversalRouter(
|
||||
{
|
||||
path: '',
|
||||
name: 'root',
|
||||
action: (context) => context.path,
|
||||
},
|
||||
{
|
||||
context: {
|
||||
user: 'name',
|
||||
},
|
||||
baseUrl: '/base',
|
||||
errorHandler: (error) => {
|
||||
console.error(error);
|
||||
console.dir(error.context);
|
||||
return error.code === 404
|
||||
? '<h1>Page Not Found</h1>'
|
||||
: '<h1>Oops! Something went wrong</h1>';
|
||||
},
|
||||
},
|
||||
).resolve('/').then(console.log);
|
||||
|
||||
resolve(routes1, { path: "/one" })
|
||||
.then(result => console.log(result));
|
||||
new UniversalRouter({
|
||||
path: '/admin',
|
||||
children: [
|
||||
{
|
||||
path: '',
|
||||
action: () => 'Admin Page',
|
||||
},
|
||||
{
|
||||
path: '/users',
|
||||
children: [
|
||||
{
|
||||
path: '',
|
||||
action: () => 'User List',
|
||||
},
|
||||
{
|
||||
path: '/:username',
|
||||
action: () => 'User Profile',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
}).resolve({ pathname: '/admin/users/john' })
|
||||
.then(result => console.log(result));
|
||||
|
||||
// Test 2
|
||||
const routes2 = [
|
||||
{
|
||||
path: "/hello/:username",
|
||||
action: (context: ActionContext) => `Welcome, ${context.params["username"]}!`
|
||||
}
|
||||
];
|
||||
|
||||
resolve(routes2, { path: "/hello/john" })
|
||||
.then(result => console.log(result));
|
||||
|
||||
// Test 3
|
||||
const routes3 = [
|
||||
{
|
||||
path: "/hello/:username",
|
||||
action: (ctx: ActionContext, { username }: Params) => `Welcome, ${username}!`
|
||||
}
|
||||
];
|
||||
|
||||
resolve(routes3, { path: "/hello/john" })
|
||||
.then(result => console.log(result));
|
||||
|
||||
// Test 4
|
||||
const routes4 = [
|
||||
{
|
||||
path: "/hello",
|
||||
action: () => new Promise(resolve => {
|
||||
setTimeout(() => resolve("Welcome!"), 1000);
|
||||
})
|
||||
}
|
||||
];
|
||||
|
||||
resolve(routes4, { path: "/hello" })
|
||||
.then(result => console.log(result));
|
||||
|
||||
// Test 5
|
||||
const routes5 = [
|
||||
{
|
||||
path: "/hello/:username",
|
||||
async action(ctx: ActionContext, { username }: Params) {
|
||||
const waitable = async (name: string) => {
|
||||
console.log(`Welcome ${name}`);
|
||||
};
|
||||
await waitable(username);
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
resolve(routes5, { path: "/hello/john" })
|
||||
.then(result => console.log(result));
|
||||
|
||||
// Test 6
|
||||
const routes6 = [
|
||||
{ path: "/one", action: () => "<h1>Page One</h1>" },
|
||||
{ path: "/two", action: () => "<h1>Page Two</h1>" }
|
||||
];
|
||||
|
||||
resolve(routes6, { path: "/one" }).then(result => {
|
||||
document.body.innerHTML = result || "<h1>Not Found</h1>";
|
||||
new UniversalRouter({
|
||||
path: '', // optional
|
||||
async action({ next }) {
|
||||
console.log('middleware: start');
|
||||
const child = await next();
|
||||
console.log('middleware: end');
|
||||
return child;
|
||||
},
|
||||
children: [
|
||||
{
|
||||
path: '/hello',
|
||||
action() {
|
||||
console.log('route: return a result');
|
||||
return 'Hello, world!';
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
// Test 7
|
||||
interface Render {
|
||||
render: typeof render;
|
||||
}
|
||||
const url = generateUrls(new UniversalRouter([
|
||||
{ name: 'users', path: '/users' },
|
||||
{ name: 'user', path: '/user/:username' },
|
||||
], { baseUrl: '/base' }));
|
||||
|
||||
const routes7 = [
|
||||
{ path: "/one", action: ({ render: func }: ActionContext & Render) => func("<h1>Page One</h1>") },
|
||||
{ path: "/two", action: ({ render: func }: ActionContext & Render) => func("<h1>Page Two</h1>") }
|
||||
];
|
||||
|
||||
function render(component: string) {
|
||||
return new Promise(resolve => {
|
||||
console.log(`Rendering... ${component}`);
|
||||
});
|
||||
}
|
||||
|
||||
resolve<Render, Promise<{}>>(routes7, { path: "/one", render });
|
||||
url('users'); // => '/base/users'
|
||||
url('user', { username: 'john' }); // => '/base/user/john'
|
||||
|
||||
Vendored
+9
-6
@@ -12,6 +12,7 @@
|
||||
// Jason Cheatham <https://github.com/jason0x43>
|
||||
// Dennis George <https://github.com/dennispg>
|
||||
// Christophe Hurpeau <https://github.com/christophehurpeau>
|
||||
// ZSkycat <https://github.com/ZSkycat>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
@@ -349,14 +350,16 @@ declare namespace webpack {
|
||||
type ExternalsFunctionElement = (context: any, request: any, callback: (error: any, result: any) => void) => any;
|
||||
|
||||
interface Node {
|
||||
console?: boolean;
|
||||
console?: boolean | 'mock';
|
||||
process?: boolean | 'mock';
|
||||
global?: boolean;
|
||||
process?: boolean;
|
||||
Buffer?: boolean;
|
||||
__filename?: boolean | string;
|
||||
__dirname?: boolean | string;
|
||||
[nodeBuiltin: string]: boolean | string | undefined;
|
||||
__filename?: boolean | 'mock';
|
||||
__dirname?: boolean | 'mock';
|
||||
Buffer?: boolean | 'mock';
|
||||
setImmediate?: boolean | 'mock' | 'empty';
|
||||
[nodeBuiltin: string]: boolean | 'mock' | 'empty' | undefined;
|
||||
}
|
||||
|
||||
interface NewLoader {
|
||||
loader: string;
|
||||
options?: { [name: string]: any };
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user