wealthica-sdk-js 0.0.10 → 0.0.13

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.
@@ -41,6 +41,7 @@ interface APIUserInterface extends APIInterface {
41
41
  institutions: InstitutionsInterface
42
42
  history: HistoryInterface
43
43
  transactions: TransactionsInterface
44
+ positions: PositionsInterface
44
45
  }
45
46
 
46
47
  interface InstitutionsInterface {
@@ -62,6 +63,11 @@ interface TransactionsInterface {
62
63
  getOne(options: TransactionOptions): Promise<Transactions> | Promise<never>
63
64
  }
64
65
 
66
+ interface PositionsInterface {
67
+ constructor(api: APIUserInterface)
68
+ getList(options: PositionsOptions): Promise<Position[]> | Promise<never>
69
+ }
70
+
65
71
  type APIConfig = {
66
72
  clientId: string;
67
73
  secret?: string;
@@ -98,19 +104,41 @@ type ConnectData = {
98
104
  }
99
105
 
100
106
  type TransactionsOptions = {
101
- institutionId: string;
107
+ institutions?: Array<string>;
108
+ investments?: Array<string>;
109
+ groups?: Array<string>;
102
110
  from?: string;
103
111
  to?: string;
104
- investments?: string;
112
+ assets?: boolean;
113
+ liabilities?: boolean;
114
+ banking?: boolean;
115
+ types?: Array<string>;
116
+ deleted?: Boolean;
117
+ invalid?: Boolean;
118
+ new?: Boolean;
119
+ peek?: Boolean;
120
+ missing?: Boolean;
105
121
  last?: string;
106
122
  limit?: number;
123
+ sort?: string;
124
+ security?: Boolean;
125
+ skip_date_filter?: Boolean;
126
+ institutionId?: string;
107
127
  }
108
128
 
109
129
  type TransactionOptions = {
110
- institutionId: string;
111
130
  txId: string;
112
131
  }
113
132
 
133
+ type PositionsOptions = {
134
+ groups?: Array<string>;
135
+ institutions?: Array<string>;
136
+ investments?: Array<string>;
137
+ assets?: Boolean;
138
+ liabilities?: Boolean;
139
+ banking?: Boolean;
140
+ }
141
+
114
142
  type Part = {
115
143
  direction: string;
116
144
  ticker: string;
@@ -145,10 +173,10 @@ type Transactions = {
145
173
  }
146
174
 
147
175
  type HistoryListOptions = {
148
- institutionId: string;
176
+ institutions: string[];
149
177
  from?: string;
150
178
  to?: string;
151
- investments?: string;
179
+ investments?: string[];
152
180
  }
153
181
 
154
182
  type BalanceHistory = {
@@ -204,3 +232,49 @@ type Institution = {
204
232
  updated_at: number;
205
233
  resource_type: string;
206
234
  }
235
+
236
+ type Position = {
237
+ _id: string;
238
+ class: string;
239
+ classes: {
240
+ class: string;
241
+ weight: number;
242
+ };
243
+ category: string;
244
+ categories: Array<string>;
245
+ security: Security;
246
+ investments: Array<PositionInvestment>
247
+ quantity: number;
248
+ book_value: number;
249
+ market_value: number;
250
+ gain_amount: number;
251
+ gain_percent: number;
252
+ }
253
+
254
+ type Security = {
255
+ _id: string;
256
+ currency: string;
257
+ symbol: string;
258
+ type: string;
259
+ name: string;
260
+ aliases: Array<string>;
261
+ last_price: number;
262
+ last_date: string;
263
+ high_price: number;
264
+ high_date: string;
265
+ low_price: number;
266
+ low_date: string;
267
+ cusip: string;
268
+ }
269
+
270
+ type PositionInvestment = {
271
+ institution: string;
272
+ investment: string;
273
+ currency: string;
274
+ quantity: number;
275
+ book_value: number;
276
+ market_value: number;
277
+ value: number;
278
+ gain_amount: number;
279
+ gain_percent: number;
280
+ }
package/lib/wealthica.js CHANGED
@@ -2453,7 +2453,7 @@ var API = /*#__PURE__*/function () {
2453
2453
  return _ref.apply(this, arguments);
2454
2454
  };
2455
2455
  }());
2456
- var userResources = createResources(user, ['institutions', 'history', 'transactions']);
2456
+ var userResources = createResources(user, ['institutions', 'history', 'transactions', 'positions']);
2457
2457
  Object.assign(user, userResources);
2458
2458
  user.config.loginName = loginName;
2459
2459
  return user;
@@ -2944,9 +2944,6 @@ module.exports = new Wealthica();
2944
2944
  /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2945
2945
 
2946
2946
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2947
- var _excluded = ["institutionId"];
2948
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
2949
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
2950
2947
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
2951
2948
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
2952
2949
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
@@ -2966,8 +2963,6 @@ var History = /*#__PURE__*/function () {
2966
2963
  value: function () {
2967
2964
  var _getList = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
2968
2965
  var options,
2969
- institutionId,
2970
- params,
2971
2966
  url,
2972
2967
  query,
2973
2968
  response,
@@ -2977,28 +2972,21 @@ var History = /*#__PURE__*/function () {
2977
2972
  switch (_context.prev = _context.next) {
2978
2973
  case 0:
2979
2974
  options = _args.length > 0 && _args[0] !== undefined ? _args[0] : {};
2980
- institutionId = options.institutionId, params = _objectWithoutProperties(options, _excluded);
2981
- if (!(!institutionId || typeof institutionId !== 'string')) {
2982
- _context.next = 4;
2983
- break;
2984
- }
2985
- throw new Error('Please provide a valid Wealthica institution id.');
2986
- case 4:
2987
- url = "/institutions/".concat(institutionId, "/history");
2988
- query = getQueryString(params);
2975
+ url = '/history';
2976
+ query = getQueryString(options);
2989
2977
  if (query) url = "".concat(url, "?").concat(query);
2990
- _context.next = 9;
2978
+ _context.next = 6;
2991
2979
  return this.api.get(url);
2992
- case 9:
2980
+ case 6:
2993
2981
  response = _context.sent;
2994
2982
  if (response.ok) {
2995
- _context.next = 12;
2983
+ _context.next = 9;
2996
2984
  break;
2997
2985
  }
2998
2986
  throw response.originalError;
2999
- case 12:
2987
+ case 9:
3000
2988
  return _context.abrupt("return", response.data);
3001
- case 13:
2989
+ case 10:
3002
2990
  case "end":
3003
2991
  return _context.stop();
3004
2992
  }
@@ -3026,7 +3014,8 @@ var RESOURCES = {
3026
3014
  history: __webpack_require__(55987),
3027
3015
  providers: __webpack_require__(95269),
3028
3016
  teams: __webpack_require__(67523),
3029
- transactions: __webpack_require__(46123)
3017
+ transactions: __webpack_require__(46123),
3018
+ positions: __webpack_require__(87334)
3030
3019
  };
3031
3020
  module.exports = function createResources(api, resources) {
3032
3021
  return resources.reduce(function (res, resource) {
@@ -3222,6 +3211,71 @@ module.exports = Institutions;
3222
3211
 
3223
3212
  /***/ }),
3224
3213
 
3214
+ /***/ 87334:
3215
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3216
+
3217
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
3218
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
3219
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
3220
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
3221
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
3222
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
3223
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
3224
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
3225
+ var _require = __webpack_require__(9853),
3226
+ getQueryString = _require.getQueryString;
3227
+ var Positions = /*#__PURE__*/function () {
3228
+ function Positions(api) {
3229
+ _classCallCheck(this, Positions);
3230
+ this.api = api.userApi;
3231
+ }
3232
+ _createClass(Positions, [{
3233
+ key: "getList",
3234
+ value: function () {
3235
+ var _getList = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
3236
+ var options,
3237
+ url,
3238
+ query,
3239
+ response,
3240
+ _args = arguments;
3241
+ return regeneratorRuntime.wrap(function _callee$(_context) {
3242
+ while (1) {
3243
+ switch (_context.prev = _context.next) {
3244
+ case 0:
3245
+ options = _args.length > 0 && _args[0] !== undefined ? _args[0] : {};
3246
+ url = '/positions';
3247
+ query = getQueryString(options);
3248
+ if (query) url = "".concat(url, "?").concat(query);
3249
+ _context.next = 6;
3250
+ return this.api.get(url);
3251
+ case 6:
3252
+ response = _context.sent;
3253
+ if (response.ok) {
3254
+ _context.next = 9;
3255
+ break;
3256
+ }
3257
+ throw response.originalError;
3258
+ case 9:
3259
+ return _context.abrupt("return", response.data);
3260
+ case 10:
3261
+ case "end":
3262
+ return _context.stop();
3263
+ }
3264
+ }
3265
+ }, _callee, this);
3266
+ }));
3267
+ function getList() {
3268
+ return _getList.apply(this, arguments);
3269
+ }
3270
+ return getList;
3271
+ }()
3272
+ }]);
3273
+ return Positions;
3274
+ }();
3275
+ module.exports = Positions;
3276
+
3277
+ /***/ }),
3278
+
3225
3279
  /***/ 95269:
3226
3280
  /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3227
3281
 
@@ -3390,10 +3444,12 @@ module.exports = Teams;
3390
3444
  /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3391
3445
 
3392
3446
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
3393
- var _excluded = ["institutionId"],
3394
- _excluded2 = ["institutionId", "txId"];
3447
+ var _excluded = ["txId"];
3395
3448
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
3396
3449
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
3450
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3451
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
3452
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
3397
3453
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
3398
3454
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
3399
3455
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
@@ -3413,9 +3469,8 @@ var Transactions = /*#__PURE__*/function () {
3413
3469
  value: function () {
3414
3470
  var _getList = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
3415
3471
  var options,
3416
- institutionId,
3417
- params,
3418
3472
  url,
3473
+ institutions,
3419
3474
  query,
3420
3475
  response,
3421
3476
  _args = arguments;
@@ -3424,15 +3479,17 @@ var Transactions = /*#__PURE__*/function () {
3424
3479
  switch (_context.prev = _context.next) {
3425
3480
  case 0:
3426
3481
  options = _args.length > 0 && _args[0] !== undefined ? _args[0] : {};
3427
- institutionId = options.institutionId, params = _objectWithoutProperties(options, _excluded);
3428
- if (!(!institutionId || typeof institutionId !== 'string')) {
3429
- _context.next = 4;
3430
- break;
3482
+ url = '/transactions';
3483
+ institutions = options.institutions || []; // Add institutionId for backward compatibility
3484
+ if (options.institutionId && !institutions.includes(options.institutionId)) {
3485
+ institutions.push(options.institutionId);
3431
3486
  }
3432
- throw new Error('Please provide a valid Wealthica institution id.');
3433
- case 4:
3434
- url = "/transactions?institutions=".concat(institutionId);
3435
- query = getQueryString(params);
3487
+
3488
+ // eslint-disable-next-line no-param-reassign
3489
+ delete options.institutionId;
3490
+ query = getQueryString(_objectSpread(_objectSpread({}, options), {}, {
3491
+ institutions: institutions
3492
+ }));
3436
3493
  if (query) url = "".concat(url, "?").concat(query);
3437
3494
  _context.next = 9;
3438
3495
  return this.api.get(url);
@@ -3462,7 +3519,6 @@ var Transactions = /*#__PURE__*/function () {
3462
3519
  value: function () {
3463
3520
  var _getOne = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
3464
3521
  var options,
3465
- institutionId,
3466
3522
  txId,
3467
3523
  params,
3468
3524
  url,
@@ -3474,34 +3530,28 @@ var Transactions = /*#__PURE__*/function () {
3474
3530
  switch (_context2.prev = _context2.next) {
3475
3531
  case 0:
3476
3532
  options = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {};
3477
- institutionId = options.institutionId, txId = options.txId, params = _objectWithoutProperties(options, _excluded2);
3478
- if (!(!institutionId || typeof institutionId !== 'string')) {
3479
- _context2.next = 4;
3480
- break;
3481
- }
3482
- throw new Error('Please provide a valid Wealthica institution id.');
3483
- case 4:
3533
+ txId = options.txId, params = _objectWithoutProperties(options, _excluded);
3484
3534
  if (!(!txId || typeof txId !== 'string')) {
3485
- _context2.next = 6;
3535
+ _context2.next = 4;
3486
3536
  break;
3487
3537
  }
3488
3538
  throw new Error('Please provide a valid Wealthica transaction id.');
3489
- case 6:
3539
+ case 4:
3490
3540
  url = "/transactions/".concat(txId);
3491
3541
  query = getQueryString(params);
3492
3542
  if (query) url = "".concat(url, "?").concat(query);
3493
- _context2.next = 11;
3543
+ _context2.next = 9;
3494
3544
  return this.api.get(url);
3495
- case 11:
3545
+ case 9:
3496
3546
  response = _context2.sent;
3497
3547
  if (response.ok) {
3498
- _context2.next = 14;
3548
+ _context2.next = 12;
3499
3549
  break;
3500
3550
  }
3501
3551
  throw response.originalError;
3502
- case 14:
3552
+ case 12:
3503
3553
  return _context2.abrupt("return", response.data);
3504
- case 15:
3554
+ case 13:
3505
3555
  case "end":
3506
3556
  return _context2.stop();
3507
3557
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wealthica-sdk-js",
3
- "version": "0.0.10",
3
+ "version": "0.0.13",
4
4
  "description": "Official Wealthica JS SDK for the Browser & NodeJS",
5
5
  "author": "Wealthica Financial Technology Inc. <hello@wealthica.com> (https://wealthica.com/)",
6
6
  "license": "MIT",