mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-11-30 02:01:46 +00:00
Merge branch 'master' of https://github.com/sinziananicolae/DefinitelyTyped
This commit is contained in:
@@ -87,6 +87,7 @@ Primero, haz un [fork](https://guides.github.com/activities/forking/) en este re
|
||||
|
||||
* `cd types/my-package-to-edit`
|
||||
* Haz cambios. Recuerda editar las pruebas.
|
||||
Si realiza cambios importantes, no olvide [actualizar una versión principal](#quiero-actualizar-un-paquete-a-una-nueva-versión-principal).
|
||||
* También puede que quieras añadirte la sección "Definitions by" en el encabezado del paquete.
|
||||
- Esto hará que seas notificado (a través de tu nombre de usuario en GitHub) cada vez que alguien haga un pull request o issue sobre el paquete.
|
||||
- Haz esto añadiendo tu nombre al final de la línea, así como en `// Definitions by: Alice <https://github.com/alice>, Bob <https://github.com/bob>`.
|
||||
|
||||
@@ -87,6 +87,7 @@ First, [fork](https://guides.github.com/activities/forking/) this repository, in
|
||||
|
||||
* `cd types/my-package-to-edit`
|
||||
* Make changes. Remember to edit tests.
|
||||
If you make breaking changes, do not forget to [update a major version](#i-want-to-update-a-package-to-a-new-major-version).
|
||||
* You may also want to add yourself to "Definitions by" section of the package header.
|
||||
- This will cause you to be notified (via your GitHub username) whenever someone makes a pull request or issue about the package.
|
||||
- Do this by adding your name to the end of the line, as in `// Definitions by: Alice <https://github.com/alice>, Bob <https://github.com/bob>`.
|
||||
|
||||
@@ -660,6 +660,12 @@
|
||||
"sourceRepoURL": "https://github.com/ashtuchkin/iconv-lite",
|
||||
"asOfVersion": "0.4.14"
|
||||
},
|
||||
{
|
||||
"libraryName": "ids",
|
||||
"typingsPackageName": "ids",
|
||||
"sourceRepoURL": "https://github.com/bpmn-io/ids",
|
||||
"asOfVersion": "0.2.2"
|
||||
},
|
||||
{
|
||||
"libraryName": "immutability-helper",
|
||||
"typingsPackageName": "immutability-helper",
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"private": true,
|
||||
"name": "definitely-typed",
|
||||
"version": "0.0.1",
|
||||
"version": "0.0.2",
|
||||
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
@@ -21,9 +21,9 @@ type MyEntity = AFrame.Entity<{
|
||||
material: THREE.Material;
|
||||
sound: { pause(): void };
|
||||
}>;
|
||||
const camera = document.querySelector<MyEntity>('a-entity[camera]').components.camera;
|
||||
const material = document.querySelector<MyEntity>('a-entity[material]').components.material;
|
||||
document.querySelector<MyEntity>('a-entity[sound]').components.sound.pause();
|
||||
const camera = (document.querySelector('a-entity[camera]') as MyEntity).components.camera;
|
||||
const material = (document.querySelector('a-entity[material]') as MyEntity).components.material;
|
||||
(document.querySelector('a-entity[sound]') as MyEntity).components.sound.pause();
|
||||
|
||||
entity.getDOMAttribute('geometry').primitive;
|
||||
|
||||
@@ -38,21 +38,82 @@ entity.addEventListener('child-detached', (event) => {
|
||||
});
|
||||
|
||||
// Components
|
||||
const Component = AFRAME.registerComponent('test', {});
|
||||
|
||||
interface TestComponent extends AFrame.Component {
|
||||
multiply: (f: number) => number;
|
||||
|
||||
data: {
|
||||
myProperty: any[],
|
||||
string: string,
|
||||
num: number
|
||||
};
|
||||
|
||||
system: TestSystem;
|
||||
}
|
||||
|
||||
const Component = AFRAME.registerComponent<TestComponent>('test-component', {
|
||||
schema: {
|
||||
myProperty: {
|
||||
default: [],
|
||||
parse() { return [true]; },
|
||||
},
|
||||
string: { type: 'string' },
|
||||
num: 0
|
||||
},
|
||||
init() {
|
||||
this.data.num = 0;
|
||||
},
|
||||
update() {},
|
||||
tick() {},
|
||||
remove() {},
|
||||
pause() {},
|
||||
play() {},
|
||||
|
||||
multiply(this: TestComponent, f: number) {
|
||||
// Reference to system because both were registered with the same name.
|
||||
return f * this.data.num * this.system.data.counter;
|
||||
}
|
||||
});
|
||||
|
||||
// Scene
|
||||
const scene = document.querySelector('a-scene');
|
||||
scene.hasLoaded;
|
||||
|
||||
// System
|
||||
const system = scene.systems['systemName'];
|
||||
|
||||
interface TestSystem extends AFrame.System {
|
||||
data: {
|
||||
counter: number;
|
||||
};
|
||||
}
|
||||
|
||||
const testSystem: AFrame.SystemDefinition<TestSystem> = {
|
||||
schema: {
|
||||
counter: 0
|
||||
},
|
||||
|
||||
init() {
|
||||
this.data.counter = 1;
|
||||
}
|
||||
};
|
||||
|
||||
AFRAME.registerSystem('test-component', testSystem);
|
||||
|
||||
// Register Custom Geometry
|
||||
AFRAME.registerGeometry('a-test-geometry', {
|
||||
|
||||
interface TestGeometry extends AFrame.Geometry {
|
||||
schema: AFrame.MultiPropertySchema<{
|
||||
groupIndex: number;
|
||||
}>;
|
||||
}
|
||||
|
||||
AFRAME.registerGeometry<TestGeometry>('a-test-geometry', {
|
||||
schema: {
|
||||
groupIndex: { default: 0 }
|
||||
},
|
||||
init(data) {
|
||||
this.geometry = new THREE.Geometry();
|
||||
const temp = data.groupIndex;
|
||||
temp;
|
||||
}
|
||||
});
|
||||
|
||||
Vendored
+93
-78
@@ -2,6 +2,7 @@
|
||||
// Project: https://aframe.io/
|
||||
// Definitions by: Paul Shannon <https://github.com/devpaul>
|
||||
// Roberto Ritger <https://github.com/bertoritger>
|
||||
// Trygve Wastvedt <https://github.com/twastvedt>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
@@ -19,7 +20,7 @@ declare var hasNativeWebVRImplementation: boolean;
|
||||
interface Document {
|
||||
createElement(tagName: string): AFrame.Entity;
|
||||
querySelector(selectors: 'a-scene'): AFrame.Scene;
|
||||
querySelector<T extends AFrame.Entity<any>>(selectors: string): T;
|
||||
querySelector(selectors: string): AFrame.Entity<any>;
|
||||
querySelectorAll(selectors: string): NodeListOf<AFrame.Entity<any> | Element>;
|
||||
}
|
||||
|
||||
@@ -36,15 +37,15 @@ declare namespace AFrame {
|
||||
components: { [ key: string ]: ComponentDescriptor };
|
||||
geometries: { [ key: string ]: GeometryDescriptor };
|
||||
primitives: { [ key: string ]: Entity };
|
||||
registerComponent(name: string, component: ComponentDefinition): ComponentConstructor;
|
||||
registerComponent<T extends Component>(name: string, component: ComponentDefinition<T>): ComponentConstructor<T>;
|
||||
registerElement(name: string, element: ANode): void;
|
||||
registerGeometry(name: string, geometry: GeometryDefinition): Geometry;
|
||||
registerGeometry<T extends Geometry>(name: string, geometry: GeometryDefinition<T>): GeometryConstructor<T>;
|
||||
registerPrimitive(name: string, primitive: PrimitiveDefinition): void;
|
||||
registerShader(name: string, shader: any): void;
|
||||
registerSystem(name: string, definition: SystemDefinition): void;
|
||||
registerShader<T extends Shader>(name: string, shader: T): ShaderConstructor<T>;
|
||||
registerSystem<T extends System>(name: string, definition: SystemDefinition<T>): SystemConstructor<T>;
|
||||
schema: SchemaUtils;
|
||||
shaders: { [ key: string ]: ShaderDescriptor };
|
||||
systems: { [key: string]: System };
|
||||
systems: { [key: string]: SystemConstructor };
|
||||
THREE: typeof THREE;
|
||||
TWEEN: typeof TWEEN;
|
||||
utils: Utils;
|
||||
@@ -89,54 +90,39 @@ declare namespace AFrame {
|
||||
tick(): void;
|
||||
}
|
||||
|
||||
interface Component {
|
||||
interface Component<T extends { [key: string]: any } = any, S extends System = System> {
|
||||
attrName?: string;
|
||||
data?: any;
|
||||
data: T;
|
||||
dependencies?: string[];
|
||||
el: Entity;
|
||||
id: string;
|
||||
multiple?: boolean;
|
||||
name: string;
|
||||
schema: Schema;
|
||||
schema: Schema<T>;
|
||||
system: S | undefined;
|
||||
|
||||
init(data?: any): void;
|
||||
pause(): void;
|
||||
play(): void;
|
||||
remove(): void;
|
||||
tick?(time: number, timeDelta: number): void;
|
||||
update(oldData: any): void;
|
||||
updateSchema?(): void;
|
||||
init(this: this, data?: T): void;
|
||||
pause(this: this): void;
|
||||
play(this: this): void;
|
||||
remove(this: this): void;
|
||||
tick?(this: this, time: number, timeDelta: number): void;
|
||||
update(this: this, oldData: T): void;
|
||||
updateSchema?(this: this): void;
|
||||
|
||||
extendSchema(update: Schema): void;
|
||||
flushToDOM(): void;
|
||||
extendSchema(this: this, update: Schema): void;
|
||||
flushToDOM(this: this): void;
|
||||
}
|
||||
|
||||
interface ComponentConstructor {
|
||||
new (el: Entity, name: string, id: string): Component;
|
||||
interface ComponentConstructor<T extends Component> {
|
||||
new (el: Entity, attrValue: string, id: string): T;
|
||||
}
|
||||
|
||||
interface ComponentDefinition {
|
||||
dependencies?: string[];
|
||||
el?: Entity;
|
||||
id?: string;
|
||||
multiple?: boolean;
|
||||
schema?: Schema;
|
||||
type ComponentDefinition<T extends Component = Component> = Partial<T>;
|
||||
|
||||
init?(data?: any): void;
|
||||
pause?(): void;
|
||||
play?(): void;
|
||||
remove?(): void;
|
||||
tick?(time: number, timeDelta: number): void;
|
||||
update?(oldData: any): void;
|
||||
updateSchema?(): void;
|
||||
|
||||
[ key: string ]: any;
|
||||
}
|
||||
|
||||
interface ComponentDescriptor {
|
||||
Component: Component;
|
||||
dependencies: string[] | null;
|
||||
multiple: boolean | null;
|
||||
interface ComponentDescriptor<T extends Component = Component> {
|
||||
Component: ComponentConstructor<T>;
|
||||
dependencies: string[] | undefined;
|
||||
multiple: boolean | undefined;
|
||||
|
||||
// internal APIs2
|
||||
// parse
|
||||
@@ -144,7 +130,6 @@ declare namespace AFrame {
|
||||
// schema
|
||||
// stringify
|
||||
// type
|
||||
[ key: string ]: any;
|
||||
}
|
||||
|
||||
interface Coordinate {
|
||||
@@ -153,8 +138,14 @@ declare namespace AFrame {
|
||||
z: number;
|
||||
}
|
||||
|
||||
interface DefaultComponents {
|
||||
position: Component<Coordinate>;
|
||||
rotation: Component<Coordinate>;
|
||||
scale: Component<Coordinate>;
|
||||
}
|
||||
|
||||
interface Entity<C = ObjectMap<Component>> extends ANode {
|
||||
components: C;
|
||||
components: C & DefaultComponents;
|
||||
isPlaying: boolean;
|
||||
object3D: THREE.Object3D;
|
||||
object3DMap: ObjectMap<THREE.Object3D>;
|
||||
@@ -165,8 +156,8 @@ declare namespace AFrame {
|
||||
/**
|
||||
* @deprecated since 0.4.0
|
||||
*/
|
||||
getComputedAttribute<T = Component>(attr: string): T;
|
||||
getDOMAttribute<T = any>(attr: string): T;
|
||||
getComputedAttribute(attr: string): Component;
|
||||
getDOMAttribute(attr: string): any;
|
||||
getObject3D(type: string): THREE.Object3D;
|
||||
getOrCreateObject3D(type: string, construct: any): THREE.Object3D;
|
||||
is(stateName: string): boolean;
|
||||
@@ -179,7 +170,6 @@ declare namespace AFrame {
|
||||
|
||||
// getAttribute specific usages
|
||||
getAttribute(type: string): any;
|
||||
getAttribute<T = Component>(attr: string): T;
|
||||
getAttribute(type: 'position' | 'rotation' | 'scale'): Coordinate;
|
||||
|
||||
// setAttribute specific usages
|
||||
@@ -192,12 +182,18 @@ declare namespace AFrame {
|
||||
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
}
|
||||
|
||||
type DetailEvent<D> = Event & { detail: D };
|
||||
type DetailEvent<D> = Event & {
|
||||
detail: D;
|
||||
target: EventTarget & Entity;
|
||||
};
|
||||
|
||||
interface EntityEventMap {
|
||||
'child-attached': DetailEvent<{ el: Element | Entity }>;
|
||||
'child-detached': DetailEvent<{ el: Element | Entity }>;
|
||||
'componentchanged': DetailEvent<{ name: string }>;
|
||||
'componentchanged': DetailEvent<{
|
||||
name: string,
|
||||
id: string
|
||||
}>;
|
||||
'componentremoved': DetailEvent<{
|
||||
name: string,
|
||||
id: string,
|
||||
@@ -215,23 +211,28 @@ declare namespace AFrame {
|
||||
interface Geometry {
|
||||
name: string;
|
||||
geometry: THREE.Geometry;
|
||||
schema: Schema;
|
||||
update(data: object): void;
|
||||
[ key: string ]: any;
|
||||
schema: Schema<any>;
|
||||
|
||||
init(this: this, data: { [P in keyof this['schema']]: any }): void;
|
||||
// Would like the above to be:
|
||||
// init?(this: this, data?: { [P in keyof T['schema']]: T['schema'][P]['default'] } ): void;
|
||||
// I think this is prevented by the following issue: https://github.com/Microsoft/TypeScript/issues/21760.
|
||||
}
|
||||
|
||||
interface GeometryDefinition extends ComponentDefinition {
|
||||
geometry?: THREE.Geometry;
|
||||
interface GeometryConstructor<T extends Geometry> {
|
||||
new (): T;
|
||||
}
|
||||
|
||||
interface GeometryDescriptor {
|
||||
Geometry: Geometry;
|
||||
type GeometryDefinition<T extends Geometry = Geometry> = Partial<T>;
|
||||
|
||||
interface GeometryDescriptor<T extends Geometry = Geometry> {
|
||||
Geometry: GeometryConstructor<T>;
|
||||
schema: Schema;
|
||||
}
|
||||
|
||||
interface MultiPropertySchema {
|
||||
[ key: string ]: SinglePropertySchema<any>;
|
||||
}
|
||||
type MultiPropertySchema<T extends { [key: string ]: any }> = {
|
||||
[P in keyof T]: SinglePropertySchema<T[P]> | T[P];
|
||||
};
|
||||
|
||||
interface PrimitiveDefinition {
|
||||
defaultComponents?: any; // TODO cleanup type
|
||||
@@ -240,8 +241,9 @@ declare namespace AFrame {
|
||||
transforms?: any; // TODO cleanup type
|
||||
}
|
||||
|
||||
type PropertyTypes = 'array' | 'boolean' | 'color' | 'int' | 'number' | 'selector' |
|
||||
'selectorAll' | 'src' | 'string' | 'vec2' | 'vec3' | 'vec4';
|
||||
type PropertyTypes = 'array' | 'asset' | 'audio' | 'boolean' | 'color' |
|
||||
'int' | 'map' | 'model' | 'number' | 'selector' | 'selectorAll' |
|
||||
'string' | 'vec2' | 'vec3' | 'vec4';
|
||||
|
||||
type SceneEvents = 'enter-vr' | 'exit-vr' | 'loaded' | 'renderstart';
|
||||
|
||||
@@ -265,7 +267,7 @@ declare namespace AFrame {
|
||||
addEventListener(type: SceneEvents, listener: EventListener, useCapture?: boolean): void;
|
||||
}
|
||||
|
||||
type Schema = SinglePropertySchema<any> | MultiPropertySchema;
|
||||
type Schema<T = { [key: string]: any }> = SinglePropertySchema<T> | MultiPropertySchema<T>;
|
||||
|
||||
interface SchemaUtils {
|
||||
isSingleProperty(schema: Schema): boolean;
|
||||
@@ -274,11 +276,25 @@ declare namespace AFrame {
|
||||
|
||||
interface Shader {
|
||||
name: string;
|
||||
schema: Schema;
|
||||
data: { [key: string]: any };
|
||||
schema: Schema<this['data']>;
|
||||
material: THREE.Material;
|
||||
vertexShader: string;
|
||||
fragmentShader: string;
|
||||
|
||||
init(this: this, data?: this['data']): void;
|
||||
tick?(this: this, time: number, timeDelta: number): void;
|
||||
update(this: this, oldData: this['data']): void;
|
||||
}
|
||||
|
||||
interface ShaderDescriptor {
|
||||
Shader: Shader;
|
||||
interface ShaderConstructor<T extends Shader> {
|
||||
new (): T;
|
||||
}
|
||||
|
||||
type ShaderDefinition<T extends Shader = Shader> = Partial<T>;
|
||||
|
||||
interface ShaderDescriptor<T extends Shader = Shader> {
|
||||
Shader: ShaderConstructor<T>;
|
||||
schema: Schema;
|
||||
}
|
||||
|
||||
@@ -287,27 +303,23 @@ declare namespace AFrame {
|
||||
'default'?: T;
|
||||
parse?(value: string): T;
|
||||
stringify?(value: T): string;
|
||||
[ key: string ]: any;
|
||||
}
|
||||
|
||||
interface System {
|
||||
data: any;
|
||||
schema: Schema;
|
||||
init(): void;
|
||||
pause(): void;
|
||||
play(): void;
|
||||
tick?(): void;
|
||||
data: { [key: string]: any };
|
||||
schema: Schema<this['data']>;
|
||||
init(this: this): void;
|
||||
pause(this: this): void;
|
||||
play(this: this): void;
|
||||
tick?(this: this, t: number, dt: number): void;
|
||||
}
|
||||
|
||||
interface SystemDefinition {
|
||||
schema?: Schema;
|
||||
init?(): void;
|
||||
pause?(): void;
|
||||
play?(): void;
|
||||
tick?(): void;
|
||||
[ key: string ]: any;
|
||||
interface SystemConstructor<T extends System = System> {
|
||||
new (scene: Scene): T;
|
||||
}
|
||||
|
||||
type SystemDefinition<T extends System = System> = Partial<T>;
|
||||
|
||||
interface Utils {
|
||||
coordinates: {
|
||||
isCoordinate(value: string): boolean;
|
||||
@@ -326,5 +338,8 @@ declare namespace AFrame {
|
||||
diff(a: object, b: object): object;
|
||||
extend(target: object, ... source: object[]): object;
|
||||
extendDeep(target: object, ... source: object[]): object;
|
||||
|
||||
throttle(tickFunction: () => void, minimumInterval: number, optionalContext?: {}): (t: number, dt: number) => void;
|
||||
throttleTick(tickFunction: (t: number, dt: number) => void, minimumInterval: number, optionalContext?: {}): (t: number, dt: number) => void;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"no-unnecessary-generics": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,4 +150,17 @@ let _algoliaQueryParameters: QueryParameters = {
|
||||
let index: Index = algoliasearch('', '').initIndex('');
|
||||
|
||||
let search = index.search({ query: '' });
|
||||
|
||||
index.search({ query: '' }, (err, res) => {});
|
||||
|
||||
// partialUpdateObject
|
||||
index.partialUpdateObject({}, () => {});
|
||||
index.partialUpdateObject({}, false, () => {});
|
||||
index.partialUpdateObject({}).then(() => {});
|
||||
index.partialUpdateObject({}, false).then(() => {});
|
||||
|
||||
// partialUpdateObjects
|
||||
index.partialUpdateObjects([{}], () => {});
|
||||
index.partialUpdateObjects([{}], false, () => {});
|
||||
index.partialUpdateObjects([{}]).then(() => {});
|
||||
index.partialUpdateObjects([{}], false).then(() => {});
|
||||
|
||||
Vendored
+5
-4
@@ -286,14 +286,13 @@ declare namespace algoliasearch {
|
||||
* https://github.com/algolia/algoliasearch-client-js#update-objects---saveobjects
|
||||
*/
|
||||
partialUpdateObject(object: {}, cb: (err: Error, res: Task) => void): void;
|
||||
partialUpdateObject(object: {}, createIfNotExists: boolean, cb: (err: Error, res: Task) => void): void;
|
||||
/**
|
||||
* Update parameters of a list of objects
|
||||
* https://github.com/algolia/algoliasearch-client-js#update-objects---saveobjects
|
||||
*/
|
||||
partialUpdateObjects(
|
||||
objects: {}[],
|
||||
cb: (err: Error, res: Task) => void
|
||||
): void;
|
||||
partialUpdateObjects(objects: {}[], cb: (err: Error, res: Task) => void): void;
|
||||
partialUpdateObjects(objects: {}[], createIfNotExists: boolean, cb: (err: Error, res: Task) => void): void;
|
||||
/**
|
||||
* Delete a specific object
|
||||
* https://github.com/algolia/algoliasearch-client-js#delete-objects---deleteobjects
|
||||
@@ -531,11 +530,13 @@ declare namespace algoliasearch {
|
||||
* https://github.com/algolia/algoliasearch-client-js#update-objects---saveobjects
|
||||
*/
|
||||
partialUpdateObject(object: {}): Promise<Task>;
|
||||
partialUpdateObject(object: {}, createIfNotExists: boolean): Promise<Task>;
|
||||
/**
|
||||
* Update parameters of a list of objects
|
||||
* https://github.com/algolia/algoliasearch-client-js#update-objects---saveobjects
|
||||
*/
|
||||
partialUpdateObjects(objects: {}[]): Promise<Task>;
|
||||
partialUpdateObjects(objects: {}[], createIfNotExists?: boolean): Promise<Task>;
|
||||
/**
|
||||
* Delete a specific object
|
||||
* https://github.com/algolia/algoliasearch-client-js#delete-objects---deleteobjects
|
||||
|
||||
+577
@@ -0,0 +1,577 @@
|
||||
// Type definitions for amazon-cognito-auth-js 1.2
|
||||
// Project: https://github.com/aws/amazon-cognito-auth-js
|
||||
// Definitions by: Scott Escue <https://github.com/scottescue>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
/*
|
||||
* Create global variable to provide access to types when used without module
|
||||
* loading.
|
||||
*/
|
||||
export as namespace AmazonCognitoIdentity;
|
||||
|
||||
// Stubs the XDomainRequest built-in from older IE browsers, does not follow the project's interface naming convention
|
||||
export interface XDomainRequest {
|
||||
readonly responseText: string;
|
||||
timeout: number;
|
||||
onprogress: () => void;
|
||||
ontimeout: () => void;
|
||||
onerror: () => void;
|
||||
onload: () => void;
|
||||
|
||||
open(method: string, url: string): void;
|
||||
send(data: string): void;
|
||||
abort(): void;
|
||||
}
|
||||
|
||||
export interface CognitoSessionData {
|
||||
/**
|
||||
* The session's Id token.
|
||||
*/
|
||||
IdToken?: CognitoIdToken;
|
||||
|
||||
/**
|
||||
* The session's refresh token.
|
||||
*/
|
||||
RefreshToken?: CognitoRefreshToken;
|
||||
|
||||
/**
|
||||
* The session's access token.
|
||||
*/
|
||||
AccessToken?: CognitoAccessToken;
|
||||
|
||||
/**
|
||||
* The session's token scopes.
|
||||
*/
|
||||
TokenScopes?: CognitoTokenScopes;
|
||||
|
||||
/**
|
||||
* The session's state.
|
||||
*/
|
||||
State?: string;
|
||||
}
|
||||
|
||||
export interface CognitoAuthOptions {
|
||||
/**
|
||||
* Required: User pool application client id.
|
||||
*/
|
||||
ClientId: string;
|
||||
|
||||
/**
|
||||
* Required: The application/user-pools Cognito web hostname,this is set at the Cognito console.
|
||||
*/
|
||||
AppWebDomain: string;
|
||||
|
||||
/**
|
||||
* Optional: The token scopes
|
||||
*/
|
||||
TokenScopesArray?: ReadonlyArray<string>;
|
||||
|
||||
/**
|
||||
* Required: Required: The redirect Uri, which will be launched after authentication as signed in.
|
||||
*/
|
||||
RedirectUriSignIn: string;
|
||||
|
||||
/**
|
||||
* Required: The redirect Uri, which will be launched when signed out.
|
||||
*/
|
||||
RedirectUriSignOut: string;
|
||||
|
||||
/**
|
||||
* Optional: Pre-selected identity provider (this allows to automatically trigger social provider authentication flow).
|
||||
*/
|
||||
IdentityProvider?: string;
|
||||
|
||||
/**
|
||||
* Optional: UserPoolId for the configured cognito userPool.
|
||||
*/
|
||||
UserPoolId?: string;
|
||||
|
||||
/**
|
||||
* Optional: boolean flag indicating if the data collection is enabled to support cognito advanced security features. By default, this flag is set to true.
|
||||
*/
|
||||
AdvancedSecurityDataCollectionFlag?: boolean;
|
||||
}
|
||||
|
||||
export interface CognitoAuthUserHandler {
|
||||
onSuccess: (authSession: CognitoAuthSession) => void;
|
||||
onFailure: (err: any) => void;
|
||||
}
|
||||
|
||||
export interface CognitoConstants {
|
||||
DOMAIN_SCHEME: string;
|
||||
DOMAIN_PATH_SIGNIN: string;
|
||||
DOMAIN_PATH_TOKEN: string;
|
||||
DOMAIN_PATH_SIGNOUT: string;
|
||||
DOMAIN_QUERY_PARAM_REDIRECT_URI: string;
|
||||
DOMAIN_QUERY_PARAM_SIGNOUT_URI: string;
|
||||
DOMAIN_QUERY_PARAM_RESPONSE_TYPE: string;
|
||||
DOMAIN_QUERY_PARAM_IDENTITY_PROVIDER: string;
|
||||
DOMAIN_QUERY_PARAM_USERCONTEXTDATA: string;
|
||||
CLIENT_ID: string;
|
||||
STATE: string;
|
||||
SCOPE: string;
|
||||
TOKEN: string;
|
||||
CODE: string;
|
||||
POST: string;
|
||||
PARAMETERERROR: string;
|
||||
SCOPETYPEERROR: string;
|
||||
QUESTIONMARK: string;
|
||||
POUNDSIGN: string;
|
||||
COLONDOUBLESLASH: string;
|
||||
SLASH: string;
|
||||
AMPERSAND: string;
|
||||
EQUALSIGN: string;
|
||||
SPACE: string;
|
||||
CONTENTTYPE: string;
|
||||
CONTENTTYPEVALUE: string;
|
||||
AUTHORIZATIONCODE: string;
|
||||
IDTOKEN: string;
|
||||
ACCESSTOKEN: string;
|
||||
REFRESHTOKEN: string;
|
||||
ERROR: string;
|
||||
ERROR_DESCRIPTION: string;
|
||||
STRINGTYPE: string;
|
||||
STATELENGTH: number;
|
||||
STATEORIGINSTRING: string;
|
||||
WITHCREDENTIALS: string;
|
||||
UNDEFINED: string;
|
||||
SELF: string;
|
||||
HOSTNAMEREGEX: RegExp;
|
||||
QUERYPARAMETERREGEX1: RegExp;
|
||||
QUERYPARAMETERREGEX2: RegExp;
|
||||
HEADER: { 'Content-Type': string };
|
||||
}
|
||||
|
||||
export class CognitoIdToken {
|
||||
/**
|
||||
* Constructs a new CognitoIdToken object
|
||||
* @param IdToken The JWT Id token
|
||||
*/
|
||||
constructor(IdToken: string);
|
||||
|
||||
/**
|
||||
* @returns the record's token.
|
||||
*/
|
||||
getJwtToken(): string;
|
||||
|
||||
/**
|
||||
* Sets new value for id token.
|
||||
* @param idToken The JWT Id token
|
||||
*/
|
||||
setJwtToken(idToken: string): void;
|
||||
|
||||
/**
|
||||
* @returns the token's expiration (exp member).
|
||||
*/
|
||||
getExpiration(): number;
|
||||
|
||||
/**
|
||||
* @returns the token's payload.
|
||||
*/
|
||||
decodePayload(): object;
|
||||
}
|
||||
|
||||
export class CognitoRefreshToken {
|
||||
/**
|
||||
* Constructs a new CognitoRefreshToken object
|
||||
* @param RefreshToken The JWT refresh token.
|
||||
*/
|
||||
constructor(RefreshToken: string);
|
||||
|
||||
/**
|
||||
* @returns the record's token.
|
||||
*/
|
||||
getToken(): string;
|
||||
|
||||
/**
|
||||
* Sets new value for refresh token.
|
||||
* @param refreshToken The JWT refresh token.
|
||||
*/
|
||||
setToken(refreshToken: string): void;
|
||||
}
|
||||
|
||||
export class CognitoAccessToken {
|
||||
/**
|
||||
* Constructs a new CognitoAccessToken object
|
||||
* @param AccessToken The JWT access token.
|
||||
*/
|
||||
constructor(AccessToken: string);
|
||||
|
||||
/**
|
||||
* @returns the record's token.
|
||||
*/
|
||||
getJwtToken(): string;
|
||||
|
||||
/**
|
||||
* Sets new value for access token.
|
||||
* @param accessToken The JWT access token.
|
||||
*/
|
||||
setJwtToken(accessToken: string): void;
|
||||
|
||||
/**
|
||||
* @returns the token's expiration (exp member).
|
||||
*/
|
||||
getExpiration(): number;
|
||||
|
||||
/**
|
||||
* @returns the username from payload.
|
||||
*/
|
||||
getUsername(): string;
|
||||
|
||||
/**
|
||||
* @returns the token's payload.
|
||||
*/
|
||||
decodePayload(): object;
|
||||
}
|
||||
|
||||
export class CognitoTokenScopes {
|
||||
/**
|
||||
* Constructs a new CognitoTokenScopes object
|
||||
* @param TokenScopesArray The token scopes
|
||||
*/
|
||||
constructor(TokenScopesArray: ReadonlyArray<string>);
|
||||
|
||||
/**
|
||||
* @returns the token scopes.
|
||||
*/
|
||||
getScopes(): string[];
|
||||
|
||||
/**
|
||||
* Sets new value for token scopes.
|
||||
* @param tokenScopes The token scopes
|
||||
*/
|
||||
setTokenScopes(tokenScopes: ReadonlyArray<string>): void;
|
||||
}
|
||||
|
||||
export class CognitoAuthSession {
|
||||
/**
|
||||
* Constructs a new CognitoUserSession object
|
||||
* @param sessionData The session's tokens, scopes, and state.
|
||||
*/
|
||||
constructor(sessionData: CognitoSessionData);
|
||||
|
||||
/**
|
||||
* @returns the session's Id token
|
||||
*/
|
||||
getIdToken(): CognitoIdToken;
|
||||
|
||||
/**
|
||||
* Set a new Id token
|
||||
* @param IdToken The session's Id token.
|
||||
*/
|
||||
setIdToken(IdToken: CognitoIdToken): void;
|
||||
|
||||
/**
|
||||
* @returns the session's refresh token
|
||||
*/
|
||||
getRefreshToken(): CognitoRefreshToken;
|
||||
|
||||
/**
|
||||
* Set a new Refresh token
|
||||
* @param RefreshToken The session's refresh token.
|
||||
*/
|
||||
setRefreshToken(RefreshToken: CognitoRefreshToken): void;
|
||||
|
||||
/**
|
||||
* @returns the session's access token
|
||||
*/
|
||||
getAccessToken(): CognitoAccessToken;
|
||||
|
||||
/**
|
||||
* Set a new Access token
|
||||
* @param AccessToken The session's access token.
|
||||
*/
|
||||
setAccessToken(AccessToken: CognitoAccessToken): void;
|
||||
|
||||
/**
|
||||
* @returns the session's token scopes
|
||||
*/
|
||||
getTokenScopes(): CognitoTokenScopes;
|
||||
|
||||
/**
|
||||
* Set new token scopes
|
||||
* @param tokenScopes The session's token scopes.
|
||||
*/
|
||||
setTokenScopes(tokenScopes: CognitoTokenScopes): void;
|
||||
|
||||
/**
|
||||
* @returns the session's state
|
||||
*/
|
||||
getState(): string;
|
||||
|
||||
/**
|
||||
* Set new state
|
||||
* @param state The session's state.
|
||||
*/
|
||||
setState(State: string): void;
|
||||
|
||||
/**
|
||||
* Checks to see if the session is still valid based on session expiry information found
|
||||
* in Access and Id Tokens and the current time
|
||||
* @returns if the session is still valid
|
||||
*/
|
||||
isValid(): boolean;
|
||||
}
|
||||
|
||||
export class CognitoAuth {
|
||||
/**
|
||||
* Called on success or error.
|
||||
*/
|
||||
userhandler: CognitoAuthUserHandler;
|
||||
|
||||
/**
|
||||
* Constructs a new CognitoAuth object
|
||||
* @param options Creation options
|
||||
*/
|
||||
constructor(options: CognitoAuthOptions);
|
||||
|
||||
/**
|
||||
* @returns the constants
|
||||
*/
|
||||
getCognitoConstants(): CognitoConstants;
|
||||
|
||||
/**
|
||||
* @returns the client id
|
||||
*/
|
||||
getClientId(): string;
|
||||
|
||||
/**
|
||||
* @returns the app web domain
|
||||
*/
|
||||
getAppWebDomain(): string;
|
||||
|
||||
/**
|
||||
* method for getting the current user of the application from the local storage
|
||||
*
|
||||
* @returns the user retrieved from storage
|
||||
*/
|
||||
getCurrentUser(): string;
|
||||
|
||||
/**
|
||||
* method for setting the current user's name
|
||||
* @param Username the user's name
|
||||
*/
|
||||
setUser(Username: string): void;
|
||||
|
||||
/**
|
||||
* sets response type to 'code'
|
||||
*/
|
||||
useCodeGrantFlow(): void;
|
||||
|
||||
/**
|
||||
* sets response type to 'token'
|
||||
*/
|
||||
useImplicitFlow(): void;
|
||||
|
||||
/**
|
||||
* @returns the current session for this user
|
||||
*/
|
||||
getSignInUserSession(): CognitoAuthSession;
|
||||
|
||||
/**
|
||||
* @returns the user's username
|
||||
*/
|
||||
getUsername(): string;
|
||||
|
||||
/**
|
||||
* @param Username the user's username
|
||||
*/
|
||||
setUsername(Username: string): void;
|
||||
|
||||
/**
|
||||
* @returns the user's state
|
||||
*/
|
||||
getState(): string;
|
||||
|
||||
/**
|
||||
* @param State the user's state
|
||||
*/
|
||||
setState(State: string): void;
|
||||
|
||||
/**
|
||||
* This is used to get a session, either from the session object or from the local storage, or by using a refresh token
|
||||
* @param RedirectUriSignIn Required: The redirect Uri, which will be launched after authentication.
|
||||
* @param TokenScopesArray Required: The token scopes, it is an array of strings specifying all scopes for the tokens.
|
||||
*/
|
||||
getSession(): void;
|
||||
|
||||
/**
|
||||
* Parse the http request response and proceed according to different response types.
|
||||
* @param httpRequestResponse the http request response
|
||||
*/
|
||||
parseCognitoWebResponse(httpRequestResponse: string): void;
|
||||
|
||||
/**
|
||||
* Get the query parameter map and proceed according to code response type.
|
||||
* @param Query parameter map
|
||||
*/
|
||||
getCodeQueryParameter(map: ReadonlyMap<string, string>): void;
|
||||
|
||||
/**
|
||||
* Get the query parameter map and proceed according to token response type.
|
||||
* @param Query parameter map
|
||||
*/
|
||||
getTokenQueryParameter(map: ReadonlyMap<string, string>): void;
|
||||
|
||||
/**
|
||||
* Get cached tokens and scopes and return a new session using all the cached data.
|
||||
* @returns the auth session
|
||||
*/
|
||||
getCachedSession(): CognitoAuthSession;
|
||||
|
||||
/**
|
||||
* This is used to get last signed in user from local storage
|
||||
* @returns the last user name
|
||||
*/
|
||||
getLastUser(): string;
|
||||
|
||||
/**
|
||||
* This is used to save the session tokens and scopes to local storage.
|
||||
*/
|
||||
cacheTokensScopes(): void;
|
||||
|
||||
/**
|
||||
* Compare two sets if they are identical.
|
||||
* @param set1 one set
|
||||
* @param set2 the other set
|
||||
* @returns boolean value is true if two sets are identical
|
||||
*/
|
||||
compareSets(set1: ReadonlySet<any>, set2: ReadonlySet<any>): boolean;
|
||||
|
||||
/**
|
||||
* Get the hostname from url.
|
||||
* @param url the url string
|
||||
* @returns hostname string
|
||||
*/
|
||||
getHostName(url: string): string;
|
||||
|
||||
/**
|
||||
* Get http query parameters and return them as a map.
|
||||
* @param url the url string
|
||||
* @param splitMark query parameters split mark (prefix)
|
||||
* @returns map
|
||||
*/
|
||||
getQueryParameters(url: string, splitMark: string): Map<string, string>;
|
||||
|
||||
/**
|
||||
* helper function to generate a random string
|
||||
* @param length the length of string
|
||||
* @param chars a original string
|
||||
* @returns a random value.
|
||||
*/
|
||||
generateRandomString(length: number, chars: string): string;
|
||||
|
||||
/**
|
||||
* This is used to clear the session tokens and scopes from local storage
|
||||
*/
|
||||
clearCachedTokensScopes(): void;
|
||||
|
||||
/**
|
||||
* This is used to build a user session from tokens retrieved in the authentication result
|
||||
* @param refreshToken Successful auth response from server.
|
||||
*/
|
||||
refreshSession(refreshToken: string): void;
|
||||
|
||||
/**
|
||||
* Make the http POST request.
|
||||
* @param header header JSON object
|
||||
* @param body body JSON object
|
||||
* @param url string
|
||||
* @param onSuccess callback
|
||||
* @param onFailure callback
|
||||
*/
|
||||
makePOSTRequest(header: object, body: object, url: string,
|
||||
onSuccess: (responseText: string) => void,
|
||||
onFailure: (responseText: string) => void): void;
|
||||
|
||||
/**
|
||||
* Create the XHR object
|
||||
* @param method which method to call
|
||||
* @param url the url string
|
||||
* @returns xhr
|
||||
*/
|
||||
createCORSRequest(method: string, url: string): XMLHttpRequest | XDomainRequest;
|
||||
|
||||
/**
|
||||
* The http POST request onFailure callback.
|
||||
* @param err the error object
|
||||
*/
|
||||
onFailure(err: any): void;
|
||||
|
||||
/**
|
||||
* The http POST request onSuccess callback when refreshing tokens.
|
||||
* @param jsonData tokens
|
||||
*/
|
||||
onSuccessRefreshToken(jsonData: string): void;
|
||||
|
||||
/**
|
||||
* The http POST request onSuccess callback when exchanging code for tokens.
|
||||
* @param jsonData tokens
|
||||
*/
|
||||
onSuccessExchangeForToken(jsonData: string): void;
|
||||
|
||||
/**
|
||||
* Launch Cognito Auth UI page.
|
||||
* @param URL the url to launch
|
||||
*/
|
||||
launchUri(URL: string): void;
|
||||
|
||||
/**
|
||||
* @returns scopes string
|
||||
*/
|
||||
getSpaceSeperatedScopeString(): string;
|
||||
|
||||
/**
|
||||
* Create the FQDN(fully qualified domain name) for authorization endpoint.
|
||||
* @returns url
|
||||
*/
|
||||
getFQDNSignIn(): string;
|
||||
|
||||
/**
|
||||
* Sign out the user.
|
||||
*/
|
||||
signOut(): void;
|
||||
|
||||
/**
|
||||
* Create the FQDN(fully qualified domain name) for signout endpoint.
|
||||
* @returns url
|
||||
*/
|
||||
getFQDNSignOut(): string;
|
||||
|
||||
/**
|
||||
* This method returns the encoded data string used for cognito advanced security feature.
|
||||
* This would be generated only when developer has included the JS used for collecting the
|
||||
* data on their client. Please refer to documentation to know more about using AdvancedSecurity
|
||||
* features
|
||||
*/
|
||||
getUserContextData(): string;
|
||||
|
||||
/**
|
||||
* Helper method to let the user know if he has either a valid cached session
|
||||
* or a valid authenticated session from the app integration callback.
|
||||
* @returns userSignedIn
|
||||
*/
|
||||
isUserSignedIn(): boolean;
|
||||
}
|
||||
|
||||
export class DateHelper {
|
||||
/**
|
||||
* @returns The current time in "ddd MMM D HH:mm:ss UTC YYYY" format.
|
||||
*/
|
||||
getNowString(): string;
|
||||
}
|
||||
|
||||
export class StorageHelper {
|
||||
/**
|
||||
* This is used to get a storage object
|
||||
* @returns the storage
|
||||
*/
|
||||
constructor();
|
||||
|
||||
/**
|
||||
* This is used to return the storage
|
||||
* @returns the storage
|
||||
*/
|
||||
getStorage(): Storage;
|
||||
}
|
||||
@@ -0,0 +1,162 @@
|
||||
import * as lib from 'amazon-cognito-auth-js';
|
||||
|
||||
const idToken: lib.CognitoIdToken = new lib.CognitoIdToken('fak3T0ken1==');
|
||||
idToken.decodePayload(); // $ExpectType object
|
||||
idToken.setJwtToken('fak3T0ken2=='); // $ExpectType void
|
||||
idToken.getJwtToken(); // $ExpectType string
|
||||
idToken.getExpiration(); // $ExpectType number
|
||||
|
||||
const refreshToken: lib.CognitoRefreshToken = new lib.CognitoRefreshToken('refreshplease==');
|
||||
refreshToken.setToken('refreshagainplease=='); // $ExpectType void
|
||||
refreshToken.getToken(); // $ExpectType string
|
||||
|
||||
const accessToken: lib.CognitoAccessToken = new lib.CognitoAccessToken('fak3T0ken3==');
|
||||
accessToken.decodePayload(); // $ExpectType object
|
||||
accessToken.setJwtToken('fak3T0ken4=='); // $ExpectType void
|
||||
accessToken.getJwtToken(); // $ExpectType string
|
||||
accessToken.getExpiration(); // $ExpectType number
|
||||
accessToken.getUsername(); // $ExpectType string
|
||||
|
||||
const tokenScopes: lib.CognitoTokenScopes = new lib.CognitoTokenScopes(['email', 'custom1']);
|
||||
tokenScopes.setTokenScopes(['openid']); // $ExpectType void
|
||||
tokenScopes.getScopes(); // $ExpectType string[]
|
||||
|
||||
let sessionData: lib.CognitoSessionData = {};
|
||||
let authSession: lib.CognitoAuthSession = new lib.CognitoAuthSession(sessionData);
|
||||
|
||||
sessionData = {
|
||||
IdToken: idToken,
|
||||
RefreshToken: refreshToken,
|
||||
AccessToken: accessToken,
|
||||
TokenScopes: tokenScopes,
|
||||
State: '/myapp/home'
|
||||
};
|
||||
authSession = new lib.CognitoAuthSession(sessionData);
|
||||
|
||||
authSession.setIdToken(new lib.CognitoIdToken('fak3T0ken5==')); // $ExpectType void
|
||||
authSession.setRefreshToken(new lib.CognitoRefreshToken('refreshmeyetagain==')); // $ExpectType void
|
||||
authSession.setAccessToken(new lib.CognitoAccessToken('fak3T0ken6==')); // $ExpectType void
|
||||
authSession.setTokenScopes(new lib.CognitoTokenScopes(['email'])); // $ExpectType void
|
||||
authSession.setState('/myapp/login'); // $ExpectType void
|
||||
authSession.getIdToken(); // $ExpectType CognitoIdToken
|
||||
authSession.getRefreshToken(); // $ExpectType CognitoRefreshToken
|
||||
authSession.getAccessToken(); // $ExpectType CognitoAccessToken
|
||||
authSession.getTokenScopes(); // $ExpectType CognitoTokenScopes
|
||||
authSession.getState(); // $ExpectType string
|
||||
|
||||
let authOptions: lib.CognitoAuthOptions = {
|
||||
ClientId: '1a2b3c4d5e6f7g',
|
||||
AppWebDomain: 'myapp.auth.us-east-1.amazoncognito.com',
|
||||
RedirectUriSignIn: 'https://myapp.com/login',
|
||||
RedirectUriSignOut: 'https://myapp.com/logout'
|
||||
};
|
||||
let auth: lib.CognitoAuth = new lib.CognitoAuth(authOptions);
|
||||
|
||||
authOptions = {
|
||||
ClientId: '1a2b3c4d5e6f7g',
|
||||
AppWebDomain: 'myapp.auth.us-east-1.amazoncognito.com',
|
||||
TokenScopesArray: ['email', 'openid'],
|
||||
RedirectUriSignIn: 'https://myapp.com/login',
|
||||
RedirectUriSignOut: 'https://myapp.com/logout',
|
||||
IdentityProvider: 'Facebook',
|
||||
UserPoolId: 'us-east-1_faKE4ReAl',
|
||||
AdvancedSecurityDataCollectionFlag: true
|
||||
};
|
||||
auth = new lib.CognitoAuth(authOptions);
|
||||
|
||||
auth.getClientId(); // $ExpectType string
|
||||
auth.getAppWebDomain(); // $ExpectType string
|
||||
auth.getCurrentUser(); // $ExpectType string
|
||||
auth.setUser('jane.doe'); // $ExpectType void
|
||||
auth.useCodeGrantFlow(); // $ExpectType void
|
||||
auth.useImplicitFlow(); // $ExpectType void
|
||||
auth.getSignInUserSession(); // $ExpectType CognitoAuthSession
|
||||
auth.getUsername(); // $ExpectType string
|
||||
auth.setUsername('john.doe'); // $ExpectType void
|
||||
auth.getState(); // $ExpectType string
|
||||
auth.setState('/myhost/default.htm'); // $ExpectType void
|
||||
auth.getSession(); // $ExpectType void
|
||||
auth.parseCognitoWebResponse('url&stuff=true'); // $ExpectType void
|
||||
auth.getCodeQueryParameter(new Map()); // $ExpectType void
|
||||
auth.getTokenQueryParameter(new Map()); // $ExpectType void
|
||||
auth.getCachedSession(); // $ExpectType CognitoAuthSession
|
||||
auth.getLastUser(); // $ExpectType string
|
||||
auth.cacheTokensScopes(); // $ExpectType void
|
||||
auth.compareSets(new Set(['1']), new Set(['1'])); // $ExpectType boolean
|
||||
auth.getHostName('https://site.com/page?size=10'); // $ExpectType string
|
||||
auth.getQueryParameters('http://site.com?1=1&2=2', '?'); // $ExpectType Map<string, string>
|
||||
auth.generateRandomString(5, '159erf'); // $ExpectType string
|
||||
auth.clearCachedTokensScopes(); // $ExpectType void
|
||||
auth.refreshSession('refreshToken=='); // $ExpectType void
|
||||
// $ExpectType void
|
||||
auth.makePOSTRequest({ 'Content-Type': 'application/json' }, { pool: '2' },
|
||||
'https://auth.com/signin',
|
||||
(data) => console.log(data),
|
||||
(error) => console.log(error));
|
||||
auth.createCORSRequest('POST', '/myapp/login'); // $ExpectType XMLHttpRequest | XDomainRequest
|
||||
auth.onFailure('request failed'); // $ExpectType void
|
||||
auth.onSuccessRefreshToken('{"name":"John", "age":31}'); // $ExpectType void
|
||||
auth.onSuccessExchangeForToken('{"name":"Jane", "age":30}'); // $ExpectType void
|
||||
auth.launchUri('https://auth.com/login'); // $ExpectType void
|
||||
auth.getSpaceSeperatedScopeString(); // $ExpectType string
|
||||
auth.getFQDNSignIn(); // $ExpectType string
|
||||
auth.signOut(); // $ExpectType void
|
||||
auth.getFQDNSignOut(); // $ExpectType string
|
||||
auth.getUserContextData(); // $ExpectType string
|
||||
auth.isUserSignedIn(); // $ExpectType boolean
|
||||
|
||||
const userHandler: lib.CognitoAuthUserHandler = {
|
||||
onSuccess: (authSession: lib.CognitoAuthSession) => console.log(authSession),
|
||||
onFailure: (error: any) => console.log(error)
|
||||
};
|
||||
auth.userhandler = userHandler;
|
||||
|
||||
const constants: lib.CognitoConstants = auth.getCognitoConstants();
|
||||
constants.DOMAIN_SCHEME; // $ExpectType string
|
||||
constants.DOMAIN_PATH_SIGNIN; // $ExpectType string
|
||||
constants.DOMAIN_PATH_TOKEN; // $ExpectType string
|
||||
constants.DOMAIN_PATH_SIGNOUT; // $ExpectType string
|
||||
constants.DOMAIN_QUERY_PARAM_REDIRECT_URI; // $ExpectType string
|
||||
constants.DOMAIN_QUERY_PARAM_SIGNOUT_URI; // $ExpectType string
|
||||
constants.DOMAIN_QUERY_PARAM_RESPONSE_TYPE; // $ExpectType string
|
||||
constants.DOMAIN_QUERY_PARAM_IDENTITY_PROVIDER; // $ExpectType string
|
||||
constants.DOMAIN_QUERY_PARAM_USERCONTEXTDATA; // $ExpectType string
|
||||
constants.CLIENT_ID; // $ExpectType string
|
||||
constants.STATE; // $ExpectType string
|
||||
constants.SCOPE; // $ExpectType string
|
||||
constants.TOKEN; // $ExpectType string
|
||||
constants.CODE; // $ExpectType string
|
||||
constants.POST; // $ExpectType string
|
||||
constants.PARAMETERERROR; // $ExpectType string
|
||||
constants.SCOPETYPEERROR; // $ExpectType string
|
||||
constants.QUESTIONMARK; // $ExpectType string
|
||||
constants.POUNDSIGN; // $ExpectType string
|
||||
constants.COLONDOUBLESLASH; // $ExpectType string
|
||||
constants.SLASH; // $ExpectType string
|
||||
constants.AMPERSAND; // $ExpectType string
|
||||
constants.EQUALSIGN; // $ExpectType string
|
||||
constants.SPACE; // $ExpectType string
|
||||
constants.CONTENTTYPE; // $ExpectType string
|
||||
constants.CONTENTTYPEVALUE; // $ExpectType string
|
||||
constants.AUTHORIZATIONCODE; // $ExpectType string
|
||||
constants.IDTOKEN; // $ExpectType string
|
||||
constants.ACCESSTOKEN; // $ExpectType string
|
||||
constants.REFRESHTOKEN; // $ExpectType string
|
||||
constants.ERROR; // $ExpectType string
|
||||
constants.ERROR_DESCRIPTION; // $ExpectType string
|
||||
constants.STRINGTYPE; // $ExpectType string
|
||||
constants.STATELENGTH; // $ExpectType number
|
||||
constants.STATEORIGINSTRING; // $ExpectType string
|
||||
constants.WITHCREDENTIALS; // $ExpectType string
|
||||
constants.UNDEFINED; // $ExpectType string
|
||||
constants.SELF; // $ExpectType string
|
||||
constants.HOSTNAMEREGEX; // $ExpectType RegExp
|
||||
constants.QUERYPARAMETERREGEX1; // $ExpectType RegExp
|
||||
constants.QUERYPARAMETERREGEX2; // $ExpectType RegExp
|
||||
constants.HEADER['Content-Type']; // $ExpectType string
|
||||
|
||||
const dateHelper: lib.DateHelper = new lib.DateHelper();
|
||||
dateHelper.getNowString(); // $ExpectType string
|
||||
|
||||
const storageHelper: lib.StorageHelper = new lib.StorageHelper();
|
||||
storageHelper.getStorage(); // $ExpectType Storage
|
||||
@@ -0,0 +1,22 @@
|
||||
AmazonCognitoIdentity.CognitoIdToken; // $ExpectType typeof CognitoIdToken
|
||||
AmazonCognitoIdentity.CognitoRefreshToken; // $ExpectType typeof CognitoRefreshToken
|
||||
AmazonCognitoIdentity.CognitoAccessToken; // $ExpectType typeof CognitoAccessToken
|
||||
AmazonCognitoIdentity.CognitoTokenScopes; // $ExpectType typeof CognitoTokenScopes
|
||||
AmazonCognitoIdentity.CognitoAuthSession; // $ExpectType typeof CognitoAuthSession
|
||||
AmazonCognitoIdentity.CognitoAuth; // $ExpectType typeof CognitoAuth
|
||||
AmazonCognitoIdentity.DateHelper; // $ExpectType typeof DateHelper
|
||||
AmazonCognitoIdentity.StorageHelper; // $ExpectType typeof StorageHelper
|
||||
|
||||
const sessionData: AmazonCognitoIdentity.CognitoSessionData = {};
|
||||
new AmazonCognitoIdentity.CognitoAuthSession(sessionData);
|
||||
|
||||
const authOptions: AmazonCognitoIdentity.CognitoAuthOptions = {
|
||||
ClientId: '1a2b3c4d5e6f7g',
|
||||
AppWebDomain: 'myapp.auth.us-east-1.amazoncognito.com',
|
||||
RedirectUriSignIn: 'https://myapp.com/login',
|
||||
RedirectUriSignOut: 'https://myapp.com/logout'
|
||||
};
|
||||
const auth = new AmazonCognitoIdentity.CognitoAuth(authOptions);
|
||||
auth.userhandler; // $ExpectType CognitoAuthUserHandler
|
||||
auth.getCognitoConstants(); // $ExpectType CognitoConstants
|
||||
auth.createCORSRequest('', ''); // $ExpectType XMLHttpRequest | XDomainRequest
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"dom",
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"test/amazon-cognito-auth-js-tests.ts",
|
||||
"test/amazon-cognito-auth-js-umd-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@@ -1,4 +1,4 @@
|
||||
import { db, aql, query } from "@arangodb";
|
||||
import { aql, db, query } from "@arangodb";
|
||||
import { md5 } from "@arangodb/crypto";
|
||||
import { createRouter } from "@arangodb/foxx";
|
||||
import sessionsMiddleware = require("@arangodb/foxx/sessions");
|
||||
@@ -52,6 +52,10 @@ bananas.updateByExample(
|
||||
{ shape: { type: "round" } },
|
||||
{ mergeObjects: true }
|
||||
);
|
||||
bananas.ensureIndex({
|
||||
type: "geo",
|
||||
fields: ["latLng"]
|
||||
});
|
||||
|
||||
const router = createRouter();
|
||||
module.context.use(router);
|
||||
|
||||
Vendored
+1
-1
@@ -89,7 +89,7 @@ declare namespace ArangoDB {
|
||||
| "network authentication required";
|
||||
type EdgeDirection = "any" | "inbound" | "outbound";
|
||||
type EngineType = "mmfiles" | "rocksdb";
|
||||
type IndexType = "hash" | "skiplist" | "fulltext" | "geo1" | "geo2";
|
||||
type IndexType = "hash" | "skiplist" | "fulltext" | "geo";
|
||||
type ViewType = "arangosearch";
|
||||
type KeyGeneratorType = "traditional" | "autoincrement";
|
||||
type ErrorName =
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import * as arrify from 'arrify';
|
||||
|
||||
/***************** arrify<T> *****************/
|
||||
arrify(null);
|
||||
arrify<number>(null);
|
||||
|
||||
@@ -12,3 +13,74 @@ arrify([2, 3]);
|
||||
function test(val?: string | string[]) {
|
||||
arrify(val);
|
||||
}
|
||||
/***************** arrify<T> *****************/
|
||||
|
||||
/***************** arrify<T1, T2> *****************/
|
||||
arrify<number, string>(undefined); // returns []
|
||||
|
||||
arrify<number, string>(null); // returns []
|
||||
|
||||
{
|
||||
const value: number | string[] = 2018;
|
||||
arrify<number, string>(value); // returns [2018]
|
||||
}
|
||||
|
||||
{
|
||||
const value: number[] | string | string[] = ['a', 'b'];
|
||||
arrify<number, string>(value); // returns ['a', 'b']
|
||||
}
|
||||
/***************** arrify<T1, T2> *****************/
|
||||
|
||||
/***************** arrify<T1, T2, T3> *****************/
|
||||
arrify<boolean, number, string>(undefined);
|
||||
|
||||
arrify<boolean, number, string>(null);
|
||||
|
||||
{
|
||||
const value: boolean | number[] | string[] = true;
|
||||
// returns [true]
|
||||
arrify<boolean, number, string>(value);
|
||||
}
|
||||
|
||||
{
|
||||
const value: boolean[] | number | string[] = ['a', 'b'];
|
||||
// returns ['a', 'b']
|
||||
arrify<boolean, number, string>(value);
|
||||
}
|
||||
/***************** arrify<T1, T2, T3> *****************/
|
||||
|
||||
/***************** arrify<T1, T2, T3, T4> *****************/
|
||||
arrify<boolean, Date, number, string>(undefined);
|
||||
|
||||
arrify<boolean, Date, number, string>(null);
|
||||
|
||||
{
|
||||
const value: boolean | Date | number[] | string[] = new Date(2018);
|
||||
// returns [ new Date(2018) ]
|
||||
arrify<boolean, Date, number, string>(value);
|
||||
}
|
||||
|
||||
{
|
||||
const value: boolean[] | Date[] | number | string = [true, false];
|
||||
// returns [true, false]
|
||||
arrify<boolean, Date, number, string>(value);
|
||||
}
|
||||
/***************** arrify<T1, T2, T3, T4> *****************/
|
||||
|
||||
/***************** arrify<T1, T2, T3, T4, T5> *****************/
|
||||
arrify<boolean, Date, number, RegExp, string>(undefined);
|
||||
|
||||
arrify<boolean, Date, number, RegExp, string>(null);
|
||||
|
||||
{
|
||||
const value: boolean | Date | number[] | RegExp | string[] = /test/;
|
||||
// returns [ /test/ ]
|
||||
arrify<boolean, Date, number, RegExp, string>(value);
|
||||
}
|
||||
|
||||
{
|
||||
const value: boolean[] | Date[] | number | RegExp[] | string = [/test1/, /test2/];
|
||||
// returns [/test1/, /test2/]
|
||||
arrify<boolean, Date, number, RegExp, string>(value);
|
||||
}
|
||||
/***************** arrify<T1, T2, T3, T4, T5> *****************/
|
||||
|
||||
Vendored
+73
@@ -14,5 +14,78 @@
|
||||
* arrify([2, 3]) // returns [2, 3]
|
||||
*/
|
||||
declare function arrify<T>(val: undefined | null | T | T[]): T[];
|
||||
|
||||
/**
|
||||
* @example
|
||||
* // returns []
|
||||
* arrify<number, string>(undefined);
|
||||
* @example
|
||||
* // returns []
|
||||
* arrify<number, string>(null);
|
||||
* @example
|
||||
* let value: number | string[] = 2018;
|
||||
* // returns [2018]
|
||||
* arrify<number, string>(value);
|
||||
* @example
|
||||
* let value: number[] | string | string[] = ['a', 'b'];
|
||||
* // returns ['a', 'b']
|
||||
* arrify<number, string>(value);
|
||||
*/
|
||||
declare function arrify<T1, T2>(val: undefined | null | T1 | T2 | T1[] | T2[]): T1[] | T2[];
|
||||
|
||||
/**
|
||||
* @example
|
||||
* // returns []
|
||||
* arrify<boolean, number, string>(undefined);
|
||||
* @example
|
||||
* // returns []
|
||||
* arrify<boolean, number, string>(null);
|
||||
* @example
|
||||
* let value: boolean | number[] | string[] = true;
|
||||
* // returns [true]
|
||||
* arrify<boolean, number, string>(value);
|
||||
* @example
|
||||
* let value: boolean[] | number | string[] = ['a', 'b'];
|
||||
* // returns ['a', 'b']
|
||||
* arrify<boolean, number, string>(value);
|
||||
*/
|
||||
declare function arrify<T1, T2, T3>(val: undefined | null | T1 | T2 | T3 | T1[] | T2[] | T3[]): T1[] | T2[] | T3[];
|
||||
|
||||
/**
|
||||
* @example
|
||||
* // returns []
|
||||
* arrify<boolean, Date, number, string>(undefined);
|
||||
* @example
|
||||
* // returns []
|
||||
* arrify<boolean, Date, number, string>(null);
|
||||
* @example
|
||||
* let value: boolean | Date | number[] | string[] = new Date(2018);
|
||||
* // returns [ new Date(2018) ]
|
||||
* arrify<boolean, Date, number, string>(value);
|
||||
* @example
|
||||
* let value: boolean[] | Date[] | number | string = [true, false];
|
||||
* // returns [true, false]
|
||||
* arrify<boolean, Date, number, string>(value);
|
||||
*/
|
||||
declare function arrify<T1, T2, T3, T4>(val: undefined | null | T1 | T2 | T3 | T4 | T1[] | T2[] | T3[] | T4[]): T1[] | T2[] | T3[] | T4[];
|
||||
|
||||
/**
|
||||
* @example
|
||||
* // returns []
|
||||
* arrify<boolean, Date, number, RegExp, string>(undefined);
|
||||
* @example
|
||||
* // returns []
|
||||
* arrify<boolean, Date, number, RegExp, string>(null);
|
||||
* @example
|
||||
* let value: boolean | Date | number[] | RegExp | string[] = /test/;
|
||||
* // returns [ /test/ ]
|
||||
* arrify<boolean, Date, number, RegExp, string>(value);
|
||||
* @example
|
||||
* let value: boolean[] | Date[] | number | RegExp[] | string = [/test1/, /test2/];
|
||||
* // returns [/test1/, /test2/]
|
||||
* arrify<boolean, Date, number, RegExp, string>(value);
|
||||
*/
|
||||
declare function arrify<T1, T2, T3, T4, T5>(val: undefined | null | T1 | T2 | T3 | T4 | T5 | T1[] | T2[] | T3[] | T4[] | T5[]): T1[] | T2[] | T3[] | T4[] | T5[];
|
||||
|
||||
declare namespace arrify {}
|
||||
export = arrify;
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
import * as blocked from 'blocked';
|
||||
|
||||
blocked((ms: number) => {
|
||||
// todo: show warning
|
||||
}, {
|
||||
threshold: 10
|
||||
});
|
||||
Vendored
+24
@@ -0,0 +1,24 @@
|
||||
// Type definitions for blocked 1.2
|
||||
// Project: https://github.com/visionmedia/node-blocked#readme
|
||||
// Definitions by: Jonas Lochmann <https://github.com/l-jonas>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
/*~ Note that ES6 modules cannot directly export callable functions.
|
||||
*~ This file should be imported using the CommonJS-style:
|
||||
*~ import x = require('someLibrary');
|
||||
*~
|
||||
*~ Refer to the documentation to understand common
|
||||
*~ workarounds for this limitation of ES6 modules.
|
||||
*/
|
||||
|
||||
export = Blocked;
|
||||
|
||||
declare function Blocked(callback: (ms: number) => void, options?: Blocked.Options): NodeJS.Timer;
|
||||
|
||||
declare namespace Blocked {
|
||||
interface Options {
|
||||
threshold: number; // in milliseconds
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"strictFunctionTypes": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"blocked-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@@ -88,6 +88,27 @@ spyStringArg('foo');
|
||||
expect(spyStringArg).to.have.been.called.always.with.exactly('foo');
|
||||
spyStringArg.should.have.been.called.always.with.exactly('foo');
|
||||
|
||||
// .first / .second / .third
|
||||
const spyStringIteratedArg = chai.spy((arg: string) => arg);
|
||||
spyStringIteratedArg('foo');
|
||||
spyStringIteratedArg('bar');
|
||||
spyStringIteratedArg('baz');
|
||||
expect(spyStringIteratedArg).to.have.been.first.called.with('foo');
|
||||
spyStringIteratedArg.should.have.been.first.called.with('foo');
|
||||
expect(spyStringIteratedArg).to.have.been.first.called.with('bar');
|
||||
spyStringIteratedArg.should.have.been.first.called.with('bar');
|
||||
expect(spyStringIteratedArg).to.have.been.first.called.with('baz');
|
||||
spyStringIteratedArg.should.have.been.first.called.with('baz');
|
||||
|
||||
// .nth
|
||||
const spyStringNthArg = chai.spy((arg: string) => arg);
|
||||
spyStringNthArg('foo');
|
||||
spyStringNthArg('bar');
|
||||
expect(spyStringNthArg).on.nth(1).be.called.with('foo');
|
||||
spyStringNthArg.should.on.nth(1).be.called.with('foo');
|
||||
expect(spyStringNthArg).on.nth(2).be.called.with('bar');
|
||||
spyStringNthArg.should.on.nth(2).be.called.with('bar');
|
||||
|
||||
// .once
|
||||
expect(spy).to.have.been.called.once;
|
||||
expect(spy).to.not.have.been.called.once;
|
||||
|
||||
Vendored
+67
@@ -10,6 +10,10 @@ declare namespace Chai {
|
||||
spy: ChaiSpies.Spy;
|
||||
}
|
||||
|
||||
interface LanguageChains {
|
||||
on: Assertion;
|
||||
}
|
||||
|
||||
interface Assertion {
|
||||
/**
|
||||
* ####.spy
|
||||
@@ -31,6 +35,28 @@ declare namespace Chai {
|
||||
* Note that ```called``` can be used as a chainable method.
|
||||
*/
|
||||
called: ChaiSpies.Called;
|
||||
|
||||
/**
|
||||
* * ####.been
|
||||
* * Assert that something has been spied on. Negation passes through.
|
||||
* * ```ts
|
||||
* * expect(spy).to.have.been.called();
|
||||
* * spy.should.have.been.called();
|
||||
* ```
|
||||
* Note that ```been``` can be used as a chainable method.
|
||||
*/
|
||||
been: ChaiSpies.Been;
|
||||
|
||||
/**
|
||||
* * ####.nth (function)
|
||||
* * Assert that something has been spied on on a certain index. Negation passes through.
|
||||
* * ```ts
|
||||
* * expect(spy).on.nth(5).be.called.with('foobar');
|
||||
* * spy.should.on.nth(5).be.called.with('foobar');
|
||||
* ```
|
||||
* Note that ```nth``` can be used as a chainable method.
|
||||
*/
|
||||
nth(index: number): Assertion;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -224,6 +250,47 @@ declare namespace ChaiSpies {
|
||||
lt(n: number): Chai.Assertion;
|
||||
}
|
||||
|
||||
interface Been extends Chai.Assertion {
|
||||
(): Chai.Assertion;
|
||||
called: Called;
|
||||
|
||||
/**
|
||||
* ####.first
|
||||
* Assert that a spy has been called first.
|
||||
* ```ts
|
||||
* expect(spy).to.have.been.called.first;
|
||||
* expect(spy).to.not.have.been.called.first;
|
||||
* spy.should.have.been.called.first;
|
||||
* spy.should.not.have.been.called.first;
|
||||
* ```
|
||||
*/
|
||||
first: Chai.Assertion;
|
||||
|
||||
/**
|
||||
* ####.second
|
||||
* Assert that a spy has been called second.
|
||||
* ```ts
|
||||
* expect(spy).to.have.been.called.second;
|
||||
* expect(spy).to.not.have.been.called.second;
|
||||
* spy.should.have.been.called.second;
|
||||
* spy.should.not.have.been.called.second;
|
||||
* ```
|
||||
*/
|
||||
second: Chai.Assertion;
|
||||
|
||||
/**
|
||||
* ####.third
|
||||
* Assert that a spy has been called third.
|
||||
* ```ts
|
||||
* expect(spy).to.have.been.called.third;
|
||||
* expect(spy).to.not.have.been.called.third;
|
||||
* spy.should.have.been.called.third;
|
||||
* spy.should.not.have.been.called.third;
|
||||
* ```
|
||||
*/
|
||||
third: Chai.Assertion;
|
||||
}
|
||||
|
||||
interface With {
|
||||
/**
|
||||
* ####.with
|
||||
|
||||
Vendored
+2
-1
@@ -221,7 +221,7 @@ declare namespace Chart {
|
||||
interface ChartTitleOptions {
|
||||
display?: boolean;
|
||||
position?: PositionType;
|
||||
fullWdith?: boolean;
|
||||
fullWidth?: boolean;
|
||||
fontSize?: number;
|
||||
fontFamily?: string;
|
||||
fontColor?: ChartColor;
|
||||
@@ -513,6 +513,7 @@ declare namespace Chart {
|
||||
gridLines?: GridLineOptions;
|
||||
barThickness?: number;
|
||||
scaleLabel?: ScaleTitleOptions;
|
||||
offset?: boolean;
|
||||
beforeUpdate?(scale?: any): void;
|
||||
beforeSetDimension?(scale?: any): void;
|
||||
beforeDataLimits?(scale?: any): void;
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
import progress = require('cli-progress');
|
||||
|
||||
function test0() {
|
||||
// Usage
|
||||
// Multiple examples are available e.g.example.js - just try it $ node example.js
|
||||
|
||||
const _cliProgress = require('cli-progress');
|
||||
|
||||
// create a new progress bar instance and use shades_classic theme
|
||||
const bar1 = new _cliProgress.Bar({}, _cliProgress.Presets.shades_classic);
|
||||
|
||||
// start the progress bar with a total value of 200 and start value of 0
|
||||
bar1.start(200, 0);
|
||||
|
||||
// update the current value in your application..
|
||||
bar1.update(100);
|
||||
|
||||
// stop the progress bar
|
||||
bar1.stop();
|
||||
}
|
||||
|
||||
function test1() {
|
||||
// Examples
|
||||
// Example 1 - Set Options
|
||||
|
||||
// change the progress characters
|
||||
// set fps limit to 5
|
||||
// change the output stream and barsize
|
||||
const bar = new progress.Bar({
|
||||
barCompleteChar: '#',
|
||||
barIncompleteChar: '.',
|
||||
fps: 5,
|
||||
stream: process.stdout,
|
||||
barsize: 65
|
||||
});
|
||||
}
|
||||
|
||||
function test2() {
|
||||
// Example 2 - Change Styles defined by Preset
|
||||
// uee shades preset
|
||||
// change the barsize
|
||||
const bar = new progress.Bar({
|
||||
barsize: 65
|
||||
}, progress.Presets.shades_grey);
|
||||
}
|
||||
|
||||
function test3() {
|
||||
// Example 3 - Custom Payload
|
||||
// create new progress bar with custom token "speed"
|
||||
const bar = new progress.Bar({
|
||||
format: 'progress [{bar}] {percentage}% | ETA: {eta}s | {value}/{total} | Speed: {speed} kbit'
|
||||
});
|
||||
|
||||
// initialize the bar - set payload token "speed" with the default value "N/A"
|
||||
bar.start(200, 0, {
|
||||
speed: "N/A"
|
||||
});
|
||||
|
||||
// some code/update loop
|
||||
// ...
|
||||
|
||||
// update bar value. set custom token "speed" to 125
|
||||
bar.update(5, {
|
||||
speed: '125'
|
||||
});
|
||||
|
||||
// process finished
|
||||
bar.stop();
|
||||
}
|
||||
|
||||
function test4() {
|
||||
// Example 4 - Custom Presets
|
||||
// File mypreset.js
|
||||
|
||||
const _colors = require('colors');
|
||||
|
||||
module.exports = {
|
||||
format: _colors.red(' {bar}') + ' {percentage}% | ETA: {eta}s | {value}/{total} | Speed: {speed} kbit',
|
||||
barCompleteChar: '\u2588',
|
||||
barIncompleteChar: '\u2591'
|
||||
};
|
||||
}
|
||||
|
||||
function test5() {
|
||||
// Application
|
||||
|
||||
const _mypreset = require('./mypreset.js');
|
||||
|
||||
const bar = new progress.Bar({
|
||||
barsize: 65
|
||||
}, _mypreset);
|
||||
}
|
||||
Vendored
+114
@@ -0,0 +1,114 @@
|
||||
// Type definitions for cli-progress 1.8
|
||||
// Project: https://github.com/AndiDittrich/Node.CLI-Progress
|
||||
// Definitions by: My Self <https://github.com/mhegazy>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
export interface Options {
|
||||
/**
|
||||
* progress bar output format.
|
||||
* The progressbar can be customized by using the following build-in placeholders. They can be combined in any order.
|
||||
* {bar} - the progress bar, customizable by the options barsize, barCompleteString and barIncompleteString
|
||||
* {percentage} - the current progress in percent (0-100)
|
||||
* {total} - the end value
|
||||
* {value} - the current value set by last update() call
|
||||
* {eta} - expected time of accomplishment in seconds
|
||||
* {duration} - elapsed time in seconds
|
||||
* {eta_formatted} - expected time of accomplishment formatted into appropriate units
|
||||
* {duration_formatted} - elapsed time formatted into appropriate units
|
||||
*
|
||||
* Example:
|
||||
* progress [{bar}] {percentage}% | ETA: {eta}s | {value}/{total}
|
||||
* is rendered as
|
||||
* progress [========================================] 100% | ETA: 0s | 200/200
|
||||
*/
|
||||
format?: string;
|
||||
|
||||
/** the maximum update rate (default: 10) */
|
||||
fps?: number;
|
||||
|
||||
/** output stream to use (default: process.stderr) */
|
||||
stream?: NodeJS.WritableStream;
|
||||
|
||||
/** automatically call stop() when the value reaches the total (default: false) */
|
||||
stopOnComplete?: boolean;
|
||||
|
||||
/** clear the progress bar on complete / stop() call (default: false) */
|
||||
clearOnComplete?: boolean;
|
||||
|
||||
/** the length of the progress bar in chars (default: 40) */
|
||||
barsize?: number;
|
||||
|
||||
/** character to use as "complete" indicator in the bar (default: "=") */
|
||||
barCompleteString?: string;
|
||||
|
||||
/** character to use as "incomplete" indicator in the bar (default: "-") */
|
||||
barIncompleteString?: string;
|
||||
|
||||
/** character to use as "complete" indicator in the bar (default: "=") */
|
||||
barCompleteChar?: string;
|
||||
|
||||
/** character to use as "incomplete" indicator in the bar (default: "-") */
|
||||
barIncompleteChar?: string;
|
||||
|
||||
/** hide the cursor during progress operation; restored on complete (default: false) */
|
||||
hideCursor?: boolean;
|
||||
|
||||
/** number of updates with which to calculate the eta; higher numbers give a more stable eta (default: 10) */
|
||||
etaBuffer?: number;
|
||||
|
||||
/** disable line wrapping (default: false) - pass null to keep terminal settings; pass true to trim the output to terminal width */
|
||||
linewrap?: boolean | null;
|
||||
}
|
||||
|
||||
export interface Preset {
|
||||
barCompleteChar: string;
|
||||
barIncompleteChar: string;
|
||||
format: string;
|
||||
}
|
||||
|
||||
export class Bar {
|
||||
/** Initialize a new Progress bar. An instance can be used multiple times! it's not required to re-create it! */
|
||||
constructor(opt: Options, preset?: Preset);
|
||||
|
||||
calculateETA(): void;
|
||||
|
||||
formatTime(t: any, roundToMultipleOf: any): any;
|
||||
|
||||
getTotal(): any;
|
||||
|
||||
/** Increases the current progress value by a specified amount (default +1). Update payload optionally */
|
||||
increment(step: number, payload?: object): void;
|
||||
|
||||
render(): void;
|
||||
|
||||
/** Sets the total progress value while progressbar is active. Especially useful handling dynamic tasks. */
|
||||
setTotal(total: number): void;
|
||||
|
||||
/** Starts the progress bar and set the total and initial value */
|
||||
start(total: number, startValue: number, payload?: object): void;
|
||||
|
||||
/** Stops the progress bar and go to next line */
|
||||
stop(): void;
|
||||
|
||||
stopTimer(): void;
|
||||
|
||||
/** Sets the current progress value and optionally the payload with values of custom tokens as a second parameter */
|
||||
update(current: number, payload?: object): void;
|
||||
}
|
||||
|
||||
export const Presets: {
|
||||
/** Styles as of cli-progress v1.3.0 */
|
||||
legacy: Preset;
|
||||
|
||||
/** Unicode Rectangles */
|
||||
rect: Preset;
|
||||
|
||||
/** Unicode background shades are used for the bar */
|
||||
shades_classic: Preset;
|
||||
|
||||
/** Unicode background shades with grey bar */
|
||||
shades_grey: Preset;
|
||||
};
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"strictFunctionTypes": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"cli-progress-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@@ -1,80 +1,116 @@
|
||||
import moment = require("moment")
|
||||
import daterangepicker = require("daterangepicker");
|
||||
import moment = require('moment');
|
||||
import daterangepicker = require('daterangepicker');
|
||||
|
||||
function tests_simple() {
|
||||
$('#daterange').daterangepicker();
|
||||
$('input[name="daterange"]').daterangepicker({
|
||||
timePicker: true,
|
||||
timePickerIncrement: 30,
|
||||
locale: {
|
||||
format: 'MM/DD/YYYY h:mm A'
|
||||
}
|
||||
});
|
||||
$('input[name="daterange"]')
|
||||
.daterangepicker({
|
||||
timePicker: true,
|
||||
timePickerIncrement: 30,
|
||||
locale: {
|
||||
format: 'MM/DD/YYYY h:mm A'
|
||||
},
|
||||
maxSpan: { days: 10 },
|
||||
applyButtonClasses: 'my-apply-class',
|
||||
cancelButtonClasses: 'my-cancel-class',
|
||||
showDropdowns: true,
|
||||
maxYear: 3000,
|
||||
minYear: 2000
|
||||
})
|
||||
.data('daterangepicker')
|
||||
.remove();
|
||||
|
||||
$('#reportrange').daterangepicker({
|
||||
ranges: {
|
||||
'Today': [moment(), moment()],
|
||||
'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
|
||||
Today: [moment(), moment()],
|
||||
Yesterday: [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
|
||||
'Last 7 Days': [moment().subtract(6, 'days'), moment()],
|
||||
'Last 30 Days': [moment().subtract(29, 'days'), moment()],
|
||||
'This Month': [moment().startOf('month'), moment().endOf('month')],
|
||||
'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
|
||||
'Last Month': [
|
||||
moment()
|
||||
.subtract(1, 'month')
|
||||
.startOf('month'),
|
||||
moment()
|
||||
.subtract(1, 'month')
|
||||
.endOf('month')
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
$('input[name="datefilter"]').on('apply.daterangepicker', function (ev, picker) {
|
||||
$(this).val(picker.startDate.format('MM/DD/YYYY') + ' - ' + picker.endDate.format('MM/DD/YYYY'));
|
||||
$('input[name="datefilter"]').on('apply.daterangepicker', function(ev, picker) {
|
||||
$(this).val(
|
||||
`${picker.startDate.format('MM/DD/YYYY')} - ${picker.endDate.format('MM/DD/YYYY')}`
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
$('input[name="datefilter"]').on('cancel.daterangepicker', function (ev, picker) {
|
||||
$('input[name="datefilter"]').on('cancel.daterangepicker', function(ev, picker) {
|
||||
$(this).val('');
|
||||
});
|
||||
|
||||
$('#demo').daterangepicker({
|
||||
"startDate": "05/06/2016",
|
||||
"endDate": "05/12/2016"
|
||||
}, function (start: moment.Moment, end: moment.Moment, label: string) {
|
||||
console.log("New date range selected: ' + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD') + ' (predefined range: ' + label + ')");
|
||||
});
|
||||
|
||||
$(function() {
|
||||
|
||||
function cb(start: moment.Moment, end: moment.Moment) {
|
||||
$('#reportrange span').html(start.format('MMMM D, YYYY') + ' - ' + end.format('MMMM D, YYYY'));
|
||||
}
|
||||
cb(moment().subtract(29, 'days'), moment());
|
||||
|
||||
$('#reportrange').daterangepicker({
|
||||
ranges: {
|
||||
'Today': [moment(), moment()],
|
||||
'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
|
||||
'Last 7 Days': [moment().subtract(6, 'days'), moment()],
|
||||
'Last 30 Days': [moment().subtract(29, 'days'), moment()],
|
||||
'This Month': [moment().startOf('month'), moment().endOf('month')],
|
||||
'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
|
||||
}
|
||||
}, cb);
|
||||
|
||||
$('#reportrange').daterangepicker({
|
||||
ranges: {
|
||||
'Today': [moment(), moment()],
|
||||
'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
|
||||
'Last 7 Days': [moment().subtract(6, 'days'), moment()],
|
||||
'Last 30 Days': [moment().subtract(29, 'days'), moment()]
|
||||
$('#demo').daterangepicker(
|
||||
{
|
||||
startDate: '05/06/2016',
|
||||
endDate: '05/12/2016'
|
||||
},
|
||||
showCustomRangeLabel: false
|
||||
}, cb);
|
||||
(start: moment.Moment, end: moment.Moment, label: string) => {
|
||||
console.log(
|
||||
"New date range selected: ' + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD') + ' (predefined range: ' + label + ')"
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
$('#endDate').daterangepicker({
|
||||
singleDatePicker: true,
|
||||
startDate: moment()
|
||||
$(() => {
|
||||
function cb(start: moment.Moment, end: moment.Moment) {
|
||||
$('#reportrange span').html(
|
||||
`${start.format('MMMM D, YYYY')} - ${end.format('MMMM D, YYYY')}`
|
||||
);
|
||||
}
|
||||
cb(moment().subtract(29, 'days'), moment());
|
||||
|
||||
$('#reportrange').daterangepicker(
|
||||
{
|
||||
ranges: {
|
||||
Today: [moment(), moment()],
|
||||
Yesterday: [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
|
||||
'Last 7 Days': [moment().subtract(6, 'days'), moment()],
|
||||
'Last 30 Days': [moment().subtract(29, 'days'), moment()],
|
||||
'This Month': [moment().startOf('month'), moment().endOf('month')],
|
||||
'Last Month': [
|
||||
moment()
|
||||
.subtract(1, 'month')
|
||||
.startOf('month'),
|
||||
moment()
|
||||
.subtract(1, 'month')
|
||||
.endOf('month')
|
||||
]
|
||||
}
|
||||
},
|
||||
cb
|
||||
);
|
||||
|
||||
$('#reportrange').daterangepicker(
|
||||
{
|
||||
ranges: {
|
||||
Today: [moment(), moment()],
|
||||
Yesterday: [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
|
||||
'Last 7 Days': [moment().subtract(6, 'days'), moment()],
|
||||
'Last 30 Days': [moment().subtract(29, 'days'), moment()]
|
||||
},
|
||||
showCustomRangeLabel: false
|
||||
},
|
||||
cb
|
||||
);
|
||||
|
||||
$('#endDate').daterangepicker({
|
||||
singleDatePicker: true,
|
||||
startDate: moment()
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
declare const host: HTMLElement;
|
||||
function test_from_amd() {
|
||||
var picker = new daterangepicker(host);
|
||||
console.log(picker.startDate.format("YYYY-MM-DD"));
|
||||
const picker = new daterangepicker(host);
|
||||
console.log(picker.startDate.format('YYYY-MM-DD'));
|
||||
}
|
||||
|
||||
Vendored
+71
-47
@@ -1,4 +1,4 @@
|
||||
// Type definitions for Date Range Picker v2.1.30
|
||||
// Type definitions for Date Range Picker 3.0
|
||||
// Project: http://www.daterangepicker.com/
|
||||
// Definitions by: SirMartin <https://github.com/SirMartin>
|
||||
// Steven Masala <https://github.com/smasala>
|
||||
@@ -7,62 +7,81 @@
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
/// <reference types="jquery"/>
|
||||
import moment = require("moment");
|
||||
import moment = require('moment');
|
||||
|
||||
declare global {
|
||||
interface JQuery {
|
||||
daterangepicker(settings?: daterangepicker.Settings): JQuery;
|
||||
daterangepicker(settings?: daterangepicker.Settings, callback?: daterangepicker.DataRangePickerCallback): JQuery;
|
||||
daterangepicker: ((
|
||||
options?: daterangepicker.Options,
|
||||
callback?: daterangepicker.DataRangePickerCallback
|
||||
) => JQuery) & { defaultOptions?: daterangepicker.Options };
|
||||
data(key: 'daterangepicker'): daterangepicker | undefined;
|
||||
}
|
||||
}
|
||||
|
||||
declare const daterangepicker: daterangepicker.DateRangePicker;
|
||||
declare class daterangepicker {
|
||||
constructor(
|
||||
element: HTMLElement,
|
||||
options?: daterangepicker.Options,
|
||||
callback?: daterangepicker.DataRangePickerCallback
|
||||
);
|
||||
|
||||
startDate: moment.Moment;
|
||||
endDate: moment.Moment;
|
||||
container: JQuery;
|
||||
|
||||
setStartDate(date: daterangepicker.DateOrString): void;
|
||||
setEndDate(date: daterangepicker.DateOrString): void;
|
||||
remove(): void;
|
||||
}
|
||||
|
||||
declare namespace daterangepicker {
|
||||
type DataRangePickerCallback = (start: moment.Moment, end: moment.Moment, label: string | null) => any;
|
||||
type DataRangePickerCallback = (
|
||||
start: moment.Moment,
|
||||
end: moment.Moment,
|
||||
label: string | null
|
||||
) => void;
|
||||
|
||||
interface DateRangePicker {
|
||||
new (element: HTMLElement, settings?: daterangepicker.Settings, callback?: DataRangePickerCallback): DateRangePicker;
|
||||
|
||||
startDate: moment.Moment;
|
||||
endDate: moment.Moment;
|
||||
container: JQuery;
|
||||
|
||||
setStartDate(date: Date | moment.Moment | string): void;
|
||||
setEndDate(date: Date | moment.Moment | string): void;
|
||||
remove(): void;
|
||||
}
|
||||
type DateOrString = string | moment.Moment | Date;
|
||||
|
||||
interface DatepickerEventObject extends JQueryEventObject {
|
||||
date: Date;
|
||||
format(format?: string): string;
|
||||
}
|
||||
|
||||
interface Settings {
|
||||
interface Options {
|
||||
/**
|
||||
* The start of the initially selected date range
|
||||
*/
|
||||
startDate?: string | moment.Moment | Date;
|
||||
startDate?: DateOrString;
|
||||
/**
|
||||
* The end of the initially selected date range
|
||||
*/
|
||||
endDate?: string | moment.Moment | Date;
|
||||
endDate?: DateOrString;
|
||||
/**
|
||||
* The earliest date a user may select
|
||||
* The earliest date a user may select
|
||||
*/
|
||||
minDate?: string | moment.Moment | Date;
|
||||
minDate?: DateOrString;
|
||||
/**
|
||||
* The latest date a user may select
|
||||
*/
|
||||
maxDate?: string | moment.Moment | Date;
|
||||
maxDate?: DateOrString;
|
||||
/**
|
||||
* The maximum span between the selected start and end dates. Can have any property you can add to a moment object (i.e. days, months)
|
||||
*/
|
||||
dateLimit?: any;
|
||||
maxSpan?: moment.MomentInput | moment.Duration;
|
||||
/**
|
||||
* Show year and month select boxes above calendars to jump to a specific month and year
|
||||
*/
|
||||
showDropdowns?: boolean;
|
||||
/**
|
||||
* The minimum year shown in the dropdowns when `showDropdowns` is set to true.
|
||||
*/
|
||||
minYear?: number;
|
||||
/**
|
||||
* The maximum year shown in the dropdowns when `showDropdowns` is set to true.
|
||||
*/
|
||||
maxYear?: number;
|
||||
/**
|
||||
* Show localized week numbers at the start of each week on the calendars
|
||||
*/
|
||||
@@ -90,15 +109,25 @@ declare namespace daterangepicker {
|
||||
/**
|
||||
* Set predefined date ranges the user can select from.Each key is the label for the range, and its value an array with two dates representing the bounds of the range.
|
||||
*/
|
||||
ranges?: any;
|
||||
ranges?: { [name: string]: [DateOrString, DateOrString] };
|
||||
/**
|
||||
* (string: 'left'/'right'/'center') Whether the picker appears aligned to the left, to the right, or centered under the HTML element it's attached to
|
||||
* Whether to show the 'Custom Range' label or just pre-defined ranges
|
||||
*/
|
||||
opens?: string;
|
||||
showCustomRangeLabel?: boolean;
|
||||
/**
|
||||
* (string: 'down' or 'up') Whether the picker appears below (default) or above the HTML element it's attached to
|
||||
* Normally, if you use the `ranges` option to specify pre-defined date ranges, calendars
|
||||
* for choosing a custom date range are not shown until the user clicks "Custom Range".
|
||||
* When this option is set to true, the calendars for choosing a custom date range are always shown instead.
|
||||
*/
|
||||
drops?: string;
|
||||
alwaysShowCalendars?: boolean;
|
||||
/**
|
||||
* Whether the picker appears aligned to the left, to the right, or centered under the HTML element it's attached to
|
||||
*/
|
||||
opens?: 'left' | 'right' | 'center';
|
||||
/**
|
||||
* Whether the picker appears below (default) or above the HTML element it's attached to
|
||||
*/
|
||||
drops?: 'down' | 'up';
|
||||
/**
|
||||
* CSS class names that will be added to all buttons in the picker
|
||||
*/
|
||||
@@ -106,11 +135,11 @@ declare namespace daterangepicker {
|
||||
/**
|
||||
* CSS class string that will be added to the apply button
|
||||
*/
|
||||
applyClass?: string;
|
||||
applyButtonClasses?: string;
|
||||
/**
|
||||
* CSS class string that will be added to the cancel button
|
||||
*/
|
||||
cancelClass?: string;
|
||||
* CSS class string that will be added to the cancel button
|
||||
*/
|
||||
cancelButtonClasses?: string;
|
||||
/**
|
||||
* Allows you to provide localized strings for buttons and labels, customize the date display format, and change the first day of week for the calendars.
|
||||
*/
|
||||
@@ -124,33 +153,28 @@ declare namespace daterangepicker {
|
||||
*/
|
||||
autoApply?: boolean;
|
||||
/**
|
||||
* When enabled, the two calendars displayed will always be for two sequential months (i.e.January and February), and both will be advanced when clicking the left or right arrows above the calendars.When disabled, the two calendars can be individually advanced and display any month/ year.
|
||||
* When enabled, the two calendars displayed will always be for two sequential months (i.e.
|
||||
* January and February), and both will be advanced when clicking the left or right arrows
|
||||
* above the calendars.When disabled, the two calendars can be individually advanced and
|
||||
* display any month/ year.
|
||||
*/
|
||||
linkedCalendars?: boolean;
|
||||
/**
|
||||
* jQuery selector of the parent element that the date range picker will be added to, if not provided this will be 'body'
|
||||
*/
|
||||
parentEl?: string;
|
||||
/**
|
||||
* A function that is passed each date in the two calendars before they are displayed, and may return true or false to indicate whether that date should be available for selection or not.
|
||||
*/
|
||||
isInvalidDate?(startDate: string | moment.Moment | Date, endDate?: string | moment.Moment | Date): boolean;
|
||||
isInvalidDate?(startDate: DateOrString, endDate?: DateOrString): boolean;
|
||||
/**
|
||||
* A function that is passed each date in the two calendars before they are displayed, and may return a string or array of CSS class names to apply to that date's calendar cell.
|
||||
*/
|
||||
isCustomDate?(date: string | moment.Moment | Date): string | string[] | undefined;
|
||||
isCustomDate?(date: DateOrString): string | string[] | undefined;
|
||||
/**
|
||||
* Indicates whether the date range picker should automatically update the value of an < input > element it's attached to at initialization and when the selected dates change.
|
||||
*/
|
||||
autoUpdateInput?: boolean;
|
||||
/**
|
||||
* Normally, if you use the ranges option to specify pre- defined date ranges, calendars for choosing a custom date range are not shown until the user clicks "Custom Range".When this option is set to true, the calendars for choosing a custom date range are always shown instead.
|
||||
*/
|
||||
alwaysShowCalendars?: boolean;
|
||||
/**
|
||||
* Whether to show the 'Custom Range' label or just pre-defined ranges
|
||||
*/
|
||||
showCustomRangeLabel?: boolean;
|
||||
* jQuery selector of the parent element that the date range picker will be added to, if not provided this will be 'body'
|
||||
*/
|
||||
parentEl?: string;
|
||||
}
|
||||
|
||||
interface Locale {
|
||||
|
||||
@@ -1,79 +1 @@
|
||||
{
|
||||
"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" }
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import * as dl from "deline";
|
||||
|
||||
const moduleName = "deline";
|
||||
|
||||
dl.deline(`deline`); // $ExpectType string
|
||||
dl.deline(`module name: ${moduleName}`); // $ExpectType string
|
||||
dl.deline`deline`; // $ExpectType string
|
||||
dl.deline`tagged template: ${moduleName}`; // $ExpectType string
|
||||
dl.deline`
|
||||
tagged template:
|
||||
|
||||
${moduleName}
|
||||
`;
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
// Type definitions for deline 1.0
|
||||
// Project: https://github.com/airbnb/deline#readme
|
||||
// Definitions by: Inaki Arroyo <https://github.com/iarroyo5>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export function deline(strings: string | TemplateStringsArray, ...values: any[]): string;
|
||||
@@ -6,7 +6,7 @@
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
@@ -18,6 +18,6 @@
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"ids-tests.ts"
|
||||
"deline-tests.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Vendored
+42
@@ -0,0 +1,42 @@
|
||||
// Type definitions for dom-to-image 2.6
|
||||
// Project: https://github.com/tsayen/dom-to-image
|
||||
// Definitions by: Jip Sterk <https://github.com/JipSterk>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
export interface DomToImage {
|
||||
toSvg(node: Node, options?: Options): Promise<string>;
|
||||
toPng(node: Node, options?: Options): Promise<string>;
|
||||
toJpeg(node: Node, options?: Options): Promise<string>;
|
||||
toBlob(node: Node, options?: Options): Promise<Blob>;
|
||||
toPixelData(node: Node, options?: Options): Promise<string>;
|
||||
}
|
||||
|
||||
export interface Options {
|
||||
filter?: (node: Node) => boolean;
|
||||
bgcolor?: string;
|
||||
width?: number;
|
||||
height?: number;
|
||||
style?: {};
|
||||
quality?: number;
|
||||
imagePlaceholder?: string;
|
||||
cachebust?: boolean;
|
||||
}
|
||||
|
||||
export const DomToImage: DomToImage;
|
||||
|
||||
type DomToImage_ = DomToImage;
|
||||
type Options_ = Options;
|
||||
|
||||
export default DomToImage;
|
||||
|
||||
declare global {
|
||||
namespace DomToImage {
|
||||
type Options = Options_;
|
||||
type DomToImage = DomToImage_;
|
||||
}
|
||||
|
||||
const DomToImage: DomToImage.DomToImage;
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
const node = new Node();
|
||||
|
||||
const options: DomToImage.Options = {
|
||||
filter,
|
||||
bgcolor: '#24292e',
|
||||
style: {
|
||||
width: '100px'
|
||||
},
|
||||
width: 100,
|
||||
height: 100,
|
||||
quality: 0.1,
|
||||
imagePlaceholder: 'data:image/gif;base64,R0lGODlhAQABAIAAAP',
|
||||
cachebust: true
|
||||
};
|
||||
|
||||
function filter(node: Node): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
async function testToSvg() {
|
||||
const svg = await DomToImage.toSvg(node, { filter });
|
||||
}
|
||||
|
||||
async function testToPng() {
|
||||
const png = await DomToImage.toPng(node, { bgcolor: '#24292e', style: { width: '100px' } });
|
||||
}
|
||||
|
||||
async function testToJpeg() {
|
||||
const jpeg = await DomToImage.toJpeg(node, { width: 100, height: 100 });
|
||||
}
|
||||
|
||||
async function testToBlob() {
|
||||
const blob = await DomToImage.toBlob(node, { quality: 0.1, });
|
||||
}
|
||||
|
||||
async function testToPixelData() {
|
||||
const pixelData = await DomToImage.toPixelData(node, { imagePlaceholder: 'data:image/gif;base64,R0lGODlhAQABAIAAAP', cachebust: true });
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
import domToImage, { Options } from 'dom-to-image';
|
||||
|
||||
const node = new Node();
|
||||
|
||||
const options: Options = {
|
||||
filter,
|
||||
bgcolor: '#24292e',
|
||||
style: {
|
||||
width: '100px'
|
||||
},
|
||||
width: 100,
|
||||
height: 100,
|
||||
quality: 0.1,
|
||||
imagePlaceholder: 'data:image/gif;base64,R0lGODlhAQABAIAAAP',
|
||||
cachebust: true
|
||||
};
|
||||
|
||||
function filter(node: Node): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
async function testToSvg() {
|
||||
const svg = await domToImage.toSvg(node, { filter });
|
||||
}
|
||||
|
||||
async function testToPng() {
|
||||
const png = await domToImage.toPng(node, { bgcolor: '#24292e', style: { width: '100px' } });
|
||||
}
|
||||
|
||||
async function testToJpeg() {
|
||||
const jpeg = await domToImage.toJpeg(node, { width: 100, height: 100 });
|
||||
}
|
||||
|
||||
async function testToBlob() {
|
||||
const blob = await domToImage.toBlob(node, { quality: 0.1, });
|
||||
}
|
||||
|
||||
async function testToPixelData() {
|
||||
const pixelData = await domToImage.toPixelData(node, { imagePlaceholder: 'data:image/gif;base64,R0lGODlhAQABAIAAAP', cachebust: true });
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
import { Options, DomToImage } from 'dom-to-image';
|
||||
|
||||
const node = new Node();
|
||||
|
||||
const options: Options = {
|
||||
filter,
|
||||
bgcolor: '#24292e',
|
||||
style: {
|
||||
width: '100px'
|
||||
},
|
||||
width: 100,
|
||||
height: 100,
|
||||
quality: 0.1,
|
||||
imagePlaceholder: 'data:image/gif;base64,R0lGODlhAQABAIAAAP',
|
||||
cachebust: true
|
||||
};
|
||||
|
||||
function filter(node: Node): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
async function testToSvg() {
|
||||
const svg = await DomToImage.toSvg(node, { filter });
|
||||
}
|
||||
|
||||
async function testToPng() {
|
||||
const png = await DomToImage.toPng(node, { bgcolor: '#24292e', style: { width: '100px' } });
|
||||
}
|
||||
|
||||
async function testToJpeg() {
|
||||
const jpeg = await DomToImage.toJpeg(node, { width: 100, height: 100 });
|
||||
}
|
||||
|
||||
async function testToBlob() {
|
||||
const blob = await DomToImage.toBlob(node, { quality: 0.1, });
|
||||
}
|
||||
|
||||
async function testToPixelData() {
|
||||
const pixelData = await DomToImage.toPixelData(node, { imagePlaceholder: 'data:image/gif;base64,R0lGODlhAQABAIAAAP', cachebust: true });
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"test/dom-to-image-module-tests.ts",
|
||||
"test/dom-to-image-global-tests.ts",
|
||||
"test/dom-to-image-import-default-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
Vendored
+1
-1
@@ -36,7 +36,7 @@ export declare function mapSync(syncFunction: Function): MapStream;
|
||||
*
|
||||
* @param matcher
|
||||
*/
|
||||
export declare function split(matcher: string | RegExp): MapStream;
|
||||
export declare function split(matcher?: string | RegExp): MapStream;
|
||||
|
||||
/**
|
||||
* Create a through stream that emits separator between each chunk, just like Array#join
|
||||
|
||||
+1
-7
@@ -4,16 +4,10 @@
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
import { Plugin, NewLoader, OldLoader } from 'webpack';
|
||||
import { Plugin, Loader } from 'webpack';
|
||||
|
||||
export = ExtractTextPlugin;
|
||||
|
||||
/**
|
||||
* extract-text-webpack-plugin has no support for .options instead of .query yet.
|
||||
* See https://github.com/webpack/extract-text-webpack-plugin/issues/281
|
||||
*/
|
||||
type Loader = string | OldLoader | NewLoader;
|
||||
|
||||
/**
|
||||
* Use an `ExtractTextPlugin` instance and a loader returned by `extract` in concert to write files to disk instead of loading them into others.
|
||||
* Usage example at https://github.com/webpack/extract-text-webpack-plugin#usage-example-with-css
|
||||
|
||||
+2
@@ -1,6 +1,7 @@
|
||||
// Type definitions for libphonenumber v7.4.3
|
||||
// Project: https://github.com/googlei18n/libphonenumber, https://github.com/seegno/google-libphonenumber
|
||||
// Definitions by: Leon Yu <https://github.com/leonyu>
|
||||
// Roman Jurkov <https://github.com/winfinit>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare namespace libphonenumber {
|
||||
@@ -112,6 +113,7 @@ declare namespace libphonenumber {
|
||||
export class PhoneNumberUtil {
|
||||
static getInstance(): PhoneNumberUtil
|
||||
format(phoneNumber: PhoneNumber, format: PhoneNumberFormat): string;
|
||||
formatOutOfCountryCallingNumber(phoneNumber: PhoneNumber, regionDialingFrom?: string): string;
|
||||
getNddPrefixForRegion(regionCode?: string, stripNonDigits?: boolean): string | undefined;
|
||||
getNumberType(phoneNumber: PhoneNumber): PhoneNumberType;
|
||||
getCountryCodeForRegion(supportedRegion:string):string;
|
||||
|
||||
@@ -1,9 +1,20 @@
|
||||
import GoogleMapReact, { BootstrapURLKeys } from 'google-map-react';
|
||||
import GoogleMapReact, { BootstrapURLKeys, MapOptions } from 'google-map-react';
|
||||
import * as React from 'react';
|
||||
|
||||
const center = { lat: 0, lng: 0 };
|
||||
|
||||
const key: BootstrapURLKeys = { key: 'my-google-maps-key' };
|
||||
const client: BootstrapURLKeys = { client: 'my-client-identifier', v: '3.28' , language: 'en' };
|
||||
const options: MapOptions = {
|
||||
zoomControl: false,
|
||||
gestureHandling: 'cooperative',
|
||||
styles: [
|
||||
{
|
||||
featureType: "administrative",
|
||||
elementType: "all",
|
||||
stylers: [ {saturation: "-100"} ]
|
||||
}
|
||||
],
|
||||
};
|
||||
|
||||
<GoogleMapReact center={center} zoom={3} bootstrapURLKeys={client}/>;
|
||||
<GoogleMapReact center={center} zoom={3} bootstrapURLKeys={client} options={options} />;
|
||||
|
||||
Vendored
+40
-7
@@ -8,15 +8,48 @@ import * as React from 'react';
|
||||
|
||||
export type BootstrapURLKeys = ({ key: string; } | { client: string; v: string; }) & { language?: string };
|
||||
|
||||
export interface Options {
|
||||
styles?: any[];
|
||||
scrollwheel?: boolean;
|
||||
panControl?: boolean;
|
||||
export interface MapTypeStyle {
|
||||
elementType: string;
|
||||
featureType: string;
|
||||
stylers: any[];
|
||||
}
|
||||
|
||||
export interface MapOptions {
|
||||
// Any options from https://developers.google.com/maps/documentation/javascript/reference/3/#MapOptions
|
||||
// excluding 'zoom' and 'center' which get set via props.
|
||||
backgroundColor?: string;
|
||||
clickableIcons?: boolean;
|
||||
disableDefaultUI?: boolean;
|
||||
disableDoubleClickZoom?: boolean;
|
||||
draggable?: boolean;
|
||||
draggableCursor?: string;
|
||||
draggingCursor?: string;
|
||||
fullscreenControl?: boolean;
|
||||
fullscreenControlOptions?: {position: number};
|
||||
gestureHandling?: string;
|
||||
heading?: number;
|
||||
keyboardShortcuts?: boolean;
|
||||
mapTypeControl?: boolean;
|
||||
minZoomOverride?: boolean;
|
||||
mapTypeControlOptions?: any;
|
||||
mapTypeId?: string;
|
||||
minZoom?: number;
|
||||
maxZoom?: number;
|
||||
gestureHandling?: string;
|
||||
noClear?: boolean;
|
||||
panControl?: boolean;
|
||||
panControlOptions?: {position: number};
|
||||
rotateControl?: boolean;
|
||||
rotateControlOptions?: {position: number};
|
||||
scaleControl?: boolean;
|
||||
scaleControlOptions?: any;
|
||||
scrollwheel?: boolean;
|
||||
streetView?: any;
|
||||
streetViewControl?: boolean;
|
||||
streetViewControlOptions?: {position: number};
|
||||
styles?: MapTypeStyle[];
|
||||
tilt?: number;
|
||||
zoomControl?: boolean;
|
||||
zoomControlOptions?: {position: number};
|
||||
minZoomOverride?: boolean; // Not a standard option; specific to google-map-react: https://github.com/google-map-react/google-map-react/pull/154
|
||||
}
|
||||
|
||||
export interface Maps {
|
||||
@@ -87,7 +120,7 @@ export interface Props {
|
||||
defaultZoom?: number;
|
||||
zoom?: number;
|
||||
hoverDistance?: number;
|
||||
options?: Options | ((maps: Maps) => Options);
|
||||
options?: MapOptions | ((maps: Maps) => MapOptions);
|
||||
margin?: any[];
|
||||
debounced?: boolean;
|
||||
draggable?: boolean;
|
||||
|
||||
+7
-6
@@ -1,3 +1,4 @@
|
||||
import Maybe from "../tsutils/Maybe";
|
||||
import { getLocation } from "../language";
|
||||
import { ASTNode } from "../language/ast";
|
||||
import { Source } from "../language/source";
|
||||
@@ -58,7 +59,7 @@ export class GraphQLError extends Error {
|
||||
/**
|
||||
* The original error thrown from a field resolver during execution.
|
||||
*/
|
||||
readonly originalError: Error | void;
|
||||
readonly originalError: Maybe<Error>;
|
||||
|
||||
/**
|
||||
* Extension fields to add to the formatted error.
|
||||
@@ -68,10 +69,10 @@ export class GraphQLError extends Error {
|
||||
constructor(
|
||||
message: string,
|
||||
nodes?: ReadonlyArray<ASTNode> | ASTNode | undefined,
|
||||
source?: Source | void,
|
||||
positions?: ReadonlyArray<number> | void,
|
||||
path?: ReadonlyArray<string | number> | void,
|
||||
originalError?: Error | void,
|
||||
extensions?: { [key: string]: any } | void
|
||||
source?: Maybe<Source>,
|
||||
positions?: Maybe<ReadonlyArray<number>>,
|
||||
path?: Maybe<ReadonlyArray<string | number>>,
|
||||
originalError?: Maybe<Error>,
|
||||
extensions?: Maybe<{ [key: string]: any }>
|
||||
);
|
||||
}
|
||||
|
||||
Vendored
+12
-11
@@ -1,3 +1,4 @@
|
||||
import Maybe from "../tsutils/Maybe";
|
||||
import { GraphQLError, locatedError } from "../error";
|
||||
import { GraphQLSchema } from "../type/schema";
|
||||
import {
|
||||
@@ -51,9 +52,9 @@ export type ExecutionArgs = {
|
||||
document: DocumentNode;
|
||||
rootValue?: any;
|
||||
contextValue?: any;
|
||||
variableValues?: { [key: string]: any } | void;
|
||||
operationName?: string | void;
|
||||
fieldResolver?: GraphQLFieldResolver<any, any> | void;
|
||||
variableValues?: Maybe<{ [key: string]: any }>;
|
||||
operationName?: Maybe<string>;
|
||||
fieldResolver?: Maybe<GraphQLFieldResolver<any, any>>;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -74,9 +75,9 @@ export function execute(
|
||||
document: DocumentNode,
|
||||
rootValue?: any,
|
||||
contextValue?: any,
|
||||
variableValues?: { [key: string]: any } | void,
|
||||
operationName?: string | void,
|
||||
fieldResolver?: GraphQLFieldResolver<any, any> | void
|
||||
variableValues?: Maybe<{ [key: string]: any }>,
|
||||
operationName?: Maybe<string>,
|
||||
fieldResolver?: Maybe<GraphQLFieldResolver<any, any>>
|
||||
): MaybePromise<ExecutionResult>;
|
||||
|
||||
/**
|
||||
@@ -101,7 +102,7 @@ export function addPath(
|
||||
export function assertValidExecutionArguments(
|
||||
schema: GraphQLSchema,
|
||||
document: DocumentNode,
|
||||
rawVariableValues: { [key: string]: any } | void
|
||||
rawVariableValues: Maybe<{ [key: string]: any }>
|
||||
): void;
|
||||
|
||||
/**
|
||||
@@ -115,9 +116,9 @@ export function buildExecutionContext(
|
||||
document: DocumentNode,
|
||||
rootValue: any,
|
||||
contextValue: any,
|
||||
rawVariableValues: { [key: string]: any } | void,
|
||||
operationName: string | void,
|
||||
fieldResolver: GraphQLFieldResolver<any, any> | void
|
||||
rawVariableValues: Maybe<{ [key: string]: any }>,
|
||||
operationName: Maybe<string>,
|
||||
fieldResolver: Maybe<GraphQLFieldResolver<any, any>>
|
||||
): ReadonlyArray<GraphQLError> | ExecutionContext;
|
||||
|
||||
/**
|
||||
@@ -181,4 +182,4 @@ export function getFieldDef(
|
||||
schema: GraphQLSchema,
|
||||
parentType: GraphQLObjectType,
|
||||
fieldName: string
|
||||
): GraphQLField<any, any> | void;
|
||||
): Maybe<GraphQLField<any, any>>;
|
||||
|
||||
Vendored
+3
-2
@@ -1,3 +1,4 @@
|
||||
import Maybe from "../tsutils/Maybe";
|
||||
import { GraphQLError } from "../error";
|
||||
import { GraphQLInputType, GraphQLField, GraphQLArgument } from "../type/definition";
|
||||
import { GraphQLDirective } from "../type/directives";
|
||||
@@ -35,7 +36,7 @@ export function getVariableValues(
|
||||
export function getArgumentValues(
|
||||
def: GraphQLField<any, any> | GraphQLDirective,
|
||||
node: FieldNode | DirectiveNode,
|
||||
variableValues?: { [key: string]: any } | void
|
||||
variableValues?: Maybe<{ [key: string]: any }>
|
||||
): { [key: string]: any };
|
||||
|
||||
/**
|
||||
@@ -54,5 +55,5 @@ export function getDirectiveValues(
|
||||
node: {
|
||||
readonly directives?: ReadonlyArray<DirectiveNode>;
|
||||
},
|
||||
variableValues?: { [key: string]: any } | void
|
||||
variableValues?: Maybe<{ [key: string]: any }>
|
||||
): undefined | { [key: string]: any };
|
||||
|
||||
Vendored
+10
-9
@@ -1,3 +1,4 @@
|
||||
import Maybe from "./tsutils/Maybe";
|
||||
import { Source } from "./language/source";
|
||||
import { GraphQLFieldResolver } from "./type/definition";
|
||||
import { GraphQLSchema } from "./type/schema";
|
||||
@@ -38,9 +39,9 @@ export interface GraphQLArgs {
|
||||
source: Source | string;
|
||||
rootValue?: any;
|
||||
contextValue?: any;
|
||||
variableValues?: { [key: string]: any } | void;
|
||||
operationName?: string | void;
|
||||
fieldResolver?: GraphQLFieldResolver<any, any> | void;
|
||||
variableValues?: Maybe<{ [key: string]: any }>;
|
||||
operationName?: Maybe<string>;
|
||||
fieldResolver?: Maybe<GraphQLFieldResolver<any, any>>;
|
||||
}
|
||||
|
||||
export function graphql(args: GraphQLArgs): Promise<ExecutionResult>;
|
||||
@@ -49,9 +50,9 @@ export function graphql(
|
||||
source: Source | string,
|
||||
rootValue?: any,
|
||||
contextValue?: any,
|
||||
variableValues?: { [key: string]: any } | void,
|
||||
operationName?: string | void,
|
||||
fieldResolver?: GraphQLFieldResolver<any, any> | void
|
||||
variableValues?: Maybe<{ [key: string]: any }>,
|
||||
operationName?: Maybe<string>,
|
||||
fieldResolver?: Maybe<GraphQLFieldResolver<any, any>>
|
||||
): Promise<ExecutionResult>;
|
||||
|
||||
/**
|
||||
@@ -66,7 +67,7 @@ export function graphqlSync(
|
||||
source: Source | string,
|
||||
rootValue?: any,
|
||||
contextValue?: any,
|
||||
variableValues?: { [key: string]: any } | void,
|
||||
operationName?: string | void,
|
||||
fieldResolver?: GraphQLFieldResolver<any, any> | void
|
||||
variableValues?: Maybe<{ [key: string]: any }>,
|
||||
operationName?: Maybe<string>,
|
||||
fieldResolver?: Maybe<GraphQLFieldResolver<any, any>>
|
||||
): ExecutionResult;
|
||||
|
||||
Vendored
+1
@@ -13,6 +13,7 @@
|
||||
// Dylan Stewart <https://github.com/dyst5422>
|
||||
// Alessio Dionisi <https://github.com/adnsio>
|
||||
// Divyendu Singh <https://github.com/divyenduz>
|
||||
// Brad Zacher <https://github.com/bradzacher>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
|
||||
Vendored
+2
-1
@@ -1,3 +1,4 @@
|
||||
import Maybe from "../tsutils/Maybe";
|
||||
import { ASTNode, ASTKindToNode } from "./ast";
|
||||
import { TypeInfo } from "../utilities/TypeInfo";
|
||||
|
||||
@@ -157,4 +158,4 @@ export function visitWithTypeInfo(typeInfo: TypeInfo, visitor: Visitor<ASTKindTo
|
||||
* Given a visitor instance, if it is leaving or not, and a node kind, return
|
||||
* the function the visitor runtime should call.
|
||||
*/
|
||||
export function getVisitFn(visitor: Visitor<any>, kind: string, isLeaving: boolean): VisitFn<any> | void;
|
||||
export function getVisitFn(visitor: Visitor<any>, kind: string, isLeaving: boolean): Maybe<VisitFn<any>>;
|
||||
|
||||
+11
-10
@@ -1,3 +1,4 @@
|
||||
import Maybe from "../tsutils/Maybe";
|
||||
import { GraphQLSchema } from "../type/schema";
|
||||
import { DocumentNode } from "../language/ast";
|
||||
import { GraphQLFieldResolver } from "../type/definition";
|
||||
@@ -28,10 +29,10 @@ export function subscribe(args: {
|
||||
document: DocumentNode;
|
||||
rootValue?: any;
|
||||
contextValue?: any;
|
||||
variableValues?: { [key: string]: any } | void;
|
||||
operationName?: string | void;
|
||||
fieldResolver?: GraphQLFieldResolver<any, any> | void;
|
||||
subscribeFieldResolver?: GraphQLFieldResolver<any, any> | void;
|
||||
variableValues?: Maybe<{ [key: string]: any }>;
|
||||
operationName?: Maybe<string>;
|
||||
fieldResolver?: Maybe<GraphQLFieldResolver<any, any>>;
|
||||
subscribeFieldResolver?: Maybe<GraphQLFieldResolver<any, any>>;
|
||||
}): Promise<AsyncIterator<ExecutionResult> | ExecutionResult>;
|
||||
|
||||
export function subscribe(
|
||||
@@ -39,10 +40,10 @@ export function subscribe(
|
||||
document: DocumentNode,
|
||||
rootValue?: any,
|
||||
contextValue?: any,
|
||||
variableValues?: { [key: string]: any } | void,
|
||||
operationName?: string | void,
|
||||
fieldResolver?: GraphQLFieldResolver<any, any> | void,
|
||||
subscribeFieldResolver?: GraphQLFieldResolver<any, any> | void
|
||||
variableValues?: Maybe<{ [key: string]: any }>,
|
||||
operationName?: Maybe<string>,
|
||||
fieldResolver?: Maybe<GraphQLFieldResolver<any, any>>,
|
||||
subscribeFieldResolver?: Maybe<GraphQLFieldResolver<any, any>>
|
||||
): Promise<AsyncIterator<ExecutionResult> | ExecutionResult>;
|
||||
|
||||
/**
|
||||
@@ -69,6 +70,6 @@ export function createSourceEventStream(
|
||||
rootValue?: any,
|
||||
contextValue?: any,
|
||||
variableValues?: { [key: string]: any },
|
||||
operationName?: string | void,
|
||||
fieldResolver?: GraphQLFieldResolver<any, any> | void
|
||||
operationName?: Maybe<string>,
|
||||
fieldResolver?: Maybe<GraphQLFieldResolver<any, any>>
|
||||
): Promise<AsyncIterable<any> | ExecutionResult>;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
@@ -21,4 +21,4 @@
|
||||
"index.d.ts",
|
||||
"graphql-tests.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
// Conveniently represents flow's "Maybe" type https://flow.org/en/docs/types/maybe/
|
||||
type Maybe<T> = null | undefined | T
|
||||
|
||||
export default Maybe
|
||||
Vendored
+65
-64
@@ -1,3 +1,4 @@
|
||||
import Maybe from "../tsutils/Maybe";
|
||||
import { MaybePromise } from "../jsutils/MaybePromise";
|
||||
import {
|
||||
ScalarTypeDefinitionNode,
|
||||
@@ -254,8 +255,8 @@ export type Thunk<T> = (() => T) | T;
|
||||
*/
|
||||
export class GraphQLScalarType {
|
||||
name: string;
|
||||
description: string | void;
|
||||
astNode?: ScalarTypeDefinitionNode | void;
|
||||
description: Maybe<string>;
|
||||
astNode?: Maybe<ScalarTypeDefinitionNode>;
|
||||
constructor(config: GraphQLScalarTypeConfig<any, any>);
|
||||
|
||||
// Serializes an internal value to include in a response.
|
||||
@@ -265,7 +266,7 @@ export class GraphQLScalarType {
|
||||
parseValue(value: any): any;
|
||||
|
||||
// Parses an externally provided literal value to use as an input.
|
||||
parseLiteral(valueNode: ValueNode, variables?: { [key: string]: any } | void): any;
|
||||
parseLiteral(valueNode: ValueNode, variables?: Maybe<{ [key: string]: any }>): any;
|
||||
|
||||
toString(): string;
|
||||
toJSON(): string;
|
||||
@@ -274,11 +275,11 @@ export class GraphQLScalarType {
|
||||
|
||||
export interface GraphQLScalarTypeConfig<TInternal, TExternal> {
|
||||
name: string;
|
||||
description?: string | void;
|
||||
astNode?: ScalarTypeDefinitionNode | void;
|
||||
serialize(value: any): TExternal | void;
|
||||
parseValue?(value: any): TInternal | void;
|
||||
parseLiteral?(valueNode: ValueNode, variables: { [key: string]: any } | void): TInternal | void;
|
||||
description?: Maybe<string>;
|
||||
astNode?: Maybe<ScalarTypeDefinitionNode>;
|
||||
serialize(value: any): Maybe<TExternal>;
|
||||
parseValue?(value: any): Maybe<TInternal>;
|
||||
parseLiteral?(valueNode: ValueNode, variables: Maybe<{ [key: string]: any }>): Maybe<TInternal>;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -320,10 +321,10 @@ export interface GraphQLScalarTypeConfig<TInternal, TExternal> {
|
||||
*/
|
||||
export class GraphQLObjectType {
|
||||
name: string;
|
||||
description: string | void;
|
||||
astNode: ObjectTypeDefinitionNode | void;
|
||||
extensionASTNodes: ReadonlyArray<ObjectTypeExtensionNode> | void;
|
||||
isTypeOf: GraphQLIsTypeOfFn<any, any> | void;
|
||||
description: Maybe<string>;
|
||||
astNode: Maybe<ObjectTypeDefinitionNode>;
|
||||
extensionASTNodes: Maybe<ReadonlyArray<ObjectTypeExtensionNode>>;
|
||||
isTypeOf: Maybe<GraphQLIsTypeOfFn<any, any>>;
|
||||
|
||||
constructor(config: GraphQLObjectTypeConfig<any, any>);
|
||||
getFields(): GraphQLFieldMap<any, any>;
|
||||
@@ -335,19 +336,19 @@ export class GraphQLObjectType {
|
||||
|
||||
export interface GraphQLObjectTypeConfig<TSource, TContext> {
|
||||
name: string;
|
||||
interfaces?: Thunk<GraphQLInterfaceType[] | void>;
|
||||
interfaces?: Thunk<Maybe<GraphQLInterfaceType[]>>;
|
||||
fields: Thunk<GraphQLFieldConfigMap<TSource, TContext>>;
|
||||
isTypeOf?: GraphQLIsTypeOfFn<TSource, TContext> | void;
|
||||
description?: string | void;
|
||||
astNode?: ObjectTypeDefinitionNode | void;
|
||||
extensionASTNodes?: ReadonlyArray<ObjectTypeExtensionNode> | void;
|
||||
isTypeOf?: Maybe<GraphQLIsTypeOfFn<TSource, TContext>>;
|
||||
description?: Maybe<string>;
|
||||
astNode?: Maybe<ObjectTypeDefinitionNode>;
|
||||
extensionASTNodes?: Maybe<ReadonlyArray<ObjectTypeExtensionNode>>;
|
||||
}
|
||||
|
||||
export type GraphQLTypeResolver<TSource, TContext> = (
|
||||
value: TSource,
|
||||
context: TContext,
|
||||
info: GraphQLResolveInfo
|
||||
) => MaybePromise<GraphQLObjectType | string | void>;
|
||||
) => MaybePromise<Maybe<GraphQLObjectType | string>>;
|
||||
|
||||
export type GraphQLIsTypeOfFn<TSource, TContext> = (
|
||||
source: TSource,
|
||||
@@ -385,9 +386,9 @@ export interface GraphQLFieldConfig<TSource, TContext, TArgs = { [argName: strin
|
||||
args?: GraphQLFieldConfigArgumentMap;
|
||||
resolve?: GraphQLFieldResolver<TSource, TContext, TArgs>;
|
||||
subscribe?: GraphQLFieldResolver<TSource, TContext, TArgs>;
|
||||
deprecationReason?: string | void;
|
||||
description?: string | void;
|
||||
astNode?: FieldDefinitionNode | void;
|
||||
deprecationReason?: Maybe<string>;
|
||||
description?: Maybe<string>;
|
||||
astNode?: Maybe<FieldDefinitionNode>;
|
||||
}
|
||||
|
||||
export type GraphQLFieldConfigArgumentMap = { [key: string]: GraphQLArgumentConfig };
|
||||
@@ -395,8 +396,8 @@ export type GraphQLFieldConfigArgumentMap = { [key: string]: GraphQLArgumentConf
|
||||
export interface GraphQLArgumentConfig {
|
||||
type: GraphQLInputType;
|
||||
defaultValue?: any;
|
||||
description?: string | void;
|
||||
astNode?: InputValueDefinitionNode | void;
|
||||
description?: Maybe<string>;
|
||||
astNode?: Maybe<InputValueDefinitionNode>;
|
||||
}
|
||||
|
||||
export type GraphQLFieldConfigMap<TSource, TContext> = {
|
||||
@@ -405,22 +406,22 @@ export type GraphQLFieldConfigMap<TSource, TContext> = {
|
||||
|
||||
export interface GraphQLField<TSource, TContext, TArgs = { [key: string]: any }> {
|
||||
name: string;
|
||||
description: string | void;
|
||||
description: Maybe<string>;
|
||||
type: GraphQLOutputType;
|
||||
args: GraphQLArgument[];
|
||||
resolve?: GraphQLFieldResolver<TSource, TContext, TArgs>;
|
||||
subscribe?: GraphQLFieldResolver<TSource, TContext, TArgs>;
|
||||
isDeprecated?: boolean;
|
||||
deprecationReason?: string | void;
|
||||
astNode?: FieldDefinitionNode | void;
|
||||
deprecationReason?: Maybe<string>;
|
||||
astNode?: Maybe<FieldDefinitionNode>;
|
||||
}
|
||||
|
||||
export interface GraphQLArgument {
|
||||
name: string;
|
||||
type: GraphQLInputType;
|
||||
defaultValue?: any;
|
||||
description?: string | void;
|
||||
astNode?: InputValueDefinitionNode | void;
|
||||
description?: Maybe<string>;
|
||||
astNode?: Maybe<InputValueDefinitionNode>;
|
||||
}
|
||||
|
||||
export type GraphQLFieldMap<TSource, TContext> = {
|
||||
@@ -447,10 +448,10 @@ export type GraphQLFieldMap<TSource, TContext> = {
|
||||
*/
|
||||
export class GraphQLInterfaceType {
|
||||
name: string;
|
||||
description: string | void;
|
||||
astNode?: InterfaceTypeDefinitionNode | void;
|
||||
extensionASTNodes: ReadonlyArray<InterfaceTypeExtensionNode> | void;
|
||||
resolveType: GraphQLTypeResolver<any, any> | void;
|
||||
description: Maybe<string>;
|
||||
astNode?: Maybe<InterfaceTypeDefinitionNode>;
|
||||
extensionASTNodes: Maybe<ReadonlyArray<InterfaceTypeExtensionNode>>;
|
||||
resolveType: Maybe<GraphQLTypeResolver<any, any>>;
|
||||
|
||||
constructor(config: GraphQLInterfaceTypeConfig<any, any>);
|
||||
|
||||
@@ -469,10 +470,10 @@ export interface GraphQLInterfaceTypeConfig<TSource, TContext> {
|
||||
* the default implementation will call `isTypeOf` on each implementing
|
||||
* Object type.
|
||||
*/
|
||||
resolveType?: GraphQLTypeResolver<TSource, TContext> | void;
|
||||
description?: string | void;
|
||||
astNode?: InterfaceTypeDefinitionNode | void;
|
||||
extensionASTNodes?: ReadonlyArray<InterfaceTypeExtensionNode> | void;
|
||||
resolveType?: Maybe<GraphQLTypeResolver<TSource, TContext>>;
|
||||
description?: Maybe<string>;
|
||||
astNode?: Maybe<InterfaceTypeDefinitionNode>;
|
||||
extensionASTNodes?: Maybe<ReadonlyArray<InterfaceTypeExtensionNode>>;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -500,9 +501,9 @@ export interface GraphQLInterfaceTypeConfig<TSource, TContext> {
|
||||
*/
|
||||
export class GraphQLUnionType {
|
||||
name: string;
|
||||
description: string | void;
|
||||
astNode?: UnionTypeDefinitionNode | void;
|
||||
resolveType: GraphQLTypeResolver<any, any> | void;
|
||||
description: Maybe<string>;
|
||||
astNode?: Maybe<UnionTypeDefinitionNode>;
|
||||
resolveType: Maybe<GraphQLTypeResolver<any, any>>;
|
||||
|
||||
constructor(config: GraphQLUnionTypeConfig<any, any>);
|
||||
|
||||
@@ -521,9 +522,9 @@ export interface GraphQLUnionTypeConfig<TSource, TContext> {
|
||||
* the default implementation will call `isTypeOf` on each implementing
|
||||
* Object type.
|
||||
*/
|
||||
resolveType?: GraphQLTypeResolver<TSource, TContext> | void;
|
||||
description?: string | void;
|
||||
astNode?: UnionTypeDefinitionNode | void;
|
||||
resolveType?: Maybe<GraphQLTypeResolver<TSource, TContext>>;
|
||||
description?: Maybe<string>;
|
||||
astNode?: Maybe<UnionTypeDefinitionNode>;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -549,15 +550,15 @@ export interface GraphQLUnionTypeConfig<TSource, TContext> {
|
||||
*/
|
||||
export class GraphQLEnumType {
|
||||
name: string;
|
||||
description: string | void;
|
||||
astNode: EnumTypeDefinitionNode | void;
|
||||
description: Maybe<string>;
|
||||
astNode: Maybe<EnumTypeDefinitionNode>;
|
||||
|
||||
constructor(config: GraphQLEnumTypeConfig);
|
||||
getValues(): GraphQLEnumValue[];
|
||||
getValue(name: string): GraphQLEnumValue | void;
|
||||
serialize(value: any): string | void;
|
||||
parseValue(value: any): any;
|
||||
parseLiteral(valueNode: ValueNode, _variables: { [key: string]: any } | void): any;
|
||||
getValue(name: string): Maybe<GraphQLEnumValue>;
|
||||
serialize(value: any): Maybe<string>;
|
||||
parseValue(value: any): Maybe<any>;
|
||||
parseLiteral(valueNode: ValueNode, _variables: Maybe<{ [key: string]: any }>): Maybe<any>;
|
||||
toString(): string;
|
||||
toJSON(): string;
|
||||
inspect(): string;
|
||||
@@ -566,25 +567,25 @@ export class GraphQLEnumType {
|
||||
export interface GraphQLEnumTypeConfig {
|
||||
name: string;
|
||||
values: GraphQLEnumValueConfigMap;
|
||||
description?: string | void;
|
||||
astNode?: EnumTypeDefinitionNode | void;
|
||||
description?: Maybe<string>;
|
||||
astNode?: Maybe<EnumTypeDefinitionNode>;
|
||||
}
|
||||
|
||||
export type GraphQLEnumValueConfigMap = { [key: string]: GraphQLEnumValueConfig };
|
||||
|
||||
export interface GraphQLEnumValueConfig {
|
||||
value?: any;
|
||||
deprecationReason?: string | void;
|
||||
description?: string | void;
|
||||
astNode?: EnumValueDefinitionNode | void;
|
||||
deprecationReason?: Maybe<string>;
|
||||
description?: Maybe<string>;
|
||||
astNode?: Maybe<EnumValueDefinitionNode>;
|
||||
}
|
||||
|
||||
export interface GraphQLEnumValue {
|
||||
name: string;
|
||||
description: string | void;
|
||||
description: Maybe<string>;
|
||||
isDeprecated?: boolean;
|
||||
deprecationReason: string | void;
|
||||
astNode?: EnumValueDefinitionNode | void;
|
||||
deprecationReason: Maybe<string>;
|
||||
astNode?: Maybe<EnumValueDefinitionNode>;
|
||||
value: any;
|
||||
}
|
||||
|
||||
@@ -610,8 +611,8 @@ export interface GraphQLEnumValue {
|
||||
*/
|
||||
export class GraphQLInputObjectType {
|
||||
name: string;
|
||||
description: string | void;
|
||||
astNode: InputObjectTypeDefinitionNode | void;
|
||||
description: Maybe<string>;
|
||||
astNode: Maybe<InputObjectTypeDefinitionNode>;
|
||||
constructor(config: GraphQLInputObjectTypeConfig);
|
||||
getFields(): GraphQLInputFieldMap;
|
||||
toString(): string;
|
||||
@@ -622,15 +623,15 @@ export class GraphQLInputObjectType {
|
||||
export interface GraphQLInputObjectTypeConfig {
|
||||
name: string;
|
||||
fields: Thunk<GraphQLInputFieldConfigMap>;
|
||||
description?: string | void;
|
||||
astNode?: InputObjectTypeDefinitionNode | void;
|
||||
description?: Maybe<string>;
|
||||
astNode?: Maybe<InputObjectTypeDefinitionNode>;
|
||||
}
|
||||
|
||||
export interface GraphQLInputFieldConfig {
|
||||
type: GraphQLInputType;
|
||||
defaultValue?: any;
|
||||
description?: string | void;
|
||||
astNode?: InputValueDefinitionNode | void;
|
||||
description?: Maybe<string>;
|
||||
astNode?: Maybe<InputValueDefinitionNode>;
|
||||
}
|
||||
|
||||
export type GraphQLInputFieldConfigMap = {
|
||||
@@ -641,8 +642,8 @@ export interface GraphQLInputField {
|
||||
name: string;
|
||||
type: GraphQLInputType;
|
||||
defaultValue?: any;
|
||||
description?: string | void;
|
||||
astNode?: InputValueDefinitionNode | void;
|
||||
description?: Maybe<string>;
|
||||
astNode?: Maybe<InputValueDefinitionNode>;
|
||||
}
|
||||
|
||||
export type GraphQLInputFieldMap = { [key: string]: GraphQLInputField };
|
||||
|
||||
Vendored
+6
-5
@@ -1,3 +1,4 @@
|
||||
import Maybe from "../tsutils/Maybe";
|
||||
import { GraphQLFieldConfigArgumentMap, GraphQLArgument } from "./definition";
|
||||
import { DirectiveDefinitionNode } from "../language/ast";
|
||||
import { DirectiveLocationEnum } from "../language/directiveLocation";
|
||||
@@ -13,20 +14,20 @@ export function isDirective(directive: any): directive is GraphQLDirective;
|
||||
*/
|
||||
export class GraphQLDirective {
|
||||
name: string;
|
||||
description: string | void;
|
||||
description: Maybe<string>;
|
||||
locations: DirectiveLocationEnum[];
|
||||
args: GraphQLArgument[];
|
||||
astNode: DirectiveDefinitionNode | void;
|
||||
astNode: Maybe<DirectiveDefinitionNode>;
|
||||
|
||||
constructor(config: GraphQLDirectiveConfig);
|
||||
}
|
||||
|
||||
export interface GraphQLDirectiveConfig {
|
||||
name: string;
|
||||
description?: string | void;
|
||||
description?: Maybe<string>;
|
||||
locations: DirectiveLocationEnum[];
|
||||
args?: GraphQLFieldConfigArgumentMap | void;
|
||||
astNode?: DirectiveDefinitionNode | void;
|
||||
args?: Maybe<GraphQLFieldConfigArgumentMap>;
|
||||
astNode?: Maybe<DirectiveDefinitionNode>;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Vendored
+14
-13
@@ -1,3 +1,4 @@
|
||||
import Maybe from "../tsutils/Maybe";
|
||||
import { GraphQLObjectType } from "./definition";
|
||||
import { GraphQLType, GraphQLNamedType, GraphQLAbstractType } from "./definition";
|
||||
import { SchemaDefinitionNode } from "../language/ast";
|
||||
@@ -35,21 +36,21 @@ export function isSchema(schema: any): schema is GraphQLSchema;
|
||||
*
|
||||
*/
|
||||
export class GraphQLSchema {
|
||||
astNode: SchemaDefinitionNode | void;
|
||||
astNode: Maybe<SchemaDefinitionNode>;
|
||||
|
||||
constructor(config: GraphQLSchemaConfig);
|
||||
|
||||
getQueryType(): GraphQLObjectType | void;
|
||||
getMutationType(): GraphQLObjectType | void;
|
||||
getSubscriptionType(): GraphQLObjectType | void;
|
||||
getQueryType(): Maybe<GraphQLObjectType>;
|
||||
getMutationType(): Maybe<GraphQLObjectType>;
|
||||
getSubscriptionType(): Maybe<GraphQLObjectType>;
|
||||
getTypeMap(): TypeMap;
|
||||
getType(name: string): GraphQLNamedType | void;
|
||||
getType(name: string): Maybe<GraphQLNamedType>;
|
||||
getPossibleTypes(abstractType: GraphQLAbstractType): ReadonlyArray<GraphQLObjectType>;
|
||||
|
||||
isPossibleType(abstractType: GraphQLAbstractType, possibleType: GraphQLObjectType): boolean;
|
||||
|
||||
getDirectives(): ReadonlyArray<GraphQLDirective>;
|
||||
getDirective(name: string): GraphQLDirective | void;
|
||||
getDirective(name: string): Maybe<GraphQLDirective>;
|
||||
}
|
||||
|
||||
type TypeMap = { [key: string]: GraphQLNamedType };
|
||||
@@ -72,14 +73,14 @@ export interface GraphQLSchemaValidationOptions {
|
||||
* This option is provided to ease adoption and may be removed in a future
|
||||
* major release.
|
||||
*/
|
||||
allowedLegacyNames?: ReadonlyArray<string> | void;
|
||||
allowedLegacyNames?: Maybe<ReadonlyArray<string>>;
|
||||
}
|
||||
|
||||
export interface GraphQLSchemaConfig extends GraphQLSchemaValidationOptions {
|
||||
query: GraphQLObjectType | void;
|
||||
mutation?: GraphQLObjectType | void;
|
||||
subscription?: GraphQLObjectType | void;
|
||||
types?: GraphQLNamedType[] | void;
|
||||
directives?: GraphQLDirective[] | void;
|
||||
astNode?: SchemaDefinitionNode | void;
|
||||
query: Maybe<GraphQLObjectType>;
|
||||
mutation?: Maybe<GraphQLObjectType>;
|
||||
subscription?: Maybe<GraphQLObjectType>;
|
||||
types?: Maybe<GraphQLNamedType[]>;
|
||||
directives?: Maybe<GraphQLDirective[]>;
|
||||
astNode?: Maybe<SchemaDefinitionNode>;
|
||||
}
|
||||
|
||||
+11
-9
@@ -1,3 +1,4 @@
|
||||
import Maybe from "../tsutils/Maybe";
|
||||
import { GraphQLSchema } from "../type/schema";
|
||||
import {
|
||||
GraphQLOutputType,
|
||||
@@ -28,14 +29,15 @@ export class TypeInfo {
|
||||
initialType?: GraphQLType
|
||||
);
|
||||
|
||||
getType(): GraphQLOutputType | void;
|
||||
getParentType(): GraphQLCompositeType | void;
|
||||
getInputType(): GraphQLInputType | void;
|
||||
getParentInputType(): GraphQLInputType | void;
|
||||
getFieldDef(): GraphQLField<any, any> | void;
|
||||
getDirective(): GraphQLDirective | void;
|
||||
getArgument(): GraphQLArgument | void;
|
||||
getEnumValue(): GraphQLEnumValue | void;
|
||||
getType(): Maybe<GraphQLOutputType>;
|
||||
getParentType(): Maybe<GraphQLCompositeType>;
|
||||
getInputType(): Maybe<GraphQLInputType>;
|
||||
getParentInputType(): Maybe<GraphQLInputType>;
|
||||
getFieldDef(): GraphQLField<any, Maybe<any>>;
|
||||
getDefaultValue(): Maybe<any>;
|
||||
getDirective(): Maybe<GraphQLDirective>;
|
||||
getArgument(): Maybe<GraphQLArgument>;
|
||||
getEnumValue(): Maybe<GraphQLEnumValue>;
|
||||
enter(node: ASTNode): any;
|
||||
leave(node: ASTNode): any;
|
||||
}
|
||||
@@ -44,4 +46,4 @@ type getFieldDef = (
|
||||
schema: GraphQLSchema,
|
||||
parentType: GraphQLType,
|
||||
fieldNode: FieldNode
|
||||
) => GraphQLField<any, any> | void;
|
||||
) => Maybe<GraphQLField<any, any>>;
|
||||
|
||||
+2
-1
@@ -1,3 +1,4 @@
|
||||
import Maybe from "../tsutils/Maybe";
|
||||
import { ValueNode } from "../language/ast";
|
||||
import { GraphQLInputType } from "../type/definition";
|
||||
|
||||
@@ -18,4 +19,4 @@ import { GraphQLInputType } from "../type/definition";
|
||||
* | null | NullValue |
|
||||
*
|
||||
*/
|
||||
export function astFromValue(value: any, type: GraphQLInputType): ValueNode | void;
|
||||
export function astFromValue(value: any, type: GraphQLInputType): Maybe<ValueNode>;
|
||||
|
||||
+3
-2
@@ -1,3 +1,4 @@
|
||||
import Maybe from "../tsutils/Maybe";
|
||||
import {
|
||||
DocumentNode,
|
||||
Location,
|
||||
@@ -47,7 +48,7 @@ type TypeDefinitionsMap = { [key: string]: TypeDefinitionNode };
|
||||
type TypeResolver = (typeRef: NamedTypeNode) => GraphQLNamedType;
|
||||
|
||||
export class ASTDefinitionBuilder {
|
||||
constructor(typeDefinitionsMap: TypeDefinitionsMap, options: BuildSchemaOptions | void, resolveType: TypeResolver);
|
||||
constructor(typeDefinitionsMap: TypeDefinitionsMap, options: Maybe<BuildSchemaOptions>, resolveType: TypeResolver);
|
||||
|
||||
buildTypes(nodes: ReadonlyArray<NamedTypeNode | TypeDefinitionNode>): Array<GraphQLNamedType>;
|
||||
|
||||
@@ -69,7 +70,7 @@ export class ASTDefinitionBuilder {
|
||||
*/
|
||||
export function getDescription(
|
||||
node: { readonly description?: StringValueNode; readonly loc?: Location },
|
||||
options: BuildSchemaOptions | void
|
||||
options: Maybe<BuildSchemaOptions>
|
||||
): string | undefined;
|
||||
|
||||
/**
|
||||
|
||||
+3
-2
@@ -1,3 +1,4 @@
|
||||
import Maybe from "../tsutils/Maybe";
|
||||
import { DocumentNode, OperationDefinitionNode } from "../language/ast";
|
||||
|
||||
/**
|
||||
@@ -7,5 +8,5 @@ import { DocumentNode, OperationDefinitionNode } from "../language/ast";
|
||||
*/
|
||||
export function getOperationAST(
|
||||
documentAST: DocumentNode,
|
||||
operationName: string | void
|
||||
): OperationDefinitionNode | void;
|
||||
operationName: Maybe<string>
|
||||
): Maybe<OperationDefinitionNode>;
|
||||
|
||||
+16
-15
@@ -1,3 +1,4 @@
|
||||
import Maybe from "../tsutils/Maybe";
|
||||
import { DirectiveLocationEnum } from "../language/directiveLocation";
|
||||
|
||||
export interface IntrospectionOptions {
|
||||
@@ -16,8 +17,8 @@ export interface IntrospectionQuery {
|
||||
|
||||
export interface IntrospectionSchema {
|
||||
readonly queryType: IntrospectionNamedTypeRef<IntrospectionObjectType>;
|
||||
readonly mutationType: IntrospectionNamedTypeRef<IntrospectionObjectType> | void;
|
||||
readonly subscriptionType: IntrospectionNamedTypeRef<IntrospectionObjectType> | void;
|
||||
readonly mutationType: Maybe<IntrospectionNamedTypeRef<IntrospectionObjectType>>;
|
||||
readonly subscriptionType: Maybe<IntrospectionNamedTypeRef<IntrospectionObjectType>>;
|
||||
readonly types: ReadonlyArray<IntrospectionType>;
|
||||
readonly directives: ReadonlyArray<IntrospectionDirective>;
|
||||
}
|
||||
@@ -42,13 +43,13 @@ export type IntrospectionInputType = IntrospectionScalarType | IntrospectionEnum
|
||||
export interface IntrospectionScalarType {
|
||||
readonly kind: "SCALAR";
|
||||
readonly name: string;
|
||||
readonly description?: string | void;
|
||||
readonly description?: Maybe<string>;
|
||||
}
|
||||
|
||||
export interface IntrospectionObjectType {
|
||||
readonly kind: "OBJECT";
|
||||
readonly name: string;
|
||||
readonly description?: string | void;
|
||||
readonly description?: Maybe<string>;
|
||||
readonly fields: ReadonlyArray<IntrospectionField>;
|
||||
readonly interfaces: ReadonlyArray<IntrospectionNamedTypeRef<IntrospectionInterfaceType>>;
|
||||
}
|
||||
@@ -56,7 +57,7 @@ export interface IntrospectionObjectType {
|
||||
export interface IntrospectionInterfaceType {
|
||||
readonly kind: "INTERFACE";
|
||||
readonly name: string;
|
||||
readonly description?: string | void;
|
||||
readonly description?: Maybe<string>;
|
||||
readonly fields: ReadonlyArray<IntrospectionField>;
|
||||
readonly possibleTypes: ReadonlyArray<IntrospectionNamedTypeRef<IntrospectionObjectType>>;
|
||||
}
|
||||
@@ -64,21 +65,21 @@ export interface IntrospectionInterfaceType {
|
||||
export interface IntrospectionUnionType {
|
||||
readonly kind: "UNION";
|
||||
readonly name: string;
|
||||
readonly description?: string | void;
|
||||
readonly description?: Maybe<string>;
|
||||
readonly possibleTypes: ReadonlyArray<IntrospectionNamedTypeRef<IntrospectionObjectType>>;
|
||||
}
|
||||
|
||||
export interface IntrospectionEnumType {
|
||||
readonly kind: "ENUM";
|
||||
readonly name: string;
|
||||
readonly description?: string | void;
|
||||
readonly description?: Maybe<string>;
|
||||
readonly enumValues: ReadonlyArray<IntrospectionEnumValue>;
|
||||
}
|
||||
|
||||
export interface IntrospectionInputObjectType {
|
||||
readonly kind: "INPUT_OBJECT";
|
||||
readonly name: string;
|
||||
readonly description?: string | void;
|
||||
readonly description?: Maybe<string>;
|
||||
readonly inputFields: ReadonlyArray<IntrospectionInputValue>;
|
||||
}
|
||||
|
||||
@@ -114,30 +115,30 @@ export interface IntrospectionNamedTypeRef<T extends IntrospectionType = Introsp
|
||||
|
||||
export interface IntrospectionField {
|
||||
readonly name: string;
|
||||
readonly description?: string | void;
|
||||
readonly description?: Maybe<string>;
|
||||
readonly args: ReadonlyArray<IntrospectionInputValue>;
|
||||
readonly type: IntrospectionOutputTypeRef;
|
||||
readonly isDeprecated: boolean;
|
||||
readonly deprecationReason?: string | void;
|
||||
readonly deprecationReason?: Maybe<string>;
|
||||
}
|
||||
|
||||
export interface IntrospectionInputValue {
|
||||
readonly name: string;
|
||||
readonly description?: string | void;
|
||||
readonly description?: Maybe<string>;
|
||||
readonly type: IntrospectionInputTypeRef;
|
||||
readonly defaultValue?: string | void;
|
||||
readonly defaultValue?: Maybe<string>;
|
||||
}
|
||||
|
||||
export interface IntrospectionEnumValue {
|
||||
readonly name: string;
|
||||
readonly description?: string | void;
|
||||
readonly description?: Maybe<string>;
|
||||
readonly isDeprecated: boolean;
|
||||
readonly deprecationReason?: string | void;
|
||||
readonly deprecationReason?: Maybe<string>;
|
||||
}
|
||||
|
||||
export interface IntrospectionDirective {
|
||||
readonly name: string;
|
||||
readonly description?: string | void;
|
||||
readonly description?: Maybe<string>;
|
||||
readonly locations: ReadonlyArray<DirectiveLocationEnum>;
|
||||
readonly args: ReadonlyArray<IntrospectionInputValue>;
|
||||
}
|
||||
|
||||
+3
-2
@@ -1,3 +1,4 @@
|
||||
import Maybe from "../tsutils/Maybe";
|
||||
import { GraphQLInputType } from "../type/definition";
|
||||
import { ValueNode, VariableNode, ListValueNode, ObjectValueNode } from "../language/ast";
|
||||
|
||||
@@ -22,7 +23,7 @@ import { ValueNode, VariableNode, ListValueNode, ObjectValueNode } from "../lang
|
||||
*
|
||||
*/
|
||||
export function valueFromAST(
|
||||
valueNode: ValueNode | void,
|
||||
valueNode: Maybe<ValueNode>,
|
||||
type: GraphQLInputType,
|
||||
variables?: { [key: string]: any } | void
|
||||
variables?: Maybe<{ [key: string]: any }>
|
||||
): any;
|
||||
|
||||
+2
-1
@@ -1,3 +1,4 @@
|
||||
import Maybe from "../tsutils/Maybe";
|
||||
import { ValueNode } from "../language/ast";
|
||||
|
||||
/**
|
||||
@@ -16,4 +17,4 @@ import { ValueNode } from "../language/ast";
|
||||
* | Null | null |
|
||||
*
|
||||
*/
|
||||
export function valueFromASTUntyped(valueNode: ValueNode, variables?: { [key: string]: any } | void): any;
|
||||
export function valueFromASTUntyped(valueNode: ValueNode, variables?: Maybe<{ [key: string]: any }>): any;
|
||||
|
||||
+14
-9
@@ -1,3 +1,4 @@
|
||||
import Maybe from "../tsutils/Maybe";
|
||||
import { GraphQLError } from "../error";
|
||||
import {
|
||||
DocumentNode,
|
||||
@@ -19,7 +20,11 @@ import { GraphQLDirective } from "../type/directives";
|
||||
import { TypeInfo } from "../utilities/TypeInfo";
|
||||
|
||||
type NodeWithSelectionSet = OperationDefinitionNode | FragmentDefinitionNode;
|
||||
type VariableUsage = { node: VariableNode; type: GraphQLInputType | void };
|
||||
type VariableUsage = {
|
||||
readonly node: VariableNode;
|
||||
readonly type: Maybe<GraphQLInputType>;
|
||||
readonly defaultValue: Maybe<any>;
|
||||
};
|
||||
|
||||
/**
|
||||
* An instance of this class is passed as the "this" context to all validators,
|
||||
@@ -37,7 +42,7 @@ export default class ValidationContext {
|
||||
|
||||
getDocument(): DocumentNode;
|
||||
|
||||
getFragment(name: string): FragmentDefinitionNode | void;
|
||||
getFragment(name: string): Maybe<FragmentDefinitionNode>;
|
||||
|
||||
getFragmentSpreads(node: SelectionSetNode): ReadonlyArray<FragmentSpreadNode>;
|
||||
|
||||
@@ -47,17 +52,17 @@ export default class ValidationContext {
|
||||
|
||||
getRecursiveVariableUsages(operation: OperationDefinitionNode): ReadonlyArray<VariableUsage>;
|
||||
|
||||
getType(): GraphQLOutputType | void;
|
||||
getType(): Maybe<GraphQLOutputType>;
|
||||
|
||||
getParentType(): GraphQLCompositeType | void;
|
||||
getParentType(): Maybe<GraphQLCompositeType>;
|
||||
|
||||
getInputType(): GraphQLInputType | void;
|
||||
getInputType(): Maybe<GraphQLInputType>;
|
||||
|
||||
getParentInputType(): GraphQLInputType | void;
|
||||
getParentInputType(): Maybe<GraphQLInputType>;
|
||||
|
||||
getFieldDef(): GraphQLField<any, any> | void;
|
||||
getFieldDef(): Maybe<GraphQLField<any, any>>;
|
||||
|
||||
getDirective(): GraphQLDirective | void;
|
||||
getDirective(): Maybe<GraphQLDirective>;
|
||||
|
||||
getArgument(): GraphQLArgument | void;
|
||||
getArgument(): Maybe<GraphQLArgument>;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import Maybe from "../../tsutils/Maybe";
|
||||
import ValidationContext from "../ValidationContext";
|
||||
import { ASTVisitor } from "../../language/visitor";
|
||||
|
||||
export function undefinedVarMessage(varName: string, opName: string | void): string;
|
||||
export function undefinedVarMessage(varName: string, opName: Maybe<string>): string;
|
||||
|
||||
/**
|
||||
* No undefined variables
|
||||
|
||||
+2
-1
@@ -1,7 +1,8 @@
|
||||
import Maybe from "../../tsutils/Maybe";
|
||||
import ValidationContext from "../ValidationContext";
|
||||
import { ASTVisitor } from "../../language/visitor";
|
||||
|
||||
export function unusedVariableMessage(varName: string, opName: string | void): string;
|
||||
export function unusedVariableMessage(varName: string, opName: Maybe<string>): string;
|
||||
|
||||
/**
|
||||
* No unused variables
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import Maybe from "../../tsutils/Maybe";
|
||||
import ValidationContext from "../ValidationContext";
|
||||
import { ASTVisitor } from "../../language/visitor";
|
||||
|
||||
export function singleFieldOnlyMessage(name: string | void): string;
|
||||
export function singleFieldOnlyMessage(name: Maybe<string>): string;
|
||||
|
||||
/**
|
||||
* Subscriptions must only include one field.
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
import svgmin = require("gulp-svgmin");
|
||||
import { basename, extname } from "path";
|
||||
|
||||
// From tests
|
||||
|
||||
svgmin({ plugins: [] });
|
||||
svgmin({ plugins: [{ removeDoctype: false }] });
|
||||
svgmin({ plugins: [{ removeDoctype: false }, { removeComments: false }] });
|
||||
|
||||
// From examples given in README
|
||||
|
||||
// $ExpectType Transform
|
||||
svgmin();
|
||||
|
||||
// $ExpectType Transform
|
||||
svgmin({
|
||||
plugins: [{
|
||||
removeDoctype: false
|
||||
}, {
|
||||
removeComments: false
|
||||
}, {
|
||||
cleanupNumericValues: {
|
||||
floatPrecision: 2
|
||||
}
|
||||
}, {
|
||||
convertColors: {
|
||||
names2hex: false,
|
||||
rgb2hex: false
|
||||
}
|
||||
}]
|
||||
});
|
||||
|
||||
// $ExpectType Transform
|
||||
svgmin({
|
||||
js2svg: {
|
||||
pretty: true
|
||||
}
|
||||
});
|
||||
|
||||
// $ExpectType Transform
|
||||
svgmin(function getOptions(file) {
|
||||
const prefix = basename(file.relative, extname(file.relative));
|
||||
return {
|
||||
plugins: [{
|
||||
cleanupIDs: {
|
||||
prefix: prefix + '-',
|
||||
minify: true
|
||||
}
|
||||
}]
|
||||
};
|
||||
});
|
||||
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
// Type definitions for gulp-svgmin 1.2
|
||||
// Project: https://github.com/ben-eb/gulp-svgmin
|
||||
// Definitions by: Aankhen <https://github.com/Aankhen>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
// (required because svgo specifies 2.2)
|
||||
|
||||
/// <reference types="node"/>
|
||||
|
||||
import SVGO = require("svgo");
|
||||
import { Transform } from "stream";
|
||||
import * as File from "vinyl";
|
||||
|
||||
export = GulpSvgmin;
|
||||
|
||||
declare function GulpSvgmin(cb: (file: File) => SVGO.Options): Transform;
|
||||
declare function GulpSvgmin(options?: SVGO.Options): Transform;
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"gulp-svgmin-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@@ -1,90 +1,52 @@
|
||||
import mocha = require('mocha');
|
||||
import chai = require('chai');
|
||||
const should = chai.should();
|
||||
import rewire = require('rewire');
|
||||
import sinon = require('sinon');
|
||||
import logger = require('hexo-log');
|
||||
|
||||
const _c = logger();
|
||||
type HexoLogger = typeof _c;
|
||||
declare function it(s: string, cb: () => void): void;
|
||||
|
||||
describe('hexo-log', () => {
|
||||
const loggerModule = rewire<(options?: { name?: string; silent?: boolean; debug?: boolean; }) => HexoLogger>('./');
|
||||
it('add alias for levels', () => {
|
||||
const log = logger();
|
||||
|
||||
it('add alias for levels', () => {
|
||||
const log = logger();
|
||||
|
||||
log.d.should.eql(log.debug);
|
||||
log.i.should.eql(log.info);
|
||||
log.w.should.eql(log.warn);
|
||||
log.e.should.eql(log.error);
|
||||
log.log.should.eql(log.info);
|
||||
});
|
||||
|
||||
it('default name is hexo', () => {
|
||||
const log = logger();
|
||||
|
||||
log.fields.name.should.eql('hexo');
|
||||
});
|
||||
|
||||
it('options.name', () => {
|
||||
const log = logger({ name: 'foo' });
|
||||
|
||||
log.fields.name.should.eql('foo');
|
||||
});
|
||||
|
||||
it('level should be trace if options.debug is true', () => {
|
||||
const log: any = logger({ debug: true });
|
||||
|
||||
log.streams[0].level.should.eql(10);
|
||||
});
|
||||
|
||||
it('should add file stream if options.debug is true', () => {
|
||||
const log: any = logger({ debug: true });
|
||||
|
||||
log.streams[1].path.should.eql('debug.log');
|
||||
});
|
||||
|
||||
it('should remove console stream if options.silent is true', () => {
|
||||
const log: any = logger({ silent: true });
|
||||
|
||||
log.streams.length.should.eql(0);
|
||||
});
|
||||
|
||||
it('should display time if options.debug is true', () => {
|
||||
const spy = sinon.spy();
|
||||
const now = new Date();
|
||||
|
||||
loggerModule.__with__({
|
||||
process: {
|
||||
stdout: {
|
||||
write: spy
|
||||
}
|
||||
}
|
||||
})(() => {
|
||||
sinon.useFakeTimers(now.valueOf());
|
||||
const log = loggerModule({ debug: true });
|
||||
log.info('test');
|
||||
sinon.restore(undefined);
|
||||
});
|
||||
|
||||
spy.args[0][0].should.contain(now.toISOString().substring(11, 23));
|
||||
});
|
||||
|
||||
it('should print error to process.stderr stream', () => {
|
||||
const spy = sinon.spy();
|
||||
|
||||
loggerModule.__with__({
|
||||
process: {
|
||||
stderr: {
|
||||
write: spy
|
||||
}
|
||||
}
|
||||
})(() => {
|
||||
const log = loggerModule();
|
||||
log.error('test');
|
||||
});
|
||||
|
||||
spy.calledOnce.should.be.true;
|
||||
});
|
||||
log.d === log.debug;
|
||||
log.i === log.info;
|
||||
log.w === log.warn;
|
||||
log.e === log.error;
|
||||
log.log === log.info;
|
||||
});
|
||||
|
||||
it('default name is hexo', () => {
|
||||
const log = logger();
|
||||
|
||||
log.fields.name === 'hexo';
|
||||
});
|
||||
|
||||
it('options.name', () => {
|
||||
const log = logger({ name: 'foo' });
|
||||
log.fields === 'foo';
|
||||
});
|
||||
|
||||
it('level should be trace if options.debug is true', () => {
|
||||
const log = logger({ debug: true });
|
||||
// TODO
|
||||
// log.streams[0].level.should.eql(10);
|
||||
});
|
||||
|
||||
it('should add file stream if options.debug is true', () => {
|
||||
const log = logger({ debug: true });
|
||||
// TODO
|
||||
// log.streams[1].path === 'debug.log';
|
||||
});
|
||||
|
||||
it('should remove console stream if options.silent is true', () => {
|
||||
const log = logger({ silent: true });
|
||||
// TODO
|
||||
// log.streams.length === 0;
|
||||
});
|
||||
|
||||
it('should display time if options.debug is true', () => {
|
||||
const log = logger({ debug: true });
|
||||
log.info('test');
|
||||
});
|
||||
|
||||
it('should print error to process.stderr stream', () => {
|
||||
const log = logger();
|
||||
log.error('test');
|
||||
});
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
import Ids = require('ids');
|
||||
|
||||
const ids = new Ids();
|
||||
|
||||
const next = ids.next(); // returns id
|
||||
|
||||
ids.claim('f71a81'); // claim id as already existing
|
||||
|
||||
ids.assigned('f71a81'); // true if id was already generated / claimed
|
||||
Vendored
-53
@@ -1,53 +0,0 @@
|
||||
// Type definitions for ids 0.2.0
|
||||
// Project: https://github.com/bpmn-io/ids
|
||||
// Definitions by: Jan Steinbruecker <https://github.com/3fd>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export = Ids;
|
||||
|
||||
declare class Ids {
|
||||
|
||||
/**
|
||||
* Create a new id generator / cache instance.
|
||||
* @param {number[]} [seed] a seed that is used internally.
|
||||
*/
|
||||
constructor(seed?: number[]);
|
||||
|
||||
/**
|
||||
* Returns true if the given id has already been assigned.
|
||||
* @param {string} id
|
||||
* @return {boolean}
|
||||
*/
|
||||
assigned(id: string): boolean;
|
||||
|
||||
/**
|
||||
* Manually claim an existing id.
|
||||
* @param {string} id
|
||||
* @param {*} [element] element the id is claimed by
|
||||
*/
|
||||
claim(id: string, element?: any): void;
|
||||
|
||||
/** Clear all claimed ids. */
|
||||
clear(): void;
|
||||
|
||||
/**
|
||||
* Generate a next id.
|
||||
* @param {*} [element] element to bind the id to
|
||||
* @return {string} id
|
||||
*/
|
||||
next(element?: any): string;
|
||||
|
||||
/**
|
||||
* Generate a next id with a given prefix.
|
||||
* @param {*} [element] element to bind the id to
|
||||
* @return {string} id
|
||||
*/
|
||||
nextPrefixed(prefix: string, element?: any): string;
|
||||
|
||||
/**
|
||||
* Unclaim an id.
|
||||
* @param {string} id - the id to unclaim
|
||||
*/
|
||||
unclaim(id: string): void;
|
||||
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
{
|
||||
"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
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
import * as iap from 'in-app-purchase';
|
||||
|
||||
iap.config({
|
||||
/* Configurations for Amazon Store */
|
||||
amazonAPIVersion: 2, // tells the module to use API version 2
|
||||
secret: 'abcdefghijklmnoporstuvwxyz', // this comes from Amazon
|
||||
|
||||
/* Configurations for Apple */
|
||||
applePassword: 'abcdefg...', // this comes from iTunes Connect (You need this to valiate subscriptions)
|
||||
|
||||
/* Configurations for Google Play */
|
||||
googlePublicKeyPath: 'path/to/public/key/directory/', // this is the path to the directory containing iap-sanbox/iap-live files
|
||||
googleAccToken: 'abcdef...', // optional, for Google Play subscriptions
|
||||
googleRefToken: 'dddd...', // optional, for Google Play subscritions
|
||||
clientId: 'aaaa', // optional, for Google Play subscriptions
|
||||
clientSecret: 'bbbb', // optional, for Google Play subscriptions
|
||||
refreshToken: 'cccc', // optional, for Google Play subscriptions
|
||||
|
||||
/* Configurations for Roku */
|
||||
rokuApiKey: 'aaaa...', // this comes from Roku Developer Dashboard
|
||||
|
||||
/* Configurations all platforms */
|
||||
test: true, // For Apple and Googl Play to force Sandbox validation only
|
||||
verbose: true // Output debug logs to stdout stream
|
||||
});
|
||||
iap.setup()
|
||||
.then(() => iap.validate('abcdef'))
|
||||
.then((validatedData) => {
|
||||
const options = {
|
||||
ignoreCanceled: true, // Apple ONLY (for now...): purchaseData will NOT contain cancceled items
|
||||
ignoreExpired: true // purchaseData will NOT contain exipired subscription items
|
||||
};
|
||||
|
||||
const purchaseData = iap.getPurchaseData(validatedData, options);
|
||||
})
|
||||
.catch((error) => {
|
||||
// error...
|
||||
});
|
||||
Vendored
+107
@@ -0,0 +1,107 @@
|
||||
// Type definitions for in-app-purchase 1.9
|
||||
// Project: https://github.com/voltrue2/in-app-purchase#readme
|
||||
// Definitions by: Jonas Lochmann <https://github.com/l-jonas>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
export const UNITY = 'unity';
|
||||
export const APPLE = 'apple';
|
||||
export const GOOGLE = 'google';
|
||||
export const WINDOWS = 'windows';
|
||||
export const AMAZON = 'amazon';
|
||||
export const ROKU = 'roku';
|
||||
|
||||
export function config(params: Config): void;
|
||||
export function setup(): Promise<void>;
|
||||
export function setup(callback: (err: any) => void): void;
|
||||
export function getService(receipt: Receipt): Service;
|
||||
|
||||
export function validate(receipt: Receipt): Promise<ValidationResponse>;
|
||||
export function validate(receipt: Receipt, callback: (err: any, res: ValidationResponse) => void): void;
|
||||
export function validate(service: Service, receipt: Receipt, callback: (err: any, res: ValidationResponse) => void): void;
|
||||
|
||||
export function validateOnce(receipt: Receipt, secretOrPubKey: any): Promise<ValidationResponse>;
|
||||
export function validateOnce(receipt: Receipt, secretOrPubKey: any, callback: (err: any, res: ValidationResponse) => void): void;
|
||||
export function validateOnce(service: Service, secretOrPubKey: any, receipt: Receipt, callback: (err: any, res: ValidationResponse) => void): void;
|
||||
|
||||
export function isValidated(response: ValidationResponse): boolean;
|
||||
export function isExpired(item: PurchasedItem): boolean;
|
||||
export function getPurchaseData(purchaseData?: ValidationResponse, options?: {
|
||||
ignoreCanceled: boolean;
|
||||
ignoreExpired: boolean;
|
||||
}): PurchasedItem[] | null;
|
||||
|
||||
export function refreshGoogleToken(): Promise<void>;
|
||||
export function refreshGoogleToken(callback: (err: any) => void): void;
|
||||
|
||||
// for test use only, resets the google setup
|
||||
export function reset(): void;
|
||||
|
||||
export interface Config {
|
||||
/* Configurations for Amazon Store */
|
||||
amazonAPIVersion?: number;
|
||||
secret?: string;
|
||||
|
||||
/* Configurations for Apple */
|
||||
|
||||
// this comes from iTunes Connect (You need this to valiate subscriptions)
|
||||
applePassword?: string;
|
||||
|
||||
/* Configurations for Google Play */
|
||||
// this is the path to the directory containing iap-sanbox/iap-live files
|
||||
googlePublicKeyPath?: string;
|
||||
// optional, for Google Play subscriptions
|
||||
googleAccToken?: string;
|
||||
// optional, for Google Play subscritions
|
||||
googleRefToken?: string;
|
||||
// optional, for Google Play subscriptions
|
||||
clientId?: string;
|
||||
// optional, for Google Play subscriptions
|
||||
clientSecret?: string;
|
||||
// optional, for Google Play subscriptions
|
||||
refreshToken?: string;
|
||||
|
||||
/* Configurations for Roku */
|
||||
// this comes from Roku Developer Dashboard
|
||||
rokuApiKey?: string;
|
||||
|
||||
/* Configurations all platforms */
|
||||
// For Apple and Googl Play to force Sandbox validation only
|
||||
test?: boolean;
|
||||
// Output debug logs to stdout stream
|
||||
verbose?: boolean;
|
||||
}
|
||||
|
||||
export type Service = typeof UNITY | typeof APPLE | typeof GOOGLE | typeof WINDOWS | typeof AMAZON | typeof ROKU;
|
||||
|
||||
export type UnityReceipt = object | string;
|
||||
export type AppleReceipt = string;
|
||||
export type GoogleReceipt = {
|
||||
date: string;
|
||||
signature: string;
|
||||
} | string;
|
||||
export type WindowsReceipt = string;
|
||||
export type AmazonReceipt = object | string;
|
||||
export type RokuReceipt = string;
|
||||
|
||||
export type Receipt = UnityReceipt | AppleReceipt | GoogleReceipt | WindowsReceipt | AmazonReceipt | RokuReceipt;
|
||||
|
||||
export interface ValidationResponse {
|
||||
service: Service;
|
||||
status: number;
|
||||
// there are more fields depending on the used service
|
||||
}
|
||||
|
||||
export interface PurchasedItem {
|
||||
bundleId?: string; // only Apple
|
||||
orderId?: string; // only Google
|
||||
transactionId: string;
|
||||
productId: string;
|
||||
purchaseDate: number;
|
||||
// iTunes, windows and amazon subscription only
|
||||
// Google subscriptions only with google play store api info
|
||||
expirationDate?: number;
|
||||
quantity: number;
|
||||
// this was created based on the source code of in-app-purchase
|
||||
// eventually there are more fields
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"in-app-purchase-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Vendored
+3
@@ -4,6 +4,7 @@
|
||||
// customize-the-intercom-messenger/the-intercom-javascript-api
|
||||
// Definitions by: Andrew Fong <https://github.com/fongandrew>
|
||||
// Samer Albahra <https://github.com/salbahra>
|
||||
// Onat Yigit Mercan <https://github.com/onatm>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare namespace Intercom_ {
|
||||
@@ -27,6 +28,8 @@ declare namespace Intercom_ {
|
||||
monthly_spend?: number,
|
||||
[index: string]: any;
|
||||
};
|
||||
vertical_padding?: number;
|
||||
horizontal_padding?: number;
|
||||
}
|
||||
|
||||
type IntercomCommand = 'boot'
|
||||
|
||||
@@ -60,3 +60,15 @@ intercomSettings = {
|
||||
user_id: "12345",
|
||||
user_hash: "775c502lcc1087d12398571837c"
|
||||
};
|
||||
|
||||
/*
|
||||
From https://docs.intercom.com/configure-intercom-for-your-product-or-site/
|
||||
customize-the-intercom-messenger/
|
||||
customize-the-intercom-messenger-technical
|
||||
*/
|
||||
intercomSettings = {
|
||||
app_id: "pi3243fa",
|
||||
alignment: "left",
|
||||
horizontal_padding: 20,
|
||||
vertical_padding: 20
|
||||
};
|
||||
|
||||
Vendored
+85
@@ -0,0 +1,85 @@
|
||||
// Type definitions for jest-axe 2.2
|
||||
// Project: https://github.com/nickcolley/jest-axe
|
||||
// Definitions by: Josh Goldberg <https://github.com/JoshuaKGoldberg>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.4
|
||||
|
||||
/// <reference types="jest" />
|
||||
|
||||
import { AxeResults, Result, RunOnly } from "axe-core";
|
||||
|
||||
/**
|
||||
* Version of the aXe verifier with defaults set.
|
||||
*
|
||||
* @remarks You can still pass additional options to this new instance;
|
||||
* they will be merged with the defaults.
|
||||
*/
|
||||
export const axe: JestAxe;
|
||||
|
||||
/**
|
||||
* Core options to run aXe.
|
||||
*/
|
||||
export interface AxeOptions {
|
||||
elementRef?: boolean;
|
||||
iframes?: boolean;
|
||||
rules?: object;
|
||||
runOnly?: RunOnly;
|
||||
selectors?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs aXe on HTML.
|
||||
*
|
||||
* @param html Raw HTML string to verify with aXe.
|
||||
* @param options Options to run aXe.
|
||||
* @returns Promise for the results of running aXe.
|
||||
*/
|
||||
export type JestAxe = (html: string, options?: AxeOptions) => Promise<AxeResults>;
|
||||
|
||||
/**
|
||||
* Creates a new aXe verifier function.
|
||||
*
|
||||
* @param options Options to run aXe.
|
||||
* @returns New aXe verifier function.
|
||||
*/
|
||||
export function configureAxe(options?: AxeOptions): JestAxe;
|
||||
|
||||
/**
|
||||
* Results from asserting whether aXe verification passed.
|
||||
*/
|
||||
export interface AssertionsResult {
|
||||
/**
|
||||
* Actual checked aXe verification results.
|
||||
*/
|
||||
actual: Result[];
|
||||
|
||||
/**
|
||||
* @returns Message from the Jest assertion.
|
||||
*/
|
||||
message(): string;
|
||||
|
||||
/**
|
||||
* Whether the assertion passed.
|
||||
*/
|
||||
pass: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts an aXe-verified result has no violations.
|
||||
*
|
||||
* @param results aXe verification result, if not running via expect().
|
||||
* @returns Jest expectations for the aXe result.
|
||||
*/
|
||||
export type IToHaveNoViolations = (results?: Partial<AxeResults>) => AssertionsResult;
|
||||
|
||||
export const toHaveNoViolations: {
|
||||
toHaveNoViolations: IToHaveNoViolations;
|
||||
};
|
||||
|
||||
declare global {
|
||||
namespace jest {
|
||||
interface Matchers<R> {
|
||||
toHaveNoViolations: IToHaveNoViolations;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import { configureAxe, axe, toHaveNoViolations, JestAxe } from "jest-axe";
|
||||
|
||||
expect.extend(toHaveNoViolations);
|
||||
|
||||
const newJestWithDefaults: JestAxe = configureAxe();
|
||||
|
||||
const newJestWithOptions: JestAxe = configureAxe({
|
||||
elementRef: false,
|
||||
iframes: false,
|
||||
rules: {},
|
||||
runOnly: {
|
||||
type: "rules",
|
||||
},
|
||||
selectors: false,
|
||||
});
|
||||
|
||||
const sameJest: JestAxe = axe;
|
||||
|
||||
expect("").toHaveNoViolations();
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"axe-core": "^2.6.1"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"jest-axe-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
// Type definitions for jsonic 0.3
|
||||
// Project: https://github.com/rjrodger/jsonic
|
||||
// Definitions by: Rong SHen <https://github.com/jacobbubu>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare function jsonic(text: string): any;
|
||||
declare namespace jsonic {
|
||||
interface Options {
|
||||
depth?: number;
|
||||
maxitems?: number;
|
||||
maxchars?: number;
|
||||
omit?: string[];
|
||||
exclude?: string[];
|
||||
}
|
||||
|
||||
function stringify(val: any, opts?: Options): string;
|
||||
}
|
||||
|
||||
export = jsonic;
|
||||
@@ -0,0 +1,7 @@
|
||||
import * as jsonic from "jsonic";
|
||||
|
||||
jsonic("a:x, b:y z");
|
||||
jsonic.stringify(
|
||||
{ a: "a", b: "b", c: { c1: "c1" } },
|
||||
{ depth: 1, omit: ["a"], exclude: ["b"] }
|
||||
);
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": ["es6"],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": ["../"],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": ["index.d.ts", "jsonic-tests.ts"]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Vendored
+4
-4
@@ -23,7 +23,7 @@ type ColumnName = string | Knex.Raw | Knex.QueryBuilder | {[key: string]: string
|
||||
type TableName = string | Knex.Raw | Knex.QueryBuilder;
|
||||
|
||||
interface Knex extends Knex.QueryInterface {
|
||||
(tableName?: string): Knex.QueryBuilder;
|
||||
(tableName?: TableName): Knex.QueryBuilder;
|
||||
VERSION: string;
|
||||
__knex__: string;
|
||||
|
||||
@@ -179,7 +179,7 @@ declare namespace Knex {
|
||||
}
|
||||
|
||||
interface Table {
|
||||
(tableName: string): QueryBuilder;
|
||||
(tableName: TableName): QueryBuilder;
|
||||
(callback: Function): QueryBuilder;
|
||||
(raw: Raw): QueryBuilder;
|
||||
}
|
||||
@@ -269,8 +269,8 @@ declare namespace Knex {
|
||||
(callback: QueryCallback): QueryBuilder;
|
||||
(object: Object): QueryBuilder;
|
||||
(columnName: string, value: Value | null): QueryBuilder;
|
||||
(columnName: string, operator: string, value: Value | null): QueryBuilder;
|
||||
(columnName: string, operator: string, query: QueryBuilder): QueryBuilder;
|
||||
(columnName: string, operator: string, value: Value | QueryBuilder | null): QueryBuilder;
|
||||
(left: Raw, operator: string, right: Value | QueryBuilder | null): QueryBuilder;
|
||||
}
|
||||
|
||||
interface WhereRaw extends RawQueryBuilder {
|
||||
|
||||
@@ -206,6 +206,11 @@ knex('users').where('votes', '>', 100);
|
||||
knex('users').where('votes', null);
|
||||
knex('users').where('votes', 'is not', null);
|
||||
|
||||
// Using Raw in where
|
||||
knex('users').where(knex.raw('votes + 1'), '>', 101);
|
||||
knex('users').where(knex.raw('votes + 1'), '>', knex.raw('100 + 1'));
|
||||
knex('users').where('votes', '>', knex.raw('100 + 1'));
|
||||
|
||||
var subquery = knex('users').where('votes', '>', 100).andWhere('status', 'active').orWhere('name', 'John').select('id');
|
||||
knex('accounts').where('id', 'in', subquery);
|
||||
|
||||
|
||||
Vendored
+10
-1
@@ -1,9 +1,18 @@
|
||||
// Type definitions for NaturalSort
|
||||
// Project: https://github.com/studio-b12/natural-sort
|
||||
// Definitions by: Antonio Morales <https://github.com/a-morales>
|
||||
// Brian Crowell <https://github.com/fluggo>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export as namespace naturalSort;
|
||||
|
||||
declare function naturalSort<T>(a: T, b: T): number;
|
||||
interface Options {
|
||||
/** Set to true to make the sort case-sensitive. */
|
||||
caseSensitive?: boolean;
|
||||
|
||||
/** Set to 'desc' to sort in reverse. */
|
||||
direction?: 'desc'
|
||||
}
|
||||
|
||||
declare function naturalSort(options?: Options): (a: string | number, b: string | number) => number;
|
||||
export = naturalSort;
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
|
||||
import naturalSort = require("natural-sort");
|
||||
|
||||
[5, 3, 2, 4, 1].sort(naturalSort);
|
||||
["a", "c", "b", "z", "w", "l"].sort(naturalSort);
|
||||
['10. tenth', 'odd', 1, '', '2. second'].sort(naturalSort());
|
||||
[3, 4, 1, 5, 2].sort(naturalSort({direction: 'desc'}));
|
||||
|
||||
['a', 'B'].sort(naturalSort());
|
||||
['a', 'B'].sort(naturalSort({caseSensitive: true}));
|
||||
|
||||
@@ -9,7 +9,7 @@ const server = Net.createServer((socket) => {
|
||||
})
|
||||
|
||||
server.listen(1337, '127.0.0.1', () => {
|
||||
const {port, address} = server.address()
|
||||
const {port, address} = server.address() as Net.AddressInfo
|
||||
const clientSocket = Net.createConnection({
|
||||
port, host: address
|
||||
}, () => {
|
||||
@@ -18,4 +18,4 @@ server.listen(1337, '127.0.0.1', () => {
|
||||
NetKeepAlive.setKeepAliveProbes(clientSocket, 1)
|
||||
clientSocket.end()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Vendored
+32
-1
@@ -1,15 +1,46 @@
|
||||
import * as React from "react";
|
||||
import * as http from "http";
|
||||
|
||||
export interface Context {
|
||||
err?: Error;
|
||||
req: http.IncomingMessage;
|
||||
res: http.ServerResponse;
|
||||
pathname: string;
|
||||
query?: {
|
||||
[key: string]:
|
||||
| boolean
|
||||
| boolean[]
|
||||
| number
|
||||
| number[]
|
||||
| string
|
||||
| string[];
|
||||
};
|
||||
asPath: string;
|
||||
|
||||
renderPage(
|
||||
enhancer?: (page: React.Component) => React.ComponentType<any>
|
||||
): {
|
||||
html?: string;
|
||||
head: Array<React.ReactElement<any>>;
|
||||
errorHtml: string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface DocumentProps {
|
||||
__NEXT_DATA__?: any;
|
||||
dev?: boolean;
|
||||
chunks?: string[];
|
||||
html?: string;
|
||||
head?: Array<React.ReactElement<any>>;
|
||||
errorHtml?: string;
|
||||
styles?: Array<React.ReactElement<any>>;
|
||||
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
export class Head extends React.Component<any> {}
|
||||
export class Main extends React.Component {}
|
||||
export class NextScript extends React.Component {}
|
||||
export default class extends React.Component<DocumentProps> {}
|
||||
export default class extends React.Component<DocumentProps> {
|
||||
static getInitialProps(ctx: Context): DocumentProps;
|
||||
}
|
||||
|
||||
Vendored
+117
-91
@@ -1,4 +1,4 @@
|
||||
// Type definitions for angularjs-toaster v0.4.13
|
||||
// Type definitions for angularjs-toaster 2.2
|
||||
// Project: https://github.com/jirikavi/AngularJS-Toaster
|
||||
// Definitions by: Ben Tesser <https://github.com/btesser>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
@@ -10,100 +10,126 @@ export = ngtoaster;
|
||||
export as namespace toaster;
|
||||
|
||||
declare namespace ngtoaster {
|
||||
interface IToasterService {
|
||||
pop(params:IPopParams): void
|
||||
/**
|
||||
* @param {string} type Type of toaster -- 'error', 'info', 'wait', 'success', and 'warning'
|
||||
*/
|
||||
pop(type?:string, title?:string, body?:string, timeout?:number, bodyOutputType?:string, clickHandler?:EventListener,
|
||||
toasterId?:number, showCloseButton?:boolean): void
|
||||
error(params: IPopParams): void
|
||||
error(title?:string, body?:string, timeout?:number, bodyOutputType?:string, clickHandler?:EventListener,
|
||||
toasterId?:number): void
|
||||
info(params: IPopParams): void
|
||||
info(title?:string, body?:string, timeout?:number, bodyOutputType?:string, clickHandler?:EventListener,
|
||||
toasterId?:number): void
|
||||
wait(params: IPopParams): void
|
||||
wait(title?:string, body?:string, timeout?:number, bodyOutputType?:string, clickHandler?:EventListener,
|
||||
toasterId?:number): void
|
||||
success(params: IPopParams): void
|
||||
success(title?:string, body?:string, timeout?:number, bodyOutputType?:string, clickHandler?:EventListener,
|
||||
toasterId?:number): void
|
||||
warning(params: IPopParams): void
|
||||
warning(title?:string, body?:string, timeout?:number, bodyOutputType?:string, clickHandler?:EventListener,
|
||||
toasterId?:number): void
|
||||
clear(): void
|
||||
toast:IToast;
|
||||
}
|
||||
interface IToasterService {
|
||||
pop(params: IPopParams): void;
|
||||
/**
|
||||
* @param type Type of toaster -- 'error', 'info', 'wait', 'success', and 'warning'
|
||||
*/
|
||||
pop(type?: string, title?: string, body?: string, timeout?: number, bodyOutputType?: string, clickHandler?: EventListener,
|
||||
toasterId?: number, showCloseButton?: boolean, toastId?: string|number,
|
||||
onHideCallback?: IToastCallback): IPopReturn;
|
||||
error(params: IPopParams): void;
|
||||
error(title?: string, body?: string, timeout?: number, bodyOutputType?: string, clickHandler?: EventListener,
|
||||
toasterId?: number, showCloseButton?: boolean, toastId?: string|number,
|
||||
onHideCallback?: IToastCallback): IPopReturn;
|
||||
info(params: IPopParams): void;
|
||||
info(title?: string, body?: string, timeout?: number, bodyOutputType?: string, clickHandler?: EventListener,
|
||||
toasterId?: number, showCloseButton?: boolean, toastId?: string|number,
|
||||
onHideCallback?: IToastCallback): IPopReturn;
|
||||
wait(params: IPopParams): void;
|
||||
wait(title?: string, body?: string, timeout?: number, bodyOutputType?: string, clickHandler?: EventListener,
|
||||
toasterId?: number, showCloseButton?: boolean, toastId?: string|number,
|
||||
onHideCallback?: IToastCallback): IPopReturn;
|
||||
success(params: IPopParams): void;
|
||||
success(title?: string, body?: string, timeout?: number, bodyOutputType?: string, clickHandler?: EventListener,
|
||||
toasterId?: number, showCloseButton?: boolean, toastId?: string|number,
|
||||
onHideCallback?: IToastCallback): IPopReturn;
|
||||
warning(params: IPopParams): void;
|
||||
warning(title?: string, body?: string, timeout?: number, bodyOutputType?: string, clickHandler?: EventListener,
|
||||
toasterId?: number, showCloseButton?: boolean, toastId?: string|number,
|
||||
onHideCallback?: IToastCallback): IPopReturn;
|
||||
clear(toasterId?: number, toastId?: string|number): void;
|
||||
toast: IToast;
|
||||
}
|
||||
|
||||
interface IToasterEventRegistry {
|
||||
setup(): void
|
||||
subscribeToNewToastEvent(onNewToast:IToastEventListener): void
|
||||
subscribeToClearToastsEvent(onClearToasts:IToastEventListener): void
|
||||
unsubscribeToNewToastEvent(onNewToast:IToastEventListener): void
|
||||
unsubscribeToClearToastsEvent(onClearToasts:IToastEventListener): void
|
||||
}
|
||||
interface IToasterEventRegistry {
|
||||
setup(): void;
|
||||
subscribeToNewToastEvent(onNewToast: IToastEventListener): void;
|
||||
subscribeToClearToastsEvent(onClearToasts: IToastEventListener): void;
|
||||
unsubscribeToNewToastEvent(onNewToast: IToastEventListener): void;
|
||||
unsubscribeToClearToastsEvent(onClearToasts: IToastEventListener): void;
|
||||
}
|
||||
|
||||
interface IPopParams extends IToast{
|
||||
toasterId?: number;
|
||||
}
|
||||
interface IPopParams extends IToast {
|
||||
toasterId?: number;
|
||||
}
|
||||
|
||||
interface IToastEventListener {
|
||||
(event:Event, toasterId: number): void;
|
||||
}
|
||||
interface IPopReturn {
|
||||
toasterId: number;
|
||||
toastId: string|number;
|
||||
}
|
||||
|
||||
interface IToast {
|
||||
/**
|
||||
* Acceptable types are:
|
||||
* 'error', 'info', 'wait', 'success', and 'warning'
|
||||
*/
|
||||
type?: string;
|
||||
title?: string;
|
||||
body?: string;
|
||||
timeout?: number;
|
||||
bodyOutputType?: string;
|
||||
clickHandler?: EventListener;
|
||||
showCloseButton?: boolean;
|
||||
}
|
||||
type IToastCallback = (toast: IToast) => void;
|
||||
|
||||
interface IToasterConfig {
|
||||
/**
|
||||
* limits max number of toasts
|
||||
*/
|
||||
limit?: number;
|
||||
'tap-to-dismiss'?: boolean;
|
||||
'close-button'?: boolean;
|
||||
'newest-on-top'?: boolean;
|
||||
'time-out'?: number;
|
||||
'icon-classes'?: IIconClasses;
|
||||
/**
|
||||
* Options include:
|
||||
* '', 'trustedHtml', 'template', 'templateWithData'
|
||||
*/
|
||||
'body-output-type'?: string;
|
||||
'body-template'?: string;
|
||||
'icon-class'?: string;
|
||||
/**
|
||||
* Options include:
|
||||
* 'toast-top-full-width', 'toast-bottom-full-width', 'toast-center',
|
||||
* 'toast-top-left', 'toast-top-center', 'toast-top-rigt',
|
||||
* 'toast-bottom-left', 'toast-bottom-center', 'toast-bottom-rigt',
|
||||
*/
|
||||
'position-class'?: string;
|
||||
'title-class'?: string;
|
||||
'message-class'?: string;
|
||||
'prevent-duplicates'?: boolean;
|
||||
/**
|
||||
* stop timeout on mouseover and restart timer on mouseout
|
||||
*/
|
||||
'mouseover-timer-stop'?: boolean;
|
||||
}
|
||||
type IToastEventListener = (event: Event, toasterId: number, toastId: string|number) => void;
|
||||
|
||||
interface IIconClasses {
|
||||
error: string;
|
||||
info: string;
|
||||
wait: string;
|
||||
success: string;
|
||||
warning: string;
|
||||
}
|
||||
interface IToast {
|
||||
/**
|
||||
* Acceptable types are:
|
||||
* 'error', 'info', 'wait', 'success', and 'warning'
|
||||
*/
|
||||
type?: string;
|
||||
title?: string;
|
||||
body?: string;
|
||||
timeout?: number;
|
||||
bodyOutputType?: string;
|
||||
clickHandler?: EventListener;
|
||||
showCloseButton?: boolean;
|
||||
closeHtml?: string;
|
||||
toastId?: string|number;
|
||||
/**
|
||||
* Called when the toast has been displayed.
|
||||
* @param toast the displayed toast
|
||||
*/
|
||||
onShowCallback?: IToastCallback;
|
||||
/**
|
||||
* Called when the toast has been removed.
|
||||
* @param toast the displayed toast
|
||||
*/
|
||||
onHideCallback?: IToastCallback;
|
||||
directiveData?: any;
|
||||
tapToDismiss?: boolean;
|
||||
}
|
||||
|
||||
interface IToasterConfig {
|
||||
/**
|
||||
* limits max number of toasts
|
||||
*/
|
||||
limit?: number;
|
||||
'tap-to-dismiss'?: boolean;
|
||||
'close-button'?: boolean;
|
||||
'close-html'?: string;
|
||||
'newest-on-top'?: boolean;
|
||||
'time-out'?: number;
|
||||
'icon-classes'?: IIconClasses;
|
||||
/**
|
||||
* Options include:
|
||||
* '', 'trustedHtml', 'template', 'templateWithData'
|
||||
*/
|
||||
'body-output-type'?: string;
|
||||
'body-template'?: string;
|
||||
'icon-class'?: string;
|
||||
/**
|
||||
* Options include:
|
||||
* 'toast-top-full-width', 'toast-bottom-full-width', 'toast-center',
|
||||
* 'toast-top-left', 'toast-top-center', 'toast-top-rigt',
|
||||
* 'toast-bottom-left', 'toast-bottom-center', 'toast-bottom-rigt',
|
||||
*/
|
||||
'position-class'?: string;
|
||||
'title-class'?: string;
|
||||
'message-class'?: string;
|
||||
'prevent-duplicates'?: boolean;
|
||||
/**
|
||||
* stop timeout on mouseover and restart timer on mouseout
|
||||
*/
|
||||
'mouseover-timer-stop'?: boolean;
|
||||
}
|
||||
|
||||
interface IIconClasses {
|
||||
error: string;
|
||||
info: string;
|
||||
wait: string;
|
||||
success: string;
|
||||
warning: string;
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user