mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 23:07:06 +00:00
+19
-19
@@ -22,15 +22,15 @@ Este es el método preferido. Solo está disponible para usuarios TypeScript 2.0
|
||||
npm install --save-dev @types/node
|
||||
```
|
||||
|
||||
Los types deberían ser incluidos automaticamente por el compilador.
|
||||
Los types deberían ser incluidos automáticamente por el compilador.
|
||||
Vea más en el [manual](http://www.typescriptlang.org/docs/handbook/declaration-files/consumption.html).
|
||||
|
||||
Para un paquete NPM "foo", Estos `typings` estarán en "@types/foo".
|
||||
Para un paquete NPM "foo", estos `typings` estarán en "@types/foo".
|
||||
Si no puedes encontrar tu paquete, búscalo en [TypeSearch](https://microsoft.github.io/TypeSearch/).
|
||||
|
||||
Si aún no puedes encontrarlo, comprueba si el paquete ya [incluye](http://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html) los typings.
|
||||
Esto es provisto usualmente en el campo `"types"` o `"typings"` en el `package.json`,
|
||||
o solo busca por cualquier archivo ".d.ts" en el paquete e incluyelo manualmente con un `/// <reference path="" />`.
|
||||
o solo busca por cualquier archivo ".d.ts" en el paquete e inclúyelo manualmente con un `/// <reference path="" />`.
|
||||
|
||||
|
||||
### Otros métodos
|
||||
@@ -39,7 +39,7 @@ Estos pueden ser utilizados por TypeScript 1.0.
|
||||
|
||||
* [Typings](https://github.com/typings/typings)
|
||||
* ~~[NuGet](http://nuget.org/packages?q=DefinitelyTyped)~~ (use las alternativas preferidas, la publicación DT type de nuget ha sido desactivada)
|
||||
* Descarguelo manualmente desde la `master` branch de este repositorio
|
||||
* Descárguelo manualmente desde la `master` branch de este repositorio
|
||||
|
||||
Tal vez debas añadir manualmente las [referencias](http://www.typescriptlang.org/docs/handbook/triple-slash-directives.html).
|
||||
|
||||
@@ -88,7 +88,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.
|
||||
* También puede que quieras añadirle 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>`.
|
||||
- O si hay más personas, puede ser multiline
|
||||
@@ -109,7 +109,7 @@ Si no lo hace, puedes hacerlo en el comentario asociado con el PR.
|
||||
Si eres el autor de la librería, o puedes hacer un pull request a la biblioteca, [bundle types](http://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html) en vez de publicarlo en DefinitelyTyped.
|
||||
|
||||
Si estás agregando typings para un paquete NPM, crea un directorio con el mismo nombre.
|
||||
Si el paquete al que le estás agregando typings no es para NPM, asegurate de que el nombre que escojas no genere problemas con el nombre del paquete en NPM.
|
||||
Si el paquete al que le estás agregando typings no es para NPM, asegúrate de que el nombre que escojas no genere problemas con el nombre del paquete en NPM.
|
||||
(Puedes usar `npm info foo` para verificar la existencia del paquete `foo`.)
|
||||
|
||||
Tu paquete debería tener esta estructura:
|
||||
@@ -126,7 +126,7 @@ Ve todas las opciones en [dts-gen](https://github.com/Microsoft/dts-gen).
|
||||
|
||||
También puedes configurar el `tsconfig.json` para añadir nuevos archivos, para agregar un `"target": "es6"` (necesitado por las funciones asíncronas), para agregar a la `"lib"`, o para agregar la opción de compilación `"jsx"`.
|
||||
|
||||
Los miembros de DefinitelyTyped frecuentemente monitorean nuevos PRs, pero ten en mente que la cantidad de PRs podrian ralentizar el proceso.
|
||||
Los miembros de DefinitelyTyped frecuentemente monitorean nuevos PRs, pero ten en mente que la cantidad de PRs podrían ralentizar el proceso.
|
||||
|
||||
Para un buen paquete de ejemplo, vea [base64-js](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/base64-js).
|
||||
|
||||
@@ -135,7 +135,7 @@ Para un buen paquete de ejemplo, vea [base64-js](https://github.com/DefinitelyTy
|
||||
|
||||
* Primero, sigue el consejo del [manual](http://www.typescriptlang.org/docs/handbook/declaration-files/do-s-and-don-ts.html).
|
||||
* Formatear: Ya sea utilizar todo en tabs, o siempre utiliza 4 espacios.
|
||||
* `function sum(nums: number[]): number`: Utiliza `ReadonlyArray` si una funcion no escribe a sus parámetros.
|
||||
* `function sum(nums: number[]): number`: Utiliza `ReadonlyArray` si una función no escribe a sus parámetros.
|
||||
* `interface Foo { new(): Foo; }`:
|
||||
Este define el tipo de objeto que esten nuevos. Probablemente quieras `declare class Foo { constructor(); }`.
|
||||
* `const Class: { new(): IClass; }`:
|
||||
@@ -146,7 +146,7 @@ Para un buen paquete de ejemplo, vea [base64-js](https://github.com/DefinitelyTy
|
||||
Un ejemplo donde un tipo de parámetro es aceptable: `function id<T>(value: T): T;`.
|
||||
Un ejemplo donde no es aceptable: `function parseJson<T>(json: string): T;`.
|
||||
Una excepción: `new Map<string, number>()` está bien.
|
||||
* Utilizando los tipos `Function` y `Object` casi nunca es una buena idea. En 99% de los casos es posible especificar un tipo más especifico. Los ejemplos son `(x: number) => number` para [funciones](http://www.typescriptlang.org/docs/handbook/functions.html#function-types) y `{ x: number, y: number }` para objetos. Si no hay certeza en lo absoluto del tipo, [`any`](http://www.typescriptlang.org/docs/handbook/basic-types.html#any) es la opción correcta, no `Object`. Si el único hecho conocido sobre el tipo es que es un objecto, usa el tipo [`object`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-2.html#object-type), no `Object` o `{ [key: string]: any }`.
|
||||
* Utilizando los tipos `Function` y `Object` casi nunca es una buena idea. En 99% de los casos es posible especificar un tipo más específico. Los ejemplos son `(x: number) => number` para [funciones](http://www.typescriptlang.org/docs/handbook/functions.html#function-types) y `{ x: number, y: number }` para objetos. Si no hay certeza en lo absoluto del tipo, [`any`](http://www.typescriptlang.org/docs/handbook/basic-types.html#any) es la opción correcta, no `Object`. Si el único hecho conocido sobre el tipo es que es un objecto, usa el tipo [`object`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-2.html#object-type), no `Object` o `{ [key: string]: any }`.
|
||||
* `var foo: string | any`:
|
||||
Cuando es usado `any` en un tipo de unión, el tipo resultante todavía es `any`. Así que mientras la porción `string` de este tipo de anotación puede _verse_ útil, de hecho, no ofrece ningún typechecking adicional más que un simple `any`.
|
||||
Dependiendo de la intención, una alternativa aceptable puede ser `any`, `string`, o `string | object`.
|
||||
@@ -204,11 +204,11 @@ Este script utiliza [dtslint](https://github.com/Microsoft/dtslint).
|
||||
|
||||
#### ¿Cuál es exactamente la relación entre este repositorio y los paquetes de `@types` en NPM?
|
||||
|
||||
La `master` branch es automaticamente publicada en el alcance de los `@types` en NPM gracias a los [types-publisher](https://github.com/Microsoft/types-publisher).
|
||||
La `master` branch es automáticamente publicada en el alcance de los `@types` en NPM gracias a los [types-publisher](https://github.com/Microsoft/types-publisher).
|
||||
|
||||
#### He enviado un pull request. ¿Cuánto tardará en ser merged?
|
||||
|
||||
Esto depende, pero la mayoría de los pull requests serán merged en alrededor de una semana. PRs que hayan sido aprovados por un autor listado en el encabezado de las definiciones usualmente son merged más rápidamente; PRs para nuevas definiciones tomarán más tiempo ya que requieren más revisiones de los mantenedores. Cada PR es revisado por un miembro de TypeScript o DefinitelyTyped antes de ser merged, por favor se paciente debido a que factores humanos pueden causar retrasos. Revisa el [PR Burndown Board](https://github.com/DefinitelyTyped/DefinitelyTyped/projects/3?card_filter_query=is%3Aopen) para ver el progreso mientras los mantenedores trabajan on los PRs abiertos.
|
||||
Esto depende, pero la mayoría de los pull requests serán merged en alrededor de una semana. PRs que hayan sido aprobados por un autor listado en el encabezado de las definiciones usualmente son merged más rápidamente; PRs para nuevas definiciones tomarán más tiempo ya que requieren más revisiones de los mantenedores. Cada PR es revisado por un miembro de TypeScript o DefinitelyTyped antes de ser merged, por favor sé paciente debido a que factores humanos pueden causar retrasos. Revisa el [PR Burndown Board](https://github.com/DefinitelyTyped/DefinitelyTyped/projects/3?card_filter_query=is%3Aopen) para ver el progreso mientras los mantenedores trabajan en los PRs abiertos.
|
||||
|
||||
#### Mi PR ha sido merged; ¿cuándo será actualizado el paquete de `@types` NPM?
|
||||
|
||||
@@ -216,12 +216,12 @@ Los paquetes NPM deberán ser actualizados en unas cuantas horas. Si ha pasado m
|
||||
|
||||
#### Estoy escribiendo una definición que depende de otra definición. Debería utilizar `<reference types="" />` o una import?
|
||||
|
||||
Si el modulo al cual te estás refiriendo es un módulo externo (utiliza `export`), utilice una import.
|
||||
Si el módulo al cual te estás refiriendo es un módulo externo (utiliza `export`), utilice una import.
|
||||
Si el módulo al cual te refieres es un módulo ambiente (utiliza `declare module`, o simplemente declara las globales), utilice `<reference types="" />`.
|
||||
|
||||
#### He notado que algunos paquetes aquí tienen `package.json`.
|
||||
|
||||
Normalmente no lo necesitaras. Cuando publicas un paquete normalmente nosotros automáticamente crearemos un `package.json` para eso.
|
||||
Normalmente no lo necesitarás. Cuando publicas un paquete normalmente nosotros automáticamente crearemos un `package.json` para eso.
|
||||
Un `package.json` puede ser incluido por el bien de especificar dependencias. Aquí tienen un [ejemplo](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/pikaday/package.json).
|
||||
No aceptamos otros campos, tales como `"description"`, para que sean definidos manualmente.
|
||||
Además, si necesitas referencia a una versión anterior de typings, debes hacerlo añadiendo `"dependencies": { "@types/foo": "x.y.z" }` al package.json.
|
||||
@@ -260,7 +260,7 @@ Cuando ya no sea un borrador, lo podremos eliminar desde DefinitelyType y hacer
|
||||
Si planeas continuar actualizando la versión anterior del paquete, puedes crear una subcarpeta con la versión actual p.ej. `v2`, y copia los archivos existentes. Si es así, necesitarás:
|
||||
|
||||
1. Actualiza las rutas relativas en `tsconfig.json` al igual que `tslint.json`.
|
||||
2. Añadir reglas de mapeo de rutas para asegurart de que la prueba se está ejecutando contra la versión prevista.
|
||||
2. Añadir reglas de mapeo de rutas para asegurarte de que la prueba se está ejecutando contra la versión prevista.
|
||||
|
||||
Por ejemplo [history v2 `tsconfig.json`](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/history/v2/tsconfig.json) se ve así:
|
||||
|
||||
@@ -280,24 +280,24 @@ Por ejemplo [history v2 `tsconfig.json`](https://github.com/DefinitelyTyped/Defi
|
||||
}
|
||||
```
|
||||
|
||||
Si hay otros paquetes en DefinitelyTyped que son incompatibles con la nueva versión, necesitaras mapear las rutas a la versión anterior. También deberá hacer esto para los paquetes que dependen de paquetes que dependen de una version anterior.
|
||||
Si hay otros paquetes en DefinitelyTyped que son incompatibles con la nueva versión, necesitarás mapear las rutas a la versión anterior. También deberá hacer esto para los paquetes que dependen de paquetes que dependen de una version anterior.
|
||||
|
||||
Por ejemplo, `react-router` depende de `history@2`, así que [react-router `tsconfig.json`](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react-router/tsconfig.json) tiene una ruta mapeada a "history": `[ "history/v2" ]`;
|
||||
transitivo así mismo, `react-router-bootstrap` (que depende de `react-router`) también añade una ruta mapeada en su [tsconfig.json](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react-router-bootstrap/tsconfig.json).
|
||||
|
||||
Además, `/// <reference types=".." />` no trabajara con rutas mapeadas, así que las dependencias deberán utilizar `import`.
|
||||
Además, `/// <reference types=".." />` no trabajará con rutas mapeadas, así que las dependencias deberán utilizar `import`.
|
||||
|
||||
#### ¿Cómo escribo definitions para paquetes que pueden ser usados globalmente y como un módulo?
|
||||
|
||||
El manual de TypeScript contiene excelente [información general para escribir definiciones](https://www.typescriptlang.org/docs/handbook/declaration-files/introduction.html), ademas [este archivo de definiciones de ejemplo](https://www.typescriptlang.org/docs/handbook/declaration-files/templates/global-modifying-module-d-ts.html) el cual muestra como crear una definición utilizando la sintaxis de módulo en ES6, asi como también especificando objetos que son disponibles en el alcance global. Esta técnica es demostrada practicamente en la [definición para big.js](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/big.js/index.d.ts), el cual es una librería que puede ser cargada globalmente a travéz de una etiqueta script en una página web, o importada via require o imports estilo ES6.
|
||||
El manual de TypeScript contiene excelente [información general para escribir definiciones](https://www.typescriptlang.org/docs/handbook/declaration-files/introduction.html), además [este archivo de definiciones de ejemplo](https://www.typescriptlang.org/docs/handbook/declaration-files/templates/global-modifying-module-d-ts.html) el cual muestra como crear una definición utilizando la sintaxis de módulo en ES6, asi como también especificando objetos que son disponibles en el alcance global. Esta técnica es demostrada prácticamente en la [definición para big.js](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/big.js/index.d.ts), el cual es una librería que puede ser cargada globalmente a través de una etiqueta script en una página web, o importada vía require o imports estilo ES6.
|
||||
|
||||
Para probar como puede ser usada tu definición cuando se refieren globalmente o como un módulo importado, crea una carpeta `test`, y coloca dos archivos de prueba en él. nombra uno `YourLibraryName-global.test.ts` y el otro `YourLibraryName-module.test.ts`. El archivo de prueba _global_ debe ejercer la definición de acuerdo como va a ser usado en un script cargado en una página web donde la librería estará disponible en el alcance global - en este escenario no debes de especificar la sentencia de import. El archivo _módulo_ de prueba debe de ejercer la definición de acuerdo a como va a ser utilizado cuando sea importado (incluyendo las sentencias `import`). Si especificas un propiedad `files` en tu archivo tsconfig.json, asegurate de incluir ambos archivos de prueba. Un [ejemplo práctico de esto](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/big.js/test) es también disponible en la definición de big.js.
|
||||
Para probar como puede ser usada tu definición cuando se refieren globalmente o como un módulo importado, crea una carpeta `test`, y coloca dos archivos de prueba en él. nombra uno `YourLibraryName-global.test.ts` y el otro `YourLibraryName-module.test.ts`. El archivo de prueba _global_ debe ejercer la definición de acuerdo como va a ser usado en un script cargado en una página web donde la librería estará disponible en el alcance global - en este escenario no debes de especificar la sentencia de import. El archivo _módulo_ de prueba debe de ejercer la definición de acuerdo a como va a ser utilizado cuando sea importado (incluyendo las sentencias `import`). Si especificas una propiedad `files` en tu archivo tsconfig.json, asegurate de incluir ambos archivos de prueba. Un [ejemplo práctico de esto](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/big.js/test) es también disponible en la definición de big.js.
|
||||
|
||||
Por favor tenga en cuenta que no es necesario para ejercer plenamente la definición en cada archivo de prueba - Es suficiente con probar solo los elementos globalmente accesibles en la prueba de archivos globales y ejercer la definición en el módulo del archivo de prueba, o viceversa.
|
||||
|
||||
#### ¿Qué pasa con paquetes scoped?
|
||||
|
||||
Types para un paquete scoped `@foo/bar` deberán ir en `types/foo__bar`. tenga en cuenta el doble guion bajo.
|
||||
Types para un paquete scoped `@foo/bar` deberán ir en `types/foo__bar`. tenga en cuenta el doble guión bajo.
|
||||
|
||||
Cuando `dts-gen` es utilizado como scaffold en un paquete scoped, las propiedades `paths` deberán ser adaptadas manualmente en el paquete generado
|
||||
`tsconfig.json` para referenciar correctamente el paquete scoped:
|
||||
|
||||
@@ -930,6 +930,12 @@
|
||||
"sourceRepoURL": "https://github.com/blakeembrey/lower-case-first",
|
||||
"asOfVersion": "1.0.1"
|
||||
},
|
||||
{
|
||||
"libraryName": "mali",
|
||||
"typingsPackageName": "mali",
|
||||
"sourceRepoURL": "https://github.com/malijs/mali",
|
||||
"asOfVersion": "0.9.2"
|
||||
},
|
||||
{
|
||||
"libraryName": "maquette",
|
||||
"typingsPackageName": "maquette",
|
||||
@@ -1200,6 +1206,12 @@
|
||||
"sourceRepoURL": "https://github.com/react-ga/react-ga",
|
||||
"asOfVersion": "2.3.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "react-i18next",
|
||||
"typingsPackageName": "react-i18next",
|
||||
"sourceRepoURL": "https://github.com/i18next/react-i18next",
|
||||
"asOfVersion": "8.1.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "react-monaco-editor",
|
||||
"typingsPackageName": "react-monaco-editor",
|
||||
|
||||
@@ -533,9 +533,10 @@ AFRAME.registerComponent('audioanalyser-waveform', {
|
||||
rings.forEach(function transformRing(ring: THREE.Line, index: number) {
|
||||
var normLevel;
|
||||
normLevel = levels[RINGCOUNT - index - 1] + 0.01; // Avoid scaling by 0.
|
||||
(ring.material as THREE.LineBasicMaterial).color.setHSL(colors[index], 1, normLevel);
|
||||
ring.material.linewidth = normLevel * 3;
|
||||
ring.material.opacity = normLevel;
|
||||
const lineMaterial = ring.material as THREE.LineBasicMaterial;
|
||||
lineMaterial.color.setHSL(colors[index], 1, normLevel);
|
||||
lineMaterial.linewidth = normLevel * 3;
|
||||
lineMaterial.opacity = normLevel;
|
||||
ring.scale.z = normLevel;
|
||||
});
|
||||
},
|
||||
|
||||
Vendored
+1
@@ -2,6 +2,7 @@
|
||||
// Project: https://github.com/epoberezkin/ajv-errors
|
||||
// Definitions by: Afshawn Lotfi <https://github.com/afshawnlotfi>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
import { Ajv } from "ajv";
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
import { parse, stringify } from 'ale-url-parser';
|
||||
|
||||
let url;
|
||||
let urlObject;
|
||||
|
||||
url = stringify({});
|
||||
console.log(url);
|
||||
|
||||
url = stringify({
|
||||
protocol: 'protocol',
|
||||
host: 'host',
|
||||
path: ['foo', 'bar', 'baz'],
|
||||
hash: 'hash',
|
||||
query: {
|
||||
foo: 1,
|
||||
bar: [2, '3']
|
||||
}
|
||||
});
|
||||
console.log(url);
|
||||
|
||||
urlObject = parse('//any.dom.ain.co.m/foo/bar?test=1&test=2#hash');
|
||||
console.log(urlObject);
|
||||
Vendored
+29
@@ -0,0 +1,29 @@
|
||||
// Type definitions for ale-url-parser 0.10
|
||||
// Project: https://github.com/msn0/ale-url-parser#readme
|
||||
// Definitions by: Michał Jezierski <https://github.com/msn0>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.1
|
||||
|
||||
export interface QueryParams {
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
export interface UrlObject {
|
||||
protocol?: string;
|
||||
host?: string;
|
||||
path?: string[];
|
||||
query?: QueryParams;
|
||||
hash?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse url string into url object.
|
||||
* @return UrlObject
|
||||
*/
|
||||
export function parse(url: string): UrlObject;
|
||||
|
||||
/**
|
||||
* Stringify url object into url string.
|
||||
* @return string
|
||||
*/
|
||||
export function stringify(urlObject: UrlObject): string;
|
||||
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"ale-url-parser-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -21,6 +21,7 @@ let _algoliaResponse: Response = {
|
||||
processingTimeMS: 32,
|
||||
query: '',
|
||||
params: '',
|
||||
index: '',
|
||||
};
|
||||
|
||||
let _clientOptions: ClientOptions = {
|
||||
@@ -103,7 +104,7 @@ let _algoliaQueryParameters: QueryParameters = {
|
||||
filters: '',
|
||||
attributesToRetrieve: [''],
|
||||
restrictSearchableAttributes: [''],
|
||||
facets: '',
|
||||
facets: [''],
|
||||
facetingAfterDistinct: true,
|
||||
maxValuesPerFacet: 2,
|
||||
attributesToHighlight: [''],
|
||||
@@ -121,28 +122,29 @@ let _algoliaQueryParameters: QueryParameters = {
|
||||
typoTolerance: false,
|
||||
allowTyposOnNumericTokens: false,
|
||||
ignorePlurals: false,
|
||||
disableTypoToleranceOnAttributes: '',
|
||||
disableTypoToleranceOnAttributes: [''],
|
||||
aroundLatLng: '',
|
||||
aroundLatLngViaIP: '',
|
||||
aroundRadius: 0,
|
||||
aroundPrecision: 0,
|
||||
minimumAroundRadius: 0,
|
||||
insideBoundingBox: [[0]],
|
||||
queryType: '',
|
||||
queryType: 'prefixAll',
|
||||
insidePolygon: [[0]],
|
||||
removeWordsIfNoResults: '',
|
||||
removeWordsIfNoResults: 'firstWords',
|
||||
advancedSyntax: false,
|
||||
optionalWords: [''],
|
||||
removeStopWords: [''],
|
||||
disableExactOnAttributes: [''],
|
||||
exactOnSingleWordQuery: '',
|
||||
alternativesAsExact: true,
|
||||
exactOnSingleWordQuery: 'attribute',
|
||||
alternativesAsExact: ["ignorePlurals"],
|
||||
distinct: 0,
|
||||
getRankingInfo: false,
|
||||
numericAttributesToIndex: [''],
|
||||
numericAttributesForFiltering: [''],
|
||||
numericFilters: [''],
|
||||
tagFilters: '',
|
||||
facetFilters: '',
|
||||
tagFilters: [''],
|
||||
facetFilters: [''],
|
||||
analytics: false,
|
||||
analyticsTags: [''],
|
||||
synonyms: true,
|
||||
@@ -172,8 +174,38 @@ index.partialUpdateObjects([{}], false).then(() => {});
|
||||
let indexName : string = index.indexName;
|
||||
|
||||
// complete copy
|
||||
client.copyIndex('from', 'to').then(()=>{})
|
||||
client.copyIndex('from', 'to', ()=> {})
|
||||
client.copyIndex('from', 'to').then(()=>{});
|
||||
client.copyIndex('from', 'to', ()=> {});
|
||||
// with scope
|
||||
client.copyIndex('from', 'to', ['settings']).then(()=>{})
|
||||
client.copyIndex('from', 'to', ['synonyms', 'rules'], ()=> {})
|
||||
client.copyIndex('from', 'to', ['settings']).then(()=>{});
|
||||
client.copyIndex('from', 'to', ['synonyms', 'rules'], ()=> {});
|
||||
|
||||
// Browsing
|
||||
const browser = index.browseAll();
|
||||
index.browseAll('query');
|
||||
index.browseAll('', {
|
||||
filters: 'dog',
|
||||
});
|
||||
|
||||
let hits: Object[] = [];
|
||||
|
||||
browser.on('result', function onResult(content) {
|
||||
hits = hits.concat(content.hits);
|
||||
});
|
||||
|
||||
browser.on('end', function onEnd() {
|
||||
const _message = `We got ${hits.length} hits`
|
||||
});
|
||||
|
||||
browser.on('error', function onError(err) {
|
||||
throw err;
|
||||
});
|
||||
|
||||
browser.stop();
|
||||
|
||||
index.browse("", {
|
||||
advancedSyntax: false,
|
||||
attributesToRetrieve: ['dogs']
|
||||
});
|
||||
client.copyIndex('from', 'to', ['settings']).then(()=>{});
|
||||
client.copyIndex('from', 'to', ['synonyms', 'rules'], ()=> {});
|
||||
|
||||
Vendored
+145
-101
@@ -1,11 +1,14 @@
|
||||
// Type definitions for algoliasearch-client-js 3.27.0
|
||||
// Type definitions for algoliasearch-client-js 3.30.0
|
||||
// Project: https://github.com/algolia/algoliasearch-client-js
|
||||
// Definitions by: Baptiste Coquelle <https://github.com/cbaptiste>
|
||||
// Haroen Viaene <https://github.com/haroenv>
|
||||
// Aurélien Hervé <https://github.com/aherve>
|
||||
// Samuel Vaillant <https://github.com/samouss>
|
||||
// Kai Eichinger <https://github.com/keichinger>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>
|
||||
|
||||
declare namespace algoliasearch {
|
||||
/**
|
||||
@@ -611,6 +614,11 @@ declare namespace algoliasearch {
|
||||
options: SearchForFacetValues.Parameters,
|
||||
cb: (err: Error, res: SearchForFacetValues.Response) => void
|
||||
): void;
|
||||
/**
|
||||
* Browse an index
|
||||
* https://github.com/algolia/algoliasearch-client-js#backup--export-an-index---browse
|
||||
*/
|
||||
browse(query: string, parameters: BrowseParameters, cb: (err: Error, res: BrowseResponse) => void): void;
|
||||
/**
|
||||
* Browse an index
|
||||
* https://github.com/algolia/algoliasearch-client-js#backup--export-an-index---browse
|
||||
@@ -620,7 +628,7 @@ declare namespace algoliasearch {
|
||||
* Browse an index
|
||||
* https://github.com/algolia/algoliasearch-client-js#backup--export-an-index---browse
|
||||
*/
|
||||
browse(query: string): Promise<BrowseResponse>;
|
||||
browse(query: string, parameters?: BrowseParameters): Promise<BrowseResponse>;
|
||||
/**
|
||||
* Browse an index from a cursor
|
||||
* https://github.com/algolia/algoliasearch-client-js#backup--export-an-index---browse
|
||||
@@ -638,7 +646,7 @@ declare namespace algoliasearch {
|
||||
* Browse an entire index
|
||||
* https://github.com/algolia/algoliasearch-client-js#backup--export-an-index---browse
|
||||
*/
|
||||
browseAll(): Promise<Response>;
|
||||
browseAll(query?: string, parameters?: BrowseParameters): Browser;
|
||||
/**
|
||||
* Clear an index content
|
||||
* https://github.com/algolia/algoliasearch-client-js#clear-index---clearindex
|
||||
@@ -966,6 +974,22 @@ declare namespace algoliasearch {
|
||||
query: string;
|
||||
processingTimeMS: number;
|
||||
}
|
||||
type BrowseParameters = Omit<
|
||||
QueryParameters,
|
||||
| "typoTolerance"
|
||||
| "distinct"
|
||||
| "facets"
|
||||
| "getRankingInfo"
|
||||
| "attributesToHighlight"
|
||||
| "attributesToSnippet"
|
||||
>
|
||||
interface Browser {
|
||||
on(type: "error", cb: (err: Error) => void): void
|
||||
on(type: "end", cb: () => void): void
|
||||
on(type: "stop", cb: () => void): void
|
||||
on(type: "result", cb: (content: BrowseResponse) => void): void
|
||||
stop(): void
|
||||
}
|
||||
/**
|
||||
* Describes a synonym object
|
||||
*/
|
||||
@@ -1099,120 +1123,121 @@ declare namespace algoliasearch {
|
||||
userToken?: string;
|
||||
}
|
||||
interface QueryParameters {
|
||||
/**
|
||||
* Query string used to perform the search
|
||||
* default: ''
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/query/
|
||||
*/
|
||||
query?: string;
|
||||
/**
|
||||
* Filter the query with numeric, facet or/and tag filters
|
||||
* default: ""
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/filters/
|
||||
*/
|
||||
filters?: string;
|
||||
/**
|
||||
* A string that contains the list of attributes you want to retrieve in order to minimize the size of the JSON answer.
|
||||
* default: *
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/attributesToRetrieve/
|
||||
*/
|
||||
attributesToRetrieve?: string[];
|
||||
/**
|
||||
* List of attributes you want to use for textual search
|
||||
* default: attributeToIndex
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/restrictSearchableAttributes/
|
||||
*/
|
||||
restrictSearchableAttributes?: string[];
|
||||
/**
|
||||
* You can use facets to retrieve only a part of your attributes declared in attributesForFaceting attributes
|
||||
* default: []
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/facets/
|
||||
*/
|
||||
facets?: string[];
|
||||
/**
|
||||
* Query string used to perform the search
|
||||
* default: ''
|
||||
* https://github.com/algolia/algoliasearch-client-js#query
|
||||
*/
|
||||
query?: string;
|
||||
/**
|
||||
* Filter the query with numeric, facet or/and tag filters
|
||||
* default: ""
|
||||
* https://github.com/algolia/algoliasearch-client-js#filters
|
||||
*/
|
||||
filters?: string;
|
||||
/**
|
||||
* A string that contains the list of attributes you want to retrieve in order to minimize the size of the JSON answer.
|
||||
* default: *
|
||||
* https://github.com/algolia/algoliasearch-client-js#attributestoretrieve
|
||||
*/
|
||||
attributesToRetrieve?: string[];
|
||||
/**
|
||||
* List of attributes you want to use for textual search
|
||||
* default: attributeToIndex
|
||||
* https://github.com/algolia/algoliasearch-client-js#restrictsearchableattributes
|
||||
*/
|
||||
restrictSearchableAttributes?: string[];
|
||||
/**
|
||||
* You can use facets to retrieve only a part of your attributes declared in attributesForFaceting attributes
|
||||
* default: ""
|
||||
* https://github.com/algolia/algoliasearch-client-js#facets
|
||||
*/
|
||||
facets?: string | string[];
|
||||
/**
|
||||
* Force faceting to be applied after de-duplication (via the Distinct setting).
|
||||
* When using the distinct setting in combination with faceting, facet counts may be higher than expected.
|
||||
* This is because the engine, by default, computes faceting before applying de-duplication (distinct).
|
||||
* When using the distinct setting in combination with faceting, facet counts may be higher than expected.
|
||||
* This is because the engine, by default, computes faceting before applying de-duplication (distinct).
|
||||
* When facetingAfterDistinct is set to true, the engine calculates faceting after the de-duplication has been applied.
|
||||
* default ""
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/facetingAfterDistinct/
|
||||
*/
|
||||
facetingAfterDistinct?: boolean;
|
||||
/**
|
||||
* Limit the number of facet values returned for each facet.
|
||||
* default: ""
|
||||
* https://github.com/algolia/algoliasearch-client-js#maxvaluesperfacet
|
||||
* default: 100
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/maxValuesPerFacet/
|
||||
*/
|
||||
maxValuesPerFacet?: number;
|
||||
/**
|
||||
* Default list of attributes to highlight. If set to null, all indexed attributes are highlighted.
|
||||
* default: null
|
||||
* https://github.com/algolia/algoliasearch-client-js#attributestohighlight
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/attributesToHighlight/
|
||||
*/
|
||||
attributesToHighlight?: string[];
|
||||
/**
|
||||
* Default list of attributes to snippet alongside the number of words to return
|
||||
* default: null
|
||||
* https://github.com/algolia/algoliasearch-client-js#attributestosnippet
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/attributesToSnippet/
|
||||
*/
|
||||
attributesToSnippet?: string[];
|
||||
/**
|
||||
* Specify the string that is inserted before the highlighted parts in the query result
|
||||
* default: <em>
|
||||
* https://github.com/algolia/algoliasearch-client-js#highlightpretag
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/highlightPreTag/
|
||||
*/
|
||||
highlightPreTag?: string;
|
||||
/**
|
||||
* Specify the string that is inserted after the highlighted parts in the query result
|
||||
* default: </em>
|
||||
* https://github.com/algolia/algoliasearch-client-js#highlightposttag
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/highlightPostTag/
|
||||
*/
|
||||
highlightPostTag?: string;
|
||||
/**
|
||||
* String used as an ellipsis indicator when a snippet is truncated.
|
||||
* default: …
|
||||
* https://github.com/algolia/algoliasearch-client-js#snippetellipsistext
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/snippetEllipsisText/
|
||||
*/
|
||||
snippetEllipsisText?: string;
|
||||
/**
|
||||
* If set to true, restrict arrays in highlights and snippets to items that matched the query at least partially else return all array items in highlights and snippets
|
||||
* default: false
|
||||
* https://github.com/algolia/algoliasearch-client-js#restricthighlightandsnippetarrays
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/restrictHighlightAndSnippetArrays/
|
||||
*/
|
||||
restrictHighlightAndSnippetArrays?: boolean;
|
||||
/**
|
||||
* Pagination parameter used to select the number of hits per page
|
||||
* default: 20
|
||||
* https://github.com/algolia/algoliasearch-client-js#hitsperpage
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/hitsPerPage/
|
||||
*/
|
||||
hitsPerPage?: number;
|
||||
/**
|
||||
* Pagination parameter used to select the page to retrieve.
|
||||
* default: 0
|
||||
* https://github.com/algolia/algoliasearch-client-js#page
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/page/
|
||||
*/
|
||||
page?: number;
|
||||
/**
|
||||
* Offset of the first hit to return
|
||||
* default: null
|
||||
* https://github.com/algolia/algoliasearch-client-js#offset
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/offset/
|
||||
*/
|
||||
offset?: number;
|
||||
/**
|
||||
* Number of hits to return.
|
||||
* default: null
|
||||
* https://github.com/algolia/algoliasearch-client-js#length
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/length/
|
||||
*/
|
||||
length?: number;
|
||||
/**
|
||||
* The minimum number of characters needed to accept one typo.
|
||||
* default: 4
|
||||
* https://github.com/algolia/algoliasearch-client-js#minwordsizefor1typo
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/minWordSizefor1Typo/
|
||||
*/
|
||||
minWordSizefor1Typo?: number;
|
||||
/**
|
||||
* The minimum number of characters needed to accept two typo.
|
||||
* fault: 8
|
||||
* https://github.com/algolia/algoliasearch-client-js#minwordsizefor2typos
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/minWordSizefor2Typos/
|
||||
*/
|
||||
minWordSizefor2Typos?: number;
|
||||
/**
|
||||
@@ -1222,62 +1247,62 @@ declare namespace algoliasearch {
|
||||
* 'false' The typo tolerance is disabled. All results with typos will be hidden.
|
||||
* 'min' Only keep results with the minimum number of typos
|
||||
* 'strict' Hits matching with 2 typos are not retrieved if there are some matching without typos.
|
||||
* https://github.com/algolia/algoliasearch-client-js#minwordsizefor2typos
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/typoTolerance/
|
||||
*/
|
||||
typoTolerance?: boolean;
|
||||
/**
|
||||
* If set to false, disables typo tolerance on numeric tokens (numbers).
|
||||
* default:
|
||||
* https://github.com/algolia/algoliasearch-client-js#allowtyposonnumerictokens
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/allowTyposOnNumericTokens/
|
||||
*/
|
||||
allowTyposOnNumericTokens?: boolean;
|
||||
/**
|
||||
* If set to true, plural won't be considered as a typo
|
||||
* default: false
|
||||
* https://github.com/algolia/algoliasearch-client-js#ignoreplurals
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/ignorePlurals/
|
||||
*/
|
||||
ignorePlurals?: boolean;
|
||||
/**
|
||||
* List of attributes on which you want to disable typo tolerance
|
||||
* default: ""
|
||||
* https://github.com/algolia/algoliasearch-client-js#disabletypotoleranceonattributes
|
||||
* default: []
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/disableTypoToleranceOnAttributes/
|
||||
*/
|
||||
disableTypoToleranceOnAttributes?: string;
|
||||
disableTypoToleranceOnAttributes?: string[];
|
||||
/**
|
||||
* Search for entries around a given location
|
||||
* default: ""
|
||||
* https://github.com/algolia/algoliasearch-client-js#aroundlatlng
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/aroundLatLng/
|
||||
*/
|
||||
aroundLatLng?: string;
|
||||
/**
|
||||
* Search for entries around a given latitude/longitude automatically computed from user IP address.
|
||||
* default: ""
|
||||
* https://github.com/algolia/algoliasearch-client-js#aroundlatlngviaip
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/aroundLatLngViaIP/
|
||||
*/
|
||||
aroundLatLngViaIP?: string;
|
||||
/**
|
||||
* Control the radius associated with a geo search. Defined in meters.
|
||||
* default: null
|
||||
* You can specify aroundRadius=all if you want to compute the geo distance without filtering in a geo area
|
||||
* https://github.com/algolia/algoliasearch-client-js#aroundradius
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/aroundRadius/
|
||||
*/
|
||||
aroundRadius?: number | 'all';
|
||||
/**
|
||||
* Control the precision of a geo search
|
||||
* default: null
|
||||
* https://github.com/algolia/algoliasearch-client-js#aroundprecision
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/aroundPrecision/
|
||||
*/
|
||||
aroundPrecision?: number;
|
||||
/**
|
||||
* Define the minimum radius used for a geo search when aroundRadius is not set.
|
||||
* default: null
|
||||
* https://github.com/algolia/algoliasearch-client-js#minimumaroundradius
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/minimumAroundRadius/
|
||||
*/
|
||||
minimumAroundRadius?: number;
|
||||
/**
|
||||
* Search entries inside a given area defined by the two extreme points of a rectangle
|
||||
* default: null
|
||||
* https://github.com/algolia/algoliasearch-client-js#insideboundingbox
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/insideBoundingBox/
|
||||
*/
|
||||
insideBoundingBox?: number[][];
|
||||
/**
|
||||
@@ -1286,13 +1311,13 @@ declare namespace algoliasearch {
|
||||
* 'prefixAll' All query words are interpreted as prefixes. This option is not recommended.
|
||||
* 'prefixLast' Only the last word is interpreted as a prefix (default behavior).
|
||||
* 'prefixNone' No query word is interpreted as a prefix. This option is not recommended.
|
||||
* https://github.com/algolia/algoliasearch-client-js#querytype
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/queryType/
|
||||
*/
|
||||
queryType?: any;
|
||||
queryType?: "prefixAll"|"prefixLast"|"prefixNone";
|
||||
/**
|
||||
* Search entries inside a given area defined by a set of points
|
||||
* defauly: ''
|
||||
* https://github.com/algolia/algoliasearch-client-js#insidepolygon
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/insidePolygon/
|
||||
*/
|
||||
insidePolygon?: number[][];
|
||||
/**
|
||||
@@ -1302,19 +1327,19 @@ declare namespace algoliasearch {
|
||||
* 'firstWords' When a query does not return any results, the first word will be added as optional
|
||||
* 'allOptional' When a query does not return any results, a second trial will be made with all words as optional
|
||||
* 'none' No specific processing is done when a query does not return any results
|
||||
* https://github.com/algolia/algoliasearch-client-js#removewordsifnoresults
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/removeWordsIfNoResults/
|
||||
*/
|
||||
removeWordsIfNoResults?: string;
|
||||
removeWordsIfNoResults?: "none"|"lastWords"|"firstWords"|"allOptional";
|
||||
/**
|
||||
* Enables the advanced query syntax
|
||||
* default: false
|
||||
* https://github.com/algolia/algoliasearch-client-js#advancedsyntax
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/advancedSyntax/
|
||||
*/
|
||||
advancedSyntax?: boolean;
|
||||
/**
|
||||
* A string that contains the comma separated list of words that should be considered as optional when found in the query
|
||||
* default: []
|
||||
* https://github.com/algolia/algoliasearch-client-js#optionalwords
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/optionalWords/
|
||||
*/
|
||||
optionalWords?: string[];
|
||||
/**
|
||||
@@ -1322,13 +1347,13 @@ declare namespace algoliasearch {
|
||||
* default: false
|
||||
* true|false: enable or disable stop words for all 41 supported languages; or
|
||||
* a list of language ISO codes (as a comma-separated string) for which stop words should be enable
|
||||
* https://github.com/algolia/algoliasearch-client-js#removestopwords
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/removeStopWords/
|
||||
*/
|
||||
removeStopWords?: string[];
|
||||
removeStopWords?: boolean|string[];
|
||||
/**
|
||||
* List of attributes on which you want to disable the computation of exact criteria
|
||||
* default: []
|
||||
* https://github.com/algolia/algoliasearch-client-js#disableexactonattributes
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/disableExactOnAttributes/
|
||||
*/
|
||||
disableExactOnAttributes?: string[];
|
||||
/**
|
||||
@@ -1337,81 +1362,90 @@ declare namespace algoliasearch {
|
||||
* 'none': no exact on single word query
|
||||
* 'word': exact set to 1 if the query word is found in the record
|
||||
* 'attribute': exact set to 1 if there is an attribute containing a string equals to the query
|
||||
* https://github.com/algolia/algoliasearch-client-js#exactonsinglewordquery
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/exactOnSingleWordQuery/
|
||||
*/
|
||||
exactOnSingleWordQuery?: string;
|
||||
exactOnSingleWordQuery?: "attribute"|"none"|"word";
|
||||
/**
|
||||
* Specify the list of approximation that should be considered as an exact match in the ranking formula
|
||||
* default: ['ignorePlurals', 'singleWordSynonym']
|
||||
* 'ignorePlurals': alternative words added by the ignorePlurals feature
|
||||
* 'singleWordSynonym': single-word synonym (For example "NY" = "NYC")
|
||||
* 'multiWordsSynonym': multiple-words synonym
|
||||
* https://github.com/algolia/algoliasearch-client-js#alternativesasexact
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/alternativesAsExact/
|
||||
*/
|
||||
alternativesAsExact?: any;
|
||||
alternativesAsExact?: Array<"ignorePlurals"|"singleWordSynonym"|"multiWordsSynonym">;
|
||||
/**
|
||||
* If set to 1, enables the distinct feature, disabled by default, if the attributeForDistinct index setting is set.
|
||||
* https://github.com/algolia/algoliasearch-client-js#distinct
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/distinct/
|
||||
*/
|
||||
distinct?: any;
|
||||
distinct?: number|boolean;
|
||||
/**
|
||||
* If set to true, the result hits will contain ranking information in the _rankingInfo attribute.
|
||||
* default: false
|
||||
* https://github.com/algolia/algoliasearch-client-js#getrankinginfo
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/getRankingInfo/
|
||||
*/
|
||||
getRankingInfo?: boolean;
|
||||
/**
|
||||
* @deprecated Use `numericAttributesForFiltering` instead
|
||||
* All numerical attributes are automatically indexed as numerical filters
|
||||
* default: ''
|
||||
* https://github.com/algolia/algoliasearch-client-js#numericattributestoindex
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/numericAttributesForFiltering/
|
||||
*/
|
||||
numericAttributesToIndex?: string[];
|
||||
/**
|
||||
* All numerical attributes are automatically indexed as numerical filters
|
||||
* default: ''
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/numericAttributesForFiltering/
|
||||
*/
|
||||
numericAttributesForFiltering?: string[];
|
||||
/**
|
||||
* @deprecated please use filters instead
|
||||
* A string that contains the comma separated list of numeric filters you want to apply.
|
||||
* https://github.com/algolia/algoliasearch-client-js#numericfilters-deprecated
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/numericFilters/
|
||||
*/
|
||||
numericFilters?: string[];
|
||||
/**
|
||||
* @deprecated
|
||||
*
|
||||
* Filter the query by a set of tags.
|
||||
* https://github.com/algolia/algoliasearch-client-js#tagfilters-deprecated
|
||||
* Default: []
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/tagFilters/
|
||||
*/
|
||||
tagFilters?: string;
|
||||
tagFilters?: string[];
|
||||
/**
|
||||
* @deprecated
|
||||
* Filter the query by a set of facets.
|
||||
* https://github.com/algolia/algoliasearch-client-js#facetfilters-deprecated
|
||||
* Default: []
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/facetFilters/
|
||||
*/
|
||||
facetFilters?: string | string[]
|
||||
facetFilters?: string[]|string[][];
|
||||
/**
|
||||
* If set to false, this query will not be taken into account in the analytics feature.
|
||||
* default true
|
||||
* https://github.com/algolia/algoliasearch-client-js#analytics
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/analytics/
|
||||
*/
|
||||
analytics?: boolean;
|
||||
/**
|
||||
* If set, tag your query with the specified identifiers
|
||||
* default: null
|
||||
* https://github.com/algolia/algoliasearch-client-js#analyticstags
|
||||
* default: []
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/analyticsTags/
|
||||
*/
|
||||
analyticsTags?: string[];
|
||||
/**
|
||||
* If set to false, the search will not use the synonyms defined for the targeted index.
|
||||
* default: true
|
||||
* https://github.com/algolia/algoliasearch-client-js#synonyms
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/synonyms/
|
||||
*/
|
||||
synonyms?: boolean;
|
||||
/**
|
||||
* If set to false, words matched via synonym expansion will not be replaced by the matched synonym in the highlighted result.
|
||||
* default: true
|
||||
* https://github.com/algolia/algoliasearch-client-js#replacesynonymsinhighlight
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/replaceSynonymsInHighlight/
|
||||
*/
|
||||
replaceSynonymsInHighlight?: boolean;
|
||||
/**
|
||||
* Configure the precision of the proximity ranking criterion
|
||||
* default: 1
|
||||
* https://github.com/algolia/algoliasearch-client-js#minproximity
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/minProximity/
|
||||
*/
|
||||
minProximity?: number;
|
||||
|
||||
@@ -1464,7 +1498,7 @@ declare namespace algoliasearch {
|
||||
interface Task {
|
||||
taskID: number;
|
||||
createdAt: string;
|
||||
objectID?: string;
|
||||
objectID?: string;
|
||||
}
|
||||
|
||||
interface TaskStatus {
|
||||
@@ -1747,42 +1781,42 @@ declare namespace algoliasearch {
|
||||
interface Response {
|
||||
/**
|
||||
* Contains all the hits matching the query
|
||||
* https://github.com/algolia/algoliasearch-client-js#response-format
|
||||
* https://www.algolia.com/doc/api-reference/api-methods/search/?language=javascript#response
|
||||
*/
|
||||
hits: any[];
|
||||
/**
|
||||
* Current page
|
||||
* https://github.com/algolia/algoliasearch-client-js#response-format
|
||||
* https://www.algolia.com/doc/api-reference/api-methods/search/?language=javascript#response
|
||||
*/
|
||||
page: number;
|
||||
/**
|
||||
* Number of total hits matching the query
|
||||
* https://github.com/algolia/algoliasearch-client-js#response-format
|
||||
* https://www.algolia.com/doc/api-reference/api-methods/search/?language=javascript#response
|
||||
*/
|
||||
nbHits: number;
|
||||
/**
|
||||
* Number of pages
|
||||
* https://github.com/algolia/algoliasearch-client-js#response-format
|
||||
* https://www.algolia.com/doc/api-reference/api-methods/search/?language=javascript#response
|
||||
*/
|
||||
nbPages: number;
|
||||
/**
|
||||
* Number of hits per pages
|
||||
* https://github.com/algolia/algoliasearch-client-js#response-format
|
||||
* https://www.algolia.com/doc/api-reference/api-methods/search/?language=javascript#response
|
||||
*/
|
||||
hitsPerPage: number;
|
||||
/**
|
||||
* Engine processing time (excluding network transfer)
|
||||
* https://github.com/algolia/algoliasearch-client-js#response-format
|
||||
* https://www.algolia.com/doc/api-reference/api-methods/search/?language=javascript#response
|
||||
*/
|
||||
processingTimeMS: number;
|
||||
/**
|
||||
* Query used to perform the search
|
||||
* https://github.com/algolia/algoliasearch-client-js#response-format
|
||||
* https://www.algolia.com/doc/api-reference/api-methods/search/?language=javascript#response
|
||||
*/
|
||||
query: string;
|
||||
/**
|
||||
* GET parameters used to perform the search
|
||||
* https://github.com/algolia/algoliasearch-client-js#response-format
|
||||
* https://www.algolia.com/doc/api-reference/api-methods/search/?language=javascript#response
|
||||
*/
|
||||
params: string;
|
||||
facets?: {
|
||||
@@ -1796,6 +1830,16 @@ declare namespace algoliasearch {
|
||||
sum: number,
|
||||
};
|
||||
};
|
||||
/**
|
||||
* The index name is only set when searching multiple indices.
|
||||
* https://www.algolia.com/doc/api-reference/api-methods/multiple-queries/?language=javascript#response
|
||||
*/
|
||||
index?: string;
|
||||
/**
|
||||
* The cursor is only set when browsing the index.
|
||||
* https://www.algolia.com/doc/api-reference/api-methods/browse/
|
||||
*/
|
||||
cursor?: string;
|
||||
}
|
||||
|
||||
interface MultiResponse {
|
||||
|
||||
Vendored
+110
-75
@@ -1,12 +1,15 @@
|
||||
// Type definitions for algoliasearch-client-js 3.27.0
|
||||
// Type definitions for algoliasearch-client-js 3.30.0
|
||||
// Project: https://github.com/algolia/algoliasearch-client-js
|
||||
// Definitions by: Baptiste Coquelle <https://github.com/cbaptiste>
|
||||
// Haroen Viaene <https://github.com/haroenv>
|
||||
// Aurélien Hervé <https://github.com/aherve>
|
||||
// Samuel Vaillant <https://github.com/samouss>
|
||||
// Claas Brüggemann <https://github.com/ClaasBrueggemann>
|
||||
// Kai Eichinger <https://github.com/keichinger>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>
|
||||
|
||||
declare namespace algoliasearch {
|
||||
/**
|
||||
@@ -130,6 +133,11 @@ declare namespace algoliasearch {
|
||||
options: SearchForFacetValues.Parameters,
|
||||
cb: (err: Error, res: SearchForFacetValues.Response) => void
|
||||
): void;
|
||||
/**
|
||||
* Browse an index
|
||||
* https://github.com/algolia/algoliasearch-client-js#backup--export-an-index---browse
|
||||
*/
|
||||
browse(query: string, parameters: BrowseParameters, cb: (err: Error, res: BrowseResponse) => void): void;
|
||||
/**
|
||||
* Browse an index
|
||||
* https://github.com/algolia/algoliasearch-client-js#backup--export-an-index---browse
|
||||
@@ -139,7 +147,7 @@ declare namespace algoliasearch {
|
||||
* Browse an index
|
||||
* https://github.com/algolia/algoliasearch-client-js#backup--export-an-index---browse
|
||||
*/
|
||||
browse(query: string): Promise<BrowseResponse>;
|
||||
browse(query: string, parameters?: BrowseParameters): Promise<BrowseResponse>;
|
||||
/**
|
||||
* Browse an index from a cursor
|
||||
* https://github.com/algolia/algoliasearch-client-js#backup--export-an-index---browse
|
||||
@@ -194,114 +202,122 @@ declare namespace algoliasearch {
|
||||
query: string;
|
||||
processingTimeMS: number;
|
||||
}
|
||||
|
||||
type BrowseParameters = Omit<
|
||||
QueryParameters,
|
||||
| "typoTolerance"
|
||||
| "distinct"
|
||||
| "facets"
|
||||
| "getRankingInfo"
|
||||
| "attributesToHighlight"
|
||||
| "attributesToSnippet"
|
||||
>
|
||||
interface QueryParameters {
|
||||
/**
|
||||
* Query string used to perform the search
|
||||
* default: ''
|
||||
* https://github.com/algolia/algoliasearch-client-js#query
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/query/
|
||||
*/
|
||||
query?: string;
|
||||
/**
|
||||
* Filter the query with numeric, facet or/and tag filters
|
||||
* default: ""
|
||||
* https://github.com/algolia/algoliasearch-client-js#filters
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/filters/
|
||||
*/
|
||||
filters?: string;
|
||||
/**
|
||||
* A string that contains the list of attributes you want to retrieve in order to minimize the size of the JSON answer.
|
||||
* default: *
|
||||
* https://github.com/algolia/algoliasearch-client-js#attributestoretrieve
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/attributesToRetrieve/
|
||||
*/
|
||||
attributesToRetrieve?: string[];
|
||||
/**
|
||||
* List of attributes you want to use for textual search
|
||||
* default: attributeToIndex
|
||||
* https://github.com/algolia/algoliasearch-client-js#restrictsearchableattributes
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/restrictSearchableAttributes/
|
||||
*/
|
||||
restrictSearchableAttributes?: string[];
|
||||
/**
|
||||
* You can use facets to retrieve only a part of your attributes declared in attributesForFaceting attributes
|
||||
* default: ""
|
||||
* https://github.com/algolia/algoliasearch-client-js#facets
|
||||
* default: []
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/facets/
|
||||
*/
|
||||
facets?: string;
|
||||
facets?: string[];
|
||||
/**
|
||||
* Limit the number of facet values returned for each facet.
|
||||
* default: ""
|
||||
* https://github.com/algolia/algoliasearch-client-js#maxvaluesperfacet
|
||||
* default: 100
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/maxValuesPerFacet/
|
||||
*/
|
||||
maxValuesPerFacet?: number;
|
||||
/**
|
||||
* Default list of attributes to highlight. If set to null, all indexed attributes are highlighted.
|
||||
* default: null
|
||||
* https://github.com/algolia/algoliasearch-client-js#attributestohighlight
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/attributesToHighlight/
|
||||
*/
|
||||
attributesToHighlight?: string[];
|
||||
/**
|
||||
* Default list of attributes to snippet alongside the number of words to return
|
||||
* default: null
|
||||
* https://github.com/algolia/algoliasearch-client-js#attributestosnippet
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/attributesToSnippet/
|
||||
*/
|
||||
attributesToSnippet?: string[];
|
||||
/**
|
||||
* Specify the string that is inserted before the highlighted parts in the query result
|
||||
* default: <em>
|
||||
* https://github.com/algolia/algoliasearch-client-js#highlightpretag
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/highlightPreTag/
|
||||
*/
|
||||
highlightPreTag?: string;
|
||||
/**
|
||||
* Specify the string that is inserted after the highlighted parts in the query result
|
||||
* default: </em>
|
||||
* https://github.com/algolia/algoliasearch-client-js#highlightposttag
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/highlightPostTag/
|
||||
*/
|
||||
highlightPostTag?: string;
|
||||
/**
|
||||
* String used as an ellipsis indicator when a snippet is truncated.
|
||||
* default: …
|
||||
* https://github.com/algolia/algoliasearch-client-js#snippetellipsistext
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/snippetEllipsisText/
|
||||
*/
|
||||
snippetEllipsisText?: string;
|
||||
/**
|
||||
* If set to true, restrict arrays in highlights and snippets to items that matched the query at least partially else return all array items in highlights and snippets
|
||||
* default: false
|
||||
* https://github.com/algolia/algoliasearch-client-js#restricthighlightandsnippetarrays
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/restrictHighlightAndSnippetArrays/
|
||||
*/
|
||||
restrictHighlightAndSnippetArrays?: boolean;
|
||||
/**
|
||||
* Pagination parameter used to select the number of hits per page
|
||||
* default: 20
|
||||
* https://github.com/algolia/algoliasearch-client-js#hitsperpage
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/hitsPerPage/
|
||||
*/
|
||||
hitsPerPage?: number;
|
||||
/**
|
||||
* Pagination parameter used to select the page to retrieve.
|
||||
* default: 0
|
||||
* https://github.com/algolia/algoliasearch-client-js#page
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/page/
|
||||
*/
|
||||
page?: number;
|
||||
/**
|
||||
* Offset of the first hit to return
|
||||
* default: null
|
||||
* https://github.com/algolia/algoliasearch-client-js#offset
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/offset/
|
||||
*/
|
||||
offset?: number;
|
||||
/**
|
||||
* Number of hits to return.
|
||||
* default: null
|
||||
* https://github.com/algolia/algoliasearch-client-js#length
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/length/
|
||||
*/
|
||||
length?: number;
|
||||
/**
|
||||
* The minimum number of characters needed to accept one typo.
|
||||
* default: 4
|
||||
* https://github.com/algolia/algoliasearch-client-js#minwordsizefor1typo
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/minWordSizefor1Typo/
|
||||
*/
|
||||
minWordSizefor1Typo?: number;
|
||||
/**
|
||||
* The minimum number of characters needed to accept two typo.
|
||||
* fault: 8
|
||||
* https://github.com/algolia/algoliasearch-client-js#minwordsizefor2typos
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/minWordSizefor2Typos/
|
||||
*/
|
||||
minWordSizefor2Typos?: number;
|
||||
/**
|
||||
@@ -311,62 +327,62 @@ declare namespace algoliasearch {
|
||||
* 'false' The typo tolerance is disabled. All results with typos will be hidden.
|
||||
* 'min' Only keep results with the minimum number of typos
|
||||
* 'strict' Hits matching with 2 typos are not retrieved if there are some matching without typos.
|
||||
* https://github.com/algolia/algoliasearch-client-js#minwordsizefor2typos
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/typoTolerance/
|
||||
*/
|
||||
typoTolerance?: boolean;
|
||||
/**
|
||||
* If set to false, disables typo tolerance on numeric tokens (numbers).
|
||||
* default:
|
||||
* https://github.com/algolia/algoliasearch-client-js#allowtyposonnumerictokens
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/allowTyposOnNumericTokens/
|
||||
*/
|
||||
allowTyposOnNumericTokens?: boolean;
|
||||
/**
|
||||
* If set to true, plural won't be considered as a typo
|
||||
* default: false
|
||||
* https://github.com/algolia/algoliasearch-client-js#ignoreplurals
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/ignorePlurals/
|
||||
*/
|
||||
ignorePlurals?: boolean;
|
||||
/**
|
||||
* List of attributes on which you want to disable typo tolerance
|
||||
* default: ""
|
||||
* https://github.com/algolia/algoliasearch-client-js#disabletypotoleranceonattributes
|
||||
* default: []
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/disableTypoToleranceOnAttributes/
|
||||
*/
|
||||
disableTypoToleranceOnAttributes?: string;
|
||||
disableTypoToleranceOnAttributes?: string[];
|
||||
/**
|
||||
* Search for entries around a given location
|
||||
* default: ""
|
||||
* https://github.com/algolia/algoliasearch-client-js#aroundlatlng
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/aroundLatLng/
|
||||
*/
|
||||
aroundLatLng?: string;
|
||||
/**
|
||||
* Search for entries around a given latitude/longitude automatically computed from user IP address.
|
||||
* default: ""
|
||||
* https://github.com/algolia/algoliasearch-client-js#aroundlatlngviaip
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/aroundLatLngViaIP/
|
||||
*/
|
||||
aroundLatLngViaIP?: string;
|
||||
/**
|
||||
* Control the radius associated with a geo search. Defined in meters.
|
||||
* default: null
|
||||
* You can specify aroundRadius=all if you want to compute the geo distance without filtering in a geo area
|
||||
* https://github.com/algolia/algoliasearch-client-js#aroundradius
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/aroundRadius/
|
||||
*/
|
||||
aroundRadius?: number | 'all';
|
||||
/**
|
||||
* Control the precision of a geo search
|
||||
* default: null
|
||||
* https://github.com/algolia/algoliasearch-client-js#aroundprecision
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/aroundPrecision/
|
||||
*/
|
||||
aroundPrecision?: number;
|
||||
/**
|
||||
* Define the minimum radius used for a geo search when aroundRadius is not set.
|
||||
* default: null
|
||||
* https://github.com/algolia/algoliasearch-client-js#minimumaroundradius
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/minimumAroundRadius/
|
||||
*/
|
||||
minimumAroundRadius?: number;
|
||||
/**
|
||||
* Search entries inside a given area defined by the two extreme points of a rectangle
|
||||
* default: null
|
||||
* https://github.com/algolia/algoliasearch-client-js#insideboundingbox
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/insideBoundingBox/
|
||||
*/
|
||||
insideBoundingBox?: number[][];
|
||||
/**
|
||||
@@ -375,13 +391,13 @@ declare namespace algoliasearch {
|
||||
* 'prefixAll' All query words are interpreted as prefixes. This option is not recommended.
|
||||
* 'prefixLast' Only the last word is interpreted as a prefix (default behavior).
|
||||
* 'prefixNone' No query word is interpreted as a prefix. This option is not recommended.
|
||||
* https://github.com/algolia/algoliasearch-client-js#querytype
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/queryType/
|
||||
*/
|
||||
queryType?: any;
|
||||
queryType?: "prefixAll"|"prefixLast"|"prefixNone";
|
||||
/**
|
||||
* Search entries inside a given area defined by a set of points
|
||||
* defauly: ''
|
||||
* https://github.com/algolia/algoliasearch-client-js#insidepolygon
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/insidePolygon/
|
||||
*/
|
||||
insidePolygon?: number[][];
|
||||
/**
|
||||
@@ -391,19 +407,19 @@ declare namespace algoliasearch {
|
||||
* 'firstWords' When a query does not return any results, the first word will be added as optional
|
||||
* 'allOptional' When a query does not return any results, a second trial will be made with all words as optional
|
||||
* 'none' No specific processing is done when a query does not return any results
|
||||
* https://github.com/algolia/algoliasearch-client-js#removewordsifnoresults
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/removeWordsIfNoResults/
|
||||
*/
|
||||
removeWordsIfNoResults?: string;
|
||||
removeWordsIfNoResults?: "none"|"lastWords"|"firstWords"|"allOptional";
|
||||
/**
|
||||
* Enables the advanced query syntax
|
||||
* default: false
|
||||
* https://github.com/algolia/algoliasearch-client-js#advancedsyntax
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/advancedSyntax/
|
||||
*/
|
||||
advancedSyntax?: boolean;
|
||||
/**
|
||||
* A string that contains the comma separated list of words that should be considered as optional when found in the query
|
||||
* default: []
|
||||
* https://github.com/algolia/algoliasearch-client-js#optionalwords
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/optionalWords/
|
||||
*/
|
||||
optionalWords?: string[];
|
||||
/**
|
||||
@@ -411,13 +427,13 @@ declare namespace algoliasearch {
|
||||
* default: false
|
||||
* true|false: enable or disable stop words for all 41 supported languages; or
|
||||
* a list of language ISO codes (as a comma-separated string) for which stop words should be enable
|
||||
* https://github.com/algolia/algoliasearch-client-js#removestopwords
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/removeStopWords/
|
||||
*/
|
||||
removeStopWords?: string[];
|
||||
removeStopWords?: boolean|string[];
|
||||
/**
|
||||
* List of attributes on which you want to disable the computation of exact criteria
|
||||
* default: []
|
||||
* https://github.com/algolia/algoliasearch-client-js#disableexactonattributes
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/disableExactOnAttributes/
|
||||
*/
|
||||
disableExactOnAttributes?: string[];
|
||||
/**
|
||||
@@ -426,81 +442,90 @@ declare namespace algoliasearch {
|
||||
* 'none': no exact on single word query
|
||||
* 'word': exact set to 1 if the query word is found in the record
|
||||
* 'attribute': exact set to 1 if there is an attribute containing a string equals to the query
|
||||
* https://github.com/algolia/algoliasearch-client-js#exactonsinglewordquery
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/exactOnSingleWordQuery/
|
||||
*/
|
||||
exactOnSingleWordQuery?: string;
|
||||
exactOnSingleWordQuery?: "attribute"|"none"|"word";
|
||||
/**
|
||||
* Specify the list of approximation that should be considered as an exact match in the ranking formula
|
||||
* default: ['ignorePlurals', 'singleWordSynonym']
|
||||
* 'ignorePlurals': alternative words added by the ignorePlurals feature
|
||||
* 'singleWordSynonym': single-word synonym (For example "NY" = "NYC")
|
||||
* 'multiWordsSynonym': multiple-words synonym
|
||||
* https://github.com/algolia/algoliasearch-client-js#alternativesasexact
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/alternativesAsExact/
|
||||
*/
|
||||
alternativesAsExact?: any;
|
||||
alternativesAsExact?: Array<"ignorePlurals"|"singleWordSynonym"|"multiWordsSynonym">;
|
||||
/**
|
||||
* If set to 1, enables the distinct feature, disabled by default, if the attributeForDistinct index setting is set.
|
||||
* https://github.com/algolia/algoliasearch-client-js#distinct
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/distinct/
|
||||
*/
|
||||
distinct?: any;
|
||||
distinct?: number|boolean;
|
||||
/**
|
||||
* If set to true, the result hits will contain ranking information in the _rankingInfo attribute.
|
||||
* default: false
|
||||
* https://github.com/algolia/algoliasearch-client-js#getrankinginfo
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/getRankingInfo/
|
||||
*/
|
||||
getRankingInfo?: boolean;
|
||||
/**
|
||||
* @deprecated Use `numericAttributesForFiltering` instead
|
||||
* All numerical attributes are automatically indexed as numerical filters
|
||||
* default: ''
|
||||
* https://github.com/algolia/algoliasearch-client-js#numericattributestoindex
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/numericAttributesForFiltering/
|
||||
*/
|
||||
numericAttributesToIndex?: string[];
|
||||
/**
|
||||
* All numerical attributes are automatically indexed as numerical filters
|
||||
* default: ''
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/numericAttributesForFiltering/
|
||||
*/
|
||||
numericAttributesForFiltering?: string[];
|
||||
/**
|
||||
* @deprecated please use filters instead
|
||||
* A string that contains the comma separated list of numeric filters you want to apply.
|
||||
* https://github.com/algolia/algoliasearch-client-js#numericfilters-deprecated
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/numericFilters/
|
||||
*/
|
||||
numericFilters?: string[];
|
||||
/**
|
||||
* @deprecated
|
||||
*
|
||||
* Filter the query by a set of tags.
|
||||
* https://github.com/algolia/algoliasearch-client-js#tagfilters-deprecated
|
||||
* Default: []
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/tagFilters/
|
||||
*/
|
||||
tagFilters?: string;
|
||||
tagFilters?: string[];
|
||||
/**
|
||||
* @deprecated
|
||||
* Filter the query by a set of facets.
|
||||
* https://github.com/algolia/algoliasearch-client-js#facetfilters-deprecated
|
||||
* Default: []
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/facetFilters/
|
||||
*/
|
||||
facetFilters?: string;
|
||||
facetFilters?: string[]|string[][];
|
||||
/**
|
||||
* If set to false, this query will not be taken into account in the analytics feature.
|
||||
* default true
|
||||
* https://github.com/algolia/algoliasearch-client-js#analytics
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/analytics/
|
||||
*/
|
||||
analytics?: boolean;
|
||||
/**
|
||||
* If set, tag your query with the specified identifiers
|
||||
* default: null
|
||||
* https://github.com/algolia/algoliasearch-client-js#analyticstags
|
||||
* default: []
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/analyticsTags/
|
||||
*/
|
||||
analyticsTags?: string[];
|
||||
/**
|
||||
* If set to false, the search will not use the synonyms defined for the targeted index.
|
||||
* default: true
|
||||
* https://github.com/algolia/algoliasearch-client-js#synonyms
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/synonyms/
|
||||
*/
|
||||
synonyms?: boolean;
|
||||
/**
|
||||
* If set to false, words matched via synonym expansion will not be replaced by the matched synonym in the highlighted result.
|
||||
* default: true
|
||||
* https://github.com/algolia/algoliasearch-client-js#replacesynonymsinhighlight
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/replaceSynonymsInHighlight/
|
||||
*/
|
||||
replaceSynonymsInHighlight?: boolean;
|
||||
/**
|
||||
* Configure the precision of the proximity ranking criterion
|
||||
* default: 1
|
||||
* https://github.com/algolia/algoliasearch-client-js#minproximity
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/minProximity/
|
||||
*/
|
||||
minProximity?: number;
|
||||
|
||||
@@ -530,42 +555,42 @@ declare namespace algoliasearch {
|
||||
interface Response {
|
||||
/**
|
||||
* Contains all the hits matching the query
|
||||
* https://github.com/algolia/algoliasearch-client-js#response-format
|
||||
* https://www.algolia.com/doc/api-reference/api-methods/search/?language=javascript#response
|
||||
*/
|
||||
hits: any[];
|
||||
/**
|
||||
* Current page
|
||||
* https://github.com/algolia/algoliasearch-client-js#response-format
|
||||
* https://www.algolia.com/doc/api-reference/api-methods/search/?language=javascript#response
|
||||
*/
|
||||
page: number;
|
||||
/**
|
||||
* Number of total hits matching the query
|
||||
* https://github.com/algolia/algoliasearch-client-js#response-format
|
||||
* https://www.algolia.com/doc/api-reference/api-methods/search/?language=javascript#response
|
||||
*/
|
||||
nbHits: number;
|
||||
/**
|
||||
* Number of pages
|
||||
* https://github.com/algolia/algoliasearch-client-js#response-format
|
||||
* https://www.algolia.com/doc/api-reference/api-methods/search/?language=javascript#response
|
||||
*/
|
||||
nbPages: number;
|
||||
/**
|
||||
* Number of hits per pages
|
||||
* https://github.com/algolia/algoliasearch-client-js#response-format
|
||||
* https://www.algolia.com/doc/api-reference/api-methods/search/?language=javascript#response
|
||||
*/
|
||||
hitsPerPage: number;
|
||||
/**
|
||||
* Engine processing time (excluding network transfer)
|
||||
* https://github.com/algolia/algoliasearch-client-js#response-format
|
||||
* https://www.algolia.com/doc/api-reference/api-methods/search/?language=javascript#response
|
||||
*/
|
||||
processingTimeMS: number;
|
||||
/**
|
||||
* Query used to perform the search
|
||||
* https://github.com/algolia/algoliasearch-client-js#response-format
|
||||
* https://www.algolia.com/doc/api-reference/api-methods/search/?language=javascript#response
|
||||
*/
|
||||
query: string;
|
||||
/**
|
||||
* GET parameters used to perform the search
|
||||
* https://github.com/algolia/algoliasearch-client-js#response-format
|
||||
* https://www.algolia.com/doc/api-reference/api-methods/search/?language=javascript#response
|
||||
*/
|
||||
params: string;
|
||||
facets?: {
|
||||
@@ -579,6 +604,16 @@ declare namespace algoliasearch {
|
||||
sum: number,
|
||||
};
|
||||
};
|
||||
/**
|
||||
* The index name is only set when searching multiple indices.
|
||||
* https://www.algolia.com/doc/api-reference/api-methods/multiple-queries/?language=javascript#response
|
||||
*/
|
||||
index?: string;
|
||||
/**
|
||||
* The cursor is only set when browsing the index.
|
||||
* https://www.algolia.com/doc/api-reference/api-methods/browse/
|
||||
*/
|
||||
cursor?: string;
|
||||
}
|
||||
|
||||
interface MultiResponse {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Vendored
+3265
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"esnext",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"esModuleInterop": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"ali-app-tests.ts"
|
||||
],
|
||||
"exclude": [
|
||||
".prettierrc"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"no-mergeable-namespace": false,
|
||||
"no-unnecessary-generics": false
|
||||
}
|
||||
}
|
||||
@@ -1,85 +1,110 @@
|
||||
// Tests for Amplitude SDK TypeScript definitions
|
||||
|
||||
module Amplitude.Tests {
|
||||
|
||||
function all() {
|
||||
amplitude.init('YOUR_API_KEY_HERE', null, {
|
||||
// optional configuration options
|
||||
var client: amplitude.AmplitudeClient = new amplitude.AmplitudeClient();
|
||||
var identify: amplitude.Identify = new amplitude.Identify();
|
||||
var revenue: amplitude.Revenue = new amplitude.Revenue();
|
||||
|
||||
client = amplitude.getInstance();
|
||||
client = amplitude.getInstance('some name');
|
||||
|
||||
amplitude.__VERSION__ === '1.2.3';
|
||||
amplitude.options.logLevel = 'WARN';
|
||||
|
||||
amplitude.init('API_KEY', 'USER_ID', {
|
||||
saveEvents: true,
|
||||
includeUtm: true,
|
||||
includeReferrer: true,
|
||||
batchEvents: true,
|
||||
eventUploadThreshold: 50
|
||||
});
|
||||
amplitude.init('YOUR_API_KEY_HERE', 'USER_ID_HERE', null, () => {});
|
||||
}, function () { });
|
||||
amplitude.init('API_KEY', 'USER_ID', { includeReferrer: true, includeUtm: true });
|
||||
amplitude.init('API_KEY', 'USER_ID');
|
||||
amplitude.init('API_KEY');
|
||||
|
||||
amplitude.logEvent('EVENT_IDENTIFIER_HERE');
|
||||
amplitude.setUserId('USER_ID_HERE');
|
||||
amplitude.init('YOUR_API_KEY_HERE', 'USER_ID_HERE');
|
||||
amplitude.setUserId(null); // not string 'null'
|
||||
amplitude.setVersionName('VERSION_NAME_HERE');
|
||||
|
||||
amplitude.regenerateDeviceId();
|
||||
amplitude.setDeviceId('CUSTOM_DEVICE_ID');
|
||||
|
||||
amplitude.logEvent('EVENT_IDENTIFIER_HERE', {
|
||||
'color': 'blue',
|
||||
'age': 20,
|
||||
'key': 'value'
|
||||
});
|
||||
amplitude.logEvent('Clicked Homepage Button', { 'finished_flow': false, 'clicks': 15 });
|
||||
amplitude.logEvent('EVENT_IDENTIFIER_HERE', { 'color': 'blue', 'age': 20, 'key': 'value' });
|
||||
amplitude.logEvent("EVENT_IDENTIFIER_HERE", null, (httpCode, response) => { });
|
||||
amplitude.logEventWithGroups('initialize_game', { 'key': 'value' }, { 'sport': 'soccer' });
|
||||
|
||||
amplitude.setDeviceId('45f0954f-eb79-4463-ac8a-233a6f45a8f0');
|
||||
amplitude.setDomain('.amplitude.com');
|
||||
amplitude.setGroup('orgId', '15');
|
||||
amplitude.setGroup('orgId', ['15', '16']);
|
||||
amplitude.setUserId('joe@gmail.com');
|
||||
amplitude.setUserProperties({ 'gender': 'female', 'sign_up_complete': true })
|
||||
amplitude.setVersionName('1.12.3');
|
||||
amplitude.isNewSession();
|
||||
amplitude.getSessionId() === 123;
|
||||
|
||||
let identify = new amplitude.Identify().set('gender', 'female').set('age', 20);
|
||||
amplitude.identify(identify);
|
||||
amplitude.logRevenue(3.99, 1, 'product_1234');
|
||||
amplitude.logRevenueV2(revenue);
|
||||
|
||||
identify = new amplitude.Identify().setOnce('sign_up_date', '08/24/2015');
|
||||
amplitude.identify(identify);
|
||||
|
||||
identify = new amplitude.Identify().setOnce('sign_up_date', '09/14/2015');
|
||||
amplitude.identify(identify);
|
||||
client.init('API_KEY', 'USER_ID', {
|
||||
saveEvents: true,
|
||||
includeUtm: true,
|
||||
includeReferrer: true,
|
||||
batchEvents: true,
|
||||
eventUploadThreshold: 50
|
||||
}, function () { });
|
||||
client.init('API_KEY', 'USER_ID', { includeReferrer: true, includeUtm: true });
|
||||
client.init('API_KEY', 'USER_ID');
|
||||
client.init('API_KEY');
|
||||
|
||||
identify = new amplitude.Identify().unset('gender').unset('age');
|
||||
amplitude.identify(identify);
|
||||
client.logEvent('Clicked Homepage Button', { 'finished_flow': false, 'clicks': 15 });
|
||||
client.logEvent('EVENT_IDENTIFIER_HERE', { 'color': 'blue', 'age': 20, 'key': 'value' });
|
||||
client.logEvent("EVENT_IDENTIFIER_HERE", null, (httpCode, response) => { });
|
||||
client.logEventWithGroups('initialize_game', { 'key': 'value' }, { 'sport': 'soccer' });
|
||||
client.logEventWithTimestamp('EVENT_IDENTIFIER_HERE', { 'key': 'value' }, 1505430378000, (httpCode, response) => { });
|
||||
|
||||
|
||||
client.setDeviceId('45f0954f-eb79-4463-ac8a-233a6f45a8f0');
|
||||
client.setDomain('.amplitude.com');
|
||||
client.setUserId('joe@gmail.com');
|
||||
client.setOptOut(true);
|
||||
client.setGroup('type', 'name');
|
||||
client.setGroup('type', ['name', 'name2']);
|
||||
client.setUserProperties({ 'gender': 'female', 'sign_up_complete': true });
|
||||
client.setGlobalUserProperties({ 'gender': 'female', 'sign_up_complete': true });
|
||||
client.setVersionName('1.12.3');
|
||||
client.setSessionId(1505430378000);
|
||||
|
||||
client.options.logLevel = 'WARN';
|
||||
client.getSessionId() === 123;
|
||||
client.isNewSession() === true;
|
||||
client.regenerateDeviceId();
|
||||
client.clearUserProperties();
|
||||
|
||||
client.identify(identify);
|
||||
client.logRevenue(3.99, 1, 'product_1234');
|
||||
client.logRevenueV2(revenue);
|
||||
|
||||
|
||||
identify = new amplitude.Identify().set('colors', ['rose', 'gold']).add('karma', 1).setOnce('sign_up_date', '2016-03-31');
|
||||
identify = new amplitude.Identify().add('karma', 1).add('friends', 1);
|
||||
amplitude.identify(identify);
|
||||
|
||||
identify = new amplitude.Identify().append('ab-tests', 'new-user-test').append('some_list', [1, 2, 3, 4, 'values']);
|
||||
amplitude.identify(identify);
|
||||
|
||||
identify = new amplitude.Identify().prepend('ab-tests', 'new-user-test').prepend('some_list', [1, 2, 3, 4, 'values']);
|
||||
amplitude.identify(identify);
|
||||
|
||||
identify = new amplitude.Identify()
|
||||
.set('karma', 10)
|
||||
.add('karma', 1)
|
||||
.unset('karma');
|
||||
amplitude.identify(identify);
|
||||
|
||||
identify = new amplitude.Identify().set('karma', 10).add('karma', 1).unset('karma');
|
||||
identify = new amplitude.Identify().append('ab-tests', 'new-user-tests');
|
||||
identify.append('some_list', [1, 2, 3, 4, 'values']);
|
||||
identify = new amplitude.Identify().prepend('ab-tests', 'new-user-tests');
|
||||
identify.prepend('some_list', [1, 2, 3, 4, 'values']);
|
||||
identify = new amplitude.Identify().set('user_type', 'beta');
|
||||
identify.set('name', { 'first': 'John', 'last': 'Doe' });
|
||||
identify = new amplitude.Identify().setOnce('sign_up_date', '2016-04-01');
|
||||
identify = new amplitude.Identify().unset('user_type').unset('age');
|
||||
identify = new amplitude.Identify()
|
||||
.set('colors', ['rose', 'gold'])
|
||||
.append('ab-tests', 'campaign_a')
|
||||
.append('existing_list', [4, 5]);
|
||||
amplitude.identify(identify);
|
||||
|
||||
amplitude.setUserProperties({
|
||||
gender: 'female',
|
||||
age: 20
|
||||
});
|
||||
|
||||
amplitude.clearUserProperties();
|
||||
|
||||
amplitude.setOptOut(true);
|
||||
amplitude.setOptOut(false);
|
||||
|
||||
amplitude.setGroup('orgId', '15');
|
||||
amplitude.setGroup('sport', ['soccer', 'tennis']);
|
||||
|
||||
// TODO: Implement those.
|
||||
/*
|
||||
var revenue = new amplitude.Revenue().setProductId('com.company.productId').setPrice(3.99).setQuantity(3);
|
||||
amplitude.logRevenueV2(revenue);
|
||||
|
||||
amplitude.logEventWithGroups('initialize_game', { 'key': 'value' }, { 'sport': 'soccer' });
|
||||
*/
|
||||
revenue = new amplitude.Revenue().setProductId('productIdentifier').setPrice(10.99);
|
||||
revenue = new amplitude.Revenue().setProductId('productIdentifier').setPrice(10.99).setEventProperties({ 'city': 'San Francisco' });
|
||||
revenue = new amplitude.Revenue().setProductId('productIdentifier').setPrice(10.99).setQuantity(5);
|
||||
revenue = new amplitude.Revenue().setProductId('productIdentifier').setPrice(10.99).setRevenueType('purchase');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Vendored
+97
-12
@@ -1,61 +1,146 @@
|
||||
// Type definitions for Amplitude SDK 2.12.1
|
||||
// Type definitions for Amplitude SDK 4.4.0
|
||||
// Project: https://github.com/amplitude/Amplitude-Javascript
|
||||
// Definitions by: Arvydas Sidorenko <https://github.com/Asido>
|
||||
// Definitions: https://github.com/Asido/DefinitelyTyped
|
||||
// Dan Manastireanu <https://github.com/danmana>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare module amplitude {
|
||||
|
||||
type Callback = (responseCode: number, responseBody: string, details?: { reason: string; }) => void;
|
||||
type LogReturn = number | void;
|
||||
|
||||
interface Config {
|
||||
apiEndpoint?: string;
|
||||
batchEvents?: boolean;
|
||||
cookieExpiration?: number;
|
||||
cookieName?: string;
|
||||
userId?: string;
|
||||
deviceId?: string;
|
||||
deviceIdFromUrlParam?: boolean;
|
||||
domain?: string;
|
||||
eventUploadPeriodMillis?: number;
|
||||
eventUploadThreshold?: number;
|
||||
forceHttps?: boolean;
|
||||
includeGclid?: boolean;
|
||||
includeReferrer?: boolean;
|
||||
includeUtm?: boolean;
|
||||
language?: string;
|
||||
logLevel?: 'DISABLE' | 'ERROR' | 'WARN' | 'INFO';
|
||||
optOut?: boolean;
|
||||
platform?: string;
|
||||
saveEvents?: boolean;
|
||||
savedMaxCount?: number;
|
||||
saveParamsReferrerOncePerSession?: boolean;
|
||||
sessionTimeout?: number;
|
||||
trackingOptions?: {
|
||||
city?: boolean;
|
||||
country?: boolean;
|
||||
device_model?: boolean;
|
||||
dma?: boolean;
|
||||
ip_address?: boolean;
|
||||
language?: boolean;
|
||||
os_name?: boolean;
|
||||
os_version?: boolean;
|
||||
platform?: boolean;
|
||||
region?: boolean;
|
||||
version_name?: boolean;
|
||||
},
|
||||
unsentKey?: string;
|
||||
unsentIdentifyKey?: string;
|
||||
uploadBatchSize?: number;
|
||||
}
|
||||
|
||||
export class Identify {
|
||||
set(key: string, value: any): Identify;
|
||||
setOnce(key: string, value: any): Identify;
|
||||
add(key: string, value: number): Identify;
|
||||
add(key: string, value: number | string): Identify;
|
||||
append(key: string, value: any): Identify;
|
||||
prepend(key: string, value: any): Identify;
|
||||
|
||||
unset(key: string): Identify;
|
||||
}
|
||||
|
||||
export function init(apiKey: string): void;
|
||||
export function init(apiKey: string, userId: string): void;
|
||||
export function init(apiKey: string, userId: string, options: Config): void;
|
||||
export function init(apiKey: string, userId: string, options: Config, callback: () => void): void;
|
||||
export class Revenue {
|
||||
|
||||
setProductId(productId: string): Revenue;
|
||||
setQuantity(quantity: number): Revenue;
|
||||
setPrice(price: number): Revenue;
|
||||
setRevenueType(revenueType: string): Revenue;
|
||||
setEventProperties(eventProperties: any): Revenue;
|
||||
}
|
||||
|
||||
export class AmplitudeClient {
|
||||
|
||||
constructor(instanceName?: string);
|
||||
|
||||
options: Config;
|
||||
|
||||
init(apiKey: string, userId?: string, config?: Config, callback?: (client: AmplitudeClient) => void): void;
|
||||
|
||||
setVersionName(versionName: string): void;
|
||||
|
||||
isNewSession(): boolean;
|
||||
setSessionId(sessionId: number): void;
|
||||
getSessionId(): number;
|
||||
|
||||
setDomain(domain: string): void;
|
||||
setUserId(userId: string): void;
|
||||
|
||||
setDeviceId(id: string): void;
|
||||
regenerateDeviceId(): void;
|
||||
|
||||
identify(identify_obj: Identify, opt_callback?: Callback): void;
|
||||
|
||||
setUserProperties(properties: any): void;
|
||||
setGlobalUserProperties(properties: any): void;
|
||||
clearUserProperties(): void;
|
||||
|
||||
setOptOut(enable: boolean): void;
|
||||
|
||||
setGroup(groupType: string, groupName: string | string[]): void;
|
||||
|
||||
logEvent(event: string, data?: any, callback?: Callback): LogReturn;
|
||||
logEventWithGroups(event: string, data?: any, groups?: any, callback?: Callback): LogReturn;
|
||||
logRevenueV2(revenue_obj: Revenue): LogReturn;
|
||||
logRevenue(pric: number, quantity: number, product: string): LogReturn;
|
||||
logEventWithTimestamp(event: string, data?: any, timestamp?: number, callback?: Callback): LogReturn;
|
||||
}
|
||||
|
||||
// Proxy methods that get executed on the default AmplitudeClient instance (not all client methods are proxied)
|
||||
|
||||
export function init(apiKey: string, userId?: string, options?: Config, callback?: (client: AmplitudeClient) => void): void;
|
||||
|
||||
export function setVersionName(version: string): void;
|
||||
|
||||
export function isNewSession(): boolean;
|
||||
export function getSessionId(): number;
|
||||
|
||||
export function setDomain(domain: string): void;
|
||||
|
||||
export function setUserId(userId: string): void;
|
||||
|
||||
export function setDeviceId(id: string): void;
|
||||
export function regenerateDeviceId(): void;
|
||||
|
||||
export function identify(identify: Identify): void;
|
||||
export function identify(identify: Identify, callback?: Callback): void;
|
||||
|
||||
export function setUserProperties(properties: Object): void;
|
||||
export function setUserProperties(properties: any): void;
|
||||
export function setGlobalUserProperties(properties: any): void;
|
||||
export function clearUserProperties(): void;
|
||||
|
||||
export function setOptOut(optOut: boolean): void;
|
||||
|
||||
export function setGroup(groupType: string, groupName: string | string[]): void;
|
||||
|
||||
export function logEvent(event: string): void;
|
||||
export function logEvent(event: string, data: Object): void;
|
||||
export function logEvent(event: string, data: Object, callback: (httpCode: number, response: any) => void): void;
|
||||
export function logEvent(event: string, data?: any, callback?: Callback): LogReturn;
|
||||
export function logEventWithGroups(event: string, data?: any, groups?: any, callback?: Callback): LogReturn;
|
||||
export function logRevenueV2(revenue_obj: Revenue): LogReturn;
|
||||
export function logRevenue(pric: number, quantity: number, product: string): LogReturn;
|
||||
export function logEventWithTimestamp(event: string, data?: any, timestamp?: number, callback?: Callback): LogReturn;
|
||||
|
||||
|
||||
|
||||
export function getInstance(instanceName?: string): AmplitudeClient;
|
||||
export const __VERSION__: string;
|
||||
export var options: Config;
|
||||
}
|
||||
|
||||
Vendored
+3
-3
@@ -8,7 +8,7 @@
|
||||
|
||||
import * as Promise from 'bluebird';
|
||||
import * as events from 'events';
|
||||
import { Replies, Options, Message } from './properties';
|
||||
import { Replies, Options, Message, GetMessage, ConsumeMessage } from './properties';
|
||||
export * from './properties';
|
||||
|
||||
export interface Connection extends events.EventEmitter {
|
||||
@@ -40,10 +40,10 @@ export interface Channel extends events.EventEmitter {
|
||||
publish(exchange: string, routingKey: string, content: Buffer, options?: Options.Publish): boolean;
|
||||
sendToQueue(queue: string, content: Buffer, options?: Options.Publish): boolean;
|
||||
|
||||
consume(queue: string, onMessage: (msg: Message | null) => any, options?: Options.Consume): Promise<Replies.Consume>;
|
||||
consume(queue: string, onMessage: (msg: ConsumeMessage | null) => any, options?: Options.Consume): Promise<Replies.Consume>;
|
||||
|
||||
cancel(consumerTag: string): Promise<Replies.Empty>;
|
||||
get(queue: string, options?: Options.Get): Promise<Message | false>;
|
||||
get(queue: string, options?: Options.Get): Promise<GetMessage | false>;
|
||||
|
||||
ack(message: Message, allUpTo?: boolean): void;
|
||||
ackAll(): void;
|
||||
|
||||
Vendored
+22
-2
@@ -145,12 +145,32 @@ export interface Message {
|
||||
properties: MessageProperties;
|
||||
}
|
||||
|
||||
export interface MessageFields {
|
||||
export interface GetMessage extends Message {
|
||||
fields: GetMessageFields;
|
||||
}
|
||||
|
||||
export interface ConsumeMessage extends Message {
|
||||
fields: ConsumeMessageFields;
|
||||
}
|
||||
|
||||
export interface CommonMessageFields {
|
||||
deliveryTag: number;
|
||||
redelivered: boolean;
|
||||
exchange: string;
|
||||
routingKey: string;
|
||||
messageCount: string;
|
||||
}
|
||||
|
||||
export interface MessageFields extends CommonMessageFields {
|
||||
messageCount?: number;
|
||||
consumerTag?: string;
|
||||
}
|
||||
|
||||
export interface GetMessageFields extends CommonMessageFields {
|
||||
messageCount: number;
|
||||
}
|
||||
|
||||
export interface ConsumeMessageFields extends CommonMessageFields {
|
||||
deliveryTag: number;
|
||||
}
|
||||
|
||||
export interface MessageProperties {
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
// All are TODOs
|
||||
"no-any-union": false,
|
||||
"no-empty-interface": false,
|
||||
"prefer-const": false
|
||||
}
|
||||
|
||||
Vendored
+1
@@ -340,6 +340,7 @@ declare module 'angular' {
|
||||
|
||||
interface IMenuService {
|
||||
hide(response?: any, options?: any): IPromise<any>;
|
||||
open(event?: MouseEvent): void;
|
||||
}
|
||||
|
||||
interface IColorPalette {
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
|
||||
@@ -16,6 +16,9 @@ interface SortLogInfo {
|
||||
Text: string;
|
||||
}
|
||||
|
||||
// Ensure that the jQuery-ui defined `sortable()` method is not overwritten
|
||||
jQuery().sortable(); // $ExpectType JQuery<HTMLElement>
|
||||
|
||||
myApp.controller('sortableController', function ($scope: MySortableControllerScope) {
|
||||
$scope.sortableOptions = {
|
||||
activate: function(e, ui) {
|
||||
@@ -84,6 +87,7 @@ myApp.controller('sortableController', function ($scope: MySortableControllerSco
|
||||
update: function(e, ui) {
|
||||
var jQueryEventObject: JQueryEventObject = e;
|
||||
var uiSortableUIParams: ng.ui.UISortableUIParams<SortableModelInfo> = ui;
|
||||
ui.item.sortable; // $ExpectType UISortableProperties<SortableModelInfo>
|
||||
var voidcanceled: void = ui.item.sortable.cancel();
|
||||
var isCanceled: Boolean = ui.item.sortable.isCanceled();
|
||||
var isCustomHelperUsed: Boolean =ui.item.sortable.isCustomHelperUsed();
|
||||
|
||||
Vendored
+7
-3
@@ -2,12 +2,16 @@
|
||||
// Project: https://github.com/angular-ui/ui-sortable
|
||||
// Definitions by: Thodoris Greasidis <https://github.com/thgreasi>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
// TypeScript Version: 2.4
|
||||
|
||||
/// <reference types="angular" />
|
||||
/// <reference types="jqueryui" />
|
||||
|
||||
import * as ng from 'angular';
|
||||
|
||||
// Diff / Omit taken from https://github.com/Microsoft/TypeScript/issues/12215#issuecomment-311923766
|
||||
type Omit<T, K extends keyof T> = Pick<T, ({ [P in keyof T]: P } & { [P in K]: never } & { [x: string]: never, [x: number]: never })[keyof T]>;
|
||||
|
||||
declare module 'angular' {
|
||||
export namespace ui {
|
||||
|
||||
@@ -79,11 +83,11 @@ declare module 'angular' {
|
||||
isCustomHelperUsed(): Boolean;
|
||||
}
|
||||
|
||||
interface UISortableUIItem<T> extends ng.IAugmentedJQuery {
|
||||
interface UISortableUIItem<T> extends Omit<ng.IAugmentedJQuery, 'sortable'> {
|
||||
sortable: UISortableProperties<T>;
|
||||
}
|
||||
|
||||
interface UISortableUIParams<T> extends SortableUIParams {
|
||||
interface UISortableUIParams<T> extends Omit<SortableUIParams, 'item'> {
|
||||
item: UISortableUIItem<T>;
|
||||
}
|
||||
|
||||
|
||||
Vendored
+6
-6
@@ -4,7 +4,7 @@
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.4
|
||||
|
||||
type FunctionBasedParamter = (element: HTMLElement, index: number, length: number) => number;
|
||||
type FunctionBasedParameter = (element: HTMLElement, index: number, length: number) => number;
|
||||
type AnimeCallbackFunction = (anim: anime.AnimeInstance) => void;
|
||||
// Allowing null is necessary because DOM queries may not return anything.
|
||||
type AnimeTarget = string | object | HTMLElement | SVGElement | NodeList | null;
|
||||
@@ -55,10 +55,10 @@ declare namespace anime {
|
||||
interface AnimeAnimParams {
|
||||
targets: AnimeTarget | ReadonlyArray<AnimeTarget>;
|
||||
|
||||
duration?: number | FunctionBasedParamter;
|
||||
delay?: number | FunctionBasedParamter;
|
||||
elasticity?: number | FunctionBasedParamter;
|
||||
round?: number | boolean | FunctionBasedParamter;
|
||||
duration?: number | FunctionBasedParameter;
|
||||
delay?: number | FunctionBasedParameter;
|
||||
elasticity?: number | FunctionBasedParameter;
|
||||
round?: number | boolean | FunctionBasedParameter;
|
||||
|
||||
easing?: EasingOptions | string | ReadonlyArray<number>;
|
||||
|
||||
@@ -106,7 +106,7 @@ declare namespace anime {
|
||||
}
|
||||
|
||||
interface AnimeTimelineAnimParams extends AnimeAnimParams {
|
||||
offset: number | string | FunctionBasedParamter;
|
||||
offset: number | string | FunctionBasedParameter;
|
||||
}
|
||||
|
||||
interface AnimeTimelineInstance extends AnimeInstance {
|
||||
|
||||
Vendored
+1
-1
@@ -3,7 +3,7 @@
|
||||
// Definitions by: bryn austin bellomy <https://github.com/brynbellomy>
|
||||
// plylrnsdy <https://github.com/plylrnsdy>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
// TypeScript Version: 2.1
|
||||
|
||||
import { EscapeCode } from './escape-code';
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
import ansi = require('ansi');
|
||||
const cursor = ansi(process.stdout);
|
||||
|
||||
Object.keys({
|
||||
white: 37
|
||||
, black: 30
|
||||
, blue: 34
|
||||
, cyan: 36
|
||||
, green: 32
|
||||
, magenta: 35
|
||||
, red: 31
|
||||
, yellow: 33
|
||||
, grey: 90
|
||||
, brightBlack: 90
|
||||
, brightRed: 91
|
||||
, brightGreen: 92
|
||||
, brightYellow: 93
|
||||
, brightBlue: 94
|
||||
, brightMagenta: 95
|
||||
, brightCyan: 96
|
||||
, brightWhite: 97
|
||||
}).forEach((color) => {
|
||||
cursor[color]().bold().write(`Hello, bold ${color.replace(/([a-z])([A-Z])/g, (_: string, l: string, u: string): string => `${l} ${u.toLowerCase()}`)} world!\n`).reset();
|
||||
});
|
||||
Vendored
+168
@@ -0,0 +1,168 @@
|
||||
// Type definitions for ansi 0.3
|
||||
// Project: https://www.npmjs.com/package/ansi
|
||||
// Definitions by: Gustavo6046 <https://github.com/Gustavo6046>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/**
|
||||
* References:
|
||||
*
|
||||
* - http://en.wikipedia.org/wiki/ANSI_escape_code
|
||||
* - http://www.termsys.demon.co.uk/vtansi.htm
|
||||
*
|
||||
*/
|
||||
|
||||
/// <reference types="node" />
|
||||
import { Stream } from "stream";
|
||||
|
||||
declare function ansi(stream: Stream, options?: any): ansi.Cursor;
|
||||
|
||||
declare namespace ansi {
|
||||
class Cursor {
|
||||
constructor(stream: Stream, options?: any);
|
||||
|
||||
/**
|
||||
* Helper function that calls `write()` on the underlying Stream.
|
||||
* Returns `this` instead of the write() return value to keep
|
||||
* the chaining going.
|
||||
*/
|
||||
write(data: string): Cursor;
|
||||
|
||||
/**
|
||||
* Buffer `write()` calls into memory.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
buffer(): Cursor;
|
||||
|
||||
/**
|
||||
* Write out the in-memory buffer.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
flush(): Cursor;
|
||||
|
||||
/**
|
||||
* Makes a beep sound!
|
||||
*/
|
||||
beep(): Cursor;
|
||||
|
||||
/**
|
||||
* Moves cursor to specific position
|
||||
*/
|
||||
goto(x?: number, y?: number): Cursor;
|
||||
|
||||
/**
|
||||
* Resets all ANSI formatting on the stream.
|
||||
*/
|
||||
reset(): Cursor;
|
||||
|
||||
/**
|
||||
* Sets the foreground color with the given RGB values.
|
||||
* The closest match out of the 216 colors is picked.
|
||||
*/
|
||||
rgb(r: number, g: number, b: number): Cursor;
|
||||
|
||||
/**
|
||||
* Accepts CSS color codes for use with ANSI escape codes.
|
||||
* For example: `#FF000` would be bright red.
|
||||
*/
|
||||
hex(color: string): Cursor;
|
||||
|
||||
up(): Cursor;
|
||||
down(): Cursor;
|
||||
forward(): Cursor;
|
||||
back(): Cursor;
|
||||
nextLine(): Cursor;
|
||||
previousLine(): Cursor;
|
||||
horizontalAbsolute(): Cursor;
|
||||
eraseData(): Cursor;
|
||||
eraseLine(): Cursor;
|
||||
scrollUp(): Cursor;
|
||||
scrollDown(): Cursor;
|
||||
savePosition(): Cursor;
|
||||
restorePosition(): Cursor;
|
||||
queryPosition(): Cursor;
|
||||
hide(): Cursor;
|
||||
show(): Cursor;
|
||||
|
||||
bold(): Cursor;
|
||||
italic(): Cursor;
|
||||
underline(): Cursor;
|
||||
inverse(): Cursor;
|
||||
resetbold(): Cursor;
|
||||
resetitalic(): Cursor;
|
||||
resetunderline(): Cursor;
|
||||
resetinverse(): Cursor;
|
||||
|
||||
white(): Cursor;
|
||||
black(): Cursor;
|
||||
blue(): Cursor;
|
||||
cyan(): Cursor;
|
||||
green(): Cursor;
|
||||
magenta(): Cursor;
|
||||
red(): Cursor;
|
||||
yellow(): Cursor;
|
||||
grey(): Cursor;
|
||||
brightBlack(): Cursor;
|
||||
brightRed(): Cursor;
|
||||
brightGreen(): Cursor;
|
||||
brightYellow(): Cursor;
|
||||
brightBlue(): Cursor;
|
||||
brightMagenta(): Cursor;
|
||||
brightCyan(): Cursor;
|
||||
brightWhite(): Cursor;
|
||||
}
|
||||
|
||||
/**
|
||||
* The `Colorer` class manages both the background and foreground colors.
|
||||
*/
|
||||
class Colorer {
|
||||
constructor(cursor: Cursor, base: string);
|
||||
|
||||
/**
|
||||
* Write an ANSI color code, ensuring that the same code doesn't get rewritten.
|
||||
*/
|
||||
_setColorCode(code: string): Colorer;
|
||||
|
||||
/**
|
||||
* Resets the color.
|
||||
*/
|
||||
reset(): Cursor;
|
||||
|
||||
/**
|
||||
* Sets the foreground color with the given RGB values.
|
||||
* The closest match out of the 216 colors is picked.
|
||||
*/
|
||||
rgb(r: number, g: number, b: number): Cursor;
|
||||
|
||||
/**
|
||||
* Accepts CSS color codes for use with ANSI escape codes.
|
||||
* For example: `#FF000` would be bright red.
|
||||
*/
|
||||
hex(color: string): Cursor;
|
||||
|
||||
white(): Cursor;
|
||||
black(): Cursor;
|
||||
blue(): Cursor;
|
||||
cyan(): Cursor;
|
||||
green(): Cursor;
|
||||
magenta(): Cursor;
|
||||
red(): Cursor;
|
||||
yellow(): Cursor;
|
||||
grey(): Cursor;
|
||||
brightBlack(): Cursor;
|
||||
brightRed(): Cursor;
|
||||
brightGreen(): Cursor;
|
||||
brightYellow(): Cursor;
|
||||
brightBlue(): Cursor;
|
||||
brightMagenta(): Cursor;
|
||||
brightCyan(): Cursor;
|
||||
brightWhite(): Cursor;
|
||||
}
|
||||
|
||||
interface Cursor {
|
||||
[key: string]: (...anything: any[]) => Cursor;
|
||||
}
|
||||
}
|
||||
|
||||
export = ansi;
|
||||
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"ansi-tests.ts"
|
||||
],
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es5",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"noEmit": true,
|
||||
"types": [],
|
||||
"forceConsistentCasingInFileNames": true
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Vendored
+1
-1
@@ -12,7 +12,7 @@ type FontFamily =
|
||||
| BaseCSSProperties['fontFamily']
|
||||
| CSS.FontFace;
|
||||
|
||||
type Omit<T, K extends keyof T> = Pick<T, ({ [P in keyof T]: P } & { [P in K]: never } & { [x: string]: never, [x: number]: never })[keyof T]>;
|
||||
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
|
||||
|
||||
type CSSProperties = Omit<BaseCSSProperties, 'fontFamily' | 'transition' | 'animationName' > & {
|
||||
fontFamily?: FontFamily | FontFamily[];
|
||||
|
||||
Vendored
+1
-1
@@ -2,7 +2,7 @@
|
||||
// Project: https://github.com/apollographql/apollo-codegen
|
||||
// Definitions by: Bradley Ayers <https://github.com/bradleyayers>, Maria Carrasco <https://github.com/kostspielig>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
// TypeScript Version: 2.6
|
||||
|
||||
import { Options } from 'graphql/utilities/schemaPrinter';
|
||||
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
// Project: https://github.com/jaydenseric/apollo-upload-client#readme
|
||||
// Definitions by: Edward Sammut Alessi <https://github.com/Slessi>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
// TypeScript Version: 2.6
|
||||
|
||||
import { ApolloLink } from "apollo-link";
|
||||
import { HttpOptions } from "apollo-link-http-common";
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6", "dom"
|
||||
"es6",
|
||||
"dom",
|
||||
"esnext.asynciterable"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
|
||||
Vendored
+22
-1
@@ -7,7 +7,10 @@
|
||||
export = apostrophe;
|
||||
export as namespace apos;
|
||||
|
||||
declare function apostrophe(options: any, ...args: any[]): any;
|
||||
declare function apostrophe(
|
||||
options: apostrophe.AposConstructor,
|
||||
...args: any[]
|
||||
): any;
|
||||
|
||||
declare namespace apostrophe {
|
||||
const moogBundle: {
|
||||
@@ -15,6 +18,20 @@ declare namespace apostrophe {
|
||||
modules: string[];
|
||||
};
|
||||
|
||||
// Pass in custom modules as first argument
|
||||
// second argument is additional custom options e.g. restApi exposed by apostrophe-headless
|
||||
interface AposConstructor<M = {}, O = {}> {
|
||||
afterInit?: () => void;
|
||||
afterListen?: () => void;
|
||||
initFailed?: (error: any) => void;
|
||||
baseUrl?: string;
|
||||
modules: { [K in AposCoreModules & M]?: AposModuleOptions | O };
|
||||
prefix?: string;
|
||||
root?: string;
|
||||
rootDir?: string;
|
||||
shortName: string;
|
||||
}
|
||||
|
||||
const ui: {
|
||||
globalBusy: (state: any) => any;
|
||||
link: (
|
||||
@@ -128,6 +145,9 @@ declare namespace apostrophe {
|
||||
required?: boolean;
|
||||
options?: AposObject;
|
||||
choices?: SelectChoice[];
|
||||
widgetType?: string;
|
||||
titleField?: string;
|
||||
schema?: Field[];
|
||||
}
|
||||
|
||||
interface SelectChoice {
|
||||
@@ -297,6 +317,7 @@ declare namespace apostrophe {
|
||||
label: string;
|
||||
fields: string[];
|
||||
}[];
|
||||
beforeConstruct?: (self: any, options: any) => any;
|
||||
defer?: boolean;
|
||||
filters?: {
|
||||
projection?: {
|
||||
|
||||
Vendored
+2
-2
@@ -2,7 +2,7 @@
|
||||
// Project: https://github.com/arangodb/arangodb
|
||||
// Definitions by: Alan Plum <https://github.com/pluma>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
// TypeScript Version: 2.6
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
@@ -1698,7 +1698,7 @@ declare module "@arangodb/crypto" {
|
||||
key: string | null,
|
||||
token: string,
|
||||
noVerify?: boolean
|
||||
): string | null;
|
||||
): object | null;
|
||||
function md5(message: string): string;
|
||||
function sha1(message: string): string;
|
||||
function sha224(message: string): string;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": ["es6"],
|
||||
"lib": ["es6", "esnext.asynciterable"],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
|
||||
@@ -0,0 +1,193 @@
|
||||
import art from 'ascii-art';
|
||||
|
||||
art.font('test', 'doom').toPromise();
|
||||
|
||||
art.font('my text', 'Doom', (rendered: string) => {
|
||||
rendered.big();
|
||||
});
|
||||
|
||||
art.font('my text', 'Doom', '', (rendered) => {
|
||||
rendered.big();
|
||||
});
|
||||
|
||||
art.artwork({
|
||||
artwork: 'textfiles.com/art/st-char.asc'
|
||||
}).lines(31, 45, (rendered: string) => {
|
||||
// cleanup non-unix terminators
|
||||
rendered = rendered.replace(/\r/g, '');
|
||||
art.image({
|
||||
filepath : '~/Images/earth_in_space.jpg',
|
||||
alphabet : 'ultra-wide'
|
||||
}).overlay(rendered, {
|
||||
x: 0,
|
||||
y: -1,
|
||||
style: 'red+blink',
|
||||
transparent: '&'
|
||||
}, (_final: any) => {});
|
||||
});
|
||||
|
||||
art.font('Ghost Wire BBS', 'Doom', (logo) => {
|
||||
art.font('No place like home', 'rusted', (subtext) => {
|
||||
art.table({
|
||||
verticalBar : ' ',
|
||||
horizontalBar : ' ',
|
||||
intersection : ' ',
|
||||
data: [
|
||||
{name: art.style('current users', 'red'), value: '203'},
|
||||
{name: 'operator', value: 'vince.vega'},
|
||||
{name: 'dial-in', value: '(917)555-4202'},
|
||||
]
|
||||
}).lines(2, (table: any) => {
|
||||
art.image({
|
||||
filepath : '~/Images/starburst_red.jpg',
|
||||
alphabet : 'ultra-wide'
|
||||
}).lines(2, 30).overlay(logo, {
|
||||
x: 0,
|
||||
y: 0,
|
||||
style: 'blue',
|
||||
}).overlay(subtext, {
|
||||
x: 19,
|
||||
y: 8,
|
||||
style: 'yellow',
|
||||
}).overlay(table, {
|
||||
x: -1,
|
||||
y: -1,
|
||||
style: 'green',
|
||||
}, (_final: any) => {
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
art.image({
|
||||
width : 40,
|
||||
filepath : '/Images/initech.png',
|
||||
alphabet : 'wide'
|
||||
}).font('INITECH', 'Doom', 'cyan', (_ascii) => {
|
||||
});
|
||||
|
||||
art.table({
|
||||
data: [
|
||||
{text: ' .\'ANDRE. '},
|
||||
{text: ' ..THE.GIANT\'. '},
|
||||
{text: '.With.Bobby."The.Brain"'},
|
||||
{text: '.Heenan.'}
|
||||
],
|
||||
verticalBar : ' ',
|
||||
horizontalBar : ' ',
|
||||
intersection : ' '
|
||||
}).lines(2, (table: any) => {
|
||||
art.strings([
|
||||
'ANDRE',
|
||||
'the',
|
||||
'GIANT',
|
||||
'POSSE',
|
||||
'7\'4"',
|
||||
'520 LB'
|
||||
], 'rusted', (andre: any, the: any, giant: any, posse: any, height: any, weight: any) => {
|
||||
art.strings([ 'has', 'a'], 'twopoint', (has: any, a: any) => {
|
||||
art.image({
|
||||
filepath : '/Images/andre_has_a_posse.jpeg',
|
||||
alphabet : 'ultra-wide'
|
||||
}).overlay(andre, {
|
||||
x: 8, y: 4,
|
||||
style: 'white'
|
||||
}).overlay(the, {
|
||||
x: 10, y: 7,
|
||||
style: 'white',
|
||||
transparent : true
|
||||
}).overlay(giant, {
|
||||
x: 8, y: 10,
|
||||
style: 'white',
|
||||
transparent : true
|
||||
}).overlay(has, {
|
||||
x: 10, y: 14,
|
||||
style: 'white'
|
||||
}).overlay(a, {
|
||||
x: 13, y: 17,
|
||||
style: 'white'
|
||||
}).overlay(posse, {
|
||||
x: 5, y: 20,
|
||||
style: 'bright_black',
|
||||
transparent: true
|
||||
}).overlay(height, {
|
||||
x: 59, y: 3,
|
||||
style: 'bright_black',
|
||||
transparent: true
|
||||
}).overlay(weight, {
|
||||
x: 59, y: 8,
|
||||
style: 'bright_black',
|
||||
transparent: true
|
||||
}).overlay(table, {
|
||||
x: 6, y: -6,
|
||||
style: 'bright_black',
|
||||
transparent: true
|
||||
}, (_final: any) => {
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
art.Figlet.fontPath = 'Fonts';
|
||||
|
||||
const image = new art.Image({
|
||||
filepath: '~/Images/metropolis.jpg',
|
||||
alphabet: 'variant4'
|
||||
});
|
||||
image.write((_err: any, _rendered: string) => {
|
||||
});
|
||||
|
||||
art.font('Prompt', 'Basic', 'red').font('v1', 'Doom', 'magenta', (_rendered) => {
|
||||
});
|
||||
|
||||
art.image({
|
||||
width : 40,
|
||||
filepath : '/Images/initech.png',
|
||||
alphabet : 'wide'
|
||||
}).font('INITECH', 'Doom', 'cyan', (_ascii) => {
|
||||
});
|
||||
|
||||
art.style('my text', 'red+underline');
|
||||
|
||||
art.table({
|
||||
width : 80,
|
||||
data : [ /* ... */ ],
|
||||
verticalBar : ' ',
|
||||
horizontalBar : ' ',
|
||||
intersection : ' ',
|
||||
columns : [
|
||||
{
|
||||
value : 'Product',
|
||||
style : 'black+gray_bg'
|
||||
}, {
|
||||
value : 'Maker',
|
||||
style : 'white'
|
||||
}, {
|
||||
value : 'Location',
|
||||
style : 'white'
|
||||
}
|
||||
]
|
||||
}, (_rendered) => {
|
||||
// use rendered text
|
||||
});
|
||||
|
||||
art.table({
|
||||
width : 80,
|
||||
data : [ /* ... */ ],
|
||||
bars : {
|
||||
ul_corner: '┏',
|
||||
ur_corner: '┓',
|
||||
lr_corner: '┛',
|
||||
ll_corner: '┗',
|
||||
bottom_t: '┻',
|
||||
top_t: '┳',
|
||||
right_t: '┫',
|
||||
left_t: '┣',
|
||||
intersection: '╋',
|
||||
vertical: '┃',
|
||||
horizontal: '━',
|
||||
},
|
||||
borderColor : 'bright_white',
|
||||
}, (_rendered) => {
|
||||
// use rendered text
|
||||
});
|
||||
Vendored
+43
@@ -0,0 +1,43 @@
|
||||
// Type definitions for ascii-art 1.4
|
||||
// Project: https://github.com/khrome/ascii-art
|
||||
// Definitions by: Lukas Elmer <https://github.com/lukaselmer>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
export type StyleType = (text: string, style?: string, close?: boolean) => Art;
|
||||
export type FontType = ((text: string, font?: string, styleOrCallback?: string | Cb, callback?: Cb) => Art);
|
||||
export type ImageType = (options: object, callback?: Cb) => Art;
|
||||
export type TableType = (options: object, callback?: Cb) => Art;
|
||||
export type ArtworkType = (options: object, callback?: Cb) => Art;
|
||||
export type LinesType = (...options: any[]) => Art;
|
||||
export type OverlayType = (...options: any[]) => Art;
|
||||
export type JoinType = (...options: any[]) => Art;
|
||||
export type StringsType = (...options: any[]) => Art;
|
||||
|
||||
export const style: StyleType;
|
||||
export const font: FontType;
|
||||
export const image: ImageType;
|
||||
export const table: TableType;
|
||||
export const artwork: ArtworkType;
|
||||
export const lines: LinesType;
|
||||
export const overlay: OverlayType;
|
||||
export const join: JoinType;
|
||||
export const strings: StringsType;
|
||||
export const Figlet: any;
|
||||
export const Image: any;
|
||||
|
||||
export interface Art {
|
||||
style: StyleType;
|
||||
font: FontType;
|
||||
image: ImageType;
|
||||
table: TableType;
|
||||
artwork: ArtworkType;
|
||||
lines: LinesType;
|
||||
overlay: OverlayType;
|
||||
join: JoinType;
|
||||
working: boolean;
|
||||
|
||||
toPromise: (() => Promise<string>);
|
||||
}
|
||||
|
||||
export type Cb = (result: string) => void;
|
||||
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"ascii-art-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
Vendored
+15
-13
@@ -7,29 +7,31 @@ export = A2MML;
|
||||
|
||||
declare var A2MML: ascii2mathml;
|
||||
|
||||
interface Options {
|
||||
decimalMark?: string;
|
||||
colSep?: string;
|
||||
rowSep?: string;
|
||||
display?: 'inline' | 'block';
|
||||
dir?: 'ltr' | 'rtl';
|
||||
bare?: boolean;
|
||||
standalone?: boolean;
|
||||
annotate?: boolean;
|
||||
}
|
||||
|
||||
interface ascii2mathml {
|
||||
/**
|
||||
* Generates a function with default options set to convert
|
||||
* ASCIIMath expression to MathML markup.
|
||||
* @param options Options
|
||||
*/
|
||||
(options: Options): ascii2mathml;
|
||||
(options: A2MML.Options): ascii2mathml;
|
||||
|
||||
/**
|
||||
* Converts ASCIIMath expression to MathML markup.
|
||||
* @param asciimath ASCIIMath expression
|
||||
* @param options Options
|
||||
*/
|
||||
(asciimath: string, options?: Options): string;
|
||||
(asciimath: string, options?: A2MML.Options): string;
|
||||
}
|
||||
|
||||
declare namespace A2MML {
|
||||
interface Options {
|
||||
decimalMark?: string;
|
||||
colSep?: string;
|
||||
rowSep?: string;
|
||||
display?: 'inline' | 'block';
|
||||
dir?: 'ltr' | 'rtl';
|
||||
bare?: boolean;
|
||||
standalone?: boolean;
|
||||
annotate?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+50
@@ -0,0 +1,50 @@
|
||||
// Type definitions for astring 1.3
|
||||
// Project: https://github.com/davidbonnet/astring
|
||||
// Definitions by: Nikolaj Kappler <https://github.com/nkappler>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import * as ESTree from 'estree';
|
||||
import 'node';
|
||||
import { Stream } from 'stream';
|
||||
|
||||
export interface Options {
|
||||
/** string to use for indentation (defaults to " ") */
|
||||
indent?: string;
|
||||
/** string to use for line endings (defaults to "\n") */
|
||||
lineEnd?: string;
|
||||
/** indent level to start from (defaults to 0) */
|
||||
startingIndentLevel?: number;
|
||||
/** generate comments if true (defaults to false) */
|
||||
comments?: boolean;
|
||||
/** custom code generator (defaults to astring.baseGenerator) */
|
||||
generator?: object;
|
||||
/** source map generator (defaults to null), see https://github.com/mozilla/source-map#sourcemapgenerator */
|
||||
sourceMap?: any;
|
||||
}
|
||||
|
||||
/** Returns a string representing the rendered code of the provided AST `node`. However, if an `output` stream is provided in the options, it writes to that stream and returns it. */
|
||||
export function generate(node: ESTree.Node, options?: Options): string;
|
||||
/** Returns a string representing the rendered code of the provided AST `node`. However, if an `output` stream is provided in the options, it writes to that stream and returns it. */
|
||||
export function generate(node: ESTree.Node, options: Options & {
|
||||
/** output stream to write the rendered code to (defaults to null) */
|
||||
output: Stream;
|
||||
}): Stream;
|
||||
|
||||
/**
|
||||
* A code generator consists of a mapping of node names and functions that take two arguments: `node` and `state`.
|
||||
* The `node` points to the node from which to generate the code and the `state` exposes the `write` method that takes generated code strings.
|
||||
*/
|
||||
export type Generator = { [key in ESTree.Node["type"]]: (node: Extract<ESTree.Node, { type: key }>, state: { write(s: string): void }) => void };
|
||||
|
||||
/** Base generator that can be used to extend Astring. See https://github.com/davidbonnet/astring#extending */
|
||||
export const baseGenerator: Generator;
|
||||
|
||||
declare global {
|
||||
interface astring {
|
||||
generate: typeof generate;
|
||||
/** Base generator that can be used to extend Astring. See https://github.com/davidbonnet/astring#extending */
|
||||
baseGenerator: Generator;
|
||||
}
|
||||
const astring: astring;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
// global scope function
|
||||
astring.generate(null);
|
||||
|
||||
// global scope function
|
||||
astring.baseGenerator.Program(null, { write(s: string) { return; } });
|
||||
@@ -0,0 +1,32 @@
|
||||
import { baseGenerator, generate } from "astring";
|
||||
import { FunctionExpression, MemberExpression, Program } from "estree";
|
||||
import { Stream } from "stream";
|
||||
|
||||
const ast: Program = null;
|
||||
const functionE: FunctionExpression = null;
|
||||
const memberE: MemberExpression = null;
|
||||
|
||||
// should accept different nodes
|
||||
generate(ast);
|
||||
generate(functionE);
|
||||
generate(memberE);
|
||||
|
||||
// options without output option should generate string
|
||||
const string: string = generate(ast, {
|
||||
comments: true,
|
||||
generator: baseGenerator,
|
||||
indent: "\t",
|
||||
lineEnd: "\n",
|
||||
startingIndentLevel: 42,
|
||||
sourceMap: null
|
||||
});
|
||||
|
||||
// options with output option should return Stream
|
||||
const stream: Stream = generate(ast, {
|
||||
output: new Stream()
|
||||
});
|
||||
|
||||
// Generator should map node types to functions whose first parameter is same node type
|
||||
baseGenerator.Program(ast, { write(s: string) { return; } });
|
||||
baseGenerator.FunctionExpression(functionE, { write(s: string) { return; } });
|
||||
baseGenerator.MemberExpression(memberE, { write(s: string) { return; } });
|
||||
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"test/astring.test.ts",
|
||||
"test/astring-global.test.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
Vendored
+77
-77
@@ -2,34 +2,34 @@
|
||||
// Project: https://github.com/caolan/async
|
||||
// Definitions by: Boris Yankov <https://github.com/borisyankov>, Arseniy Maximov <https://github.com/kern0>, Joe Herman <https://github.com/Penryn>, Angus Fenying <https://github.com/fenying>, Pascal Martin <https://github.com/pascalmartin>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.1
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
export as namespace async;
|
||||
|
||||
export interface Dictionary<T> { [key: string]: T; }
|
||||
export type IterableCollection<T> = T[] | IterableIterator<T> | Dictionary<T>
|
||||
|
||||
export interface ErrorCallback<T> { (err?: T): void; }
|
||||
export interface AsyncBooleanResultCallback<E> { (err?: E, truthValue?: boolean): void; }
|
||||
export interface AsyncResultCallback<T, E> { (err?: E, result?: T): void; }
|
||||
export interface AsyncResultArrayCallback<T, E> { (err?: E, results?: Array<T | undefined>): void; }
|
||||
export interface AsyncResultObjectCallback<T, E> { (err: E | undefined, results: Dictionary<T | undefined>): void; }
|
||||
export interface ErrorCallback<E = Error> { (err?: E | null): void; }
|
||||
export interface AsyncBooleanResultCallback<E = Error> { (err?: E | null, truthValue?: boolean): void; }
|
||||
export interface AsyncResultCallback<T, E = Error> { (err?: E | null, result?: T): void; }
|
||||
export interface AsyncResultArrayCallback<T, E = Error> { (err?: E | null, results?: Array<T | undefined>): void; }
|
||||
export interface AsyncResultObjectCallback<T, E = Error> { (err: E | undefined, results: Dictionary<T | undefined>): void; }
|
||||
|
||||
export interface AsyncFunction<T, E> { (callback: (err?: E, result?: T) => void): void; }
|
||||
export interface AsyncFunctionEx<T, E> { (callback: (err?: E, ...results: T[]) => void): void; }
|
||||
export interface AsyncIterator<T, E> { (item: T, callback: ErrorCallback<E>): void; }
|
||||
export interface AsyncForEachOfIterator<T, E> { (item: T, key: number|string, callback: ErrorCallback<E>): void; }
|
||||
export interface AsyncResultIterator<T, R, E> { (item: T, callback: AsyncResultCallback<R, E>): void; }
|
||||
export interface AsyncMemoIterator<T, R, E> { (memo: R | undefined, item: T, callback: AsyncResultCallback<R, E>): void; }
|
||||
export interface AsyncBooleanIterator<T, E> { (item: T, callback: AsyncBooleanResultCallback<E>): void; }
|
||||
export interface AsyncFunction<T, E = Error> { (callback: (err?: E | null, result?: T) => void): void; }
|
||||
export interface AsyncFunctionEx<T, E = Error> { (callback: (err?: E | null, ...results: T[]) => void): void; }
|
||||
export interface AsyncIterator<T, E = Error> { (item: T, callback: ErrorCallback<E>): void; }
|
||||
export interface AsyncForEachOfIterator<T, E = Error> { (item: T, key: number|string, callback: ErrorCallback<E>): void; }
|
||||
export interface AsyncResultIterator<T, R, E = Error> { (item: T, callback: AsyncResultCallback<R, E>): void; }
|
||||
export interface AsyncMemoIterator<T, R, E = Error> { (memo: R | undefined, item: T, callback: AsyncResultCallback<R, E>): void; }
|
||||
export interface AsyncBooleanIterator<T, E = Error> { (item: T, callback: AsyncBooleanResultCallback<E>): void; }
|
||||
|
||||
export interface AsyncWorker<T, E> { (task: T, callback: ErrorCallback<E>): void; }
|
||||
export interface AsyncVoidFunction<E> { (callback: ErrorCallback<E>): void; }
|
||||
export interface AsyncWorker<T, E = Error> { (task: T, callback: ErrorCallback<E>): void; }
|
||||
export interface AsyncVoidFunction<E = Error> { (callback: ErrorCallback<E>): void; }
|
||||
|
||||
export type AsyncAutoTasks<R extends Dictionary<any>, E> = { [K in keyof R]: AsyncAutoTask<R[K], R, E> }
|
||||
export type AsyncAutoTask<R1, R extends Dictionary<any>, E> = AsyncAutoTaskFunctionWithoutDependencies<R1, E> | (keyof R | AsyncAutoTaskFunction<R1, R, E>)[];
|
||||
export interface AsyncAutoTaskFunctionWithoutDependencies<R1, E> { (cb: AsyncResultCallback<R1, E> | ErrorCallback<E>): void; }
|
||||
export interface AsyncAutoTaskFunction<R1, R extends Dictionary<any>, E> { (results: R, cb: AsyncResultCallback<R1, E> | ErrorCallback<E>): void; }
|
||||
export interface AsyncAutoTaskFunctionWithoutDependencies<R1, E = Error> { (cb: AsyncResultCallback<R1, E> | ErrorCallback<E>): void; }
|
||||
export interface AsyncAutoTaskFunction<R1, R extends Dictionary<any>, E = Error> { (results: R, cb: AsyncResultCallback<R1, E> | ErrorCallback<E>): void; }
|
||||
|
||||
export interface AsyncQueue<T> {
|
||||
length(): number;
|
||||
@@ -37,9 +37,8 @@ export interface AsyncQueue<T> {
|
||||
running(): number;
|
||||
idle(): boolean;
|
||||
concurrency: number;
|
||||
push<E>(task: T | T[], callback?: ErrorCallback<E>): void;
|
||||
push<R,E>(task: T, callback?: AsyncResultCallback<R, E>): void;
|
||||
unshift<E>(task: T | T[], callback?: ErrorCallback<E>): void;
|
||||
push<R,E = Error>(task: T | T[], callback?: AsyncResultCallback<R, E>): void;
|
||||
unshift<E = Error>(task: T | T[], callback?: ErrorCallback<E>): void;
|
||||
saturated: () => any;
|
||||
empty: () => any;
|
||||
drain: () => any;
|
||||
@@ -61,7 +60,7 @@ export interface AsyncPriorityQueue<T> {
|
||||
concurrency: number;
|
||||
started: boolean;
|
||||
paused: boolean;
|
||||
push<R,E>(task: T | T[], priority: number, callback?: AsyncResultArrayCallback<R, E>): void;
|
||||
push<R,E = Error>(task: T | T[], priority: number, callback?: AsyncResultArrayCallback<R, E>): void;
|
||||
saturated: () => any;
|
||||
empty: () => any;
|
||||
drain: () => any;
|
||||
@@ -94,112 +93,113 @@ export interface AsyncCargo {
|
||||
}
|
||||
|
||||
// Collections
|
||||
export function each<T, E>(arr: IterableCollection<T>, iterator: AsyncIterator<T, E>, callback?: ErrorCallback<E>): void;
|
||||
export function each<T, E = Error>(arr: IterableCollection<T>, iterator: AsyncIterator<T, E>, callback?: ErrorCallback<E>): void;
|
||||
export const eachSeries: typeof each;
|
||||
export function eachLimit<T, E>(arr: IterableCollection<T>, limit: number, iterator: AsyncIterator<T, E>, callback?: ErrorCallback<E>): void;
|
||||
export function eachLimit<T, E = Error>(arr: IterableCollection<T>, limit: number, iterator: AsyncIterator<T, E>, callback?: ErrorCallback<E>): void;
|
||||
export const forEach: typeof each;
|
||||
export const forEachSeries: typeof each;
|
||||
export const forEachLimit: typeof eachLimit;
|
||||
export function forEachOf<T, E>(obj: IterableCollection<T>, iterator: AsyncForEachOfIterator<T, E>, callback?: ErrorCallback<E>): void;
|
||||
export function forEachOf<T, E = Error>(obj: IterableCollection<T>, iterator: AsyncForEachOfIterator<T, E>, callback?: ErrorCallback<E>): void;
|
||||
export const forEachOfSeries: typeof forEachOf;
|
||||
export function forEachOfLimit<T, E>(obj: IterableCollection<T>, limit: number, iterator: AsyncForEachOfIterator<T, E>, callback?: ErrorCallback<E>): void;
|
||||
export function forEachOfLimit<T, E = Error>(obj: IterableCollection<T>, limit: number, iterator: AsyncForEachOfIterator<T, E>, callback?: ErrorCallback<E>): void;
|
||||
export const eachOf: typeof forEachOf;
|
||||
export const eachOfSeries: typeof forEachOf;
|
||||
export const eachOfLimit: typeof forEachOfLimit;
|
||||
export function map<T, R, E>(arr: T[] | IterableIterator<T>, iterator: AsyncResultIterator<T, R, E>, callback?: AsyncResultArrayCallback<R, E>): void;
|
||||
export function map<T, R, E>(arr: Dictionary<T>, iterator: AsyncResultIterator<T, R, E>, callback?: AsyncResultArrayCallback<R, E>): void;
|
||||
export function map<T, R, E = Error>(arr: T[] | IterableIterator<T>, iterator: AsyncResultIterator<T, R, E>, callback?: AsyncResultArrayCallback<R, E>): void;
|
||||
export function map<T, R, E = Error>(arr: Dictionary<T>, iterator: AsyncResultIterator<T, R, E>, callback?: AsyncResultArrayCallback<R, E>): void;
|
||||
export const mapSeries: typeof map;
|
||||
export function mapLimit<T, R, E>(arr: IterableCollection<T>, limit: number, iterator: AsyncResultIterator<T, R, E>, callback?: AsyncResultArrayCallback<R, E>): void;
|
||||
export function mapValuesLimit<T, R, E>(obj: Dictionary<T>, limit: number, iteratee: (value: T, key: string, callback: AsyncResultCallback<R, E>) => void, callback: AsyncResultObjectCallback<R, E>): void;
|
||||
export function mapValues<T, R, E>(obj: Dictionary<T>, iteratee: (value: T, key: string, callback: AsyncResultCallback<R, E>) => void, callback: AsyncResultObjectCallback<R, E>): void;
|
||||
export function mapLimit<T, R, E = Error>(arr: IterableCollection<T>, limit: number, iterator: AsyncResultIterator<T, R, E>, callback?: AsyncResultArrayCallback<R, E>): void;
|
||||
export function mapValuesLimit<T, R, E = Error>(obj: Dictionary<T>, limit: number, iteratee: (value: T, key: string, callback: AsyncResultCallback<R, E>) => void, callback: AsyncResultObjectCallback<R, E>): void;
|
||||
export function mapValues<T, R, E = Error>(obj: Dictionary<T>, iteratee: (value: T, key: string, callback: AsyncResultCallback<R, E>) => void, callback: AsyncResultObjectCallback<R, E>): void;
|
||||
export const mapValuesSeries: typeof mapValues;
|
||||
export function filter<T, E>(arr: IterableCollection<T>, iterator: AsyncBooleanIterator<T, E>, callback?: AsyncResultArrayCallback<T, E>): void;
|
||||
export function filter<T, E = Error>(arr: IterableCollection<T>, iterator: AsyncBooleanIterator<T, E>, callback?: AsyncResultArrayCallback<T, E>): void;
|
||||
export const filterSeries: typeof filter;
|
||||
export function filterLimit<T, E>(arr: IterableCollection<T>, limit: number, iterator: AsyncBooleanIterator<T, E>, callback?: AsyncResultArrayCallback<T, E>): void;
|
||||
export function filterLimit<T, E = Error>(arr: IterableCollection<T>, limit: number, iterator: AsyncBooleanIterator<T, E>, callback?: AsyncResultArrayCallback<T, E>): void;
|
||||
export const select: typeof filter;
|
||||
export const selectSeries: typeof filter;
|
||||
export const selectLimit: typeof filterLimit;
|
||||
export const reject: typeof filter;
|
||||
export const rejectSeries: typeof filter;
|
||||
export const rejectLimit: typeof filterLimit;
|
||||
export function reduce<T, R, E>(arr: T[] | IterableIterator<T>, memo: R, iterator: AsyncMemoIterator<T, R, E>, callback?: AsyncResultCallback<R, E>): void;
|
||||
export function reduce<T, R, E = Error>(arr: T[] | IterableIterator<T>, memo: R, iterator: AsyncMemoIterator<T, R, E>, callback?: AsyncResultCallback<R, E>): void;
|
||||
export const inject: typeof reduce;
|
||||
export const foldl: typeof reduce;
|
||||
export const reduceRight: typeof reduce;
|
||||
export const foldr: typeof reduce;
|
||||
export function detect<T, E>(arr: IterableCollection<T>, iterator: AsyncBooleanIterator<T, E>, callback?: AsyncResultCallback<T, E>): void;
|
||||
export function detect<T, E = Error>(arr: IterableCollection<T>, iterator: AsyncBooleanIterator<T, E>, callback?: AsyncResultCallback<T, E>): void;
|
||||
export const detectSeries: typeof detect;
|
||||
export function detectLimit<T, E>(arr: IterableCollection<T>, limit: number, iterator: AsyncBooleanIterator<T, E>, callback?: AsyncResultCallback<T, E>): void;
|
||||
export function detectLimit<T, E = Error>(arr: IterableCollection<T>, limit: number, iterator: AsyncBooleanIterator<T, E>, callback?: AsyncResultCallback<T, E>): void;
|
||||
export const find: typeof detect;
|
||||
export const findSeries: typeof detect;
|
||||
export const findLimit: typeof detectLimit;
|
||||
export function sortBy<T, V, E>(arr: T[] | IterableIterator<T>, iterator: AsyncResultIterator<T, V, E>, callback?: AsyncResultArrayCallback<T, E>): void;
|
||||
export function some<T, E>(arr: IterableCollection<T>, iterator: AsyncBooleanIterator<T, E>, callback?: AsyncBooleanResultCallback<E>): void;
|
||||
export function sortBy<T, V, E = Error>(arr: T[] | IterableIterator<T>, iterator: AsyncResultIterator<T, V, E>, callback?: AsyncResultArrayCallback<T, E>): void;
|
||||
export function some<T, E = Error>(arr: IterableCollection<T>, iterator: AsyncBooleanIterator<T, E>, callback?: AsyncBooleanResultCallback<E>): void;
|
||||
export const someSeries: typeof some;
|
||||
export function someLimit<T, E>(arr: IterableCollection<T>, limit: number, iterator: AsyncBooleanIterator<T, E>, callback?: AsyncBooleanResultCallback<E>): void;
|
||||
export function someLimit<T, E = Error>(arr: IterableCollection<T>, limit: number, iterator: AsyncBooleanIterator<T, E>, callback?: AsyncBooleanResultCallback<E>): void;
|
||||
export const any: typeof some;
|
||||
export const anySeries: typeof someSeries;
|
||||
export const anyLimit: typeof someLimit;
|
||||
export function every<T, E>(arr: IterableCollection<T>, iterator: AsyncBooleanIterator<T, E>, callback?: AsyncBooleanResultCallback<E>): void;
|
||||
export function every<T, E = Error>(arr: IterableCollection<T>, iterator: AsyncBooleanIterator<T, E>, callback?: AsyncBooleanResultCallback<E>): void;
|
||||
export const everySeries: typeof every;
|
||||
export function everyLimit<T, E>(arr: IterableCollection<T>, limit: number, iterator: AsyncBooleanIterator<T, E>, callback?: AsyncBooleanResultCallback<E>): void;
|
||||
export function everyLimit<T, E = Error>(arr: IterableCollection<T>, limit: number, iterator: AsyncBooleanIterator<T, E>, callback?: AsyncBooleanResultCallback<E>): void;
|
||||
export const all: typeof every;
|
||||
export const allSeries: typeof every;
|
||||
export const allLimit: typeof everyLimit;
|
||||
|
||||
export function concat<T, R, E>(arr: IterableCollection<T>, iterator: AsyncResultIterator<T, R[], E>, callback?: AsyncResultArrayCallback<R, E>): void;
|
||||
export function concatLimit<T, R, E>(arr: IterableCollection<T>, limit: number, iterator: AsyncResultIterator<T, R[], E>, callback?: AsyncResultArrayCallback<R, E>): void;
|
||||
export function concat<T, R, E = Error>(arr: IterableCollection<T>, iterator: AsyncResultIterator<T, R[], E>, callback?: AsyncResultArrayCallback<R, E>): void;
|
||||
export function concatLimit<T, R, E = Error>(arr: IterableCollection<T>, limit: number, iterator: AsyncResultIterator<T, R[], E>, callback?: AsyncResultArrayCallback<R, E>): void;
|
||||
export const concatSeries: typeof concat;
|
||||
|
||||
// Control Flow
|
||||
export function series<T, E>(tasks: AsyncFunction<T, E>[], callback?: AsyncResultArrayCallback<T, E>): void;
|
||||
export function series<T, E>(tasks: Dictionary<AsyncFunction<T, E>>, callback?: AsyncResultObjectCallback<T, E>): void;
|
||||
export function parallel<T, E>(tasks: Array<AsyncFunction<T, E>>, callback?: AsyncResultArrayCallback<T, E>): void;
|
||||
export function parallel<T, E>(tasks: Dictionary<AsyncFunction<T, E>>, callback?: AsyncResultObjectCallback<T, E>): void;
|
||||
export function parallelLimit<T, E>(tasks: Array<AsyncFunction<T, E>>, limit: number, callback?: AsyncResultArrayCallback<T, E>): void;
|
||||
export function parallelLimit<T, E>(tasks: Dictionary<AsyncFunction<T, E>>, limit: number, callback?: AsyncResultObjectCallback<T, E>): void;
|
||||
export function whilst<E>(test: () => boolean, fn: AsyncVoidFunction<E>, callback: ErrorCallback<E>): void;
|
||||
export function doWhilst<T, E>(fn: AsyncFunctionEx<T, E>, test: (...results: T[]) => boolean, callback: ErrorCallback<E>): void;
|
||||
export function until<E>(test: () => boolean, fn: AsyncVoidFunction<E>, callback: ErrorCallback<E>): void;
|
||||
export function doUntil<T, E>(fn: AsyncFunctionEx<T, E>, test: (...results: T[]) => boolean, callback: ErrorCallback<E>): void;
|
||||
export function during<E>(test: (testCallback : AsyncBooleanResultCallback<E>) => void, fn: AsyncVoidFunction<E>, callback: ErrorCallback<E>): void;
|
||||
export function doDuring<E>(fn: AsyncVoidFunction<E>, test: (testCallback: AsyncBooleanResultCallback<E>) => void, callback: ErrorCallback<E>): void;
|
||||
export function forever<E>(next: (next : ErrorCallback<E>) => void, errBack: ErrorCallback<E>) : void;
|
||||
export function waterfall<T, E>(tasks: Function[], callback?: AsyncResultCallback<T, E | Error>): void;
|
||||
export function series<T, E = Error>(tasks: AsyncFunction<T, E>[], callback?: AsyncResultArrayCallback<T, E>): void;
|
||||
export function series<T, E = Error>(tasks: Dictionary<AsyncFunction<T, E>>, callback?: AsyncResultObjectCallback<T, E>): void;
|
||||
export function parallel<T, E = Error>(tasks: Array<AsyncFunction<T, E>>, callback?: AsyncResultArrayCallback<T, E>): void;
|
||||
export function parallel<T, E = Error>(tasks: Dictionary<AsyncFunction<T, E>>, callback?: AsyncResultObjectCallback<T, E>): void;
|
||||
export function parallelLimit<T, E = Error>(tasks: Array<AsyncFunction<T, E>>, limit: number, callback?: AsyncResultArrayCallback<T, E>): void;
|
||||
export function parallelLimit<T, E = Error>(tasks: Dictionary<AsyncFunction<T, E>>, limit: number, callback?: AsyncResultObjectCallback<T, E>): void;
|
||||
export function whilst<E = Error>(test: () => boolean, fn: AsyncVoidFunction<E>, callback: ErrorCallback<E>): void;
|
||||
export function doWhilst<T, E = Error>(fn: AsyncFunctionEx<T, E>, test: (...results: T[]) => boolean, callback: ErrorCallback<E>): void;
|
||||
export function until<E = Error>(test: () => boolean, fn: AsyncVoidFunction<E>, callback: ErrorCallback<E>): void;
|
||||
export function doUntil<T, E = Error>(fn: AsyncFunctionEx<T, E>, test: (...results: T[]) => boolean, callback: ErrorCallback<E>): void;
|
||||
export function during<E = Error>(test: (testCallback : AsyncBooleanResultCallback<E>) => void, fn: AsyncVoidFunction<E>, callback: ErrorCallback<E>): void;
|
||||
export function doDuring<E = Error>(fn: AsyncVoidFunction<E>, test: (testCallback: AsyncBooleanResultCallback<E>) => void, callback: ErrorCallback<E>): void;
|
||||
export function forever<E = Error>(next: (next : ErrorCallback<E>) => void, errBack: ErrorCallback<E>) : void;
|
||||
export function waterfall<T, E = Error>(tasks: Function[], callback?: AsyncResultCallback<T, E>): void;
|
||||
export function compose(...fns: Function[]): Function;
|
||||
export function seq(...fns: Function[]): Function;
|
||||
export function applyEach(fns: Function[], ...argsAndCallback: any[]): void; // applyEach(fns, args..., callback). TS does not support ... for a middle argument. Callback is optional.
|
||||
export function applyEachSeries(fns: Function[], ...argsAndCallback: any[]): void; // applyEachSeries(fns, args..., callback). TS does not support ... for a middle argument. Callback is optional.
|
||||
export function queue<T, E>(worker: AsyncWorker<T, E>, concurrency?: number): AsyncQueue<T>;
|
||||
export function queue<T, R, E>(worker: AsyncResultIterator<T, R, E>, concurrency?: number): AsyncQueue<T>;
|
||||
export function priorityQueue<T, E>(worker: AsyncWorker<T, E>, concurrency: number): AsyncPriorityQueue<T>;
|
||||
export function cargo<E>(worker : (tasks: any[], callback : ErrorCallback<E>) => void, payload? : number) : AsyncCargo;
|
||||
export function auto<R extends Dictionary<any>, E>(tasks: AsyncAutoTasks<R, E>, concurrency?: number, callback?: AsyncResultCallback<R, E>): void;
|
||||
export function autoInject<E>(tasks: any, callback?: AsyncResultCallback<any, E>): void;
|
||||
export function retry<T, E>(opts: number, task: (callback : AsyncResultCallback<T, E>, results: any) => void, callback: AsyncResultCallback<any, E | Error>): void;
|
||||
export function retry<T, E>(opts: { times: number, interval: number|((retryCount: number) => number) }, task: (callback: AsyncResultCallback<T, E>, results : any) => void, callback: AsyncResultCallback<any, E | Error>): void;
|
||||
export function retryable<T, E>(opts: number | {times: number, interval: number}, task: AsyncFunction<T, E>): AsyncFunction<T, E | Error>;
|
||||
export function apply<E>(fn: Function, ...args: any[]): AsyncFunction<any,E | Error>;
|
||||
export function queue<T, E = Error>(worker: AsyncWorker<T, E>, concurrency?: number): AsyncQueue<T>;
|
||||
export function queue<T, R, E = Error>(worker: AsyncResultIterator<T, R, E>, concurrency?: number): AsyncQueue<T>;
|
||||
export function priorityQueue<T, E = Error>(worker: AsyncWorker<T, E>, concurrency: number): AsyncPriorityQueue<T>;
|
||||
export function cargo<E = Error>(worker : (tasks: any[], callback : ErrorCallback<E>) => void, payload? : number) : AsyncCargo;
|
||||
export function auto<R extends Dictionary<any>, E = Error>(tasks: AsyncAutoTasks<R, E>, concurrency?: number, callback?: AsyncResultCallback<R, E>): void;
|
||||
export function auto<R extends Dictionary<any>, E = Error>(tasks: AsyncAutoTasks<R, E>, callback?: AsyncResultCallback<R, E>): void;
|
||||
export function autoInject<E = Error>(tasks: any, callback?: AsyncResultCallback<any, E>): void;
|
||||
export function retry<T, E = Error>(opts: number, task: (callback : AsyncResultCallback<T, E>, results: any) => void, callback: AsyncResultCallback<any, E>): void;
|
||||
export function retry<T, E = Error>(opts: { times: number, interval: number|((retryCount: number) => number) }, task: (callback: AsyncResultCallback<T, E>, results : any) => void, callback: AsyncResultCallback<any, E>): void;
|
||||
export function retryable<T, E = Error>(opts: number | {times: number, interval: number}, task: AsyncFunction<T, E>): AsyncFunction<T, E>;
|
||||
export function apply<E = Error>(fn: Function, ...args: any[]): AsyncFunction<any,E>;
|
||||
export function nextTick(callback: Function, ...args: any[]): void;
|
||||
export const setImmediate: typeof nextTick;
|
||||
|
||||
export function reflect<T, E>(fn: AsyncFunction<T, E>) : (callback: (err: null, result: {error?: E, value?: T}) => void) => void;
|
||||
export function reflectAll<T, E>(tasks: AsyncFunction<T, E>[]): ((callback: (err: null, result: {error?: E, value?: T}) => void) => void)[];
|
||||
export function reflect<T, E = Error>(fn: AsyncFunction<T, E>) : (callback: (err: null, result: {error?: E, value?: T}) => void) => void;
|
||||
export function reflectAll<T, E = Error>(tasks: AsyncFunction<T, E>[]): ((callback: (err: null, result: {error?: E, value?: T}) => void) => void)[];
|
||||
|
||||
export function timeout<T, E>(fn: AsyncFunction<T, E>, milliseconds: number, info?: any): AsyncFunction<T, E | Error>;
|
||||
export function timeout<T, R, E>(fn: AsyncResultIterator<T, R, E>, milliseconds: number, info?: any): AsyncResultIterator<T, R, E | Error>;
|
||||
export function timeout<T, E = Error>(fn: AsyncFunction<T, E>, milliseconds: number, info?: any): AsyncFunction<T, E>;
|
||||
export function timeout<T, R, E = Error>(fn: AsyncResultIterator<T, R, E>, milliseconds: number, info?: any): AsyncResultIterator<T, R, E>;
|
||||
|
||||
export function times<T, E> (n: number, iterator: AsyncResultIterator<number, T, E>, callback: AsyncResultArrayCallback<T, E>): void;
|
||||
export function timesSeries<T, E>(n: number, iterator: AsyncResultIterator<number, T, E>, callback: AsyncResultArrayCallback<T, E>): void;
|
||||
export function timesLimit<T, E>(n: number, limit: number, iterator: AsyncResultIterator<number, T, E>, callback: AsyncResultArrayCallback<T, E>): void;
|
||||
export function timesSeries<T, E = Error>(n: number, iterator: AsyncResultIterator<number, T, E>, callback: AsyncResultArrayCallback<T, E>): void;
|
||||
export function timesLimit<T, E = Error>(n: number, limit: number, iterator: AsyncResultIterator<number, T, E>, callback: AsyncResultArrayCallback<T, E>): void;
|
||||
|
||||
export function transform<T, R, E>(arr: T[], iteratee: (acc: R[], item: T, key: number, callback: (error?: E) => void) => void, callback?: AsyncResultArrayCallback<T, E>): void;
|
||||
export function transform<T, R, E>(arr: T[], acc: R[], iteratee: (acc: R[], item: T, key: number, callback: (error?: E) => void) => void, callback?: AsyncResultArrayCallback<T, E>): void;
|
||||
export function transform<T, R, E = Error>(arr: T[], iteratee: (acc: R[], item: T, key: number, callback: (error?: E) => void) => void, callback?: AsyncResultArrayCallback<T, E>): void;
|
||||
export function transform<T, R, E = Error>(arr: T[], acc: R[], iteratee: (acc: R[], item: T, key: number, callback: (error?: E) => void) => void, callback?: AsyncResultArrayCallback<T, E>): void;
|
||||
|
||||
export function transform<T, R, E>(arr: {[key: string] : T}, iteratee: (acc: {[key: string] : R}, item: T, key: string, callback: (error?: E) => void) => void, callback?: AsyncResultObjectCallback<T, E>): void;
|
||||
export function transform<T, R, E>(arr: {[key: string] : T}, acc: {[key: string] : R}, iteratee: (acc: {[key: string] : R}, item: T, key: string, callback: (error?: E) => void) => void, callback?: AsyncResultObjectCallback<T, E>): void;
|
||||
export function transform<T, R, E = Error>(arr: {[key: string] : T}, iteratee: (acc: {[key: string] : R}, item: T, key: string, callback: (error?: E) => void) => void, callback?: AsyncResultObjectCallback<T, E>): void;
|
||||
export function transform<T, R, E = Error>(arr: {[key: string] : T}, acc: {[key: string] : R}, iteratee: (acc: {[key: string] : R}, item: T, key: string, callback: (error?: E) => void) => void, callback?: AsyncResultObjectCallback<T, E>): void;
|
||||
|
||||
export function race<T, E>(tasks: (AsyncFunction<T, E>)[], callback: AsyncResultCallback<T, E | Error>) : void;
|
||||
export function race<T, E = Error>(tasks: (AsyncFunction<T, E>)[], callback: AsyncResultCallback<T, E>) : void;
|
||||
|
||||
// Utils
|
||||
export function memoize(fn: Function, hasher?: Function): Function;
|
||||
|
||||
+79
-46
@@ -114,7 +114,7 @@ async.series([
|
||||
],
|
||||
function (err, results) { });
|
||||
|
||||
async.series<string,Error>([
|
||||
async.series<string>([
|
||||
function (callback) {
|
||||
callback(undefined, 'one');
|
||||
},
|
||||
@@ -138,7 +138,7 @@ async.series({
|
||||
},
|
||||
function (err, results) { });
|
||||
|
||||
async.series<number,Error>({
|
||||
async.series<number>({
|
||||
one: function (callback) {
|
||||
setTimeout(function () {
|
||||
callback(undefined, 1);
|
||||
@@ -178,7 +178,7 @@ async.parallel([
|
||||
],
|
||||
function (err, results) { });
|
||||
|
||||
async.parallel<string,Error>([
|
||||
async.parallel<string>([
|
||||
function (callback) {
|
||||
setTimeout(function () {
|
||||
callback(undefined, 'one');
|
||||
@@ -207,7 +207,7 @@ async.parallel({
|
||||
},
|
||||
function (err, results) { });
|
||||
|
||||
async.parallel<number,Error>({
|
||||
async.parallel<number>({
|
||||
one: function (callback) {
|
||||
setTimeout(function () {
|
||||
callback(undefined, 1);
|
||||
@@ -273,7 +273,7 @@ async.waterfall([
|
||||
], function (err, result) { });
|
||||
|
||||
|
||||
var q = async.queue<any,Error>(function (task: any, callback: (err?:Error,msg?:string) => void) {
|
||||
var q = async.queue<any>(function (task: any, callback: (err?:Error,msg?:string) => void) {
|
||||
console.log('hello ' + task.name);
|
||||
callback(undefined,'a message.');
|
||||
}, 2);
|
||||
@@ -293,7 +293,7 @@ q.push([{ name: 'baz' }, { name: 'bay' }, { name: 'bax' }], function (err) {
|
||||
console.log('finished processing bar');
|
||||
});
|
||||
|
||||
q.push<string,Error>({name: 'foo'}, function (err,msg) {
|
||||
q.push<string>({name: 'foo'}, function (err, msg) {
|
||||
console.log('foo finished with a message "'+ msg! + '"');
|
||||
});
|
||||
|
||||
@@ -330,7 +330,7 @@ q.resume();
|
||||
q.kill();
|
||||
|
||||
// tests for strongly typed tasks
|
||||
var q2 = async.queue<string,Error>(function (task: string, callback: () => void) {
|
||||
var q2 = async.queue<string>(function (task: string, callback: () => void) {
|
||||
console.log('Task: ' + task);
|
||||
callback();
|
||||
}, 1);
|
||||
@@ -356,7 +356,7 @@ q2.unshift(['task3', 'task4', 'task5'], function (error) {
|
||||
});
|
||||
|
||||
|
||||
var aq = async.queue<number, number, Error>(function (level: number, callback: (error?: Error, newLevel?: number) => void) {
|
||||
var aq = async.queue<number, number>(function (level: number, callback: (error?: Error, newLevel?: number) => void) {
|
||||
console.log('hello ' + level);
|
||||
callback(undefined, level+1);
|
||||
});
|
||||
@@ -387,14 +387,47 @@ cargo.push({ name: 'baz' }, function (err: Error) {
|
||||
|
||||
var filename = '';
|
||||
async.auto({
|
||||
get_data: function (callback: any) { },
|
||||
make_folder: function (callback: any) { },
|
||||
get_data: function (callback: AsyncResultCallback<any>) { },
|
||||
make_folder: function (callback: AsyncResultCallback<any>) { },
|
||||
//arrays with different types are not accepted by TypeScript.
|
||||
write_file: ['get_data', 'make_folder', <any>function (callback: any) {
|
||||
write_file: ['get_data', 'make_folder', <any>function (callback: AsyncResultCallback<any>) {
|
||||
callback(null, filename);
|
||||
}],
|
||||
//arrays with different types are not accepted by TypeScript.
|
||||
email_link: ['write_file', <any>function (callback: any, results: any) { }]
|
||||
email_link: ['write_file', <any>function (callback: AsyncResultCallback<any>, results: any) { }]
|
||||
});
|
||||
|
||||
async.auto({
|
||||
get_data: function (callback: AsyncResultCallback<any>) { },
|
||||
make_folder: function (callback: AsyncResultCallback<any>) { },
|
||||
//arrays with different types are not accepted by TypeScript.
|
||||
write_file: ['get_data', 'make_folder', <any>function (callback: AsyncResultCallback<any>) {
|
||||
callback(null, filename);
|
||||
}],
|
||||
//arrays with different types are not accepted by TypeScript.
|
||||
email_link: ['write_file', <any>function (callback: AsyncResultCallback<any>, results: any) { }]
|
||||
}, function (err, results) {
|
||||
console.log('finished auto');
|
||||
});
|
||||
|
||||
interface A {
|
||||
get_data: any;
|
||||
make_folder: any;
|
||||
write_file: any;
|
||||
email_link: any;
|
||||
}
|
||||
|
||||
async.auto<A>({
|
||||
get_data: function (callback: AsyncResultCallback<any>) { },
|
||||
make_folder: function (callback: AsyncResultCallback<any>) { },
|
||||
//arrays with different types are not accepted by TypeScript.
|
||||
write_file: ['get_data', 'make_folder', <any>function (callback: AsyncResultCallback<any>) {
|
||||
callback(null, filename);
|
||||
}],
|
||||
//arrays with different types are not accepted by TypeScript.
|
||||
email_link: ['write_file', <any>function (callback: AsyncResultCallback<any>, results: any) { }]
|
||||
}, 1, function (err, results) {
|
||||
console.log('finished auto');
|
||||
});
|
||||
|
||||
async.retry(3, function (callback, results) { }, function (err, result) { });
|
||||
@@ -459,10 +492,10 @@ async.dir(function (name: string, callback: any) {
|
||||
|
||||
// each
|
||||
|
||||
async.each<number,Error>({
|
||||
async.each<number>({
|
||||
"a": 1,
|
||||
"b": 2
|
||||
}, function(val: number, next: ErrorCallback<Error>): void {
|
||||
}, function(val: number, next: ErrorCallback): void {
|
||||
|
||||
setTimeout(function(): void {
|
||||
|
||||
@@ -478,10 +511,10 @@ async.each<number,Error>({
|
||||
|
||||
});
|
||||
|
||||
async.eachSeries<number, Error>({
|
||||
async.eachSeries<number>({
|
||||
"a": 1,
|
||||
"b": 2
|
||||
}, function(val: number, next: ErrorCallback<Error>): void {
|
||||
}, function(val: number, next: ErrorCallback): void {
|
||||
|
||||
setTimeout(function(): void {
|
||||
|
||||
@@ -497,14 +530,14 @@ async.eachSeries<number, Error>({
|
||||
|
||||
});
|
||||
|
||||
async.eachLimit<number, Error>({
|
||||
async.eachLimit<number>({
|
||||
"a": 1,
|
||||
"b": 2,
|
||||
"c": 3,
|
||||
"d": 4,
|
||||
"e": 5,
|
||||
"f": 6
|
||||
}, 2, function(val: number, next: ErrorCallback<Error>): void {
|
||||
}, 2, function(val: number, next: ErrorCallback): void {
|
||||
|
||||
setTimeout(function(): void {
|
||||
|
||||
@@ -522,10 +555,10 @@ async.eachLimit<number, Error>({
|
||||
|
||||
// forEachOf/eachOf
|
||||
|
||||
async.eachOf<number, Error>({
|
||||
async.eachOf<number>({
|
||||
"a": 1,
|
||||
"b": 2
|
||||
}, function(val: number, key: string, next: ErrorCallback<Error>): void {
|
||||
}, function(val: number, key: string, next: ErrorCallback): void {
|
||||
|
||||
setTimeout(function(): void {
|
||||
|
||||
@@ -541,10 +574,10 @@ async.eachOf<number, Error>({
|
||||
|
||||
});
|
||||
|
||||
async.forEachOfSeries<number, Error>({
|
||||
async.forEachOfSeries<number>({
|
||||
"a": 1,
|
||||
"b": 2
|
||||
}, function(val: number, key: string, next: ErrorCallback<Error>): void {
|
||||
}, function(val: number, key: string, next: ErrorCallback): void {
|
||||
|
||||
setTimeout(function(): void {
|
||||
|
||||
@@ -560,14 +593,14 @@ async.forEachOfSeries<number, Error>({
|
||||
|
||||
});
|
||||
|
||||
async.forEachOfLimit<number, Error>({
|
||||
async.forEachOfLimit<number>({
|
||||
"a": 1,
|
||||
"b": 2,
|
||||
"c": 3,
|
||||
"d": 4,
|
||||
"e": 5,
|
||||
"f": 6
|
||||
}, 2, function(val: number, key: string, next: ErrorCallback<Error>): void {
|
||||
}, 2, function(val: number, key: string, next: ErrorCallback): void {
|
||||
|
||||
setTimeout(function(): void {
|
||||
|
||||
@@ -585,11 +618,11 @@ async.forEachOfLimit<number, Error>({
|
||||
|
||||
// map
|
||||
|
||||
async.map<number, string, Error>({
|
||||
async.map<number, string>({
|
||||
"a": 1,
|
||||
"b": 2,
|
||||
"c": 3
|
||||
}, function(val: number, next: AsyncResultCallback<string, Error>): void {
|
||||
}, function(val: number, next: AsyncResultCallback<string>): void {
|
||||
|
||||
setTimeout(function(): void {
|
||||
|
||||
@@ -605,11 +638,11 @@ async.map<number, string, Error>({
|
||||
|
||||
});
|
||||
|
||||
async.mapSeries<number, string, Error>({
|
||||
async.mapSeries<number, string>({
|
||||
"a": 1,
|
||||
"b": 2,
|
||||
"c": 3
|
||||
}, function(val: number, next: AsyncResultCallback<string, Error>): void {
|
||||
}, function(val: number, next: AsyncResultCallback<string>): void {
|
||||
|
||||
setTimeout(function(): void {
|
||||
|
||||
@@ -625,14 +658,14 @@ async.mapSeries<number, string, Error>({
|
||||
|
||||
});
|
||||
|
||||
async.mapLimit<number, string, Error>({
|
||||
async.mapLimit<number, string>({
|
||||
"a": 1,
|
||||
"b": 2,
|
||||
"c": 3,
|
||||
"d": 4,
|
||||
"e": 5,
|
||||
"f": 6
|
||||
}, 2, function(val: number, next: AsyncResultCallback<string, Error>): void {
|
||||
}, 2, function(val: number, next: AsyncResultCallback<string>): void {
|
||||
|
||||
setTimeout(function(): void {
|
||||
|
||||
@@ -650,11 +683,11 @@ async.mapLimit<number, string, Error>({
|
||||
|
||||
// mapValues
|
||||
|
||||
async.mapValues<number, string, Error>({
|
||||
async.mapValues<number, string>({
|
||||
"a": 1,
|
||||
"b": 2,
|
||||
"c": 3
|
||||
}, function(val: number, key: string, next: AsyncResultCallback<string, Error>): void {
|
||||
}, function(val: number, key: string, next: AsyncResultCallback<string>): void {
|
||||
|
||||
setTimeout(function(): void {
|
||||
|
||||
@@ -670,11 +703,11 @@ async.mapValues<number, string, Error>({
|
||||
|
||||
});
|
||||
|
||||
async.mapValuesSeries<number, string, Error>({
|
||||
async.mapValuesSeries<number, string>({
|
||||
"a": 1,
|
||||
"b": 2,
|
||||
"c": 3
|
||||
}, function(val: number, key: string, next: AsyncResultCallback<string, Error>): void {
|
||||
}, function(val: number, key: string, next: AsyncResultCallback<string>): void {
|
||||
|
||||
setTimeout(function(): void {
|
||||
|
||||
@@ -692,11 +725,11 @@ async.mapValuesSeries<number, string, Error>({
|
||||
|
||||
// filter/select/reject
|
||||
|
||||
async.filter<number, Error>({
|
||||
async.filter<number>({
|
||||
"a": 1,
|
||||
"b": 2,
|
||||
"c": 3
|
||||
}, function(val: number, next: AsyncBooleanResultCallback<Error>): void {
|
||||
}, function(val: number, next: AsyncBooleanResultCallback): void {
|
||||
|
||||
setTimeout(function(): void {
|
||||
|
||||
@@ -712,11 +745,11 @@ async.filter<number, Error>({
|
||||
|
||||
});
|
||||
|
||||
async.reject<number, Error>({
|
||||
async.reject<number>({
|
||||
"a": 1,
|
||||
"b": 2,
|
||||
"c": 3
|
||||
}, function(val: number, next: AsyncBooleanResultCallback<Error>): void {
|
||||
}, function(val: number, next: AsyncBooleanResultCallback): void {
|
||||
|
||||
setTimeout(function(): void {
|
||||
|
||||
@@ -734,11 +767,11 @@ async.reject<number, Error>({
|
||||
|
||||
// concat
|
||||
|
||||
async.concat<string, string, Error>({
|
||||
async.concat<string, string>({
|
||||
"a": "1",
|
||||
"b": "2",
|
||||
"c": "3"
|
||||
}, function(item: string, next: AsyncResultCallback<string[], Error>): void {
|
||||
}, function(item: string, next: AsyncResultCallback<string[]>): void {
|
||||
|
||||
console.log(`async.concat: ${item}`);
|
||||
|
||||
@@ -752,11 +785,11 @@ async.concat<string, string, Error>({
|
||||
|
||||
// detect/find
|
||||
|
||||
async.detect<number, Error>({
|
||||
async.detect<number>({
|
||||
"a": 1,
|
||||
"b": 2,
|
||||
"c": 3
|
||||
}, function(item: number, next: AsyncBooleanResultCallback<Error>): void {
|
||||
}, function(item: number, next: AsyncBooleanResultCallback): void {
|
||||
|
||||
console.log(`async.detect/find: ${item}`);
|
||||
|
||||
@@ -777,11 +810,11 @@ async.detect<number, Error>({
|
||||
|
||||
// every/all
|
||||
|
||||
async.every<number,Error>({
|
||||
async.every<number>({
|
||||
"a": 1,
|
||||
"b": 2,
|
||||
"c": 3
|
||||
}, function(item: number, next: AsyncBooleanResultCallback<Error>): void {
|
||||
}, function(item: number, next: AsyncBooleanResultCallback): void {
|
||||
|
||||
console.log(`async.every/all: ${item}`);
|
||||
|
||||
@@ -795,11 +828,11 @@ async.every<number,Error>({
|
||||
|
||||
// some/any
|
||||
|
||||
async.some<number, Error>({
|
||||
async.some<number>({
|
||||
"a": 1,
|
||||
"b": 2,
|
||||
"c": 3
|
||||
}, function(item: number, next: AsyncBooleanResultCallback<Error>): void {
|
||||
}, function(item: number, next: AsyncBooleanResultCallback): void {
|
||||
|
||||
console.log(`async.some/any: ${item}`);
|
||||
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ declare class Session {
|
||||
readonly token: string;
|
||||
readonly createdAt: Date;
|
||||
readonly expiresAt: Date;
|
||||
|
||||
|
||||
constructor(token: string, createdAt: Date, expiresAt: Date);
|
||||
toCrowd(): SessionObj;
|
||||
static fromCrowd(obj: SessionObj): Session;
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ export interface Settings {
|
||||
readonly application: {
|
||||
readonly name: string;
|
||||
readonly password: string;
|
||||
}
|
||||
};
|
||||
readonly nesting?: boolean;
|
||||
readonly sessionTimeout?: number;
|
||||
readonly debug?: boolean;
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
"await-promise": [true, "CancellablePromise"],
|
||||
"indent": [true, "spaces", 4],
|
||||
"max-line-length": [true, 100],
|
||||
"no-any": true
|
||||
"no-any": true,
|
||||
|
||||
// TODOs
|
||||
"no-declare-current-package": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
import * as auth from 'auth-header';
|
||||
|
||||
const basic: string = auth.format('Basic');
|
||||
const basic2: string = auth.format({scheme: 'Basic'});
|
||||
|
||||
const parsed: {scheme: string, token: null | string | string[]} = auth.parse('');
|
||||
Vendored
+27
@@ -0,0 +1,27 @@
|
||||
// Type definitions for auth-header 1.0
|
||||
// Project: https://github.com/izaakschroeder/auth-header
|
||||
// Definitions by: ForbesLindesay <https://github.com/ForbesLindesay>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.1
|
||||
|
||||
type Params =
|
||||
| Array<[string, string | ReadonlyArray<string>]>
|
||||
| {[key: string]: string | ReadonlyArray<string>};
|
||||
export {Params};
|
||||
|
||||
export interface TokenOptions {
|
||||
scheme: string;
|
||||
token?: string;
|
||||
params?: Params;
|
||||
}
|
||||
|
||||
export interface Token {
|
||||
scheme: string;
|
||||
params: {[key: string]: string | string[]};
|
||||
token: null | string | string[];
|
||||
}
|
||||
|
||||
export function format(token: TokenOptions): string;
|
||||
export function format(scheme: string, token?: string, params?: Params): string;
|
||||
|
||||
export function parse(header: string): Token;
|
||||
@@ -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",
|
||||
"auth-header-tests.ts"
|
||||
]
|
||||
}
|
||||
Vendored
+46
-12
@@ -4,6 +4,7 @@
|
||||
// Matt Durrant <https://github.com/mdurrant>
|
||||
// Peter Blazejewicz <https://github.com/peterblazejewicz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
export as namespace auth0;
|
||||
|
||||
@@ -172,7 +173,7 @@ export class WebAuth {
|
||||
*
|
||||
* @param callback: any(err, token_payload)
|
||||
*/
|
||||
parseHash(callback: Auth0Callback<Auth0DecodedHash>): void;
|
||||
parseHash(callback: Auth0Callback<Auth0DecodedHash | null, Auth0ParseHashError>): void;
|
||||
|
||||
/**
|
||||
* Parse the url hash and extract the returned tokens depending on the transaction.
|
||||
@@ -183,7 +184,7 @@ export class WebAuth {
|
||||
*
|
||||
* @param callback: any(err, token_payload)
|
||||
*/
|
||||
parseHash(options: ParseHashOptions, callback: Auth0Callback<Auth0DecodedHash>): void;
|
||||
parseHash(options: ParseHashOptions, callback: Auth0Callback<Auth0DecodedHash | null, Auth0ParseHashError>): void;
|
||||
|
||||
/**
|
||||
* Decodes the id_token and verifies the nonce.
|
||||
@@ -482,7 +483,7 @@ export class CrossOriginAuthentication {
|
||||
callback(): void;
|
||||
}
|
||||
|
||||
export type Auth0Callback<T> = (error: null | Auth0Error, result: T) => void;
|
||||
export type Auth0Callback<T, E = Auth0Error> = (error: null | E, result: T) => void;
|
||||
|
||||
export interface TokenProvider {
|
||||
enableCache?: boolean;
|
||||
@@ -522,18 +523,51 @@ export interface PasswordlessAuthOptions {
|
||||
email: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* These are error codes defined by the auth0-js lib.
|
||||
*/
|
||||
export type LibErrorCodes = 'timeout' | 'request_error' | 'invalid_token';
|
||||
|
||||
/**
|
||||
* The user was not logged in at Auth0, so silent authentication is not possible.
|
||||
*/
|
||||
export type LoginRequiredErrorCode = 'login_required';
|
||||
|
||||
/**
|
||||
* The user was logged in at Auth0 and has authorized the application, but needs to
|
||||
* be redirected elsewhere before authentication can be completed; for example, when
|
||||
* using a redirect rule.
|
||||
*/
|
||||
export type InteractionRequiredErrorCode = 'interaction_required';
|
||||
|
||||
/**
|
||||
* The user was logged in at Auth0, but needs to give consent to authorize the application.
|
||||
*/
|
||||
export type ConsentRequiredErrorCode = 'consent_required';
|
||||
|
||||
/**
|
||||
* These are error codes defined by the OpenID Connect specification.
|
||||
*/
|
||||
export type SpecErrorCodes =
|
||||
LoginRequiredErrorCode |
|
||||
InteractionRequiredErrorCode |
|
||||
ConsentRequiredErrorCode |
|
||||
'account_selection_required' |
|
||||
'invalid_request_uri' |
|
||||
'invalid_request_object' |
|
||||
'request_not_supported' |
|
||||
'request_uri_not_supported' |
|
||||
'registration_not_supported';
|
||||
|
||||
export interface Auth0Error {
|
||||
error?: any;
|
||||
errorDescription?: string;
|
||||
code?: string;
|
||||
description?: string;
|
||||
name?: string;
|
||||
policy?: string;
|
||||
original?: any;
|
||||
statusCode?: number;
|
||||
statusText?: string;
|
||||
error: LibErrorCodes | SpecErrorCodes | string;
|
||||
errorDescription: string;
|
||||
}
|
||||
|
||||
export type Auth0ParseHashError = Auth0Error & {
|
||||
state?: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* The contents of the authResult object returned by {@link WebAuth#parseHash }
|
||||
*/
|
||||
|
||||
Vendored
+2
@@ -5,6 +5,7 @@
|
||||
// Larry Faudree <https://github.com/lfaudreejr>
|
||||
// Will Caulfield <https://github.com/willcaul>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.7
|
||||
|
||||
/// <reference types="auth0-js" />
|
||||
|
||||
@@ -98,6 +99,7 @@ interface Auth0LockAuthOptions {
|
||||
params?: Auth0LockAuthParamsOptions;
|
||||
redirect?: boolean;
|
||||
redirectUrl?: string;
|
||||
responseMode?: string;
|
||||
responseType?: string;
|
||||
sso?: boolean;
|
||||
audience?: string;
|
||||
|
||||
@@ -203,3 +203,26 @@ management.linkUsers('primaryId', { user_id: 'secondaryId' })
|
||||
management.linkUsers('primaryId', { user_id: 'secondaryId' },
|
||||
(err: Error, result: any) => {});
|
||||
|
||||
// Get all clients (with promise)
|
||||
management.getClients()
|
||||
.then((clients: auth0.Client[]) => {
|
||||
console.log(clients);
|
||||
})
|
||||
.catch((err) => {
|
||||
// Handle the error
|
||||
});
|
||||
|
||||
//Get all clients (with callback)
|
||||
management.getClients((err: Error, clients: auth0.Client[]) => {});
|
||||
|
||||
// Get all clients with params (with promise)
|
||||
management.getClients({fields:['name','client_metadata'], include_fields:true})
|
||||
.then((clients: auth0.Client[]) => {
|
||||
console.log(clients);
|
||||
})
|
||||
.catch((err) => {
|
||||
// Handle the error
|
||||
});
|
||||
|
||||
// Get all cients with params (with callback)
|
||||
management.getClients({fields:['name','client_metadata'], include_fields:true}, (err:Error, clients:auth0.Client[]) => {});
|
||||
|
||||
Vendored
+16
-3
@@ -588,7 +588,19 @@ export interface ImpersonateSettingOptions {
|
||||
clientId?: string;
|
||||
}
|
||||
|
||||
|
||||
export type ClientAppType = 'native' | 'spa' | 'regular_web' | 'non_interactive' | 'rms' | 'box' |
|
||||
'cloudbees' | 'concur' | 'dropbox' | 'mscrm' | 'echosign' | 'egnyte' | 'newrelic' | 'office365' |
|
||||
'salesforce' | 'sentry' | 'sharepoint' | 'slack' | 'springcm' | 'zendesk' | 'zoom';
|
||||
export interface GetClientsOptions {
|
||||
fields?: string[];
|
||||
include_fields?: boolean;
|
||||
page?: number;
|
||||
per_page?: number;
|
||||
include_totals?: boolean;
|
||||
is_global?: boolean;
|
||||
is_first_party?: boolean;
|
||||
app_type?: ClientAppType[];
|
||||
}
|
||||
|
||||
export class AuthenticationClient {
|
||||
|
||||
@@ -661,8 +673,9 @@ export class ManagementClient {
|
||||
|
||||
|
||||
// Clients
|
||||
getClients(): Promise<Client[]>;
|
||||
getClients(cb: (err: Error, clients: Client[]) => void): void;
|
||||
getClients(params?: GetClientsOptions): Promise<Client[]>;
|
||||
getClients(cb: (err: Error, clients: Client[]) => void ): void;
|
||||
getClients(params: GetClientsOptions, cb: (err: Error, clients: Client[]) => void ): void;
|
||||
|
||||
getClient(params: ClientParams): Promise<Client>;
|
||||
getClient(params: ClientParams, cb: (err: Error, client: Client) => void): void;
|
||||
|
||||
Vendored
+2
@@ -190,6 +190,8 @@ declare namespace autobahn {
|
||||
export class Connection {
|
||||
constructor(options?: IConnectionOptions);
|
||||
|
||||
isOpen: boolean;
|
||||
|
||||
open(): void;
|
||||
|
||||
close(reason?: string, message?: string): void;
|
||||
|
||||
@@ -8,6 +8,7 @@ declare let error: Error;
|
||||
declare let bool: boolean;
|
||||
declare let boolOrUndefined: boolean | undefined;
|
||||
declare let apiGwEvtReqCtx: AWSLambda.APIGatewayEventRequestContext;
|
||||
declare let apiGwEvtReqCtxOpt: AWSLambda.APIGatewayEventRequestContext | null | undefined;
|
||||
declare let apiGwEvt: AWSLambda.APIGatewayEvent;
|
||||
declare let customAuthorizerEvt: AWSLambda.CustomAuthorizerEvent;
|
||||
declare let clientCtx: AWSLambda.ClientContext;
|
||||
@@ -102,11 +103,13 @@ str = apiGwEvtReqCtx.resourcePath;
|
||||
/* API Gateway Event */
|
||||
strOrNull = apiGwEvt.body;
|
||||
str = apiGwEvt.headers["example"];
|
||||
str = apiGwEvt.multiValueHeaders["example"][0];
|
||||
str = apiGwEvt.httpMethod;
|
||||
bool = apiGwEvt.isBase64Encoded;
|
||||
str = apiGwEvt.path;
|
||||
str = apiGwEvt.pathParameters!["example"];
|
||||
str = apiGwEvt.queryStringParameters!["example"];
|
||||
str = apiGwEvt.multiValueQueryStringParameters!["example"][0];
|
||||
str = apiGwEvt.stageVariables!["example"];
|
||||
apiGwEvtReqCtx = apiGwEvt.requestContext;
|
||||
str = apiGwEvt.resource;
|
||||
@@ -115,10 +118,12 @@ str = apiGwEvt.resource;
|
||||
str = customAuthorizerEvt.type;
|
||||
str = customAuthorizerEvt.methodArn;
|
||||
strOrUndefined = customAuthorizerEvt.authorizationToken;
|
||||
str = apiGwEvt.pathParameters!["example"];
|
||||
str = apiGwEvt.queryStringParameters!["example"];
|
||||
str = apiGwEvt.stageVariables!["example"];
|
||||
apiGwEvtReqCtx = apiGwEvt.requestContext;
|
||||
str = customAuthorizerEvt.headers!["example"];
|
||||
str = customAuthorizerEvt.multiValueHeaders!["example"][0];
|
||||
str = customAuthorizerEvt.pathParameters!["example"];
|
||||
str = customAuthorizerEvt.queryStringParameters!["example"];
|
||||
str = customAuthorizerEvt.multiValueQueryStringParameters!["example"][0];
|
||||
apiGwEvtReqCtxOpt = customAuthorizerEvt.requestContext;
|
||||
|
||||
/* DynamoDB Stream Event */
|
||||
const dynamoDBStreamEvent: AWSLambda.DynamoDBStreamEvent = {
|
||||
@@ -245,6 +250,9 @@ num = proxyResult.statusCode;
|
||||
proxyResult.headers!["example"] = str;
|
||||
proxyResult.headers!["example"] = bool;
|
||||
proxyResult.headers!["example"] = num;
|
||||
proxyResult.multiValueHeaders!["example"][0] = str;
|
||||
proxyResult.multiValueHeaders!["example"][0] = bool;
|
||||
proxyResult.multiValueHeaders!["example"][0] = num;
|
||||
boolOrUndefined = proxyResult.isBase64Encoded;
|
||||
str = proxyResult.body;
|
||||
|
||||
@@ -383,6 +391,8 @@ cognitoUserPoolEvent.triggerSource === "TokenGeneration_Authentication";
|
||||
cognitoUserPoolEvent.triggerSource === "TokenGeneration_NewPasswordChallenge";
|
||||
cognitoUserPoolEvent.triggerSource === "TokenGeneration_AuthenticateDevice";
|
||||
cognitoUserPoolEvent.triggerSource === "TokenGeneration_RefreshTokens";
|
||||
cognitoUserPoolEvent.triggerSource === "UserMigration_Authentication";
|
||||
cognitoUserPoolEvent.triggerSource === "UserMigration_ForgotPassword";
|
||||
str = cognitoUserPoolEvent.region;
|
||||
str = cognitoUserPoolEvent.userPoolId;
|
||||
strOrUndefined = cognitoUserPoolEvent.userName;
|
||||
@@ -404,6 +414,7 @@ strOrUndefined = cognitoUserPoolEvent.request.session![0].challengeMetadata;
|
||||
strOrUndefined = cognitoUserPoolEvent.request.challengeName;
|
||||
str = cognitoUserPoolEvent.request.privateChallengeParameters!["answer"];
|
||||
str = cognitoUserPoolEvent.request.challengeAnswer!;
|
||||
strOrUndefined = cognitoUserPoolEvent.request.password;
|
||||
boolOrUndefined = cognitoUserPoolEvent.response.answerCorrect;
|
||||
strOrUndefined = cognitoUserPoolEvent.response.smsMessage;
|
||||
strOrUndefined = cognitoUserPoolEvent.response.emailMessage;
|
||||
@@ -415,6 +426,14 @@ str = cognitoUserPoolEvent.response.publicChallengeParameters!["captchaUrl"];
|
||||
str = cognitoUserPoolEvent.response.privateChallengeParameters!["answer"];
|
||||
strOrUndefined = cognitoUserPoolEvent.response.challengeMetadata;
|
||||
boolOrUndefined = cognitoUserPoolEvent.response.answerCorrect;
|
||||
str = cognitoUserPoolEvent.response.userAttributes!["username"];
|
||||
cognitoUserPoolEvent.response.finalUserStatus === "CONFIRMED";
|
||||
cognitoUserPoolEvent.response.finalUserStatus === "RESET_REQUIRED";
|
||||
cognitoUserPoolEvent.response.messageAction === "SUPPRESS";
|
||||
cognitoUserPoolEvent.response.desiredDeliveryMediums === ["EMAIL"];
|
||||
cognitoUserPoolEvent.response.desiredDeliveryMediums === ["SMS"];
|
||||
cognitoUserPoolEvent.response.desiredDeliveryMediums === ["SMS", "EMAIL"];
|
||||
boolOrUndefined = cognitoUserPoolEvent.response.forceAliasCreation;
|
||||
|
||||
// CloudFormation Custom Resource
|
||||
switch (cloudformationCustomResourceEvent.RequestType) {
|
||||
|
||||
Vendored
+18
-1
@@ -22,6 +22,8 @@
|
||||
// Louis Larry <https://github.com/louislarry>
|
||||
// Daniel Papukchiev <https://github.com/dpapukchiev>
|
||||
// Oliver Hookins <https://github.com/ohookins>
|
||||
// Trevor Leach <https://github.com/trevor-leach>
|
||||
// James Gregory <https://github.com/jagregory>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
@@ -58,11 +60,13 @@ export interface APIGatewayEventRequestContext {
|
||||
export interface APIGatewayProxyEvent {
|
||||
body: string | null;
|
||||
headers: { [name: string]: string };
|
||||
multiValueHeaders: { [name: string]: string[] };
|
||||
httpMethod: string;
|
||||
isBase64Encoded: boolean;
|
||||
path: string;
|
||||
pathParameters: { [name: string]: string } | null;
|
||||
queryStringParameters: { [name: string]: string } | null;
|
||||
multiValueQueryStringParameters: { [name: string]: string[] } | null;
|
||||
stageVariables: { [name: string]: string } | null;
|
||||
requestContext: APIGatewayEventRequestContext;
|
||||
resource: string;
|
||||
@@ -75,8 +79,10 @@ export interface CustomAuthorizerEvent {
|
||||
methodArn: string;
|
||||
authorizationToken?: string;
|
||||
headers?: { [name: string]: string };
|
||||
multiValueHeaders?: { [name: string]: string[] };
|
||||
pathParameters?: { [name: string]: string } | null;
|
||||
queryStringParameters?: { [name: string]: string } | null;
|
||||
multiValueQueryStringParameters?: { [name: string]: string[] } | null;
|
||||
requestContext?: APIGatewayEventRequestContext;
|
||||
}
|
||||
|
||||
@@ -234,7 +240,9 @@ export interface CognitoUserPoolTriggerEvent {
|
||||
| "TokenGeneration_Authentication"
|
||||
| "TokenGeneration_NewPasswordChallenge"
|
||||
| "TokenGeneration_AuthenticateDevice"
|
||||
| "TokenGeneration_RefreshTokens";
|
||||
| "TokenGeneration_RefreshTokens"
|
||||
| "UserMigration_Authentication"
|
||||
| "UserMigration_ForgotPassword";
|
||||
region: string;
|
||||
userPoolId: string;
|
||||
userName?: string;
|
||||
@@ -256,6 +264,7 @@ export interface CognitoUserPoolTriggerEvent {
|
||||
challengeName?: string;
|
||||
privateChallengeParameters?: { [key: string]: string };
|
||||
challengeAnswer?: string;
|
||||
password?: string;
|
||||
};
|
||||
response: {
|
||||
autoConfirmUser?: boolean;
|
||||
@@ -269,6 +278,11 @@ export interface CognitoUserPoolTriggerEvent {
|
||||
privateChallengeParameters?: { [key: string]: string };
|
||||
challengeMetadata?: string;
|
||||
answerCorrect?: boolean;
|
||||
userAttributes?: { [key: string]: string };
|
||||
finalUserStatus?: "CONFIRMED" | "RESET_REQUIRED";
|
||||
messageAction?: "SUPPRESS";
|
||||
desiredDeliveryMediums?: Array<"EMAIL" | "SMS">;
|
||||
forceAliasCreation?: boolean;
|
||||
};
|
||||
}
|
||||
export type CognitoUserPoolEvent = CognitoUserPoolTriggerEvent;
|
||||
@@ -433,6 +447,9 @@ export interface APIGatewayProxyResult {
|
||||
headers?: {
|
||||
[header: string]: boolean | number | string;
|
||||
};
|
||||
multiValueHeaders?: {
|
||||
[header: string]: Array<boolean | number | string>;
|
||||
};
|
||||
body: string;
|
||||
isBase64Encoded?: boolean;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
|
||||
+1
@@ -2,6 +2,7 @@
|
||||
// Project: https://github.com/sandrinodimattia/axios-token-interceptor#readme
|
||||
// Definitions by: Mike Dodge <https://github.com/innovation-team>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
import { AxiosRequestConfig } from 'axios';
|
||||
|
||||
|
||||
@@ -2,14 +2,21 @@
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
// All are TODOs
|
||||
"eofline": false,
|
||||
"adjacent-overload-signatures": false,
|
||||
"array-type": false,
|
||||
"ban-types": false,
|
||||
"comment-format": false,
|
||||
"dt-header": false,
|
||||
"eofline": false,
|
||||
"max-line-length": false,
|
||||
"member-access": false,
|
||||
"no-consecutive-blank-lines": false,
|
||||
"no-empty-interface": false,
|
||||
"no-namespace": false,
|
||||
"no-unnecessary-class": false,
|
||||
"no-useless-files": false,
|
||||
"no-var": false,
|
||||
"semicolon": false
|
||||
"semicolon": false,
|
||||
"space-before-function-paren": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
import express = require('express');
|
||||
import basicAuth = require('basicauth-middleware');
|
||||
|
||||
const app = express();
|
||||
|
||||
app.use(basicAuth("username", "password", "realm"));
|
||||
app.use(basicAuth([["username", "password"]]));
|
||||
|
||||
function checkSync(username: string, password: string): boolean {
|
||||
return username === "user" && password === "pass";
|
||||
}
|
||||
function checkCallback(username: string, password: string, callback: (err: Error|null, authorized: boolean) => void): void {
|
||||
callback(null, username === "user" && password === "pass");
|
||||
}
|
||||
function checkPromise(username: string, password: string): Promise<boolean> {
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
|
||||
app.use(basicAuth(checkSync));
|
||||
app.use(basicAuth(checkCallback));
|
||||
app.use(basicAuth(checkPromise));
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// Type definitions for basicauth-middleware 3.1
|
||||
// Project: https://github.com/nchaulet/basicauth-middleware
|
||||
// Definitions by: My Self <https://github.com/nchaulet>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
import { RequestHandler } from "express";
|
||||
type checkFunctionSync = (username: string, password: string) => boolean;
|
||||
type checkFunctionCallback = (username: string, password: string, callback: (err: Error|null, authorized: boolean) => void) => void;
|
||||
type checkFunctionPromise = (username: string, password: string) => PromiseLike<boolean>;
|
||||
type CheckFunction = checkFunctionSync | checkFunctionPromise | checkFunctionCallback;
|
||||
|
||||
declare function basicAuth(checkFnOrUsers: Array<[string, string]>|CheckFunction, realm?: string): RequestHandler;
|
||||
declare function basicAuth(username: string, password: string, realm?: string): RequestHandler;
|
||||
|
||||
export = basicAuth;
|
||||
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"basicauth-middleware-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Vendored
+1
-1
@@ -2,7 +2,7 @@
|
||||
// Project: https://github.com/hapijs/bell
|
||||
// Definitions by: Simon Schick <https://github.com/SimonSchick>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.7
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import { Server, Request, Plugin, AuthCredentials } from 'hapi';
|
||||
|
||||
|
||||
Vendored
+41
@@ -1,6 +1,7 @@
|
||||
// Type definitions for better-scroll 1.12
|
||||
// Project: https://github.com/ustbhuangyi/better-scroll
|
||||
// Definitions by: cloudstone <https://github.com/stoneChen>
|
||||
// jack <https://github.com/cnjack>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
// TypeScript Version: 2.2
|
||||
@@ -42,6 +43,24 @@ export interface PullUpOption {
|
||||
threshold: number;
|
||||
}
|
||||
|
||||
export interface MouseWheelOption {
|
||||
speed: number;
|
||||
invert: boolean;
|
||||
easeTime: number;
|
||||
}
|
||||
|
||||
export interface ZoomOption {
|
||||
start: number;
|
||||
min: number;
|
||||
max: number;
|
||||
}
|
||||
|
||||
export interface InfinityOption {
|
||||
fetch: (count: number) => void;
|
||||
render: (item: any, div: Element) => Element;
|
||||
createTombstone: () => Element;
|
||||
}
|
||||
|
||||
export interface BounceObjectOption {
|
||||
top?: boolean;
|
||||
bottom?: boolean;
|
||||
@@ -49,6 +68,10 @@ export interface BounceObjectOption {
|
||||
right?: boolean;
|
||||
}
|
||||
|
||||
export interface DoubleClick {
|
||||
delay: number;
|
||||
}
|
||||
|
||||
export interface EaseOption {
|
||||
swipe?: {
|
||||
style: string;
|
||||
@@ -73,6 +96,7 @@ export interface BsOption {
|
||||
directionLockThreshold: number;
|
||||
eventPassthrough: string | boolean;
|
||||
click: boolean;
|
||||
dblclick: boolean | DoubleClick;
|
||||
tap: boolean;
|
||||
bounce: boolean | BounceObjectOption;
|
||||
bounceTime: number;
|
||||
@@ -140,6 +164,23 @@ export interface BsOption {
|
||||
* }
|
||||
*/
|
||||
pullUpLoad: Partial<PullUpOption> | boolean;
|
||||
|
||||
// mouseWheel: {
|
||||
// speed: 20,
|
||||
// invert: false,
|
||||
// easeTime: 300
|
||||
// }
|
||||
mouseWheel: Partial<MouseWheelOption> | boolean;
|
||||
|
||||
// zoom: {
|
||||
// start: 1,
|
||||
// min: 1,
|
||||
// max: 4
|
||||
// }
|
||||
zoom: Partial<ZoomOption> | boolean;
|
||||
|
||||
// https://ustbhuangyi.github.io/better-scroll/doc/zh-hans/options-advanced.html
|
||||
infinity: Partial<InfinityOption> | boolean;
|
||||
}
|
||||
|
||||
export interface Position {
|
||||
|
||||
Vendored
+1
-1
@@ -45,7 +45,7 @@ interface ReductionContext {
|
||||
declare class BN {
|
||||
constructor(
|
||||
number: number | string | number[] | Buffer | BN,
|
||||
base?: number,
|
||||
base?: number | 'hex',
|
||||
endian?: Endianness
|
||||
);
|
||||
constructor(
|
||||
|
||||
@@ -144,12 +144,12 @@ const boomifiedError = Boom.boomify(new Error('test'), { statusCode: 400, messag
|
||||
|
||||
// isBoom
|
||||
|
||||
const isBoomError = new Boom('test')
|
||||
const isBoomError = new Boom('test');
|
||||
|
||||
Boom.isBoom(isBoomError);
|
||||
|
||||
const maybeBoom = <any>new Boom('test');
|
||||
if(Boom.isBoom(maybeBoom)) {
|
||||
const maybeBoom = <any> new Boom('test');
|
||||
if (Boom.isBoom(maybeBoom)) {
|
||||
// isBoom is a type guard that allows accessing these properties:
|
||||
maybeBoom.output.headers;
|
||||
}
|
||||
@@ -183,7 +183,8 @@ interface CustomPayload extends Boom.Payload {
|
||||
/**
|
||||
* Test assignment of custom error data:
|
||||
*/
|
||||
const errorWithData = Boom.badImplementation('', { custom1: 'test', customType: 'Custom1', isCustom: true } as CustomData1);
|
||||
// tslint:disable-next-line:no-object-literal-type-assertion
|
||||
const errorWithData = Boom.badImplementation('', <CustomData1> { custom1: 'test', customType: 'Custom1', isCustom: true });
|
||||
const errorWithNoExplicitDataType: Boom = errorWithData; // can assign to error without explicit data type
|
||||
const errorWithExplicitType: Boom<CustomData> = errorWithData; // can assign to union data type
|
||||
const errorWithConcreteCustomData: Boom<CustomData1> = errorWithData; // can assign to concrete data type
|
||||
|
||||
Vendored
+86
-63
@@ -1,4 +1,4 @@
|
||||
// Type definitions for boom 7.2.0
|
||||
// Type definitions for boom 7.2
|
||||
// Project: https://github.com/hapijs/boom
|
||||
// Definitions by: Igor Rogatty <https://github.com/rogatty>
|
||||
// AJP <https://github.com/AJamesPhillips>
|
||||
@@ -10,28 +10,31 @@
|
||||
|
||||
export = Boom;
|
||||
/**
|
||||
* boom provides a set of utilities for returning HTTP errors. Each utility returns a Boom error response object (instance of Error) which includes the following properties:
|
||||
* @see {@link https://github.com/hapijs/boom#boom}
|
||||
*/
|
||||
* boom provides a set of utilities for returning HTTP errors. Each utility returns a Boom error response object (instance of Error) which includes the following properties:
|
||||
* @see {@link https://github.com/hapijs/boom#boom}
|
||||
*/
|
||||
declare class Boom<Data = any> extends Error {
|
||||
|
||||
/** Creates a new Boom object using the provided message and then calling boomify() to decorate the error with the Boom properties. */
|
||||
constructor(message?: string | Error, options?: Boom.Options<Data>);
|
||||
/** isBoom - if true, indicates this is a Boom object instance. */
|
||||
isBoom: boolean;
|
||||
/** isServer - convenience bool indicating status code >= 500. */
|
||||
isServer: boolean;
|
||||
/** message - the error message. */
|
||||
message: string;
|
||||
/** output - the formatted response. Can be directly manipulated after object construction to return a custom error response. Allowed root keys: */
|
||||
output: Boom.Output;
|
||||
/** reformat() - rebuilds error.output using the other object properties. */
|
||||
reformat: () => string;
|
||||
/** "If message is unset, the 'error' segment of the header will not be present and isMissing will be true on the error object." mentioned in @see {@link https://github.com/hapijs/boom#boomunauthorizedmessage-scheme-attributes} */
|
||||
isMissing?: boolean;
|
||||
/** https://github.com/hapijs/boom#createstatuscode-message-data and https://github.com/hapijs/boom/blob/v4.3.0/lib/index.js#L99 */
|
||||
data: Data;
|
||||
}
|
||||
/** Creates a new Boom object using the provided message and then calling boomify() to decorate the error with the Boom properties. */
|
||||
constructor(message?: string | Error, options?: Boom.Options<Data>);
|
||||
/** isBoom - if true, indicates this is a Boom object instance. */
|
||||
isBoom: boolean;
|
||||
/** isServer - convenience bool indicating status code >= 500. */
|
||||
isServer: boolean;
|
||||
/** message - the error message. */
|
||||
message: string;
|
||||
/** output - the formatted response. Can be directly manipulated after object construction to return a custom error response. Allowed root keys: */
|
||||
output: Boom.Output;
|
||||
/** reformat() - rebuilds error.output using the other object properties. */
|
||||
reformat(): string;
|
||||
/**
|
||||
* "If message is unset, the 'error' segment of the header will not be present and
|
||||
* isMissing will be true on the error object." mentioned in
|
||||
* @see {@link https://github.com/hapijs/boom#boomunauthorizedmessage-scheme-attributes}
|
||||
*/
|
||||
isMissing?: boolean;
|
||||
/** https://github.com/hapijs/boom#createstatuscode-message-data and https://github.com/hapijs/boom/blob/v4.3.0/lib/index.js#L99 */
|
||||
data: Data;
|
||||
}
|
||||
declare namespace Boom {
|
||||
interface Options<Data> {
|
||||
/** statusCode - the HTTP status code. Defaults to 500 if no status code is already set. */
|
||||
@@ -44,20 +47,32 @@ declare namespace Boom {
|
||||
ctor?: any;
|
||||
/** message - error message string. If the error already has a message, the provided message is added as a prefix. Defaults to no message. */
|
||||
message?: string;
|
||||
/** override - if false, the err provided is a Boom object, and a statusCode or message are provided, the values are ignored. Defaults to true (apply the provided statusCode and message options to the error regardless of its type, Error or Boom object). */
|
||||
/**
|
||||
* override - if false, the err provided is a Boom object, and a statusCode or message are
|
||||
* provided, the values are ignored. Defaults to true (apply the provided statusCode and
|
||||
* message options to the error regardless of its type, Error or Boom object).
|
||||
*/
|
||||
override?: boolean;
|
||||
}
|
||||
|
||||
interface Output {
|
||||
/** statusCode - the HTTP status code (typically 4xx or 5xx). */
|
||||
statusCode: number;
|
||||
/** headers - an object containing any HTTP headers where each key is a header name and value is the header content. (Limited value type to string https://github.com/hapijs/boom/issues/151 ) */
|
||||
/**
|
||||
* headers - an object containing any HTTP headers where each key is a header name and
|
||||
* value is the header content. (Limited value type to string
|
||||
* https://github.com/hapijs/boom/issues/151 )
|
||||
*/
|
||||
headers: {[index: string]: string};
|
||||
/** payload - the formatted object used as the response payload (stringified). Can be directly manipulated but any changes will be lost if reformat() is called. Any content allowed and by default includes the following content: */
|
||||
/**
|
||||
* payload - the formatted object used as the response payload (stringified).
|
||||
* Can be directly manipulated but any changes will be lost if reformat() is called.
|
||||
* Any content allowed and by default includes the following content:
|
||||
*/
|
||||
payload: Payload;
|
||||
}
|
||||
|
||||
interface Payload {
|
||||
interface Payload {
|
||||
/** statusCode - the HTTP status code, derived from error.output.statusCode. */
|
||||
statusCode: number;
|
||||
/** error - the HTTP status message (e.g. 'Bad Request', 'Internal Server Error') derived from statusCode. */
|
||||
@@ -79,13 +94,13 @@ declare namespace Boom {
|
||||
* @param options optional additional options
|
||||
* @see {@link https://github.com/hapijs/boom#boomifyerror-options}
|
||||
*/
|
||||
function boomify(error: Error, options?: { statusCode?: number, message?: string, override?: boolean }): Boom<null>;
|
||||
function boomify(error: Error, options?: { statusCode?: number, message?: string, override?: boolean }): Boom<null>;
|
||||
|
||||
/**
|
||||
* Identifies whether an error is a Boom object. Same as calling instanceof Boom.
|
||||
* @param error the error object to identify.
|
||||
*/
|
||||
function isBoom(error: Error): error is Boom
|
||||
function isBoom(error: Error): error is Boom;
|
||||
|
||||
// 4xx
|
||||
/**
|
||||
@@ -94,7 +109,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boombadrequestmessage-data}
|
||||
*/
|
||||
function badRequest<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
function badRequest<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 401 Unauthorized error
|
||||
@@ -102,13 +117,21 @@ declare namespace Boom {
|
||||
* @param scheme can be one of the following:
|
||||
* * an authentication scheme name
|
||||
* * an array of string values. These values will be separated by ', ' and set to the 'WWW-Authenticate' header.
|
||||
* @param attributes an object of values to use while setting the 'WWW-Authenticate' header. This value is only used when scheme is a string, otherwise it is ignored. Every key/value pair will be included in the 'WWW-Authenticate' in the format of 'key="value"' as well as in the response payload under the attributes key. Alternatively value can be a string which is use to set the value of the scheme, for example setting the token value for negotiate header. If string is used message parameter must be null. null and undefined will be replaced with an empty string. If attributes is set, message will be used as the 'error' segment of the 'WWW-Authenticate' header. If message is unset, the 'error' segment of the header will not be present and isMissing will be true on the error object.
|
||||
* @param attributes an object of values to use while setting the 'WWW-Authenticate' header.
|
||||
* This value is only used when scheme is a string, otherwise it is ignored.
|
||||
* Every key/value pair will be included in the 'WWW-Authenticate' in the format of
|
||||
* 'key="value"' as well as in the response payload under the attributes key.
|
||||
* Alternatively value can be a string which is use to set the value of the scheme,
|
||||
* for example setting the token value for negotiate header.
|
||||
* If string is used message parameter must be null.
|
||||
* null and undefined will be replaced with an empty string. If attributes is set,
|
||||
* message will be used as the 'error' segment of the 'WWW-Authenticate' header.
|
||||
* If message is unset, the 'error' segment of the header will not be present and isMissing will be true on the error object.
|
||||
* @see {@link https://github.com/hapijs/boom#boomunauthorizedmessage-scheme-attributes}
|
||||
*/
|
||||
function unauthorized(message?: string, scheme?: string, attributes?: {[index: string]: string}): Boom<null>;
|
||||
function unauthorized(message?: string, scheme?: string[]): Boom<null>;
|
||||
function unauthorized(message?: null, scheme?: string, attributes?: {[index: string]: string} | string): Boom<null>;
|
||||
function unauthorized(message?: null, scheme?: string[]): Boom<null>;
|
||||
function unauthorized(message?: string, scheme?: string, attributes?: {[index: string]: string}): Boom<null>;
|
||||
function unauthorized(message?: string, scheme?: string[]): Boom<null>;
|
||||
function unauthorized(message?: null, scheme?: string, attributes?: {[index: string]: string} | string): Boom<null>;
|
||||
|
||||
/**
|
||||
* Returns a 402 Payment Required error
|
||||
@@ -116,7 +139,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boompaymentrequiredmessage-data}
|
||||
*/
|
||||
function paymentRequired<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
function paymentRequired<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 403 Forbidden error
|
||||
@@ -124,7 +147,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomforbiddenmessage-data}
|
||||
*/
|
||||
function forbidden<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
function forbidden<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 404 Not Found error
|
||||
@@ -132,7 +155,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomnotfoundmessage-data}
|
||||
*/
|
||||
function notFound<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
function notFound<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 405 Method Not Allowed error
|
||||
@@ -141,7 +164,7 @@ declare namespace Boom {
|
||||
* @param allow optional string or array of strings (to be combined and separated by ', ') which is set to the 'Allow' header.
|
||||
* @see {@link https://github.com/hapijs/boom#boommethodnotallowedmessage-data-allow}
|
||||
*/
|
||||
function methodNotAllowed<Data = null>(message?: string, data?: Data, allow?: string | string[]): Boom<Data>;
|
||||
function methodNotAllowed<Data = null>(message?: string, data?: Data, allow?: string | string[]): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 406 Not Acceptable error
|
||||
@@ -149,7 +172,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomnotacceptablemessage-data}
|
||||
*/
|
||||
function notAcceptable<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
function notAcceptable<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 407 Proxy Authentication Required error
|
||||
@@ -157,7 +180,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomproxyauthrequiredmessage-data}
|
||||
*/
|
||||
function proxyAuthRequired<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
function proxyAuthRequired<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 408 Request Time-out error
|
||||
@@ -165,7 +188,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomclienttimeoutmessage-data}
|
||||
*/
|
||||
function clientTimeout<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
function clientTimeout<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 409 Conflict error
|
||||
@@ -173,7 +196,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomconflictmessage-data}
|
||||
*/
|
||||
function conflict<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
function conflict<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 410 Gone error
|
||||
@@ -181,7 +204,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomresourcegonemessage-data}
|
||||
*/
|
||||
function resourceGone<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
function resourceGone<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 411 Length Required error
|
||||
@@ -189,7 +212,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomlengthrequiredmessage-data}
|
||||
*/
|
||||
function lengthRequired<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
function lengthRequired<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 412 Precondition Failed error
|
||||
@@ -197,7 +220,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boompreconditionfailedmessage-data}
|
||||
*/
|
||||
function preconditionFailed<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
function preconditionFailed<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 413 Request Entity Too Large error
|
||||
@@ -205,7 +228,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomentitytoolargemessage-data}
|
||||
*/
|
||||
function entityTooLarge<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
function entityTooLarge<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 414 Request-URI Too Large error
|
||||
@@ -213,7 +236,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomuritoolongmessage-data}
|
||||
*/
|
||||
function uriTooLong<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
function uriTooLong<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 415 Unsupported Media Type error
|
||||
@@ -221,7 +244,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomunsupportedmediatypemessage-data}
|
||||
*/
|
||||
function unsupportedMediaType<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
function unsupportedMediaType<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 416 Requested Range Not Satisfiable error
|
||||
@@ -229,7 +252,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomrangenotsatisfiablemessage-data}
|
||||
*/
|
||||
function rangeNotSatisfiable<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
function rangeNotSatisfiable<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 417 Expectation Failed error
|
||||
@@ -237,7 +260,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomexpectationfailedmessage-data}
|
||||
*/
|
||||
function expectationFailed<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
function expectationFailed<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 418 I'm a Teapot error
|
||||
@@ -245,7 +268,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomteapotmessage-data}
|
||||
*/
|
||||
function teapot<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
function teapot<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 422 Unprocessable Entity error
|
||||
@@ -253,7 +276,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boombaddatamessage-data}
|
||||
*/
|
||||
function badData<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
function badData<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 423 Locked error
|
||||
@@ -261,7 +284,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomlockedmessage-data}
|
||||
*/
|
||||
function locked<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
function locked<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 424 Failed Dependency error
|
||||
@@ -269,7 +292,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomfaileddependencymessage-data}
|
||||
*/
|
||||
function failedDependency<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
function failedDependency<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 428 Precondition Required error
|
||||
@@ -277,7 +300,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boompreconditionrequiredmessage-data}
|
||||
*/
|
||||
function preconditionRequired<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
function preconditionRequired<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 429 Too Many Requests error
|
||||
@@ -285,7 +308,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomtoomanyrequestsmessage-data}
|
||||
*/
|
||||
function tooManyRequests<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
function tooManyRequests<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 451 Unavailable For Legal Reasons error
|
||||
@@ -293,7 +316,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomillegalmessage-data}
|
||||
*/
|
||||
function illegal<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
function illegal<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
// 5xx
|
||||
/**
|
||||
@@ -303,7 +326,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boombadimplementationmessage-data---alias-internal}
|
||||
*/
|
||||
function badImplementation<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
function badImplementation<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 500 Internal Server Error error
|
||||
@@ -312,7 +335,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boombadimplementationmessage-data---alias-internal}
|
||||
*/
|
||||
function internal<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
function internal<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 501 Not Implemented error with your error message to the user
|
||||
@@ -320,7 +343,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomnotimplementedmessage-data}
|
||||
*/
|
||||
function notImplemented<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
function notImplemented<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 502 Bad Gateway error with your error message to the user
|
||||
@@ -328,7 +351,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boombadgatewaymessage-data}
|
||||
*/
|
||||
function badGateway<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
function badGateway<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 503 Service Unavailable error with your error message to the user
|
||||
@@ -336,7 +359,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomserverunavailablemessage-data}
|
||||
*/
|
||||
function serverUnavailable<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
function serverUnavailable<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 504 Gateway Time-out error with your error message to the user
|
||||
@@ -344,5 +367,5 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomgatewaytimeoutmessage-data}
|
||||
*/
|
||||
function gatewayTimeout<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
function gatewayTimeout<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
}
|
||||
|
||||
+1
-77
@@ -1,79 +1,3 @@
|
||||
{
|
||||
"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"
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import Boom = require('boom');
|
||||
import * as Hapi from 'hapi';
|
||||
|
||||
// 4xx and data type
|
||||
|
||||
|
||||
@@ -25,4 +25,4 @@
|
||||
"index.d.ts",
|
||||
"boom-tests.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
import Plugin = require('broccoli-plugin');
|
||||
|
||||
declare function copySync(src: string, dest: string): void;
|
||||
declare function setTimeout(callback: () => void, duration: number): void;
|
||||
|
||||
class SlowItDown extends Plugin {
|
||||
constructor(private readonly waitInMS: number) {
|
||||
super([], {
|
||||
annotation: `${waitInMS} ms`,
|
||||
needsCache: false
|
||||
});
|
||||
}
|
||||
|
||||
async build() {
|
||||
await new Promise(resolve => setTimeout(resolve, this.waitInMS));
|
||||
}
|
||||
}
|
||||
|
||||
class FileCopier extends Plugin {
|
||||
constructor(inputNodes: Plugin.BroccoliNode[]) {
|
||||
super(inputNodes, {
|
||||
name: 'CopyFiles',
|
||||
persistentOutput: true
|
||||
});
|
||||
}
|
||||
|
||||
build() {
|
||||
for (const input of this.inputPaths) {
|
||||
copySync(input, this.outputPath);
|
||||
}
|
||||
}
|
||||
|
||||
getCallbackObject() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
new FileCopier([
|
||||
new SlowItDown(5000),
|
||||
'src',
|
||||
'assets'
|
||||
]);
|
||||
|
||||
new Plugin(); // $ExpectError
|
||||
new Plugin([{}]); // $ExpectError
|
||||
new Plugin([], { foo: 'bar' }); // $ExpectError
|
||||
Vendored
+78
@@ -0,0 +1,78 @@
|
||||
// Type definitions for broccoli-plugin 1.3
|
||||
// Project: https://github.com/broccolijs/broccoli-plugin
|
||||
// Definitions by: Dan Freeman <https://github.com/dfreeman>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.1
|
||||
|
||||
export = BroccoliPlugin;
|
||||
|
||||
declare namespace BroccoliPlugin {
|
||||
type BroccoliNode = BroccoliPlugin | string;
|
||||
|
||||
interface BroccoliPluginOptions {
|
||||
/**
|
||||
* The name of this plugin. Defaults to `this.constructor.name`.
|
||||
*/
|
||||
name?: string;
|
||||
|
||||
/**
|
||||
* A descriptive annotation. Useful for debugging, to tell multiple
|
||||
* instances of the same plugin apart.
|
||||
*/
|
||||
annotation?: string;
|
||||
|
||||
/**
|
||||
* If `true`, the output directory is not automatically emptied between
|
||||
* builds. Defaults to `false`.
|
||||
*/
|
||||
persistentOutput?: boolean;
|
||||
|
||||
/**
|
||||
* If `true`, a cache directory is created automatically and the path is
|
||||
* set at `cachePath`. If `false`, a cache directory is not created and
|
||||
* `this.cachePath` is `undefined`. Defaults to `true`.
|
||||
*/
|
||||
needsCache?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
declare class BroccoliPlugin {
|
||||
constructor(inputNodes: BroccoliPlugin.BroccoliNode[], options?: BroccoliPlugin.BroccoliPluginOptions);
|
||||
|
||||
/**
|
||||
* An array of paths on disk corresponding to each node in `inputNodes`.
|
||||
* Your plugin will read files from these paths.
|
||||
*/
|
||||
readonly inputPaths: ReadonlyArray<string>;
|
||||
|
||||
/**
|
||||
* The path on disk corresponding to this plugin instance (this node).
|
||||
* Your plugin will write files to this path. This directory is emptied by
|
||||
* Broccoli before each build, unless the `persistentOutput` options is
|
||||
* `true`.
|
||||
*/
|
||||
readonly outputPath: string;
|
||||
|
||||
/**
|
||||
* The path on disk to an auxiliary cache directory. Use this to store
|
||||
* files that you want preserved between builds. This directory will
|
||||
* only be deleted when Broccoli exits. If a cache directory is not
|
||||
* needed, set `needsCache` to false when calling `broccoli-plugin`
|
||||
* constructor.
|
||||
*/
|
||||
readonly cachePath?: string;
|
||||
|
||||
/**
|
||||
* Override this method in your subclass. It will be called on each
|
||||
* (re-)build. All paths stay the same between builds.
|
||||
* To perform asynchronous work, return a promise.
|
||||
*/
|
||||
build(): void | Promise<any>;
|
||||
|
||||
/**
|
||||
* Advanced usage only.
|
||||
* Return the object on which Broccoli will call `obj.build()`. Called
|
||||
* once after instantiation. By default, returns `this`.
|
||||
*/
|
||||
getCallbackObject(): { build(): void | Promise<any> };
|
||||
}
|
||||
@@ -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",
|
||||
"broccoli-plugin-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@@ -125,6 +125,7 @@ videoQueue.add({ video: 'http://example.com/video1.mov' }, { jobId: 1 })
|
||||
pdfQueue
|
||||
.on('error', (err: Error) => undefined)
|
||||
.on('active', (job: Queue.Job, jobPromise: Queue.JobPromise) => jobPromise.cancel())
|
||||
.on('waiting', (jobId: Queue.JobId) => undefined)
|
||||
.on('active', (job: Queue.Job) => undefined)
|
||||
.on('stalled', (job: Queue.Job) => undefined)
|
||||
.on('progress', (job: Queue.Job) => undefined)
|
||||
@@ -132,4 +133,53 @@ pdfQueue
|
||||
.on('failed', (job: Queue.Job) => undefined)
|
||||
.on('paused', () => undefined)
|
||||
.on('resumed', () => undefined)
|
||||
.on('cleaned', (jobs: Queue.Job[], status: Queue.JobStatus) => undefined);
|
||||
.on('cleaned', (jobs: Queue.Job[], status: Queue.JobStatus) => undefined)
|
||||
.on('drained', () => undefined)
|
||||
.on('removed', (job: Queue.Job) => undefined);
|
||||
|
||||
// test different process methods
|
||||
|
||||
const profileQueue = new Queue('profile');
|
||||
// Max concurrency for requestProfile is 100
|
||||
profileQueue.process('requestProfile', 100, () => {});
|
||||
profileQueue.process(100, () => {});
|
||||
|
||||
// other tests
|
||||
const myQueue = new Queue('myQueue', {
|
||||
settings: {
|
||||
drainDelay: 5
|
||||
},
|
||||
defaultJobOptions: {
|
||||
stackTraceLimit: 1,
|
||||
}
|
||||
});
|
||||
|
||||
myQueue.on('active', (job: Queue.Job) => {
|
||||
job.moveToCompleted();
|
||||
job.moveToCompleted('done');
|
||||
job.moveToCompleted('done', true);
|
||||
job.moveToCompleted('done', true).then(val => {
|
||||
if (val) {
|
||||
const nextJobData: any = val[0];
|
||||
const nextJobId: Queue.JobId = val[1];
|
||||
}
|
||||
});
|
||||
|
||||
job.moveToFailed({ message: "Call to external service failed!" }, true);
|
||||
job.moveToFailed(new Error('test error'), true);
|
||||
job.moveToFailed(new Error('test error'), true).then(val => {
|
||||
if (val) {
|
||||
const nextJobData: any = val[0];
|
||||
const nextJobId: Queue.JobId = val[1];
|
||||
}
|
||||
});
|
||||
|
||||
job.discard();
|
||||
});
|
||||
|
||||
// test all constructor options:
|
||||
|
||||
new Queue('profile');
|
||||
new Queue('profile', 'url');
|
||||
new Queue('profile', { prefix: 'test' });
|
||||
new Queue('profile', 'url', { prefix: 'test' });
|
||||
|
||||
Vendored
+57
-3
@@ -1,4 +1,4 @@
|
||||
// Type definitions for bull 3.3
|
||||
// Type definitions for bull 3.4
|
||||
// Project: https://github.com/OptimalBits/bull
|
||||
// Definitions by: Bruno Grieder <https://github.com/bgrieder>
|
||||
// Cameron Crothers <https://github.com/JProgrammer>
|
||||
@@ -10,6 +10,7 @@
|
||||
// Bond Akinmade <https://github.com/bondz>
|
||||
// Wuha Team <https://github.com/wuha-team>
|
||||
// Alec Brunelle <https://github.com/aleccool213>
|
||||
// Dan Manastireanu <https://github.com/danmana>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
@@ -23,9 +24,9 @@ import * as Promise from "bluebird";
|
||||
*/
|
||||
declare const Bull: {
|
||||
(queueName: string, opts?: Bull.QueueOptions): Bull.Queue;
|
||||
(queueName: string, url?: string): Bull.Queue; // tslint:disable-line unified-signatures
|
||||
(queueName: string, url: string, opts?: Bull.QueueOptions): Bull.Queue; // tslint:disable-line unified-signatures
|
||||
new (queueName: string, opts?: Bull.QueueOptions): Bull.Queue;
|
||||
new (queueName: string, url?: string): Bull.Queue; // tslint:disable-line unified-signatures
|
||||
new (queueName: string, url: string, opts?: Bull.QueueOptions): Bull.Queue; // tslint:disable-line unified-signatures
|
||||
};
|
||||
|
||||
declare namespace Bull {
|
||||
@@ -92,6 +93,12 @@ declare namespace Bull {
|
||||
backoffStrategies?: {
|
||||
[key: string]: (attemptsMade: number, err: typeof Error) => number;
|
||||
};
|
||||
|
||||
/**
|
||||
* A timeout for when the queue is in `drained` state (empty waiting for jobs).
|
||||
* It is used when calling `queue.getNextJob()`, which will pass it to `.brpoplpush` on the Redis client.
|
||||
*/
|
||||
drainDelay?: number;
|
||||
}
|
||||
|
||||
type DoneCallback = (error?: Error | null, value?: any) => void;
|
||||
@@ -141,6 +148,11 @@ declare namespace Bull {
|
||||
*/
|
||||
retry(): Promise<void>;
|
||||
|
||||
/**
|
||||
* Ensure this job is never ran again even if attemptsMade is less than job.attempts.
|
||||
*/
|
||||
discard(): Promise<void>;
|
||||
|
||||
/**
|
||||
* Returns a promise that resolves to the returned data when the job has been finished.
|
||||
* TODO: Add a watchdog to check if the job has finished periodically.
|
||||
@@ -148,6 +160,18 @@ declare namespace Bull {
|
||||
*/
|
||||
finished(): Promise<any>;
|
||||
|
||||
/**
|
||||
* Moves a job to the `completed` queue. Pulls a job from 'waiting' to 'active'
|
||||
* and returns a tuple containing the next jobs data and id. If no job is in the `waiting` queue, returns null.
|
||||
*/
|
||||
moveToCompleted(returnValue?: string, ignoreLock?: boolean): Promise<[any, JobId] | null>;
|
||||
|
||||
/**
|
||||
* Moves a job to the `failed` queue. Pulls a job from 'waiting' to 'active'
|
||||
* and returns a tuple containing the next jobs data and id. If no job is in the `waiting` queue, returns null.
|
||||
*/
|
||||
moveToFailed(errorInfo: { message: string; }, ignoreLock?: boolean): Promise<[any, JobId] | null>;
|
||||
|
||||
/**
|
||||
* Promotes a job that is currently "delayed" to the "waiting" state and executed as soon as possible.
|
||||
*/
|
||||
@@ -205,6 +229,11 @@ declare namespace Bull {
|
||||
* Cron pattern specifying when the job should execute
|
||||
*/
|
||||
cron: string;
|
||||
|
||||
/**
|
||||
* Start date when the repeat job should start repeating (only with cron).
|
||||
*/
|
||||
startDate?: Date | string | number;
|
||||
}
|
||||
|
||||
interface EveryRepeatOptions extends RepeatOptions {
|
||||
@@ -273,6 +302,11 @@ declare namespace Bull {
|
||||
* Default behavior is to keep the job in the completed set.
|
||||
*/
|
||||
removeOnFail?: boolean;
|
||||
|
||||
/**
|
||||
* Limits the amount of stack trace lines that will be recorded in the stacktrace.
|
||||
*/
|
||||
stackTraceLimit?: number;
|
||||
}
|
||||
|
||||
interface JobCounts {
|
||||
@@ -618,6 +652,11 @@ declare namespace Bull {
|
||||
*/
|
||||
on(event: 'error', callback: ErrorEventCallback): this;
|
||||
|
||||
/**
|
||||
* A Job is waiting to be processed as soon as a worker is idling.
|
||||
*/
|
||||
on(event: 'waiting', callback: WaitingEventCallback): this;
|
||||
|
||||
/**
|
||||
* A job has started. You can use `jobPromise.cancel()` to abort it
|
||||
*/
|
||||
@@ -654,6 +693,11 @@ declare namespace Bull {
|
||||
*/
|
||||
on(event: 'resumed', callback: EventCallback): this; // tslint:disable-line unified-signatures
|
||||
|
||||
/**
|
||||
* A job successfully removed.
|
||||
*/
|
||||
on(event: 'removed', callback: RemovedEventCallback<T>): this;
|
||||
|
||||
/**
|
||||
* Old jobs have been cleaned from the queue.
|
||||
* `jobs` is an array of jobs that were removed, and `type` is the type of those jobs.
|
||||
@@ -661,6 +705,12 @@ declare namespace Bull {
|
||||
* @see Queue#clean() for details
|
||||
*/
|
||||
on(event: 'cleaned', callback: CleanedEventCallback<T>): this;
|
||||
|
||||
/**
|
||||
* Emitted every time the queue has processed all the waiting jobs
|
||||
* (even if there can be some delayed jobs not yet processed)
|
||||
*/
|
||||
on(event: 'drained', callback: EventCallback): this; // tslint:disable-line unified-signatures
|
||||
}
|
||||
|
||||
type EventCallback = () => void;
|
||||
@@ -685,6 +735,10 @@ declare namespace Bull {
|
||||
type FailedEventCallback<T = any> = (job: Job<T>, error: Error) => void;
|
||||
|
||||
type CleanedEventCallback<T = any> = (jobs: Array<Job<T>>, status: JobStatus) => void;
|
||||
|
||||
type RemovedEventCallback<T = any> = (job: Job<T>) => void;
|
||||
|
||||
type WaitingEventCallback = (jobId: JobId) => void;
|
||||
}
|
||||
|
||||
export = Bull;
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
// Project: https://github.com/gluwer/bunyan-winston-adapter
|
||||
// Definitions by: Steve Hipwell <https://github.com/stevehipwell>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.1
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
import * as bunyan from "bunyan";
|
||||
import { Logger } from "winston";
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
import * as caniuse from "caniuse-api";
|
||||
|
||||
caniuse.features; // $ExpectType string[]
|
||||
|
||||
caniuse.getSupport(""); // $ExpectType BrowserSupport
|
||||
|
||||
caniuse.isSupported("", ""); // $ExpectType boolean
|
||||
caniuse.isSupported("", [""]); // $ExpectType boolean
|
||||
|
||||
caniuse.find(""); // $ExpectType string[]
|
||||
|
||||
caniuse.getLatestStableBrowsers(); // $ExpectType string[]
|
||||
|
||||
caniuse.setBrowserScope(""); // $ExpectType void
|
||||
caniuse.setBrowserScope([""]); // $ExpectType void
|
||||
|
||||
caniuse.getBrowserScope(); // $ExpectType string[]
|
||||
Vendored
+32
@@ -0,0 +1,32 @@
|
||||
// Type definitions for caniuse-api 3.0
|
||||
// Project: https://github.com/nyalab/caniuse-api#readme
|
||||
// Definitions by: Dave Cardwell <https://github.com/davecardwell>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export const features: string[];
|
||||
|
||||
export interface BrowserSupport {
|
||||
[browser: string]: {
|
||||
y?: number;
|
||||
n?: number;
|
||||
a?: number;
|
||||
x?: number;
|
||||
};
|
||||
}
|
||||
|
||||
export function getSupport(feature: string): BrowserSupport;
|
||||
|
||||
export function isSupported(
|
||||
feature: string,
|
||||
browsers: string | ReadonlyArray<string>
|
||||
): boolean;
|
||||
|
||||
export function find(query: string): string[];
|
||||
|
||||
export function getLatestStableBrowsers(): string[];
|
||||
|
||||
export function setBrowserScope(
|
||||
browserscope: string | ReadonlyArray<string>
|
||||
): void;
|
||||
|
||||
export function getBrowserScope(): string[];
|
||||
@@ -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", "caniuse-api-tests.ts"]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Vendored
-1
@@ -493,4 +493,3 @@ declare module "cash" {
|
||||
export = CashStatic;
|
||||
}
|
||||
declare var cash: CashStatic;
|
||||
declare var $: CashStatic;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as CatbotRedis from 'catbox-redis';
|
||||
|
||||
const cache = new CatbotRedis({
|
||||
const cache = new CatbotRedis<string>({
|
||||
host: 'localhost',
|
||||
partition: 'test',
|
||||
port: 2018,
|
||||
@@ -10,3 +10,8 @@ cache.get({
|
||||
segment: 'test',
|
||||
id: 'test',
|
||||
});
|
||||
|
||||
cache.set({
|
||||
segment: 'test',
|
||||
id: 'test',
|
||||
}, 'test', 123);
|
||||
|
||||
Vendored
+1
-1
@@ -53,7 +53,7 @@ declare module 'catbox-redis' {
|
||||
sentinelName?: string;
|
||||
}
|
||||
}
|
||||
class CatboxRedis extends Client {
|
||||
class CatboxRedis<T> extends Client<T> {
|
||||
constructor(options: CatboxRedis.CatboxRedisOptions);
|
||||
}
|
||||
export = CatboxRedis;
|
||||
|
||||
@@ -1,16 +1,22 @@
|
||||
import { CacheItem, Client, Policy, EnginePrototypeOrObject } from "catbox";
|
||||
import { Client, Policy, EnginePrototypeOrObject, DecoratedResult, CachedObject } from "catbox";
|
||||
|
||||
const Memory: EnginePrototypeOrObject = {
|
||||
async start(): Promise<void> {},
|
||||
stop(): void {},
|
||||
async get(): Promise<null | CacheItem> {},
|
||||
async get(): Promise<null | CachedObject<string>> {
|
||||
return {
|
||||
item: 'asd',
|
||||
stored: 12,
|
||||
ttl: 123,
|
||||
};
|
||||
},
|
||||
async set(): Promise<void> {},
|
||||
async drop(): Promise<void> {},
|
||||
isReady(): boolean { return true; },
|
||||
validateSegmentName(segment: string): null { return null; },
|
||||
};
|
||||
|
||||
const client = new Client(Memory, { partition: 'cache' });
|
||||
const client = new Client<string>(Memory, { partition: 'cache' });
|
||||
|
||||
const cache = new Policy({
|
||||
expiresIn: 5000,
|
||||
@@ -25,3 +31,11 @@ cache.drop('foo').then(() => {});
|
||||
cache.isReady();
|
||||
|
||||
cache.stats();
|
||||
|
||||
const decoratedCache = new Policy({
|
||||
getDecoratedValue: true,
|
||||
}, client, 'cache2');
|
||||
|
||||
decoratedCache.get('test').then((a: DecoratedResult<string>) => {
|
||||
const res: string = a.value;
|
||||
});
|
||||
|
||||
Vendored
+63
-78
@@ -4,7 +4,7 @@
|
||||
// AJP <https://github.com/AJamesPhillips>
|
||||
// Rodrigo Saboya <https://github.com/saboya>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.4
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
/**
|
||||
* Client
|
||||
@@ -17,7 +17,7 @@
|
||||
* the Riak bucket, or as a key prefix in Redis and Memcached. To share the cache across multiple clients, use the same partition name.
|
||||
* @see {@link https://github.com/hapijs/catbox#client}
|
||||
*/
|
||||
export class Client implements ClientApi {
|
||||
export class Client<T> implements ClientApi<T> {
|
||||
constructor(engine: EnginePrototypeOrObject, options: ClientOptions);
|
||||
|
||||
/** start() - creates a connection to the cache server. Must be called before any other method is available. */
|
||||
@@ -28,14 +28,14 @@ export class Client implements ClientApi {
|
||||
* get(key, callback) - retrieve an item from the cache engine if found where:
|
||||
* * key - a cache key object (see [ICacheKey]).
|
||||
*/
|
||||
get(key: CacheKey): Promise<null | CachedObject>;
|
||||
get(key: CacheKey): Promise<null | CachedObject<T>>;
|
||||
/**
|
||||
* set(key, value, ttl, callback) - store an item in the cache for a specified length of time, where:
|
||||
* * key - a cache key object (see [ICacheKey]).
|
||||
* * value - the string or object value to be stored.
|
||||
* * ttl - a time-to-live value in milliseconds after which the item is automatically removed from the cache (or is marked invalid).
|
||||
*/
|
||||
set(key: CacheKey, value: CacheItem, ttl: number): Promise<void>;
|
||||
set(key: CacheKey, value: T, ttl: number): Promise<void>;
|
||||
/**
|
||||
* drop(key, callback) - remove an item from cache where:
|
||||
* * key - a cache key object (see [ICacheKey]).
|
||||
@@ -47,13 +47,13 @@ export class Client implements ClientApi {
|
||||
validateSegmentName(segment: string): null | Error;
|
||||
}
|
||||
|
||||
export type EnginePrototypeOrObject = EnginePrototype | ClientApi;
|
||||
export type EnginePrototypeOrObject = EnginePrototype<any> | ClientApi<any>;
|
||||
|
||||
/**
|
||||
* A prototype CatBox engine function
|
||||
*/
|
||||
export interface EnginePrototype {
|
||||
new(settings: ClientOptions): ClientApi;
|
||||
export interface EnginePrototype<T> {
|
||||
new(settings: ClientOptions): ClientApi<T>;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -61,7 +61,7 @@ export interface EnginePrototype {
|
||||
* The Client object provides the following methods:
|
||||
* @see {@link https://github.com/hapijs/catbox#api}
|
||||
*/
|
||||
export interface ClientApi {
|
||||
export interface ClientApi<T> {
|
||||
/** start() - creates a connection to the cache server. Must be called before any other method is available. */
|
||||
start(): Promise<void>;
|
||||
/** stop() - terminates the connection to the cache server. */
|
||||
@@ -70,14 +70,14 @@ export interface ClientApi {
|
||||
* get(key, callback) - retrieve an item from the cache engine if found where:
|
||||
* * key - a cache key object (see [ICacheKey]).
|
||||
*/
|
||||
get(key: CacheKey): Promise<null | CachedObject>;
|
||||
get(key: CacheKey): Promise<null | CachedObject<T>>;
|
||||
/**
|
||||
* set(key, value, ttl) - store an item in the cache for a specified length of time, where:
|
||||
* * key - a cache key object (see [ICacheKey]).
|
||||
* * value - the string or object value to be stored.
|
||||
* * ttl - a time-to-live value in milliseconds after which the item is automatically removed from the cache (or is marked invalid).
|
||||
*/
|
||||
set(key: CacheKey, value: CacheItem, ttl: number): Promise<void>;
|
||||
set(key: CacheKey, value: T, ttl: number): Promise<void>;
|
||||
/**
|
||||
* drop(key) - remove an item from cache where:
|
||||
* * key - a cache key object (see [ICacheKey]).
|
||||
@@ -100,17 +100,15 @@ export interface CacheKey {
|
||||
}
|
||||
|
||||
/** Cached object contains the following: */
|
||||
export interface CachedObject {
|
||||
export interface CachedObject<T> {
|
||||
/** item - the value stored in the cache using set(). */
|
||||
item: any;
|
||||
item: T;
|
||||
/** stored - the timestamp when the item was stored in the cache (in milliseconds). */
|
||||
stored: number;
|
||||
/** ttl - the remaining time-to-live (not the original value used when storing the object). */
|
||||
ttl: number;
|
||||
}
|
||||
|
||||
export type CacheItem = any;
|
||||
|
||||
export interface ClientOptions {
|
||||
/**
|
||||
* this will store items under keys that start with this value.
|
||||
@@ -118,89 +116,69 @@ export interface ClientOptions {
|
||||
partition: string;
|
||||
}
|
||||
|
||||
export type PolicyOptionVariants<T> = PolicyOptions<T> | DecoratedPolicyOptions<T>;
|
||||
|
||||
/**
|
||||
* The Policy object provides a convenient cache interface by setting a global policy which is automatically applied to every storage action.
|
||||
* The Policy object provides a convenient cache interface by setting a
|
||||
* global policy which is automatically applied to every storage action.
|
||||
* The object is constructed using new Policy(options, [cache, segment]) where:
|
||||
* * options - an object with the IPolicyOptions structure
|
||||
* * cache - a Client instance (which has already been started).
|
||||
* * segment - required when cache is provided. The segment name used to isolate cached items within the cache partition.
|
||||
* * segment - required when cache is provided. The segment name used to
|
||||
* isolate cached items within the cache partition.
|
||||
* @see {@link https://github.com/hapijs/catbox#policy}
|
||||
*/
|
||||
export class Policy implements PolicyAPI {
|
||||
constructor(options: PolicyOptions, cache: Client, segment: string);
|
||||
export class Policy<T, O extends PolicyOptionVariants<T>> {
|
||||
constructor(options: O, cache: Client<T>, segment: string);
|
||||
/**
|
||||
* get(id) - retrieve an item from the cache. If the item is not found and the generateFunc method was provided,
|
||||
* a new value is generated, stored in the cache, and returned. Multiple concurrent requests are queued and processed once. The method arguments are:
|
||||
* * id - the unique item identifier (within the policy segment). Can be a string or an object with the required 'id' key.
|
||||
* retrieve an item from the cache. If the item is not
|
||||
* found and the generateFunc method was provided,
|
||||
* a new value is generated, stored in the cache, and returned.
|
||||
* Multiple concurrent requests are queued and processed once. The method arguments are:
|
||||
* @param id the unique item identifier (within the policy segment).
|
||||
* Can be a string or an object with the required 'id' key.
|
||||
*/
|
||||
get(id: string | { id: string }): Promise<PolicyGetPromiseResult | null>;
|
||||
get(id: string | { id: string }): Promise<O extends DecoratedPolicyOptions<T> ? DecoratedResult<T> : T | null>;
|
||||
|
||||
/**
|
||||
* set(id, value, ttl) - store an item in the cache where:
|
||||
* * id - the unique item identifier (within the policy segment).
|
||||
* * value - the string or object value to be stored.
|
||||
* * ttl - a time-to-live override value in milliseconds after which the item is automatically removed from the cache (or is marked invalid).
|
||||
* store an item in the cache where:
|
||||
* @param id - the unique item identifier (within the policy segment).
|
||||
* @param value - the string or object value to be stored.
|
||||
* @param ttl - a time-to-live override value in milliseconds after which the item is automatically
|
||||
* removed from the cache (or is marked invalid).
|
||||
* This should be set to 0 in order to use the caching rules configured when creating the Policy object.
|
||||
*/
|
||||
set(id: string | { id: string }, value: CacheItem, ttl: number | null): Promise<void>;
|
||||
set(id: string | { id: string }, value: T, ttl?: number): Promise<void>;
|
||||
/**
|
||||
* drop(id) - remove the item from cache where:
|
||||
* * id - the unique item identifier (within the policy segment).
|
||||
* remove the item from cache where:
|
||||
* @param id the unique item identifier (within the policy segment).
|
||||
*/
|
||||
drop(id: string | { id: string }): Promise<void>;
|
||||
/** ttl(created) - given a created timestamp in milliseconds, returns the time-to-live left based on the configured rules. */
|
||||
/**
|
||||
* given a created timestamp in milliseconds, returns the time-to-live left
|
||||
* based on the configured rules.
|
||||
*/
|
||||
ttl(created: number): number;
|
||||
/** rules(options) - changes the policy rules after construction (note that items already stored will not be affected) */
|
||||
rules(options: PolicyOptions): void;
|
||||
/** isReady() - returns true if cache engine determines itself as ready, false if it is not ready or if there is no cache engine set. */
|
||||
/** changes the policy rules after construction (note that items already stored will not be affected) */
|
||||
rules(options: PolicyOptions<T>): void;
|
||||
/**
|
||||
* returns true if cache engine determines itself as ready, false if it is not ready or if
|
||||
* here is no cache engine set.
|
||||
*/
|
||||
isReady(): boolean;
|
||||
/** stats - an object with cache statistics */
|
||||
/** an object with cache statistics */
|
||||
stats(): CacheStatisticsObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Policy API
|
||||
* The Policy object provides the following methods:
|
||||
* @see {@link https://github.com/hapijs/catbox#api-1}
|
||||
*/
|
||||
export interface PolicyAPI {
|
||||
/**
|
||||
* get(id) - retrieve an item from the cache. If the item is not found and the generateFunc method was provided,
|
||||
* a new value is generated, stored in the cache, and returned. Multiple concurrent requests are queued and processed once. The method arguments are:
|
||||
* * id - the unique item identifier (within the policy segment). Can be a string or an object with the required 'id' key.
|
||||
*/
|
||||
get(id: string | { id: string }): Promise<PolicyGetPromiseResult | null>;
|
||||
/**
|
||||
* set(id, value, ttl) - store an item in the cache where:
|
||||
* * id - the unique item identifier (within the policy segment).
|
||||
* * value - the string or object value to be stored.
|
||||
* * ttl - a time-to-live override value in milliseconds after which the item is automatically removed from the cache (or is marked invalid).
|
||||
* This should be set to 0 in order to use the caching rules configured when creating the Policy object.
|
||||
*/
|
||||
set(id: string | { id: string }, value: CacheItem, ttl: number | null): Promise<void>;
|
||||
/**
|
||||
* drop(id) - remove the item from cache where:
|
||||
* * id - the unique item identifier (within the policy segment).
|
||||
*/
|
||||
drop(id: string | { id: string }): Promise<void>;
|
||||
/** ttl(created) - given a created timestamp in milliseconds, returns the time-to-live left based on the configured rules. */
|
||||
ttl(created: number): number;
|
||||
/** rules(options) - changes the policy rules after construction (note that items already stored will not be affected) */
|
||||
rules(options: PolicyOptions): void;
|
||||
/** isReady() - returns true if cache engine determines itself as ready, false if it is not ready or if there is no cache engine set. */
|
||||
isReady(): boolean;
|
||||
/** stats - an object with cache statistics */
|
||||
stats(): CacheStatisticsObject;
|
||||
}
|
||||
|
||||
export interface PolicyGetPromiseResult {
|
||||
value: CacheItem;
|
||||
cached: PolicyGetCachedOptions;
|
||||
export interface DecoratedResult<T> {
|
||||
value: T;
|
||||
cached: PolicyGetCachedOptions<T>;
|
||||
report: PolicyGetReportLog;
|
||||
}
|
||||
|
||||
export interface PolicyGetCachedOptions {
|
||||
export interface PolicyGetCachedOptions<T> {
|
||||
/** item - the cached value. */
|
||||
item: CacheItem;
|
||||
item: T;
|
||||
/** stored - the timestamp when the item was stored in the cache. */
|
||||
stored: number;
|
||||
/** ttl - the cache ttl value for the record. */
|
||||
@@ -212,13 +190,13 @@ export interface PolicyGetCachedOptions {
|
||||
/**
|
||||
* @see {@link https://github.com/hapijs/catbox#policy}
|
||||
*/
|
||||
export interface PolicyOptions {
|
||||
export interface PolicyOptions<T> {
|
||||
/** expiresIn - relative expiration expressed in the number of milliseconds since the item was saved in the cache. Cannot be used together with expiresAt. */
|
||||
expiresIn?: number;
|
||||
/** expiresAt - time of day expressed in 24h notation using the 'HH:MM' format, at which point all cache records for the route expire. Uses local time. Cannot be used together with expiresIn. */
|
||||
expiresAt?: string;
|
||||
/** generateFunc - a function used to generate a new cache item if one is not found in the cache when calling get(). The method's signature is function(id, next) where: */
|
||||
generateFunc?: GenerateFunc;
|
||||
generateFunc?: GenerateFunc<T>;
|
||||
/**
|
||||
* staleIn - number of milliseconds to mark an item stored in cache as stale and attempt to regenerate it when generateFunc is provided.
|
||||
* Must be less than expiresIn. Alternatively function that returns staleIn value in milliseconds. The function signature is function(stored, ttl) where:
|
||||
@@ -242,11 +220,18 @@ export interface PolicyOptions {
|
||||
generateIgnoreWriteError?: boolean;
|
||||
/**
|
||||
* pendingGenerateTimeout - number of milliseconds while generateFunc call is in progress for a given id, before a subsequent generateFunc call is allowed.
|
||||
* Defaults to 0, no blocking of concurrent generateFunc calls beyond staleTimeout.
|
||||
* @default 0, no blocking of concurrent generateFunc calls beyond staleTimeout.
|
||||
*/
|
||||
pendingGenerateTimeout?: number;
|
||||
}
|
||||
|
||||
export interface DecoratedPolicyOptions<T> extends PolicyOptions<T> {
|
||||
/**
|
||||
* @default false
|
||||
*/
|
||||
getDecoratedValue?: boolean;
|
||||
}
|
||||
|
||||
export interface GenerateFuncFlags {
|
||||
ttl: number;
|
||||
}
|
||||
@@ -262,7 +247,7 @@ export interface GenerateFuncFlags {
|
||||
* * ttl - the cache ttl value in milliseconds. Set to 0 to skip storing in the cache. Defaults to the cache global policy.
|
||||
* @see {@link https://github.com/hapijs/catbox#policy}
|
||||
*/
|
||||
export type GenerateFunc = (id: string, flags: GenerateFuncFlags) => Promise<CacheItem>;
|
||||
export type GenerateFunc<T> = (id: string, flags: GenerateFuncFlags) => Promise<T>;
|
||||
|
||||
/**
|
||||
* An object with logging information about the generation operation containing the following keys (as relevant):
|
||||
|
||||
Vendored
+1
-1
@@ -1,6 +1,6 @@
|
||||
// Type definitions for chai-fs 2.0
|
||||
// Project: https://github.com/chaijs/chai-fs
|
||||
// Definitions by: Dimitar Danailov <https://github.com/Nemo157>
|
||||
// Definitions by: Dimitar Danailov <https://github.com/dimitardanailov>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
|
||||
@@ -808,6 +808,24 @@ function frozen() {
|
||||
expect(Object.freeze({})).to.be.frozen;
|
||||
({}).should.be.not.frozen;
|
||||
Object.freeze({}).should.be.frozen;
|
||||
|
||||
expect([1, 2, 3]).to.have.all.members([1, 2, 3]);
|
||||
expect([1, 2, 3]).to.have.all.members(Object.freeze([1, 2, 3]));
|
||||
|
||||
expect({1: "", 2: "", 3: ""}).to.have.all.keys([1, 2, 3]);
|
||||
expect({1: "", 2: "", 3: ""}).to.have.all.keys(Object.freeze([1, 2, 3]));
|
||||
|
||||
assert.notDeepInclude([1, 2, 3], 1);
|
||||
assert.notDeepInclude(Object.freeze([1, 2, 3]), 1);
|
||||
|
||||
assert.include([1, 2, 3], 1);
|
||||
assert.include(Object.freeze([1, 2, 3]), 1);
|
||||
|
||||
assert.notInclude([1, 2, 3], 1);
|
||||
assert.notInclude(Object.freeze([1, 2, 3]), 1);
|
||||
|
||||
expect([1, 2, 3]).to.have.oneOf([1, 2, 3]);
|
||||
expect([1, 2, 3]).to.have.oneOf(Object.freeze([1, 2, 3]));
|
||||
}
|
||||
|
||||
class PoorlyConstructedError {
|
||||
|
||||
Vendored
+6
-6
@@ -118,7 +118,7 @@ declare namespace Chai {
|
||||
extensible: Assertion;
|
||||
sealed: Assertion;
|
||||
frozen: Assertion;
|
||||
oneOf(list: any[], message?: string): Assertion;
|
||||
oneOf(list: ReadonlyArray<any>, message?: string): Assertion;
|
||||
}
|
||||
|
||||
interface LanguageChains {
|
||||
@@ -235,7 +235,7 @@ declare namespace Chai {
|
||||
|
||||
interface Keys {
|
||||
(...keys: string[]): Assertion;
|
||||
(keys: any[]|Object): Assertion;
|
||||
(keys: ReadonlyArray<any>|Object): Assertion;
|
||||
}
|
||||
|
||||
interface Throw {
|
||||
@@ -252,7 +252,7 @@ declare namespace Chai {
|
||||
}
|
||||
|
||||
interface Members {
|
||||
(set: any[], message?: string): Assertion;
|
||||
(set: ReadonlyArray<any>, message?: string): Assertion;
|
||||
}
|
||||
|
||||
interface PropertyChange {
|
||||
@@ -696,7 +696,7 @@ declare namespace Chai {
|
||||
* @param needle Potential value contained in haystack.
|
||||
* @param message Message to display on error.
|
||||
*/
|
||||
include<T>(haystack: T[], needle: T, message?: string): void;
|
||||
include<T>(haystack: ReadonlyArray<T>, needle: T, message?: string): void;
|
||||
|
||||
/**
|
||||
* Asserts that haystack does not include needle.
|
||||
@@ -705,7 +705,7 @@ declare namespace Chai {
|
||||
* @param needle Potential expected substring of haystack.
|
||||
* @param message Message to display on error.
|
||||
*/
|
||||
notInclude(haystack: string | any[], needle: any, message?: string): void;
|
||||
notInclude(haystack: string | ReadonlyArray<any>, needle: any, message?: string): void;
|
||||
|
||||
/**
|
||||
* Asserts that haystack includes needle. Can be used to assert the inclusion of a value in an array or a subset of properties in an object. Deep equality is used.
|
||||
@@ -732,7 +732,7 @@ declare namespace Chai {
|
||||
* @param needle Potential expected substring of haystack.
|
||||
* @param message Message to display on error.
|
||||
*/
|
||||
notDeepInclude(haystack: string | any[], needle: any, message?: string): void;
|
||||
notDeepInclude(haystack: string | ReadonlyArray<any>, needle: any, message?: string): void;
|
||||
|
||||
/**
|
||||
* Asserts that ‘haystack’ includes ‘needle’. Can be used to assert the inclusion of a subset of properties in an object.
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user