mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-07 08:17:05 +00:00
Merge remote-tracking branch 'origin/master' into feature/react-bootstrap-table-next
This commit is contained in:
+344
-190
File diff suppressed because it is too large
Load Diff
@@ -20,6 +20,7 @@ If adding a new definition:
|
||||
If changing an existing definition:
|
||||
- [ ] Provide a URL to documentation or source code which provides context for the suggested changes: <<url here>>
|
||||
- [ ] If this PR brings the type definitions up to date with a new version of the JS library, update the version number in the header.
|
||||
- [ ] Include [tests for your changes](https://github.com/DefinitelyTyped/DefinitelyTyped#testing)
|
||||
- [ ] If you are making substantial changes, consider adding a `tslint.json` containing `{ "extends": "dtslint/dt.json" }`. If for reason the any rule need to be disabled, disable it for that line using `// tslint:disable-next-line [ruleName]` and not for whole package so that the need for disabling can be reviewed.
|
||||
|
||||
If removing a declaration:
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"$schema": "http://json.schemastore.org/prettierrc",
|
||||
"arrowParens": "avoid",
|
||||
"singleQuote": true,
|
||||
"trailingComma": "all",
|
||||
"tabWidth": 4,
|
||||
|
||||
+40
-4
@@ -6,6 +6,8 @@
|
||||
|
||||
*你可以去看其他语言的 README,[英语](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/README.md),[西班牙语](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/README.es.md),[韩语](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/README.ko.md),[俄罗斯语](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/README.ru.md)*
|
||||
|
||||
*[管理员手册](./docs/admin.md)*
|
||||
|
||||
## 目录
|
||||
|
||||
* [当前状态](#当前状态)
|
||||
@@ -57,13 +59,43 @@ npm install --save-dev @types/node
|
||||
这通常会在 `package.json` 文件中的 `"types"` 或 `"typings"` 字段中提供,
|
||||
或者可以只查找包中的任何 ".d.ts" 文件并手动将它们包含在 `/// <reference path="" />`.
|
||||
|
||||
### 其他方法
|
||||
#### 旧版本的 TypeScript(2.7 和更早版本)
|
||||
|
||||
Definitely Typed 仅在小于 2 年的 TypeScript 版本上测试软件包。当前已测试 2.8 及更高版本。如果您使用的是 TypeScript 2.0 到 2.7,仍然可以尝试安装 @types 软件包,大多数软件包都不使用 TypeScript 的新特性。但是不能保证它们会起作用,这是支持窗口:
|
||||
|
||||
Version | Released | End of Support
|
||||
-- | -- | --
|
||||
2.8 | March 2018 | March 2020
|
||||
2.9 | May 2018 | May 2020
|
||||
3.0 | July 2018 | July 2020
|
||||
3.1 | September 2018 | September 2020
|
||||
3.2 | November 2018 | November 2020
|
||||
3.3 | January 2019 | January 2021
|
||||
3.4 | March 2019 | March 2021
|
||||
3.5 | May 2019 | May 2021
|
||||
3.6 | August 2019 | August 2021
|
||||
3.7 | November 2019 | November 2021
|
||||
3.8 | February 2020 | February 2022
|
||||
|
||||
`@types` 软件包具有它们明确支持的 TypeScript 版本的标记,因此通常可以获取早于 2 年窗口的较早版本的软件包。例如,如果运行 `npm dist-tags @types/react`,您将看到 TypeScript 2.5 可以将类型用于 react@16.0,而 TypeScript 2.6 和 2.7 可以将类型用于 react@16.4:
|
||||
|
||||
|Tag | Version|
|
||||
|----|---------|
|
||||
|latest| 16.9.23|
|
||||
|ts2.0| 15.0.1|
|
||||
| ... | ... |
|
||||
|ts2.5| 16.0.36|
|
||||
|ts2.6| 16.4.7|
|
||||
|ts2.7| 16.4.7|
|
||||
| ... | ... |
|
||||
|
||||
#### TypeScript 1.*
|
||||
|
||||
这些可以被 TypeScript 1.0 使用。
|
||||
|
||||
* [Typings](https://github.com/typings/typings)
|
||||
* 从该仓库的 `master` 分支手动下载并将其放入您的项目中
|
||||
* ~~[Typings](https://github.com/typings/typings)~~ (使用首选替代方案,typings 已经被弃用)
|
||||
* ~~[NuGet](http://nuget.org/packages?q=DefinitelyTyped)~~ (使用首选替代方案, nuget DT 类型发布已关闭)
|
||||
* 从这个仓库的 `master` 分支手动下载
|
||||
|
||||
你可能需要手动添加 [引用](http://www.typescriptlang.org/docs/handbook/triple-slash-directives.html)。
|
||||
|
||||
@@ -152,7 +184,11 @@ Definitely Typed 的成员会定期查看新的 PRs,但是请记住当有许
|
||||
#### 常见错误
|
||||
|
||||
* 首先,请遵循 [手册](http://www.typescriptlang.org/docs/handbook/declaration-files/do-s-and-don-ts.html) 的建议。
|
||||
* 格式化:使用4个空格。 对于新代码,这由 Prettier 强制执行。
|
||||
* 格式化:使用4个空格。 该仓库已经设置了 prettier,因此你只需要运行 `npm run prettier -- --write path/to/package/**/*.ts`. [使用断言时](https://github.com/SamVerschueren/tsd#assertions),添加 `// prettier-ignore` 将这几行标记为不需要格式化的代码:
|
||||
```tsx
|
||||
// prettier-ignore
|
||||
const incompleteThemeColorModes: Theme = { colors: { modes: { papaya: { // $ExpectError
|
||||
```
|
||||
* `function sum(nums: number[]): number`: 如果函数没有写入的参数,请使用 `ReadonlyArray`.
|
||||
* `interface Foo { new(): Foo; }`:
|
||||
这定义了一个可实例化的类型,你可能需要的是 `declare class Foo { constructor(); }`.
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
* [Current status](#current-status)
|
||||
* [How can I contribute?](#how-can-i-contribute)
|
||||
* [Test](#test)
|
||||
* [Testing](#testing)
|
||||
* [Make a pull request](#make-a-pull-request)
|
||||
* [Edit an existing package](#edit-an-existing-package)
|
||||
* [Create a new package](#create-a-new-package)
|
||||
@@ -112,17 +112,16 @@ You may need to add manual [references](http://www.typescriptlang.org/docs/handb
|
||||
|
||||
Definitely Typed only works because of contributions by users like you!
|
||||
|
||||
### Test
|
||||
### Testing
|
||||
|
||||
Before you share your improvement with the world, use it yourself.
|
||||
|
||||
#### Test editing an existing package
|
||||
|
||||
To add new features you can use [module augmentation](http://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation).
|
||||
You can also directly edit the types in `node_modules/@types/foo/index.d.ts`, or copy them from there and follow the steps below.
|
||||
To test local to your app, you can use [module augmentation](http://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation) to extend existing types from the DT module you want to work on.
|
||||
Alternatively, you can also edit the types directly in `node_modules/@types/foo/index.d.ts` to validate your changes, then bring the changes to this repo with the steps below.
|
||||
|
||||
|
||||
#### Test a new package
|
||||
#### Adding tests to a new package
|
||||
|
||||
Add to your `tsconfig.json`:
|
||||
|
||||
@@ -131,10 +130,12 @@ Add to your `tsconfig.json`:
|
||||
"typeRoots": ["types"],
|
||||
```
|
||||
|
||||
(You can also use `src/types`.)
|
||||
Create `types/foo/index.d.ts` containing declarations for the module "foo".
|
||||
You should now be able to import from `"foo"` in your code and it will route to the new type definition.
|
||||
Then build *and* run the code to make sure your type definition actually corresponds to what happens at runtime.
|
||||
|
||||
If you're wondering where to start with test code, the examples in the README of the module are a great place to start.
|
||||
|
||||
Once you've tested your definitions with real code, make a [PR](#make-a-pull-request)
|
||||
then follow the instructions to [edit an existing package](#edit-an-existing-package) or
|
||||
[create a new package](#create-a-new-package).
|
||||
@@ -167,6 +168,39 @@ First, [fork](https://guides.github.com/activities/forking/) this repository, in
|
||||
When you make a PR to edit an existing package, `dt-bot` should @-mention previous authors.
|
||||
If it doesn't, you can do so yourself in the comment associated with the PR.
|
||||
|
||||
#### Editing tests on an existing package
|
||||
|
||||
There should be a `[modulename]-tests.ts` file, which is considered your test file, along with any `*.ts` files it imports.
|
||||
If you don't see any test files in the module's folder, create a `[modulename]-tests.ts`.
|
||||
These files are used to validate the API exported from the `*.d.ts` files which are shipped as `@types/yourmodule`.
|
||||
|
||||
Changes to the `*.d.ts` files should include a corresponding `*.ts` file change which shows the API being used, so that someone doesn't accidentally break code you depend on.
|
||||
If you don't see any test files in the module's folder, create a `[modulename]-tests.ts`
|
||||
|
||||
For example, this change to a function in a `.d.ts` file adding an a new param to a function:
|
||||
|
||||
`index.d.ts`:
|
||||
|
||||
```diff
|
||||
- export function twoslash(body: string): string
|
||||
+ export function twoslash(body: string, config?: { version: string }): string
|
||||
```
|
||||
|
||||
`index-tests.ts`:
|
||||
```diff
|
||||
import {twoslash} from "./"
|
||||
|
||||
// $ExpectType string
|
||||
const result = twoslash("//")
|
||||
|
||||
+ // Handle options param
|
||||
+ const resultWithOptions = twoslash("//", { version: "3.7" })
|
||||
+ // When the param is incorrect
|
||||
+ // $ExpectError
|
||||
+ const resultWithOptions = twoslash("//", { })
|
||||
```
|
||||
|
||||
You can validate your changes with `npm test` from the root of this repo, which takes changed files into account.
|
||||
|
||||
#### Create a new package
|
||||
|
||||
|
||||
+24
-6
@@ -564,6 +564,12 @@
|
||||
"sourceRepoURL": "https://github.com/sindresorhus/clipboardy",
|
||||
"asOfVersion": "2.0.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "cloudevents-sdk",
|
||||
"typingsPackageName": "cloudevents-sdk",
|
||||
"sourceRepoURL": "https://github.com/cloudevents/sdk-javascript",
|
||||
"asOfVersion": "1.0.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "colors.js (colors)",
|
||||
"typingsPackageName": "colors",
|
||||
@@ -984,6 +990,12 @@
|
||||
"sourceRepoURL": "https://github.com/jonathantneal/document-promises#readme",
|
||||
"asOfVersion": "4.0.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "docx-templates",
|
||||
"typingsPackageName": "docx-templates",
|
||||
"sourceRepoURL": "https://github.com/guigrpa/docx-templates",
|
||||
"asOfVersion": "4.0.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "dom-helpers",
|
||||
"typingsPackageName": "dom-helpers",
|
||||
@@ -4032,6 +4044,12 @@
|
||||
"sourceRepoURL": "https://github.com/yonahforst/react-native-permissions",
|
||||
"asOfVersion": "2.0.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "react-native-responsive-dimensions",
|
||||
"typingsPackageName": "react-native-responsive-dimensions",
|
||||
"sourceRepoURL": "https://github.com/DaniAkash/react-native-responsive-dimensions",
|
||||
"asOfVersion": "3.1.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "react-native-safe-area",
|
||||
"typingsPackageName": "react-native-safe-area",
|
||||
@@ -5016,18 +5034,18 @@
|
||||
"sourceRepoURL": "https://github.com/arendjr/text-clipper",
|
||||
"asOfVersion": "1.3.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "theming",
|
||||
"typingsPackageName": "theming",
|
||||
"sourceRepoURL": "https://github.com/cssinjs/theming",
|
||||
"asOfVersion": "2.0.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "theme-ui",
|
||||
"typingsPackageName": "theme-ui__color",
|
||||
"sourceRepoURL": "https://github.com/system-ui/theme-ui",
|
||||
"asOfVersion": "0.3.1"
|
||||
},
|
||||
{
|
||||
"libraryName": "theming",
|
||||
"typingsPackageName": "theming",
|
||||
"sourceRepoURL": "https://github.com/cssinjs/theming",
|
||||
"asOfVersion": "2.0.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "three",
|
||||
"typingsPackageName": "three",
|
||||
|
||||
+3
-2
@@ -24,7 +24,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"dtslint": "latest",
|
||||
"prettier": "^1.17.1",
|
||||
"prettier": "^2.0.2",
|
||||
"types-publisher": "github:Microsoft/types-publisher#production"
|
||||
},
|
||||
"husky": {
|
||||
@@ -32,5 +32,6 @@
|
||||
"_comment": "This will remove husky from when we started migrating to use prettier",
|
||||
"pre-commit": "npm uninstall husky"
|
||||
}
|
||||
}
|
||||
},
|
||||
"dependencies": {}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
import abs = require('abs-svg-path');
|
||||
const absolutized = abs([['M', 10, 10], ['l', 100, 100]]); // $ExpectType AbsAnyCommand[]
|
||||
Vendored
+43
@@ -0,0 +1,43 @@
|
||||
// Type definitions for abs-svg-path 0.1
|
||||
// Project: https://github.com/jkroso/abs-svg-path
|
||||
// Definitions by: Liam Martens <https://github.com/LiamMartens>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
type RelMoveCommand = ['m', number, number];
|
||||
type AbsMoveCommand = ['M', number, number];
|
||||
type MoveCommand = RelMoveCommand | AbsMoveCommand;
|
||||
type RelLineCommand = ['l', number, number];
|
||||
type AbsLineCommand = ['L', number, number];
|
||||
type LineCommand = RelLineCommand | AbsLineCommand;
|
||||
type RelHorizontalCommand = ['h', number];
|
||||
type AbsHorizontalCommand = ['H', number];
|
||||
type HorizontalCommand = RelHorizontalCommand | AbsHorizontalCommand;
|
||||
type RelVerticalCommand = ['v', number];
|
||||
type AbsVerticalCommand = ['V', number];
|
||||
type VerticalCommand = RelVerticalCommand | AbsVerticalCommand;
|
||||
type RelClosePathCommand = ['z'];
|
||||
type AbsClosePathCommand = ['Z'];
|
||||
type ClosePathCommand = RelClosePathCommand | AbsClosePathCommand;
|
||||
type RelBezierCurveCommand = ['c', number, number, number, number, number, number];
|
||||
type AbsBezierCurveCommand = ['C', number, number, number, number, number, number];
|
||||
type BezierCurveCommand = RelBezierCurveCommand | AbsBezierCurveCommand;
|
||||
type RelFollowingBezierCurveCommand = ['s', number, number, number, number];
|
||||
type AbsFollowingBezierCurveCommand = ['S', number, number, number, number];
|
||||
type FollowingBezierCurveCommand = RelFollowingBezierCurveCommand | AbsFollowingBezierCurveCommand;
|
||||
type RelQuadraticCurveCommand = ['q', number, number, number, number];
|
||||
type AbsQuadraticCurveCommand = ['Q', number, number, number, number];
|
||||
type QuadraticCurveCommand = RelQuadraticCurveCommand | AbsQuadraticCurveCommand;
|
||||
type RelFollowingQuadraticCurveCommand = ['t', number, number];
|
||||
type AbsFollowingQuadraticCurveCommand = ['T', number, number];
|
||||
type FollowingQuadraticCurveCommand = RelFollowingQuadraticCurveCommand | AbsFollowingQuadraticCurveCommand;
|
||||
type RelArcCommand = ['a', number, number, number, number, number, number, number];
|
||||
type AbsArcCommand = ['A', number, number, number, number, number, number, number];
|
||||
type ArcCommand = RelArcCommand | AbsArcCommand;
|
||||
type AnyCommand = MoveCommand | LineCommand | HorizontalCommand | VerticalCommand |
|
||||
ClosePathCommand | BezierCurveCommand | FollowingBezierCurveCommand |
|
||||
QuadraticCurveCommand | FollowingQuadraticCurveCommand | ArcCommand;
|
||||
type AbsAnyCommand = AbsMoveCommand | AbsLineCommand | AbsHorizontalCommand | AbsVerticalCommand |
|
||||
AbsClosePathCommand | AbsBezierCurveCommand | AbsFollowingBezierCurveCommand |
|
||||
AbsQuadraticCurveCommand | AbsFollowingQuadraticCurveCommand | AbsArcCommand;
|
||||
declare function absolutize(path: AnyCommand[]): AbsAnyCommand[];
|
||||
export = absolutize;
|
||||
+1
-1
@@ -18,6 +18,6 @@
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"react-native-responsive-dimensions-tests.ts"
|
||||
"abs-svg-path-tests.ts"
|
||||
]
|
||||
}
|
||||
Vendored
+1
-1
@@ -3080,7 +3080,7 @@ declare namespace AceAjax {
|
||||
docHTML?: string;
|
||||
}
|
||||
|
||||
export type CompletionCallback = (error: Error, results: Completion[]) => void;
|
||||
export type CompletionCallback = (error: Error | null, results: Completion[]) => void;
|
||||
}
|
||||
|
||||
declare var ace: AceAjax.Ace;
|
||||
|
||||
@@ -13,19 +13,11 @@ zipEntries.forEach(zipEntry => {
|
||||
// outputs the content of 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);
|
||||
// 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
|
||||
new AdmZip();
|
||||
@@ -36,6 +28,13 @@ zip.addFile('test.txt', new Buffer('inner content of the file'), 'entry comment
|
||||
zip.addLocalFile('/home/me/some_picture.png');
|
||||
// get everything as a buffer
|
||||
const willSendthis = zip.toBuffer();
|
||||
|
||||
zip.toBuffer(
|
||||
buffer => console.log(buffer.length),
|
||||
() => {},
|
||||
name => console.log(name),
|
||||
name => console.log(name),
|
||||
);
|
||||
// or write everything to disk
|
||||
zip.writeZip(/*target file name*/ '/home/me/files.zip');
|
||||
|
||||
|
||||
Vendored
+19
-20
@@ -3,6 +3,7 @@
|
||||
// Definitions by: John Vilk <https://github.com/jvilk>
|
||||
// Abner Oliveira <https://github.com/abner>
|
||||
// BendingBender <https://github.com/BendingBender>
|
||||
// Matthew Sainsbury <https://github.com/mattsains>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
@@ -23,10 +24,7 @@ declare class AdmZip {
|
||||
* @param entry The full path of the entry or a `IZipEntry` object.
|
||||
* @param callback Called with a `Buffer` or `null` in case of error.
|
||||
*/
|
||||
readFileAsync(
|
||||
entry: string | AdmZip.IZipEntry,
|
||||
callback: (data: Buffer | null, 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.
|
||||
@@ -40,11 +38,7 @@ declare class AdmZip {
|
||||
* @param callback Called with the resulting string.
|
||||
* @param encoding If no encoding is specified `"utf8"` is used.
|
||||
*/
|
||||
readAsTextAsync(
|
||||
fileName: string | 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.
|
||||
@@ -97,11 +91,7 @@ declare class AdmZip {
|
||||
* @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,
|
||||
filter?: RegExp | ((filename: string) => boolean)
|
||||
): 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`
|
||||
@@ -140,7 +130,7 @@ declare class AdmZip {
|
||||
entryPath: string | AdmZip.IZipEntry,
|
||||
targetPath: string,
|
||||
maintainEntryPath?: boolean,
|
||||
overwrite?: boolean
|
||||
overwrite?: boolean,
|
||||
): boolean;
|
||||
/**
|
||||
* Extracts the entire archive to the given location.
|
||||
@@ -156,11 +146,7 @@ declare class AdmZip {
|
||||
* 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
|
||||
@@ -171,6 +157,19 @@ declare class AdmZip {
|
||||
* Returns the content of the entire zip file.
|
||||
*/
|
||||
toBuffer(): Buffer;
|
||||
/**
|
||||
* Asynchronously returns the content of the entire zip file.
|
||||
* @param onSuccess called with the content of the zip file, once it has been generated.
|
||||
* @param onFail unused.
|
||||
* @param onItemStart called before an entry is compressed.
|
||||
* @param onItemEnd called after an entry is compressed.
|
||||
*/
|
||||
toBuffer(
|
||||
onSuccess: (buffer: Buffer) => void,
|
||||
onFail?: (...args: any[]) => void,
|
||||
onItemStart?: (name: string) => void,
|
||||
onItemEnd?: (name: string) => void,
|
||||
): void;
|
||||
}
|
||||
|
||||
declare namespace AdmZip {
|
||||
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
// Type definitions for @adobe/es-modules-middleware 1.1
|
||||
// Project: https://github.com/adobe/es-modules-middleware#readme
|
||||
// Definitions by: Piotr Błażejewicz <https://github.com/peterblazejewicz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 3.2
|
||||
|
||||
import 'karma';
|
||||
import { NextHandleFunction } from 'connect';
|
||||
|
||||
declare module 'karma' {
|
||||
interface ConfigOptions {
|
||||
/**
|
||||
* used in Karma to aid in testing es-modules in the browser
|
||||
* see {@link https://github.com/adobe/es-modules-middleware}
|
||||
*/
|
||||
esModulesMiddleware?: MiddlewareOptions;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* used as a connect middleware by providing it with a map of url base path to file system path from which to serve files.
|
||||
* Any files served through the middleware will be processed to resolve import/export paths properly.
|
||||
*/
|
||||
export interface MiddlewareOptions {
|
||||
/** a map of url base path to file system path from which to serve files */
|
||||
paths: {
|
||||
[path: string]: string;
|
||||
};
|
||||
}
|
||||
export function middleware(options?: MiddlewareOptions): NextHandleFunction;
|
||||
@@ -0,0 +1,19 @@
|
||||
/// <reference types="node" />
|
||||
import esModuleMiddleware = require('@adobe/es-modules-middleware');
|
||||
import express = require('express');
|
||||
import path = require('path');
|
||||
|
||||
const app = express();
|
||||
const port = 3000;
|
||||
|
||||
const rootPath = path.resolve(__dirname);
|
||||
|
||||
app.use(
|
||||
esModuleMiddleware.middleware({
|
||||
paths: {
|
||||
'/node_modules': path.join(rootPath, 'node_modules'),
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
app.listen(port, () => console.log(`Example app listening on port ${port}!`));
|
||||
@@ -0,0 +1,39 @@
|
||||
/// <reference types="node" />
|
||||
import path = require('path');
|
||||
import karma = require('karma');
|
||||
|
||||
module.exports = (config: karma.Config) => {
|
||||
config.set({
|
||||
// @adobe/es-modules-middleware
|
||||
esModulesMiddleware: {
|
||||
paths: {
|
||||
'/': __dirname,
|
||||
'/node_modules': path.join(__dirname, 'node_modules'),
|
||||
},
|
||||
},
|
||||
|
||||
// other
|
||||
basePath: '.',
|
||||
plugins: ['karma-*', require('@adobe/es-modules-middleware')],
|
||||
frameworks: ['mocha', 'chai', 'sinon', 'web-components'],
|
||||
middleware: ['es-modules'],
|
||||
files: [
|
||||
{
|
||||
pattern: '**/*.test.html',
|
||||
watched: false,
|
||||
included: false,
|
||||
served: true,
|
||||
},
|
||||
{
|
||||
pattern: '**/test/*.js',
|
||||
watched: true,
|
||||
included: false,
|
||||
served: false,
|
||||
},
|
||||
],
|
||||
proxies: {
|
||||
'/node_modules/': '/base/node_modules/',
|
||||
},
|
||||
reporters: ['mocha'],
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"paths": {
|
||||
"@adobe/es-modules-middleware": [
|
||||
"adobe__es-modules-middleware"
|
||||
]
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"test/express.tests.ts",
|
||||
"test/karma.tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -8,3 +8,6 @@ const ecb = new aesjs.ModeOfOperation.ecb(key);
|
||||
ecb.decrypt(ecb.encrypt(data));
|
||||
|
||||
const hex: string = aesjs.utils.hex.fromBytes(data);
|
||||
|
||||
const ctr = new aesjs.ModeOfOperation.ctr(key, new aesjs.Counter([]));
|
||||
ctr.encrypt(data);
|
||||
|
||||
Vendored
+1
-1
@@ -19,7 +19,7 @@ export class AES {
|
||||
* @param initialValue The Counter initial value.
|
||||
*/
|
||||
export class Counter {
|
||||
constructor(initialValue: number)
|
||||
constructor(initialValue: number | ByteSource)
|
||||
setValue(value: number): void;
|
||||
setBytes(bytes: ByteSource): void;
|
||||
increment(): void;
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
Bindings for the Akamai [EdgeWorker API]. This allows you to write
|
||||
your EdgeWorkers in TypeScript.
|
||||
Bindings for the Akamai [EdgeWorker API]. This allows you to write
|
||||
your EdgeWorkers in TypeScript.
|
||||
|
||||
Types are available for the `Request` and `Response` objects, as well as the
|
||||
built-in modules.
|
||||
Types are available for the `Request` and `Response` objects, as well as the
|
||||
built-in modules.
|
||||
|
||||
# User Guide
|
||||
|
||||
EdgeWorkers are written in ECMAScript6, so you need to set your
|
||||
`tsconfig.json` to use `es6` as the compilation target and module
|
||||
EdgeWorkers are written in ECMAScript6, so you need to set your
|
||||
`tsconfig.json` to use `es6` as the compilation target and module
|
||||
code generator:
|
||||
|
||||
```json5
|
||||
@@ -15,32 +15,32 @@ code generator:
|
||||
"compilerOptions": {
|
||||
"module": "es6",
|
||||
"target": "es6",
|
||||
//...
|
||||
//...
|
||||
}
|
||||
}
|
||||
```
|
||||
```
|
||||
|
||||
## Using the `Request` and `Response` Objects
|
||||
|
||||
The predefined EdgeWorker callbacks take Request and Response objects as
|
||||
The predefined EdgeWorker callbacks take Request and Response objects as
|
||||
arguments. After you have installed this package, you can create a `main.ts`
|
||||
with the following stubs:
|
||||
|
||||
```typescript
|
||||
/// <reference types="akamai-edgeworkers"/>
|
||||
|
||||
export function onClientRequest(request : EW.MutableRequest & EW.HasRespondWith){}
|
||||
export function onOriginRequest(request : EW.MutableRequest) {}
|
||||
export function onOriginResponse(request : EW.ImmutableRequest & EW.HasRespondWith, response : EW.Response) {}
|
||||
export function onClientResponse(request : EW.ImmutableRequest, response : EW.Response) {}
|
||||
export function onClientRequest(request: EW.IngressClientRequest) {}
|
||||
export function onOriginRequest(request: EW.IngressOriginRequest) {}
|
||||
export function onOriginResponse(request: EW.EgressOriginRequest, response: EW.EgressOriginResponse) {}
|
||||
export function onClientResponse(request: EW.EgressClientRequest, response: EW.EgressClientResponse) {}
|
||||
```
|
||||
|
||||
The triple-slashed first line references this package and pulls `EW` into your
|
||||
namespace.
|
||||
The triple-slashed first line references this package and pulls `EW` into your
|
||||
namespace.
|
||||
|
||||
## Using Built-In Modules
|
||||
|
||||
Bindings are available for the built-in `cookies` and `url-search-params`
|
||||
Bindings are available for the built-in `cookies` and `url-search-params`
|
||||
modules. Once you've added the triple-slash reference to `akamai-edgeworkers`
|
||||
you can import them normally:
|
||||
|
||||
@@ -51,8 +51,8 @@ import { Cookies } from 'cookies';
|
||||
|
||||
function onClientRequest(request: EW.MutableRequest & EW.HasRespondWith) {
|
||||
const cookie = new Cookies(request.getHeader('cookies') || undefined);
|
||||
//...
|
||||
//...
|
||||
}
|
||||
```
|
||||
|
||||
[EdgeWorker API]: https://developer.akamai.com/api/web_performance/edgeworkers/v1.html
|
||||
[EdgeWorker API]: https://learn.akamai.com/en-us/webhelp/edgeworkers/edgeworkers-user-guide/GUID-14077BCA-0D9F-422C-8273-2F3E37339D5B.html
|
||||
|
||||
Vendored
+116
-6
@@ -30,11 +30,19 @@ declare namespace EW {
|
||||
|
||||
interface ReadsVariables {
|
||||
/**
|
||||
* Get's the value of a request variable
|
||||
* Gets the value of a metadata variable
|
||||
*/
|
||||
getVariable(name: string): string | undefined;
|
||||
}
|
||||
|
||||
interface MutatesVariables {
|
||||
/**
|
||||
* Sets the value of a metadata variable, throwing an error if the
|
||||
* variable name does not start with 'PMUSER_'
|
||||
*/
|
||||
setVariable(name: string, value: string): void;
|
||||
}
|
||||
|
||||
interface HasRespondWith {
|
||||
/**
|
||||
* Indicates that a complete response is being generated for a
|
||||
@@ -68,6 +76,72 @@ declare namespace EW {
|
||||
status: number;
|
||||
}
|
||||
|
||||
interface HasRoute {
|
||||
/**
|
||||
* If called, indicates that the request should be routed to a pre-specified origin
|
||||
* server,or have the path or query string modified.
|
||||
*
|
||||
* @param destination Object holding properties that will control route
|
||||
*/
|
||||
route(destination: Destination): void;
|
||||
}
|
||||
|
||||
interface CacheKey {
|
||||
/**
|
||||
* Specifies that the entire query string should be excluded from the cache key. By
|
||||
* default, the entire query string is part of the cache key.
|
||||
*/
|
||||
excludeQueryString(): void;
|
||||
|
||||
/**
|
||||
* Specifies that the entire query string should be included from the cache key. This is
|
||||
* done by default, however it is provided as an API to be reverted to the default.
|
||||
*/
|
||||
includeQueryString(): void;
|
||||
|
||||
/**
|
||||
* Specifies that the named query argument is included in the cache key. Can be called
|
||||
* multiple times to include multiple query arguments. Calling this function will result
|
||||
* in all query arguments not explicitly included to be excluded from the cache key. By
|
||||
* default, the entire query string is part of the cache key. This would override previous
|
||||
* calls to "excludeQueryString()" or "includeQueryString()".
|
||||
*
|
||||
* @param name The name of the query arg to include in the cache key
|
||||
*/
|
||||
includeQueryArgument(name: string): void;
|
||||
|
||||
/**
|
||||
* Specifies that the named cookie is included in the cache key. Can be called multiple
|
||||
* times to include multiple cookies.
|
||||
*
|
||||
* @param name The name of the cookie to include in the cid
|
||||
*/
|
||||
includeCookie(name: string): void;
|
||||
|
||||
/**
|
||||
* Specifies that the named HTTP request header is included in the cache key. Can be
|
||||
* called multiple times to include multiple headers.
|
||||
*
|
||||
* @param name The name of the header to include in the cid
|
||||
*/
|
||||
includeHeader(name: string): void;
|
||||
|
||||
/**
|
||||
* Specifies that the named variable is included in the cache key. Can be called multiple
|
||||
* times to include multiple variable.
|
||||
*
|
||||
* @param name The name of the variable to include in the cid
|
||||
*/
|
||||
includeVariable(name: string): void;
|
||||
}
|
||||
|
||||
interface HasCacheKey {
|
||||
/**
|
||||
* An object for manipulating this requests cache key. Only present during `onClientRequest()`.
|
||||
*/
|
||||
readonly cacheKey: CacheKey;
|
||||
}
|
||||
|
||||
interface Request {
|
||||
/**
|
||||
* The Host header value of the incoming request.
|
||||
@@ -96,7 +170,7 @@ declare namespace EW {
|
||||
readonly query: string;
|
||||
|
||||
/**
|
||||
* The Relative URL of the incoming request. This includes the path as well
|
||||
* The relative URL of the incoming request. This includes the path as well
|
||||
* as the query string.
|
||||
*/
|
||||
readonly url: string;
|
||||
@@ -109,27 +183,63 @@ declare namespace EW {
|
||||
readonly userLocation: UserLocation | undefined;
|
||||
|
||||
/**
|
||||
* Object containing properties specifying the device characteristics. This
|
||||
* Object containing properties specifying the device characteristics. The
|
||||
* value of this property will be null if the contract associated with the
|
||||
* request does not have entitlements for EDC.
|
||||
*/
|
||||
readonly device: Device | undefined;
|
||||
|
||||
/**
|
||||
* The cpcode used for reporting.
|
||||
* The CP code used for reporting.
|
||||
*/
|
||||
readonly cpCode: number;
|
||||
}
|
||||
|
||||
// Legacy interfaces for backwards compatibility
|
||||
interface MutableRequest extends MutatesHeaders, ReadsHeaders, ReadsVariables, Request {
|
||||
}
|
||||
|
||||
interface ImmutableRequest extends ReadsHeaders, ReadsVariables, Request {
|
||||
}
|
||||
|
||||
interface Response extends HasStatus, MutatesHeaders, ReadsHeaders {
|
||||
}
|
||||
|
||||
// onClientRequest
|
||||
interface IngressClientRequest extends MutatesHeaders, ReadsHeaders, ReadsVariables, Request, HasRespondWith, HasRoute, HasCacheKey, MutatesVariables {
|
||||
}
|
||||
|
||||
// onOriginRequest
|
||||
interface IngressOriginRequest extends MutatesHeaders, ReadsHeaders, ReadsVariables, Request, MutatesVariables {
|
||||
}
|
||||
|
||||
// onOriginResponse
|
||||
interface EgressOriginRequest extends ReadsHeaders, ReadsVariables, Request, HasRespondWith, MutatesVariables {
|
||||
}
|
||||
interface EgressOriginResponse extends MutatesHeaders, ReadsHeaders, HasStatus {
|
||||
}
|
||||
|
||||
// onClientResponse
|
||||
interface EgressClientRequest extends ReadsHeaders, ReadsVariables, Request, MutatesVariables {
|
||||
}
|
||||
interface EgressClientResponse extends MutatesHeaders, ReadsHeaders, HasStatus {
|
||||
}
|
||||
|
||||
interface Destination {
|
||||
/**
|
||||
* The identifier of the pre-configured origin to send the outgoing request to.
|
||||
*/
|
||||
origin?: string;
|
||||
|
||||
/**
|
||||
* The new path to use in the outgoing request.
|
||||
*/
|
||||
path?: string;
|
||||
|
||||
/**
|
||||
* The new query string to use in the outgoing request.
|
||||
*/
|
||||
query?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:
|
||||
* * If the IP address is in the reserved IP space (as designated by the
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export function onClientRequest(request: EW.MutableRequest & EW.HasRespondWith) {
|
||||
export function onClientRequest(request: EW.IngressClientRequest) {
|
||||
// Exercise EW.ClientRequest.setHeader()
|
||||
request.setHeader("from-set-header-1", ["value-1", "trailer-1"]);
|
||||
|
||||
@@ -20,7 +20,7 @@ export function onClientRequest(request: EW.MutableRequest & EW.HasRespondWith)
|
||||
}
|
||||
}
|
||||
|
||||
export function onOriginRequest(request: EW.MutableRequest) {
|
||||
export function onOriginRequest(request: EW.IngressOriginRequest) {
|
||||
// getHeader
|
||||
const h = request.getHeader("onOriginRequest-getHeader");
|
||||
if (h == null) {
|
||||
@@ -43,7 +43,7 @@ export function onOriginRequest(request: EW.MutableRequest) {
|
||||
request.setHeader("variable", v);
|
||||
}
|
||||
|
||||
export function onOriginResponse(request: EW.ImmutableRequest & EW.HasRespondWith, response: EW.Response) {
|
||||
export function onOriginResponse(request: EW.EgressOriginRequest, response: EW.EgressOriginResponse) {
|
||||
if (response.getHeader("should-respondWith")) {
|
||||
request.respondWith(444, {}, "wanted a respond with");
|
||||
return;
|
||||
@@ -82,7 +82,7 @@ export function onOriginResponse(request: EW.ImmutableRequest & EW.HasRespondWit
|
||||
response.status = 189;
|
||||
}
|
||||
|
||||
export function onClientResponse(request: EW.ImmutableRequest, response: EW.Response) {
|
||||
export function onClientResponse(request: EW.EgressClientRequest, response: EW.EgressClientResponse) {
|
||||
if (request.getHeader("should-status")) {
|
||||
response.status = 234;
|
||||
return;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Cookies, SetCookie } from 'cookies';
|
||||
|
||||
function onClientRequest(request: EW.MutableRequest & EW.HasRespondWith) {
|
||||
function onClientRequest(request: EW.IngressClientRequest) {
|
||||
// Verify parse constructor
|
||||
const c = new Cookies(request.getHeader('cookies') || undefined);
|
||||
|
||||
@@ -31,7 +31,7 @@ function onClientRequest(request: EW.MutableRequest & EW.HasRespondWith) {
|
||||
c.delete('name');
|
||||
}
|
||||
|
||||
function onClientRequest2(request: EW.MutableRequest & EW.HasRespondWith) {
|
||||
function onClientRequest2(request: EW.IngressClientRequest) {
|
||||
// The values passed to SetCookie can be ignored - they're just to verify the compiler.
|
||||
const c = new SetCookie({
|
||||
name: "n",
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
export function onClientRequest(request: EW.IngressClientRequest) {
|
||||
request.setVariable('PMUSER_client_request', 'foobar');
|
||||
}
|
||||
|
||||
export function onOriginRequest(request: EW.IngressOriginRequest) {
|
||||
request.setVariable('PMUSER_origin_request', 'foobar');
|
||||
}
|
||||
|
||||
export function onOriginResponse(request: EW.EgressOriginRequest, response: EW.EgressOriginResponse) {
|
||||
request.setVariable('PMUSER_origin_response', 'foobar');
|
||||
}
|
||||
|
||||
export function onClientResponse(request: EW.EgressClientRequest, response: EW.EgressClientResponse) {
|
||||
request.setVariable('PMUSER_client_response', 'foobar');
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import URLSearchParams from 'url-search-params';
|
||||
|
||||
export function onClientRequest(request: EW.MutableRequest & EW.HasRespondWith) {
|
||||
export function onClientRequest(request: EW.IngressClientRequest) {
|
||||
const params = new URLSearchParams(request.query);
|
||||
|
||||
params.append("from-script", "from-value");
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
"index.d.ts",
|
||||
"test/akamai-edgeworkers-global.test.ts",
|
||||
"test/cookies-tests.ts",
|
||||
"test/set_variable.ts",
|
||||
"test/url-search-params-tests.ts"
|
||||
]
|
||||
}
|
||||
|
||||
Vendored
+1
@@ -180,6 +180,7 @@ declare namespace OSS {
|
||||
|
||||
interface PutObjectResult {
|
||||
name: string;
|
||||
url: string;
|
||||
data: object;
|
||||
res: NormalSuccessResponse;
|
||||
}
|
||||
|
||||
+1
-1
@@ -103,7 +103,7 @@ export interface AmqpConnectionManager extends EventEmitter {
|
||||
* Create a new ChannelWrapper. This is a proxy for the actual channel (which may or may not exist at any moment, depending on whether or not we are currently connected.)
|
||||
* @param opts
|
||||
*/
|
||||
createChannel(opts: CreateChannelOpts): ChannelWrapper;
|
||||
createChannel(opts?: CreateChannelOpts): ChannelWrapper;
|
||||
|
||||
/**
|
||||
* Returns true if the AmqpConnectionManager is connected to a broker, false otherwise.
|
||||
|
||||
@@ -59,6 +59,24 @@ function testTrack(): void {
|
||||
}
|
||||
});
|
||||
|
||||
analytics.track({
|
||||
anonymousId: '019mr8mf4r',
|
||||
event: 'Purchased an Item',
|
||||
properties: {
|
||||
revenue: 39.95,
|
||||
shippingMethod: '2-day'
|
||||
}
|
||||
});
|
||||
|
||||
// $ExpectError
|
||||
analytics.track({
|
||||
event: 'Purchased an Item',
|
||||
properties: {
|
||||
revenue: 39.95,
|
||||
shippingMethod: '2-day'
|
||||
}
|
||||
});
|
||||
|
||||
analytics.track({
|
||||
userId: '019mr8mf4r',
|
||||
event: 'Purchased an Item',
|
||||
|
||||
Vendored
+12
-19
@@ -3,11 +3,16 @@
|
||||
// Definitions by: Andrew Fong <https://github.com/fongandrew>
|
||||
// Thomas Thiebaud <https://github.com/thomasthiebaud>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.1
|
||||
|
||||
export = AnalyticsNode.Analytics;
|
||||
|
||||
declare namespace AnalyticsNode {
|
||||
interface Message {
|
||||
type Identity =
|
||||
| { userId: string | number }
|
||||
| { userId?: string | number; anonymousId: string | number };
|
||||
|
||||
type Message = Identity & {
|
||||
type: string;
|
||||
context: {
|
||||
library: {
|
||||
@@ -22,9 +27,7 @@ declare namespace AnalyticsNode {
|
||||
};
|
||||
timestamp?: Date;
|
||||
messageId?: string;
|
||||
anonymousId?: string | number;
|
||||
userId?: string | number;
|
||||
}
|
||||
};
|
||||
|
||||
interface Data {
|
||||
batch: Message[];
|
||||
@@ -49,9 +52,7 @@ declare namespace AnalyticsNode {
|
||||
|
||||
/* The identify method lets you tie a user to their actions and record
|
||||
traits about them. */
|
||||
identify(message: {
|
||||
userId?: string | number;
|
||||
anonymousId?: string | number;
|
||||
identify(message: Identity & {
|
||||
traits?: any;
|
||||
timestamp?: Date;
|
||||
context?: any;
|
||||
@@ -59,9 +60,7 @@ declare namespace AnalyticsNode {
|
||||
}, callback?: (err: Error, data: Data) => void): Analytics;
|
||||
|
||||
/* The track method lets you record the actions your users perform. */
|
||||
track(message: {
|
||||
userId?: string | number;
|
||||
anonymousId?: string | number;
|
||||
track(message: Identity & {
|
||||
event: string;
|
||||
properties?: any;
|
||||
timestamp?: Date;
|
||||
@@ -71,9 +70,7 @@ declare namespace AnalyticsNode {
|
||||
|
||||
/* The page method lets you record page views on your website, along with
|
||||
optional extra information about the page being viewed. */
|
||||
page(message: {
|
||||
userId?: string | number;
|
||||
anonymousId?: string | number;
|
||||
page(message: Identity & {
|
||||
category?: string;
|
||||
name?: string;
|
||||
properties?: any;
|
||||
@@ -83,18 +80,14 @@ declare namespace AnalyticsNode {
|
||||
}, callback?: (err: Error, data: Data) => void): Analytics;
|
||||
|
||||
/* alias is how you associate one identity with another. */
|
||||
alias(message: {
|
||||
alias(message: Identity & {
|
||||
previousId: string | number;
|
||||
userId?: string | number;
|
||||
anonymousId?: string | number;
|
||||
integrations?: Integrations;
|
||||
}, callback?: (err: Error, data: Data) => void): Analytics;
|
||||
|
||||
/* Group calls can be used to associate individual users with shared
|
||||
accounts or companies. */
|
||||
group(message: {
|
||||
userId?: string | number;
|
||||
anonymousId?: string | number;
|
||||
group(message: Identity & {
|
||||
groupId: string | number;
|
||||
traits?: any;
|
||||
context?: any;
|
||||
|
||||
@@ -6,6 +6,15 @@
|
||||
*/
|
||||
|
||||
declare var $routeProvider: ng.route.IRouteProvider;
|
||||
if (!$routeProvider.eagerInstantiationEnabled()) {
|
||||
throw new Error("The default of $routeProvider.eagerInstantiationEnabled should be true.");
|
||||
}
|
||||
|
||||
$routeProvider.eagerInstantiationEnabled(false);
|
||||
if ($routeProvider.eagerInstantiationEnabled()) {
|
||||
throw new Error("$routeProvider.eagerInstantiationEnabled is expected to be false.");
|
||||
}
|
||||
|
||||
$routeProvider
|
||||
.when('/projects/:projectId/dashboard', {
|
||||
controller: 'I am a string',
|
||||
|
||||
Vendored
+14
@@ -200,6 +200,20 @@ declare module 'angular' {
|
||||
* This option defaults to false. If the option is set to true, then the particular route can be matched without being case sensitive
|
||||
*/
|
||||
caseInsensitiveMatch?: boolean;
|
||||
/**
|
||||
* Call this method as a setter to enable/disable eager instantiation of the $route service upon application bootstrap.
|
||||
*
|
||||
* Instantiating $route early is necessary for capturing the initial $locationChangeStart event and navigating to the appropriate route. Usually, $route is instantiated in time by the ngView directive. Yet, in cases where ngView is included in an asynchronously loaded template (e.g. in another directive's template), the directive factory might not be called soon enough for $route to be instantiated before the initial $locationChangeSuccess event is fired. Eager instantiation ensures that $route is always instantiated in time, regardless of when ngView will be loaded.
|
||||
*
|
||||
* The default value is true.
|
||||
*
|
||||
* @param enabled If provided, update the internal eagerInstantiationEnabled flag.
|
||||
*/
|
||||
eagerInstantiationEnabled(enabled: boolean) : IRouteProvider;
|
||||
/**
|
||||
* Call this method as a getter (i.e. without any arguments) to get the current value of the eagerInstantiationEnabled flag.
|
||||
*/
|
||||
eagerInstantiationEnabled() : boolean;
|
||||
/**
|
||||
* Sets route definition that will be used on route change when no other route definition is matched.
|
||||
*
|
||||
|
||||
@@ -1012,7 +1012,7 @@ angular.module('docsTimeDirective', [])
|
||||
return {
|
||||
link(scope: ng.IScope, element: JQLite, attrs: ng.IAttributes) {
|
||||
let format: any;
|
||||
let timeoutId: any;
|
||||
let timeoutId: angular.IPromise<any>;
|
||||
|
||||
function updateTime() {
|
||||
element.text(dateFilter(new Date(), format));
|
||||
@@ -1538,3 +1538,10 @@ angular.module('WithGenerics', [])
|
||||
scope['name'] = 'Jeff';
|
||||
};
|
||||
});
|
||||
|
||||
angular.errorHandlingConfig(); // $ExpectType IErrorHandlingConfig
|
||||
// $ExpectType void
|
||||
angular.errorHandlingConfig({
|
||||
objectMaxDepth: 5,
|
||||
urlErrorParamsEnabled: true,
|
||||
});
|
||||
|
||||
Vendored
+35
-4
@@ -1,10 +1,11 @@
|
||||
// Type definitions for Angular JS 1.6
|
||||
// Type definitions for Angular JS 1.7
|
||||
// Project: http://angularjs.org
|
||||
// Definitions by: Diego Vilar <https://github.com/diegovilar>
|
||||
// Georgii Dolzhykov <https://github.com/thorn0>
|
||||
// Caleb St-Denis <https://github.com/calebstdenis>
|
||||
// Leonard Thieu <https://github.com/leonard-thieu>
|
||||
// Steffen Kowalski <https://github.com/scipper>
|
||||
// Piotr Błażejewicz <https://github.com/peterblazejewicz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
@@ -89,6 +90,12 @@ declare namespace angular {
|
||||
* If jQuery is available, angular.element is an alias for the jQuery function. If jQuery is not available, angular.element delegates to Angular's built-in subset of jQuery, called "jQuery lite" or "jqLite."
|
||||
*/
|
||||
element: JQueryStatic;
|
||||
/**
|
||||
* Configure several aspects of error handling in AngularJS if used as a setter
|
||||
* or return the current configuration if used as a getter
|
||||
*/
|
||||
errorHandlingConfig(): IErrorHandlingConfig;
|
||||
errorHandlingConfig(config: IErrorHandlingConfig): void;
|
||||
equals(value1: any, value2: any): boolean;
|
||||
extend(destination: any, ...sources: any[]): any;
|
||||
|
||||
@@ -140,7 +147,6 @@ declare namespace angular {
|
||||
isObject<T>(value: any): value is T;
|
||||
isString(value: any): value is string;
|
||||
isUndefined(value: any): boolean;
|
||||
lowercase(str: string): string;
|
||||
|
||||
/**
|
||||
* Deeply extends the destination object dst by copying own enumerable properties from the src object(s) to dst. You can specify multiple src objects. If you want to preserve original objects, you can do so by passing an empty object as the target: var object = angular.merge({}, object1, object2).
|
||||
@@ -169,7 +175,6 @@ declare namespace angular {
|
||||
noop(...args: any[]): void;
|
||||
reloadWithDebugInfo(): void;
|
||||
toJson(obj: any, pretty?: boolean | number): string;
|
||||
uppercase(str: string): string;
|
||||
version: {
|
||||
full: string;
|
||||
major: number;
|
||||
@@ -373,6 +378,7 @@ declare namespace angular {
|
||||
$name?: string;
|
||||
$pending?: { [validationErrorKey: string]: Array<INgModelController | IFormController> };
|
||||
$addControl(control: INgModelController | IFormController): void;
|
||||
$getControls(): ReadonlyArray<INgModelController | IFormController>;
|
||||
$removeControl(control: INgModelController | IFormController): void;
|
||||
$setValidity(validationErrorKey: string, isValid: boolean, control: INgModelController | IFormController): void;
|
||||
$setDirty(): void;
|
||||
@@ -435,6 +441,17 @@ declare namespace angular {
|
||||
allowInvalid?: boolean;
|
||||
getterSetter?: boolean;
|
||||
timezone?: string;
|
||||
/**
|
||||
* Defines if the time and datetime-local types should show seconds and milliseconds.
|
||||
* The option follows the format string of date filter.
|
||||
* By default, the options is undefined which is equal to 'ss.sss' (seconds and milliseconds)
|
||||
*/
|
||||
timeSecondsFormat?: string;
|
||||
/**
|
||||
* Defines if the time and datetime-local types should strip the seconds and milliseconds
|
||||
* from the formatted value if they are zero. This option is applied after `timeSecondsFormat`
|
||||
*/
|
||||
timeStripZeroSeconds?: boolean;
|
||||
}
|
||||
|
||||
interface IModelValidators {
|
||||
@@ -448,6 +465,21 @@ declare namespace angular {
|
||||
[index: string]: (modelValue: any, viewValue: any) => IPromise<any>;
|
||||
}
|
||||
|
||||
interface IErrorHandlingConfig {
|
||||
/**
|
||||
* The max depth for stringifying objects.
|
||||
* Setting to a non-positive or non-numeric value, removes the max depth limit
|
||||
* @default 5
|
||||
*/
|
||||
objectMaxDepth?: number;
|
||||
/**
|
||||
* Specifies whether the generated error url will contain the parameters of the thrown error.
|
||||
* Disabling the parameters can be useful if the generated error url is very long.
|
||||
* @default true;
|
||||
*/
|
||||
urlErrorParamsEnabled?: boolean;
|
||||
}
|
||||
|
||||
interface IModelParser {
|
||||
(value: any): any;
|
||||
}
|
||||
@@ -1484,7 +1516,6 @@ declare namespace angular {
|
||||
interface IControllerProvider extends IServiceProvider {
|
||||
register(name: string, controllerConstructor: Function): void;
|
||||
register(name: string, dependencyAnnotatedConstructor: any[]): void;
|
||||
allowGlobals(): void;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
import Apicalypse from 'apicalypse';
|
||||
|
||||
// $ExpectType Apicalypse
|
||||
Apicalypse({
|
||||
baseURL: 'https://my-api.url',
|
||||
queryMethod: 'url',
|
||||
auth: {
|
||||
username: 'user',
|
||||
password: 'pass',
|
||||
},
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
},
|
||||
responseType: 'json',
|
||||
timeout: 30000,
|
||||
});
|
||||
|
||||
// $ExpectType Promise<AxiosResponse<any>>
|
||||
Apicalypse()
|
||||
.fields('id,slug,name')
|
||||
.fields(['rating', 'popularity'])
|
||||
.sort('rating desc')
|
||||
.sort('name', 'asc')
|
||||
.limit(10)
|
||||
.offset(20)
|
||||
.where('rating > 0; popularity > 10')
|
||||
.where(['popularity < 100', 'first_release_date > 788918400'])
|
||||
.request('/games');
|
||||
|
||||
// $ExpectType Promise<any[]>
|
||||
Apicalypse()
|
||||
.search('title')
|
||||
.requestAll('/games');
|
||||
|
||||
// $ExpectType Promise<any[]>
|
||||
Apicalypse()
|
||||
.search('title')
|
||||
.requestAll('/games', {});
|
||||
|
||||
// $ExpectType Promise<any[]>
|
||||
Apicalypse()
|
||||
.search('title')
|
||||
.requestAll('/games', {
|
||||
concurrency: 2,
|
||||
delay: 500,
|
||||
});
|
||||
|
||||
// $ExpectType Apicalypse
|
||||
Apicalypse().multi([
|
||||
Apicalypse()
|
||||
.query('/games', 'game')
|
||||
.where('id == 1081'),
|
||||
Apicalypse()
|
||||
.query('/achievements', 'achievements')
|
||||
.where('game_id == 1081'),
|
||||
]);
|
||||
Vendored
+39
@@ -0,0 +1,39 @@
|
||||
// Type definitions for apicalypse 0.1
|
||||
// Project: https://github.com/igdb/node-apicalypse
|
||||
// Definitions by: Susam <https://github.com/susam-projects>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
import { AxiosRequestConfig, AxiosResponse } from 'axios';
|
||||
|
||||
export interface Apicalypse {
|
||||
request(url: string): Promise<AxiosResponse>;
|
||||
requestAll(url: string, options?: RequestAllConfig): Promise<any[]>;
|
||||
|
||||
multi(queries: ReadonlyArray<Apicalypse>): Apicalypse;
|
||||
query(endpoint: string, name: string): Apicalypse;
|
||||
|
||||
fields(fields: string | ReadonlyArray<string>): Apicalypse;
|
||||
sort(field: string, direction?: SortDirection): Apicalypse;
|
||||
limit(limit: number): Apicalypse;
|
||||
offset(offset: number): Apicalypse;
|
||||
search(search: string): Apicalypse;
|
||||
where(filters: string | ReadonlyArray<string>): Apicalypse;
|
||||
}
|
||||
|
||||
export interface RequestAllConfig {
|
||||
concurrency?: number;
|
||||
delay?: number;
|
||||
}
|
||||
|
||||
export type SortDirection = 'asc' | 'desc';
|
||||
|
||||
declare function apicalypseFactory(options?: ApicalypseConfig): Apicalypse;
|
||||
declare function apicalypseFactory(rawQueryString: string, options?: ApicalypseConfig): Apicalypse;
|
||||
|
||||
export interface ApicalypseConfig extends AxiosRequestConfig {
|
||||
queryMethod?: QueryMethod;
|
||||
}
|
||||
|
||||
export type QueryMethod = 'body' | 'url';
|
||||
|
||||
export default apicalypseFactory;
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"axios": "^0.19.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"apicalypse-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Vendored
+3763
-680
File diff suppressed because it is too large
Load Diff
Vendored
+7
-1
@@ -1,4 +1,4 @@
|
||||
// Type definitions for ArcGIS API for JavaScript 3.31
|
||||
// Type definitions for ArcGIS API for JavaScript 3.32
|
||||
// Project: https://developers.arcgis.com/javascript/3/
|
||||
// Definitions by: Esri <https://github.com/Esri>
|
||||
// Bjorn Svensson <https://github.com/bsvensson>
|
||||
@@ -2855,6 +2855,10 @@ declare module "esri/ServerInfo" {
|
||||
adminTokenServiceUrl: string;
|
||||
/** Version of the ArcGIS Server REST API deployed on this server. */
|
||||
currentVersion: number;
|
||||
/** Indicates whether the server is a Portal instance. */
|
||||
hasPortal: boolean;
|
||||
/** Indicates whether the server is an ArcGIS Server instance. */
|
||||
hasServer: boolean;
|
||||
/** The server URL. */
|
||||
server: string;
|
||||
/** Validity of short-lived token in minutes. */
|
||||
@@ -17522,6 +17526,8 @@ declare module "esri/tasks/query" {
|
||||
static SPATIAL_REL_TOUCHES: any;
|
||||
/** The feature from feature class 1 is completely enclosed by the feature from feature class 2. */
|
||||
static SPATIAL_REL_WITHIN: any;
|
||||
/** Indicates if the service should cache the query results. */
|
||||
cacheHint: boolean;
|
||||
/** Buffer distance for input geometries. */
|
||||
distance: number;
|
||||
/** The geometry to apply to the spatial filter. */
|
||||
|
||||
Vendored
+1835
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,56 @@
|
||||
import Ari, { Channel, Bridge, ChannelLeftBridge } from 'ari-client';
|
||||
|
||||
// TypeScript version of example published on project https://github.com/asterisk/node-ari-client.
|
||||
|
||||
Ari.connect(
|
||||
'http://ari.js:8088',
|
||||
'user',
|
||||
'secret',
|
||||
|
||||
(err, client) => {
|
||||
// use once to start the application
|
||||
client.on('StasisStart', (event, incoming) => {
|
||||
incoming.answer(err => {
|
||||
getOrCreateBridge(incoming);
|
||||
});
|
||||
});
|
||||
|
||||
const getOrCreateBridge = (channel: Channel) => {
|
||||
client.bridges.list((err: Error, bridges: Bridge[]) => {
|
||||
let bridge = bridges.filter((candidate: Bridge) => {
|
||||
return candidate['bridge_type'] === 'holding';
|
||||
})[0];
|
||||
|
||||
if (!bridge) {
|
||||
bridge = client.Bridge();
|
||||
bridge.create({ type: 'holding' }, (err: Error, bridge: Bridge) => {
|
||||
bridge.on('ChannelLeftBridge', (event, instances) => {
|
||||
cleanupBridge(event, instances, bridge);
|
||||
});
|
||||
joinHoldingBridgeAndPlayMoh(bridge, channel);
|
||||
});
|
||||
} else {
|
||||
// Add incoming channel to existing holding bridge and play
|
||||
// music on hold
|
||||
joinHoldingBridgeAndPlayMoh(bridge, channel);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const cleanupBridge = (event: ChannelLeftBridge, instances: ChannelLeftBridge, bridge: Bridge) => {
|
||||
const holdingBridge = instances.bridge;
|
||||
if (holdingBridge.channels.length === 0 && holdingBridge.id === bridge.id) {
|
||||
bridge.destroy(err => {});
|
||||
}
|
||||
};
|
||||
|
||||
const joinHoldingBridgeAndPlayMoh = (bridge: Bridge, channel: Channel) => {
|
||||
bridge.addChannel({ channel: channel.id }, err => {
|
||||
channel.startMoh(err => {});
|
||||
});
|
||||
};
|
||||
|
||||
// can also use client.start(['app-name'...]) to start multiple applications
|
||||
client.start('bridge-example');
|
||||
},
|
||||
);
|
||||
@@ -0,0 +1,50 @@
|
||||
import Ari, { Channel, Bridge } from 'ari-client';
|
||||
|
||||
// async/await version of the example published on project https://github.com/asterisk/node-ari-client.
|
||||
|
||||
export default async () => {
|
||||
try {
|
||||
const client = await Ari.connect('http://ari.js:8088', 'user', 'secret');
|
||||
|
||||
client.on('StasisStart', async (event, incoming) => {
|
||||
await incoming.answer();
|
||||
const bridge = await getOrCreateBridge();
|
||||
await joinHoldingBridgeAndPlayMoh(bridge, incoming);
|
||||
});
|
||||
|
||||
const getOrCreateBridge = async () => {
|
||||
const bridges = await client.bridges.list();
|
||||
let bridge = bridges.filter(candidate => {
|
||||
return candidate['bridge_type'] === 'holding';
|
||||
})[0];
|
||||
|
||||
if (!bridge) {
|
||||
bridge = client.Bridge();
|
||||
return bridge.create({ type: 'holding' });
|
||||
} else {
|
||||
// Add incoming channel to existing holding bridge and play
|
||||
// music on hold
|
||||
return bridge;
|
||||
}
|
||||
};
|
||||
|
||||
const joinHoldingBridgeAndPlayMoh = async (bridge: Bridge, channel: Channel) => {
|
||||
bridge.on('ChannelLeftBridge', async (event, instances) => {
|
||||
const holdingBridge = instances.bridge;
|
||||
if (holdingBridge.channels.length === 0 && holdingBridge.id === bridge.id) {
|
||||
try {
|
||||
await bridge.destroy();
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
}
|
||||
});
|
||||
await bridge.addChannel({ channel: channel.id });
|
||||
await channel.startMoh();
|
||||
};
|
||||
|
||||
client.start('bridge-example');
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,56 @@
|
||||
import Ari from 'ari-client';
|
||||
import util = require('util');
|
||||
|
||||
// TypeScript version of example published on project https://github.com/asterisk/node-ari-client.
|
||||
|
||||
const BRIDGE_STATE = 'device-state-example';
|
||||
|
||||
// replace ari.js with your Asterisk instance
|
||||
Ari.connect('http://ari.js:8088', 'user', 'secret', (err, client) => {
|
||||
const bridge = client.Bridge();
|
||||
// Keep track of bridge state at the application level so we don't have to
|
||||
// make extra calls to ARI
|
||||
let currentBridgeState = 'NOT_INUSE';
|
||||
|
||||
bridge.create({ type: 'mixing' }, (err, instance) => {
|
||||
// Mark this bridge as available
|
||||
const opts = {
|
||||
deviceName: util.format('Stasis:%s', BRIDGE_STATE),
|
||||
deviceState: 'NOT_INUSE',
|
||||
};
|
||||
client.deviceStates.update(opts, err => {});
|
||||
});
|
||||
|
||||
client.on('ChannelEnteredBridge', (event, objects) => {
|
||||
if (objects.bridge.channels.length > 0 && currentBridgeState !== 'BUSY') {
|
||||
// Mark this bridge as busy
|
||||
const opts = {
|
||||
deviceName: util.format('Stasis:%s', BRIDGE_STATE),
|
||||
deviceState: 'BUSY',
|
||||
};
|
||||
client.deviceStates.update(opts, err => {});
|
||||
currentBridgeState = 'BUSY';
|
||||
}
|
||||
});
|
||||
|
||||
client.on('ChannelLeftBridge', (event, objects) => {
|
||||
if (objects.bridge.channels.length === 0 && currentBridgeState !== 'NOT_INUSE') {
|
||||
// Mark this bridge as available
|
||||
const opts = {
|
||||
deviceName: util.format('Stasis:%s', BRIDGE_STATE),
|
||||
deviceState: 'NOT_INUSE',
|
||||
};
|
||||
client.deviceStates.update(opts, err => {});
|
||||
currentBridgeState = 'NOT_INUSE';
|
||||
}
|
||||
});
|
||||
|
||||
client.on('StasisStart', (event, incoming) => {
|
||||
incoming.answer(err => {
|
||||
bridge.addChannel({ channel: incoming.id }, err => {});
|
||||
});
|
||||
});
|
||||
|
||||
// can also use client.start(['app-name'...]) to start multiple applications
|
||||
client.start('device-state-example');
|
||||
});
|
||||
@@ -0,0 +1,72 @@
|
||||
import Ari from 'ari-client';
|
||||
import util = require('util');
|
||||
|
||||
// async/await version of the example published on project https://github.com/asterisk/node-ari-client.
|
||||
|
||||
export default async () => {
|
||||
const BRIDGE_STATE = 'device-state-example';
|
||||
|
||||
try {
|
||||
const client = await Ari.connect('http://ari.js:8088', 'user', 'secret');
|
||||
|
||||
const bridge = client.Bridge();
|
||||
// Keep track of bridge state at the application level so we don't have to
|
||||
// make extra calls to ARI
|
||||
let currentBridgeState = 'NOT_INUSE';
|
||||
|
||||
const instance = await bridge.create({ type: 'mixing' });
|
||||
|
||||
// Mark this bridge as available
|
||||
const opts = {
|
||||
deviceName: util.format('Stasis:%s', BRIDGE_STATE),
|
||||
deviceState: 'NOT_INUSE',
|
||||
};
|
||||
await client.deviceStates.update(opts);
|
||||
|
||||
client.on('ChannelEnteredBridge', async (event, objects) => {
|
||||
if (objects.bridge.channels.length > 0 && currentBridgeState !== 'BUSY') {
|
||||
// Mark this bridge as busy
|
||||
const opts = {
|
||||
deviceName: util.format('Stasis:%s', BRIDGE_STATE),
|
||||
deviceState: 'BUSY',
|
||||
};
|
||||
try {
|
||||
await client.deviceStates.update(opts);
|
||||
currentBridgeState = 'BUSY';
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
client.on('ChannelLeftBridge', async (event, objects) => {
|
||||
if (objects.bridge.channels.length === 0 && currentBridgeState !== 'NOT_INUSE') {
|
||||
// Mark this bridge as available
|
||||
const opts = {
|
||||
deviceName: util.format('Stasis:%s', BRIDGE_STATE),
|
||||
deviceState: 'NOT_INUSE',
|
||||
};
|
||||
try {
|
||||
await client.deviceStates.update(opts);
|
||||
currentBridgeState = 'NOT_INUSE';
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
client.on('StasisStart', async (event, incoming) => {
|
||||
try {
|
||||
await incoming.answer();
|
||||
await bridge.addChannel({ channel: incoming.id });
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
});
|
||||
|
||||
// can also use client.start(['app-name'...]) to start multiple applications
|
||||
client.start('device-state-example');
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,50 @@
|
||||
import Ari, { Channel } from 'ari-client';
|
||||
import util = require('util');
|
||||
|
||||
// TypeScript version of example published on project https://github.com/asterisk/node-ari-client.
|
||||
|
||||
// replace ari.js with your Asterisk instance
|
||||
Ari.connect('http://ari.js:8088', 'user', 'secret', (err, client) => {
|
||||
if (err) {
|
||||
throw err; // program will crash if it fails to connect
|
||||
}
|
||||
|
||||
// Use once to start the application
|
||||
client.on('StasisStart', (event, incoming) => {
|
||||
// Handle DTMF events
|
||||
incoming.on('ChannelDtmfReceived', (event, channel) => {
|
||||
const digit = event.digit;
|
||||
switch (digit) {
|
||||
case '#':
|
||||
play(channel, 'sound:vm-goodbye', err => {
|
||||
channel.hangup(err => {
|
||||
process.exit(0);
|
||||
});
|
||||
});
|
||||
break;
|
||||
case '*':
|
||||
play(channel, 'sound:tt-monkeys');
|
||||
break;
|
||||
default:
|
||||
play(channel, util.format('sound:digits/%s', digit));
|
||||
}
|
||||
});
|
||||
|
||||
incoming.answer(err => {
|
||||
play(incoming, 'sound:hello-world');
|
||||
});
|
||||
});
|
||||
|
||||
const play = (channel: Channel, sound: string, callback?: (param: any) => void) => {
|
||||
const playback = client.Playback();
|
||||
playback.once('PlaybackFinished', (event, instance) => {
|
||||
if (callback) {
|
||||
callback(null);
|
||||
}
|
||||
});
|
||||
channel.play({ media: sound }, playback, (err, playback) => {});
|
||||
};
|
||||
|
||||
// can also use client.start(['app-name'...]) to start multiple applications
|
||||
client.start('example');
|
||||
});
|
||||
@@ -0,0 +1,52 @@
|
||||
import Ari, { Channel } from 'ari-client';
|
||||
import util = require('util');
|
||||
|
||||
// async/await version of the example published on project https://github.com/asterisk/node-ari-client.
|
||||
|
||||
export default async () => {
|
||||
try {
|
||||
const client = await Ari.connect('http://ari.js:8088', 'user', 'secret');
|
||||
|
||||
// Use once to start the application
|
||||
client.on('StasisStart', async (event, incoming) => {
|
||||
// Handle DTMF events
|
||||
incoming.on('ChannelDtmfReceived', async (event, channel) => {
|
||||
const digit = event.digit;
|
||||
switch (digit) {
|
||||
case '#':
|
||||
await play(channel, 'sound:vm-goodbye');
|
||||
await channel.hangup();
|
||||
process.exit(0);
|
||||
break;
|
||||
case '*':
|
||||
await play(channel, 'sound:tt-monkeys');
|
||||
break;
|
||||
default:
|
||||
await play(channel, util.format('sound:digits/%s', digit));
|
||||
}
|
||||
});
|
||||
|
||||
await incoming.answer();
|
||||
await play(incoming, 'sound:hello-world');
|
||||
});
|
||||
|
||||
const play = (channel: Channel, sound: string) => {
|
||||
const playback = client.Playback();
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
playback.once('PlaybackFinished', (event, playback) => {
|
||||
resolve(playback);
|
||||
});
|
||||
|
||||
channel.play({ media: sound }, playback).catch(err => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
// can also use client.start(['app-name'...]) to start multiple applications
|
||||
client.start('example');
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,101 @@
|
||||
import Ari from 'ari-client';
|
||||
import util = require('util');
|
||||
|
||||
// TypeScript version of example published on project https://github.com/asterisk/node-ari-client.
|
||||
|
||||
// replace ari.js with your Asterisk instance
|
||||
Ari.connect('http://ari.js:8088', 'user', 'secret', (err, client) => {
|
||||
// Create new mailbox
|
||||
const mailbox = client.Mailbox('mwi-example');
|
||||
let messages = 0;
|
||||
|
||||
client.on(
|
||||
'StasisStart',
|
||||
|
||||
(event, channel) => {
|
||||
channel.on('ChannelDtmfReceived', (event, channel) => {
|
||||
const digit = event.digit;
|
||||
switch (digit) {
|
||||
case '5':
|
||||
// Record message
|
||||
const recording = client.LiveRecording();
|
||||
|
||||
recording.once('RecordingFinished', (event, newRecording) => {
|
||||
const playback = client.Playback();
|
||||
playback.once('PlaybackFinished', (event, newPlayback) => {
|
||||
// Update MWI
|
||||
messages += 1;
|
||||
const opts = {
|
||||
oldMessages: 0,
|
||||
newMessages: messages,
|
||||
};
|
||||
mailbox.update(opts, err => {});
|
||||
|
||||
channel.hangup(err => {});
|
||||
});
|
||||
|
||||
channel.play({ media: 'sound:vm-msgsaved' }, playback, err => {});
|
||||
});
|
||||
|
||||
const opts = {
|
||||
name: channel.id, // name parameter is required. See channels.json fixture file.
|
||||
format: 'wav',
|
||||
maxSilenceSeconds: 2,
|
||||
beep: true,
|
||||
};
|
||||
|
||||
// Record a message
|
||||
channel.record(opts, recording, err => {});
|
||||
break;
|
||||
case '6':
|
||||
// Playback last message
|
||||
client.recordings.listStored((err, recordings) => {
|
||||
const playback = client.Playback();
|
||||
const recording = recordings[recordings.length - 1];
|
||||
|
||||
if (!recording) {
|
||||
channel.play({ media: 'sound:vm-nomore' }, playback, err => {});
|
||||
} else {
|
||||
playback.once('PlaybackFinished', (event, newPlayback) => {
|
||||
recording.deleteStored(err => {
|
||||
// Remove MWI
|
||||
messages -= 1;
|
||||
const opts = {
|
||||
oldMessages: 0,
|
||||
newMessages: messages,
|
||||
};
|
||||
mailbox.update(opts, err => {});
|
||||
|
||||
const playback = client.Playback();
|
||||
channel.play({ media: 'sound:vm-next' }, playback, err => {});
|
||||
});
|
||||
});
|
||||
|
||||
const opts = {
|
||||
media: util.format('recording:%s', recording.name),
|
||||
};
|
||||
|
||||
// Play the latest message
|
||||
channel.play(opts, playback, err => {});
|
||||
}
|
||||
});
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
channel.answer(err => {
|
||||
let playback = client.Playback();
|
||||
|
||||
playback.once('PlaybackFinished', (err, newPlayback) => {
|
||||
playback = client.Playback();
|
||||
channel.play({ media: 'sound:vm-next' }, playback, err => {});
|
||||
});
|
||||
|
||||
channel.play({ media: 'sound:vm-leavemsg' }, playback, err => {});
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
// can also use client.start(['app-name'...]) to start multiple applications
|
||||
client.start('mwi-example');
|
||||
});
|
||||
@@ -0,0 +1,99 @@
|
||||
import Ari from 'ari-client';
|
||||
import util = require('util');
|
||||
|
||||
// async/await version of the example published on project https://github.com/asterisk/node-ari-client.
|
||||
|
||||
export default async () => {
|
||||
try {
|
||||
const client = await Ari.connect('http://ari.js:8088', 'user', 'secret');
|
||||
|
||||
// Create new mailbox
|
||||
const mailbox = client.Mailbox('mwi-example');
|
||||
let messages = 0;
|
||||
|
||||
client.on('StasisStart', async (event, channel) => {
|
||||
channel.on('ChannelDtmfReceived', async (event, channel) => {
|
||||
const digit = event.digit;
|
||||
switch (digit) {
|
||||
case '5':
|
||||
// Record message
|
||||
const message = client.LiveRecording();
|
||||
|
||||
message.once('RecordingFinished', async (event, newRecording) => {
|
||||
const playback = client.Playback();
|
||||
playback.once('PlaybackFinished', async (event, newPlayback) => {
|
||||
// Update MWI
|
||||
messages += 1;
|
||||
const opts = {
|
||||
oldMessages: 0,
|
||||
newMessages: messages,
|
||||
};
|
||||
await mailbox.update(opts);
|
||||
await channel.hangup();
|
||||
});
|
||||
|
||||
await channel.play({ media: 'sound:vm-msgsaved' }, playback);
|
||||
});
|
||||
|
||||
const messageOptions = {
|
||||
name: channel.id, // name parameter is required. See channels.json fixture file.
|
||||
format: 'wav',
|
||||
maxSilenceSeconds: 2,
|
||||
beep: true,
|
||||
};
|
||||
|
||||
// Record a message
|
||||
await channel.record(messageOptions, message);
|
||||
break;
|
||||
case '6':
|
||||
// Playback last message
|
||||
const recordings = await client.recordings.listStored();
|
||||
|
||||
const playback = client.Playback();
|
||||
const lastMessage = recordings[recordings.length - 1];
|
||||
|
||||
if (!lastMessage) return channel.play({ media: 'sound:vm-nomore' }, playback);
|
||||
|
||||
playback.once('PlaybackFinished', async (event, newPlayback) => {
|
||||
await lastMessage.deleteStored();
|
||||
|
||||
// Remove MWI
|
||||
messages -= 1;
|
||||
const opts = {
|
||||
oldMessages: 0,
|
||||
newMessages: messages,
|
||||
};
|
||||
await mailbox.update(opts);
|
||||
|
||||
const playback = client.Playback();
|
||||
await channel.play({ media: 'sound:vm-next' }, playback);
|
||||
});
|
||||
|
||||
const lastMessageOptions = {
|
||||
media: util.format('recording:%s', lastMessage.name),
|
||||
};
|
||||
|
||||
// Play the latest message
|
||||
await channel.play(lastMessageOptions, playback);
|
||||
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
await channel.answer();
|
||||
let playback = client.Playback();
|
||||
|
||||
playback.once('PlaybackFinished', async (err, newPlayback) => {
|
||||
playback = client.Playback();
|
||||
await channel.play({ media: 'sound:vm-next' }, playback);
|
||||
});
|
||||
|
||||
await channel.play({ media: 'sound:vm-leavemsg' }, playback);
|
||||
});
|
||||
|
||||
// can also use client.start(['app-name'...]) to start multiple applications
|
||||
client.start('mwi-example');
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,55 @@
|
||||
import Ari, { Channel, Containers } from 'ari-client';
|
||||
|
||||
// TypeScript version of example published on project https://github.com/asterisk/node-ari-client.
|
||||
|
||||
const ENDPOINT = 'PJSIP/sipphone';
|
||||
|
||||
// replace ari.js with your Asterisk instance
|
||||
Ari.connect('http://ari.js:8088', 'user', 'secret', (err, client) => {
|
||||
// Use once to start the application to ensure this listener will only run
|
||||
// for the incoming channel
|
||||
client.once('StasisStart', (event, incoming) => {
|
||||
incoming.answer(err => {
|
||||
originate(incoming);
|
||||
});
|
||||
});
|
||||
|
||||
const originate = (incoming: Channel) => {
|
||||
incoming.once('StasisEnd', (event, channel) => {
|
||||
outgoing.hangup(err => {});
|
||||
});
|
||||
|
||||
const outgoing = client.Channel();
|
||||
|
||||
outgoing.once('ChannelDestroyed', (event, channel) => {
|
||||
incoming.hangup(err => {});
|
||||
});
|
||||
|
||||
outgoing.once('StasisStart', (event, outgoing) => {
|
||||
const bridge = client.Bridge();
|
||||
|
||||
outgoing.once('StasisEnd', (event, channel) => {
|
||||
bridge.destroy(err => {});
|
||||
});
|
||||
|
||||
outgoing.answer(err => {
|
||||
bridge.create({ type: 'mixing' }, (err, bridge) => {
|
||||
bridge.addChannel({ channel: [incoming.id, outgoing.id] }, err => {});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
const playback = client.Playback();
|
||||
incoming.play({ media: 'sound:vm-dialout' }, playback, err => {});
|
||||
|
||||
// Originate call from incoming channel to endpoint
|
||||
const variables: Containers = { 'CALLERID(name)': 'Alice', name: 'test' };
|
||||
outgoing.originate(
|
||||
{ endpoint: ENDPOINT, app: 'originate-example', appArgs: 'dialed', variables },
|
||||
(err, channel) => {},
|
||||
);
|
||||
};
|
||||
|
||||
// can also use client.start(['app-name'...]) to start multiple applications
|
||||
client.start('originate-example');
|
||||
});
|
||||
@@ -0,0 +1,55 @@
|
||||
import Ari, { Channel } from 'ari-client';
|
||||
|
||||
// async/await version of the example published on project https://github.com/asterisk/node-ari-client.
|
||||
|
||||
export default async () => {
|
||||
try {
|
||||
const client = await Ari.connect('http://ari.js:8088', 'user', 'secret');
|
||||
const ENDPOINT = 'PJSIP/sipphone';
|
||||
|
||||
// Use once to start the application to ensure this listener will only run
|
||||
// for the incoming channel
|
||||
client.once('StasisStart', async (event, incoming) => {
|
||||
await incoming.answer();
|
||||
originate(incoming);
|
||||
});
|
||||
|
||||
const originate = async (incoming: Channel) => {
|
||||
incoming.once('StasisEnd', async (event, channel) => {
|
||||
await outgoing.hangup();
|
||||
});
|
||||
|
||||
const outgoing = client.Channel();
|
||||
|
||||
outgoing.once('ChannelDestroyed', async (event, channel) => {
|
||||
await incoming.hangup();
|
||||
});
|
||||
|
||||
outgoing.once('StasisStart', async (event, outgoing) => {
|
||||
const bridge = client.Bridge();
|
||||
|
||||
outgoing.once('StasisEnd', async (event, channel) => {
|
||||
await bridge.destroy();
|
||||
});
|
||||
|
||||
await outgoing.answer();
|
||||
const mixingBridge = await bridge.create({ type: 'mixing' });
|
||||
await mixingBridge.addChannel({ channel: [incoming.id, outgoing.id] });
|
||||
});
|
||||
|
||||
const playback = client.Playback();
|
||||
await incoming.play({ media: 'sound:vm-dialout' }, playback);
|
||||
|
||||
// Originate call from incoming channel to endpoint
|
||||
await outgoing.originate({
|
||||
endpoint: ENDPOINT,
|
||||
app: 'originate-example',
|
||||
appArgs: 'dialed',
|
||||
});
|
||||
};
|
||||
|
||||
client.start('originate-example');
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,54 @@
|
||||
import Ari, { Channel, Playback } from 'ari-client';
|
||||
import util = require('util');
|
||||
|
||||
// TypeScript version of example published on project https://github.com/asterisk/node-ari-client.
|
||||
|
||||
// replace ari.js with your Asterisk instance
|
||||
Ari.connect('http://ari.js:8088', 'user', 'secret', (err, client) => {
|
||||
// Use once to start the application
|
||||
client.once('StasisStart', (event, incoming) => {
|
||||
incoming.answer(err => {
|
||||
const playback = client.Playback();
|
||||
|
||||
// Play demo greeting and register dtmf event listeners
|
||||
incoming.play({ media: 'sound:demo-congrats' }, playback, (err, playback) => {
|
||||
registerDtmfListeners(err, playback, incoming);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
const registerDtmfListeners = (err: Error, playback: Playback, incoming: Channel) => {
|
||||
incoming.on('ChannelDtmfReceived', (event, channel) => {
|
||||
const digit = event.digit;
|
||||
|
||||
switch (digit) {
|
||||
case '5':
|
||||
playback.control({ operation: 'pause' }, err => {});
|
||||
break;
|
||||
case '8':
|
||||
playback.control({ operation: 'unpause' }, err => {});
|
||||
break;
|
||||
case '4':
|
||||
playback.control({ operation: 'reverse' }, err => {});
|
||||
break;
|
||||
case '6':
|
||||
playback.control({ operation: 'forward' }, err => {});
|
||||
break;
|
||||
case '2':
|
||||
playback.control({ operation: 'restart' }, err => {});
|
||||
break;
|
||||
case '#':
|
||||
playback.control({ operation: 'stop' }, err => {});
|
||||
incoming.hangup(err => {
|
||||
process.exit(0);
|
||||
});
|
||||
break;
|
||||
default:
|
||||
console.error(util.format('Unknown DTMF %s', digit));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// can also use client.start(['app-name'...]) to start multiple applications
|
||||
client.start('playback-example');
|
||||
});
|
||||
@@ -0,0 +1,52 @@
|
||||
import Ari, { Channel, Playback } from 'ari-client';
|
||||
import util = require('util');
|
||||
|
||||
// async/await version of the example published on project https://github.com/asterisk/node-ari-client.
|
||||
|
||||
export default async () => {
|
||||
try {
|
||||
const client = await Ari.connect('http://ari.js:8088', 'user', 'secret');
|
||||
|
||||
// Use once to start the application
|
||||
client.once('StasisStart', async (event, incoming) => {
|
||||
await incoming.answer();
|
||||
const playback = client.Playback();
|
||||
// Play demo greeting and register dtmf event listeners
|
||||
const newPlayback = await incoming.play({ media: 'sound:demo-congrats' }, playback);
|
||||
registerDtmfListeners(newPlayback, incoming);
|
||||
});
|
||||
|
||||
const registerDtmfListeners = (playback: Playback, incoming: Channel) => {
|
||||
incoming.on('ChannelDtmfReceived', async (event, channel) => {
|
||||
const digit = event.digit;
|
||||
switch (digit) {
|
||||
case '5':
|
||||
await playback.control({ operation: 'pause' });
|
||||
break;
|
||||
case '8':
|
||||
await playback.control({ operation: 'unpause' });
|
||||
break;
|
||||
case '4':
|
||||
await playback.control({ operation: 'reverse' });
|
||||
break;
|
||||
case '6':
|
||||
await playback.control({ operation: 'forward' });
|
||||
break;
|
||||
case '2':
|
||||
await playback.control({ operation: 'restart' });
|
||||
break;
|
||||
case '#':
|
||||
await playback.control({ operation: 'stop' });
|
||||
await incoming.hangup();
|
||||
process.exit(0);
|
||||
default:
|
||||
console.error(util.format('Unknown DTMF %s', digit));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
client.start('playback-example');
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"test/bridge.ts",
|
||||
"test/bridgeAsyncAwait.ts",
|
||||
"test/deviceState.ts",
|
||||
"test/deviceStateAsyncAwait.ts",
|
||||
"test/example.ts",
|
||||
"test/exampleAsyncAwait.ts",
|
||||
"test/mwi.ts",
|
||||
"test/mwiAsyncAwait.ts",
|
||||
"test/originate.ts",
|
||||
"test/originateAsyncAwait.ts",
|
||||
"test/playback.ts",
|
||||
"test/playbackAsyncAwait.ts"
|
||||
],
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"esModuleInterop": true,
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
@@ -27,3 +27,4 @@ lock.isBusy('key');
|
||||
const lock2 = new AsyncLock({ timeout : 5000 });
|
||||
const lock3 = new AsyncLock({ maxPending : 5000 });
|
||||
const lock4 = new AsyncLock({ Promise: null });
|
||||
const lock5 = new AsyncLock({ skipQueue: true });
|
||||
|
||||
Vendored
+2
@@ -3,6 +3,7 @@
|
||||
// Definitions by: Elisée MAURER <https://github.com/elisee>
|
||||
// Alejandro <https://github.com/afharo>
|
||||
// Anatoly <https://github.com/rhymmor>
|
||||
// Humulus <https://github.com/humulus>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.1
|
||||
|
||||
@@ -13,6 +14,7 @@ interface AsyncLockOptions {
|
||||
maxPending?: number;
|
||||
domainReentrant?: boolean;
|
||||
Promise?: any;
|
||||
skipQueue?: boolean;
|
||||
}
|
||||
|
||||
declare class AsyncLock {
|
||||
|
||||
Vendored
+9
-1
@@ -1,4 +1,4 @@
|
||||
// Type definitions for Async 3.0
|
||||
// Type definitions for Async 3.2
|
||||
// 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>
|
||||
@@ -8,6 +8,7 @@
|
||||
// Dmitri Trofimov <https://github.com/Dmitri1337>
|
||||
// Etienne Rossignon <https://github.com/erossignon>
|
||||
// Lifeng Zhu <https://github.com/Juliiii>
|
||||
// Tümay Çeber <https://github.com/brendtumi>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
@@ -199,14 +200,21 @@ export const concatSeries: typeof concat;
|
||||
// Control Flow
|
||||
export function series<T, E = Error>(tasks: Array<AsyncFunction<T, E>>, callback?: AsyncResultArrayCallback<T, E>): void;
|
||||
export function series<T, E = Error>(tasks: Dictionary<AsyncFunction<T, E>>, callback?: AsyncResultObjectCallback<T, E>): void;
|
||||
export function series<T, R, E = Error>(tasks: Array<AsyncFunction<T, E>> | Dictionary<AsyncFunction<T, E>>): Promise<R>;
|
||||
export function parallel<T, E = Error>(tasks: Array<AsyncFunction<T, E>>, callback?: AsyncResultArrayCallback<T, E>): void;
|
||||
export function parallel<T, E = Error>(tasks: Dictionary<AsyncFunction<T, E>>, callback?: AsyncResultObjectCallback<T, E>): void;
|
||||
export function parallel<T, R, E = Error>(tasks: Array<AsyncFunction<T, E>> | Dictionary<AsyncFunction<T, E>>): Promise<R>;
|
||||
export function parallelLimit<T, E = Error>(tasks: Array<AsyncFunction<T, E>>, limit: number, callback?: AsyncResultArrayCallback<T, E>): void;
|
||||
export function parallelLimit<T, E = Error>(tasks: Dictionary<AsyncFunction<T, E>>, limit: number, callback?: AsyncResultObjectCallback<T, E>): void;
|
||||
export function parallelLimit<T, R, E = Error>(tasks: Array<AsyncFunction<T, E>> | Dictionary<AsyncFunction<T, E>>, limit: number): Promise<R>;
|
||||
export function whilst<E = Error>(test: () => boolean, fn: AsyncVoidFunction<E>, callback: ErrorCallback<E>): void;
|
||||
export function whilst<R, E = Error>(test: () => boolean, fn: AsyncVoidFunction<E>): Promise<R>;
|
||||
export function doWhilst<T, E = Error>(fn: AsyncFunctionEx<T, E>, test: (...results: T[]) => boolean, callback: ErrorCallback<E>): void;
|
||||
export function doWhilst<T, R, E = Error>(fn: AsyncFunctionEx<T, E>, test: (...results: T[]) => boolean): Promise<R>;
|
||||
export function until<E = Error>(test: () => boolean, fn: AsyncVoidFunction<E>, callback: ErrorCallback<E>): void;
|
||||
export function until<R, E = Error>(test: () => boolean, fn: AsyncVoidFunction<E>): Promise<R>;
|
||||
export function doUntil<T, E = Error>(fn: AsyncFunctionEx<T, E>, test: (...results: T[]) => boolean, callback: ErrorCallback<E>): void;
|
||||
export function doUntil<T, R, E = Error>(fn: AsyncFunctionEx<T, E>, test: (...results: T[]) => boolean): Promise<R>;
|
||||
export function during<E = Error>(test: (testCallback: AsyncBooleanResultCallback<E>) => void, fn: AsyncVoidFunction<E>, callback: ErrorCallback<E>): void;
|
||||
export function doDuring<E = Error>(fn: AsyncVoidFunction<E>, test: (testCallback: AsyncBooleanResultCallback<E>) => void, callback: ErrorCallback<E>): void;
|
||||
export function forever<E = Error>(next: (next: ErrorCallback<E>) => void, errBack: ErrorCallback<E>): void;
|
||||
|
||||
@@ -3,4 +3,6 @@ autocomplete-plus/index.d.ts
|
||||
linter/config.d.ts
|
||||
linter/index.d.ts
|
||||
status-bar/config.d.ts
|
||||
status-bar/index.d.ts
|
||||
status-bar/index.d.ts
|
||||
tool-bar/config.d.ts
|
||||
tool-bar/index.d.ts
|
||||
|
||||
Vendored
+1
@@ -3,6 +3,7 @@
|
||||
// Definitions by: GlenCFL <https://github.com/GlenCFL>
|
||||
// smhxx <https://github.com/smhxx>
|
||||
// lierdakil <https://github.com/lierdakil>
|
||||
// aminya <https://github.com/aminya>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
|
||||
Vendored
+28
@@ -0,0 +1,28 @@
|
||||
import "../index"
|
||||
|
||||
declare module "atom" {
|
||||
interface ConfigValues {
|
||||
/** Make tool-bar visible. - default: true */
|
||||
"tool-bar.visible": boolean
|
||||
|
||||
/** Icon size. - default: "24px" */
|
||||
"tool-bar.iconSize":
|
||||
| "12px"
|
||||
| "14px"
|
||||
| "16px"
|
||||
| "18px"
|
||||
| "21px"
|
||||
| "24px"
|
||||
| "28px"
|
||||
| "32px"
|
||||
|
||||
/** Position of tool-bar. - default: "Top" */
|
||||
"tool-bar.position": "Top" | "Right" | "Bottom" | "Left"
|
||||
|
||||
/** Fit the tool-bar to the window's full-width. - default: true */
|
||||
"tool-bar.fullWidth": boolean
|
||||
|
||||
/** On MacOS, show seven first tool-bar buttons in the TouchBar. - default: true */
|
||||
"tool-bar.useTouchBar": string
|
||||
}
|
||||
}
|
||||
Vendored
+233
@@ -0,0 +1,233 @@
|
||||
// tool-bar 1.2.x
|
||||
// https://atom.io/packages/tool-bar
|
||||
// Definitions by: aminya <https://github.com/aminya>
|
||||
|
||||
/// <reference path="./config.d.ts" />
|
||||
|
||||
import {TooltipPlacement, Disposable} from "../index";
|
||||
|
||||
export declare interface ButtonOptions {
|
||||
/** (optional)
|
||||
* icon name
|
||||
* ## Example:
|
||||
* ```js
|
||||
* icon: 'octoface',
|
||||
* ```
|
||||
*/
|
||||
icon?: string;
|
||||
|
||||
/** (optional)
|
||||
* icon set name.
|
||||
* It can be chosen among these:
|
||||
* - not given : if `iconset` is not given Octicons (default Atom's flavour) is chosen
|
||||
* - `ion` with `ios-` and `md- `prefixes for the icon names (Ionicons)
|
||||
* - `fa` and fab for brands (FontAwesome)
|
||||
* - `fi` (Foundation)
|
||||
* - `icomoon` (IcoMoon)
|
||||
* - `devicon` (Devicon)
|
||||
* - `mdi` (MaterialDesignIcons)
|
||||
*
|
||||
* ## Example:
|
||||
* ```ts
|
||||
* icon: 'ios-gear-a',
|
||||
* iconset: 'ion'
|
||||
* ```
|
||||
*/
|
||||
iconset?:
|
||||
| undefined
|
||||
| "ion"
|
||||
| "fa"
|
||||
| "fab"
|
||||
| "fi"
|
||||
| "icomoon"
|
||||
| "devicon"
|
||||
| "mdi";
|
||||
|
||||
/** (optional)
|
||||
* You can use `text` to:
|
||||
* - add text as a button, or
|
||||
*
|
||||
* ## Example:
|
||||
* ```ts
|
||||
* text: 'hello',
|
||||
* ```
|
||||
* - use HTML for a button. Needs `html` to be set to `true`
|
||||
*
|
||||
* ## Example:
|
||||
* ```ts
|
||||
* text: '<b>BIG</b> button',
|
||||
* html: true,
|
||||
* ```
|
||||
*/
|
||||
text?: string;
|
||||
|
||||
/** (optional)
|
||||
* if set to `true`, `text` will be rendered as HTML
|
||||
* ## Example:
|
||||
* ```ts
|
||||
* text: '<b>BIG</b> button',
|
||||
* html: true,
|
||||
* ```
|
||||
*/
|
||||
html?: boolean;
|
||||
|
||||
/** (mandatory)
|
||||
|
||||
* The callback must be either:
|
||||
* - Atom command: a string or array of strings,
|
||||
* - a custom callback function,
|
||||
* - or an object where the keys are key modifiers (alt, ctrl or shift) and the values are commands or custom functions
|
||||
*
|
||||
* ## Example:
|
||||
* ```ts
|
||||
* callback: 'application:about',
|
||||
* ```
|
||||
*
|
||||
*
|
||||
* ## Example - Callback with modifiers
|
||||
* ```ts
|
||||
* callback: {
|
||||
* '': 'application:cmd-1', // Without modifiers is default action
|
||||
* 'alt': 'application:cmd-2',
|
||||
* 'ctrl': 'application:cmd-3', // With function callback
|
||||
* 'shift'(data) {
|
||||
* console.log(data);
|
||||
* },
|
||||
* 'alt+shift': 'application:cmd-5', // Multiple modifiers
|
||||
* 'alt+ctrl+shift': 'application:cmd-6' // All modifiers
|
||||
* },
|
||||
* data: 'foo'
|
||||
* ```
|
||||
*/
|
||||
callback:
|
||||
| string
|
||||
| Array<string>
|
||||
| ((data?: any) => void)
|
||||
| { [modifier: string]: string }
|
||||
| { [modifier: string]: (data?: any) => void };
|
||||
|
||||
/** `data` can be passed as the input argument of callback, If callback is of type
|
||||
* - `(data: any) => void)` or
|
||||
* - `{ [modifier: string]: ((data: any) => void) }`,
|
||||
*
|
||||
*/
|
||||
data?: any;
|
||||
|
||||
/** (optional) defaults to `50` */
|
||||
priority?: number;
|
||||
|
||||
/** (optional)
|
||||
* The tooltip option may be a string or an object that is passed to Atom's TooltipManager
|
||||
*/
|
||||
tooltip?:
|
||||
| string // minimally sets title
|
||||
// similar to what TooltipManager.add options accepts:
|
||||
| { item?: object }
|
||||
| ({
|
||||
title?: string | (() => string);
|
||||
html?: boolean;
|
||||
keyBindingCommand?: string;
|
||||
keyBindingTarget?: HTMLElement;
|
||||
} & {
|
||||
class?: string;
|
||||
placement?: TooltipPlacement | (() => TooltipPlacement);
|
||||
trigger?: "click" | "hover" | "focus" | "manual";
|
||||
delay?: { show: number; hide: number };
|
||||
});
|
||||
|
||||
/** (optional) Color of the button */
|
||||
color?: string;
|
||||
|
||||
/** (optional) Color of the button's background */
|
||||
background?: string;
|
||||
|
||||
/** Buttons can be styled with arbitrary CSS through classes.
|
||||
* An example of how the class can be used is show below.
|
||||
*
|
||||
* ## Example:
|
||||
* ```ts
|
||||
* class: 'my-awesome-class'
|
||||
* ```
|
||||
*
|
||||
* ## Example:
|
||||
* ```ts
|
||||
* class: ['multiple', 'classes', 'also', 'works']
|
||||
* ```
|
||||
*/
|
||||
class?: string | Array<string>;
|
||||
}
|
||||
|
||||
export declare interface SpacerOptions {
|
||||
/** (optional) defaults to `50` */
|
||||
priority?: number;
|
||||
}
|
||||
|
||||
declare interface ToolBarButtonView {
|
||||
element: HTMLButtonElement;
|
||||
subscriptions: Disposable;
|
||||
priority: number;
|
||||
options: ButtonOptions;
|
||||
group: string;
|
||||
enabled: boolean;
|
||||
|
||||
setEnabled(enabled: boolean): void;
|
||||
|
||||
setSelected(selected: boolean): void;
|
||||
|
||||
getSelected(): boolean;
|
||||
|
||||
_onMouseDown(event: MouseEvent): void;
|
||||
|
||||
_onClick(event: MouseEvent): void;
|
||||
|
||||
executeCallback(event: MouseEvent): void;
|
||||
|
||||
destroy(): void;
|
||||
}
|
||||
|
||||
declare interface ToolBarSpacerView {
|
||||
element: HTMLHRElement;
|
||||
priority: number;
|
||||
group: string;
|
||||
|
||||
destroy(): void;
|
||||
}
|
||||
|
||||
export declare interface ToolBarManager {
|
||||
/** Adds a button. The input to this function is a `ButtonOptions` object */
|
||||
addButton(options: ButtonOptions): ToolBarButtonView;
|
||||
|
||||
/** Adds a spacer. Optionally, you can pass a `SpacerOptions` object */
|
||||
addSpacer(options?: SpacerOptions): ToolBarSpacerView;
|
||||
|
||||
/** Use the method removeItems to remove the buttons added by your package. This is particular useful in your package deactivate method, but can be used at any time.
|
||||
*/
|
||||
removeItems(): void;
|
||||
|
||||
/** The onDidDestroy method takes a function that will be called when the tool-bar package is destroyed. This is useful if your package needs to do cleanup when the tool-bar is deactivated but your package continues running.
|
||||
*/
|
||||
onDidDestroy(callback: () => void): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Passed as an input to `consumeToolBar(getToolBar: getToolBarManager)` function of your package.
|
||||
*
|
||||
* In your main package file, add the following methods and replace your-package-name with your package name.
|
||||
* ```ts
|
||||
* let toolBar: ToolBarManager
|
||||
*
|
||||
* export function consumeToolBar(getToolBar: getToolBarManager) {
|
||||
* toolBar = getToolBar("packageName");
|
||||
* // Add buttons and spacers here...
|
||||
* }
|
||||
*
|
||||
*
|
||||
* export function deactivate() {
|
||||
* if (toolBar) {
|
||||
* toolBar.removeItems();
|
||||
* toolBar = null;
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
export type getToolBarManager = (packageName: string) => ToolBarManager;
|
||||
Vendored
+1
-1
@@ -86,7 +86,7 @@ interface Auth0LockThemeOptions {
|
||||
// https://auth0.com/docs/libraries/lock/v10/sending-authentication-parameters
|
||||
interface Auth0LockAuthParamsOptions {
|
||||
access_token?: any;
|
||||
connection_scopes?: any;
|
||||
connection_scope?: any;
|
||||
device?: any;
|
||||
nonce?: any;
|
||||
protocol?: any;
|
||||
|
||||
@@ -375,6 +375,12 @@ management.importUsers({
|
||||
upsert: true
|
||||
}, (err, data) => console.log(data));
|
||||
|
||||
management.importUsers({
|
||||
users_json: "some json data",
|
||||
connection_id: 'con_id',
|
||||
send_completion_email: false
|
||||
}, (err, data) => console.log(data));
|
||||
|
||||
management.exportUsers({
|
||||
connection_id: 'con_id',
|
||||
fields: [
|
||||
@@ -446,6 +452,10 @@ management.updateRole({id: "role_id"}, {
|
||||
|
||||
management.getPermissionsInRole({id: "role_id"}).then(permissions => console.log(permissions));
|
||||
management.getPermissionsInRole({id: "role_id"}, (err, data) => console.log(data));
|
||||
management.getPermissionsInRole({id: "role_id", per_page: 8}).then(permissions => console.log(permissions));
|
||||
management.getPermissionsInRole({id: "role_id", per_page: 8}, (err, data) => console.log(data));
|
||||
management.getPermissionsInRole({id: "role_id", include_totals: true}).then(permissions => console.log(permissions));
|
||||
management.getPermissionsInRole({id: "role_id", include_totals: true}, (err, data) => console.log(data));
|
||||
|
||||
management.removePermissionsFromRole({id: "role_id"}, {
|
||||
permissions: [
|
||||
@@ -569,3 +579,13 @@ management.unblockUserByIdentifier({ identifier: 'email' }, (err, response) => {
|
||||
}
|
||||
console.log(response);
|
||||
});
|
||||
|
||||
// Rules configurations
|
||||
management.setRulesConfig({key: 'test'}, {value: 'test'}).then((config) => console.log(config));
|
||||
management.setRulesConfig({key: 'test'}, {value: 'test'}, (err, config) => console.log(config));
|
||||
|
||||
management.deleteRulesConfig({key: 'test'}).then(() => {});
|
||||
management.deleteRulesConfig({key: 'test'}, (err) => {});
|
||||
|
||||
management.getRulesConfigs().then((configs) => console.log(configs));
|
||||
management.getRulesConfigs((err, configs) => console.log(configs));
|
||||
|
||||
Vendored
+58
-6
@@ -118,6 +118,20 @@ export interface Rule {
|
||||
order?: number;
|
||||
}
|
||||
|
||||
export interface RulesConfig {
|
||||
/**
|
||||
* Key for a rules config variable.
|
||||
*/
|
||||
key: string;
|
||||
}
|
||||
|
||||
export interface RulesConfigData {
|
||||
/**
|
||||
* Value for a rules config variable.
|
||||
*/
|
||||
value: string
|
||||
}
|
||||
|
||||
export interface Role {
|
||||
id?: string;
|
||||
name?: string;
|
||||
@@ -168,6 +182,15 @@ export interface PermissionData {
|
||||
permission_name: string;
|
||||
}
|
||||
|
||||
export interface GetRolePermissionsData extends ObjectWithId {
|
||||
per_page?: number;
|
||||
page?: number;
|
||||
}
|
||||
|
||||
export interface GetRolePermissionsDataPaged extends GetRolePermissionsData {
|
||||
include_totals: boolean;
|
||||
}
|
||||
|
||||
export interface GetRoleUsersData extends ObjectWithId {
|
||||
per_page?: number;
|
||||
page?: number;
|
||||
@@ -564,6 +587,12 @@ export interface AuthorizationCodeGrantOptions {
|
||||
redirect_uri: string;
|
||||
}
|
||||
|
||||
export interface TokenResponse {
|
||||
access_token: string;
|
||||
token_type: string;
|
||||
expires_in: number;
|
||||
}
|
||||
|
||||
export interface ObjectWithId {
|
||||
id: string;
|
||||
}
|
||||
@@ -669,14 +698,23 @@ export interface VerificationEmailJob {
|
||||
created_at?: string;
|
||||
}
|
||||
|
||||
export interface ImportUsersOptions {
|
||||
users: string;
|
||||
export interface BaseImportUsersOptions {
|
||||
connection_id: string;
|
||||
upsert?: boolean;
|
||||
external_id?: string;
|
||||
send_completion_email?: boolean;
|
||||
}
|
||||
|
||||
export interface ImportUsersFromFileOptions extends BaseImportUsersOptions {
|
||||
users: string;
|
||||
}
|
||||
|
||||
export interface ImportUsersFromJsonOptions extends BaseImportUsersOptions {
|
||||
users_json: string;
|
||||
}
|
||||
|
||||
export type ImportUsersOptions = ImportUsersFromFileOptions | ImportUsersFromJsonOptions;
|
||||
|
||||
export interface ExportUsersOptions {
|
||||
connection_id?: string;
|
||||
format?: JobFormat;
|
||||
@@ -836,11 +874,11 @@ export class AuthenticationClient {
|
||||
getProfile(accessToken: string): Promise<any>;
|
||||
getProfile(accessToken: string, cb: (err: Error, message: string) => void): void;
|
||||
|
||||
clientCredentialsGrant(options: ClientCredentialsGrantOptions): Promise<any>;
|
||||
clientCredentialsGrant(options: ClientCredentialsGrantOptions, cb: (err: Error, response: any) => void): void;
|
||||
clientCredentialsGrant(options: ClientCredentialsGrantOptions): Promise<TokenResponse>;
|
||||
clientCredentialsGrant(options: ClientCredentialsGrantOptions, cb: (err: Error, response: TokenResponse) => void): void;
|
||||
|
||||
passwordGrant(options: PasswordGrantOptions): Promise<any>;
|
||||
passwordGrant(options: PasswordGrantOptions, cb: (err: Error, response: any) => void): void;
|
||||
passwordGrant(options: PasswordGrantOptions): Promise<TokenResponse>;
|
||||
passwordGrant(options: PasswordGrantOptions, cb: (err: Error, response: TokenResponse) => void): void;
|
||||
|
||||
}
|
||||
|
||||
@@ -931,6 +969,10 @@ export class ManagementClient<A=AppMetadata, U=UserMetadata> {
|
||||
|
||||
getPermissionsInRole(params: ObjectWithId): Promise<Permission[]>;
|
||||
getPermissionsInRole(params: ObjectWithId, cb: (err: Error, permissions: Permission[]) => void): void;
|
||||
getPermissionsInRole(params: GetRolePermissionsData): Promise<Permission[]>;
|
||||
getPermissionsInRole(params: GetRolePermissionsData, cb: (err: Error, permissions: Permission[]) => void): void;
|
||||
getPermissionsInRole(params: GetRolePermissionsDataPaged): Promise<PermissionPage>;
|
||||
getPermissionsInRole(params: GetRolePermissionsDataPaged, cb: (err: Error, permissionPage: PermissionPage) => void): void;
|
||||
|
||||
removePermissionsFromRole(params: ObjectWithId, data: PermissionsData): Promise<void>;
|
||||
removePermissionsFromRole(params: ObjectWithId, data: PermissionsData, cb: (err: Error) => void): void;
|
||||
@@ -961,6 +1003,16 @@ export class ManagementClient<A=AppMetadata, U=UserMetadata> {
|
||||
deleteRule(params: ObjectWithId): Promise<void>;
|
||||
deleteRule(params: ObjectWithId, cb: (err: Error) => void): void;
|
||||
|
||||
// Rules Configurations
|
||||
getRulesConfigs(): Promise<RulesConfig[]>;
|
||||
getRulesConfigs(cb: (err: Error, rulesConfigs: RulesConfig[]) => void): void;
|
||||
|
||||
setRulesConfig(params: RulesConfig, data: RulesConfigData): Promise<RulesConfig & RulesConfigData>;
|
||||
setRulesConfig(params: RulesConfig, data: RulesConfigData,
|
||||
cb: (err: Error, rulesConfig: RulesConfig & RulesConfigData) => void):void;
|
||||
|
||||
deleteRulesConfig(params: RulesConfig): Promise<void>;
|
||||
deleteRulesConfig(params: RulesConfig, cb: (err: Error) => void): void;
|
||||
|
||||
// Users
|
||||
getUsers(params: GetUsersDataPaged): Promise<UserPage<A, U>>;
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import autoprefixer = require('autoprefixer');
|
||||
import Browsers = require('autoprefixer/lib/browsers');
|
||||
import Prefixes = require('autoprefixer/lib/prefixes');
|
||||
import { Transformer } from 'postcss';
|
||||
|
||||
// No options
|
||||
@@ -36,3 +38,31 @@ const ap3: Transformer = autoprefixer({
|
||||
ssr: ['node 12'],
|
||||
},
|
||||
});
|
||||
|
||||
const prefixes = new Prefixes(autoprefixer.data.prefixes, new Browsers(autoprefixer.data.browsers, []));
|
||||
const autoprefixerApiTest = {
|
||||
atRuleName(identifier: string) {
|
||||
return Boolean(prefixes.remove[`@${identifier.toLowerCase()}`]);
|
||||
},
|
||||
selector(identifier: string) {
|
||||
return prefixes.remove.selectors.some((selectorObj: { prefixed: string }) => {
|
||||
return identifier.toLowerCase() === selectorObj.prefixed;
|
||||
});
|
||||
},
|
||||
mediaFeatureName(identifier: string) {
|
||||
return identifier.toLowerCase().includes('device-pixel-ratio');
|
||||
},
|
||||
property(identifier: string) {
|
||||
return Boolean(autoprefixer.data.prefixes[prefixes.unprefixed(identifier.toLowerCase())]);
|
||||
},
|
||||
propertyValue(prop: string, value: string) {
|
||||
const possiblePrefixableValues =
|
||||
(prefixes.remove[prop.toLowerCase()] && prefixes.remove[prop.toLowerCase()].values) || false;
|
||||
return (
|
||||
possiblePrefixableValues &&
|
||||
possiblePrefixableValues.some((valueObj: { prefixed: string }) => {
|
||||
return value.toLowerCase() === valueObj.prefixed;
|
||||
})
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
import browserslist = require('browserslist');
|
||||
|
||||
type Queries = string | ReadonlyArray<string>;
|
||||
|
||||
interface Browsers {
|
||||
parse(queries: Queries): string[];
|
||||
prefix(browser: string): string;
|
||||
isSelected(browser: string): boolean;
|
||||
}
|
||||
|
||||
declare class BrowsersImpl implements Browsers {
|
||||
constructor(data: { [k: string]: any }, options?: any, browserslistOpts?: browserslist.Options);
|
||||
|
||||
isSelected(browser: string): boolean;
|
||||
|
||||
parse(queries: string | ReadonlyArray<string>): string[];
|
||||
|
||||
prefix(browser: string): string;
|
||||
|
||||
prefixes(): string[];
|
||||
|
||||
withPrefix(value: string): boolean;
|
||||
}
|
||||
|
||||
export = BrowsersImpl;
|
||||
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
import Browsers = require('./browsers');
|
||||
|
||||
interface Prefixes {
|
||||
remove: { [k: string]: any };
|
||||
|
||||
unprefixed(value: string): string;
|
||||
}
|
||||
|
||||
declare class PrefixesImpl implements Prefixes {
|
||||
constructor(data: string[], browsers: Browsers, options?: any);
|
||||
|
||||
remove: { [p: string]: any };
|
||||
|
||||
unprefixed(value: string): string;
|
||||
}
|
||||
|
||||
export = PrefixesImpl;
|
||||
@@ -0,0 +1,50 @@
|
||||
import kcl from 'aws-kcl';
|
||||
|
||||
// Example used from https://github.com/awslabs/amazon-kinesis-client-nodejs
|
||||
const recordProcessor = {
|
||||
initialize(_initializeInput: kcl.InitializeInput, completeCallback: kcl.Callback) {
|
||||
completeCallback();
|
||||
},
|
||||
|
||||
processRecords(processRecordsInput: kcl.ProcessRecordsInput, completeCallback: kcl.Callback) {
|
||||
if (!processRecordsInput || !processRecordsInput.records) {
|
||||
completeCallback();
|
||||
return;
|
||||
}
|
||||
|
||||
const records = processRecordsInput.records;
|
||||
let record;
|
||||
let sequenceNumber;
|
||||
|
||||
for (record of records) {
|
||||
sequenceNumber = record.sequenceNumber;
|
||||
const partitionKey = record.partitionKey;
|
||||
const data = new Buffer(record.data, 'base64').toString();
|
||||
console.log(partitionKey, data);
|
||||
}
|
||||
|
||||
if (!sequenceNumber) {
|
||||
completeCallback();
|
||||
return;
|
||||
}
|
||||
processRecordsInput.checkpointer.checkpoint(
|
||||
sequenceNumber,
|
||||
(_err: string | undefined, _checkpointedSequenceNumber: string) => {
|
||||
completeCallback();
|
||||
},
|
||||
);
|
||||
},
|
||||
|
||||
leaseLost(_leaseLostInput: kcl.LeaseLossInput, completeCallback: kcl.Callback) {
|
||||
completeCallback();
|
||||
},
|
||||
|
||||
shardEnded(shardEndedInput: kcl.ShardEndedInput, completeCallback: kcl.Callback) {
|
||||
shardEndedInput.checkpointer.checkpoint((_err?: string) => {
|
||||
completeCallback();
|
||||
});
|
||||
completeCallback();
|
||||
},
|
||||
};
|
||||
|
||||
kcl(recordProcessor).run();
|
||||
Vendored
+136
@@ -0,0 +1,136 @@
|
||||
// Type definitions for aws-kcl 2.0
|
||||
// Project: https://github.com/awslabs/amazon-kinesis-client-nodejs
|
||||
// Definitions by: Vlad Shlosberg <https://github.com/vshlos>
|
||||
// Foqal <https://github.com/foqal>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
import * as fs from "fs";
|
||||
|
||||
export = KCLProcess;
|
||||
|
||||
declare function KCLProcess(
|
||||
recordProcessor: KCLProcess.RecordProcessor,
|
||||
inputFile?: fs.ReadStream,
|
||||
outputFile?: fs.WriteStream,
|
||||
errorFile?: fs.WriteStream,
|
||||
): KCLProcess.KCLManager;
|
||||
|
||||
declare namespace KCLProcess {
|
||||
type Callback = () => void;
|
||||
|
||||
type CheckpointCallback = (error: string | undefined, checkpointedSequenceNumber: string) => void;
|
||||
|
||||
interface Checkpointer {
|
||||
/**
|
||||
* Checkpoints at a given sequence number.
|
||||
* @param sequenceNumber Sequence number of the record to checkpoint;
|
||||
* @param callback Function that is invoked after the checkpoint operation completes.
|
||||
*/
|
||||
checkpoint(sequenceNumber: string, callback: CheckpointCallback): void;
|
||||
|
||||
/**
|
||||
* Checkpoints at the checkpoint will be at the end of the most
|
||||
* recently-delivered list of records.
|
||||
* @param callback Function that is invoked after the checkpoint
|
||||
* operation completes.
|
||||
*/
|
||||
checkpoint(callback: CheckpointCallback): void;
|
||||
}
|
||||
|
||||
interface InitializeInput {
|
||||
shardId: string;
|
||||
sequenceNumber?: string;
|
||||
subSequenceNumber?: number;
|
||||
}
|
||||
|
||||
interface CheckpointInput {
|
||||
checkpointer: Checkpointer;
|
||||
}
|
||||
|
||||
interface Record {
|
||||
data: string;
|
||||
partitionKey: string;
|
||||
sequenceNumber: string;
|
||||
}
|
||||
|
||||
interface ProcessRecordsInput extends CheckpointInput {
|
||||
records: Record[];
|
||||
millisBehindLatest?: number;
|
||||
}
|
||||
|
||||
interface LeaseLossInput {} // tslint:disable-line:no-empty-interface
|
||||
|
||||
interface ShardEndedInput extends CheckpointInput {} // tslint:disable-line:no-empty-interface
|
||||
|
||||
interface RecordProcessor {
|
||||
/**
|
||||
* Called once by the KCL before any calls to processRecords. Any initialization
|
||||
* logic for record processing can go here.
|
||||
*
|
||||
* @param initializeInput - Initialization related information.
|
||||
* @param completeCallback - The callback that must be invoked
|
||||
* once the initialization operation is complete.
|
||||
*/
|
||||
initialize(initializeInput: InitializeInput, completeCallback: Callback): void;
|
||||
|
||||
/**
|
||||
* Called by KCL with a list of records to be processed and checkpointed.
|
||||
* A record looks like:
|
||||
*
|
||||
* The checkpointer can optionally be used to checkpoint a particular sequence
|
||||
* number (from a record). If checkpointing, the checkpoint must always be
|
||||
* invoked before calling `completeCallback` for processRecords. Moreover,
|
||||
* `completeCallback` should only be invoked once the checkpoint operation
|
||||
* callback is received.
|
||||
*
|
||||
* @param processRecordsInput Process records information with
|
||||
* array of records that are to be processed.
|
||||
* @param completeCallback The callback that must be invoked
|
||||
* once all records are processed and checkpoint (optional) is
|
||||
* complete.
|
||||
*/
|
||||
processRecords(processRecordsInput: ProcessRecordsInput, completeCallback: Callback): void;
|
||||
|
||||
/**
|
||||
* Called by the KCL to indicate that this record processor should shut down.
|
||||
* After the lease lost operation is complete, there will not be any more calls to
|
||||
* any other functions of this record processor. Clients should not attempt to
|
||||
* checkpoint because the lease has been lost by this Worker.
|
||||
*
|
||||
* @param leaseLostInput Lease lost information.
|
||||
* @param completeCallback The callback must be invoked once lease
|
||||
* lost operations are completed.
|
||||
*/
|
||||
leaseLost(leaseLostInput: LeaseLossInput, completeCallback: Callback): void;
|
||||
/**
|
||||
* Called by the KCL to indicate that this record processor should shutdown.
|
||||
* After the shard ended operation is complete, there will not be any more calls to
|
||||
* any other functions of this record processor. Clients are required to checkpoint
|
||||
* at this time. This indicates that the current record processor has finished
|
||||
* processing and new record processors for the children will be created.
|
||||
*
|
||||
* @param shardEndedInput ShardEnded information.
|
||||
* @param completeCallback The callback must be invoked once shard
|
||||
* ended operations are completed.
|
||||
*/
|
||||
shardEnded(shardEndedInput: ShardEndedInput, completeCallback: Callback): void;
|
||||
}
|
||||
|
||||
interface KCLInput {
|
||||
recordProcessor: RecordProcessor;
|
||||
version: symbol;
|
||||
}
|
||||
|
||||
class KCLManager {
|
||||
constructor(
|
||||
kclManagerInput: KCLInput,
|
||||
inputFile?: fs.ReadStream,
|
||||
outputFile?: fs.WriteStream,
|
||||
errorFile?: fs.WriteStream,
|
||||
);
|
||||
checkpoint(sequenceNumber: string): void;
|
||||
run(): void;
|
||||
}
|
||||
}
|
||||
@@ -6,17 +6,19 @@
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": ["../"],
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"allowSyntheticDefaultImports": true
|
||||
"esModuleInterop": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"cloudevents-sdk-tests.ts"
|
||||
"aws-kcl-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
+3
-3
@@ -60,9 +60,9 @@ export interface CloudFrontEvent {
|
||||
config: {
|
||||
readonly distributionDomainName: string;
|
||||
readonly distributionId: string;
|
||||
} & (
|
||||
| { readonly eventType: 'origin-request' | 'origin-response' }
|
||||
| { readonly eventType: 'viewer-request' | 'viewer-response'; readonly requestId: string });
|
||||
readonly eventType: 'origin-request' | 'origin-response' | 'viewer-request' | 'viewer-response';
|
||||
readonly requestId: string;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -201,7 +201,6 @@ const authorizer: APIGatewayAuthorizerHandler = async (event, context, callback)
|
||||
str = event.resource; // $ExpectError
|
||||
} else {
|
||||
event.type; // $ExpectType "REQUEST"
|
||||
str = event.methodArn; // $ExpectError
|
||||
str = event.resource;
|
||||
}
|
||||
|
||||
@@ -221,7 +220,6 @@ const authorizerWithCustomContext: APIGatewayAuthorizerWithContextHandler<Custom
|
||||
str = event.resource; // $ExpectError
|
||||
} else {
|
||||
event.type; // $ExpectType "REQUEST"
|
||||
str = event.methodArn; // $ExpectError
|
||||
str = event.resource;
|
||||
}
|
||||
|
||||
@@ -273,7 +271,7 @@ const requestAuthorizer: APIGatewayRequestAuthorizerHandler = async (event, cont
|
||||
event.type; // $ExpectType "REQUEST"
|
||||
|
||||
str = event.type;
|
||||
str = event.methodArn; // $ExpectError
|
||||
str = event.methodArn;
|
||||
str = event.authorizationToken; // $ExpectError
|
||||
str = event.resource;
|
||||
str = event.path;
|
||||
@@ -291,8 +289,10 @@ const requestAuthorizer: APIGatewayRequestAuthorizerHandler = async (event, cont
|
||||
if (event.stageVariables !== null)
|
||||
str = event.stageVariables[str];
|
||||
const requestContext: APIGatewayEventRequestContext = event.requestContext;
|
||||
str = event.domainName;
|
||||
str = event.apiId;
|
||||
if (requestContext.domainName != null) {
|
||||
str = requestContext.domainName;
|
||||
}
|
||||
str = requestContext.apiId;
|
||||
|
||||
const result = createAuthorizerResult();
|
||||
|
||||
@@ -305,7 +305,7 @@ const requestAuthorizerWithCustomContext: APIGatewayRequestAuthorizerWithContext
|
||||
event.type; // $ExpectType "REQUEST"
|
||||
|
||||
str = event.type;
|
||||
str = event.methodArn; // $ExpectError
|
||||
str = event.methodArn;
|
||||
str = event.authorizationToken; // $ExpectError
|
||||
|
||||
const result = createAuthorizerResultWithCustomContext();
|
||||
|
||||
@@ -277,3 +277,201 @@ const responseEvent: CloudFrontResponseEvent = {
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const originRequestEvent: CloudFrontRequestEvent = {
|
||||
Records: [
|
||||
{
|
||||
cf: {
|
||||
config: {
|
||||
distributionDomainName: "d111111abcdef8.cloudfront.net",
|
||||
distributionId: "EDFDVBD6EXAMPLE",
|
||||
eventType: "origin-request",
|
||||
requestId: "4TyzHTaYWb1GX1qTfsHhEqV6HUDd_BzoBZnwfnvQc_1oF26ClkoUSEQ=="
|
||||
},
|
||||
request: {
|
||||
clientIp: "203.0.113.178",
|
||||
headers: {
|
||||
"x-forwarded-for": [
|
||||
{
|
||||
key: "X-Forwarded-For",
|
||||
value: "203.0.113.178"
|
||||
}
|
||||
],
|
||||
"user-agent": [
|
||||
{
|
||||
key: "User-Agent",
|
||||
value: "Amazon CloudFront"
|
||||
}
|
||||
],
|
||||
via: [
|
||||
{
|
||||
key: "Via",
|
||||
value:
|
||||
"2.0 2afae0d44e2540f472c0635ab62c232b.cloudfront.net (CloudFront)"
|
||||
}
|
||||
],
|
||||
host: [
|
||||
{
|
||||
key: "Host",
|
||||
value: "example.org"
|
||||
}
|
||||
],
|
||||
"cache-control": [
|
||||
{
|
||||
key: "Cache-Control",
|
||||
value: "no-cache, cf-no-cache"
|
||||
}
|
||||
]
|
||||
},
|
||||
method: "GET",
|
||||
origin: {
|
||||
custom: {
|
||||
customHeaders: {},
|
||||
domainName: "example.org",
|
||||
keepaliveTimeout: 5,
|
||||
path: "",
|
||||
port: 443,
|
||||
protocol: "https",
|
||||
readTimeout: 30,
|
||||
sslProtocols: ["TLSv1", "TLSv1.1", "TLSv1.2"]
|
||||
}
|
||||
},
|
||||
querystring: "",
|
||||
uri: "/"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
const originResponseEvent: CloudFrontResponseEvent = {
|
||||
Records: [
|
||||
{
|
||||
cf: {
|
||||
config: {
|
||||
distributionDomainName: "d111111abcdef8.cloudfront.net",
|
||||
distributionId: "EDFDVBD6EXAMPLE",
|
||||
eventType: "origin-response",
|
||||
requestId: "4TyzHTaYWb1GX1qTfsHhEqV6HUDd_BzoBZnwfnvQc_1oF26ClkoUSEQ=="
|
||||
},
|
||||
request: {
|
||||
clientIp: "203.0.113.178",
|
||||
headers: {
|
||||
"x-forwarded-for": [
|
||||
{
|
||||
key: "X-Forwarded-For",
|
||||
value: "203.0.113.178"
|
||||
}
|
||||
],
|
||||
"user-agent": [
|
||||
{
|
||||
key: "User-Agent",
|
||||
value: "Amazon CloudFront"
|
||||
}
|
||||
],
|
||||
via: [
|
||||
{
|
||||
key: "Via",
|
||||
value:
|
||||
"2.0 8f22423015641505b8c857a37450d6c0.cloudfront.net (CloudFront)"
|
||||
}
|
||||
],
|
||||
host: [
|
||||
{
|
||||
key: "Host",
|
||||
value: "example.org"
|
||||
}
|
||||
],
|
||||
"cache-control": [
|
||||
{
|
||||
key: "Cache-Control",
|
||||
value: "no-cache, cf-no-cache"
|
||||
}
|
||||
]
|
||||
},
|
||||
method: "GET",
|
||||
origin: {
|
||||
custom: {
|
||||
customHeaders: {},
|
||||
domainName: "example.org",
|
||||
keepaliveTimeout: 5,
|
||||
path: "",
|
||||
port: 443,
|
||||
protocol: "https",
|
||||
readTimeout: 30,
|
||||
sslProtocols: ["TLSv1", "TLSv1.1", "TLSv1.2"]
|
||||
}
|
||||
},
|
||||
querystring: "",
|
||||
uri: "/"
|
||||
},
|
||||
response: {
|
||||
headers: {
|
||||
"access-control-allow-credentials": [
|
||||
{
|
||||
key: "Access-Control-Allow-Credentials",
|
||||
value: "true"
|
||||
}
|
||||
],
|
||||
"access-control-allow-origin": [
|
||||
{
|
||||
key: "Access-Control-Allow-Origin",
|
||||
value: "*"
|
||||
}
|
||||
],
|
||||
date: [
|
||||
{
|
||||
key: "Date",
|
||||
value: "Mon, 13 Jan 2020 20:12:38 GMT"
|
||||
}
|
||||
],
|
||||
"referrer-policy": [
|
||||
{
|
||||
key: "Referrer-Policy",
|
||||
value: "no-referrer-when-downgrade"
|
||||
}
|
||||
],
|
||||
server: [
|
||||
{
|
||||
key: "Server",
|
||||
value: "ExampleCustomOriginServer"
|
||||
}
|
||||
],
|
||||
"x-content-type-options": [
|
||||
{
|
||||
key: "X-Content-Type-Options",
|
||||
value: "nosniff"
|
||||
}
|
||||
],
|
||||
"x-frame-options": [
|
||||
{
|
||||
key: "X-Frame-Options",
|
||||
value: "DENY"
|
||||
}
|
||||
],
|
||||
"x-xss-protection": [
|
||||
{
|
||||
key: "X-XSS-Protection",
|
||||
value: "1; mode=block"
|
||||
}
|
||||
],
|
||||
"content-type": [
|
||||
{
|
||||
key: "Content-Type",
|
||||
value: "text/html; charset=utf-8"
|
||||
}
|
||||
],
|
||||
"content-length": [
|
||||
{
|
||||
key: "Content-Length",
|
||||
value: "9593"
|
||||
}
|
||||
]
|
||||
},
|
||||
status: "200",
|
||||
statusDescription: "OK"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
@@ -49,6 +49,7 @@ const handler: CognitoUserPoolTriggerHandler = async (event, context, callback)
|
||||
event.request.session![0].challengeName === 'DEVICE_SRP_AUTH';
|
||||
event.request.session![0].challengeName === 'DEVICE_PASSWORD_VERIFIER';
|
||||
event.request.session![0].challengeName === 'ADMIN_NO_SRP_AUTH';
|
||||
event.request.session![0].challengeName === 'SRP_A';
|
||||
bool = event.request.session![0].challengeResult;
|
||||
strOrUndefined = event.request.session![0].challengeMetadata;
|
||||
strOrUndefined = event.request.challengeName;
|
||||
@@ -56,6 +57,7 @@ const handler: CognitoUserPoolTriggerHandler = async (event, context, callback)
|
||||
str = event.request.challengeAnswer!;
|
||||
strOrUndefined = event.request.password;
|
||||
str = event.request.clientMetadata!['action'];
|
||||
boolOrUndefined = event.request.userNotFound;
|
||||
boolOrUndefined = event.response.answerCorrect;
|
||||
strOrUndefined = event.response.smsMessage;
|
||||
strOrUndefined = event.response.emailMessage;
|
||||
|
||||
+3
-2
@@ -34,8 +34,11 @@ export interface APIGatewayTokenAuthorizerEvent {
|
||||
// Note, when invoked by the tester in the AWS web console, the map values can be null,
|
||||
// but they will be empty objects in the real object.
|
||||
// Worse, it will include "body" and "isBase64Encoded" properties, unlike the real call!
|
||||
// See https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-lambda-authorizer-input.html for the
|
||||
// formal definition.
|
||||
export interface APIGatewayRequestAuthorizerEvent {
|
||||
type: "REQUEST";
|
||||
methodArn: string;
|
||||
resource: string;
|
||||
path: string;
|
||||
httpMethod: string;
|
||||
@@ -46,8 +49,6 @@ export interface APIGatewayRequestAuthorizerEvent {
|
||||
multiValueQueryStringParameters: { [name: string]: string[] } | null;
|
||||
stageVariables: { [name: string]: string } | null;
|
||||
requestContext: APIGatewayEventRequestContextWithAuthorizer<undefined>;
|
||||
domainName: string;
|
||||
apiId: string;
|
||||
}
|
||||
|
||||
export interface APIGatewayAuthorizerResult {
|
||||
|
||||
+3
-1
@@ -57,7 +57,8 @@ export interface CognitoUserPoolTriggerEvent {
|
||||
| 'SMS_MFA'
|
||||
| 'DEVICE_SRP_AUTH'
|
||||
| 'DEVICE_PASSWORD_VERIFIER'
|
||||
| 'ADMIN_NO_SRP_AUTH';
|
||||
| 'ADMIN_NO_SRP_AUTH'
|
||||
| 'SRP_A';
|
||||
challengeResult: boolean;
|
||||
challengeMetadata?: string;
|
||||
}>;
|
||||
@@ -66,6 +67,7 @@ export interface CognitoUserPoolTriggerEvent {
|
||||
challengeAnswer?: string;
|
||||
password?: string;
|
||||
clientMetadata?: { [key: string]: string };
|
||||
userNotFound?: boolean;
|
||||
};
|
||||
response: {
|
||||
autoConfirmUser?: boolean;
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
import bSpline = require('b-spline');
|
||||
bSpline<[number, number]>(0, 1, [[0, 0], [1, 0], [1, 1]]); // $ExpectType [number, number]
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
// Type definitions for b-spline 2.0
|
||||
// Project: https://github.com/thibauts/b-spline
|
||||
// Definitions by: Ruby <https://github.com/Rupertofly>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
declare function interpolate<T extends ArrayLike<number>>(t: number, degree: number, points: T[], knots?: number[], weights?: number[]): T;
|
||||
|
||||
export = interpolate;
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": ["es6"],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": ["../"],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": ["index.d.ts", "b-spline-tests.ts"]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Vendored
+4
-4
@@ -71,7 +71,7 @@ export interface TransformOptions {
|
||||
*
|
||||
* Default: `undefined`
|
||||
*/
|
||||
configFile?: string | false | null;
|
||||
configFile?: string | boolean | null;
|
||||
|
||||
/**
|
||||
* Specify whether or not to use .babelrc and
|
||||
@@ -87,7 +87,7 @@ export interface TransformOptions {
|
||||
*
|
||||
* Default: `(root)`
|
||||
*/
|
||||
babelrcRoots?: true | string | string[] | null;
|
||||
babelrcRoots?: boolean | MatchPattern | MatchPattern[] | null;
|
||||
|
||||
/**
|
||||
* Defaults to environment variable `BABEL_ENV` if set, or else `NODE_ENV` if set, or else it defaults to `"development"`
|
||||
@@ -192,7 +192,7 @@ export interface TransformOptions {
|
||||
*
|
||||
* Default: `null`
|
||||
*/
|
||||
ignore?: string[] | null;
|
||||
ignore?: MatchPattern[] | null;
|
||||
|
||||
/**
|
||||
* This option is a synonym for "test"
|
||||
@@ -240,7 +240,7 @@ export interface TransformOptions {
|
||||
*
|
||||
* Default: `null`
|
||||
*/
|
||||
only?: string | RegExp | Array<string | RegExp> | null;
|
||||
only?: MatchPattern[] | null;
|
||||
|
||||
/**
|
||||
* Allows users to provide an array of options that will be merged into the current configuration one at a time.
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
/* tslint:disable:no-consecutive-blank-lines comment-format */
|
||||
|
||||
import { Options } from '@babel/plugin-transform-runtime';
|
||||
|
||||
|
||||
//========//
|
||||
// COREJS //
|
||||
//========//
|
||||
|
||||
let options: Options = {
|
||||
corejs: 2,
|
||||
};
|
||||
|
||||
options = {
|
||||
corejs: 3,
|
||||
};
|
||||
|
||||
options = {
|
||||
corejs: {
|
||||
version: 2,
|
||||
proposals: true,
|
||||
},
|
||||
};
|
||||
|
||||
options = {
|
||||
corejs: {
|
||||
version: 3,
|
||||
proposals: false,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
//=========//
|
||||
// HELPERS //
|
||||
//=========//
|
||||
|
||||
options = {
|
||||
helpers: true,
|
||||
};
|
||||
|
||||
options = {
|
||||
helpers: false,
|
||||
};
|
||||
|
||||
|
||||
//=============//
|
||||
// REGENERATOR //
|
||||
//=============//
|
||||
|
||||
options = {
|
||||
regenerator: true,
|
||||
};
|
||||
|
||||
options = {
|
||||
regenerator: false,
|
||||
};
|
||||
|
||||
|
||||
//================//
|
||||
// USE ES MODULES //
|
||||
//================//
|
||||
|
||||
options = {
|
||||
useESModules: true,
|
||||
};
|
||||
|
||||
options = {
|
||||
useESModules: false,
|
||||
};
|
||||
|
||||
|
||||
//==================//
|
||||
// ABSOLUTE RUNTIME //
|
||||
//==================//
|
||||
|
||||
options = {
|
||||
absoluteRuntime: true,
|
||||
};
|
||||
|
||||
options = {
|
||||
absoluteRuntime: false,
|
||||
};
|
||||
|
||||
options = {
|
||||
absoluteRuntime: '/some/path/here',
|
||||
};
|
||||
|
||||
|
||||
//=========//
|
||||
// VERSION //
|
||||
//=========//
|
||||
|
||||
options = {
|
||||
version: '^1.2.3',
|
||||
};
|
||||
@@ -0,0 +1,21 @@
|
||||
// Type definitions for @babel/plugin-transform-runtime 7.9
|
||||
// Project: https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-runtime, https://babeljs.io/docs/en/babel-plugin-transform-runtime
|
||||
// Definitions by: Slava Fomin II <https://github.com/slavafomin>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export interface Options {
|
||||
corejs?: CorejsOption;
|
||||
helpers?: boolean;
|
||||
regenerator?: boolean;
|
||||
useESModules?: boolean;
|
||||
absoluteRuntime?: (boolean | string);
|
||||
version?: string;
|
||||
}
|
||||
|
||||
export type CorejsOption = (
|
||||
| CorejsVersion
|
||||
| { version: CorejsVersion, proposals: boolean }
|
||||
| false
|
||||
);
|
||||
|
||||
export type CorejsVersion = (2 | 3);
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"strict": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"paths": {
|
||||
"@babel/plugin-transform-runtime": [
|
||||
"babel__plugin-transform-runtime"
|
||||
]
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"babel__plugin-transform-runtime-tests.ts"
|
||||
]
|
||||
}
|
||||
+1
-2
@@ -1,4 +1,3 @@
|
||||
{
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
|
||||
}
|
||||
@@ -0,0 +1,277 @@
|
||||
/* tslint:disable:no-consecutive-blank-lines comment-format */
|
||||
|
||||
import { Options } from '@babel/preset-env';
|
||||
|
||||
|
||||
//=========//
|
||||
// TARGETS //
|
||||
//=========//
|
||||
|
||||
let options: Options = {
|
||||
targets: '> 0.25%, not dead',
|
||||
};
|
||||
|
||||
options = {
|
||||
targets: [
|
||||
'> 0.25%',
|
||||
'not dead',
|
||||
],
|
||||
};
|
||||
|
||||
options = {
|
||||
targets: {
|
||||
OperaMini: '80',
|
||||
Edge: '22',
|
||||
ie: '11',
|
||||
},
|
||||
};
|
||||
|
||||
options = {
|
||||
targets: {
|
||||
esmodules: true,
|
||||
},
|
||||
};
|
||||
|
||||
options = {
|
||||
targets: {
|
||||
node: '12',
|
||||
},
|
||||
};
|
||||
|
||||
options = {
|
||||
targets: {
|
||||
node: 'current',
|
||||
},
|
||||
};
|
||||
|
||||
options = {
|
||||
targets: {
|
||||
node: true,
|
||||
},
|
||||
};
|
||||
|
||||
options = {
|
||||
targets: {
|
||||
safari: '20',
|
||||
},
|
||||
};
|
||||
|
||||
options = {
|
||||
targets: {
|
||||
safari: 'tp',
|
||||
},
|
||||
};
|
||||
|
||||
options = {
|
||||
targets: {
|
||||
browsers: '> 0.25%, not dead',
|
||||
},
|
||||
};
|
||||
|
||||
options = {
|
||||
targets: {
|
||||
browsers: [
|
||||
'> 0.25%',
|
||||
'not dead',
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
//==========//
|
||||
// BUGFIXES //
|
||||
//==========//
|
||||
|
||||
options = {
|
||||
bugfixes: true,
|
||||
};
|
||||
|
||||
options = {
|
||||
bugfixes: false,
|
||||
};
|
||||
|
||||
|
||||
//======//
|
||||
// SPEC //
|
||||
//======//
|
||||
|
||||
options = {
|
||||
spec: true,
|
||||
};
|
||||
|
||||
options = {
|
||||
spec: false,
|
||||
};
|
||||
|
||||
|
||||
//=======//
|
||||
// LOOSE //
|
||||
//=======//
|
||||
|
||||
options = {
|
||||
loose: true,
|
||||
};
|
||||
|
||||
options = {
|
||||
loose: false,
|
||||
};
|
||||
|
||||
|
||||
//=========//
|
||||
// MODULES //
|
||||
//=========//
|
||||
|
||||
options = {
|
||||
modules: 'amd',
|
||||
};
|
||||
|
||||
options = {
|
||||
modules: 'cjs',
|
||||
};
|
||||
|
||||
options = {
|
||||
modules: 'commonjs',
|
||||
};
|
||||
|
||||
options = {
|
||||
modules: false,
|
||||
};
|
||||
|
||||
|
||||
//=======//
|
||||
// DEBUG //
|
||||
//=======//
|
||||
|
||||
options = {
|
||||
debug: true,
|
||||
};
|
||||
|
||||
options = {
|
||||
debug: false,
|
||||
};
|
||||
|
||||
|
||||
//=========//
|
||||
// INCLUDE //
|
||||
//=========//
|
||||
|
||||
options = {
|
||||
include: [],
|
||||
};
|
||||
|
||||
options = {
|
||||
include: ['foo', 'bar'],
|
||||
};
|
||||
|
||||
options = {
|
||||
include: [/foo/, /bar/],
|
||||
};
|
||||
|
||||
|
||||
//=========//
|
||||
// EXCLUDE //
|
||||
//=========//
|
||||
|
||||
options = {
|
||||
exclude: [],
|
||||
};
|
||||
|
||||
options = {
|
||||
exclude: ['foo', 'bar'],
|
||||
};
|
||||
|
||||
options = {
|
||||
exclude: [/foo/, /bar/],
|
||||
};
|
||||
|
||||
|
||||
//===============//
|
||||
// USE BUILT INS //
|
||||
//===============//
|
||||
|
||||
options = {
|
||||
useBuiltIns: 'usage',
|
||||
};
|
||||
|
||||
options = {
|
||||
useBuiltIns: 'entry',
|
||||
};
|
||||
|
||||
options = {
|
||||
useBuiltIns: false,
|
||||
};
|
||||
|
||||
|
||||
//========//
|
||||
// COREJS //
|
||||
//========//
|
||||
|
||||
options = {
|
||||
corejs: 2,
|
||||
};
|
||||
|
||||
options = {
|
||||
corejs: 3,
|
||||
};
|
||||
|
||||
options = {
|
||||
corejs: {
|
||||
version: 2,
|
||||
proposals: true,
|
||||
},
|
||||
};
|
||||
|
||||
options = {
|
||||
corejs: {
|
||||
version: 3,
|
||||
proposals: false,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
//======================//
|
||||
// FORCE ALL TRANSFORMS //
|
||||
//======================//
|
||||
|
||||
options = {
|
||||
forceAllTransforms: true,
|
||||
};
|
||||
|
||||
options = {
|
||||
forceAllTransforms: false,
|
||||
};
|
||||
|
||||
|
||||
//======================//
|
||||
// FORCE ALL TRANSFORMS //
|
||||
//======================//
|
||||
|
||||
options = {
|
||||
configPath: '/etc/babel-config.json',
|
||||
};
|
||||
|
||||
|
||||
//============================//
|
||||
// IGNORE BROWSERSLIST CONFIG //
|
||||
//============================//
|
||||
|
||||
options = {
|
||||
ignoreBrowserslistConfig: true,
|
||||
};
|
||||
|
||||
options = {
|
||||
ignoreBrowserslistConfig: false,
|
||||
};
|
||||
|
||||
|
||||
//===================//
|
||||
// SHIPPED PROPOSALS //
|
||||
//===================//
|
||||
|
||||
options = {
|
||||
shippedProposals: true,
|
||||
};
|
||||
|
||||
options = {
|
||||
shippedProposals: false,
|
||||
};
|
||||
Vendored
+94
@@ -0,0 +1,94 @@
|
||||
// Type definitions for @babel/preset-env 7.9
|
||||
// Project: https://github.com/babel/babel/tree/master/packages/babel-preset-env, https://babeljs.io/docs/en/babel-preset-env
|
||||
// Definitions by: Slava Fomin II <https://github.com/slavafomin>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export interface Options {
|
||||
targets?: TargetsOptions;
|
||||
bugfixes?: boolean;
|
||||
spec?: boolean;
|
||||
loose?: boolean;
|
||||
modules?: ModuleOption;
|
||||
debug?: boolean;
|
||||
include?: PluginList;
|
||||
exclude?: PluginList;
|
||||
useBuiltIns?: UseBuiltInsOption;
|
||||
corejs?: CorejsOption;
|
||||
forceAllTransforms?: boolean;
|
||||
configPath?: string;
|
||||
ignoreBrowserslistConfig?: boolean;
|
||||
shippedProposals?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* "targets" config option:
|
||||
* https://babeljs.io/docs/en/babel-preset-env#targets
|
||||
*/
|
||||
export type TargetsOptions = (
|
||||
| BrowserslistQuery
|
||||
| ReadonlyArray<BrowserslistQuery>
|
||||
| { [key in Target]?: string; }
|
||||
| { esmodules: true }
|
||||
| { node: (string | 'current' | true) }
|
||||
| { safari: (string | 'tp') }
|
||||
| { browsers: (string | ReadonlyArray<string>) }
|
||||
);
|
||||
|
||||
export type BrowserslistQuery = string;
|
||||
|
||||
/**
|
||||
* List of supported Browserslist targets:
|
||||
* Source: https://github.com/browserslist/browserslist#browsers
|
||||
*/
|
||||
export type Target = (
|
||||
| 'Android'
|
||||
| 'Baidu'
|
||||
| 'BlackBerry' | 'bb'
|
||||
| 'Chrome'
|
||||
| 'ChromeAndroid' | 'and_chr'
|
||||
| 'Edge'
|
||||
| 'Electron'
|
||||
| 'Explorer' | 'ie'
|
||||
| 'ExplorerMobile' | 'ie_mob'
|
||||
| 'Firefox' | 'ff'
|
||||
| 'FirefoxAndroid' | 'and_ff'
|
||||
| 'iOS' | 'ios_saf'
|
||||
| 'Node'
|
||||
| 'Opera'
|
||||
| 'OperaMini' | 'op_mini'
|
||||
| 'OperaMobile' | 'op_mob'
|
||||
| 'QQAndroid' | 'and_qq'
|
||||
| 'Safari'
|
||||
| 'Samsung'
|
||||
| 'UCAndroid' | 'and_uc'
|
||||
| 'kaios'
|
||||
);
|
||||
|
||||
/**
|
||||
* https://babeljs.io/docs/en/babel-preset-env#modules
|
||||
*/
|
||||
export type ModuleOption = (
|
||||
| 'amd'
|
||||
| 'umd'
|
||||
| 'systemjs'
|
||||
| 'commonjs'
|
||||
| 'cjs'
|
||||
| 'auto'
|
||||
| false
|
||||
);
|
||||
|
||||
export type PluginList = ReadonlyArray<PluginListItem>;
|
||||
export type PluginListItem = (string | RegExp);
|
||||
|
||||
export type UseBuiltInsOption = (
|
||||
| 'usage'
|
||||
| 'entry'
|
||||
| false
|
||||
);
|
||||
|
||||
export type CorejsOption = (
|
||||
| CorejsVersion
|
||||
| { version: CorejsVersion, proposals: boolean }
|
||||
);
|
||||
|
||||
export type CorejsVersion = (2 | 3);
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"strict": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"paths": {
|
||||
"@babel/preset-env": [
|
||||
"babel__preset-env"
|
||||
]
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"babel__preset-env-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
Vendored
+2
-2
@@ -4,9 +4,9 @@
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// Minimum TypeScript Version: 3.4
|
||||
|
||||
import { TransformOptions, types, FileResultCallback } from '@babel/core';
|
||||
import { TransformOptions, types, FileResultCallback, BabelFileResult } from '@babel/core';
|
||||
|
||||
export function transform(code: string, options: TransformOptions): string;
|
||||
export function transform(code: string, options: TransformOptions): BabelFileResult;
|
||||
|
||||
export function transformFromAst(ast: types.Node, code: string | undefined, opts: TransformOptions | undefined, callback?: FileResultCallback): void;
|
||||
|
||||
|
||||
@@ -99,6 +99,11 @@ const v1: Visitor = {
|
||||
|
||||
path.scope.rename("n", "x");
|
||||
path.scope.rename("n");
|
||||
|
||||
// $ExpectError
|
||||
path.pushContainer('returnType', t.stringLiteral('hello'));
|
||||
// $ExpectError
|
||||
path.unshiftContainer('returnType', t.stringLiteral('hello'));
|
||||
},
|
||||
ExportDefaultDeclaration(path) {
|
||||
{
|
||||
@@ -121,6 +126,16 @@ const v1: Visitor = {
|
||||
// $ExpectType NodePath<BooleanLiteral>
|
||||
booleanPath;
|
||||
}
|
||||
{
|
||||
const [newPath] = path.insertBefore(t.stringLiteral('hello'));
|
||||
// $ExpectType NodePath<StringLiteral>
|
||||
newPath;
|
||||
}
|
||||
{
|
||||
const [newPath] = path.insertAfter(t.stringLiteral('hello'));
|
||||
// $ExpectType NodePath<StringLiteral>
|
||||
newPath;
|
||||
}
|
||||
},
|
||||
Program(path) {
|
||||
{
|
||||
@@ -128,6 +143,11 @@ const v1: Visitor = {
|
||||
// $ExpectType NodePath<StringLiteral>
|
||||
newPath;
|
||||
}
|
||||
{
|
||||
const [newPath] = path.pushContainer('body', t.stringLiteral('hello'));
|
||||
// $ExpectType NodePath<StringLiteral>
|
||||
newPath;
|
||||
}
|
||||
{
|
||||
const [stringPath, booleanPath] = path.unshiftContainer('body', [
|
||||
t.stringLiteral('hello'),
|
||||
@@ -138,6 +158,16 @@ const v1: Visitor = {
|
||||
// $ExpectType NodePath<BooleanLiteral | StringLiteral>
|
||||
booleanPath;
|
||||
}
|
||||
{
|
||||
const [stringPath, booleanPath] = path.pushContainer('body', [
|
||||
t.stringLiteral('hello'),
|
||||
t.booleanLiteral(false)
|
||||
]);
|
||||
// $ExpectType NodePath<BooleanLiteral | StringLiteral>
|
||||
stringPath;
|
||||
// $ExpectType NodePath<BooleanLiteral | StringLiteral>
|
||||
booleanPath;
|
||||
}
|
||||
{
|
||||
const [stringPath, booleanPath] = path.unshiftContainer<[t.StringLiteral, t.BooleanLiteral]>('body', [
|
||||
t.stringLiteral('hello'),
|
||||
@@ -148,6 +178,16 @@ const v1: Visitor = {
|
||||
// $ExpectType NodePath<BooleanLiteral>
|
||||
booleanPath;
|
||||
}
|
||||
{
|
||||
const [stringPath, booleanPath] = path.pushContainer<[t.StringLiteral, t.BooleanLiteral]>('body', [
|
||||
t.stringLiteral('hello'),
|
||||
t.booleanLiteral(false)
|
||||
]);
|
||||
// $ExpectType NodePath<StringLiteral>
|
||||
stringPath;
|
||||
// $ExpectType NodePath<BooleanLiteral>
|
||||
booleanPath;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Vendored
+6
-4
@@ -32,6 +32,8 @@ export interface TraverseOptions<S = Node> extends Visitor<S> {
|
||||
noScope?: boolean;
|
||||
}
|
||||
|
||||
export type ArrayKeys<T> = { [P in keyof T]: T[P] extends any[] ? P : never }[keyof T];
|
||||
|
||||
export class Scope {
|
||||
constructor(path: NodePath, parentScope?: Scope);
|
||||
path: NodePath;
|
||||
@@ -419,13 +421,13 @@ export class NodePath<T = Node> {
|
||||
|
||||
// ------------------------- modification -------------------------
|
||||
/** Insert the provided nodes before the current one. */
|
||||
insertBefore(nodes: Node | Node[]): any;
|
||||
insertBefore<Nodes extends Node | Node[]>(nodes: Nodes): NodePaths<Nodes>;
|
||||
|
||||
/**
|
||||
* Insert the provided nodes after the current one. When inserting nodes after an
|
||||
* expression, ensure that the completion record is correct by pushing the current node.
|
||||
*/
|
||||
insertAfter(nodes: Node | Node[]): any;
|
||||
insertAfter<Nodes extends Node | Node[]>(nodes: Nodes): NodePaths<Nodes>;
|
||||
|
||||
/** Update all sibling node paths after `fromIndex` by `incrementBy`. */
|
||||
updateSiblingKeys(fromIndex: number, incrementBy: number): void;
|
||||
@@ -435,14 +437,14 @@ export class NodePath<T = Node> {
|
||||
* @param listKey - The key at which the child nodes are stored (usually body).
|
||||
* @param nodes - the nodes to insert.
|
||||
*/
|
||||
unshiftContainer<Nodes extends Node | Node[]>(listKey: string, nodes: Nodes): NodePaths<Nodes>;
|
||||
unshiftContainer<Nodes extends Node | Node[]>(listKey: ArrayKeys<T>, nodes: Nodes): NodePaths<Nodes>;
|
||||
|
||||
/**
|
||||
* Insert child nodes at the end of the current node.
|
||||
* @param listKey - The key at which the child nodes are stored (usually body).
|
||||
* @param nodes - the nodes to insert.
|
||||
*/
|
||||
pushContainer(listKey: string, nodes: Node | Node[]): void;
|
||||
pushContainer<Nodes extends Node | Node[]>(listKey: ArrayKeys<T>, nodes: Nodes): NodePaths<Nodes>;
|
||||
|
||||
/** Hoist the current node to the highest scope possible and return a UID referencing it. */
|
||||
hoist(scope: Scope): void;
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
import baretest = require('baretest');
|
||||
|
||||
const test = baretest('my program');
|
||||
|
||||
function doSetup(): void {}
|
||||
function doCleanup(): void {}
|
||||
function assertSomeThings(): void {}
|
||||
|
||||
test.before(doSetup);
|
||||
|
||||
test.after(doCleanup);
|
||||
|
||||
test('it can do things', assertSomeThings);
|
||||
|
||||
test.skip('it can create world peace', assertSomeThings);
|
||||
|
||||
test('it can do things asynchronously', async () => {
|
||||
return;
|
||||
});
|
||||
|
||||
// $ExpectError
|
||||
test("you shouldn't return from a test function", () => {
|
||||
return 2 + 2;
|
||||
});
|
||||
|
||||
// $ExpectError
|
||||
test("you shouldn't take parameters in a test function", (people: number) => {});
|
||||
|
||||
// $ExpectError
|
||||
test("you shouldn't return from an async test function", async () => {
|
||||
return 'data from an API under test';
|
||||
});
|
||||
|
||||
(async () => {
|
||||
const result = await test.run();
|
||||
result; // $ExpectType boolean
|
||||
})();
|
||||
Vendored
+21
@@ -0,0 +1,21 @@
|
||||
// Type definitions for baretest 2.0
|
||||
// Project: https://volument.com/baretest
|
||||
// Definitions by: Rory O’Kane <https://github.com/roryokane>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export = baretest;
|
||||
|
||||
declare function baretest(headline: string): TesterFunctionObject;
|
||||
|
||||
type TesterFunctionObject = TesterFunction & TesterSubFunctions;
|
||||
|
||||
type TesterFunction = (name: string, fn: SyncOrAsyncVoidFunction) => void;
|
||||
interface TesterSubFunctions {
|
||||
only: (name: string, fn: SyncOrAsyncVoidFunction) => void;
|
||||
skip: (name?: string, fn?: SyncOrAsyncVoidFunction) => void;
|
||||
before: (fn: SyncOrAsyncVoidFunction) => void;
|
||||
after: (fn: SyncOrAsyncVoidFunction) => void;
|
||||
run: () => Promise<boolean>;
|
||||
}
|
||||
|
||||
type SyncOrAsyncVoidFunction = () => void | Promise<void>;
|
||||
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"baretest-tests.ts"
|
||||
]
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user