mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-06 07:47:04 +00:00
+1
-1
@@ -1,6 +1,6 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- node
|
||||
- 8
|
||||
|
||||
sudo: false
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ or just look for any ".d.ts" files in the package and manually include them with
|
||||
These can be used by TypeScript 1.0.
|
||||
|
||||
* [Typings](https://github.com/typings/typings)
|
||||
* ~~[NuGet](http://nuget.org/Tpackages?q=DefinitelyTyped)~~ (use preferred alternatives, nuget DT type publishing has been turned off)
|
||||
* ~~[NuGet](http://nuget.org/packages?q=DefinitelyTyped)~~ (use preferred alternatives, nuget DT type publishing has been turned off)
|
||||
* Manually download from the `master` branch of this repository
|
||||
|
||||
You may need to add manual [references](http://www.typescriptlang.org/docs/handbook/triple-slash-directives.html).
|
||||
|
||||
@@ -60,6 +60,12 @@
|
||||
"sourceRepoURL": "https://github.com/AlexTeixeira/Askmethat-Rating",
|
||||
"asOfVersion": "0.4.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "autobind-decorator",
|
||||
"typingsPackageName": "autobind-decorator",
|
||||
"sourceRepoURL": "https://github.com/andreypopp/autobind-decorator",
|
||||
"asOfVersion": "2.1.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "aws-sdk",
|
||||
"typingsPackageName": "aws-sdk",
|
||||
@@ -132,6 +138,12 @@
|
||||
"sourceRepoURL": "https://github.com/mapbox/cheap-ruler",
|
||||
"asOfVersion": "2.5.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "commander",
|
||||
"typingsPackageName": "commander",
|
||||
"sourceRepoURL": "https://github.com/tj/commander.js",
|
||||
"asOfVersion": "2.12.2"
|
||||
},
|
||||
{
|
||||
"libraryName": "constant-case",
|
||||
"typingsPackageName": "constant-case",
|
||||
@@ -186,6 +198,12 @@
|
||||
"sourceRepoURL": "https://github.com/loopline-systems/electron-builder",
|
||||
"asOfVersion": "2.8.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "error-stack-parser",
|
||||
"typingsPackageName": "error-stack-parser",
|
||||
"sourceRepoURL": "https://github.com/stacktracejs/error-stack-parser",
|
||||
"asOfVersion": "2.0.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "eventemitter2",
|
||||
"typingsPackageName": "eventemitter2",
|
||||
@@ -330,6 +348,12 @@
|
||||
"sourceRepoURL": "https://github.com/tdegrunt/jsonschema",
|
||||
"asOfVersion": "1.1.1"
|
||||
},
|
||||
{
|
||||
"libraryName": "jsplumb",
|
||||
"typingsPackageName": "jsplumb",
|
||||
"sourceRepoURL": "https://github.com/jsplumb/jsPlumb",
|
||||
"asOfVersion": "2.5.7"
|
||||
},
|
||||
{
|
||||
"libraryName": "knockout-paging",
|
||||
"typingsPackageName": "knockout-paging",
|
||||
@@ -348,6 +372,12 @@
|
||||
"sourceRepoURL": "https://github.com/elitechance/lambda-phi",
|
||||
"asOfVersion": "1.0.1"
|
||||
},
|
||||
{
|
||||
"libraryName": "left-pad",
|
||||
"typingsPackageName": "left-pad",
|
||||
"sourceRepoURL": "https://github.com/stevemao/left-pad",
|
||||
"asOfVersion": "1.2.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "Linq.JS",
|
||||
"typingsPackageName": "linq",
|
||||
@@ -546,6 +576,12 @@
|
||||
"sourceRepoURL": "https://github.com/gpbl/react-day-picker",
|
||||
"asOfVersion": "5.3.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "react-native-elements",
|
||||
"typingsPackageName": "react-native-elements",
|
||||
"sourceRepoURL": "https://github.com/react-native-training/react-native-elements",
|
||||
"asOfVersion": "0.18.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "realm",
|
||||
"typingsPackageName": "realm",
|
||||
|
||||
Vendored
+51
-15
@@ -345,18 +345,47 @@ declare namespace AceAjax {
|
||||
insert(position: Position, text: string): any;
|
||||
|
||||
/**
|
||||
* Inserts the elements in `lines` into the document, starting at the row index given by `row`. This method also triggers the `'change'` event.
|
||||
* @param row The index of the row to insert at
|
||||
* @param lines An array of strings
|
||||
**/
|
||||
* @deprecated Use the insertFullLines method instead.
|
||||
*/
|
||||
insertLines(row: number, lines: string[]): any;
|
||||
|
||||
/**
|
||||
* Inserts a new line into the document at the current row's `position`. This method also triggers the `'change'` event.
|
||||
* @param position The position to insert at
|
||||
**/
|
||||
* Inserts the elements in `lines` into the document as full lines (does not merge with existing line), starting at the row index given by `row`. This method also triggers the `"change"` event.
|
||||
* @param {Number} row The index of the row to insert at
|
||||
* @param {Array} lines An array of strings
|
||||
* @returns {Object} Contains the final row and column, like this:
|
||||
* ```
|
||||
* {row: endRow, column: 0}
|
||||
* ```
|
||||
* If `lines` is empty, this function returns an object containing the current row, and column, like this:
|
||||
* ```
|
||||
* {row: row, column: 0}
|
||||
* ```
|
||||
*
|
||||
**/
|
||||
insertFullLines(row: number, lines: string[]): any;
|
||||
|
||||
/**
|
||||
* @deprecated Use insertMergedLines(position, ['', '']) instead.
|
||||
*/
|
||||
insertNewLine(position: Position): any;
|
||||
|
||||
/**
|
||||
* Inserts the elements in `lines` into the document, starting at the position index given by `row`. This method also triggers the `"change"` event.
|
||||
* @param {Number} row The index of the row to insert at
|
||||
* @param {Array} lines An array of strings
|
||||
* @returns {Object} Contains the final row and column, like this:
|
||||
* ```
|
||||
* {row: endRow, column: 0}
|
||||
* ```
|
||||
* If `lines` is empty, this function returns an object containing the current row, and column, like this:
|
||||
* ```
|
||||
* {row: row, column: 0}
|
||||
* ```
|
||||
*
|
||||
**/
|
||||
insertMergedLines(row: number, lines: string[]): any;
|
||||
|
||||
/**
|
||||
* Inserts `text` into the `position` at the current row. This method also triggers the `'change'` event.
|
||||
* @param position The position to insert at
|
||||
@@ -379,12 +408,19 @@ declare namespace AceAjax {
|
||||
removeInLine(row: number, startColumn: number, endColumn: number): any;
|
||||
|
||||
/**
|
||||
* Removes a range of full lines. This method also triggers the `'change'` event.
|
||||
* @param firstRow The first row to be removed
|
||||
* @param lastRow The last row to be removed
|
||||
**/
|
||||
* @deprecated Use the removeFullLines method instead.
|
||||
*/
|
||||
removeLines(firstRow: number, lastRow: number): string[];
|
||||
|
||||
/**
|
||||
* Removes a range of full lines. This method also triggers the `"change"` event.
|
||||
* @param {Number} firstRow The first row to be removed
|
||||
* @param {Number} lastRow The last row to be removed
|
||||
* @returns {[String]} Returns all the removed lines.
|
||||
*
|
||||
**/
|
||||
removeFullLines(firstRow: number, lastRow: number): string[];
|
||||
|
||||
/**
|
||||
* Removes the new line between `row` and the row immediately following it. This method also triggers the `'change'` event.
|
||||
* @param row The row to check
|
||||
@@ -474,9 +510,9 @@ declare namespace AceAjax {
|
||||
removeFold(arg: any): void;
|
||||
|
||||
expandFold(arg: any): void;
|
||||
|
||||
|
||||
foldAll(startRow?: number, endRow?: number, depth?: number): void
|
||||
|
||||
|
||||
unfold(arg1: any, arg2: boolean): void;
|
||||
|
||||
screenToDocumentColumn(row: number, column: number): void;
|
||||
@@ -2659,9 +2695,9 @@ declare namespace AceAjax {
|
||||
characterWidth: number;
|
||||
|
||||
lineHeight: number;
|
||||
|
||||
|
||||
setScrollMargin(top:number, bottom:number, left: number, right: number): void;
|
||||
|
||||
|
||||
screenToTextCoordinates(left: number, top: number): void;
|
||||
|
||||
/**
|
||||
|
||||
+12
-17
@@ -1,13 +1,13 @@
|
||||
import acorn = require('acorn');
|
||||
import * as ESTree from 'estree';
|
||||
|
||||
declare var token: acorn.Token;
|
||||
declare var tokens: acorn.Token[];
|
||||
declare var comment: acorn.Comment;
|
||||
declare var comments: acorn.Comment[];
|
||||
declare var program: ESTree.Program;
|
||||
var any: any;
|
||||
var string: string;
|
||||
declare let token: acorn.Token;
|
||||
declare let tokens: acorn.Token[];
|
||||
declare let comment: acorn.Comment;
|
||||
declare let comments: acorn.Comment[];
|
||||
declare let program: ESTree.Program;
|
||||
let any: any;
|
||||
let string: string;
|
||||
|
||||
// acorn
|
||||
string = acorn.version;
|
||||
@@ -32,16 +32,12 @@ const parser = new acorn.Parser({}, 'export default ""', 0);
|
||||
const node = new acorn.Node(parser, 1, 1);
|
||||
|
||||
class LooseParser {
|
||||
constructor(input: string, options = {}) {
|
||||
|
||||
}
|
||||
constructor(input: string, options = {}) {}
|
||||
|
||||
// this means you can extend LooseParser
|
||||
test() {
|
||||
|
||||
}
|
||||
test() {}
|
||||
}
|
||||
acorn.addLooseExports(function () {
|
||||
acorn.addLooseExports(() => {
|
||||
return {
|
||||
type: 'Program',
|
||||
sourceType: 'script',
|
||||
@@ -50,7 +46,7 @@ acorn.addLooseExports(function () {
|
||||
type: 'EmptyStatement'
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
||||
}, LooseParser, {});
|
||||
|
||||
acorn.parseExpressionAt('string', 2);
|
||||
@@ -63,8 +59,7 @@ acorn.isIdentifierChar(56);
|
||||
|
||||
acorn.getLineInfo('string', 56);
|
||||
|
||||
acorn.plugins['test'] = function (p: acorn.Parser, config: any) {
|
||||
}
|
||||
acorn.plugins['test'] = (p: acorn.Parser, config: any) => {};
|
||||
|
||||
acorn.tokenizer('console.log("hello world)', {locations: true}).getToken();
|
||||
acorn.tokenizer('console.log("hello world)', {locations: true})[Symbol.iterator]().next();
|
||||
|
||||
Vendored
+9
-14
@@ -1,10 +1,8 @@
|
||||
// Type definitions for Acorn v4.0.3
|
||||
// Type definitions for Acorn 4.0
|
||||
// Project: https://github.com/marijnh/acorn
|
||||
// Definitions by: RReverser <https://github.com/RReverser>, e-cloud <https://github.com/e-cloud>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="estree" />
|
||||
|
||||
export as namespace acorn;
|
||||
export = acorn;
|
||||
import * as ESTree from 'estree';
|
||||
@@ -181,7 +179,7 @@ declare namespace acorn {
|
||||
_typeof: TokenType;
|
||||
_void: TokenType;
|
||||
_delete: TokenType;
|
||||
}
|
||||
};
|
||||
|
||||
class TokContext {
|
||||
constructor(token: string, isExpr: boolean, preserveSpace: boolean, override: (p: Parser) => void);
|
||||
@@ -230,19 +228,18 @@ declare namespace acorn {
|
||||
|
||||
const version: string;
|
||||
|
||||
interface IParse {
|
||||
(input: string, options?: Options): ESTree.Program;
|
||||
}
|
||||
// TODO: rename type.
|
||||
type IParse = (input: string, options?: Options) => ESTree.Program;
|
||||
|
||||
const parse: IParse;
|
||||
|
||||
function parseExpressionAt(input: string, pos?: number, options?: Options): ESTree.Expression;
|
||||
|
||||
interface ITokenizer {
|
||||
getToken() : Token,
|
||||
[Symbol.iterator](): Iterator<Token>
|
||||
getToken(): Token;
|
||||
[Symbol.iterator](): Iterator<Token>;
|
||||
}
|
||||
|
||||
|
||||
function tokenizer(input: string, options: Options): ITokenizer;
|
||||
|
||||
let parse_dammit: IParse | undefined;
|
||||
@@ -250,12 +247,10 @@ declare namespace acorn {
|
||||
let pluginsLoose: PluginsObject | undefined;
|
||||
|
||||
interface ILooseParserClass {
|
||||
new (input: string, options?: Options): ILooseParser
|
||||
new (input: string, options?: Options): ILooseParser;
|
||||
}
|
||||
|
||||
interface ILooseParser {
|
||||
|
||||
}
|
||||
interface ILooseParser {}
|
||||
|
||||
function addLooseExports(parse: IParse, parser: ILooseParserClass, plugins: PluginsObject): void;
|
||||
}
|
||||
|
||||
+1
-71
@@ -1,79 +1,9 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"adjacent-overload-signatures": false,
|
||||
"array-type": false,
|
||||
"arrow-return-shorthand": false,
|
||||
"ban-types": false,
|
||||
"callable-types": false,
|
||||
"comment-format": false,
|
||||
"dt-header": false,
|
||||
"eofline": false,
|
||||
"export-just-namespace": false,
|
||||
"import-spacing": false,
|
||||
"interface-name": false,
|
||||
"interface-over-type-literal": false,
|
||||
"jsdoc-format": false,
|
||||
"max-line-length": false,
|
||||
"member-access": false,
|
||||
"new-parens": false,
|
||||
"no-any-union": false,
|
||||
"no-boolean-literal-compare": false,
|
||||
"no-conditional-assignment": false,
|
||||
"no-consecutive-blank-lines": false,
|
||||
"no-construct": false,
|
||||
"no-declare-current-package": false,
|
||||
"no-duplicate-imports": false,
|
||||
"no-duplicate-variable": false,
|
||||
"no-empty-interface": false,
|
||||
"no-for-in-array": false,
|
||||
"no-inferrable-types": false,
|
||||
"no-internal-module": false,
|
||||
"no-irregular-whitespace": false,
|
||||
"no-mergeable-namespace": false,
|
||||
"no-misused-new": false,
|
||||
"no-namespace": false,
|
||||
"no-object-literal-type-assertion": false,
|
||||
"no-padding": false,
|
||||
"no-redundant-jsdoc": false,
|
||||
"no-redundant-jsdoc-2": false,
|
||||
"no-redundant-undefined": false,
|
||||
"no-reference-import": false,
|
||||
"no-relative-import-in-test": false,
|
||||
"no-self-import": false,
|
||||
"no-single-declare-module": false,
|
||||
"no-string-throw": false,
|
||||
"no-unnecessary-callback-wrapper": false,
|
||||
"no-unnecessary-class": false,
|
||||
"no-unnecessary-generics": false,
|
||||
"no-unnecessary-qualifier": false,
|
||||
"no-unnecessary-type-assertion": false,
|
||||
"no-useless-files": false,
|
||||
"no-var-keyword": false,
|
||||
"no-var-requires": false,
|
||||
"no-void-expression": false,
|
||||
"no-trailing-whitespace": false,
|
||||
"object-literal-key-quotes": false,
|
||||
"object-literal-shorthand": false,
|
||||
"one-line": false,
|
||||
"one-variable-per-declaration": false,
|
||||
"only-arrow-functions": false,
|
||||
"prefer-conditional-expression": false,
|
||||
"prefer-const": false,
|
||||
"prefer-declare-function": false,
|
||||
"prefer-for-of": false,
|
||||
"prefer-method-signature": false,
|
||||
"prefer-template": false,
|
||||
"radix": false,
|
||||
"semicolon": false,
|
||||
"space-before-function-paren": false,
|
||||
"space-within-parens": false,
|
||||
"strict-export-declare-modifiers": false,
|
||||
"trim-file": false,
|
||||
"triple-equals": false,
|
||||
"typedef-whitespace": false,
|
||||
"unified-signatures": false,
|
||||
"void-return": false,
|
||||
"whitespace": false
|
||||
"no-unnecessary-class": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
License Notices:
|
||||
|
||||
The API definitions are from Actions on Google reference site [1] and actions-on-google library [2].
|
||||
The actions-on-google library is licensed under the Apache 2.0 License [3].
|
||||
|
||||
The code documentation is reproduced from work created and shared by Google [4]
|
||||
and used according to terms described in the Creative Commons 3.0 Attribution License [5].
|
||||
|
||||
[1] https://developers.google.com/actions/
|
||||
[2] https://github.com/actions-on-google/actions-on-google-nodejs
|
||||
[3] http://www.apache.org/licenses/LICENSE-2.0
|
||||
[4] https://developers.google.com/readme/policies/
|
||||
[5] http://creativecommons.org/licenses/by/3.0/
|
||||
@@ -0,0 +1,33 @@
|
||||
import { ActionsSdkApp, ActionsSdkAppOptions, DialogflowApp, DialogflowAppOptions, AssistantApp,
|
||||
Responses, Transactions } from 'actions-on-google';
|
||||
import * as express from 'express';
|
||||
|
||||
function testActionsSdk(request: express.Request, response: express.Response) {
|
||||
const app = new ActionsSdkApp({request, response});
|
||||
const actionMap = new Map();
|
||||
actionMap.set(app.StandardIntents.MAIN, () => {
|
||||
const richResponse: Responses.RichResponse = app.buildRichResponse()
|
||||
.addSimpleResponse('Hello world')
|
||||
.addSuggestions(['foo', 'bar']);
|
||||
app.ask(richResponse);
|
||||
});
|
||||
app.handleRequest(actionMap);
|
||||
}
|
||||
|
||||
function testDialogflow(request: express.Request, response: express.Response) {
|
||||
const app = new DialogflowApp({request, response});
|
||||
const actionMap = new Map();
|
||||
actionMap.set(app.StandardIntents.MAIN, () => {
|
||||
const order: Transactions.Order = app.buildOrder('foo');
|
||||
app.askForTransactionDecision(order, {
|
||||
type: app.Transactions.PaymentType.PAYMENT_CARD,
|
||||
displayName: 'VISA-1234',
|
||||
deliveryAddressRequired: true
|
||||
});
|
||||
});
|
||||
app.handleRequest(actionMap);
|
||||
}
|
||||
|
||||
const expressApp = express();
|
||||
expressApp.get('/actionssdk', testActionsSdk);
|
||||
expressApp.get('/dialogflow', testDialogflow);
|
||||
+415
@@ -0,0 +1,415 @@
|
||||
import * as express from 'express';
|
||||
|
||||
import { AssistantApp } from './assistant-app';
|
||||
import { Carousel, List, RichResponse, SimpleResponse } from './response-builder';
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Actions SDK support
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export interface ActionsSdkAppOptions {
|
||||
/** Express HTTP request object. */
|
||||
request: express.Request;
|
||||
/** Express HTTP response object. */
|
||||
response: express.Response;
|
||||
/** Function callback when session starts. */
|
||||
sessionStarted?(): any;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is the class that handles the conversation API directly from Assistant,
|
||||
* providing implementation for all the methods available in the API.
|
||||
*/
|
||||
export class ActionsSdkApp extends AssistantApp {
|
||||
/**
|
||||
* Constructor for ActionsSdkApp object.
|
||||
* To be used in the Actions SDK HTTP endpoint logic.
|
||||
*
|
||||
* @example
|
||||
* const ActionsSdkApp = require('actions-on-google').ActionsSdkApp;
|
||||
* const app = new ActionsSdkApp({request: request, response: response,
|
||||
* sessionStarted:sessionStarted});
|
||||
*
|
||||
* @actionssdk
|
||||
*/
|
||||
constructor(options: ActionsSdkAppOptions);
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* Validates whether request is from Assistant through signature verification.
|
||||
* Uses Google-Auth-Library to verify authorization token against given
|
||||
* Google Cloud Project ID. Auth token is given in request header with key,
|
||||
* "Authorization".
|
||||
*
|
||||
* @example
|
||||
* const app = new ActionsSdkApp({request, response});
|
||||
* app.isRequestFromAssistant('nodejs-cloud-test-project-1234')
|
||||
* .then(() => {
|
||||
* app.ask('Hey there, thanks for stopping by!');
|
||||
* })
|
||||
* .catch(err => {
|
||||
* response.status(400).send();
|
||||
* });
|
||||
*
|
||||
* @param projectId Google Cloud Project ID for the Assistant app.
|
||||
* @return Promise resolving with google-auth-library LoginTicket
|
||||
* if request is from a valid source, otherwise rejects with the error reason
|
||||
* for an invalid token.
|
||||
* @actionssdk
|
||||
*/
|
||||
isRequestFromAssistant(projectId: string): Promise<object>;
|
||||
|
||||
/**
|
||||
* Validates whether request is from Google through signature verification.
|
||||
* Uses Google-Auth-Library to verify authorization token against given
|
||||
* Google Cloud Project ID. Auth token is given in request header with key,
|
||||
* "Authorization".
|
||||
*
|
||||
* @example
|
||||
* const app = new ActionsSdkApp({request, response});
|
||||
* app.isRequestFromGoogle('nodejs-cloud-test-project-1234')
|
||||
* .then(() => {
|
||||
* app.ask('Hey there, thanks for stopping by!');
|
||||
* })
|
||||
* .catch(err => {
|
||||
* response.status(400).send();
|
||||
* });
|
||||
*
|
||||
* @param projectId Google Cloud Project ID for the Assistant app.
|
||||
* @return Promise resolving with google-auth-library LoginTicket
|
||||
* if request is from a valid source, otherwise rejects with the error reason
|
||||
* for an invalid token.
|
||||
* @actionssdk
|
||||
*/
|
||||
isRequestFromGoogle(projectId: string): Promise<object>;
|
||||
|
||||
/**
|
||||
* Gets the request Conversation API version.
|
||||
*
|
||||
* @example
|
||||
* const app = new ActionsSdkApp({request: request, response: response});
|
||||
* const apiVersion = app.getApiVersion();
|
||||
*
|
||||
* @return Version value or null if no value.
|
||||
* @actionssdk
|
||||
*/
|
||||
getApiVersion(): string;
|
||||
|
||||
/**
|
||||
* Gets the user's raw input query.
|
||||
*
|
||||
* @example
|
||||
* const app = new ActionsSdkApp({request: request, response: response});
|
||||
* app.tell('You said ' + app.getRawInput());
|
||||
*
|
||||
* @return User's raw query or null if no value.
|
||||
* @actionssdk
|
||||
*/
|
||||
getRawInput(): string;
|
||||
|
||||
/**
|
||||
* Gets previous JSON dialog state that the app sent to Assistant.
|
||||
* Alternatively, use the app.data field to store JSON values between requests.
|
||||
*
|
||||
* @example
|
||||
* const app = new ActionsSdkApp({request: request, response: response});
|
||||
* const dialogState = app.getDialogState();
|
||||
*
|
||||
* @return JSON object provided to the Assistant in the previous
|
||||
* user turn or {} if no value.
|
||||
* @actionssdk
|
||||
*/
|
||||
getDialogState(): any;
|
||||
|
||||
/**
|
||||
* Gets the "versionLabel" specified inside the Action Package.
|
||||
* Used by app to do version control.
|
||||
*
|
||||
* @example
|
||||
* const app = new ActionsSdkApp({request: request, response: response});
|
||||
* const actionVersionLabel = app.getActionVersionLabel();
|
||||
*
|
||||
* @return The specified version label or null if unspecified.
|
||||
* @actionssdk
|
||||
*/
|
||||
getActionVersionLabel(): string;
|
||||
|
||||
/**
|
||||
* Gets the unique conversation ID. It's a new ID for the initial query,
|
||||
* and stays the same until the end of the conversation.
|
||||
*
|
||||
* @example
|
||||
* const app = new ActionsSdkApp({request: request, response: response});
|
||||
* const conversationId = app.getConversationId();
|
||||
*
|
||||
* @return Conversation ID or null if no value.
|
||||
* @actionssdk
|
||||
*/
|
||||
getConversationId(): string;
|
||||
|
||||
/**
|
||||
* Get the current intent. Alternatively, using a handler Map with
|
||||
* {@link AssistantApp#handleRequest|handleRequest}, the client library will
|
||||
* automatically handle the incoming intents.
|
||||
*
|
||||
* @example
|
||||
* const app = new ActionsSdkApp({request: request, response: response});
|
||||
*
|
||||
* function responseHandler (app) {
|
||||
* const intent = app.getIntent();
|
||||
* switch (intent) {
|
||||
* case app.StandardIntents.MAIN:
|
||||
* const inputPrompt = app.buildInputPrompt(false, 'Welcome to action snippets! Say anything.');
|
||||
* app.ask(inputPrompt);
|
||||
* break;
|
||||
*
|
||||
* case app.StandardIntents.TEXT:
|
||||
* app.tell('You said ' + app.getRawInput());
|
||||
* break;
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* app.handleRequest(responseHandler);
|
||||
*
|
||||
* @return Intent id or null if no value.
|
||||
* @actionssdk
|
||||
*/
|
||||
getIntent(): string;
|
||||
|
||||
/**
|
||||
* Get the argument value by name from the current intent. If the argument
|
||||
* is not a text argument, the entire argument object is returned.
|
||||
*
|
||||
* Note: If incoming request is using an API version under 2 (e.g. 'v1'),
|
||||
* the argument object will be in Proto2 format (snake_case, etc).
|
||||
*
|
||||
* @param argName Name of the argument.
|
||||
* @return Argument value matching argName
|
||||
* or null if no matching argument.
|
||||
* @actionssdk
|
||||
*/
|
||||
getArgument(argName: string): string;
|
||||
|
||||
/**
|
||||
* Returns the option key user chose from options response.
|
||||
*
|
||||
* @example
|
||||
* const app = new App({request: req, response: res});
|
||||
*
|
||||
* function pickOption (app) {
|
||||
* if (app.hasSurfaceCapability(app.SurfaceCapabilities.SCREEN_OUTPUT)) {
|
||||
* app.askWithCarousel('Which of these looks good?',
|
||||
* app.buildCarousel().addItems(
|
||||
* app.buildOptionItem('another_choice', ['Another choice']).
|
||||
* setTitle('Another choice').setDescription('Choose me!')));
|
||||
* } else {
|
||||
* app.ask('What would you like?');
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* function optionPicked (app) {
|
||||
* app.ask('You picked ' + app.getSelectedOption());
|
||||
* }
|
||||
*
|
||||
* const actionMap = new Map();
|
||||
* actionMap.set(app.StandardIntents.TEXT, pickOption);
|
||||
* actionMap.set(app.StandardIntents.OPTION, optionPicked);
|
||||
*
|
||||
* app.handleRequest(actionMap);
|
||||
*
|
||||
* @return Option key of selected item. Null if no option selected or
|
||||
* if current intent is not OPTION intent.
|
||||
* @actionssdk
|
||||
*/
|
||||
getSelectedOption(): string;
|
||||
|
||||
/**
|
||||
* Asks to collect user's input; all user's queries need to be sent to
|
||||
* the app.
|
||||
* {@link https://developers.google.com/actions/policies/general-policies#user_experience|The guidelines when prompting the user for a response must be followed at all times}.
|
||||
*
|
||||
* @example
|
||||
* const app = new ActionsSdkApp({request: request, response: response});
|
||||
*
|
||||
* function mainIntent (app) {
|
||||
* const inputPrompt = app.buildInputPrompt(true, '<speak>Hi! <break time="1"/> ' +
|
||||
* 'I can read out an ordinal like ' +
|
||||
* '<say-as interpret-as="ordinal">123</say-as>. Say a number.</speak>',
|
||||
* ['I didn\'t hear a number', 'If you\'re still there, what\'s the number?', 'What is the number?']);
|
||||
* app.ask(inputPrompt);
|
||||
* }
|
||||
*
|
||||
* function rawInput (app) {
|
||||
* if (app.getRawInput() === 'bye') {
|
||||
* app.tell('Goodbye!');
|
||||
* } else {
|
||||
* const inputPrompt = app.buildInputPrompt(true, '<speak>You said, <say-as interpret-as="ordinal">' +
|
||||
* app.getRawInput() + '</say-as></speak>',
|
||||
* ['I didn\'t hear a number', 'If you\'re still there, what\'s the number?', 'What is the number?']);
|
||||
* app.ask(inputPrompt);
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* const actionMap = new Map();
|
||||
* actionMap.set(app.StandardIntents.MAIN, mainIntent);
|
||||
* actionMap.set(app.StandardIntents.TEXT, rawInput);
|
||||
*
|
||||
* app.handleRequest(actionMap);
|
||||
*
|
||||
* @param inputPrompt Holding initial and
|
||||
* no-input prompts.
|
||||
* @param dialogState JSON object the app uses to hold dialog state that
|
||||
* will be circulated back by App.
|
||||
* @return The response that is sent to Assistant to ask user to provide input.
|
||||
* @actionssdk
|
||||
*/
|
||||
ask(inputPrompt: object | SimpleResponse | RichResponse, dialogState?: object): express.Response | null;
|
||||
|
||||
/**
|
||||
* Asks to collect user's input with a list.
|
||||
*
|
||||
* @example
|
||||
* const app = new ActionsSdkApp({request, response});
|
||||
*
|
||||
* function welcomeIntent (app) {
|
||||
* app.askWithlist('Which of these looks good?',
|
||||
* app.buildList('List title')
|
||||
* .addItems([
|
||||
* app.buildOptionItem(SELECTION_KEY_ONE,
|
||||
* ['synonym of KEY_ONE 1', 'synonym of KEY_ONE 2'])
|
||||
* .setTitle('Number one'),
|
||||
* app.buildOptionItem(SELECTION_KEY_TWO,
|
||||
* ['synonym of KEY_TWO 1', 'synonym of KEY_TWO 2'])
|
||||
* .setTitle('Number two'),
|
||||
* ]));
|
||||
* }
|
||||
*
|
||||
* function optionIntent (app) {
|
||||
* if (app.getSelectedOption() === SELECTION_KEY_ONE) {
|
||||
* app.tell('Number one is a great choice!');
|
||||
* } else {
|
||||
* app.tell('Number two is a great choice!');
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* const actionMap = new Map();
|
||||
* actionMap.set(app.StandardIntents.TEXT, welcomeIntent);
|
||||
* actionMap.set(app.StandardIntents.OPTION, optionIntent);
|
||||
* app.handleRequest(actionMap);
|
||||
*
|
||||
* @param inputPrompt Holding initial and
|
||||
* no-input prompts. Cannot contain basic card.
|
||||
* @param list List built with {@link AssistantApp#buildList|buildList}.
|
||||
* @param dialogState JSON object the app uses to hold dialog state that
|
||||
* will be circulated back by Assistant.
|
||||
* @return The response that is sent to Assistant to ask user to provide input.
|
||||
* @actionssdk
|
||||
*/
|
||||
askWithList(inputPrompt: object | SimpleResponse | RichResponse, list: List, dialogState?: object): express.Response | null;
|
||||
|
||||
/**
|
||||
* Asks to collect user's input with a carousel.
|
||||
*
|
||||
* @example
|
||||
* const app = new ActionsSdkApp({request, response});
|
||||
*
|
||||
* function welcomeIntent (app) {
|
||||
* app.askWithCarousel('Which of these looks good?',
|
||||
* app.buildCarousel()
|
||||
* .addItems([
|
||||
* app.buildOptionItem(SELECTION_KEY_ONE,
|
||||
* ['synonym of KEY_ONE 1', 'synonym of KEY_ONE 2'])
|
||||
* .setTitle('Number one'),
|
||||
* app.buildOptionItem(SELECTION_KEY_TWO,
|
||||
* ['synonym of KEY_TWO 1', 'synonym of KEY_TWO 2'])
|
||||
* .setTitle('Number two'),
|
||||
* ]));
|
||||
* }
|
||||
*
|
||||
* function optionIntent (app) {
|
||||
* if (app.getSelectedOption() === SELECTION_KEY_ONE) {
|
||||
* app.tell('Number one is a great choice!');
|
||||
* } else {
|
||||
* app.tell('Number two is a great choice!');
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* const actionMap = new Map();
|
||||
* actionMap.set(app.StandardIntents.TEXT, welcomeIntent);
|
||||
* actionMap.set(app.StandardIntents.OPTION, optionIntent);
|
||||
* app.handleRequest(actionMap);
|
||||
*
|
||||
* @param inputPrompt Holding initial and
|
||||
* no-input prompts. Cannot contain basic card.
|
||||
* @param carousel Carousel built with
|
||||
* {@link AssistantApp#buildCarousel|buildCarousel}.
|
||||
* @param dialogState JSON object the app uses to hold dialog state that
|
||||
* will be circulated back by Assistant.
|
||||
* @return The response that is sent to Assistant to ask user to provide input.
|
||||
* @actionssdk
|
||||
*/
|
||||
askWithCarousel(inputPrompt: object | SimpleResponse | RichResponse, carousel: Carousel, dialogState?: object): express.Response | null;
|
||||
|
||||
/**
|
||||
* Tells Assistant to render the speech response and close the mic.
|
||||
*
|
||||
* @example
|
||||
* const app = new ActionsSdkApp({request: request, response: response});
|
||||
*
|
||||
* function mainIntent (app) {
|
||||
* const inputPrompt = app.buildInputPrompt(true, '<speak>Hi! <break time="1"/> ' +
|
||||
* 'I can read out an ordinal like ' +
|
||||
* '<say-as interpret-as="ordinal">123</say-as>. Say a number.</speak>',
|
||||
* ['I didn\'t hear a number', 'If you\'re still there, what\'s the number?', 'What is the number?']);
|
||||
* app.ask(inputPrompt);
|
||||
* }
|
||||
*
|
||||
* function rawInput (app) {
|
||||
* if (app.getRawInput() === 'bye') {
|
||||
* app.tell('Goodbye!');
|
||||
* } else {
|
||||
* const inputPrompt = app.buildInputPrompt(true, '<speak>You said, <say-as interpret-as="ordinal">' +
|
||||
* app.getRawInput() + '</say-as></speak>',
|
||||
* ['I didn\'t hear a number', 'If you\'re still there, what\'s the number?', 'What is the number?']);
|
||||
* app.ask(inputPrompt);
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* const actionMap = new Map();
|
||||
* actionMap.set(app.StandardIntents.MAIN, mainIntent);
|
||||
* actionMap.set(app.StandardIntents.TEXT, rawInput);
|
||||
*
|
||||
* app.handleRequest(actionMap);
|
||||
*
|
||||
* @param textToSpeech Final response.
|
||||
* Spoken response can be SSML.
|
||||
* @return The HTTP response that is sent back to Assistant.
|
||||
* @actionssdk
|
||||
*/
|
||||
tell(textToSpeech: string | SimpleResponse | RichResponse): express.Response | null;
|
||||
|
||||
/**
|
||||
* Builds the {@link https://developers.google.com/actions/reference/conversation#InputPrompt|InputPrompt object}
|
||||
* from initial prompt and no-input prompts.
|
||||
*
|
||||
* The App needs one initial prompt to start the conversation. If there is no user response,
|
||||
* the App re-opens the mic and renders the no-input prompts three times
|
||||
* (one for each no-input prompt that was configured) to help the user
|
||||
* provide the right response.
|
||||
*
|
||||
* Note: we highly recommend app to provide all the prompts required here in order to ensure a
|
||||
* good user experience.
|
||||
*
|
||||
* @example
|
||||
* const inputPrompt = app.buildInputPrompt(false, 'Welcome to action snippets! Say a number.',
|
||||
* ['Say any number', 'Pick a number', 'What is the number?']);
|
||||
* app.ask(inputPrompt);
|
||||
*
|
||||
* @param isSsml Indicates whether the text to speech is SSML or not.
|
||||
* @param initialPrompt The initial prompt the App asks the user.
|
||||
* @param noInputs Array of re-prompts when the user does not respond (max 3).
|
||||
* @return.
|
||||
* @actionssdk
|
||||
*/
|
||||
buildInputPrompt(isSsml: boolean, initialPrompt: string, noInputs?: string[]): object;
|
||||
}
|
||||
+1475
File diff suppressed because it is too large
Load Diff
+571
@@ -0,0 +1,571 @@
|
||||
import * as express from 'express';
|
||||
|
||||
import { AssistantApp } from './assistant-app';
|
||||
import { Carousel, List, RichResponse, SimpleResponse } from './response-builder';
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Dialogflow support
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Dialogflow {@link https://dialogflow.com/docs/concept-contexts|Context}.
|
||||
*/
|
||||
export interface Context {
|
||||
/** Full name of the context. */
|
||||
name: string;
|
||||
/**
|
||||
* Parameters carried within this context.
|
||||
* See {@link https://dialogflow.com/docs/concept-actions#section-extracting-values-from-contexts|here}.
|
||||
*/
|
||||
parameters: object;
|
||||
/** Remaining number of intents */
|
||||
lifespan: number;
|
||||
}
|
||||
|
||||
export interface DialogflowAppOptions {
|
||||
/** Express HTTP request object. */
|
||||
request: express.Request;
|
||||
/** Express HTTP response object. */
|
||||
response: express.Response;
|
||||
/**
|
||||
* Function callback when session starts.
|
||||
* Only called if webhook is enabled for welcome/triggering intents, and
|
||||
* called from Web Simulator or Google Home device (i.e., not Dialogflow simulator).
|
||||
*/
|
||||
sessionStarted?(): any;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is the class that handles the communication with Dialogflow's fulfillment API.
|
||||
*/
|
||||
export class DialogflowApp extends AssistantApp {
|
||||
/**
|
||||
* Constructor for DialogflowApp object.
|
||||
* To be used in the Dialogflow fulfillment webhook logic.
|
||||
*
|
||||
* @example
|
||||
* const DialogflowApp = require('actions-on-google').DialogflowApp;
|
||||
* const app = new DialogflowApp({request: request, response: response,
|
||||
* sessionStarted:sessionStarted});
|
||||
*
|
||||
* @dialogflow
|
||||
*/
|
||||
constructor(options: DialogflowAppOptions);
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* Verifies whether the request comes from Dialogflow.
|
||||
*
|
||||
* @param key The header key specified by the developer in the
|
||||
* Dialogflow Fulfillment settings of the app.
|
||||
* @param value The private value specified by the developer inside the
|
||||
* fulfillment header.
|
||||
* @return True if the request comes from Dialogflow.
|
||||
* @dialogflow
|
||||
*/
|
||||
isRequestFromApiAi(key: string, value: string): boolean;
|
||||
|
||||
/**
|
||||
* Verifies whether the request comes from Dialogflow.
|
||||
*
|
||||
* @param key The header key specified by the developer in the
|
||||
* Dialogflow Fulfillment settings of the app.
|
||||
* @param value The private value specified by the developer inside the
|
||||
* fulfillment header.
|
||||
* @return True if the request comes from Dialogflow.
|
||||
* @dialogflow
|
||||
*/
|
||||
isRequestFromDialogflow(key: string, value: string): boolean;
|
||||
|
||||
/**
|
||||
* Get the current intent. Alternatively, using a handler Map with
|
||||
* {@link AssistantApp#handleRequest|handleRequest},
|
||||
* the client library will automatically handle the incoming intents.
|
||||
* 'Intent' in the Dialogflow context translates into the current action.
|
||||
*
|
||||
* @example
|
||||
* const app = new DialogflowApp({request: request, response: response});
|
||||
*
|
||||
* function responseHandler (app) {
|
||||
* const intent = app.getIntent();
|
||||
* switch (intent) {
|
||||
* case WELCOME_INTENT:
|
||||
* app.ask('Welcome to action snippets! Say a number.');
|
||||
* break;
|
||||
*
|
||||
* case NUMBER_INTENT:
|
||||
* const number = app.getArgument(NUMBER_ARGUMENT);
|
||||
* app.tell('You said ' + number);
|
||||
* break;
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* app.handleRequest(responseHandler);
|
||||
*
|
||||
* @return Intent id or null if no value (action name).
|
||||
* @dialogflow
|
||||
*/
|
||||
getIntent(): string;
|
||||
|
||||
/**
|
||||
* Get the argument value by name from the current intent. If the argument
|
||||
* is included in originalRequest, and is not a text argument, the entire
|
||||
* argument object is returned.
|
||||
*
|
||||
* Note: If incoming request is using an API version under 2 (e.g. 'v1'),
|
||||
* the argument object will be in Proto2 format (snake_case, etc).
|
||||
*
|
||||
* @example
|
||||
* const app = new DialogflowApp({request: request, response: response});
|
||||
* const WELCOME_INTENT = 'input.welcome';
|
||||
* const NUMBER_INTENT = 'input.number';
|
||||
*
|
||||
* function welcomeIntent (app) {
|
||||
* app.ask('Welcome to action snippets! Say a number.');
|
||||
* }
|
||||
*
|
||||
* function numberIntent (app) {
|
||||
* const number = app.getArgument(NUMBER_ARGUMENT);
|
||||
* app.tell('You said ' + number);
|
||||
* }
|
||||
*
|
||||
* const actionMap = new Map();
|
||||
* actionMap.set(WELCOME_INTENT, welcomeIntent);
|
||||
* actionMap.set(NUMBER_INTENT, numberIntent);
|
||||
* app.handleRequest(actionMap);
|
||||
*
|
||||
* @param argName Name of the argument.
|
||||
* @return Argument value matching argName
|
||||
* or null if no matching argument.
|
||||
* @dialogflow
|
||||
*/
|
||||
getArgument(argName: string): object;
|
||||
|
||||
/**
|
||||
* Get the context argument value by name from the current intent. Context
|
||||
* arguments include parameters collected in previous intents during the
|
||||
* lifespan of the given context. If the context argument has an original
|
||||
* value, usually representing the underlying entity value, that will be given
|
||||
* as part of the return object.
|
||||
*
|
||||
* @example
|
||||
* const app = new DialogflowApp({request: request, response: response});
|
||||
* const WELCOME_INTENT = 'input.welcome';
|
||||
* const NUMBER_INTENT = 'input.number';
|
||||
* const OUT_CONTEXT = 'output_context';
|
||||
* const NUMBER_ARG = 'myNumberArg';
|
||||
*
|
||||
* function welcomeIntent (app) {
|
||||
* const parameters = {};
|
||||
* parameters[NUMBER_ARG] = '42';
|
||||
* app.setContext(OUT_CONTEXT, 1, parameters);
|
||||
* app.ask('Welcome to action snippets! Ask me for your number.');
|
||||
* }
|
||||
*
|
||||
* function numberIntent (app) {
|
||||
* const number = app.getContextArgument(OUT_CONTEXT, NUMBER_ARG);
|
||||
* // number === { value: 42 }
|
||||
* app.tell('Your number is ' + number.value);
|
||||
* }
|
||||
*
|
||||
* const actionMap = new Map();
|
||||
* actionMap.set(WELCOME_INTENT, welcomeIntent);
|
||||
* actionMap.set(NUMBER_INTENT, numberIntent);
|
||||
* app.handleRequest(actionMap);
|
||||
*
|
||||
* @param contextName Name of the context.
|
||||
* @param argName Name of the argument.
|
||||
* @return Object containing value property and optional original
|
||||
* property matching context argument. Null if no matching argument.
|
||||
* @dialogflow
|
||||
*/
|
||||
getContextArgument(contextName: string, argName: string): object;
|
||||
|
||||
/**
|
||||
* Returns the RichResponse constructed in Dialogflow response builder.
|
||||
*
|
||||
* @example
|
||||
* const app = new App({request: req, response: res});
|
||||
*
|
||||
* function tellFact (app) {
|
||||
* let fact = 'Google was founded in 1998';
|
||||
*
|
||||
* if (app.hasSurfaceCapability(app.SurfaceCapabilities.SCREEN_OUTPUT)) {
|
||||
* app.ask(app.getIncomingRichResponse().addSimpleResponse('Here\'s a ' +
|
||||
* 'fact for you. ' + fact + ' Which one do you want to hear about ' +
|
||||
* 'next, Google\'s history or headquarters?'));
|
||||
* } else {
|
||||
* app.ask('Here\'s a fact for you. ' + fact + ' Which one ' +
|
||||
* 'do you want to hear about next, Google\'s history or headquarters?');
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* const actionMap = new Map();
|
||||
* actionMap.set('tell.fact', tellFact);
|
||||
*
|
||||
* app.handleRequest(actionMap);
|
||||
*
|
||||
* @return RichResponse created in Dialogflow. If no RichResponse was
|
||||
* created, an empty RichResponse is returned.
|
||||
* @dialogflow
|
||||
*/
|
||||
getIncomingRichResponse(): RichResponse;
|
||||
|
||||
/**
|
||||
* Returns the List constructed in Dialogflow response builder.
|
||||
*
|
||||
* @example
|
||||
* const app = new App({request: req, response: res});
|
||||
*
|
||||
* function pickOption (app) {
|
||||
* if (app.hasSurfaceCapability(app.SurfaceCapabilities.SCREEN_OUTPUT)) {
|
||||
* app.askWithList('Which of these looks good?',
|
||||
* app.getIncomingList().addItems(
|
||||
* app.buildOptionItem('another_choice', ['Another choice']).
|
||||
* setTitle('Another choice')));
|
||||
* } else {
|
||||
* app.ask('What would you like?');
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* const actionMap = new Map();
|
||||
* actionMap.set('pick.option', pickOption);
|
||||
*
|
||||
* app.handleRequest(actionMap);
|
||||
*
|
||||
* @return List created in Dialogflow. If no List was created, an empty
|
||||
* List is returned.
|
||||
* @dialogflow
|
||||
*/
|
||||
getIncomingList(): List;
|
||||
|
||||
/**
|
||||
* Returns the Carousel constructed in Dialogflow response builder.
|
||||
*
|
||||
* @example
|
||||
* const app = new App({request: req, response: res});
|
||||
*
|
||||
* function pickOption (app) {
|
||||
* if (app.hasSurfaceCapability(app.SurfaceCapabilities.SCREEN_OUTPUT)) {
|
||||
* app.askWithCarousel('Which of these looks good?',
|
||||
* app.getIncomingCarousel().addItems(
|
||||
* app.buildOptionItem('another_choice', ['Another choice']).
|
||||
* setTitle('Another choice').setDescription('Choose me!')));
|
||||
* } else {
|
||||
* app.ask('What would you like?');
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* const actionMap = new Map();
|
||||
* actionMap.set('pick.option', pickOption);
|
||||
*
|
||||
* app.handleRequest(actionMap);
|
||||
*
|
||||
* @return Carousel created in Dialogflow. If no Carousel was created,
|
||||
* an empty Carousel is returned.
|
||||
* @dialogflow
|
||||
*/
|
||||
getIncomingCarousel(): Carousel;
|
||||
|
||||
/**
|
||||
* Returns the option key user chose from options response.
|
||||
*
|
||||
* @example
|
||||
* const app = new App({request: req, response: res});
|
||||
*
|
||||
* function pickOption (app) {
|
||||
* if (app.hasSurfaceCapability(app.SurfaceCapabilities.SCREEN_OUTPUT)) {
|
||||
* app.askWithCarousel('Which of these looks good?',
|
||||
* app.getIncomingCarousel().addItems(
|
||||
* app.buildOptionItem('another_choice', ['Another choice']).
|
||||
* setTitle('Another choice').setDescription('Choose me!')));
|
||||
* } else {
|
||||
* app.ask('What would you like?');
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* function optionPicked (app) {
|
||||
* app.ask('You picked ' + app.getSelectedOption());
|
||||
* }
|
||||
*
|
||||
* const actionMap = new Map();
|
||||
* actionMap.set('pick.option', pickOption);
|
||||
* actionMap.set('option.picked', optionPicked);
|
||||
*
|
||||
* app.handleRequest(actionMap);
|
||||
*
|
||||
* @return Option key of selected item. Null if no option selected or
|
||||
* if current intent is not OPTION intent.
|
||||
* @dialogflow
|
||||
*/
|
||||
getSelectedOption(): string;
|
||||
|
||||
/**
|
||||
* Asks to collect the user's input.
|
||||
* {@link https://developers.google.com/actions/policies/general-policies#user_experience|The guidelines when prompting the user for a response must be followed at all times}.
|
||||
*
|
||||
* NOTE: Due to a bug, if you specify the no-input prompts,
|
||||
* the mic is closed after the 3rd prompt, so you should use the 3rd prompt
|
||||
* for a bye message until the bug is fixed.
|
||||
*
|
||||
* @example
|
||||
* const app = new DialogflowApp({request: request, response: response});
|
||||
* const WELCOME_INTENT = 'input.welcome';
|
||||
* const NUMBER_INTENT = 'input.number';
|
||||
*
|
||||
* function welcomeIntent (app) {
|
||||
* app.ask('Welcome to action snippets! Say a number.',
|
||||
* ['Say any number', 'Pick a number', 'We can stop here. See you soon.']);
|
||||
* }
|
||||
*
|
||||
* function numberIntent (app) {
|
||||
* const number = app.getArgument(NUMBER_ARGUMENT);
|
||||
* app.tell('You said ' + number);
|
||||
* }
|
||||
*
|
||||
* const actionMap = new Map();
|
||||
* actionMap.set(WELCOME_INTENT, welcomeIntent);
|
||||
* actionMap.set(NUMBER_INTENT, numberIntent);
|
||||
* app.handleRequest(actionMap);
|
||||
*
|
||||
* @param inputPrompt The input prompt
|
||||
* response.
|
||||
* @param noInputs Array of re-prompts when the user does not respond (max 3).
|
||||
* @return HTTP response.
|
||||
* @dialogflow
|
||||
*/
|
||||
ask(inputPrompt: string | SimpleResponse | RichResponse, noInputs?: string[]): express.Response | null;
|
||||
|
||||
/**
|
||||
* Asks to collect the user's input with a list.
|
||||
*
|
||||
* @example
|
||||
* const app = new DialogflowApp({request, response});
|
||||
* const WELCOME_INTENT = 'input.welcome';
|
||||
* const OPTION_INTENT = 'option.select';
|
||||
*
|
||||
* function welcomeIntent (app) {
|
||||
* app.askWithList('Which of these looks good?',
|
||||
* app.buildList('List title')
|
||||
* .addItems([
|
||||
* app.buildOptionItem(SELECTION_KEY_ONE,
|
||||
* ['synonym of KEY_ONE 1', 'synonym of KEY_ONE 2'])
|
||||
* .setTitle('Title of First List Item'),
|
||||
* app.buildOptionItem(SELECTION_KEY_TWO,
|
||||
* ['synonym of KEY_TWO 1', 'synonym of KEY_TWO 2'])
|
||||
* .setTitle('Title of Second List Item'),
|
||||
* ]));
|
||||
* }
|
||||
*
|
||||
* function optionIntent (app) {
|
||||
* if (app.getSelectedOption() === SELECTION_KEY_ONE) {
|
||||
* app.tell('Number one is a great choice!');
|
||||
* } else {
|
||||
* app.tell('Number two is a great choice!');
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* const actionMap = new Map();
|
||||
* actionMap.set(WELCOME_INTENT, welcomeIntent);
|
||||
* actionMap.set(OPTION_INTENT, optionIntent);
|
||||
* app.handleRequest(actionMap);
|
||||
*
|
||||
* @param inputPrompt The input prompt
|
||||
* response.
|
||||
* @param.list List built with {@link AssistantApp#buildList|buildList}
|
||||
* @return HTTP response.
|
||||
* @dialogflow
|
||||
*/
|
||||
askWithList(inputPrompt: string | RichResponse | SimpleResponse, list: List): express.Response | null;
|
||||
|
||||
/**
|
||||
* Asks to collect the user's input with a carousel.
|
||||
*
|
||||
* @example
|
||||
* const app = new DialogflowApp({request, response});
|
||||
* const WELCOME_INTENT = 'input.welcome';
|
||||
* const OPTION_INTENT = 'option.select';
|
||||
*
|
||||
* function welcomeIntent (app) {
|
||||
* app.askWithCarousel('Which of these looks good?',
|
||||
* app.buildCarousel()
|
||||
* .addItems([
|
||||
* app.buildOptionItem(SELECTION_KEY_ONE,
|
||||
* ['synonym of KEY_ONE 1', 'synonym of KEY_ONE 2'])
|
||||
* .setTitle('Number one'),
|
||||
* app.buildOptionItem(SELECTION_KEY_TWO,
|
||||
* ['synonym of KEY_TWO 1', 'synonym of KEY_TWO 2'])
|
||||
* .setTitle('Number two'),
|
||||
* ]));
|
||||
* }
|
||||
*
|
||||
* function optionIntent (app) {
|
||||
* if (app.getSelectedOption() === SELECTION_KEY_ONE) {
|
||||
* app.tell('Number one is a great choice!');
|
||||
* } else {
|
||||
* app.tell('Number two is a great choice!');
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* const actionMap = new Map();
|
||||
* actionMap.set(WELCOME_INTENT, welcomeIntent);
|
||||
* actionMap.set(OPTION_INTENT, optionIntent);
|
||||
* app.handleRequest(actionMap);
|
||||
*
|
||||
* @param inputPrompt The input prompt
|
||||
* response.
|
||||
* @param carousel Carousel built with
|
||||
* {@link AssistantApp#buildCarousel|buildCarousel}.
|
||||
* @return HTTP response.
|
||||
* @dialogflow
|
||||
*/
|
||||
askWithCarousel(inputPrompt: string | RichResponse | SimpleResponse, carousel: Carousel): express.Response | null;
|
||||
|
||||
/**
|
||||
* Tells the Assistant to render the speech response and close the mic.
|
||||
*
|
||||
* @example
|
||||
* const app = new DialogflowApp({request: request, response: response});
|
||||
* const WELCOME_INTENT = 'input.welcome';
|
||||
* const NUMBER_INTENT = 'input.number';
|
||||
*
|
||||
* function welcomeIntent (app) {
|
||||
* app.ask('Welcome to action snippets! Say a number.');
|
||||
* }
|
||||
*
|
||||
* function numberIntent (app) {
|
||||
* const number = app.getArgument(NUMBER_ARGUMENT);
|
||||
* app.tell('You said ' + number);
|
||||
* }
|
||||
*
|
||||
* const actionMap = new Map();
|
||||
* actionMap.set(WELCOME_INTENT, welcomeIntent);
|
||||
* actionMap.set(NUMBER_INTENT, numberIntent);
|
||||
* app.handleRequest(actionMap);
|
||||
*
|
||||
* @param speechResponse Final response.
|
||||
* Spoken response can be SSML.
|
||||
* @return The response that is sent back to Assistant.
|
||||
* @dialogflow
|
||||
*/
|
||||
tell(speechResponse: string | SimpleResponse | RichResponse): express.Response | null;
|
||||
|
||||
/**
|
||||
* Set a new context for the current intent.
|
||||
*
|
||||
* @example
|
||||
* const app = new DialogflowApp({request: request, response: response});
|
||||
* const CONTEXT_NUMBER = 'number';
|
||||
* const NUMBER_ARGUMENT = 'myNumber';
|
||||
*
|
||||
* function welcomeIntent (app) {
|
||||
* app.setContext(CONTEXT_NUMBER);
|
||||
* app.ask('Welcome to action snippets! Say a number.');
|
||||
* }
|
||||
*
|
||||
* function numberIntent (app) {
|
||||
* const number = app.getArgument(NUMBER_ARGUMENT);
|
||||
* app.tell('You said ' + number);
|
||||
* }
|
||||
*
|
||||
* const actionMap = new Map();
|
||||
* actionMap.set(WELCOME_INTENT, welcomeIntent);
|
||||
* actionMap.set(NUMBER_INTENT, numberIntent);
|
||||
* app.handleRequest(actionMap);
|
||||
*
|
||||
* @param name Name of the context. Dialogflow converts to lowercase.
|
||||
* @param [lifespan=1] Context lifespan.
|
||||
* @param parameters Context JSON parameters.
|
||||
* @return Null if the context name is not defined.
|
||||
* @dialogflow
|
||||
*/
|
||||
setContext(name: string, lifespan?: number, parameters?: any): null | undefined;
|
||||
|
||||
/**
|
||||
* Returns the incoming contexts for this intent.
|
||||
*
|
||||
* @example
|
||||
* const app = new DialogflowApp({request: request, response: response});
|
||||
* const CONTEXT_NUMBER = 'number';
|
||||
* const NUMBER_ARGUMENT = 'myNumber';
|
||||
*
|
||||
* function welcomeIntent (app) {
|
||||
* app.setContext(CONTEXT_NUMBER);
|
||||
* app.ask('Welcome to action snippets! Say a number.');
|
||||
* }
|
||||
*
|
||||
* function numberIntent (app) {
|
||||
* let contexts = app.getContexts();
|
||||
* // contexts === [{
|
||||
* // name: 'number',
|
||||
* // lifespan: 0,
|
||||
* // parameters: {
|
||||
* // myNumber: '23',
|
||||
* // myNumber.original: '23'
|
||||
* // }
|
||||
* // }]
|
||||
* const number = app.getArgument(NUMBER_ARGUMENT);
|
||||
* app.tell('You said ' + number);
|
||||
* }
|
||||
*
|
||||
* const actionMap = new Map();
|
||||
* actionMap.set(WELCOME_INTENT, welcomeIntent);
|
||||
* actionMap.set(NUMBER_INTENT, numberIntent);
|
||||
* app.handleRequest(actionMap);
|
||||
*
|
||||
* @return Empty if no active contexts.
|
||||
* @dialogflow
|
||||
*/
|
||||
getContexts(): Context[];
|
||||
|
||||
/**
|
||||
* Returns the incoming context by name for this intent.
|
||||
*
|
||||
* @example
|
||||
* const app = new DialogflowApp({request: request, response: response});
|
||||
* const CONTEXT_NUMBER = 'number';
|
||||
* const NUMBER_ARGUMENT = 'myNumber';
|
||||
*
|
||||
* function welcomeIntent (app) {
|
||||
* app.setContext(CONTEXT_NUMBER);
|
||||
* app.ask('Welcome to action snippets! Say a number.');
|
||||
* }
|
||||
*
|
||||
* function numberIntent (app) {
|
||||
* let context = app.getContext(CONTEXT_NUMBER);
|
||||
* // context === {
|
||||
* // name: 'number',
|
||||
* // lifespan: 0,
|
||||
* // parameters: {
|
||||
* // myNumber: '23',
|
||||
* // myNumber.original: '23'
|
||||
* // }
|
||||
* // }
|
||||
* const number = app.getArgument(NUMBER_ARGUMENT);
|
||||
* app.tell('You said ' + number);
|
||||
* }
|
||||
*
|
||||
* const actionMap = new Map();
|
||||
* actionMap.set(WELCOME_INTENT, welcomeIntent);
|
||||
* actionMap.set(NUMBER_INTENT, numberIntent);
|
||||
* app.handleRequest(actionMap);
|
||||
*
|
||||
* @param name The name of the Context to retrieve.
|
||||
* @return Context value matching name
|
||||
* or null if no matching context.
|
||||
* @dialogflow
|
||||
*/
|
||||
getContext(name: string): object;
|
||||
|
||||
/**
|
||||
* Gets the user's raw input query.
|
||||
*
|
||||
* @example
|
||||
* const app = new DialogflowApp({request: request, response: response});
|
||||
* app.tell('You said ' + app.getRawInput());
|
||||
*
|
||||
* @return User's raw query or null if no value.
|
||||
* @dialogflow
|
||||
*/
|
||||
getRawInput(): string;
|
||||
}
|
||||
Vendored
+24
@@ -0,0 +1,24 @@
|
||||
// Type definitions for actions-on-google 1.6
|
||||
// Project: https://github.com/actions-on-google/actions-on-google-nodejs
|
||||
// Definitions by: Joel Hegg <https://github.com/joelhegg>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.4
|
||||
|
||||
/**
|
||||
* The Actions on Google client library.
|
||||
* https://developers.google.com/actions/
|
||||
*/
|
||||
|
||||
import * as Transactions from './transactions';
|
||||
import * as Responses from './response-builder';
|
||||
|
||||
export { AssistantApp } from './assistant-app';
|
||||
export { ActionsSdkApp, ActionsSdkAppOptions } from './actions-sdk-app';
|
||||
export { DialogflowApp, DialogflowAppOptions } from './dialogflow-app';
|
||||
export { Transactions };
|
||||
export { Responses };
|
||||
// Backwards compatibility
|
||||
export { AssistantApp as Assistant } from './assistant-app';
|
||||
export { ActionsSdkApp as ActionsSdkAssistant } from './actions-sdk-app';
|
||||
export { DialogflowApp as ApiAiAssistant } from './dialogflow-app';
|
||||
export { DialogflowApp as ApiAiApp } from './dialogflow-app';
|
||||
+404
@@ -0,0 +1,404 @@
|
||||
/**
|
||||
* A collection of response builders.
|
||||
*/
|
||||
|
||||
import { OrderUpdate } from './transactions';
|
||||
|
||||
/**
|
||||
* Simple Response type.
|
||||
*/
|
||||
export interface SimpleResponse {
|
||||
/** Speech to be spoken to user. SSML allowed. */
|
||||
speech: string;
|
||||
/** Optional text to be shown to user */
|
||||
displayText?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Suggestions to show with response.
|
||||
*/
|
||||
export interface Suggestion {
|
||||
/** Text of the suggestion. */
|
||||
title: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Link Out Suggestion. Used in rich response as a suggestion chip which, when
|
||||
* selected, links out to external URL.
|
||||
*/
|
||||
export interface LinkOutSuggestion {
|
||||
/** Text shown on the suggestion chip. */
|
||||
title: string;
|
||||
/** String URL to open. */
|
||||
url: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Image type shown on visual elements.
|
||||
*/
|
||||
export interface Image {
|
||||
/** Image source URL. */
|
||||
url: string;
|
||||
/** Text to replace for image for accessibility. */
|
||||
accessibilityText: string;
|
||||
/** Width of the image. */
|
||||
width: number;
|
||||
/** Height of the image. */
|
||||
height: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Basic Card Button. Shown below basic cards. Open a URL when selected.
|
||||
*/
|
||||
export interface Button {
|
||||
/** Text shown on the button. */
|
||||
title: string;
|
||||
/** Action to take when selected. */
|
||||
openUrlAction: {
|
||||
/** String URL to open. */
|
||||
url: string;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Option info. Provides unique identifier for a given OptionItem.
|
||||
*/
|
||||
export interface OptionInfo {
|
||||
/** Unique string ID for this option. */
|
||||
key: string;
|
||||
/** Synonyms that can be used by the user to indicate this option if they do not use the key. */
|
||||
synonyms: string[];
|
||||
}
|
||||
|
||||
export interface StructuredResponse {
|
||||
orderUpdate: OrderUpdate;
|
||||
}
|
||||
|
||||
export interface RichResponseItemBasicCard {
|
||||
basicCard: BasicCard;
|
||||
}
|
||||
|
||||
export interface RichResponseItemSimpleResponse {
|
||||
simpleResponse: SimpleResponse;
|
||||
}
|
||||
|
||||
export interface RichResponseItemStructuredResponse {
|
||||
structuredResponse: StructuredResponse;
|
||||
}
|
||||
|
||||
export type RichResponseItem = RichResponseItemBasicCard | RichResponseItemSimpleResponse | RichResponseItemStructuredResponse;
|
||||
|
||||
/**
|
||||
* Class for initializing and constructing Rich Responses with chainable interface.
|
||||
*/
|
||||
export class RichResponse {
|
||||
/**
|
||||
* Constructor for RichResponse. Accepts optional RichResponse to clone.
|
||||
*
|
||||
* @param richResponse Optional RichResponse to clone.
|
||||
*/
|
||||
constructor(richResponse?: RichResponse);
|
||||
|
||||
/**
|
||||
* Ordered list of either SimpleResponse objects or BasicCard objects.
|
||||
* First item must be SimpleResponse. There can be at most one card.
|
||||
*/
|
||||
items: RichResponseItem[];
|
||||
|
||||
/**
|
||||
* Ordered list of text suggestions to display. Optional.
|
||||
*/
|
||||
suggestions: Suggestion[];
|
||||
|
||||
/**
|
||||
* Link Out Suggestion chip for this rich response. Optional.
|
||||
*/
|
||||
linkOutSuggestion?: LinkOutSuggestion;
|
||||
|
||||
/**
|
||||
* Adds a SimpleResponse to list of items.
|
||||
*
|
||||
* @param simpleResponse Simple response to present to
|
||||
* user. If just a string, display text will not be set.
|
||||
* @return Returns current constructed RichResponse.
|
||||
*/
|
||||
addSimpleResponse(simpleResponse: string | SimpleResponse): RichResponse;
|
||||
|
||||
/**
|
||||
* Adds a BasicCard to list of items.
|
||||
*
|
||||
* @param basicCard Basic card to include in response.
|
||||
* @return Returns current constructed RichResponse.
|
||||
*/
|
||||
addBasicCard(basicCard: BasicCard): RichResponse;
|
||||
|
||||
/**
|
||||
* Adds a single suggestion or list of suggestions to list of items.
|
||||
*
|
||||
* @param suggestions Either a single string suggestion
|
||||
* or list of suggestions to add.
|
||||
* @return Returns current constructed RichResponse.
|
||||
*/
|
||||
addSuggestions(suggestions: string | string[]): RichResponse;
|
||||
|
||||
/**
|
||||
* Returns true if the given suggestion text is valid to be added to the suggestion list. A valid
|
||||
* text string is not longer than 25 characters.
|
||||
* @param suggestionText Text to validate as suggestion.
|
||||
* @return True if the text is valid, false otherwise.s
|
||||
*/
|
||||
isValidSuggestionText(suggestionText: string): boolean;
|
||||
|
||||
/**
|
||||
* Sets the suggestion link for this rich response.
|
||||
*
|
||||
* @param destinationName Name of the link out destination.
|
||||
* @param suggestionUrl - String URL to open when suggestion is used.
|
||||
* @return Returns current constructed RichResponse.
|
||||
*/
|
||||
addSuggestionLink(destinationName: string, suggestionUrl: string): RichResponse;
|
||||
|
||||
/**
|
||||
* Adds an order update to this response. Use after a successful transaction
|
||||
* decision to confirm the order.
|
||||
*
|
||||
* @param orderUpdate OrderUpdate object to add.
|
||||
* @return Returns current constructed RichResponse.
|
||||
*/
|
||||
addOrderUpdate(orderUpdate: OrderUpdate): RichResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
* Class for initializing and constructing Basic Cards with chainable interface.
|
||||
*/
|
||||
export class BasicCard {
|
||||
/**
|
||||
* Constructor for BasicCard. Accepts optional BasicCard to clone.
|
||||
*
|
||||
* @param basicCard Optional BasicCard to clone.
|
||||
*/
|
||||
constructor(basicCard?: BasicCard);
|
||||
|
||||
/**
|
||||
* Title of the card. Optional.
|
||||
*/
|
||||
title?: string;
|
||||
|
||||
/**
|
||||
* Body text to show on the card. Required, unless image is present.
|
||||
*/
|
||||
formattedText: string;
|
||||
|
||||
/**
|
||||
* Subtitle of the card. Optional.
|
||||
*/
|
||||
subtitle?: string;
|
||||
|
||||
/**
|
||||
* Image to show on the card. Optional.
|
||||
*/
|
||||
image?: Image;
|
||||
|
||||
/**
|
||||
* Ordered list of buttons to show below card. Optional.
|
||||
*/
|
||||
buttons: Button[];
|
||||
|
||||
/**
|
||||
* Sets the title for this Basic Card.
|
||||
*
|
||||
* @param title Title to show on card.
|
||||
* @return Returns current constructed BasicCard.
|
||||
*/
|
||||
setTitle(title: string): BasicCard;
|
||||
|
||||
/**
|
||||
* Sets the subtitle for this Basic Card.
|
||||
*
|
||||
* @param subtitle Subtitle to show on card.
|
||||
* @return Returns current constructed BasicCard.
|
||||
*/
|
||||
setSubtitle(subtitle: string): BasicCard;
|
||||
|
||||
/**
|
||||
* Sets the body text for this Basic Card.
|
||||
*
|
||||
* @param bodyText Body text to show on card.
|
||||
* @return Returns current constructed BasicCard.
|
||||
*/
|
||||
setBodyText(bodyText: string): BasicCard;
|
||||
|
||||
/**
|
||||
* Sets the image for this Basic Card.
|
||||
*
|
||||
* @param url Image source URL.
|
||||
* @param accessibilityText Text to replace for image for
|
||||
* accessibility.
|
||||
* @param width Width of the image.
|
||||
* @param height Height of the image.
|
||||
* @return Returns current constructed BasicCard.
|
||||
*/
|
||||
setImage(url: string, accessibilityText: string, width?: number, height?: number): BasicCard;
|
||||
|
||||
/**
|
||||
* Adds a button below card.
|
||||
*
|
||||
* @param text Text to show on button.
|
||||
* @param url URL to open when button is selected.
|
||||
* @return Returns current constructed BasicCard.
|
||||
*/
|
||||
addButton(text: string, url: string): BasicCard;
|
||||
}
|
||||
|
||||
/**
|
||||
* Class for initializing and constructing Lists with chainable interface.
|
||||
*/
|
||||
export class List {
|
||||
/**
|
||||
* Constructor for List. Accepts optional List to clone, string title, or
|
||||
* list of items to copy.
|
||||
*
|
||||
* @param list Either a list to clone, a title
|
||||
* to set for a new List, or an array of OptionItem to initialize a new
|
||||
* list.
|
||||
*/
|
||||
constructor(list?: List | string | OptionItem[]);
|
||||
|
||||
/**
|
||||
* Title of the list. Optional.
|
||||
*/
|
||||
title?: string;
|
||||
|
||||
/**
|
||||
* List of 2-20 items to show in this list. Required.
|
||||
*/
|
||||
items: OptionItem[];
|
||||
|
||||
/**
|
||||
* Sets the title for this List.
|
||||
*
|
||||
* @param title Title to show on list.
|
||||
* @return Returns current constructed List.
|
||||
*/
|
||||
setTitle(title: string): List;
|
||||
|
||||
/**
|
||||
* Adds a single item or list of items to the list.
|
||||
*
|
||||
* @param optionItems OptionItems to add.
|
||||
* @return Returns current constructed List.
|
||||
*/
|
||||
addItems(optionItems: OptionItem | OptionItem[]): List;
|
||||
}
|
||||
|
||||
/**
|
||||
* Class for initializing and constructing Carousel with chainable interface.
|
||||
*/
|
||||
export class Carousel {
|
||||
/**
|
||||
* Constructor for Carousel. Accepts optional Carousel to clone or list of
|
||||
* items to copy.
|
||||
*
|
||||
* @param carousel Either a carousel to clone
|
||||
* or an array of OptionItem to initialize a new carousel
|
||||
*/
|
||||
constructor(carousel?: Carousel | OptionItem[]);
|
||||
|
||||
/**
|
||||
* List of 2-20 items to show in this carousel. Required.
|
||||
*/
|
||||
items: OptionItem[];
|
||||
|
||||
/**
|
||||
* Adds a single item or list of items to the carousel.
|
||||
*
|
||||
* @param optionItems OptionItems to add.
|
||||
* @return Returns current constructed Carousel.
|
||||
*/
|
||||
addItems(optionItems: OptionItem | OptionItem[]): Carousel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Class for initializing and constructing Option Items with chainable interface.
|
||||
*/
|
||||
export class OptionItem {
|
||||
/**
|
||||
* Constructor for OptionItem. Accepts optional OptionItem to clone.
|
||||
*
|
||||
* @param optionItem Optional OptionItem to clone.
|
||||
*/
|
||||
constructor(optionItem?: OptionItem);
|
||||
|
||||
/**
|
||||
* Option info of the option item. Required.
|
||||
*/
|
||||
optionInfo: OptionInfo;
|
||||
|
||||
/**
|
||||
* Title of the option item. Required.
|
||||
*/
|
||||
title: string;
|
||||
|
||||
/**
|
||||
* Description text of the item. Optional.
|
||||
*/
|
||||
description?: string;
|
||||
|
||||
/**
|
||||
* Image to show on item. Optional.
|
||||
*/
|
||||
image?: Image;
|
||||
|
||||
/**
|
||||
* Sets the title for this Option Item.
|
||||
*
|
||||
* @param title Title to show on item.
|
||||
* @return Returns current constructed OptionItem.
|
||||
*/
|
||||
setTitle(title: string): OptionItem;
|
||||
|
||||
/**
|
||||
* Sets the description for this Option Item.
|
||||
*
|
||||
* @param description Description to show on item.
|
||||
* @return Returns current constructed OptionItem.
|
||||
*/
|
||||
setDescription(description: string): OptionItem;
|
||||
|
||||
/**
|
||||
* Sets the image for this Option Item.
|
||||
*
|
||||
* @param url Image source URL.
|
||||
* @param accessibilityText Text to replace for image for
|
||||
* accessibility.
|
||||
* @param width Width of the image.
|
||||
* @param height Height of the image.
|
||||
* @return Returns current constructed OptionItem.
|
||||
*/
|
||||
setImage(url: string, accessibilityText: string, width?: number, height?: number): OptionItem;
|
||||
|
||||
/**
|
||||
* Sets the key for the OptionInfo of this Option Item. This will be returned
|
||||
* as an argument in the resulting actions.intent.OPTION intent.
|
||||
*
|
||||
* @param key Key to uniquely identify this item.
|
||||
* @return Returns current constructed OptionItem.
|
||||
*/
|
||||
setKey(key: string): OptionItem;
|
||||
|
||||
/**
|
||||
* Adds a single synonym or list of synonyms to item.
|
||||
*
|
||||
* @param synonyms Either a single string synonyms
|
||||
* or list of synonyms to add.
|
||||
* @return Returns current constructed OptionItem.
|
||||
*/
|
||||
addSynonyms(synonyms: string | string[]): OptionItem;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if given text contains SSML.
|
||||
* @param text Text to check.
|
||||
* @return True if text contains SSML, false otherwise.
|
||||
*/
|
||||
export function isSsml(text: string): boolean;
|
||||
+1113
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"assistant-app.d.ts",
|
||||
"actions-sdk-app.d.ts",
|
||||
"dialogflow-app.d.ts",
|
||||
"response-builder.d.ts",
|
||||
"transactions.d.ts",
|
||||
"actions-on-google-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
import addZero from "add-zero";
|
||||
|
||||
addZero(5, 2);
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
// Type definitions for add-zero 1.0
|
||||
// Project: https://github.com/rafaelrinaldi/add-zero#readme
|
||||
// Definitions by: Giles Roadnight <https://github.com/Roaders>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export default function addZero(value: string | number, digits?: number): string;
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"add-zero-tests.ts"
|
||||
]
|
||||
}
|
||||
Vendored
-3
@@ -731,9 +731,6 @@ declare namespace adone {
|
||||
*/
|
||||
creationData(): DatetimeCreationData;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
parsingFlags(): DatetimeParsingFlags;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
// Global
|
||||
|
||||
const threeCamera = new AFRAME.THREE.Camera();
|
||||
AFRAME.TWEEN.Easing;
|
||||
|
||||
@@ -42,9 +41,18 @@ entity.addEventListener('child-detached', (event) => {
|
||||
const Component = AFRAME.registerComponent('test', {});
|
||||
|
||||
// Scene
|
||||
|
||||
const scene = document.querySelector('a-scene');
|
||||
scene.hasLoaded;
|
||||
|
||||
// System
|
||||
const system = scene.systems['systemName'];
|
||||
|
||||
// Register Custom Geometry
|
||||
AFRAME.registerGeometry('a-test-geometry', {
|
||||
schema: {
|
||||
groupIndex: { default: 0 }
|
||||
},
|
||||
init(data) {
|
||||
this.geometry = new THREE.Geometry();
|
||||
}
|
||||
});
|
||||
|
||||
Vendored
+9
-4
@@ -1,6 +1,7 @@
|
||||
// Type definitions for AFRAME 0.5
|
||||
// Type definitions for AFRAME 0.7
|
||||
// Project: https://aframe.io/
|
||||
// Definitions by: Paul Shannon <https://github.com/devpaul>
|
||||
// Roberto Ritger <https://github.com/bertoritger>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
@@ -40,7 +41,7 @@ declare namespace AFrame {
|
||||
primitives: { [ key: string ]: Entity };
|
||||
registerComponent(name: string, component: ComponentDefinition): ComponentConstructor;
|
||||
registerElement(name: string, element: ANode): void;
|
||||
registerGeometry(name: string, geometery: THREE.Geometry): Geometry;
|
||||
registerGeometry(name: string, geometry: GeometryDefinition): Geometry;
|
||||
registerPrimitive(name: string, primitive: PrimitiveDefinition): void;
|
||||
registerShader(name: string, shader: any): void;
|
||||
registerSystem(name: string, definition: SystemDefinition): void;
|
||||
@@ -101,7 +102,7 @@ declare namespace AFrame {
|
||||
name: string;
|
||||
schema: Schema;
|
||||
|
||||
init(): void;
|
||||
init(data?: any): void;
|
||||
pause(): void;
|
||||
play(): void;
|
||||
remove(): void;
|
||||
@@ -124,7 +125,7 @@ declare namespace AFrame {
|
||||
multiple?: boolean;
|
||||
schema?: Schema;
|
||||
|
||||
init?(): void;
|
||||
init?(data?: any): void;
|
||||
pause?(): void;
|
||||
play?(): void;
|
||||
remove?(): void;
|
||||
@@ -222,6 +223,10 @@ declare namespace AFrame {
|
||||
[ key: string ]: any;
|
||||
}
|
||||
|
||||
interface GeometryDefinition extends ComponentDefinition {
|
||||
geometry?: THREE.Geometry;
|
||||
}
|
||||
|
||||
interface GeometryDescriptor {
|
||||
Geometry: Geometry;
|
||||
schema: Schema;
|
||||
|
||||
Vendored
+779
-18
@@ -4,15 +4,85 @@
|
||||
// Huw <https://github.com/hoo29>
|
||||
// pascalwhoop <https://github.com/pascalwhoop>
|
||||
// Ben <https://github.com/blforce>
|
||||
// rk-7 <https://github.com/rk-7>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
export function handler<T>(event: RequestBody<T>, context: Context, callback?: (err: any, response: any) => void): AlexaObject<T>;
|
||||
export function CreateStateHandler(state: string, obj: any): any;
|
||||
export let StateString: string;
|
||||
|
||||
export type ConfirmationStatuses = "NONE" | "DENIED" | "CONFIRMED";
|
||||
export type DialogStates = "STARTED" | "IN_PROGRESS" | "COMPLETED";
|
||||
export type ListItemObjectStatus = "active" | "completed";
|
||||
export type ListObjectState = "active" | "archived";
|
||||
export type ImageSourceSize = "X_SMALL" | "SMALL" | "MEDIUM" | "LARGE" | "X_LARGE";
|
||||
export type TemplateBackButtonVisibility = "HIDDEN" | "VISIBLE";
|
||||
export type TemplateType = "BodyTemplate1" | "BodyTemplate2" | "BodyTemplate3" | "BodyTemplate6" | "BodyTemplate6" | "ListTemplate1" | "ListTemplate2";
|
||||
export type AudioPlayerActivity = "IDLE" | "PAUSED" | "PLAYING" | "BUFFER_UNDERRUN" | "FINISHED" | "STOPPED";
|
||||
export type CardType = "Standard" | "Simple" | "LinkAccount" | "AskForPermissionsConsent";
|
||||
export type HintType = "PlainText";
|
||||
export type DirectiveTypes = "AudioPlayer.Play" | "AudioPlayer.Stop" | "AudioPlayer.ClearQueue" | "Display.RenderTemplate" | "Hint" | "VideoApp.Launch";
|
||||
export type TextContentType = "PlainText" | "RichText";
|
||||
|
||||
//#region Types
|
||||
export interface CardImage {
|
||||
/**
|
||||
* Recommended size (in px): 720w x 480h
|
||||
*/
|
||||
smallImageUrl: string;
|
||||
/**
|
||||
* Recommended size (in px): 1200w x 800h
|
||||
*/
|
||||
largeImageUrl: string;
|
||||
}
|
||||
export interface ImageSource {
|
||||
url: string;
|
||||
widthPixels?: number;
|
||||
heightPixels?: number;
|
||||
/**
|
||||
* Recommended sizes for the following dimensions (in px):
|
||||
* 480 x 320 for X_SMALL,
|
||||
* 720 x 480 for SMALL,
|
||||
* 960 x 640 for MEDIUM,
|
||||
* 1200 x 800 for LARGE,
|
||||
* 1920 x 1280 for X_LARGE
|
||||
*/
|
||||
size?: ImageSourceSize;
|
||||
}
|
||||
export interface Image {
|
||||
contentDescription: string;
|
||||
sources: ImageSource[];
|
||||
}
|
||||
export interface TextField {
|
||||
text: string;
|
||||
type: string;
|
||||
}
|
||||
export interface TextContent {
|
||||
primaryText?: TextField;
|
||||
secondaryText?: TextField;
|
||||
tertiaryText?: TextField;
|
||||
}
|
||||
export interface ListItem {
|
||||
image?: Image;
|
||||
token: string;
|
||||
textContent?: TextContent;
|
||||
}
|
||||
|
||||
export interface Template {
|
||||
title?: string;
|
||||
token: string;
|
||||
backgroundImage?: Image;
|
||||
/**
|
||||
* Visibility of the back button.
|
||||
*/
|
||||
backButton?: TemplateBackButtonVisibility;
|
||||
/**
|
||||
* Template type.
|
||||
*/
|
||||
type: TemplateType;
|
||||
image?: Image;
|
||||
listItems?: ListItem[];
|
||||
}
|
||||
|
||||
export interface AlexaObject<T> extends Handler<T> {
|
||||
_event: any;
|
||||
@@ -38,12 +108,16 @@ export interface Handler<T> {
|
||||
emitWithState: any;
|
||||
state: any;
|
||||
handler: any;
|
||||
i18n: any;
|
||||
locale: any;
|
||||
event: RequestBody<T>;
|
||||
attributes: any;
|
||||
context: any;
|
||||
callback: (param: any) => void;
|
||||
name: any;
|
||||
isOverriden: any;
|
||||
t: (token: string, ...args: any[]) => void;
|
||||
response: ResponseBuilder;
|
||||
}
|
||||
|
||||
export interface Context {
|
||||
@@ -55,8 +129,28 @@ export interface Context {
|
||||
functionVersion: string;
|
||||
invokeid: string;
|
||||
awsRequestId: string;
|
||||
System?: System;
|
||||
AudioPlayer?: AudioPlayer;
|
||||
}
|
||||
export interface Application {
|
||||
applicationId: string;
|
||||
[key: string]: string;
|
||||
}
|
||||
export interface System {
|
||||
apiAccessToken: string;
|
||||
apiEndpoint: string;
|
||||
application: Application;
|
||||
device: any;
|
||||
user: any;
|
||||
}
|
||||
export interface AudioPlayer {
|
||||
token: string;
|
||||
offsetInMilliseconds: number;
|
||||
/**
|
||||
* Player activity
|
||||
*/
|
||||
playerActivity: AudioPlayerActivity;
|
||||
}
|
||||
|
||||
export interface RequestBody<T> {
|
||||
version: string;
|
||||
session: Session;
|
||||
@@ -66,20 +160,22 @@ export interface RequestBody<T> {
|
||||
export interface Session {
|
||||
new: boolean;
|
||||
sessionId: string;
|
||||
attributes: any;
|
||||
application: SessionApplication;
|
||||
attributes: { [key: string]: any };
|
||||
application: Application;
|
||||
user: SessionUser;
|
||||
}
|
||||
|
||||
export interface SessionApplication {
|
||||
applicationId: string;
|
||||
}
|
||||
|
||||
export interface SessionUser {
|
||||
userId: string;
|
||||
accessToken?: string;
|
||||
permissions: Permissions;
|
||||
}
|
||||
export interface Permissions {
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
consentToken: string;
|
||||
[key: string]: string;
|
||||
}
|
||||
|
||||
export interface LaunchRequest extends Request { }
|
||||
|
||||
export interface IntentRequest extends Request {
|
||||
@@ -144,7 +240,8 @@ export interface Response {
|
||||
outputSpeech?: OutputSpeech;
|
||||
card?: Card;
|
||||
reprompt?: Reprompt;
|
||||
shouldEndSession: boolean;
|
||||
directives?: any;
|
||||
shouldEndSession?: boolean;
|
||||
}
|
||||
|
||||
export interface OutputSpeech {
|
||||
@@ -154,18 +251,682 @@ export interface OutputSpeech {
|
||||
}
|
||||
|
||||
export interface Card {
|
||||
type: "Simple" | "Standard" | "LinkAccount";
|
||||
type: CardType;
|
||||
title?: string;
|
||||
content?: string;
|
||||
text?: string;
|
||||
image?: Image;
|
||||
}
|
||||
|
||||
export interface Image {
|
||||
smallImageUrl: string;
|
||||
largeImageUrl: string;
|
||||
image?: CardImage;
|
||||
}
|
||||
|
||||
export interface Reprompt {
|
||||
outputSpeech: OutputSpeech;
|
||||
}
|
||||
|
||||
export interface ApiClientOptions {
|
||||
hostname: string;
|
||||
port: string;
|
||||
path: string;
|
||||
protocol: string;
|
||||
headers: string;
|
||||
method: string;
|
||||
}
|
||||
export interface ApiClientResponse {
|
||||
statusCode: string;
|
||||
statusText: string;
|
||||
body: object;
|
||||
headers: object;
|
||||
}
|
||||
/**
|
||||
* Todo-ListItem class
|
||||
* Refer https://developer.amazon.com/docs/custom-skills/access-the-alexa-shopping-and-to-do-lists.html
|
||||
*/
|
||||
export interface ListItemObject {
|
||||
/**
|
||||
* item id (String, limit 60 characters)
|
||||
*/
|
||||
id: string;
|
||||
/**
|
||||
* item value (String, limit is 256 characters)
|
||||
*/
|
||||
value: string;
|
||||
/**
|
||||
* item status
|
||||
*/
|
||||
status?: ListItemObjectStatus;
|
||||
/**
|
||||
* item version (Positive integer)
|
||||
*/
|
||||
version?: number | string;
|
||||
/**
|
||||
* created time (ISO 8601 time format with time zone)
|
||||
*/
|
||||
createdTime: Date;
|
||||
/**
|
||||
* updated time (ISO 8601 time format with time zone)
|
||||
*/
|
||||
updatedTime: Date;
|
||||
/**
|
||||
* URL to retrieve the item (String)
|
||||
*/
|
||||
href?: string;
|
||||
}
|
||||
/**
|
||||
* Todo-List class
|
||||
* Refer https://developer.amazon.com/docs/custom-skills/access-the-alexa-shopping-and-to-do-lists.html
|
||||
*/
|
||||
export interface ListObject {
|
||||
/**
|
||||
* list id (String)
|
||||
*/
|
||||
listId: string;
|
||||
/**
|
||||
* list name (String)
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* state
|
||||
* "active" or "archived" (Enum)
|
||||
*/
|
||||
state?: ListObjectState;
|
||||
/**
|
||||
* Possibly status of the list (or state?)
|
||||
* Fetched from commit eebba0d at https://github.com/alexa/alexa-skills-kit-sdk-for-nodejs/
|
||||
* File path: alexa-skills-kit-sdk-for-nodejs/lib/services/listManagementService.js
|
||||
*/
|
||||
status?: string;
|
||||
/**
|
||||
* list version (Positive integer)
|
||||
*/
|
||||
version?: number;
|
||||
/**
|
||||
* Urls to active and completed items
|
||||
* href is lint to the items having certain status.
|
||||
* The status can be "active" or "completed".
|
||||
*/
|
||||
statusMap: { href: string; status: ListItemObjectStatus; };
|
||||
/**
|
||||
* Items that belong to this list.
|
||||
*/
|
||||
items: ListItemObject[];
|
||||
}
|
||||
//#endregion
|
||||
|
||||
//#region templateBuilders
|
||||
/**
|
||||
* Generates templates for Echo Show device.
|
||||
*/
|
||||
export namespace templateBuilders {
|
||||
interface SetTextContent<T extends TemplateBuilder<T>> {
|
||||
setTextContent(primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): T;
|
||||
}
|
||||
interface SetListItems<T extends TemplateBuilder<T>> {
|
||||
setListItems(listItems: ListItem[]): T;
|
||||
}
|
||||
/**
|
||||
* Refer https://developer.amazon.com/docs/custom-skills/display-interface-reference.html#image-sizes
|
||||
*/
|
||||
abstract class TemplateBuilder<T extends TemplateBuilder<T>> {
|
||||
template: Template;
|
||||
constructor();
|
||||
|
||||
/**
|
||||
* Sets the title of the template
|
||||
* @param title title
|
||||
* @returns TemplateBuilder
|
||||
*/
|
||||
setTitle(title: string): T;
|
||||
|
||||
/**
|
||||
* Sets the token of the template
|
||||
* @param token token
|
||||
* @returns TemplateBuilder
|
||||
*/
|
||||
setToken(token: string): T;
|
||||
|
||||
/**
|
||||
* Sets the background image of the template
|
||||
* @param image image
|
||||
* @returns TemplateBuilder
|
||||
*/
|
||||
setBackgroundImage(image: Image): T;
|
||||
|
||||
/**
|
||||
* Sets the backButton behavior
|
||||
* @param backButtonBehavior "VISIBLE" or "HIDDEN"
|
||||
* @returns TemplateBuilder
|
||||
*/
|
||||
setBackButtonBehavior(backButtonBehavior: string): T;
|
||||
|
||||
/**
|
||||
* Builds the template JSON object
|
||||
* @returns Template
|
||||
*/
|
||||
build(): Template;
|
||||
}
|
||||
/**
|
||||
* Used to build a list of ListItems for ListTemplate
|
||||
*/
|
||||
class ListItemBuilder {
|
||||
constructor();
|
||||
items: ListItem[];
|
||||
/**
|
||||
* Add an item to the list of template
|
||||
* @param image image
|
||||
* @param token token
|
||||
* @param primaryText primaryText
|
||||
* @param secondaryText secondaryText
|
||||
* @param tertiaryText tertiaryText
|
||||
*/
|
||||
addItem(image: Image, token: string, primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): ListItemBuilder;
|
||||
|
||||
build(): ListItem[];
|
||||
}
|
||||
/**
|
||||
* Used to create BodyTemplate1 objects
|
||||
*/
|
||||
class BodyTemplate1Builder extends TemplateBuilder<BodyTemplate1Builder> implements SetTextContent<BodyTemplate1Builder> {
|
||||
constructor();
|
||||
/**
|
||||
* Sets the text content for the template
|
||||
* @param primaryText primaryText
|
||||
* @param secondaryText secondaryText
|
||||
* @param tertiaryText tertiaryText
|
||||
* @returns BodyTemplate1Builder
|
||||
*/
|
||||
setTextContent(primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): BodyTemplate1Builder;
|
||||
}
|
||||
/**
|
||||
* Used to create BodyTemplate2 objects
|
||||
*/
|
||||
class BodyTemplate2Builder extends TemplateBuilder<BodyTemplate2Builder> implements SetTextContent<BodyTemplate2Builder> {
|
||||
constructor();
|
||||
|
||||
/**
|
||||
* Sets the image for the template
|
||||
* @param image image
|
||||
* @returns BodyTemplate2Builder
|
||||
*/
|
||||
setImage(image: Image): BodyTemplate2Builder;
|
||||
|
||||
/**
|
||||
* Sets the text content for the template
|
||||
* @param primaryText primaryText
|
||||
* @param secondaryText secondaryText
|
||||
* @param tertiaryText tertiaryText
|
||||
* @returns BodyTemplate2Builder
|
||||
*/
|
||||
setTextContent(primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): BodyTemplate2Builder;
|
||||
}
|
||||
/**
|
||||
* Used to create BodyTemplate3 objects
|
||||
*/
|
||||
class BodyTemplate3Builder extends TemplateBuilder<BodyTemplate3Builder> implements SetTextContent<BodyTemplate3Builder> {
|
||||
constructor();
|
||||
|
||||
/**
|
||||
* Sets the image for the template
|
||||
* @param image image
|
||||
* @returns BodyTemplate3Builder
|
||||
*/
|
||||
setImage(image: Image): BodyTemplate3Builder;
|
||||
|
||||
/**
|
||||
* Sets the text content for the template
|
||||
* @param primaryText primaryText
|
||||
* @param secondaryText secondaryText
|
||||
* @param tertiaryText tertiaryText
|
||||
* @returns BodyTemplate3Builder
|
||||
*/
|
||||
setTextContent(primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): BodyTemplate3Builder;
|
||||
}
|
||||
/**
|
||||
* Used to create BodyTemplate6 objects
|
||||
*/
|
||||
class BodyTemplate6Builder extends TemplateBuilder<BodyTemplate6Builder> implements SetTextContent<BodyTemplate6Builder> {
|
||||
constructor();
|
||||
|
||||
/**
|
||||
* Sets the image for the template
|
||||
* @param image image
|
||||
* @returns BodyTemplate6Builder
|
||||
*/
|
||||
setImage(image: Image): BodyTemplate6Builder;
|
||||
|
||||
/**
|
||||
* Sets the text content for the template
|
||||
* @param primaryText primaryText
|
||||
* @param secondaryText secondaryText
|
||||
* @param tertiaryText tertiaryText
|
||||
* @returns BodyTemplate6Builder
|
||||
*/
|
||||
setTextContent(primaryText: TextField, secondaryText?: TextField, tertiaryText?: TextField): BodyTemplate6Builder;
|
||||
}
|
||||
/**
|
||||
* Used to create BodyTemplate7 objects
|
||||
*/
|
||||
class BodyTemplate7Builder extends TemplateBuilder<BodyTemplate7Builder> {
|
||||
constructor();
|
||||
|
||||
/**
|
||||
* Sets the image for the template
|
||||
* @param image image
|
||||
* @returns BodyTemplate7Builder
|
||||
*/
|
||||
setImage(image: Image): BodyTemplate7Builder;
|
||||
}
|
||||
/**
|
||||
* Used to create ListTemplate1 objects
|
||||
*/
|
||||
class ListTemplate1Builder extends TemplateBuilder<ListTemplate1Builder> implements SetListItems<ListTemplate1Builder> {
|
||||
constructor();
|
||||
|
||||
/**
|
||||
* Set the items for the list
|
||||
* @param listItems listItems
|
||||
* @returns ListTemplate1Builder
|
||||
*/
|
||||
setListItems(listItems: ListItem[]): ListTemplate1Builder;
|
||||
}
|
||||
/**
|
||||
* Used to create ListTemplate2 objects
|
||||
*/
|
||||
class ListTemplate2Builder extends TemplateBuilder<ListTemplate2Builder> implements SetListItems<ListTemplate2Builder> {
|
||||
constructor();
|
||||
|
||||
/**
|
||||
* Set the items for the list
|
||||
* @param listItems listItems
|
||||
* @returns ListTemplate2Builder
|
||||
*/
|
||||
setListItems(listItems: ListItem[]): ListTemplate2Builder;
|
||||
}
|
||||
}
|
||||
//#endregion
|
||||
|
||||
//#region services
|
||||
export namespace services {
|
||||
interface ApiClient {
|
||||
/**
|
||||
* Make a POST API call to the specified uri with headers and optional body
|
||||
* @param uri http(s?) endpoint to call
|
||||
* @param headers Key value pair of headers
|
||||
* @param body post body to send
|
||||
* @returns Promise<ApiClientResponse>
|
||||
*/
|
||||
post(uri: string, headers: object, body?: string): Promise<ApiClientResponse>;
|
||||
/**
|
||||
* Make a PUT API call to the specified uri with headers and optional body
|
||||
* @param uri http(s?) endpoint to call
|
||||
* @param headers Key value pair of headers
|
||||
* @param body post body to send
|
||||
* @returns Promise<ApiClientResponse>
|
||||
*/
|
||||
put(uri: string, headers: object, body?: string): Promise<ApiClientResponse>;
|
||||
/**
|
||||
* Make a GET API call to the specified uri with headers
|
||||
* @param uri http(s?) endpoint to call
|
||||
* @param headers key value pair of headers
|
||||
* @returns Promise<ApiClientResponse>
|
||||
*/
|
||||
get(uri: string, headers: object): Promise<ApiClientResponse>;
|
||||
/**
|
||||
* Make a DELETE API call to the specified uri with headers
|
||||
* @param uri http(s?) endpoint to call
|
||||
* @param headers key value pair of headers
|
||||
* @returns Promise<ApiClientResponse>
|
||||
*/
|
||||
delete(uri: string, headers: object): Promise<ApiClientResponse>;
|
||||
}
|
||||
class DeviceAddressService {
|
||||
/**
|
||||
* Create an instance of DeviceAddressService
|
||||
* @param [apiClient=new ApiClient()] ApiClient
|
||||
*/
|
||||
constructor(apiClient: ApiClient);
|
||||
|
||||
/**
|
||||
* Get full address information from Alexa Device Address API
|
||||
* @param deviceId deviceId from Alexa request
|
||||
* @param apiEndpoint API apiEndpoint from Alexa request
|
||||
* @param token bearer token for device address permission
|
||||
* @returns Promise<object>
|
||||
*/
|
||||
getFullAddress(deviceId: string, apiEndpoint: string, token: string): Promise<object>;
|
||||
|
||||
/**
|
||||
* Get country and postal information from Alexa Device Address API
|
||||
* @param deviceId deviceId from Alexa request
|
||||
* @param apiEndpoint API apiEndpoint from Alexa request
|
||||
* @param token bearer token for device address permission
|
||||
* @returns Promise<object>
|
||||
*/
|
||||
getCountryAndPostalCode(deviceId: string, apiEndpoint: string, token: string): Promise<object>;
|
||||
}
|
||||
class DirectiveService {
|
||||
/**
|
||||
* Creates an instance of DirectiveService.
|
||||
* @param [apiClient=new ApiClient()] ApiClient
|
||||
*/
|
||||
constructor(apiClient: ApiClient);
|
||||
|
||||
/**
|
||||
* Send the specified directiveObj to Alexa directive service
|
||||
*
|
||||
* @param directive directive to send to service
|
||||
* @param apiEndpoint API endpoint from Alexa request
|
||||
* @param token bearer token for directive service
|
||||
* @returns Promise<void>
|
||||
*/
|
||||
enqueue(directive: object, apiEndpoint: string, token: string): Promise<void>;
|
||||
}
|
||||
class ListManagementService {
|
||||
/**
|
||||
* Create an instance of ListManagementService
|
||||
* @param apiClient apiClient
|
||||
*/
|
||||
constructor(apiClient: ApiClient);
|
||||
|
||||
/**
|
||||
* Set apiEndpoint address, default is "https://api.amazonalexa.com"
|
||||
* @param apiEndpoint apiEndpoint
|
||||
* @returns void
|
||||
*/
|
||||
setApiEndpoint(apiEndpoint: string): void;
|
||||
|
||||
/**
|
||||
* Get currently set apiEndpoint address
|
||||
* @returns string
|
||||
*/
|
||||
getApiEndpoint(): string;
|
||||
|
||||
/**
|
||||
* Retrieve the metadata for all customer lists, including the customer's default lists
|
||||
* @param token bearer token for list management permission
|
||||
* @returns Promise<object>
|
||||
*/
|
||||
getListsMetadata(token: string): Promise<object>;
|
||||
|
||||
/**
|
||||
* Create a custom list. The new list name must be different than any existing list name
|
||||
* @param listObject listObject
|
||||
* @param token bearer token for list management permission
|
||||
* @returns Promise<object>
|
||||
*/
|
||||
createList(listObject: ListObject, token: string): Promise<object>;
|
||||
|
||||
/**
|
||||
* Retrieve list metadata including the items in the list with requested status
|
||||
* @param listId unique Id associated with the list
|
||||
* @param itemStatus itemsStatus can be either "active" or "completed"
|
||||
* @param token bearer token for list management permission
|
||||
* @returns Promise<object>
|
||||
*/
|
||||
getList(listId: string, itemStatus: ListItemObjectStatus, token: string): Promise<object>;
|
||||
|
||||
/**
|
||||
* Update a custom list. Only the list name or state can be updated
|
||||
* @param listId unique Id associated with the list
|
||||
* @param listObject listObject
|
||||
* @param token bearer token for list management permission
|
||||
* @returns Promise<object>
|
||||
*/
|
||||
updateList(listId: string, listObject: ListObject, token: string): Promise<object>;
|
||||
|
||||
/**
|
||||
* Delete a custom list
|
||||
* @param listId unique Id associated with the list
|
||||
* @param token bearer token for list management permission
|
||||
* @returns Promise<object>
|
||||
*/
|
||||
deleteList(listId: string, token: string): Promise<object>;
|
||||
|
||||
/**
|
||||
* Create an item in an active list or in a default list
|
||||
* @param listId unique Id associated with the list
|
||||
* @param listItemObject listItemObject
|
||||
* @param token bearer token for list management permission
|
||||
* @returns Promise<object>
|
||||
*/
|
||||
createListItem(listId: string, listItemObject: ListItemObject, token: string): Promise<object>;
|
||||
|
||||
/**
|
||||
* Retrieve single item within any list by listId and itemId
|
||||
* @param listId unique Id associated with the list
|
||||
* @param itemId unique Id associated with the item
|
||||
* @param token bearer token for list management permission
|
||||
* @returns Promise<object>
|
||||
*/
|
||||
getListItem(listId: string, itemId: string, token: string): Promise<object>;
|
||||
|
||||
/**
|
||||
* Update an item value or item status
|
||||
* @param listId unique Id associated with the list
|
||||
* @param itemId unique Id associated with the item
|
||||
* @param listItemObject listItemObject
|
||||
* @param token bearer token for list management permission
|
||||
* @returns Promise<object>
|
||||
*/
|
||||
updateListItem(listId: string, itemId: string, listItemObject: ListItemObject, token: string): Promise<object>;
|
||||
|
||||
/**
|
||||
* Delete an item in the specified list
|
||||
* @param listId unique Id associated with the list
|
||||
* @param itemId unique Id associated with the item
|
||||
* @param token bearer token for list management permission
|
||||
* @returns Promise<object>
|
||||
*/
|
||||
deleteListItem(listId: string, itemId: string, token: string): Promise<object>;
|
||||
}
|
||||
}
|
||||
//#endregion
|
||||
|
||||
//#region ResponseBuilder
|
||||
/**
|
||||
* Responsible for building JSON responses as per the Alexa skills kit interface
|
||||
* https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/alexa-skills-kit-interface-reference#response-body-syntax
|
||||
*/
|
||||
export class ResponseBuilder {
|
||||
constructor(alexaHandler: Handler<Request>);
|
||||
|
||||
/**
|
||||
* Have Alexa say the provided speechOutput to the user
|
||||
* @param speechOutput speechOutput
|
||||
* @returns ResponseBuilder
|
||||
*/
|
||||
speak(speechOutput: string): ResponseBuilder;
|
||||
|
||||
/**
|
||||
* Have alexa listen for speech from the user. If the user doesn't respond within 8 seconds
|
||||
* then have alexa reprompt with the provided reprompt speech
|
||||
* @param repromptSpeech repromptSpeech
|
||||
* @returns ResponseBuilder
|
||||
*/
|
||||
listen(repromptSpeech: string): ResponseBuilder;
|
||||
|
||||
/**
|
||||
* Render a card with the following title, content and image
|
||||
* @param cardTitle cardTitle
|
||||
* @param cardContent cardContent
|
||||
* @param cardImage cardImage
|
||||
* @returns ResponseBuilder
|
||||
*/
|
||||
cardRenderer(cardTitle: string, cardContent: string, cardImage: CardImage): ResponseBuilder;
|
||||
|
||||
/**
|
||||
* Render a link account card
|
||||
* @returns ResponseBuilder
|
||||
*/
|
||||
linkAccountCard(): ResponseBuilder;
|
||||
|
||||
/**
|
||||
* Render a askForPermissionsConsent card
|
||||
* @param permissions permissions
|
||||
* @returns ResponseBuilder
|
||||
*/
|
||||
askForPermissionsConsentCard(permissions: [{ [key: string]: string }]): ResponseBuilder;
|
||||
|
||||
/**
|
||||
* Creates a play, stop or clearQueue audioPlayer directive depending on the directive type passed in.
|
||||
* @deprecated - use audioPlayerPlay, audioPlayerStop, audioPlayerClearQueue instead
|
||||
* @param directiveType directiveType
|
||||
* @param behavior behavior
|
||||
* @param url url
|
||||
* @param token token
|
||||
* @param expectedPreviousToken expectedPreviousToken
|
||||
* @param offsetInMilliseconds offsetInMilliseconds
|
||||
* @returns ResponseBuilder
|
||||
*/
|
||||
audioPlayer(directiveType: string, behavior: string, url: string, token: string, expectedPreviousToken: string, offsetInMilliseconds: number): ResponseBuilder;
|
||||
|
||||
/**
|
||||
* Creates an AudioPlayer play directive
|
||||
* @param behavior Describes playback behavior. Accepted values:
|
||||
* REPLACE_ALL: Immediately begin playback of the specified stream, and replace current and enqueued streams.
|
||||
* ENQUEUE: Add the specified stream to the end of the current queue. This does not impact the currently playing stream.
|
||||
* REPLACE_ENQUEUED: Replace all streams in the queue. This does not impact the currently playing stream.
|
||||
* @param url Identifies the location of audio content at a remote HTTPS location.
|
||||
* The audio file must be hosted at an Internet-accessible HTTPS endpoint. HTTPS is required, and the domain hosting the
|
||||
* files must present a valid, trusted SSL certificate. Self-signed certificates cannot be used.
|
||||
* The supported formats for the audio file include AAC/MP4, MP3, HLS, PLS and M3U. Bitrates: 16kbps to 384 kbps.
|
||||
* @param token A token that represents the audio stream. This token cannot exceed 1024 characters
|
||||
* @param expectedPreviousToken A token that represents the expected previous stream.
|
||||
* This property is required and allowed only when the playBehavior is ENQUEUE. This is used to prevent potential race conditions
|
||||
* if requests to progress through a playlist and change tracks occur at the same time.
|
||||
* @param offsetInMilliseconds The timestamp in the stream from which Alexa should begin playback.
|
||||
* Set to 0 to start playing the stream from the beginning. Set to any other value to start playback from that associated point in the stream
|
||||
* @returns ResponseBuilder
|
||||
*/
|
||||
audioPlayerPlay(behavior: string, url: string, token: string, expectedPreviousToken: string, offsetInMilliseconds: number): ResponseBuilder;
|
||||
|
||||
/**
|
||||
* Creates an AudioPlayer Stop directive - Stops the current audio Playback
|
||||
* @returns ResponseBuilder
|
||||
*/
|
||||
audioPlayerStop(): ResponseBuilder;
|
||||
|
||||
/**
|
||||
* Creates an AudioPlayer ClearQueue directive - clear the queue without stopping the currently playing stream,
|
||||
* or clear the queue and stop any currently playing stream.
|
||||
* @param clearBehavior Describes the clear queue behavior. Accepted values:
|
||||
* CLEAR_ENQUEUED: clears the queue and continues to play the currently playing stream
|
||||
* CLEAR_ALL: clears the entire playback queue and stops the currently playing stream (if applicable).
|
||||
* @returns ResponseBuilder
|
||||
*/
|
||||
audioPlayerClearQueue(clearBehavior: string): ResponseBuilder;
|
||||
|
||||
/**
|
||||
* Creates a Display RenderTemplate Directive
|
||||
* Use a template builder to generate a template object
|
||||
* @param template template
|
||||
* @returns ResponseBuilder
|
||||
*/
|
||||
renderTemplate(template: Template): ResponseBuilder;
|
||||
|
||||
/**
|
||||
* Creates a hint directive - show a hint on the screen of the echo show
|
||||
* @param hintText text to show on the hint
|
||||
* @param hintType (optional) Default value : PlainText
|
||||
* @returns ResponseBuilder
|
||||
*/
|
||||
hint(hintText: string, hintType?: HintType): ResponseBuilder;
|
||||
|
||||
/**
|
||||
* Creates a VideoApp play directive to play a video
|
||||
* @param source Identifies the location of video content at a remote HTTPS location.
|
||||
* The video file must be hosted at an Internet-accessible HTTPS endpoint.
|
||||
* @param metadata (optional) Contains an object that provides the
|
||||
* information that can be displayed on VideoApp.
|
||||
* @returns ResponseBuilder
|
||||
*/
|
||||
playVideo(source: string, metadata?: { title: string, subtitle: string }): ResponseBuilder;
|
||||
}
|
||||
//#endregion
|
||||
|
||||
//#region directives
|
||||
export namespace directives {
|
||||
class VoicePlayerSpeakDirective {
|
||||
header: { requestId: string };
|
||||
directive: { type: string, speech: string };
|
||||
/**
|
||||
* Creates an instance of VoicePlayerSpeakDirective.
|
||||
* @param requestId - requestId from which the call is originated from
|
||||
* @param speechContent - Contents of the speech directive either in plain text or SSML.
|
||||
*/
|
||||
constructor(requestId: string, speechContent: string);
|
||||
}
|
||||
}
|
||||
//#endregion
|
||||
|
||||
//#region utils
|
||||
export namespace utils {
|
||||
namespace ImageUtils {
|
||||
/**
|
||||
* Creates an image object with a single source
|
||||
* These images may be in either JPEG or PNG formats, with the appropriate file extensions.
|
||||
* An image cannot be larger than 2 MB
|
||||
* You must host the images at HTTPS URLs that are publicly accessible.
|
||||
* widthPixels and heightPixels are optional - Do not include them unless they are exactly correct.
|
||||
* By default, for Echo Show, size takes the value X_SMALL. If the other size values are included,
|
||||
* then the order of precedence for displaying images begins with X_LARGE and proceeds downward,
|
||||
* which means that larger images will be downscaled for display on Echo Show if provided.
|
||||
* example : ImageUtils.makeImage("https://url/to/my/img.png", 300, 400, "SMALL", "image description")
|
||||
* @param url url of the image
|
||||
* @param widthPixels (optional) width of the image in pixels
|
||||
* @param heightPixels (optional) height of the image in pixels
|
||||
* @param size size of the image (X_SMALL, SMALL, MEDIUM, LARGE, X_LARGE)
|
||||
* @param description text used to describe the image in a screen reader
|
||||
* @returns Image
|
||||
*/
|
||||
function makeImage(url: string, widthPixels?: number, heightPixels?: number, size?: ImageSourceSize, description?: string): Image;
|
||||
/**
|
||||
* Creates an image object with a multiple sources, source images are provided as an array of image objects
|
||||
* These images may be in either JPEG or PNG formats, with the appropriate file extensions.
|
||||
* An image cannot be larger than 2 MB
|
||||
* You must host the images at HTTPS URLs that are publicly accessible.
|
||||
* widthPixels and heightPixels are optional - Do not include them unless they are exactly correct.
|
||||
* By default, for Echo Show, size takes the value X_SMALL. If the other size values are included,
|
||||
* then the order of precedence for displaying images begins with X_LARGE and proceeds downward,
|
||||
* which means that larger images will be downscaled for display on Echo Show if provided.
|
||||
* example :
|
||||
* let imgArr = [
|
||||
* { "https://url/to/my/small.png", 300, 400, "SMALL" },
|
||||
* { "https://url/to/my/large.png", 900, 1200, "LARGE" },
|
||||
* ]
|
||||
* ImageUtils.makeImage(imgArr, "image description")
|
||||
*
|
||||
* @param imgArr Array of Image
|
||||
* @param description text used to describe the image in a screen reader
|
||||
* @returns Image
|
||||
*/
|
||||
function makeImages(imgArr: Array<{ url: string, widthPixels?: number, heightPixels?: number, size: ImageSourceSize }>, description: string): Image;
|
||||
}
|
||||
/**
|
||||
* Utility methods for building TextField objects
|
||||
*/
|
||||
namespace TextUtils {
|
||||
/**
|
||||
* Creates a plain TextField object with contents : text
|
||||
* @param text contents of plain text object
|
||||
* @returns TextField
|
||||
*/
|
||||
function makePlainText(text: string): TextField;
|
||||
|
||||
/**
|
||||
* Creates a rich TextField object with contents : text
|
||||
* @param text text
|
||||
* @returns TextField
|
||||
*/
|
||||
function makeRichText(text: string): TextField;
|
||||
|
||||
/**
|
||||
* Creates a textContent
|
||||
* @param primaryText primary Text
|
||||
* @param secondaryText secondary Text
|
||||
* @param tertiaryText tertiary Text
|
||||
* @returns TextContent
|
||||
*/
|
||||
function makeTextContent(primaryText: { type: TextContentType, text: string },
|
||||
secondaryText: { type: TextContentType, text: string }, tertiaryText: { type: TextContentType, text: string }): TextContent;
|
||||
}
|
||||
}
|
||||
//#endregion
|
||||
|
||||
@@ -20,4 +20,4 @@
|
||||
"index.d.ts",
|
||||
"alexa-sdk-tests.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
{ "extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"object-literal-shorthand": false,
|
||||
"object-literal-key-quote": false,
|
||||
"no-empty-interface": false,
|
||||
"prefer-method-signature": false,
|
||||
"object-literal-key-quotes": false,
|
||||
"no-any": false
|
||||
}
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"object-literal-shorthand": false,
|
||||
"object-literal-key-quote": false,
|
||||
"no-empty-interface": false,
|
||||
"prefer-method-signature": false,
|
||||
"object-literal-key-quotes": false,
|
||||
"no-any": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,12 +121,12 @@ let _algoliaQueryParameters: AlgoliaQueryParameters = {
|
||||
disableTypoToleranceOnAttributes: '',
|
||||
aroundLatLng: '',
|
||||
aroundLatLngViaIP: '',
|
||||
aroundRadius: '',
|
||||
aroundRadius: 0,
|
||||
aroundPrecision: 0,
|
||||
minimumAroundRadius: 0,
|
||||
insideBoundingBox: '',
|
||||
insideBoundingBox: [[0]],
|
||||
queryType: '',
|
||||
insidePolygon: '',
|
||||
insidePolygon: [[0]],
|
||||
removeWordsIfNoResults: '',
|
||||
advancedSyntax: false,
|
||||
optionalWords: [''],
|
||||
|
||||
Vendored
+273
-28
@@ -1,4 +1,4 @@
|
||||
// Type definitions for algoliasearch-client-js 3.24.5
|
||||
// Type definitions for algoliasearch-client-js 3.24.6
|
||||
// Project: https://github.com/algolia/algoliasearch-client-js
|
||||
// Definitions by: Baptiste Coquelle <https://github.com/cbaptiste>
|
||||
// Haroen Viaene <https://github.com/haroenv>
|
||||
@@ -49,6 +49,9 @@ declare namespace algoliasearch {
|
||||
*/
|
||||
params: string;
|
||||
}
|
||||
interface AlgoliaMultiResponse {
|
||||
results: AlgoliaResponse[];
|
||||
}
|
||||
/*
|
||||
Interface for the algolia client object
|
||||
*/
|
||||
@@ -71,8 +74,8 @@ declare namespace algoliasearch {
|
||||
indexName: string;
|
||||
query: string;
|
||||
params: AlgoliaQueryParameters;
|
||||
},
|
||||
cb: (err: Error, res: any) => void
|
||||
}[],
|
||||
cb: (err: Error, res: AlgoliaMultiResponse) => void
|
||||
): void;
|
||||
/**
|
||||
* Query on multiple index
|
||||
@@ -84,7 +87,7 @@ declare namespace algoliasearch {
|
||||
indexName: string;
|
||||
query: string;
|
||||
params: AlgoliaQueryParameters;
|
||||
}): Promise<AlgoliaResponse>;
|
||||
}[]): Promise<AlgoliaMultiResponse>;
|
||||
/**
|
||||
* clear browser cache
|
||||
* https://github.com/algolia/algoliasearch-client-js#cache
|
||||
@@ -95,6 +98,18 @@ declare namespace algoliasearch {
|
||||
* https://github.com/algolia/algoliasearch-client-js#keep-alive
|
||||
*/
|
||||
destroy(): void;
|
||||
/**
|
||||
* Add a header to be sent with all upcoming requests
|
||||
*/
|
||||
setExtraHeader(name: string, value: string): void;
|
||||
/**
|
||||
* Get the value of an extra header
|
||||
*/
|
||||
getExtraHeader(name: string): string;
|
||||
/**
|
||||
* remove an extra header for all upcoming requests
|
||||
*/
|
||||
unsetExtraHeader(name: string): void;
|
||||
/**
|
||||
* List all your indices along with their associated information (number of entries, disk size, etc.)
|
||||
* @param cb(err, res)
|
||||
@@ -307,8 +322,8 @@ declare namespace algoliasearch {
|
||||
getLogs(options: LogsOptions): Promise<any>;
|
||||
}
|
||||
/**
|
||||
* Interface for the index algolia object
|
||||
*/
|
||||
* Interface for the index algolia object
|
||||
*/
|
||||
interface AlgoliaIndex {
|
||||
/**
|
||||
* Gets a specific object
|
||||
@@ -533,6 +548,65 @@ declare namespace algoliasearch {
|
||||
options: SearchSynonymOptions,
|
||||
cb: (err: Error, res: any) => void
|
||||
): void;
|
||||
/**
|
||||
* Save a rule object
|
||||
* @param rule
|
||||
* @param options
|
||||
* @param cb(err, res)
|
||||
* https://github.com/algolia/algoliasearch-client-js#save-rule---saverule
|
||||
*/
|
||||
saveRule(
|
||||
rule: AlgoliaRule,
|
||||
options: RuleOption,
|
||||
cb: (err: Error, res: any) => void
|
||||
): void;
|
||||
/**
|
||||
* Save a rule object
|
||||
* @param rules
|
||||
* @param options
|
||||
* @param cb(err, res)
|
||||
*/
|
||||
batchRules(
|
||||
rules: AlgoliaRule[],
|
||||
options: RuleOption,
|
||||
cb: (err: Error, res: any) => void
|
||||
): void;
|
||||
/**
|
||||
* Delete a specific rule
|
||||
* @param identifier
|
||||
* @param options
|
||||
* @param cb(err, res)
|
||||
* https://github.com/algolia/algoliasearch-client-js#batch-rules---batchrules
|
||||
*/
|
||||
deleteRule(
|
||||
identifier: string,
|
||||
options: RuleOption,
|
||||
cb: (err: Error, res: any) => void
|
||||
): void;
|
||||
/**
|
||||
* Clear all rules of an index
|
||||
* @param options
|
||||
* @param cb(err, res)
|
||||
* https://github.com/algolia/algoliasearch-client-js#clear-all-rules---clearrules
|
||||
*/
|
||||
clearRules(options: RuleOption, cb: (err: Error, res: any) => void): void;
|
||||
/**
|
||||
* Get a specific rule
|
||||
* @param identifier
|
||||
* @param cb(err, res)
|
||||
* https://github.com/algolia/algoliasearch-client-js#get-rule---getrule
|
||||
*/
|
||||
getRule(identifier: string, cb: (err: Error, res: any) => void): void;
|
||||
/**
|
||||
* Search a rules
|
||||
* @param options
|
||||
* @param cb(err, res)
|
||||
* https://github.com/algolia/algoliasearch-client-js#search-rules---searchrules
|
||||
*/
|
||||
searchRules(
|
||||
options: SearchRuleOptions,
|
||||
cb: (err: Error, res: any) => void
|
||||
): void;
|
||||
/**
|
||||
* List index user keys
|
||||
* @param cb(err, res)
|
||||
@@ -712,7 +786,7 @@ declare namespace algoliasearch {
|
||||
* @param err() error callback
|
||||
* https://github.com/algolia/algoliasearch-client-js#search-in-an-index---search
|
||||
*/
|
||||
search(params: AlgoliaQueryParameters): Promise<any>;
|
||||
search(params: AlgoliaQueryParameters): Promise<AlgoliaResponse>;
|
||||
/**
|
||||
* Search in an index
|
||||
* @param params query parameter
|
||||
@@ -722,7 +796,7 @@ declare namespace algoliasearch {
|
||||
*/
|
||||
search(
|
||||
params: AlgoliaQueryParameters,
|
||||
cb: (err: Error, res: any) => void
|
||||
cb: (err: Error, res: AlgoliaResponse) => void
|
||||
): void;
|
||||
/**
|
||||
* Search in an index
|
||||
@@ -738,8 +812,7 @@ declare namespace algoliasearch {
|
||||
}: {
|
||||
facetName: string;
|
||||
facetQuery: string;
|
||||
qp: AlgoliaQueryParameters;
|
||||
}): Promise<any>;
|
||||
} & AlgoliaQueryParameters): Promise<any>;
|
||||
/**
|
||||
* Search in an index
|
||||
* @param params query parameter
|
||||
@@ -755,8 +828,7 @@ declare namespace algoliasearch {
|
||||
}: {
|
||||
facetName: string;
|
||||
facetQuery: string;
|
||||
qp: AlgoliaQueryParameters;
|
||||
},
|
||||
} & AlgoliaQueryParameters,
|
||||
cb: (err: Error, res: any) => void
|
||||
): void;
|
||||
/**
|
||||
@@ -846,6 +918,50 @@ declare namespace algoliasearch {
|
||||
* https://github.com/algolia/algoliasearch-client-js#search-synonyms---searchsynonyms
|
||||
*/
|
||||
searchSynonyms(options: SearchSynonymOptions): Promise<any>;
|
||||
/**
|
||||
* Save a rule object
|
||||
* @param rule
|
||||
* @param options
|
||||
* return {Promise}
|
||||
* https://github.com/algolia/algoliasearch-client-js#save-rule---saverule
|
||||
*/
|
||||
saveRule(rule: AlgoliaRule, options: RuleOption): Promise<any>;
|
||||
/**
|
||||
* Save a rule object
|
||||
* @param rules
|
||||
* @param options
|
||||
* return {Promise}
|
||||
*/
|
||||
batchRules(rules: AlgoliaRule[], options: RuleOption): Promise<any>;
|
||||
/**
|
||||
* Delete a specific rule
|
||||
* @param identifier
|
||||
* @param options
|
||||
* return {Promise}
|
||||
* https://github.com/algolia/algoliasearch-client-js#batch-rules---batchrules
|
||||
*/
|
||||
deleteRule(identifier: string, options: RuleOption): Promise<any>;
|
||||
/**
|
||||
* Clear all query rules of an index
|
||||
* @param options
|
||||
* return {Promise}
|
||||
* https://github.com/algolia/algoliasearch-client-js#clear-all-rules---clearrules
|
||||
*/
|
||||
clearRules(options: RuleOption): Promise<any>;
|
||||
/**
|
||||
* Get a specific query rule
|
||||
* @param identifier
|
||||
* return {Promise}
|
||||
* https://github.com/algolia/algoliasearch-client-js#get-rule---getrule
|
||||
*/
|
||||
getRule(identifier: string): Promise<any>;
|
||||
/**
|
||||
* Search for query rules
|
||||
* @param options
|
||||
* return {Promise}
|
||||
* https://github.com/algolia/algoliasearch-client-js#search-rules---searchrules
|
||||
*/
|
||||
searchRules(options: SearchRuleOptions): Promise<any>;
|
||||
/**
|
||||
* List index user keys
|
||||
* return {Promise}
|
||||
@@ -957,8 +1073,8 @@ Interface describing options available for gettings the logs
|
||||
type?: string;
|
||||
}
|
||||
/**
|
||||
* Describe the action object used for batch operation
|
||||
*/
|
||||
* Describe the action object used for batch operation
|
||||
*/
|
||||
interface AlgoliaAction {
|
||||
/**
|
||||
* Type of the batch action
|
||||
@@ -984,8 +1100,8 @@ Interface describing options available for gettings the logs
|
||||
body: {};
|
||||
}
|
||||
/**
|
||||
* Describes the option used when creating user key
|
||||
*/
|
||||
* Describes the option used when creating user key
|
||||
*/
|
||||
interface AlgoliaApiKeyOptions {
|
||||
/**
|
||||
* Add a validity period. The key will be valid for a specific period of time (in seconds).
|
||||
@@ -1024,8 +1140,8 @@ Interface describing options available for gettings the logs
|
||||
description?: string;
|
||||
}
|
||||
/**
|
||||
* Describes option used when making operation on synonyms
|
||||
*/
|
||||
* Describes option used when making operation on synonyms
|
||||
*/
|
||||
interface SynonymOption {
|
||||
/**
|
||||
* You can forward all settings updates to the replicas of an index
|
||||
@@ -1039,8 +1155,8 @@ Interface describing options available for gettings the logs
|
||||
replaceExistingSynonyms?: boolean;
|
||||
}
|
||||
/**
|
||||
* Describes options used when searching for synonyms
|
||||
*/
|
||||
* Describes options used when searching for synonyms
|
||||
*/
|
||||
interface SearchSynonymOptions {
|
||||
/**
|
||||
* The actual search query to find synonyms
|
||||
@@ -1049,7 +1165,7 @@ Interface describing options available for gettings the logs
|
||||
query?: string;
|
||||
/**
|
||||
* The page to fetch when browsing through several pages of results
|
||||
* default: 100
|
||||
* default: 0
|
||||
* https://github.com/algolia/algoliasearch-client-js#search-synonyms---searchsynonyms
|
||||
*/
|
||||
page?: number;
|
||||
@@ -1066,6 +1182,49 @@ Interface describing options available for gettings the logs
|
||||
*/
|
||||
hitsPerPage?: number;
|
||||
}
|
||||
/**
|
||||
* Describes option used when making operation on query rules
|
||||
*/
|
||||
interface RuleOption {
|
||||
/**
|
||||
* You can forward all settings updates to the replicas of an index
|
||||
* https://github.com/algolia/algoliasearch-client-js#replica-settings
|
||||
*/
|
||||
forwardToReplicas?: boolean;
|
||||
/**
|
||||
* Replace all existing query rules on the index with the content of the batch
|
||||
*/
|
||||
clearExistingRules?: boolean;
|
||||
}
|
||||
/**
|
||||
* Describes options used when searching for query rules
|
||||
*/
|
||||
interface SearchRuleOptions {
|
||||
/**
|
||||
* The actual search query to find synonyms
|
||||
*/
|
||||
query?: string;
|
||||
/**
|
||||
* When specified, restricts matches to rules with a specific anchoring type.
|
||||
* When omitted, all anchoring types may match.
|
||||
*/
|
||||
anchoring?: string;
|
||||
/**
|
||||
* When specified, restricts matches to contextual rules with a specific context (exact match).
|
||||
* When omitted, any generic or contextual rule (with any context) may match.
|
||||
*/
|
||||
context?: string;
|
||||
/**
|
||||
* Requested page (zero-based)
|
||||
* default: 0
|
||||
*/
|
||||
page?: number;
|
||||
/**
|
||||
* Number of hits per page
|
||||
* default: 20
|
||||
*/
|
||||
hitsPerPage?: number;
|
||||
}
|
||||
interface AlgoliaBrowseResponse {
|
||||
cursor?: string;
|
||||
hits: any[];
|
||||
@@ -1094,8 +1253,94 @@ Interface describing options available for gettings the logs
|
||||
synonyms: string[];
|
||||
}
|
||||
/**
|
||||
* Describes the options used when generating new api keys
|
||||
*/
|
||||
* Describes a query rule object
|
||||
*/
|
||||
interface AlgoliaRule {
|
||||
/**
|
||||
* ObjectID of the synonym
|
||||
* https://github.com/algolia/algoliasearch-client-js#save-synonym---savesynonym
|
||||
*/
|
||||
objectID: string;
|
||||
/**
|
||||
* Condition of the rule
|
||||
*/
|
||||
condition: {
|
||||
/**
|
||||
* Query pattern
|
||||
* syntax: https://www.algolia.com/doc/rest-api/query-rules/?language=php#query-pattern-syntax
|
||||
*/
|
||||
pattern: string;
|
||||
/**
|
||||
* Whether the pattern must match the beginning or the end of the query string, or both, or none.
|
||||
*/
|
||||
anchoring: 'is' | 'startsWith' | 'endsWith' | 'contains';
|
||||
/**
|
||||
* Rule context (format: [A-Za-z0-9_-]+).
|
||||
* When specified, the rule is contextual and applies only when the same context is specified
|
||||
* at query time (using the ruleContexts parameter).
|
||||
* When absent, the rule is generic and always applies
|
||||
* (provided that its other conditions are met, of course).
|
||||
*/
|
||||
context?: string;
|
||||
};
|
||||
/**
|
||||
* Consequence of the rule. At least one of the following must be used:
|
||||
*/
|
||||
consequence: {
|
||||
params?: {
|
||||
/**
|
||||
* When a string, it replaces the entire query string.
|
||||
* When an object, describes incremental edits to be made to the query string.
|
||||
*/
|
||||
query?:
|
||||
| string
|
||||
| {
|
||||
/**
|
||||
* Tokens (literals or placeholders) from the query pattern
|
||||
* that should be removed from the query string.
|
||||
*/
|
||||
remove: string[];
|
||||
};
|
||||
/**
|
||||
* Names of facets to which automatic filtering must be applied;
|
||||
* they must match the facet name of a facet value placeholder in the query pattern.
|
||||
*/
|
||||
automaticFacetFilters?: string[];
|
||||
/**
|
||||
* Same as automaticFacetFilters, but for optionalFacetFilters.
|
||||
* The same syntax as query parameters can be used to specify a score: facetName<score=1>.
|
||||
*/
|
||||
automaticOptionalFacetFilters?: string[];
|
||||
};
|
||||
/**
|
||||
* Objects to promote as hits. Each object must contain the following fields
|
||||
*/
|
||||
promote?: {
|
||||
/**
|
||||
* Unique identifier of the object to promote
|
||||
*/
|
||||
objectID: string;
|
||||
/**
|
||||
* Promoted rank for the object (zero-based)
|
||||
*/
|
||||
position: number;
|
||||
}[];
|
||||
/**
|
||||
* Custom JSON object that will be appended to the userData array in the response.
|
||||
* This object is not interpreted by the API. It is limited to 1kB of minified JSON.
|
||||
*/
|
||||
userData?: {};
|
||||
};
|
||||
/**
|
||||
* This field is intended for rule management purposes,
|
||||
* in particular to ease searching for rules and presenting them to human readers.
|
||||
* It is not interpreted by the API.
|
||||
*/
|
||||
description?: string;
|
||||
}
|
||||
/**
|
||||
* Describes the options used when generating new api keys
|
||||
*/
|
||||
interface AlgoliaSecuredApiOptions {
|
||||
/**
|
||||
* Filter the query with numeric, facet or/and tag filters
|
||||
@@ -1121,8 +1366,8 @@ Interface describing options available for gettings the logs
|
||||
}
|
||||
|
||||
/**
|
||||
* Describes the settings available for configure your index
|
||||
*/
|
||||
* Describes the settings available for configure your index
|
||||
*/
|
||||
interface AlgoliaIndexSettings {
|
||||
/**
|
||||
* The list of attributes you want index
|
||||
@@ -1527,7 +1772,7 @@ Interface describing options available for gettings the logs
|
||||
* You can specify aroundRadius=all if you want to compute the geo distance without filtering in a geo area
|
||||
* https://github.com/algolia/algoliasearch-client-js#aroundradius
|
||||
*/
|
||||
aroundRadius?: any;
|
||||
aroundRadius?: number | 'all';
|
||||
/**
|
||||
* Control the precision of a geo search
|
||||
* default: null
|
||||
@@ -1545,7 +1790,7 @@ Interface describing options available for gettings the logs
|
||||
* default: null
|
||||
* https://github.com/algolia/algoliasearch-client-js#insideboundingbox
|
||||
*/
|
||||
insideBoundingBox?: string;
|
||||
insideBoundingBox?: number[][];
|
||||
/**
|
||||
* Selects how the query words are interpreted
|
||||
* default: 'prefixLast'
|
||||
@@ -1560,7 +1805,7 @@ Interface describing options available for gettings the logs
|
||||
* defauly: ''
|
||||
* https://github.com/algolia/algoliasearch-client-js#insidepolygon
|
||||
*/
|
||||
insidePolygon?: string;
|
||||
insidePolygon?: number[][];
|
||||
/**
|
||||
* This option is used to select a strategy in order to avoid having an empty result page
|
||||
* default: 'none'
|
||||
|
||||
@@ -1,23 +1,16 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"algoliasearch-tests.ts"
|
||||
]
|
||||
}
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": ["es6"],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": ["../"],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": ["index.d.ts", "algoliasearch-tests.ts"]
|
||||
}
|
||||
|
||||
@@ -1,79 +1,79 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"adjacent-overload-signatures": false,
|
||||
"array-type": false,
|
||||
"arrow-return-shorthand": false,
|
||||
"ban-types": false,
|
||||
"callable-types": false,
|
||||
"comment-format": false,
|
||||
"dt-header": false,
|
||||
"eofline": false,
|
||||
"export-just-namespace": false,
|
||||
"import-spacing": false,
|
||||
"interface-name": false,
|
||||
"interface-over-type-literal": false,
|
||||
"jsdoc-format": false,
|
||||
"max-line-length": false,
|
||||
"member-access": false,
|
||||
"new-parens": false,
|
||||
"no-any-union": false,
|
||||
"no-boolean-literal-compare": false,
|
||||
"no-conditional-assignment": false,
|
||||
"no-consecutive-blank-lines": false,
|
||||
"no-construct": false,
|
||||
"no-declare-current-package": false,
|
||||
"no-duplicate-imports": false,
|
||||
"no-duplicate-variable": false,
|
||||
"no-empty-interface": false,
|
||||
"no-for-in-array": false,
|
||||
"no-inferrable-types": false,
|
||||
"no-internal-module": false,
|
||||
"no-irregular-whitespace": false,
|
||||
"no-mergeable-namespace": false,
|
||||
"no-misused-new": false,
|
||||
"no-namespace": false,
|
||||
"no-object-literal-type-assertion": false,
|
||||
"no-padding": false,
|
||||
"no-redundant-jsdoc": false,
|
||||
"no-redundant-jsdoc-2": false,
|
||||
"no-redundant-undefined": false,
|
||||
"no-reference-import": false,
|
||||
"no-relative-import-in-test": false,
|
||||
"no-self-import": false,
|
||||
"no-single-declare-module": false,
|
||||
"no-string-throw": false,
|
||||
"no-unnecessary-callback-wrapper": false,
|
||||
"no-unnecessary-class": false,
|
||||
"no-unnecessary-generics": false,
|
||||
"no-unnecessary-qualifier": false,
|
||||
"no-unnecessary-type-assertion": false,
|
||||
"no-useless-files": false,
|
||||
"no-var-keyword": false,
|
||||
"no-var-requires": false,
|
||||
"no-void-expression": false,
|
||||
"no-trailing-whitespace": false,
|
||||
"object-literal-key-quotes": false,
|
||||
"object-literal-shorthand": false,
|
||||
"one-line": false,
|
||||
"one-variable-per-declaration": false,
|
||||
"only-arrow-functions": false,
|
||||
"prefer-conditional-expression": false,
|
||||
"prefer-const": false,
|
||||
"prefer-declare-function": false,
|
||||
"prefer-for-of": false,
|
||||
"prefer-method-signature": false,
|
||||
"prefer-template": false,
|
||||
"radix": false,
|
||||
"semicolon": false,
|
||||
"space-before-function-paren": false,
|
||||
"space-within-parens": false,
|
||||
"strict-export-declare-modifiers": false,
|
||||
"trim-file": false,
|
||||
"triple-equals": false,
|
||||
"typedef-whitespace": false,
|
||||
"unified-signatures": false,
|
||||
"void-return": false,
|
||||
"whitespace": false
|
||||
}
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"adjacent-overload-signatures": false,
|
||||
"array-type": false,
|
||||
"arrow-return-shorthand": false,
|
||||
"ban-types": false,
|
||||
"callable-types": false,
|
||||
"comment-format": false,
|
||||
"dt-header": false,
|
||||
"eofline": false,
|
||||
"export-just-namespace": false,
|
||||
"import-spacing": false,
|
||||
"interface-name": false,
|
||||
"interface-over-type-literal": false,
|
||||
"jsdoc-format": false,
|
||||
"max-line-length": false,
|
||||
"member-access": false,
|
||||
"new-parens": false,
|
||||
"no-any-union": false,
|
||||
"no-boolean-literal-compare": false,
|
||||
"no-conditional-assignment": false,
|
||||
"no-consecutive-blank-lines": false,
|
||||
"no-construct": false,
|
||||
"no-declare-current-package": false,
|
||||
"no-duplicate-imports": false,
|
||||
"no-duplicate-variable": false,
|
||||
"no-empty-interface": false,
|
||||
"no-for-in-array": false,
|
||||
"no-inferrable-types": false,
|
||||
"no-internal-module": false,
|
||||
"no-irregular-whitespace": false,
|
||||
"no-mergeable-namespace": false,
|
||||
"no-misused-new": false,
|
||||
"no-namespace": false,
|
||||
"no-object-literal-type-assertion": false,
|
||||
"no-padding": false,
|
||||
"no-redundant-jsdoc": false,
|
||||
"no-redundant-jsdoc-2": false,
|
||||
"no-redundant-undefined": false,
|
||||
"no-reference-import": false,
|
||||
"no-relative-import-in-test": false,
|
||||
"no-self-import": false,
|
||||
"no-single-declare-module": false,
|
||||
"no-string-throw": false,
|
||||
"no-unnecessary-callback-wrapper": false,
|
||||
"no-unnecessary-class": false,
|
||||
"no-unnecessary-generics": false,
|
||||
"no-unnecessary-qualifier": false,
|
||||
"no-unnecessary-type-assertion": false,
|
||||
"no-useless-files": false,
|
||||
"no-var-keyword": false,
|
||||
"no-var-requires": false,
|
||||
"no-void-expression": false,
|
||||
"no-trailing-whitespace": false,
|
||||
"object-literal-key-quotes": false,
|
||||
"object-literal-shorthand": false,
|
||||
"one-line": false,
|
||||
"one-variable-per-declaration": false,
|
||||
"only-arrow-functions": false,
|
||||
"prefer-conditional-expression": false,
|
||||
"prefer-const": false,
|
||||
"prefer-declare-function": false,
|
||||
"prefer-for-of": false,
|
||||
"prefer-method-signature": false,
|
||||
"prefer-template": false,
|
||||
"radix": false,
|
||||
"semicolon": false,
|
||||
"space-before-function-paren": false,
|
||||
"space-within-parens": false,
|
||||
"strict-export-declare-modifiers": false,
|
||||
"trim-file": false,
|
||||
"triple-equals": false,
|
||||
"typedef-whitespace": false,
|
||||
"unified-signatures": false,
|
||||
"void-return": false,
|
||||
"whitespace": false
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+929
-45
File diff suppressed because it is too large
Load Diff
Vendored
+1
-1
@@ -63,4 +63,4 @@ export interface ConfirmChannel extends Channel {
|
||||
waitForConfirms(): Promise<void>;
|
||||
}
|
||||
|
||||
export function connect(url: string, socketOptions?: any): Promise<Connection>;
|
||||
export function connect(url: string | Options.Connect, socketOptions?: any): Promise<Connection>;
|
||||
|
||||
Vendored
+59
-1
@@ -21,6 +21,64 @@ export namespace Replies {
|
||||
}
|
||||
|
||||
export namespace Options {
|
||||
interface Connect {
|
||||
/**
|
||||
* The to be used protocol
|
||||
*
|
||||
* Default value: 'amqp'
|
||||
*/
|
||||
protocol?: string;
|
||||
/**
|
||||
* Hostname used for connecting to the server.
|
||||
*
|
||||
* Default value: 'localhost'
|
||||
*/
|
||||
hostname?: string;
|
||||
/**
|
||||
* Port used for connecting to the server.
|
||||
*
|
||||
* Default value: 5672
|
||||
*/
|
||||
port?: number;
|
||||
/**
|
||||
* Username used for authenticating against the server.
|
||||
*
|
||||
* Default value: 'guest'
|
||||
*/
|
||||
username?: string;
|
||||
/**
|
||||
* Password used for authenticating against the server.
|
||||
*
|
||||
* Default value: 'guest'
|
||||
*/
|
||||
password?: string;
|
||||
/**
|
||||
* The desired locale for error messages. RabbitMQ only ever uses en_US
|
||||
*
|
||||
* Default value: 'en_US'
|
||||
*/
|
||||
locale?: string;
|
||||
/**
|
||||
* The size in bytes of the maximum frame allowed over the connection. 0 means
|
||||
* no limit (but since frames have a size field which is an unsigned 32 bit integer, it’s perforce 2^32 - 1).
|
||||
*
|
||||
* Default value: 0x1000 (4kb) - That's the allowed minimum, it will fit many purposes
|
||||
*/
|
||||
frameMax?: number;
|
||||
/**
|
||||
* The period of the connection heartbeat in seconds.
|
||||
*
|
||||
* Default value: 0
|
||||
*/
|
||||
heartbeat?: number;
|
||||
/**
|
||||
* What VHost shall be used.
|
||||
*
|
||||
* Default value: '/'
|
||||
*/
|
||||
vhost?: string;
|
||||
}
|
||||
|
||||
interface AssertQueue {
|
||||
exclusive?: boolean;
|
||||
durable?: boolean;
|
||||
@@ -85,4 +143,4 @@ export interface Message {
|
||||
content: Buffer;
|
||||
fields: any;
|
||||
properties: any;
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -2,7 +2,7 @@
|
||||
// Project: http://angularjs.org
|
||||
// Definitions by: Michel Salib <https://github.com/michelsalib>, Adi Dahiya <https://github.com/adidahiya>, Raphael Schweizer <https://github.com/rasch>, Cody Schaaf <https://github.com/codyschaaf>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.1
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
declare var _: string;
|
||||
export = _;
|
||||
|
||||
Vendored
+1
-1
@@ -2,7 +2,7 @@
|
||||
// Project: https://github.com/nervgh/angular-file-upload
|
||||
// Definitions by: Cyril Gandon <https://github.com/cyrilgandon>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
import * as angular from 'angular';
|
||||
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
## What is it?
|
||||
|
||||
This is a typescript interface to be used with [angular-hotkeys](https://github.com/chieffancypants/angular-hotkeys/).
|
||||
|
||||
## What are declaration files?
|
||||
|
||||
See the [TypeScript handbook](http://www.typescriptlang.org/docs/handbook/declaration-files/introduction.html).
|
||||
|
||||
|
||||
## How do I get them?
|
||||
|
||||
### npm
|
||||
|
||||
This is the preferred method. This is only available for TypeScript 2.0+ users. For these typings:
|
||||
|
||||
```sh
|
||||
npm install --save-dev @types/angular-hotkeys
|
||||
```
|
||||
|
||||
The types should then be automatically included by the compiler.
|
||||
See more in the [handbook](http://www.typescriptlang.org/docs/handbook/declaration-files/consumption.html).
|
||||
|
||||
|
||||
### Other methods
|
||||
|
||||
These can be used by TypeScript 1.0.
|
||||
|
||||
* [Typings](https://github.com/typings/typings)
|
||||
* ~~[NuGet](http://nuget.org/Tpackages?q=DefinitelyTyped)~~ (use preferred alternatives, nuget DT type publishing has been turned off)
|
||||
* Manually download from the `master` branch of this repository
|
||||
|
||||
You may need to add manual [references](http://www.typescriptlang.org/docs/handbook/triple-slash-directives.html).
|
||||
|
||||
## How to use
|
||||
|
||||
After installing a package you can import the definition file and begin using it as so:
|
||||
|
||||
```ts
|
||||
|
||||
import * as hotkeys from '../../node_modules/@types/angular-hotkeys'
|
||||
|
||||
class FooController {
|
||||
static $inject = [
|
||||
'hotkeys'
|
||||
];
|
||||
|
||||
constructor(
|
||||
private hotkeys: ng.hotkeys.HotkeysProvider
|
||||
) { }
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
for a detailed explanation of the behavior of angular-hotkeys please refer to [its documentation](https://github.com/chieffancypants/angular-hotkeys/)
|
||||
|
||||
@@ -1,30 +1,67 @@
|
||||
var scope: ng.IScope;
|
||||
var hotkeyProvider: ng.hotkeys.HotkeysProvider;
|
||||
var hotkeyObj: ng.hotkeys.Hotkey;
|
||||
import { HotkeysProvider, Hotkey } from 'angular-hotkeys';
|
||||
import { module } from 'angular';
|
||||
|
||||
hotkeyProvider.add("mod+s", "saves a file", (event: Event, hotkey: ng.hotkeys.Hotkey) => {} );
|
||||
hotkeyProvider.add(["mod+s"], "saves a file", (event: Event, hotkey: ng.hotkeys.Hotkey) => {} );
|
||||
hotkeyProvider.add(hotkeyObj);
|
||||
hotkeyProvider.bindTo(scope);
|
||||
hotkeyProvider.del("mod+s");
|
||||
hotkeyProvider.del(["mod+s"]);
|
||||
hotkeyProvider.get("mod+s");
|
||||
hotkeyProvider.get(["mod+s"]);
|
||||
hotkeyProvider.toggleCheatSheet();
|
||||
|
||||
hotkeyProvider.add(hotkeyObj.combo, hotkeyObj.description ,hotkeyObj.callback);
|
||||
|
||||
hotkeyProvider.bindTo(scope)
|
||||
.add(hotkeyObj)
|
||||
.add(hotkeyObj)
|
||||
.add({
|
||||
combo: 'w',
|
||||
description: 'blah blah',
|
||||
callback: function() {}
|
||||
})
|
||||
.add({
|
||||
combo: ['w', 'mod+w'],
|
||||
description: 'blah blah',
|
||||
callback: function() {}
|
||||
module('myApp', ['cfp.hotkeys'])
|
||||
.config((hotkeysProvider: HotkeysProvider) => {
|
||||
hotkeysProvider.includeCheatSheet = false;
|
||||
const somehotKeyObj: Hotkey = {
|
||||
combo: '',
|
||||
callback: () => { }
|
||||
};
|
||||
});
|
||||
|
||||
function someInjectionService(
|
||||
scope: ng.IScope,
|
||||
hotkeyProvider: ng.hotkeys.HotkeysProvider,
|
||||
hotkeyObj: ng.hotkeys.Hotkey
|
||||
) {
|
||||
hotkeyProvider.add("mod+s", "saves a file", (event: Event, hotkey: ng.hotkeys.Hotkey) => { });
|
||||
hotkeyProvider.add(["mod+s"], "saves a file", (event: Event, hotkey: ng.hotkeys.Hotkey) => { });
|
||||
hotkeyProvider.add(hotkeyObj);
|
||||
hotkeyProvider.bindTo(scope);
|
||||
hotkeyProvider.del("mod+s");
|
||||
hotkeyProvider.del(["mod+s"]);
|
||||
hotkeyProvider.get("mod+s");
|
||||
hotkeyProvider.get(["mod+s"]);
|
||||
hotkeyProvider.toggleCheatSheet();
|
||||
|
||||
hotkeyProvider.add(hotkeyObj.combo, hotkeyObj.description, hotkeyObj.callback);
|
||||
|
||||
hotkeyProvider.bindTo(scope)
|
||||
.add(hotkeyObj)
|
||||
.add(hotkeyObj)
|
||||
.add({
|
||||
combo: 'w',
|
||||
description: 'blah blah',
|
||||
callback: () => { }
|
||||
})
|
||||
.add({
|
||||
combo: ['w', 'mod+w'],
|
||||
description: 'blah blah',
|
||||
callback: () => { }
|
||||
});
|
||||
|
||||
hotkeyProvider.add({
|
||||
combo: 'ctrl+w',
|
||||
description: 'Description goes here',
|
||||
callback: (event, hotkey) => {
|
||||
event.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
hotkeyProvider.add({
|
||||
combo: 'ctrl+x',
|
||||
callback: (event, hotkey) => {
|
||||
//
|
||||
}
|
||||
});
|
||||
|
||||
hotkeyProvider.add({
|
||||
combo: 'ctrl+w',
|
||||
description: 'Description goes here',
|
||||
allowIn: ['INPUT', 'SELECT', 'TEXTAREA'],
|
||||
callback(event, hotkey) {
|
||||
event.preventDefault();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Vendored
+99
-24
@@ -1,12 +1,10 @@
|
||||
// Type definitions for angular-hotkeys
|
||||
// Type definitions for angular-hotkeys 1.7
|
||||
// Project: https://github.com/chieffancypants/angular-hotkeys
|
||||
// Definitions by: Jason Zhao <https://github.com/jlz27>, Stefan Steinhart <https://github.com/reppners>
|
||||
// Definitions by: Jason Zhao <https://github.com/jlz27>
|
||||
// Stefan Steinhart <https://github.com/reppners>
|
||||
// Cyril Gandon <https://github.com/cyrilgandon>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
//readme written by David Valentine <https://github.com/dvalenti314>
|
||||
|
||||
|
||||
/// <reference types="angular" />
|
||||
|
||||
import * as ng from 'angular';
|
||||
|
||||
@@ -15,46 +13,123 @@ export type HotkeysProviderChained = ng.hotkeys.HotkeysProviderChained;
|
||||
export type Hotkey = ng.hotkeys.Hotkey;
|
||||
|
||||
declare module 'angular' {
|
||||
export namespace hotkeys {
|
||||
|
||||
namespace hotkeys {
|
||||
interface HotkeysProvider {
|
||||
template: string;
|
||||
templateTitle: string;
|
||||
/**
|
||||
* Configurable setting to disable the cheatsheet entirely.
|
||||
* @default true
|
||||
*/
|
||||
includeCheatSheet: boolean;
|
||||
/**
|
||||
* Configurable setting to disable ngRoute hooks.
|
||||
*/
|
||||
useNgRoute: boolean;
|
||||
/**
|
||||
* Configurable setting for the cheat sheet title
|
||||
* @default 'Keyboard Shortcuts'
|
||||
*/
|
||||
templateTitle: string;
|
||||
/**
|
||||
* Configurable settings for the cheat sheet header in HTML.
|
||||
* This overrides the normal title if specified.
|
||||
* @default null
|
||||
*/
|
||||
templateHeader: string | null;
|
||||
/**
|
||||
* Configurable settings for the cheat sheet footer in HTML.
|
||||
* @default null
|
||||
*/
|
||||
templateFooter: string | null;
|
||||
/**
|
||||
* Cheat sheet template in the event you want to totally customize it.
|
||||
*/
|
||||
template: string;
|
||||
/**
|
||||
* Configurable setting for the cheat sheet hotkey.
|
||||
* @default '?'
|
||||
*/
|
||||
cheatSheetHotkey: string;
|
||||
/**
|
||||
* Configurable setting for the cheat sheet description.
|
||||
* @default 'Show / hide this help menu'
|
||||
*/
|
||||
cheatSheetDescription: string;
|
||||
|
||||
add(combo: string | string[], callback: (event: Event, hotkey?: Hotkey) => void, action?: string, allowIn?: Array<string>, persistent?: boolean): ng.hotkeys.Hotkey;
|
||||
/**
|
||||
* Creates a new Hotkey and creates the Mousetrap binding.
|
||||
*/
|
||||
add(combo: string | string[], description?: string, callback?: (event: Event, hotkey: Hotkey) => void, action?: string, allowIn?: string[], persistent?: boolean): Hotkey;
|
||||
|
||||
add(combo: string | string[], description: string, callback: (event: Event, hotkey?: Hotkey) => void, action?: string, allowIn?: Array<string>, persistent?: boolean): ng.hotkeys.Hotkey;
|
||||
/**
|
||||
* Creates a new Hotkey and creates the Mousetrap binding.
|
||||
*/
|
||||
add(hotkeyObj: Hotkey): Hotkey;
|
||||
|
||||
add(hotkeyObj: ng.hotkeys.Hotkey): ng.hotkeys.Hotkey;
|
||||
/**
|
||||
* Binds the hotkey to a particular scope.
|
||||
* Useful if the scope is destroyed, we can automatically destroy the hotkey binding.
|
||||
* @param scope The scope to bind to
|
||||
*/
|
||||
bindTo(scope: IScope): HotkeysProviderChained;
|
||||
|
||||
bindTo(scope: ng.IScope): ng.hotkeys.HotkeysProviderChained;
|
||||
/**
|
||||
* Removes and unbinds a hotkey
|
||||
* @param combo The keyboard combo (shortcut) or the HotKey object
|
||||
*/
|
||||
del(combo: string | string[] | Hotkey): void;
|
||||
|
||||
del(combo: string | string[]): void;
|
||||
|
||||
del(hotkeyObj: ng.hotkeys.Hotkey): void;
|
||||
|
||||
get(combo: string | string[]): ng.hotkeys.Hotkey;
|
||||
/**
|
||||
* Returns the Hotkey object
|
||||
* @param combo The keyboard combo (shortcut)
|
||||
*/
|
||||
get(combo: string | string[]): Hotkey;
|
||||
|
||||
/**
|
||||
* Toggles the help menu element's visiblity
|
||||
*/
|
||||
toggleCheatSheet(): void;
|
||||
|
||||
/**
|
||||
* Purges all non-persistent hotkeys (such as those defined in routes)
|
||||
*
|
||||
* Without this, the same hotkey would get recreated everytime
|
||||
* the route is accessed.
|
||||
*/
|
||||
purgeHotkeys(): void;
|
||||
}
|
||||
|
||||
interface HotkeysProviderChained {
|
||||
add(combo: string | string[], description: string, callback: (event: Event, hotkeys: ng.hotkeys.Hotkey) => void): HotkeysProviderChained;
|
||||
add(combo: string | string[], description: string, callback: (event: Event, hotkeys: Hotkey) => void): HotkeysProviderChained;
|
||||
|
||||
add(hotkeyObj: ng.hotkeys.Hotkey): HotkeysProviderChained;
|
||||
add(hotkeyObj: Hotkey): HotkeysProviderChained;
|
||||
}
|
||||
|
||||
interface Hotkey {
|
||||
/**
|
||||
* They keyboard combo (shortcut) you want to bind to.
|
||||
*/
|
||||
combo: string | string[];
|
||||
/**
|
||||
* The description for what the combo does and is only used for the Cheat Sheet.
|
||||
* If it is not supplied, it will not show up, and in effect, allows you to have unlisted hotkeys.
|
||||
*/
|
||||
description?: string;
|
||||
callback: (event: Event, hotkey: ng.hotkeys.Hotkey) => void;
|
||||
/**
|
||||
* The function to execute when the key(s) are pressed. Passes along two arguments, event and hotkey
|
||||
*/
|
||||
callback(event: Event, hotkey: Hotkey): void;
|
||||
/**
|
||||
* The type of event to listen for, such as keypress, keydown or keyup.
|
||||
* Usage of this parameter is discouraged as the underlying library will pick the most suitable option automatically.
|
||||
* This should only be necessary in advanced situations.
|
||||
*/
|
||||
action?: string;
|
||||
allowIn?: Array<string>;
|
||||
/**
|
||||
* An array of tag names to allow this combo in ('INPUT', 'SELECT', and/or 'TEXTAREA')
|
||||
*/
|
||||
allowIn?: Array<'INPUT' | 'SELECT' | 'TEXTAREA'>;
|
||||
/**
|
||||
* Whether the hotkey persists navigation events
|
||||
*/
|
||||
persistent?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
@@ -21,4 +21,4 @@
|
||||
"index.d.ts",
|
||||
"angular-hotkeys-tests.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,79 +1 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"adjacent-overload-signatures": false,
|
||||
"array-type": false,
|
||||
"arrow-return-shorthand": false,
|
||||
"ban-types": false,
|
||||
"callable-types": false,
|
||||
"comment-format": false,
|
||||
"dt-header": false,
|
||||
"eofline": false,
|
||||
"export-just-namespace": false,
|
||||
"import-spacing": false,
|
||||
"interface-name": false,
|
||||
"interface-over-type-literal": false,
|
||||
"jsdoc-format": false,
|
||||
"max-line-length": false,
|
||||
"member-access": false,
|
||||
"new-parens": false,
|
||||
"no-any-union": false,
|
||||
"no-boolean-literal-compare": false,
|
||||
"no-conditional-assignment": false,
|
||||
"no-consecutive-blank-lines": false,
|
||||
"no-construct": false,
|
||||
"no-declare-current-package": false,
|
||||
"no-duplicate-imports": false,
|
||||
"no-duplicate-variable": false,
|
||||
"no-empty-interface": false,
|
||||
"no-for-in-array": false,
|
||||
"no-inferrable-types": false,
|
||||
"no-internal-module": false,
|
||||
"no-irregular-whitespace": false,
|
||||
"no-mergeable-namespace": false,
|
||||
"no-misused-new": false,
|
||||
"no-namespace": false,
|
||||
"no-object-literal-type-assertion": false,
|
||||
"no-padding": false,
|
||||
"no-redundant-jsdoc": false,
|
||||
"no-redundant-jsdoc-2": false,
|
||||
"no-redundant-undefined": false,
|
||||
"no-reference-import": false,
|
||||
"no-relative-import-in-test": false,
|
||||
"no-self-import": false,
|
||||
"no-single-declare-module": false,
|
||||
"no-string-throw": false,
|
||||
"no-unnecessary-callback-wrapper": false,
|
||||
"no-unnecessary-class": false,
|
||||
"no-unnecessary-generics": false,
|
||||
"no-unnecessary-qualifier": false,
|
||||
"no-unnecessary-type-assertion": false,
|
||||
"no-useless-files": false,
|
||||
"no-var-keyword": false,
|
||||
"no-var-requires": false,
|
||||
"no-void-expression": false,
|
||||
"no-trailing-whitespace": false,
|
||||
"object-literal-key-quotes": false,
|
||||
"object-literal-shorthand": false,
|
||||
"one-line": false,
|
||||
"one-variable-per-declaration": false,
|
||||
"only-arrow-functions": false,
|
||||
"prefer-conditional-expression": false,
|
||||
"prefer-const": false,
|
||||
"prefer-declare-function": false,
|
||||
"prefer-for-of": false,
|
||||
"prefer-method-signature": false,
|
||||
"prefer-template": false,
|
||||
"radix": false,
|
||||
"semicolon": false,
|
||||
"space-before-function-paren": false,
|
||||
"space-within-parens": false,
|
||||
"strict-export-declare-modifiers": false,
|
||||
"trim-file": false,
|
||||
"triple-equals": false,
|
||||
"typedef-whitespace": false,
|
||||
"unified-signatures": false,
|
||||
"void-return": false,
|
||||
"whitespace": false
|
||||
}
|
||||
}
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
|
||||
@@ -5,6 +5,7 @@ interface TestScope extends ng.IScope {
|
||||
}
|
||||
|
||||
myApp.config((
|
||||
$mdAriaProvider: ng.material.IAriaProvider,
|
||||
$mdThemingProvider: ng.material.IThemingProvider,
|
||||
$mdIconProvider: ng.material.IIconProvider,
|
||||
$mdProgressCircularProvider: ng.material.IProgressCircularProvider) => {
|
||||
@@ -52,6 +53,9 @@ myApp.config((
|
||||
return c * Math.pow(2, (t / d - 1) * 10) + b;
|
||||
}
|
||||
});
|
||||
|
||||
// Globally disables all ARIA warnings.
|
||||
$mdAriaProvider.disableWarnings();
|
||||
});
|
||||
|
||||
myApp.controller('BottomSheetController', ($scope: TestScope, $mdBottomSheet: ng.material.IBottomSheetService, $q: ng.IQService) => {
|
||||
@@ -136,6 +140,9 @@ myApp.controller('DialogController', ($scope: TestScope, $mdDialog: ng.material.
|
||||
$scope['promptDialog'] = () => {
|
||||
$mdDialog.show($mdDialog.prompt().initialValue('Buddy'));
|
||||
};
|
||||
$scope['promptDialog'] = () => {
|
||||
$mdDialog.show($mdDialog.prompt().required(true));
|
||||
};
|
||||
$scope['prerenderedDialog'] = () => {
|
||||
$mdDialog.show({
|
||||
template: '<md-dialog>Hello!</md-dialog>',
|
||||
|
||||
Vendored
+6
-1
@@ -1,6 +1,6 @@
|
||||
// Type definitions for angular-material 1.1
|
||||
// Project: https://github.com/angular/material
|
||||
// Definitions by: Blake Bigelow <https://github.com/blbigelow>, Peter Hajdu <https://github.com/PeterHajdu>, Davide Donadello <https://github.com/Dona278>, Geert Jansen <https://github.com/geertjansen>
|
||||
// Definitions by: Blake Bigelow <https://github.com/blbigelow>, Peter Hajdu <https://github.com/PeterHajdu>, Davide Donadello <https://github.com/Dona278>, Geert Jansen <https://github.com/geertjansen>, Edward Knowles <https://github.com/eknowles>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
@@ -11,6 +11,10 @@ export = _;
|
||||
|
||||
declare module 'angular' {
|
||||
namespace material {
|
||||
interface IAriaProvider {
|
||||
disableWarnings(): void;
|
||||
}
|
||||
|
||||
interface ResolveObject {
|
||||
[name: string]: Injectable<(...args: any[]) => PromiseLike<any>>;
|
||||
}
|
||||
@@ -76,6 +80,7 @@ declare module 'angular' {
|
||||
|
||||
interface IPromptDialog extends IPresetDialog<IPromptDialog> {
|
||||
cancel(cancel: string): IPromptDialog;
|
||||
required(required: boolean): IPromptDialog; // default: false
|
||||
placeholder(placeholder: string): IPromptDialog;
|
||||
initialValue(initialValue: string): IPromptDialog;
|
||||
}
|
||||
|
||||
@@ -45,9 +45,9 @@ function withContainerAsString() {
|
||||
});
|
||||
}
|
||||
|
||||
// With container as jQuery element
|
||||
// With container as jQuery/JQLite element
|
||||
function withContainerAsJquery() {
|
||||
var container: JQuery = $('body');
|
||||
var container: JQuery = angular.element('body');
|
||||
btfModal({
|
||||
template: '<div></div>',
|
||||
container: container
|
||||
@@ -94,6 +94,10 @@ function callingValues() {
|
||||
template: '<div></div>'
|
||||
});
|
||||
modal.activate().then(() => {}, () => {});
|
||||
// activating with random locals
|
||||
modal.activate({name: 'TestName'}).then(() => {}, () => {});
|
||||
// activating with genericly typed locals
|
||||
modal.activate<{name: string}>({name: 'TestName'}).then(() => {}, () => {});
|
||||
modal.deactivate().then(() => {}, () => {});
|
||||
var isActive: boolean = modal.active();
|
||||
}
|
||||
|
||||
Vendored
+2
-2
@@ -5,7 +5,6 @@
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
/// <reference types="angular" />
|
||||
/// <reference types="jquery" />
|
||||
|
||||
declare namespace angularModal {
|
||||
|
||||
@@ -28,7 +27,8 @@ declare namespace angularModal {
|
||||
}
|
||||
|
||||
export interface AngularModal {
|
||||
activate(): angular.IPromise<void>;
|
||||
activate(locals?: {}): angular.IPromise<void>;
|
||||
activate<T>(locals: T): angular.IPromise<void>;
|
||||
deactivate(): angular.IPromise<void>;
|
||||
active(): boolean;
|
||||
}
|
||||
|
||||
@@ -4,5 +4,6 @@ declare var $sanitizeService: ng.sanitize.ISanitizeService;
|
||||
shouldBeString = $sanitizeService(shouldBeString);
|
||||
|
||||
declare var $linky: ng.sanitize.filter.ILinky;
|
||||
shouldBeString = $linky(shouldBeString);
|
||||
shouldBeString = $linky(shouldBeString, "target");
|
||||
shouldBeString = $linky(shouldBeString, shouldBeString);
|
||||
|
||||
Vendored
+1
-1
@@ -36,7 +36,7 @@ declare module 'angular' {
|
||||
* see https://docs.angularjs.org/api/ngSanitize/filter/linky
|
||||
*/
|
||||
interface ILinky {
|
||||
(text: string, target: string, attributes?: { [attribute: string]: string } | ((url: string) => { [attribute: string]: string })): string;
|
||||
(text: string, target?: string, attributes?: { [attribute: string]: string } | ((url: string) => { [attribute: string]: string })): string;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Vendored
+4
-1
@@ -6,10 +6,13 @@
|
||||
|
||||
/// <reference types="angular" />
|
||||
|
||||
declare var _: string;
|
||||
export = _;
|
||||
|
||||
import * as angular from 'angular';
|
||||
|
||||
declare module 'angular' {
|
||||
export namespace a0.storage {
|
||||
namespace a0.storage {
|
||||
interface IStoreService extends INamespacedStoreService {
|
||||
/**
|
||||
* Returns a namespaced store
|
||||
|
||||
Vendored
+1
@@ -2,6 +2,7 @@
|
||||
// Project: http://720kb.github.io/angular-tooltips
|
||||
// Definitions by: Leonard Thieu <https://github.com/leonard-thieu>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
declare const AngularTooltips: '720kb.tooltips';
|
||||
export = AngularTooltips;
|
||||
|
||||
@@ -1,69 +1,62 @@
|
||||
let dummySocket: ng.websocket.IWebSocket;
|
||||
let dummyPromise: ng.IPromise<void>;
|
||||
let dummyScope: ng.IScope;
|
||||
import * as ng from 'angular';
|
||||
|
||||
let provider: ng.websocket.IWebSocketProvider = (url: string, protocols?:string[] | ng.websocket.IWebSocketConfigOptions, options?: ng.websocket.IWebSocketConfigOptions) => {
|
||||
return dummySocket;
|
||||
}
|
||||
(promise: angular.IPromise<void>, scope: ng.IScope, provider: ng.websocket.IWebSocketProvider) => {
|
||||
const socket = provider("wss://localhost");
|
||||
const socketWithProtocols = provider("wss://localhost", ["protocol-a", "protocol-b"]);
|
||||
|
||||
let socketWithProtocol = provider("wss://localhost", "protocol");
|
||||
let socketWithProtocols = provider("wss://localhost", ["protocol-a", "protocol-b"]);
|
||||
const socketWithOptions = provider("wss://localhost", {
|
||||
scope,
|
||||
rootScopeFailOver: true,
|
||||
useApplyAsync: true,
|
||||
initialTimeout: 100,
|
||||
maxTimeout: 300000,
|
||||
reconnectIfNotNormalClose: true,
|
||||
binaryType: "blob"
|
||||
});
|
||||
|
||||
let socketWithOptions = provider("wss://localhost", {
|
||||
scope: dummyScope,
|
||||
rootScopeFailOver: true,
|
||||
useApplyAsync: true,
|
||||
initialTimeout: 100,
|
||||
maxTimeout: 300000,
|
||||
reconnectIfNotNormalClose: true,
|
||||
binaryType: "blob"
|
||||
});
|
||||
const socketWithProtocolAndOptions = provider("wss://localhost", "protocol", {
|
||||
scope,
|
||||
rootScopeFailOver: true,
|
||||
useApplyAsync: true,
|
||||
initialTimeout: 100,
|
||||
maxTimeout: 300000,
|
||||
reconnectIfNotNormalClose: true,
|
||||
binaryType: "blob"
|
||||
});
|
||||
|
||||
let socketWithProtocolAndOptions = provider("wss://localhost", "protocol", {
|
||||
scope: dummyScope,
|
||||
rootScopeFailOver: true,
|
||||
useApplyAsync: true,
|
||||
initialTimeout: 100,
|
||||
maxTimeout: 300000,
|
||||
reconnectIfNotNormalClose: true,
|
||||
binaryType: "blob"
|
||||
});
|
||||
socket.onOpen((event: Event) => {})
|
||||
.onClose((event: Event) => {})
|
||||
.onError((event: Event) => {})
|
||||
.onMessage((event: Event) => {});
|
||||
|
||||
let socket = provider("wss://localhost");
|
||||
socket.onMessage((event: Event) => {}, { filter: /Some Filter/ })
|
||||
.onMessage((event: Event) => {}, { filter: 'Some Filter' })
|
||||
.onMessage((event: Event) => {}, { filter: 'Some Filter', autoApply: true })
|
||||
.onMessage((event: Event) => {}, { autoApply: false });
|
||||
|
||||
socket.onOpen((event) => {})
|
||||
.onClose((event) => {})
|
||||
.onError((event) => {})
|
||||
.onMessage((event) => {});
|
||||
socket.close(true);
|
||||
socket.close();
|
||||
|
||||
socket.onMessage((event) => {}, { filter: /Some Filter/ })
|
||||
.onMessage((event) => {}, { filter: 'Some Filter' })
|
||||
.onMessage((event) => {}, { filter: 'Some Filter', autoApply: true })
|
||||
.onMessage((event) => {}, { autoApply: false });
|
||||
socket.send("Some great data here!").finally(() => {});
|
||||
socket.send({ list: [1, 2, 3, 4] });
|
||||
|
||||
socket.close(true);
|
||||
socket.close();
|
||||
socket.socket.send("data");
|
||||
socket.socket.close();
|
||||
socket.socket.close(1);
|
||||
socket.socket.close(1, "reason");
|
||||
|
||||
socket.send("Some great data here!").finally(() => {});
|
||||
socket.send({ list: [1, 2, 3, 4] });
|
||||
socket.sendQueue.push({ message: "msg", defered: promise });
|
||||
|
||||
socket.socket.send("data");
|
||||
socket.socket.close();
|
||||
socket.socket.close(1);
|
||||
socket.socket.close(1, "reason");
|
||||
socket.onOpenCallbacks.push((event: Event) => {});
|
||||
socket.onCloseCallbacks.push((event: CloseEvent) => {});
|
||||
socket.onErrorCallbacks.push((event: Event) => {});
|
||||
socket.onMessageCallbacks.push({ fn: (event: MessageEvent) => {}, pattern: 'Some Filter', autoApply: true });
|
||||
socket.onMessageCallbacks.push({ fn: (event: MessageEvent) => {}, pattern: /Some Filter/, autoApply: true });
|
||||
socket.onMessageCallbacks.push({ fn: (event: MessageEvent) => {}, autoApply: true });
|
||||
|
||||
socket.sendQueue.push({ message: "msg", defered: dummyPromise });
|
||||
socket.readyState = 0;
|
||||
|
||||
socket.onOpenCallbacks.push((event: Event) => {});
|
||||
socket.onCloseCallbacks.push((event: CloseEvent) => {});
|
||||
socket.onErrorCallbacks.push((event: Event) => {});
|
||||
socket.onMessageCallbacks.push({ fn: (event: MessageEvent) => {}, pattern: 'Some Filter', autoApply: true });
|
||||
socket.onMessageCallbacks.push({ fn: (event: MessageEvent) => {}, pattern: /Some Filter/, autoApply: true });
|
||||
socket.onMessageCallbacks.push({ fn: (event: MessageEvent) => {}, pattern: undefined, autoApply: true });
|
||||
|
||||
socket.readyState = 0;
|
||||
|
||||
socket.initialTimeout = 10;
|
||||
|
||||
socket.maxTimeout = 5000;
|
||||
socket.initialTimeout = 10;
|
||||
|
||||
socket.maxTimeout = 5000;
|
||||
};
|
||||
|
||||
Vendored
+40
-35
@@ -1,39 +1,45 @@
|
||||
// Type definitions for angular-websocket v2.0
|
||||
// Type definitions for angular-websocket 2.0
|
||||
// Project: https://github.com/AngularClass/angular-websocket
|
||||
// Definitions by: Nick Veys <https://github.com/nickveys>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
import * as ng from "angular";
|
||||
import * as angular from "angular";
|
||||
|
||||
export type IWebSocketConfigOptions = angular.websocket.IWebSocketConfigOptions;
|
||||
export type IWebSocketProvider = angular.websocket.IWebSocketProvider;
|
||||
export type IWebSocketMessageOptions = angular.websocket.IWebSocketMessageOptions;
|
||||
export type IWebSocketMessageHandler = angular.websocket.IWebSocketMessageHandler;
|
||||
export type IWebSocketQueueItem = angular.websocket.IWebSocketQueueItem;
|
||||
export type IWebSocket = angular.websocket.IWebSocket;
|
||||
|
||||
declare module "angular" {
|
||||
namespace websocket {
|
||||
|
||||
/**
|
||||
* Options available to be specified for IWebSocketProvider.
|
||||
*/
|
||||
type IWebSocketConfigOptions = {
|
||||
scope?: ng.IScope;
|
||||
rootScopeFailOver?: boolean;
|
||||
useApplyAsync?: boolean;
|
||||
initialTimeout?: number;
|
||||
maxTimeout?: number;
|
||||
binaryType?: "blob" | "arraybuffer";
|
||||
reconnectIfNotNormalClose?: boolean;
|
||||
}
|
||||
interface IWebSocketProvider {
|
||||
/**
|
||||
* Creates and opens an IWebSocket instance.
|
||||
*
|
||||
* @param url url to connect to
|
||||
* @return websocket instance
|
||||
*/
|
||||
(url: string, protocols?: string | string[] | IWebSocketConfigOptions, options?: IWebSocketConfigOptions): IWebSocket;
|
||||
interface IWebSocketConfigOptions {
|
||||
scope?: IScope;
|
||||
rootScopeFailOver?: boolean;
|
||||
useApplyAsync?: boolean;
|
||||
initialTimeout?: number;
|
||||
maxTimeout?: number;
|
||||
binaryType?: "blob" | "arraybuffer";
|
||||
reconnectIfNotNormalClose?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and opens an IWebSocket instance.
|
||||
*
|
||||
* @param url url to connect to
|
||||
* @return websocket instance
|
||||
*/
|
||||
type IWebSocketProvider =
|
||||
(url: string, protocols?: string | string[] | IWebSocketConfigOptions,
|
||||
options?: IWebSocketConfigOptions) => IWebSocket;
|
||||
|
||||
/** Options available to be specified for IWebSocket.onMessage */
|
||||
type IWebSocketMessageOptions = {
|
||||
|
||||
interface IWebSocketMessageOptions {
|
||||
/**
|
||||
* If specified, only messages that match the filter will cause the message event
|
||||
* to be fired.
|
||||
@@ -44,21 +50,20 @@ declare module "angular" {
|
||||
autoApply?: boolean;
|
||||
}
|
||||
|
||||
/** Type corresponding to onMessage callbaks stored in $Websocket#onMessageCallbacks instance. */
|
||||
type IWebSocketMessageHandler = {
|
||||
fn: (evt: MessageEvent) => void;
|
||||
pattern: string | RegExp;
|
||||
autoApply: boolean;
|
||||
/** Type corresponding to onMessage callbacks stored in $Websocket#onMessageCallbacks instance. */
|
||||
interface IWebSocketMessageHandler {
|
||||
fn: (evt: MessageEvent) => void;
|
||||
pattern?: string | RegExp;
|
||||
autoApply: boolean;
|
||||
}
|
||||
|
||||
/** Type corresponding to items stored in $WebSocket#sendQueue instance. */
|
||||
type IWebSocketQueueItem = {
|
||||
message: any;
|
||||
defered: ng.IPromise<void>;
|
||||
interface IWebSocketQueueItem {
|
||||
message: any;
|
||||
defered: IPromise<void>;
|
||||
}
|
||||
|
||||
interface IWebSocket {
|
||||
|
||||
/**
|
||||
* Adds a callback to be executed each time a socket connection is opened for
|
||||
* this instance.
|
||||
@@ -108,7 +113,7 @@ declare module "angular" {
|
||||
*
|
||||
* @param data data to send, if this is an object, it will be stringified before sending
|
||||
*/
|
||||
send(data: string | {}): ng.IPromise<any>;
|
||||
send(data: string | {}): IPromise<any>;
|
||||
|
||||
/**
|
||||
* WebSocket instance.
|
||||
@@ -123,7 +128,7 @@ declare module "angular" {
|
||||
/**
|
||||
* List of callbacks to be executed when the socket is opened.
|
||||
*/
|
||||
onOpenCallbacks: ((evt: Event) => void)[];
|
||||
onOpenCallbacks: Array<((evt: Event) => void)>;
|
||||
|
||||
/**
|
||||
* List of callbacks to be executed when a message is received from the socket.
|
||||
@@ -133,12 +138,12 @@ declare module "angular" {
|
||||
/**
|
||||
* List of callbacks to be executed when an error is received from the socket.
|
||||
*/
|
||||
onErrorCallbacks: ((evt: Event) => void)[];
|
||||
onErrorCallbacks: Array<((evt: Event) => void)>;
|
||||
|
||||
/**
|
||||
* List of callbacks to be executed when the socket is closed.
|
||||
*/
|
||||
onCloseCallbacks: ((evt: CloseEvent) => void)[];
|
||||
onCloseCallbacks: Array<((evt: CloseEvent) => void)>;
|
||||
|
||||
/**
|
||||
* Returns either the readyState value from the underlying WebSocket instance
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
{
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"angular-websocket-tests.ts"
|
||||
],
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
@@ -11,8 +7,8 @@
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"strictFunctionTypes": false,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
@@ -20,5 +16,9 @@
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"angular-websocket-tests.ts"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,79 +1,6 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"adjacent-overload-signatures": false,
|
||||
"array-type": false,
|
||||
"arrow-return-shorthand": false,
|
||||
"ban-types": false,
|
||||
"callable-types": false,
|
||||
"comment-format": false,
|
||||
"dt-header": false,
|
||||
"eofline": false,
|
||||
"export-just-namespace": false,
|
||||
"import-spacing": false,
|
||||
"interface-name": false,
|
||||
"interface-over-type-literal": false,
|
||||
"jsdoc-format": false,
|
||||
"max-line-length": false,
|
||||
"member-access": false,
|
||||
"new-parens": false,
|
||||
"no-any-union": false,
|
||||
"no-boolean-literal-compare": false,
|
||||
"no-conditional-assignment": false,
|
||||
"no-consecutive-blank-lines": false,
|
||||
"no-construct": false,
|
||||
"no-declare-current-package": false,
|
||||
"no-duplicate-imports": false,
|
||||
"no-duplicate-variable": false,
|
||||
"no-empty-interface": false,
|
||||
"no-for-in-array": false,
|
||||
"no-inferrable-types": false,
|
||||
"no-internal-module": false,
|
||||
"no-irregular-whitespace": false,
|
||||
"no-mergeable-namespace": false,
|
||||
"no-misused-new": false,
|
||||
"no-namespace": false,
|
||||
"no-object-literal-type-assertion": false,
|
||||
"no-padding": false,
|
||||
"no-redundant-jsdoc": false,
|
||||
"no-redundant-jsdoc-2": false,
|
||||
"no-redundant-undefined": false,
|
||||
"no-reference-import": false,
|
||||
"no-relative-import-in-test": false,
|
||||
"no-self-import": false,
|
||||
"no-single-declare-module": false,
|
||||
"no-string-throw": false,
|
||||
"no-unnecessary-callback-wrapper": false,
|
||||
"no-unnecessary-class": false,
|
||||
"no-unnecessary-generics": false,
|
||||
"no-unnecessary-qualifier": false,
|
||||
"no-unnecessary-type-assertion": false,
|
||||
"no-useless-files": false,
|
||||
"no-var-keyword": false,
|
||||
"no-var-requires": false,
|
||||
"no-void-expression": false,
|
||||
"no-trailing-whitespace": false,
|
||||
"object-literal-key-quotes": false,
|
||||
"object-literal-shorthand": false,
|
||||
"one-line": false,
|
||||
"one-variable-per-declaration": false,
|
||||
"only-arrow-functions": false,
|
||||
"prefer-conditional-expression": false,
|
||||
"prefer-const": false,
|
||||
"prefer-declare-function": false,
|
||||
"prefer-for-of": false,
|
||||
"prefer-method-signature": false,
|
||||
"prefer-template": false,
|
||||
"radix": false,
|
||||
"semicolon": false,
|
||||
"space-before-function-paren": false,
|
||||
"space-within-parens": false,
|
||||
"strict-export-declare-modifiers": false,
|
||||
"trim-file": false,
|
||||
"triple-equals": false,
|
||||
"typedef-whitespace": false,
|
||||
"unified-signatures": false,
|
||||
"void-return": false,
|
||||
"whitespace": false
|
||||
"interface-name": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -644,6 +644,9 @@ isolateScope = element.find('div').isolateScope();
|
||||
isolateScope = element.children().isolateScope();
|
||||
let element2 = angular.element(element);
|
||||
let elementArray = angular.element(document.querySelectorAll('div'));
|
||||
let elementReadyFn = angular.element(() => {
|
||||
console.log('ready');
|
||||
});
|
||||
|
||||
// $timeout signature tests
|
||||
namespace TestTimeout {
|
||||
@@ -704,7 +707,7 @@ class SampleDirective implements ng.IDirective {
|
||||
restrict = 'A';
|
||||
name = 'doh';
|
||||
|
||||
compile(templateElement: ng.IAugmentedJQuery) {
|
||||
compile(templateElement: JQLite) {
|
||||
return {
|
||||
post: this.link
|
||||
};
|
||||
@@ -720,7 +723,7 @@ class SampleDirective implements ng.IDirective {
|
||||
class SampleDirective2 implements ng.IDirective {
|
||||
restrict = 'EAC';
|
||||
|
||||
compile(templateElement: ng.IAugmentedJQuery) {
|
||||
compile(templateElement: JQLite) {
|
||||
return {
|
||||
pre: this.link
|
||||
};
|
||||
@@ -738,7 +741,7 @@ angular.module('SameplDirective', []).directive('sampleDirective', SampleDirecti
|
||||
angular.module('AnotherSampleDirective', []).directive('myDirective', ['$interpolate', '$q', ($interpolate: ng.IInterpolateService, $q: ng.IQService) => {
|
||||
return {
|
||||
restrict: 'A',
|
||||
link: (scope: ng.IScope, el: ng.IAugmentedJQuery, attr: ng.IAttributes) => {
|
||||
link: (scope: ng.IScope, el: JQLite, attr: ng.IAttributes) => {
|
||||
$interpolate(attr['test'])(scope);
|
||||
$interpolate('', true)(scope);
|
||||
$interpolate('', true, 'html')(scope);
|
||||
@@ -866,7 +869,7 @@ angular.module('docsTimeDirective', [])
|
||||
}])
|
||||
.directive('myCurrentTime', ['$interval', 'dateFilter', ($interval: any, dateFilter: any) => {
|
||||
return {
|
||||
link(scope: ng.IScope, element: ng.IAugmentedJQuery, attrs: ng.IAttributes) {
|
||||
link(scope: ng.IScope, element: JQLite, attrs: ng.IAttributes) {
|
||||
let format: any;
|
||||
let timeoutId: any;
|
||||
|
||||
@@ -913,7 +916,7 @@ angular.module('docsTransclusionExample', [])
|
||||
transclude: true,
|
||||
scope: {},
|
||||
templateUrl: 'my-dialog.html',
|
||||
link(scope: ng.IScope, element: ng.IAugmentedJQuery) {
|
||||
link(scope: ng.IScope, element: JQLite) {
|
||||
scope['name'] = 'Jeff';
|
||||
}
|
||||
};
|
||||
@@ -1014,7 +1017,7 @@ angular.module('docsTabsExample', [])
|
||||
scope: {
|
||||
title: '@'
|
||||
},
|
||||
link(scope: ng.IScope, element: ng.IAugmentedJQuery, attrs: ng.IAttributes, tabsCtrl: any) {
|
||||
link(scope: ng.IScope, element: JQLite, attrs: ng.IAttributes, tabsCtrl: any) {
|
||||
tabsCtrl.addPane(scope);
|
||||
},
|
||||
templateUrl: 'my-pane.html'
|
||||
@@ -1095,6 +1098,18 @@ angular.module('copyExample', [])
|
||||
$scope.reset();
|
||||
}]);
|
||||
|
||||
// Extending IScope for a directive, see https://github.com/DefinitelyTyped/DefinitelyTyped/issues/21160
|
||||
interface IMyScope extends angular.IScope {
|
||||
myScopeProperty: boolean;
|
||||
}
|
||||
|
||||
angular.module('aaa').directive('directive', () => ({
|
||||
link(scope: IMyScope) {
|
||||
console.log(scope.myScopeProperty);
|
||||
return;
|
||||
}
|
||||
}));
|
||||
|
||||
namespace locationTests {
|
||||
const $location: ng.ILocationService = null;
|
||||
|
||||
@@ -1309,3 +1324,35 @@ function toPromise<T>(val: T): ng.IPromise<T> {
|
||||
const p: ng.IPromise<T> = null;
|
||||
return p;
|
||||
}
|
||||
|
||||
const directiveCompileFn: ng.IDirectiveCompileFn = (
|
||||
templateElement: JQLite,
|
||||
templateAttributes: ng.IAttributes,
|
||||
transclude: ng.ITranscludeFunction
|
||||
): ng.IDirectiveLinkFn => {
|
||||
return (
|
||||
scope: ng.IScope,
|
||||
instanceElement: JQLite,
|
||||
instanceAttributes: ng.IAttributes
|
||||
) => {
|
||||
return null;
|
||||
};
|
||||
};
|
||||
|
||||
interface MyScope extends ng.IScope {
|
||||
foo: string;
|
||||
}
|
||||
|
||||
const directiveCompileFnWithGeneric: ng.IDirectiveCompileFn<MyScope> = (
|
||||
templateElement: JQLite,
|
||||
templateAttributes: ng.IAttributes,
|
||||
transclude: ng.ITranscludeFunction
|
||||
): ng.IDirectiveLinkFn<MyScope> => {
|
||||
return (
|
||||
scope: MyScope,
|
||||
instanceElement: JQLite,
|
||||
instanceAttributes: ng.IAttributes
|
||||
) => {
|
||||
return null;
|
||||
};
|
||||
};
|
||||
|
||||
Vendored
+28
-22
@@ -9,9 +9,6 @@
|
||||
|
||||
/// <reference path="jqlite.d.ts" />
|
||||
|
||||
// NOTE: @types/angular technically doesn't require TypeScript 2.3, only TypeScript 2.1.
|
||||
// It has a TypeScript 2.3 header so that merging tests with @types/jquery v3 will work.
|
||||
|
||||
declare var angular: angular.IAngularStatic;
|
||||
|
||||
// Support for painless dependency injection
|
||||
@@ -232,8 +229,8 @@ declare namespace angular {
|
||||
* @param name Name of the directive in camel-case (i.e. ngBind which will match as ng-bind)
|
||||
* @param directiveFactory An injectable directive factory function.
|
||||
*/
|
||||
directive(name: string, directiveFactory: Injectable<IDirectiveFactory>): IModule;
|
||||
directive(object: {[directiveName: string]: Injectable<IDirectiveFactory>}): IModule;
|
||||
directive<TScope extends IScope = IScope>(name: string, directiveFactory: Injectable<IDirectiveFactory<TScope>>): IModule;
|
||||
directive<TScope extends IScope = IScope>(object: {[directiveName: string]: Injectable<IDirectiveFactory<TScope>>}): IModule;
|
||||
/**
|
||||
* Register a service factory, which will be called to return the service instance. This is short for registering a service where its provider consists of only a $get property, which is the given service factory function. You should use $provide.factory(getFn) if you do not need to configure your service in a provider.
|
||||
*
|
||||
@@ -1252,8 +1249,8 @@ declare namespace angular {
|
||||
}
|
||||
|
||||
interface ICompileProvider extends IServiceProvider {
|
||||
directive(name: string, directiveFactory: Injectable<IDirectiveFactory>): ICompileProvider;
|
||||
directive(object: {[directiveName: string]: Injectable<IDirectiveFactory>}): ICompileProvider;
|
||||
directive<TScope extends IScope = IScope>(name: string, directiveFactory: Injectable<IDirectiveFactory<TScope>>): ICompileProvider;
|
||||
directive<TScope extends IScope = IScope>(object: {[directiveName: string]: Injectable<IDirectiveFactory<TScope>>}): ICompileProvider;
|
||||
|
||||
component(name: string, options: IComponentOptions): ICompileProvider;
|
||||
|
||||
@@ -1302,6 +1299,17 @@ declare namespace angular {
|
||||
*/
|
||||
cssClassDirectivesEnabled(): boolean;
|
||||
cssClassDirectivesEnabled(enabled: boolean): ICompileProvider;
|
||||
|
||||
/**
|
||||
* Call this method to enable/disable strict component bindings check.
|
||||
* If enabled, the compiler will enforce that for all bindings of a
|
||||
* component that are not set as optional with ?, an attribute needs
|
||||
* to be provided on the component's HTML tag.
|
||||
* Defaults to false.
|
||||
* See: https://docs.angularjs.org/api/ng/provider/$compileProvider#strictComponentBindingsEnabled
|
||||
*/
|
||||
strictComponentBindingsEnabled(): boolean;
|
||||
strictComponentBindingsEnabled(enabled: boolean): ICompileProvider;
|
||||
}
|
||||
|
||||
interface ICloneAttachFunction {
|
||||
@@ -1961,13 +1969,13 @@ declare namespace angular {
|
||||
// and http://docs.angularjs.org/guide/directive
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
interface IDirectiveFactory {
|
||||
(...args: any[]): IDirective | IDirectiveLinkFn;
|
||||
interface IDirectiveFactory<TScope extends IScope = IScope> {
|
||||
(...args: any[]): IDirective<TScope> | IDirectiveLinkFn<TScope>;
|
||||
}
|
||||
|
||||
interface IDirectiveLinkFn {
|
||||
interface IDirectiveLinkFn<TScope extends IScope = IScope> {
|
||||
(
|
||||
scope: IScope,
|
||||
scope: TScope,
|
||||
instanceElement: JQLite,
|
||||
instanceAttributes: IAttributes,
|
||||
controller?: IController | IController[] | {[key: string]: IController},
|
||||
@@ -1975,12 +1983,12 @@ declare namespace angular {
|
||||
): void;
|
||||
}
|
||||
|
||||
interface IDirectivePrePost {
|
||||
pre?: IDirectiveLinkFn;
|
||||
post?: IDirectiveLinkFn;
|
||||
interface IDirectivePrePost<TScope extends IScope = IScope> {
|
||||
pre?: IDirectiveLinkFn<TScope>;
|
||||
post?: IDirectiveLinkFn<TScope>;
|
||||
}
|
||||
|
||||
interface IDirectiveCompileFn {
|
||||
interface IDirectiveCompileFn<TScope extends IScope = IScope> {
|
||||
(
|
||||
templateElement: JQLite,
|
||||
templateAttributes: IAttributes,
|
||||
@@ -1991,11 +1999,11 @@ declare namespace angular {
|
||||
* that is passed to the link function instead.
|
||||
*/
|
||||
transclude: ITranscludeFunction
|
||||
): void | IDirectiveLinkFn | IDirectivePrePost;
|
||||
): void | IDirectiveLinkFn<TScope> | IDirectivePrePost<TScope>;
|
||||
}
|
||||
|
||||
interface IDirective {
|
||||
compile?: IDirectiveCompileFn;
|
||||
interface IDirective<TScope extends IScope = IScope> {
|
||||
compile?: IDirectiveCompileFn<TScope>;
|
||||
controller?: string | Injectable<IControllerConstructor>;
|
||||
controllerAs?: string;
|
||||
/**
|
||||
@@ -2004,7 +2012,7 @@ declare namespace angular {
|
||||
* relies upon bindings inside a $onInit method on the controller, instead.
|
||||
*/
|
||||
bindToController?: boolean | {[boundProperty: string]: string};
|
||||
link?: IDirectiveLinkFn | IDirectivePrePost;
|
||||
link?: IDirectiveLinkFn<TScope> | IDirectivePrePost<TScope>;
|
||||
multiElement?: boolean;
|
||||
priority?: number;
|
||||
/**
|
||||
@@ -2077,9 +2085,7 @@ declare namespace angular {
|
||||
get<T>(name: '$xhrFactory'): IXhrFactory<T>;
|
||||
has(name: string): boolean;
|
||||
instantiate<T>(typeConstructor: {new(...args: any[]): T}, locals?: any): T;
|
||||
invoke(inlineAnnotatedFunction: any[], context?: any, locals?: any): any;
|
||||
invoke<T>(func: (...args: any[]) => T, context?: any, locals?: any): T;
|
||||
invoke(func: Function, context?: any, locals?: any): any;
|
||||
invoke<T = any>(func: Injectable<Function | ((...args: any[]) => T)>, context?: any, locals?: any): T;
|
||||
strictDi: boolean;
|
||||
}
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -684,7 +684,7 @@ interface JQuery {
|
||||
}
|
||||
|
||||
interface JQueryStatic {
|
||||
(element: string | Element | Document | JQuery | ArrayLike<Element>): JQLite;
|
||||
(element: string | Element | Document | JQuery | ArrayLike<Element> | (() => void)): JQLite;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
"noImplicitAny": false,
|
||||
"noImplicitThis": false,
|
||||
"strictNullChecks": false,
|
||||
"strictFunctionTypes": false,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
@@ -25,4 +25,4 @@
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import * as angular from 'angular';
|
||||
import { angulartics } from 'angulartics';
|
||||
import * as angulartics from 'angulartics';
|
||||
|
||||
namespace Analytics {
|
||||
angular.module("angulartics.app", ["angulartics"])
|
||||
|
||||
Vendored
+39
-11
@@ -1,11 +1,13 @@
|
||||
// Type definitions for Angulartics 1.3
|
||||
// Type definitions for Angulartics 1.4
|
||||
// Project: http://luisfarzati.github.io/angulartics/
|
||||
// Definitions by: Steven Fan <https://github.com/stevenfan>
|
||||
// Definitions by: Bateast2 <https://github.com/bateast2>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
import * as angular from 'angular';
|
||||
|
||||
export = angulartics;//AMD/Require module support
|
||||
export as namespace angulartics;//UMD module support
|
||||
declare namespace angulartics {
|
||||
|
||||
interface IAngularticsStatic {
|
||||
@@ -13,41 +15,67 @@ declare namespace angulartics {
|
||||
}
|
||||
|
||||
interface IAnalyticsService {
|
||||
eventTrack(eventName: string, properties?: any): any;
|
||||
getOptOut(): boolean;
|
||||
pageTrack(path: string, location?: angular.ILocationService): any;
|
||||
eventTrack(eventName: string, properties?: any): any;
|
||||
exceptionTrack(error: any, cause: string): any;
|
||||
transactionTrack: any;
|
||||
setAlias(alias: string): any;
|
||||
setOptOut(value: boolean): void;
|
||||
setUsername(username: string): any;
|
||||
setUserProperties(properties: any): any;
|
||||
setSuperProperties(properties: any): any;
|
||||
setUserProperties(userProperties: any): any;
|
||||
setUserPropertiesOnce(userProperties: any): any;
|
||||
setSuperProperties(superProperties: any): any;
|
||||
setSuperPropertiesOnce(superProperties: any): any;
|
||||
incrementProperty(property: string, value?: any): any;
|
||||
userTimings(properties: any): any;
|
||||
clearCookies: any;
|
||||
|
||||
getOptOut(): boolean;
|
||||
setOptOut(value: boolean): void;
|
||||
}
|
||||
|
||||
interface IAnalyticsServiceProvider extends angular.IServiceProvider {
|
||||
virtualPageviews(value: boolean): void;
|
||||
trackStates(value: boolean): void;
|
||||
trackRoutes(value: boolean): void;
|
||||
excludeRoutes(value: string[]): void;
|
||||
queryKeysWhitelist(keys: string[]): void
|
||||
queryKeysBlacklist(keys: string[]): void
|
||||
firstPageview(value: boolean): void;
|
||||
withBase(value: boolean): void;
|
||||
withAutoBase(value: boolean): void;
|
||||
developerMode(value: boolean): void;
|
||||
trackExceptions(value: boolean): void;
|
||||
trackRoutes(value: boolean): void;
|
||||
trackStates(value: boolean): void;
|
||||
developerMode(value: boolean): void;
|
||||
|
||||
registerPageTrack(callback: (path: string, location?: angular.ILocationService) => any): void;
|
||||
registerEventTrack(callback: (eventName: string, properties?: any) => any): void;
|
||||
registerTransactionTrack(callback: any): void;
|
||||
registerSetAlias(callback: (alias: string) => any): void;
|
||||
registerSetUsername(callback: (username: string) => any): void;
|
||||
registerSetUserProperties(callback: (userProperties: any) => any): void;
|
||||
registerSetUserPropertiesOnce(callback: (userProperties: any) => any): void;
|
||||
registerSetSuperProperties(callback: (superProperties: any) => any): void;
|
||||
registerSetSuperPropertiesOnce(callback: (superProperties: any) => any): void;
|
||||
registerIncrementProperty(callback: (property: string, value?: any) => any): void;
|
||||
registerUserTimings(callback: (properties: any) => any): void;
|
||||
registerClearCookies(callback: any): void;
|
||||
|
||||
settings: {
|
||||
pageTracking: {
|
||||
autoTrackingVirtualPages: boolean,
|
||||
autoTrackingFirstPage: boolean,
|
||||
trackRelativePath: boolean,
|
||||
trackRoutes: boolean,
|
||||
trackStates: boolean,
|
||||
autoBasePath: boolean,
|
||||
basePath: string,
|
||||
autoBasePath: boolean
|
||||
excludedRoutes: string[],
|
||||
queryKeysWhitelisted: string[],
|
||||
queryKeysBlacklisted: string[]
|
||||
},
|
||||
eventTracking: {},
|
||||
bufferFlushDelay: number,
|
||||
trackExceptions: boolean,
|
||||
optOut: boolean,
|
||||
developerMode: boolean
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import ansiRegex = require("ansi-regex");
|
||||
|
||||
ansiRegex(); // $ExpectType RegExp
|
||||
|
||||
// From the ansi-regex README.md
|
||||
ansiRegex().test('\u001B[4mcake\u001B[0m'); // $ExpectType boolean
|
||||
// => true
|
||||
|
||||
ansiRegex().test('cake'); // $ExpectType boolean
|
||||
// => false
|
||||
|
||||
'\u001B[4mcake\u001B[0m'.match(ansiRegex()); // $ExpectType RegExpMatchArray | null
|
||||
// => ['\u001B[4m', '\u001B[0m']
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
// Type definitions for ansi-regex 3.0
|
||||
// Project: https://github.com/chalk/ansi-regex#readme
|
||||
// Definitions by: Manish Vachharajani <https://github.com/mvachhar>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare function r(): RegExp;
|
||||
export = r;
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"ansi-regex-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Vendored
+1
@@ -2,6 +2,7 @@
|
||||
// Project: https://github.com/apex/node-apex
|
||||
// Definitions by: Yoriki Yamaguchi <https://github.com/y13i>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
/// <reference types="aws-lambda" />
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
import * as errorHandler from 'api-error-handler';
|
||||
import * as express from 'express';
|
||||
|
||||
|
||||
Vendored
+1
-3
@@ -2,9 +2,7 @@
|
||||
// Project: https://github.com/expressjs/api-error-handler
|
||||
// Definitions by: Tanguy Krotoff <https://github.com/tkrotoff>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
|
||||
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
import * as express from 'express';
|
||||
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
import appdmg = require("appdmg");
|
||||
import { Options, Specification, SpecificationOptions } from "appdmg";
|
||||
|
||||
const proc = appdmg({
|
||||
target: "/foo/bar.dmg",
|
||||
basepath: "/baz",
|
||||
specification: {
|
||||
title: "Happy",
|
||||
icon: "happy.icns",
|
||||
background: "happy.tiff",
|
||||
format: "UDBZ",
|
||||
"icon-size": 98,
|
||||
contents: [
|
||||
{
|
||||
x: 405,
|
||||
y: 150,
|
||||
type: "link",
|
||||
path: "/Applications"
|
||||
},
|
||||
{
|
||||
x: 127,
|
||||
y: 150,
|
||||
type: "file",
|
||||
path: "/foo/bar.app"
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
proc.on("progress", info => {
|
||||
if (info.type === "step-begin") {
|
||||
process.stdout.write(`${info.title}... `);
|
||||
}
|
||||
|
||||
if (info.type === "step-end") {
|
||||
process.stdout.write(`${info.status}\n`);
|
||||
}
|
||||
});
|
||||
|
||||
proc.on("finish", () => {
|
||||
console.log('Installer was created successfully!');
|
||||
});
|
||||
|
||||
proc.on("error", (err) => {
|
||||
console.error('Installer could not be created', err);
|
||||
process.exit(1);
|
||||
});
|
||||
Vendored
+70
@@ -0,0 +1,70 @@
|
||||
// Type definitions for appdmg 0.5
|
||||
// Project: https://github.com/LinusU/node-appdmg#readme
|
||||
// Definitions by: Daniel Perez Alvarez <https://github.com/unindented>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
declare namespace appdmg {
|
||||
interface Progress {
|
||||
current: number;
|
||||
total: number;
|
||||
type: "step-begin" | "step-end";
|
||||
title: string;
|
||||
status: "ok" | "skip" | "fail";
|
||||
}
|
||||
|
||||
interface EventEmitter extends NodeJS.EventEmitter {
|
||||
on(event: "progress", listener: (info: Progress) => void): this;
|
||||
on(event: "finish", listener: () => void): this;
|
||||
on(event: "error", listener: (err: any) => void): this;
|
||||
}
|
||||
|
||||
interface SpecificationOptions {
|
||||
app: string;
|
||||
background: string;
|
||||
icon: string;
|
||||
iconSize: number;
|
||||
title: string;
|
||||
}
|
||||
|
||||
interface SpecificationWindow {
|
||||
position?: { x: number; y: number };
|
||||
size?: { width: number; height: number };
|
||||
}
|
||||
|
||||
interface SpecificationContents {
|
||||
x: number;
|
||||
y: number;
|
||||
type: "link" | "file" | "position";
|
||||
path: string;
|
||||
name?: string;
|
||||
}
|
||||
|
||||
interface SpecificationCodeSign {
|
||||
"signing-identity": string;
|
||||
identifier?: string;
|
||||
}
|
||||
|
||||
interface Specification {
|
||||
title: string;
|
||||
icon?: string;
|
||||
background?: string;
|
||||
"background-color"?: string;
|
||||
"icon-size"?: number;
|
||||
window?: SpecificationWindow;
|
||||
format: "UDRW" | "UDRO" | "UDCO" | "UDZO" | "UDBZ" | "ULFO";
|
||||
contents: SpecificationContents[];
|
||||
"code-sign"?: SpecificationCodeSign;
|
||||
}
|
||||
|
||||
interface Options {
|
||||
target: string;
|
||||
basepath: string;
|
||||
specification: Specification;
|
||||
}
|
||||
}
|
||||
|
||||
declare function appdmg(options?: appdmg.Options): appdmg.EventEmitter;
|
||||
|
||||
export = appdmg;
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"appdmg-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@@ -22,7 +22,7 @@ describe("ApplePaySession", () => {
|
||||
});
|
||||
it("can create a new instance", () => {
|
||||
const version = 1;
|
||||
const paymentRequest = {
|
||||
const paymentRequest: ApplePayJS.ApplePayPaymentRequest = {
|
||||
countryCode: "US",
|
||||
currencyCode: "USD",
|
||||
supportedNetworks: [
|
||||
@@ -57,8 +57,8 @@ describe("ApplePaySession", () => {
|
||||
});
|
||||
});
|
||||
it("can call instance methods", () => {
|
||||
const version = 1;
|
||||
const paymentRequest = {
|
||||
const version = 3;
|
||||
const paymentRequest: ApplePayJS.ApplePayPaymentRequest = {
|
||||
countryCode: "US",
|
||||
currencyCode: "USD",
|
||||
supportedNetworks: [
|
||||
@@ -66,7 +66,9 @@ describe("ApplePaySession", () => {
|
||||
"visa"
|
||||
],
|
||||
merchantCapabilities: [
|
||||
"supports3DS"
|
||||
"supports3DS",
|
||||
"supportsCredit",
|
||||
"supportsDebit"
|
||||
],
|
||||
total: {
|
||||
label: "My Store",
|
||||
@@ -80,15 +82,29 @@ describe("ApplePaySession", () => {
|
||||
session.completeMerchantValidation({
|
||||
foo: "bar"
|
||||
});
|
||||
|
||||
session.completePayment(ApplePaySession.STATUS_SUCCESS);
|
||||
|
||||
const total = {
|
||||
const authorizationResult: ApplePayJS.ApplePayPaymentAuthorizationResult = {
|
||||
status: ApplePaySession.STATUS_FAILURE,
|
||||
errors: [
|
||||
{
|
||||
code: "addressUnserviceable",
|
||||
contactField: "postalCode",
|
||||
message: "The specified postal code cannot be delivered to."
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
session.completePayment(authorizationResult);
|
||||
|
||||
const total: ApplePayJS.ApplePayLineItem = {
|
||||
label: "Subtotal",
|
||||
type: "final",
|
||||
amount: "35.00"
|
||||
};
|
||||
|
||||
const lineItems = [
|
||||
const lineItems: ApplePayJS.ApplePayLineItem[] = [
|
||||
{
|
||||
label: "Subtotal",
|
||||
type: "final",
|
||||
@@ -97,11 +113,12 @@ describe("ApplePaySession", () => {
|
||||
{
|
||||
label: "Free Shipping",
|
||||
amount: "0.00",
|
||||
type: "pending"
|
||||
type: "final"
|
||||
},
|
||||
{
|
||||
label: "Estimated Tax",
|
||||
amount: "3.06"
|
||||
amount: "3.06",
|
||||
type: "pending"
|
||||
}
|
||||
];
|
||||
|
||||
@@ -120,17 +137,35 @@ describe("ApplePaySession", () => {
|
||||
|
||||
session.completePaymentMethodSelection(total, lineItems);
|
||||
|
||||
const paymentUpdate = {
|
||||
newTotal: total
|
||||
};
|
||||
|
||||
session.completePaymentMethodSelection(paymentUpdate);
|
||||
|
||||
session.completeShippingContactSelection(
|
||||
ApplePaySession.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,
|
||||
shippingMethods,
|
||||
total,
|
||||
lineItems);
|
||||
|
||||
const contactUpdate = {
|
||||
newTotal: total
|
||||
};
|
||||
|
||||
session.completeShippingContactSelection(contactUpdate);
|
||||
|
||||
session.completeShippingMethodSelection(
|
||||
ApplePaySession.STATUS_SUCCESS,
|
||||
total,
|
||||
lineItems);
|
||||
|
||||
const shippingUpdate = {
|
||||
newTotal: total
|
||||
};
|
||||
|
||||
session.completeShippingMethodSelection(shippingUpdate);
|
||||
|
||||
session.oncancel = (event: ApplePayJS.Event): void => {
|
||||
event.cancelBubble = true;
|
||||
};
|
||||
@@ -201,7 +236,9 @@ describe("ApplePayPaymentRequest", () => {
|
||||
"1 Infinite Loop"
|
||||
],
|
||||
locality: "Cupertino",
|
||||
subLocality: "",
|
||||
administrativeArea: "CA",
|
||||
subAdministrativeArea: "",
|
||||
postalCode: "95014",
|
||||
country: "United States",
|
||||
countryCode: "US"
|
||||
@@ -233,7 +270,7 @@ describe("ApplePayPaymentRequest", () => {
|
||||
"postalAddress",
|
||||
"name",
|
||||
"phone",
|
||||
"email"
|
||||
"name"
|
||||
];
|
||||
|
||||
paymentRequest.shippingContact = {
|
||||
@@ -241,11 +278,15 @@ describe("ApplePayPaymentRequest", () => {
|
||||
familyName: "Patel",
|
||||
givenName: "Ravi",
|
||||
phoneNumber: "(408) 555-5555",
|
||||
phoneticFamilyName: "Patel",
|
||||
phoneticGivenName: "Ravi",
|
||||
addressLines: [
|
||||
"1 Infinite Loop"
|
||||
],
|
||||
locality: "Cupertino",
|
||||
subLocality: "",
|
||||
administrativeArea: "CA",
|
||||
subAdministrativeArea: "",
|
||||
postalCode: "95014",
|
||||
country: "United States",
|
||||
countryCode: "US"
|
||||
@@ -265,5 +306,6 @@ describe("ApplePayPaymentRequest", () => {
|
||||
];
|
||||
|
||||
paymentRequest.shippingType = "storePickup";
|
||||
paymentRequest.shippingType = "delivery";
|
||||
});
|
||||
});
|
||||
|
||||
Vendored
+322
-52
@@ -1,26 +1,26 @@
|
||||
// Type definitions for Apple Pay JS 1.0
|
||||
// Type definitions for Apple Pay JS 3.0
|
||||
// Project: https://developer.apple.com/reference/applepayjs
|
||||
// Definitions by: Martin Costello <https://martincostello.com/>
|
||||
// Definitions by: Martin Costello <https://github.com/martincostello>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/**
|
||||
* A session object for managing the payment process on the web.
|
||||
* ApplePaySession is the entry point for Apple Pay on the web.
|
||||
*/
|
||||
declare class ApplePaySession extends EventTarget {
|
||||
/**
|
||||
* Creates a new instance of the ApplePaySession class.
|
||||
* @param version - The version of the ApplePay JS API you are using.
|
||||
* @param paymentRequest - An ApplePayPaymentRequest object that contains the information that is displayed on the Apple Pay payment sheet.
|
||||
* The entry point for Apple Pay on the web.
|
||||
* @param version - The version number of the ApplePay JS API you are using. The current API version number is 3.
|
||||
* @param paymentRequest - An ApplePayPaymentRequest object that contains the information to be displayed on the Apple Pay payment sheet.
|
||||
*/
|
||||
constructor(version: number, paymentRequest: ApplePayJS.ApplePayPaymentRequest);
|
||||
|
||||
/**
|
||||
* A callback function that is automatically called when the payment UI is dismissed with an error.
|
||||
* A callback function that is automatically called when the payment UI is dismissed.
|
||||
*/
|
||||
oncancel: (event: ApplePayJS.Event) => void;
|
||||
|
||||
/**
|
||||
* A callback function that is automatically called when the user has authorized the Apple Pay payment, typically via TouchID.
|
||||
* A callback function that is automatically called when the user has authorized the Apple Pay payment with Touch ID, Face ID, or passcode.
|
||||
*/
|
||||
onpaymentauthorized: (event: ApplePayJS.ApplePayPaymentAuthorizedEvent) => void;
|
||||
|
||||
@@ -45,28 +45,28 @@ declare class ApplePaySession extends EventTarget {
|
||||
onvalidatemerchant: (event: ApplePayJS.ApplePayValidateMerchantEvent) => void;
|
||||
|
||||
/**
|
||||
* Indicates whether or not the device supports Apple Pay.
|
||||
* Indicates whether the device supports Apple Pay.
|
||||
* @returns true if the device supports making payments with Apple Pay; otherwise, false.
|
||||
*/
|
||||
static canMakePayments(): boolean;
|
||||
|
||||
/**
|
||||
* Indicates whether or not the device supports Apple Pay and if the user has an active card in Wallet.
|
||||
* @param merchantIdentifier - The merchant ID received when the merchant enrolled in Apple Pay.
|
||||
* @returns true if the device supports Apple Pay and there is at least one active card in Wallet; otherwise, false.
|
||||
* Indicates whether the device supports Apple Pay and whether the user has an active card in Wallet.
|
||||
* @param merchantIdentifier - The merchant ID created when the merchant enrolled in Apple Pay.
|
||||
* @returns true if the device supports Apple Pay and there is at least one active card in Wallet that is qualified for payments on the web; otherwise, false.
|
||||
*/
|
||||
static canMakePaymentsWithActiveCard(merchantIdentifier: string): Promise<boolean>;
|
||||
|
||||
/**
|
||||
* Displays the Set up Apple Pay button.
|
||||
* @param merchantIdentifier - The merchant ID received when the merchant enrolled in Apple Pay.
|
||||
* @param merchantIdentifier - The merchant ID created when the merchant enrolled in Apple Pay.
|
||||
* @returns A boolean value indicating whether setup was successful.
|
||||
*/
|
||||
static openPaymentSetup(merchantIdentifier: string): Promise<boolean>;
|
||||
|
||||
/**
|
||||
* Verifies if a web browser supports a given Apple Pay JS API version.
|
||||
* @param version - A number representing the Apple Pay JS API version being checked. The initial version is 1.
|
||||
* Verifies whether a web browser supports a given Apple Pay JS API version.
|
||||
* @param version - A number representing the Apple Pay JS API version being checked. The initial version is 1. The latest version is 3.
|
||||
* @returns A boolean value indicating whether the web browser supports the given API version. Returns false if the web browser does not support the specified version.
|
||||
*/
|
||||
static supportsVersion(version: number): boolean;
|
||||
@@ -82,26 +82,33 @@ declare class ApplePaySession extends EventTarget {
|
||||
begin(): void;
|
||||
|
||||
/**
|
||||
* Call after the merchant has been validated.
|
||||
* Completes the validation for a merchant session.
|
||||
* @param merchantSession - An opaque message session object.
|
||||
*/
|
||||
completeMerchantValidation(merchantSession: any): void;
|
||||
|
||||
/**
|
||||
* Call when a payment has been authorized.
|
||||
* @param status - The status of the payment.
|
||||
* Completes the payment authorization with a result.
|
||||
* @param result - The status of the payment, whether it succeeded or failed for Apple Pay JS versions 1 and 2,
|
||||
* or the result of the payment authorization, including its status and list of errors for Apple Pay JS version 3.
|
||||
*/
|
||||
completePayment(status: number): void;
|
||||
completePayment(result: number | ApplePayJS.ApplePayPaymentAuthorizationResult): void;
|
||||
|
||||
/**
|
||||
* Call after a payment method has been selected.
|
||||
* Call after a payment method has been selected for Apple Pay JS versions 1 and 2.
|
||||
* @param newTotal - An ApplePayLineItem dictionary representing the total price for the purchase.
|
||||
* @param newLineItems - A sequence of ApplePayLineItem dictionaries.
|
||||
*/
|
||||
completePaymentMethodSelection(newTotal: ApplePayJS.ApplePayLineItem, newLineItems: ApplePayJS.ApplePayLineItem[]): void;
|
||||
|
||||
/**
|
||||
* Call after a shipping contact has been selected.
|
||||
* Completes the selection of a payment method with an update for Apple Pay JS version 3.
|
||||
* @param update - The updated payment method.
|
||||
*/
|
||||
completePaymentMethodSelection(update: ApplePayJS.ApplePayPaymentMethodUpdate): void;
|
||||
|
||||
/**
|
||||
* Completes the selection of a shipping contact with an update for Apple Pay JS versions 1 and 2.
|
||||
* @param status - The status of the shipping contact update.
|
||||
* @param newShippingMethods - A sequence of ApplePayShippingMethod dictionaries.
|
||||
* @param newTotal - An ApplePayLineItem dictionary representing the total price for the purchase.
|
||||
@@ -114,13 +121,25 @@ declare class ApplePaySession extends EventTarget {
|
||||
newLineItems: ApplePayJS.ApplePayLineItem[]): void;
|
||||
|
||||
/**
|
||||
* Call after the shipping method has been selected.
|
||||
* Completes the selection of a shipping contact with an update for Apple Pay JS version 3.
|
||||
* @param update - The updated shipping contact.
|
||||
*/
|
||||
completeShippingContactSelection(update: ApplePayJS.ApplePayShippingContactUpdate): void;
|
||||
|
||||
/**
|
||||
* Call after the shipping method has been selected for Apple Pay JS versions 1 and 2.
|
||||
* @param status - The status of the shipping method update.
|
||||
* @param newTotal - An ApplePayLineItem dictionary representing the total price for the purchase.
|
||||
* @param newLineItems - A sequence of ApplePayLineItem dictionaries.
|
||||
*/
|
||||
completeShippingMethodSelection(status: number, newTotal: ApplePayJS.ApplePayLineItem, newLineItems: ApplePayJS.ApplePayLineItem[]): void;
|
||||
|
||||
/**
|
||||
* Completes the selection of a shipping method with an update for Apple Pay JS version 3.
|
||||
* @param update - The updated shipping method.
|
||||
*/
|
||||
completeShippingMethodSelection(update: ApplePayJS.ApplePayShippingMethodUpdate): void;
|
||||
|
||||
/**
|
||||
* The requested action succeeded.
|
||||
*/
|
||||
@@ -163,6 +182,78 @@ declare class ApplePaySession extends EventTarget {
|
||||
}
|
||||
|
||||
declare namespace ApplePayJS {
|
||||
/**
|
||||
* Field names used for requesting contact information in a payment request.
|
||||
*/
|
||||
type ApplePayContactField =
|
||||
'email' |
|
||||
'name' |
|
||||
'phone' |
|
||||
'postalAddress' |
|
||||
'phoneticName';
|
||||
|
||||
/**
|
||||
* A customizable error type that you create to indicate problems with the address or contact information on an Apple Pay sheet.
|
||||
*/
|
||||
interface ApplePayError {
|
||||
/**
|
||||
* The error code for this instance.
|
||||
*/
|
||||
code: ApplePayErrorCode;
|
||||
|
||||
/**
|
||||
* The name of the field that contains the error.
|
||||
*/
|
||||
contactField?: ApplePayErrorContactField;
|
||||
|
||||
/**
|
||||
* A localized, user-facing string that describes the error.
|
||||
*/
|
||||
message: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* The error code that indicates whether an error on the payment sheet is for shipping or billing information, or for another kind of error.
|
||||
*/
|
||||
type ApplePayErrorCode =
|
||||
/**
|
||||
* Shipping address or contact information is invalid or missing.
|
||||
*/
|
||||
'shippingContactInvalid' |
|
||||
|
||||
/**
|
||||
* Billing address information is invalid or missing.
|
||||
*/
|
||||
'billingContactInvalid' |
|
||||
|
||||
/**
|
||||
* The merchant cannot provide service to the shipping address (for example, can't deliver to a P.O. Box).
|
||||
*/
|
||||
'addressUnserviceable' |
|
||||
|
||||
/**
|
||||
* An unknown but nonfatal error occurred during payment processing. The user can attempt authorization again.
|
||||
*/
|
||||
'unknown';
|
||||
|
||||
/**
|
||||
* Names of the fields in the shipping or billing contact information, used to locate errors in the payment sheet.
|
||||
*/
|
||||
type ApplePayErrorContactField =
|
||||
'phoneNumber' |
|
||||
'emailAddress' |
|
||||
'name' |
|
||||
'phoneticName' |
|
||||
'postalAddress' |
|
||||
'addressLines' |
|
||||
'locality' |
|
||||
'subLocality' |
|
||||
'postalCode' |
|
||||
'administrativeArea' |
|
||||
'subAdministrativeArea' |
|
||||
'country' |
|
||||
'countryCode';
|
||||
|
||||
/**
|
||||
* Defines a line item in a payment request - for example, total, tax, discount, or grand total.
|
||||
*/
|
||||
@@ -180,15 +271,53 @@ declare namespace ApplePayJS {
|
||||
/**
|
||||
* A value that indicates if the line item is final or pending.
|
||||
*/
|
||||
type?: string;
|
||||
type?: ApplePayLineItemType;
|
||||
}
|
||||
|
||||
/**
|
||||
* A type that indicates whether a line item is final or pending.
|
||||
*/
|
||||
type ApplePayLineItemType =
|
||||
/**
|
||||
* A line item representing the known, final cost.
|
||||
*/
|
||||
'final' |
|
||||
|
||||
/**
|
||||
* A line item representing an estimated or unknown cost.
|
||||
*/
|
||||
'pending';
|
||||
|
||||
/**
|
||||
* The payment capabilities supported by the merchant.
|
||||
*/
|
||||
type ApplePayMerchantCapability =
|
||||
/**
|
||||
* Required. This value must be supplied.
|
||||
*/
|
||||
'supports3DS' |
|
||||
|
||||
/**
|
||||
* Include this value only if you support China Union Pay transactions.
|
||||
*/
|
||||
'supportsEMV' |
|
||||
|
||||
/**
|
||||
* Optional. If present, only transactions that are categorized as credit cards are allowed.
|
||||
*/
|
||||
'supportsCredit' |
|
||||
|
||||
/**
|
||||
* Optional. If present, only transactions that are categorized as debit cards are allowed.
|
||||
*/
|
||||
'supportsDebit';
|
||||
|
||||
/**
|
||||
* Represents the result of authorizing a payment request and contains encrypted payment information.
|
||||
*/
|
||||
interface ApplePayPayment {
|
||||
/**
|
||||
* The encrypted token for an authorized payment.
|
||||
* The encrypted information for an authorized payment.
|
||||
*/
|
||||
token: ApplePayPaymentToken;
|
||||
|
||||
@@ -208,11 +337,26 @@ declare namespace ApplePayJS {
|
||||
*/
|
||||
abstract class ApplePayPaymentAuthorizedEvent extends Event {
|
||||
/**
|
||||
* The payment token used to authorize a payment.
|
||||
* The authorized payment information for this transaction.
|
||||
*/
|
||||
readonly payment: ApplePayPayment;
|
||||
}
|
||||
|
||||
/**
|
||||
* The result of payment authorization, including status and errors.
|
||||
*/
|
||||
interface ApplePayPaymentAuthorizationResult {
|
||||
/**
|
||||
* The status code for the authorization result.
|
||||
*/
|
||||
status: number;
|
||||
|
||||
/**
|
||||
* A list of custom errors to display on the payment sheet.
|
||||
*/
|
||||
errors?: ApplePayError[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Encapsulates contact information needed for billing and shipping.
|
||||
*/
|
||||
@@ -220,56 +364,76 @@ declare namespace ApplePayJS {
|
||||
/**
|
||||
* An email address for the contact.
|
||||
*/
|
||||
emailAddress: string;
|
||||
emailAddress?: string;
|
||||
|
||||
/**
|
||||
* The contact's family name.
|
||||
*/
|
||||
familyName: string;
|
||||
familyName?: string;
|
||||
|
||||
/**
|
||||
* The contact's given name.
|
||||
*/
|
||||
givenName: string;
|
||||
givenName?: string;
|
||||
|
||||
/**
|
||||
* A phone number for the contact.
|
||||
*/
|
||||
phoneNumber: string;
|
||||
phoneNumber?: string;
|
||||
|
||||
/**
|
||||
* The address for the contact.
|
||||
* The phonetic spelling of the contact's family name.
|
||||
*/
|
||||
addressLines: string[];
|
||||
phoneticFamilyName?: string;
|
||||
|
||||
/**
|
||||
* The phonetic spelling of the contact's given name.
|
||||
*/
|
||||
phoneticGivenName?: string;
|
||||
|
||||
/**
|
||||
* The street portion of the address for the contact.
|
||||
*/
|
||||
addressLines?: string[];
|
||||
|
||||
/**
|
||||
* The city for the contact.
|
||||
*/
|
||||
locality: string;
|
||||
locality?: string;
|
||||
|
||||
/**
|
||||
* Additional information associated with the location, typically defined at the city or town level (such as district or neighborhood), in a postal address.
|
||||
*/
|
||||
subLocality?: string;
|
||||
|
||||
/**
|
||||
* The state for the contact.
|
||||
*/
|
||||
administrativeArea: string;
|
||||
administrativeArea?: string;
|
||||
|
||||
/**
|
||||
* The zip code, where applicable, for the contact.
|
||||
* The subadministrative area (such as a county or other region) in a postal address.
|
||||
*/
|
||||
postalCode: string;
|
||||
subAdministrativeArea?: string;
|
||||
|
||||
/**
|
||||
* The colloquial country name for the contact.
|
||||
* The zip code or postal code, where applicable, for the contact.
|
||||
*/
|
||||
country: string;
|
||||
postalCode?: string;
|
||||
|
||||
/**
|
||||
* The contact's ISO country code.
|
||||
* The name of the country for the contact.
|
||||
*/
|
||||
countryCode: string;
|
||||
country?: string;
|
||||
|
||||
/**
|
||||
* The contact’s two-letter ISO 3166 country code.
|
||||
*/
|
||||
countryCode?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Contains information about an Apple Pay payment card.
|
||||
* A dictionary that describes an Apple Pay payment card.
|
||||
*/
|
||||
interface ApplePayPaymentMethod {
|
||||
/**
|
||||
@@ -279,21 +443,29 @@ declare namespace ApplePayJS {
|
||||
|
||||
/**
|
||||
* A string, suitable for display, that is the name of the payment network backing the card.
|
||||
* The value is one of the supported networks specified in the supportedNetworks property of the ApplePayPaymentRequest.
|
||||
*/
|
||||
network: string;
|
||||
|
||||
/**
|
||||
* A value representing the card's type of payment.
|
||||
*/
|
||||
type: string;
|
||||
type: ApplePayPaymentMethodType;
|
||||
|
||||
/**
|
||||
* The payment pass object associated with the payment.
|
||||
* The payment pass object currently selected to complete the payment.
|
||||
*/
|
||||
paymentPass: ApplePayPaymentPass;
|
||||
}
|
||||
|
||||
/**
|
||||
* A payment card's type of payment.
|
||||
*/
|
||||
type ApplePayPaymentMethodType =
|
||||
'debit' |
|
||||
'credit' |
|
||||
'prepaid' |
|
||||
'store';
|
||||
|
||||
/**
|
||||
* The ApplePayPaymentMethodSelectedEvent class defines the attributes contained by the ApplePaySession.onpaymentmethodselected callback function.
|
||||
*/
|
||||
@@ -304,6 +476,21 @@ declare namespace ApplePayJS {
|
||||
readonly paymentMethod: ApplePayPaymentMethod;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updated transaction details resulting from a change in payment method.
|
||||
*/
|
||||
interface ApplePayPaymentMethodUpdate {
|
||||
/**
|
||||
* An optional list of line items.
|
||||
*/
|
||||
newLineItems?: ApplePayLineItem[];
|
||||
|
||||
/**
|
||||
* The new total resulting from a change in the payment method.
|
||||
*/
|
||||
newTotal: ApplePayLineItem;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a provisioned payment card for Apple Pay payments.
|
||||
*/
|
||||
@@ -331,9 +518,38 @@ declare namespace ApplePayJS {
|
||||
/**
|
||||
* The activation state of the pass.
|
||||
*/
|
||||
activationState: string;
|
||||
activationState: ApplePayPaymentPassActivationState;
|
||||
}
|
||||
|
||||
/**
|
||||
* Payment pass activation states.
|
||||
*/
|
||||
type ApplePayPaymentPassActivationState =
|
||||
/**
|
||||
* Active and ready to be used for payment.
|
||||
*/
|
||||
'activated' |
|
||||
|
||||
/**
|
||||
* Not active but may be activated by the issuer.
|
||||
*/
|
||||
'requiresActivation' |
|
||||
|
||||
/**
|
||||
* Not ready for use but activation is in progress.
|
||||
*/
|
||||
'activating' |
|
||||
|
||||
/**
|
||||
* Not active and can't be activated.
|
||||
*/
|
||||
'suspended' |
|
||||
|
||||
/**
|
||||
* Not active because the issuer has disabled the account associated with the device.
|
||||
*/
|
||||
'deactivated';
|
||||
|
||||
/**
|
||||
* Encapsulates a request for payment, including information about payment processing capabilities, the payment amount, and shipping information.
|
||||
*/
|
||||
@@ -357,7 +573,7 @@ declare namespace ApplePayJS {
|
||||
* The payment capabilities supported by the merchant.
|
||||
* The value must at least contain ApplePayMerchantCapability.supports3DS.
|
||||
*/
|
||||
merchantCapabilities: string[];
|
||||
merchantCapabilities: ApplePayMerchantCapability[];
|
||||
|
||||
/**
|
||||
* The payment networks supported by the merchant.
|
||||
@@ -377,12 +593,12 @@ declare namespace ApplePayJS {
|
||||
/**
|
||||
* The billing information that you require from the user in order to process the transaction.
|
||||
*/
|
||||
requiredBillingContactFields?: string[];
|
||||
requiredBillingContactFields?: ApplePayContactField[];
|
||||
|
||||
/**
|
||||
* The shipping information that you require from the user in order to fulfill the order.
|
||||
*/
|
||||
requiredShippingContactFields?: string[];
|
||||
requiredShippingContactFields?: ApplePayContactField[];
|
||||
|
||||
/**
|
||||
* Shipping contact information for the user.
|
||||
@@ -397,7 +613,12 @@ declare namespace ApplePayJS {
|
||||
/**
|
||||
* How the items are to be shipped.
|
||||
*/
|
||||
shippingType?: string;
|
||||
shippingType?: ApplePayShippingType;
|
||||
|
||||
/**
|
||||
* A list of ISO 3166 country codes for limiting payments to cards from specific countries.
|
||||
*/
|
||||
supportedCountries?: string[];
|
||||
|
||||
/**
|
||||
* Optional user-defined data.
|
||||
@@ -406,7 +627,7 @@ declare namespace ApplePayJS {
|
||||
}
|
||||
|
||||
/**
|
||||
* Contains the user's payment credentials.
|
||||
* An object that contains the user's payment credentials.
|
||||
*/
|
||||
interface ApplePayPaymentToken {
|
||||
/**
|
||||
@@ -426,7 +647,7 @@ declare namespace ApplePayJS {
|
||||
}
|
||||
|
||||
/**
|
||||
* The ApplePayShippingContactSelectedEvent class defines the attributes contained by the ApplePaySession.onshippingcontactselected callback function.
|
||||
* Encapsulates the attributes contained by the onshippingcontactselected callback function.
|
||||
*/
|
||||
abstract class ApplePayShippingContactSelectedEvent extends Event {
|
||||
/**
|
||||
@@ -435,6 +656,31 @@ declare namespace ApplePayJS {
|
||||
readonly shippingContact: ApplePayPaymentContact;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updated transaction details resulting from a change in shipping contact, including any errors.
|
||||
*/
|
||||
class ApplePayShippingContactUpdate {
|
||||
/**
|
||||
* List of custom errors to display on the payment sheet.
|
||||
*/
|
||||
errors?: ApplePayError[];
|
||||
|
||||
/**
|
||||
* An optional list of updated line items.
|
||||
*/
|
||||
newLineItems?: ApplePayLineItem[];
|
||||
|
||||
/**
|
||||
* A list of shipping methods that are available to the updated shipping contact.
|
||||
*/
|
||||
newShippingMethods?: ApplePayShippingMethod[];
|
||||
|
||||
/**
|
||||
* The new total resulting from a change in the shipping contact.
|
||||
*/
|
||||
newTotal: ApplePayLineItem;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines a shipping method for delivering physical goods.
|
||||
*/
|
||||
@@ -471,11 +717,35 @@ declare namespace ApplePayJS {
|
||||
}
|
||||
|
||||
/**
|
||||
* The ApplePayValidateMerchantEvent class defines the attributes contained by the ApplePaySession.onvalidatemerchant callback function.
|
||||
* Updated transaction details resulting from a change in shipping method.
|
||||
*/
|
||||
interface ApplePayShippingMethodUpdate {
|
||||
/**
|
||||
* An optional list of updated line items.
|
||||
*/
|
||||
newLineItems?: ApplePayLineItem[];
|
||||
|
||||
/**
|
||||
* The new total resulting from a change in the shipping method.
|
||||
*/
|
||||
newTotal: ApplePayLineItem;
|
||||
}
|
||||
|
||||
/**
|
||||
* A type that indicates how purchased items are to be shipped.
|
||||
*/
|
||||
type ApplePayShippingType =
|
||||
'shipping' |
|
||||
'delivery' |
|
||||
'storePickup' |
|
||||
'servicePickup';
|
||||
|
||||
/**
|
||||
* The attributes contained by the onvalidatemerchant callback function.
|
||||
*/
|
||||
abstract class ApplePayValidateMerchantEvent extends Event {
|
||||
/**
|
||||
* The URL used to validate the merchant server.
|
||||
* The URL your server must use to validate itself and obtain a merchant session object.
|
||||
*/
|
||||
readonly validationURL: string;
|
||||
}
|
||||
|
||||
+1
-1
@@ -777,7 +777,7 @@ declare module Microsoft.ApplicationInsights {
|
||||
* @param authenticatedUserId {string} - The authenticated user id. A unique and persistent string that represents each authenticated user in the service.
|
||||
* @param accountId {string} - An optional string to represent the account associated with the authenticated user.
|
||||
*/
|
||||
setAuthenticatedUserContext(authenticatedUserId: string, accountId?: string): any;
|
||||
setAuthenticatedUserContext(authenticatedUserId: string, accountId?: string, storeInCookie?: boolean): any;
|
||||
/**
|
||||
* Clears the authenticated user id and the account id from the user context.
|
||||
*/
|
||||
|
||||
+1
@@ -2,6 +2,7 @@
|
||||
// Project: https://github.com/Esri/arcgis-to-geojson-utils
|
||||
// Definitions by: Jeff Jacobson <https://github.com/JeffJacobson>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
/// <reference types="geojson" />
|
||||
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
import * as args from "args";
|
||||
|
||||
args
|
||||
.option("opt1", "desc")
|
||||
.option("opt2", "desc", false, (value: any): any => value)
|
||||
.options([
|
||||
{
|
||||
name: 'opt3',
|
||||
description: 'desc',
|
||||
defaultValue: 1,
|
||||
init: (value: any) => { },
|
||||
},
|
||||
{
|
||||
name: 'opt4',
|
||||
description: 'desc',
|
||||
},
|
||||
])
|
||||
.command("cm1", "desc")
|
||||
.command("cm2", "desc", (value: any): void => { }, ['a'])
|
||||
.example("ex1", "desc")
|
||||
.examples([
|
||||
{
|
||||
usage: "ex2",
|
||||
description: "desc",
|
||||
},
|
||||
]);
|
||||
|
||||
args.parse(['~/bin/node', '~/dir', 'arg', '--param'], {
|
||||
help: true,
|
||||
name: "name",
|
||||
version: true,
|
||||
usageFilter: (a: any): any => a,
|
||||
value: "value",
|
||||
mri: {
|
||||
args: ['a'],
|
||||
alias: {
|
||||
a: "b",
|
||||
c: ['d'],
|
||||
},
|
||||
boolean: ['wat'],
|
||||
default: {
|
||||
foo: 'bar',
|
||||
},
|
||||
string: ['zulu'],
|
||||
unknown: (param: string): boolean => true,
|
||||
},
|
||||
minimist: {
|
||||
string: ['string'],
|
||||
boolean: ['string'],
|
||||
alias: {
|
||||
bar: 'foo',
|
||||
foo: ['bar1', 'bar2'],
|
||||
},
|
||||
default: {
|
||||
foo: 'bar',
|
||||
},
|
||||
stopEarly: true,
|
||||
"--": false,
|
||||
unknown: (param: string): boolean => true,
|
||||
},
|
||||
mainColor: "yellow",
|
||||
subColor: "dim"
|
||||
});
|
||||
|
||||
args.showHelp();
|
||||
|
||||
const x: string = args.sub[0];
|
||||
Vendored
+72
@@ -0,0 +1,72 @@
|
||||
// Type definitions for args 3.0
|
||||
// Project: https://github.com/leo/args#readme
|
||||
// Definitions by: Slessi <https://github.com/Slessi>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare const c: args;
|
||||
export = c;
|
||||
|
||||
interface args {
|
||||
sub: string[];
|
||||
|
||||
option(name: string | [string, string], description: string, defaultValue?: any, init?: OptionInitFunction): args;
|
||||
options(list: Option[]): args;
|
||||
command(name: string, description: string, init?: (name: string, sub: string[], options: ConfigurationOptions) => void, aliases?: string[]): args;
|
||||
example(usage: string, description: string): args;
|
||||
examples(list: Example[]): args;
|
||||
parse(argv: string[], options?: ConfigurationOptions): { [key: string]: any };
|
||||
showHelp(): void;
|
||||
}
|
||||
|
||||
type OptionInitFunction = (value: any) => any;
|
||||
|
||||
interface MriOptions {
|
||||
args?: string[];
|
||||
alias?: {
|
||||
[key: string]: string | string[]
|
||||
};
|
||||
boolean?: string | string[];
|
||||
default?: {
|
||||
[key: string]: any
|
||||
};
|
||||
string?: string | string[];
|
||||
unknown?: (param: string) => boolean;
|
||||
}
|
||||
|
||||
interface MinimistOptions {
|
||||
string?: string | string[];
|
||||
boolean?: boolean | string | string[];
|
||||
alias?: {
|
||||
[key: string]: string | string[]
|
||||
};
|
||||
default?: {
|
||||
[key: string]: any
|
||||
};
|
||||
stopEarly?: boolean;
|
||||
"--"?: boolean;
|
||||
unknown?: (param: string) => boolean;
|
||||
}
|
||||
|
||||
interface ConfigurationOptions {
|
||||
help?: boolean;
|
||||
name?: string;
|
||||
version?: boolean;
|
||||
usageFilter?: (output: any) => any;
|
||||
value?: string;
|
||||
mri: MriOptions;
|
||||
minimist?: MinimistOptions;
|
||||
mainColor: string | string[];
|
||||
subColor: string | string[];
|
||||
}
|
||||
|
||||
interface Option {
|
||||
name: string | [string, string];
|
||||
description: string;
|
||||
init?: OptionInitFunction;
|
||||
defaultValue?: any;
|
||||
}
|
||||
|
||||
interface Example {
|
||||
usage: string;
|
||||
description: string;
|
||||
}
|
||||
@@ -18,6 +18,6 @@
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"left-pad-tests.ts"
|
||||
"args-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@@ -0,0 +1,7 @@
|
||||
import union = require('arr-union');
|
||||
|
||||
// $ExpectType string[]
|
||||
union(['a'], ['b', 'c'], ['d', 'e', 'f']);
|
||||
|
||||
// $ExpectType number[]
|
||||
union([1, 1], [2, 3]);
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
// Type definitions for arr-union 3.1
|
||||
// Project: https://github.com/jonschlinkert/arr-union
|
||||
// Definitions by: mrmlnc <https://github.com/mrmlnc>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare function union<T>(...arrays: Array<ArrayLike<T>>): T[];
|
||||
|
||||
export = union;
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"arr-union-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Vendored
+1
-1
@@ -2,7 +2,7 @@
|
||||
// Project: https://github.com/shoreditch-ops/artillery#readme
|
||||
// Definitions by: Kira McCoan <https://github.com/kmccoan-allocadia>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
// TypeScript Version: 2.3
|
||||
import * as request from 'request';
|
||||
import * as events from 'events';
|
||||
|
||||
|
||||
Vendored
+3
-2
@@ -15,6 +15,7 @@ export interface AsyncResultArrayCallback<T, E> { (err?: E, results?: (T | undef
|
||||
export interface AsyncResultObjectCallback<T, E> { (err: E | undefined, results: Dictionary<T | undefined>): void; }
|
||||
|
||||
export interface AsyncFunction<T, E> { (callback: (err?: E, result?: T) => void): void; }
|
||||
export interface AsyncFunctionEx<T, E> { (callback: (err?: E, ...results: T[]) => void): void; }
|
||||
export interface AsyncIterator<T, E> { (item: T, callback: ErrorCallback<E>): void; }
|
||||
export interface AsyncForEachOfIterator<T, E> { (item: T, key: number|string, callback: ErrorCallback<E>): void; }
|
||||
export interface AsyncResultIterator<T, R, E> { (item: T, callback: AsyncResultCallback<R, E>): void; }
|
||||
@@ -174,9 +175,9 @@ export function parallel<T, E>(tasks: Dictionary<AsyncFunction<T, E>>, callback?
|
||||
export function parallelLimit<T, E>(tasks: Array<AsyncFunction<T, E>>, limit: number, callback?: AsyncResultArrayCallback<T, E>): void;
|
||||
export function parallelLimit<T, E>(tasks: Dictionary<AsyncFunction<T, E>>, limit: number, callback?: AsyncResultObjectCallback<T, E>): void;
|
||||
export function whilst<E>(test: () => boolean, fn: AsyncVoidFunction<E>, callback: ErrorCallback<E>): void;
|
||||
export function doWhilst<E>(fn: AsyncVoidFunction<E>, test: () => boolean, callback: ErrorCallback<E>): void;
|
||||
export function doWhilst<T, E>(fn: AsyncFunctionEx<T, E>, test: (...results: T[]) => boolean, callback: ErrorCallback<E>): void;
|
||||
export function until<E>(test: () => boolean, fn: AsyncVoidFunction<E>, callback: ErrorCallback<E>): void;
|
||||
export function doUntil<E>(fn: AsyncVoidFunction<E>, test: () => boolean, callback: ErrorCallback<E>): void;
|
||||
export function doUntil<T, E>(fn: AsyncFunctionEx<T, E>, test: (...results: T[]) => boolean, callback: ErrorCallback<E>): void;
|
||||
export function during<E>(test: (testCallback : AsyncBooleanResultCallback<E>) => void, fn: AsyncVoidFunction<E>, callback: ErrorCallback<E>): void;
|
||||
export function doDuring<E>(fn: AsyncVoidFunction<E>, test: (testCallback: AsyncBooleanResultCallback<E>) => void, callback: ErrorCallback<E>): void;
|
||||
export function forever<E>(next: (next : ErrorCallback<E>) => void, errBack: ErrorCallback<E>) : void;
|
||||
|
||||
@@ -47,13 +47,13 @@ interface NumberCallback { (err?: Error, result?: number): void; }
|
||||
interface AsyncNumberGetter { (callback: NumberCallback): void; }
|
||||
|
||||
var taskDict: Lookup<AsyncNumberGetter> = {
|
||||
one: function(callback){
|
||||
setTimeout(function(){
|
||||
one: function(callback) {
|
||||
setTimeout(function() {
|
||||
callback(undefined, 1);
|
||||
}, 200);
|
||||
},
|
||||
two: function(callback){
|
||||
setTimeout(function(){
|
||||
two: function(callback) {
|
||||
setTimeout(function() {
|
||||
callback(undefined, 2);
|
||||
}, 100);
|
||||
}
|
||||
|
||||
@@ -239,16 +239,16 @@ async.parallelLimit({
|
||||
|
||||
|
||||
function whileFn(callback: any) {
|
||||
count++;
|
||||
setTimeout(callback, 1000);
|
||||
setTimeout(() => callback(null, ++count), 1000);
|
||||
}
|
||||
|
||||
function whileTest() { return count < 5; }
|
||||
function doWhileTest(count: number) { return count < 5; }
|
||||
var count = 0;
|
||||
async.whilst(whileTest, whileFn, function (err) { });
|
||||
async.until(whileTest, whileFn, function (err) { });
|
||||
async.doWhilst(whileFn, whileTest, function (err) { });
|
||||
async.doUntil(whileFn, whileTest, function (err) { });
|
||||
async.doWhilst(whileFn, doWhileTest, function (err) { });
|
||||
async.doUntil(whileFn, doWhileTest, function (err) { });
|
||||
|
||||
async.during(function (testCallback) { testCallback(new Error(), false); }, function (callback) { callback() }, function (error) { console.log(error) });
|
||||
async.doDuring(function (callback) { callback() }, function (testCallback) { testCallback(new Error(), false); }, function (error) { console.log(error) });
|
||||
|
||||
@@ -0,0 +1,135 @@
|
||||
import { ArrayIterator, AsyncIterator, BufferedIterator, ClonedIterator, EmptyIterator, IntegerIterator,
|
||||
MultiTransformIterator, SingletonIterator, SimpleTransformIterator, TransformIterator } from "asynciterator";
|
||||
|
||||
function test_asynciterator() {
|
||||
// We can't instantiate an abstract class.
|
||||
const it1: AsyncIterator<number> = <any> {};
|
||||
const read1: number = it1.read();
|
||||
it1.each((data: number) => console.log(data));
|
||||
it1.each((data: number) => console.log(data), {});
|
||||
it1.close();
|
||||
|
||||
const it2: AsyncIterator<string> = <any> {};
|
||||
const read2: string = it2.read();
|
||||
it2.each((data: string) => console.log(data));
|
||||
it2.each((data: string) => console.log(data), {});
|
||||
it2.close();
|
||||
|
||||
const it3: AsyncIterator<AsyncIterator<string>> = <any> {};
|
||||
const read3: AsyncIterator<string> = it3.read();
|
||||
it3.each((data: AsyncIterator<string>) => data.each((data: string) => console.log(data)));
|
||||
it3.each((data: AsyncIterator<string>) => data.each((data: string) => console.log(data), {}), {});
|
||||
it3.close();
|
||||
|
||||
const readable2: boolean = it1.readable;
|
||||
const closed2: boolean = it1.closed;
|
||||
const ended2: boolean = it1.ended;
|
||||
|
||||
it1.setProperty('name1', 123);
|
||||
it2.setProperty('name2', 'someValue');
|
||||
const p1: number = it1.getProperty('name1');
|
||||
const p2: string = it1.getProperty('name2');
|
||||
it1.getProperty('name1', (value: number) => console.log(value));
|
||||
it1.getProperty('name2', (value: string) => console.log(value));
|
||||
const ps1: {[id: string]: any} = it1.getProperties();
|
||||
it1.setProperties({ name1: 1234, name2: 'someOtherValue' });
|
||||
it1.copyProperties(it2, [ 'name1', 'name2' ]);
|
||||
|
||||
const str: string = it1.toString();
|
||||
|
||||
const stit1: SimpleTransformIterator<number, string> = it1.transform();
|
||||
const stit2: SimpleTransformIterator<number, string> = it1.map((number: number) => 'i' + number);
|
||||
const stit3: AsyncIterator<string> = it1.map((number: number) => 'i' + number);
|
||||
const stit4: AsyncIterator<number> = it2.map(parseInt);
|
||||
const stit5: AsyncIterator<number> = it1.map((number: number) => number + 1);
|
||||
const stit6: AsyncIterator<number> = it1.filter((number: number) => number < 10);
|
||||
const stit7: AsyncIterator<number> = it1.prepend([0, 1, 2]);
|
||||
const stit8: AsyncIterator<number> = it1.append([0, 1, 2]);
|
||||
const stit9: AsyncIterator<number> = it1.surround([0, 1, 2], [0, 1, 2]);
|
||||
const stit10: AsyncIterator<number> = it1.skip(2);
|
||||
const stit11: AsyncIterator<number> = it1.take(2);
|
||||
const stit12: AsyncIterator<number> = it1.range(2, 20);
|
||||
const stit13: AsyncIterator<number> = it1.clone();
|
||||
|
||||
const intit1: IntegerIterator = AsyncIterator.range(10, 100, 1);
|
||||
const intit2: IntegerIterator = AsyncIterator.range(10, 100);
|
||||
const intit3: IntegerIterator = AsyncIterator.range(10);
|
||||
const intit4: IntegerIterator = AsyncIterator.range();
|
||||
}
|
||||
|
||||
function test_emptyiterator() {
|
||||
const it1: AsyncIterator<number> = new EmptyIterator();
|
||||
const it2: AsyncIterator<string> = new EmptyIterator();
|
||||
}
|
||||
|
||||
function test_singletoniterator() {
|
||||
const it1: AsyncIterator<number> = new SingletonIterator(3);
|
||||
const it2: AsyncIterator<string> = new SingletonIterator('a');
|
||||
}
|
||||
|
||||
function test_arrayiterator() {
|
||||
const it1: AsyncIterator<number> = new ArrayIterator([1, 2, 3]);
|
||||
const it2: AsyncIterator<string> = new ArrayIterator(['a', 'b', 'c']);
|
||||
}
|
||||
|
||||
function test_integeriterator() {
|
||||
const it1: IntegerIterator = new IntegerIterator();
|
||||
const it2: AsyncIterator<number> = new IntegerIterator({});
|
||||
const it3: AsyncIterator<number> = new IntegerIterator({ start: 0 });
|
||||
const it4: AsyncIterator<number> = new IntegerIterator({ end: 100 });
|
||||
const it5: AsyncIterator<number> = new IntegerIterator({ step: 10 });
|
||||
}
|
||||
|
||||
function test_bufferediterator() {
|
||||
const it1: BufferedIterator<number> = new BufferedIterator();
|
||||
const it2: AsyncIterator<number> = new BufferedIterator({});
|
||||
const it3: AsyncIterator<number> = new BufferedIterator({ maxBufferSize: 10 });
|
||||
const it4: AsyncIterator<number> = new BufferedIterator({ autoStart: true });
|
||||
}
|
||||
|
||||
function test_transformiterator() {
|
||||
const it1: TransformIterator<number, string> = new TransformIterator<number, string>();
|
||||
const it2: AsyncIterator<string> = new TransformIterator<number, string>();
|
||||
const it3: AsyncIterator<number> = new TransformIterator<string, number>(it1);
|
||||
const it4: AsyncIterator<number> = new TransformIterator<string, number>(it1, {});
|
||||
const it5: AsyncIterator<number> = new TransformIterator<string, number>(it1, { optional: true });
|
||||
const it6: AsyncIterator<number> = new TransformIterator<string, number>({ source: it1 });
|
||||
|
||||
const source: AsyncIterator<number> = it1.source;
|
||||
}
|
||||
|
||||
function test_simpletransformiterator() {
|
||||
const it1: SimpleTransformIterator<number, string> = new SimpleTransformIterator<number, string>();
|
||||
const it2: TransformIterator<number, string> = new SimpleTransformIterator<number, string>();
|
||||
const it3: AsyncIterator<string> = new SimpleTransformIterator<number, string>();
|
||||
const it4: AsyncIterator<number> = new SimpleTransformIterator<string, number>(it1);
|
||||
const it5: AsyncIterator<number> = new SimpleTransformIterator<string, number>(it1, {});
|
||||
const it6: AsyncIterator<number> = new SimpleTransformIterator<string, number>({});
|
||||
const it7: AsyncIterator<number> = new SimpleTransformIterator<string, number>({ optional: true });
|
||||
const it8: AsyncIterator<number> = new SimpleTransformIterator<string, number>({ source: it1 });
|
||||
const it9: AsyncIterator<number> = new SimpleTransformIterator<string, number>({ offset: 2 });
|
||||
const it10: AsyncIterator<number> = new SimpleTransformIterator<string, number>({ limit: 2 });
|
||||
const it11: AsyncIterator<number> = new SimpleTransformIterator<string, number>({ prepend: [0, 1, 2] });
|
||||
const it12: AsyncIterator<number> = new SimpleTransformIterator<string, number>({ append: [0, 1, 2] });
|
||||
const it13: AsyncIterator<number> = new SimpleTransformIterator<number, number>(
|
||||
{ filter: (val: number) => val > 10 });
|
||||
const it14: AsyncIterator<number> = new SimpleTransformIterator<number, number>({ map: (val: number) => val + 1 });
|
||||
const it15: AsyncIterator<number> = new SimpleTransformIterator<number, number>(
|
||||
{ transform: (val: number, cb: (result: number) => void) => cb(val + 1) });
|
||||
}
|
||||
|
||||
function test_multitransformiterator() {
|
||||
const it1: MultiTransformIterator<number, string> = new MultiTransformIterator<number, string>();
|
||||
const it2: TransformIterator<number, string> = new MultiTransformIterator<number, string>();
|
||||
const it3: AsyncIterator<string> = new MultiTransformIterator<number, string>();
|
||||
const it4: AsyncIterator<number> = new MultiTransformIterator<string, number>(it1);
|
||||
const it5: AsyncIterator<number> = new MultiTransformIterator<string, number>(it1, {});
|
||||
const it6: AsyncIterator<number> = new MultiTransformIterator<string, number>({});
|
||||
const it7: AsyncIterator<number> = new MultiTransformIterator<string, number>({ optional: true });
|
||||
const it8: AsyncIterator<number> = new MultiTransformIterator<string, number>({ source: it1 });
|
||||
}
|
||||
|
||||
function test_clonediterator() {
|
||||
const it1: ClonedIterator<number> = new ClonedIterator<number>();
|
||||
const it2: ClonedIterator<number> = new ClonedIterator<number>(it1);
|
||||
}
|
||||
Vendored
+164
@@ -0,0 +1,164 @@
|
||||
// Type definitions for asynciterator 1.1
|
||||
// Project: https://github.com/rubenverborgh/AsyncIterator#readme
|
||||
// Definitions by: Ruben Taelman <https://github.com/rubensworks>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.4
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
import { EventEmitter } from "events";
|
||||
|
||||
export abstract class AsyncIterator<T> extends NodeJS.EventEmitter {
|
||||
protected static STATES: ['INIT', 'OPEN', 'CLOSING', 'CLOSED', 'ENDED'];
|
||||
protected static INIT: 0;
|
||||
protected static OPEN: 1;
|
||||
protected static CLOSING: 2;
|
||||
protected static CLOSED: 3;
|
||||
protected static ENDED: 4;
|
||||
|
||||
protected _state: number;
|
||||
protected _readable: boolean;
|
||||
protected _destination?: AsyncIterator<any>;
|
||||
|
||||
readable: boolean;
|
||||
closed: boolean;
|
||||
ended: boolean;
|
||||
|
||||
constructor();
|
||||
|
||||
read(): T;
|
||||
each(callback: (data: T) => void, self?: any): void;
|
||||
close(): void;
|
||||
|
||||
protected _changeState(newState: number, eventAsync?: boolean): void;
|
||||
private _hasListeners(eventName: string | symbol): boolean;
|
||||
// tslint:disable-next-line ban-types
|
||||
private _addSingleListener(eventName: string | symbol, listener: Function): void;
|
||||
protected _end(): void;
|
||||
|
||||
getProperty(propertyName: string, callback?: (value: any) => void): any;
|
||||
setProperty(propertyName: string, value: any): void;
|
||||
getProperties(): {[id: string]: any};
|
||||
setProperties(properties: {[id: string]: any}): void;
|
||||
copyProperties(source: AsyncIterator<any>, propertyNames: string[]): void;
|
||||
|
||||
toString(): string;
|
||||
protected _toStringDetails(): string;
|
||||
|
||||
transform<T2>(options?: SimpleTransformIteratorOptions<T, T2>): SimpleTransformIterator<T, T2>;
|
||||
map<T2>(mapper: (item: T) => T2, self?: object): SimpleTransformIterator<T, T2>;
|
||||
filter(filter: (item: T) => boolean, self?: object): SimpleTransformIterator<T, T>;
|
||||
prepend(items: T[]): SimpleTransformIterator<T, T>;
|
||||
append<T>(items: T[]): SimpleTransformIterator<T, T>;
|
||||
surround<T>(prepend: T[], append: T[]): SimpleTransformIterator<T, T>;
|
||||
skip<T>(offset: number): SimpleTransformIterator<T, T>;
|
||||
take<T>(limit: number): SimpleTransformIterator<T, T>;
|
||||
range<T>(start: number, end: number): SimpleTransformIterator<T, T>;
|
||||
clone(): ClonedIterator<T>;
|
||||
|
||||
static range(start?: number, end?: number, step?: number): IntegerIterator;
|
||||
}
|
||||
|
||||
export class EmptyIterator<T> extends AsyncIterator<T> {
|
||||
_state: 4;
|
||||
}
|
||||
|
||||
export class SingletonIterator<T> extends AsyncIterator<T> {
|
||||
constructor(item?: T);
|
||||
}
|
||||
|
||||
export class ArrayIterator<T> extends AsyncIterator<T> {
|
||||
constructor(items?: T[]);
|
||||
}
|
||||
|
||||
export interface IntegerIteratorOptions {
|
||||
step?: number;
|
||||
end?: number;
|
||||
start?: number;
|
||||
}
|
||||
|
||||
export class IntegerIterator extends AsyncIterator<number> {
|
||||
protected _step: number;
|
||||
protected _last: number;
|
||||
protected _next: number;
|
||||
|
||||
constructor(options?: IntegerIteratorOptions);
|
||||
}
|
||||
|
||||
export interface BufferedIteratorOptions {
|
||||
maxBufferSize?: number;
|
||||
autoStart?: boolean;
|
||||
}
|
||||
|
||||
export class BufferedIterator<T> extends AsyncIterator<T> {
|
||||
maxBufferSize: number;
|
||||
protected _pushedCount: number;
|
||||
protected _buffer: T[];
|
||||
|
||||
protected _init(autoStart: boolean): void;
|
||||
protected _begin(done: () => void): void;
|
||||
protected _read(count: number, done: () => void): void;
|
||||
protected _push(item: T): void;
|
||||
protected _fillBuffer(): void;
|
||||
protected _completeClose(): void;
|
||||
protected _flush(done: () => void): void;
|
||||
|
||||
constructor(options?: BufferedIteratorOptions);
|
||||
}
|
||||
|
||||
export interface TransformIteratorOptions<S> extends BufferedIteratorOptions {
|
||||
optional?: boolean;
|
||||
source?: AsyncIterator<S>;
|
||||
}
|
||||
|
||||
export class TransformIterator<S, T> extends BufferedIterator<T> {
|
||||
protected _optional: boolean;
|
||||
source: AsyncIterator<S>;
|
||||
|
||||
protected _validateSource(source: AsyncIterator<S>, allowDestination?: boolean): void;
|
||||
protected _transform(item: S, done: (result: T) => void): void;
|
||||
protected _closeWhenDone(): void;
|
||||
|
||||
constructor(source?: AsyncIterator<S> | TransformIteratorOptions<S>, options?: TransformIteratorOptions<S>);
|
||||
}
|
||||
|
||||
export interface SimpleTransformIteratorOptions<S, T> extends TransformIteratorOptions<S> {
|
||||
offset?: number;
|
||||
limit?: number;
|
||||
prepend?: T[];
|
||||
append?: T[];
|
||||
|
||||
filter?(item: S): boolean;
|
||||
map?(item: S): T;
|
||||
transform?(item: S, callback: (result: T) => void): void;
|
||||
}
|
||||
|
||||
export class SimpleTransformIterator<S, T> extends TransformIterator<S, T> {
|
||||
protected _offset: number;
|
||||
protected _limit: number;
|
||||
protected _prepender?: ArrayIterator<T>;
|
||||
protected _appender?: ArrayIterator<T>;
|
||||
|
||||
protected _filter?(item: S): boolean;
|
||||
protected _map?(item: S): T;
|
||||
protected _transform(item: S, done: (result: T) => void): void;
|
||||
|
||||
protected _insert(inserter: AsyncIterator<S>, done: () => void): void;
|
||||
|
||||
constructor(source?: AsyncIterator<S> | SimpleTransformIteratorOptions<S, T>,
|
||||
options?: SimpleTransformIteratorOptions<S, T>);
|
||||
}
|
||||
|
||||
export class MultiTransformIterator<S, T> extends TransformIterator<S, T> {
|
||||
_transformerQueue: S[];
|
||||
|
||||
protected _createTransformer(): AsyncIterator<S>;
|
||||
|
||||
constructor(source?: AsyncIterator<S> | TransformIteratorOptions<S>, options?: TransformIteratorOptions<S>);
|
||||
}
|
||||
|
||||
export class ClonedIterator<T> extends TransformIterator<T, T> {
|
||||
_readPosition: number;
|
||||
|
||||
constructor(source?: AsyncIterator<T>);
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"asynciterator-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@@ -1,8 +1,9 @@
|
||||
import { Disposable } from "event-kit";
|
||||
import KeymapManager = require("atom-keymap");
|
||||
import * as ImportTest from "atom-keymap";
|
||||
|
||||
declare const element: HTMLElement;
|
||||
declare let sub: EventKit.Disposable;
|
||||
declare let sub: Disposable;
|
||||
declare const event: KeyboardEvent;
|
||||
|
||||
// NPM Examples ===============================================================
|
||||
|
||||
Vendored
+36
-24
@@ -2,17 +2,19 @@
|
||||
// Project: https://github.com/atom/atom-keymap
|
||||
// Definitions by: GlenCFL <https://github.com/GlenCFL>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
/// <reference types="event-kit" />
|
||||
import { Disposable } from "event-kit";
|
||||
|
||||
declare global {
|
||||
namespace AtomKeymap {
|
||||
/** The event objects that are passed into the callbacks which the user provides to
|
||||
/**
|
||||
* The event objects that are passed into the callbacks which the user provides to
|
||||
* specific API calls.
|
||||
*/
|
||||
namespace Events {
|
||||
/** This custom subclass of CustomEvent exists to provide the ::abortKeyBinding
|
||||
/**
|
||||
* This custom subclass of CustomEvent exists to provide the ::abortKeyBinding
|
||||
* method, as well as versions of the ::stopPropagation methods that record the
|
||||
* intent to stop propagation so event bubbling can be properly simulated for
|
||||
* detached elements.
|
||||
@@ -70,12 +72,14 @@ declare global {
|
||||
}
|
||||
|
||||
interface AddedKeystrokeResolver {
|
||||
/** The currently resolved keystroke string. If your function returns a falsy
|
||||
/**
|
||||
* The currently resolved keystroke string. If your function returns a falsy
|
||||
* value, this is how Atom will resolve your keystroke.
|
||||
*/
|
||||
keystroke: string;
|
||||
|
||||
/** The raw DOM 3 `KeyboardEvent` being resolved. See the DOM API documentation
|
||||
/**
|
||||
* The raw DOM 3 `KeyboardEvent` being resolved. See the DOM API documentation
|
||||
* for more details.
|
||||
*/
|
||||
event: KeyboardEvent;
|
||||
@@ -83,7 +87,8 @@ declare global {
|
||||
/** The OS-specific name of the current keyboard layout. */
|
||||
layoutName: string;
|
||||
|
||||
/** An object mapping DOM 3 `KeyboardEvent.code` values to objects with the
|
||||
/**
|
||||
* An object mapping DOM 3 `KeyboardEvent.code` values to objects with the
|
||||
* typed character for that key in each modifier state, based on the current
|
||||
* operating system layout.
|
||||
*/
|
||||
@@ -91,7 +96,8 @@ declare global {
|
||||
}
|
||||
}
|
||||
|
||||
/** The option objects that the user is expected to fill out and provide to
|
||||
/**
|
||||
* The option objects that the user is expected to fill out and provide to
|
||||
* specific API calls.
|
||||
*/
|
||||
namespace Options {
|
||||
@@ -120,7 +126,8 @@ declare global {
|
||||
/** Determines whether the given keystroke matches any contained within this binding. */
|
||||
matches(keystroke: string): boolean;
|
||||
|
||||
/** Compare another KeyBinding to this instance.
|
||||
/**
|
||||
* Compare another KeyBinding to this instance.
|
||||
* Returns <= -1 if the argument is considered lesser or of lower priority.
|
||||
* Returns 0 if this binding is equivalent to the argument.
|
||||
* Returns >= 1 if the argument is considered greater or of higher priority.
|
||||
@@ -128,7 +135,8 @@ declare global {
|
||||
compare(other: KeyBinding): number;
|
||||
}
|
||||
|
||||
/** Allows commands to be associated with keystrokes in a context-sensitive way.
|
||||
/**
|
||||
* Allows commands to be associated with keystrokes in a context-sensitive way.
|
||||
* In Atom, you can access a global instance of this object via `atom.keymaps`.
|
||||
*/
|
||||
interface KeymapManager {
|
||||
@@ -143,29 +151,30 @@ declare global {
|
||||
destroy(): void;
|
||||
|
||||
// Event Subscription
|
||||
/** Invoke the given callback when one or more keystrokes completely match a key binding. */
|
||||
/**
|
||||
* Invoke the given callback when one or more keystrokes completely match a
|
||||
* key binding.
|
||||
*/
|
||||
onDidMatchBinding(callback: (event: Events.FullKeybindingMatch) => void):
|
||||
EventKit.Disposable;
|
||||
Disposable;
|
||||
|
||||
/** Invoke the given callback when one or more keystrokes partially match a binding. */
|
||||
onDidPartiallyMatchBindings(callback: (event: Events.PartialKeybindingMatch) =>
|
||||
void): EventKit.Disposable;
|
||||
void): Disposable;
|
||||
|
||||
/** Invoke the given callback when one or more keystrokes fail to match any bindings. */
|
||||
onDidFailToMatchBinding(callback: (event: Events.FailedKeybindingMatch) =>
|
||||
void): EventKit.Disposable;
|
||||
void): Disposable;
|
||||
|
||||
/** Invoke the given callback when a keymap file is reloaded. */
|
||||
onDidReloadKeymap(callback: (event: Events.KeymapLoaded) => void):
|
||||
EventKit.Disposable;
|
||||
onDidReloadKeymap(callback: (event: Events.KeymapLoaded) => void): Disposable;
|
||||
|
||||
/** Invoke the given callback when a keymap file is unloaded. */
|
||||
onDidUnloadKeymap(callback: (event: Events.KeymapLoaded) => void):
|
||||
EventKit.Disposable;
|
||||
onDidUnloadKeymap(callback: (event: Events.KeymapLoaded) => void): Disposable;
|
||||
|
||||
/** Invoke the given callback when a keymap file not able to be loaded. */
|
||||
onDidFailToReadFile(callback: (error: Events.FailedKeymapFileRead) => void):
|
||||
EventKit.Disposable;
|
||||
Disposable;
|
||||
|
||||
// Adding and Removing Bindings
|
||||
/** Construct KeyBindings from an object grouping them by CSS selector. */
|
||||
@@ -174,7 +183,7 @@ declare global {
|
||||
|
||||
/** Add sets of key bindings grouped by CSS selector. */
|
||||
add(source: string, bindings: { [key: string]: { [key: string]: string }},
|
||||
priority?: number): EventKit.Disposable;
|
||||
priority?: number): Disposable;
|
||||
|
||||
// Accessing Bindings
|
||||
/** Get all current key bindings. */
|
||||
@@ -192,13 +201,15 @@ declare global {
|
||||
loadKeymap(bindingsPath: string, options?: { watch?: boolean, priority?: number }):
|
||||
void;
|
||||
|
||||
/** Cause the keymap to reload the key bindings file at the given path whenever
|
||||
/**
|
||||
* Cause the keymap to reload the key bindings file at the given path whenever
|
||||
* it changes.
|
||||
*/
|
||||
watchKeymap(filePath: string, options?: { priority: number }): void;
|
||||
|
||||
// Managing Keyboard Events
|
||||
/** Dispatch a custom event associated with the matching key binding for the
|
||||
/**
|
||||
* Dispatch a custom event associated with the matching key binding for the
|
||||
* given `KeyboardEvent` if one can be found.
|
||||
*/
|
||||
handleKeyboardEvent(event: KeyboardEvent): void;
|
||||
@@ -208,9 +219,10 @@ declare global {
|
||||
|
||||
/** Customize translation of raw keyboard events to keystroke strings. */
|
||||
addKeystrokeResolver(resolver: (event: Events.AddedKeystrokeResolver) => string):
|
||||
EventKit.Disposable;
|
||||
Disposable;
|
||||
|
||||
/** Get the number of milliseconds allowed before pending states caused by
|
||||
/**
|
||||
* Get the number of milliseconds allowed before pending states caused by
|
||||
* partial matches of multi-keystroke bindings are terminated.
|
||||
*/
|
||||
getPartialMatchTimeout(): number;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": false,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
|
||||
@@ -1,36 +1,8 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"class-name": true,
|
||||
"indent": [true, "spaces", 4],
|
||||
"jsdoc-format": true,
|
||||
"max-line-length": [true, 110],
|
||||
"quotemark": [true, "double", "avoid-escape"],
|
||||
"trailing-comma": [true, {
|
||||
"multiline": { "objects": "always", "arrays": "always", "functions": "never" },
|
||||
"singleline": { "objects": "never", "arrays": "never", "functions": "never" }
|
||||
}],
|
||||
"whitespace": [
|
||||
true,
|
||||
"check-branch",
|
||||
"check-decl",
|
||||
"check-operator",
|
||||
"check-module",
|
||||
"check-separator",
|
||||
"check-type",
|
||||
"check-typecast",
|
||||
"check-rest-spread",
|
||||
"check-preblock"
|
||||
],
|
||||
// Soon to be defaults.
|
||||
"arrow-return-shorthand": [true, "multiline"],
|
||||
"no-any": true,
|
||||
"no-floating-promises": true,
|
||||
"no-unbound-method": true,
|
||||
"no-unsafe-any": true,
|
||||
"number-literal-format": true,
|
||||
"restrict-plus-operands": true,
|
||||
"return-undefined": true,
|
||||
"switch-final-break": true
|
||||
"max-line-length": [true, 100],
|
||||
"no-any": true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { AtomEnvironment, TestRunnerParams } from "atom";
|
||||
import { createRunner } from "atom-mocha-test-runner";
|
||||
import defaultMochaRunner = require("atom-mocha-test-runner");
|
||||
|
||||
@@ -20,12 +21,12 @@ testRunner = createRunner({
|
||||
testSuffixes: ["test.file"],
|
||||
});
|
||||
|
||||
declare const atom: AtomCore.AtomEnvironment;
|
||||
declare const atom: AtomEnvironment;
|
||||
declare const blob: object;
|
||||
declare let num: number;
|
||||
|
||||
async function runTests(): Promise<number> {
|
||||
const runnerArgs: AtomCore.Structures.TestRunnerArgs = {
|
||||
const runnerArgs: TestRunnerParams = {
|
||||
testPaths: ["/var/test"],
|
||||
logFile: "/var/log",
|
||||
headless: false,
|
||||
|
||||
+4
-3
@@ -5,7 +5,8 @@
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
/// <reference types="mocha" />
|
||||
/// <reference types="atom" />
|
||||
|
||||
import { TestRunner } from "atom";
|
||||
|
||||
interface AtomMochaOptions {
|
||||
/** Which reporter to use on the terminal. */
|
||||
@@ -30,9 +31,9 @@ interface AtomMochaOptions {
|
||||
// module.exports = createRunner()
|
||||
// module.exports.createRunner = createRunner
|
||||
// Which is what we're trying to model here.
|
||||
interface TestRunnerExport extends AtomCore.TestRunner {
|
||||
interface TestRunnerExport extends TestRunner {
|
||||
createRunner(options?: AtomMochaOptions, mochaConfigFunction?:
|
||||
(mocha: Mocha) => void): AtomCore.TestRunner;
|
||||
(mocha: Mocha) => void): TestRunner;
|
||||
}
|
||||
|
||||
declare const runner: TestRunnerExport;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": false,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
|
||||
@@ -1,36 +1,8 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"class-name": true,
|
||||
"indent": [true, "spaces", 4],
|
||||
"jsdoc-format": true,
|
||||
"max-line-length": [true, 100],
|
||||
"quotemark": [true, "double", "avoid-escape"],
|
||||
"trailing-comma": [true, {
|
||||
"multiline": { "objects": "always", "arrays": "always", "functions": "never" },
|
||||
"singleline": { "objects": "never", "arrays": "never", "functions": "never" }
|
||||
}],
|
||||
"whitespace": [
|
||||
true,
|
||||
"check-branch",
|
||||
"check-decl",
|
||||
"check-operator",
|
||||
"check-module",
|
||||
"check-separator",
|
||||
"check-type",
|
||||
"check-typecast",
|
||||
"check-rest-spread",
|
||||
"check-preblock"
|
||||
],
|
||||
// Soon to be defaults.
|
||||
"arrow-return-shorthand": [true, "multiline"],
|
||||
"no-any": true,
|
||||
"no-floating-promises": true,
|
||||
"no-unbound-method": true,
|
||||
"no-unsafe-any": true,
|
||||
"number-literal-format": true,
|
||||
"restrict-plus-operands": true,
|
||||
"return-undefined": true,
|
||||
"switch-final-break": true
|
||||
"no-any": true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
## Atom API Type Definitions
|
||||
|
||||
TypeScript type definitions for the [Atom Text Editor](https://atom.io/) public API, which is used to develop packages for the editor. Documentation for the public API can be found [here](https://atom.io/docs/api/v1.21.0/).
|
||||
|
||||
### Exports
|
||||
|
||||
#### The "atom" Variable
|
||||
|
||||
These definitions declare a global static variable named "atom" as ambient. Once these definitions have been referenced within your project, you will be able to access properties and member functions from the [AtomEnvironment](https://atom.io/docs/api/v1.21.0/AtomEnvironment) class off of this variable, as it is an instance of that class.
|
||||
|
||||
```ts
|
||||
if (atom.inDevMode()) {}
|
||||
```
|
||||
|
||||
#### The Atom Namespace
|
||||
|
||||
All of the types used by or referenced by the Atom public API have been pulled into the Atom namespace, providing a consistent and easy way to access each of them, without having to care about where that type actually lives within the Atom codebase.
|
||||
|
||||
```ts
|
||||
function example(buffer: Atom.TextBuffer) {}
|
||||
```
|
||||
|
||||
#### The AtomCore Namespace
|
||||
|
||||
All classes which are core to Atom itself have been provided under the AtomCore namespace.
|
||||
|
||||
```ts
|
||||
function example(cursor: AtomCore.Cursor) {}
|
||||
```
|
||||
|
||||
### Service Type Definitions
|
||||
|
||||
There are many services provided by other Atom packages that you may want to use within your own Atom package. We bundle type definitions for several of these services with these type definitions. All type definitions for services are available only through ES6 imports.
|
||||
|
||||
```ts
|
||||
import { AutocompleteProvider } from "atom/autocomplete-plus";
|
||||
let completionProvider: AutocompleteProvider;
|
||||
```
|
||||
|
||||
The currently supported services are:
|
||||
- [Autocomplete](https://github.com/atom/autocomplete-plus) (atom/autocomplete-plus)
|
||||
- [Linter](https://github.com/atom/linter) (atom/linter)
|
||||
- [Status Bar](https://github.com/atom/status-bar) (atom/status-bar)
|
||||
|
||||
### Exposing Private Methods and Properties
|
||||
|
||||
[Declaration Merging](https://www.typescriptlang.org/docs/handbook/declaration-merging.html) can be used to augment any of the types used within Atom. As an example, if we wanted to reveal the private ```triggerActivationHook``` method within the PackageManager class, then we would create a file with the following contents:
|
||||
|
||||
```ts
|
||||
// <<filename>>.d.ts
|
||||
|
||||
declare namespace AtomCore {
|
||||
interface PackageManager {
|
||||
triggerActivationHook(name: string): void;
|
||||
triggerDeferredActivationHooks(): void;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Once this file is either referenced or included within your project, then this new member function would be freely usable on instances of the PackageManager class without TypeScript reporting errors.
|
||||
+108
-83
@@ -12,59 +12,59 @@ declare let regExp: RegExp;
|
||||
declare let element: HTMLElement;
|
||||
declare let elements: HTMLElement[];
|
||||
declare const div: HTMLDivElement;
|
||||
declare const keyboardEvent: KeyboardEvent;
|
||||
declare const event: KeyboardEvent;
|
||||
|
||||
declare let buffer: TextBuffer.TextBuffer;
|
||||
declare const color: AtomCore.Color;
|
||||
declare let cursor: AtomCore.Cursor;
|
||||
declare let cursors: AtomCore.Cursor[];
|
||||
declare let decoration: AtomCore.Decoration;
|
||||
declare let decorations: AtomCore.Decoration[];
|
||||
declare let decorationLayerProps: AtomCore.Options.DecorationLayerProps;
|
||||
declare let dir: PathWatcher.Directory;
|
||||
declare let dirs: PathWatcher.Directory[];
|
||||
declare let displayMarker: TextBuffer.DisplayMarker;
|
||||
declare let displayMarkers: TextBuffer.DisplayMarker[];
|
||||
declare let displayMarkerLayer: TextBuffer.DisplayMarkerLayer;
|
||||
declare let dock: AtomCore.Dock;
|
||||
declare let editor: AtomCore.TextEditor;
|
||||
declare let editors: AtomCore.TextEditor[];
|
||||
declare let emitter: EventKit.Emitter;
|
||||
declare let file: PathWatcher.File;
|
||||
declare let grammar: FirstMate.Grammar;
|
||||
declare let grammars: FirstMate.Grammar[];
|
||||
declare let gutter: AtomCore.Gutter;
|
||||
declare let gutters: AtomCore.Gutter[];
|
||||
declare let historyPaths: AtomCore.Structures.HistoryProject[];
|
||||
declare let layerDecoration: AtomCore.LayerDecoration;
|
||||
declare let marker: TextBuffer.Marker;
|
||||
declare let markers: TextBuffer.Marker[];
|
||||
declare let markerLayer: TextBuffer.MarkerLayer;
|
||||
declare let notification: AtomCore.Notification;
|
||||
declare let notifications: AtomCore.Notification[];
|
||||
declare let pack: AtomCore.Package;
|
||||
declare let packs: AtomCore.Package[];
|
||||
declare let pane: AtomCore.Pane;
|
||||
declare let panes: AtomCore.Pane[];
|
||||
declare let paneContainer: AtomCore.Dock|AtomCore.WorkspaceCenter;
|
||||
declare let panel: AtomCore.Panel;
|
||||
declare let panels: AtomCore.Panel[];
|
||||
declare let pos: TextBuffer.Point;
|
||||
declare let posArr: TextBuffer.Point[];
|
||||
declare let project: AtomCore.Project;
|
||||
declare let range: TextBuffer.Range;
|
||||
declare let ranges: TextBuffer.Range[];
|
||||
declare let registry: FirstMate.GrammarRegistry;
|
||||
declare let repository: AtomCore.GitRepository;
|
||||
declare let repositories: AtomCore.GitRepository[];
|
||||
declare let scopeDescriptor: AtomCore.ScopeDescriptor;
|
||||
declare let selection: AtomCore.Selection;
|
||||
declare let selections: AtomCore.Selection[];
|
||||
declare let styleManager: AtomCore.StyleManager;
|
||||
declare let subscription: EventKit.Disposable;
|
||||
declare let subscriptions: EventKit.CompositeDisposable;
|
||||
declare let tooltips: AtomCore.Structures.Tooltip[];
|
||||
declare let workspaceCenter: AtomCore.WorkspaceCenter;
|
||||
declare let buffer: Atom.TextBuffer;
|
||||
declare const color: Atom.Color;
|
||||
declare let cursor: Atom.Cursor;
|
||||
declare let cursors: Atom.Cursor[];
|
||||
declare let decoration: Atom.Decoration;
|
||||
declare let decorations: Atom.Decoration[];
|
||||
declare let decorationLayerProps: Atom.DecorationLayerOptions;
|
||||
declare let dir: Atom.Directory;
|
||||
declare let dirs: Atom.Directory[];
|
||||
declare let displayMarker: Atom.DisplayMarker;
|
||||
declare let displayMarkers: Atom.DisplayMarker[];
|
||||
declare let displayMarkerLayer: Atom.DisplayMarkerLayer;
|
||||
declare let dock: Atom.Dock;
|
||||
declare let editor: Atom.TextEditor;
|
||||
declare let editors: Atom.TextEditor[];
|
||||
declare let emitter: Atom.Emitter;
|
||||
declare let file: Atom.File;
|
||||
declare let grammar: Atom.Grammar;
|
||||
declare let grammars: Atom.Grammar[];
|
||||
declare let gutter: Atom.Gutter;
|
||||
declare let gutters: Atom.Gutter[];
|
||||
declare let historyPaths: Atom.ProjectHistory[];
|
||||
declare let layerDecoration: Atom.LayerDecoration;
|
||||
declare let marker: Atom.Marker;
|
||||
declare let markers: Atom.Marker[];
|
||||
declare let markerLayer: Atom.MarkerLayer;
|
||||
declare let notification: Atom.Notification;
|
||||
declare let notifications: Atom.Notification[];
|
||||
declare let pack: Atom.Package;
|
||||
declare let packs: Atom.Package[];
|
||||
declare let pane: Atom.Pane;
|
||||
declare let panes: Atom.Pane[];
|
||||
declare let paneContainer: Atom.Dock|Atom.WorkspaceCenter;
|
||||
declare let panel: Atom.Panel;
|
||||
declare let panels: Atom.Panel[];
|
||||
declare let pos: Atom.Point;
|
||||
declare let posArr: Atom.Point[];
|
||||
declare let project: Atom.Project;
|
||||
declare let range: Atom.Range;
|
||||
declare let ranges: Atom.Range[];
|
||||
declare let registry: Atom.GrammarRegistry;
|
||||
declare let repository: Atom.GitRepository;
|
||||
declare let repositories: Atom.GitRepository[];
|
||||
declare let scopeDescriptor: Atom.ScopeDescriptor;
|
||||
declare let selection: Atom.Selection;
|
||||
declare let selections: Atom.Selection[];
|
||||
declare let styleManager: Atom.StyleManager;
|
||||
declare let subscription: Atom.Disposable;
|
||||
declare let subscriptions: Atom.CompositeDisposable;
|
||||
declare let tooltips: Atom.Tooltip[];
|
||||
declare let workspaceCenter: Atom.WorkspaceCenter;
|
||||
|
||||
// AtomEnvironment ============================================================
|
||||
function testAtomEnvironment() {
|
||||
@@ -125,8 +125,8 @@ function testAtomEnvironment() {
|
||||
});
|
||||
|
||||
subscription = atom.workspace.observeTextEditors((editor) => {
|
||||
subscription = editor.onDidStopChanging((keyboardEvent) => {
|
||||
for (const change of keyboardEvent.changes) {
|
||||
subscription = editor.onDidStopChanging((event) => {
|
||||
for (const change of event.changes) {
|
||||
change.newExtent;
|
||||
}
|
||||
});
|
||||
@@ -276,9 +276,6 @@ function testCommandRegistry() {
|
||||
|
||||
// CompositeDisposable ========================================================
|
||||
function testCompositeDisposable() {
|
||||
// Properties
|
||||
bool = subscriptions.disposed;
|
||||
|
||||
// Construction and Lifecycle
|
||||
subscriptions = new Atom.CompositeDisposable();
|
||||
new Atom.CompositeDisposable(subscription);
|
||||
@@ -482,7 +479,7 @@ function testCursor() {
|
||||
|
||||
// TestRunner =================================================================
|
||||
function testTestRunner() {
|
||||
const testRunner: AtomCore.TestRunner = (params) => {
|
||||
const testRunner: Atom.TestRunner = (params) => {
|
||||
const delegate = params.buildDefaultApplicationDelegate();
|
||||
const environment = params.buildAtomEnvironment({
|
||||
applicationDelegate: delegate,
|
||||
@@ -803,7 +800,6 @@ function testDisplayMarkerLayer() {
|
||||
|
||||
// Disposable =================================================================
|
||||
function testDisposable() {
|
||||
bool = subscription.disposed;
|
||||
if (subscription.disposalAction) subscription.disposalAction();
|
||||
subscription.dispose();
|
||||
}
|
||||
@@ -829,8 +825,12 @@ function testDock() {
|
||||
subscription = dock.onDidChangeActivePane(pane => pane.activate());
|
||||
subscription = dock.observeActivePane(pane => pane.activate());
|
||||
subscription = dock.onDidAddPaneItem(event => event.index && event.item && event.pane);
|
||||
subscription = dock.onWillDestroyPaneItem(event => event.index && event.item && event.pane);
|
||||
subscription = dock.onDidDestroyPaneItem(event => event.index && event.item && event.pane);
|
||||
subscription = dock.onWillDestroyPaneItem(event => {
|
||||
event.index && event.item && event.pane;
|
||||
});
|
||||
subscription = dock.onDidDestroyPaneItem(event => {
|
||||
event.index && event.item && event.pane;
|
||||
});
|
||||
|
||||
// Pane Items
|
||||
objs = dock.getPaneItems();
|
||||
@@ -844,11 +844,12 @@ function testDock() {
|
||||
}
|
||||
|
||||
// Emitter ====================================================================
|
||||
interface TestEmissions {
|
||||
"test-event": string;
|
||||
}
|
||||
|
||||
function testEmitter() {
|
||||
emitter = new Atom.Emitter();
|
||||
|
||||
bool = emitter.disposed;
|
||||
|
||||
emitter.clear();
|
||||
emitter.dispose();
|
||||
|
||||
@@ -860,6 +861,27 @@ function testEmitter() {
|
||||
// Event Emission
|
||||
emitter.emit("test-event");
|
||||
emitter.emit("test-event", 42);
|
||||
|
||||
// Optional Value Emitter
|
||||
const optEmitter = new Atom.Emitter<{ "test-event": string }>();
|
||||
optEmitter.emit("test-event");
|
||||
optEmitter.emit("test-event", "test");
|
||||
optEmitter.on("test-event", value => {
|
||||
str = value ? value : "";
|
||||
});
|
||||
|
||||
// Required Value Emitter
|
||||
const reqEmitter = new Atom.Emitter<{}, TestEmissions>();
|
||||
reqEmitter.on("test-event", value => {
|
||||
str = value;
|
||||
});
|
||||
reqEmitter.emit("test-event", "test");
|
||||
|
||||
// Mixed Value Emitter
|
||||
const mixedEmitter = new Atom.Emitter<{ "t1": "test" }, { "t2": "test" }>();
|
||||
mixedEmitter.emit("t1");
|
||||
mixedEmitter.emit("t1", "test");
|
||||
mixedEmitter.emit("t2", "test");
|
||||
}
|
||||
|
||||
// File =======================================================================
|
||||
@@ -1113,7 +1135,7 @@ function testKeymapManager() {
|
||||
subscription = manager.add("a", {}, 0);
|
||||
|
||||
// Accessing Bindings
|
||||
let bindings: AtomKeymap.KeyBinding[] = manager.getKeyBindings();
|
||||
let bindings: Atom.KeyBinding[] = manager.getKeyBindings();
|
||||
bindings = manager.findKeyBindings();
|
||||
bindings = manager.findKeyBindings({ command: "a" });
|
||||
bindings = manager.findKeyBindings({ keystrokes: "a" });
|
||||
@@ -1127,8 +1149,8 @@ function testKeymapManager() {
|
||||
manager.loadKeymap("Test.file", { watch: true, priority: 0});
|
||||
|
||||
// Managing Keyboard Events
|
||||
manager.handleKeyboardEvent(keyboardEvent);
|
||||
manager.keystrokeForKeyboardEvent(keyboardEvent);
|
||||
manager.handleKeyboardEvent(event);
|
||||
manager.keystrokeForKeyboardEvent(event);
|
||||
|
||||
subscription = manager.addKeystrokeResolver((event): string => {
|
||||
event.layoutName;
|
||||
@@ -1151,10 +1173,6 @@ function testLayerDecoration() {
|
||||
function testMarker() {
|
||||
// Properties
|
||||
num = marker.id;
|
||||
bool = marker.tailed;
|
||||
bool = marker.reversed;
|
||||
bool = marker.valid;
|
||||
str = marker.invalidate;
|
||||
|
||||
// Lifecycle
|
||||
marker = marker.copy({
|
||||
@@ -1301,8 +1319,8 @@ function testNotification() {
|
||||
});
|
||||
|
||||
// Event Subscription
|
||||
subscription = notification.onDidDismiss(notification => notification.dismissed);
|
||||
subscription = notification.onDidDisplay(notification => notification.timestamp);
|
||||
subscription = notification.onDidDismiss(notification => notification.getType());
|
||||
subscription = notification.onDidDisplay(notification => notification.getMessage());
|
||||
|
||||
// Methods
|
||||
str = notification.getType();
|
||||
@@ -1377,7 +1395,7 @@ function testPackageManager() {
|
||||
subscription = atom.packages.onDidActivatePackage(pack => pack.name);
|
||||
subscription = atom.packages.onDidDeactivatePackage(pack => pack.path);
|
||||
subscription = atom.packages.onDidLoadPackage(pack => pack.isCompatible());
|
||||
subscription = atom.packages.onDidUnloadPackage(pack => pack.bundledPackage);
|
||||
subscription = atom.packages.onDidUnloadPackage(pack => pack.name);
|
||||
|
||||
// Package system data
|
||||
str = atom.packages.getApmPath();
|
||||
@@ -1618,7 +1636,7 @@ function testPoint() {
|
||||
point.isGreaterThanOrEqual([0, 0]);
|
||||
|
||||
// Operations
|
||||
const frozenPoint: Readonly<TextBuffer.Point> = point.freeze();
|
||||
const frozenPoint: Readonly<Atom.Point> = point.freeze();
|
||||
|
||||
point = point.translate(point);
|
||||
point.translate([0, 0]);
|
||||
@@ -1644,7 +1662,7 @@ function testProject() {
|
||||
});
|
||||
|
||||
subscription = project.onDidAddBuffer(buffer => buffer.id);
|
||||
subscription = project.observeBuffers(buffer => buffer.file);
|
||||
subscription = project.observeBuffers(buffer => buffer.getUri());
|
||||
|
||||
// Accessing the git repository
|
||||
repositories = project.getRepositories();
|
||||
@@ -1707,7 +1725,7 @@ function testRange() {
|
||||
nums = range.getRows();
|
||||
|
||||
// Operations
|
||||
const frozenRange: Readonly<TextBuffer.Range> = range.freeze();
|
||||
const frozenRange: Readonly<Atom.Range> = range.freeze();
|
||||
range = range.union(range);
|
||||
|
||||
range = range.translate(pos);
|
||||
@@ -1923,7 +1941,7 @@ function testStyleManager() {
|
||||
|
||||
// Task =======================================================================
|
||||
function testTask() {
|
||||
let task: AtomCore.Task = Atom.Task.once("File.path", {}, () => {});
|
||||
let task: Atom.Task = Atom.Task.once("File.path", {}, () => {});
|
||||
task = new Atom.Task("File.path");
|
||||
|
||||
task.start({}, () => {});
|
||||
@@ -2282,7 +2300,7 @@ function testTextEditor() {
|
||||
subscription = editor.onDidChangeSoftWrapped(softWrapped => {});
|
||||
subscription = editor.onDidChangeEncoding(encoding => {});
|
||||
subscription = editor.observeGrammar(grammar => grammar.name);
|
||||
subscription = editor.onDidChangeGrammar(grammar => grammar.scopeName);
|
||||
subscription = editor.onDidChangeGrammar(grammar => grammar.name);
|
||||
subscription = editor.onDidChangeModified(modified => {});
|
||||
subscription = editor.onDidConflict(() => {});
|
||||
subscription = editor.onWillInsertText(event => event.cancel && event.text);
|
||||
@@ -2945,7 +2963,7 @@ function testTooltipManager() {
|
||||
subscription = atom.tooltips.add(element, { class: "test-class" });
|
||||
subscription = atom.tooltips.add(element, { placement: "top" });
|
||||
|
||||
subscription = atom.tooltips.add(element, { placement: () => "left" });
|
||||
subscription = atom.tooltips.add(element, { placement: () => "auto left" });
|
||||
|
||||
subscription = atom.tooltips.add(element, { trigger: "click" });
|
||||
subscription = atom.tooltips.add(element, { delay: { hide: 42, show: 42 }});
|
||||
@@ -2997,8 +3015,9 @@ function testWorkspace() {
|
||||
subscription = atom.workspace.observeActivePane(pane => pane.activate());
|
||||
subscription = atom.workspace.onDidAddPaneItem(event => event.index && event.item &&
|
||||
event.pane);
|
||||
subscription = atom.workspace.onWillDestroyPaneItem(event => event.index &&
|
||||
event.item && event.pane);
|
||||
subscription = atom.workspace.onWillDestroyPaneItem(event => {
|
||||
event.index && event.item && event.pane;
|
||||
});
|
||||
subscription = atom.workspace.onDidDestroyPaneItem(event => event.index &&
|
||||
event.item && event.pane);
|
||||
subscription = atom.workspace.onDidAddTextEditor(event => event.index && event.pane &&
|
||||
@@ -3045,7 +3064,13 @@ function testWorkspace() {
|
||||
if (result) obj = result;
|
||||
}
|
||||
|
||||
atom.workspace.addOpener(() => element);
|
||||
atom.workspace.addOpener((uri) => {
|
||||
if (uri === "test://") {
|
||||
return {
|
||||
getTitle: () => "Test Title",
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
atom.workspace.buildTextEditor(obj);
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user