├── .gitignore ├── .gitattributes ├── dist ├── img │ └── new_relic_logo.png ├── module.d.ts ├── module.js.map ├── module.ts ├── datasource │ ├── img │ │ └── new_relic_logo.png │ ├── module.js.map │ ├── config_ctrl.d.ts │ ├── module.d.ts │ ├── module.ts │ ├── plugin.json │ ├── partials │ │ ├── config.html │ │ ├── query.options.html │ │ └── query.editor.html │ ├── query_ctrl.d.ts │ ├── datasource.d.ts │ ├── config_ctrl.ts │ ├── module.js │ ├── config_ctrl.js.map │ ├── config_ctrl.js │ ├── query_ctrl.ts │ ├── query_ctrl.js.map │ ├── query_ctrl.js │ ├── datasource.ts │ ├── datasource.js.map │ └── datasource.js ├── module.js ├── typings │ ├── tsd.d.ts │ └── es6-shim │ │ └── es6-shim.d.ts ├── config │ ├── config.d.ts │ ├── config.html │ ├── config.ts │ ├── config.js.map │ └── config.js ├── plugin.json └── README.md ├── src ├── img │ └── new_relic_logo.png ├── module.ts ├── datasource │ ├── img │ │ └── new_relic_logo.png │ ├── module.ts │ ├── plugin.json │ ├── partials │ │ ├── config.html │ │ ├── query.options.html │ │ └── query.editor.html │ ├── config_ctrl.ts │ ├── query_ctrl.ts │ └── datasource.ts ├── typings │ ├── tsd.d.ts │ └── es6-shim │ │ └── es6-shim.d.ts ├── plugin.json └── config │ ├── config.html │ └── config.ts ├── tsd.json ├── tsconfig.json ├── LICENSE.txt ├── package.json ├── Gruntfile.js └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Don't diff files in dist/ 2 | *.map binary 3 | dist/** binary 4 | -------------------------------------------------------------------------------- /dist/img/new_relic_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wevanscfi/grafana-newrelic-apm-datasource/HEAD/dist/img/new_relic_logo.png -------------------------------------------------------------------------------- /dist/module.d.ts: -------------------------------------------------------------------------------- 1 | import { NewRelicAppConfigCtrl } from './config/config'; 2 | export { NewRelicAppConfigCtrl as ConfigCtrl }; 3 | -------------------------------------------------------------------------------- /src/img/new_relic_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wevanscfi/grafana-newrelic-apm-datasource/HEAD/src/img/new_relic_logo.png -------------------------------------------------------------------------------- /dist/module.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"module.js","sourceRoot":"","sources":["module.ts"],"names":[],"mappings":";;;;;;;;YAG2B,uDAAU"} -------------------------------------------------------------------------------- /dist/module.ts: -------------------------------------------------------------------------------- 1 | import {NewRelicAppConfigCtrl} from './config/config'; 2 | 3 | export { 4 | NewRelicAppConfigCtrl as ConfigCtrl 5 | }; 6 | -------------------------------------------------------------------------------- /src/module.ts: -------------------------------------------------------------------------------- 1 | import {NewRelicAppConfigCtrl} from './config/config'; 2 | 3 | export { 4 | NewRelicAppConfigCtrl as ConfigCtrl 5 | }; 6 | -------------------------------------------------------------------------------- /dist/datasource/img/new_relic_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wevanscfi/grafana-newrelic-apm-datasource/HEAD/dist/datasource/img/new_relic_logo.png -------------------------------------------------------------------------------- /src/datasource/img/new_relic_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wevanscfi/grafana-newrelic-apm-datasource/HEAD/src/datasource/img/new_relic_logo.png -------------------------------------------------------------------------------- /tsd.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "v4", 3 | "repo": "borisyankov/DefinitelyTyped", 4 | "ref": "master", 5 | "path": "typings", 6 | "bundle": "typings/tsd.d.ts", 7 | "installed": { 8 | "es6-shim/es6-shim.d.ts": { 9 | "commit": "edb64e4a35896510ce02b93c0bca5ec3878db738" 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /dist/datasource/module.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"module.js","sourceRoot":"","sources":["module.ts"],"names":["NewRelicQueryOptionsCtrl","NewRelicQueryOptionsCtrl.constructor"],"mappings":";;;;;;;;;;;;;;;YAIA;gBAAAA;gBAEAC,CAACA;gBADQD,oCAAWA,GAAGA,wCAAwCA,CAACA;gBAChEA,+BAACA;YAADA,CAACA,AAFD,IAEC;YAGuB,wDAAU;YACX,sDAAS;YACF,uDAAgB;YACpB,2DAAU"} -------------------------------------------------------------------------------- /dist/module.js: -------------------------------------------------------------------------------- 1 | System.register(['./config/config'], function(exports_1) { 2 | var config_1; 3 | return { 4 | setters:[ 5 | function (config_1_1) { 6 | config_1 = config_1_1; 7 | }], 8 | execute: function() { 9 | exports_1("ConfigCtrl", config_1.NewRelicAppConfigCtrl); 10 | } 11 | } 12 | }); 13 | //# sourceMappingURL=module.js.map -------------------------------------------------------------------------------- /dist/datasource/config_ctrl.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | export declare class NewRelicDSConfigCtrl { 3 | private backendSrv; 4 | static templateUrl: string; 5 | name: string; 6 | current: any; 7 | types: any; 8 | apps: any[]; 9 | constructor($scope: any, $injector: any, backendSrv: any); 10 | getApplications(): any; 11 | loadApplications(): void; 12 | } 13 | -------------------------------------------------------------------------------- /dist/datasource/module.d.ts: -------------------------------------------------------------------------------- 1 | import { NewRelicDSConfigCtrl } from './config_ctrl'; 2 | import { NewRelicDatasource } from './datasource'; 3 | import { NewRelicQueryCtrl } from './query_ctrl'; 4 | declare class NewRelicQueryOptionsCtrl { 5 | static templateUrl: string; 6 | } 7 | export { NewRelicDatasource as Datasource, NewRelicQueryCtrl as QueryCtrl, NewRelicQueryOptionsCtrl as QueryOptionsCtrl, NewRelicDSConfigCtrl as ConfigCtrl }; 8 | -------------------------------------------------------------------------------- /src/typings/tsd.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | declare module 'moment' { 3 | var moment: any; 4 | export default moment; 5 | } 6 | 7 | declare module 'app/plugins/sdk' { 8 | class QueryCtrl { 9 | target: any; 10 | constructor($scope: any, $injector: any) 11 | } 12 | 13 | export { 14 | QueryCtrl, 15 | }; 16 | } 17 | 18 | declare module 'lodash' { 19 | var lodash: any; 20 | export default lodash; 21 | } 22 | -------------------------------------------------------------------------------- /dist/typings/tsd.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | declare module 'moment' { 3 | var moment: any; 4 | export default moment; 5 | } 6 | 7 | declare module 'app/plugins/sdk' { 8 | class QueryCtrl { 9 | target: any; 10 | constructor($scope: any, $injector: any) 11 | } 12 | 13 | export { 14 | QueryCtrl, 15 | }; 16 | } 17 | 18 | declare module 'lodash' { 19 | var lodash: any; 20 | export default lodash; 21 | } 22 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "sourceMap": true, 4 | "declaration": true, 5 | "outDir": "dist/", 6 | "noImplicitAny": false, 7 | "target": "es5", 8 | "sourceRoot": "src/", 9 | "module": "system", 10 | "noEmitOnError": true, 11 | "emitDecoratorMetadata": true, 12 | "experimentalDecorators": true 13 | }, 14 | "files": [ 15 | "src/**/*.ts" 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /dist/config/config.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | export declare class NewRelicAppConfigCtrl { 3 | private backendSrv; 4 | appModel: any; 5 | appEditCtrl: any; 6 | jsonData: any; 7 | apiValidated: boolean; 8 | apiError: boolean; 9 | constructor($scope: any, $injector: any, backendSrv: any); 10 | preUpdate(): Promise; 11 | reset(): void; 12 | validateApiConnection(): any; 13 | static templateUrl: string; 14 | } 15 | -------------------------------------------------------------------------------- /src/datasource/module.ts: -------------------------------------------------------------------------------- 1 | import {NewRelicDSConfigCtrl} from './config_ctrl'; 2 | import {NewRelicDatasource} from './datasource'; 3 | import {NewRelicQueryCtrl} from './query_ctrl'; 4 | 5 | class NewRelicQueryOptionsCtrl { 6 | static templateUrl = 'datasource/partials/query.options.html'; 7 | } 8 | 9 | export { 10 | NewRelicDatasource as Datasource, 11 | NewRelicQueryCtrl as QueryCtrl, 12 | NewRelicQueryOptionsCtrl as QueryOptionsCtrl, 13 | NewRelicDSConfigCtrl as ConfigCtrl 14 | }; 15 | -------------------------------------------------------------------------------- /dist/datasource/module.ts: -------------------------------------------------------------------------------- 1 | import {NewRelicDSConfigCtrl} from './config_ctrl'; 2 | import {NewRelicDatasource} from './datasource'; 3 | import {NewRelicQueryCtrl} from './query_ctrl'; 4 | 5 | class NewRelicQueryOptionsCtrl { 6 | static templateUrl = 'datasource/partials/query.options.html'; 7 | } 8 | 9 | export { 10 | NewRelicDatasource as Datasource, 11 | NewRelicQueryCtrl as QueryCtrl, 12 | NewRelicQueryOptionsCtrl as QueryOptionsCtrl, 13 | NewRelicDSConfigCtrl as ConfigCtrl 14 | }; 15 | -------------------------------------------------------------------------------- /dist/datasource/plugin.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "NewRelic Data Source", 3 | "type": "datasource", 4 | "id": "newrelic-ds", 5 | 6 | "metrics": true, 7 | "annotations": false, 8 | 9 | "info": { 10 | "author": { 11 | "name": "Paul", 12 | "url": "https://callrail.com" 13 | }, 14 | "logos": { 15 | "small": "img/new_relic_logo.png", 16 | "large": "img/new_relic_logo.png" 17 | }, 18 | "dependencies": { 19 | "grafanaVersion": "^3.0.1", 20 | "plugins": [ ] 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/datasource/plugin.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "NewRelic Data Source", 3 | "type": "datasource", 4 | "id": "newrelic-ds", 5 | 6 | "metrics": true, 7 | "annotations": false, 8 | 9 | "info": { 10 | "author": { 11 | "name": "Paul", 12 | "url": "https://callrail.com" 13 | }, 14 | "logos": { 15 | "small": "img/new_relic_logo.png", 16 | "large": "img/new_relic_logo.png" 17 | }, 18 | "dependencies": { 19 | "grafanaVersion": "^3.0.1", 20 | "plugins": [ ] 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /dist/datasource/partials/config.html: -------------------------------------------------------------------------------- 1 |

NewRelic API Credentials

2 | 3 |
4 |
5 | 11 | 15 |
16 |
17 | -------------------------------------------------------------------------------- /src/datasource/partials/config.html: -------------------------------------------------------------------------------- 1 |

NewRelic API Credentials

2 | 3 |
4 |
5 | 11 | 15 |
16 |
17 | -------------------------------------------------------------------------------- /dist/datasource/query_ctrl.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | import { QueryCtrl } from 'app/plugins/sdk'; 3 | declare class NewRelicQueryCtrl extends QueryCtrl { 4 | static templateUrl: string; 5 | refresh: any; 6 | metric_types: any; 7 | datasource: any; 8 | type: any; 9 | metrics: any[]; 10 | apps: any[]; 11 | /** @ngInject **/ 12 | constructor($scope: any, $injector: any); 13 | getMetrics(): any; 14 | getMetricNamespaces(): any; 15 | getMetricValues(): any; 16 | getApplications(): any; 17 | reset(): void; 18 | onChangeInternal(): void; 19 | } 20 | export { NewRelicQueryCtrl }; 21 | -------------------------------------------------------------------------------- /src/plugin.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "NewRelic App", 3 | "type": "app", 4 | "id": "newrelic-app", 5 | 6 | "routes": [ 7 | { 8 | "path": "v2/*", 9 | "method": "*", 10 | "url": "https://api.newrelic.com/v2", 11 | "headers": [ 12 | {"name": "X-Api-Key", "content": "{{.SecureJsonData.apiKey}}"} 13 | ] 14 | } 15 | ], 16 | 17 | "info": { 18 | "author": { 19 | "name": "Paul", 20 | "url": "https://callrail.com" 21 | }, 22 | "logos": { 23 | "small": "img/new_relic_logo.png", 24 | "large": "img/new_relic_logo.png" 25 | }, 26 | "dependencies": { 27 | "grafanaVersion": "^3.0.1", 28 | "plugins": [ ] 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /dist/plugin.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "NewRelic App", 3 | "type": "app", 4 | "id": "newrelic-app", 5 | 6 | "routes": [ 7 | { 8 | "path": "v2/*", 9 | "method": "*", 10 | "url": "https://api.newrelic.com/v2", 11 | "headers": [ 12 | {"name": "X-Api-Key", "content": "{{.SecureJsonData.apiKey}}"} 13 | ] 14 | } 15 | ], 16 | 17 | "info": { 18 | "author": { 19 | "name": "Paul", 20 | "url": "https://callrail.com" 21 | }, 22 | "logos": { 23 | "small": "img/new_relic_logo.png", 24 | "large": "img/new_relic_logo.png" 25 | }, 26 | "dependencies": { 27 | "grafanaVersion": "^3.0.1", 28 | "plugins": [ ] 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/datasource/partials/query.options.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |
5 | 6 | Group by time interval 7 | 9 | 10 |
11 |
12 |
13 |
14 | -------------------------------------------------------------------------------- /dist/datasource/partials/query.options.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |
5 | 6 | Group by time interval 7 | 9 | 10 |
11 |
12 |
13 |
14 | -------------------------------------------------------------------------------- /dist/datasource/datasource.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | declare class NewRelicDatasource { 3 | private $q; 4 | private backendSrv; 5 | private templateSrv; 6 | name: string; 7 | appId: any; 8 | baseApiUrl: string; 9 | /** @ngInject */ 10 | constructor(instanceSettings: any, $q: any, backendSrv: any, templateSrv: any); 11 | query(options: any): Promise<{}>; 12 | testDatasource(): any; 13 | _convertToSeconds(interval: any): number; 14 | _parseMetricResults(results: any): any[]; 15 | _parseseacrhTarget(metric: any): any[]; 16 | _getTargetSeries(target: any, metric: any): any[]; 17 | _parseTargetAlias(metric: any, value: any): any; 18 | makeMultipleRequests(requests: any): Promise<{}>; 19 | getMetricNames(application_id: any): any; 20 | getApplications(): any; 21 | makeApiRequest(request: any): any; 22 | } 23 | export { NewRelicDatasource }; 24 | -------------------------------------------------------------------------------- /dist/datasource/config_ctrl.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | export class NewRelicDSConfigCtrl { 4 | static templateUrl = 'datasource/partials/config.html'; 5 | name: string; 6 | current: any; 7 | types: any; 8 | apps: any[]; 9 | 10 | constructor($scope, $injector, private backendSrv) { 11 | this.backendSrv = backendSrv; 12 | this.loadApplications(); 13 | } 14 | 15 | getApplications() { 16 | var promise = this.backendSrv.get('api/plugin-proxy/newrelic-app/v2/applications.json'); 17 | return promise.then(result => { 18 | if (result && result.applications) { 19 | return result.applications; 20 | } else { 21 | return []; 22 | } 23 | }); 24 | } 25 | 26 | loadApplications() { 27 | this.getApplications().then(apps => { 28 | apps = apps.map(app => { 29 | return { name: app.name, id: app.id.toString() }; 30 | }); 31 | this.apps = apps; 32 | }); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/datasource/config_ctrl.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | export class NewRelicDSConfigCtrl { 4 | static templateUrl = 'datasource/partials/config.html'; 5 | name: string; 6 | current: any; 7 | types: any; 8 | apps: any[]; 9 | 10 | constructor($scope, $injector, private backendSrv) { 11 | this.backendSrv = backendSrv; 12 | this.loadApplications(); 13 | } 14 | 15 | getApplications() { 16 | var promise = this.backendSrv.get('api/plugin-proxy/newrelic-app/v2/applications.json'); 17 | return promise.then(result => { 18 | if (result && result.applications) { 19 | return result.applications; 20 | } else { 21 | return []; 22 | } 23 | }); 24 | } 25 | 26 | loadApplications() { 27 | this.getApplications().then(apps => { 28 | apps = apps.map(app => { 29 | return { name: app.name, id: app.id.toString() }; 30 | }); 31 | this.apps = apps; 32 | }); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 William Paul Evans 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /dist/config/config.html: -------------------------------------------------------------------------------- 1 |

New Relic API Credentials

2 | 3 |
4 |
5 |
6 | 7 | 8 | The API key generated for authorization in the APM dashboard. 9 | 10 | 11 | 12 | 13 |
14 |
15 | 16 |
17 | 18 |
19 |
20 |
21 | reset 22 |
23 |
24 |
-------------------------------------------------------------------------------- /src/config/config.html: -------------------------------------------------------------------------------- 1 |

New Relic API Credentials

2 | 3 |
4 |
5 |
6 | 7 | 8 | The API key generated for authorization in the APM dashboard. 9 | 10 | 11 | 12 | 13 |
14 |
15 | 16 |
17 | 18 |
19 |
20 |
21 | reset 22 |
23 |
24 |
-------------------------------------------------------------------------------- /dist/datasource/module.js: -------------------------------------------------------------------------------- 1 | System.register(['./config_ctrl', './datasource', './query_ctrl'], function(exports_1) { 2 | var config_ctrl_1, datasource_1, query_ctrl_1; 3 | var NewRelicQueryOptionsCtrl; 4 | return { 5 | setters:[ 6 | function (config_ctrl_1_1) { 7 | config_ctrl_1 = config_ctrl_1_1; 8 | }, 9 | function (datasource_1_1) { 10 | datasource_1 = datasource_1_1; 11 | }, 12 | function (query_ctrl_1_1) { 13 | query_ctrl_1 = query_ctrl_1_1; 14 | }], 15 | execute: function() { 16 | NewRelicQueryOptionsCtrl = (function () { 17 | function NewRelicQueryOptionsCtrl() { 18 | } 19 | NewRelicQueryOptionsCtrl.templateUrl = 'datasource/partials/query.options.html'; 20 | return NewRelicQueryOptionsCtrl; 21 | })(); 22 | exports_1("Datasource", datasource_1.NewRelicDatasource); 23 | exports_1("QueryCtrl", query_ctrl_1.NewRelicQueryCtrl); 24 | exports_1("QueryOptionsCtrl", NewRelicQueryOptionsCtrl); 25 | exports_1("ConfigCtrl", config_ctrl_1.NewRelicDSConfigCtrl); 26 | } 27 | } 28 | }); 29 | //# sourceMappingURL=module.js.map -------------------------------------------------------------------------------- /dist/datasource/config_ctrl.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"config_ctrl.js","sourceRoot":"","sources":["config_ctrl.ts"],"names":["NewRelicDSConfigCtrl","NewRelicDSConfigCtrl.constructor","NewRelicDSConfigCtrl.getApplications","NewRelicDSConfigCtrl.loadApplications"],"mappings":"AAAA,2CAA2C;;;;;;YAE3C;gBAOEA,8BAAYA,MAAMA,EAAEA,SAASA,EAAUA,UAAUA;oBAAVC,eAAUA,GAAVA,UAAUA,CAAAA;oBAC/CA,IAAIA,CAACA,UAAUA,GAAGA,UAAUA,CAACA;oBAC7BA,IAAIA,CAACA,gBAAgBA,EAAEA,CAACA;gBAC1BA,CAACA;gBAEDD,8CAAeA,GAAfA;oBACEE,IAAIA,OAAOA,GAAGA,IAAIA,CAACA,UAAUA,CAACA,GAAGA,CAACA,oDAAoDA,CAACA,CAACA;oBACxFA,MAAMA,CAACA,OAAOA,CAACA,IAAIA,CAACA,UAAAA,MAAMA;wBACxBA,EAAEA,CAACA,CAACA,MAAMA,IAAIA,MAAMA,CAACA,YAAYA,CAACA,CAACA,CAACA;4BAClCA,MAAMA,CAACA,MAAMA,CAACA,YAAYA,CAACA;wBAC7BA,CAACA;wBAACA,IAAIA,CAACA,CAACA;4BACNA,MAAMA,CAACA,EAAEA,CAACA;wBACZA,CAACA;oBACHA,CAACA,CAACA,CAACA;gBACLA,CAACA;gBAEDF,+CAAgBA,GAAhBA;oBAAAG,iBAOCA;oBANCA,IAAIA,CAACA,eAAeA,EAAEA,CAACA,IAAIA,CAACA,UAAAA,IAAIA;wBAC9BA,IAAIA,GAAGA,IAAIA,CAACA,GAAGA,CAACA,UAAAA,GAAGA;4BACjBA,MAAMA,CAACA,EAAEA,IAAIA,EAAEA,GAAGA,CAACA,IAAIA,EAAEA,EAAEA,EAAEA,GAAGA,CAACA,EAAEA,CAACA,QAAQA,EAAEA,EAAEA,CAACA;wBACnDA,CAACA,CAACA,CAACA;wBACHA,KAAIA,CAACA,IAAIA,GAAGA,IAAIA,CAACA;oBACnBA,CAACA,CAACA,CAACA;gBACLA,CAACA;gBA7BMH,gCAAWA,GAAGA,iCAAiCA,CAACA;gBA+BzDA,2BAACA;YAADA,CAACA,AAhCD,IAgCC;YAhCD,uDAgCC,CAAA"} -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "newrelic-apm-datasource", 3 | "version": "1.0.0", 4 | "description": "Datasource for interacting with the NewRelic APM and Server API", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "git+ssh://git@github.com/wevanscfi/grafana-newrelic-apm-datasource.git" 12 | }, 13 | "author": "wevanscfi", 14 | "license": "MIT", 15 | "bugs": { 16 | "url": "https://github.com/wevanscfi/grafana-newrelic-apm-datasource/issues" 17 | }, 18 | "homepage": "https://github.com/wevanscfi/grafana-newrelic-apm-datasource#readme", 19 | "devDependencies": { 20 | "babel": "~6.5.1", 21 | "babel-plugin-transform-es2015-modules-systemjs": "^6.5.0", 22 | "babel-preset-es2015": "^6.5.0", 23 | "grunt": "~0.4.5", 24 | "grunt-contrib-clean": "~0.6.0", 25 | "grunt-contrib-copy": "~0.8.2", 26 | "grunt-contrib-uglify": "~0.11.0", 27 | "grunt-contrib-watch": "^0.6.1", 28 | "grunt-execute": "~0.2.2", 29 | "grunt-systemjs-builder": "^0.2.5", 30 | "grunt-typescript": "^0.8.0", 31 | "load-grunt-tasks": "~3.2.0" 32 | }, 33 | "dependencies": { 34 | "angular": "^1.5.6", 35 | "lodash": "^4.13.1", 36 | "moment": "^2.13.0" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Gruntfile.js: -------------------------------------------------------------------------------- 1 | module.exports = function(grunt) { 2 | 3 | require('load-grunt-tasks')(grunt); 4 | 5 | grunt.loadNpmTasks('grunt-execute'); 6 | grunt.loadNpmTasks('grunt-contrib-clean'); 7 | grunt.loadNpmTasks('grunt-typescript'); 8 | 9 | grunt.initConfig({ 10 | 11 | clean: ["dist"], 12 | 13 | copy: { 14 | src_to_dist: { 15 | cwd: 'src', 16 | expand: true, 17 | src: ['**/*', '!**/*.js', '!**/*.scss'], 18 | dest: 'dist' 19 | }, 20 | pluginDef: { 21 | expand: true, 22 | src: [ 'plugin.json', 'README.md' ], 23 | dest: 'dist', 24 | } 25 | }, 26 | 27 | watch: { 28 | rebuild_all: { 29 | files: ['src/**/*', 'plugin.json'], 30 | tasks: ['default'], 31 | options: {spawn: false} 32 | }, 33 | }, 34 | 35 | typescript: { 36 | base: { 37 | src: ['dist/**/*.ts'], 38 | dest: 'dist/', 39 | options: { 40 | module: 'system', //or commonjs 41 | target: 'es5', //or es3 42 | sourceMap: true, 43 | declaration: true, 44 | emitDecoratorMetadata: true, 45 | experimentalDecorators: true, 46 | noImplicitAny: false, 47 | } 48 | } 49 | }, 50 | 51 | }); 52 | 53 | grunt.registerTask('default', ['clean', 'copy:src_to_dist', 'copy:pluginDef', 'typescript']); 54 | }; 55 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # New Relic APM Datasource - Custom Plugin 2 | This is a simple datasource for use with the New Relic APM API. 3 | 4 | ## Major Update Notice 5 | This datasource plugin has been converted to a full app plugin to allow for more secure handling of 6 | new relic API keys. If you have previously used the old datasource plugin version, you will need to 7 | configure this application with your api key, and then create a new datasource. 8 | 9 | ## Supported Version Information 10 | This datasource has been tested with 4.2 stable. 11 | 12 | ## To install and use 13 | 14 | 1. Add the contents of this repository to your grafana plugins directory (default /var/lib/grafana/plugins) and then restart the grafana server. 15 | 16 | 2. Create a new app and configure it with your API key 17 | 18 | 2. Create a new datasource and select NewRelic from the drop down. 19 | 20 | 3. Create a new panel and set the datasource to NewRelic. Metrics take a namespace and optional value configuration. The namespaces must be exact match of the metric name, which can be found for your application [here](https://rpm.newrelic.com/api/explore/applications/metric_names) 21 | 22 | This datasource supports aliases and altering the group by interval. 23 | ![Alias](http://i.imgur.com/sV0bEoA.png) 24 | 25 | If you leave the value field blank, you will get a separate group for each value of the metric. You can access the value as $value in the alias. 26 | 27 | -------------------------------------------------------------------------------- /dist/README.md: -------------------------------------------------------------------------------- 1 | # New Relic APM Datasource - Custom Plugin 2 | This is a simple datasource for use with the New Relic APM API. 3 | 4 | ## Major Update Notice 5 | This datasource plugin has been converted to a full app plugin to allow for more secure handling of 6 | new relic API keys. If you have previously used the old datasource plugin version, you will need to 7 | configure this application with your api key, and then create a new datasource. 8 | 9 | ## Supported Version Information 10 | This datasource has been tested with 4.2 stable. 11 | 12 | ## To install and use 13 | 14 | 1. Add the contents of this repository to your grafana plugins directory (default /var/lib/grafana/plugins) and then restart the grafana server. 15 | 16 | 2. Create a new app and configure it with your API key 17 | 18 | 2. Create a new datasource and select NewRelic from the drop down. 19 | 20 | 3. Create a new panel and set the datasource to NewRelic. Metrics take a namespace and optional value configuration. The namespaces must be exact match of the metric name, which can be found for your application [here](https://rpm.newrelic.com/api/explore/applications/metric_names) 21 | 22 | This datasource supports aliases and altering the group by interval. 23 | ![Alias](http://i.imgur.com/sV0bEoA.png) 24 | 25 | If you leave the value field blank, you will get a separate group for each value of the metric. You can access the value as $value in the alias. 26 | 27 | -------------------------------------------------------------------------------- /dist/config/config.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | export class NewRelicAppConfigCtrl { 4 | appModel: any; 5 | appEditCtrl: any; 6 | jsonData: any; 7 | apiValidated: boolean; 8 | apiError: boolean; 9 | 10 | constructor($scope, $injector, private backendSrv) { 11 | this.backendSrv = backendSrv; 12 | console.log(this); 13 | 14 | this.appEditCtrl.setPreUpdateHook(this.preUpdate.bind(this)); 15 | 16 | if (!this.appModel.jsonData) { 17 | this.appModel.jsonData = {}; 18 | } 19 | if (!this.appModel.secureJsonData) { 20 | this.appModel.secureJsonData = {}; 21 | } 22 | 23 | if (this.appModel.enabled && this.appModel.jsonData.tokenSet) { 24 | this.validateApiConnection(); 25 | } 26 | } 27 | 28 | preUpdate() { 29 | if (this.appModel.secureJsonData.apiKey) { 30 | this.appModel.jsonData.tokenSet = true; 31 | } 32 | return Promise.resolve(); 33 | } 34 | 35 | reset() { 36 | this.appModel.jsonData.tokenSet = false; 37 | this.appModel.secureJsonData = {}; 38 | this.apiValidated = false; 39 | } 40 | 41 | validateApiConnection() { 42 | var promise = this.backendSrv.get('/api/plugin-proxy/newrelic-app/v2/applications.json'); 43 | promise.then(() => { 44 | this.apiValidated = true; 45 | }, () => { 46 | this.apiValidated = false; 47 | this.apiError = true; 48 | }); 49 | return promise; 50 | } 51 | 52 | static templateUrl = 'config/config.html'; 53 | } 54 | -------------------------------------------------------------------------------- /src/config/config.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | export class NewRelicAppConfigCtrl { 4 | appModel: any; 5 | appEditCtrl: any; 6 | jsonData: any; 7 | apiValidated: boolean; 8 | apiError: boolean; 9 | 10 | constructor($scope, $injector, private backendSrv) { 11 | this.backendSrv = backendSrv; 12 | console.log(this); 13 | 14 | this.appEditCtrl.setPreUpdateHook(this.preUpdate.bind(this)); 15 | 16 | if (!this.appModel.jsonData) { 17 | this.appModel.jsonData = {}; 18 | } 19 | if (!this.appModel.secureJsonData) { 20 | this.appModel.secureJsonData = {}; 21 | } 22 | 23 | if (this.appModel.enabled && this.appModel.jsonData.tokenSet) { 24 | this.validateApiConnection(); 25 | } 26 | } 27 | 28 | preUpdate() { 29 | if (this.appModel.secureJsonData.apiKey) { 30 | this.appModel.jsonData.tokenSet = true; 31 | } 32 | return Promise.resolve(); 33 | } 34 | 35 | reset() { 36 | this.appModel.jsonData.tokenSet = false; 37 | this.appModel.secureJsonData = {}; 38 | this.apiValidated = false; 39 | } 40 | 41 | validateApiConnection() { 42 | var promise = this.backendSrv.get('/api/plugin-proxy/newrelic-app/v2/applications.json'); 43 | promise.then(() => { 44 | this.apiValidated = true; 45 | }, () => { 46 | this.apiValidated = false; 47 | this.apiError = true; 48 | }); 49 | return promise; 50 | } 51 | 52 | static templateUrl = 'config/config.html'; 53 | } 54 | -------------------------------------------------------------------------------- /dist/datasource/config_ctrl.js: -------------------------------------------------------------------------------- 1 | /// 2 | System.register([], function(exports_1) { 3 | var NewRelicDSConfigCtrl; 4 | return { 5 | setters:[], 6 | execute: function() { 7 | NewRelicDSConfigCtrl = (function () { 8 | function NewRelicDSConfigCtrl($scope, $injector, backendSrv) { 9 | this.backendSrv = backendSrv; 10 | this.backendSrv = backendSrv; 11 | this.loadApplications(); 12 | } 13 | NewRelicDSConfigCtrl.prototype.getApplications = function () { 14 | var promise = this.backendSrv.get('api/plugin-proxy/newrelic-app/v2/applications.json'); 15 | return promise.then(function (result) { 16 | if (result && result.applications) { 17 | return result.applications; 18 | } 19 | else { 20 | return []; 21 | } 22 | }); 23 | }; 24 | NewRelicDSConfigCtrl.prototype.loadApplications = function () { 25 | var _this = this; 26 | this.getApplications().then(function (apps) { 27 | apps = apps.map(function (app) { 28 | return { name: app.name, id: app.id.toString() }; 29 | }); 30 | _this.apps = apps; 31 | }); 32 | }; 33 | NewRelicDSConfigCtrl.templateUrl = 'datasource/partials/config.html'; 34 | return NewRelicDSConfigCtrl; 35 | })(); 36 | exports_1("NewRelicDSConfigCtrl", NewRelicDSConfigCtrl); 37 | } 38 | } 39 | }); 40 | //# sourceMappingURL=config_ctrl.js.map -------------------------------------------------------------------------------- /dist/config/config.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"config.js","sourceRoot":"","sources":["config.ts"],"names":["NewRelicAppConfigCtrl","NewRelicAppConfigCtrl.constructor","NewRelicAppConfigCtrl.preUpdate","NewRelicAppConfigCtrl.reset","NewRelicAppConfigCtrl.validateApiConnection"],"m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GA,KAAKA,CAACA;oBACxCA,IAAIA,CAACA,QAAQA,CAACA,cAAcA,GAAGA,EAAEA,CAACA;oBAClCA,IAAIA,CAACA,YAAYA,GAAGA,KAAKA,CAACA;gBAC5BA,CAACA;gBAEDH,qDAAqBA,GAArBA;oBAAAI,iBASCA;oBARCA,IAAIA,OAAOA,GAAGA,IAAIA,CAACA,UAAUA,CAACA,GAAGA,CAACA,qDAAqDA,CAACA,CAACA;oBACzFA,OAAOA,CAACA,IAAIA,CAACA;wBACXA,KAAIA,CAACA,YAAYA,GAAGA,IAAIA,CAACA;oBAC3BA,CAACA,EAAEA;wBACDA,KAAIA,CAACA,YAAYA,GAAGA,KAAKA,CAACA;wBAC1BA,KAAIA,CAACA,QAAQA,GAAGA,IAAIA,CAACA;oBACvBA,CAACA,CAACA,CAACA;oBACHA,MAAMA,CAACA,OAAOA,CAACA;gBACjBA,CAACA;gBAEMJ,iCAAWA,GAAGA,oBAAoBA,CAACA;gBAC5CA,4BAACA;YAADA,CAACA,AAlDD,IAkDC;YAlDD,yDAkDC,CAAA"} -------------------------------------------------------------------------------- /dist/datasource/partials/query.editor.html: -------------------------------------------------------------------------------- 1 | 2 |
3 |
4 | 8 | 9 | 10 | 11 | 12 | 16 | 21 |
22 |
23 | 24 |
25 |
26 | 27 |
28 | 32 | 33 | 34 |
35 | 36 |
37 | 40 | 41 | 42 |
43 |
44 |
45 |
46 | 47 |
48 |
49 | 50 | 51 |
52 |
53 |
54 | -------------------------------------------------------------------------------- /src/datasource/partials/query.editor.html: -------------------------------------------------------------------------------- 1 | 2 |
3 |
4 | 8 | 9 | 10 | 11 | 12 | 16 | 21 |
22 |
23 | 24 |
25 |
26 | 27 |
28 | 32 | 33 | 34 |
35 | 36 |
37 | 40 | 41 | 42 |
43 |
44 |
45 |
46 | 47 |
48 |
49 | 50 | 51 |
52 |
53 |
54 | -------------------------------------------------------------------------------- /dist/config/config.js: -------------------------------------------------------------------------------- 1 | /// 2 | System.register([], function(exports_1) { 3 | var NewRelicAppConfigCtrl; 4 | return { 5 | setters:[], 6 | execute: function() { 7 | NewRelicAppConfigCtrl = (function () { 8 | function NewRelicAppConfigCtrl($scope, $injector, backendSrv) { 9 | this.backendSrv = backendSrv; 10 | this.backendSrv = backendSrv; 11 | console.log(this); 12 | this.appEditCtrl.setPreUpdateHook(this.preUpdate.bind(this)); 13 | if (!this.appModel.jsonData) { 14 | this.appModel.jsonData = {}; 15 | } 16 | if (!this.appModel.secureJsonData) { 17 | this.appModel.secureJsonData = {}; 18 | } 19 | if (this.appModel.enabled && this.appModel.jsonData.tokenSet) { 20 | this.validateApiConnection(); 21 | } 22 | } 23 | NewRelicAppConfigCtrl.prototype.preUpdate = function () { 24 | if (this.appModel.secureJsonData.apiKey) { 25 | this.appModel.jsonData.tokenSet = true; 26 | } 27 | return Promise.resolve(); 28 | }; 29 | NewRelicAppConfigCtrl.prototype.reset = function () { 30 | this.appModel.jsonData.tokenSet = false; 31 | this.appModel.secureJsonData = {}; 32 | this.apiValidated = false; 33 | }; 34 | NewRelicAppConfigCtrl.prototype.validateApiConnection = function () { 35 | var _this = this; 36 | var promise = this.backendSrv.get('/api/plugin-proxy/newrelic-app/v2/applications.json'); 37 | promise.then(function () { 38 | _this.apiValidated = true; 39 | }, function () { 40 | _this.apiValidated = false; 41 | _this.apiError = true; 42 | }); 43 | return promise; 44 | }; 45 | NewRelicAppConfigCtrl.templateUrl = 'config/config.html'; 46 | return NewRelicAppConfigCtrl; 47 | })(); 48 | exports_1("NewRelicAppConfigCtrl", NewRelicAppConfigCtrl); 49 | } 50 | } 51 | }); 52 | //# sourceMappingURL=config.js.map -------------------------------------------------------------------------------- /src/datasource/query_ctrl.ts: -------------------------------------------------------------------------------- 1 | /// 2 | import {QueryCtrl} from 'app/plugins/sdk'; 3 | import _ from 'lodash'; 4 | 5 | class NewRelicQueryCtrl extends QueryCtrl { 6 | static templateUrl = 'datasource/partials/query.editor.html'; 7 | refresh: any; 8 | metric_types: any; 9 | datasource: any; 10 | type: any; 11 | metrics: any[]; 12 | apps: any[]; 13 | 14 | /** @ngInject **/ 15 | constructor($scope, $injector) { 16 | super($scope, $injector); 17 | this.metric_types = [ 18 | { value: 'applications', label: 'Application' }, 19 | { value: 'servers', label: 'Server'} 20 | ]; 21 | 22 | let target_defaults = { 23 | type: 'applications', 24 | app_id: null, 25 | target: 'Select namespace', 26 | value: 'Select metric' 27 | } 28 | _.defaultsDeep(this.target, target_defaults); 29 | 30 | this.getMetrics(); 31 | this.getApplications(); 32 | }; 33 | 34 | getMetrics() { 35 | if (this.metrics) { 36 | return Promise.resolve(this.metrics); 37 | } else { 38 | return this.datasource.getMetricNames(this.target.app_id) 39 | .then(metrics => { 40 | this.metrics = metrics; 41 | return metrics; 42 | }); 43 | } 44 | } 45 | 46 | getMetricNamespaces() { 47 | return this.getMetrics().then(metrics => { 48 | return _.map(metrics, metric => { 49 | return { text: metric.name, value: metric.name }; 50 | }); 51 | }); 52 | } 53 | 54 | getMetricValues() { 55 | let name = this.target.target; 56 | return this.getMetrics().then(metrics => { 57 | let ns = _.find(metrics, {name: name}); 58 | if (ns) { 59 | return _.map(ns.values, val => { 60 | return { text: val, value: val }; 61 | }); 62 | } else { 63 | return []; 64 | } 65 | }); 66 | } 67 | 68 | getApplications() { 69 | if (this.apps) { 70 | return Promise.resolve(this.apps); 71 | } else { 72 | return this.datasource.getApplications() 73 | .then(apps => { 74 | apps = _.map(apps, app => { 75 | return { name: app.name, id: app.id }; 76 | }); 77 | apps.push({ name: 'Default', id: null }); 78 | this.apps = apps; 79 | 80 | return apps; 81 | }); 82 | } 83 | } 84 | 85 | reset() { 86 | this.metrics = null; 87 | this.getMetrics(); 88 | this.refresh(); 89 | } 90 | 91 | onChangeInternal() { 92 | this.refresh(); 93 | } 94 | } 95 | 96 | export {NewRelicQueryCtrl}; 97 | -------------------------------------------------------------------------------- /dist/datasource/query_ctrl.ts: -------------------------------------------------------------------------------- 1 | /// 2 | import {QueryCtrl} from 'app/plugins/sdk'; 3 | import _ from 'lodash'; 4 | 5 | class NewRelicQueryCtrl extends QueryCtrl { 6 | static templateUrl = 'datasource/partials/query.editor.html'; 7 | refresh: any; 8 | metric_types: any; 9 | datasource: any; 10 | type: any; 11 | metrics: any[]; 12 | apps: any[]; 13 | 14 | /** @ngInject **/ 15 | constructor($scope, $injector) { 16 | super($scope, $injector); 17 | this.metric_types = [ 18 | { value: 'applications', label: 'Application' }, 19 | { value: 'servers', label: 'Server'} 20 | ]; 21 | 22 | let target_defaults = { 23 | type: 'applications', 24 | app_id: null, 25 | target: 'Select namespace', 26 | value: 'Select metric' 27 | } 28 | _.defaultsDeep(this.target, target_defaults); 29 | 30 | this.getMetrics(); 31 | this.getApplications(); 32 | }; 33 | 34 | getMetrics() { 35 | if (this.metrics) { 36 | return Promise.resolve(this.metrics); 37 | } else { 38 | return this.datasource.getMetricNames(this.target.app_id) 39 | .then(metrics => { 40 | this.metrics = metrics; 41 | return metrics; 42 | }); 43 | } 44 | } 45 | 46 | getMetricNamespaces() { 47 | return this.getMetrics().then(metrics => { 48 | return _.map(metrics, metric => { 49 | return { text: metric.name, value: metric.name }; 50 | }); 51 | }); 52 | } 53 | 54 | getMetricValues() { 55 | let name = this.target.target; 56 | return this.getMetrics().then(metrics => { 57 | let ns = _.find(metrics, {name: name}); 58 | if (ns) { 59 | return _.map(ns.values, val => { 60 | return { text: val, value: val }; 61 | }); 62 | } else { 63 | return []; 64 | } 65 | }); 66 | } 67 | 68 | getApplications() { 69 | if (this.apps) { 70 | return Promise.resolve(this.apps); 71 | } else { 72 | return this.datasource.getApplications() 73 | .then(apps => { 74 | apps = _.map(apps, app => { 75 | return { name: app.name, id: app.id }; 76 | }); 77 | apps.push({ name: 'Default', id: null }); 78 | this.apps = apps; 79 | 80 | return apps; 81 | }); 82 | } 83 | } 84 | 85 | reset() { 86 | this.metrics = null; 87 | this.getMetrics(); 88 | this.refresh(); 89 | } 90 | 91 | onChangeInternal() { 92 | this.refresh(); 93 | } 94 | } 95 | 96 | export {NewRelicQueryCtrl}; 97 | -------------------------------------------------------------------------------- /dist/datasource/query_ctrl.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"query_ctrl.js","sourceRoot":"","sources":["query_ctrl.ts"],"names":["NewRelicQueryCtrl","NewRelicQueryCtrl.constructor","NewRelicQueryCtrl.getMetrics","NewRelicQueryCtrl.getMetricNamespaces","NewRelicQueryCtrl.getMetricValues","NewRelicQueryCtrl.getApplications","NewRelicQueryCtrl.reset","NewRelicQueryCtrl.onChangeInternal"],"mappings":";;;;;;;;;;;;;;;;;YAIA;gBAAgCA,qCAASA;gBASvCA,iBAAiBA;gBACjBA,2BAAYA,MAAMA,EAAEA,SAASA;oBAC3BC,kBAAMA,MAAMA,EAAEA,SAASA,CAACA,CAACA;oBACzBA,IAAIA,CAACA,YAAYA,GAAGA;wBAClBA,EAAEA,KAAKA,EAAEA,cAAcA,EAAEA,KAAKA,EAAEA,aAAaA,EAAEA;wBAC/CA,EAAEA,KAAKA,EAAEA,SAASA,EAAEA,KAAKA,EAAEA,QAAQA,EAACA;qBACrCA,CAACA;oBAEFA,IAAIA,eAAeA,GAAGA;wBACpBA,IAAIA,EAAEA,cAAcA;wBACpBA,MAAMA,EAAEA,IAAIA;wBACZA,MAAMA,EAAEA,kBAAkBA;wBAC1BA,KAAKA,EAAEA,eAAeA;qBACvBA,CAAAA;oBACDA,gBAACA,CAACA,YAAYA,CAACA,IAAIA,CAACA,MAAMA,EAAEA,eAAeA,CAACA,CAACA;oBAE7CA,IAAIA,CAACA,UAAUA,EAAEA,CAACA;oBAClBA,IAAIA,CAACA,eAAeA,EAAEA,CAACA;gBACzBA,CAACA;;gBAEDD,sCAAUA,GAAVA;oBAAAE,iBAUCA;oBATCA,EAAEA,CAACA,CAACA,IAAIA,CAACA,OAAOA,CAACA,CAACA,CAACA;wBACjBA,MAAMA,CAACA,OAAOA,CAACA,OAAOA,CAACA,IAAIA,CAACA,OAAOA,CAACA,CAACA;oBACvCA,CAACA;oBAACA,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D,EAAgC,eAAS,EAyFxC;YAEO,iDAAiB"} -------------------------------------------------------------------------------- /dist/datasource/query_ctrl.js: -------------------------------------------------------------------------------- 1 | System.register(['app/plugins/sdk', 'lodash'], function(exports_1) { 2 | var __extends = (this && this.__extends) || function (d, b) { 3 | for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; 4 | function __() { this.constructor = d; } 5 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); 6 | }; 7 | var sdk_1, lodash_1; 8 | var NewRelicQueryCtrl; 9 | return { 10 | setters:[ 11 | function (sdk_1_1) { 12 | sdk_1 = sdk_1_1; 13 | }, 14 | function (lodash_1_1) { 15 | lodash_1 = lodash_1_1; 16 | }], 17 | execute: function() { 18 | NewRelicQueryCtrl = (function (_super) { 19 | __extends(NewRelicQueryCtrl, _super); 20 | /** @ngInject **/ 21 | function NewRelicQueryCtrl($scope, $injector) { 22 | _super.call(this, $scope, $injector); 23 | this.metric_types = [ 24 | { value: 'applications', label: 'Application' }, 25 | { value: 'servers', label: 'Server' } 26 | ]; 27 | var target_defaults = { 28 | type: 'applications', 29 | app_id: null, 30 | target: 'Select namespace', 31 | value: 'Select metric' 32 | }; 33 | lodash_1.default.defaultsDeep(this.target, target_defaults); 34 | this.getMetrics(); 35 | this.getApplications(); 36 | } 37 | ; 38 | NewRelicQueryCtrl.prototype.getMetrics = function () { 39 | var _this = this; 40 | if (this.metrics) { 41 | return Promise.resolve(this.metrics); 42 | } 43 | else { 44 | return this.datasource.getMetricNames(this.target.app_id) 45 | .then(function (metrics) { 46 | _this.metrics = metrics; 47 | return metrics; 48 | }); 49 | } 50 | }; 51 | NewRelicQueryCtrl.prototype.getMetricNamespaces = function () { 52 | return this.getMetrics().then(function (metrics) { 53 | return lodash_1.default.map(metrics, function (metric) { 54 | return { text: metric.name, value: metric.name }; 55 | }); 56 | }); 57 | }; 58 | NewRelicQueryCtrl.prototype.getMetricValues = function () { 59 | var name = this.target.target; 60 | return this.getMetrics().then(function (metrics) { 61 | var ns = lodash_1.default.find(metrics, { name: name }); 62 | if (ns) { 63 | return lodash_1.default.map(ns.values, function (val) { 64 | return { text: val, value: val }; 65 | }); 66 | } 67 | else { 68 | return []; 69 | } 70 | }); 71 | }; 72 | NewRelicQueryCtrl.prototype.getApplications = function () { 73 | var _this = this; 74 | if (this.apps) { 75 | return Promise.resolve(this.apps); 76 | } 77 | else { 78 | return this.datasource.getApplications() 79 | .then(function (apps) { 80 | apps = lodash_1.default.map(apps, function (app) { 81 | return { name: app.name, id: app.id }; 82 | }); 83 | apps.push({ name: 'Default', id: null }); 84 | _this.apps = apps; 85 | return apps; 86 | }); 87 | } 88 | }; 89 | NewRelicQueryCtrl.prototype.reset = function () { 90 | this.metrics = null; 91 | this.getMetrics(); 92 | this.refresh(); 93 | }; 94 | NewRelicQueryCtrl.prototype.onChangeInternal = function () { 95 | this.refresh(); 96 | }; 97 | NewRelicQueryCtrl.templateUrl = 'datasource/partials/query.editor.html'; 98 | return NewRelicQueryCtrl; 99 | })(sdk_1.QueryCtrl); 100 | exports_1("NewRelicQueryCtrl", NewRelicQueryCtrl); 101 | } 102 | } 103 | }); 104 | //# sourceMappingURL=query_ctrl.js.map -------------------------------------------------------------------------------- /src/datasource/datasource.ts: -------------------------------------------------------------------------------- 1 | /// 2 | import moment from 'moment'; 3 | 4 | class NewRelicDatasource { 5 | name: string; 6 | appId: any; 7 | baseApiUrl: string; 8 | 9 | /** @ngInject */ 10 | constructor(instanceSettings, private $q, private backendSrv, private templateSrv) { 11 | this.name = instanceSettings.name; 12 | this.appId = instanceSettings.jsonData.app_id; 13 | this.baseApiUrl = 'api/plugin-proxy/newrelic-app'; 14 | this.backendSrv = backendSrv; 15 | } 16 | 17 | query(options) { 18 | var requests = []; 19 | 20 | options.targets.forEach(target => { 21 | var value = target.value || null; 22 | var type = target.type || 'applications'; 23 | /* Todo: clean up defaulting app_id based on datasource config */ 24 | var app_id = target.app_id || this.appId; 25 | var id = type === 'applications' ? app_id : target.server_id; 26 | var request = { 27 | refId: target.refId, 28 | alias: target.alias, 29 | url: '/v2/' + type + '/' + id + '/metrics/data.json', 30 | params: { 31 | names: [target.target], 32 | to: options.range.to, 33 | from: options.range.from, 34 | period: this._convertToSeconds(options.interval || "60s") 35 | } 36 | }; 37 | if (value) { 38 | request.params["values"] = [value]; 39 | } 40 | if (id) { 41 | requests.push(request); 42 | } 43 | }); 44 | return this.makeMultipleRequests(requests); 45 | } 46 | 47 | testDatasource() { 48 | var url = '/v2/applications/' + this.appId + '.json'; 49 | 50 | return this.makeApiRequest({url: url}).then(() => { 51 | return { status: "success", message: "Data source is working", title: "Success" }; 52 | }); 53 | } 54 | 55 | _convertToSeconds(interval) { 56 | var seconds: number = parseInt(interval); 57 | var unit: string = interval.slice(-1).toLowerCase(); 58 | switch (unit) { 59 | case "s": 60 | break; 61 | case "m": 62 | seconds = seconds * 60; 63 | break; 64 | case "h": 65 | seconds = seconds * 3600; 66 | break; 67 | case "d": 68 | seconds = seconds * 86400; 69 | break; 70 | } 71 | return seconds; 72 | } 73 | 74 | _parseMetricResults(results) { 75 | var targetList = []; 76 | var metrics = results.response.metric_data.metrics; 77 | metrics.forEach(metric => { 78 | metric.alias = results.alias; 79 | targetList = targetList.concat(this._parseseacrhTarget(metric)); 80 | }); 81 | return targetList; 82 | } 83 | 84 | _parseseacrhTarget(metric) { 85 | var targets = Object.keys(metric.timeslices[0].values); 86 | var targetData = []; 87 | targets.forEach(target => { 88 | targetData.push({ 89 | target: this._parseTargetAlias(metric, target), 90 | datapoints: this._getTargetSeries(target, metric) 91 | }); 92 | }); 93 | return targetData; 94 | } 95 | 96 | _getTargetSeries(target, metric) { 97 | var series = []; 98 | metric.timeslices.forEach(function(slice){ 99 | series.push([slice.values[target], moment(slice.to).valueOf()]); 100 | }); 101 | return series; 102 | } 103 | 104 | _parseTargetAlias(metric, value) { 105 | if (metric.alias) { 106 | return metric.alias.replace(/\$value/g, value); 107 | } else { 108 | return metric.name + ":" + value; 109 | } 110 | } 111 | 112 | makeMultipleRequests(requests) { 113 | return new Promise((resolve, reject) => { 114 | var mergedResults = { 115 | data: [] 116 | }; 117 | var promises = []; 118 | requests.forEach(request => { 119 | promises.push(this.makeApiRequest(request)); 120 | }); 121 | 122 | return Promise.all(promises).then(data => { 123 | data.forEach(result => { 124 | mergedResults.data = mergedResults.data.concat(this._parseMetricResults(result)); 125 | }); 126 | resolve(mergedResults); 127 | }); 128 | }); 129 | } 130 | 131 | getMetricNames(application_id) { 132 | if (!application_id) { 133 | application_id = this.appId; 134 | } 135 | 136 | let request = { 137 | url: '/v2/applications/' + application_id + '/metrics.json' 138 | }; 139 | 140 | return this.makeApiRequest(request) 141 | .then(result => { 142 | if (result && result.response && result.response.metrics) { 143 | return result.response.metrics; 144 | } else { 145 | return []; 146 | } 147 | }); 148 | } 149 | 150 | getApplications() { 151 | let request = { 152 | url: '/v2/applications.json' 153 | }; 154 | 155 | return this.makeApiRequest(request) 156 | .then(result => { 157 | if (result && result.response && result.response.applications) { 158 | return result.response.applications; 159 | } else { 160 | return []; 161 | } 162 | }); 163 | } 164 | 165 | makeApiRequest(request) { 166 | var options: any = { 167 | method: "get", 168 | url: this.baseApiUrl + request.url, 169 | params: request.params, 170 | data: request.data, 171 | }; 172 | 173 | return this.backendSrv.datasourceRequest(options) 174 | .then(result => { 175 | return {response: result.data, refId: request.refId, alias: request.alias }; 176 | }) 177 | .catch(err => { 178 | if (err.status !== 0 || err.status >= 300) { 179 | if (err.data && err.data.error) { 180 | throw { message: 'New Relic Error Response: ' + err.data.error.title, data: err.data, config: err.config }; 181 | } else { 182 | throw { message: 'New Relic Error: ' + err.message, data: err.data, config: err.config }; 183 | } 184 | } 185 | }); 186 | } 187 | 188 | } 189 | 190 | export {NewRelicDatasource}; 191 | -------------------------------------------------------------------------------- /dist/datasource/datasource.ts: -------------------------------------------------------------------------------- 1 | /// 2 | import moment from 'moment'; 3 | 4 | class NewRelicDatasource { 5 | name: string; 6 | appId: any; 7 | baseApiUrl: string; 8 | 9 | /** @ngInject */ 10 | constructor(instanceSettings, private $q, private backendSrv, private templateSrv) { 11 | this.name = instanceSettings.name; 12 | this.appId = instanceSettings.jsonData.app_id; 13 | this.baseApiUrl = 'api/plugin-proxy/newrelic-app'; 14 | this.backendSrv = backendSrv; 15 | } 16 | 17 | query(options) { 18 | var requests = []; 19 | 20 | options.targets.forEach(target => { 21 | var value = target.value || null; 22 | var type = target.type || 'applications'; 23 | /* Todo: clean up defaulting app_id based on datasource config */ 24 | var app_id = target.app_id || this.appId; 25 | var id = type === 'applications' ? app_id : target.server_id; 26 | var request = { 27 | refId: target.refId, 28 | alias: target.alias, 29 | url: '/v2/' + type + '/' + id + '/metrics/data.json', 30 | params: { 31 | names: [target.target], 32 | to: options.range.to, 33 | from: options.range.from, 34 | period: this._convertToSeconds(options.interval || "60s") 35 | } 36 | }; 37 | if (value) { 38 | request.params["values"] = [value]; 39 | } 40 | if (id) { 41 | requests.push(request); 42 | } 43 | }); 44 | return this.makeMultipleRequests(requests); 45 | } 46 | 47 | testDatasource() { 48 | var url = '/v2/applications/' + this.appId + '.json'; 49 | 50 | return this.makeApiRequest({url: url}).then(() => { 51 | return { status: "success", message: "Data source is working", title: "Success" }; 52 | }); 53 | } 54 | 55 | _convertToSeconds(interval) { 56 | var seconds: number = parseInt(interval); 57 | var unit: string = interval.slice(-1).toLowerCase(); 58 | switch (unit) { 59 | case "s": 60 | break; 61 | case "m": 62 | seconds = seconds * 60; 63 | break; 64 | case "h": 65 | seconds = seconds * 3600; 66 | break; 67 | case "d": 68 | seconds = seconds * 86400; 69 | break; 70 | } 71 | return seconds; 72 | } 73 | 74 | _parseMetricResults(results) { 75 | var targetList = []; 76 | var metrics = results.response.metric_data.metrics; 77 | metrics.forEach(metric => { 78 | metric.alias = results.alias; 79 | targetList = targetList.concat(this._parseseacrhTarget(metric)); 80 | }); 81 | return targetList; 82 | } 83 | 84 | _parseseacrhTarget(metric) { 85 | var targets = Object.keys(metric.timeslices[0].values); 86 | var targetData = []; 87 | targets.forEach(target => { 88 | targetData.push({ 89 | target: this._parseTargetAlias(metric, target), 90 | datapoints: this._getTargetSeries(target, metric) 91 | }); 92 | }); 93 | return targetData; 94 | } 95 | 96 | _getTargetSeries(target, metric) { 97 | var series = []; 98 | metric.timeslices.forEach(function(slice){ 99 | series.push([slice.values[target], moment(slice.to).valueOf()]); 100 | }); 101 | return series; 102 | } 103 | 104 | _parseTargetAlias(metric, value) { 105 | if (metric.alias) { 106 | return metric.alias.replace(/\$value/g, value); 107 | } else { 108 | return metric.name + ":" + value; 109 | } 110 | } 111 | 112 | makeMultipleRequests(requests) { 113 | return new Promise((resolve, reject) => { 114 | var mergedResults = { 115 | data: [] 116 | }; 117 | var promises = []; 118 | requests.forEach(request => { 119 | promises.push(this.makeApiRequest(request)); 120 | }); 121 | 122 | return Promise.all(promises).then(data => { 123 | data.forEach(result => { 124 | mergedResults.data = mergedResults.data.concat(this._parseMetricResults(result)); 125 | }); 126 | resolve(mergedResults); 127 | }); 128 | }); 129 | } 130 | 131 | getMetricNames(application_id) { 132 | if (!application_id) { 133 | application_id = this.appId; 134 | } 135 | 136 | let request = { 137 | url: '/v2/applications/' + application_id + '/metrics.json' 138 | }; 139 | 140 | return this.makeApiRequest(request) 141 | .then(result => { 142 | if (result && result.response && result.response.metrics) { 143 | return result.response.metrics; 144 | } else { 145 | return []; 146 | } 147 | }); 148 | } 149 | 150 | getApplications() { 151 | let request = { 152 | url: '/v2/applications.json' 153 | }; 154 | 155 | return this.makeApiRequest(request) 156 | .then(result => { 157 | if (result && result.response && result.response.applications) { 158 | return result.response.applications; 159 | } else { 160 | return []; 161 | } 162 | }); 163 | } 164 | 165 | makeApiRequest(request) { 166 | var options: any = { 167 | method: "get", 168 | url: this.baseApiUrl + request.url, 169 | params: request.params, 170 | data: request.data, 171 | }; 172 | 173 | return this.backendSrv.datasourceRequest(options) 174 | .then(result => { 175 | return {response: result.data, refId: request.refId, alias: request.alias }; 176 | }) 177 | .catch(err => { 178 | if (err.status !== 0 || err.status >= 300) { 179 | if (err.data && err.data.error) { 180 | throw { message: 'New Relic Error Response: ' + err.data.error.title, data: err.data, config: err.config }; 181 | } else { 182 | throw { message: 'New Relic Error: ' + err.message, data: err.data, config: err.config }; 183 | } 184 | } 185 | }); 186 | } 187 | 188 | } 189 | 190 | export {NewRelicDatasource}; 191 | -------------------------------------------------------------------------------- /dist/datasource/datasource.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"datasource.js","sourceRoot":"","sources":["datasource.ts"],"names":["NewRelicDatasource","NewRelicDatasource.constructor","NewRelicDatasource.query","NewRelicDatasource.testDatasource","NewRelicDatasource._convertToSeconds","NewRelicDatasource._parseMetricResults","NewRelicDatasource._parseseacrhTarget","NewRelicDatasource._getTargetSeries","NewRelicDatasource._parseTargetAlias","NewRelicDatasource.makeMultipleRequests","NewRelicDatasource.getMetricNames","NewRelicDatasource.getApplications","NewRelicDatasource.makeApiRequest"],"mappings":";;;;;;;;;YAGA;gBAKEA,gBAAgBA;gBAChBA,4BAAYA,gBAAgBA,EAAUA,EAAEA,EAAUA,UAAUA,EAAUA,WAAWA;oBAA3CC,OAAEA,GAAFA,EAAEA,CAAAA;oBAAUA,eAAUA,GAAVA,UAAUA,CAAAA;oBAAUA,gBAAWA,GAAXA,WAAWA,CAAAA;oBAC/EA,IAAIA,CAACA,IAAIA,GAAGA,gBAAgBA,CAACA,IAAIA,CAACA;oBAClCA,IAAIA,CAACA,KAAKA,GAAGA,gBAAgBA,CAACA,QAAQA,CAACA,MAAMA,CAACA;oBAC9CA,IAAIA,CAACA,UAAUA,GAAGA,+BAA+BA,CAACA;oBAClDA,IAAIA,CAACA,UAAUA,GAAGA,UAAUA,CAACA;gBAC/BA,CAACA;gBAEDD,kCAAKA,GAALA,UAAMA,OAAOA;oBAAbE,iBA4BCA;oBA3BCA,IAAIA,QAAQA,GAAGA,EAAEA,CAACA;oBAElBA,OAAOA,CAACA,OAAOA,CAACA,OAAOA,CAACA,UAAAA,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IAwLC;YAEO,mDAAkB"} -------------------------------------------------------------------------------- /dist/datasource/datasource.js: -------------------------------------------------------------------------------- 1 | System.register(['moment'], function(exports_1) { 2 | var moment_1; 3 | var NewRelicDatasource; 4 | return { 5 | setters:[ 6 | function (moment_1_1) { 7 | moment_1 = moment_1_1; 8 | }], 9 | execute: function() { 10 | NewRelicDatasource = (function () { 11 | /** @ngInject */ 12 | function NewRelicDatasource(instanceSettings, $q, backendSrv, templateSrv) { 13 | this.$q = $q; 14 | this.backendSrv = backendSrv; 15 | this.templateSrv = templateSrv; 16 | this.name = instanceSettings.name; 17 | this.appId = instanceSettings.jsonData.app_id; 18 | this.baseApiUrl = 'api/plugin-proxy/newrelic-app'; 19 | this.backendSrv = backendSrv; 20 | } 21 | NewRelicDatasource.prototype.query = function (options) { 22 | var _this = this; 23 | var requests = []; 24 | options.targets.forEach(function (target) { 25 | var value = target.value || null; 26 | var type = target.type || 'applications'; 27 | /* Todo: clean up defaulting app_id based on datasource config */ 28 | var app_id = target.app_id || _this.appId; 29 | var id = type === 'applications' ? app_id : target.server_id; 30 | var request = { 31 | refId: target.refId, 32 | alias: target.alias, 33 | url: '/v2/' + type + '/' + id + '/metrics/data.json', 34 | params: { 35 | names: [target.target], 36 | to: options.range.to, 37 | from: options.range.from, 38 | period: _this._convertToSeconds(options.interval || "60s") 39 | } 40 | }; 41 | if (value) { 42 | request.params["values"] = [value]; 43 | } 44 | if (id) { 45 | requests.push(request); 46 | } 47 | }); 48 | return this.makeMultipleRequests(requests); 49 | }; 50 | NewRelicDatasource.prototype.testDatasource = function () { 51 | var url = '/v2/applications/' + this.appId + '.json'; 52 | return this.makeApiRequest({ url: url }).then(function () { 53 | return { status: "success", message: "Data source is working", title: "Success" }; 54 | }); 55 | }; 56 | NewRelicDatasource.prototype._convertToSeconds = function (interval) { 57 | var seconds = parseInt(interval); 58 | var unit = interval.slice(-1).toLowerCase(); 59 | switch (unit) { 60 | case "s": 61 | break; 62 | case "m": 63 | seconds = seconds * 60; 64 | break; 65 | case "h": 66 | seconds = seconds * 3600; 67 | break; 68 | case "d": 69 | seconds = seconds * 86400; 70 | break; 71 | } 72 | return seconds; 73 | }; 74 | NewRelicDatasource.prototype._parseMetricResults = function (results) { 75 | var _this = this; 76 | var targetList = []; 77 | var metrics = results.response.metric_data.metrics; 78 | metrics.forEach(function (metric) { 79 | metric.alias = results.alias; 80 | targetList = targetList.concat(_this._parseseacrhTarget(metric)); 81 | }); 82 | return targetList; 83 | }; 84 | NewRelicDatasource.prototype._parseseacrhTarget = function (metric) { 85 | var _this = this; 86 | var targets = Object.keys(metric.timeslices[0].values); 87 | var targetData = []; 88 | targets.forEach(function (target) { 89 | targetData.push({ 90 | target: _this._parseTargetAlias(metric, target), 91 | datapoints: _this._getTargetSeries(target, metric) 92 | }); 93 | }); 94 | return targetData; 95 | }; 96 | NewRelicDatasource.prototype._getTargetSeries = function (target, metric) { 97 | var series = []; 98 | metric.timeslices.forEach(function (slice) { 99 | series.push([slice.values[target], moment_1.default(slice.to).valueOf()]); 100 | }); 101 | return series; 102 | }; 103 | NewRelicDatasource.prototype._parseTargetAlias = function (metric, value) { 104 | if (metric.alias) { 105 | return metric.alias.replace(/\$value/g, value); 106 | } 107 | else { 108 | return metric.name + ":" + value; 109 | } 110 | }; 111 | NewRelicDatasource.prototype.makeMultipleRequests = function (requests) { 112 | var _this = this; 113 | return new Promise(function (resolve, reject) { 114 | var mergedResults = { 115 | data: [] 116 | }; 117 | var promises = []; 118 | requests.forEach(function (request) { 119 | promises.push(_this.makeApiRequest(request)); 120 | }); 121 | return Promise.all(promises).then(function (data) { 122 | data.forEach(function (result) { 123 | mergedResults.data = mergedResults.data.concat(_this._parseMetricResults(result)); 124 | }); 125 | resolve(mergedResults); 126 | }); 127 | }); 128 | }; 129 | NewRelicDatasource.prototype.getMetricNames = function (application_id) { 130 | if (!application_id) { 131 | application_id = this.appId; 132 | } 133 | var request = { 134 | url: '/v2/applications/' + application_id + '/metrics.json' 135 | }; 136 | return this.makeApiRequest(request) 137 | .then(function (result) { 138 | if (result && result.response && result.response.metrics) { 139 | return result.response.metrics; 140 | } 141 | else { 142 | return []; 143 | } 144 | }); 145 | }; 146 | NewRelicDatasource.prototype.getApplications = function () { 147 | var request = { 148 | url: '/v2/applications.json' 149 | }; 150 | return this.makeApiRequest(request) 151 | .then(function (result) { 152 | if (result && result.response && result.response.applications) { 153 | return result.response.applications; 154 | } 155 | else { 156 | return []; 157 | } 158 | }); 159 | }; 160 | NewRelicDatasource.prototype.makeApiRequest = function (request) { 161 | var options = { 162 | method: "get", 163 | url: this.baseApiUrl + request.url, 164 | params: request.params, 165 | data: request.data, 166 | }; 167 | return this.backendSrv.datasourceRequest(options) 168 | .then(function (result) { 169 | return { response: result.data, refId: request.refId, alias: request.alias }; 170 | }) 171 | .catch(function (err) { 172 | if (err.status !== 0 || err.status >= 300) { 173 | if (err.data && err.data.error) { 174 | throw { message: 'New Relic Error Response: ' + err.data.error.title, data: err.data, config: err.config }; 175 | } 176 | else { 177 | throw { message: 'New Relic Error: ' + err.message, data: err.data, config: err.config }; 178 | } 179 | } 180 | }); 181 | }; 182 | return NewRelicDatasource; 183 | })(); 184 | exports_1("NewRelicDatasource", NewRelicDatasource); 185 | } 186 | } 187 | }); 188 | //# sourceMappingURL=datasource.js.map -------------------------------------------------------------------------------- /dist/typings/es6-shim/es6-shim.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for es6-shim v0.31.2 2 | // Project: https://github.com/paulmillr/es6-shim 3 | // Definitions by: Ron Buckton 4 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped 5 | 6 | declare type PropertyKey = string | number | symbol; 7 | 8 | interface IteratorResult { 9 | done: boolean; 10 | value?: T; 11 | } 12 | 13 | interface IterableShim { 14 | /** 15 | * Shim for an ES6 iterable. Not intended for direct use by user code. 16 | */ 17 | "_es6-shim iterator_"(): Iterator; 18 | } 19 | 20 | interface Iterator { 21 | next(value?: any): IteratorResult; 22 | return?(value?: any): IteratorResult; 23 | throw?(e?: any): IteratorResult; 24 | } 25 | 26 | interface IterableIteratorShim extends IterableShim, Iterator { 27 | /** 28 | * Shim for an ES6 iterable iterator. Not intended for direct use by user code. 29 | */ 30 | "_es6-shim iterator_"(): IterableIteratorShim; 31 | } 32 | 33 | interface StringConstructor { 34 | /** 35 | * Return the String value whose elements are, in order, the elements in the List elements. 36 | * If length is 0, the empty string is returned. 37 | */ 38 | fromCodePoint(...codePoints: number[]): string; 39 | 40 | /** 41 | * String.raw is intended for use as a tag function of a Tagged Template String. When called 42 | * as such the first argument will be a well formed template call site object and the rest 43 | * parameter will contain the substitution values. 44 | * @param template A well-formed template string call site representation. 45 | * @param substitutions A set of substitution values. 46 | */ 47 | raw(template: TemplateStringsArray, ...substitutions: any[]): string; 48 | } 49 | 50 | interface String { 51 | /** 52 | * Returns a nonnegative integer Number less than 1114112 (0x110000) that is the code point 53 | * value of the UTF-16 encoded code point starting at the string element at position pos in 54 | * the String resulting from converting this object to a String. 55 | * If there is no element at that position, the result is undefined. 56 | * If a valid UTF-16 surrogate pair does not begin at pos, the result is the code unit at pos. 57 | */ 58 | codePointAt(pos: number): number; 59 | 60 | /** 61 | * Returns true if searchString appears as a substring of the result of converting this 62 | * object to a String, at one or more positions that are 63 | * greater than or equal to position; otherwise, returns false. 64 | * @param searchString search string 65 | * @param position If position is undefined, 0 is assumed, so as to search all of the String. 66 | */ 67 | includes(searchString: string, position?: number): boolean; 68 | 69 | /** 70 | * Returns true if the sequence of elements of searchString converted to a String is the 71 | * same as the corresponding elements of this object (converted to a String) starting at 72 | * endPosition – length(this). Otherwise returns false. 73 | */ 74 | endsWith(searchString: string, endPosition?: number): boolean; 75 | 76 | /** 77 | * Returns a String value that is made from count copies appended together. If count is 0, 78 | * T is the empty String is returned. 79 | * @param count number of copies to append 80 | */ 81 | repeat(count: number): string; 82 | 83 | /** 84 | * Returns true if the sequence of elements of searchString converted to a String is the 85 | * same as the corresponding elements of this object (converted to a String) starting at 86 | * position. Otherwise returns false. 87 | */ 88 | startsWith(searchString: string, position?: number): boolean; 89 | 90 | /** 91 | * Returns an HTML anchor element and sets the name attribute to the text value 92 | * @param name 93 | */ 94 | anchor(name: string): string; 95 | 96 | /** Returns a HTML element */ 97 | big(): string; 98 | 99 | /** Returns a HTML element */ 100 | blink(): string; 101 | 102 | /** Returns a HTML element */ 103 | bold(): string; 104 | 105 | /** Returns a HTML element */ 106 | fixed(): string 107 | 108 | /** Returns a HTML element and sets the color attribute value */ 109 | fontcolor(color: string): string 110 | 111 | /** Returns a HTML element and sets the size attribute value */ 112 | fontsize(size: number): string; 113 | 114 | /** Returns a HTML element and sets the size attribute value */ 115 | fontsize(size: string): string; 116 | 117 | /** Returns an HTML element */ 118 | italics(): string; 119 | 120 | /** Returns an HTML element and sets the href attribute value */ 121 | link(url: string): string; 122 | 123 | /** Returns a HTML element */ 124 | small(): string; 125 | 126 | /** Returns a HTML element */ 127 | strike(): string; 128 | 129 | /** Returns a HTML element */ 130 | sub(): string; 131 | 132 | /** Returns a HTML element */ 133 | sup(): string; 134 | 135 | /** 136 | * Shim for an ES6 iterable. Not intended for direct use by user code. 137 | */ 138 | "_es6-shim iterator_"(): IterableIteratorShim; 139 | } 140 | 141 | interface ArrayConstructor { 142 | /** 143 | * Creates an array from an array-like object. 144 | * @param arrayLike An array-like object to convert to an array. 145 | * @param mapfn A mapping function to call on every element of the array. 146 | * @param thisArg Value of 'this' used to invoke the mapfn. 147 | */ 148 | from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => U, thisArg?: any): Array; 149 | 150 | /** 151 | * Creates an array from an iterable object. 152 | * @param iterable An iterable object to convert to an array. 153 | * @param mapfn A mapping function to call on every element of the array. 154 | * @param thisArg Value of 'this' used to invoke the mapfn. 155 | */ 156 | from(iterable: IterableShim, mapfn: (v: T, k: number) => U, thisArg?: any): Array; 157 | 158 | /** 159 | * Creates an array from an array-like object. 160 | * @param arrayLike An array-like object to convert to an array. 161 | */ 162 | from(arrayLike: ArrayLike): Array; 163 | 164 | /** 165 | * Creates an array from an iterable object. 166 | * @param iterable An iterable object to convert to an array. 167 | */ 168 | from(iterable: IterableShim): Array; 169 | 170 | /** 171 | * Returns a new array from a set of elements. 172 | * @param items A set of elements to include in the new array object. 173 | */ 174 | of(...items: T[]): Array; 175 | } 176 | 177 | interface Array { 178 | /** 179 | * Returns the value of the first element in the array where predicate is true, and undefined 180 | * otherwise. 181 | * @param predicate find calls predicate once for each element of the array, in ascending 182 | * order, until it finds one where predicate returns true. If such an element is found, find 183 | * immediately returns that element value. Otherwise, find returns undefined. 184 | * @param thisArg If provided, it will be used as the this value for each invocation of 185 | * predicate. If it is not provided, undefined is used instead. 186 | */ 187 | find(predicate: (value: T, index: number, obj: Array) => boolean, thisArg?: any): T; 188 | 189 | /** 190 | * Returns the index of the first element in the array where predicate is true, and undefined 191 | * otherwise. 192 | * @param predicate find calls predicate once for each element of the array, in ascending 193 | * order, until it finds one where predicate returns true. If such an element is found, find 194 | * immediately returns that element value. Otherwise, find returns undefined. 195 | * @param thisArg If provided, it will be used as the this value for each invocation of 196 | * predicate. If it is not provided, undefined is used instead. 197 | */ 198 | findIndex(predicate: (value: T) => boolean, thisArg?: any): number; 199 | 200 | /** 201 | * Returns the this object after filling the section identified by start and end with value 202 | * @param value value to fill array section with 203 | * @param start index to start filling the array at. If start is negative, it is treated as 204 | * length+start where length is the length of the array. 205 | * @param end index to stop filling the array at. If end is negative, it is treated as 206 | * length+end. 207 | */ 208 | fill(value: T, start?: number, end?: number): T[]; 209 | 210 | /** 211 | * Returns the this object after copying a section of the array identified by start and end 212 | * to the same array starting at position target 213 | * @param target If target is negative, it is treated as length+target where length is the 214 | * length of the array. 215 | * @param start If start is negative, it is treated as length+start. If end is negative, it 216 | * is treated as length+end. 217 | * @param end If not specified, length of the this object is used as its default value. 218 | */ 219 | copyWithin(target: number, start: number, end?: number): T[]; 220 | 221 | /** 222 | * Returns an array of key, value pairs for every entry in the array 223 | */ 224 | entries(): IterableIteratorShim<[number, T]>; 225 | 226 | /** 227 | * Returns an list of keys in the array 228 | */ 229 | keys(): IterableIteratorShim; 230 | 231 | /** 232 | * Returns an list of values in the array 233 | */ 234 | values(): IterableIteratorShim; 235 | 236 | /** 237 | * Shim for an ES6 iterable. Not intended for direct use by user code. 238 | */ 239 | "_es6-shim iterator_"(): IterableIteratorShim; 240 | } 241 | 242 | interface NumberConstructor { 243 | /** 244 | * The value of Number.EPSILON is the difference between 1 and the smallest value greater than 1 245 | * that is representable as a Number value, which is approximately: 246 | * 2.2204460492503130808472633361816 x 10‍−‍16. 247 | */ 248 | EPSILON: number; 249 | 250 | /** 251 | * Returns true if passed value is finite. 252 | * Unlike the global isFininte, Number.isFinite doesn't forcibly convert the parameter to a 253 | * number. Only finite values of the type number, result in true. 254 | * @param number A numeric value. 255 | */ 256 | isFinite(number: number): boolean; 257 | 258 | /** 259 | * Returns true if the value passed is an integer, false otherwise. 260 | * @param number A numeric value. 261 | */ 262 | isInteger(number: number): boolean; 263 | 264 | /** 265 | * Returns a Boolean value that indicates whether a value is the reserved value NaN (not a 266 | * number). Unlike the global isNaN(), Number.isNaN() doesn't forcefully convert the parameter 267 | * to a number. Only values of the type number, that are also NaN, result in true. 268 | * @param number A numeric value. 269 | */ 270 | isNaN(number: number): boolean; 271 | 272 | /** 273 | * Returns true if the value passed is a safe integer. 274 | * @param number A numeric value. 275 | */ 276 | isSafeInteger(number: number): boolean; 277 | 278 | /** 279 | * The value of the largest integer n such that n and n + 1 are both exactly representable as 280 | * a Number value. 281 | * The value of Number.MIN_SAFE_INTEGER is 9007199254740991 2^53 − 1. 282 | */ 283 | MAX_SAFE_INTEGER: number; 284 | 285 | /** 286 | * The value of the smallest integer n such that n and n − 1 are both exactly representable as 287 | * a Number value. 288 | * The value of Number.MIN_SAFE_INTEGER is −9007199254740991 (−(2^53 − 1)). 289 | */ 290 | MIN_SAFE_INTEGER: number; 291 | 292 | /** 293 | * Converts a string to a floating-point number. 294 | * @param string A string that contains a floating-point number. 295 | */ 296 | parseFloat(string: string): number; 297 | 298 | /** 299 | * Converts A string to an integer. 300 | * @param s A string to convert into a number. 301 | * @param radix A value between 2 and 36 that specifies the base of the number in numString. 302 | * If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal. 303 | * All other strings are considered decimal. 304 | */ 305 | parseInt(string: string, radix?: number): number; 306 | } 307 | 308 | interface ObjectConstructor { 309 | /** 310 | * Copy the values of all of the enumerable own properties from one or more source objects to a 311 | * target object. Returns the target object. 312 | * @param target The target object to copy to. 313 | * @param sources One or more source objects to copy properties from. 314 | */ 315 | assign(target: any, ...sources: any[]): any; 316 | 317 | /** 318 | * Returns true if the values are the same value, false otherwise. 319 | * @param value1 The first value. 320 | * @param value2 The second value. 321 | */ 322 | is(value1: any, value2: any): boolean; 323 | 324 | /** 325 | * Sets the prototype of a specified object o to object proto or null. Returns the object o. 326 | * @param o The object to change its prototype. 327 | * @param proto The value of the new prototype or null. 328 | * @remarks Requires `__proto__` support. 329 | */ 330 | setPrototypeOf(o: any, proto: any): any; 331 | } 332 | 333 | interface RegExp { 334 | /** 335 | * Returns a string indicating the flags of the regular expression in question. This field is read-only. 336 | * The characters in this string are sequenced and concatenated in the following order: 337 | * 338 | * - "g" for global 339 | * - "i" for ignoreCase 340 | * - "m" for multiline 341 | * - "u" for unicode 342 | * - "y" for sticky 343 | * 344 | * If no flags are set, the value is the empty string. 345 | */ 346 | flags: string; 347 | } 348 | 349 | interface Math { 350 | /** 351 | * Returns the number of leading zero bits in the 32-bit binary representation of a number. 352 | * @param x A numeric expression. 353 | */ 354 | clz32(x: number): number; 355 | 356 | /** 357 | * Returns the result of 32-bit multiplication of two numbers. 358 | * @param x First number 359 | * @param y Second number 360 | */ 361 | imul(x: number, y: number): number; 362 | 363 | /** 364 | * Returns the sign of the x, indicating whether x is positive, negative or zero. 365 | * @param x The numeric expression to test 366 | */ 367 | sign(x: number): number; 368 | 369 | /** 370 | * Returns the base 10 logarithm of a number. 371 | * @param x A numeric expression. 372 | */ 373 | log10(x: number): number; 374 | 375 | /** 376 | * Returns the base 2 logarithm of a number. 377 | * @param x A numeric expression. 378 | */ 379 | log2(x: number): number; 380 | 381 | /** 382 | * Returns the natural logarithm of 1 + x. 383 | * @param x A numeric expression. 384 | */ 385 | log1p(x: number): number; 386 | 387 | /** 388 | * Returns the result of (e^x - 1) of x (e raised to the power of x, where e is the base of 389 | * the natural logarithms). 390 | * @param x A numeric expression. 391 | */ 392 | expm1(x: number): number; 393 | 394 | /** 395 | * Returns the hyperbolic cosine of a number. 396 | * @param x A numeric expression that contains an angle measured in radians. 397 | */ 398 | cosh(x: number): number; 399 | 400 | /** 401 | * Returns the hyperbolic sine of a number. 402 | * @param x A numeric expression that contains an angle measured in radians. 403 | */ 404 | sinh(x: number): number; 405 | 406 | /** 407 | * Returns the hyperbolic tangent of a number. 408 | * @param x A numeric expression that contains an angle measured in radians. 409 | */ 410 | tanh(x: number): number; 411 | 412 | /** 413 | * Returns the inverse hyperbolic cosine of a number. 414 | * @param x A numeric expression that contains an angle measured in radians. 415 | */ 416 | acosh(x: number): number; 417 | 418 | /** 419 | * Returns the inverse hyperbolic sine of a number. 420 | * @param x A numeric expression that contains an angle measured in radians. 421 | */ 422 | asinh(x: number): number; 423 | 424 | /** 425 | * Returns the inverse hyperbolic tangent of a number. 426 | * @param x A numeric expression that contains an angle measured in radians. 427 | */ 428 | atanh(x: number): number; 429 | 430 | /** 431 | * Returns the square root of the sum of squares of its arguments. 432 | * @param values Values to compute the square root for. 433 | * If no arguments are passed, the result is +0. 434 | * If there is only one argument, the result is the absolute value. 435 | * If any argument is +Infinity or -Infinity, the result is +Infinity. 436 | * If any argument is NaN, the result is NaN. 437 | * If all arguments are either +0 or −0, the result is +0. 438 | */ 439 | hypot(...values: number[]): number; 440 | 441 | /** 442 | * Returns the integral part of the a numeric expression, x, removing any fractional digits. 443 | * If x is already an integer, the result is x. 444 | * @param x A numeric expression. 445 | */ 446 | trunc(x: number): number; 447 | 448 | /** 449 | * Returns the nearest single precision float representation of a number. 450 | * @param x A numeric expression. 451 | */ 452 | fround(x: number): number; 453 | 454 | /** 455 | * Returns an implementation-dependent approximation to the cube root of number. 456 | * @param x A numeric expression. 457 | */ 458 | cbrt(x: number): number; 459 | } 460 | 461 | interface PromiseLike { 462 | /** 463 | * Attaches callbacks for the resolution and/or rejection of the Promise. 464 | * @param onfulfilled The callback to execute when the Promise is resolved. 465 | * @param onrejected The callback to execute when the Promise is rejected. 466 | * @returns A Promise for the completion of which ever callback is executed. 467 | */ 468 | then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): PromiseLike; 469 | then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): PromiseLike; 470 | } 471 | 472 | /** 473 | * Represents the completion of an asynchronous operation 474 | */ 475 | interface Promise { 476 | /** 477 | * Attaches callbacks for the resolution and/or rejection of the Promise. 478 | * @param onfulfilled The callback to execute when the Promise is resolved. 479 | * @param onrejected The callback to execute when the Promise is rejected. 480 | * @returns A Promise for the completion of which ever callback is executed. 481 | */ 482 | then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; 483 | then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): Promise; 484 | 485 | /** 486 | * Attaches a callback for only the rejection of the Promise. 487 | * @param onrejected The callback to execute when the Promise is rejected. 488 | * @returns A Promise for the completion of the callback. 489 | */ 490 | catch(onrejected?: (reason: any) => T | PromiseLike): Promise; 491 | catch(onrejected?: (reason: any) => void): Promise; 492 | } 493 | 494 | interface PromiseConstructor { 495 | /** 496 | * A reference to the prototype. 497 | */ 498 | prototype: Promise; 499 | 500 | /** 501 | * Creates a new Promise. 502 | * @param executor A callback used to initialize the promise. This callback is passed two arguments: 503 | * a resolve callback used resolve the promise with a value or the result of another promise, 504 | * and a reject callback used to reject the promise with a provided reason or error. 505 | */ 506 | new (executor: (resolve: (value?: T | PromiseLike) => void, reject: (reason?: any) => void) => void): Promise; 507 | 508 | /** 509 | * Creates a Promise that is resolved with an array of results when all of the provided Promises 510 | * resolve, or rejected when any Promise is rejected. 511 | * @param values An array of Promises. 512 | * @returns A new Promise. 513 | */ 514 | all(values: IterableShim>): Promise; 515 | 516 | /** 517 | * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved 518 | * or rejected. 519 | * @param values An array of Promises. 520 | * @returns A new Promise. 521 | */ 522 | race(values: IterableShim>): Promise; 523 | 524 | /** 525 | * Creates a new rejected promise for the provided reason. 526 | * @param reason The reason the promise was rejected. 527 | * @returns A new rejected Promise. 528 | */ 529 | reject(reason: any): Promise; 530 | 531 | /** 532 | * Creates a new rejected promise for the provided reason. 533 | * @param reason The reason the promise was rejected. 534 | * @returns A new rejected Promise. 535 | */ 536 | reject(reason: any): Promise; 537 | 538 | /** 539 | * Creates a new resolved promise for the provided value. 540 | * @param value A promise. 541 | * @returns A promise whose internal state matches the provided promise. 542 | */ 543 | resolve(value: T | PromiseLike): Promise; 544 | 545 | /** 546 | * Creates a new resolved promise . 547 | * @returns A resolved promise. 548 | */ 549 | resolve(): Promise; 550 | } 551 | 552 | declare var Promise: PromiseConstructor; 553 | 554 | interface Map { 555 | clear(): void; 556 | delete(key: K): boolean; 557 | forEach(callbackfn: (value: V, index: K, map: Map) => void, thisArg?: any): void; 558 | get(key: K): V; 559 | has(key: K): boolean; 560 | set(key: K, value?: V): Map; 561 | size: number; 562 | entries(): IterableIteratorShim<[K, V]>; 563 | keys(): IterableIteratorShim; 564 | values(): IterableIteratorShim; 565 | } 566 | 567 | interface MapConstructor { 568 | new (): Map; 569 | new (iterable: IterableShim<[K, V]>): Map; 570 | prototype: Map; 571 | } 572 | 573 | declare var Map: MapConstructor; 574 | 575 | interface Set { 576 | add(value: T): Set; 577 | clear(): void; 578 | delete(value: T): boolean; 579 | forEach(callbackfn: (value: T, index: T, set: Set) => void, thisArg?: any): void; 580 | has(value: T): boolean; 581 | size: number; 582 | entries(): IterableIteratorShim<[T, T]>; 583 | keys(): IterableIteratorShim; 584 | values(): IterableIteratorShim; 585 | } 586 | 587 | interface SetConstructor { 588 | new (): Set; 589 | new (iterable: IterableShim): Set; 590 | prototype: Set; 591 | } 592 | 593 | declare var Set: SetConstructor; 594 | 595 | interface WeakMap { 596 | delete(key: K): boolean; 597 | get(key: K): V; 598 | has(key: K): boolean; 599 | set(key: K, value?: V): WeakMap; 600 | } 601 | 602 | interface WeakMapConstructor { 603 | new (): WeakMap; 604 | new (iterable: IterableShim<[K, V]>): WeakMap; 605 | prototype: WeakMap; 606 | } 607 | 608 | declare var WeakMap: WeakMapConstructor; 609 | 610 | interface WeakSet { 611 | add(value: T): WeakSet; 612 | delete(value: T): boolean; 613 | has(value: T): boolean; 614 | } 615 | 616 | interface WeakSetConstructor { 617 | new (): WeakSet; 618 | new (iterable: IterableShim): WeakSet; 619 | prototype: WeakSet; 620 | } 621 | 622 | declare var WeakSet: WeakSetConstructor; 623 | 624 | declare namespace Reflect { 625 | function apply(target: Function, thisArgument: any, argumentsList: ArrayLike): any; 626 | function construct(target: Function, argumentsList: ArrayLike): any; 627 | function defineProperty(target: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean; 628 | function deleteProperty(target: any, propertyKey: PropertyKey): boolean; 629 | function enumerate(target: any): IterableIteratorShim; 630 | function get(target: any, propertyKey: PropertyKey, receiver?: any): any; 631 | function getOwnPropertyDescriptor(target: any, propertyKey: PropertyKey): PropertyDescriptor; 632 | function getPrototypeOf(target: any): any; 633 | function has(target: any, propertyKey: PropertyKey): boolean; 634 | function isExtensible(target: any): boolean; 635 | function ownKeys(target: any): Array; 636 | function preventExtensions(target: any): boolean; 637 | function set(target: any, propertyKey: PropertyKey, value: any, receiver?: any): boolean; 638 | function setPrototypeOf(target: any, proto: any): boolean; 639 | } 640 | 641 | declare module "es6-shim" { 642 | var String: StringConstructor; 643 | var Array: ArrayConstructor; 644 | var Number: NumberConstructor; 645 | var Math: Math; 646 | var Object: ObjectConstructor; 647 | var Map: MapConstructor; 648 | var Set: SetConstructor; 649 | var WeakMap: WeakMapConstructor; 650 | var WeakSet: WeakSetConstructor; 651 | var Promise: PromiseConstructor; 652 | namespace Reflect { 653 | function apply(target: Function, thisArgument: any, argumentsList: ArrayLike): any; 654 | function construct(target: Function, argumentsList: ArrayLike): any; 655 | function defineProperty(target: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean; 656 | function deleteProperty(target: any, propertyKey: PropertyKey): boolean; 657 | function enumerate(target: any): Iterator; 658 | function get(target: any, propertyKey: PropertyKey, receiver?: any): any; 659 | function getOwnPropertyDescriptor(target: any, propertyKey: PropertyKey): PropertyDescriptor; 660 | function getPrototypeOf(target: any): any; 661 | function has(target: any, propertyKey: PropertyKey): boolean; 662 | function isExtensible(target: any): boolean; 663 | function ownKeys(target: any): Array; 664 | function preventExtensions(target: any): boolean; 665 | function set(target: any, propertyKey: PropertyKey, value: any, receiver?: any): boolean; 666 | function setPrototypeOf(target: any, proto: any): boolean; 667 | } 668 | } 669 | -------------------------------------------------------------------------------- /src/typings/es6-shim/es6-shim.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for es6-shim v0.31.2 2 | // Project: https://github.com/paulmillr/es6-shim 3 | // Definitions by: Ron Buckton 4 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped 5 | 6 | declare type PropertyKey = string | number | symbol; 7 | 8 | interface IteratorResult { 9 | done: boolean; 10 | value?: T; 11 | } 12 | 13 | interface IterableShim { 14 | /** 15 | * Shim for an ES6 iterable. Not intended for direct use by user code. 16 | */ 17 | "_es6-shim iterator_"(): Iterator; 18 | } 19 | 20 | interface Iterator { 21 | next(value?: any): IteratorResult; 22 | return?(value?: any): IteratorResult; 23 | throw?(e?: any): IteratorResult; 24 | } 25 | 26 | interface IterableIteratorShim extends IterableShim, Iterator { 27 | /** 28 | * Shim for an ES6 iterable iterator. Not intended for direct use by user code. 29 | */ 30 | "_es6-shim iterator_"(): IterableIteratorShim; 31 | } 32 | 33 | interface StringConstructor { 34 | /** 35 | * Return the String value whose elements are, in order, the elements in the List elements. 36 | * If length is 0, the empty string is returned. 37 | */ 38 | fromCodePoint(...codePoints: number[]): string; 39 | 40 | /** 41 | * String.raw is intended for use as a tag function of a Tagged Template String. When called 42 | * as such the first argument will be a well formed template call site object and the rest 43 | * parameter will contain the substitution values. 44 | * @param template A well-formed template string call site representation. 45 | * @param substitutions A set of substitution values. 46 | */ 47 | raw(template: TemplateStringsArray, ...substitutions: any[]): string; 48 | } 49 | 50 | interface String { 51 | /** 52 | * Returns a nonnegative integer Number less than 1114112 (0x110000) that is the code point 53 | * value of the UTF-16 encoded code point starting at the string element at position pos in 54 | * the String resulting from converting this object to a String. 55 | * If there is no element at that position, the result is undefined. 56 | * If a valid UTF-16 surrogate pair does not begin at pos, the result is the code unit at pos. 57 | */ 58 | codePointAt(pos: number): number; 59 | 60 | /** 61 | * Returns true if searchString appears as a substring of the result of converting this 62 | * object to a String, at one or more positions that are 63 | * greater than or equal to position; otherwise, returns false. 64 | * @param searchString search string 65 | * @param position If position is undefined, 0 is assumed, so as to search all of the String. 66 | */ 67 | includes(searchString: string, position?: number): boolean; 68 | 69 | /** 70 | * Returns true if the sequence of elements of searchString converted to a String is the 71 | * same as the corresponding elements of this object (converted to a String) starting at 72 | * endPosition – length(this). Otherwise returns false. 73 | */ 74 | endsWith(searchString: string, endPosition?: number): boolean; 75 | 76 | /** 77 | * Returns a String value that is made from count copies appended together. If count is 0, 78 | * T is the empty String is returned. 79 | * @param count number of copies to append 80 | */ 81 | repeat(count: number): string; 82 | 83 | /** 84 | * Returns true if the sequence of elements of searchString converted to a String is the 85 | * same as the corresponding elements of this object (converted to a String) starting at 86 | * position. Otherwise returns false. 87 | */ 88 | startsWith(searchString: string, position?: number): boolean; 89 | 90 | /** 91 | * Returns an HTML anchor element and sets the name attribute to the text value 92 | * @param name 93 | */ 94 | anchor(name: string): string; 95 | 96 | /** Returns a HTML element */ 97 | big(): string; 98 | 99 | /** Returns a HTML element */ 100 | blink(): string; 101 | 102 | /** Returns a HTML element */ 103 | bold(): string; 104 | 105 | /** Returns a HTML element */ 106 | fixed(): string 107 | 108 | /** Returns a HTML element and sets the color attribute value */ 109 | fontcolor(color: string): string 110 | 111 | /** Returns a HTML element and sets the size attribute value */ 112 | fontsize(size: number): string; 113 | 114 | /** Returns a HTML element and sets the size attribute value */ 115 | fontsize(size: string): string; 116 | 117 | /** Returns an HTML element */ 118 | italics(): string; 119 | 120 | /** Returns an HTML element and sets the href attribute value */ 121 | link(url: string): string; 122 | 123 | /** Returns a HTML element */ 124 | small(): string; 125 | 126 | /** Returns a HTML element */ 127 | strike(): string; 128 | 129 | /** Returns a HTML element */ 130 | sub(): string; 131 | 132 | /** Returns a HTML element */ 133 | sup(): string; 134 | 135 | /** 136 | * Shim for an ES6 iterable. Not intended for direct use by user code. 137 | */ 138 | "_es6-shim iterator_"(): IterableIteratorShim; 139 | } 140 | 141 | interface ArrayConstructor { 142 | /** 143 | * Creates an array from an array-like object. 144 | * @param arrayLike An array-like object to convert to an array. 145 | * @param mapfn A mapping function to call on every element of the array. 146 | * @param thisArg Value of 'this' used to invoke the mapfn. 147 | */ 148 | from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => U, thisArg?: any): Array; 149 | 150 | /** 151 | * Creates an array from an iterable object. 152 | * @param iterable An iterable object to convert to an array. 153 | * @param mapfn A mapping function to call on every element of the array. 154 | * @param thisArg Value of 'this' used to invoke the mapfn. 155 | */ 156 | from(iterable: IterableShim, mapfn: (v: T, k: number) => U, thisArg?: any): Array; 157 | 158 | /** 159 | * Creates an array from an array-like object. 160 | * @param arrayLike An array-like object to convert to an array. 161 | */ 162 | from(arrayLike: ArrayLike): Array; 163 | 164 | /** 165 | * Creates an array from an iterable object. 166 | * @param iterable An iterable object to convert to an array. 167 | */ 168 | from(iterable: IterableShim): Array; 169 | 170 | /** 171 | * Returns a new array from a set of elements. 172 | * @param items A set of elements to include in the new array object. 173 | */ 174 | of(...items: T[]): Array; 175 | } 176 | 177 | interface Array { 178 | /** 179 | * Returns the value of the first element in the array where predicate is true, and undefined 180 | * otherwise. 181 | * @param predicate find calls predicate once for each element of the array, in ascending 182 | * order, until it finds one where predicate returns true. If such an element is found, find 183 | * immediately returns that element value. Otherwise, find returns undefined. 184 | * @param thisArg If provided, it will be used as the this value for each invocation of 185 | * predicate. If it is not provided, undefined is used instead. 186 | */ 187 | find(predicate: (value: T, index: number, obj: Array) => boolean, thisArg?: any): T; 188 | 189 | /** 190 | * Returns the index of the first element in the array where predicate is true, and undefined 191 | * otherwise. 192 | * @param predicate find calls predicate once for each element of the array, in ascending 193 | * order, until it finds one where predicate returns true. If such an element is found, find 194 | * immediately returns that element value. Otherwise, find returns undefined. 195 | * @param thisArg If provided, it will be used as the this value for each invocation of 196 | * predicate. If it is not provided, undefined is used instead. 197 | */ 198 | findIndex(predicate: (value: T) => boolean, thisArg?: any): number; 199 | 200 | /** 201 | * Returns the this object after filling the section identified by start and end with value 202 | * @param value value to fill array section with 203 | * @param start index to start filling the array at. If start is negative, it is treated as 204 | * length+start where length is the length of the array. 205 | * @param end index to stop filling the array at. If end is negative, it is treated as 206 | * length+end. 207 | */ 208 | fill(value: T, start?: number, end?: number): T[]; 209 | 210 | /** 211 | * Returns the this object after copying a section of the array identified by start and end 212 | * to the same array starting at position target 213 | * @param target If target is negative, it is treated as length+target where length is the 214 | * length of the array. 215 | * @param start If start is negative, it is treated as length+start. If end is negative, it 216 | * is treated as length+end. 217 | * @param end If not specified, length of the this object is used as its default value. 218 | */ 219 | copyWithin(target: number, start: number, end?: number): T[]; 220 | 221 | /** 222 | * Returns an array of key, value pairs for every entry in the array 223 | */ 224 | entries(): IterableIteratorShim<[number, T]>; 225 | 226 | /** 227 | * Returns an list of keys in the array 228 | */ 229 | keys(): IterableIteratorShim; 230 | 231 | /** 232 | * Returns an list of values in the array 233 | */ 234 | values(): IterableIteratorShim; 235 | 236 | /** 237 | * Shim for an ES6 iterable. Not intended for direct use by user code. 238 | */ 239 | "_es6-shim iterator_"(): IterableIteratorShim; 240 | } 241 | 242 | interface NumberConstructor { 243 | /** 244 | * The value of Number.EPSILON is the difference between 1 and the smallest value greater than 1 245 | * that is representable as a Number value, which is approximately: 246 | * 2.2204460492503130808472633361816 x 10‍−‍16. 247 | */ 248 | EPSILON: number; 249 | 250 | /** 251 | * Returns true if passed value is finite. 252 | * Unlike the global isFininte, Number.isFinite doesn't forcibly convert the parameter to a 253 | * number. Only finite values of the type number, result in true. 254 | * @param number A numeric value. 255 | */ 256 | isFinite(number: number): boolean; 257 | 258 | /** 259 | * Returns true if the value passed is an integer, false otherwise. 260 | * @param number A numeric value. 261 | */ 262 | isInteger(number: number): boolean; 263 | 264 | /** 265 | * Returns a Boolean value that indicates whether a value is the reserved value NaN (not a 266 | * number). Unlike the global isNaN(), Number.isNaN() doesn't forcefully convert the parameter 267 | * to a number. Only values of the type number, that are also NaN, result in true. 268 | * @param number A numeric value. 269 | */ 270 | isNaN(number: number): boolean; 271 | 272 | /** 273 | * Returns true if the value passed is a safe integer. 274 | * @param number A numeric value. 275 | */ 276 | isSafeInteger(number: number): boolean; 277 | 278 | /** 279 | * The value of the largest integer n such that n and n + 1 are both exactly representable as 280 | * a Number value. 281 | * The value of Number.MIN_SAFE_INTEGER is 9007199254740991 2^53 − 1. 282 | */ 283 | MAX_SAFE_INTEGER: number; 284 | 285 | /** 286 | * The value of the smallest integer n such that n and n − 1 are both exactly representable as 287 | * a Number value. 288 | * The value of Number.MIN_SAFE_INTEGER is −9007199254740991 (−(2^53 − 1)). 289 | */ 290 | MIN_SAFE_INTEGER: number; 291 | 292 | /** 293 | * Converts a string to a floating-point number. 294 | * @param string A string that contains a floating-point number. 295 | */ 296 | parseFloat(string: string): number; 297 | 298 | /** 299 | * Converts A string to an integer. 300 | * @param s A string to convert into a number. 301 | * @param radix A value between 2 and 36 that specifies the base of the number in numString. 302 | * If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal. 303 | * All other strings are considered decimal. 304 | */ 305 | parseInt(string: string, radix?: number): number; 306 | } 307 | 308 | interface ObjectConstructor { 309 | /** 310 | * Copy the values of all of the enumerable own properties from one or more source objects to a 311 | * target object. Returns the target object. 312 | * @param target The target object to copy to. 313 | * @param sources One or more source objects to copy properties from. 314 | */ 315 | assign(target: any, ...sources: any[]): any; 316 | 317 | /** 318 | * Returns true if the values are the same value, false otherwise. 319 | * @param value1 The first value. 320 | * @param value2 The second value. 321 | */ 322 | is(value1: any, value2: any): boolean; 323 | 324 | /** 325 | * Sets the prototype of a specified object o to object proto or null. Returns the object o. 326 | * @param o The object to change its prototype. 327 | * @param proto The value of the new prototype or null. 328 | * @remarks Requires `__proto__` support. 329 | */ 330 | setPrototypeOf(o: any, proto: any): any; 331 | } 332 | 333 | interface RegExp { 334 | /** 335 | * Returns a string indicating the flags of the regular expression in question. This field is read-only. 336 | * The characters in this string are sequenced and concatenated in the following order: 337 | * 338 | * - "g" for global 339 | * - "i" for ignoreCase 340 | * - "m" for multiline 341 | * - "u" for unicode 342 | * - "y" for sticky 343 | * 344 | * If no flags are set, the value is the empty string. 345 | */ 346 | flags: string; 347 | } 348 | 349 | interface Math { 350 | /** 351 | * Returns the number of leading zero bits in the 32-bit binary representation of a number. 352 | * @param x A numeric expression. 353 | */ 354 | clz32(x: number): number; 355 | 356 | /** 357 | * Returns the result of 32-bit multiplication of two numbers. 358 | * @param x First number 359 | * @param y Second number 360 | */ 361 | imul(x: number, y: number): number; 362 | 363 | /** 364 | * Returns the sign of the x, indicating whether x is positive, negative or zero. 365 | * @param x The numeric expression to test 366 | */ 367 | sign(x: number): number; 368 | 369 | /** 370 | * Returns the base 10 logarithm of a number. 371 | * @param x A numeric expression. 372 | */ 373 | log10(x: number): number; 374 | 375 | /** 376 | * Returns the base 2 logarithm of a number. 377 | * @param x A numeric expression. 378 | */ 379 | log2(x: number): number; 380 | 381 | /** 382 | * Returns the natural logarithm of 1 + x. 383 | * @param x A numeric expression. 384 | */ 385 | log1p(x: number): number; 386 | 387 | /** 388 | * Returns the result of (e^x - 1) of x (e raised to the power of x, where e is the base of 389 | * the natural logarithms). 390 | * @param x A numeric expression. 391 | */ 392 | expm1(x: number): number; 393 | 394 | /** 395 | * Returns the hyperbolic cosine of a number. 396 | * @param x A numeric expression that contains an angle measured in radians. 397 | */ 398 | cosh(x: number): number; 399 | 400 | /** 401 | * Returns the hyperbolic sine of a number. 402 | * @param x A numeric expression that contains an angle measured in radians. 403 | */ 404 | sinh(x: number): number; 405 | 406 | /** 407 | * Returns the hyperbolic tangent of a number. 408 | * @param x A numeric expression that contains an angle measured in radians. 409 | */ 410 | tanh(x: number): number; 411 | 412 | /** 413 | * Returns the inverse hyperbolic cosine of a number. 414 | * @param x A numeric expression that contains an angle measured in radians. 415 | */ 416 | acosh(x: number): number; 417 | 418 | /** 419 | * Returns the inverse hyperbolic sine of a number. 420 | * @param x A numeric expression that contains an angle measured in radians. 421 | */ 422 | asinh(x: number): number; 423 | 424 | /** 425 | * Returns the inverse hyperbolic tangent of a number. 426 | * @param x A numeric expression that contains an angle measured in radians. 427 | */ 428 | atanh(x: number): number; 429 | 430 | /** 431 | * Returns the square root of the sum of squares of its arguments. 432 | * @param values Values to compute the square root for. 433 | * If no arguments are passed, the result is +0. 434 | * If there is only one argument, the result is the absolute value. 435 | * If any argument is +Infinity or -Infinity, the result is +Infinity. 436 | * If any argument is NaN, the result is NaN. 437 | * If all arguments are either +0 or −0, the result is +0. 438 | */ 439 | hypot(...values: number[]): number; 440 | 441 | /** 442 | * Returns the integral part of the a numeric expression, x, removing any fractional digits. 443 | * If x is already an integer, the result is x. 444 | * @param x A numeric expression. 445 | */ 446 | trunc(x: number): number; 447 | 448 | /** 449 | * Returns the nearest single precision float representation of a number. 450 | * @param x A numeric expression. 451 | */ 452 | fround(x: number): number; 453 | 454 | /** 455 | * Returns an implementation-dependent approximation to the cube root of number. 456 | * @param x A numeric expression. 457 | */ 458 | cbrt(x: number): number; 459 | } 460 | 461 | interface PromiseLike { 462 | /** 463 | * Attaches callbacks for the resolution and/or rejection of the Promise. 464 | * @param onfulfilled The callback to execute when the Promise is resolved. 465 | * @param onrejected The callback to execute when the Promise is rejected. 466 | * @returns A Promise for the completion of which ever callback is executed. 467 | */ 468 | then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): PromiseLike; 469 | then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): PromiseLike; 470 | } 471 | 472 | /** 473 | * Represents the completion of an asynchronous operation 474 | */ 475 | interface Promise { 476 | /** 477 | * Attaches callbacks for the resolution and/or rejection of the Promise. 478 | * @param onfulfilled The callback to execute when the Promise is resolved. 479 | * @param onrejected The callback to execute when the Promise is rejected. 480 | * @returns A Promise for the completion of which ever callback is executed. 481 | */ 482 | then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; 483 | then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): Promise; 484 | 485 | /** 486 | * Attaches a callback for only the rejection of the Promise. 487 | * @param onrejected The callback to execute when the Promise is rejected. 488 | * @returns A Promise for the completion of the callback. 489 | */ 490 | catch(onrejected?: (reason: any) => T | PromiseLike): Promise; 491 | catch(onrejected?: (reason: any) => void): Promise; 492 | } 493 | 494 | interface PromiseConstructor { 495 | /** 496 | * A reference to the prototype. 497 | */ 498 | prototype: Promise; 499 | 500 | /** 501 | * Creates a new Promise. 502 | * @param executor A callback used to initialize the promise. This callback is passed two arguments: 503 | * a resolve callback used resolve the promise with a value or the result of another promise, 504 | * and a reject callback used to reject the promise with a provided reason or error. 505 | */ 506 | new (executor: (resolve: (value?: T | PromiseLike) => void, reject: (reason?: any) => void) => void): Promise; 507 | 508 | /** 509 | * Creates a Promise that is resolved with an array of results when all of the provided Promises 510 | * resolve, or rejected when any Promise is rejected. 511 | * @param values An array of Promises. 512 | * @returns A new Promise. 513 | */ 514 | all(values: IterableShim>): Promise; 515 | 516 | /** 517 | * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved 518 | * or rejected. 519 | * @param values An array of Promises. 520 | * @returns A new Promise. 521 | */ 522 | race(values: IterableShim>): Promise; 523 | 524 | /** 525 | * Creates a new rejected promise for the provided reason. 526 | * @param reason The reason the promise was rejected. 527 | * @returns A new rejected Promise. 528 | */ 529 | reject(reason: any): Promise; 530 | 531 | /** 532 | * Creates a new rejected promise for the provided reason. 533 | * @param reason The reason the promise was rejected. 534 | * @returns A new rejected Promise. 535 | */ 536 | reject(reason: any): Promise; 537 | 538 | /** 539 | * Creates a new resolved promise for the provided value. 540 | * @param value A promise. 541 | * @returns A promise whose internal state matches the provided promise. 542 | */ 543 | resolve(value: T | PromiseLike): Promise; 544 | 545 | /** 546 | * Creates a new resolved promise . 547 | * @returns A resolved promise. 548 | */ 549 | resolve(): Promise; 550 | } 551 | 552 | declare var Promise: PromiseConstructor; 553 | 554 | interface Map { 555 | clear(): void; 556 | delete(key: K): boolean; 557 | forEach(callbackfn: (value: V, index: K, map: Map) => void, thisArg?: any): void; 558 | get(key: K): V; 559 | has(key: K): boolean; 560 | set(key: K, value?: V): Map; 561 | size: number; 562 | entries(): IterableIteratorShim<[K, V]>; 563 | keys(): IterableIteratorShim; 564 | values(): IterableIteratorShim; 565 | } 566 | 567 | interface MapConstructor { 568 | new (): Map; 569 | new (iterable: IterableShim<[K, V]>): Map; 570 | prototype: Map; 571 | } 572 | 573 | declare var Map: MapConstructor; 574 | 575 | interface Set { 576 | add(value: T): Set; 577 | clear(): void; 578 | delete(value: T): boolean; 579 | forEach(callbackfn: (value: T, index: T, set: Set) => void, thisArg?: any): void; 580 | has(value: T): boolean; 581 | size: number; 582 | entries(): IterableIteratorShim<[T, T]>; 583 | keys(): IterableIteratorShim; 584 | values(): IterableIteratorShim; 585 | } 586 | 587 | interface SetConstructor { 588 | new (): Set; 589 | new (iterable: IterableShim): Set; 590 | prototype: Set; 591 | } 592 | 593 | declare var Set: SetConstructor; 594 | 595 | interface WeakMap { 596 | delete(key: K): boolean; 597 | get(key: K): V; 598 | has(key: K): boolean; 599 | set(key: K, value?: V): WeakMap; 600 | } 601 | 602 | interface WeakMapConstructor { 603 | new (): WeakMap; 604 | new (iterable: IterableShim<[K, V]>): WeakMap; 605 | prototype: WeakMap; 606 | } 607 | 608 | declare var WeakMap: WeakMapConstructor; 609 | 610 | interface WeakSet { 611 | add(value: T): WeakSet; 612 | delete(value: T): boolean; 613 | has(value: T): boolean; 614 | } 615 | 616 | interface WeakSetConstructor { 617 | new (): WeakSet; 618 | new (iterable: IterableShim): WeakSet; 619 | prototype: WeakSet; 620 | } 621 | 622 | declare var WeakSet: WeakSetConstructor; 623 | 624 | declare namespace Reflect { 625 | function apply(target: Function, thisArgument: any, argumentsList: ArrayLike): any; 626 | function construct(target: Function, argumentsList: ArrayLike): any; 627 | function defineProperty(target: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean; 628 | function deleteProperty(target: any, propertyKey: PropertyKey): boolean; 629 | function enumerate(target: any): IterableIteratorShim; 630 | function get(target: any, propertyKey: PropertyKey, receiver?: any): any; 631 | function getOwnPropertyDescriptor(target: any, propertyKey: PropertyKey): PropertyDescriptor; 632 | function getPrototypeOf(target: any): any; 633 | function has(target: any, propertyKey: PropertyKey): boolean; 634 | function isExtensible(target: any): boolean; 635 | function ownKeys(target: any): Array; 636 | function preventExtensions(target: any): boolean; 637 | function set(target: any, propertyKey: PropertyKey, value: any, receiver?: any): boolean; 638 | function setPrototypeOf(target: any, proto: any): boolean; 639 | } 640 | 641 | declare module "es6-shim" { 642 | var String: StringConstructor; 643 | var Array: ArrayConstructor; 644 | var Number: NumberConstructor; 645 | var Math: Math; 646 | var Object: ObjectConstructor; 647 | var Map: MapConstructor; 648 | var Set: SetConstructor; 649 | var WeakMap: WeakMapConstructor; 650 | var WeakSet: WeakSetConstructor; 651 | var Promise: PromiseConstructor; 652 | namespace Reflect { 653 | function apply(target: Function, thisArgument: any, argumentsList: ArrayLike): any; 654 | function construct(target: Function, argumentsList: ArrayLike): any; 655 | function defineProperty(target: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean; 656 | function deleteProperty(target: any, propertyKey: PropertyKey): boolean; 657 | function enumerate(target: any): Iterator; 658 | function get(target: any, propertyKey: PropertyKey, receiver?: any): any; 659 | function getOwnPropertyDescriptor(target: any, propertyKey: PropertyKey): PropertyDescriptor; 660 | function getPrototypeOf(target: any): any; 661 | function has(target: any, propertyKey: PropertyKey): boolean; 662 | function isExtensible(target: any): boolean; 663 | function ownKeys(target: any): Array; 664 | function preventExtensions(target: any): boolean; 665 | function set(target: any, propertyKey: PropertyKey, value: any, receiver?: any): boolean; 666 | function setPrototypeOf(target: any, proto: any): boolean; 667 | } 668 | } 669 | --------------------------------------------------------------------------------