@barchart/portfolio-client-js 1.2.38 → 1.2.41

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.
@@ -62,13 +62,13 @@ module.exports = function () {
62
62
  return '[Configuration]';
63
63
  }
64
64
  }], [{
65
- key: 'localHost',
65
+ key: 'developmentHost',
66
66
  get: function get() {
67
- return '127.0.0.1';
67
+ return 'ldnddf3nsh.execute-api.us-east-1.amazonaws.com/dev';
68
68
  }
69
69
 
70
70
  /**
71
- * The host of the development system.
71
+ * The host of the staging system.
72
72
  *
73
73
  * @public
74
74
  * @static
@@ -76,13 +76,13 @@ module.exports = function () {
76
76
  */
77
77
 
78
78
  }, {
79
- key: 'developmentHost',
79
+ key: 'stagingHost',
80
80
  get: function get() {
81
- return 'ldnddf3nsh.execute-api.us-east-1.amazonaws.com/dev';
81
+ return '24ok2r76k6.execute-api.us-east-1.amazonaws.com/stage';
82
82
  }
83
83
 
84
84
  /**
85
- * The host of the staging system.
85
+ * The host of the production system.
86
86
  *
87
87
  * @public
88
88
  * @static
@@ -90,23 +90,23 @@ module.exports = function () {
90
90
  */
91
91
 
92
92
  }, {
93
- key: 'stagingHost',
93
+ key: 'productionHost',
94
94
  get: function get() {
95
- return '24ok2r76k6.execute-api.us-east-1.amazonaws.com/stage';
95
+ return 'o77obtxxr4.execute-api.us-east-1.amazonaws.com/prod';
96
96
  }
97
97
 
98
98
  /**
99
- * The host of the production system.
99
+ * The host of the internal admin system.
100
100
  *
101
101
  * @public
102
102
  * @static
103
- * @returns {String}
103
+ * @return {String}
104
104
  */
105
105
 
106
106
  }, {
107
- key: 'productionHost',
107
+ key: 'adminHost',
108
108
  get: function get() {
109
- return 'o77obtxxr4.execute-api.us-east-1.amazonaws.com/prod';
109
+ return '38moiq7ek9.execute-api.us-east-1.amazonaws.com/admin';
110
110
  }
111
111
  }]);
112
112
 
@@ -984,17 +984,17 @@ module.exports = function () {
984
984
  return this._environment;
985
985
  }
986
986
  }], [{
987
- key: 'forLocal',
988
- value: function forLocal(requestInterceptor) {
987
+ key: 'forDevelopment',
988
+ value: function forDevelopment(requestInterceptor) {
989
989
  return Promise.resolve(requestInterceptor).then(function (requestInterceptor) {
990
990
  assert.argumentIsOptional(requestInterceptor, 'requestInterceptor', RequestInterceptor, 'RequestInterceptor');
991
991
 
992
- return start(new PortfolioGateway('http', Configuration.localHost, 3000, requestInterceptor));
992
+ return start(new PortfolioGateway('https', Configuration.developmentHost, 443, 'development', requestInterceptor));
993
993
  });
994
994
  }
995
995
 
996
996
  /**
997
- * Creates and starts a new {@link PortfolioGateway} for use in the development environment.
997
+ * Creates and starts a new {@link PortfolioGateway} for use in the staging environment.
998
998
  *
999
999
  * @public
1000
1000
  * @static
@@ -1003,17 +1003,17 @@ module.exports = function () {
1003
1003
  */
1004
1004
 
1005
1005
  }, {
1006
- key: 'forDevelopment',
1007
- value: function forDevelopment(requestInterceptor) {
1006
+ key: 'forStaging',
1007
+ value: function forStaging(requestInterceptor) {
1008
1008
  return Promise.resolve(requestInterceptor).then(function (requestInterceptor) {
1009
1009
  assert.argumentIsOptional(requestInterceptor, 'requestInterceptor', RequestInterceptor, 'RequestInterceptor');
1010
1010
 
1011
- return start(new PortfolioGateway('https', Configuration.developmentHost, 443, 'development', requestInterceptor));
1011
+ return start(new PortfolioGateway('https', Configuration.stagingHost, 443, 'staging', requestInterceptor));
1012
1012
  });
1013
1013
  }
1014
1014
 
1015
1015
  /**
1016
- * Creates and starts a new {@link PortfolioGateway} for use in the staging environment.
1016
+ * Creates and starts a new {@link PortfolioGateway} for use in the production environment.
1017
1017
  *
1018
1018
  * @public
1019
1019
  * @static
@@ -1022,17 +1022,17 @@ module.exports = function () {
1022
1022
  */
1023
1023
 
1024
1024
  }, {
1025
- key: 'forStaging',
1026
- value: function forStaging(requestInterceptor) {
1025
+ key: 'forProduction',
1026
+ value: function forProduction(requestInterceptor) {
1027
1027
  return Promise.resolve(requestInterceptor).then(function (requestInterceptor) {
1028
1028
  assert.argumentIsOptional(requestInterceptor, 'requestInterceptor', RequestInterceptor, 'RequestInterceptor');
1029
1029
 
1030
- return start(new PortfolioGateway('https', Configuration.stagingHost, 443, 'staging', requestInterceptor));
1030
+ return start(new PortfolioGateway('https', Configuration.productionHost, 443, 'production', requestInterceptor));
1031
1031
  });
1032
1032
  }
1033
1033
 
1034
1034
  /**
1035
- * Creates and starts a new {@link PortfolioGateway} for use in the production environment.
1035
+ * Creates and starts a new {@link PortfolioGateway} for use in the administration environment.
1036
1036
  *
1037
1037
  * @public
1038
1038
  * @static
@@ -1041,12 +1041,12 @@ module.exports = function () {
1041
1041
  */
1042
1042
 
1043
1043
  }, {
1044
- key: 'forProduction',
1045
- value: function forProduction(requestInterceptor) {
1044
+ key: 'forAdmin',
1045
+ value: function forAdmin(requestInterceptor) {
1046
1046
  return Promise.resolve(requestInterceptor).then(function (requestInterceptor) {
1047
1047
  assert.argumentIsOptional(requestInterceptor, 'requestInterceptor', RequestInterceptor, 'RequestInterceptor');
1048
1048
 
1049
- return start(new PortfolioGateway('https', Configuration.productionHost, 443, 'production', requestInterceptor));
1049
+ return start(new PortfolioGateway('https', Configuration.adminHost, 443, requestInterceptor));
1050
1050
  });
1051
1051
  }
1052
1052
  }]);
@@ -1216,8 +1216,6 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
1216
1216
 
1217
1217
  var assert = require('@barchart/common-js/lang/assert'),
1218
1218
  Disposable = require('@barchart/common-js/lang/Disposable'),
1219
- Enum = require('@barchart/common-js/lang/Enum'),
1220
- is = require('@barchart/common-js/lang/is'),
1221
1219
  Scheduler = require('@barchart/common-js/timing/Scheduler');
1222
1220
 
1223
1221
  var EndpointBuilder = require('@barchart/common-js/api/http/builders/EndpointBuilder'),
@@ -1411,7 +1409,7 @@ module.exports = function () {
1411
1409
  }], [{
1412
1410
  key: 'forDevelopment',
1413
1411
  value: function forDevelopment(userId, userLegacyId) {
1414
- return start(new JwtGateway(_forDevelopment(userId, userLegacyId), 60000));
1412
+ return start(new JwtGateway(_forDevelopment(userId, userLegacyId), 180000));
1415
1413
  }
1416
1414
 
1417
1415
  /**
@@ -1498,6 +1496,39 @@ module.exports = function () {
1498
1496
  return jwtGateway.toRequestInterceptor();
1499
1497
  });
1500
1498
  }
1499
+
1500
+ /**
1501
+ * Creates and starts a new {@link JwtGateway} for use in the internal admin environment.
1502
+ *
1503
+ * @public
1504
+ * @static
1505
+ * @param {String} userId - The identifier of the user to impersonate.
1506
+ * @param {String} userLegacyId - The legacy identifier of the user to impersonate.
1507
+ * @returns {Promise.<JwtGateway>}
1508
+ */
1509
+
1510
+ }, {
1511
+ key: 'forAdmin',
1512
+ value: function forAdmin(userId, userLegacyId) {
1513
+ return start(new JwtGateway(_forAdmin(userId, userLegacyId), 180000));
1514
+ }
1515
+
1516
+ /**
1517
+ * Creates and starts a new {@link RequestInterceptor} for use in the internal admin environment.
1518
+ *
1519
+ * @public
1520
+ * @static
1521
+ * @param {String} userId - The identifier of the user to impersonate.
1522
+ * @returns {Promise.<RequestInterceptor>}
1523
+ */
1524
+
1525
+ }, {
1526
+ key: 'forAdminClient',
1527
+ value: function forAdminClient(userId, userLegacyId) {
1528
+ return JwtGateway.forAdmin(userId, userLegacyId).then(function (jwtGateway) {
1529
+ return jwtGateway.toRequestInterceptor();
1530
+ });
1531
+ }
1501
1532
  }]);
1502
1533
 
1503
1534
  return JwtGateway;
@@ -1539,10 +1570,18 @@ module.exports = function () {
1539
1570
  }).withRequestInterceptor(externalRequestInterceptor).withResponseInterceptor(ResponseInterceptor.DATA).endpoint;
1540
1571
  }
1541
1572
 
1573
+ function _forAdmin(userId, legacyUserId) {
1574
+ return EndpointBuilder.for('read-jwt-token-for-development', 'lookup user identity').withVerb(VerbType.GET).withProtocol(ProtocolType.HTTPS).withHost(Configuration.adminHost).withPathBuilder(function (pb) {
1575
+ pb.withLiteralParameter('token', 'token').withLiteralParameter('barchart', 'barchart').withLiteralParameter('generator', 'generator');
1576
+ }).withQueryBuilder(function (qb) {
1577
+ qb.withLiteralParameter('user', 'userId', userId).withLiteralParameter('legacy user', 'userLegacyId', legacyUserId).withLiteralParameter('user context', 'userContext', 'TGAM').withLiteralParameter('user permission level', 'userPermissions', 'registered');
1578
+ }).withResponseInterceptor(ResponseInterceptor.DATA).endpoint;
1579
+ }
1580
+
1542
1581
  return JwtGateway;
1543
1582
  }();
1544
1583
 
1545
- },{"./../../common/Configuration":2,"@barchart/common-js/api/failures/FailureReason":6,"@barchart/common-js/api/failures/FailureType":8,"@barchart/common-js/api/http/Gateway":9,"@barchart/common-js/api/http/builders/EndpointBuilder":10,"@barchart/common-js/api/http/definitions/Endpoint":12,"@barchart/common-js/api/http/definitions/ProtocolType":15,"@barchart/common-js/api/http/definitions/VerbType":16,"@barchart/common-js/api/http/interceptors/RequestInterceptor":21,"@barchart/common-js/api/http/interceptors/ResponseInterceptor":22,"@barchart/common-js/lang/Disposable":31,"@barchart/common-js/lang/Enum":32,"@barchart/common-js/lang/assert":37,"@barchart/common-js/lang/is":40,"@barchart/common-js/timing/Scheduler":50}],5:[function(require,module,exports){
1584
+ },{"./../../common/Configuration":2,"@barchart/common-js/api/failures/FailureReason":6,"@barchart/common-js/api/failures/FailureType":8,"@barchart/common-js/api/http/Gateway":9,"@barchart/common-js/api/http/builders/EndpointBuilder":10,"@barchart/common-js/api/http/definitions/Endpoint":12,"@barchart/common-js/api/http/definitions/ProtocolType":15,"@barchart/common-js/api/http/definitions/VerbType":16,"@barchart/common-js/api/http/interceptors/RequestInterceptor":21,"@barchart/common-js/api/http/interceptors/ResponseInterceptor":22,"@barchart/common-js/lang/Disposable":31,"@barchart/common-js/lang/assert":37,"@barchart/common-js/timing/Scheduler":50}],5:[function(require,module,exports){
1546
1585
  'use strict';
1547
1586
 
1548
1587
  var JwtGateway = require('./gateway/jwt/JwtGateway'),
@@ -1554,7 +1593,7 @@ module.exports = function () {
1554
1593
  return {
1555
1594
  JwtGateway: JwtGateway,
1556
1595
  PortfolioGateway: PortfolioGateway,
1557
- version: '1.2.38'
1596
+ version: '1.2.41'
1558
1597
  };
1559
1598
  }();
1560
1599
 
@@ -11,17 +11,6 @@ module.exports = (() => {
11
11
 
12
12
  }
13
13
 
14
- /**
15
- * The host of the development system.
16
- *
17
- * @public
18
- * @static
19
- * @returns {String}
20
- */
21
- static get localHost() {
22
- return '127.0.0.1';
23
- }
24
-
25
14
  /**
26
15
  * The host of the development system.
27
16
  *
@@ -55,6 +44,17 @@ module.exports = (() => {
55
44
  return 'o77obtxxr4.execute-api.us-east-1.amazonaws.com/prod';
56
45
  }
57
46
 
47
+ /**
48
+ * The host of the internal admin system.
49
+ *
50
+ * @public
51
+ * @static
52
+ * @return {String}
53
+ */
54
+ static get adminHost() {
55
+ return '38moiq7ek9.execute-api.us-east-1.amazonaws.com/admin';
56
+ }
57
+
58
58
  toString() {
59
59
  return '[Configuration]';
60
60
  }
@@ -954,63 +954,63 @@ module.exports = (() => {
954
954
  * @param {RequestInterceptor=|Promise.<RequestInterceptor>=} requestInterceptor - A request interceptor used with each request (typically used to inject JWT tokens).
955
955
  * @returns {Promise.<PortfolioGateway>}
956
956
  */
957
- static forLocal(requestInterceptor) {
957
+ static forDevelopment(requestInterceptor) {
958
958
  return Promise.resolve(requestInterceptor)
959
959
  .then((requestInterceptor) => {
960
960
  assert.argumentIsOptional(requestInterceptor, 'requestInterceptor', RequestInterceptor, 'RequestInterceptor');
961
961
 
962
- return start(new PortfolioGateway('http', Configuration.localHost, 3000, requestInterceptor));
962
+ return start(new PortfolioGateway('https', Configuration.developmentHost, 443, 'development', requestInterceptor));
963
963
  });
964
964
  }
965
965
 
966
966
  /**
967
- * Creates and starts a new {@link PortfolioGateway} for use in the development environment.
967
+ * Creates and starts a new {@link PortfolioGateway} for use in the staging environment.
968
968
  *
969
969
  * @public
970
970
  * @static
971
971
  * @param {RequestInterceptor=|Promise.<RequestInterceptor>=} requestInterceptor - A request interceptor used with each request (typically used to inject JWT tokens).
972
972
  * @returns {Promise.<PortfolioGateway>}
973
973
  */
974
- static forDevelopment(requestInterceptor) {
974
+ static forStaging(requestInterceptor) {
975
975
  return Promise.resolve(requestInterceptor)
976
976
  .then((requestInterceptor) => {
977
977
  assert.argumentIsOptional(requestInterceptor, 'requestInterceptor', RequestInterceptor, 'RequestInterceptor');
978
978
 
979
- return start(new PortfolioGateway('https', Configuration.developmentHost, 443, 'development', requestInterceptor));
979
+ return start(new PortfolioGateway('https', Configuration.stagingHost, 443, 'staging', requestInterceptor));
980
980
  });
981
981
  }
982
982
 
983
983
  /**
984
- * Creates and starts a new {@link PortfolioGateway} for use in the staging environment.
984
+ * Creates and starts a new {@link PortfolioGateway} for use in the production environment.
985
985
  *
986
986
  * @public
987
987
  * @static
988
988
  * @param {RequestInterceptor=|Promise.<RequestInterceptor>=} requestInterceptor - A request interceptor used with each request (typically used to inject JWT tokens).
989
989
  * @returns {Promise.<PortfolioGateway>}
990
990
  */
991
- static forStaging(requestInterceptor) {
991
+ static forProduction(requestInterceptor) {
992
992
  return Promise.resolve(requestInterceptor)
993
993
  .then((requestInterceptor) => {
994
994
  assert.argumentIsOptional(requestInterceptor, 'requestInterceptor', RequestInterceptor, 'RequestInterceptor');
995
995
 
996
- return start(new PortfolioGateway('https', Configuration.stagingHost, 443, 'staging', requestInterceptor));
996
+ return start(new PortfolioGateway('https', Configuration.productionHost, 443, 'production', requestInterceptor));
997
997
  });
998
998
  }
999
999
 
1000
1000
  /**
1001
- * Creates and starts a new {@link PortfolioGateway} for use in the production environment.
1001
+ * Creates and starts a new {@link PortfolioGateway} for use in the administration environment.
1002
1002
  *
1003
1003
  * @public
1004
1004
  * @static
1005
1005
  * @param {RequestInterceptor=|Promise.<RequestInterceptor>=} requestInterceptor - A request interceptor used with each request (typically used to inject JWT tokens).
1006
1006
  * @returns {Promise.<PortfolioGateway>}
1007
1007
  */
1008
- static forProduction(requestInterceptor) {
1008
+ static forAdmin(requestInterceptor) {
1009
1009
  return Promise.resolve(requestInterceptor)
1010
1010
  .then((requestInterceptor) => {
1011
1011
  assert.argumentIsOptional(requestInterceptor, 'requestInterceptor', RequestInterceptor, 'RequestInterceptor');
1012
1012
 
1013
- return start(new PortfolioGateway('https', Configuration.productionHost, 443, 'production', requestInterceptor));
1013
+ return start(new PortfolioGateway('https', Configuration.adminHost, 443, requestInterceptor));
1014
1014
  });
1015
1015
  }
1016
1016
 
@@ -1,7 +1,5 @@
1
1
  const assert = require('@barchart/common-js/lang/assert'),
2
2
  Disposable = require('@barchart/common-js/lang/Disposable'),
3
- Enum = require('@barchart/common-js/lang/Enum'),
4
- is = require('@barchart/common-js/lang/is'),
5
3
  Scheduler = require('@barchart/common-js/timing/Scheduler');
6
4
 
7
5
  const EndpointBuilder = require('@barchart/common-js/api/http/builders/EndpointBuilder'),
@@ -164,7 +162,7 @@ module.exports = (() => {
164
162
  * @returns {Promise.<JwtGateway>}
165
163
  */
166
164
  static forDevelopment(userId, userLegacyId) {
167
- return start(new JwtGateway(forDevelopment(userId, userLegacyId), 60000));
165
+ return start(new JwtGateway(forDevelopment(userId, userLegacyId), 180000));
168
166
  }
169
167
 
170
168
  /**
@@ -240,6 +238,34 @@ module.exports = (() => {
240
238
  });
241
239
  }
242
240
 
241
+ /**
242
+ * Creates and starts a new {@link JwtGateway} for use in the internal admin environment.
243
+ *
244
+ * @public
245
+ * @static
246
+ * @param {String} userId - The identifier of the user to impersonate.
247
+ * @param {String} userLegacyId - The legacy identifier of the user to impersonate.
248
+ * @returns {Promise.<JwtGateway>}
249
+ */
250
+ static forAdmin(userId, userLegacyId) {
251
+ return start(new JwtGateway(forAdmin(userId, userLegacyId), 180000));
252
+ }
253
+
254
+ /**
255
+ * Creates and starts a new {@link RequestInterceptor} for use in the internal admin environment.
256
+ *
257
+ * @public
258
+ * @static
259
+ * @param {String} userId - The identifier of the user to impersonate.
260
+ * @returns {Promise.<RequestInterceptor>}
261
+ */
262
+ static forAdminClient(userId, userLegacyId) {
263
+ return JwtGateway.forAdmin(userId, userLegacyId)
264
+ .then((jwtGateway) => {
265
+ return jwtGateway.toRequestInterceptor();
266
+ });
267
+ }
268
+
243
269
  _onDispose() {
244
270
  return;
245
271
  }
@@ -308,5 +334,25 @@ module.exports = (() => {
308
334
  .endpoint;
309
335
  }
310
336
 
337
+ function forAdmin(userId, legacyUserId) {
338
+ return EndpointBuilder.for('read-jwt-token-for-development', 'lookup user identity')
339
+ .withVerb(VerbType.GET)
340
+ .withProtocol(ProtocolType.HTTPS)
341
+ .withHost(Configuration.adminHost)
342
+ .withPathBuilder((pb) => {
343
+ pb.withLiteralParameter('token', 'token')
344
+ .withLiteralParameter('barchart', 'barchart')
345
+ .withLiteralParameter('generator', 'generator');
346
+ })
347
+ .withQueryBuilder((qb) => {
348
+ qb.withLiteralParameter('user', 'userId', userId)
349
+ .withLiteralParameter('legacy user', 'userLegacyId', legacyUserId)
350
+ .withLiteralParameter('user context', 'userContext', 'TGAM')
351
+ .withLiteralParameter('user permission level', 'userPermissions', 'registered');
352
+ })
353
+ .withResponseInterceptor(ResponseInterceptor.DATA)
354
+ .endpoint;
355
+ }
356
+
311
357
  return JwtGateway;
312
358
  })();
package/lib/index.js CHANGED
@@ -7,6 +7,6 @@ module.exports = (() => {
7
7
  return {
8
8
  JwtGateway: JwtGateway,
9
9
  PortfolioGateway: PortfolioGateway,
10
- version: '1.2.38'
10
+ version: '1.2.41'
11
11
  };
12
12
  })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barchart/portfolio-client-js",
3
- "version": "1.2.38",
3
+ "version": "1.2.41",
4
4
  "description": "JavaScript library for interfacing with Barchart's Portfolio API",
5
5
  "author": {
6
6
  "name": "Bryan Ingle",