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.
package/dist/wealthica.js CHANGED
@@ -6049,7 +6049,7 @@ var API = /*#__PURE__*/function () {
6049
6049
  return _ref.apply(this, arguments);
6050
6050
  };
6051
6051
  }());
6052
- var userResources = createResources(user, ['institutions', 'history', 'transactions']);
6052
+ var userResources = createResources(user, ['institutions', 'history', 'transactions', 'positions']);
6053
6053
  Object.assign(user, userResources);
6054
6054
  user.config.loginName = loginName;
6055
6055
  return user;
@@ -6540,9 +6540,6 @@ module.exports = new Wealthica();
6540
6540
  /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6541
6541
 
6542
6542
  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); }
6543
- var _excluded = ["institutionId"];
6544
- 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; }
6545
- 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; }
6546
6543
  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); } }
6547
6544
  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); }); }; }
6548
6545
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
@@ -6562,8 +6559,6 @@ var History = /*#__PURE__*/function () {
6562
6559
  value: function () {
6563
6560
  var _getList = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
6564
6561
  var options,
6565
- institutionId,
6566
- params,
6567
6562
  url,
6568
6563
  query,
6569
6564
  response,
@@ -6573,28 +6568,21 @@ var History = /*#__PURE__*/function () {
6573
6568
  switch (_context.prev = _context.next) {
6574
6569
  case 0:
6575
6570
  options = _args.length > 0 && _args[0] !== undefined ? _args[0] : {};
6576
- institutionId = options.institutionId, params = _objectWithoutProperties(options, _excluded);
6577
- if (!(!institutionId || typeof institutionId !== 'string')) {
6578
- _context.next = 4;
6579
- break;
6580
- }
6581
- throw new Error('Please provide a valid Wealthica institution id.');
6582
- case 4:
6583
- url = "/institutions/".concat(institutionId, "/history");
6584
- query = getQueryString(params);
6571
+ url = '/history';
6572
+ query = getQueryString(options);
6585
6573
  if (query) url = "".concat(url, "?").concat(query);
6586
- _context.next = 9;
6574
+ _context.next = 6;
6587
6575
  return this.api.get(url);
6588
- case 9:
6576
+ case 6:
6589
6577
  response = _context.sent;
6590
6578
  if (response.ok) {
6591
- _context.next = 12;
6579
+ _context.next = 9;
6592
6580
  break;
6593
6581
  }
6594
6582
  throw response.originalError;
6595
- case 12:
6583
+ case 9:
6596
6584
  return _context.abrupt("return", response.data);
6597
- case 13:
6585
+ case 10:
6598
6586
  case "end":
6599
6587
  return _context.stop();
6600
6588
  }
@@ -6622,7 +6610,8 @@ var RESOURCES = {
6622
6610
  history: __webpack_require__(55987),
6623
6611
  providers: __webpack_require__(95269),
6624
6612
  teams: __webpack_require__(67523),
6625
- transactions: __webpack_require__(46123)
6613
+ transactions: __webpack_require__(46123),
6614
+ positions: __webpack_require__(87334)
6626
6615
  };
6627
6616
  module.exports = function createResources(api, resources) {
6628
6617
  return resources.reduce(function (res, resource) {
@@ -6818,6 +6807,71 @@ module.exports = Institutions;
6818
6807
 
6819
6808
  /***/ }),
6820
6809
 
6810
+ /***/ 87334:
6811
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6812
+
6813
+ 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); }
6814
+ 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); } }
6815
+ 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); }); }; }
6816
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6817
+ 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); } }
6818
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
6819
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
6820
+ 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); }
6821
+ var _require = __webpack_require__(9853),
6822
+ getQueryString = _require.getQueryString;
6823
+ var Positions = /*#__PURE__*/function () {
6824
+ function Positions(api) {
6825
+ _classCallCheck(this, Positions);
6826
+ this.api = api.userApi;
6827
+ }
6828
+ _createClass(Positions, [{
6829
+ key: "getList",
6830
+ value: function () {
6831
+ var _getList = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
6832
+ var options,
6833
+ url,
6834
+ query,
6835
+ response,
6836
+ _args = arguments;
6837
+ return regeneratorRuntime.wrap(function _callee$(_context) {
6838
+ while (1) {
6839
+ switch (_context.prev = _context.next) {
6840
+ case 0:
6841
+ options = _args.length > 0 && _args[0] !== undefined ? _args[0] : {};
6842
+ url = '/positions';
6843
+ query = getQueryString(options);
6844
+ if (query) url = "".concat(url, "?").concat(query);
6845
+ _context.next = 6;
6846
+ return this.api.get(url);
6847
+ case 6:
6848
+ response = _context.sent;
6849
+ if (response.ok) {
6850
+ _context.next = 9;
6851
+ break;
6852
+ }
6853
+ throw response.originalError;
6854
+ case 9:
6855
+ return _context.abrupt("return", response.data);
6856
+ case 10:
6857
+ case "end":
6858
+ return _context.stop();
6859
+ }
6860
+ }
6861
+ }, _callee, this);
6862
+ }));
6863
+ function getList() {
6864
+ return _getList.apply(this, arguments);
6865
+ }
6866
+ return getList;
6867
+ }()
6868
+ }]);
6869
+ return Positions;
6870
+ }();
6871
+ module.exports = Positions;
6872
+
6873
+ /***/ }),
6874
+
6821
6875
  /***/ 95269:
6822
6876
  /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6823
6877
 
@@ -6986,10 +7040,12 @@ module.exports = Teams;
6986
7040
  /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6987
7041
 
6988
7042
  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); }
6989
- var _excluded = ["institutionId"],
6990
- _excluded2 = ["institutionId", "txId"];
7043
+ var _excluded = ["txId"];
6991
7044
  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; }
6992
7045
  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; }
7046
+ 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; }
7047
+ 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; }
7048
+ 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; }
6993
7049
  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); } }
6994
7050
  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); }); }; }
6995
7051
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
@@ -7009,9 +7065,8 @@ var Transactions = /*#__PURE__*/function () {
7009
7065
  value: function () {
7010
7066
  var _getList = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
7011
7067
  var options,
7012
- institutionId,
7013
- params,
7014
7068
  url,
7069
+ institutions,
7015
7070
  query,
7016
7071
  response,
7017
7072
  _args = arguments;
@@ -7020,15 +7075,17 @@ var Transactions = /*#__PURE__*/function () {
7020
7075
  switch (_context.prev = _context.next) {
7021
7076
  case 0:
7022
7077
  options = _args.length > 0 && _args[0] !== undefined ? _args[0] : {};
7023
- institutionId = options.institutionId, params = _objectWithoutProperties(options, _excluded);
7024
- if (!(!institutionId || typeof institutionId !== 'string')) {
7025
- _context.next = 4;
7026
- break;
7078
+ url = '/transactions';
7079
+ institutions = options.institutions || []; // Add institutionId for backward compatibility
7080
+ if (options.institutionId && !institutions.includes(options.institutionId)) {
7081
+ institutions.push(options.institutionId);
7027
7082
  }
7028
- throw new Error('Please provide a valid Wealthica institution id.');
7029
- case 4:
7030
- url = "/transactions?institutions=".concat(institutionId);
7031
- query = getQueryString(params);
7083
+
7084
+ // eslint-disable-next-line no-param-reassign
7085
+ delete options.institutionId;
7086
+ query = getQueryString(_objectSpread(_objectSpread({}, options), {}, {
7087
+ institutions: institutions
7088
+ }));
7032
7089
  if (query) url = "".concat(url, "?").concat(query);
7033
7090
  _context.next = 9;
7034
7091
  return this.api.get(url);
@@ -7058,7 +7115,6 @@ var Transactions = /*#__PURE__*/function () {
7058
7115
  value: function () {
7059
7116
  var _getOne = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
7060
7117
  var options,
7061
- institutionId,
7062
7118
  txId,
7063
7119
  params,
7064
7120
  url,
@@ -7070,34 +7126,28 @@ var Transactions = /*#__PURE__*/function () {
7070
7126
  switch (_context2.prev = _context2.next) {
7071
7127
  case 0:
7072
7128
  options = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {};
7073
- institutionId = options.institutionId, txId = options.txId, params = _objectWithoutProperties(options, _excluded2);
7074
- if (!(!institutionId || typeof institutionId !== 'string')) {
7075
- _context2.next = 4;
7076
- break;
7077
- }
7078
- throw new Error('Please provide a valid Wealthica institution id.');
7079
- case 4:
7129
+ txId = options.txId, params = _objectWithoutProperties(options, _excluded);
7080
7130
  if (!(!txId || typeof txId !== 'string')) {
7081
- _context2.next = 6;
7131
+ _context2.next = 4;
7082
7132
  break;
7083
7133
  }
7084
7134
  throw new Error('Please provide a valid Wealthica transaction id.');
7085
- case 6:
7135
+ case 4:
7086
7136
  url = "/transactions/".concat(txId);
7087
7137
  query = getQueryString(params);
7088
7138
  if (query) url = "".concat(url, "?").concat(query);
7089
- _context2.next = 11;
7139
+ _context2.next = 9;
7090
7140
  return this.api.get(url);
7091
- case 11:
7141
+ case 9:
7092
7142
  response = _context2.sent;
7093
7143
  if (response.ok) {
7094
- _context2.next = 14;
7144
+ _context2.next = 12;
7095
7145
  break;
7096
7146
  }
7097
7147
  throw response.originalError;
7098
- case 14:
7148
+ case 12:
7099
7149
  return _context2.abrupt("return", response.data);
7100
- case 15:
7150
+ case 13:
7101
7151
  case "end":
7102
7152
  return _context2.stop();
7103
7153
  }
@@ -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
+ }