@barchart/portfolio-api-common 1.4.2 → 1.5.1

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 CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "esversion": 6,
2
+ "esversion": 9,
3
3
  "validthis": true,
4
4
  "-W018": true,
5
5
  "-W093": true
@@ -0,0 +1,3 @@
1
+ **New Features**
2
+
3
+ * Added new ```Schema``` for results of a query by symbol.
@@ -0,0 +1,3 @@
1
+ **Configuration Changes**
2
+
3
+ * The failure message for corrupt corporate actions (e.g. two instruments with same symbol) was updated to indicate an expected time to correction (of 24 to 48 hours).
package/gulpfile.js CHANGED
@@ -4,12 +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'),
7
+ exec = require('child_process').exec,
8
8
  git = require('gulp-git'),
9
9
  gitStatus = require('git-get-status'),
10
10
  glob = require('glob'),
11
11
  jasmine = require('gulp-jasmine'),
12
12
  jshint = require('gulp-jshint'),
13
+ prompt = require('gulp-prompt'),
13
14
  source = require('vinyl-source-stream');
14
15
 
15
16
  function getVersionFromPackage() {
@@ -26,10 +27,31 @@ gulp.task('ensure-clean-working-directory', (cb) => {
26
27
  });
27
28
  });
28
29
 
29
- gulp.task('bump-version', () => {
30
- return gulp.src([ './package.json' ])
31
- .pipe(bump({ type: 'patch' }))
32
- .pipe(gulp.dest('./'));
30
+ gulp.task('bump-choice', (cb) => {
31
+ const processor = prompt.prompt({
32
+ type: 'list',
33
+ name: 'bump',
34
+ message: 'What type of bump would you like to do?',
35
+ choices: ['patch', 'minor', 'major'],
36
+ }, (res) => {
37
+ global.bump = res.bump;
38
+
39
+ return cb();
40
+ });
41
+
42
+ return gulp.src(['./package.json']).pipe(processor);
43
+ });
44
+
45
+ gulp.task('bump-version', (cb) => {
46
+ exec(`npm version ${global.bump || 'patch'} --no-git-tag-version`, {
47
+ cwd: './'
48
+ }, (error) => {
49
+ if (error) {
50
+ cb(error);
51
+ }
52
+
53
+ cb();
54
+ });
33
55
  });
34
56
 
35
57
  gulp.task('commit-changes', () => {
@@ -81,6 +103,7 @@ gulp.task('execute-tests', gulp.series(
81
103
  gulp.task('release', gulp.series(
82
104
  'ensure-clean-working-directory',
83
105
  'execute-tests',
106
+ 'bump-choice',
84
107
  'bump-version',
85
108
  'commit-changes',
86
109
  'push-changes',
@@ -89,7 +112,7 @@ gulp.task('release', gulp.series(
89
112
 
90
113
  gulp.task('lint', () => {
91
114
  return gulp.src([ './**/*.js', './test/specs/**/*.js', '!./node_modules/**', '!./test/SpecRunner.js' ])
92
- .pipe(jshint({'esversion': 6}))
115
+ .pipe(jshint({'esversion': 9}))
93
116
  .pipe(jshint.reporter('default'))
94
117
  .pipe(jshint.reporter('fail'));
95
118
  });
@@ -353,7 +353,7 @@ module.exports = (() => {
353
353
  const transactionCreateFailedTypeReserved = new FailureType('TRANSACTION_CREATE_FAILED_TYPE_RESERVED', 'Unable to create {U|type.description} transaction, this type of transaction is managed by the system.');
354
354
  const transactionCreateFailedReinvestPriceUnavailable = new FailureType('TRANSACTION_CREATE_FAILED_REINVEST_PRICE_UNAVAILABLE', 'Unable to create transaction, a dividend was paid on {L|day}; however no historical price is available for this day. To successfully create this transaction, please turn off dividend reinvestment for this position.');
355
355
  const transactionCreateFailedPositionLocked = new FailureType('TRANSACTION_CREATE_FAILED_POSITION_LOCKED', 'Unable to create transaction, your {L|description} history is being recalculated. Please re-enter this transaction in a minute or two.');
356
- const transactionCreateFailedInstrumentCorrupt = new FailureType('TRANSACTION_CREATE_FAILED_INSTRUMENT_CORRUPT', 'Unable to create transaction, corporate action history for {U|symbol} cannot be located.');
356
+ const transactionCreateFailedInstrumentCorrupt = new FailureType('TRANSACTION_CREATE_FAILED_INSTRUMENT_CORRUPT', 'Unable to create transaction, corporate action history for {U|symbol} cannot be located. The issue should be corrected within 24 to 48 hours.');
357
357
 
358
358
  const transactionDeleteFailedOutOfSequence = new FailureType('TRANSACTION_DELETE_FAILED_OUT_OF_SEQUENCE', 'Deleting any transaction, except for the most recent, will cause transaction history to be re-written. Please confirm your intent to re-write transaction history (which could take some time and alter the historical results for this position).');
359
359
  const transactionDeleteFailedNoTransaction = new FailureType('TRANSACTION_DELETE_FAILED_NO_TRANSACTION', 'Unable to delete transaction. The referenced transaction does not exist.', false);
@@ -40,14 +40,14 @@ module.exports = (() => {
40
40
 
41
41
  this._reporting = reporting;
42
42
 
43
- this._data = { };
44
-
45
- this._data.basis = null;
46
-
47
43
  this._currentQuote = null;
48
44
  this._previousQuote = null;
49
45
  this._currentPrice = null;
50
46
 
47
+ this._data = { };
48
+
49
+ this._data.basis = null;
50
+
51
51
  this._data.currentPrice = null;
52
52
  this._data.currentPricePrevious = null;
53
53
 
@@ -67,6 +67,17 @@ module.exports = (() => {
67
67
  return update;
68
68
  }
69
69
 
70
+ /**
71
+ * Result item for query of positions by symbol.
72
+ *
73
+ * @static
74
+ * @public
75
+ * @returns {PositionSchema}
76
+ */
77
+ static get SIMPLE() {
78
+ return simple;
79
+ }
80
+
70
81
  toString() {
71
82
  return '[PositionSchema]';
72
83
  }
@@ -102,8 +113,8 @@ module.exports = (() => {
102
113
  .withField('legacy.portfolio', DataType.STRING, true)
103
114
  .withField('legacy.position', DataType.STRING, true)
104
115
  .withField('system.version', DataType.NUMBER, true)
105
- .withField('system.locked', DataType.BOOLEAN, true)
106
116
  .withField('system.calculate.processors', DataType.NUMBER, true)
117
+ .withField('system.locked', DataType.BOOLEAN, true)
107
118
  .withField('root', DataType.STRING, true)
108
119
  .schema
109
120
  );
@@ -133,8 +144,8 @@ module.exports = (() => {
133
144
  .withField('snapshot.basis', DataType.DECIMAL)
134
145
  .withField('snapshot.income', DataType.DECIMAL)
135
146
  .withField('snapshot.value', DataType.DECIMAL)
136
- .withField('system.locked', DataType.BOOLEAN, true)
137
147
  .withField('system.calculate.processors', DataType.NUMBER, true)
148
+ .withField('system.locked', DataType.BOOLEAN, true)
138
149
  .withField('previous', DataType.NUMBER, true)
139
150
  .schema
140
151
  );
@@ -152,5 +163,17 @@ module.exports = (() => {
152
163
  .schema
153
164
  );
154
165
 
166
+ const simple = new PositionSchema(SchemaBuilder.withName('simple')
167
+ .withField('user', DataType.STRING)
168
+ .withField('portfolio', DataType.STRING)
169
+ .withField('instrument.id', DataType.STRING)
170
+ .withField('instrument.name', DataType.STRING)
171
+ .withField('instrument.symbol.barchart', DataType.STRING, true)
172
+ .withField('instrument.symbol.display', DataType.STRING, true)
173
+ .withField('position', DataType.STRING)
174
+ .withField('open', DataType.BOOLEAN, true)
175
+ .schema
176
+ );
177
+
155
178
  return PositionSchema;
156
179
  })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barchart/portfolio-api-common",
3
- "version": "1.4.2",
3
+ "version": "1.5.1",
4
4
  "description": "Common code used by the Portfolio system",
5
5
  "author": {
6
6
  "name": "Bryan Ingle",
@@ -19,11 +19,11 @@
19
19
  "git-get-status": "^1.0.5",
20
20
  "glob": "^6.0.1",
21
21
  "gulp": "^4.0.2",
22
- "gulp-bump": "~1.0.0",
23
22
  "gulp-git": "^2.9.0",
24
23
  "gulp-jasmine": "^2.2.1",
25
- "gulp-jshint": "~2.1.0",
26
- "jshint": "2.9.5",
24
+ "gulp-jshint": "^2.1.0",
25
+ "gulp-prompt": "^1.2.0",
26
+ "jshint": "^2.10.3",
27
27
  "vinyl-buffer": "^1.0.1",
28
28
  "vinyl-source-stream": "^2.0.0"
29
29
  },