├── .gitignore ├── .npmignore ├── README.md ├── index.js ├── index.ts ├── odoorpc.service.js ├── odoorpc.service.ts ├── package.json ├── tsconfig.json ├── typings.json └── typings ├── browser.d.ts ├── globals ├── es6-shim │ ├── index.d.ts │ └── typings.json ├── jasmine │ ├── index.d.ts │ └── typings.json └── zone.js │ ├── index.d.ts │ └── typings.json └── index.d.ts /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | npm-debug.log 3 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | npm-debug.log 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # angular2-odoorpc 2 | OdooRPC for angular2 3 | 4 | Migrate from [https://github.com/akretion/angular-odoo/blob/master/src/components/odoo/jsonRpc-service.js](https://github.com/akretion/angular-odoo/blob/master/src/components/odoo/jsonRpc-service.js) 5 | + Support Basic Authentication 6 | 7 | ## Installation 8 | 9 | `npm install --save angular2-odoo-jsonrpc` 10 | 11 | ## Functions list 12 | 13 | - `login(db, user, pass)` 14 | - `logout(force)` 15 | - `getDbList() // doesn't work with odoo >= 9.0` 16 | - `searchRead(model, domain, fields)` 17 | - `call(model, method, args, kwargs)` 18 | 19 | 20 | ## How to use 21 | 22 | Import `OdooRPCService` into component 23 | 24 | ```typescript 25 | import { Component } from '@angular/core'; 26 | import { OdooRPCService } from 'angular2-odoo-jsonrpc'; 27 | ``` 28 | 29 | Add provider in app component 30 | 31 | ```typescript 32 | @Component({ 33 | ... 34 | providers: [OdooRPCService] 35 | }) 36 | ``` 37 | 38 | Initialize configuration in `constructor` of component 39 | 40 | ```typescript 41 | 42 | export class OdooClientExampleComponent { 43 | 44 | constructor(odooRPC: OdooRPCService){ 45 | this.odooRPC.init({ 46 | odoo_server: "https://odoo-server-example", 47 | http_auth: "username:password" // optional 48 | }); 49 | this.odooRPC.login('db_example', 'username', 'password').then(res => { 50 | console.log('login success'); 51 | }).catch( err => { 52 | console.error('login failed', err); 53 | }) 54 | } 55 | 56 | ... 57 | 58 | } 59 | 60 | ``` 61 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | function __export(m) { 3 | for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; 4 | } 5 | __export(require("./odoorpc.service")); 6 | -------------------------------------------------------------------------------- /index.ts: -------------------------------------------------------------------------------- 1 | export * from "./odoorpc.service"; 2 | -------------------------------------------------------------------------------- /odoorpc.service.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { 3 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; 4 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 5 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; 6 | return c > 3 && r && Object.defineProperty(target, key, r), r; 7 | }; 8 | var __param = (this && this.__param) || function (paramIndex, decorator) { 9 | return function (target, key) { decorator(target, key, paramIndex); } 10 | }; 11 | var core_1 = require("@angular/core"); 12 | var http_1 = require("@angular/http"); 13 | require("rxjs/add/operator/toPromise"); 14 | var Cookies = (function () { 15 | function Cookies() { 16 | this.session_id = null; 17 | } 18 | Cookies.prototype.delete_sessionId = function () { 19 | this.session_id = null; 20 | document.cookie = "session_id=; expires=Wed, 29 Jun 2016 00:00:00 UTC"; 21 | }; 22 | Cookies.prototype.get_sessionId = function () { 23 | return document 24 | .cookie.split("; ") 25 | .filter(function (x) { return x.indexOf("session_id") === 0; }) 26 | .map(function (x) { return x.split("=")[1]; }) 27 | .pop() || this.session_id || ""; 28 | }; 29 | Cookies.prototype.set_sessionId = function (val) { 30 | document.cookie = "session_id=" + val; 31 | this.session_id = val; 32 | }; 33 | return Cookies; 34 | }()); 35 | var OdooRPCService = (function () { 36 | function OdooRPCService(http) { 37 | this.http = http; 38 | this.uniq_id_counter = 0; 39 | this.shouldManageSessionId = false; // try without first 40 | this.context = JSON.parse(localStorage.getItem("user_context")) || { "lang": "en_US" }; 41 | this.cookies = new Cookies(); 42 | } 43 | OdooRPCService.prototype.buildRequest = function (url, params) { 44 | this.uniq_id_counter += 1; 45 | if (this.shouldManageSessionId) { 46 | params.session_id = this.cookies.get_sessionId(); 47 | } 48 | var json_data = { 49 | jsonrpc: "2.0", 50 | method: "call", 51 | params: params, 52 | }; 53 | this.headers = new http_1.Headers({ 54 | "Content-Type": "application/json", 55 | "X-Openerp-Session-Id": this.cookies.get_sessionId(), 56 | "Authorization": "Basic " + btoa("" + this.http_auth) 57 | }); 58 | return JSON.stringify({ 59 | jsonrpc: "2.0", 60 | method: "call", 61 | params: params, 62 | }); 63 | }; 64 | OdooRPCService.prototype.handleOdooErrors = function (response) { 65 | response = response.json(); 66 | if (!response.error) { 67 | return response.result; 68 | } 69 | var error = response.error; 70 | var errorObj = { 71 | title: " ", 72 | message: "", 73 | fullTrace: error 74 | }; 75 | if (error.code === 200 && error.message === "Odoo Server Error" && error.data.name === "werkzeug.exceptions.NotFound") { 76 | errorObj.title = "page_not_found"; 77 | errorObj.message = "HTTP Error"; 78 | } 79 | else if ((error.code === 100 && error.message === "Odoo Session Expired") || 80 | (error.code === 300 && error.message === "OpenERP WebClient Error" && error.data.debug.match("SessionExpiredException")) // v7 81 | ) { 82 | errorObj.title = "session_expired"; 83 | this.cookies.delete_sessionId(); 84 | } 85 | else if ((error.message === "Odoo Server Error" && /FATAL: database "(.+)" does not exist/.test(error.data.message))) { 86 | errorObj.title = "database_not_found"; 87 | errorObj.message = error.data.message; 88 | } 89 | else if ((error.data.name === "openerp.exceptions.AccessError")) { 90 | errorObj.title = "AccessError"; 91 | errorObj.message = error.data.message; 92 | } 93 | else { 94 | var split = ("" + error.data.fault_code).split("\n")[0].split(" -- "); 95 | if (split.length > 1) { 96 | error.type = split.shift(); 97 | error.data.fault_code = error.data.fault_code.substr(error.type.length + 4); 98 | } 99 | if (error.code === 200 && error.type) { 100 | errorObj.title = error.type; 101 | errorObj.message = error.data.fault_code.replace(/\n/g, "
"); 102 | } 103 | else { 104 | errorObj.title = error.message; 105 | errorObj.message = error.data.debug.replace(/\n/g, "
"); 106 | } 107 | } 108 | return Promise.reject(errorObj); 109 | }; 110 | OdooRPCService.prototype.handleHttpErrors = function (error) { 111 | return Promise.reject(error.message || error); 112 | }; 113 | OdooRPCService.prototype.init = function (configs) { 114 | this.odoo_server = configs.odoo_server; 115 | this.http_auth = configs.http_auth || null; 116 | }; 117 | OdooRPCService.prototype.setOdooServer = function (odoo_server) { 118 | this.odoo_server = odoo_server; 119 | }; 120 | OdooRPCService.prototype.setHttpAuth = function (http_auth) { 121 | this.http_auth = http_auth; 122 | }; 123 | OdooRPCService.prototype.sendRequest = function (url, params) { 124 | var options = this.buildRequest(url, params); 125 | return this.http.post(this.odoo_server + url, options, { headers: this.headers }) 126 | .toPromise() 127 | .then(this.handleOdooErrors) 128 | .catch(this.handleHttpErrors); 129 | }; 130 | OdooRPCService.prototype.getServerInfo = function () { 131 | return this.sendRequest("/web/webclient/version_info", {}); 132 | }; 133 | OdooRPCService.prototype.getSessionInfo = function () { 134 | return this.sendRequest("/web/session/get_session_info", {}); 135 | }; 136 | OdooRPCService.prototype.login = function (db, login, password) { 137 | var params = { 138 | db: db, 139 | login: login, 140 | password: password 141 | }; 142 | var $this = this; 143 | return this.sendRequest("/web/session/authenticate", params).then(function (result) { 144 | if (!result.uid) { 145 | $this.cookies.delete_sessionId(); 146 | return Promise.reject({ 147 | title: "wrong_login", 148 | message: "Username and password don't match", 149 | fullTrace: result 150 | }); 151 | } 152 | $this.context = result.user_context; 153 | localStorage.setItem("user_context", JSON.stringify($this.context)); 154 | $this.cookies.set_sessionId(result.session_id); 155 | return result; 156 | }); 157 | }; 158 | OdooRPCService.prototype.isLoggedIn = function (force) { 159 | var _this = this; 160 | if (force === void 0) { force = true; } 161 | if (!force) { 162 | return Promise.resolve(this.cookies.get_sessionId().length > 0); 163 | } 164 | return this.getSessionInfo().then(function (result) { 165 | _this.cookies.set_sessionId(result.session_id); 166 | return !!(result.uid); 167 | }); 168 | }; 169 | OdooRPCService.prototype.logout = function (force) { 170 | var _this = this; 171 | if (force === void 0) { force = true; } 172 | this.cookies.delete_sessionId(); 173 | if (force) { 174 | return this.getSessionInfo().then(function (r) { 175 | if (r.db) 176 | return _this.login(r.db, "", ""); 177 | }); 178 | } 179 | else { 180 | return Promise.resolve(); 181 | } 182 | }; 183 | OdooRPCService.prototype.getDbList = function () { 184 | return this.sendRequest("/web/database/get_list", {}); 185 | }; 186 | OdooRPCService.prototype.searchRead = function (model, domain, fields, limit) { 187 | var params = { 188 | model: model, 189 | domain: domain, 190 | fields: fields, 191 | limit: limit, 192 | context: this.context 193 | }; 194 | return this.sendRequest("/web/dataset/search_read", params); 195 | }; 196 | OdooRPCService.prototype.updateContext = function (context) { 197 | var _this = this; 198 | localStorage.setItem("user_context", JSON.stringify(context)); 199 | var args = [[this.context.uid], context]; 200 | this.call("res.users", "write", args, {}) 201 | .then(function () { return _this.context = context; }) 202 | .catch(function (err) { return _this.context = context; }); 203 | }; 204 | OdooRPCService.prototype.getContext = function () { 205 | return this.context; 206 | }; 207 | OdooRPCService.prototype.call = function (model, method, args, kwargs) { 208 | kwargs = kwargs || {}; 209 | kwargs.context = kwargs.context || {}; 210 | Object.assign(kwargs.context, this.context); 211 | var params = { 212 | model: model, 213 | method: method, 214 | args: args, 215 | kwargs: kwargs, 216 | }; 217 | return this.sendRequest("/web/dataset/call_kw", params); 218 | }; 219 | OdooRPCService.prototype.call_workflow = function (model, method, id ) { 220 | var params = { 221 | model: model, 222 | id: parseInt(id), 223 | signal: method, 224 | }; 225 | return this.sendRequest("/web/dataset/exec_workflow", params); 226 | }; 227 | OdooRPCService = __decorate([ 228 | core_1.Injectable(), 229 | __param(0, core_1.Inject(http_1.Http)) 230 | ], OdooRPCService); 231 | return OdooRPCService; 232 | }()); 233 | exports.OdooRPCService = OdooRPCService; 234 | -------------------------------------------------------------------------------- /odoorpc.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable, Inject } from "@angular/core"; 2 | import { Http, Response, Headers } from "@angular/http"; 3 | 4 | import "rxjs/add/operator/toPromise"; 5 | 6 | class Cookies { // cookies doesn't work with Android default browser / Ionic 7 | 8 | private session_id: string = null; 9 | 10 | delete_sessionId() { 11 | this.session_id = null; 12 | document.cookie = "session_id=; expires=Wed, 29 Jun 2016 00:00:00 UTC"; 13 | } 14 | 15 | get_sessionId() { 16 | return document 17 | .cookie.split("; ") 18 | .filter(x => { return x.indexOf("session_id") === 0; }) 19 | .map(x => { return x.split("=")[1]; }) 20 | .pop() || this.session_id || ""; 21 | } 22 | 23 | set_sessionId(val: string) { 24 | document.cookie = `session_id=${val}`; 25 | this.session_id = val; 26 | } 27 | } 28 | 29 | @Injectable() 30 | export class OdooRPCService { 31 | private odoo_server: string; 32 | private http_auth: string; 33 | private cookies: Cookies; 34 | private uniq_id_counter: number = 0; 35 | private shouldManageSessionId: boolean = false; // try without first 36 | private context: Object = JSON.parse(localStorage.getItem("user_context")) || {"lang": "en_US"}; 37 | private headers: Headers; 38 | 39 | constructor( 40 | @Inject(Http) private http: Http) { 41 | this.cookies = new Cookies(); 42 | } 43 | 44 | private buildRequest(url: string, params: any) { 45 | this.uniq_id_counter += 1; 46 | if (this.shouldManageSessionId) { 47 | params.session_id = this.cookies.get_sessionId(); 48 | } 49 | 50 | let json_data = { 51 | jsonrpc: "2.0", 52 | method: "call", 53 | params: params, // payload 54 | }; 55 | this.headers = new Headers({ 56 | "Content-Type": "application/json", 57 | "X-Openerp-Session-Id": this.cookies.get_sessionId(), 58 | "Authorization": "Basic " + btoa(`${this.http_auth}`) 59 | }); 60 | return JSON.stringify({ 61 | jsonrpc: "2.0", 62 | method: "call", 63 | params: params, // payload 64 | }); 65 | } 66 | 67 | private handleOdooErrors(response: any) { 68 | response = response.json(); 69 | if (!response.error) { 70 | return response.result; 71 | } 72 | 73 | let error = response.error; 74 | let errorObj = { 75 | title: " ", 76 | message: "", 77 | fullTrace: error 78 | }; 79 | 80 | if (error.code === 200 && error.message === "Odoo Server Error" && error.data.name === "werkzeug.exceptions.NotFound") { 81 | errorObj.title = "page_not_found"; 82 | errorObj.message = "HTTP Error"; 83 | } else if ( (error.code === 100 && error.message === "Odoo Session Expired") || // v8 84 | (error.code === 300 && error.message === "OpenERP WebClient Error" && error.data.debug.match("SessionExpiredException")) // v7 85 | ) { 86 | errorObj.title = "session_expired"; 87 | this.cookies.delete_sessionId(); 88 | } else if ( (error.message === "Odoo Server Error" && /FATAL: database "(.+)" does not exist/.test(error.data.message))) { 89 | errorObj.title = "database_not_found"; 90 | errorObj.message = error.data.message; 91 | } else if ( (error.data.name === "openerp.exceptions.AccessError")) { 92 | errorObj.title = "AccessError"; 93 | errorObj.message = error.data.message; 94 | } else { 95 | let split = ("" + error.data.fault_code).split("\n")[0].split(" -- "); 96 | if (split.length > 1) { 97 | error.type = split.shift(); 98 | error.data.fault_code = error.data.fault_code.substr(error.type.length + 4); 99 | } 100 | 101 | if (error.code === 200 && error.type) { 102 | errorObj.title = error.type; 103 | errorObj.message = error.data.fault_code.replace(/\n/g, "
"); 104 | } else { 105 | errorObj.title = error.message; 106 | errorObj.message = error.data.debug.replace(/\n/g, "
"); 107 | } 108 | } 109 | return Promise.reject(errorObj); 110 | } 111 | 112 | private handleHttpErrors(error: any) { 113 | return Promise.reject(error.message || error); 114 | } 115 | 116 | public init(configs: any) { 117 | this.odoo_server = configs.odoo_server; 118 | this.http_auth = configs.http_auth || null; 119 | } 120 | 121 | public setOdooServer(odoo_server: string) { 122 | this.odoo_server = odoo_server; 123 | } 124 | 125 | public setHttpAuth(http_auth: string) { 126 | this.http_auth = http_auth; 127 | } 128 | 129 | public sendRequest(url: string, params: Object): Promise { 130 | let options = this.buildRequest(url, params); 131 | return this.http.post(this.odoo_server + url, options, {headers: this.headers}) 132 | .toPromise() 133 | .then(this.handleOdooErrors) 134 | .catch(this.handleHttpErrors); 135 | } 136 | 137 | public getServerInfo() { 138 | return this.sendRequest("/web/webclient/version_info", {}); 139 | } 140 | 141 | public getSessionInfo() { 142 | return this.sendRequest("/web/session/get_session_info", {}); 143 | } 144 | 145 | public login(db: string, login: string, password: string) { 146 | let params = { 147 | db : db, 148 | login : login, 149 | password : password 150 | }; 151 | let $this = this; 152 | return this.sendRequest("/web/session/authenticate", params).then(function(result: any) { 153 | if (!result.uid) { 154 | $this.cookies.delete_sessionId(); 155 | return Promise.reject({ 156 | title: "wrong_login", 157 | message: "Username and password don't match", 158 | fullTrace: result 159 | }); 160 | } 161 | $this.context = result.user_context; 162 | localStorage.setItem("user_context", JSON.stringify($this.context)); 163 | $this.cookies.set_sessionId(result.session_id); 164 | return result; 165 | }); 166 | } 167 | 168 | public isLoggedIn(force: boolean = true) { 169 | if (!force) { 170 | return Promise.resolve(this.cookies.get_sessionId().length > 0); 171 | } 172 | return this.getSessionInfo().then((result: any) => { 173 | this.cookies.set_sessionId(result.session_id); 174 | return !!(result.uid); 175 | }); 176 | } 177 | 178 | public logout(force: boolean = true) { 179 | this.cookies.delete_sessionId(); 180 | if (force) { 181 | return this.getSessionInfo().then((r: any) => { // get db from sessionInfo 182 | if (r.db) 183 | return this.login(r.db, "", ""); 184 | }); 185 | }else { 186 | return Promise.resolve(); 187 | } 188 | } 189 | 190 | public getDbList() { // only use for odoo < 9.0 191 | return this.sendRequest("/web/database/get_list", {}); 192 | } 193 | 194 | public searchRead(model: string, domain: any, fields: any, limit: number) { 195 | let params = { 196 | model: model, 197 | domain: domain, 198 | fields: fields, 199 | limit: limit, 200 | context: this.context 201 | }; 202 | return this.sendRequest("/web/dataset/search_read", params); 203 | } 204 | 205 | public updateContext(context: any) { 206 | localStorage.setItem("user_context", JSON.stringify(context)); 207 | let args = [[(this.context).uid], context]; 208 | this.call("res.users", "write", args, {}) 209 | .then(()=>this.context = context) 210 | .catch((err: any) => this.context = context); 211 | } 212 | 213 | public getContext() { 214 | return this.context; 215 | } 216 | 217 | public call(model: string, method: string, args: any, kwargs: any) { 218 | 219 | kwargs = kwargs || {}; 220 | kwargs.context = kwargs.context || {}; 221 | Object.assign(kwargs.context, this.context); 222 | 223 | let params = { 224 | model: model, 225 | method: method, 226 | args: args, 227 | kwargs: kwargs, 228 | }; 229 | return this.sendRequest("/web/dataset/call_kw", params); 230 | } 231 | 232 | public call_workflow(model: string, method: string, id: any) { 233 | let params = { 234 | model: model, 235 | id: parseInt(id), 236 | signal: method, 237 | }; 238 | return this.sendRequest("/web/dataset/exec_workflow", params); 239 | } 240 | } 241 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "angular2-odoo-jsonrpc", 3 | "version": "0.0.7", 4 | "description": "Odoo JsonRPC Service for angular 2", 5 | "main": "odoorpc.service.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "git+https://github.com/astronaut1712/angular2-odoo-jsonrpc.git" 12 | }, 13 | "keywords": [ 14 | "odoo", 15 | "angular", 16 | "2", 17 | "jsonrpc", 18 | "angular2" 19 | ], 20 | "author": "Quang ", 21 | "license": "UNLICENSED", 22 | "bugs": { 23 | "url": "https://github.com/astronaut1712/angular2-odoo-jsonrpc/issues" 24 | }, 25 | "homepage": "https://github.com/astronaut1712/angular2-odoo-jsonrpc#readme", 26 | "dependencies": { 27 | "@angular/common": "^2.0.0-rc.3", 28 | "@angular/compiler": "^2.0.0-rc.3", 29 | "@angular/core": "^2.0.0-rc.3", 30 | "@angular/http": "^2.0.0-rc.3", 31 | "@angular/platform-browser": "^2.0.0-rc.3", 32 | "rxjs": "^5.0.0-beta.6", 33 | "zone.js": "^0.6.12" 34 | }, 35 | "devDependencies": { 36 | "tslint": "^3.13.0", 37 | "typescript": "^1.8.10" 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "target": "es5", 5 | "noImplicitAny": false, 6 | "sourceMap": false, 7 | "experimentalDecorators": true 8 | }, 9 | "exclude": [ 10 | "node_modules" 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": {}, 3 | "devDependencies": {}, 4 | "globalDependencies": { 5 | "es6-shim": "github:DefinitelyTyped/DefinitelyTyped/es6-shim/es6-shim.d.ts#4de74cb527395c13ba20b438c3a7a419ad931f1c", 6 | "jasmine": "github:DefinitelyTyped/DefinitelyTyped/jasmine/jasmine.d.ts#dd638012d63e069f2c99d06ef4dcc9616a943ee4", 7 | "zone.js": "github:DefinitelyTyped/DefinitelyTyped/zone.js/zone.js.d.ts#9027703c0bd831319dcdf7f3169f7a468537f448" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /typings/browser.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | /// 4 | -------------------------------------------------------------------------------- /typings/globals/es6-shim/index.d.ts: -------------------------------------------------------------------------------- 1 | // Generated by typings 2 | // Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/4de74cb527395c13ba20b438c3a7a419ad931f1c/es6-shim/es6-shim.d.ts 3 | declare type PropertyKey = string | number | symbol; 4 | 5 | interface IteratorResult { 6 | done: boolean; 7 | value?: T; 8 | } 9 | 10 | interface IterableShim { 11 | /** 12 | * Shim for an ES6 iterable. Not intended for direct use by user code. 13 | */ 14 | "_es6-shim iterator_"(): Iterator; 15 | } 16 | 17 | interface Iterator { 18 | next(value?: any): IteratorResult; 19 | return?(value?: any): IteratorResult; 20 | throw?(e?: any): IteratorResult; 21 | } 22 | 23 | interface IterableIteratorShim extends IterableShim, Iterator { 24 | /** 25 | * Shim for an ES6 iterable iterator. Not intended for direct use by user code. 26 | */ 27 | "_es6-shim iterator_"(): IterableIteratorShim; 28 | } 29 | 30 | interface StringConstructor { 31 | /** 32 | * Return the String value whose elements are, in order, the elements in the List elements. 33 | * If length is 0, the empty string is returned. 34 | */ 35 | fromCodePoint(...codePoints: number[]): string; 36 | 37 | /** 38 | * String.raw is intended for use as a tag function of a Tagged Template String. When called 39 | * as such the first argument will be a well formed template call site object and the rest 40 | * parameter will contain the substitution values. 41 | * @param template A well-formed template string call site representation. 42 | * @param substitutions A set of substitution values. 43 | */ 44 | raw(template: TemplateStringsArray, ...substitutions: any[]): string; 45 | } 46 | 47 | interface String { 48 | /** 49 | * Returns a nonnegative integer Number less than 1114112 (0x110000) that is the code point 50 | * value of the UTF-16 encoded code point starting at the string element at position pos in 51 | * the String resulting from converting this object to a String. 52 | * If there is no element at that position, the result is undefined. 53 | * If a valid UTF-16 surrogate pair does not begin at pos, the result is the code unit at pos. 54 | */ 55 | codePointAt(pos: number): number; 56 | 57 | /** 58 | * Returns true if searchString appears as a substring of the result of converting this 59 | * object to a String, at one or more positions that are 60 | * greater than or equal to position; otherwise, returns false. 61 | * @param searchString search string 62 | * @param position If position is undefined, 0 is assumed, so as to search all of the String. 63 | */ 64 | includes(searchString: string, position?: number): boolean; 65 | 66 | /** 67 | * Returns true if the sequence of elements of searchString converted to a String is the 68 | * same as the corresponding elements of this object (converted to a String) starting at 69 | * endPosition – length(this). Otherwise returns false. 70 | */ 71 | endsWith(searchString: string, endPosition?: number): boolean; 72 | 73 | /** 74 | * Returns a String value that is made from count copies appended together. If count is 0, 75 | * T is the empty String is returned. 76 | * @param count number of copies to append 77 | */ 78 | repeat(count: number): string; 79 | 80 | /** 81 | * Returns true if the sequence of elements of searchString converted to a String is the 82 | * same as the corresponding elements of this object (converted to a String) starting at 83 | * position. Otherwise returns false. 84 | */ 85 | startsWith(searchString: string, position?: number): boolean; 86 | 87 | /** 88 | * Returns an HTML anchor element and sets the name attribute to the text value 89 | * @param name 90 | */ 91 | anchor(name: string): string; 92 | 93 | /** Returns a HTML element */ 94 | big(): string; 95 | 96 | /** Returns a HTML element */ 97 | blink(): string; 98 | 99 | /** Returns a HTML element */ 100 | bold(): string; 101 | 102 | /** Returns a HTML element */ 103 | fixed(): string 104 | 105 | /** Returns a HTML element and sets the color attribute value */ 106 | fontcolor(color: string): string 107 | 108 | /** Returns a HTML element and sets the size attribute value */ 109 | fontsize(size: number): string; 110 | 111 | /** Returns a HTML element and sets the size attribute value */ 112 | fontsize(size: string): string; 113 | 114 | /** Returns an HTML element */ 115 | italics(): string; 116 | 117 | /** Returns an HTML element and sets the href attribute value */ 118 | link(url: string): string; 119 | 120 | /** Returns a HTML element */ 121 | small(): string; 122 | 123 | /** Returns a HTML element */ 124 | strike(): string; 125 | 126 | /** Returns a HTML element */ 127 | sub(): string; 128 | 129 | /** Returns a HTML element */ 130 | sup(): string; 131 | 132 | /** 133 | * Shim for an ES6 iterable. Not intended for direct use by user code. 134 | */ 135 | "_es6-shim iterator_"(): IterableIteratorShim; 136 | } 137 | 138 | interface ArrayConstructor { 139 | /** 140 | * Creates an array from an array-like object. 141 | * @param arrayLike An array-like object to convert to an array. 142 | * @param mapfn A mapping function to call on every element of the array. 143 | * @param thisArg Value of 'this' used to invoke the mapfn. 144 | */ 145 | from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => U, thisArg?: any): Array; 146 | 147 | /** 148 | * Creates an array from an iterable object. 149 | * @param iterable An iterable object to convert to an array. 150 | * @param mapfn A mapping function to call on every element of the array. 151 | * @param thisArg Value of 'this' used to invoke the mapfn. 152 | */ 153 | from(iterable: IterableShim, mapfn: (v: T, k: number) => U, thisArg?: any): Array; 154 | 155 | /** 156 | * Creates an array from an array-like object. 157 | * @param arrayLike An array-like object to convert to an array. 158 | */ 159 | from(arrayLike: ArrayLike): Array; 160 | 161 | /** 162 | * Creates an array from an iterable object. 163 | * @param iterable An iterable object to convert to an array. 164 | */ 165 | from(iterable: IterableShim): Array; 166 | 167 | /** 168 | * Returns a new array from a set of elements. 169 | * @param items A set of elements to include in the new array object. 170 | */ 171 | of(...items: T[]): Array; 172 | } 173 | 174 | interface Array { 175 | /** 176 | * Returns the value of the first element in the array where predicate is true, and undefined 177 | * otherwise. 178 | * @param predicate find calls predicate once for each element of the array, in ascending 179 | * order, until it finds one where predicate returns true. If such an element is found, find 180 | * immediately returns that element value. Otherwise, find returns undefined. 181 | * @param thisArg If provided, it will be used as the this value for each invocation of 182 | * predicate. If it is not provided, undefined is used instead. 183 | */ 184 | find(predicate: (value: T, index: number, obj: Array) => boolean, thisArg?: any): T; 185 | 186 | /** 187 | * Returns the index of the first element in the array where predicate is true, and undefined 188 | * otherwise. 189 | * @param predicate find calls predicate once for each element of the array, in ascending 190 | * order, until it finds one where predicate returns true. If such an element is found, find 191 | * immediately returns that element value. Otherwise, find returns undefined. 192 | * @param thisArg If provided, it will be used as the this value for each invocation of 193 | * predicate. If it is not provided, undefined is used instead. 194 | */ 195 | findIndex(predicate: (value: T) => boolean, thisArg?: any): number; 196 | 197 | /** 198 | * Returns the this object after filling the section identified by start and end with value 199 | * @param value value to fill array section with 200 | * @param start index to start filling the array at. If start is negative, it is treated as 201 | * length+start where length is the length of the array. 202 | * @param end index to stop filling the array at. If end is negative, it is treated as 203 | * length+end. 204 | */ 205 | fill(value: T, start?: number, end?: number): T[]; 206 | 207 | /** 208 | * Returns the this object after copying a section of the array identified by start and end 209 | * to the same array starting at position target 210 | * @param target If target is negative, it is treated as length+target where length is the 211 | * length of the array. 212 | * @param start If start is negative, it is treated as length+start. If end is negative, it 213 | * is treated as length+end. 214 | * @param end If not specified, length of the this object is used as its default value. 215 | */ 216 | copyWithin(target: number, start: number, end?: number): T[]; 217 | 218 | /** 219 | * Returns an array of key, value pairs for every entry in the array 220 | */ 221 | entries(): IterableIteratorShim<[number, T]>; 222 | 223 | /** 224 | * Returns an list of keys in the array 225 | */ 226 | keys(): IterableIteratorShim; 227 | 228 | /** 229 | * Returns an list of values in the array 230 | */ 231 | values(): IterableIteratorShim; 232 | 233 | /** 234 | * Shim for an ES6 iterable. Not intended for direct use by user code. 235 | */ 236 | "_es6-shim iterator_"(): IterableIteratorShim; 237 | } 238 | 239 | interface NumberConstructor { 240 | /** 241 | * The value of Number.EPSILON is the difference between 1 and the smallest value greater than 1 242 | * that is representable as a Number value, which is approximately: 243 | * 2.2204460492503130808472633361816 x 10‍−‍16. 244 | */ 245 | EPSILON: number; 246 | 247 | /** 248 | * Returns true if passed value is finite. 249 | * Unlike the global isFininte, Number.isFinite doesn't forcibly convert the parameter to a 250 | * number. Only finite values of the type number, result in true. 251 | * @param number A numeric value. 252 | */ 253 | isFinite(number: number): boolean; 254 | 255 | /** 256 | * Returns true if the value passed is an integer, false otherwise. 257 | * @param number A numeric value. 258 | */ 259 | isInteger(number: number): boolean; 260 | 261 | /** 262 | * Returns a Boolean value that indicates whether a value is the reserved value NaN (not a 263 | * number). Unlike the global isNaN(), Number.isNaN() doesn't forcefully convert the parameter 264 | * to a number. Only values of the type number, that are also NaN, result in true. 265 | * @param number A numeric value. 266 | */ 267 | isNaN(number: number): boolean; 268 | 269 | /** 270 | * Returns true if the value passed is a safe integer. 271 | * @param number A numeric value. 272 | */ 273 | isSafeInteger(number: number): boolean; 274 | 275 | /** 276 | * The value of the largest integer n such that n and n + 1 are both exactly representable as 277 | * a Number value. 278 | * The value of Number.MIN_SAFE_INTEGER is 9007199254740991 2^53 − 1. 279 | */ 280 | MAX_SAFE_INTEGER: number; 281 | 282 | /** 283 | * The value of the smallest integer n such that n and n − 1 are both exactly representable as 284 | * a Number value. 285 | * The value of Number.MIN_SAFE_INTEGER is −9007199254740991 (−(2^53 − 1)). 286 | */ 287 | MIN_SAFE_INTEGER: number; 288 | 289 | /** 290 | * Converts a string to a floating-point number. 291 | * @param string A string that contains a floating-point number. 292 | */ 293 | parseFloat(string: string): number; 294 | 295 | /** 296 | * Converts A string to an integer. 297 | * @param s A string to convert into a number. 298 | * @param radix A value between 2 and 36 that specifies the base of the number in numString. 299 | * If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal. 300 | * All other strings are considered decimal. 301 | */ 302 | parseInt(string: string, radix?: number): number; 303 | } 304 | 305 | interface ObjectConstructor { 306 | /** 307 | * Copy the values of all of the enumerable own properties from one or more source objects to a 308 | * target object. Returns the target object. 309 | * @param target The target object to copy to. 310 | * @param sources One or more source objects to copy properties from. 311 | */ 312 | assign(target: any, ...sources: any[]): any; 313 | 314 | /** 315 | * Returns true if the values are the same value, false otherwise. 316 | * @param value1 The first value. 317 | * @param value2 The second value. 318 | */ 319 | is(value1: any, value2: any): boolean; 320 | 321 | /** 322 | * Sets the prototype of a specified object o to object proto or null. Returns the object o. 323 | * @param o The object to change its prototype. 324 | * @param proto The value of the new prototype or null. 325 | * @remarks Requires `__proto__` support. 326 | */ 327 | setPrototypeOf(o: any, proto: any): any; 328 | } 329 | 330 | interface RegExp { 331 | /** 332 | * Returns a string indicating the flags of the regular expression in question. This field is read-only. 333 | * The characters in this string are sequenced and concatenated in the following order: 334 | * 335 | * - "g" for global 336 | * - "i" for ignoreCase 337 | * - "m" for multiline 338 | * - "u" for unicode 339 | * - "y" for sticky 340 | * 341 | * If no flags are set, the value is the empty string. 342 | */ 343 | flags: string; 344 | } 345 | 346 | interface Math { 347 | /** 348 | * Returns the number of leading zero bits in the 32-bit binary representation of a number. 349 | * @param x A numeric expression. 350 | */ 351 | clz32(x: number): number; 352 | 353 | /** 354 | * Returns the result of 32-bit multiplication of two numbers. 355 | * @param x First number 356 | * @param y Second number 357 | */ 358 | imul(x: number, y: number): number; 359 | 360 | /** 361 | * Returns the sign of the x, indicating whether x is positive, negative or zero. 362 | * @param x The numeric expression to test 363 | */ 364 | sign(x: number): number; 365 | 366 | /** 367 | * Returns the base 10 logarithm of a number. 368 | * @param x A numeric expression. 369 | */ 370 | log10(x: number): number; 371 | 372 | /** 373 | * Returns the base 2 logarithm of a number. 374 | * @param x A numeric expression. 375 | */ 376 | log2(x: number): number; 377 | 378 | /** 379 | * Returns the natural logarithm of 1 + x. 380 | * @param x A numeric expression. 381 | */ 382 | log1p(x: number): number; 383 | 384 | /** 385 | * Returns the result of (e^x - 1) of x (e raised to the power of x, where e is the base of 386 | * the natural logarithms). 387 | * @param x A numeric expression. 388 | */ 389 | expm1(x: number): number; 390 | 391 | /** 392 | * Returns the hyperbolic cosine of a number. 393 | * @param x A numeric expression that contains an angle measured in radians. 394 | */ 395 | cosh(x: number): number; 396 | 397 | /** 398 | * Returns the hyperbolic sine of a number. 399 | * @param x A numeric expression that contains an angle measured in radians. 400 | */ 401 | sinh(x: number): number; 402 | 403 | /** 404 | * Returns the hyperbolic tangent of a number. 405 | * @param x A numeric expression that contains an angle measured in radians. 406 | */ 407 | tanh(x: number): number; 408 | 409 | /** 410 | * Returns the inverse hyperbolic cosine of a number. 411 | * @param x A numeric expression that contains an angle measured in radians. 412 | */ 413 | acosh(x: number): number; 414 | 415 | /** 416 | * Returns the inverse hyperbolic sine of a number. 417 | * @param x A numeric expression that contains an angle measured in radians. 418 | */ 419 | asinh(x: number): number; 420 | 421 | /** 422 | * Returns the inverse hyperbolic tangent of a number. 423 | * @param x A numeric expression that contains an angle measured in radians. 424 | */ 425 | atanh(x: number): number; 426 | 427 | /** 428 | * Returns the square root of the sum of squares of its arguments. 429 | * @param values Values to compute the square root for. 430 | * If no arguments are passed, the result is +0. 431 | * If there is only one argument, the result is the absolute value. 432 | * If any argument is +Infinity or -Infinity, the result is +Infinity. 433 | * If any argument is NaN, the result is NaN. 434 | * If all arguments are either +0 or −0, the result is +0. 435 | */ 436 | hypot(...values: number[]): number; 437 | 438 | /** 439 | * Returns the integral part of the a numeric expression, x, removing any fractional digits. 440 | * If x is already an integer, the result is x. 441 | * @param x A numeric expression. 442 | */ 443 | trunc(x: number): number; 444 | 445 | /** 446 | * Returns the nearest single precision float representation of a number. 447 | * @param x A numeric expression. 448 | */ 449 | fround(x: number): number; 450 | 451 | /** 452 | * Returns an implementation-dependent approximation to the cube root of number. 453 | * @param x A numeric expression. 454 | */ 455 | cbrt(x: number): number; 456 | } 457 | 458 | interface PromiseLike { 459 | /** 460 | * Attaches callbacks for the resolution and/or rejection of the Promise. 461 | * @param onfulfilled The callback to execute when the Promise is resolved. 462 | * @param onrejected The callback to execute when the Promise is rejected. 463 | * @returns A Promise for the completion of which ever callback is executed. 464 | */ 465 | then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): PromiseLike; 466 | then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): PromiseLike; 467 | } 468 | 469 | /** 470 | * Represents the completion of an asynchronous operation 471 | */ 472 | interface Promise { 473 | /** 474 | * Attaches callbacks for the resolution and/or rejection of the Promise. 475 | * @param onfulfilled The callback to execute when the Promise is resolved. 476 | * @param onrejected The callback to execute when the Promise is rejected. 477 | * @returns A Promise for the completion of which ever callback is executed. 478 | */ 479 | then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; 480 | then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): Promise; 481 | 482 | /** 483 | * Attaches a callback for only the rejection of the Promise. 484 | * @param onrejected The callback to execute when the Promise is rejected. 485 | * @returns A Promise for the completion of the callback. 486 | */ 487 | catch(onrejected?: (reason: any) => T | PromiseLike): Promise; 488 | catch(onrejected?: (reason: any) => void): Promise; 489 | } 490 | 491 | interface PromiseConstructor { 492 | /** 493 | * A reference to the prototype. 494 | */ 495 | prototype: Promise; 496 | 497 | /** 498 | * Creates a new Promise. 499 | * @param executor A callback used to initialize the promise. This callback is passed two arguments: 500 | * a resolve callback used resolve the promise with a value or the result of another promise, 501 | * and a reject callback used to reject the promise with a provided reason or error. 502 | */ 503 | new (executor: (resolve: (value?: T | PromiseLike) => void, reject: (reason?: any) => void) => void): Promise; 504 | 505 | /** 506 | * Creates a Promise that is resolved with an array of results when all of the provided Promises 507 | * resolve, or rejected when any Promise is rejected. 508 | * @param values An array of Promises. 509 | * @returns A new Promise. 510 | */ 511 | all(values: IterableShim>): Promise; 512 | 513 | /** 514 | * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved 515 | * or rejected. 516 | * @param values An array of Promises. 517 | * @returns A new Promise. 518 | */ 519 | race(values: IterableShim>): Promise; 520 | 521 | /** 522 | * Creates a new rejected promise for the provided reason. 523 | * @param reason The reason the promise was rejected. 524 | * @returns A new rejected Promise. 525 | */ 526 | reject(reason: any): Promise; 527 | 528 | /** 529 | * Creates a new rejected promise for the provided reason. 530 | * @param reason The reason the promise was rejected. 531 | * @returns A new rejected Promise. 532 | */ 533 | reject(reason: any): Promise; 534 | 535 | /** 536 | * Creates a new resolved promise for the provided value. 537 | * @param value A promise. 538 | * @returns A promise whose internal state matches the provided promise. 539 | */ 540 | resolve(value: T | PromiseLike): Promise; 541 | 542 | /** 543 | * Creates a new resolved promise . 544 | * @returns A resolved promise. 545 | */ 546 | resolve(): Promise; 547 | } 548 | 549 | declare var Promise: PromiseConstructor; 550 | 551 | interface Map { 552 | clear(): void; 553 | delete(key: K): boolean; 554 | forEach(callbackfn: (value: V, index: K, map: Map) => void, thisArg?: any): void; 555 | get(key: K): V; 556 | has(key: K): boolean; 557 | set(key: K, value?: V): Map; 558 | size: number; 559 | entries(): IterableIteratorShim<[K, V]>; 560 | keys(): IterableIteratorShim; 561 | values(): IterableIteratorShim; 562 | } 563 | 564 | interface MapConstructor { 565 | new (): Map; 566 | new (iterable: IterableShim<[K, V]>): Map; 567 | prototype: Map; 568 | } 569 | 570 | declare var Map: MapConstructor; 571 | 572 | interface Set { 573 | add(value: T): Set; 574 | clear(): void; 575 | delete(value: T): boolean; 576 | forEach(callbackfn: (value: T, index: T, set: Set) => void, thisArg?: any): void; 577 | has(value: T): boolean; 578 | size: number; 579 | entries(): IterableIteratorShim<[T, T]>; 580 | keys(): IterableIteratorShim; 581 | values(): IterableIteratorShim; 582 | } 583 | 584 | interface SetConstructor { 585 | new (): Set; 586 | new (iterable: IterableShim): Set; 587 | prototype: Set; 588 | } 589 | 590 | declare var Set: SetConstructor; 591 | 592 | interface WeakMap { 593 | delete(key: K): boolean; 594 | get(key: K): V; 595 | has(key: K): boolean; 596 | set(key: K, value?: V): WeakMap; 597 | } 598 | 599 | interface WeakMapConstructor { 600 | new (): WeakMap; 601 | new (iterable: IterableShim<[K, V]>): WeakMap; 602 | prototype: WeakMap; 603 | } 604 | 605 | declare var WeakMap: WeakMapConstructor; 606 | 607 | interface WeakSet { 608 | add(value: T): WeakSet; 609 | delete(value: T): boolean; 610 | has(value: T): boolean; 611 | } 612 | 613 | interface WeakSetConstructor { 614 | new (): WeakSet; 615 | new (iterable: IterableShim): WeakSet; 616 | prototype: WeakSet; 617 | } 618 | 619 | declare var WeakSet: WeakSetConstructor; 620 | 621 | declare module Reflect { 622 | function apply(target: Function, thisArgument: any, argumentsList: ArrayLike): any; 623 | function construct(target: Function, argumentsList: ArrayLike): any; 624 | function defineProperty(target: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean; 625 | function deleteProperty(target: any, propertyKey: PropertyKey): boolean; 626 | function enumerate(target: any): IterableIteratorShim; 627 | function get(target: any, propertyKey: PropertyKey, receiver?: any): any; 628 | function getOwnPropertyDescriptor(target: any, propertyKey: PropertyKey): PropertyDescriptor; 629 | function getPrototypeOf(target: any): any; 630 | function has(target: any, propertyKey: PropertyKey): boolean; 631 | function isExtensible(target: any): boolean; 632 | function ownKeys(target: any): Array; 633 | function preventExtensions(target: any): boolean; 634 | function set(target: any, propertyKey: PropertyKey, value: any, receiver?: any): boolean; 635 | function setPrototypeOf(target: any, proto: any): boolean; 636 | } 637 | 638 | declare module "es6-shim" { 639 | var String: StringConstructor; 640 | var Array: ArrayConstructor; 641 | var Number: NumberConstructor; 642 | var Math: Math; 643 | var Object: ObjectConstructor; 644 | var Map: MapConstructor; 645 | var Set: SetConstructor; 646 | var WeakMap: WeakMapConstructor; 647 | var WeakSet: WeakSetConstructor; 648 | var Promise: PromiseConstructor; 649 | module Reflect { 650 | function apply(target: Function, thisArgument: any, argumentsList: ArrayLike): any; 651 | function construct(target: Function, argumentsList: ArrayLike): any; 652 | function defineProperty(target: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean; 653 | function deleteProperty(target: any, propertyKey: PropertyKey): boolean; 654 | function enumerate(target: any): Iterator; 655 | function get(target: any, propertyKey: PropertyKey, receiver?: any): any; 656 | function getOwnPropertyDescriptor(target: any, propertyKey: PropertyKey): PropertyDescriptor; 657 | function getPrototypeOf(target: any): any; 658 | function has(target: any, propertyKey: PropertyKey): boolean; 659 | function isExtensible(target: any): boolean; 660 | function ownKeys(target: any): Array; 661 | function preventExtensions(target: any): boolean; 662 | function set(target: any, propertyKey: PropertyKey, value: any, receiver?: any): boolean; 663 | function setPrototypeOf(target: any, proto: any): boolean; 664 | } 665 | } 666 | -------------------------------------------------------------------------------- /typings/globals/es6-shim/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "resolution": "main", 3 | "tree": { 4 | "src": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/4de74cb527395c13ba20b438c3a7a419ad931f1c/es6-shim/es6-shim.d.ts", 5 | "raw": "github:DefinitelyTyped/DefinitelyTyped/es6-shim/es6-shim.d.ts#4de74cb527395c13ba20b438c3a7a419ad931f1c", 6 | "typings": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/4de74cb527395c13ba20b438c3a7a419ad931f1c/es6-shim/es6-shim.d.ts" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /typings/globals/jasmine/index.d.ts: -------------------------------------------------------------------------------- 1 | // Generated by typings 2 | // Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/dd638012d63e069f2c99d06ef4dcc9616a943ee4/jasmine/jasmine.d.ts 3 | declare function describe(description: string, specDefinitions: () => void): void; 4 | declare function fdescribe(description: string, specDefinitions: () => void): void; 5 | declare function xdescribe(description: string, specDefinitions: () => void): void; 6 | 7 | declare function it(expectation: string, assertion?: () => void, timeout?: number): void; 8 | declare function it(expectation: string, assertion?: (done: () => void) => void, timeout?: number): void; 9 | declare function fit(expectation: string, assertion?: () => void, timeout?: number): void; 10 | declare function fit(expectation: string, assertion?: (done: () => void) => void, timeout?: number): void; 11 | declare function xit(expectation: string, assertion?: () => void, timeout?: number): void; 12 | declare function xit(expectation: string, assertion?: (done: () => void) => void, timeout?: number): void; 13 | 14 | /** If you call the function pending anywhere in the spec body, no matter the expectations, the spec will be marked pending. */ 15 | declare function pending(reason?: string): void; 16 | 17 | declare function beforeEach(action: () => void, timeout?: number): void; 18 | declare function beforeEach(action: (done: () => void) => void, timeout?: number): void; 19 | declare function afterEach(action: () => void, timeout?: number): void; 20 | declare function afterEach(action: (done: () => void) => void, timeout?: number): void; 21 | 22 | declare function beforeAll(action: () => void, timeout?: number): void; 23 | declare function beforeAll(action: (done: () => void) => void, timeout?: number): void; 24 | declare function afterAll(action: () => void, timeout?: number): void; 25 | declare function afterAll(action: (done: () => void) => void, timeout?: number): void; 26 | 27 | declare function expect(spy: Function): jasmine.Matchers; 28 | declare function expect(actual: any): jasmine.Matchers; 29 | 30 | declare function fail(e?: any): void; 31 | 32 | declare function spyOn(object: any, method: string): jasmine.Spy; 33 | 34 | declare function runs(asyncMethod: Function): void; 35 | declare function waitsFor(latchMethod: () => boolean, failureMessage?: string, timeout?: number): void; 36 | declare function waits(timeout?: number): void; 37 | 38 | declare module jasmine { 39 | 40 | var clock: () => Clock; 41 | 42 | function any(aclass: any): Any; 43 | function anything(): Any; 44 | function arrayContaining(sample: any[]): ArrayContaining; 45 | function objectContaining(sample: any): ObjectContaining; 46 | function createSpy(name: string, originalFn?: Function): Spy; 47 | function createSpyObj(baseName: string, methodNames: any[]): any; 48 | function createSpyObj(baseName: string, methodNames: any[]): T; 49 | function pp(value: any): string; 50 | function getEnv(): Env; 51 | function addCustomEqualityTester(equalityTester: CustomEqualityTester): void; 52 | function addMatchers(matchers: CustomMatcherFactories): void; 53 | function stringMatching(str: string): Any; 54 | function stringMatching(str: RegExp): Any; 55 | 56 | interface Any { 57 | 58 | new (expectedClass: any): any; 59 | 60 | jasmineMatches(other: any): boolean; 61 | jasmineToString(): string; 62 | } 63 | 64 | // taken from TypeScript lib.core.es6.d.ts, applicable to CustomMatchers.contains() 65 | interface ArrayLike { 66 | length: number; 67 | [n: number]: T; 68 | } 69 | 70 | interface ArrayContaining { 71 | new (sample: any[]): any; 72 | 73 | asymmetricMatch(other: any): boolean; 74 | jasmineToString(): string; 75 | } 76 | 77 | interface ObjectContaining { 78 | new (sample: any): any; 79 | 80 | jasmineMatches(other: any, mismatchKeys: any[], mismatchValues: any[]): boolean; 81 | jasmineToString(): string; 82 | } 83 | 84 | interface Block { 85 | 86 | new (env: Env, func: SpecFunction, spec: Spec): any; 87 | 88 | execute(onComplete: () => void): void; 89 | } 90 | 91 | interface WaitsBlock extends Block { 92 | new (env: Env, timeout: number, spec: Spec): any; 93 | } 94 | 95 | interface WaitsForBlock extends Block { 96 | new (env: Env, timeout: number, latchFunction: SpecFunction, message: string, spec: Spec): any; 97 | } 98 | 99 | interface Clock { 100 | install(): void; 101 | uninstall(): void; 102 | /** Calls to any registered callback are triggered when the clock is ticked forward via the jasmine.clock().tick function, which takes a number of milliseconds. */ 103 | tick(ms: number): void; 104 | mockDate(date?: Date): void; 105 | } 106 | 107 | interface CustomEqualityTester { 108 | (first: any, second: any): boolean; 109 | } 110 | 111 | interface CustomMatcher { 112 | compare(actual: T, expected: T): CustomMatcherResult; 113 | compare(actual: any, expected: any): CustomMatcherResult; 114 | } 115 | 116 | interface CustomMatcherFactory { 117 | (util: MatchersUtil, customEqualityTesters: Array): CustomMatcher; 118 | } 119 | 120 | interface CustomMatcherFactories { 121 | [index: string]: CustomMatcherFactory; 122 | } 123 | 124 | interface CustomMatcherResult { 125 | pass: boolean; 126 | message?: string; 127 | } 128 | 129 | interface MatchersUtil { 130 | equals(a: any, b: any, customTesters?: Array): boolean; 131 | contains(haystack: ArrayLike | string, needle: any, customTesters?: Array): boolean; 132 | buildFailureMessage(matcherName: string, isNot: boolean, actual: any, ...expected: Array): string; 133 | } 134 | 135 | interface Env { 136 | setTimeout: any; 137 | clearTimeout: void; 138 | setInterval: any; 139 | clearInterval: void; 140 | updateInterval: number; 141 | 142 | currentSpec: Spec; 143 | 144 | matchersClass: Matchers; 145 | 146 | version(): any; 147 | versionString(): string; 148 | nextSpecId(): number; 149 | addReporter(reporter: Reporter): void; 150 | execute(): void; 151 | describe(description: string, specDefinitions: () => void): Suite; 152 | // ddescribe(description: string, specDefinitions: () => void): Suite; Not a part of jasmine. Angular team adds these 153 | beforeEach(beforeEachFunction: () => void): void; 154 | beforeAll(beforeAllFunction: () => void): void; 155 | currentRunner(): Runner; 156 | afterEach(afterEachFunction: () => void): void; 157 | afterAll(afterAllFunction: () => void): void; 158 | xdescribe(desc: string, specDefinitions: () => void): XSuite; 159 | it(description: string, func: () => void): Spec; 160 | // iit(description: string, func: () => void): Spec; Not a part of jasmine. Angular team adds these 161 | xit(desc: string, func: () => void): XSpec; 162 | compareRegExps_(a: RegExp, b: RegExp, mismatchKeys: string[], mismatchValues: string[]): boolean; 163 | compareObjects_(a: any, b: any, mismatchKeys: string[], mismatchValues: string[]): boolean; 164 | equals_(a: any, b: any, mismatchKeys: string[], mismatchValues: string[]): boolean; 165 | contains_(haystack: any, needle: any): boolean; 166 | addCustomEqualityTester(equalityTester: CustomEqualityTester): void; 167 | addMatchers(matchers: CustomMatcherFactories): void; 168 | specFilter(spec: Spec): boolean; 169 | } 170 | 171 | interface FakeTimer { 172 | 173 | new (): any; 174 | 175 | reset(): void; 176 | tick(millis: number): void; 177 | runFunctionsWithinRange(oldMillis: number, nowMillis: number): void; 178 | scheduleFunction(timeoutKey: any, funcToCall: () => void, millis: number, recurring: boolean): void; 179 | } 180 | 181 | interface HtmlReporter { 182 | new (): any; 183 | } 184 | 185 | interface HtmlSpecFilter { 186 | new (): any; 187 | } 188 | 189 | interface Result { 190 | type: string; 191 | } 192 | 193 | interface NestedResults extends Result { 194 | description: string; 195 | 196 | totalCount: number; 197 | passedCount: number; 198 | failedCount: number; 199 | 200 | skipped: boolean; 201 | 202 | rollupCounts(result: NestedResults): void; 203 | log(values: any): void; 204 | getItems(): Result[]; 205 | addResult(result: Result): void; 206 | passed(): boolean; 207 | } 208 | 209 | interface MessageResult extends Result { 210 | values: any; 211 | trace: Trace; 212 | } 213 | 214 | interface ExpectationResult extends Result { 215 | matcherName: string; 216 | passed(): boolean; 217 | expected: any; 218 | actual: any; 219 | message: string; 220 | trace: Trace; 221 | } 222 | 223 | interface Trace { 224 | name: string; 225 | message: string; 226 | stack: any; 227 | } 228 | 229 | interface PrettyPrinter { 230 | 231 | new (): any; 232 | 233 | format(value: any): void; 234 | iterateObject(obj: any, fn: (property: string, isGetter: boolean) => void): void; 235 | emitScalar(value: any): void; 236 | emitString(value: string): void; 237 | emitArray(array: any[]): void; 238 | emitObject(obj: any): void; 239 | append(value: any): void; 240 | } 241 | 242 | interface StringPrettyPrinter extends PrettyPrinter { 243 | } 244 | 245 | interface Queue { 246 | 247 | new (env: any): any; 248 | 249 | env: Env; 250 | ensured: boolean[]; 251 | blocks: Block[]; 252 | running: boolean; 253 | index: number; 254 | offset: number; 255 | abort: boolean; 256 | 257 | addBefore(block: Block, ensure?: boolean): void; 258 | add(block: any, ensure?: boolean): void; 259 | insertNext(block: any, ensure?: boolean): void; 260 | start(onComplete?: () => void): void; 261 | isRunning(): boolean; 262 | next_(): void; 263 | results(): NestedResults; 264 | } 265 | 266 | interface Matchers { 267 | 268 | new (env: Env, actual: any, spec: Env, isNot?: boolean): any; 269 | 270 | env: Env; 271 | actual: any; 272 | spec: Env; 273 | isNot?: boolean; 274 | message(): any; 275 | 276 | toBe(expected: any, expectationFailOutput?: any): boolean; 277 | toEqual(expected: any, expectationFailOutput?: any): boolean; 278 | toMatch(expected: string | RegExp, expectationFailOutput?: any): boolean; 279 | toBeDefined(expectationFailOutput?: any): boolean; 280 | toBeUndefined(expectationFailOutput?: any): boolean; 281 | toBeNull(expectationFailOutput?: any): boolean; 282 | toBeNaN(): boolean; 283 | toBeTruthy(expectationFailOutput?: any): boolean; 284 | toBeFalsy(expectationFailOutput?: any): boolean; 285 | toHaveBeenCalled(): boolean; 286 | toHaveBeenCalledWith(...params: any[]): boolean; 287 | toHaveBeenCalledTimes(expected: number): boolean; 288 | toContain(expected: any, expectationFailOutput?: any): boolean; 289 | toBeLessThan(expected: number, expectationFailOutput?: any): boolean; 290 | toBeGreaterThan(expected: number, expectationFailOutput?: any): boolean; 291 | toBeCloseTo(expected: number, precision: any, expectationFailOutput?: any): boolean; 292 | toThrow(expected?: any): boolean; 293 | toThrowError(message?: string | RegExp): boolean; 294 | toThrowError(expected?: Error, message?: string | RegExp): boolean; 295 | not: Matchers; 296 | 297 | Any: Any; 298 | } 299 | 300 | interface Reporter { 301 | reportRunnerStarting(runner: Runner): void; 302 | reportRunnerResults(runner: Runner): void; 303 | reportSuiteResults(suite: Suite): void; 304 | reportSpecStarting(spec: Spec): void; 305 | reportSpecResults(spec: Spec): void; 306 | log(str: string): void; 307 | } 308 | 309 | interface MultiReporter extends Reporter { 310 | addReporter(reporter: Reporter): void; 311 | } 312 | 313 | interface Runner { 314 | 315 | new (env: Env): any; 316 | 317 | execute(): void; 318 | beforeEach(beforeEachFunction: SpecFunction): void; 319 | afterEach(afterEachFunction: SpecFunction): void; 320 | beforeAll(beforeAllFunction: SpecFunction): void; 321 | afterAll(afterAllFunction: SpecFunction): void; 322 | finishCallback(): void; 323 | addSuite(suite: Suite): void; 324 | add(block: Block): void; 325 | specs(): Spec[]; 326 | suites(): Suite[]; 327 | topLevelSuites(): Suite[]; 328 | results(): NestedResults; 329 | } 330 | 331 | interface SpecFunction { 332 | (spec?: Spec): void; 333 | } 334 | 335 | interface SuiteOrSpec { 336 | id: number; 337 | env: Env; 338 | description: string; 339 | queue: Queue; 340 | } 341 | 342 | interface Spec extends SuiteOrSpec { 343 | 344 | new (env: Env, suite: Suite, description: string): any; 345 | 346 | suite: Suite; 347 | 348 | afterCallbacks: SpecFunction[]; 349 | spies_: Spy[]; 350 | 351 | results_: NestedResults; 352 | matchersClass: Matchers; 353 | 354 | getFullName(): string; 355 | results(): NestedResults; 356 | log(arguments: any): any; 357 | runs(func: SpecFunction): Spec; 358 | addToQueue(block: Block): void; 359 | addMatcherResult(result: Result): void; 360 | expect(actual: any): any; 361 | waits(timeout: number): Spec; 362 | waitsFor(latchFunction: SpecFunction, timeoutMessage?: string, timeout?: number): Spec; 363 | fail(e?: any): void; 364 | getMatchersClass_(): Matchers; 365 | addMatchers(matchersPrototype: CustomMatcherFactories): void; 366 | finishCallback(): void; 367 | finish(onComplete?: () => void): void; 368 | after(doAfter: SpecFunction): void; 369 | execute(onComplete?: () => void): any; 370 | addBeforesAndAftersToQueue(): void; 371 | explodes(): void; 372 | spyOn(obj: any, methodName: string, ignoreMethodDoesntExist: boolean): Spy; 373 | removeAllSpies(): void; 374 | } 375 | 376 | interface XSpec { 377 | id: number; 378 | runs(): void; 379 | } 380 | 381 | interface Suite extends SuiteOrSpec { 382 | 383 | new (env: Env, description: string, specDefinitions: () => void, parentSuite: Suite): any; 384 | 385 | parentSuite: Suite; 386 | 387 | getFullName(): string; 388 | finish(onComplete?: () => void): void; 389 | beforeEach(beforeEachFunction: SpecFunction): void; 390 | afterEach(afterEachFunction: SpecFunction): void; 391 | beforeAll(beforeAllFunction: SpecFunction): void; 392 | afterAll(afterAllFunction: SpecFunction): void; 393 | results(): NestedResults; 394 | add(suiteOrSpec: SuiteOrSpec): void; 395 | specs(): Spec[]; 396 | suites(): Suite[]; 397 | children(): any[]; 398 | execute(onComplete?: () => void): void; 399 | } 400 | 401 | interface XSuite { 402 | execute(): void; 403 | } 404 | 405 | interface Spy { 406 | (...params: any[]): any; 407 | 408 | identity: string; 409 | and: SpyAnd; 410 | calls: Calls; 411 | mostRecentCall: { args: any[]; }; 412 | argsForCall: any[]; 413 | wasCalled: boolean; 414 | } 415 | 416 | interface SpyAnd { 417 | /** By chaining the spy with and.callThrough, the spy will still track all calls to it but in addition it will delegate to the actual implementation. */ 418 | callThrough(): Spy; 419 | /** By chaining the spy with and.returnValue, all calls to the function will return a specific value. */ 420 | returnValue(val: any): Spy; 421 | /** By chaining the spy with and.callFake, all calls to the spy will delegate to the supplied function. */ 422 | callFake(fn: Function): Spy; 423 | /** By chaining the spy with and.throwError, all calls to the spy will throw the specified value. */ 424 | throwError(msg: string): Spy; 425 | /** When a calling strategy is used for a spy, the original stubbing behavior can be returned at any time with and.stub. */ 426 | stub(): Spy; 427 | } 428 | 429 | interface Calls { 430 | /** By chaining the spy with calls.any(), will return false if the spy has not been called at all, and then true once at least one call happens. **/ 431 | any(): boolean; 432 | /** By chaining the spy with calls.count(), will return the number of times the spy was called **/ 433 | count(): number; 434 | /** By chaining the spy with calls.argsFor(), will return the arguments passed to call number index **/ 435 | argsFor(index: number): any[]; 436 | /** By chaining the spy with calls.allArgs(), will return the arguments to all calls **/ 437 | allArgs(): any[]; 438 | /** By chaining the spy with calls.all(), will return the context (the this) and arguments passed all calls **/ 439 | all(): CallInfo[]; 440 | /** By chaining the spy with calls.mostRecent(), will return the context (the this) and arguments for the most recent call **/ 441 | mostRecent(): CallInfo; 442 | /** By chaining the spy with calls.first(), will return the context (the this) and arguments for the first call **/ 443 | first(): CallInfo; 444 | /** By chaining the spy with calls.reset(), will clears all tracking for a spy **/ 445 | reset(): void; 446 | } 447 | 448 | interface CallInfo { 449 | /** The context (the this) for the call */ 450 | object: any; 451 | /** All arguments passed to the call */ 452 | args: any[]; 453 | } 454 | 455 | interface Util { 456 | inherit(childClass: Function, parentClass: Function): any; 457 | formatException(e: any): any; 458 | htmlEscape(str: string): string; 459 | argsToArray(args: any): any; 460 | extend(destination: any, source: any): any; 461 | } 462 | 463 | interface JsApiReporter extends Reporter { 464 | 465 | started: boolean; 466 | finished: boolean; 467 | result: any; 468 | messages: any; 469 | 470 | new (): any; 471 | 472 | suites(): Suite[]; 473 | summarize_(suiteOrSpec: SuiteOrSpec): any; 474 | results(): any; 475 | resultsForSpec(specId: any): any; 476 | log(str: any): any; 477 | resultsForSpecs(specIds: any): any; 478 | summarizeResult_(result: any): any; 479 | } 480 | 481 | interface Jasmine { 482 | Spec: Spec; 483 | clock: Clock; 484 | util: Util; 485 | } 486 | 487 | export var HtmlReporter: HtmlReporter; 488 | export var HtmlSpecFilter: HtmlSpecFilter; 489 | export var DEFAULT_TIMEOUT_INTERVAL: number; 490 | } 491 | -------------------------------------------------------------------------------- /typings/globals/jasmine/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "resolution": "main", 3 | "tree": { 4 | "src": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/dd638012d63e069f2c99d06ef4dcc9616a943ee4/jasmine/jasmine.d.ts", 5 | "raw": "github:DefinitelyTyped/DefinitelyTyped/jasmine/jasmine.d.ts#dd638012d63e069f2c99d06ef4dcc9616a943ee4", 6 | "typings": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/dd638012d63e069f2c99d06ef4dcc9616a943ee4/jasmine/jasmine.d.ts" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /typings/globals/zone.js/index.d.ts: -------------------------------------------------------------------------------- 1 | // Generated by typings 2 | // Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/9027703c0bd831319dcdf7f3169f7a468537f448/zone.js/zone.js.d.ts 3 | declare class Zone { 4 | constructor(parentZone: Zone, data: any); 5 | 6 | fork(locals?: {[key: string]: any}): Zone; 7 | bind(fn: Function, skipEnqueue?: boolean): void; 8 | bindOnce(fn: Function): any; 9 | run(fn: Function, applyTo?: any, applyWith?: any): void; 10 | isRootZone(): boolean; 11 | 12 | static bindPromiseFn Promise>(fn: T): T; 13 | 14 | static longStackTraceZone: {[key: string]: any}; 15 | } 16 | -------------------------------------------------------------------------------- /typings/globals/zone.js/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "resolution": "main", 3 | "tree": { 4 | "src": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/9027703c0bd831319dcdf7f3169f7a468537f448/zone.js/zone.js.d.ts", 5 | "raw": "github:DefinitelyTyped/DefinitelyTyped/zone.js/zone.js.d.ts#9027703c0bd831319dcdf7f3169f7a468537f448", 6 | "typings": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/9027703c0bd831319dcdf7f3169f7a468537f448/zone.js/zone.js.d.ts" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /typings/index.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | /// 4 | --------------------------------------------------------------------------------