Merge branch 'master' into async-fixes

This commit is contained in:
Erik Krogh Kristensen
2017-03-14 15:49:01 +01:00
1039 changed files with 61066 additions and 31440 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
language: node_js
node_js:
- 6.9.2
- node
sudo: false
+3 -2
View File
@@ -1,5 +1,3 @@
/// <reference types="estree" />
import acorn = require('acorn');
import * as ESTree from 'estree';
@@ -67,3 +65,6 @@ acorn.getLineInfo('string', 56);
acorn.plugins['test'] = function (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();
+6 -3
View File
@@ -238,9 +238,12 @@ declare namespace acorn {
function parseExpressionAt(input: string, pos?: number, options?: Options): ESTree.Expression;
// todo: here the tokenizer function returns a Parser instance, that is targeting the detail of
// Parser prototype. Someone need this please reade README.md first.
// function tokenizer(options: Options, input: string): Parser;
interface ITokenizer {
getToken() : Token,
[Symbol.iterator](): Iterator<Token>
}
function tokenizer(input: string, options: Options): ITokenizer;
let parse_dammit: IParse | undefined;
let LooseParser: ILooseParserClass | undefined;
-3
View File
@@ -1,6 +1,3 @@
/// <reference types="jquery" />
import amplify = require("amplify");
// Copied examples directly from AmplifyJs site
@@ -1,6 +1,3 @@
///<reference path='index.d.ts'/>
///<reference types="angular"/>
var myApp = angular.module('testModule');
interface MyAppScope extends ng.IScope {
@@ -15,6 +15,9 @@ class LocaleTestController {
var newLocale = "mt"
tmhDynamicLocaleService.set(newLocale);
newLocale = "en";
tmhDynamicLocaleService.set(newLocale).then((value) => {});
}
}
+1 -1
View File
@@ -11,7 +11,7 @@ declare module 'angular' {
export namespace dynamicLocale {
interface tmhDynamicLocaleService {
set(locale: string): void;
set(locale: string): angular.IPromise<string>;
get(): string;
}
@@ -1,5 +1,3 @@
/// <reference types="angular" />
import * as angular from "angular";
let myApp = angular.module('myApp', ['feature-flags']);
-2
View File
@@ -1,5 +1,3 @@
/// <reference types="angular" />
var scope: ng.IScope;
var hotkeyProvider: ng.hotkeys.HotkeysProvider;
var hotkeyObj: ng.hotkeys.Hotkey;
-2
View File
@@ -1,5 +1,3 @@
/// <reference types="angular" />
var app = angular.module("angular-jwt-tests", ["angular-jwt"]);
var $jwtHelper: ng.jwt.IJwtHelper;
-2
View File
@@ -1,5 +1,3 @@
/// <reference types="jquery" />
var btfModal: angularModal.AngularModalFactory;
// Using template URL
+10
View File
@@ -0,0 +1,10 @@
import * as angular from 'angular';
angular.module('angular-oauth2-test', ['angular-oauth2'])
.config(['OAuthProvider', (OAuthProvider: angular.oauth2.OAuthProvider) => {
OAuthProvider.configure({
baseUrl: 'https://api.website.com',
clientId: 'CLIENT_ID',
clientSecret: 'CLIENT_SECRET' // optional
});
}]);
+49
View File
@@ -0,0 +1,49 @@
// Type definitions for angular-oauth2 4.1
// Project: https://github.com/oauthjs/angular-oauth2
// Definitions by: Antério Vieira <https://github.com/anteriovieira>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import * as angular from 'angular';
declare module 'angular' {
export namespace oauth2 {
interface OAuthConfig {
baseUrl: string;
clientId: string;
clientSecret?: string;
grantPath?: string;
revokePath?: string;
}
interface OAuthProvider {
configure(params: OAuthConfig): OAuthConfig;
}
interface Data {
username: string;
password: string;
}
interface OAuth {
isAuthenticated(): boolean;
getAccessToken(data: Data, options?: any): angular.IPromise<string>;
getRefreshToken(data?: Data, options?: any): angular.IPromise<string>;
revokeToken(data?: Data, options?: any): angular.IPromise<string>;
}
interface OAuthTokenConfig {
name: string;
options: any;
}
interface OAuthTokenOptions {
secure: boolean;
}
interface OAuthTokenProvider {
configure(params: OAuthTokenConfig): OAuthTokenConfig;
}
}
}
+24
View File
@@ -0,0 +1,24 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"angular-oauth2-tests.ts"
]
}
+2 -1
View File
@@ -587,7 +587,8 @@ namespace TestPromise {
function test_angular_forEach() {
const values: { [key: string]: string } = { name: 'misko', gender: 'male' };
const log: string[] = [];
angular.forEach(values, (value, key) => {
angular.forEach(values, (value, key, obj) => {
obj[key] = value;
this.push(key + ': ' + value);
}, log);
// expect(log).toEqual(['name: misko', 'gender: male']);
+13 -3
View File
@@ -97,7 +97,7 @@ declare namespace angular {
* @param iterator Iterator function.
* @param context Object to become context (this) for the iterator function.
*/
forEach<T>(obj: T[], iterator: (value: T, key: number) => any, context?: any): any;
forEach<T>(obj: T[], iterator: (value: T, key: number, obj: T[]) => void, context?: any): T[];
/**
* Invokes the iterator function once for each item in obj collection, which can be either an object or an array. The iterator function is invoked with iterator(value, key), where value is the value of an object property or an array element and key is the object property key or array element index. Specifying a context for the function is optional.
*
@@ -107,7 +107,7 @@ declare namespace angular {
* @param iterator Iterator function.
* @param context Object to become context (this) for the iterator function.
*/
forEach<T>(obj: { [index: string]: T; }, iterator: (value: T, key: string) => any, context?: any): any;
forEach<T>(obj: { [index: string]: T; }, iterator: (value: T, key: string, obj: { [index: string]: T; }) => void, context?: any): { [index: string]: T; };
/**
* Invokes the iterator function once for each item in obj collection, which can be either an object or an array. The iterator function is invoked with iterator(value, key), where value is the value of an object property or an array element and key is the object property key or array element index. Specifying a context for the function is optional.
*
@@ -117,7 +117,7 @@ declare namespace angular {
* @param iterator Iterator function.
* @param context Object to become context (this) for the iterator function.
*/
forEach(obj: any, iterator: (value: any, key: any) => any, context?: any): any;
forEach(obj: any, iterator: (value: any, key: any, obj: any) => void, context?: any): any;
fromJson(json: string): any;
identity<T>(arg?: T): T;
@@ -1332,9 +1332,19 @@ declare namespace angular {
// see http://docs.angularjs.org/api/ng.$controller
// see http://docs.angularjs.org/api/ng.$controllerProvider
///////////////////////////////////////////////////////////////////////////
/**
* The minimal local definitions required by $controller(ctrl, locals) calls.
*/
interface IControllerLocals {
$scope: ng.IScope;
$element: JQuery;
}
interface IControllerService {
// Although the documentation doesn't state this, locals are optional
<T>(controllerConstructor: new (...args: any[]) => T, locals?: any, later?: boolean, ident?: string): T;
<T>(controllerConstructor: Function, locals?: IControllerLocals, later?: boolean, ident?: string): T;
<T>(controllerConstructor: Function, locals?: any, later?: boolean, ident?: string): T;
<T>(controllerName: string, locals?: any, later?: boolean, ident?: string): T;
}
-483
View File
@@ -1,483 +0,0 @@
/// <reference types="react" />
/*import {
Affix,
Button,
Alert,
Badge,
Breadcrumb,
Calendar,
Carousel,
Cascader,
Checkbox,
Collapse,
DatePicker,
Dropdown,
Icon,
Form,
Input,
InputNumber,
Row,
Col,
Menu,
message,
Modal,
notification,
Pagination,
Popconfirm,
Popover,
Progress,
QueueAnim,
Radio,
Select,
Slider,
Spin,
Steps,
Switch,
Table,
Tabs,
Tag,
TimePicker,
Timeline,
Tooltip,
Transfer,
Tree,
TreeSelect,
Upload,
} from 'antd';*/
import * as React from 'react'
import Affix from 'antd/lib/Affix'
import Button from 'antd/lib/Button'
import Alert from 'antd/lib/Alert'
import Badge from 'antd/lib/Badge'
import Breadcrumb from 'antd/lib/Breadcrumb'
import Calendar from 'antd/lib/Calendar'
import Carousel from 'antd/lib/Carousel'
import Cascader from 'antd/lib/Cascader'
import Checkbox from 'antd/lib/Checkbox'
import Collapse from 'antd/lib/Collapse'
import DatePicker from 'antd/lib/DatePicker'
import Dropdown from 'antd/lib/Dropdown'
import Icon from 'antd/lib/Icon'
import Form from 'antd/lib/Form'
import Input from 'antd/lib/Input'
import InputNumber from 'antd/lib/InputNumber'
import Row from 'antd/lib/Row'
import Col from 'antd/lib/Col'
import Menu from 'antd/lib/Menu'
import message from 'antd/lib/message'
import Modal from 'antd/lib/Modal'
import notification from 'antd/lib/notification'
import Pagination from 'antd/lib/Pagination'
import Popconfirm from 'antd/lib/Popconfirm'
import Popover from 'antd/lib/Popover'
import Progress from 'antd/lib/Progress'
import QueueAnim from 'antd/lib/QueueAnim'
import Radio from 'antd/lib/Radio'
import Select from 'antd/lib/Select'
import Slider from 'antd/lib/Slider'
import Spin from 'antd/lib/Spin'
import Steps from 'antd/lib/Steps'
import Switch from 'antd/lib/Switch'
import Table from 'antd/lib/Table'
import Tabs from 'antd/lib/Tabs'
import Tag from 'antd/lib/Tag'
import TimePicker from 'antd/lib/TimePicker'
import Timeline from 'antd/lib/Timeline'
import Tooltip from 'antd/lib/Tooltip'
import Transfer from 'antd/lib/Transfer'
import Tree from 'antd/lib/Tree'
import TreeSelect from 'antd/lib/TreeSelect'
import Upload from 'antd/lib/Upload'
const ButtonGroup = Button.Group;
const CheckboxGroup = Checkbox.Group;
const Panel = Collapse.Panel;
const RangePicker = DatePicker.RangePicker;
const MonthPicker = DatePicker.MonthPicker;
const DropdownButton = Dropdown.Button;
const SubMenu = Menu.SubMenu;
const MenuItemGroup = Menu.ItemGroup;
const ProgressCircle = Progress.Circle;
const ProgressLine = Progress.Line;
const RadioGroup = Radio.Group;
const Option = Select.Option;
const OptGroup = Select.OptGroup;
const Step = Steps.Step;
const FormItem = Form.Item;
const TabPane = Tabs.TabPane;
const TreeNode = Tree.TreeNode;
const TreeSelectTreeNode = TreeSelect.TreeNode;
const onChange = () => { }
const options = [{
value: 'zhejiang',
label: '浙江',
children: [{
value: 'hangzhou',
label: '杭州',
children: [{
value: 'xihu',
label: '西湖',
}],
}],
}, {
value: 'jiangsu',
label: '江苏',
children: [{
value: 'nanjing',
label: '南京',
children: [{
value: 'zhonghuamen',
label: '中华门',
}],
}],
}];
const columns = [{
title: '姓名',
dataIndex: 'name',
key: 'name',
render(text: any) {
return <a href="#">{text}</a>;
}
}, {
title: '年龄',
dataIndex: 'age',
key: 'age',
}, {
title: '住址',
dataIndex: 'address',
key: 'address',
}, {
title: '操作',
key: 'operation',
render(text: any, record: any) {
return (
<span>
<a href="#">操作一{record.name}</a>
<span className="ant-divider"></span>
<a href="#">操作二</a>
<span className="ant-divider"></span>
<a href="#" className="ant-dropdown-link">
更多 <Icon type="down" />
</a>
</span>
);
}
}];
const data = [{
key: '1',
name: '胡彦斌',
age: 32,
address: '西湖区湖底公园1号'
}, {
key: '2',
name: '胡彦祖',
age: 42,
address: '西湖区湖底公园1号'
}, {
key: '3',
name: '李大嘴',
age: 32,
address: '西湖区湖底公园1号'
}];
// tests
class AccountForm extends React.Component<any, any>{
render() {
const { getFieldProps } = this.props.form;
return (
<Form inline>
<FormItem
label="账户:">
<Input placeholder="请输入账户名"
{...getFieldProps('userName') } />
</FormItem>
<FormItem
label="密码:">
<Input type="password" placeholder="请输入密码"
{...getFieldProps('password') } />
</FormItem>
<FormItem>
<label className="ant-checkbox-inline">
<Checkbox
{...getFieldProps('agreement') } />记住我
</label>
</FormItem>
<Button type="primary" htmlType="submit">登录</Button>
</Form>
);
}
}
var Account = Form.create()(AccountForm);
// app
class App extends React.Component<any, any>{
render() {
message.success('success')
message.config({ top: 100 })
message.destroy()
message.info('info', 1000)
message.error('error', 3500)
Modal.info({ title: 'hello' });
Modal.success({ cancelText: 'No' })
notification.success({
message: 'hello',
description: 'test'
})
const props = {
name: 'file',
action: '/upload.do',
onChange(info: any) {
if (info.file.status !== 'uploading') {
console.log(info.file, info.fileList);
}
if (info.file.status === 'done') {
message.success(`${info.file.name} 上传成功。`);
} else if (info.file.status === 'error') {
message.error(`${info.file.name} 上传失败。`);
}
}
};
return <div>
<Affix>Affix</Affix>
<Row>
<Col>test</Col>
</Row>
<Alert message="Hello" type='info' closable={true}/>
<Badge count={10}/>
<Button type='primary'>Primary Button</Button>
<ButtonGroup>
<Button type='primary'>Primary Button</Button>
<Button type='ghost'>Primary Button</Button>
</ButtonGroup>
<Breadcrumb>
<Breadcrumb.Item>首页</Breadcrumb.Item>
<Breadcrumb.Item href="">应用中心</Breadcrumb.Item>
<Breadcrumb.Item href="">应用列表</Breadcrumb.Item>
<Breadcrumb.Item>某应用</Breadcrumb.Item>
</Breadcrumb>
<Calendar/>
<Carousel autoplay>
<div><h3>1</h3></div>
<div><h3>2</h3></div>
<div><h3>3</h3></div>
<div><h3>4</h3></div>
</Carousel>
<Cascader options={options} />
<CheckboxGroup options={['Apple', 'Pear', 'Orange']} defaultValue={['Apple']} onChange={onChange} />
<Collapse defaultActiveKey={['1']}>
<Panel header="This is panel header 1" key="1">
<p>test1</p>
</Panel>
<Panel header="This is panel header 2" key="2">
<p>test2</p>
</Panel>
<Panel header="This is panel header 3" key="3">
<p>test3</p>
</Panel>
</Collapse>
<DatePicker defaultValue="2015-01-01" />
<RangePicker showTime format="yyyy/MM/dd HH:mm:ss" onChange={onChange} />
<MonthPicker defaultValue="2015-12" />
<Dropdown trigger={['click']} overlay={<div>Hello Dp</div>}>
<a className="ant-dropdown-link" href="#">
触发链接 <Icon type="down" />
</a>
</Dropdown>
<DropdownButton overlay={<p>dpb</p>} type="primary">
某功能按钮
</DropdownButton>
<InputNumber min={0} max={10}/>
<Menu
selectedKeys={[this.state.current]}
theme={this.state.theme}
mode="horizontal">
<Menu.Item key="mail">
<Icon type="mail" />导航一
</Menu.Item>
<SubMenu title={<span><Icon type="setting" />导航 - 子菜单</span>}>
<MenuItemGroup title="分组1">
<Menu.Item key="setting:1">选项1</Menu.Item>
<Menu.Item key="setting:2">选项2</Menu.Item>
</MenuItemGroup>
<MenuItemGroup title="分组2">
<Menu.Item key="setting:3">选项3</Menu.Item>
<Menu.Item key="setting:4">选项4</Menu.Item>
</MenuItemGroup>
</SubMenu>
</Menu>
<Modal title='Modal .....' maskClosable/>
<Pagination defaultCurrent={1} total={50} />,
<Popconfirm title="confirm .">
<a href="#">remove</a>
</Popconfirm>
<Popover overlay={<div>Overlay</div>} title="title">
<Button type="primary">display card</Button>
</Popover>
<ProgressCircle percent={75} />
<ProgressCircle percent={70} status="exception" />
<ProgressCircle percent={100} />
<ProgressLine percent={30} />
<ProgressLine percent={50} status="active" />
<ProgressLine percent={70} status="exception" />
<ProgressLine percent={100} />
<ProgressLine percent={50} showInfo={false} />
<QueueAnim>
<div key='demo1'>demo1</div>
<div key='demo2'>demo2</div>
<div key='demo3'>demo3</div>
<div key='demo4'>demo4</div>
</QueueAnim>
<RadioGroup>
<Radio key="a" value={1}>A</Radio>
<Radio key="b" value={2}>B</Radio>
<Radio key="c" value={3}>C</Radio>
<Radio key="d" value={null}>D</Radio>
</RadioGroup>
<Select defaultValue="lucy"
style={{ width: 200 }}
showSearch={false}>
<OptGroup label="Manager">
<Option value="jack">jack</Option>
<Option value="lucy">lucy</Option>
</OptGroup>
<OptGroup label="Engineer">
<Option value="yiminghe">yiminghe</Option>
</OptGroup>
</Select>
<Select defaultValue="lucy" style={{ width: 120 }} disabled>
<Option value="lucy">Lucy</Option>
</Select>
<Slider defaultValue={30} />
<Slider range defaultValue={[20, 50]} />
<Slider range defaultValue={[20, 50]} disabled />
<Spin />
<Step status="finish" title="步骤1" icon="cloud" />
<Step status="process" title="步骤2" icon="apple" />
<Step status="wait" title="步骤3" icon="github" />
<Switch defaultChecked={false} onChange={onChange} />,
<Tabs defaultActiveKey="1" onChange={onChange}>
<TabPane tab="选项卡一" key="1">选项卡一内容</TabPane>
<TabPane tab="选项卡二" key="2">选项卡二内容</TabPane>
<TabPane tab="选项卡三" key="3">选项卡三内容</TabPane>
</Tabs>
<Tag>标签一</Tag>
<Tag>标签二</Tag>
<Tag closable onClose={() => { } }>标签三</Tag>
<Tag><a href="https://www.alipay.com/" target="_blank">标签四(链接)</a></Tag>
<TimePicker onChange={onChange} />
<Timeline>
<Timeline.Item>创建服务现场 2015-09-01</Timeline.Item>
<Timeline.Item>初步排除网络异常 2015-09-01</Timeline.Item>
<Timeline.Item>技术测试异常 2015-09-01</Timeline.Item>
<Timeline.Item>网络异常正在修复 2015-09-01</Timeline.Item>
</Timeline>
<Tooltip title="提示文字">
<span>鼠标移上来就会出现提示</span>
</Tooltip>
<Transfer
dataSource={this.state.mockData}
targetKeys={this.state.targetKeys}
onChange={onChange} />
<Tree className="myCls" showLine multiple checkable
defaultExpandedKeys={this.state.defaultExpandedKeys}
defaultSelectedKeys={this.state.defaultSelectedKeys}
defaultCheckedKeys={this.state.defaultCheckedKeys}
>
<TreeNode title="parent 1" key="0-0">
<TreeNode title="parent 1-0" key="0-0-0" disabled>
<TreeNode title="leaf" key="0-0-0-0" disableCheckbox />
<TreeNode title="leaf" key="0-0-0-1" />
</TreeNode>
<TreeNode title="parent 1-1" key="0-0-1">
<TreeNode title={<span style={{ color: '#08c' }}>sss</span>} key="0-0-1-0" />
</TreeNode>
</TreeNode>
</Tree>
<Upload {...props}>
<Button type="ghost">
<Icon type="upload" /> 点击上传
</Button>
</Upload>
<TreeSelect style={{ width: 300 }}
value={this.state.value}
dropdownStyle={{ maxHeight: 400, overflow: 'auto' }}
placeholder="请选择"
allowClear
treeDefaultExpandAll
onChange={onChange}>
<TreeSelectTreeNode value="parent 1" title="parent 1" key="0-1">
<TreeSelectTreeNode value="parent 1-0" title="parent 1-0" key="0-1-1">
<TreeSelectTreeNode value="leaf1" title="my leaf" key="random" />
<TreeSelectTreeNode value="leaf2" title="your leaf" key="random1" />
</TreeSelectTreeNode>
<TreeSelectTreeNode value="parent 1-1" title="parent 1-1" key="random2">
<TreeSelectTreeNode value="sss" title={<b style={{ color: '#08c' }}>sss</b>} key="random3" />
</TreeSelectTreeNode>
</TreeSelectTreeNode>
</TreeSelect>
<Table columns={columns} dataSource={data}/>
</div>
}
}
-2083
View File
File diff suppressed because it is too large Load Diff
+1814 -147
View File
File diff suppressed because it is too large Load Diff
+45 -14
View File
@@ -1,4 +1,4 @@
// Type definitions for ArcGIS API for JavaScript 3.19
// Type definitions for ArcGIS API for JavaScript 3.20
// Project: https://developers.arcgis.com/javascript/3/
// Definitions by: Esri <https://github.com/Esri>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@@ -21,7 +21,6 @@ declare module "esri" {
import Color = require("esri/Color");
import LocationProviderBase = require("esri/tasks/locationproviders/LocationProviderBase");
import PictureMarkerSymbol = require("esri/symbols/PictureMarkerSymbol");
import RouteParameters = require("esri/tasks/RouteParameters");
import SimpleLineSymbol = require("esri/symbols/SimpleLineSymbol");
import Font = require("esri/symbols/Font");
import ArcGISDynamicMapServiceLayer = require("esri/layers/ArcGISDynamicMapServiceLayer");
@@ -263,6 +262,12 @@ declare module "esri" {
/** The symbol in which the BlendRenderer is applied. */
symbol: Symbol;
}
export interface BookmarkItemOptions {
/** The extent for the specified bookmark item. */
extent?: Extent;
/** The name for the bookmark item. */
name?: string;
}
export interface BookmarksOptions {
/** An array of BookmarkItem objects or a json object with the BookmarkItem format to initially display in the bookmark widget. */
bookmarks?: BookmarkItem[];
@@ -282,8 +287,14 @@ declare module "esri" {
latitudeFieldName?: string;
/** The longitude field name. */
longitudeFieldName?: string;
/** Opacity or transparency of layer. */
opacity?: number;
/** An array of strings which correspond to fields to include in the CSVLayer. */
outFields?: string[];
/** Refresh interval of the layer in minutes. */
refreshInterval?: number;
/** Visibility of the layer. */
visible?: boolean;
}
export interface ChooseBestFacilitiesOptions {
/** The URL to the analysis service, for example "http://analysis.arcgis.com/arcgis/rest/services/tasks/GPServer". */
@@ -624,8 +635,8 @@ declare module "esri" {
canModifyStops?: boolean;
/** Center the map at the start of the selected route segment. */
centerAtSegmentStart?: boolean;
/** The returned directions object from the routing solve result. */
directions?: any;
/** The locale used for the directions. */
directionsLanguage?: string;
/** Length units. */
directionsLengthUnits?: string;
/** Enable the dragging of stop locations on the map. */
@@ -658,8 +669,6 @@ declare module "esri" {
printTemplate?: string;
/** When true, the route will return to start point. */
returnToStart?: boolean;
/** Specify the input parameters for the route task. */
routeParams?: RouteParameters;
/** Define the symbol used to draw the route on the map. */
routeSymbol?: SimpleLineSymbol;
/** Specify the service that will be used to calculate directions. */
@@ -672,6 +681,8 @@ declare module "esri" {
segmentSymbol?: SimpleLineSymbol;
/** Defines whether the Directions widget will show the map-click-active toggle button. */
showActivateButton?: boolean;
/** Indicates whether to expose barriers when using the widget. */
showBarriersButton?: boolean;
/** If true, the Clear button is shown. */
showClearButton?: boolean;
/** If true, the toggle button group allowing user to choose between Miles and Kilometers is shown. */
@@ -1076,6 +1087,8 @@ declare module "esri" {
export interface GeoRSSLayerOptions {
/** The template used to display popup window for identify operation. */
infoTemplate?: InfoTemplate;
/** Opacity or transparency of layer. */
opacity?: number;
/** The output spatial reference for the GeoRSSLayer. */
outSpatialReference?: SpatialReference;
/** The default symbol use to display point features. */
@@ -1084,6 +1097,8 @@ declare module "esri" {
polygonSymbol?: Symbol;
/** The default symbol used to display polyline features. */
polylineSymbol?: Symbol;
/** Refresh interval of the layer in minutes. */
refreshInterval?: number;
}
export interface GeocoderOptions {
/** By default, the Geocoder widget uses the Esri World Locator to find search locations. */
@@ -3235,7 +3250,7 @@ declare module "esri/arcgis/Portal" {
tags: string[];
/** The url to the thumbnail image for the user. */
thumbnailUrl: string;
/** The url for the user content. */
/** The URL for the user content. */
userContentUrl: string;
/** The username for the user. */
username: string;
@@ -3554,16 +3569,15 @@ declare module "esri/dijit/BasemapToggle" {
}
declare module "esri/dijit/BookmarkItem" {
import Extent = require("esri/geometry/Extent");
import esri = require("esri");
/** Defines a bookmark for use in the Bookmark widget. */
class BookmarkItem {
/**
* Creates a new BookmarkItem.
* @param name The name for the bookmark item.
* @param extent The extent for the specified bookmark item.
* @param params See options list for parameters.
*/
constructor(name: string, extent: Extent);
constructor(params?: esri.BookmarkItemOptions);
}
export = BookmarkItem;
}
@@ -3815,7 +3829,6 @@ declare module "esri/dijit/Directions" {
import esri = require("esri");
import DirectionsFeatureSet = require("esri/tasks/DirectionsFeatureSet");
import Graphic = require("esri/graphic");
import RouteParameters = require("esri/tasks/RouteParameters");
import RouteTask = require("esri/tasks/RouteTask");
import Point = require("esri/geometry/Point");
import RouteResult = require("esri/tasks/RouteResult");
@@ -3832,14 +3845,14 @@ declare module "esri/dijit/Directions" {
mergedRouteGraphic: Graphic;
/** If specified, this specifies the portal where the produced route layers are going to be stored and accessed. */
portalUrl: string;
/** Routing parameters for the widget. */
routeParams: RouteParameters;
/** Routing task for the widget. */
routeTask: RouteTask;
/** Read-only: The Service Description object returned by the Route REST Endpoint. */
serviceDescription: any;
/** Indicates whether the Directions widget will display the map-click-active toggle button. */
showActivateButton: boolean;
/** Indicates whether to expose barriers when using the widget. */
showBarriersButton: boolean;
/** If true, the Clear button is shown. */
showClearButton: boolean;
/** If true, the toggle button group allowing user to choose between Miles and Kilometers is shown. */
@@ -9230,8 +9243,14 @@ declare module "esri/layers/CSVLayer" {
latitudeFieldName: string;
/** The longitude field name. */
longitudeFieldName: string;
/** Opacity or transparency of layer. */
opacity: number;
/** Refresh interval of the layer in minutes. */
refreshInterval: number;
/** The url to a CSV resource. */
url: string;
/** Visibility of the layer. */
visible: boolean;
/**
* Creates a CSV layer.
* @param url URL to a CSV resource.
@@ -9938,6 +9957,10 @@ declare module "esri/layers/GeoRSSLayer" {
items: Graphic[];
/** The name of the layer. */
name: string;
/** Opacity or transparency of layer. */
opacity: number;
/** Refresh interval of the layer in minutes. */
refreshInterval: number;
/** The publicly accessible URL to a GeoRSS file. */
url: string;
/**
@@ -11703,6 +11726,7 @@ declare module "esri/layers/pixelfilters/StretchFilter" {
declare module "esri/map" {
import esri = require("esri");
import Attribution = require("esri/dijit/Attribution");
import Color = require("esri/Color");
import Extent = require("esri/geometry/Extent");
import GraphicsLayer = require("esri/layers/GraphicsLayer");
import InfoWindowBase = require("esri/InfoWindowBase");
@@ -11721,6 +11745,8 @@ declare module "esri/map" {
attribution: Attribution;
/** Value is true when the map automatically resizes if the browser window or ContentPane widget enclosing the map is resized. */
autoResize: boolean;
/** The background color "behind" the map. */
backgroundColor: Color;
/** An array of IDs corresponding to the layers that make up the map's current basemap. */
basemapLayerIds: string[];
/** The current extent of the map in map units. */
@@ -11924,6 +11950,11 @@ declare module "esri/map" {
* @param immediate By default, the actual resize logic is delayed internally in order to throttle spurious resize events dispatched by some browsers.
*/
resize(immediate?: boolean): void;
/**
* Change the background color of the map.
* @param color Color specified using either a named string (e.g.
*/
setBackgroundColor(color: Color | string): void;
/**
* Change the map's current basemap.
* @param basemap A valid basemap name.
-3
View File
@@ -1,6 +1,3 @@
/// <reference types="node" />
import Archiver = require('archiver');
import FS = require('fs');
-1
View File
@@ -1,5 +1,4 @@
/// <reference types="node" />
/// <reference types="pathwatcher" />
import path = require("path");
import _atom = require("atom");
@@ -0,0 +1,11 @@
export class ViewModel {
constructor(private knockoutBindable: KnockoutBindable) {
}
activate(settings: any): void {
this.knockoutBindable.applyBindableValues(settings, this);
this.knockoutBindable.applyBindableValues(settings, this, true);
}
}
+19
View File
@@ -0,0 +1,19 @@
// Type definitions for aurelia-knockout 2.0
// Project: https://github.com/code-chris/aurelia-knockout
// Definitions by: Christian Kotzbauer <https://github.com/code-chris>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare interface KnockoutBindable {
/**
* Applys all values from a data object (usually the activation data) to the corresponding instance fields
* in the current view model if they are marked as @bindable. By default all matching values from the data object
* are applied. To only apply observable values set the last parameter to `true`. Subscriptions are created
* for all Knockout observables in the data object to update the view-model values respectively.
*
* @param data - the data object
* @param target - the target view model
* @param applyOnlyObservables - `true` if only observable values should be applied, false by default.
*/
applyBindableValues(data: any, target: any, applyOnlyObservables?: boolean): void;
}
@@ -9,7 +9,6 @@
"noImplicitThis": true,
"strictNullChecks": false,
"baseUrl": "../",
"jsx": "react",
"typeRoots": [
"../"
],
@@ -19,6 +18,6 @@
},
"files": [
"index.d.ts",
"antd-tests.tsx"
"aurelia-knockout-tests.ts"
]
}
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "../tslint.json" }
+28 -6
View File
@@ -1,4 +1,4 @@
import 'auth0-js';
import * as auth0 from 'auth0-js';
let webAuth = new auth0.WebAuth({
domain: 'mine.auth0.com',
@@ -61,10 +61,8 @@ webAuth.signupAndAuthorize({
});
webAuth.client.login({
ealm: 'Username-Password-Authentication', //connection name or HRD domain
realm: 'Username-Password-Authentication', //connection name or HRD domain
username: 'info@auth0.com',
password: 'areallystrongpassword',
audience: 'https://mystore.com/api/v2',
@@ -73,6 +71,26 @@ webAuth.client.login({
// Auth tokens in the result or an error
});
webAuth.popup.buildPopupHandler();
webAuth.popup.preload({});
webAuth.popup.authorize({}, (err, data) => {
if (err) /* handle error */ return;
// do something with data
});
webAuth.popup.loginWithCredentials({}, (err, data) => {
if (err) /* handle error */ return;
// do something with data
});
webAuth.popup.passwordlessVerify({}, (err, data) => {
if (err) /* handle error */ return;
// do something with data
});
webAuth.popup.signupAndLogin({}, (err, data) => {
if (err) /* handle error */ return;
// do something with data
});
let authentication = new auth0.Authentication({
domain: 'me.auth0.com',
clientID: '...',
@@ -101,7 +119,9 @@ authentication.delegation({
refresh_token: 'your_refresh_token',
api_type: 'app'
}, (err, data) => {
if (!err) {
localStorage.setItem('token', data.idToken)
}
});
authentication.loginWithDefaultDirectory({
@@ -146,6 +166,8 @@ let management = new auth0.Management({
management.getUser('asd', (err, user) => {});
management.patchUserMetadata('asd', {role: 'admin'}, (err, user) => {});
management.patchUserMetadata('asd', {role: 'admin'}, (err, user) => {
if (!err && user.email_verified) return; // do something
});
management.linkUser('asd', 'eqwe', (err, user) => {});
+497 -437
View File
@@ -1,456 +1,516 @@
// Type definitions for Auth0.js 8.1
// Type definitions for Auth0.js 8.3
// Project: https://github.com/auth0/auth0.js
// Definitions by: Adrian Chia <https://github.com/adrianchia>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare namespace auth0 {
export as namespace auth0;
export class Authentication {
constructor(options: AuthOptions);
passwordless: PasswordlessAuthentication;
dbConnection: DBConnection;
export class Authentication {
constructor(options: AuthOptions);
/**
* Builds and returns the `/authorize` url in order to initialize a new authN/authZ transaction
*
* @method buildAuthorizeUrl
* @param {Object} options: https://auth0.com/docs/api/authentication#!#get--authorize_db
*/
buildAuthorizeUrl(options: any): string;
passwordless: PasswordlessAuthentication;
dbConnection: DBConnection;
/**
* Builds and returns the Logout url in order to initialize a new authN/authZ transaction
*
* @method buildLogoutUrl
* @param {Object} options: https://auth0.com/docs/api/authentication#!#get--v2-logout
*/
buildLogoutUrl(options?: any): string;
/**
* Builds and returns the `/authorize` url in order to initialize a new authN/authZ transaction
*
* @method buildAuthorizeUrl
* @param {Object} options: https://auth0.com/docs/api/authentication#!#get--authorize_db
*/
buildAuthorizeUrl(options: any): string;
/**
* Makes a call to the `oauth/token` endpoint with `password` grant type
*
* @method loginWithDefaultDirectory
* @param {Object} options: https://auth0.com/docs/api-auth/grant/password
* @param {Function} callback
*/
loginWithDefaultDirectory(options: any, callback: (error?: Auth0Error, authResult?: any) => any): void;
/**
* Builds and returns the Logout url in order to initialize a new authN/authZ transaction
*
* @method buildLogoutUrl
* @param {Object} options: https://auth0.com/docs/api/authentication#!#get--v2-logout
*/
buildLogoutUrl(options?: any): string;
/**
* Makes a call to the `/ro` endpoint
* @param {any} options
* @param {Function} callback
* @deprecated `loginWithResourceOwner` will be soon deprecated, user `login` instead.
*/
loginWithResourceOwner(options: any, callback: (error?: Auth0Error, authResult?: any) => any): void;
/**
* Makes a call to the `oauth/token` endpoint with `password` grant type
*
* @method loginWithDefaultDirectory
* @param {Object} options: https://auth0.com/docs/api-auth/grant/password
* @param {Function} callback
*/
loginWithDefaultDirectory(options: any, callback: Auth0Callback<any>): void;
/**
* Makes a call to the `oauth/token` endpoint with `password-realm` grant type
* @param {any} options
* @param {Function} callback
*/
login(options: any, callback: (error?: Auth0Error, authResult?: any) => any): void;
/**
* Makes a call to the `/ro` endpoint
* @param {any} options
* @param {Function} callback
* @deprecated `loginWithResourceOwner` will be soon deprecated, user `login` instead.
*/
loginWithResourceOwner(options: any, callback: Auth0Callback<any>): void;
/**
* Makes a call to the `oauth/token` endpoint
* @param {any} options
* @param {Function} callback
*/
oauthToken(options: any, callback: (error?: Auth0Error, authResult?: any) => any): void;
/**
* Makes a call to the `oauth/token` endpoint with `password-realm` grant type
* @param {any} options
* @param {Function} callback
*/
login(options: any, callback: Auth0Callback<any>): void;
/**
* Makes a call to the `/ssodata` endpoint
*
* @method getSSOData
* @param {Boolean} withActiveDirectories
* @param {Function} callback
* @deprecated `getSSOData` will be soon deprecated.
*/
getSSOData(callback?: (error?: Auth0Error, authResult?: any) => any): void;
/**
* Makes a call to the `oauth/token` endpoint
* @param {any} options
* @param {Function} callback
*/
oauthToken(options: any, callback: Auth0Callback<any>): void;
/**
* Makes a call to the `/ssodata` endpoint
*
* @method getSSOData
* @param {Boolean} withActiveDirectories
* @param {Function} callback
* @deprecated `getSSOData` will be soon deprecated.
*/
getSSOData(withActiveDirectories: boolean, callback?: (error?: Auth0Error, authResult?: any) => any): void;
/**
* Makes a call to the `/ssodata` endpoint
*
* @method getSSOData
* @param {Function} callback
*/
getSSOData(callback?: Auth0Callback<any>): void;
/**
* Makes a call to the `/userinfo` endpoint and returns the user profile
*
* @method userInfo
* @param {String} accessToken
* @param {Function} callback
*/
userInfo(token: string, callback: (error?: Auth0Error, user?: any) => any): void;
/**
* Makes a call to the `/ssodata` endpoint
*
* @method getSSOData
* @param {Boolean} withActiveDirectories
* @param {Function} callback
*/
getSSOData(withActiveDirectories: boolean, callback?: Auth0Callback<any>): void;
/**
* Makes a call to the `/delegation` endpoint
*
* @method delegation
* @param {Object} options: https://auth0.com/docs/api/authentication#!#post--delegation
* @param {Function} callback
* @deprecated `delegation` will be soon deprecated.
*/
delegation(options: any, callback: (error?: Auth0Error, authResult?: Auth0DelegationToken) => any): any;
/**
* Makes a call to the `/userinfo` endpoint and returns the user profile
*
* @method userInfo
* @param {String} accessToken
* @param {Function} callback
*/
userInfo(token: string, callback: Auth0Callback<Auth0UserProfile>): void;
/**
* Fetches the user country based on the ip.
*
* @method getUserCountry
* @param {Function} callback
*/
getUserCountry(callback: (error?: Auth0Error, result?: any) => any): void;
}
export class PasswordlessAuthentication {
constructor(request: any, option: any);
/**
* Builds and returns the passwordless TOTP verify url in order to initialize a new authN/authZ transaction
*
* @method buildVerifyUrl
* @param {Object} options
* @param {Function} callback
*/
buildVerifyUrl(options: any): string;
/**
* Initializes a new passwordless authN/authZ transaction
*
* @method start
* @param {Object} options: https://auth0.com/docs/api/authentication#passwordless
* @param {Function} callback
*/
start(options: PasswordlessStartOptions, callback: any): void;
/**
* Verifies the passwordless TOTP and returns an error if any.
*
* @method buildVerifyUrl
* @param {Object} options
* @param {Function} callback
*/
verify(options: any, callback: any): void;
}
export class DBConnection {
constructor(request: any, option: any);
/**
* Signup a new user
*
* @method signup
* @param {Object} options: https://auth0.com/docs/api/authentication#!#post--dbconnections-signup
* @param {Function} calback
*/
signup(options: any, callback: any): void;
/**
* Initializes the change password flow
*
* @method signup
* @param {Object} options: https://auth0.com/docs/api/authentication#!#post--dbconnections-change_password
* @param {Function} callback
*/
changePassword(options: ChangePasswordOptions, callback: any): void;
}
export class Management {
constructor(options: ManagementOptions);
/**
* Returns the user profile. https://auth0.com/docs/api/management/v2#!/Users/get_users_by_id
*
* @method getUser
* @param {String} userId
* @param {Function} callback
*/
getUser(userId: string, callback: (error?: Auth0Error, user?: any) => any): void;
/**
* Updates the user metdata. It will patch the user metdata with the attributes sent.
* https://auth0.com/docs/api/management/v2#!/Users/patch_users_by_id
*
* @method patchUserMetadata
* @param {String} userId
* @param {Object} userMetadata
* @param {Function} callback
*/
patchUserMetadata(userId: string, userMetadata: any, callback: (error?: Auth0Error, user?: any) => any): void;
/**
* Link two users. https://auth0.com/docs/api/management/v2#!/Users/post_identities
*
* @method linkUser
* @param {String} userId
* @param {String} secondaryUserToken
* @param {Function} callback
*/
linkUser(userId: string, secondaryUserToken: string, callback: (error?: Auth0Error, user?: any) => any): void;
}
export class WebAuth {
constructor(options: AuthOptions);
client: Authentication;
popup: Popup;
redirect: Redirect;
/**
* Redirects to the hosted login page (`/authorize`) in order to initialize a new authN/authZ transaction
*
* @method authorize
* @param {Object} options: https://auth0.com/docs/api/authentication#!#get--authorize_db
*/
authorize(options: any): void;
/**
* Parse the url hash and extract the returned tokens depending on the transaction.
*
* Only validates id_tokens signed by Auth0 using the RS256 algorithm using the public key exposed
* by the `/.well-known/jwks.json` endpoint. Id tokens signed with other algorithms will not be
* accepted.
*
* @method parseHash
* @param {Object} options:
* @param {String} options.state [OPTIONAL] to verify the response
* @param {String} options.nonce [OPTIONAL] to verify the id_token
* @param {String} options.hash [OPTIONAL] the url hash. If not provided it will extract from window.location.hash
* @param {Function} callback: any(err, token_payload)
*/
parseHash(options: any, callback: (error?: Auth0Error, authResult?: any) => any): void;
/**
* Decodes the id_token and verifies the nonce.
*
* @method validateToken
* @param {String} token
* @param {String} state
* @param {String} nonce
* @param {Function} callback: function(err, {payload, transaction})
*/
validateToken(token: string, state: string, nonce: string, callback: any): void;
/**
* Executes a silent authentication transaction under the hood in order to fetch a new token.
*
* @method renewAuth
* @param {Object} options: any valid oauth2 parameter to be sent to the `/authorize` endpoint
* @param {Function} callback
*/
renewAuth(options: any, callback: (error?: Auth0Error, authResult?: any) => any): void;
/**
* Initialices a change password transaction
*
* @method changePassword
* @param {Object} options: https://auth0.com/docs/api/authentication#!#post--dbconnections-change_password
* @param {Function} callback
*/
changePassword(options: any, callback: (error?: Auth0Error, authResult?: any) => any): void;
/**
* Signs up a new user
*
* @method signup
* @param {Object} options: https://auth0.com/docs/api/authentication#!#post--dbconnections-signup
* @param {Function} callback
*/
signup(options: any, callback: any): void;
/**
* Signs up a new user, automatically logs the user in after the signup and returns the user token.
* The login will be done using /oauth/token with password-realm grant type.
*
* @method signupAndAuthorize
* @param {Object} options: https://auth0.com/docs/api/authentication#!#post--dbconnections-signup
* @param {Function} callback
*/
signupAndAuthorize(options: any, callback: (error?: Auth0Error, authResult?: any) => any): void;
/**
* Redirects to the auth0 logout page
*
* @method logout
* @param {Object} options: https://auth0.com/docs/api/authentication#!#get--v2-logout
*/
logout(options: any): void;
passwordlessStart(options: PasswordlessStartOptions, callback: (error?: Auth0Error, data?: any) => any): void;
/**
* Verifies the passwordless TOTP and redirects to finish the passwordless transaction
*
* @method passwordlessVerify
* @param {Object} options:
* @param {Object} options.type: `sms` or `email`
* @param {Object} options.phoneNumber: only if type = sms
* @param {Object} options.email: only if type = email
* @param {Object} options.connection: the connection name
* @param {Object} options.verificationCode: the TOTP code
* @param {Function} callback
*/
passwordlessVerify(options: any, callback: any): void;
}
export class Redirect {
constructor(client: any, options: any);
/**
* Initializes the legacy Lock login flow in a popup
*
* @method loginWithCredentials
* @param {Object} options
* @param {Function} callback
* @deprecated `webauth.popup.loginWithCredentials` will be soon deprecated, use `webauth.client.login` instead.
*/
loginWithCredentials(options: any, callback: any): void;
/**
* Signs up a new user and automatically logs the user in after the signup.
*
* @method signupAndLogin
* @param {Object} options: https://auth0.com/docs/api/authentication#!#post--dbconnections-signup
* @param {Function} callback
*/
signupAndLogin(options: any, callback: any): void;
}
export class Popup {
constructor(client: any, options: any);
/**
* Initializes the popup window and returns the instance to be used later in order to avoid being blocked by the browser.
*
* @method preload
* @param {Object} options: receives the window height and width and any other window feature to be sent to window.open
*/
preload(options: any): any;
/**
* Internal use.
*
* @method getPopupHandler
*/
getPopupHandler(options: any, preload: boolean): any;
/**
* Opens in a popup the hosted login page (`/authorize`) in order to initialize a new authN/authZ transaction
*
* @method authorize
* @param {Object} options: https://auth0.com/docs/api/authentication#!#get--authorize_db
* @param {Function} callback
*/
authorize(options: any, callback: any): void;
/**
* Initializes the legacy Lock login flow in a popup
*
* @method loginWithCredentials
* @param {Object} options
* @param {Function} callback
* @deprecated `webauth.popup.loginWithCredentials` will be soon deprecated, use `webauth.client.login` instead.
*/
loginWithCredentials(options: any, callback: any): void;
/**
* Verifies the passwordless TOTP and returns the requested token
*
* @method passwordlessVerify
* @param {Object} options:
* @param {Object} options.type: `sms` or `email`
* @param {Object} options.phoneNumber: only if type = sms
* @param {Object} options.email: only if type = email
* @param {Object} options.connection: the connection name
* @param {Object} options.verificationCode: the TOTP code
* @param {Function} callback
*/
passwordlessVerify(options: any, callback: any): void;
/**
* Signs up a new user and automatically logs the user in after the signup.
*
* @method signupAndLogin
* @param {Object} options: https://auth0.com/docs/api/authentication#!#post--dbconnections-signup
* @param {Function} callback
*/
signupAndLogin(options: any, callback: any): void;
}
interface ManagementOptions {
domain: string;
token: string;
_sendTelemetry?: boolean;
_telemetryInfo?: any;
}
interface AuthOptions {
domain: string;
clientID: string;
responseType?: string;
responseMode?: string;
redirectUri?: string;
scope?: string;
audience?: string;
leeway?: number;
_disableDeprecationWarnings?: boolean;
_sendTelemetry?: boolean;
_telemetryInfo?: any;
}
interface PasswordlessAuthOptions {
connection: string;
verificationCode: string;
phoneNumber: string;
email: string;
}
interface Auth0Error {
error: any;
errorDescription: string;
}
interface Auth0DecodedHash {
accessToken?: string;
idToken?: string;
idTokenPayload?: any;
refreshToken?: string;
state?: string;
expiresIn?: number;
tokenType?: string;
}
/** Represents the response from an API Token Delegation request. */
interface Auth0DelegationToken {
/** The length of time in seconds the token is valid for. */
ExpiresIn: number;
/** The JWT for delegated access. */
idToken: string;
/** The type of token being returned. Possible values: "Bearer" */
tokenType: string;
}
interface ChangePasswordOptions {
connection: string;
email: string;
password?: string;
}
interface PasswordlessStartOptions {
connection: string;
send: string;
phoneNumber?: string;
email?: string;
authParams?: any;
}
interface PasswordlessVerifyOptions {
connection: string;
verificationCode: string;
phoneNumber?: string;
email?: string;
}
/**
* Makes a call to the `/delegation` endpoint
*
* @method delegation
* @param {Object} options: https://auth0.com/docs/api/authentication#!#post--delegation
* @param {Function} callback
*/
delegation(options: any, callback: Auth0Callback<Auth0DelegationToken>): any;
/**
* Fetches the user country based on the ip.
*
* @method getUserCountry
* @param {Function} callback
*/
getUserCountry(callback: Auth0Callback<{ countryCode: string }>): void;
}
export class PasswordlessAuthentication {
constructor(request: any, option: any);
/**
* Builds and returns the passwordless TOTP verify url in order to initialize a new authN/authZ transaction
*
* @method buildVerifyUrl
* @param {Object} options
* @param {Function} callback
*/
buildVerifyUrl(options: any): string;
/**
* Initializes a new passwordless authN/authZ transaction
*
* @method start
* @param {Object} options: https://auth0.com/docs/api/authentication#passwordless
* @param {Function} callback
*/
start(options: PasswordlessStartOptions, callback: Auth0Callback<any>): void;
/**
* Verifies the passwordless TOTP and returns an error if any.
*
* @method buildVerifyUrl
* @param {Object} options
* @param {Function} callback
*/
verify(options: any, callback: Auth0Callback<any>): void;
}
export class DBConnection {
constructor(request: any, option: any);
/**
* Signup a new user
*
* @method signup
* @param {Object} options: https://auth0.com/docs/api/authentication#!#post--dbconnections-signup
* @param {Function} calback
*/
signup(options: any, callback: Auth0Callback<any>): void;
/**
* Initializes the change password flow
*
* @method signup
* @param {Object} options: https://auth0.com/docs/api/authentication#!#post--dbconnections-change_password
* @param {Function} callback
*/
changePassword(options: ChangePasswordOptions, callback: Auth0Callback<any>): void;
}
export class Management {
constructor(options: ManagementOptions);
/**
* Returns the user profile. https://auth0.com/docs/api/management/v2#!/Users/get_users_by_id
*
* @method getUser
* @param {String} userId
* @param {Function} callback
*/
getUser(userId: string, callback: Auth0Callback<Auth0UserProfile>): void;
/**
* Updates the user metdata. It will patch the user metdata with the attributes sent.
* https://auth0.com/docs/api/management/v2#!/Users/patch_users_by_id
*
* @method patchUserMetadata
* @param {String} userId
* @param {Object} userMetadata
* @param {Function} callback
*/
patchUserMetadata(userId: string, userMetadata: any, callback: Auth0Callback<Auth0UserProfile>): void;
/**
* Link two users. https://auth0.com/docs/api/management/v2#!/Users/post_identities
*
* @method linkUser
* @param {String} userId
* @param {String} secondaryUserToken
* @param {Function} callback
*/
linkUser(userId: string, secondaryUserToken: string, callback: Auth0Callback<any>): void;
}
export class WebAuth {
constructor(options: AuthOptions);
client: Authentication;
popup: Popup;
redirect: Redirect;
/**
* Redirects to the hosted login page (`/authorize`) in order to initialize a new authN/authZ transaction
*
* @method authorize
* @param {Object} options: https://auth0.com/docs/api/authentication#!#get--authorize_db
*/
authorize(options: any): void;
/**
* Parse the url hash and extract the returned tokens depending on the transaction.
*
* Only validates id_tokens signed by Auth0 using the RS256 algorithm using the public key exposed
* by the `/.well-known/jwks.json` endpoint. Id tokens signed with other algorithms will not be
* accepted.
*
* @method parseHash
* @param {Object} options:
* @param {String} options._idTokenVerification [OPTIONAL] Default: true
* @param {String} options.state [OPTIONAL] to verify the response
* @param {String} options.nonce [OPTIONAL] to verify the id_token
* @param {String} options.hash [OPTIONAL] the url hash. If not provided it will extract from window.location.hash
* @param {Function} callback: any(err, token_payload)
*/
parseHash(options: any, callback: Auth0Callback<Auth0DecodedHash>): void;
/**
* Decodes the id_token and verifies the nonce.
*
* @method validateToken
* @param {String} token
* @param {String} state
* @param {String} nonce
* @param {Function} callback: function(err, {payload, transaction})
*/
validateToken(token: string, state: string, nonce: string, callback: Auth0Callback<any>): void;
/**
* Executes a silent authentication transaction under the hood in order to fetch a new token.
*
* @method renewAuth
* @param {Object} options: any valid oauth2 parameter to be sent to the `/authorize` endpoint
* @param {Function} callback
*/
renewAuth(options: any, callback: Auth0Callback<any>): void;
/**
* Initialices a change password transaction
*
* @method changePassword
* @param {Object} options: https://auth0.com/docs/api/authentication#!#post--dbconnections-change_password
* @param {Function} callback
*/
changePassword(options: any, callback: Auth0Callback<any>): void;
/**
* Signs up a new user
*
* @method signup
* @param {Object} options: https://auth0.com/docs/api/authentication#!#post--dbconnections-signup
* @param {Function} callback
*/
signup(options: any, callback: Auth0Callback<any>): void;
/**
* Signs up a new user, automatically logs the user in after the signup and returns the user token.
* The login will be done using /oauth/token with password-realm grant type.
*
* @method signupAndAuthorize
* @param {Object} options: https://auth0.com/docs/api/authentication#!#post--dbconnections-signup
* @param {Function} callback
*/
signupAndAuthorize(options: any, callback: Auth0Callback<any>): void;
/**
* Redirects to the auth0 logout page
*
* @method logout
* @param {Object} options: https://auth0.com/docs/api/authentication#!#get--v2-logout
*/
logout(options: any): void;
/**
* Initialices a passwordless authentication transaction
*
* @method passwordlessStart
* @param {Object} options: https://auth0.com/docs/api/authentication#passwordless
* @param {Object} options.send: `link` or `code`
* @param {Object} options.phoneNumber: send should be code and email not set
* @param {Object} options.email: phoneNumber should be ignored
* @param {Object} options.connection
* @param {Object} options.authParams
* @param {Function} callback
*/
passwordlessStart(options: PasswordlessStartOptions, callback: Auth0Callback<any>): void;
/**
* Verifies the passwordless TOTP and redirects to finish the passwordless transaction
*
* @method passwordlessVerify
* @param {Object} options:
* @param {Object} options.type: `sms` or `email`
* @param {Object} options.phoneNumber: only if type = sms
* @param {Object} options.email: only if type = email
* @param {Object} options.connection: the connection name
* @param {Object} options.verificationCode: the TOTP code
* @param {Function} callback
*/
passwordlessVerify(options: any, callback: Auth0Callback<any>): void;
}
export class Redirect {
constructor(client: any, options: any);
/**
* Initializes the legacy Lock login flow in a popup
*
* @method loginWithCredentials
* @param {Object} options
* @param {Function} callback
* @deprecated `webauth.popup.loginWithCredentials` will be soon deprecated, use `webauth.client.login` instead.
*/
loginWithCredentials(options: any, callback: Auth0Callback<any>): void;
/**
* Signs up a new user and automatically logs the user in after the signup.
*
* @method signupAndLogin
* @param {Object} options: https://auth0.com/docs/api/authentication#!#post--dbconnections-signup
* @param {Function} callback
*/
signupAndLogin(options: any, callback: Auth0Callback<any>): void;
}
export class Popup {
constructor(client: any, options: any);
/**
* Returns a new instance of the popup handler
*
* @method buildPopupHandler
*/
buildPopupHandler(): any;
/**
* Initializes the popup window and returns the instance to be used later in order to avoid being blocked by the browser.
*
* @method preload
* @param {Object} options: receives the window height and width and any other window feature to be sent to window.open
*/
preload(options: any): any;
/**
* Opens in a popup the hosted login page (`/authorize`) in order to initialize a new authN/authZ transaction
*
* @method authorize
* @param {Object} options: https://auth0.com/docs/api/authentication#!#get--authorize_db
* @param {Function} callback
*/
authorize(options: any, callback: Auth0Callback<any>): void;
/**
* Initializes the legacy Lock login flow in a popup
*
* @method loginWithCredentials
* @param {Object} options
* @param {Function} callback
* @deprecated `webauth.popup.loginWithCredentials` will be soon deprecated, use `webauth.client.login` instead.
*/
loginWithCredentials(options: any, callback: Auth0Callback<any>): void;
/**
* Verifies the passwordless TOTP and returns the requested token
*
* @method passwordlessVerify
* @param {Object} options:
* @param {Object} options.type: `sms` or `email`
* @param {Object} options.phoneNumber: only if type = sms
* @param {Object} options.email: only if type = email
* @param {Object} options.connection: the connection name
* @param {Object} options.verificationCode: the TOTP code
* @param {Function} callback
*/
passwordlessVerify(options: any, callback: Auth0Callback<any>): void;
/**
* Signs up a new user and automatically logs the user in after the signup.
*
* @method signupAndLogin
* @param {Object} options: https://auth0.com/docs/api/authentication#!#post--dbconnections-signup
* @param {Function} callback
*/
signupAndLogin(options: any, callback: Auth0Callback<any>): void;
}
type Auth0Callback<T> = (error: null | Auth0Error, result: T) => void;
interface ManagementOptions {
domain: string;
token: string;
_sendTelemetry?: boolean;
_telemetryInfo?: any;
}
interface AuthOptions {
domain: string;
clientID: string;
responseType?: string;
responseMode?: string;
redirectUri?: string;
scope?: string;
audience?: string;
leeway?: number;
plugins?: any[];
_disableDeprecationWarnings?: boolean;
_sendTelemetry?: boolean;
_telemetryInfo?: any;
}
interface PasswordlessAuthOptions {
connection: string;
verificationCode: string;
phoneNumber: string;
email: string;
}
interface Auth0Error {
error?: any;
errorDescription?: string;
code?: string;
description?: string;
name?: string;
policy?: string;
original?: any;
statusCode?: number;
statusText?: string;
}
interface Auth0DecodedHash {
accessToken?: string;
idToken?: string;
idTokenPayload?: any;
refreshToken?: string;
state?: string;
expiresIn?: number;
tokenType?: string;
}
/** Represents the response from an API Token Delegation request. */
interface Auth0DelegationToken {
/** The length of time in seconds the token is valid for. */
expiresIn: number;
/** The JWT for delegated access. */
idToken: string;
/** The type of token being returned. Possible values: "Bearer" */
tokenType: string;
}
interface ChangePasswordOptions {
connection: string;
email: string;
password?: string;
}
interface PasswordlessStartOptions {
connection: string;
send: string;
phoneNumber?: string;
email?: string;
authParams?: any;
}
interface PasswordlessVerifyOptions {
connection: string;
verificationCode: string;
phoneNumber?: string;
email?: string;
}
interface Auth0UserProfile {
name: string;
nickname: string;
picture: string;
user_id: string;
username?: string;
given_name?: string;
family_name?: string;
email?: string;
email_verified?: string;
clientID: string;
gender?: string;
locale?: string;
identities: Auth0Identity[];
created_at: string;
updated_at: string;
sub: string;
user_metadata?: any;
app_metadata?: any;
}
interface MicrosoftUserProfile extends Auth0UserProfile {
emails?: string[]; //optional depending on whether email addresses permission is granted
}
interface Office365UserProfile extends Auth0UserProfile {
tenantid: string;
upn: string;
}
interface AdfsUserProfile extends Auth0UserProfile {
issuer?: string;
}
interface Auth0Identity {
connection: string;
isSocial: boolean;
provider: string;
user_id: string;
}
+2 -2
View File
@@ -1,4 +1,4 @@
import 'auth0-js/v7';
import * as auth0 from 'auth0-js';
import Auth0Lock from 'auth0-lock';
const CLIENT_ID = "YOUR_AUTH0_APP_CLIENTID";
@@ -38,7 +38,7 @@ lock.show(showOptions);
// "on" event-driven example
lock.on("authenticated", function(authResult : any) {
lock.getProfile(authResult.idToken, function(error, profile) {
lock.getProfile(authResult.idToken, function(error: auth0.Auth0Error, profile: auth0.Auth0UserProfile) {
if (error) {
// Handle error
return;
+13 -10
View File
@@ -1,9 +1,9 @@
// Type definitions for auth0-lock 10.9
// Type definitions for auth0-lock 10.10
// Project: http://auth0.com
// Definitions by: Brian Caruso <https://github.com/carusology>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="auth0-js/v7" />
/// <reference types="auth0-js" />
interface Auth0LockAdditionalSignUpFieldOption {
value: string;
@@ -11,13 +11,13 @@ interface Auth0LockAdditionalSignUpFieldOption {
}
type Auth0LockAdditionalSignUpFieldOptionsCallback =
(error: Auth0Error, options: Auth0LockAdditionalSignUpFieldOption[]) => void;
(error: auth0.Auth0Error, options: Auth0LockAdditionalSignUpFieldOption[]) => void;
type Auth0LockAdditionalSignUpFieldOptionsFunction =
(callback: Auth0LockAdditionalSignUpFieldOptionsCallback) => void;
type Auth0LockAdditionalSignUpFieldPrefillCallback =
(error: Auth0Error, prefill: string) => void;
(error: auth0.Auth0Error, prefill: string) => void;
type Auth0LockAdditionalSignUpFieldPrefillFunction =
(callback: Auth0LockAdditionalSignUpFieldPrefillCallback) => void;
@@ -32,8 +32,8 @@ interface Auth0LockAdditionalSignUpField {
validator?: (input: string) => { valid: boolean; hint?: string };
}
type Auth0LockAvatarUrlCallback = (error: Auth0Error, url: string) => void;
type Auth0LockAvatarDisplayNameCallback = (error: Auth0Error, displayName: string) => void;
type Auth0LockAvatarUrlCallback = (error: auth0.Auth0Error, url: string) => void;
type Auth0LockAvatarDisplayNameCallback = (error: auth0.Auth0Error, displayName: string) => void;
interface Auth0LockAvatarOptions {
url: (email: string, callback: Auth0LockAvatarUrlCallback) => void;
@@ -63,6 +63,7 @@ interface Auth0LockAuthOptions {
redirectUrl?: string;
responseType?: string;
sso?: boolean;
audience?: string;
}
interface Auth0LockPopupOptions {
@@ -101,6 +102,7 @@ interface Auth0LockConstructorOptions {
socialButtonStyle?: "big" | "small";
theme?: Auth0LockThemeOptions;
usernameStyle?: string;
oidcConformant?: boolean;
}
interface Auth0LockFlashMessageOptions {
@@ -123,15 +125,16 @@ interface Auth0LockStatic {
new (clientId: string, domain: string, options?: Auth0LockConstructorOptions): Auth0LockStatic;
// deprecated
getProfile(token: string, callback: (error: Auth0Error, profile: Auth0UserProfile) => void): void;
getUserInfo(token: string, callback: (error: Auth0Error, profile: Auth0UserProfile) => void): void;
getProfile(token: string, callback: (error: auth0.Auth0Error, profile: auth0.Auth0UserProfile) => void): void;
getUserInfo(token: string, callback: (error: auth0.Auth0Error, profile: auth0.Auth0UserProfile) => void): void;
// https://github.com/auth0/lock#resumeauthhash-callback
resumeAuth( hash: string, callback: (error: auth0.Auth0Error, authResult: any) => void): void;
show(options?: Auth0LockShowOptions): void;
hide(): void;
logout(query: any): void;
on(event: "show" | "hide", callback: () => void): void;
on(event: "unrecoverable_error" | "authorization_error", callback: (error: Auth0Error) => void): void;
on(event: "unrecoverable_error" | "authorization_error", callback: (error: auth0.Auth0Error) => void): void;
on(event: "authenticated", callback: (authResult: any) => void): void;
on(event: string, callback: (...args: any[]) => void): void;
}
-2
View File
@@ -1,5 +1,3 @@
/// <reference types="auth0" />
import * as auth0 from 'auth0';
const management = new auth0.ManagementClient({
+17
View File
@@ -0,0 +1,17 @@
import * as autopref from 'autoprefixer';
const ap: autopref.Transformer = autopref({
browsers: ['> 5%', 'last 2 versions'],
env: '',
cascade: true,
add: true,
remove: true,
supports: true,
flexbox: true,
grid: true,
stats: {},
});
const ap2: autopref.Transformer = autopref({
flexbox: 'no-2009',
});
const info: string = ap.info();
+32
View File
@@ -0,0 +1,32 @@
// Type definitions for autoprefixer 6.7
// Project: https://github.com/postcss/autoprefixer
// Definitions by: Armando Meziat <https://github.com/odnamrataizem>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import { Plugin, Transformer as PostcssTransformer } from 'postcss';
declare namespace autoprefixer {
export interface Options {
browsers?: string[];
env?: string;
cascade?: boolean;
add?: boolean;
remove?: boolean;
supports?: boolean;
flexbox?: boolean | 'no-2009';
grid?: boolean;
stats?: any;
}
export interface Transformer extends PostcssTransformer {
info(): string;
}
export interface Autoprefixer extends Plugin<Options> {
(opts?: Options): Transformer;
}
}
declare const autoprefixer: autoprefixer.Autoprefixer;
export = autoprefixer;
+5
View File
@@ -0,0 +1,5 @@
{
"dependencies": {
"postcss": "^5.2.15"
}
}
+22
View File
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"autoprefixer-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "../tslint.json" }
-2
View File
@@ -1,5 +1,3 @@
/// <reference types="autosize" />
// from a NodeList
autosize(document.querySelectorAll('textarea'));
+31 -26
View File
@@ -1,3 +1,5 @@
import * as Awesomplete from 'awesomplete';
var input = document.getElementById("myinput");
new Awesomplete(input, {list: "#mylist"});
@@ -11,45 +13,48 @@ var awesomplete = new Awesomplete(input);
awesomplete.list = ["Ada", "Java", "JavaScript", "LOLCODE", "Node.js", "Ruby on Rails"];
new Awesomplete(input, {
list: [
{ label: "Belarus", value: "BY" },
{ label: "China", value: "CN" },
{ label: "United States", value: "US" }
]
list: [
{ label: "Belarus", value: "BY" },
{ label: "China", value: "CN" },
{ label: "United States", value: "US" }
]
});
// Same with arrays:
new Awesomplete(input, {
list: [
[ "Belarus", "BY" ],
[ "China", "CN" ],
[ "United States", "US" ]
]
list: [
[ "Belarus", "BY" ],
[ "China", "CN" ],
[ "United States", "US" ]
]
});
new Awesomplete('input[type="email"]', {
list: ["aol.com", "att.net", "comcast.net", "facebook.com", "gmail.com", "gmx.com", "googlemail.com", "google.com", "hotmail.com", "hotmail.co.uk", "mac.com", "me.com", "mail.com", "msn.com", "live.com", "sbcglobal.net", "verizon.net", "yahoo.com", "yahoo.co.uk"],
data: function (text: string, input: any) {
return input.slice(0, input.indexOf("@")) + "@" + text;
},
filter: Awesomplete.FILTER_STARTSWITH
list: ["aol.com", "att.net", "comcast.net", "facebook.com", "gmail.com",
"gmx.com", "googlemail.com", "google.com", "hotmail.com",
"hotmail.co.uk", "mac.com", "me.com", "mail.com", "msn.com",
"live.com", "sbcglobal.net", "verizon.net", "yahoo.com", "yahoo.co.uk"],
data: (text: string, input: string) => {
return input.slice(0, input.indexOf("@")) + "@" + text;
},
filter: Awesomplete.FILTER_STARTSWITH
});
new Awesomplete('input[data-multiple]', {
filter: function(text: string, input: any) {
return Awesomplete.FILTER_CONTAINS(text, input.match(/[^,]*$/)[0]);
},
filter: (text: string, input: any) => {
return Awesomplete.FILTER_CONTAINS(text, input.match(/[^,]*$/)[0]);
},
replace: function(text: string) {
var before = this.input.value.match(/^.+,\s*|/)[0];
this.input.value = before + text + ", ";
}
replace: (text: string) => {
var before = this.input.value.match(/^.+,\s*|/)[0];
this.input.value = before + text + ", ";
}
});
var ajax = new XMLHttpRequest();
ajax.open("GET", "https://restcountries.eu/rest/v1/lang/fr", true);
ajax.onload = function() {
var list = JSON.parse(ajax.responseText).map(function(i: any) { return i.name; });
new Awesomplete(document.querySelector("#ajax-example input"),{ list: list });
ajax.onload = () => {
var list = JSON.parse(ajax.responseText).map((i: any) => { return i.name; });
new Awesomplete(document.querySelector("#ajax-example input"), { list: list });
};
ajax.send();
ajax.send();
+50 -42
View File
@@ -1,49 +1,57 @@
// Type definitions for Awesomplete v1.1.0
// Type definitions for Awesomplete 1.1
// Project: https://leaverou.github.io/awesomplete/
// Definitions by: webbiesdk <https://github.com/webbiesdk/>, Ben Dixon <https://github.com/bmdixon/>
// Definitions by: webbiesdk <https://github.com/webbiesdk/>, Ben Dixon <https://github.com/bmdixon/>, Trevor Bekolay <https://github.com/tbekolay/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare class Awesomplete {
constructor(input: Element | HTMLElement | string, o?: AwesompleteOptions);
static all: Array<any>;
static $$: (expr: string | NodeSelector, con?: any) => NodeList;
static ITEM: (text: string, input: string) => HTMLElement;
static $: {
(expr: string|Element, con?: NodeSelector): string | Element;
regExpEscape: (s: { replace: (arg0: RegExp, arg1: string) => void }) => any;
create: (tag: string, o: any) => HTMLElement;
fire: (target: EventTarget, type: string, properties: any) => any;
siblingIndex: (el: Element) => number;
};
static FILTER_STARTSWITH: (text: string, input: string) => boolean;
static FILTER_CONTAINS: (text: string, input: string) => boolean;
static SORT_BYLENGTH: (a: number | any[], b: number | any[]) => number;
static REPLACE: (text: any) => void;
next: () => void;
container: HTMLElement;
select: (selected?: HTMLElement, originalTarget?: HTMLElement) => void;
previous: () => void;
index: number;
opened: number;
list: string | string[] | Element | { label: string, value: any }[] | [string, string][];
input: HTMLElement | string;
goto: (i: number) => void;
ul: HTMLElement;
close: () => void;
evaluate: () => void;
selected: boolean;
open: () => void;
status: HTMLElement;
constructor(input: Element | HTMLElement | string, o?: Awesomplete.Options);
static all: any[];
static $$: (expr: string | NodeSelector, con?: any) => NodeList;
static ITEM: (text: string, input: string) => HTMLElement;
static $: {
(expr: string|Element, con?: NodeSelector): string | Element;
regExpEscape: (s: { replace: (arg0: RegExp, arg1: string) => void }) => any;
create: (tag: string, o: any) => HTMLElement;
fire: (target: EventTarget, type: string, properties: any) => any;
siblingIndex: (el: Element) => number;
};
static FILTER_STARTSWITH: (text: string, input: string) => boolean;
static FILTER_CONTAINS: (text: string, input: string) => boolean;
static SORT_BYLENGTH: (left: number | any[], right: number | any[]) => number;
static REPLACE: (text: string) => void;
static DATA: (item: Awesomplete.Suggestion) => Awesomplete.Suggestion;
next: () => void;
container: HTMLElement;
select: (selected?: HTMLElement, originalTarget?: HTMLElement) => void;
previous: () => void;
index: number;
opened: number;
list: string | Element | Awesomplete.Suggestion[];
input: HTMLElement | string;
goto: (i: number) => void;
ul: HTMLElement;
close: () => void;
evaluate: () => void;
selected: boolean;
open: () => void;
status: HTMLElement;
}
interface AwesompleteOptions {
list?: string | string[] | Element | { label: string, value: any }[] | [string, string][];
minChars?: Number;
maxItems?: Number;
autoFirst?: boolean;
data?: Function;
filter?: Function;
sort?: Function;
item?: Function;
replace?: Function;
declare namespace Awesomplete {
type Suggestion = string | {label: string | any, value: string | any} | [string, string];
interface Options {
list?: string | string[] | Element | { label: string, value: any }[] | [string, string][];
minChars?: number;
maxItems?: number;
autoFirst?: boolean;
data?: (item: Suggestion, input: string) => string;
filter?: (text: string, input: string) => boolean;
sort?: (left: number | any[], right: number | any[]) => number;
item?: (text: string, input: string) => HTMLElement;
replace?: (text: string) => void;
}
}
export = Awesomplete;
export as namespace Awesomplete;
+1
View File
@@ -0,0 +1 @@
{ "extends": "../tslint.json" }
+34 -3
View File
@@ -1,5 +1,3 @@
/// <reference types="aws-lambda" />
var str: string = "any string";
var date: Date = new Date();
var anyObj: any = { abc: 123 };
@@ -13,6 +11,12 @@ var clientContextClient: AWSLambda.ClientContextClient;
var context: AWSLambda.Context;
var identity: AWSLambda.CognitoIdentity;
var proxyResult: AWSLambda.ProxyResult;
var snsEvt: AWSLambda.SNSEvent;
var snsEvtRecs: Array<AWSLambda.SNSEventRecord>;
var snsEvtRec: AWSLambda.SNSEventRecord;
var snsMsg: AWSLambda.SNSMessage;
var snsMsgAttr: AWSLambda.SNSMessageAttribute;
var snsMsgAttrs: AWSLambda.SNSMessageAttributes;
/* API Gateway Event */
str = apiGwEvt.body;
@@ -44,9 +48,36 @@ str = apiGwEvt.requestContext.resourceId;
str = apiGwEvt.requestContext.resourcePath;
str = apiGwEvt.resource;
/* SNS Event */
snsEvtRecs = snsEvt.Records;
str = snsEvtRec.EventSource;
str = snsEvtRec.EventSubscriptionArn;
str = snsEvtRec.EventVersion;
snsMsg = snsEvtRec.Sns;
str = snsMsg.SignatureVersion;
str = snsMsg.Timestamp;
str = snsMsg.Signature;
str = snsMsg.SigningCertUrl;
str = snsMsg.MessageId;
str = snsMsg.Message;
snsMsgAttrs = snsMsg.MessageAttributes;
str = snsMsg.Type;
str = snsMsg.UnsubscribeUrl;
str = snsMsg.TopicArn;
str = snsMsg.Subject;
snsMsgAttrs["example"] = snsMsgAttr;
str = snsMsgAttr.Type;
str = snsMsgAttr.Value;
/* Lambda Proxy Result */
num = proxyResult.statusCode;
str = proxyResult.headers["example"];
proxyResult.headers["example"] = str;
proxyResult.headers["example"] = b;
proxyResult.headers["example"] = num;
str = proxyResult.body
/* Context */
+38 -3
View File
@@ -39,6 +39,41 @@ interface APIGatewayEvent {
resource: string;
}
// SNS "event"
interface SNSMessageAttribute {
Type: string;
Value: string;
}
interface SNSMessageAttributes {
[name: string]: SNSMessageAttribute;
}
interface SNSMessage {
SignatureVersion: string;
Timestamp: string;
Signature: string;
SigningCertUrl: string;
MessageId: string;
Message: string;
MessageAttributes: SNSMessageAttributes;
Type: string;
UnsubscribeUrl: string;
TopicArn: string;
Subject: string;
}
interface SNSEventRecord {
EventVersion: string;
EventSubscriptionArn: string;
EventSource: string;
Sns: SNSMessage;
}
interface SNSEvent {
Records: Array<SNSEventRecord>;
}
// Context
// http://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-context.html
interface Context {
@@ -97,7 +132,7 @@ interface ClientContextEnv {
interface ProxyResult {
statusCode: number;
headers?: {
[header: string]: string;
[header: string]: boolean | number | string;
},
body: string;
}
@@ -110,8 +145,8 @@ interface ProxyResult {
* @param context – runtime information of the Lambda function that is executing.
* @param callback – optional callback to return information to the caller, otherwise return value is null.
*/
export type Handler = (event: any, context: Context, callback?: Callback) => void;
export type ProxyHandler = (event: APIGatewayEvent, context: Context, callback?: ProxyCallback) => void;
export type Handler = (event: any, context: Context, callback?: Callback) => void;
export type ProxyHandler = (event: APIGatewayEvent, context: Context, callback?: ProxyCallback) => void;
/**
* Optional callback parameter.
@@ -1,9 +1,10 @@
/// <reference types="express"/>
import * as awsServerlessExpress from 'aws-serverless-express';
import * as express from 'express';
import { eventContext } from 'aws-serverless-express/middleware';
const app = express();
app.use(eventContext());
const server = awsServerlessExpress.createServer(app, () => {});
const mockEvent = {
+3 -3
View File
@@ -1,6 +1,6 @@
// Type definitions for aws-serverless-express
// Type definitions for aws-serverless-express 2.1
// Project: https://github.com/awslabs/aws-serverless-express
// Definitions by: Ben Speakman <https://github.com/threesquared>
// Definitions by: Ben Speakman <https://github.com/threesquared>, Josh Caffey <https://github.com/jcaffey>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node"/>
@@ -16,4 +16,4 @@ export function proxy(
server: http.Server,
event: any,
context: lambda.Context
): void;
): void;
+8
View File
@@ -0,0 +1,8 @@
import { RequestHandler } from 'express';
export interface Options {
reqPropKey?: string;
deleteHeaders?: boolean;
}
export function eventContext(options?: Options): RequestHandler;
+2 -1
View File
@@ -17,6 +17,7 @@
},
"files": [
"index.d.ts",
"middleware.d.ts",
"aws-serverless-express-tests.ts"
]
}
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "../tslint.json" }
+52
View File
@@ -0,0 +1,52 @@
import b_ = require("b_");
const blockClass: string = b_("block");
const blockWithModsClass: string = b_("block", {stringMod: "string", boolMod: true, numberMod: 5});
const elemClass: string = b_("block", "elem");
const elemWithModsClass: string = b_("block", "elem", {stringMod: "string", boolMod: true, numberMod: 5});
const withBlock = b_.with("block");
const withBlockClass: string = withBlock();
const withBlockWithModsClass: string = withBlock({stringMod: "string", boolMod: true, numberMod: 5});
const withBlockElemClass: string = withBlock("elem");
const withBlockElemWithModsClass: string = withBlock("elem", {stringMod: "string", boolMod: true, numberMod: 5});
const lockBlock = b_.lock("block");
const lockBlockClass: string = lockBlock();
const lockBlockWithModsClass: string = lockBlock({stringMod: "string", boolMod: true, numberMod: 5});
const lockBlockElemClass: string = lockBlock("elem");
const lockBlockElemWithModsClass: string = lockBlock("elem", {stringMod: "string", boolMod: true, numberMod: 5});
const withElem = b_.with("block", "elem");
const withElemClass: string = withElem();
const withElemWithModsClass: string = withElem({stringMod: "string", boolMod: true, numberMod: 5});
const parameterizedB_ = b_.B({
tailSpace: " ",
elementSeparator: "-",
modSeparator: "_",
modValueSeparator: "-",
classSeparator: " ",
isFullModifier: true
});
const parameterizedBlockClass: string = parameterizedB_("block");
const parameterizedBlockWithModsClass: string = parameterizedB_("block", {stringMod: "string", boolMod: true, numberMod: 5});
const parameterizedElemClass: string = parameterizedB_("block", "elem");
const parameterizedElemWithModsClass: string = parameterizedB_("block", "elem", {stringMod: "string", boolMod: true, numberMod: 5});
const parameterizedWithBlock = parameterizedB_.with("block");
const parameterizedWithBlockClass: string = parameterizedWithBlock();
const parameterizedWithBlockWithModsClass: string = parameterizedWithBlock({stringMod: "string", boolMod: true, numberMod: 5});
const parameterizedWithBlockElemClass: string = parameterizedWithBlock("elem");
const parameterizedWithBlockElemWithModsClass: string = parameterizedWithBlock("elem", {stringMod: "string", boolMod: true, numberMod: 5});
const parameterizedLockBlock = parameterizedB_.lock("block");
const parameterizedLockBlockClass: string = parameterizedLockBlock();
const parameterizedLockBlockWithModsClass: string = parameterizedLockBlock({stringMod: "string", boolMod: true, numberMod: 5});
const parameterizedLockBlockElemClass: string = parameterizedLockBlock("elem");
const parameterizedLockBlockElemWithModsClass: string = parameterizedLockBlock("elem", {stringMod: "string", boolMod: true, numberMod: 5});
const parameterizedWithElem = parameterizedB_.with("block", "elem");
const parameterizedWithElemClass: string = parameterizedWithElem();
const parameterizedWithElemWithModsClass: string = parameterizedWithElem({stringMod: "string", boolMod: true, numberMod: 5});
+40
View File
@@ -0,0 +1,40 @@
// Type definitions for b_ 1.3
// Project: https://github.com/azproduction/b_
// Definitions by: Vasya Aksyonov <https://github.com/outring>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
interface Options {
tailSpace?: string;
elementSeparator?: string;
modSeparator?: string;
modValueSeparator?: string;
classSeparator?: string;
isFullModifier?: boolean;
}
interface Mods {
[name: string]: any;
}
interface Formatter {
(block: string, mods?: Mods): string;
(block: string, elem: string, mods?: Mods): string;
with(block: string): BlockFormatter;
with(block: string, elem: string): ElemFormatter;
lock(block: string): BlockFormatter;
lock(block: string, elem: string): ElemFormatter;
B(options: Options): Formatter;
}
interface BlockFormatter {
(mods?: Mods): string;
(elem: string, mods?: Mods): string;
}
type ElemFormatter = (mods?: Mods) => string;
declare const formatter: Formatter;
export = formatter;
+22
View File
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"b_-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "../tslint.json" }
-3
View File
@@ -1,7 +1,4 @@
/// <reference types="babel-generator" />
/// <reference types="babel-types" />
// Example from https://github.com/babel/babel/tree/master/packages/babel-template
import template = require('babel-template');
-2
View File
@@ -1,5 +1,3 @@
/// <reference types="babel-types" />
/// <reference types="babylon" />
-5
View File
@@ -1,8 +1,3 @@
/// <reference types="babel-types" />
/// <reference types="babel-types" />
// Example from https://github.com/thejameskyle/babel-handbook/blob/master/translations/en/plugin-handbook.md#babylon
import * as babylon from "babylon";
declare function assert(expr: boolean): void;
+15 -5
View File
@@ -1,4 +1,4 @@
// Type definitions for babylon v6.7
// Type definitions for babylon v6.16.1
// Project: https://github.com/babel/babylon
// Definitions by: Troy Gerwien <https://github.com/yortus>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@@ -41,7 +41,17 @@ export interface BabylonOptions {
plugins?: PluginName[];
}
export type PluginName = 'jsx' | 'flow' | 'asyncFunctions' | 'classConstructorCall' | 'doExpressions'
| 'trailingFunctionCommas' | 'objectRestSpread' | 'decorators' | 'classProperties' | 'exportExtensions'
| 'exponentiationOperator' | 'asyncGenerators' | 'functionBind' | 'functionSent' | '*';
export type PluginName =
'estree' |
'jsx' |
'flow' |
'classConstructorCall' |
'doExpressions' |
'objectRestSpread' |
'decorators' |
'classProperties' |
'exportExtensions' |
'asyncGenerators' |
'functionBind' |
'functionSent' |
'dynamicImport';
@@ -1,5 +1,3 @@
/// <reference types="jquery"/>
import * as Backbone from 'backbone';
// Example code.
@@ -26,7 +24,7 @@ class View extends Backbone.Layout<Backbone.Model> {
"mouseleave": "removeElement"
}
}
wrapElement(): void {
this.$el.wrap("<b>");
}
-2
View File
@@ -1,5 +1,3 @@
/// <reference types="jquery" />
function test_events() {
var object = new Backbone.Events();
-3
View File
@@ -1,6 +1,3 @@
/// <reference types="mocha" />
/// <reference types="chai" />
import * as angular from 'angular';
import 'angular-mocks';
-2
View File
@@ -1,5 +1,3 @@
/// <reference types="node" />
import fs = require('fs');
import BatchStream = require('batch-stream');
@@ -1,5 +1,3 @@
/// <reference types="bazinga-translator" />
Translator.fallback = 'en';
Translator.defaultDomain = 'messages';
-2
View File
@@ -1,5 +1,3 @@
/// <reference types="bezier-js" />
function test() {
var bezierjs: typeof BezierJs;
+1
View File
@@ -113,5 +113,6 @@ isBigInteger = x.times( "100" );
isNumber = x.toJSNumber();
isString = x.toString();
isString = x.toString(36);
isNumber = x.valueOf();
+1 -1
View File
@@ -195,7 +195,7 @@ interface BigInteger {
toJSNumber(): number;
/** Converts a bigInt to a string. */
toString(): string;
toString( radix?: number ): string;
/** Converts a bigInt to a native Javascript number. This override allows you to use native arithmetic operators without explicit conversion. */
valueOf(): number;
+445
View File
@@ -0,0 +1,445 @@
var x: BigNumber.BigNumber = new BigNumber(9)
var y = new BigNumber(x)
BigNumber(435.345)
new BigNumber('5032485723458348569331745.33434346346912144534543')
new BigNumber('4.321e+4')
new BigNumber('-735.0918e-430')
new BigNumber(Infinity)
new BigNumber(NaN)
new BigNumber('.5')
new BigNumber('+2')
new BigNumber(-10110100.1, 2)
new BigNumber(-0b10110100)
new BigNumber('123412421.234324', 5)
new BigNumber('ff.8', 16)
new BigNumber('0xff.8')
new BigNumber(9, 2)
new BigNumber(96517860459076817.4395)
new BigNumber('blurgh')
BigNumber.config({ DECIMAL_PLACES: 5 })
new BigNumber(1.23456789)
new BigNumber(1.23456789, 10)
BigNumber.config({ DECIMAL_PLACES: 5 })
var BN = BigNumber.another({ DECIMAL_PLACES: 9 })
x = new BigNumber(1)
y = new BN(1)
x.div(3)
y.div(3)
BN = BigNumber.another()
BN.config({ DECIMAL_PLACES: 9 })
BigNumber.config({ DECIMAL_PLACES: 5 })
BigNumber.set({ DECIMAL_PLACES: 5 })
BigNumber.config(5)
BigNumber.config({ ROUNDING_MODE: 0 })
BigNumber.config(undefined, BigNumber.ROUND_UP)
BigNumber.config({ EXPONENTIAL_AT: 2 })
new BigNumber(12.3)
new BigNumber(123)
new BigNumber(0.123)
new BigNumber(0.0123)
BigNumber.config({ EXPONENTIAL_AT: [-7, 20] })
new BigNumber(123456789)
new BigNumber(0.000000123)
BigNumber.config({ EXPONENTIAL_AT: 1e+9 })
BigNumber.config({ EXPONENTIAL_AT: 0 })
BigNumber.config({ RANGE: 500 })
BigNumber.config().RANGE
new BigNumber('9.999e499')
new BigNumber('1e500')
new BigNumber('1e-499')
new BigNumber('1e-500')
BigNumber.config({ RANGE: [-3, 4] })
new BigNumber(99999)
new BigNumber(100000)
new BigNumber(0.001)
new BigNumber(0.0001)
BigNumber.config({ ERRORS: false })
BigNumber.config({ CRYPTO: true })
BigNumber.config().CRYPTO
BigNumber.random()
BigNumber.config({ MODULO_MODE: BigNumber.EUCLID })
BigNumber.config({ MODULO_MODE: 9 })
BigNumber.config({ POW_PRECISION: 100 })
BigNumber.config({
FORMAT: {
decimalSeparator: '.',
groupSeparator: ',',
groupSize: 3,
secondaryGroupSize: 0,
fractionGroupSeparator: ' ',
fractionGroupSize: 0
}
});
BigNumber.config({
DECIMAL_PLACES: 40,
ROUNDING_MODE: BigNumber.ROUND_HALF_CEIL,
EXPONENTIAL_AT: [-10, 20],
RANGE: [-500, 500],
ERRORS: true,
CRYPTO: true,
MODULO_MODE: BigNumber.ROUND_FLOOR,
POW_PRECISION: 80,
FORMAT: {
groupSize: 3,
groupSeparator: ' ',
decimalSeparator: ','
}
});
BigNumber.config(40, 7, [-10, 20], 500, 1, 1, 3, 80)
var obj = BigNumber.config();
obj.ERRORS
obj.RANGE
x = new BigNumber('3257869345.0378653')
BigNumber.max(4e9, x, '123456789.9')
var arr = [12, '13', new BigNumber(14)]
BigNumber.max(arr)
x = new BigNumber('3257869345.0378653')
BigNumber.min(4e9, x, '123456789.9')
arr = [2, new BigNumber(-14), '-15.9999', -12]
BigNumber.min(arr)
BigNumber.config({ DECIMAL_PLACES: 10 })
BigNumber.random()
BigNumber.random(20)
BigNumber.config({ ROUNDING_MODE: BigNumber.ROUND_CEIL })
BigNumber.config({ ROUNDING_MODE: 2 })
x = new BigNumber(-0.8)
y = x.absoluteValue()
var z = y.abs()
x = new BigNumber(1.3)
x.ceil()
y = new BigNumber(-1.8)
y.ceil()
x = new BigNumber(Infinity)
y = new BigNumber(5)
x.comparedTo(y)
x.comparedTo(x.minus(1))
y.cmp(NaN)
y.cmp('110', 2)
x = new BigNumber(123.45)
x.decimalPlaces()
y = new BigNumber('9.9e-101')
y.dp()
x = new BigNumber(355)
y = new BigNumber(113)
x.dividedBy(y)
x.div(5)
x.div(47, 16)
x = new BigNumber(5)
y = new BigNumber(3)
x.dividedToIntegerBy(y)
x.divToInt(0.7)
x.divToInt('0.f', 16)
0 === 1e-324
x = new BigNumber(0)
x.equals('1e-324')
BigNumber(-0).eq(x)
BigNumber(255).eq('ff', 16)
y = new BigNumber(NaN)
y.equals(NaN)
x = new BigNumber(1.8)
x.floor()
y = new BigNumber(-1.3)
y.floor()
0.1 > (0.3 - 0.2)
x = new BigNumber(0.1)
x.greaterThan(BigNumber(0.3).minus(0.2))
BigNumber(0).gt(x)
BigNumber(11, 3).gt(11.1, 2)
x = new BigNumber(0.3).minus(0.2)
x.greaterThanOrEqualTo(0.1)
BigNumber(1).gte(x)
BigNumber(10, 18).gte('i', 36)
x = new BigNumber(1)
x.isFinite()
y = new BigNumber(Infinity)
y.isFinite()
x = new BigNumber(1)
x.isInteger()
y = new BigNumber(123.456)
y.isInt()
x = new BigNumber(NaN)
x.isNaN()
y = new BigNumber('Infinity')
y.isNaN()
x = new BigNumber(-0)
x.isNegative()
y = new BigNumber(2)
y.isNeg()
x = new BigNumber(-0)
x.isZero() && x.isNeg()
y = new BigNumber(Infinity)
y.isZero()
x = new BigNumber(0.3).minus(0.2)
x.lessThan(0.1)
BigNumber(0).lt(x)
BigNumber(11.1, 2).lt(11, 3)
x = new BigNumber(0.1)
x.lessThanOrEqualTo(BigNumber(0.3).minus(0.2))
BigNumber(-1).lte(x)
BigNumber(10, 18).lte('i', 36)
x = new BigNumber(0.3)
x.minus(0.1)
x.sub(0.6, 20)
x = new BigNumber(1)
x.modulo(0.9)
y = new BigNumber(33)
y.mod('a', 33)
x = new BigNumber(1.8)
x.negated()
y = new BigNumber(-1.3)
y.neg()
x = new BigNumber(0.1)
y = x.plus(0.2)
BigNumber(0.7).plus(x).add(y)
x.plus('0.1', 8)
x = new BigNumber(1.234)
x.precision()
y = new BigNumber(987000)
y.sd()
y.sd(true)
y = new BigNumber(x)
y.round()
y.round(1)
y.round(2)
y.round(10)
y.round(0, 1)
y.round(0, 6)
y.round(1, 1)
y.round(1, BigNumber.ROUND_HALF_EVEN)
y
x = new BigNumber(1.23)
x.shift(3)
x.shift(-3)
x = new BigNumber(16)
x.squareRoot()
y = new BigNumber(3)
y.sqrt()
x = new BigNumber(0.6)
y = x.times(3)
BigNumber('7e+500').times(y)
x.times('-a', 16)
BigNumber.config({ DECIMAL_PLACES: 5, ROUNDING_MODE: 4 })
x = new BigNumber(9876.54321)
x.toDigits()
x.toDigits(6)
x.toDigits(6, BigNumber.ROUND_UP)
x.toDigits(2)
x.toDigits(2, 1)
x
y = new BigNumber(45.6)
y.toExponential()
y.toExponential(0)
y.toExponential(1)
y.toExponential(1, 1)
y.toExponential(3)
y = new BigNumber(3.456)
y.toFixed()
y.toFixed(0)
y.toFixed(2)
y.toFixed(2, 1)
y.toFixed(5)
var format = {
decimalSeparator: '.',
groupSeparator: ',',
groupSize: 3,
secondaryGroupSize: 0,
fractionGroupSeparator: ' ',
fractionGroupSize: 0
}
BigNumber.config({ FORMAT: format })
x = new BigNumber('123456789.123456789')
x.toFormat()
x.toFormat(1)
format.groupSeparator = ' '
format.fractionGroupSize = 5
x.toFormat()
BigNumber.config({
FORMAT: {
decimalSeparator: ',',
groupSeparator: '.',
groupSize: 3,
secondaryGroupSize: 2
}
})
x.toFormat(6)
x = new BigNumber(1.75)
x.toFraction()
var pi = new BigNumber('3.14159265358')
pi.toFraction()
pi.toFraction(100000)
pi.toFraction(10000)
pi.toFraction(100)
pi.toFraction(10)
pi.toFraction(1)
x = new BigNumber('177.7e+457')
y = new BigNumber(235.4325)
z = new BigNumber('0.0098074')
var str = JSON.stringify([x, y, z])
JSON.parse(str, (key, val) => key === '' ? val : new BigNumber(val))
x = new BigNumber(456.789)
x.toNumber()
{ +x }
y = new BigNumber('45987349857634085409857349856430985')
y.toNumber()
z = new BigNumber(-0)
1 / +z
1 / z.toNumber()
x = new BigNumber(0.7)
x.toPower(2)
BigNumber(3).pow(-2)
y = new BigNumber(45.6)
x.toPrecision()
y.toPrecision()
x.toPrecision(1)
y.toPrecision(1)
y.toPrecision(2, 0)
y.toPrecision(2, 1)
x.toPrecision(5)
y.toPrecision(5)
x = new BigNumber(750000)
x.toString()
BigNumber.config({ EXPONENTIAL_AT: 5 })
x.toString()
y = new BigNumber(362.875)
y.toString(2)
y.toString(9)
y.toString(32)
BigNumber.config({ DECIMAL_PLACES: 4 });
z = new BigNumber('1.23456789')
z.toString()
z.toString(10)
x = new BigNumber(123.456)
x.truncated()
y = new BigNumber(-12.3)
y.trunc()
x = new BigNumber('-0')
x.toString()
x.valueOf()
y = new BigNumber('1.777e+457')
y.valueOf()
x = new BigNumber(0.123)
x.toExponential()
x.c
x.e
x.s
z = new BigNumber('-123.4567000e+2')
z.toExponential()
z.c
z.e
z.s
x = new BigNumber(3)
x instanceof BigNumber
x.isBigNumber
BN = BigNumber.another();
y = new BN(3)
y instanceof BigNumber
y.isBigNumber
y = new BigNumber(-0)
y.c
y.e
y.s
try {
// ...
} catch (e) {
if (e instanceof Error && e.name == 'BigNumber Error') {
// ...
}
}
x = new BigNumber("1.0")
y = new BigNumber("1.1000")
z = x.add(y)
x = new BigNumber("1.20")
y = new BigNumber("3.45000")
z = x.mul(y)
+681
View File
@@ -0,0 +1,681 @@
// Type definitions for bignumber.js 4.0
// Project: https://github.com/MikeMcl/bignumber.js/
// Definitions by: Viktor Smirnov <https://github.com/LaserUnicorns/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
declare var BigNumber: BigNumber.BigNumberStatic;
export as namespace BigNumber;
export = BigNumber;
declare namespace BigNumber {
interface FormatConfig {
/**
* The decimal separator.
*/
decimalSeparator: string;
/**
* The grouping separator of the integer part.
*/
groupSeparator: string;
/**
* The primary grouping size of the integer part.
*/
groupSize: number;
/**
* The secondary grouping size of the integer part.
*/
secondaryGroupSize: number;
/**
* The grouping separator of the fraction part.
*/
fractionGroupSeparator: string;
/**
* The grouping size of the fraction part.
*/
fractionGroupSize: number;
}
interface BigNumberConfig {
/**
* The maximum number of decimal places of the results of operations involving division,
* i.e. division, square root and base conversion operations, and power operations with negative exponents.
*/
DECIMAL_PLACES: number;
/**
* The rounding mode used in the above operations and the default rounding mode of round, `toExponential`, `toFixed`, `toFormat` and `toPrecision`.
*/
ROUNDING_MODE: RoundingMode;
/**
* The exponent value(s) at which `toString` returns exponential notation.
*
* If a single number is assigned, the value is the exponent magnitude.
*
* If an array of two numbers is assigned then the first number is the negative exponent value at and beneath which exponential notation is used,
* and the second number is the positive exponent value at and above which the same.
*/
EXPONENTIAL_AT: number | number[];
/**
* The exponent value(s) beyond which overflow to `Infinity` and underflow to zero occurs.
*
* If a single number is assigned, it is the maximum exponent magnitude:
* values wth a positive exponent of greater magnitude become `Infinity`
* and those with a negative exponent of greater magnitude become zero.
*
* If an array of two numbers is assigned then the first number is the negative exponent limit and the second number is the positive exponent limit.
*/
RANGE: number | number[];
/**
* The value that determines whether BigNumber Errors are thrown.
*
* If `ERRORS` is false, no errors will be thrown.
*/
ERRORS: boolean | 0 | 1;
/**
* The value that determines whether cryptographically-secure pseudo-random number generation is used.
*
* If `CRYPTO` is set to `true` then the `random` method will generate random digits using `crypto.getRandomValues` in browsers that support it,
* or `crypto.randomBytes` if using a version of Node.js that supports it.
*
* If neither function is supported by the host environment then attempting to set `CRYPTO` to `true` will fail, and if `ERRORS` is `true` an exception will be thrown.
*
* If `CRYPTO` is `false` then the source of randomness used will be `Math.random` (which is assumed to generate at least `30` bits of randomness).
*/
CRYPTO: boolean | 0 | 1;
/**
* The modulo mode used when calculating the modulus: `a mod n`.
*
* The quotient, `q = a / n`, is calculated according to the `ROUNDING_MODE` that corresponds to the chosen `MODULO_MODE`.
*
* The remainder, `r`, is calculated as: `r = a - n * q`.
*/
MODULO_MODE: ModuloMode;
/**
* The maximum number of significant digits of the result of the power operation (unless a modulus is specified).
*
* If set to `0`, the number of signifcant digits will not be limited.
*/
POW_PRECISION: number;
/**
* The `FORMAT` object configures the format of the string returned by the toFormat method.
*/
FORMAT: Partial<FormatConfig>
}
type NumberLike = number | string | BigNumber;
type RoundingMode = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8
type ModuloMode = RoundingMode | 9
interface BigNumberStatic {
/**
* Returns a new instance of a BigNumber object.
*/
(value: NumberLike, base?: number): BigNumber;
/**
* Returns a new instance of a BigNumber object.
*/
new (value: NumberLike, base?: number): BigNumber;
/**
* Returns a new independent BigNumber constructor with configuration as described by obj, or with the default configuration if obj is null or undefined.
*/
another(obj?: Partial<BigNumberConfig>): BigNumberStatic;
/**
* Configures the settings for this particular BigNumber constructor.
*
*/
config(obj?: Partial<BigNumberConfig>): BigNumberConfig;
/**
* Configures the settings for this particular BigNumber constructor.
*/
config(
DECIMAL_PLACES?: number,
ROUNDING_MODE?: RoundingMode,
EXPONENTIAL_AT?: number | number[],
RANGE?: number | number[],
ERRORS?: boolean | 0 | 1,
CRYPTO?: boolean | 0 | 1,
MODULO_MODE?: ModuloMode,
POW_PRECISION?: number
): BigNumberConfig;
/**
* Configures the settings for this particular BigNumber constructor.
*/
set(obj?: Partial<BigNumberConfig>): BigNumberConfig;
/**
* Configures the settings for this particular BigNumber constructor.
*/
set(
DECIMAL_PLACES?: number,
ROUNDING_MODE?: RoundingMode,
EXPONENTIAL_AT?: number | number[],
RANGE?: number | number[],
ERRORS?: boolean | 0 | 1,
CRYPTO?: boolean | 0 | 1,
MODULO_MODE?: ModuloMode,
POW_PRECISION?: number
): BigNumberConfig;
/**
* Returns a BigNumber whose value is the maximum of `args`.
*/
max(...args: NumberLike[]): BigNumber;
/**
* Returns a BigNumber whose value is the maximum of `args`.
*/
max(args: NumberLike[]): BigNumber;
/**
* Returns a BigNumber whose value is the minimum of `args`.
*/
min(...args: NumberLike[]): BigNumber;
/**
* Returns a BigNumber whose value is the minimum of `args`.
*/
min(args: NumberLike[]): BigNumber;
/**
* Returns a new BigNumber with a pseudo-random value equal to or greater than `0` and less than `1`.
*
* The return value will have `dp` decimal places (or less if trailing zeros are produced).
* If `dp` is omitted then the number of decimal places will default to the current `DECIMAL_PLACES` setting.
*
* Depending on the value of this BigNumber constructor's `CRYPTO` setting and the support for the `crypto` object in the host environment,
* the random digits of the return value are generated by either
* `Math.random` (fastest),
* `crypto.getRandomValues` (Web Cryptography API in recent browsers)
* or `crypto.randomBytes` (Node.js).
*
* If `CRYPTO` is `true`, i.e. one of the `crypto` methods is to be used,
* the value of a returned BigNumber should be cryptographically-secure and statistically indistinguishable from a random value.
*/
random(dp?: number): BigNumber;
/**
* Rounds away from zero
*/
ROUND_UP: 0;
/**
* Rounds towards zero
*/
ROUND_DOWN: 1;
/**
* Rounds towards `Infinity`
*/
ROUND_CEIL: 2;
/**
* Rounds towards `-Infinity`
*/
ROUND_FLOOR: 3;
/**
* Rounds towards nearest neighbour.
* If equidistant, rounds away from zero.
*/
ROUND_HALF_UP: 4;
/**
* Rounds towards nearest neighbour.
* If equidistant, rounds towards zero.
*/
ROUND_HALF_DOWN: 5;
/**
* Rounds towards nearest neighbour.
* If equidistant, rounds towards even neighbour.
*/
ROUND_HALF_EVEN: 6;
/**
* Rounds towards nearest neighbour.
* If equidistant, rounds towards `Infinity`.
*/
ROUND_HALF_CEIL: 7;
/**
* Rounds towards nearest neighbour.
* If equidistant, rounds towards `-Infinity`.
*/
ROUND_HALF_FLOOR: 8;
/**
* The remainder is always positive.
*
* Euclidian division: `q = sign(n) * floor(a / abs(n))`
*/
EUCLID: 9;
}
interface BigNumber {
/**
* Returns a BigNumber whose value is the absolute value, i.e. the magnitude, of the value of this BigNumber.
*/
absoluteValue(): BigNumber;
/**
* Returns a BigNumber whose value is the absolute value, i.e. the magnitude, of the value of this BigNumber.
*/
abs(): BigNumber;
/**
* Returns a BigNumber whose value is the value of this BigNumber rounded to a whole number in the direction of positive Infinity.
*/
ceil(): BigNumber;
/**
* Returns
*
* `1` if the value of this BigNumber is greater than the value of `n`
*
* `-1` if the value of this BigNumber is less than the value of `n`
*
* `0` if this BigNumber and `n` have the same value
*
* `null` if the value of either this BigNumber or `n` is `NaN`
*/
comparedTo(n: NumberLike, base?: number): 1 | -1 | 0 | null;
/**
* Returns
*
* `1` if the value of this BigNumber is greater than the value of `n`
*
* `-1` if the value of this BigNumber is less than the value of `n`
*
* `0` if this BigNumber and `n` have the same value
*
* `null` if the value of either this BigNumber or `n` is `NaN`
*/
cmp(n: NumberLike, base?: number): 1 | -1 | 0 | null;
/**
* Return the number of decimal places of the value of this BigNumber, or `null` if the value of this BigNumber is `±Infinity` or `NaN`.
*/
decimalPlaces(): number;
/**
* Return the number of decimal places of the value of this BigNumber, or `null` if the value of this BigNumber is `±Infinity` or `NaN`.
*/
dp(): number;
/**
* Returns a BigNumber whose value is the value of this BigNumber divided by `n`, rounded according to the current `DECIMAL_PLACES` and `ROUNDING_MODE` configuration.
*/
dividedBy(n: NumberLike, base?: number): BigNumber;
/**
* Returns a BigNumber whose value is the value of this BigNumber divided by `n`, rounded according to the current `DECIMAL_PLACES` and `ROUNDING_MODE` configuration.
*/
div(n: NumberLike, base?: number): BigNumber;
/**
* Return a BigNumber whose value is the integer part of dividing the value of this BigNumber by `n`.
*/
dividedToIntegerBy(n: NumberLike, base?: number): BigNumber;
/**
* Return a BigNumber whose value is the integer part of dividing the value of this BigNumber by `n`.
*/
divToInt(n: NumberLike, base?: number): BigNumber;
/**
* Returns `true` if the value of this BigNumber equals the value of `n`, otherwise returns `false`.
*
* As with JavaScript, `NaN` does not equal `NaN`.
*/
equals(n: NumberLike, base?: number): boolean;
/**
* Returns `true` if the value of this BigNumber equals the value of `n`, otherwise returns `false`.
*
* As with JavaScript, `NaN` does not equal `NaN`.
*/
eq(n: NumberLike, base?: number): boolean;
/**
* Returns a BigNumber whose value is the value of this BigNumber rounded to a whole number in the direction of negative `Infinity`.
*/
floor(): BigNumber;
/**
* Returns `true` if the value of this BigNumber is greater than the value of `n`, otherwise returns `false`.
*/
greaterThan(n: NumberLike, base?: number): boolean;
/**
* Returns `true` if the value of this BigNumber is greater than the value of `n`, otherwise returns `false`.
*/
gt(n: NumberLike, base?: number): boolean;
/**
* Returns `true` if the value of this BigNumber is greater than or equal to the value of `n`, otherwise returns `false`.
*/
greaterThanOrEqualTo(n: NumberLike, base?: number): boolean;
/**
* Returns `true` if the value of this BigNumber is greater than or equal to the value of `n`, otherwise returns `false`.
*/
gte(n: NumberLike, base?: number): boolean;
/**
* Returns `true` if the value of this BigNumber is a finite number, otherwise returns `false`.
*
* The only possible non-finite values of a BigNumber are `NaN`, `Infinity` and `-Infinity`.
*/
isFinite(): boolean;
/**
* Returns `true` if the value of this BigNumber is a whole number, otherwise returns `false`.
*/
isInteger(): boolean;
/**
* Returns `true` if the value of this BigNumber is a whole number, otherwise returns `false`.
*/
isInt(): boolean;
/**
* Returns `true` if the value of this BigNumber is NaN, otherwise returns `false`.
*/
isNaN(): boolean;
/**
* Returns `true` if the value of this BigNumber is negative, otherwise returns `false`.
*/
isNegative(): boolean;
/**
* Returns `true` if the value of this BigNumber is negative, otherwise returns `false`.
*/
isNeg(): boolean;
/**
* Returns `true` if the value of this BigNumber is zero or minus zero, otherwise returns `false`.
*/
isZero(): boolean;
/**
* Returns `true` if the value of this BigNumber is less than the value of `n`, otherwise returns `false`.
*/
lessThan(n: NumberLike, base?: number): boolean;
/**
* Returns `true` if the value of this BigNumber is less than the value of `n`, otherwise returns `false`.
*/
lt(n: NumberLike, base?: number): boolean;
/**
* Returns `true` if the value of this BigNumber is less than or equal to the value of `n`, otherwise returns
*/
lessThanOrEqualTo(n: NumberLike, base?: number): boolean;
/**
* Returns `true` if the value of this BigNumber is less than or equal to the value of `n`, otherwise returns
*/
lte(n: NumberLike, base?: number): boolean;
/**
* Returns a BigNumber whose value is the value of this BigNumber minus `n`.
*/
minus(n: NumberLike, base?: number): BigNumber;
/**
* Returns a BigNumber whose value is the value of this BigNumber minus `n`.
*/
sub(n: NumberLike, base?: number): BigNumber;
/**
* Returns a BigNumber whose value is the value of this BigNumber modulo `n`, i.e. the integer remainder of dividing this BigNumber by `n`.
*
* The value returned, and in particular its sign, is dependent on the value of the `MODULO_MODE` setting of this BigNumber constructor.
* If it is `1` (default value), the result will have the same sign as this BigNumber,
* and it will match that of Javascript's `%` operator (within the limits of double precision) and BigDecimal's `remainder` method.
*/
modulo(n: NumberLike, base?: number): BigNumber;
/**
* Returns a BigNumber whose value is the value of this BigNumber modulo `n`, i.e. the integer remainder of dividing this BigNumber by `n`.
*
* The value returned, and in particular its sign, is dependent on the value of the `MODULO_MODE` setting of this BigNumber constructor.
* If it is `1` (default value), the result will have the same sign as this BigNumber,
* and it will match that of Javascript's `%` operator (within the limits of double precision) and BigDecimal's `remainder` method.
*/
mod(n: NumberLike, base?: number): BigNumber;
/**
* Returns a BigNumber whose value is the value of this BigNumber negated, i.e. multiplied by `-1`.
*/
negated(): BigNumber;
/**
* Returns a BigNumber whose value is the value of this BigNumber negated, i.e. multiplied by `-1`.
*/
neg(): BigNumber;
/**
* Returns a BigNumber whose value is the value of this BigNumber plus `n`.
*/
plus(n: NumberLike, base?: number): BigNumber;
/**
* Returns a BigNumber whose value is the value of this BigNumber plus `n`.
*/
add(n: NumberLike, base?: number): BigNumber;
/**
* Returns the number of significant digits of the value of this BigNumber.
*
* If `z` is `true` or `1` then any trailing zeros of the integer part of a number are counted as significant digits, otherwise they are not.
*/
precision(z?: boolean | 0 | 1): number;
/**
* Returns the number of significant digits of the value of this BigNumber.
*
* If `z` is `true` or `1` then any trailing zeros of the integer part of a number are counted as significant digits, otherwise they are not.
*/
sd(z?: boolean | 0 | 1): number;
/**
* Returns a BigNumber whose value is the value of this BigNumber rounded by rounding mode `rm` to a maximum of `dp` decimal places.
*
* If `dp` is omitted, or is `null` or `undefined`, the return value is `n` rounded to a whole number.
*
* If `rm` is omitted, or is `null` or `undefined`, `ROUNDING_MODE` is used.
*/
round(dp?: number, rm?: RoundingMode): BigNumber;
/**
* Returns a BigNumber whose value is the value of this BigNumber shifted `n` places.
*
* The shift is of the decimal point, i.e. of powers of ten, and is to the left if `n` is negative or to the right if `n` is positive.
*/
shift(n: number): BigNumber;
/**
* Returns a BigNumber whose value is the square root of the value of this BigNumber, rounded according to the current `DECIMAL_PLACES` and `ROUNDING_MODE` configuration.
*
* The return value will be correctly rounded, i.e. rounded as if the result was first calculated to an infinite number of correct digits before rounding.
*/
squareRoot(): BigNumber;
/**
* Returns a BigNumber whose value is the square root of the value of this BigNumber, rounded according to the current `DECIMAL_PLACES` and `ROUNDING_MODE` configuration.
*
* The return value will be correctly rounded, i.e. rounded as if the result was first calculated to an infinite number of correct digits before rounding.
*/
sqrt(): BigNumber;
/**
* Returns a BigNumber whose value is the value of this BigNumber times `n`.
*/
times(n: NumberLike, base?: number): BigNumber;
/**
* Returns a BigNumber whose value is the value of this BigNumber times `n`.
*/
mul(n: NumberLike, base?: number): BigNumber;
/**
* Returns a BigNumber whose value is the value of this BigNumber rounded to `sd` significant digits using rounding mode `rm`.
*
* If `sd` is omitted or is `null` or `undefined`, the return value will not be rounded.
*
* If `rm` is omitted or is `null` or `undefined`, ROUNDING_MODE will be used.
*/
toDigits(sd?: number, rm?: RoundingMode): BigNumber;
/**
* Returns a string representing the value of this BigNumber in exponential notation rounded using rounding mode `rm` to `dp` decimal places,
* i.e with one digit before the decimal point and `dp` digits after it.
*
* If the value of this BigNumber in exponential notation has fewer than `dp` fraction digits, the return value will be appended with zeros accordingly.
*
* If `dp` is omitted, or is `null` or `undefined`, the number of digits after the decimal point defaults to the minimum number of digits necessary to represent the value exactly.
*
* If `rm` is omitted or is `null` or `undefined`, `ROUNDING_MODE` is used.
*/
toExponential(dp?: number, rm?: RoundingMode): string;
/**
* Returns a string representing the value of this BigNumber in normal (fixed-point) notation rounded to `dp` decimal places using rounding mode `rm`.
*
* If the value of this BigNumber in normal notation has fewer than `dp` fraction digits, the return value will be appended with zeros accordingly.
*
* Unlike `Number.prototype.toFixed`, which returns exponential notation if a number is greater or equal to `10e21`, this method will always return normal notation.
*
* If `dp` is omitted or is `null` or `undefined`, the return value will be unrounded and in normal notation.
* This is also unlike `Number.prototype.toFixed`, which returns the value to zero decimal places.
* It is useful when fixed-point notation is required and the current `EXPONENTIAL_AT` setting causes `toString` to return exponential notation.
*
* If `rm` is omitted or is `null` or `undefined`, `ROUNDING_MODE` is used.
*/
toFixed(dp?: number, rm?: RoundingMode): string;
/**
* Returns a string representing the value of this BigNumber in normal (fixed-point) notation rounded to `dp` decimal places using rounding mode `rm`,
* and formatted according to the properties of the `FORMAT` object.
*
* If `dp` is omitted or is `null` or `undefined`, then the return value is not rounded to a fixed number of decimal places.
*
* If `rm` is omitted or is `null` or `undefined`, `ROUNDING_MODE` is used.
*/
toFormat(dp?: number, rm?: RoundingMode): string;
/**
* Returns a string array representing the value of this BigNumber as a simple fraction with an integer numerator and an integer denominator.
* The denominator will be a positive non-zero value less than or equal to `max`.
*
* If a maximum denominator, `max`, is not specified, or is `null` or `undefined`, the denominator will be the lowest value necessary to represent the number exactly.
*/
toFraction(max?: NumberLike): [string, string];
/**
* As `valueOf`.
*/
toJSON(): string;
/**
* Returns the value of this BigNumber as a JavaScript number primitive.
*
* Type coercion with, for example, the unary plus operator will also work, except that a BigNumber with the value minus zero will be converted to positive zero.
*/
toNumber(): number;
/**
* Returns a BigNumber whose value is the value of this BigNumber raised to the power `n`, and optionally modulo a modulus `m`.
*
* If `n` is negative the result is rounded according to the current `DECIMAL_PLACES` and `ROUNDING_MODE` configuration.
*/
toPower(n: number, m?: NumberLike): BigNumber;
/**
* Returns a BigNumber whose value is the value of this BigNumber raised to the power `n`, and optionally modulo a modulus `m`.
*
* If `n` is negative the result is rounded according to the current `DECIMAL_PLACES` and `ROUNDING_MODE` configuration.
*/
pow(n: number, m?: NumberLike): BigNumber;
/**
* Returns a string representing the value of this BigNumber rounded to `sd` significant digits using rounding mode `rm`.
*
* If `sd` is less than the number of digits necessary to represent the integer part of the value in normal (fixed-point) notation, then exponential notation is used.
*
* If `sd` is omitted, or is `null` or `undefined`, then the return value is the same as `n.toString()`.
*
* If `rm` is omitted or is `null` or `undefined`, `ROUNDING_MODE` is used.
*/
toPrecision(sd?: number, rm?: RoundingMode): string;
/**
* Returns a string representing the value of this BigNumber in the specified base, or base `10` if `base` is omitted or is `null` or `undefined`.
*/
toString(base?: number): string;
/**
* Returns a BigNumber whose value is the value of this BigNumber truncated to a whole number.
*/
truncated(): BigNumber;
/**
* Returns a BigNumber whose value is the value of this BigNumber truncated to a whole number.
*/
trunc(): BigNumber;
/**
* As `toString`, but does not accept a base argument and includes the minus sign for negative zero.
*/
valueOf(): string;
/**
* coefficient
* @description Array of base 1e14 numbers
*/
c: number[] | null;
/**
* exponent
* @description Integer, -1000000000 to 1000000000 inclusive
*/
e: number | null;
/**
* sign
*/
s: -1 | 1 | null;
/**
* type identifier
*/
isBigNumber: true;
}
}
+22
View File
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"bignumber.js-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "../tslint.json" }
-7
View File
@@ -1,10 +1,3 @@
/// <reference path="Microsoft.Maps.AdvancedShapes.d.ts"/>
/// <reference path="Microsoft.Maps.Directions.d.ts"/>
/// <reference path="Microsoft.Maps.Search.d.ts"/>
/// <reference path="Microsoft.Maps.Themes.BingTheme.d.ts"/>
/// <reference path="Microsoft.Maps.Traffic.d.ts"/>
/// <reference path="Microsoft.Maps.VenueMaps.d.ts"/>
namespace BingMapsTests {
// An interactive set of Bing Maps AJAX control usages can be found at http://www.bingmapsportal.com/isdk/ajaxv7
-2
View File
@@ -1,5 +1,3 @@
/// <reference types="bit-array" />
import BitArray = require("bit-array");
const a = new BitArray(32);
+2
View File
@@ -16,6 +16,7 @@ declare namespace BittorrentProtocol {
}
export interface Extension {
//tslint:disable-next-line:no-misused-new - could use class instead of interface but class is not extendible
constructor(wire: Wire): this;
onHandshake?: () => void;
onExtendedHandshake?: () => void;
@@ -24,6 +25,7 @@ declare namespace BittorrentProtocol {
}
export interface Request {
//tslint:disable-next-line:no-misused-new - could use class instead of interface but class is not extendible
constructor(piece: number, offset: number, length: number, callback: () => void): this;
piece: number;
offset: number;
+1 -1
View File
@@ -19,4 +19,4 @@
"index.d.ts",
"bittorrent-protocol-tests.ts"
]
}
}
-3
View File
@@ -1,6 +1,3 @@
/// <reference types="node" />
var bl = require('blob-stream');
var blob = bl.toBlob();
-1
View File
@@ -1,4 +1,3 @@
/// <reference types="node" />
/// <reference types="bluebird" />
import tape = require('blue-tape');
+2 -1
View File
@@ -1,4 +1,4 @@
// Type definitions for bluebird 3.0
// Type definitions for bluebird 3.5
// Project: https://github.com/petkaantonov/bluebird
// Definitions by: d-ph <https://github.com/d-ph>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@@ -76,6 +76,7 @@ declare global {
spread: typeof Bluebird.prototype.spread;
suppressUnhandledRejections: typeof Bluebird.prototype.suppressUnhandledRejections;
tap: typeof Bluebird.prototype.tap;
tapCatch: typeof Bluebird.prototype.tapCatch;
// then: typeof Bluebird.prototype.then;
thenReturn: typeof Bluebird.prototype.thenReturn;
thenThrow: typeof Bluebird.prototype.thenThrow;
-2
View File
@@ -1,5 +1,3 @@
/// <reference types="bluebird" />
import Promise = require('bluebird');
import retry = require('bluebird-retry');
+3
View File
@@ -17,6 +17,9 @@ declare namespace retry {
timeout?: number;
max_tries?: number;
predicate?: any;
throw_original?: boolean;
context?: any;
args?: any;
}
}
+27 -7
View File
@@ -151,6 +151,10 @@ var BlueBird: typeof Promise;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
var version: string = Promise.version;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
var nodeCallbackFunc = (callback: (err: any, result: string) => void) => {}
var nodeCallbackFuncErrorOnly = (callback: (err: any) => void) => {}
@@ -336,14 +340,12 @@ fooOrBarProm = fooProm.caught(Promise.CancellationError, (reason: any) => {
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
{
class CustomError extends Error {
public customField: number;
}
fooProm = fooProm.catch(CustomError, reason => {
let a: number = reason.customField
})
class CustomError extends Error {
public customField: number;
}
fooProm = fooProm.catch(CustomError, reason => {
let a: number = reason.customField
})
{
class CustomErrorWithConstructor extends Error {
@@ -433,6 +435,24 @@ fooProm = fooProm.tap(() => {
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
fooProm = fooProm.tapCatch((err) => {
return "foo";
});
fooProm = fooProm.tapCatch(err => {
return Promise.resolve("foo");
});
fooProm.tapCatch(CustomError, (err: CustomError) => {
return err.customField;
});
fooProm.tapCatch((e: any) => e instanceof CustomError, (err: CustomError) => {
return err.customField;
});
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
fooProm = fooProm.delay(num);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+19 -6
View File
@@ -1,4 +1,4 @@
// Type definitions for bluebird 3.0.0
// Type definitions for bluebird 3.5.0
// Project: https://github.com/petkaantonov/bluebird
// Definitions by: Leonard Hecker <https://github.com/lhecker>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@@ -68,19 +68,19 @@ declare class Bluebird<R> implements Bluebird.Thenable<R>, Bluebird.Inspection<R
*/
catch(predicate: (error: any) => boolean, onReject: (error: any) => R | Bluebird.Thenable<R> | void | Bluebird.Thenable<void>): Bluebird<R>;
caught(predicate: (error: any) => boolean, onReject: (error: any) => R | Bluebird.Thenable<R> | void | Bluebird.Thenable<void>): Bluebird<R>;
catch<U>(predicate: (error: any) => boolean, onReject: (error: any) => U | Bluebird.Thenable<U>): Bluebird<U | R>;
caught<U>(predicate: (error: any) => boolean, onReject: (error: any) => U | Bluebird.Thenable<U>): Bluebird<U | R>;
catch<E extends Error>(ErrorClass: new (...args: any[]) => E, onReject: (error: E) => R | Bluebird.Thenable<R> | void | Bluebird.Thenable<void>): Bluebird<R>;
caught<E extends Error>(ErrorClass: new (...args: any[]) => E, onReject: (error: E) => R | Bluebird.Thenable<R> | void | Bluebird.Thenable<void>): Bluebird<R>;
catch<E extends Error, U>(ErrorClass: new (...args: any[]) => E, onReject: (error: E) => U | Bluebird.Thenable<U>): Bluebird<U | R>;
caught<E extends Error, U>(ErrorClass: new (...args: any[]) => E, onReject: (error: E) => U | Bluebird.Thenable<U>): Bluebird<U | R>;
catch(predicate: Object, onReject: (error: any) => R | Bluebird.Thenable<R> | void | Bluebird.Thenable<void>): Bluebird<R>;
caught(predicate: Object, onReject: (error: any) => R | Bluebird.Thenable<R> | void | Bluebird.Thenable<void>): Bluebird<R>;
catch<U>(predicate: Object, onReject: (error: any) => U | Bluebird.Thenable<U>): Bluebird<U | R>;
caught<U>(predicate: Object, onReject: (error: any) => U | Bluebird.Thenable<U>): Bluebird<U | R>;
@@ -114,6 +114,14 @@ declare class Bluebird<R> implements Bluebird.Thenable<R>, Bluebird.Inspection<R
tap<U>(onFulFill: (value: R) => Bluebird.Thenable<U>): Bluebird<R>;
tap<U>(onFulfill: (value: R) => U): Bluebird<R>;
/**
* Like `.catch()` but rethrows the error
*/
tapCatch<U>(onReject: (error?: any) => U | Bluebird.Thenable<U> | void | Bluebird.Thenable<void>): Bluebird<R>;
tapCatch<U, E extends Error>(ErrorClass: new (...args: any[]) => E, onReject: (error: E) => U | Bluebird.Thenable<U> | void | Bluebird.Thenable<void>): Bluebird<R>;
tapCatch<U>(predicate: (error?: any) => boolean, onReject: (error?: any) => U | Bluebird.Thenable<U> | void | Bluebird.Thenable<void>): Bluebird<R>;
/**
* Same as calling `Promise.delay(ms, this)`.
*/
@@ -321,7 +329,7 @@ declare class Bluebird<R> implements Bluebird.Thenable<R>, Bluebird.Inspection<R
/**
* Basically sugar for doing: somePromise.catch(function(){});
*
*
* Which is needed in case error handlers are attached asynchronously to the promise later, which would otherwise result in premature unhandled rejection reporting.
*/
suppressUnhandledRejections(): void;
@@ -631,6 +639,11 @@ declare class Bluebird<R> implements Bluebird.Thenable<R>, Bluebird.Inspection<R
/** Enable monitoring */
monitoring?: boolean;
}): void;
/**
* The version number of the library
*/
static version: string;
}
declare namespace Bluebird {
+22
View File
@@ -0,0 +1,22 @@
import * as express from 'express';
import {
json,
raw,
text,
urlencoded,
} from 'body-parser';
const app = express();
app.use(json());
app.use(raw());
app.use(text());
app.use(urlencoded());
// send any data, it should be parsed and printed
app.all('/', (req, res, next) => {
console.log(req.body);
res.json(req.body);
});
app.listen(8080);
+25 -179
View File
@@ -1,202 +1,48 @@
// Type definitions for body-parser
// Project: http://expressjs.com
// Definitions by: Santi Albo <https://github.com/santialbo/>, VILIC VANE <https://vilic.info>, Jonathan Häberle <https://github.com/dreampulse/>, Gevik Babakhani <https://github.com/blendsdk/>
// Type definitions for body-parser 1.16
// Project: https://github.com/expressjs/body-parser
// Definitions by: Santi Albo <https://github.com/santialbo>, Vilic Vane <https://github.com/vilic>, Jonathan Häberle <https://github.com/dreampulse>, Gevik Babakhani <https://github.com/blendsdk/>, Tomasz Łaziuk <https://github.com/tlaziuk>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
import { Request, RequestHandler, Response } from 'express';
// for docs go to https://github.com/expressjs/body-parser/tree/1.16.0#body-parser
import * as express from "express";
/**
* bodyParser: use individual json/urlencoded middlewares
* @deprecated
*/
declare function bodyParser(options?: {
/**
* if deflated bodies will be inflated. (default: true)
*/
inflate?: boolean;
/**
* maximum request body size. (default: '100kb')
*/
limit?: any;
/**
* function to verify body content, the parsing can be aborted by throwing an error.
*/
verify?: (req: express.Request, res: express.Response, buf: Buffer, encoding: string) => void;
/**
* only parse objects and arrays. (default: true)
*/
strict?: boolean;
/**
* passed to JSON.parse().
*/
reviver?: (key: string, value: any) => any;
/**
* parse extended syntax with the qs module. (default: true)
*/
extended?: boolean;
}): express.RequestHandler;
// @deprecated
declare function bodyParser(options?: bodyParser.OptionsJson & bodyParser.OptionsText & bodyParser.OptionsUrlencoded): RequestHandler;
declare namespace bodyParser {
/**
* Interface for defining the options for the json() middleware
*
* @export
* @interface JsonOptions
*/
export interface JsonOptions {
/**
* if deflated bodies will be inflated. (default: true)
*/
export interface Options {
inflate?: boolean;
/**
* maximum request body size. (default: '100kb')
*/
limit?: any;
/**
* request content-type to parse, passed directly to the type-is library. (default: 'json')
*/
type?: any;
/**
* function to verify body content, the parsing can be aborted by throwing an error.
*/
verify?: (req: express.Request, res: express.Response, buf: Buffer, encoding: string) => void;
/**
* only parse objects and arrays. (default: true)
*/
limit?: number | string;
type?: string | ((req: Request) => any);
verify?: (req: Request, res: Response, buf: Buffer, encoding: string) => void;
}
export interface OptionsJson extends Options {
reviever?: (key: string, value: any) => any;
strict?: boolean;
/**
* passed to JSON.parse().
*/
reviver?: (key: string, value: any) => any;
}
/**
* Interface for defining the options the raw() middleware
*
* @export
* @interface RawOptions
*/
export interface RawOptions {
/**
* if deflated bodies will be inflated. (default: true)
*/
inflate?: boolean;
/**
* maximum request body size. (default: '100kb')
*/
limit?: any;
/**
* request content-type to parse, passed directly to the type-is library. (default: 'application/octet-stream')
*/
type?: any;
/**
* function to verify body content, the parsing can be aborted by throwing an error.
*/
verify?: (req: express.Request, res: express.Response, buf: Buffer, encoding: string) => void;
}
/**
* Interface for defining the options for the text() middleware
*
* @export
* @interface TextOptions
*/
export interface TextOptions {
/**
* if deflated bodies will be inflated. (default: true)
*/
inflate?: boolean;
/**
* maximum request body size. (default: '100kb')
*/
limit?: any;
/**
* request content-type to parse, passed directly to the type-is library. (default: 'text/plain')
*/
type?: any;
/**
* function to verify body content, the parsing can be aborted by throwing an error.
*/
verify?: (req: express.Request, res: express.Response, buf: Buffer, encoding: string) => void;
/**
* the default charset to parse as, if not specified in content-type. (default: 'utf-8')
*/
export interface OptionsText extends Options {
defaultCharset?: string;
}
/**
* Interface for defining the options for the urlencoded() middleware
*
* @export
* @interface UrlEncodedOptions
*/
export interface UrlEncodedOptions {
/**
* if deflated bodies will be inflated. (default: true)
*/
inflate?: boolean;
/**
* maximum request body size. (default: '100kb')
*/
limit?: any;
/**
* request content-type to parse, passed directly to the type-is library. (default: 'urlencoded')
*/
type?: any;
/**
* function to verify body content, the parsing can be aborted by throwing an error.
*/
verify?: (req: express.Request, res: express.Response, buf: Buffer, encoding: string) => void;
/**
* parse extended syntax with the qs module.
*/
extended: boolean;
export interface OptionsUrlencoded extends Options {
extended?: boolean;
parameterLimit?: number;
}
/**
* Returns middleware that only parses json. This parser accepts any Unicode encoding
* of the body and supports automatic inflation of gzip and deflate encodings.
*
* @export
* @param {JsonOptions} [options]
* @returns {express.RequestHandler}
*/
export function json(options?: JsonOptions): express.RequestHandler;
export function json(options?: OptionsJson): RequestHandler;
/**
* Returns middleware that parses all bodies as a Buffer. This parser supports automatic
* inflation of gzip and deflate encodings.
*
* @export
* @param {RawOptions} [options]
* @returns {express.RequestHandler}
*/
export function raw(options?: RawOptions): express.RequestHandler;
export function raw(options?: Options): RequestHandler;
/**
* Returns middleware that parses all bodies as a string. This parser supports
* automatic inflation of gzip and deflate encodings.
*
* @export
* @param {TextOptions} [options]
* @returns {express.RequestHandler}
*/
export function text(options?: TextOptions): express.RequestHandler;
export function text(options?: OptionsText): RequestHandler;
export function urlencoded(options?: OptionsUrlencoded): RequestHandler;
/**
* Returns middleware that only parses urlencoded bodies. This parser accepts only
* UTF-8 encoding of the body and supports automatic inflation of gzip and deflate encodings.
*
* @export
* @param {UrlEncodedOptions} [options]
* @returns {express.RequestHandler}
*/
export function urlencoded(options?: UrlEncodedOptions): express.RequestHandler;
}
export = bodyParser;
+5 -3
View File
@@ -2,7 +2,8 @@
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
@@ -16,6 +17,7 @@
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts"
"index.d.ts",
"body-parser-tests.ts"
]
}
}
+6
View File
@@ -0,0 +1,6 @@
{
"extends": "../tslint.json",
"rules": {
"max-line-length": false
}
}
+47
View File
@@ -1330,3 +1330,50 @@ new User({name: 'John'}).fetchAll({require: true})
/* events.trigger(), see http://bookshelfjs.org/#Events-instance-trigger */
/* events.triggerThen(), see http://bookshelfjs.org/#Events-instance-triggerThen */
/* model - foreignKey and foreignKeyTarget, see http://bookshelfjs.org/#Model-instance-hasOne */
{
class Capital extends bookshelf.Model<Capital> {
get tableName() { return 'capitals'; }
}
class City extends bookshelf.Model<City> {
get tableName() { return 'cities'; }
country(): Country {
return this.belongsTo(Country, 'key1', 'key2');
}
}
class Language extends bookshelf.Model<Language> {
get tableName() { return 'languages'; }
countries(): Bookshelf.Collection<Country> {
return this.belongsToMany(Country, 'languages_countries', 'lang_id', 'country_id');
}
}
class Country extends bookshelf.Model<Country> {
get tableName() { return 'countries'; }
capital(): Capital {
return this.hasOne(Capital, 'id', 'capital_id');
}
cities(): Bookshelf.Collection<City> {
return this.hasMany(City, 'key2', 'key1');
}
}
// select * from `health_records` where `patient_id` = 1;
const capital = <Capital> new Country({id: 1}).related('capital');
capital.fetch().then(model => {
// ...
});
// alternatively, if you don't need the relation loaded on the patient's relations hash:
new Country({id: 1}).capital().fetch().then(model => {
// ...
});
}
+3 -3
View File
@@ -92,14 +92,14 @@ declare namespace Bookshelf {
static where<T>(properties: { [key: string]: any }): T;
static where<T>(key: string, operatorOrValue: string | number | boolean, valueIfOperator?: string | number | boolean): T;
belongsTo<R extends Model<any>>(target: { new (...args: any[]): R }, foreignKey?: string): R;
belongsTo<R extends Model<any>>(target: { new (...args: any[]): R }, foreignKey?: string, foreignKeyTarget?: string): R;
belongsToMany<R extends Model<any>>(target: { new (...args: any[]): R }, table?: string, foreignKey?: string, otherKey?: string): Collection<R>;
count(column?: string, options?: SyncOptions): BlueBird<number>;
destroy(options?: DestroyOptions): BlueBird<T>;
fetch(options?: FetchOptions): BlueBird<T>;
fetchAll(options?: FetchAllOptions): BlueBird<Collection<T>>;
hasMany<R extends Model<any>>(target: { new (...args: any[]): R }, foreignKey?: string): Collection<R>;
hasOne<R extends Model<any>>(target: { new (...args: any[]): R }, foreignKey?: string): R;
hasMany<R extends Model<any>>(target: { new (...args: any[]): R }, foreignKey?: string, foreignKeyTarget?: string): Collection<R>;
hasOne<R extends Model<any>>(target: { new (...args: any[]): R }, foreignKey?: string, foreignKeyTarget?: string): R;
load(relations: string | string[], options?: LoadOptions): BlueBird<T>;
morphMany<R extends Model<any>>(target: { new (...args: any[]): R }, name?: string, columnNames?: string[], morphValue?: string): Collection<R>;
morphOne<R extends Model<any>>(target: { new (...args: any[]): R }, name?: string, columnNames?: string[], morphValue?: string): R;
+1 -1
View File
@@ -6,7 +6,7 @@ bootbox.alert("Are we ok with callback?", function () {
console.log("Callback called!");
});
bootbox.alert({
size: "medium",
size: "small",
message: "Are we ok with callback and custom button?",
callback: function () {
console.log("Callback called!");
+3 -2
View File
@@ -15,7 +15,8 @@ interface BootboxBaseOptions {
closeButton?: boolean;
animate?: boolean;
className?: string;
size?: string;
/** All other values result in medium */
size?: "small" | "large";
buttons?: BootboxButtonMap; // complex object where each key is of type BootboxButton
}
@@ -40,7 +41,7 @@ interface BootboxConfirmOptions extends BootboxDialogOptions {
interface BootboxPromptOptions extends BootboxBaseOptions {
title: string;
value?: string;
inputType?: string;
inputType?: "text" | "textarea" | "email" | "select" | "checkbox" | "date" | "time" | "number" | "password";
callback: (result: string) => any;
buttons?: BootboxConfirmPromptButtonMap;
}
-2
View File
@@ -1,5 +1,3 @@
/// <reference types="jquery"/>
var pagerSelector = ".bootpager";
var $pager = $(pagerSelector);
-1
View File
@@ -1,4 +1,3 @@
/// <reference path="index.d.ts"/>
function tests_simple() {
$('#datepicker').datepicker();
$('#datepicker').datepicker({
@@ -1,5 +1,3 @@
/// <reference types="jquery"/>
// Examples from the projects github page
$('input[maxlength]').maxlength();
@@ -1,6 +1,3 @@
/// <reference types="jquery" />
//Test for bootstrap-notify v3.1.3
//Copied example directly from Bootstrap-notify site
@@ -1,5 +1,3 @@
/// <reference types="jquery"/>
$(".selectpicker").selectpicker({
actionsBox: true,
container: "body",
@@ -1,6 +1,3 @@
/// <reference types="jquery" />
$(function() {
// examples from http://seiyria.github.io/bootstrap-slider/
+2 -5
View File
@@ -1,9 +1,6 @@
/// <reference types="jquery"/>
function test_cases() {
$('#switch').bootstrapSwitch();
$('#switch').bootstrapSwitch({
state: false
});
@@ -15,7 +12,7 @@ function test_cases() {
//var mySwitch = $('#switch').get(0);
//mySwitch.toggleAnimate();
$('#switch').bootstrapSwitch('state', true, true);
$('#switch').bootstrapSwitch('state') === true;
@@ -1,6 +1,3 @@
/// <reference types="jquery" />
$(function () {
// Example 1 from http://www.virtuosoft.eu/code/bootstrap-touchspin/
$("input[name='demo1']").TouchSpin({
@@ -26,7 +23,7 @@ $(function () {
$("input[name='demo_vertical']").TouchSpin({
verticalbuttons: true
});
// Example 4 from http://www.virtuosoft.eu/code/bootstrap-touchspin/
$("input[name='demo_vertical2']").TouchSpin({
verticalbuttons: true,
@@ -1,5 +1,3 @@
/// <reference types="jquery" />
$('#myForm').validator();
$('#myForm').validator('update');
$('#myForm').validator('validate');
@@ -1,26 +1,175 @@
/// <reference types="jquery"/>
import * as moment from "moment";
import * as moment from 'moment';
const dp = $("#picker").datetimepicker().data("DateTimePicker");
function test_cases() {
$('#datetimepicker').datetimepicker();
$('#datetimepicker').datetimepicker({
minDate: '2012-12-31'
$("#datetimepicker").datetimepicker();
$("#datetimepicker").datetimepicker({
minDate: "2012-12-31"
});
$('#datetimepicker').data("DateTimePicker").maxDate('2012-12-31');
$("#datetimepicker").data("DateTimePicker").maxDate("2012-12-31");
var startDate = moment(new Date(2012, 1, 20));
var endDate = moment(new Date(2012, 1, 25));
$('#datetimepicker2')
let startDate = moment(new Date(2012, 1, 20));
const endDate = moment(new Date(2012, 1, 25));
$("#datetimepicker2")
.datetimepicker()
.on("dp.change", function (ev) {
.on("dp.change", ev => {
if (ev.date.valueOf() > endDate.valueOf()) {
$('#alert').show().find('strong').text('The start date must be before the end date.');
$("#alert").show().find("strong").text("The start date must be before the end date.");
} else {
$('#alert').hide();
$("#alert").hide();
startDate = ev.date;
$('#date-start-display').text($('#date-start').data('date'));
$("#date-start-display").text($("#date-start").data("date"));
}
})
.on("dp.error", ev => {
console.log(`Error: ${ev.date.format("YYYY-MM-DD")}`);
})
.on("dp.update", ev => {
console.log(`Change: ${ev.change}, ${ev.viewDate.format("YYYY-MM-DD")}`);
});
}
}
function test_date() {
let momentObj = moment("20111031", "YYYYMMDD");
dp.date(null);
dp.date("1969-07-21");
dp.date(new Date());
dp.date(momentObj);
momentObj = dp.date();
}
function test_format() {
let boolFormat = false;
let strFormat = "YYYY-MM-DD";
let momentFormat = moment.ISO_8601;
$("#picker").datetimepicker({
format: boolFormat
});
$("#picker").datetimepicker({
format: strFormat
});
$("#picker").datetimepicker({
format: momentFormat
});
dp.format(boolFormat);
boolFormat = dp.format() as boolean;
dp.format(strFormat);
strFormat = dp.format() as string;
dp.format(momentFormat);
momentFormat = dp.format() as moment.MomentBuiltinFormat;
}
function test_extraFormats() {
let boolFormat = false;
let strFormats = ["YYYYMMDD", "YYYY/MM/DD"];
let mixFormats = ["YYYYMMDD", moment.ISO_8601];
$("#picker").datetimepicker({
extraFormats: boolFormat
});
$("#picker").datetimepicker({
extraFormats: strFormats
});
$("#picker").datetimepicker({
extraFormats: mixFormats
});
dp.extraFormats(boolFormat);
boolFormat = dp.extraFormats() as boolean;
dp.extraFormats(strFormats);
strFormats = dp.extraFormats() as string[];
dp.extraFormats(mixFormats);
mixFormats = dp.extraFormats() as Array<(string | moment.MomentBuiltinFormat)>;
}
function test_timeZone() {
let nullTz = null;
let strFormats = "Africa/Abidjan";
$("#picker").datetimepicker({
timeZone: nullTz
});
$("#picker").datetimepicker({
timeZone: strFormats
});
dp.timeZone(nullTz);
nullTz = dp.timeZone() as null;
dp.timeZone(strFormats);
strFormats = dp.timeZone() as string;
}
function test_widgetParent() {
let nullW: null = null;
let str: string = "myId";
let jquery = $("#element");
$("#picker").datetimepicker({
widgetParent: nullW
});
$("#picker").datetimepicker({
widgetParent: str
});
$("#picker").datetimepicker({
widgetParent: jquery
});
dp.widgetParent(nullW);
nullW = dp.widgetParent() as null;
dp.widgetParent(str);
str = dp.widgetParent() as string;
dp.widgetParent(jquery);
jquery = dp.widgetParent() as JQuery;
}
function inputParser(inputDate: string | Date | moment.Moment) {
const relativeDatePattern = /[0-9]+\s+(days ago)/;
if (moment.isMoment(inputDate) || inputDate instanceof Date) {
return moment(inputDate);
} else {
const relativeDate = inputDate.match(relativeDatePattern);
if (relativeDate !== null) {
const subDays = +relativeDate[0].replace("days ago", "").trim();
return moment().subtract(subDays, "day");
} else {
return moment();
}
}
};
function test_parseInputDate() {
let undef: undefined;
let parser: BootstrapV3DatetimePicker.InputParser;
$("#picker").datetimepicker();
$("#picker").datetimepicker({
parseInputDate: inputParser
});
undef = dp.parseInputDate() as undefined;
parser = dp.parseInputDate() as BootstrapV3DatetimePicker.InputParser;
}
+47 -43
View File
@@ -1,21 +1,23 @@
// Type definitions for Bootstrap 3 Datepicker v4.17.37
// Type definitions for Bootstrap 3 Datepicker 4.17
// Project: http://eonasdan.github.io/bootstrap-datetimepicker
// Definitions by: Katona Péter <https://github.com/katonap>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// based on the previous version created by Jesica N. Fera <https://github.com/bayitajesi>
/**
* bootstrap-datetimepicker.js 4.17.37 Copyright (c) 2015 Jonathan Peterson
* bootstrap-datetimepicker.js 4.17.45 Copyright (c) 2015 Jonathan Peterson
* Available via the MIT license.
* see: http://eonasdan.github.io/bootstrap-datetimepicker or https://github.com/Eonasdan/bootstrap-datetimepicker for details.
*/
/// <reference types="jquery"/>
import * as moment from 'moment';
import * as moment from "moment";
export as namespace BootstrapV3DatetimePicker;
type InputParser = (input: string | Date | moment.Moment) => moment.Moment;
export interface Datetimepicker {
/**Clears the datepicker by setting the value to null */
clear(): void;
@@ -30,7 +32,7 @@ export interface Datetimepicker {
* Emits:
* - dp.change - In case newDate is different from current moment
*/
date(date: moment.Moment | Date | string): void;
date(date: moment.Moment | Date | string | null): void;
/**Destroys the widget and removes all attached event listeners */
destroy(): void;
/**Disables the input element, the component is attached to, by adding a disabled="true" attribute to it. If the widget was visible before that call it is hidden.
@@ -149,21 +151,23 @@ export interface Datetimepicker {
* Like en/disabledDates, the en/disabledHours options are mutually exclusive and will reset one of the options back to false. */
enabledHours(value: boolean | Array<number>): void;
/**Returns a boolean or array with the options.extraFormats option configuration */
extraFormats(): boolean | Array<string>;
extraFormats(): boolean | Array<string | moment.MomentBuiltinFormat>;
/**Takes an array of valid input moment format options, or boolean:false */
extraFormats(formats: boolean | Array<string>): void;
extraFormats(formats: boolean | Array<string | moment.MomentBuiltinFormat>): void;
/**Returns the options.focusOnShow option. */
focusOnShow(): boolean;
/**If false, the textbox will not be given focus when the picker is shown */
focusOnShow(value: boolean): void;
/**Returns the component's options.format string */
format(): boolean | string;
format(): boolean | string | moment.MomentBuiltinFormat;
/**Takes a moment.js format string and sets the components options.format.
* This is used for displaying and also for parsing input strings either from the input element the component is attached to or the date() function.
* The parameter can also be a boolean:false in which case the format is set to the locale's L LT.
* Note: this is also used to determine if the TimePicker sub component will display the hours in 12 or 24 format. (if "a" or "h" exists in the passed string then a 12 hour mode is set)
* Throws:
* - TypeError - if format is boolean:true
*/
format(format: boolean | string): void;
format(format: boolean | string | moment.MomentBuiltinFormat): void;
/**Returns options.icons */
icons(): Icons;
/**Takes an Object of strings.
@@ -224,11 +228,11 @@ export interface Datetimepicker {
*/
minDate(date: moment.Moment | Date | string | boolean): void;
/**Returns the options.parseInputDate option */
parseInputDate(): Function;
parseInputDate(): InputParser | undefined;
/**Allows custom input formatting For example: the user can enter "yesterday"" or "30 days ago".
* {@link http://eonasdan.github.io/bootstrap-datetimepicker/Functions/#parseinputdate}
*/
parseInputDate(value: (input: string) => moment.Moment): void;
parseInputDate(value: InputParser): void;
/**Returns the options.showClear option. */
showClear(): boolean;
/**Set if the clear date button will appear on the widget */
@@ -249,12 +253,19 @@ export interface Datetimepicker {
stepping(): number;
/**This will be the amount the up/down arrows move the minute value with a time picker. */
stepping(step: number): void;
/** Returns a string of options.timeZone */
timeZone(): string | null;
/** Takes a null or a string of a valid timezone.
* Throws:
* - TypeError - if tooltips parameter is not a string or null
*/
timeZone(timeZone: string | null): void;
/**Returns the options.toolbarplacement option. */
toolbarPlacement(): string;
/**Changes the placement of the toolbar where the today, clear, component switch icon are located.
* See valid values at DatetimepickerOptions.toolbarplacement
* Throws:
* - TypeError if the parameter is not a valid value
* - TypeError - if the parameter is not a valid value
*/
toolbarPlacement(value: string): void;
/**Returns the options.tooltips option */
@@ -267,10 +278,12 @@ export interface Datetimepicker {
/**Returns the options.useCurrent option configuration */
useCurrent(): boolean | string;
/**Takes a boolean or string.
* If a boolean true is passed and the components model moment is not set (either through setDate or through a valid value on the input element the component is attached to) then the first time the user opens the datetimepicker widget the value is initialized to the current moment of the action.
* If a boolean true is passed and the components model moment is not set (either through setDate or through a valid value on the input element the component is attached to)
* then the first time the user opens the datetimepicker widget the value is initialized to the current moment of the action.
* If a false boolean is passed then no initialization happens on the input element.
* You can select the granularity on the initialized moment by passing one of the following strings ("year", "month", "day", "hour", "minute") in the variable.
* If for example you pass "day" to the useCurrent function and the input field is empty the first time the user opens the datetimepicker widget the input text will be initialized to the current datetime with day granularity (ie if currentTime = 2014-08-10 13:32:33 the input value will be initialized to 2014-08-10 00:00:00)
* If for example you pass "day" to the useCurrent function and the input field is empty the first time the user opens the datetimepicker widget the input text will be
* initialized to the current datetime with day granularity (ie if currentTime = 2014-08-10 13:32:33 the input value will be initialized to 2014-08-10 00:00:00)
* Note: If the options.defaultDate is set or the input element the component is attached to has already a value that takes precedence and the functionality of useCurrent is not triggered!
*/
useCurrent(value: boolean | string): void;
@@ -289,6 +302,10 @@ export interface Datetimepicker {
* - TypeError - if the parameter is not a string or not a valid value
*/
viewMode(value: string): void;
/**Returns a $(element) variable with the currently set options.widgetParent option. */
widgetParent(): string | JQuery | null
/**Takes a string or $(element) value. */
widgetParent(widgetParent: string | JQuery | null): void;
/**Returns the options.widgetPositioning object */
widgetPositioning(): WidgetPositioningOptions;
/**WidgetPositioning defines where the dropdown with the widget will appear relative to the input element the component is attached to.
@@ -364,7 +381,7 @@ export interface DatetimepickerOptions {
/**Allows for several input formats to be valid. See: https://github.com/Eonasdan/bootstrap-datetimepicker/pull/666
* @default: false
*/
extraFormats?: boolean | Array<string>;
extraFormats?: boolean | Array<string | moment.MomentBuiltinFormat>;
/**If false, the textbox will not be given focus when the picker is shown
* @default: true
*/
@@ -372,7 +389,7 @@ export interface DatetimepickerOptions {
/**See momentjs' docs for valid formats. Format also dictates what components are shown, e.g. MM/dd/YYYY will not display the time picker.
* @default: false
*/
format?: boolean | string;
format?: boolean | string | moment.MomentBuiltinFormat;
/**Change the default icons for the pickers functions. */
icons?: Icons;
/**Allow date picker show event to fire even when the associated input element has the readonly="readonly"property.
@@ -416,7 +433,7 @@ export interface DatetimepickerOptions {
/**Allows custom input formatting For example: the user can enter "yesterday"" or "30 days ago".
* {@link http://eonasdan.github.io/bootstrap-datetimepicker/Functions/#parseinputdate}
*/
parseInputDate?: (input: string) => moment.Moment;
parseInputDate?: InputParser;
/**Show the "Clear" button in the icon toolbar.
* Clicking the "Clear" button will set the calendar to null.
* @default: false
@@ -440,6 +457,11 @@ export interface DatetimepickerOptions {
* @default: 1
*/
stepping?: number;
/**
* Timezone to use, if moment-timezone is loaded. If null or empty string, ignore timezones.
* @default: ""
*/
timeZone?: string | null;
/**Changes the placement of the icon toolbar.
* @default: "default"
*/
@@ -466,7 +488,7 @@ export interface DatetimepickerOptions {
/**On picker show, places the widget at the identifier (string) or jQuery object if the element has css position: "relative"
* @default: null
*/
widgetParent?: string | JQuery;
widgetParent?: string | JQuery | null;
widgetPositioning?: WidgetPositioningOptions;
}
@@ -540,12 +562,12 @@ export interface UpdateEvent extends JQueryEventObject {
viewDate: moment.Moment;
}
type EventName = "dp.show" | "dp.hide" | "dp.error";
declare global {
interface JQuery {
datetimepicker(): JQuery;
datetimepicker(options: DatetimepickerOptions): JQuery;
datetimepicker(options?: DatetimepickerOptions): JQuery;
data(key: "DateTimePicker"): Datetimepicker;
@@ -556,36 +578,18 @@ declare global {
off(events: "dp.change", handler: (eventobject: ChangeEvent) => any): JQuery;
off(events: "dp.change", selector?: string, handler?: (eventobject: ChangeEvent) => any): JQuery;
on(events: EventName , handler: (eventObject: Event) => any): JQuery;
on(events: EventName, selector: string, handler: (eventobject: Event) => any): JQuery;
on(events: EventName, selector: string, data: any, handler?: (eventobject: Event) => any): JQuery;
on(events: "dp.show", handler: (eventObject: Event) => any): JQuery;
on(events: "dp.show", selector: string, handler: (eventobject: Event) => any): JQuery;
on(events: "dp.show", selector: string, data: any, handler?: (eventobject: Event) => any): JQuery;
off(events: "dp.show", handler: (eventobject: Event) => any): JQuery;
off(events: "dp.show", selector?: string, handler?: (eventobject: Event) => any): JQuery;
on(events: "dp.hide", handler: (eventObject: Event) => any): JQuery;
on(events: "dp.hide", selector: string, handler: (eventobject: Event) => any): JQuery;
on(events: "dp.hide", selector: string, data: any, handler?: (eventobject: Event) => any): JQuery;
off(events: "dp.hide", handler: (eventobject: Event) => any): JQuery;
off(events: "dp.hide", selector?: string, handler?: (eventobject: Event) => any): JQuery;
on(events: "dp.error", handler: (eventObject: Event) => any): JQuery;
on(events: "dp.error", selector: string, handler: (eventobject: Event) => any): JQuery;
on(events: "dp.error", selector: string, data: any, handler?: (eventobject: Event) => any): JQuery;
off(events: "dp.error", handler: (eventobject: Event) => any): JQuery;
off(events: "dp.error", selector?: string, handler?: (eventobject: Event) => any): JQuery;
off(events: EventName, handler: (eventobject: Event) => any): JQuery;
off(events: EventName, selector?: string, handler?: (eventobject: Event) => any): JQuery;
on(events: "dp.update", handler: (eventObject: UpdateEvent) => any): JQuery;
on(events: "dp.update", selector: string, handler: (eventobject: UpdateEvent) => any): JQuery;
on(events: "dp.update", selector: string, data: any, handler?: (eventobject: UpdateEvent) => any): JQuery;
off(events: "dp.update", handler: (eventobject: Event) => any): JQuery;
off(events: "dp.update", handler: (eventobject: UpdateEvent) => any): JQuery;
off(events: "dp.update", selector?: string, handler?: (eventobject: UpdateEvent) => any): JQuery;
}
}
+1 -1
View File
@@ -11,7 +11,7 @@
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
+6
View File
@@ -0,0 +1,6 @@
{
"extends": "../tslint.json",
"rules": {
"quotemark": [true, "double", "avoid-escape"]
}
}

Some files were not shown because too many files have changed in this diff Show More