@barchart/portfolio-client-js 1.4.4 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.jshintrc +2 -2
- package/example/example.js +59 -5
- package/gulpfile.js +29 -6
- package/lib/gateway/PortfolioGateway.js +36 -0
- package/lib/index.js +1 -1
- package/package.json +4 -4
package/.jshintrc
CHANGED
package/example/example.js
CHANGED
|
@@ -1169,6 +1169,9 @@ module.exports = (() => {
|
|
|
1169
1169
|
}).withQueryBuilder(qb => {
|
|
1170
1170
|
qb.withVariableParameter('frames', 'frames', 'frames', true, frames => frames.map(f => f.code).join());
|
|
1171
1171
|
}).withRequestInterceptor(requestInterceptorToUse).withRequestInterceptor(RequestInterceptor.PLAIN_TEXT_RESPONSE).withResponseInterceptor(responseInterceptorForBrokerageReportAvailabilityDeserialization).withErrorInterceptor(ErrorInterceptor.GENERAL).endpoint;
|
|
1172
|
+
this._readVersionEndpoint = EndpointBuilder.for('read-api-version', 'read api version').withVerb(VerbType.GET).withProtocol(protocolType).withHost(host).withPort(port).withPathBuilder(pb => {
|
|
1173
|
+
pb.withLiteralParameter('system', 'system').withLiteralParameter('version', 'version');
|
|
1174
|
+
}).withRequestInterceptor(requestInterceptorToUse).withRequestInterceptor(RequestInterceptor.PLAIN_TEXT_RESPONSE).withResponseInterceptor(responseInterceptorForVersion).withErrorInterceptor(ErrorInterceptor.GENERAL).endpoint;
|
|
1172
1175
|
|
|
1173
1176
|
this._brokerageReportUrlGenerator = (user, portfolio, frame, end) => {
|
|
1174
1177
|
return `https://${Configuration.getBrokerageHost(host)}/reports/portfolios/${portfolio}/frames/${frame.code}/date/${end.format()}/${user}`;
|
|
@@ -1838,6 +1841,19 @@ module.exports = (() => {
|
|
|
1838
1841
|
return Gateway.invoke(this._readBrokerageReportAvailabilityEndpoint, payload);
|
|
1839
1842
|
});
|
|
1840
1843
|
}
|
|
1844
|
+
/**
|
|
1845
|
+
* Returns current API version of portfolio.
|
|
1846
|
+
*
|
|
1847
|
+
* @public
|
|
1848
|
+
* @returns {Promise<Object>}
|
|
1849
|
+
*/
|
|
1850
|
+
|
|
1851
|
+
|
|
1852
|
+
readVersion() {
|
|
1853
|
+
return Promise.resolve().then(() => {
|
|
1854
|
+
return Gateway.invoke(this._readVersionEndpoint);
|
|
1855
|
+
});
|
|
1856
|
+
}
|
|
1841
1857
|
/**
|
|
1842
1858
|
* Generates a URL suitable for downloading a brokerage report (as a PDF).
|
|
1843
1859
|
*
|
|
@@ -2052,6 +2068,13 @@ module.exports = (() => {
|
|
|
2052
2068
|
console.error('Error deserializing data', e);
|
|
2053
2069
|
}
|
|
2054
2070
|
});
|
|
2071
|
+
const responseInterceptorForVersion = ResponseInterceptor.fromDelegate((response, ignored) => {
|
|
2072
|
+
try {
|
|
2073
|
+
return JSON.parse(response.data).version;
|
|
2074
|
+
} catch (e) {
|
|
2075
|
+
console.error('Error deserializing data', e);
|
|
2076
|
+
}
|
|
2077
|
+
});
|
|
2055
2078
|
|
|
2056
2079
|
function start(gateway) {
|
|
2057
2080
|
return gateway.start().then(() => {
|
|
@@ -2473,7 +2496,7 @@ module.exports = (() => {
|
|
|
2473
2496
|
return {
|
|
2474
2497
|
JwtGateway: JwtGateway,
|
|
2475
2498
|
PortfolioGateway: PortfolioGateway,
|
|
2476
|
-
version: '1.
|
|
2499
|
+
version: '1.5.0'
|
|
2477
2500
|
};
|
|
2478
2501
|
})();
|
|
2479
2502
|
|
|
@@ -7043,8 +7066,11 @@ const moment = require('moment-timezone');
|
|
|
7043
7066
|
|
|
7044
7067
|
module.exports = (() => {
|
|
7045
7068
|
'use strict';
|
|
7069
|
+
|
|
7070
|
+
const MILLISECONDS_PER_SECOND = 1000;
|
|
7046
7071
|
/**
|
|
7047
|
-
*
|
|
7072
|
+
* An immutable data structure that encapsulates (and lazy loads)
|
|
7073
|
+
* a moment (see https://momentjs.com/).
|
|
7048
7074
|
*
|
|
7049
7075
|
* @public
|
|
7050
7076
|
* @param {Number} timestamp
|
|
@@ -7060,7 +7086,7 @@ module.exports = (() => {
|
|
|
7060
7086
|
this._moment = null;
|
|
7061
7087
|
}
|
|
7062
7088
|
/**
|
|
7063
|
-
* The timestamp.
|
|
7089
|
+
* The timestamp (milliseconds since epoch).
|
|
7064
7090
|
*
|
|
7065
7091
|
* @public
|
|
7066
7092
|
* @returns {Number}
|
|
@@ -7089,6 +7115,34 @@ module.exports = (() => {
|
|
|
7089
7115
|
|
|
7090
7116
|
return this._moment;
|
|
7091
7117
|
}
|
|
7118
|
+
/**
|
|
7119
|
+
* Returns a new {@link Timestamp} instance shifted forward (or backward)
|
|
7120
|
+
* by a specific number of seconds.
|
|
7121
|
+
*
|
|
7122
|
+
* @public
|
|
7123
|
+
* @param {Number} milliseconds
|
|
7124
|
+
* @returns {Timestamp}
|
|
7125
|
+
*/
|
|
7126
|
+
|
|
7127
|
+
|
|
7128
|
+
add(milliseconds) {
|
|
7129
|
+
assert.argumentIsRequired(milliseconds, 'seconds', Number);
|
|
7130
|
+
return new Timestamp(this._timestamp + milliseconds, this._timezone);
|
|
7131
|
+
}
|
|
7132
|
+
/**
|
|
7133
|
+
* Returns a new {@link Timestamp} instance shifted forward (or backward)
|
|
7134
|
+
* by a specific number of seconds.
|
|
7135
|
+
*
|
|
7136
|
+
* @public
|
|
7137
|
+
* @param {Number} seconds
|
|
7138
|
+
* @returns {Timestamp}
|
|
7139
|
+
*/
|
|
7140
|
+
|
|
7141
|
+
|
|
7142
|
+
addSeconds(seconds) {
|
|
7143
|
+
assert.argumentIsRequired(seconds, 'seconds', Number);
|
|
7144
|
+
return this.add(seconds * MILLISECONDS_PER_SECOND);
|
|
7145
|
+
}
|
|
7092
7146
|
/**
|
|
7093
7147
|
* Returns the JSON representation.
|
|
7094
7148
|
*
|
|
@@ -11473,8 +11527,8 @@ module.exports = (() => {
|
|
|
11473
11527
|
.withField('legacy.portfolio', DataType.STRING, true)
|
|
11474
11528
|
.withField('legacy.position', DataType.STRING, true)
|
|
11475
11529
|
.withField('system.version', DataType.NUMBER, true)
|
|
11476
|
-
.withField('system.locked', DataType.BOOLEAN, true)
|
|
11477
11530
|
.withField('system.calculate.processors', DataType.NUMBER, true)
|
|
11531
|
+
.withField('system.locked', DataType.BOOLEAN, true)
|
|
11478
11532
|
.withField('root', DataType.STRING, true)
|
|
11479
11533
|
.schema
|
|
11480
11534
|
);
|
|
@@ -11504,8 +11558,8 @@ module.exports = (() => {
|
|
|
11504
11558
|
.withField('snapshot.basis', DataType.DECIMAL)
|
|
11505
11559
|
.withField('snapshot.income', DataType.DECIMAL)
|
|
11506
11560
|
.withField('snapshot.value', DataType.DECIMAL)
|
|
11507
|
-
.withField('system.locked', DataType.BOOLEAN, true)
|
|
11508
11561
|
.withField('system.calculate.processors', DataType.NUMBER, true)
|
|
11562
|
+
.withField('system.locked', DataType.BOOLEAN, true)
|
|
11509
11563
|
.withField('previous', DataType.NUMBER, true)
|
|
11510
11564
|
.schema
|
|
11511
11565
|
);
|
package/gulpfile.js
CHANGED
|
@@ -4,13 +4,13 @@ const fs = require('fs');
|
|
|
4
4
|
|
|
5
5
|
const browserify = require('browserify'),
|
|
6
6
|
buffer = require('vinyl-buffer'),
|
|
7
|
-
bump = require('gulp-bump'),
|
|
8
7
|
exec = require('child_process').exec,
|
|
9
8
|
git = require('gulp-git'),
|
|
10
9
|
gitStatus = require('git-get-status'),
|
|
11
10
|
glob = require('glob'),
|
|
12
11
|
jasmine = require('gulp-jasmine'),
|
|
13
12
|
jshint = require('gulp-jshint'),
|
|
13
|
+
prompt = require('gulp-prompt'),
|
|
14
14
|
replace = require('gulp-replace'),
|
|
15
15
|
source = require('vinyl-source-stream');
|
|
16
16
|
|
|
@@ -28,10 +28,32 @@ gulp.task('ensure-clean-working-directory', (cb) => {
|
|
|
28
28
|
});
|
|
29
29
|
});
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
|
|
32
|
+
gulp.task('bump-choice', (cb) => {
|
|
33
|
+
const processor = prompt.prompt({
|
|
34
|
+
type: 'list',
|
|
35
|
+
name: 'bump',
|
|
36
|
+
message: 'What type of bump would you like to do?',
|
|
37
|
+
choices: ['patch', 'minor', 'major'],
|
|
38
|
+
}, (res) => {
|
|
39
|
+
global.bump = res.bump;
|
|
40
|
+
|
|
41
|
+
return cb();
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
return gulp.src(['./package.json']).pipe(processor);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
gulp.task('bump-version', (cb) => {
|
|
48
|
+
exec(`npm version ${global.bump || 'patch'} --no-git-tag-version`, {
|
|
49
|
+
cwd: './'
|
|
50
|
+
}, (error) => {
|
|
51
|
+
if (error) {
|
|
52
|
+
cb(error);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
cb();
|
|
56
|
+
});
|
|
35
57
|
});
|
|
36
58
|
|
|
37
59
|
gulp.task('embed-version', () => {
|
|
@@ -99,6 +121,7 @@ gulp.task('execute-tests', gulp.series(
|
|
|
99
121
|
gulp.task('release', gulp.series(
|
|
100
122
|
'ensure-clean-working-directory',
|
|
101
123
|
'execute-tests',
|
|
124
|
+
'bump-choice',
|
|
102
125
|
'bump-version',
|
|
103
126
|
'embed-version',
|
|
104
127
|
'build-example-bundle',
|
|
@@ -109,7 +132,7 @@ gulp.task('release', gulp.series(
|
|
|
109
132
|
|
|
110
133
|
gulp.task('lint', () => {
|
|
111
134
|
return gulp.src([ './**/*.js', './test/specs/**/*.js', '!./node_modules/**', '!./docs/**', '!./test/SpecRunner.js', '!./example/example.js' ])
|
|
112
|
-
.pipe(jshint({
|
|
135
|
+
.pipe(jshint({ esversion: 9 }))
|
|
113
136
|
.pipe(jshint.reporter('default'))
|
|
114
137
|
.pipe(jshint.reporter('fail'));
|
|
115
138
|
});
|
|
@@ -385,6 +385,21 @@ module.exports = (() => {
|
|
|
385
385
|
.withErrorInterceptor(ErrorInterceptor.GENERAL)
|
|
386
386
|
.endpoint;
|
|
387
387
|
|
|
388
|
+
this._readVersionEndpoint = EndpointBuilder.for('read-api-version', 'read api version')
|
|
389
|
+
.withVerb(VerbType.GET)
|
|
390
|
+
.withProtocol(protocolType)
|
|
391
|
+
.withHost(host)
|
|
392
|
+
.withPort(port)
|
|
393
|
+
.withPathBuilder((pb) => {
|
|
394
|
+
pb.withLiteralParameter('system', 'system')
|
|
395
|
+
.withLiteralParameter('version', 'version');
|
|
396
|
+
})
|
|
397
|
+
.withRequestInterceptor(requestInterceptorToUse)
|
|
398
|
+
.withRequestInterceptor(RequestInterceptor.PLAIN_TEXT_RESPONSE)
|
|
399
|
+
.withResponseInterceptor(responseInterceptorForVersion)
|
|
400
|
+
.withErrorInterceptor(ErrorInterceptor.GENERAL)
|
|
401
|
+
.endpoint;
|
|
402
|
+
|
|
388
403
|
this._brokerageReportUrlGenerator = (user, portfolio, frame, end) => {
|
|
389
404
|
return `https://${Configuration.getBrokerageHost(host)}/reports/portfolios/${portfolio}/frames/${frame.code}/date/${end.format()}/${user}`;
|
|
390
405
|
};
|
|
@@ -1088,6 +1103,19 @@ module.exports = (() => {
|
|
|
1088
1103
|
});
|
|
1089
1104
|
}
|
|
1090
1105
|
|
|
1106
|
+
/**
|
|
1107
|
+
* Returns current API version of portfolio.
|
|
1108
|
+
*
|
|
1109
|
+
* @public
|
|
1110
|
+
* @returns {Promise<Object>}
|
|
1111
|
+
*/
|
|
1112
|
+
readVersion() {
|
|
1113
|
+
return Promise.resolve()
|
|
1114
|
+
.then(() => {
|
|
1115
|
+
return Gateway.invoke(this._readVersionEndpoint);
|
|
1116
|
+
});
|
|
1117
|
+
}
|
|
1118
|
+
|
|
1091
1119
|
/**
|
|
1092
1120
|
* Generates a URL suitable for downloading a brokerage report (as a PDF).
|
|
1093
1121
|
*
|
|
@@ -1323,6 +1351,14 @@ module.exports = (() => {
|
|
|
1323
1351
|
}
|
|
1324
1352
|
});
|
|
1325
1353
|
|
|
1354
|
+
const responseInterceptorForVersion = ResponseInterceptor.fromDelegate((response, ignored) => {
|
|
1355
|
+
try {
|
|
1356
|
+
return JSON.parse(response.data).version;
|
|
1357
|
+
} catch (e) {
|
|
1358
|
+
console.error('Error deserializing data', e);
|
|
1359
|
+
}
|
|
1360
|
+
});
|
|
1361
|
+
|
|
1326
1362
|
function start(gateway) {
|
|
1327
1363
|
return gateway.start()
|
|
1328
1364
|
.then(() => {
|
package/lib/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@barchart/portfolio-client-js",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "JavaScript library for interfacing with Barchart's Portfolio API",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Bryan Ingle",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
],
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@barchart/common-js": "^3.5.1",
|
|
25
|
-
"@barchart/portfolio-api-common": "^1.4.
|
|
25
|
+
"@barchart/portfolio-api-common": "^1.4.4"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@babel/core": "^7.6.2",
|
|
@@ -31,13 +31,13 @@
|
|
|
31
31
|
"git-get-status": "^1.0.5",
|
|
32
32
|
"glob": "^6.0.1",
|
|
33
33
|
"gulp": "^4.0.2",
|
|
34
|
-
"gulp-bump": "~1.0.0",
|
|
35
34
|
"gulp-git": "^2.9.0",
|
|
36
35
|
"gulp-jasmine": "^2.2.1",
|
|
37
36
|
"gulp-jsdoc3": "^1.0.1",
|
|
38
37
|
"gulp-jshint": "~2.1.0",
|
|
39
38
|
"gulp-replace": "^0.5.4",
|
|
40
|
-
"
|
|
39
|
+
"gulp-prompt": "^1.2.0",
|
|
40
|
+
"jshint": "^2.10.3",
|
|
41
41
|
"vinyl-buffer": "^1.0.1",
|
|
42
42
|
"vinyl-source-stream": "^2.0.0"
|
|
43
43
|
},
|