Skip to content

Commit

Permalink
Exposing also ts type definitions. Now the interface or type definiti…
Browse files Browse the repository at this point in the history
…on can be shared with hawkular console.
  • Loading branch information
jkremser committed Jan 13, 2016
1 parent c4d0417 commit feb9ff8
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 15 deletions.
3 changes: 2 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"hawkular-ui"
],
"main": [
"dist/hawkular-ui-service.js"
"dist/hawkular-ui-service.js",
"dist/defs/hawkRest.d.ts"
],
"ignore": [
"*",
Expand Down
26 changes: 20 additions & 6 deletions gulp/scripts.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,28 @@
'use strict';

import gulp from 'gulp';
import gulp from 'gulp';
import tslintRules from '../tslint.json';
import merge from 'merge2';

const paths = gulp.paths;

const $ = require('gulp-load-plugins')({
pattern: ['gulp-*', 'del']
});

const config = {
main: '.',
ts: ['src/**/*.ts'],
tsProject: $.typescript.createProject({
target: 'ES5',
module: 'commonjs',
declaration: true,
removeComments: true,
noExternalResolve: false
})
};


gulp.task('tslint', function () {
gulp.src([paths.src + '/hawkRest.ts', paths.src + '/hawkRest-*.ts'])
.pipe($.tslint({
Expand All @@ -21,20 +35,20 @@ gulp.task('scripts', function () {

const license = tslintRules.rules['license-header'][1];

return gulp.src([paths.src + '/hawkRest.ts', paths.src + '/hawkRest-*.ts'])
.pipe($.typescript({
removeComments: true
}))
const tsResult = gulp.src([paths.src + '/hawkRest.ts', paths.src + '/hawkRest*.ts'])
.pipe($.typescript(config.tsProject))
.on('error', function handleError(err) {
console.error(err.toString());
this.emit('end');
})
});
const jsPipe = tsResult
.pipe($.concat('hawkular-ui-service.js'))
.pipe($.header(license))
.pipe(gulp.dest(paths.dist + '/'))
.pipe($.concat('hawkular-ui-service.min.js'))
//.pipe($.uglify())
.pipe(gulp.dest(paths.dist + '/'));
return merge([tsResult.dts.pipe(gulp.dest(paths.dist + '/defs')), jsPipe]);
});

gulp.task('clean', function (done) {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"gulp-tslint": "3.3.1",
"gulp-typescript": "2.10.0",
"gulp-uglify": "1.5.1",
"merge2": "0.3.6",
"karma-jasmine": "0.3.6",
"karma-phantomjs-launcher": "0.2.1",
"lodash": "3.10.1",
Expand Down
10 changes: 2 additions & 8 deletions src/rest/hawkRest-inventory-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,6 @@

module hawkularRest {

export interface IWebSocketHandler {
onmessage?(json: any): void;
onopen? (event: any): void;
onclose? (event: any): void;
onerror? (event: any): void;
}

_module.constant('inventoryInterceptURLS',
[new RegExp('.+/inventory/.+/resources/.+%2F.+', 'i'), new RegExp('.+/inventory/.+/resources/.+%252F.+', 'i')]);

Expand Down Expand Up @@ -298,7 +291,8 @@ module hawkularRest {
if (handler && handler.onmessage) {
handler.onmessage(eventData);
} else {
$log.log('ws: received event: ' + eventData);
$log.log('ws: received event');
$log.log(eventData);
}
};

Expand Down
9 changes: 9 additions & 0 deletions src/rest/hawkRest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,13 @@ module hawkularRest {

export var _module = angular.module('hawkular.services', ['ngResource']);

// here comes type definitions and interfaces that can be reused by consumers of this module
// these types/ifaces can define a contract
export interface IWebSocketHandler {
onmessage?(json: any): void;
onopen?(event: any): void;
onclose?(event: any): void;
onerror?(event: any): void;
}

}

0 comments on commit feb9ff8

Please sign in to comment.