mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-16 15:00:26 +00:00
Merge conflict
This commit is contained in:
+305
-266
File diff suppressed because it is too large
Load Diff
@@ -11,8 +11,8 @@ Also see the [definitelytyped.org](http://definitelytyped.org) website, although
|
||||
This section tracks the health of the repository and publishing process.
|
||||
It may be helpful for contributors experiencing any issues with their PRs and packages.
|
||||
|
||||
* All packages are type-checking/linting cleanly: [](https://travis-ci.org/DefinitelyTyped/DefinitelyTyped)
|
||||
* All packages are being published to npm in under 10,000 seconds: [](https://typescript.visualstudio.com/TypeScript/_build/latest?definitionId=13)
|
||||
* All packages are [type-checking/linting](https://github.com/Microsoft/dtslint) cleanly: [](https://travis-ci.org/DefinitelyTyped/DefinitelyTyped)
|
||||
* All packages are being [published to npm](https://github.com/Microsoft/types-publisher) in under an hour: [](https://typescript.visualstudio.com/TypeScript/_build/latest?definitionId=13)
|
||||
* [typescript-bot](https://github.com/typescript-bot) has been active on DefinitelyTyped [](https://typescript.visualstudio.com/TypeScript/_build/latest?definitionId=14)
|
||||
|
||||
If anything here seems wrong, or any of the above are failing, please raise an issue in [the DefinitelyTyped Gitter channel](https://gitter.im/DefinitelyTyped/DefinitelyTyped).
|
||||
@@ -229,7 +229,7 @@ It depends, but most pull requests will be merged within a week. PRs that have b
|
||||
|
||||
#### My PR is merged; when will the `@types` NPM package be updated?
|
||||
|
||||
NPM packages should update within a few hours. If it's been more than 24 hours, ping @RyanCavanaugh and @andy-ms on the PR to investigate.
|
||||
NPM packages should update within a few minutes. If it's been more than an hour, mention the PR number on [the DefinitelyTyped Gitter channel](https://gitter.im/DefinitelyTyped/DefinitelyTyped) and the current maintainer will get the correct team member to investigate.
|
||||
|
||||
#### I'm writing a definition that depends on another definition. Should I use `<reference types="" />` or an import?
|
||||
|
||||
@@ -255,12 +255,30 @@ Here are the [currently requested definitions](https://github.com/DefinitelyType
|
||||
|
||||
If types are part of a web standard, they should be contributed to [TSJS-lib-generator](https://github.com/Microsoft/TSJS-lib-generator) so that they can become part of the default `lib.dom.d.ts`.
|
||||
|
||||
#### Should I add an empty namespace to a package that doesn't export a module to use ES6 style imports?
|
||||
|
||||
Some packages, like [chai-http](https://github.com/chaijs/chai-http), export a function.
|
||||
|
||||
Importing this module with an ES6 style import in the form `import * as foo from "foo";` leads to the error:
|
||||
|
||||
> error TS2497: Module 'foo' resolves to a non-module entity and cannot be imported using this construct
|
||||
|
||||
This error can be suppressed by merging the function declaration with an empty namespace of the same name, but this practice is discouraged.
|
||||
This is a commonly cited [Stack Overflow answer](https://stackoverflow.com/questions/39415661/what-does-resolves-to-a-non-module-entity-and-cannot-be-imported-using-this) regarding this matter.
|
||||
|
||||
It is more appropriate to import the module using the `import foo = require("foo");` syntax.
|
||||
Nevertheless, if you want to use a default import like `import foo from "foo";` you have two options:
|
||||
- you can use the [`--allowSyntheticDefaultImports` compiler option](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-1-8.html#support-for-default-import-interop-with-systemjs) if your module runtime supports an interop scheme for non-ECMAScript modules, i.e. if default imports work in your environment (e.g. Webpack, SystemJS, esm).
|
||||
- you can use the [`--esModuleInterop` compiler option](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-7.html#support-for-import-d-from-cjs-form-commonjs-modules-with---esmoduleinterop) if you want TypeScript to take care of non-ECMAScript interop (since Typescript 2.7).
|
||||
|
||||
#### A package uses `export =`, but I prefer to use default imports. Can I change `export =` to `export default`?
|
||||
|
||||
If you are using TypeScript 2.7 or later, use `--esModuleInterop` in your project.
|
||||
Otherwise, if default imports work in your environment (e.g. Webpack, SystemJS, esm), consider turning on the [`--allowSyntheticDefaultImports`](http://www.typescriptlang.org/docs/handbook/compiler-options.html) compiler option.
|
||||
Like in the previous question, refer to using either the [`--allowSyntheticDefaultImports`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-1-8.html#support-for-default-import-interop-with-systemjs)
|
||||
or [`--esModuleInterop`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-7.html#support-for-import-d-from-cjs-form-commonjs-modules-with---esmoduleinterop)
|
||||
compiler options.
|
||||
|
||||
Do not change the type definition if it is accurate.
|
||||
For an NPM package, `export =` is accurate if `node -p 'require("foo")'` is the export, and `export default` is accurate if `node -p 'require("foo").default'` is the export.
|
||||
For an NPM package, `export =` is accurate if `node -p 'require("foo")'` works to import a module, and `export default` is accurate if `node -p 'require("foo").default'` works to import a module.
|
||||
|
||||
#### I want to use features from TypeScript 2.1 or above.
|
||||
|
||||
@@ -268,8 +286,9 @@ Then you will have to add a comment to the last line of your definition header (
|
||||
|
||||
#### I want to use features from TypeScript 3.1 or above.
|
||||
|
||||
You will need to use the `typesVersions` feature of TypeScript 3.1 and above. You can find a detailed explanation
|
||||
of this feature in the [official TypeScript documentation](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-1.html#version-selection-with-typesversions).
|
||||
You can use the same `// TypeScript Version: 3.1` comment as above.
|
||||
However, if your project needs to maintain types that are compatible with 3.1 and above *at the same time as* types that are compatible with 3.0 or below, you will need to use the `typesVersions` feature, which is available in TypeScript 3.1 and above.
|
||||
You can find a detailed explanation of this feature in the [official TypeScript documentation](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-1.html#version-selection-with-typesversions).
|
||||
|
||||
Here's a short explanation to get you started:
|
||||
|
||||
@@ -308,14 +327,60 @@ If the standard is still a draft, it belongs here.
|
||||
Use a name beginning with `dom-` and include a link to the standard as the "Project" link in the header.
|
||||
When it graduates draft mode, we may remove it from DefinitelyTyped and deprecate the associated `@types` package.
|
||||
|
||||
#### I want to update a package to a new major version
|
||||
#### How do DefinitelyTyped package versions relate to versions of the corresponding library?
|
||||
|
||||
If you intend to continue updating the older version of the package, you may create a new subfolder with the current version e.g. `v2`, and copy existing files to it. If so, you will need to:
|
||||
_NOTE: The discussion in this section assumes familiarity with [Semantic versioning](https://semver.org/)_
|
||||
|
||||
Each DefinitelyTyped package is versioned when published to NPM.
|
||||
The [types-publisher](https://github.com/Microsoft/types-publisher) (the tool that publishes `@types` packages to npm) will set the declaration package's version by using the `major.minor` version number listed in the first line of its `index.d.ts` file.
|
||||
For example, here are the first few lines of [Node's type declarations](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/1253faabf5e0d2c5470db6ea87795d7f96fef7e2/types/node/index.d.ts) for version `10.12.x` at the time of writing:
|
||||
|
||||
```js
|
||||
// Type definitions for Node.js 10.12
|
||||
// Project: http://nodejs.org/
|
||||
// Definitions by: Microsoft TypeScript <https://github.com/Microsoft>
|
||||
// DefinitelyTyped <https://github.com/DefinitelyTyped>
|
||||
// Alberto Schiabel <https://github.com/jkomyno>
|
||||
```
|
||||
|
||||
Because `10.12` is at the end the first line, the npm version of the `@types/node` package will also be `10.12.x`.
|
||||
Note that the first-line comment in the `index.d.ts` file should only contain the `major.minor` version (e.g. `10.12`) and should not contain a patch version (e.g. `10.12.4`).
|
||||
This is because only the major and minor release numbers are aligned between library packages and type declaration packages.
|
||||
The patch release number of the type declaration package (e.g. `.0` in `10.12.0`) is initialized to zero by DefinitelyTyped and is incremented each time a new `@types/node` package is published to NPM for the same major/minor version of the corresponding library.
|
||||
|
||||
Sometimes type declaration package versions and library package versions can get out of sync.
|
||||
Below are a few common reasons why, in order of how much they inconvenience users of a library.
|
||||
Only the last case is typically problematic.
|
||||
|
||||
* As noted above, the patch version of the type declaration package is unrelated to the library patch version.
|
||||
This allows DefinitelyTyped to safely update type declarations for the same major/minor version of a library.
|
||||
* If updating a package for new functionality, don't forget to update the version number to line up with that version of the library.
|
||||
If users make sure versions correspond between JavaScript packages and their respective `@types` packages, then `npm update` should typically just work.
|
||||
* It's common for type declaration package updates to lag behind library updates because it's often library users, not maintainers, who update DefinitelyTyped when new library features are released.
|
||||
So there may be a lag of days, weeks, or even months before a helpful community member sends a PR to update the type declaration package for a new library release.
|
||||
If you're impacted by this, you can be the change you want to see in the world and you can be that helpful community member!
|
||||
|
||||
:exclamation: If you're updating type declarations for a library, always set the `major.minor` version in the first line of `index.d.ts` to match the library version that you're documenting! :exclamation:
|
||||
|
||||
#### If a library is updated to a new major version with breaking changes, how should I update its type declaration package?
|
||||
|
||||
[Semantic versioning](https://semver.org/) requires that versions with breaking changes must increment the major version number.
|
||||
For example, a library that removes a publicly exported function after its `3.5.8` release must bump its version to `4.0.0` in its next release.
|
||||
Furthermore, when the library's `4.0.0` release is out, its DefinitelyTyped type declaration package should also be updated to `4.0.0`, including any breaking changes to the library's API.
|
||||
|
||||
Many libraries have a large installed base of developers (including maintainers of other packages using that library as a dependency) who won't move right away to a new version that has breaking changes, because it might be months until a maintainer has time to rewrite code to adapt to the new version.
|
||||
In the meantime, users of old library versions still may want to update type declarations for older versions.
|
||||
|
||||
If you intend to continue updating the older version of a library's type declarations, you may create a new subfolder (e.g. `/v2/`) named for the current (soon to be "old") version, and copy existing files from the current version to it.
|
||||
|
||||
Because the root folder should always contain the type declarations for the latest ("new") version, you'll need to make a few changes to the files in your old-version subdirectory to ensure that relative path references point to the subdirectory, not the root.
|
||||
|
||||
1. Update the relative paths in `tsconfig.json` as well as `tslint.json`.
|
||||
2. Add path mapping rules to ensure that tests are running against the intended version.
|
||||
|
||||
For example [history v2 `tsconfig.json`](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/history/v2/tsconfig.json) looks like:
|
||||
For example, the [`history`](https://github.com/ReactTraining/history/) library introduced breaking changes between version `2.x` and `3.x`.
|
||||
Because many users still consumed the older `2.x` version, a maintainer who wanted to update the type declarations for this library to `3.x` added a `v2` folder inside the history repository that contains type declarations for the older version.
|
||||
At the time of writing, the [history v2 `tsconfig.json`](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/1253faabf5e0d2c5470db6ea87795d7f96fef7e2/types/history/v2/tsconfig.json) looks roughly like:
|
||||
|
||||
```json
|
||||
{
|
||||
@@ -333,10 +398,11 @@ For example [history v2 `tsconfig.json`](https://github.com/DefinitelyTyped/Defi
|
||||
}
|
||||
```
|
||||
|
||||
If there are other packages on DefinitelyTyped that are incompatible with the new version, you will need to add path mappings to the old version. You will also need to do this for packages depending on packages depending on the old version.
|
||||
If there are other packages in DefinitelyTyped that are incompatible with the new version, you will need to add path mappings to the old version.
|
||||
You will also need to do this recursively for packages depending on packages depending on the old version.
|
||||
|
||||
For example, `react-router` depends on `history@2`, so [react-router `tsconfig.json`](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react-router/tsconfig.json) has a path mapping to `"history": [ "history/v2" ]`;
|
||||
transitively `react-router-bootstrap` (which depends on `react-router`) also adds a path mapping in its [tsconfig.json](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react-router-bootstrap/tsconfig.json).
|
||||
For example, `react-router` depends on `history@2`, so [react-router `tsconfig.json`](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react-router/v2/tsconfig.json) has a path mapping to `"history": [ "history/v2" ]`.
|
||||
Transitively, `react-router-bootstrap` (which depends on `react-router`) also needed to add the same path mapping (`"history": [ "history/v2" ]`) in its `tsconfig.json` until its `react-router` dependency was updated to the latest version.
|
||||
|
||||
Also, `/// <reference types=".." />` will not work with path mapping, so dependencies must use `import`.
|
||||
|
||||
@@ -368,19 +434,6 @@ When `dts-gen` is used to scaffold a scoped package, the `paths` property has to
|
||||
|
||||
GitHub doesn't [support](http://stackoverflow.com/questions/5646174/how-to-make-github-follow-directory-history-after-renames) file history for renamed files. Use [`git log --follow`](https://www.git-scm.com/docs/git-log) instead.
|
||||
|
||||
#### Should I add an empty namespace to a package that doesn't export a module to use ES6 style imports?
|
||||
|
||||
Some packages, like [chai-http](https://github.com/chaijs/chai-http), export a function.
|
||||
|
||||
Importing this module with an ES6 style import in the form `import * as foo from "foo";` leads to the error:
|
||||
|
||||
> error TS2497: Module 'foo' resolves to a non-module entity and cannot be imported using this construct
|
||||
|
||||
This error can be suppressed by merging the function declaration with an empty namespace of the same name, but this practice is discouraged.
|
||||
This is a commonly cited [Stack Overflow answer](https://stackoverflow.com/questions/39415661/what-does-resolves-to-a-non-module-entity-and-cannot-be-imported-using-this) regarding this matter.
|
||||
|
||||
It is more appropriate to import the module using the `import foo = require("foo");` syntax, or to use a default import like `import foo from "foo";` if using the `--allowSyntheticDefaultImports` flag if your module runtime supports an interop scheme for non-ECMAScript modules as such.
|
||||
|
||||
## License
|
||||
|
||||
This project is licensed under the MIT license.
|
||||
|
||||
@@ -564,6 +564,30 @@
|
||||
"sourceRepoURL": "https://www.npmjs.com/package/fast-simplex-noise",
|
||||
"asOfVersion": "3.0.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "fastify-cors",
|
||||
"typingsPackageName": "fastify-cors",
|
||||
"sourceRepoURL": "https://github.com/fastify/fastify-cors",
|
||||
"asOfVersion": "2.1.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "Fastify-JWT",
|
||||
"typingsPackageName": "fastify-jwt",
|
||||
"sourceRepoURL": "https://github.com/fastify/fastify-jwt",
|
||||
"asOfVersion": "0.8.1"
|
||||
},
|
||||
{
|
||||
"libraryName": "fastify-multipart",
|
||||
"typingsPackageName": "fastify-multipart",
|
||||
"sourceRepoURL": "https://github.com/fastify/fastify-multipart",
|
||||
"asOfVersion": "0.7.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "fastify-static",
|
||||
"typingsPackageName": "fastify-static",
|
||||
"sourceRepoURL": "https://github.com/fastify/fastify-static",
|
||||
"asOfVersion": "2.2.1"
|
||||
},
|
||||
{
|
||||
"libraryName": "fecha",
|
||||
"typingsPackageName": "fecha",
|
||||
@@ -702,6 +726,12 @@
|
||||
"sourceRepoURL": "https://github.com/prettymuchbryce/node-http-status",
|
||||
"asOfVersion": "1.2.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "i18next-xhr-backend",
|
||||
"typingsPackageName": "i18next-xhr-backend",
|
||||
"sourceRepoURL": "https://github.com/i18next/i18next-xhr-backend",
|
||||
"asOfVersion": "1.4.2"
|
||||
},
|
||||
{
|
||||
"libraryName": "iconv-lite",
|
||||
"typingsPackageName": "iconv-lite",
|
||||
@@ -1086,6 +1116,12 @@
|
||||
"sourceRepoURL": "http://onsen.io",
|
||||
"asOfVersion": "2.0.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "p-throttle",
|
||||
"typingsPackageName": "p-throttle",
|
||||
"sourceRepoURL": "https://github.com/sindresorhus/p-throttle",
|
||||
"asOfVersion": "2.0.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "param-case",
|
||||
"typingsPackageName": "param-case",
|
||||
@@ -1260,6 +1296,12 @@
|
||||
"sourceRepoURL": "https://github.com/i18next/react-i18next",
|
||||
"asOfVersion": "8.1.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "React Icons",
|
||||
"typingsPackageName": "react-icons",
|
||||
"sourceRepoURL": "https://www.npmjs.com/package/react-icons",
|
||||
"asOfVersion": "3.0.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "react-monaco-editor",
|
||||
"typingsPackageName": "react-monaco-editor",
|
||||
@@ -1608,6 +1650,12 @@
|
||||
"sourceRepoURL": "http://gcanti.github.io/tcomb/guide/index.html",
|
||||
"asOfVersion": "2.6.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "terser",
|
||||
"typingsPackageName": "terser",
|
||||
"sourceRepoURL": "https://github.com/terser-js/terser",
|
||||
"asOfVersion": "3.12.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "timezonecomplete",
|
||||
"typingsPackageName": "timezonecomplete",
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@
|
||||
"lint": "dtslint types"
|
||||
},
|
||||
"devDependencies": {
|
||||
"dtslint": "github:Microsoft/dtslint#production",
|
||||
"dtslint": "latest",
|
||||
"types-publisher": "github:Microsoft/types-publisher#production"
|
||||
},
|
||||
"dependencies": {}
|
||||
|
||||
Vendored
+1
-1
@@ -1,5 +1,5 @@
|
||||
// Type definitions for abs 1.3
|
||||
// Project: https://github.com/IonicaBizau/node-abs
|
||||
// Project: https://github.com/ionicabizau/abs
|
||||
// Definitions by: Aya Morisawa <https://github.com/AyaMorisawa>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
|
||||
Vendored
+159
-130
@@ -1,150 +1,179 @@
|
||||
// Type definitions for node_acl 0.4.8
|
||||
// Type definitions for acl 0.4
|
||||
// Project: https://github.com/optimalbits/node_acl
|
||||
// Definitions by: Qubo <https://github.com/tkQubo>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
/// <reference types="node"/>
|
||||
/// <reference types="express"/>
|
||||
|
||||
import http = require('http');
|
||||
import Promise = require("bluebird");
|
||||
import express = require("express");
|
||||
import Promise = require('bluebird');
|
||||
import express = require('express');
|
||||
import redis = require('redis');
|
||||
import mongo = require('mongodb');
|
||||
|
||||
type strings = string|string[];
|
||||
type Value = string|number;
|
||||
type Values = Value|Value[];
|
||||
export = AclStatic;
|
||||
|
||||
declare const AclStatic: AclStatic;
|
||||
|
||||
type strings = string | string[];
|
||||
type Value = string | number;
|
||||
type Values = Value | Value[];
|
||||
type Action = () => any;
|
||||
type Callback = (err: Error) => any;
|
||||
type Callback = (err?: Error) => any;
|
||||
type AnyCallback = (err: Error, obj: any) => any;
|
||||
type AllowedCallback = (err: Error, allowed: boolean) => any;
|
||||
type GetUserId = (req: http.IncomingMessage, res: http.ServerResponse) => Value;
|
||||
|
||||
interface AclStatic {
|
||||
new (backend: Backend<any>, logger: Logger, options: Option): Acl;
|
||||
new (backend: Backend<any>, logger: Logger): Acl;
|
||||
new (backend: Backend<any>): Acl;
|
||||
memoryBackend: MemoryBackendStatic;
|
||||
new (
|
||||
backend: AclStatic.Backend<any>,
|
||||
logger?: AclStatic.Logger,
|
||||
options?: AclStatic.Option
|
||||
): AclStatic.Acl;
|
||||
readonly memoryBackend: AclStatic.MemoryBackendStatic;
|
||||
readonly mongodbBackend: AclStatic.MongodbBackendStatic;
|
||||
readonly redisBackend: AclStatic.RedisBackendStatic;
|
||||
}
|
||||
|
||||
interface Logger {
|
||||
debug: (msg: string) => any;
|
||||
}
|
||||
|
||||
interface Acl {
|
||||
addUserRoles: (userId: Value, roles: strings, cb?: Callback) => Promise<void>;
|
||||
removeUserRoles: (userId: Value, roles: strings, cb?: Callback) => Promise<void>;
|
||||
userRoles: (userId: Value, cb?: (err: Error, roles: string[]) => any) => Promise<string[]>;
|
||||
roleUsers: (role: Value, cb?: (err: Error, users: Values) => any) => Promise<any>;
|
||||
hasRole: (userId: Value, role: string, cb?: (err: Error, isInRole: boolean) => any) => Promise<boolean>;
|
||||
addRoleParents: (role: string, parents: Values, cb?: Callback) => Promise<void>;
|
||||
removeRole: (role: string, cb?: Callback) => Promise<void>;
|
||||
removeResource: (resource: string, cb?: Callback) => Promise<void>;
|
||||
allow: {
|
||||
(roles: Values, resources: strings, permissions: strings, cb?: Callback): Promise<void>;
|
||||
(aclSets: AclSet | AclSet[]): Promise<void>;
|
||||
declare namespace AclStatic {
|
||||
interface Logger {
|
||||
debug: (msg: string) => any;
|
||||
}
|
||||
removeAllow: (role: string, resources: strings, permissions: strings, cb?: Callback) => Promise<void>;
|
||||
removePermissions: (role: string, resources: strings, permissions: strings, cb?: Function) => Promise<void>;
|
||||
allowedPermissions: (userId: Value, resources: strings, cb?: AnyCallback) => Promise<void>;
|
||||
isAllowed: (userId: Value, resources: strings, permissions: strings, cb?: AllowedCallback) => Promise<boolean>;
|
||||
areAnyRolesAllowed: (roles: strings, resource: strings, permissions: strings, cb?: AllowedCallback) => Promise<any>;
|
||||
whatResources: {
|
||||
(roles: strings, cb?: AnyCallback): Promise<any>;
|
||||
(roles: strings, permissions: strings, cb?: AnyCallback): Promise<any>;
|
||||
|
||||
interface Acl {
|
||||
addUserRoles: (userId: Value, roles: strings, cb?: Callback) => Promise<void>;
|
||||
removeUserRoles: (userId: Value, roles: strings, cb?: Callback) => Promise<void>;
|
||||
userRoles: (userId: Value, cb?: (err: Error, roles: string[]) => any) => Promise<string[]>;
|
||||
roleUsers: (role: Value, cb?: (err: Error, users: Values) => any) => Promise<any>;
|
||||
hasRole: (
|
||||
userId: Value,
|
||||
role: string,
|
||||
cb?: (err: Error, isInRole: boolean) => any
|
||||
) => Promise<boolean>;
|
||||
addRoleParents: (role: string, parents: Values, cb?: Callback) => Promise<void>;
|
||||
removeRole: (role: string, cb?: Callback) => Promise<void>;
|
||||
removeResource: (resource: string, cb?: Callback) => Promise<void>;
|
||||
allow: {
|
||||
(roles: Values, resources: strings, permissions: strings, cb?: Callback): Promise<void>;
|
||||
(aclSets: AclSet | AclSet[]): Promise<void>;
|
||||
};
|
||||
removeAllow: (
|
||||
role: string,
|
||||
resources: strings,
|
||||
permissions: strings,
|
||||
cb?: Callback
|
||||
) => Promise<void>;
|
||||
removePermissions: (
|
||||
role: string,
|
||||
resources: strings,
|
||||
permissions: strings,
|
||||
cb?: Callback
|
||||
) => Promise<void>;
|
||||
allowedPermissions: (userId: Value, resources: strings, cb?: AnyCallback) => Promise<void>;
|
||||
isAllowed: (
|
||||
userId: Value,
|
||||
resources: strings,
|
||||
permissions: strings,
|
||||
cb?: AllowedCallback
|
||||
) => Promise<boolean>;
|
||||
areAnyRolesAllowed: (
|
||||
roles: strings,
|
||||
resource: strings,
|
||||
permissions: strings,
|
||||
cb?: AllowedCallback
|
||||
) => Promise<any>;
|
||||
whatResources: {
|
||||
(roles: strings, cb?: AnyCallback): Promise<any>;
|
||||
(roles: strings, permissions: strings, cb?: AnyCallback): Promise<any>;
|
||||
};
|
||||
permittedResources: (roles: strings, permissions: strings, cb?: Callback) => Promise<void>;
|
||||
middleware: (
|
||||
numPathComponents?: number,
|
||||
userId?: Value | GetUserId,
|
||||
actions?: strings
|
||||
) => express.RequestHandler;
|
||||
}
|
||||
|
||||
interface Option {
|
||||
buckets?: BucketsOption;
|
||||
}
|
||||
|
||||
interface BucketsOption {
|
||||
meta?: string;
|
||||
parents?: string;
|
||||
permissions?: string;
|
||||
resources?: string;
|
||||
roles?: string;
|
||||
users?: string;
|
||||
}
|
||||
|
||||
interface AclSet {
|
||||
roles: strings;
|
||||
allows: AclAllow[];
|
||||
}
|
||||
|
||||
interface AclAllow {
|
||||
resources: strings;
|
||||
permissions: strings;
|
||||
}
|
||||
|
||||
interface MemoryBackend extends Backend<Action[]> {}
|
||||
interface MemoryBackendStatic {
|
||||
new (): MemoryBackend;
|
||||
}
|
||||
|
||||
//
|
||||
// For internal use
|
||||
//
|
||||
interface Backend<T> {
|
||||
begin: () => T;
|
||||
end: (transaction: T, cb?: Action) => void;
|
||||
clean: (cb?: Action) => void;
|
||||
get: (bucket: string, key: Value, cb?: Action) => void;
|
||||
union: (bucket: string, keys: Value[], cb?: Action) => void;
|
||||
add: (transaction: T, bucket: string, key: Value, values: Values) => void;
|
||||
del: (transaction: T, bucket: string, keys: Value[]) => void;
|
||||
remove: (transaction: T, bucket: string, key: Value, values: Values) => void;
|
||||
|
||||
endAsync: (transaction: T, cb?: (err: Error | null) => void) => Promise<void>;
|
||||
getAsync: (
|
||||
bucket: string,
|
||||
key: Value,
|
||||
cb?: (err: Error | null, value: any) => void
|
||||
) => Promise<any>;
|
||||
cleanAsync: (cb?: (error?: Error) => void) => Promise<void>;
|
||||
unionAsync: (
|
||||
bucket: string,
|
||||
keys: Value[],
|
||||
cb?: (error: Error | undefined, results: any[]) => void
|
||||
) => Promise<any[]>;
|
||||
}
|
||||
|
||||
interface Contract {
|
||||
(args: IArguments): Contract | NoOp;
|
||||
debug: boolean;
|
||||
fulfilled: boolean;
|
||||
args: any[];
|
||||
checkedParams: string[];
|
||||
params: (...types: string[]) => Contract | NoOp;
|
||||
end: () => void;
|
||||
}
|
||||
|
||||
interface NoOp {
|
||||
params: (...types: string[]) => NoOp;
|
||||
end: () => void;
|
||||
}
|
||||
|
||||
// for redis backend
|
||||
interface RedisBackend extends Backend<redis.RedisClient> {}
|
||||
interface RedisBackendStatic {
|
||||
new (redis: redis.RedisClient, prefix?: string): RedisBackend;
|
||||
}
|
||||
|
||||
// for mongodb backend
|
||||
interface MongodbBackend extends Backend<Callback> {}
|
||||
interface MongodbBackendStatic {
|
||||
new (db: mongo.Db, prefix?: string, useSingle?: boolean): MongodbBackend;
|
||||
}
|
||||
permittedResources: (roles: strings, permissions: strings, cb?: Function) => Promise<void>;
|
||||
middleware: (numPathComponents?: number, userId?: Value | GetUserId, actions?: strings) => express.RequestHandler;
|
||||
}
|
||||
|
||||
interface Option {
|
||||
buckets?: BucketsOption;
|
||||
}
|
||||
|
||||
interface BucketsOption {
|
||||
meta?: string;
|
||||
parents?: string;
|
||||
permissions?: string;
|
||||
resources?: string;
|
||||
roles?: string;
|
||||
users?: string;
|
||||
}
|
||||
|
||||
interface AclSet {
|
||||
roles: strings;
|
||||
allows: AclAllow[];
|
||||
}
|
||||
|
||||
interface AclAllow {
|
||||
resources: strings;
|
||||
permissions: strings;
|
||||
}
|
||||
|
||||
interface MemoryBackend extends Backend<Action[]> { }
|
||||
interface MemoryBackendStatic {
|
||||
new (): MemoryBackend;
|
||||
}
|
||||
|
||||
//
|
||||
// For internal use
|
||||
//
|
||||
interface Backend<T> {
|
||||
begin: () => T;
|
||||
end: (transaction: T, cb?: Action) => void;
|
||||
clean: (cb?: Action) => void;
|
||||
get: (bucket: string, key: Value, cb?: Action) => void;
|
||||
union: (bucket: string, keys: Value[], cb?: Action) => void;
|
||||
add: (transaction: T, bucket: string, key: Value, values: Values) => void;
|
||||
del: (transaction: T, bucket: string, keys: Value[]) => void;
|
||||
remove: (transaction: T, bucket: string, key: Value, values: Values) => void;
|
||||
|
||||
endAsync: Function; //TODO: Give more specific function signature
|
||||
getAsync: Function;
|
||||
cleanAsync: Function;
|
||||
unionAsync: Function;
|
||||
}
|
||||
|
||||
interface Contract {
|
||||
(args: IArguments): Contract | NoOp;
|
||||
debug: boolean;
|
||||
fulfilled: boolean;
|
||||
args: any[];
|
||||
checkedParams: string[];
|
||||
params: (...types: string[]) => Contract | NoOp;
|
||||
end: () => void;
|
||||
}
|
||||
|
||||
interface NoOp {
|
||||
params: (...types: string[]) => NoOp;
|
||||
end: () => void;
|
||||
}
|
||||
|
||||
// for redis backend
|
||||
import redis = require('redis');
|
||||
|
||||
interface AclStatic {
|
||||
redisBackend: RedisBackendStatic;
|
||||
}
|
||||
|
||||
interface RedisBackend extends Backend<redis.RedisClient> { }
|
||||
interface RedisBackendStatic {
|
||||
new (redis: redis.RedisClient, prefix: string): RedisBackend;
|
||||
new (redis: redis.RedisClient): RedisBackend;
|
||||
}
|
||||
|
||||
// for mongodb backend
|
||||
import mongo = require('mongodb');
|
||||
|
||||
interface AclStatic {
|
||||
mongodbBackend: MongodbBackendStatic;
|
||||
}
|
||||
|
||||
interface MongodbBackend extends Backend<Callback> { }
|
||||
interface MongodbBackendStatic {
|
||||
new (db: mongo.Db, prefix: string, useSingle: boolean): MongodbBackend;
|
||||
new (db: mongo.Db, prefix: string): MongodbBackend;
|
||||
new (db: mongo.Db): MongodbBackend;
|
||||
}
|
||||
|
||||
declare var _: AclStatic;
|
||||
export = _;
|
||||
|
||||
+35
-36
@@ -2,15 +2,15 @@
|
||||
// https://github.com/OptimalBits/node_acl/blob/master/Readme.md
|
||||
import Acl = require('acl');
|
||||
|
||||
var report = <T>(err: Error, value: T) => {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
}
|
||||
console.info(value);
|
||||
const report = (err: Error, value: any) => {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
}
|
||||
console.info(value);
|
||||
};
|
||||
|
||||
// Using the memory backend
|
||||
var acl = new Acl(new Acl.memoryBackend());
|
||||
const acl: Acl.Acl = new Acl(new Acl.memoryBackend());
|
||||
|
||||
// middleware with no optional parameters
|
||||
acl.middleware();
|
||||
@@ -18,11 +18,11 @@ acl.middleware();
|
||||
acl.middleware(1);
|
||||
|
||||
acl.middleware(1, () => {
|
||||
return "joed";
|
||||
return 'joed';
|
||||
});
|
||||
|
||||
acl.middleware(1, () => {
|
||||
return 2;
|
||||
return 2;
|
||||
});
|
||||
|
||||
acl.middleware(1, 'joed');
|
||||
@@ -33,36 +33,36 @@ acl.middleware(3, 'joed', 'post');
|
||||
acl.allow('guest', 'blogs', 'view');
|
||||
|
||||
// allow function accepts arrays as any parameter
|
||||
acl.allow('member', 'blogs', ['edit','view', 'delete']);
|
||||
acl.allow('member', 'blogs', ['edit', 'view', 'delete']);
|
||||
|
||||
acl.addUserRoles('joed', 'guest');
|
||||
|
||||
acl.addRoleParents('baz', ['foo','bar']);
|
||||
acl.addRoleParents('baz', ['foo', 'bar']);
|
||||
|
||||
acl.allow('foo', ['blogs','forums','news'], ['view', 'delete']);
|
||||
acl.allow('foo', ['blogs', 'forums', 'news'], ['view', 'delete']);
|
||||
|
||||
acl.allow('admin', ['blogs','forums'], '*');
|
||||
acl.allow('admin', ['blogs', 'forums'], '*');
|
||||
|
||||
acl.allow([
|
||||
{
|
||||
roles:['guest','special-member'],
|
||||
allows:[
|
||||
{resources:'blogs', permissions:'get'},
|
||||
{resources:['forums','news'], permissions:['get','put','delete']}
|
||||
]
|
||||
roles: ['guest', 'special-member'],
|
||||
allows: [
|
||||
{ resources: 'blogs', permissions: 'get' },
|
||||
{ resources: ['forums', 'news'], permissions: ['get', 'put', 'delete'] },
|
||||
],
|
||||
},
|
||||
{
|
||||
roles:['gold','silver'],
|
||||
allows:[
|
||||
{resources:'cash', permissions:['sell','exchange']},
|
||||
{resources:['account','deposit'], permissions:['put','delete']}
|
||||
]
|
||||
}
|
||||
roles: ['gold', 'silver'],
|
||||
allows: [
|
||||
{ resources: 'cash', permissions: ['sell', 'exchange'] },
|
||||
{ resources: ['account', 'deposit'], permissions: ['put', 'delete'] },
|
||||
],
|
||||
},
|
||||
]);
|
||||
|
||||
acl.isAllowed('joed', 'blogs', 'view', (err, res) => {
|
||||
if (res) {
|
||||
console.log("User joed is allowed to view blogs");
|
||||
console.log('User joed is allowed to view blogs');
|
||||
}
|
||||
});
|
||||
|
||||
@@ -78,15 +78,14 @@ acl.whatResources('foo', 'view', (err, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
acl.isAllowed('jsmith', 'blogs', ['edit','view','delete'])
|
||||
.then((result) => {
|
||||
console.dir('jsmith is allowed blogs ' + result);
|
||||
acl.addUserRoles('jsmith', 'member');
|
||||
}).then(() =>
|
||||
acl.isAllowed('jsmith', 'blogs', ['edit','view','delete'])
|
||||
).then((result) =>
|
||||
console.dir('jsmith is allowed blogs ' + result)
|
||||
).then(() => {
|
||||
acl.allowedPermissions('james', ['blogs','forums'], report);
|
||||
acl.allowedPermissions('jsmith', ['blogs','forums'], report);
|
||||
});
|
||||
acl.isAllowed('jsmith', 'blogs', ['edit', 'view', 'delete'])
|
||||
.then(result => {
|
||||
console.dir('jsmith is allowed blogs ' + result);
|
||||
acl.addUserRoles('jsmith', 'member');
|
||||
})
|
||||
.then(() => acl.isAllowed('jsmith', 'blogs', ['edit', 'view', 'delete']))
|
||||
.then(result => console.dir('jsmith is allowed blogs ' + result))
|
||||
.then(() => {
|
||||
acl.allowedPermissions('james', ['blogs', 'forums'], report);
|
||||
acl.allowedPermissions('jsmith', ['blogs', 'forums'], report);
|
||||
});
|
||||
|
||||
@@ -5,10 +5,10 @@ import mongodb = require('mongodb');
|
||||
declare var db: mongodb.Db;
|
||||
|
||||
// Using the mongo db backend
|
||||
var acl = new Acl(new Acl.mongodbBackend(db, 'acl_', true));
|
||||
const acl = new Acl(new Acl.mongodbBackend(db, 'acl_', true));
|
||||
|
||||
// guest is allowed to view blogs
|
||||
acl.allow('guest', 'blogs', 'view');
|
||||
|
||||
// allow function accepts arrays as any parameter
|
||||
acl.allow('member', 'blogs', ['edit','view', 'delete']);
|
||||
acl.allow('member', 'blogs', ['edit', 'view', 'delete']);
|
||||
|
||||
@@ -5,10 +5,10 @@ import redis = require('redis');
|
||||
declare var client: redis.RedisClient;
|
||||
|
||||
// Using the redis backend
|
||||
var acl = new Acl(new Acl.redisBackend(client, 'acl_'));
|
||||
const acl = new Acl(new Acl.redisBackend(client, 'acl_'));
|
||||
|
||||
// guest is allowed to view blogs
|
||||
acl.allow('guest', 'blogs', 'view');
|
||||
|
||||
// allow function accepts arrays as any parameter
|
||||
acl.allow('member', 'blogs', ['edit','view', 'delete']);
|
||||
acl.allow('member', 'blogs', ['edit', 'view', 'delete']);
|
||||
|
||||
+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"
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -1,5 +1,5 @@
|
||||
// Type definitions for Acorn 4.0
|
||||
// Project: https://github.com/marijnh/acorn
|
||||
// Project: https://github.com/acornjs/acorn
|
||||
// Definitions by: RReverser <https://github.com/RReverser>, e-cloud <https://github.com/e-cloud>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -1,5 +1,5 @@
|
||||
// Type definitions for ActiveStorage 5.2
|
||||
// Project: https://github.com/rails/rails/tree/master/activestorage/app/javascipt
|
||||
// Project: https://github.com/rails/rails/tree/master/activestorage/app/javascript, http://rubyonrails.org
|
||||
// Definitions by: Cameron Bothner <https://github.com/cbothner>
|
||||
// Definitions: https://github.com/cbothner/DefinitelyTyped
|
||||
// TypeScript Version: 2.1
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Type definitions for Microsoft Access 14.0 Object Library - Access 14.0
|
||||
// Type definitions for non-npm package Microsoft Access 14.0 Object Library - Access 14.0
|
||||
// Project: https://msdn.microsoft.com/en-us/library/dn142571.aspx
|
||||
// Definitions by: Zev Spitz <https://github.com/zspitz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Type definitions for Microsoft ActiveX Data Objects 6.0 Library - ADODB 6.1
|
||||
// Type definitions for non-npm package Microsoft ActiveX Data Objects 6.0 Library - ADODB 6.1
|
||||
// Project: https://msdn.microsoft.com/en-us/library/jj249010.aspx
|
||||
// Definitions by: Zev Spitz <https://github.com/zspitz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Type definitions for Microsoft ADO Extensions 6.0 for DDL and Security - ADOX 6.0
|
||||
// Type definitions for non-npm package Microsoft ADO Extensions 6.0 for DDL and Security - ADOX 6.0
|
||||
// Project: https://docs.microsoft.com/en-us/sql/ado/reference/adox-api/adox-object-model
|
||||
// Definitions by: Zev Spitz <https://github.com/zspitz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Type definitions for Microsoft Office 16.0 Access Database Engine Object Library - DAO 16.0
|
||||
// Type definitions for non-npm package Microsoft Office 16.0 Access Database Engine Object Library - DAO 16.0
|
||||
// Project: https://msdn.microsoft.com/en-us/library/dn124645.aspx
|
||||
// Definitions by: Zev Spitz <https://github.com/zspitz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Type definitions for DiskQuotaTypeLibrary 1.0
|
||||
// Type definitions for non-npm package DiskQuotaTypeLibrary 1.0
|
||||
// Project: https://msdn.microsoft.com/en-us/library/windows/desktop/bb773938(v=vs.85).aspx
|
||||
// Definitions by: Zev Spitz <https://github.com/zspitz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Type definitions for Microsoft Excel 14.0 Object Library - Excel 14.0
|
||||
// Type definitions for non-npm package Microsoft Excel 14.0 Object Library - Excel 14.0
|
||||
// Project: https://msdn.microsoft.com/en-us/library/fp179694.aspx
|
||||
// Definitions by: Zev Spitz <https://github.com/zspitz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Type definitions for Microsoft Fax Service Extended COM Type Library - FAXCOMEXLib 1.0
|
||||
// Type definitions for non-npm package Microsoft Fax Service Extended COM Type Library - FAXCOMEXLib 1.0
|
||||
// Project: https://msdn.microsoft.com/en-us/library/windows/desktop/ms684513(v=vs.85).aspx
|
||||
// Definitions by: Zev Spitz <https://github.com/zspitz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Type definitions for Microsoft InfoPath 3.0 Type Library - InfoPath 3.0
|
||||
// Type definitions for non-npm package Microsoft InfoPath 3.0 Type Library - InfoPath 3.0
|
||||
// Project: https://msdn.microsoft.com/en-us/library/jj602751.aspx
|
||||
// Definitions by: Zev Spitz <https://github.com/zspitz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Type definitions for Javascript Automation interop 0.0
|
||||
// Type definitions for non-npm package Javascript Automation interop 0.0
|
||||
// Project: https://msdn.microsoft.com/en-us/library/ff521046(v=vs.85).aspx
|
||||
// Definitions by: Zev Spitz <https://github.com/zspitz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Type definitions for Windows Script Host Runtime Object Model 0.0
|
||||
// Type definitions for non-npm package Windows Script Host Runtime Object Model 0.0
|
||||
// Project: https://msdn.microsoft.com/en-us/library/9bbdkx3k.aspx
|
||||
// Definitions by: Zev Spitz <https://github.com/zspitz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Type definitions for LibreOffice 5.3
|
||||
// Type definitions for non-npm package LibreOffice 5.3
|
||||
// Project: https://api.libreoffice.org/
|
||||
// Definitions by: Zev Spitz <https://github.com/zspitz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Type definitions for Microsoft Forms 2.0 Object Library - MSForms 2.0
|
||||
// Type definitions for non-npm package Microsoft Forms 2.0 Object Library - MSForms 2.0
|
||||
// Project: https://msdn.microsoft.com/VBA/Language-Reference-VBA/articles/reference-microsoft-forms
|
||||
// Definitions by: Zev Spitz <https://github.com/zspitz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Type definitions for Microsoft HTML Object Library - MSHTML 4.0
|
||||
// Type definitions for non-npm package Microsoft HTML Object Library - MSHTML 4.0
|
||||
// Project: https://msdn.microsoft.com/en-us/library/aa741317(v=vs.85).aspx
|
||||
// Definitions by: Zev Spitz <https://github.com/zspitz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Type definitions for Microsoft XML, v6.0 - MSXML2 6.0
|
||||
// Type definitions for non-npm package Microsoft XML, v6.0 - MSXML2 6.0
|
||||
// Project: https://msdn.microsoft.com/en-us/library/ms763742.aspx
|
||||
// Definitions by: Zev Spitz <https://github.com/zspitz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Type definitions for Microsoft Office 16.0 Object Library - Office 16.0
|
||||
// Type definitions for non-npm package Microsoft Office 16.0 Object Library - Office 16.0
|
||||
// Project: https://msdn.microsoft.com/VBA/Office-Shared-VBA/articles/office-vba-object-library-reference
|
||||
// Definitions by: Zev Spitz <https://github.com/zspitz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Type definitions for Microsoft Outlook 14.0 Object Library - Outlook 14.0
|
||||
// Type definitions for non-npm package Microsoft Outlook 14.0 Object Library - Outlook 14.0
|
||||
// Project: https://msdn.microsoft.com/en-us/vba/vba-outlook
|
||||
// Definitions by: Zev Spitz <https://github.com/zspitz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Type definitions for Microsoft PowerPoint 14.0 Object Library - PowerPoint 14.0
|
||||
// Type definitions for non-npm package Microsoft PowerPoint 14.0 Object Library - PowerPoint 14.0
|
||||
// Project: https://msdn.microsoft.com/en-us/library/fp161225.aspx
|
||||
// Definitions by: Zev Spitz <https://github.com/zspitz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Type definitions for Microsoft Scripting Runtime 1.0
|
||||
// Type definitions for non-npm package Microsoft Scripting Runtime 1.0
|
||||
// Project: https://msdn.microsoft.com/en-us/library/bstcxhf7(v=vs.84).aspx
|
||||
// Definitions by: Zev Spitz <https://github.com/zspitz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Type definitions for Microsoft Internet Controls - SHDocVw 1.1
|
||||
// Type definitions for non-npm package Microsoft Internet Controls - SHDocVw 1.1
|
||||
// Project: https://msdn.microsoft.com/en-us/library/aa752040(v=vs.85).aspx
|
||||
// Definitions by: Zev Spitz <https://github.com/zspitz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Type definitions for Microsoft Shell Controls And Automation - Shell32 1.0
|
||||
// Type definitions for non-npm package Microsoft Shell Controls And Automation - Shell32 1.0
|
||||
// Project: https://msdn.microsoft.com/en-us/library/windows/desktop/bb773938(v=vs.85).aspx
|
||||
// Definitions by: Zev Spitz <https://github.com/zspitz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Type definitions for OLE Automation - stdole 2.0
|
||||
// Type definitions for non-npm package OLE Automation - stdole 2.0
|
||||
// Project: https://msdn.microsoft.com/en-us/library/hh272953.aspx
|
||||
// Definitions by: Zev Spitz <https://github.com/zspitz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Type definitions for Microsoft Visual Basic for Applications Extensibility 5.3 - VBIDE 14.0
|
||||
// Type definitions for non-npm package Microsoft Visual Basic for Applications Extensibility 5.3 - VBIDE 14.0
|
||||
// Project: https://msdn.microsoft.com/en-us/vba/language-reference-vba/articles/collections-visual-basic-add-in-model
|
||||
// Definitions by: Zev Spitz <https://github.com/zspitz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Type definitions for Windows Image Acquisition 2.0
|
||||
// Type definitions for non-npm package Windows Image Acquisition 2.0
|
||||
// Project: https://msdn.microsoft.com/en-us/library/windows/desktop/ms630368(v=vs.85).aspx
|
||||
// Definitions by: Zev Spitz <https://github.com/zspitz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Type definitions for Microsoft Word 14.0 Object Library - Word 14.0
|
||||
// Type definitions for non-npm package Microsoft Word 14.0 Object Library - Word 14.0
|
||||
// Project: https://msdn.microsoft.com/en-us/library/fp179696.aspx
|
||||
// Definitions by: Zev Spitz <https://github.com/zspitz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
Vendored
+1
-1
@@ -1,5 +1,5 @@
|
||||
// Type definitions for adlib 3.0
|
||||
// Project: https://github.com/Esri/adlib
|
||||
// Project: https://github.com/Esri/adlib, https://arcgis.github.io/ember-arcgis-adlib-service
|
||||
// Definitions by: Esri <https://github.com/Esri>
|
||||
// Mike Tschudi <https://github.com/MikeTschudi>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
@@ -1,62 +1,69 @@
|
||||
|
||||
import AdmZip = require("adm-zip");
|
||||
import AdmZip = require('adm-zip');
|
||||
|
||||
// reading archives
|
||||
var zip = new AdmZip("./my_file.zip");
|
||||
var zipEntries: AdmZip.IZipEntry[] = zip.getEntries(); // an array of ZipEntry records
|
||||
const zip = new AdmZip('./my_file.zip');
|
||||
const zipEntries: AdmZip.IZipEntry[] = zip.getEntries(); // an array of ZipEntry records
|
||||
|
||||
zipEntries.forEach(function (zipEntry) {
|
||||
zipEntries.forEach(zipEntry => {
|
||||
console.log(zipEntry.toString()); // outputs zip entries information
|
||||
if (zipEntry.entryName == "my_file.txt") {
|
||||
if (zipEntry.entryName === 'my_file.txt') {
|
||||
console.log(zipEntry.getData().toString('utf8'));
|
||||
}
|
||||
});
|
||||
// outputs the content of some_folder/my_file.txt
|
||||
console.log(zip.readAsText("some_folder/my_file.txt"));
|
||||
console.log(zip.readAsText('some_folder/my_file.txt'));
|
||||
// extracts the specified file to the specified location
|
||||
zip.extractEntryTo(/*entry name*/"some_folder/my_file.txt", /*target path*/"/home/me/tempfolder", /*overwrite*/true)
|
||||
zip.extractEntryTo(
|
||||
/*entry name*/ 'some_folder/my_file.txt',
|
||||
/*target path*/ '/home/me/tempfolder',
|
||||
/*overwrite*/ true
|
||||
);
|
||||
// extracts everything
|
||||
zip.extractAllTo(/*target path*/"/home/me/zipcontent/", /*overwrite*/true);
|
||||
zip.extractAllTo(/*target path*/ '/home/me/zipcontent/', /*overwrite*/ true);
|
||||
// extracts everything and calls callback -> async extracction
|
||||
zip.extractAllToAsync(/*target path*/"/home/me/zipcontent/", /*overwrite*/true, (error: Error)=> {});
|
||||
zip.extractAllToAsync(
|
||||
/*target path*/ '/home/me/zipcontent/',
|
||||
/*overwrite*/ true,
|
||||
(error: Error) => {}
|
||||
);
|
||||
|
||||
// creating archives
|
||||
var zip = new AdmZip();
|
||||
new AdmZip();
|
||||
|
||||
// add file directly
|
||||
zip.addFile("test.txt", new Buffer("inner content of the file"), "entry comment goes here");
|
||||
zip.addFile('test.txt', new Buffer('inner content of the file'), 'entry comment goes here');
|
||||
// add local file
|
||||
zip.addLocalFile("/home/me/some_picture.png");
|
||||
zip.addLocalFile('/home/me/some_picture.png');
|
||||
// get everything as a buffer
|
||||
var willSendthis = zip.toBuffer();
|
||||
const willSendthis = zip.toBuffer();
|
||||
// or write everything to disk
|
||||
zip.writeZip(/*target file name*/"/home/me/files.zip");
|
||||
zip.writeZip(/*target file name*/ '/home/me/files.zip');
|
||||
|
||||
function processZipEntry(zipEntry: AdmZip.IZipEntry) {
|
||||
console.log('comment', zipEntry.comment);
|
||||
}
|
||||
|
||||
//tests taken from examples at https://github.com/cthackers/adm-zip/wiki/ADM-ZIP
|
||||
import Zip = require("adm-zip");
|
||||
// tests taken from examples at https://github.com/cthackers/adm-zip/wiki/ADM-ZIP
|
||||
import Zip = require('adm-zip');
|
||||
// loads and parses existing zip file local_file.zip
|
||||
var zip = new Zip("local_file.zip");
|
||||
new Zip('local_file.zip');
|
||||
// creates new in memory zip
|
||||
zip = new Zip();
|
||||
new Zip();
|
||||
// loads and parses existing zip file local_file.zip
|
||||
zip = new Zip("local_file.zip");
|
||||
new Zip('local_file.zip');
|
||||
// get all entries and iterate them
|
||||
zip.getEntries().forEach((entry) => {
|
||||
var entryName = entry.entryName;
|
||||
var decompressedData = zip.readFile(entry); // decompressed buffer of the entry
|
||||
console.log(zip.readAsText(entry)); // outputs the decompressed content of the entry
|
||||
zip.getEntries().forEach(entry => {
|
||||
const entryName = entry.entryName;
|
||||
const decompressedData = zip.readFile(entry); // decompressed buffer of the entry
|
||||
console.log(zip.readAsText(entry)); // outputs the decompressed content of the entry
|
||||
});
|
||||
|
||||
// will extract the file myfile.txt from the archive to /home/user/folder/subfolder/myfile.txt
|
||||
zip.extractEntryTo("folder/subfolder/myfile.txt", "/home/user/", true, true);
|
||||
zip.extractEntryTo('folder/subfolder/myfile.txt', '/home/user/', true, true);
|
||||
|
||||
// will extract the file myfile.txt from the archive to /home/user/myfile.txt
|
||||
zip.extractEntryTo("folder/subfolder/myfile.txt", "/home/user/", false, true);
|
||||
zip.extractEntryTo('folder/subfolder/myfile.txt', '/home/user/', false, true);
|
||||
|
||||
function isAdmZipEntry(obj: any): obj is AdmZip.IZipEntry {
|
||||
return obj !== null && typeof obj === "object" && typeof obj['entryName'] === 'string';
|
||||
return obj !== null && typeof obj === 'object' && typeof obj['entryName'] === 'string';
|
||||
}
|
||||
|
||||
Vendored
+93
-155
@@ -1,90 +1,56 @@
|
||||
// Type definitions for adm-zip v0.4.4
|
||||
// Type definitions for adm-zip 0.4
|
||||
// Project: https://github.com/cthackers/adm-zip
|
||||
// Definitions by: John Vilk <https://github.com/jvilk>, Abner Oliveira <https://github.com/abner>
|
||||
// Definitions by: John Vilk <https://github.com/jvilk>
|
||||
// Abner Oliveira <https://github.com/abner>
|
||||
// BendingBender <https://github.com/BendingBender>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
|
||||
declare class AdmZip {
|
||||
/**
|
||||
* Create a new, empty archive.
|
||||
* @param fileNameOrRawData If provided, reads an existing archive. Otherwise creates a new, empty archive.
|
||||
*/
|
||||
constructor();
|
||||
constructor(fileNameOrRawData?: string | Buffer);
|
||||
/**
|
||||
* Read an existing archive.
|
||||
* Extracts the given entry from the archive and returns the content.
|
||||
* @param entry The full path of the entry or a `IZipEntry` object.
|
||||
* @return `Buffer` or `null` in case of error.
|
||||
*/
|
||||
constructor(fileName: string);
|
||||
constructor(rawData: Buffer);
|
||||
readFile(entry: string | AdmZip.IZipEntry): Buffer | null;
|
||||
/**
|
||||
* Extracts the given entry from the archive and returns the content as a
|
||||
* Buffer object.
|
||||
* @param entry String with the full path of the entry
|
||||
* @return Buffer or Null in case of error
|
||||
* Asynchronous `readFile`.
|
||||
* @param entry The full path of the entry or a `IZipEntry` object.
|
||||
* @param callback Called with a `Buffer` or `null` in case of error.
|
||||
*/
|
||||
readFile(entry: string): Buffer;
|
||||
/**
|
||||
* Extracts the given entry from the archive and returns the content as a
|
||||
* Buffer object.
|
||||
* @param entry ZipEntry object
|
||||
* @return Buffer or Null in case of error
|
||||
*/
|
||||
readFile(entry: AdmZip.IZipEntry): Buffer;
|
||||
/**
|
||||
* Asynchronous readFile
|
||||
* @param entry String with the full path of the entry
|
||||
* @param callback Called with a Buffer or Null in case of error
|
||||
*/
|
||||
readFileAsync(entry: string, callback: (data: Buffer, err: string) => any): void;
|
||||
/**
|
||||
* Asynchronous readFile
|
||||
* @param entry ZipEntry object
|
||||
* @param callback Called with a Buffer or Null in case of error
|
||||
* @return Buffer or Null in case of error
|
||||
*/
|
||||
readFileAsync(entry: AdmZip.IZipEntry, callback: (data: Buffer, err: string) => any): void;
|
||||
readFileAsync(
|
||||
entry: string | AdmZip.IZipEntry,
|
||||
callback: (data: Buffer | null, err: string) => any
|
||||
): void;
|
||||
/**
|
||||
* Extracts the given entry from the archive and returns the content as
|
||||
* plain text in the given encoding
|
||||
* @param entry String with the full path of the entry
|
||||
* @param encoding Optional. If no encoding is specified utf8 is used
|
||||
* @return String
|
||||
* plain text in the given encoding.
|
||||
* @param entry The full path of the entry or a `IZipEntry` object.
|
||||
* @param encoding If no encoding is specified `"utf8"` is used.
|
||||
*/
|
||||
readAsText(fileName: string, encoding?: string): string;
|
||||
readAsText(fileName: string | AdmZip.IZipEntry, encoding?: string): string;
|
||||
/**
|
||||
* Extracts the given entry from the archive and returns the content as
|
||||
* plain text in the given encoding
|
||||
* @param entry ZipEntry object
|
||||
* @param encoding Optional. If no encoding is specified utf8 is used
|
||||
* @return String
|
||||
*/
|
||||
readAsText(fileName: AdmZip.IZipEntry, encoding?: string): string;
|
||||
/**
|
||||
* Asynchronous readAsText
|
||||
* @param entry String with the full path of the entry
|
||||
* Asynchronous `readAsText`.
|
||||
* @param entry The full path of the entry or a `IZipEntry` object.
|
||||
* @param callback Called with the resulting string.
|
||||
* @param encoding Optional. If no encoding is specified utf8 is used
|
||||
* @param encoding If no encoding is specified `"utf8"` is used.
|
||||
*/
|
||||
readAsTextAsync(fileName: string, callback: (data: string) => any, encoding?: string): void;
|
||||
/**
|
||||
* Asynchronous readAsText
|
||||
* @param entry ZipEntry object
|
||||
* @param callback Called with the resulting string.
|
||||
* @param encoding Optional. If no encoding is specified utf8 is used
|
||||
*/
|
||||
readAsTextAsync(fileName: AdmZip.IZipEntry, callback: (data: string) => any, encoding?: string): void;
|
||||
readAsTextAsync(
|
||||
fileName: string | AdmZip.IZipEntry,
|
||||
callback: (data: string) => any,
|
||||
encoding?: string
|
||||
): void;
|
||||
/**
|
||||
* Remove the entry from the file or the entry and all its nested directories
|
||||
* and files if the given entry is a directory
|
||||
* @param entry String with the full path of the entry
|
||||
* and files if the given entry is a directory.
|
||||
* @param entry The full path of the entry or a `IZipEntry` object.
|
||||
*/
|
||||
deleteFile(entry: string): void;
|
||||
/**
|
||||
* Remove the entry from the file or the entry and all its nested directories
|
||||
* and files if the given entry is a directory
|
||||
* @param entry A ZipEntry object.
|
||||
*/
|
||||
deleteFile(entry: AdmZip.IZipEntry): void;
|
||||
deleteFile(entry: string | AdmZip.IZipEntry): void;
|
||||
/**
|
||||
* Adds a comment to the zip. The zip must be rewritten after
|
||||
* adding the comment.
|
||||
@@ -92,72 +58,55 @@ declare class AdmZip {
|
||||
*/
|
||||
addZipComment(comment: string): void;
|
||||
/**
|
||||
* Returns the zip comment
|
||||
* @return The zip comment.
|
||||
*/
|
||||
getZipComment(): string;
|
||||
/**
|
||||
* Adds a comment to a specified zipEntry. The zip must be rewritten after
|
||||
* Adds a comment to a specified file or `IZipEntry`. The zip must be rewritten after
|
||||
* adding the comment.
|
||||
* The comment cannot exceed 65535 characters in length.
|
||||
* @param entry String with the full path of the entry
|
||||
* @param entry The full path of the entry or a `IZipEntry` object.
|
||||
* @param comment The comment to add to the entry.
|
||||
*/
|
||||
addZipEntryComment(entry: string, comment: string): void;
|
||||
/**
|
||||
* Adds a comment to a specified zipEntry. The zip must be rewritten after
|
||||
* adding the comment.
|
||||
* The comment cannot exceed 65535 characters in length.
|
||||
* @param entry ZipEntry object.
|
||||
* @param comment The comment to add to the entry.
|
||||
*/
|
||||
addZipEntryComment(entry: AdmZip.IZipEntry, comment: string): void;
|
||||
addZipEntryComment(entry: string | AdmZip.IZipEntry, comment: string): void;
|
||||
/**
|
||||
* Returns the comment of the specified entry.
|
||||
* @param entry String with the full path of the entry.
|
||||
* @return String The comment of the specified entry.
|
||||
* @param entry The full path of the entry or a `IZipEntry` object.
|
||||
* @return The comment of the specified entry.
|
||||
*/
|
||||
getZipEntryComment(entry: string): string;
|
||||
/**
|
||||
* Returns the comment of the specified entry
|
||||
* @param entry ZipEntry object.
|
||||
* @return String The comment of the specified entry.
|
||||
*/
|
||||
getZipEntryComment(entry: AdmZip.IZipEntry): string;
|
||||
getZipEntryComment(entry: string | AdmZip.IZipEntry): string;
|
||||
/**
|
||||
* Updates the content of an existing entry inside the archive. The zip
|
||||
* must be rewritten after updating the content
|
||||
* @param entry String with the full path of the entry.
|
||||
* must be rewritten after updating the content.
|
||||
* @param entry The full path of the entry or a `IZipEntry` object.
|
||||
* @param content The entry's new contents.
|
||||
*/
|
||||
updateFile(entry: string, content: Buffer): void;
|
||||
/**
|
||||
* Updates the content of an existing entry inside the archive. The zip
|
||||
* must be rewritten after updating the content
|
||||
* @param entry ZipEntry object.
|
||||
* @param content The entry's new contents.
|
||||
*/
|
||||
updateFile(entry: AdmZip.IZipEntry, content: Buffer): void;
|
||||
updateFile(entry: string | AdmZip.IZipEntry, content: Buffer): void;
|
||||
/**
|
||||
* Adds a file from the disk to the archive.
|
||||
* @param localPath Path to a file on disk.
|
||||
* @param zipPath Path to a directory in the archive. Defaults to the empty
|
||||
* string.
|
||||
* @param zipName Name for the file.
|
||||
*/
|
||||
addLocalFile(localPath: string, zipPath?: string): void;
|
||||
addLocalFile(localPath: string, zipPath?: string, zipName?: string): void;
|
||||
/**
|
||||
* Adds a local directory and all its nested files and directories to the
|
||||
* archive.
|
||||
* @param localPath Path to a folder on disk.
|
||||
* @param zipPath Path to a folder in the archive. Defaults to an empty
|
||||
* string.
|
||||
* @param zipPath Path to a folder in the archive. Default: `""`.
|
||||
* @param filter RegExp or Function if files match will be included.
|
||||
*/
|
||||
addLocalFolder(localPath: string, zipPath?: string): void;
|
||||
addLocalFolder(
|
||||
localPath: string,
|
||||
zipPath?: string,
|
||||
filter?: RegExp | ((filename: string) => boolean)
|
||||
): void;
|
||||
/**
|
||||
* Allows you to create a entry (file or directory) in the zip file.
|
||||
* If you want to create a directory the entryName must end in / and a null
|
||||
* If you want to create a directory the `entryName` must end in `"/"` and a `null`
|
||||
* buffer should be provided.
|
||||
* @param entryName Entry path
|
||||
* @param entryName Entry path.
|
||||
* @param content Content to add to the entry; must be a 0-length buffer
|
||||
* for a directory.
|
||||
* @param comment Comment to add to the entry.
|
||||
@@ -165,89 +114,81 @@ declare class AdmZip {
|
||||
*/
|
||||
addFile(entryName: string, data: Buffer, comment?: string, attr?: number): void;
|
||||
/**
|
||||
* Returns an array of ZipEntry objects representing the files and folders
|
||||
* inside the archive
|
||||
* Returns an array of `IZipEntry` objects representing the files and folders
|
||||
* inside the archive.
|
||||
*/
|
||||
getEntries(): AdmZip.IZipEntry[];
|
||||
/**
|
||||
* Returns a ZipEntry object representing the file or folder specified by
|
||||
* ``name``.
|
||||
* Returns a `IZipEntry` object representing the file or folder specified by `name`.
|
||||
* @param name Name of the file or folder to retrieve.
|
||||
* @return ZipEntry The entry corresponding to the name.
|
||||
* @return The entry corresponding to the `name`.
|
||||
*/
|
||||
getEntry(name: string): AdmZip.IZipEntry;
|
||||
/**
|
||||
* Extracts the given entry to the given targetPath.
|
||||
* Extracts the given entry to the given `targetPath`.
|
||||
* If the entry is a directory inside the archive, the entire directory and
|
||||
* its subdirectories will be extracted.
|
||||
* @param entry String with the full path of the entry
|
||||
* @param targetPath Target folder where to write the file
|
||||
* @param maintainEntryPath If maintainEntryPath is true and the entry is
|
||||
* inside a folder, the entry folder will be created in targetPath as
|
||||
* well. Default is TRUE
|
||||
* @param entry The full path of the entry or a `IZipEntry` object.
|
||||
* @param targetPath Target folder where to write the file.
|
||||
* @param maintainEntryPath If maintainEntryPath is `true` and the entry is
|
||||
* inside a folder, the entry folder will be created in `targetPath` as
|
||||
* well. Default: `true`.
|
||||
* @param overwrite If the file already exists at the target path, the file
|
||||
* will be overwriten if this is true. Default is FALSE
|
||||
*
|
||||
* @return Boolean
|
||||
* will be overwriten if this is `true`. Default: `false`.
|
||||
*/
|
||||
extractEntryTo(entryPath: string, targetPath: string, maintainEntryPath?: boolean, overwrite?: boolean): boolean;
|
||||
extractEntryTo(
|
||||
entryPath: string | AdmZip.IZipEntry,
|
||||
targetPath: string,
|
||||
maintainEntryPath?: boolean,
|
||||
overwrite?: boolean
|
||||
): boolean;
|
||||
/**
|
||||
* Extracts the given entry to the given targetPath.
|
||||
* If the entry is a directory inside the archive, the entire directory and
|
||||
* its subdirectories will be extracted.
|
||||
* @param entry ZipEntry object
|
||||
* @param targetPath Target folder where to write the file
|
||||
* @param maintainEntryPath If maintainEntryPath is true and the entry is
|
||||
* inside a folder, the entry folder will be created in targetPath as
|
||||
* well. Default is TRUE
|
||||
* Extracts the entire archive to the given location.
|
||||
* @param targetPath Target location.
|
||||
* @param overwrite If the file already exists at the target path, the file
|
||||
* will be overwriten if this is true. Default is FALSE
|
||||
* @return Boolean
|
||||
*/
|
||||
extractEntryTo(entryPath: AdmZip.IZipEntry, targetPath: string, maintainEntryPath?: boolean, overwrite?: boolean): boolean;
|
||||
/**
|
||||
* Extracts the entire archive to the given location
|
||||
* @param targetPath Target location
|
||||
* @param overwrite If the file already exists at the target path, the file
|
||||
* will be overwriten if this is true. Default is FALSE
|
||||
* will be overwriten if this is `true`. Default: `false`.
|
||||
*/
|
||||
extractAllTo(targetPath: string, overwrite?: boolean): void;
|
||||
/**
|
||||
* Extracts the entire archive to the given location
|
||||
* @param targetPath Target location
|
||||
* Extracts the entire archive to the given location.
|
||||
* @param targetPath Target location.
|
||||
* @param overwrite If the file already exists at the target path, the file
|
||||
* will be overwriten if this is true. Default is FALSE
|
||||
* @param callback The callback function will be called afeter extraction
|
||||
* will be overwriten if this is `true`. Default: `false`.
|
||||
* @param callback The callback function will be called after extraction.
|
||||
*/
|
||||
extractAllToAsync(targetPath: string, overwrite: boolean, callback: (error: Error) => void): void;
|
||||
extractAllToAsync(
|
||||
targetPath: string,
|
||||
overwrite?: boolean,
|
||||
callback?: (error: Error) => void
|
||||
): void;
|
||||
/**
|
||||
* Writes the newly created zip file to disk at the specified location or
|
||||
* if a zip was opened and no ``targetFileName`` is provided, it will
|
||||
* overwrite the opened zip
|
||||
* @param targetFileName
|
||||
* if a zip was opened and no `targetFileName` is provided, it will
|
||||
* overwrite the opened zip.
|
||||
*/
|
||||
writeZip(targetPath?: string): void;
|
||||
writeZip(targetFileName?: string, callback?: (error: Error | null) => void): void;
|
||||
/**
|
||||
* Returns the content of the entire zip file as a Buffer object
|
||||
* @return Buffer
|
||||
* Returns the content of the entire zip file.
|
||||
*/
|
||||
toBuffer(): Buffer;
|
||||
}
|
||||
|
||||
declare namespace AdmZip {
|
||||
/**
|
||||
* The ZipEntry is more than a structure representing the entry inside the
|
||||
* The `IZipEntry` is more than a structure representing the entry inside the
|
||||
* zip file. Beside the normal attributes and headers a entry can have, the
|
||||
* class contains a reference to the part of the file where the compressed
|
||||
* data resides and decompresses it when requested. It also compresses the
|
||||
* data and creates the headers required to write in the zip file.
|
||||
*/
|
||||
// disable warning about the I-prefix in interface name to prevent breaking stuff for users without a major bump
|
||||
// tslint:disable-next-line:interface-name
|
||||
interface IZipEntry {
|
||||
/**
|
||||
* Represents the full name and path of the file
|
||||
*/
|
||||
entryName: string;
|
||||
rawEntryName: Buffer;
|
||||
readonly rawEntryName: Buffer;
|
||||
/**
|
||||
* Extra data associated with this entry.
|
||||
*/
|
||||
@@ -256,15 +197,16 @@ declare namespace AdmZip {
|
||||
* Entry comment.
|
||||
*/
|
||||
comment: string;
|
||||
name: string;
|
||||
readonly name: string;
|
||||
/**
|
||||
* Read-Only property that indicates the type of the entry.
|
||||
*/
|
||||
isDirectory: boolean;
|
||||
readonly isDirectory: boolean;
|
||||
/**
|
||||
* Get the header associated with this ZipEntry.
|
||||
*/
|
||||
header: Buffer;
|
||||
attr: number;
|
||||
/**
|
||||
* Retrieve the compressed data for this entry. Note that this may trigger
|
||||
* compression if any properties were modified.
|
||||
@@ -278,11 +220,7 @@ declare namespace AdmZip {
|
||||
/**
|
||||
* Set the (uncompressed) data to be associated with this entry.
|
||||
*/
|
||||
setData(value: string): void;
|
||||
/**
|
||||
* Set the (uncompressed) data to be associated with this entry.
|
||||
*/
|
||||
setData(value: Buffer): void;
|
||||
setData(value: string | Buffer): void;
|
||||
/**
|
||||
* Get the decompressed data associated with this entry.
|
||||
*/
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
@@ -20,4 +20,4 @@
|
||||
"index.d.ts",
|
||||
"adm-zip-tests.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
import * as Ajv from "ajv";
|
||||
|
||||
import ajvMergePatch = require("ajv-merge-patch");
|
||||
|
||||
const ajv = new Ajv();
|
||||
|
||||
ajvMergePatch(ajv); // $ExpectType void
|
||||
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
// Type definitions for ajv-merge-patch 4.1
|
||||
// Project: https://github.com/epoberezkin/ajv-merge-patch#readme
|
||||
// Definitions by: Zhu Zijia <https://github.com/littlepiggy03>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
import { Ajv } from "ajv";
|
||||
|
||||
declare function ajvMergePatch(ajv: Ajv): void;
|
||||
|
||||
export = ajvMergePatch;
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"ajv": ">=4.1.0"
|
||||
}
|
||||
}
|
||||
@@ -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",
|
||||
"ajv-merge-patch-tests.ts"
|
||||
]
|
||||
}
|
||||
Vendored
+1
-1
@@ -1,5 +1,5 @@
|
||||
// Type definitions for Alexa SDK for Node.js 1.1
|
||||
// Project: https://github.com/alexa/alexa-skills-kit-sdk-for-nodejs
|
||||
// Project: https://github.com/alexa/alexa-skill-sdk-for-nodejs
|
||||
// Definitions by: Pete Beegle <https://github.com/petebeegle>
|
||||
// Huw <https://github.com/hoo29>
|
||||
// pascalwhoop <https://github.com/pascalwhoop>
|
||||
|
||||
Vendored
+1
-1
@@ -1,5 +1,5 @@
|
||||
// Type definitions for alexa-voice-service 0.0
|
||||
// Project: https://github.com/miguelmota/alexa-voice-service.js
|
||||
// Project: https://github.com/miguelmota/alexa-voice-service
|
||||
// Definitions by: Dolan Miu <https://github.com/dolanmiu>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
|
||||
@@ -0,0 +1,325 @@
|
||||
import * as algoliasearch from 'algoliasearch';
|
||||
import * as algoliasearchHelper from 'algoliasearch-helper';
|
||||
// tslint:disable-next-line:no-duplicate-imports
|
||||
import { SearchResults, SearchParameters } from 'algoliasearch-helper';
|
||||
|
||||
// https://community.algolia.com/algoliasearch-helper-js/reference.html#module:algoliasearchHelper
|
||||
|
||||
const client = algoliasearch('latency', '6be0576ff61c053d5f9a3225e2a90f76');
|
||||
const helper = algoliasearchHelper(client, 'bestbuy', {
|
||||
facets: ['shipping'],
|
||||
disjunctiveFacets: ['category']
|
||||
});
|
||||
helper.on('result', (result) => {
|
||||
console.log(result);
|
||||
});
|
||||
helper.toggleRefine('Movies & TV Shows')
|
||||
.toggleRefine('Free shipping')
|
||||
.search();
|
||||
|
||||
const updateTheResult = (results: SearchResults, state: SearchParameters) => {
|
||||
console.log(results, state);
|
||||
};
|
||||
helper.on('result', updateTheResult);
|
||||
helper.once('result', updateTheResult);
|
||||
helper.removeListener('result', updateTheResult);
|
||||
helper.removeAllListeners('result');
|
||||
|
||||
() => {
|
||||
// Changing the number of records returned per page to 1
|
||||
// This example uses the callback API
|
||||
const state = helper.searchOnce({hitsPerPage: 1},
|
||||
(error, content: SearchResults, state: SearchParameters) => {});
|
||||
|
||||
// Changing the number of records returned per page to 1
|
||||
// This example uses the promise API
|
||||
const state1 = helper.searchOnce({hitsPerPage: 1})
|
||||
.then(promiseHandler);
|
||||
|
||||
function promiseHandler(res: {content: SearchResults, state: SearchParameters}) {
|
||||
// res contains
|
||||
// {
|
||||
// content : SearchResults
|
||||
// state : SearchParameters (the one used for this specific search)
|
||||
// }
|
||||
}
|
||||
};
|
||||
|
||||
helper.setIndex('highestPrice_products').getIndex();
|
||||
helper.setPage(0).nextPage().getPage();
|
||||
helper.setPage(1).previousPage().getPage();
|
||||
helper.setQueryParameter('hitsPerPage', 20).search();
|
||||
const hitsPerPage = helper.getQueryParameter('hitsPerPage');
|
||||
helper.addFacetRefinement('film-genre', 'comedy');
|
||||
helper.addFacetRefinement('film-genre', 'science-fiction');
|
||||
|
||||
() => {
|
||||
const indexName = 'test';
|
||||
const helper2 = algoliasearchHelper(client, indexName, {
|
||||
facets: ['nameOfTheAttribute']
|
||||
});
|
||||
};
|
||||
|
||||
// Removing all the refinements
|
||||
helper.clearRefinements().search();
|
||||
|
||||
// Removing all the filters on a the category attribute.
|
||||
helper.clearRefinements('category').search();
|
||||
|
||||
// Removing only the exclude filters on the category facet.
|
||||
helper.clearRefinements((value, attribute, type) => {
|
||||
return type === 'exclude' && attribute === 'category';
|
||||
}).search();
|
||||
|
||||
// https://community.algolia.com/algoliasearch-helper-js/reference.html#AlgoliaSearchHelper#hasRefinements
|
||||
|
||||
helper.hasRefinements('price'); // false
|
||||
helper.addNumericRefinement('price', '>', 100);
|
||||
helper.hasRefinements('price'); // true
|
||||
|
||||
helper.hasRefinements('color'); // false
|
||||
helper.addFacetRefinement('color', 'blue');
|
||||
helper.hasRefinements('color'); // true
|
||||
|
||||
helper.hasRefinements('material'); // false
|
||||
helper.addDisjunctiveFacetRefinement('material', 'plastic');
|
||||
helper.hasRefinements('material'); // true
|
||||
|
||||
helper.hasRefinements('categories'); // false
|
||||
helper.toggleFacetRefinement('categories', 'kitchen > knife');
|
||||
helper.hasRefinements('categories'); // true
|
||||
|
||||
// https://community.algolia.com/algoliasearch-helper-js/reference.html#AlgoliaSearchHelper#getRefinements
|
||||
|
||||
helper.addNumericRefinement('price', '>', 100);
|
||||
helper.getRefinements('price');
|
||||
|
||||
helper.addFacetRefinement('color', 'blue');
|
||||
helper.addFacetExclusion('color', 'red');
|
||||
helper.getRefinements('color');
|
||||
|
||||
helper.addDisjunctiveFacetRefinement('material', 'plastic');
|
||||
|
||||
helper.addDisjunctiveFacetRefinement('tech', 'crt');
|
||||
helper.addDisjunctiveFacetRefinement('tech', 'led');
|
||||
helper.addDisjunctiveFacetRefinement('tech', 'plasma');
|
||||
|
||||
() => {
|
||||
const helper2 = algoliasearchHelper(client, 'test', {
|
||||
disjunctiveFacets: ['nameOfTheAttribute']
|
||||
});
|
||||
};
|
||||
|
||||
// https://community.algolia.com/algoliasearch-helper-js/reference.html#AlgoliaSearchHelper#hasRefinements
|
||||
|
||||
// hasRefinements works with numeric, conjunctive, disjunctive and hierarchical filters
|
||||
helper.hasRefinements('price'); // false
|
||||
helper.addNumericRefinement('price', '>', 100);
|
||||
helper.hasRefinements('price'); // true
|
||||
|
||||
helper.hasRefinements('color'); // false
|
||||
helper.addFacetRefinement('color', 'blue');
|
||||
helper.hasRefinements('color'); // true
|
||||
|
||||
helper.hasRefinements('material'); // false
|
||||
helper.addDisjunctiveFacetRefinement('material', 'plastic');
|
||||
helper.hasRefinements('material'); // true
|
||||
|
||||
helper.hasRefinements('categories'); // false
|
||||
helper.toggleFacetRefinement('categories', 'kitchen > knife');
|
||||
helper.hasRefinements('categories'); // true
|
||||
|
||||
// https://community.algolia.com/algoliasearch-helper-js/reference.html#SearchResults#getFacetValues
|
||||
helper.on('result', (content) => {
|
||||
// get values ordered only by name ascending using the string predicate
|
||||
content.getFacetValues('city', {sortBy: ['name:asc']});
|
||||
// get values ordered only by count ascending using a function
|
||||
content.getFacetValues('city', {
|
||||
// this is equivalent to ['count:asc']
|
||||
sortBy(a: { count: number }, b: { count: number }) {
|
||||
if (a.count === b.count) return 0;
|
||||
if (a.count > b.count) return 1;
|
||||
if (b.count > a.count) return -1;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// https://community.algolia.com/algoliasearch-helper-js/reference.html#SearchParameters#addTagRefinement
|
||||
|
||||
const searchparameter = new SearchParameters();
|
||||
|
||||
// for price = 50 or 40
|
||||
searchparameter.addNumericRefinement('price', '=', [50, 40]);
|
||||
|
||||
// for size = 38 and 40
|
||||
searchparameter.addNumericRefinement('size', '=', 38);
|
||||
searchparameter.addNumericRefinement('size', '=', 40);
|
||||
|
||||
let queryParameters = new SearchParameters({}); // everything is optional
|
||||
queryParameters = new SearchParameters({
|
||||
advancedSyntax: true,
|
||||
allowTyposOnNumericTokens: true,
|
||||
analytics: true,
|
||||
analyticsTags: ['test'],
|
||||
aroundLatLng: 'latitude',
|
||||
aroundLatLngViaIP: true,
|
||||
aroundPrecision: 1,
|
||||
aroundRadius: 1,
|
||||
attributesToHighlight: ['test'],
|
||||
attributesToRetrieve: ['test'],
|
||||
attributesToSnippet: ['test'],
|
||||
disableExactOnAttributes: ['test'],
|
||||
disjunctiveFacets: ['test'],
|
||||
disjunctiveFacetsRefinements: { test: ['test'] },
|
||||
distinct: 2,
|
||||
enableExactOnSingleWordQuery: true,
|
||||
facets: ['test'],
|
||||
facetsExcludes: { test: ['test'] },
|
||||
facetsRefinements: { test: ['test'] },
|
||||
getRankingInfo: true,
|
||||
hierarchicalFacets: ['test'],
|
||||
hierarchicalFacetsRefinements: { test: ['test'] },
|
||||
highlightPostTag: 'test',
|
||||
highlightPreTag: 'test',
|
||||
hitsPerPage: 1,
|
||||
ignorePlurals: true,
|
||||
index: 'test',
|
||||
insideBoundingBox: [[1, 2, 3, 4]],
|
||||
insidePolygon: [[1, 2, 3, 4]],
|
||||
length: 2,
|
||||
maxValuesPerFacet: 1,
|
||||
minimumAroundRadius: 1,
|
||||
minProximity: 1,
|
||||
minWordSizefor1Typo: 1,
|
||||
minWordSizefor2Typos: 1,
|
||||
numericFilters: ['test'],
|
||||
numericRefinements: { test: { '=': [1], '>': [[2, 3]] } },
|
||||
offset: 1,
|
||||
optionalFacetFilters: 'test',
|
||||
optionalTagFilters: 'test',
|
||||
optionalWords: ['test'],
|
||||
page: 1,
|
||||
query: 'test',
|
||||
queryType: 'prefixAll',
|
||||
removeWordsIfNoResults: 'none',
|
||||
replaceSynonymsInHighlight: true,
|
||||
restrictSearchableAttributes: ['test'],
|
||||
snippetEllipsisText: '...',
|
||||
synonyms: true,
|
||||
tagFilters: ['test'],
|
||||
tagRefinements: ['test'],
|
||||
typoTolerance: true,
|
||||
});
|
||||
|
||||
queryParameters.advancedSyntax;
|
||||
queryParameters.allowTyposOnNumericTokens;
|
||||
queryParameters.analytics;
|
||||
queryParameters.analyticsTags;
|
||||
queryParameters.aroundLatLng;
|
||||
queryParameters.aroundLatLngViaIP;
|
||||
queryParameters.aroundPrecision;
|
||||
queryParameters.aroundRadius;
|
||||
queryParameters.attributesToHighlight;
|
||||
queryParameters.attributesToRetrieve;
|
||||
queryParameters.attributesToSnippet;
|
||||
queryParameters.disableExactOnAttributes;
|
||||
queryParameters.disjunctiveFacets;
|
||||
queryParameters.disjunctiveFacetsRefinements;
|
||||
queryParameters.distinct;
|
||||
queryParameters.enableExactOnSingleWordQuery;
|
||||
queryParameters.facets;
|
||||
queryParameters.facetsExcludes;
|
||||
queryParameters.facetsRefinements;
|
||||
queryParameters.getRankingInfo;
|
||||
queryParameters.hierarchicalFacets;
|
||||
queryParameters.hierarchicalFacetsRefinements;
|
||||
queryParameters.highlightPostTag;
|
||||
queryParameters.highlightPreTag;
|
||||
queryParameters.hitsPerPage;
|
||||
queryParameters.ignorePlurals;
|
||||
queryParameters.index;
|
||||
queryParameters.insideBoundingBox;
|
||||
queryParameters.insidePolygon;
|
||||
queryParameters.length;
|
||||
queryParameters.maxValuesPerFacet;
|
||||
queryParameters.minimumAroundRadius;
|
||||
queryParameters.minProximity;
|
||||
queryParameters.minWordSizefor1Typo;
|
||||
queryParameters.minWordSizefor2Typos;
|
||||
queryParameters.numericFilters;
|
||||
queryParameters.numericRefinements;
|
||||
queryParameters.offset;
|
||||
queryParameters.optionalFacetFilters;
|
||||
queryParameters.optionalTagFilters;
|
||||
queryParameters.optionalWords;
|
||||
queryParameters.page;
|
||||
queryParameters.query;
|
||||
queryParameters.queryType;
|
||||
queryParameters.removeWordsIfNoResults;
|
||||
queryParameters.replaceSynonymsInHighlight;
|
||||
queryParameters.restrictSearchableAttributes;
|
||||
queryParameters.snippetEllipsisText;
|
||||
queryParameters.synonyms;
|
||||
queryParameters.tagFilters;
|
||||
queryParameters.tagRefinements;
|
||||
queryParameters.typoTolerance;
|
||||
|
||||
queryParameters.addDisjunctiveFacet('test');
|
||||
queryParameters.addDisjunctiveFacetRefinement('test', 'test');
|
||||
queryParameters.addExcludeRefinement('test', 'test');
|
||||
queryParameters.addFacet('test');
|
||||
queryParameters.addFacetRefinement('test', 'test');
|
||||
queryParameters.addHierarchicalFacet({});
|
||||
queryParameters.addHierarchicalFacetRefinement('test', 'test');
|
||||
queryParameters.addNumericRefinement('test', '>', [7]);
|
||||
queryParameters.addTagRefinement('test');
|
||||
queryParameters.clearRefinements('test');
|
||||
queryParameters.clearTags();
|
||||
queryParameters.filter(['test']);
|
||||
queryParameters.getConjunctiveRefinements('test');
|
||||
queryParameters.getDisjunctiveRefinements('test');
|
||||
queryParameters.getExcludeRefinements('test');
|
||||
queryParameters.getHierarchicalFacetBreadcrumb('test');
|
||||
queryParameters.getHierarchicalFacetByName('test');
|
||||
queryParameters.getHierarchicalRefinement('test');
|
||||
queryParameters.getNumericRefinement('test', '=');
|
||||
queryParameters.getNumericRefinements('test');
|
||||
queryParameters.getQueryParameter('test');
|
||||
queryParameters.getRefinedDisjunctiveFacets('test', {});
|
||||
queryParameters.getRefinedHierarchicalFacets('test', {});
|
||||
queryParameters.getUnrefinedDisjunctiveFacets();
|
||||
queryParameters.isConjunctiveFacet('test');
|
||||
queryParameters.isDisjunctiveFacet('test');
|
||||
queryParameters.isDisjunctiveFacetRefined('test', 'test');
|
||||
queryParameters.isExcludeRefined('test', 'test');
|
||||
queryParameters.isFacetRefined('test', 'test');
|
||||
queryParameters.isHierarchicalFacet('test');
|
||||
queryParameters.isHierarchicalFacetRefined('test', 'test');
|
||||
queryParameters.isNumericRefined('test', '>', 'test');
|
||||
queryParameters.isTagRefined('test');
|
||||
queryParameters.removeDisjunctiveFacet('test');
|
||||
queryParameters.removeDisjunctiveFacetRefinement('test', 'test');
|
||||
queryParameters.removeExcludeRefinement('test', 'test');
|
||||
queryParameters.removeFacet('test');
|
||||
queryParameters.removeFacetRefinement('test', 'test');
|
||||
queryParameters.removeHierarchicalFacet('test');
|
||||
queryParameters.removeHierarchicalFacetRefinement('test');
|
||||
queryParameters.removeTagRefinement('test');
|
||||
queryParameters.setDisjunctiveFacets(['test']);
|
||||
queryParameters.setFacets(['test']);
|
||||
queryParameters.setHitsPerPage(1);
|
||||
queryParameters.setPage(1);
|
||||
queryParameters.setQuery('test');
|
||||
queryParameters.setQueryParameter('test', {});
|
||||
queryParameters.setQueryParameters({ test: {} });
|
||||
queryParameters.setTypoTolerance('test');
|
||||
queryParameters.toggleConjunctiveFacetRefinement('test', {});
|
||||
queryParameters.toggleDisjunctiveFacetRefinement('test', {});
|
||||
queryParameters.toggleExcludeFacetRefinement('test', {});
|
||||
queryParameters.toggleFacetRefinement('test', {});
|
||||
queryParameters.toggleHierarchicalFacetRefinement('test', {});
|
||||
queryParameters.toggleTagRefinement('test');
|
||||
|
||||
// static methods
|
||||
SearchParameters.make(queryParameters);
|
||||
SearchParameters.validate(queryParameters, { queryType: 'prefixAll' });
|
||||
+747
@@ -0,0 +1,747 @@
|
||||
// Type definitions for algoliasearch-helper 2.26
|
||||
// Project: https://community.algolia.com/algoliasearch-helper-js/
|
||||
// Definitions by: Gordon Burgett <https://github.com/gburgett>
|
||||
// Haroen Viaene <https://github.com/haroenv>
|
||||
// Samuel Vaillant <https://github.com/samouss>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import { Client } from 'algoliasearch';
|
||||
import { EventEmitter } from 'events';
|
||||
import algoliasearch = require('algoliasearch');
|
||||
|
||||
/**
|
||||
* The algoliasearchHelper module is the function that will let its
|
||||
* contains everything needed to use the Algoliasearch
|
||||
* Helper. It is a also a function that instanciate the helper.
|
||||
* To use the helper, you also need the Algolia JS client v3.
|
||||
* @param client an AlgoliaSearch client
|
||||
* @param index the name of the index to query
|
||||
* @param opts
|
||||
*/
|
||||
declare function algoliasearchHelper(client: Client, index: string, opts: algoliasearchHelper.QueryParameters): algoliasearchHelper.AlgoliaSearchHelper;
|
||||
|
||||
declare namespace algoliasearchHelper {
|
||||
export const version: string;
|
||||
|
||||
export class AlgoliaSearchHelper extends EventEmitter {
|
||||
state: SearchParameters;
|
||||
lastResults: SearchResults;
|
||||
derivedHelpers: AlgoliaSearchHelper[];
|
||||
|
||||
on(event: 'change' | 'search', cb: (state: SearchParameters, lastResults: SearchResults | null) => any): this;
|
||||
on(event: 'searchForFacetValues', cb: (state: SearchParameters, facet: string, query: string) => any): this;
|
||||
on(event: 'searchOnce', cb: (state: SearchParameters) => any): this;
|
||||
on(event: 'result', cb: (results: SearchResults, state: SearchParameters) => any): this;
|
||||
on(event: 'error', cb: (error: any) => any): this;
|
||||
on(event: 'searchQueueEmpty', cb: () => any): this;
|
||||
|
||||
/**
|
||||
* Start the search with the parameters set in the state. When the
|
||||
* method is called, it triggers a `search` event. The results will
|
||||
* be available through the `result` event. If an error occurs, an
|
||||
* `error` will be fired instead.
|
||||
* @return
|
||||
* @fires search
|
||||
* @fires result
|
||||
* @fires error
|
||||
* @chainable
|
||||
*/
|
||||
search(): this;
|
||||
|
||||
/**
|
||||
* Gets the search query parameters that would be sent to the Algolia Client
|
||||
* for the hits
|
||||
* @return Query Parameters
|
||||
*/
|
||||
getQuery(): QueryParameters;
|
||||
|
||||
/**
|
||||
* Start a search using a modified version of the current state. This method does
|
||||
* not trigger the helper lifecycle and does not modify the state kept internally
|
||||
* by the helper. This second aspect means that the next search call will be the
|
||||
* same as a search call before calling searchOnce.
|
||||
* @param options can contain all the parameters that can be set to SearchParameters
|
||||
* plus the index
|
||||
* @param [callback] optional callback executed when the response from the
|
||||
* server is back.
|
||||
* @return if a callback is passed the method returns undefined
|
||||
* otherwise it returns a promise containing an object with two keys :
|
||||
* - content with a SearchResults
|
||||
* - state with the state used for the query as a SearchParameters
|
||||
* @example
|
||||
* // Changing the number of records returned per page to 1
|
||||
* // This example uses the callback API
|
||||
* var state = helper.searchOnce({hitsPerPage: 1},
|
||||
* function(error, content, state) {
|
||||
* // if an error occurred it will be passed in error, otherwise its value is null
|
||||
* // content contains the results formatted as a SearchResults
|
||||
* // state is the instance of SearchParameters used for this search
|
||||
* });
|
||||
* @example
|
||||
* // Changing the number of records returned per page to 1
|
||||
* // This example uses the promise API
|
||||
* var state1 = helper.searchOnce({hitsPerPage: 1})
|
||||
* .then(promiseHandler);
|
||||
*
|
||||
* function promiseHandler(res) {
|
||||
* // res contains
|
||||
* // {
|
||||
* // content : SearchResults
|
||||
* // state : SearchParameters (the one used for this specific search)
|
||||
* // }
|
||||
* }
|
||||
*/
|
||||
searchOnce(options: QueryParameters): Promise<{ content: SearchResults, state: SearchParameters }>;
|
||||
searchOnce(options: QueryParameters, cb: (error: any, content: SearchResults, state: SearchParameters) => any): undefined;
|
||||
|
||||
/**
|
||||
* Search for facet values based on an query and the name of a faceted attribute. This
|
||||
* triggers a search and will return a promise. On top of using the query, it also sends
|
||||
* the parameters from the state so that the search is narrowed down to only the possible values.
|
||||
*
|
||||
* See the description of [FacetSearchResult](reference.html#FacetSearchResult)
|
||||
* @param facet the name of the faceted attribute
|
||||
* @param query the string query for the search
|
||||
* @param [maxFacetHits] the maximum number values returned. Should be > 0 and <= 100
|
||||
* @param [userState] the set of custom parameters to use on top of the current state. Setting a property to `undefined` removes
|
||||
* it in the generated query.
|
||||
* @return the results of the search
|
||||
*/
|
||||
searchForFacetValues(facet: string, query: string, maxFacetHits: number, userState: any): Promise<AlgoliaSearchHelper.FacetSearchResult>;
|
||||
|
||||
/**
|
||||
* Sets the text query used for the search.
|
||||
*
|
||||
* This method resets the current page to 0.
|
||||
* @param q the user query
|
||||
* @return
|
||||
* @fires change
|
||||
* @chainable
|
||||
*/
|
||||
setQuery(q: string): this;
|
||||
|
||||
/**
|
||||
* Remove all the types of refinements except tags. A string can be provided to remove
|
||||
* only the refinements of a specific attribute. For more advanced use case, you can
|
||||
* provide a function instead. This function should follow the
|
||||
* [clearCallback definition](#SearchParameters.clearCallback).
|
||||
*
|
||||
* This method resets the current page to 0.
|
||||
* @param [name] optional name of the facet / attribute on which we want to remove all refinements
|
||||
* @return
|
||||
* @fires change
|
||||
* @chainable
|
||||
* @example
|
||||
* // Removing all the refinements
|
||||
* helper.clearRefinements().search();
|
||||
* @example
|
||||
* // Removing all the filters on a the category attribute.
|
||||
* helper.clearRefinements('category').search();
|
||||
* @example
|
||||
* // Removing only the exclude filters on the category facet.
|
||||
* helper.clearRefinements(function(value, attribute, type) {
|
||||
* return type === 'exclude' && attribute === 'category';
|
||||
* }).search();
|
||||
*/
|
||||
clearRefinements(name?: string): this;
|
||||
clearRefinements(func: (value: any, attribute: string, type: string) => boolean): this;
|
||||
|
||||
/**
|
||||
* Remove all the tag filters.
|
||||
*
|
||||
* This method resets the current page to 0.
|
||||
* @return
|
||||
* @fires change
|
||||
* @chainable
|
||||
*/
|
||||
clearTags(): this;
|
||||
|
||||
/**
|
||||
* Updates the name of the index that will be targeted by the query.
|
||||
*
|
||||
* This method resets the current page to 0.
|
||||
* @param name the index name
|
||||
* @return
|
||||
* @fires change
|
||||
* @chainable
|
||||
*/
|
||||
setIndex(name: string): this;
|
||||
|
||||
addDisjunctiveFacetRefinement(...args: any[]): any;
|
||||
addDisjunctiveRefine(...args: any[]): any;
|
||||
addHierarchicalFacetRefinement(...args: any[]): any;
|
||||
addNumericRefinement(...args: any[]): any;
|
||||
addFacetRefinement(...args: any[]): any;
|
||||
addRefine(...args: any[]): any;
|
||||
addFacetExclusion(...args: any[]): any;
|
||||
addExclude(...args: any[]): any;
|
||||
addTag(...args: any[]): any;
|
||||
removeNumericRefinement(...args: any[]): any;
|
||||
removeDisjunctiveFacetRefinement(...args: any[]): any;
|
||||
removeDisjunctiveRefine(...args: any[]): any;
|
||||
removeHierarchicalFacetRefinement(...args: any[]): any;
|
||||
removeFacetRefinement(...args: any[]): any;
|
||||
removeRefine(...args: any[]): any;
|
||||
removeFacetExclusion(...args: any[]): any;
|
||||
removeExclude(...args: any[]): any;
|
||||
removeTag(...args: any[]): any;
|
||||
toggleFacetExclusion(...args: any[]): any;
|
||||
toggleExclude(...args: any[]): any;
|
||||
toggleRefinement(...args: any[]): any;
|
||||
toggleFacetRefinement(...args: any[]): any;
|
||||
toggleRefine(...args: any[]): any;
|
||||
toggleTag(...args: any[]): any;
|
||||
nextPage(...args: any[]): any;
|
||||
previousPage(...args: any[]): any;
|
||||
setCurrentPage(...args: any[]): any;
|
||||
setPage(...args: any[]): any;
|
||||
setQueryParameter(...args: any[]): any;
|
||||
|
||||
/**
|
||||
* Set the whole state (warning: will erase previous state)
|
||||
* @param newState the whole new state
|
||||
* @return
|
||||
* @fires change
|
||||
* @chainable
|
||||
*/
|
||||
setState(newState: QueryParameters): this;
|
||||
|
||||
/**
|
||||
* Get the current search state stored in the helper. This object is immutable.
|
||||
* @param [filters] optional filters to retrieve only a subset of the state
|
||||
* @return if filters is specified a plain object is
|
||||
* returned containing only the requested fields, otherwise return the unfiltered
|
||||
* state
|
||||
* @example
|
||||
* // Get the complete state as stored in the helper
|
||||
* helper.getState();
|
||||
* @example
|
||||
* // Get a part of the state with all the refinements on attributes and the query
|
||||
* helper.getState(['query', 'attribute:category']);
|
||||
*/
|
||||
getState(): SearchParameters;
|
||||
getState(filters: string[]): QueryParameters;
|
||||
|
||||
getStateAsQueryString(...args: any[]): any;
|
||||
setStateFromQueryString(...args: any[]): any;
|
||||
overrideStateWithoutTriggeringChangeEvent(...args: any[]): any;
|
||||
isRefined(...args: any[]): any;
|
||||
hasRefinements(...args: any[]): any;
|
||||
isExcluded(...args: any[]): any;
|
||||
isDisjunctiveRefined(...args: any[]): any;
|
||||
hasTag(...args: any[]): any;
|
||||
isTagRefined(...args: any[]): any;
|
||||
getIndex(...args: any[]): any;
|
||||
getCurrentPage(...args: any[]): any;
|
||||
getPage(...args: any[]): any;
|
||||
getTags(...args: any[]): any;
|
||||
getQueryParameter(...args: any[]): any;
|
||||
getRefinements(...args: any[]): any;
|
||||
getNumericRefinement(...args: any[]): any;
|
||||
getHierarchicalFacetBreadcrumb(...args: any[]): any;
|
||||
containsRefinement(...args: any[]): any;
|
||||
clearCache(...args: any[]): any;
|
||||
setClient(...args: any[]): any;
|
||||
getClient(...args: any[]): any;
|
||||
derive(...args: any[]): any;
|
||||
detachDerivedHelper(...args: any[]): any;
|
||||
hasPendingRequests(...args: any[]): any;
|
||||
}
|
||||
|
||||
namespace AlgoliaSearchHelper {
|
||||
/**
|
||||
* Structure of each result when using
|
||||
* [`searchForFacetValues()`](reference.html#AlgoliaSearchHelper#searchForFacetValues)
|
||||
*/
|
||||
interface FacetSearchHit {
|
||||
value: string;
|
||||
highlighted: string;
|
||||
count: number;
|
||||
isRefined: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Structure of the data resolved by the
|
||||
* [`searchForFacetValues()`](reference.html#AlgoliaSearchHelper#searchForFacetValues)
|
||||
* promise.
|
||||
*/
|
||||
interface FacetSearchResult {
|
||||
facetHits: FacetSearchHit;
|
||||
processingTimeMS: number;
|
||||
}
|
||||
}
|
||||
|
||||
export interface QueryParameters extends algoliasearch.QueryParameters {
|
||||
/**
|
||||
* Targeted index. This parameter is mandatory.
|
||||
*/
|
||||
index?: string;
|
||||
/**
|
||||
* This attribute contains the list of all the disjunctive facets
|
||||
* used. This list will be added to requested facets in the
|
||||
* [facets attribute](https://www.algolia.com/doc/rest-api/search#param-facets) sent to algolia.
|
||||
*/
|
||||
disjunctiveFacets?: string[];
|
||||
/**
|
||||
* This attribute contains the list of all the hierarchical facets
|
||||
* used. This list will be added to requested facets in the
|
||||
* [facets attribute](https://www.algolia.com/doc/rest-api/search#param-facets) sent to algolia.
|
||||
* Hierarchical facets are a sub type of disjunctive facets that
|
||||
* let you filter faceted attributes hierarchically.
|
||||
*/
|
||||
hierarchicalFacets?: string[] | object[];
|
||||
|
||||
// Refinements
|
||||
/**
|
||||
* This attribute contains all the filters that need to be
|
||||
* applied on the conjunctive facets. Each facet must be properly
|
||||
* defined in the `facets` attribute.
|
||||
*
|
||||
* The key is the name of the facet, and the `FacetList` contains all
|
||||
* filters selected for the associated facet name.
|
||||
*
|
||||
* When querying algolia, the values stored in this attribute will
|
||||
* be translated into the `facetFilters` attribute.
|
||||
*/
|
||||
facetsRefinements?: { [facet: string]: SearchParameters.FacetList };
|
||||
/**
|
||||
* This attribute contains all the filters that need to be
|
||||
* excluded from the conjunctive facets. Each facet must be properly
|
||||
* defined in the `facets` attribute.
|
||||
*
|
||||
* The key is the name of the facet, and the `FacetList` contains all
|
||||
* filters excluded for the associated facet name.
|
||||
*
|
||||
* When querying algolia, the values stored in this attribute will
|
||||
* be translated into the `facetFilters` attribute.
|
||||
*/
|
||||
facetsExcludes?: { [facet: string]: SearchParameters.FacetList };
|
||||
/**
|
||||
* This attribute contains all the filters that need to be
|
||||
* applied on the disjunctive facets. Each facet must be properly
|
||||
* defined in the `disjunctiveFacets` attribute.
|
||||
*
|
||||
* The key is the name of the facet, and the `FacetList` contains all
|
||||
* filters selected for the associated facet name.
|
||||
*
|
||||
* When querying algolia, the values stored in this attribute will
|
||||
* be translated into the `facetFilters` attribute.
|
||||
*/
|
||||
disjunctiveFacetsRefinements?: { [facet: string]: SearchParameters.FacetList };
|
||||
/**
|
||||
* This attribute contains all the filters that need to be
|
||||
* applied on the numeric attributes.
|
||||
*
|
||||
* The key is the name of the attribute, and the value is the
|
||||
* filters to apply to this attribute.
|
||||
*
|
||||
* When querying algolia, the values stored in this attribute will
|
||||
* be translated into the `numericFilters` attribute.
|
||||
*/
|
||||
numericRefinements?: { [facet: string]: SearchParameters.OperatorList };
|
||||
/**
|
||||
* This attribute contains all the tags used to refine the query.
|
||||
*
|
||||
* When querying algolia, the values stored in this attribute will
|
||||
* be translated into the `tagFilters` attribute.
|
||||
*/
|
||||
tagRefinements?: string[];
|
||||
/**
|
||||
* This attribute contains all the filters that need to be
|
||||
* applied on the hierarchical facets. Each facet must be properly
|
||||
* defined in the `hierarchicalFacets` attribute.
|
||||
*
|
||||
* The key is the name of the facet, and the `FacetList` contains all
|
||||
* filters selected for the associated facet name. The FacetList values
|
||||
* are structured as a string that contain the values for each level
|
||||
* separated by the configured separator.
|
||||
*
|
||||
* When querying algolia, the values stored in this attribute will
|
||||
* be translated into the `facetFilters` attribute.
|
||||
*/
|
||||
hierarchicalFacetsRefinements?: { [facet: string]: SearchParameters.FacetList };
|
||||
|
||||
/**
|
||||
* Contains the optional tag filters in the raw format of the Algolia API.
|
||||
* @see https://www.algolia.com/doc/rest#param-tagFilters
|
||||
*/
|
||||
optionalTagFilters?: string;
|
||||
|
||||
/**
|
||||
* Contains the optional facet filters in the raw format of the Algolia API.
|
||||
* @see https://www.algolia.com/doc/rest#param-tagFilters
|
||||
*/
|
||||
optionalFacetFilters?: string;
|
||||
|
||||
// Misc. parameters
|
||||
/**
|
||||
* Applies 'exact' on single word queries if the word contains at least 3 characters
|
||||
* and is not a stop word.
|
||||
* Can take two values?: true or false.
|
||||
* By default, its set to false.
|
||||
* @see https://www.algolia.com/doc/rest#param-enableExactOnSingleWordQuery
|
||||
*/
|
||||
enableExactOnSingleWordQuery?: boolean;
|
||||
}
|
||||
|
||||
export class SearchParameters implements QueryParameters {
|
||||
index?: string ;
|
||||
disjunctiveFacets?: string[] ;
|
||||
hierarchicalFacets?: string[] | object[] ;
|
||||
facetsRefinements?: { [facet: string]: string[]; } ;
|
||||
facetsExcludes?: { [facet: string]: string[]; } ;
|
||||
disjunctiveFacetsRefinements?: { [facet: string]: string[]; } ;
|
||||
numericRefinements?: { [facet: string]: SearchParameters.OperatorList };
|
||||
tagRefinements?: string[] ;
|
||||
hierarchicalFacetsRefinements?: { [facet: string]: string[]; } ;
|
||||
optionalTagFilters?: string ;
|
||||
optionalFacetFilters?: string ;
|
||||
hitsPerPage?: number ;
|
||||
maxValuesPerFacet?: number ;
|
||||
minWordSizefor1Typo?: number ;
|
||||
minWordSizefor2Typos?: number ;
|
||||
minProximity?: any;
|
||||
allowTyposOnNumericTokens?: boolean ;
|
||||
ignorePlurals?: boolean ;
|
||||
advancedSyntax?: boolean ;
|
||||
analytics?: boolean ;
|
||||
synonyms?: boolean ;
|
||||
replaceSynonymsInHighlight?: boolean ;
|
||||
highlightPreTag?: string ;
|
||||
highlightPostTag?: string ;
|
||||
distinct?: number | boolean ;
|
||||
aroundLatLng?: string ;
|
||||
aroundRadius?: number ;
|
||||
minimumAroundRadius?: number ;
|
||||
aroundPrecision?: number ;
|
||||
snippetEllipsisText?: string;
|
||||
enableExactOnSingleWordQuery?: boolean ;
|
||||
query?: string ;
|
||||
filters?: string ;
|
||||
attributesToRetrieve?: string[] ;
|
||||
restrictSearchableAttributes?: string[] ;
|
||||
facets?: string[] ;
|
||||
facetingAfterDistinct?: boolean ;
|
||||
attributesToHighlight?: string[] ;
|
||||
attributesToSnippet?: string[] ;
|
||||
restrictHighlightAndSnippetArrays?: boolean ;
|
||||
page?: number ;
|
||||
offset?: number ;
|
||||
length?: number ;
|
||||
typoTolerance?: boolean ;
|
||||
disableTypoToleranceOnAttributes?: string[] ;
|
||||
aroundLatLngViaIP?: boolean ;
|
||||
insideBoundingBox?: number[][] ;
|
||||
queryType?: "prefixAll" | "prefixLast" | "prefixNone" ;
|
||||
insidePolygon?: number[][] ;
|
||||
removeWordsIfNoResults?: "none" | "lastWords" | "firstWords" | "allOptional" ;
|
||||
optionalWords?: string[] ;
|
||||
removeStopWords?: boolean | string[] ;
|
||||
disableExactOnAttributes?: string[] ;
|
||||
exactOnSingleWordQuery?: "none" | "attribute" | "word" ;
|
||||
alternativesAsExact?: Array<"ignorePlurals" | "singleWordSynonym" | "multiWordsSynonym"> ;
|
||||
getRankingInfo?: boolean ;
|
||||
numericAttributesToIndex?: string[] ;
|
||||
numericAttributesForFiltering?: string[] ;
|
||||
numericFilters?: string[] ;
|
||||
tagFilters?: string[] ;
|
||||
facetFilters?: string[] | string[][] ;
|
||||
analyticsTags?: string[] ;
|
||||
nbShards?: number ;
|
||||
userData?: string | object ;
|
||||
|
||||
constructor(newParameters?: QueryParameters)
|
||||
|
||||
/* Add a disjunctive facet to the disjunctiveFacets attribute of the helper configuration, if it isn't already present. */
|
||||
addDisjunctiveFacet(facet: string): SearchParameters;
|
||||
/* Adds a refinement on a disjunctive facet. */
|
||||
addDisjunctiveFacetRefinement(facet: string, value: string): SearchParameters;
|
||||
/* Exclude a value from a "normal" facet */
|
||||
addExcludeRefinement(facet: string, value: string): SearchParameters;
|
||||
/* Add a facet to the facets attribute of the helper configuration, if it isn't already present. */
|
||||
addFacet(facet: string): SearchParameters;
|
||||
/* Add a refinement on a "normal" facet */
|
||||
addFacetRefinement(facet: string, value: string): SearchParameters;
|
||||
addHierarchicalFacet(facet: any): SearchParameters;
|
||||
addHierarchicalFacetRefinement(facet: string, path: string): SearchParameters;
|
||||
addNumericRefinement(attribute: string, operator: SearchParameters.Operator, value: number | number[]): SearchParameters;
|
||||
addTagRefinement(tag: string): SearchParameters;
|
||||
clearRefinements(attribute?: string | ((value: any, attribute: string, type: string) => any)): SearchParameters;
|
||||
clearTags(): SearchParameters;
|
||||
filter(filters: string[]): any;
|
||||
getConjunctiveRefinements(facetName: string): string[];
|
||||
getDisjunctiveRefinements(facetName: string): string[];
|
||||
getExcludeRefinements(facetName: string): string[];
|
||||
getHierarchicalFacetBreadcrumb(facetName: string): string[];
|
||||
getHierarchicalFacetByName(hierarchicalFacetName: string): any;
|
||||
getHierarchicalRefinement(facetName: string): string[];
|
||||
getNumericRefinements(facetName: string): SearchParameters.OperatorList[];
|
||||
getNumericRefinement(attribute: string, operator: SearchParameters.Operator): Array<number | number[]>;
|
||||
getQueryParameter(paramName: string): any;
|
||||
getRefinedDisjunctiveFacets(facet: string, value: any): string[];
|
||||
getRefinedHierarchicalFacets(facet: string, value: any): string[];
|
||||
getUnrefinedDisjunctiveFacets(): string[];
|
||||
isConjunctiveFacet(facet: string): boolean;
|
||||
isDisjunctiveFacetRefined(facet: string, value?: string): boolean;
|
||||
isDisjunctiveFacet(facet: string): boolean;
|
||||
isExcludeRefined(facet: string, value?: string): boolean;
|
||||
isFacetRefined(facet: string, value?: string): boolean;
|
||||
isHierarchicalFacetRefined(facet: string, value?: string): boolean;
|
||||
isHierarchicalFacet(facet: string): boolean;
|
||||
isNumericRefined(attribute: string, operator: SearchParameters.Operator, value?: string): boolean;
|
||||
isTagRefined(tag: string): boolean;
|
||||
static make(newParameters: QueryParameters): SearchParameters;
|
||||
removeExcludeRefinement(facet: string, value: string): SearchParameters;
|
||||
removeFacet(facet: string): SearchParameters;
|
||||
removeFacetRefinement(facet: string, value?: string): SearchParameters;
|
||||
removeDisjunctiveFacet(facet: string): SearchParameters;
|
||||
removeDisjunctiveFacetRefinement(facet: string, value?: string): SearchParameters;
|
||||
removeHierarchicalFacet(facet: string): SearchParameters;
|
||||
removeHierarchicalFacetRefinement(facet: string): SearchParameters;
|
||||
removeTagRefinement(tag: string): SearchParameters;
|
||||
setDisjunctiveFacets(facets: string[]): SearchParameters;
|
||||
setFacets(facets: string[]): SearchParameters;
|
||||
setHitsPerPage(n: number): SearchParameters;
|
||||
setPage(newPage: number): SearchParameters;
|
||||
setQueryParameters(params: { [key: string]: any }): SearchParameters;
|
||||
setQueryParameter(parameter: string, value: any): SearchParameters;
|
||||
setQuery(newQuery: string): SearchParameters;
|
||||
setTypoTolerance(typoTolerance: string): SearchParameters;
|
||||
toggleDisjunctiveFacetRefinement(facet: string, value: any): SearchParameters;
|
||||
toggleExcludeFacetRefinement(facet: string, value: any): SearchParameters;
|
||||
toggleConjunctiveFacetRefinement(facet: string, value: any): SearchParameters;
|
||||
toggleHierarchicalFacetRefinement(facet: string, value: any): SearchParameters;
|
||||
toggleFacetRefinement(facet: string, value: any): SearchParameters;
|
||||
toggleTagRefinement(tag: string): SearchParameters;
|
||||
static validate(currentState: SearchParameters, parameters: QueryParameters): null | Error;
|
||||
}
|
||||
|
||||
namespace SearchParameters {
|
||||
type FacetList = string[];
|
||||
|
||||
type OperatorList = {
|
||||
[k in Operator]?: Array<number | number[]>
|
||||
};
|
||||
type Operator = '=' | '>' | '>=' | '<' | '<=' | '!=';
|
||||
}
|
||||
|
||||
export class SearchResults {
|
||||
/**
|
||||
* query used to generate the results
|
||||
*/
|
||||
query: string;
|
||||
/**
|
||||
* The query as parsed by the engine given all the rules.
|
||||
*/
|
||||
parsedQuery: string;
|
||||
/**
|
||||
* all the records that match the search parameters. Each record is
|
||||
* augmented with a new attribute `_highlightResult`
|
||||
* which is an object keyed by attribute and with the following properties:
|
||||
* - `value` : the value of the facet highlighted (html)
|
||||
* - `matchLevel`: full, partial or none depending on how the query terms match
|
||||
*/
|
||||
hits: any[];
|
||||
/**
|
||||
* index where the results come from
|
||||
*/
|
||||
index: string;
|
||||
/**
|
||||
* number of hits per page requested
|
||||
*/
|
||||
hitsPerPage: number;
|
||||
/**
|
||||
* total number of hits of this query on the index
|
||||
*/
|
||||
nbHits: number;
|
||||
/**
|
||||
* total number of pages with respect to the number of hits per page and the total number of hits
|
||||
*/
|
||||
nbPages: number;
|
||||
/**
|
||||
* current page
|
||||
*/
|
||||
page: number;
|
||||
/**
|
||||
* sum of the processing time of all the queries
|
||||
*/
|
||||
processingTimeMS: number;
|
||||
/**
|
||||
* The position if the position was guessed by IP.
|
||||
* @example "48.8637,2.3615",
|
||||
*/
|
||||
aroundLatLng: string;
|
||||
/**
|
||||
* The radius computed by Algolia.
|
||||
* @example "126792922",
|
||||
*/
|
||||
automaticRadius: string;
|
||||
/**
|
||||
* String identifying the server used to serve this request.
|
||||
* @example "c7-use-2.algolia.net",
|
||||
*/
|
||||
serverUsed: string;
|
||||
/**
|
||||
* Boolean that indicates if the computation of the counts did time out.
|
||||
* @deprecated
|
||||
*/
|
||||
timeoutCounts: boolean;
|
||||
/**
|
||||
* Boolean that indicates if the computation of the hits did time out.
|
||||
* @deprecated
|
||||
*/
|
||||
timeoutHits: boolean;
|
||||
|
||||
/**
|
||||
* True if the counts of the facets is exhaustive
|
||||
*/
|
||||
exhaustiveFacetsCount: boolean;
|
||||
|
||||
/**
|
||||
* True if the number of hits is exhaustive
|
||||
*/
|
||||
exhaustiveNbHits: boolean;
|
||||
|
||||
/**
|
||||
* Contains the userData if they are set by a [query rule](https://www.algolia.com/doc/guides/query-rules/query-rules-overview/).
|
||||
*/
|
||||
userData: any[];
|
||||
|
||||
/**
|
||||
* queryID is the unique identifier of the query used to generate the current search results.
|
||||
* This value is only available if the `clickAnalytics` search parameter is set to `true`.
|
||||
*/
|
||||
queryID: string;
|
||||
|
||||
/**
|
||||
* disjunctive facets results
|
||||
*/
|
||||
disjunctiveFacets: SearchResults.Facet[];
|
||||
/**
|
||||
* disjunctive facets results
|
||||
*/
|
||||
hierarchicalFacets: SearchResults.HierarchicalFacet[];
|
||||
|
||||
/**
|
||||
* other facets results
|
||||
*/
|
||||
facets: SearchResults.Facet[];
|
||||
|
||||
_rawResults: any;
|
||||
_state: SearchParameters;
|
||||
|
||||
constructor(state: SearchParameters, results: any[])
|
||||
|
||||
/**
|
||||
* Get a facet object with its name
|
||||
* @deprecated
|
||||
* @param name name of the faceted attribute
|
||||
* @return the facet object
|
||||
*/
|
||||
getFacetByName(name: string): SearchResults.Facet;
|
||||
|
||||
/**
|
||||
* Get a the list of values for a given facet attribute. Those values are sorted
|
||||
* refinement first, descending count (bigger value on top), and name ascending
|
||||
* (alphabetical order). The sort formula can overridden using either string based
|
||||
* predicates or a function.
|
||||
*
|
||||
* This method will return all the values returned by the Algolia engine plus all
|
||||
* the values already refined. This means that it can happen that the
|
||||
* `maxValuesPerFacet` [configuration](https://www.algolia.com/doc/rest-api/search#param-maxValuesPerFacet)
|
||||
* might not be respected if you have facet values that are already refined.
|
||||
* @param attribute attribute name
|
||||
* @param opts configuration options.
|
||||
* @param opts.sortBy
|
||||
* When using strings, it consists of
|
||||
* the name of the [FacetValue](#SearchResults.FacetValue) or the
|
||||
* [HierarchicalFacet](#SearchResults.HierarchicalFacet) attributes with the
|
||||
* order (`asc` or `desc`). For example to order the value by count, the
|
||||
* argument would be `['count:asc']`.
|
||||
*
|
||||
* If only the attribute name is specified, the ordering defaults to the one
|
||||
* specified in the default value for this attribute.
|
||||
*
|
||||
* When not specified, the order is
|
||||
* ascending. This parameter can also be a function which takes two facet
|
||||
* values and should return a number, 0 if equal, 1 if the first argument is
|
||||
* bigger or -1 otherwise.
|
||||
*
|
||||
* The default value for this attribute `['isRefined:desc', 'count:desc', 'name:asc']`
|
||||
* @return depending on the type of facet of
|
||||
* the attribute requested (hierarchical, disjunctive or conjunctive)
|
||||
* @example
|
||||
* helper.on('results', function(content){
|
||||
* //get values ordered only by name ascending using the string predicate
|
||||
* content.getFacetValues('city', {sortBy: ['name:asc']});
|
||||
* //get values ordered only by count ascending using a function
|
||||
* content.getFacetValues('city', {
|
||||
* // this is equivalent to ['count:asc']
|
||||
* sortBy: function(a, b) {
|
||||
* if (a.count === b.count) return 0;
|
||||
* if (a.count > b.count) return 1;
|
||||
* if (b.count > a.count) return -1;
|
||||
* }
|
||||
* });
|
||||
* });
|
||||
*/
|
||||
getFacetValues(attribute: string, opts: any): SearchResults.FacetValue[] | SearchResults.HierarchicalFacet;
|
||||
|
||||
/**
|
||||
* Returns the facet stats if attribute is defined and the facet contains some.
|
||||
* Otherwise returns undefined.
|
||||
* @param attribute name of the faceted attribute
|
||||
* @return The stats of the facet
|
||||
*/
|
||||
getFacetStats(attribute: string): any;
|
||||
|
||||
/**
|
||||
* Returns all refinements for all filters + tags. It also provides
|
||||
* additional information: count and exhausistivity for each filter.
|
||||
*
|
||||
* See the [refinement type](#Refinement) for an exhaustive view of the available
|
||||
* data.
|
||||
*
|
||||
* @return all the refinements
|
||||
*/
|
||||
getRefinements(): SearchResults.Refinement[];
|
||||
}
|
||||
|
||||
namespace SearchResults {
|
||||
interface Facet {
|
||||
name: string;
|
||||
data: object;
|
||||
stats: object;
|
||||
}
|
||||
|
||||
interface HierarchicalFacet {
|
||||
name: string;
|
||||
count: number;
|
||||
path: string;
|
||||
isRefined: boolean;
|
||||
data: HierarchicalFacet[];
|
||||
}
|
||||
|
||||
interface FacetValue {
|
||||
name: string;
|
||||
count: number;
|
||||
isRefined: boolean;
|
||||
isExcluded: boolean;
|
||||
}
|
||||
|
||||
interface Refinement {
|
||||
type: `numeric` | `facet` | `exclude` | `disjunctive` | `hierarchical`;
|
||||
attributeName: string;
|
||||
name: string;
|
||||
numericValue: number;
|
||||
operator: string;
|
||||
count: number;
|
||||
exhaustive: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
export {};
|
||||
}
|
||||
|
||||
export = algoliasearchHelper;
|
||||
@@ -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",
|
||||
"algoliasearch-helper-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -97,6 +97,7 @@ let _algoliaIndexSettings: IndexSettings = {
|
||||
minProximity: 0,
|
||||
placeholders: { '': [''] },
|
||||
camelCaseAttributes: [''],
|
||||
sortFacetValuesBy: 'count',
|
||||
};
|
||||
|
||||
let _algoliaQueryParameters: QueryParameters = {
|
||||
@@ -124,7 +125,7 @@ let _algoliaQueryParameters: QueryParameters = {
|
||||
ignorePlurals: false,
|
||||
disableTypoToleranceOnAttributes: [''],
|
||||
aroundLatLng: '',
|
||||
aroundLatLngViaIP: '',
|
||||
aroundLatLngViaIP: true,
|
||||
aroundRadius: 0,
|
||||
aroundPrecision: 0,
|
||||
minimumAroundRadius: 0,
|
||||
@@ -150,6 +151,7 @@ let _algoliaQueryParameters: QueryParameters = {
|
||||
synonyms: true,
|
||||
replaceSynonymsInHighlight: false,
|
||||
minProximity: 0,
|
||||
sortFacetValuesBy: 'alpha',
|
||||
};
|
||||
|
||||
let client: Client = algoliasearch('', '');
|
||||
|
||||
Vendored
+9
-2
@@ -1279,7 +1279,7 @@ declare namespace algoliasearch {
|
||||
* default: ""
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/aroundLatLngViaIP/
|
||||
*/
|
||||
aroundLatLngViaIP?: string;
|
||||
aroundLatLngViaIP?: boolean;
|
||||
/**
|
||||
* Control the radius associated with a geo search. Defined in meters.
|
||||
* default: null
|
||||
@@ -1451,6 +1451,11 @@ declare namespace algoliasearch {
|
||||
|
||||
nbShards?: number;
|
||||
userData?: string | object;
|
||||
|
||||
/**
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/sortFacetValuesBy/
|
||||
*/
|
||||
sortFacetValuesBy?: 'count' | 'alpha';
|
||||
}
|
||||
|
||||
namespace SearchForFacetValues {
|
||||
@@ -1687,7 +1692,7 @@ declare namespace algoliasearch {
|
||||
* 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
|
||||
*/
|
||||
removeStopWords?: string[];
|
||||
removeStopWords?: boolean | string[];
|
||||
/**
|
||||
* List of attributes on which you want to apply word-splitting ("decompounding") for
|
||||
* each of the languages supported (German, Dutch, and Finnish as of 05/2018)
|
||||
@@ -1776,6 +1781,8 @@ declare namespace algoliasearch {
|
||||
https://www.algolia.com/doc/api-reference/api-parameters/camelCaseAttributes/
|
||||
*/
|
||||
camelCaseAttributes?: string[];
|
||||
|
||||
sortFacetValuesBy?: 'count' | 'alpha';
|
||||
}
|
||||
|
||||
interface Response {
|
||||
|
||||
Vendored
+5
@@ -531,6 +531,11 @@ declare namespace algoliasearch {
|
||||
|
||||
nbShards?: number;
|
||||
userData?: string | object;
|
||||
|
||||
/**
|
||||
* https://www.algolia.com/doc/api-reference/api-parameters/sortFacetValuesBy/
|
||||
*/
|
||||
sortFacetValuesBy?: 'count' | 'alpha';
|
||||
}
|
||||
|
||||
namespace SearchForFacetValues {
|
||||
|
||||
Vendored
+1
-1
@@ -1,5 +1,5 @@
|
||||
// Type definitions for ali-oss 6.0
|
||||
// Project: https://github.com/ali-sdk/ali-oss
|
||||
// Project: https://github.com/aliyun/oss-nodejs-sdk
|
||||
// Definitions by: Ptrdu <https://github.com/ptrdu>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
Vendored
+1
-1
@@ -148,7 +148,7 @@ declare module "alt/AltContainer" {
|
||||
stores?:Array<AltJS.AltStore<any>>;
|
||||
inject?:{[key:string]:any};
|
||||
actions?:{[key:string]:Object};
|
||||
render?:(...props:Array<any>) => React.ReactElement<any>;
|
||||
render?:(...props:Array<any>) => React.ReactElement;
|
||||
flux?:AltJS.Alt;
|
||||
transform?:(store:AltJS.AltStore<any>, actions:any) => any;
|
||||
shouldComponentUpdate?:(props:any) => boolean;
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Type definitions for amap-js-sdk 1.4
|
||||
// Type definitions for non-npm package amap-js-sdk 1.4
|
||||
// Project: http://lbs.amap.com/api/javascript-api/summary/
|
||||
// Definitions by: Bian Zhongjie <https://github.com/agasbzj>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
// Type definitions for amazon-cognito-auth-js 1.2
|
||||
// Project: https://github.com/aws/amazon-cognito-auth-js
|
||||
// Project: https://github.com/aws/amazon-cognito-auth-js, http://aws.amazon.com/cognito
|
||||
// Definitions by: Scott Escue <https://github.com/scottescue>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
Vendored
+1
-1
@@ -1,5 +1,5 @@
|
||||
// Type definitions for amCharts 3.21
|
||||
// Project: http://www.amcharts.com/
|
||||
// Project: https://amcharts.com
|
||||
// Definitions by: ldrick <https://github.com/ldrick>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
Vendored
+1
-1
@@ -1,5 +1,5 @@
|
||||
// Type definitions for AmplifyJs (using JQuery Deferred) 1.1
|
||||
// Project: http://amplifyjs.com/
|
||||
// Project: http://amplifyjs.com/, https://github.com/laurentiustamate94/amplify-deferred
|
||||
// Definitions by: Jonas Eriksson <https://github.com/joeriks>, Laurentiu Stamate <https://github.com/laurentiustamate94>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
Vendored
+1
-1
@@ -1,5 +1,5 @@
|
||||
// Type definitions for amqplib 0.5
|
||||
// Project: https://github.com/squaremo/amqp.node
|
||||
// Project: https://github.com/squaremo/amqp.node, http://squaremo.github.io/amqp.node
|
||||
// Definitions by: Michael Nahkies <https://github.com/mnahkies>, Ab Reitsma <https://github.com/abreits>, Nicolás Fantone <https://github.com/nfantone>, Nick Zelei <https://github.com/zelein>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
Vendored
+1
-1
@@ -1,5 +1,5 @@
|
||||
// Type definitions for analytics-node 3.1
|
||||
// Project: https://segment.com/docs/libraries/node/
|
||||
// Project: https://segment.com/docs/libraries/node/, https://github.com/segmentio/analytics-node
|
||||
// Definitions by: Andrew Fong <https://github.com/fongandrew>
|
||||
// Thomas Thiebaud <https://github.com/thomasthiebaud>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
Vendored
+1
-1
@@ -1,5 +1,5 @@
|
||||
// Type definitions for angular-gridster (gridster module) 0.13
|
||||
// Project: https://github.com/ManifestWebDesign/angular-gridster
|
||||
// Project: https://github.com/ManifestWebDesign/angular-gridster, http://manifestwebdesign.github.io/angular-gridster
|
||||
// Definitions by: Joao Monteiro <https://github.com/jpmnteiro>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
Vendored
+1
-1
@@ -1,5 +1,5 @@
|
||||
// Type definitions for angular-hotkeys 1.7
|
||||
// Project: https://github.com/chieffancypants/angular-hotkeys
|
||||
// Project: https://github.com/chieffancypants/angular-hotkeys, https://chieffancypants.github.io/angular-hotkeys
|
||||
// Definitions by: Jason Zhao <https://github.com/jlz27>
|
||||
// Stefan Steinhart <https://github.com/reppners>
|
||||
// Cyril Gandon <https://github.com/cyrilgandon>
|
||||
|
||||
Vendored
+2
-2
@@ -1,5 +1,5 @@
|
||||
// Type definitions for angular-material 1.1
|
||||
// Project: https://github.com/angular/material
|
||||
// Project: https://github.com/angular/material, https://material.angularjs.org
|
||||
// Definitions by: Blake Bigelow <https://github.com/blbigelow>, Peter Hajdu <https://github.com/PeterHajdu>, Davide Donadello <https://github.com/Dona278>, Geert Jansen <https://github.com/geertjansen>, Edward Knowles <https://github.com/eknowles>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
@@ -346,7 +346,7 @@ declare module 'angular' {
|
||||
interface IMenuService {
|
||||
close(): void;
|
||||
hide(response?: any, options?: any): IPromise<any>;
|
||||
open(event?: MouseEvent): void;
|
||||
open(event?: MouseEvent | JQueryEventObject): void;
|
||||
}
|
||||
|
||||
interface IColorPalette {
|
||||
|
||||
Vendored
+1
-1
@@ -1,5 +1,5 @@
|
||||
// Type definitions for angular-oauth2 4.1
|
||||
// Project: https://github.com/oauthjs/angular-oauth2
|
||||
// Project: https://github.com/oauthjs/angular-oauth2, https://github.com/seegno/angular-oauth2
|
||||
// Definitions by: Antério Vieira <https://github.com/anteriovieira>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
Vendored
+1
-1
@@ -1,5 +1,5 @@
|
||||
// Type definitions for angular-websocket 2.0
|
||||
// Project: https://github.com/AngularClass/angular-websocket
|
||||
// Project: https://github.com/gdi2290/angular-websocket, https://github.com/angular-class/angular-websocket
|
||||
// Definitions by: Nick Veys <https://github.com/nickveys>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
@@ -294,6 +294,14 @@ foo.then((x) => {
|
||||
x.toFixed();
|
||||
});
|
||||
|
||||
namespace TestPromiseInterop {
|
||||
declare const promiseInterop: ng.IPromise<number>;
|
||||
const ngStringPromise: ng.IPromise<string> =
|
||||
promiseInterop.then((num) => Promise.resolve(String(num)));
|
||||
const caughtStringPromise: ng.IPromise<string|number> =
|
||||
promiseInterop.catch((reason) => Promise.resolve('oh noes'));
|
||||
}
|
||||
|
||||
// $q signature tests
|
||||
namespace TestQ {
|
||||
interface AbcObject {
|
||||
|
||||
Vendored
+14
@@ -1197,6 +1197,15 @@ declare namespace angular {
|
||||
* the `notifyCallback` method. The promise can not be resolved or rejected from the
|
||||
* `notifyCallback` method.
|
||||
*/
|
||||
then<TResult1 = T, TResult2 = never>(
|
||||
successCallback?:
|
||||
| ((value: T) => PromiseLike<never> | PromiseLike<TResult1> | TResult1)
|
||||
| null,
|
||||
errorCallback?:
|
||||
| ((reason: any) => PromiseLike<never> | PromiseLike<TResult2> | TResult2)
|
||||
| null,
|
||||
notifyCallback?: (state: any) => any
|
||||
): IPromise<TResult1 | TResult2>;
|
||||
then<TResult1 = T, TResult2 = never>(
|
||||
successCallback?:
|
||||
| ((value: T) => IPromise<never> | IPromise<TResult1> | TResult1)
|
||||
@@ -1210,6 +1219,11 @@ declare namespace angular {
|
||||
/**
|
||||
* Shorthand for promise.then(null, errorCallback)
|
||||
*/
|
||||
catch<TResult = never>(
|
||||
onRejected?:
|
||||
| ((reason: any) => PromiseLike<never> | PromiseLike<TResult> | TResult)
|
||||
| null
|
||||
): IPromise<T | TResult>;
|
||||
catch<TResult = never>(
|
||||
onRejected?:
|
||||
| ((reason: any) => IPromise<never> | IPromise<TResult> | TResult)
|
||||
|
||||
@@ -11,7 +11,8 @@
|
||||
"lib": [
|
||||
"es5",
|
||||
"dom",
|
||||
"es2015.iterable"
|
||||
"es2015.iterable",
|
||||
"es2015.promise"
|
||||
],
|
||||
"noImplicitAny": false,
|
||||
"noImplicitThis": false,
|
||||
@@ -25,4 +26,4 @@
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -1,5 +1,5 @@
|
||||
// Type definitions for ansi 0.3
|
||||
// Project: https://www.npmjs.com/package/ansi
|
||||
// Project: https://github.com/tootallnate/ansi.js
|
||||
// Definitions by: Gustavo6046 <https://github.com/Gustavo6046>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.1
|
||||
|
||||
Vendored
+1
-1
@@ -1,5 +1,5 @@
|
||||
// Type definitions for anymatch 1.3
|
||||
// Project: https://github.com/es128/anymatch
|
||||
// Project: https://github.com/micromatch/anymatch
|
||||
// Definitions by: BendingBender <https://github.com/BendingBender>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -1,5 +1,5 @@
|
||||
// Type definitions for aos 3.0
|
||||
// Project: https://github.com/michalsnik/aos
|
||||
// Project: https://github.com/michalsnik/aos, https://michalsnik.github.io/aos
|
||||
// Definitions by: Rostislav Shermenyov <https://github.com/shermendev>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Type definitions for ArangoDB 3.4
|
||||
// Type definitions for non-npm package ArangoDB 3.4
|
||||
// Project: https://github.com/arangodb/arangodb
|
||||
// Definitions by: Alan Plum <https://github.com/pluma>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Type definitions for ArcGIS REST API 10.4
|
||||
// Type definitions for non-npm package ArcGIS REST API 10.4
|
||||
// Project: http://resources.arcgis.com/en/help/arcgis-rest-api/
|
||||
// Definitions by: Jeff Jacobson <https://github.com/JeffJacobson>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
Vendored
+1
-1
@@ -1,5 +1,5 @@
|
||||
// Type definitions for artillery 1.6
|
||||
// Project: https://github.com/shoreditch-ops/artillery#readme
|
||||
// Project: https://github.com/artilleryio/artillery
|
||||
// Definitions by: Kira McCoan <https://github.com/kmccoan-allocadia>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
import { Ber, BerReader, BerWriter } from 'asn1';
|
||||
|
||||
let buf: Buffer = Buffer.alloc(0);
|
||||
let bool = false;
|
||||
let str = '';
|
||||
let num = 0;
|
||||
let numOrNull: number | null = 0;
|
||||
const roStrArray: ReadonlyArray<string> = [str];
|
||||
|
||||
const reader = new BerReader(buf);
|
||||
numOrNull = reader.peek();
|
||||
bool = reader.readBoolean();
|
||||
numOrNull = reader.readByte(bool);
|
||||
num = reader.readEnumeration();
|
||||
num = reader.readInt();
|
||||
num = reader.readLength();
|
||||
num = reader.readLength(num);
|
||||
str = reader.readOID();
|
||||
str = reader.readOID(num);
|
||||
numOrNull = reader.readSequence();
|
||||
numOrNull = reader.readSequence(num);
|
||||
str = reader.readString();
|
||||
str = reader.readString(num);
|
||||
buf = reader.readString(num, bool);
|
||||
num = reader._readTag();
|
||||
num = reader._readTag(num);
|
||||
|
||||
let writer = new BerWriter();
|
||||
writer = new BerWriter({
|
||||
size: num,
|
||||
growthFactor: num,
|
||||
});
|
||||
|
||||
buf = writer.buffer;
|
||||
buf = writer._buf;
|
||||
num = writer._size;
|
||||
num = writer._offset;
|
||||
|
||||
writer.endSequence();
|
||||
writer.startSequence();
|
||||
writer.startSequence(num);
|
||||
writer.writeBoolean(bool);
|
||||
writer.writeBoolean(bool, num);
|
||||
writer.writeBuffer(buf, num);
|
||||
writer.writeByte(num);
|
||||
writer.writeEnumeration(num);
|
||||
writer.writeEnumeration(num, num);
|
||||
writer.writeInt(num);
|
||||
writer.writeInt(num, num);
|
||||
writer.writeLength(num);
|
||||
writer.writeNull();
|
||||
writer.writeOID(str, num);
|
||||
writer.writeString(str);
|
||||
writer.writeString(str, num);
|
||||
writer.writeStringArray(roStrArray);
|
||||
writer._ensure(num);
|
||||
|
||||
num = Ber.BMPString;
|
||||
num = Ber.BitString;
|
||||
num = Ber.Boolean;
|
||||
num = Ber.CharacterString;
|
||||
num = Ber.Constructor;
|
||||
num = Ber.Context;
|
||||
num = Ber.EOC;
|
||||
num = Ber.Enumeration;
|
||||
num = Ber.External;
|
||||
num = Ber.GeneralString;
|
||||
num = Ber.GeneralizedTime;
|
||||
num = Ber.GraphicString;
|
||||
num = Ber.IA5String;
|
||||
num = Ber.Integer;
|
||||
num = Ber.Null;
|
||||
num = Ber.NumericString;
|
||||
num = Ber.OID;
|
||||
num = Ber.ObjectDescriptor;
|
||||
num = Ber.OctetString;
|
||||
num = Ber.PDV;
|
||||
num = Ber.PrintableString;
|
||||
num = Ber.Real;
|
||||
num = Ber.RelativeOID;
|
||||
num = Ber.Sequence;
|
||||
num = Ber.Set;
|
||||
num = Ber.T61String;
|
||||
num = Ber.UTCTime;
|
||||
num = Ber.UniversalString;
|
||||
num = Ber.Utf8String;
|
||||
num = Ber.VideotexString;
|
||||
num = Ber.VisibleString;
|
||||
Vendored
+126
@@ -0,0 +1,126 @@
|
||||
// Type definitions for asn1 0.2
|
||||
// Project: https://github.com/joyent/node-asn1
|
||||
// Definitions by: Jim Geurts <https://github.com/jgeurts>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
/// <reference types="node" />
|
||||
|
||||
export class BerReader {
|
||||
readonly buffer: Buffer;
|
||||
readonly offset: number;
|
||||
readonly length: number;
|
||||
readonly remain: number;
|
||||
readonly _buf: Buffer;
|
||||
_size: number;
|
||||
_offset: number;
|
||||
|
||||
constructor(data: Buffer);
|
||||
|
||||
peek(): number | null;
|
||||
readBoolean(): boolean;
|
||||
readByte(peek: boolean): number | null;
|
||||
readEnumeration(): number;
|
||||
readInt(): number;
|
||||
readLength(offset?: number): number;
|
||||
readOID(tag?: number): string;
|
||||
readSequence(tag?: number): number | null;
|
||||
readString(tag?: number): string;
|
||||
readString(tag: number, retbuf: boolean): Buffer;
|
||||
_readTag(tag?: number): number;
|
||||
}
|
||||
|
||||
export class BerWriter {
|
||||
readonly buffer: Buffer;
|
||||
readonly _buf: Buffer;
|
||||
readonly _size: number;
|
||||
_offset: number;
|
||||
|
||||
constructor(options?: {
|
||||
size: number;
|
||||
growthFactor: number;
|
||||
});
|
||||
|
||||
endSequence(): void;
|
||||
startSequence(tag?: number): void;
|
||||
writeBoolean(b: boolean, tag?: number): void;
|
||||
writeBuffer(buf: Buffer, tag: number): void;
|
||||
writeByte(b: number): void;
|
||||
writeEnumeration(i: number, tag?: number): void;
|
||||
writeInt(i: number, tag?: number): void;
|
||||
writeLength(len: number): void;
|
||||
writeNull(): void;
|
||||
writeOID(s: string, tag: number): void;
|
||||
writeString(s: string, tag?: number): void;
|
||||
writeStringArray(strings: ReadonlyArray<string>): void;
|
||||
_ensure(length: number): void;
|
||||
}
|
||||
|
||||
export namespace Ber {
|
||||
const BMPString: number;
|
||||
const BitString: number;
|
||||
const Boolean: number;
|
||||
const CharacterString: number;
|
||||
const Constructor: number;
|
||||
const Context: number;
|
||||
const EOC: number;
|
||||
const Enumeration: number;
|
||||
const External: number;
|
||||
const GeneralString: number;
|
||||
const GeneralizedTime: number;
|
||||
const GraphicString: number;
|
||||
const IA5String: number;
|
||||
const Integer: number;
|
||||
const Null: number;
|
||||
const NumericString: number;
|
||||
const OID: number;
|
||||
const ObjectDescriptor: number;
|
||||
const OctetString: number;
|
||||
const PDV: number;
|
||||
const PrintableString: number;
|
||||
const Real: number;
|
||||
const RelativeOID: number;
|
||||
const Sequence: number;
|
||||
const Set: number;
|
||||
const T61String: number;
|
||||
const UTCTime: number;
|
||||
const UniversalString: number;
|
||||
const Utf8String: number;
|
||||
const VideotexString: number;
|
||||
const VisibleString: number;
|
||||
}
|
||||
/*
|
||||
declare enum BerType {
|
||||
EOC = 0,
|
||||
Boolean = 1,
|
||||
Integer = 2,
|
||||
BitString = 3,
|
||||
OctetString = 4,
|
||||
Null = 5,
|
||||
OID = 6,
|
||||
ObjectDescriptor = 7,
|
||||
External = 8,
|
||||
Real = 9, // float
|
||||
Enumeration = 10,
|
||||
PDV = 11,
|
||||
Utf8String = 12,
|
||||
RelativeOID = 13,
|
||||
Sequence = 16,
|
||||
Set = 17,
|
||||
NumericString = 18,
|
||||
PrintableString = 19,
|
||||
T61String = 20,
|
||||
VideotexString = 21,
|
||||
IA5String = 22,
|
||||
UTCTime = 23,
|
||||
GeneralizedTime = 24,
|
||||
GraphicString = 25,
|
||||
VisibleString = 26,
|
||||
GeneralString = 28,
|
||||
UniversalString = 29,
|
||||
CharacterString = 30,
|
||||
BMPString = 31,
|
||||
Constructor = 32,
|
||||
Context = 128,
|
||||
}
|
||||
|
||||
*/
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"noUnusedParameters": true,
|
||||
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"asn1-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
Vendored
+1
-1
@@ -1,5 +1,5 @@
|
||||
// Type definitions for commonjs-assert 1.4
|
||||
// Project: https://github.com/browserify/commonjs-assert
|
||||
// Project: https://github.com/browserify/commonjs-assert, https://github.com/defunctzombie/commonjs-assert
|
||||
// Definitions by: Nico Gallinal <https://github.com/nicoabie>
|
||||
// Linus Unnebäck <https://github.com/LinusU>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
// Type definitions for assets-webpack-plugin 3.5
|
||||
// Project: https://github.com/sporto/assets-webpack-plugin
|
||||
// Project: https://github.com/ztoben/assets-webpack-plugin
|
||||
// Definitions by: Michael Strobel <https://github.com/kryops>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
Vendored
+1
-1
@@ -1,5 +1,5 @@
|
||||
// Type definitions for async-lock 1.1
|
||||
// Project: https://github.com/rain1017/async-lock
|
||||
// Project: https://github.com/rain1017/async-lock, https://github.com/rogierschouten/async-lock
|
||||
// Definitions by: Elisée MAURER <https://github.com/elisee>
|
||||
// Alejandro <https://github.com/afharo>
|
||||
// Anatoly <https://github.com/rhymmor>
|
||||
|
||||
Vendored
+1
-1
@@ -1,5 +1,5 @@
|
||||
// Type definitions for async.nexttick 0.5
|
||||
// Project: https://www.npmjs.com/package/async.nexttick
|
||||
// Project: https://github.com/caolan/async
|
||||
// Definitions by: Damien "pyrho" Rajon <https://github.com/pyrho>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -1,5 +1,5 @@
|
||||
// Type definitions for Async 2.4
|
||||
// Project: https://github.com/caolan/async
|
||||
// Project: https://github.com/caolan/async, https://caolan.github.io/async
|
||||
// Definitions by: Boris Yankov <https://github.com/borisyankov>
|
||||
// Arseniy Maximov <https://github.com/kern0>
|
||||
// Joe Herman <https://github.com/Penryn>
|
||||
|
||||
Vendored
+2
-2
@@ -42,9 +42,9 @@ export interface ButtonProps {
|
||||
/** Provides a url for buttons being used as a link. */
|
||||
readonly href?: string;
|
||||
/** Places an icon within the button, after the button's text. */
|
||||
readonly iconAfter?: ReactElement<any>;
|
||||
readonly iconAfter?: ReactElement;
|
||||
/** Places an icon within the button, before the button's text. */
|
||||
readonly iconBefore?: ReactElement<any>;
|
||||
readonly iconBefore?: ReactElement;
|
||||
/** Pass a reference on to the styled component */
|
||||
readonly innerRef?: (instance: any) => void;
|
||||
/** Provide a unique id to the button. */
|
||||
|
||||
Vendored
+1
-1
@@ -1,5 +1,5 @@
|
||||
// Type definitions for atlaskit__calendar 5.0
|
||||
// Project: https://bitbucket.org/atlassian/atlaskit-mk-2/src/master/
|
||||
// Project: https://bitbucket.org/atlassian/atlaskit-mk-2/src/master/, https://bitbucket.org/atlassian/atlaskit-mk-2
|
||||
// Definitions by: Lee Standen <https://github.com/lstanden>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
+3
-3
@@ -12,9 +12,9 @@ export interface BaseProps {
|
||||
/** Label above the input. */
|
||||
label?: string;
|
||||
/** Component to be shown when reading only */
|
||||
readView: ReactElement<any>;
|
||||
readView: ReactElement;
|
||||
/** Component to be shown when editing. Should be an @atlaskit/input. */
|
||||
editView?: ReactElement<any>;
|
||||
editView?: ReactElement;
|
||||
/** Set whether the read view should fit width, most obvious when hovered. */
|
||||
isFitContainerWidthReadView?: boolean;
|
||||
/** Greys out text and shows spinner. Does not disable input. */
|
||||
@@ -38,7 +38,7 @@ export interface BaseProps {
|
||||
/** Set whether default stylings should be disabled when editing. */
|
||||
disableEditViewFieldBase?: boolean;
|
||||
/** Component to be shown in an @atlaskit/inline-dialog when edit view is open. */
|
||||
invalidMessage?: ReactElement<any>;
|
||||
invalidMessage?: ReactElement;
|
||||
}
|
||||
|
||||
export interface StatelessProps extends BaseProps {
|
||||
|
||||
Vendored
+1
-1
@@ -1,5 +1,5 @@
|
||||
// Type definitions for @atlaskit/layer 3.1
|
||||
// Project: https://bitbucket.org/atlassian/atlaskit-mk-2/src/master/
|
||||
// Project: https://bitbucket.org/atlassian/atlaskit-mk-2/src/master/, https://bitbucket.org/atlassian/atlaskit-mk-2
|
||||
// Definitions by: Lee Standen <https://github.com/lstanden>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
// Type definitions for @atlaskit/single-select 4.0
|
||||
// Project: https://bitbucket.org/atlassian/atlaskit-mk-2/src/master/
|
||||
// Project: https://bitbucket.org/atlassian/atlaskit-mk-2/src/master/, https://bitbucket.org/atlassian/atlaskit-mk-2
|
||||
// Definitions by: Lee Standen <https://github.com/lstanden>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Type definitions for Atom 1.31
|
||||
// Type definitions for non-npm package Atom 1.31
|
||||
// Project: https://github.com/atom/atom
|
||||
// Definitions by: GlenCFL <https://github.com/GlenCFL>
|
||||
// smhxx <https://github.com/smhxx>
|
||||
|
||||
Vendored
+10
@@ -569,6 +569,14 @@ export type SpecErrorCodes =
|
||||
export interface Auth0Error {
|
||||
error: LibErrorCodes | SpecErrorCodes | string;
|
||||
errorDescription: string;
|
||||
// Need to include non-intuitive error fields that Auth0 uses
|
||||
code?: string;
|
||||
description?: string;
|
||||
name?: string;
|
||||
policy?: string;
|
||||
original?: any;
|
||||
statusCode?: number;
|
||||
statusText?: string;
|
||||
}
|
||||
|
||||
export type Auth0ParseHashError = Auth0Error & {
|
||||
@@ -812,6 +820,8 @@ export interface AuthorizeOptions {
|
||||
login_hint?: string;
|
||||
prompt?: string;
|
||||
mode?: "login" | "signUp";
|
||||
accessType?: string;
|
||||
approvalPrompt?: string;
|
||||
}
|
||||
|
||||
export interface CheckSessionOptions extends AuthorizeOptions {
|
||||
|
||||
Vendored
+1
-1
@@ -1,5 +1,5 @@
|
||||
// Type definitions for auth0-lock 11.4
|
||||
// Project: http://auth0.com
|
||||
// Project: http://auth0.com, https://github.com/auth0/lock
|
||||
// Definitions by: Brian Caruso <https://github.com/carusology>
|
||||
// Dan Caddigan <https://github.com/goldcaddy77>
|
||||
// Larry Faudree <https://github.com/lfaudreejr>
|
||||
|
||||
Vendored
+1
-1
@@ -1,5 +1,5 @@
|
||||
// Type definitions for auto-launch 5.0
|
||||
// Project: https://github.com/Teamwork/node-auto-launch
|
||||
// Project: https://github.com/Teamwork/node-auto-launch, https://github.com/4ver/node-auto-launch
|
||||
// Definitions by: rhysd <https://github.com/rhysd>, Daniel Perez Alvarez <https://github.com/unindented>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -1,5 +1,5 @@
|
||||
// Type definitions for auto-sni 2.1
|
||||
// Project: https://www.npmjs.com/package/auto-sni
|
||||
// Project: https://github.com/dylanpiercey/auto-sni
|
||||
// Definitions by: Jan Wolf <https://github.com/janwo>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -1,5 +1,5 @@
|
||||
// Type definitions for AutobahnJS 0.9
|
||||
// Project: http://autobahn.ws/js/
|
||||
// Project: http://autobahn.ws/js/, https://github.com/crossbario/autobahn-js
|
||||
// Definitions by: Elad Zelingher <https://github.com/darkl>, Andy Hawkins <https://github.com/a904guy>, Wladimir Totino <https://github.com/valepu>, Mathias Teier <https://github.com/glenroy37>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
declare let str: string;
|
||||
declare let strOrNull: string | null;
|
||||
declare let strOrUndefined: string | undefined;
|
||||
declare let strOrUndefinedOrNull: string | undefined | null;
|
||||
declare let date: Date;
|
||||
declare let anyObj: any;
|
||||
declare let num: number;
|
||||
declare let error: Error;
|
||||
declare let bool: boolean;
|
||||
declare let boolOrUndefined: boolean | undefined;
|
||||
declare let numOrUndefined: number | undefined;
|
||||
declare let apiGwEvtReqCtx: AWSLambda.APIGatewayEventRequestContext;
|
||||
declare let apiGwEvtReqCtxOpt: AWSLambda.APIGatewayEventRequestContext | null | undefined;
|
||||
declare let apiGwEvt: AWSLambda.APIGatewayEvent;
|
||||
@@ -80,6 +82,11 @@ declare const scheduledEvent: AWSLambda.ScheduledEvent;
|
||||
str = apiGwEvtReqCtx.accountId;
|
||||
str = apiGwEvtReqCtx.apiId;
|
||||
authResponseContextOpt = apiGwEvtReqCtx.authorizer;
|
||||
numOrUndefined = apiGwEvtReqCtx.connectedAt;
|
||||
strOrUndefined = apiGwEvtReqCtx.connectionId;
|
||||
strOrUndefined = apiGwEvtReqCtx.domainName;
|
||||
strOrUndefined = apiGwEvtReqCtx.eventType;
|
||||
strOrUndefined = apiGwEvtReqCtx.extendedRequestId;
|
||||
str = apiGwEvtReqCtx.httpMethod;
|
||||
strOrNull = apiGwEvtReqCtx.identity.accessKey;
|
||||
strOrNull = apiGwEvtReqCtx.identity.accountId;
|
||||
@@ -94,11 +101,15 @@ str = apiGwEvtReqCtx.identity.sourceIp;
|
||||
strOrNull = apiGwEvtReqCtx.identity.user;
|
||||
strOrNull = apiGwEvtReqCtx.identity.userAgent;
|
||||
strOrNull = apiGwEvtReqCtx.identity.userArn;
|
||||
strOrUndefined = apiGwEvtReqCtx.messageDirection;
|
||||
strOrUndefinedOrNull = apiGwEvtReqCtx.messageId;
|
||||
str = apiGwEvtReqCtx.path;
|
||||
str = apiGwEvtReqCtx.stage;
|
||||
str = apiGwEvtReqCtx.requestId;
|
||||
strOrUndefined = apiGwEvtReqCtx.requestTime;
|
||||
str = apiGwEvtReqCtx.resourceId;
|
||||
str = apiGwEvtReqCtx.resourcePath;
|
||||
strOrUndefined = apiGwEvtReqCtx.routeKey;
|
||||
|
||||
/* API Gateway Event */
|
||||
strOrNull = apiGwEvt.body;
|
||||
@@ -1056,3 +1067,113 @@ const firehoseEventHandler: AWSLambda.FirehoseTransformationHandler = (
|
||||
]
|
||||
});
|
||||
};
|
||||
|
||||
declare let lexEvent: AWSLambda.LexEvent;
|
||||
lexEvent = {
|
||||
currentIntent: {
|
||||
name: 'intent-name',
|
||||
slots: {
|
||||
slot1: null,
|
||||
slot2: 'value2',
|
||||
},
|
||||
slotDetails: {
|
||||
slot1: {
|
||||
resolutions: [
|
||||
{ value: 'value1' },
|
||||
],
|
||||
originalValue: 'originalValue',
|
||||
}
|
||||
},
|
||||
confirmationStatus: 'None',
|
||||
},
|
||||
bot: {
|
||||
name: 'bot name',
|
||||
alias: 'bot alias',
|
||||
version: 'bot version',
|
||||
},
|
||||
userId: 'User ID specified in the POST request to Amazon Lex.',
|
||||
inputTranscript: 'Text used to process the request',
|
||||
invocationSource: 'FulfillmentCodeHook',
|
||||
outputDialogMode: 'Text',
|
||||
messageVersion: '1.0',
|
||||
sessionAttributes: {
|
||||
key1: 'value1',
|
||||
key2: 'value2',
|
||||
},
|
||||
requestAttributes: {
|
||||
key1: 'value1',
|
||||
key2: 'value2',
|
||||
}
|
||||
};
|
||||
|
||||
declare let lexResult: AWSLambda.LexResult;
|
||||
declare let lexDialogAction: AWSLambda.LexDialogAction;
|
||||
declare let lexDialogActionBase: AWSLambda.LexDialogActionBase;
|
||||
declare let lexDialogActionClose: AWSLambda.LexDialogActionClose;
|
||||
declare let lexDialogActionConfirmIntent: AWSLambda.LexDialogActionConfirmIntent;
|
||||
declare let lexDialogActionDelegate: AWSLambda.LexDialogActionDelegate;
|
||||
declare let lexDialogActionElicitIntent: AWSLambda.LexDialogActionElicitIntent;
|
||||
declare let lexDialogActionElicitSlot: AWSLambda.LexDialogActionElicitSlot;
|
||||
declare let lexGenericAttachment: AWSLambda.LexGenericAttachment;
|
||||
|
||||
lexResult = {
|
||||
sessionAttributes: {
|
||||
attrib1: 'Value One',
|
||||
},
|
||||
dialogAction: {
|
||||
type: 'Close',
|
||||
fulfillmentState: 'Failed',
|
||||
},
|
||||
};
|
||||
|
||||
str = lexGenericAttachment.title;
|
||||
str = lexGenericAttachment.subTitle;
|
||||
str = lexGenericAttachment.imageUrl;
|
||||
str = lexGenericAttachment.attachmentLinkUrl;
|
||||
str = lexGenericAttachment.buttons[0].text;
|
||||
str = lexGenericAttachment.buttons[0].value;
|
||||
|
||||
lexDialogAction.type === 'Close';
|
||||
lexDialogAction.type === 'ConfirmIntent';
|
||||
lexDialogAction.type === 'Delegate';
|
||||
lexDialogAction.type === 'ElicitIntent';
|
||||
lexDialogAction.type === 'ElicitSlot';
|
||||
|
||||
lexDialogActionBase.message!.contentType === 'CustomPayload';
|
||||
lexDialogActionBase.message!.contentType === 'PlainText';
|
||||
lexDialogActionBase.message!.contentType === 'SSML';
|
||||
str = lexDialogActionBase.message!.content;
|
||||
num = lexDialogActionBase.responseCard!.version;
|
||||
lexDialogActionBase.responseCard!.contentType === 'application/vnd.amazonaws.card.generic';
|
||||
// $ExpectType LexGenericAttachment
|
||||
lexDialogActionBase.responseCard!.genericAttachments[0];
|
||||
|
||||
lexDialogActionClose.type === 'Close';
|
||||
lexDialogActionClose.fulfillmentState === 'Failed';
|
||||
lexDialogActionClose.fulfillmentState === 'Fulfilled';
|
||||
|
||||
lexDialogActionConfirmIntent.type === 'ConfirmIntent';
|
||||
str = lexDialogActionConfirmIntent.intentName;
|
||||
strOrNull = lexDialogActionConfirmIntent.slots['example'];
|
||||
|
||||
lexDialogActionDelegate.type === 'Delegate';
|
||||
strOrNull = lexDialogActionDelegate.slots['example'];
|
||||
|
||||
lexDialogActionElicitIntent.type === 'ElicitIntent';
|
||||
lexDialogActionElicitSlot.type === 'ElicitSlot';
|
||||
strOrNull = lexDialogActionElicitSlot.slots['example'];
|
||||
str = lexDialogActionElicitSlot.slotToElicit;
|
||||
str = lexDialogActionElicitSlot.intentName;
|
||||
|
||||
const lexEventHandler: AWSLambda.LexHandler = async (
|
||||
event: AWSLambda.LexEvent,
|
||||
context: AWSLambda.Context,
|
||||
) => {
|
||||
// $ExpectType LexEvent
|
||||
event;
|
||||
|
||||
// $ExpectType Context
|
||||
context;
|
||||
str = context.functionName;
|
||||
return lexResult;
|
||||
};
|
||||
|
||||
Vendored
+107
@@ -25,6 +25,7 @@
|
||||
// Trevor Leach <https://github.com/trevor-leach>
|
||||
// James Gregory <https://github.com/jagregory>
|
||||
// Erik Dalén <https://github.com/dalen>
|
||||
// Loïk Gaonac'h <https://github.com/loikg>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
@@ -33,6 +34,11 @@ export interface APIGatewayEventRequestContext {
|
||||
accountId: string;
|
||||
apiId: string;
|
||||
authorizer?: AuthResponseContext | null;
|
||||
connectedAt: number;
|
||||
connectionId?: string;
|
||||
domainName?: string;
|
||||
eventType?: string;
|
||||
extendedRequestId?: string;
|
||||
httpMethod: string;
|
||||
identity: {
|
||||
accessKey: string | null;
|
||||
@@ -49,12 +55,16 @@ export interface APIGatewayEventRequestContext {
|
||||
userAgent: string | null;
|
||||
userArn: string | null;
|
||||
};
|
||||
messageDirection?: string;
|
||||
messageId?: string | null;
|
||||
path: string;
|
||||
stage: string;
|
||||
requestId: string;
|
||||
requestTime?: string;
|
||||
requestTimeEpoch: number;
|
||||
resourceId: string;
|
||||
resourcePath: string;
|
||||
routeKey?: string;
|
||||
}
|
||||
|
||||
// API Gateway "event"
|
||||
@@ -876,6 +886,100 @@ export interface SQSMessageAttributes {
|
||||
[name: string]: SQSMessageAttribute;
|
||||
}
|
||||
|
||||
// Lex
|
||||
// https://docs.aws.amazon.com/lambda/latest/dg/invoking-lambda-function.html#supported-event-source-lex
|
||||
export interface LexEvent {
|
||||
currentIntent: {
|
||||
name: string;
|
||||
slots: { [name: string]: string | null };
|
||||
slotDetails: LexSlotDetails;
|
||||
confirmationStatus: 'None' | 'Confirmed' | 'Denied';
|
||||
};
|
||||
bot: {
|
||||
name: string;
|
||||
alias: string;
|
||||
version: string;
|
||||
};
|
||||
userId: string;
|
||||
inputTranscript: string;
|
||||
invocationSource: 'DialogCodeHook' | 'FulfillmentCodeHook';
|
||||
outputDialogMode: 'Text' | 'Voice';
|
||||
messageVersion: '1.0';
|
||||
sessionAttributes: { [key: string]: string };
|
||||
requestAttributes: { [key: string]: string } | null;
|
||||
}
|
||||
|
||||
export interface LexSlotResolution {
|
||||
value: string;
|
||||
}
|
||||
|
||||
export interface LexSlotDetails {
|
||||
[name: string]: {
|
||||
// The following line only works in TypeScript Version: 3.0, The array should have at least 1 and no more than 5 items
|
||||
// resolutions: [LexSlotResolution, LexSlotResolution?, LexSlotResolution?, LexSlotResolution?, LexSlotResolution?];
|
||||
resolutions: LexSlotResolution[]
|
||||
originalValue: string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface LexGenericAttachment {
|
||||
title: string;
|
||||
subTitle: string;
|
||||
imageUrl: string;
|
||||
attachmentLinkUrl: string;
|
||||
buttons: Array<{
|
||||
text: string;
|
||||
value: string;
|
||||
}>;
|
||||
}
|
||||
|
||||
export interface LexDialogActionBase {
|
||||
type: 'Close' | 'ElicitIntent' | 'ElicitSlot' | 'ConfirmIntent';
|
||||
message?: {
|
||||
contentType: 'PlainText' | 'SSML' | 'CustomPayload';
|
||||
content: string;
|
||||
};
|
||||
responseCard?: {
|
||||
version: number;
|
||||
contentType: 'application/vnd.amazonaws.card.generic';
|
||||
genericAttachments: LexGenericAttachment[];
|
||||
};
|
||||
}
|
||||
|
||||
export interface LexDialogActionClose extends LexDialogActionBase {
|
||||
type: 'Close';
|
||||
fulfillmentState: 'Fulfilled' | 'Failed';
|
||||
}
|
||||
|
||||
export interface LexDialogActionElicitIntent extends LexDialogActionBase {
|
||||
type: 'ElicitIntent';
|
||||
}
|
||||
|
||||
export interface LexDialogActionElicitSlot extends LexDialogActionBase {
|
||||
type: 'ElicitSlot';
|
||||
intentName: string;
|
||||
slots: { [name: string]: string | null };
|
||||
slotToElicit: string;
|
||||
}
|
||||
|
||||
export interface LexDialogActionConfirmIntent extends LexDialogActionBase {
|
||||
type: 'ConfirmIntent';
|
||||
intentName: string;
|
||||
slots: { [name: string]: string | null };
|
||||
}
|
||||
|
||||
export interface LexDialogActionDelegate {
|
||||
type: 'Delegate';
|
||||
slots: { [name: string]: string | null };
|
||||
}
|
||||
|
||||
export type LexDialogAction = LexDialogActionClose | LexDialogActionElicitIntent | LexDialogActionElicitSlot | LexDialogActionConfirmIntent | LexDialogActionDelegate;
|
||||
|
||||
export interface LexResult {
|
||||
sessionAttributes?: { [key: string]: string };
|
||||
dialogAction: LexDialogAction;
|
||||
}
|
||||
|
||||
/**
|
||||
* AWS Lambda handler function.
|
||||
* http://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-handler.html
|
||||
@@ -938,6 +1042,9 @@ export type ScheduledHandler = Handler<ScheduledEvent, void>;
|
||||
|
||||
// TODO: Alexa
|
||||
|
||||
export type LexHandler = Handler<LexEvent, LexResult>;
|
||||
export type LexCallback = Callback<LexResult>;
|
||||
|
||||
export type APIGatewayProxyHandler = Handler<APIGatewayProxyEvent, APIGatewayProxyResult>;
|
||||
export type APIGatewayProxyCallback = Callback<APIGatewayProxyResult>;
|
||||
export type ProxyHandler = APIGatewayProxyHandler; // Old name
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
import { SSM } from 'aws-sdk';
|
||||
import {
|
||||
ParameterQuery,
|
||||
parameterQuery,
|
||||
getParameter,
|
||||
getParameters,
|
||||
getParametersByPath,
|
||||
getParameterSync,
|
||||
getParametersSync,
|
||||
getParametersByPathSync,
|
||||
} from 'aws-param-store';
|
||||
|
||||
declare let bool: boolean;
|
||||
declare let query: ParameterQuery;
|
||||
declare let psName: SSM.Types.PSParameterName;
|
||||
declare let psNames: SSM.Types.ParameterNameList;
|
||||
declare let options: SSM.Types.ClientConfiguration;
|
||||
declare let paramResult: SSM.Types.Parameter;
|
||||
declare let paramsResult: SSM.Types.GetParametersResult;
|
||||
declare let paramsByPathResult: SSM.Types.ParameterList;
|
||||
declare let allParamResults: SSM.Types.Parameter | SSM.Types.GetParametersByPathResult | SSM.Types.ParameterList;
|
||||
declare let promiseParamResult: Promise<SSM.Types.Parameter>;
|
||||
declare let promiseParamsResult: Promise<SSM.Types.GetParametersResult>;
|
||||
declare let promiseParamsByPathResult: Promise<SSM.Types.ParameterList>;
|
||||
declare let promiseAllParamResults: Promise<typeof allParamResults>;
|
||||
|
||||
query = parameterQuery();
|
||||
|
||||
query.path(psName);
|
||||
query.named(psName);
|
||||
query.named(psNames);
|
||||
query.decryption(bool);
|
||||
query.recursive(bool);
|
||||
|
||||
promiseAllParamResults = query.execute();
|
||||
allParamResults = query.executeSync();
|
||||
|
||||
// test chaining
|
||||
query = query
|
||||
.path(psName)
|
||||
.named(psName)
|
||||
.named(psNames)
|
||||
.decryption(bool)
|
||||
.recursive(bool);
|
||||
|
||||
promiseAllParamResults = query
|
||||
.path(psName)
|
||||
.named(psName)
|
||||
.named(psNames)
|
||||
.decryption(bool)
|
||||
.recursive(bool)
|
||||
.execute();
|
||||
|
||||
allParamResults = query
|
||||
.path(psName)
|
||||
.named(psName)
|
||||
.named(psNames)
|
||||
.decryption(bool)
|
||||
.recursive(bool)
|
||||
.executeSync();
|
||||
|
||||
promiseParamResult = getParameter(psName);
|
||||
promiseParamResult = getParameter(psName, options);
|
||||
|
||||
promiseParamsResult = getParameters(psNames);
|
||||
promiseParamsResult = getParameters(psNames, options);
|
||||
|
||||
promiseParamsByPathResult = getParametersByPath(psNames);
|
||||
promiseParamsByPathResult = getParametersByPath(psNames, options);
|
||||
|
||||
paramResult = getParameterSync(psName);
|
||||
paramResult = getParameterSync(psName, options);
|
||||
|
||||
paramsResult = getParametersSync(psNames);
|
||||
paramsResult = getParametersSync(psNames, options);
|
||||
|
||||
paramsByPathResult = getParametersByPathSync(psNames);
|
||||
paramsByPathResult = getParametersByPathSync(psNames, options);
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user