@barchart/portfolio-api-common 1.3.22 → 1.4.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,6 @@
1
1
  {
2
2
  "esversion": 6,
3
3
  "validthis": true,
4
- "-W018": true
4
+ "-W018": true,
5
+ "-W093": true
5
6
  }
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # @barchart/portfolio-api-common
2
2
 
3
+ [![AWS CodeBuild](https://codebuild.us-east-1.amazonaws.com/badges?uuid=eyJlbmNyeXB0ZWREYXRhIjoiSXBJTDZKWVFmSGVOSG9XQUgwbzB3Um5BZ0JsN2h1U3NQNWNhZTRHMlJKTVpEVVlVMENPaEFmR0NYS29rSStZWmZ5M1d0YVh2eXErVGhiekFtdHBpVmhJPSIsIml2UGFyYW1ldGVyU3BlYyI6ImROM3ZLMURwaXFyekltdDYiLCJtYXRlcmlhbFNldFNlcmlhbCI6MX0%3D&branch=master)](https://github.com/barchart/portfolio-api-common)
4
+
3
5
  A *private* library of shared JavaScript code pertaining to the paper-trading portfolio system.
4
6
 
5
7
  ### Overview
package/buildspec.yml ADDED
@@ -0,0 +1,15 @@
1
+ version: 0.2
2
+
3
+ phases:
4
+ install:
5
+ runtime-versions:
6
+ nodejs: 12.x
7
+
8
+ pre_build:
9
+ commands:
10
+ - npm install
11
+
12
+ build:
13
+ commands:
14
+ - ./node_modules/.bin/gulp lint
15
+ - ./node_modules/.bin/gulp test
package/gulpfile.js CHANGED
@@ -5,7 +5,6 @@ const fs = require('fs');
5
5
  const browserify = require('browserify'),
6
6
  buffer = require('vinyl-buffer'),
7
7
  bump = require('gulp-bump'),
8
- exec = require('child_process').exec,
9
8
  git = require('gulp-git'),
10
9
  gitStatus = require('git-get-status'),
11
10
  glob = require('glob'),
@@ -14,7 +13,7 @@ const browserify = require('browserify'),
14
13
  source = require('vinyl-source-stream');
15
14
 
16
15
  function getVersionFromPackage() {
17
- return JSON.parse(fs.readFileSync('./package.json', 'utf8')).version;
16
+ return JSON.parse(fs.readFileSync('./package.json', 'utf8')).version;
18
17
  }
19
18
 
20
19
  gulp.task('ensure-clean-working-directory', (cb) => {
@@ -33,35 +32,26 @@ gulp.task('bump-version', () => {
33
32
  .pipe(gulp.dest('./'));
34
33
  });
35
34
 
36
- gulp.task('document', (cb) => {
37
- exec('jsdoc . -c jsdoc.json -r -d docs', (error, stdout, stderr) => {
38
- console.log(stdout);
39
- console.log(stderr);
40
-
41
- cb();
42
- });
43
- });
44
-
45
35
  gulp.task('commit-changes', () => {
46
- return gulp.src([ './', './test/', './package.json' ])
47
- .pipe(git.add())
48
- .pipe(git.commit('Release. Bump version number'));
36
+ return gulp.src([ './', './test/', './package.json' ])
37
+ .pipe(git.add())
38
+ .pipe(git.commit('Release. Bump version number'));
49
39
  });
50
40
 
51
41
  gulp.task('push-changes', (cb) => {
52
- git.push('origin', 'master', cb);
42
+ git.push('origin', 'master', cb);
53
43
  });
54
44
 
55
45
  gulp.task('create-tag', (cb) => {
56
- const version = getVersionFromPackage();
46
+ const version = getVersionFromPackage();
57
47
 
58
- git.tag(version, 'Release ' + version, (error) => {
59
- if (error) {
60
- return cb(error);
61
- }
48
+ git.tag(version, 'Release ' + version, (error) => {
49
+ if (error) {
50
+ return cb(error);
51
+ }
62
52
 
63
- git.push('origin', 'master', { args: '--tags' }, cb);
64
- });
53
+ git.push('origin', 'master', { args: '--tags' }, cb);
54
+ });
65
55
  });
66
56
 
67
57
  gulp.task('build-test-bundle', () => {
@@ -73,13 +63,13 @@ gulp.task('build-test-bundle', () => {
73
63
  });
74
64
 
75
65
  gulp.task('execute-browser-tests', () => {
76
- return gulp.src('test/SpecRunner.js')
77
- .pipe(jasmine());
66
+ return gulp.src('test/SpecRunner.js')
67
+ .pipe(jasmine());
78
68
  });
79
69
 
80
70
  gulp.task('execute-node-tests', () => {
81
- return gulp.src(['test/specs/**/*.js'])
82
- .pipe(jasmine());
71
+ return gulp.src(['test/specs/**/*.js'])
72
+ .pipe(jasmine());
83
73
  });
84
74
 
85
75
  gulp.task('execute-tests', gulp.series(
@@ -91,7 +81,6 @@ gulp.task('execute-tests', gulp.series(
91
81
  gulp.task('release', gulp.series(
92
82
  'ensure-clean-working-directory',
93
83
  'execute-tests',
94
- 'document',
95
84
  'bump-version',
96
85
  'commit-changes',
97
86
  'push-changes',
@@ -99,9 +88,10 @@ gulp.task('release', gulp.series(
99
88
  ));
100
89
 
101
90
  gulp.task('lint', () => {
102
- return gulp.src([ './**/*.js', './test/specs/**/*.js', '!./node_modules/**', '!./docs/**', '!./test/SpecRunner.js' ])
103
- .pipe(jshint({'esversion': 6}))
104
- .pipe(jshint.reporter('default'));
91
+ return gulp.src([ './**/*.js', './test/specs/**/*.js', '!./node_modules/**', '!./docs/**', '!./test/SpecRunner.js' ])
92
+ .pipe(jshint({'esversion': 6}))
93
+ .pipe(jshint.reporter('default'))
94
+ .pipe(jshint.reporter('fail'));
105
95
  });
106
96
 
107
97
  gulp.task('test', gulp.series('execute-tests'));
@@ -356,13 +356,13 @@ module.exports = (() => {
356
356
  const transactionCreateFailedInstrumentCorrupt = new FailureType('TRANSACTION_CREATE_FAILED_INSTRUMENT_CORRUPT', 'Unable to create transaction, corporate action history for {U|symbol} cannot be located.');
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
- const transactionDeleteFailedNoTransaction = new FailureType('TRANSACTION_DELETE_FAILED_NO_TRANSACTION', 'Unable to delete transaction. The referenced transaction does not exist.');
359
+ const transactionDeleteFailedNoTransaction = new FailureType('TRANSACTION_DELETE_FAILED_NO_TRANSACTION', 'Unable to delete transaction. The referenced transaction does not exist.', false);
360
360
  const transactionDeleteFailedDirectionSwitchOnRewrite = new FailureType('TRANSACTION_DELETE_FAILED_DIRECTION_SWITCH_ON_REWRITE', 'Deleting this transaction would cause your history to be re-written and the position to switch from long to short (i.e. positive to negative) or vice versa.', false);
361
361
  const transactionDeleteFailedPositionLocked = new FailureType('TRANSACTION_DELETE_FAILED_POSITION_LOCKED', 'Unable to delete transaction, your {L|description} history is being recalculated. Please wait a minute or two and retry.');
362
362
  const transactionDeleteFailedTypeReserved = new FailureType('TRANSACTION_DELETE_FAILED_TYPE_RESERVED', 'Unable to delete {U|type.description} transaction, this type of transaction is managed by the system.');
363
363
 
364
364
  const transactionEditFailedInvalidDate = new FailureType('TRANSACTION_EDIT_FAILED_INVALID_DATE', 'Unable to edit transaction with given date.');
365
- const transactionEditFailedNoTransaction = new FailureType('TRANSACTION_EDIT_FAILED_NO_TRANSACTION', 'Unable to edit transaction. The referenced transaction does not exist.');
365
+ const transactionEditFailedNoTransaction = new FailureType('TRANSACTION_EDIT_FAILED_NO_TRANSACTION', 'Unable to edit transaction. The referenced transaction does not exist.', false);
366
366
  const transactionEditFailedTypeReserved = new FailureType('TRANSACTION_EDIT_FAILED_TYPE_RESERVED', 'Unable to edit {U|type.description} transaction, this type of transaction is managed by the system.');
367
367
 
368
368
  return PortfolioFailureType;
@@ -104,6 +104,10 @@ module.exports = (() => {
104
104
  static get SPINOFF() {
105
105
  return spinoff;
106
106
  }
107
+
108
+ toString() {
109
+ return `[CorporateActionType (code=${this.code})]`;
110
+ }
107
111
  }
108
112
 
109
113
  const split = new CorporateActionType('SPLIT', 'Split', false);
@@ -252,7 +252,7 @@ module.exports = (() => {
252
252
  }
253
253
 
254
254
  toString() {
255
- return '[InstrumentType]';
255
+ return `[InstrumentType (code=${this.code})]`;
256
256
  }
257
257
  }
258
258
 
@@ -118,6 +118,10 @@ module.exports = (() => {
118
118
  return even;
119
119
  }
120
120
  }
121
+
122
+ toString() {
123
+ return `[PositionDirection (code=${this.code})]`;
124
+ }
121
125
  }
122
126
 
123
127
  const long = new PositionDirection('LONG', 'Long', 'positive');
@@ -175,7 +175,7 @@ module.exports = (() => {
175
175
  }
176
176
 
177
177
  toString() {
178
- return '[PositionSummaryFrame]';
178
+ return `[PositionSummaryFrame (code=${this.code})]`;
179
179
  }
180
180
  }
181
181
 
@@ -494,7 +494,7 @@ module.exports = (() => {
494
494
  }
495
495
 
496
496
  toString() {
497
- return '[TransactionType]';
497
+ return `[TransactionType (code=${this.code})]`;
498
498
  }
499
499
  }
500
500
 
@@ -70,20 +70,20 @@ module.exports = (() => {
70
70
  return transactions.every((t) => {
71
71
  let valid = true;
72
72
 
73
- if (is.object(t.reference) && is.string(t.reference.root) && is.number(t.reference.sequence)) {
73
+ if (is.object(t.reference) && is.string(t.reference.root) && is.string(t.reference.transaction)) {
74
74
  const root = t.reference.root;
75
- const sequence = t.reference.sequence;
75
+ const transaction = t.reference.transaction;
76
76
 
77
77
  if (!references.hasOwnProperty(root)) {
78
78
  references[root] = [ ];
79
79
  }
80
80
 
81
- const sequences = references[root];
81
+ const transactions = references[root];
82
82
 
83
- if (sequences.some(s => s === sequence)) {
83
+ if (transactions.some(t => t === transaction)) {
84
84
  valid = false;
85
85
  } else {
86
- sequences.push(sequence);
86
+ transactions.push(transaction);
87
87
  }
88
88
  }
89
89
 
@@ -48,7 +48,7 @@ module.exports = (() => {
48
48
  }
49
49
 
50
50
  toString() {
51
- return '[ValuationType]';
51
+ return `[ValuationType (code=${this.code})]`;
52
52
  }
53
53
  }
54
54
 
@@ -130,6 +130,7 @@ module.exports = (() => {
130
130
  const complete = new TransactionSchema(SchemaBuilder.withName('complete')
131
131
  .withField('portfolio', DataType.STRING)
132
132
  .withField('position', DataType.STRING)
133
+ .withField('transaction', DataType.STRING)
133
134
  .withField('sequence', DataType.NUMBER)
134
135
  .withField('type', DataType.forEnum(TransactionType, 'TransactionType'))
135
136
  .withField('date', DataType.DAY)
@@ -138,7 +139,7 @@ module.exports = (() => {
138
139
  .withField('quantity', DataType.DECIMAL)
139
140
  .withField('fee', DataType.DECIMAL, true)
140
141
  .withField('reference.position', DataType.STRING, true)
141
- .withField('reference.sequence', DataType.NUMBER, true)
142
+ .withField('reference.transaction', DataType.STRING, true)
142
143
  .withField('snapshot.open', DataType.DECIMAL)
143
144
  .withField('snapshot.direction', DataType.forEnum(PositionDirection, 'PositionDirection'))
144
145
  .withField('snapshot.buys', DataType.DECIMAL)
@@ -179,6 +180,7 @@ module.exports = (() => {
179
180
  const client = new TransactionSchema(SchemaBuilder.withName('client')
180
181
  .withField('portfolio', DataType.STRING)
181
182
  .withField('position', DataType.STRING)
183
+ .withField('transaction', DataType.STRING)
182
184
  .withField('sequence', DataType.NUMBER)
183
185
  .withField('type', DataType.forEnum(TransactionType, 'TransactionType'))
184
186
  .withField('date', DataType.DAY)
@@ -187,7 +189,7 @@ module.exports = (() => {
187
189
  .withField('quantity', DataType.DECIMAL)
188
190
  .withField('fee', DataType.DECIMAL, true)
189
191
  .withField('reference.position', DataType.STRING, true)
190
- .withField('reference.sequence', DataType.NUMBER, true)
192
+ .withField('reference.transaction', DataType.NUMBER, true)
191
193
  .withField('snapshot.open', DataType.DECIMAL)
192
194
  .withField('snapshot.direction', DataType.forEnum(PositionDirection, 'PositionDirection'))
193
195
  .withField('snapshot.buys', DataType.DECIMAL)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@barchart/portfolio-api-common",
3
- "version": "1.3.22",
4
- "description": "Common classes used by the Portfolio system",
3
+ "version": "1.4.1",
4
+ "description": "Common code used by the Portfolio system",
5
5
  "author": {
6
6
  "name": "Bryan Ingle",
7
7
  "email": "bryan.ingle@barchart.com",
@@ -9,8 +9,8 @@
9
9
  },
10
10
  "scripts": {},
11
11
  "dependencies": {
12
- "@barchart/common-js": "~3.3.0",
13
- "uuid": "3.1.0"
12
+ "@barchart/common-js": "^3.5.1",
13
+ "uuid": "^3.4.0"
14
14
  },
15
15
  "devDependencies": {
16
16
  "@babel/core": "^7.6.2",
@@ -22,7 +22,6 @@
22
22
  "gulp-bump": "~1.0.0",
23
23
  "gulp-git": "^2.9.0",
24
24
  "gulp-jasmine": "^2.2.1",
25
- "gulp-jsdoc3": "^1.0.1",
26
25
  "gulp-jshint": "~2.1.0",
27
26
  "jsdoc": "^3.5.5",
28
27
  "jshint": "2.9.5",
@@ -253,7 +253,7 @@ module.exports = (() => {
253
253
  }
254
254
 
255
255
  toString() {
256
- return '[InstrumentType]';
256
+ return `[InstrumentType (code=${this.code})]`;
257
257
  }
258
258
  }
259
259
 
@@ -393,6 +393,10 @@ module.exports = (() => {
393
393
  return even;
394
394
  }
395
395
  }
396
+
397
+ toString() {
398
+ return `[PositionDirection (code=${this.code})]`;
399
+ }
396
400
  }
397
401
 
398
402
  const long = new PositionDirection('LONG', 'Long', 'positive');
@@ -580,7 +584,7 @@ module.exports = (() => {
580
584
  }
581
585
 
582
586
  toString() {
583
- return '[PositionSummaryFrame]';
587
+ return `[PositionSummaryFrame (code=${this.code})]`;
584
588
  }
585
589
  }
586
590
 
@@ -1247,7 +1251,7 @@ module.exports = (() => {
1247
1251
  }
1248
1252
 
1249
1253
  toString() {
1250
- return '[TransactionType]';
1254
+ return `[TransactionType (code=${this.code})]`;
1251
1255
  }
1252
1256
  }
1253
1257
 
@@ -1357,20 +1361,20 @@ module.exports = (() => {
1357
1361
  return transactions.every((t) => {
1358
1362
  let valid = true;
1359
1363
 
1360
- if (is.object(t.reference) && is.string(t.reference.root) && is.number(t.reference.sequence)) {
1364
+ if (is.object(t.reference) && is.string(t.reference.root) && is.string(t.reference.transaction)) {
1361
1365
  const root = t.reference.root;
1362
- const sequence = t.reference.sequence;
1366
+ const transaction = t.reference.transaction;
1363
1367
 
1364
1368
  if (!references.hasOwnProperty(root)) {
1365
1369
  references[root] = [ ];
1366
1370
  }
1367
1371
 
1368
- const sequences = references[root];
1372
+ const transactions = references[root];
1369
1373
 
1370
- if (sequences.some(s => s === sequence)) {
1374
+ if (transactions.some(t => t === transaction)) {
1371
1375
  valid = false;
1372
1376
  } else {
1373
- sequences.push(sequence);
1377
+ transactions.push(transaction);
1374
1378
  }
1375
1379
  }
1376
1380
 
@@ -4980,6 +4984,7 @@ module.exports = (() => {
4980
4984
  const complete = new TransactionSchema(SchemaBuilder.withName('complete')
4981
4985
  .withField('portfolio', DataType.STRING)
4982
4986
  .withField('position', DataType.STRING)
4987
+ .withField('transaction', DataType.STRING)
4983
4988
  .withField('sequence', DataType.NUMBER)
4984
4989
  .withField('type', DataType.forEnum(TransactionType, 'TransactionType'))
4985
4990
  .withField('date', DataType.DAY)
@@ -4988,7 +4993,7 @@ module.exports = (() => {
4988
4993
  .withField('quantity', DataType.DECIMAL)
4989
4994
  .withField('fee', DataType.DECIMAL, true)
4990
4995
  .withField('reference.position', DataType.STRING, true)
4991
- .withField('reference.sequence', DataType.NUMBER, true)
4996
+ .withField('reference.transaction', DataType.STRING, true)
4992
4997
  .withField('snapshot.open', DataType.DECIMAL)
4993
4998
  .withField('snapshot.direction', DataType.forEnum(PositionDirection, 'PositionDirection'))
4994
4999
  .withField('snapshot.buys', DataType.DECIMAL)
@@ -5029,6 +5034,7 @@ module.exports = (() => {
5029
5034
  const client = new TransactionSchema(SchemaBuilder.withName('client')
5030
5035
  .withField('portfolio', DataType.STRING)
5031
5036
  .withField('position', DataType.STRING)
5037
+ .withField('transaction', DataType.STRING)
5032
5038
  .withField('sequence', DataType.NUMBER)
5033
5039
  .withField('type', DataType.forEnum(TransactionType, 'TransactionType'))
5034
5040
  .withField('date', DataType.DAY)
@@ -5037,7 +5043,7 @@ module.exports = (() => {
5037
5043
  .withField('quantity', DataType.DECIMAL)
5038
5044
  .withField('fee', DataType.DECIMAL, true)
5039
5045
  .withField('reference.position', DataType.STRING, true)
5040
- .withField('reference.sequence', DataType.NUMBER, true)
5046
+ .withField('reference.transaction', DataType.NUMBER, true)
5041
5047
  .withField('snapshot.open', DataType.DECIMAL)
5042
5048
  .withField('snapshot.direction', DataType.forEnum(PositionDirection, 'PositionDirection'))
5043
5049
  .withField('snapshot.buys', DataType.DECIMAL)
@@ -7488,6 +7494,7 @@ module.exports = (() => {
7488
7494
  * item's value. If no matching item can be found, a null value is returned.
7489
7495
  *
7490
7496
  * @public
7497
+ * @static
7491
7498
  * @param {Function} type - The enumeration type.
7492
7499
  * @param {String} code - The enumeration item's code.
7493
7500
  * @returns {*|null}
@@ -7501,6 +7508,7 @@ module.exports = (() => {
7501
7508
  * Returns all of the enumeration's items (given an enumeration type).
7502
7509
  *
7503
7510
  * @public
7511
+ * @static
7504
7512
  * @param {Function} type - The enumeration to list.
7505
7513
  * @returns {Array}
7506
7514
  */
@@ -8822,7 +8830,7 @@ module.exports = (() => {
8822
8830
 
8823
8831
  return {
8824
8832
  /**
8825
- * Returns true, if the argument is a number. NaN will return false.
8833
+ * Returns true if the argument is a number. NaN will return false.
8826
8834
  *
8827
8835
  * @static
8828
8836
  * @public
@@ -8834,7 +8842,7 @@ module.exports = (() => {
8834
8842
  },
8835
8843
 
8836
8844
  /**
8837
- * Returns true, if the argument is NaN.
8845
+ * Returns true if the argument is NaN.
8838
8846
  *
8839
8847
  * @static
8840
8848
  * @public
@@ -8846,7 +8854,7 @@ module.exports = (() => {
8846
8854
  },
8847
8855
 
8848
8856
  /**
8849
- * Returns true, if the argument is a valid 32-bit integer.
8857
+ * Returns true if the argument is a valid 32-bit integer.
8850
8858
  *
8851
8859
  * @static
8852
8860
  * @public
@@ -8858,7 +8866,7 @@ module.exports = (() => {
8858
8866
  },
8859
8867
 
8860
8868
  /**
8861
- * Returns true, if the argument is a valid integer (which can exceed 32 bits); however,
8869
+ * Returns true if the argument is a valid integer (which can exceed 32 bits); however,
8862
8870
  * the check can fail above the value of Number.MAX_SAFE_INTEGER.
8863
8871
  *
8864
8872
  * @static
@@ -8871,7 +8879,7 @@ module.exports = (() => {
8871
8879
  },
8872
8880
 
8873
8881
  /**
8874
- * Returns true, if the argument is a number that is positive.
8882
+ * Returns true if the argument is a number that is positive.
8875
8883
  *
8876
8884
  * @static
8877
8885
  * @public
@@ -8883,7 +8891,7 @@ module.exports = (() => {
8883
8891
  },
8884
8892
 
8885
8893
  /**
8886
- * Returns true, if the argument is a number that is negative.
8894
+ * Returns true if the argument is a number that is negative.
8887
8895
  *
8888
8896
  * @static
8889
8897
  * @public
@@ -8895,7 +8903,7 @@ module.exports = (() => {
8895
8903
  },
8896
8904
 
8897
8905
  /**
8898
- * Returns true, if the argument is a string.
8906
+ * Returns true if the argument is a string.
8899
8907
  *
8900
8908
  * @static
8901
8909
  * @public
@@ -8907,7 +8915,7 @@ module.exports = (() => {
8907
8915
  },
8908
8916
 
8909
8917
  /**
8910
- * Returns true, if the argument is a JavaScript Date instance.
8918
+ * Returns true if the argument is a JavaScript Date instance.
8911
8919
  *
8912
8920
  * @static
8913
8921
  * @public
@@ -8919,7 +8927,7 @@ module.exports = (() => {
8919
8927
  },
8920
8928
 
8921
8929
  /**
8922
- * Returns true, if the argument is a function.
8930
+ * Returns true if the argument is a function.
8923
8931
  *
8924
8932
  * @static
8925
8933
  * @public
@@ -8931,7 +8939,7 @@ module.exports = (() => {
8931
8939
  },
8932
8940
 
8933
8941
  /**
8934
- * Returns true, if the argument is an array.
8942
+ * Returns true if the argument is an array.
8935
8943
  *
8936
8944
  * @static
8937
8945
  * @public
@@ -8943,7 +8951,7 @@ module.exports = (() => {
8943
8951
  },
8944
8952
 
8945
8953
  /**
8946
- * Returns true, if the argument is a Boolean value.
8954
+ * Returns true if the argument is a Boolean value.
8947
8955
  *
8948
8956
  * @static
8949
8957
  * @public
@@ -8955,7 +8963,7 @@ module.exports = (() => {
8955
8963
  },
8956
8964
 
8957
8965
  /**
8958
- * Returns true, if the argument is an object.
8966
+ * Returns true if the argument is an object.
8959
8967
  *
8960
8968
  * @static
8961
8969
  * @public
@@ -8967,7 +8975,7 @@ module.exports = (() => {
8967
8975
  },
8968
8976
 
8969
8977
  /**
8970
- * Returns true, if the argument is a null value.
8978
+ * Returns true if the argument is a null value.
8971
8979
  *
8972
8980
  * @static
8973
8981
  * @public
@@ -8979,7 +8987,7 @@ module.exports = (() => {
8979
8987
  },
8980
8988
 
8981
8989
  /**
8982
- * Returns true, if the argument is an undefined value.
8990
+ * Returns true if the argument is an undefined value.
8983
8991
  *
8984
8992
  * @static
8985
8993
  * @public
@@ -8990,6 +8998,18 @@ module.exports = (() => {
8990
8998
  return candidate === undefined;
8991
8999
  },
8992
9000
 
9001
+ /**
9002
+ * Returns true if the argument is a zero-length string.
9003
+ *
9004
+ * @static
9005
+ * @public
9006
+ * @param {*} candidate
9007
+ * @returns {boolean}
9008
+ */
9009
+ zeroLengthString(candidate) {
9010
+ return this.string(candidate) && candidate.length === 0;
9011
+ },
9012
+
8993
9013
  /**
8994
9014
  * Given two classes, determines if the "child" class extends
8995
9015
  * the "parent" class (without instantiation).
@@ -9029,11 +9049,11 @@ module.exports = (() => {
9029
9049
  simple(fn) {
9030
9050
  const cache = {};
9031
9051
  return x => {
9032
- if (cache.hasOwnProperty(x)) {
9033
- return cache[x];
9034
- } else {
9035
- return cache[x] = fn(x);
9052
+ if (!cache.hasOwnProperty(x)) {
9053
+ cache[x] = fn(x);
9036
9054
  }
9055
+
9056
+ return cache[x];
9037
9057
  };
9038
9058
  },
9039
9059
 
@@ -10168,9 +10188,9 @@ module.exports = (() => {
10168
10188
 
10169
10189
  },{"./../../../lang/assert":29,"./../../../lang/is":33,"./../Component":36,"./../DataType":37,"./../Field":38,"./../Schema":39,"./ComponentBuilder":40}],42:[function(require,module,exports){
10170
10190
  /*
10171
- * big.js v5.0.3
10191
+ * big.js v5.2.2
10172
10192
  * A small, fast, easy-to-use library for arbitrary-precision decimal arithmetic.
10173
- * Copyright (c) 2017 Michael Mclaughlin <M8ch88l@gmail.com>
10193
+ * Copyright (c) 2018 Michael Mclaughlin <M8ch88l@gmail.com>
10174
10194
  * https://github.com/MikeMcl/big.js/LICENCE
10175
10195
  */
10176
10196
  ;(function (GLOBAL) {
@@ -10276,7 +10296,7 @@ module.exports = (() => {
10276
10296
  Big.RM = RM;
10277
10297
  Big.NE = NE;
10278
10298
  Big.PE = PE;
10279
- Big.version = '5.0.2';
10299
+ Big.version = '5.2.2';
10280
10300
 
10281
10301
  return Big;
10282
10302
  }
@@ -10360,7 +10380,7 @@ module.exports = (() => {
10360
10380
  more = xc[i] > 5 || xc[i] == 5 &&
10361
10381
  (more || i < 0 || xc[i + 1] !== UNDEFINED || xc[i - 1] & 1);
10362
10382
  } else if (rm === 3) {
10363
- more = more || xc[i] !== UNDEFINED || i < 0;
10383
+ more = more || !!xc[0];
10364
10384
  } else {
10365
10385
  more = false;
10366
10386
  if (rm !== 0) throw Error(INVALID_RM);
@@ -10827,7 +10847,7 @@ module.exports = (() => {
10827
10847
  xc = xc.slice();
10828
10848
 
10829
10849
  // Prepend zeros to equalise exponents.
10830
- // Note: Faster to use reverse then do unshifts.
10850
+ // Note: reverse faster than unshifts.
10831
10851
  if (a = xe - ye) {
10832
10852
  if (a > 0) {
10833
10853
  ye = xe;
@@ -10899,18 +10919,19 @@ module.exports = (() => {
10899
10919
 
10900
10920
 
10901
10921
  /*
10902
- * Return a new Big whose value is the value of this Big rounded to a maximum of dp decimal
10903
- * places using rounding mode rm.
10922
+ * Return a new Big whose value is the value of this Big rounded using rounding mode rm
10923
+ * to a maximum of dp decimal places, or, if dp is negative, to an integer which is a
10924
+ * multiple of 10**-dp.
10904
10925
  * If dp is not specified, round to 0 decimal places.
10905
10926
  * If rm is not specified, use Big.RM.
10906
10927
  *
10907
- * dp? {number} Integer, 0 to MAX_DP inclusive.
10928
+ * dp? {number} Integer, -MAX_DP to MAX_DP inclusive.
10908
10929
  * rm? 0, 1, 2 or 3 (ROUND_DOWN, ROUND_HALF_UP, ROUND_HALF_EVEN, ROUND_UP)
10909
10930
  */
10910
10931
  P.round = function (dp, rm) {
10911
10932
  var Big = this.constructor;
10912
10933
  if (dp === UNDEFINED) dp = 0;
10913
- else if (dp !== ~~dp || dp < 0 || dp > MAX_DP) throw Error(INVALID_DP);
10934
+ else if (dp !== ~~dp || dp < -MAX_DP || dp > MAX_DP) throw Error(INVALID_DP);
10914
10935
  return round(new Big(this), dp, rm === UNDEFINED ? Big.RM : rm);
10915
10936
  };
10916
10937
 
@@ -10934,17 +10955,18 @@ module.exports = (() => {
10934
10955
  if (s < 0) throw Error(NAME + 'No square root');
10935
10956
 
10936
10957
  // Estimate.
10937
- s = Math.sqrt(x.toString());
10958
+ s = Math.sqrt(x + '');
10938
10959
 
10939
10960
  // Math.sqrt underflow/overflow?
10940
- // Re-estimate: pass x to Math.sqrt as integer, then adjust the result exponent.
10961
+ // Re-estimate: pass x coefficient to Math.sqrt as integer, then adjust the result exponent.
10941
10962
  if (s === 0 || s === 1 / 0) {
10942
10963
  c = x.c.join('');
10943
10964
  if (!(c.length + e & 1)) c += '0';
10944
- r = new Big(Math.sqrt(c).toString());
10945
- r.e = ((e + 1) / 2 | 0) - (e < 0 || e & 1);
10965
+ s = Math.sqrt(c);
10966
+ e = ((e + 1) / 2 | 0) - (e < 0 || e & 1);
10967
+ r = new Big((s == 1 / 0 ? '1e' : (s = s.toExponential()).slice(0, s.indexOf('e') + 1)) + e);
10946
10968
  } else {
10947
- r = new Big(s.toString());
10969
+ r = new Big(s);
10948
10970
  }
10949
10971
 
10950
10972
  e = r.e + (Big.DP += 4);
@@ -16968,43 +16990,48 @@ for (var i = 0; i < 256; ++i) {
16968
16990
  function bytesToUuid(buf, offset) {
16969
16991
  var i = offset || 0;
16970
16992
  var bth = byteToHex;
16971
- return bth[buf[i++]] + bth[buf[i++]] +
16972
- bth[buf[i++]] + bth[buf[i++]] + '-' +
16973
- bth[buf[i++]] + bth[buf[i++]] + '-' +
16974
- bth[buf[i++]] + bth[buf[i++]] + '-' +
16975
- bth[buf[i++]] + bth[buf[i++]] + '-' +
16976
- bth[buf[i++]] + bth[buf[i++]] +
16977
- bth[buf[i++]] + bth[buf[i++]] +
16978
- bth[buf[i++]] + bth[buf[i++]];
16993
+ // join used to fix memory issue caused by concatenation: https://bugs.chromium.org/p/v8/issues/detail?id=3175#c4
16994
+ return ([
16995
+ bth[buf[i++]], bth[buf[i++]],
16996
+ bth[buf[i++]], bth[buf[i++]], '-',
16997
+ bth[buf[i++]], bth[buf[i++]], '-',
16998
+ bth[buf[i++]], bth[buf[i++]], '-',
16999
+ bth[buf[i++]], bth[buf[i++]], '-',
17000
+ bth[buf[i++]], bth[buf[i++]],
17001
+ bth[buf[i++]], bth[buf[i++]],
17002
+ bth[buf[i++]], bth[buf[i++]]
17003
+ ]).join('');
16979
17004
  }
16980
17005
 
16981
17006
  module.exports = bytesToUuid;
16982
17007
 
16983
17008
  },{}],49:[function(require,module,exports){
16984
- (function (global){
16985
17009
  // Unique ID creation requires a high quality random # generator. In the
16986
17010
  // browser this is a little complicated due to unknown quality of Math.random()
16987
17011
  // and inconsistent support for the `crypto` API. We do the best we can via
16988
17012
  // feature-detection
16989
- var rng;
16990
17013
 
16991
- var crypto = global.crypto || global.msCrypto; // for IE 11
16992
- if (crypto && crypto.getRandomValues) {
17014
+ // getRandomValues needs to be invoked in a context where "this" is a Crypto
17015
+ // implementation. Also, find the complete implementation of crypto on IE11.
17016
+ var getRandomValues = (typeof(crypto) != 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto)) ||
17017
+ (typeof(msCrypto) != 'undefined' && typeof window.msCrypto.getRandomValues == 'function' && msCrypto.getRandomValues.bind(msCrypto));
17018
+
17019
+ if (getRandomValues) {
16993
17020
  // WHATWG crypto RNG - http://wiki.whatwg.org/wiki/Crypto
16994
17021
  var rnds8 = new Uint8Array(16); // eslint-disable-line no-undef
16995
- rng = function whatwgRNG() {
16996
- crypto.getRandomValues(rnds8);
17022
+
17023
+ module.exports = function whatwgRNG() {
17024
+ getRandomValues(rnds8);
16997
17025
  return rnds8;
16998
17026
  };
16999
- }
17000
-
17001
- if (!rng) {
17027
+ } else {
17002
17028
  // Math.random()-based (RNG)
17003
17029
  //
17004
17030
  // If all else fails, use Math.random(). It's fast, but is of unspecified
17005
17031
  // quality.
17006
17032
  var rnds = new Array(16);
17007
- rng = function() {
17033
+
17034
+ module.exports = function mathRNG() {
17008
17035
  for (var i = 0, r; i < 16; i++) {
17009
17036
  if ((i & 0x03) === 0) r = Math.random() * 0x100000000;
17010
17037
  rnds[i] = r >>> ((i & 0x03) << 3) & 0xff;
@@ -17014,9 +17041,6 @@ if (!rng) {
17014
17041
  };
17015
17042
  }
17016
17043
 
17017
- module.exports = rng;
17018
-
17019
- }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
17020
17044
  },{}],50:[function(require,module,exports){
17021
17045
  var rng = require('./lib/rng');
17022
17046
  var bytesToUuid = require('./lib/bytesToUuid');
@@ -17026,30 +17050,40 @@ var bytesToUuid = require('./lib/bytesToUuid');
17026
17050
  // Inspired by https://github.com/LiosK/UUID.js
17027
17051
  // and http://docs.python.org/library/uuid.html
17028
17052
 
17029
- // random #'s we need to init node and clockseq
17030
- var _seedBytes = rng();
17031
-
17032
- // Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1)
17033
- var _nodeId = [
17034
- _seedBytes[0] | 0x01,
17035
- _seedBytes[1], _seedBytes[2], _seedBytes[3], _seedBytes[4], _seedBytes[5]
17036
- ];
17037
-
17038
- // Per 4.2.2, randomize (14 bit) clockseq
17039
- var _clockseq = (_seedBytes[6] << 8 | _seedBytes[7]) & 0x3fff;
17053
+ var _nodeId;
17054
+ var _clockseq;
17040
17055
 
17041
17056
  // Previous uuid creation time
17042
- var _lastMSecs = 0, _lastNSecs = 0;
17057
+ var _lastMSecs = 0;
17058
+ var _lastNSecs = 0;
17043
17059
 
17044
- // See https://github.com/broofa/node-uuid for API details
17060
+ // See https://github.com/uuidjs/uuid for API details
17045
17061
  function v1(options, buf, offset) {
17046
17062
  var i = buf && offset || 0;
17047
17063
  var b = buf || [];
17048
17064
 
17049
17065
  options = options || {};
17050
-
17066
+ var node = options.node || _nodeId;
17051
17067
  var clockseq = options.clockseq !== undefined ? options.clockseq : _clockseq;
17052
17068
 
17069
+ // node and clockseq need to be initialized to random values if they're not
17070
+ // specified. We do this lazily to minimize issues related to insufficient
17071
+ // system entropy. See #189
17072
+ if (node == null || clockseq == null) {
17073
+ var seedBytes = rng();
17074
+ if (node == null) {
17075
+ // Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1)
17076
+ node = _nodeId = [
17077
+ seedBytes[0] | 0x01,
17078
+ seedBytes[1], seedBytes[2], seedBytes[3], seedBytes[4], seedBytes[5]
17079
+ ];
17080
+ }
17081
+ if (clockseq == null) {
17082
+ // Per 4.2.2, randomize (14 bit) clockseq
17083
+ clockseq = _clockseq = (seedBytes[6] << 8 | seedBytes[7]) & 0x3fff;
17084
+ }
17085
+ }
17086
+
17053
17087
  // UUID timestamps are 100 nano-second units since the Gregorian epoch,
17054
17088
  // (1582-10-15 00:00). JSNumbers aren't precise enough for this, so
17055
17089
  // time is handled internally as 'msecs' (integer milliseconds) and 'nsecs'
@@ -17109,7 +17143,6 @@ function v1(options, buf, offset) {
17109
17143
  b[i++] = clockseq & 0xff;
17110
17144
 
17111
17145
  // `node`
17112
- var node = options.node || _nodeId;
17113
17146
  for (var n = 0; n < 6; ++n) {
17114
17147
  b[i + n] = node[n];
17115
17148
  }
@@ -17127,7 +17160,7 @@ function v4(options, buf, offset) {
17127
17160
  var i = buf && offset || 0;
17128
17161
 
17129
17162
  if (typeof(options) == 'string') {
17130
- buf = options == 'binary' ? new Array(16) : null;
17163
+ buf = options === 'binary' ? new Array(16) : null;
17131
17164
  options = null;
17132
17165
  }
17133
17166
  options = options || {};
@@ -17842,8 +17875,8 @@ describe('When validating transaction order', () => {
17842
17875
  describe('When validating transaction references', () => {
17843
17876
  'use strict';
17844
17877
 
17845
- const build = (root, sequence) => {
17846
- return { reference: { root: root, sequence: sequence } };
17878
+ const build = (root, transaction) => {
17879
+ return { reference: { root: root, transaction: transaction } };
17847
17880
  };
17848
17881
 
17849
17882
  it('An array of zero transactions should be valid', () => {
@@ -17855,11 +17888,11 @@ describe('When validating transaction references', () => {
17855
17888
  });
17856
17889
 
17857
17890
  it('An array with distinct references should be valid', () => {
17858
- expect(TransactionValidator.validateReferences([ build('a', 1), build('a', 2), build('b', 1) ])).toEqual(true);
17891
+ expect(TransactionValidator.validateReferences([ build('a', 'x'), build('a', 'y'), build('b', 'y') ])).toEqual(true);
17859
17892
  });
17860
17893
 
17861
17894
  it('An array with non-distinct references should be not valid', () => {
17862
- expect(TransactionValidator.validateReferences([ build('a', 1), build('a', 2), build('b', 1), build('a', 2) ])).toEqual(false);
17895
+ expect(TransactionValidator.validateReferences([ build('a', 'x'), build('a', 'y'), build('b', 'x'), build('a', 'y') ])).toEqual(false);
17863
17896
  });
17864
17897
  });
17865
17898
 
@@ -58,8 +58,8 @@ describe('When validating transaction order', () => {
58
58
  describe('When validating transaction references', () => {
59
59
  'use strict';
60
60
 
61
- const build = (root, sequence) => {
62
- return { reference: { root: root, sequence: sequence } };
61
+ const build = (root, transaction) => {
62
+ return { reference: { root: root, transaction: transaction } };
63
63
  };
64
64
 
65
65
  it('An array of zero transactions should be valid', () => {
@@ -71,11 +71,11 @@ describe('When validating transaction references', () => {
71
71
  });
72
72
 
73
73
  it('An array with distinct references should be valid', () => {
74
- expect(TransactionValidator.validateReferences([ build('a', 1), build('a', 2), build('b', 1) ])).toEqual(true);
74
+ expect(TransactionValidator.validateReferences([ build('a', 'x'), build('a', 'y'), build('b', 'y') ])).toEqual(true);
75
75
  });
76
76
 
77
77
  it('An array with non-distinct references should be not valid', () => {
78
- expect(TransactionValidator.validateReferences([ build('a', 1), build('a', 2), build('b', 1), build('a', 2) ])).toEqual(false);
78
+ expect(TransactionValidator.validateReferences([ build('a', 'x'), build('a', 'y'), build('b', 'x'), build('a', 'y') ])).toEqual(false);
79
79
  });
80
80
  });
81
81