bkper-js 1.0.0 → 1.2.0

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.
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
2
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
3
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -8,9 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
8
  });
10
9
  };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.TransactionIterator = void 0;
13
- const TransactionPage_1 = require("./TransactionPage");
10
+ import { TransactionPage } from "./TransactionPage.js";
14
11
  /**
15
12
  *
16
13
  * An iterator that allows scripts to iterate over a potentially large collection of transactions.
@@ -30,7 +27,7 @@ const TransactionPage_1 = require("./TransactionPage");
30
27
  *
31
28
  * @public
32
29
  */
33
- class TransactionIterator {
30
+ export class TransactionIterator {
34
31
  /** @internal */
35
32
  constructor(book, query) {
36
33
  this.book = book;
@@ -38,9 +35,9 @@ class TransactionIterator {
38
35
  if (this.query == null) {
39
36
  this.query = "";
40
37
  }
41
- this.currentPage = null;
42
- this.nextPage = null;
43
- this.lastCursor = null;
38
+ this.currentPage = undefined;
39
+ this.nextPage = undefined;
40
+ this.lastCursor = undefined;
44
41
  }
45
42
  /**
46
43
  * Gets the Book that originate the iterator
@@ -57,7 +54,7 @@ class TransactionIterator {
57
54
  */
58
55
  getContinuationToken() {
59
56
  if (this.currentPage == null) {
60
- return null;
57
+ return undefined;
61
58
  }
62
59
  var cursor = this.lastCursor;
63
60
  if (cursor == null) {
@@ -84,7 +81,7 @@ class TransactionIterator {
84
81
  this.lastCursor = cursor;
85
82
  }
86
83
  let indexNum = new Number(index).valueOf();
87
- this.currentPage = yield new TransactionPage_1.TransactionPage().init(this.book, this.query, this.lastCursor);
84
+ this.currentPage = yield new TransactionPage().init(this.book, this.query, this.lastCursor);
88
85
  this.currentPage.setIndex(indexNum);
89
86
  });
90
87
  }
@@ -94,7 +91,7 @@ class TransactionIterator {
94
91
  hasNext() {
95
92
  return __awaiter(this, void 0, void 0, function* () {
96
93
  if (this.currentPage == null) {
97
- this.currentPage = yield new TransactionPage_1.TransactionPage().init(this.book, this.query, this.lastCursor);
94
+ this.currentPage = yield new TransactionPage().init(this.book, this.query, this.lastCursor);
98
95
  }
99
96
  if (this.currentPage.hasNext()) {
100
97
  return true;
@@ -102,7 +99,7 @@ class TransactionIterator {
102
99
  else if (!this.currentPage.hasReachEnd()) {
103
100
  this.lastCursor = this.currentPage.getCursor();
104
101
  if (this.nextPage == null) {
105
- this.nextPage = yield new TransactionPage_1.TransactionPage().init(this.book, this.query, this.lastCursor);
102
+ this.nextPage = yield new TransactionPage().init(this.book, this.query, this.lastCursor);
106
103
  }
107
104
  return this.nextPage.hasNext();
108
105
  }
@@ -117,24 +114,24 @@ class TransactionIterator {
117
114
  next() {
118
115
  return __awaiter(this, void 0, void 0, function* () {
119
116
  if (this.currentPage == null) {
120
- this.currentPage = yield new TransactionPage_1.TransactionPage().init(this.book, this.query, this.lastCursor);
117
+ this.currentPage = yield new TransactionPage().init(this.book, this.query, this.lastCursor);
121
118
  }
122
119
  if (this.currentPage.hasNext()) {
123
120
  return this.currentPage.next();
124
121
  }
125
122
  else if (!this.currentPage.hasReachEnd()) {
126
123
  this.lastCursor = this.currentPage.getCursor();
127
- if (this.nextPage != null) {
124
+ if (this.nextPage) {
128
125
  this.currentPage = this.nextPage;
129
- this.nextPage = null;
126
+ this.nextPage = undefined;
130
127
  }
131
128
  else {
132
- this.currentPage = yield new TransactionPage_1.TransactionPage().init(this.book, this.query, this.lastCursor);
129
+ this.currentPage = yield new TransactionPage().init(this.book, this.query, this.lastCursor);
133
130
  }
134
131
  return this.currentPage.next();
135
132
  }
136
133
  else {
137
- return null;
134
+ return undefined;
138
135
  }
139
136
  });
140
137
  }
@@ -144,11 +141,10 @@ class TransactionIterator {
144
141
  getAccount() {
145
142
  return __awaiter(this, void 0, void 0, function* () {
146
143
  if (this.currentPage == null) {
147
- this.currentPage = yield new TransactionPage_1.TransactionPage().init(this.book, this.query, this.lastCursor);
144
+ this.currentPage = yield new TransactionPage().init(this.book, this.query, this.lastCursor);
148
145
  }
149
146
  return this.currentPage.getAccount();
150
147
  });
151
148
  }
152
149
  }
153
- exports.TransactionIterator = TransactionIterator;
154
150
  //# sourceMappingURL=TransactionIterator.js.map
@@ -1,27 +1,3 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
1
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
2
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
3
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -31,20 +7,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
31
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
32
8
  });
33
9
  };
34
- Object.defineProperty(exports, "__esModule", { value: true });
35
- exports.TransactionPage = void 0;
36
- const Transaction_1 = require("./Transaction");
37
- const TransactionService = __importStar(require("../service/transaction-service"));
38
- const utils_1 = require("../utils");
39
- class TransactionPage {
10
+ import { Transaction } from "./Transaction.js";
11
+ import * as TransactionService from '../service/transaction-service.js';
12
+ export class TransactionPage {
13
+ constructor() {
14
+ this.transactions = [];
15
+ }
40
16
  init(book, query, lastCursor) {
41
17
  return __awaiter(this, void 0, void 0, function* () {
42
18
  var transactionList = yield TransactionService.searchTransactions(book.getId(), query, 1000, lastCursor);
43
- if (transactionList.items == null) {
19
+ if (!transactionList.items) {
44
20
  transactionList.items = [];
45
21
  }
46
- this.transactions = (0, utils_1.wrapObjects)(new Transaction_1.Transaction(), transactionList.items);
47
- book.configureTransactions_(this.transactions);
22
+ this.transactions = transactionList.items.map(tx => new Transaction(book, tx));
48
23
  this.cursor = transactionList.cursor;
49
24
  if (transactionList.account) {
50
25
  this.account = yield book.getAccount(transactionList.account);
@@ -63,17 +38,17 @@ class TransactionPage {
63
38
  return this.cursor;
64
39
  }
65
40
  hasNext() {
66
- return this.index < this.transactions.length;
41
+ return (this.index && this.index < this.transactions.length) || false;
67
42
  }
68
43
  hasReachEnd() {
69
- return this.reachEnd;
44
+ return this.reachEnd || false;
70
45
  }
71
46
  getIndex() {
72
- if (this.index >= this.transactions.length) {
47
+ if (this.index && this.index >= this.transactions.length) {
73
48
  return 0;
74
49
  }
75
50
  else {
76
- return this.index;
51
+ return this.index || 0;
77
52
  }
78
53
  }
79
54
  setIndex(index) {
@@ -83,15 +58,14 @@ class TransactionPage {
83
58
  return this.account;
84
59
  }
85
60
  next() {
86
- if (this.index < this.transactions.length) {
61
+ if (this.index && this.index < this.transactions.length) {
87
62
  var transaction = this.transactions[this.index];
88
63
  this.index++;
89
64
  return transaction;
90
65
  }
91
66
  else {
92
- return null;
67
+ return undefined;
93
68
  }
94
69
  }
95
70
  }
96
- exports.TransactionPage = TransactionPage;
97
71
  //# sourceMappingURL=TransactionPage.js.map
package/lib/model/User.js CHANGED
@@ -1,27 +1,3 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
1
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
2
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
3
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -31,18 +7,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
31
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
32
8
  });
33
9
  };
34
- Object.defineProperty(exports, "__esModule", { value: true });
35
- exports.User = void 0;
36
- const Connection_1 = require("./Connection");
37
- const ConnectionService = __importStar(require("../service/connection-service"));
10
+ import { Connection } from "./Connection.js";
11
+ import * as ConnectionService from '../service/connection-service.js';
38
12
  /**
39
13
  * This class defines a User.
40
14
  *
41
15
  * @public
42
16
  */
43
- class User {
44
- constructor(wrapped) {
45
- this.wrapped = wrapped;
17
+ export class User {
18
+ constructor(json) {
19
+ /** @internal */
20
+ this.wrapped = {};
21
+ this.wrapped = json || {};
46
22
  }
47
23
  /**
48
24
  * Gets the id of the User.
@@ -76,7 +52,7 @@ class User {
76
52
  getConnections() {
77
53
  return __awaiter(this, void 0, void 0, function* () {
78
54
  const json = yield ConnectionService.listConnections();
79
- return json.map(c => new Connection_1.Connection(c));
55
+ return json.map(c => new Connection(c));
80
56
  });
81
57
  }
82
58
  /**
@@ -89,9 +65,8 @@ class User {
89
65
  getConnection(id) {
90
66
  return __awaiter(this, void 0, void 0, function* () {
91
67
  const json = yield ConnectionService.getConnection(id);
92
- return new Connection_1.Connection(json);
68
+ return new Connection(json);
93
69
  });
94
70
  }
95
71
  }
96
- exports.User = User;
97
72
  //# sourceMappingURL=User.js.map
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
2
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
3
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -8,34 +7,29 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
8
  });
10
9
  };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.createAccount = createAccount;
13
- exports.updateAccount = updateAccount;
14
- exports.deleteAccount = deleteAccount;
15
- exports.getAccount = getAccount;
16
- const http_api_request_1 = require("./http-api-request");
17
- function createAccount(bookId, account) {
10
+ import { HttpBooksApiV5Request } from './http-api-request.js';
11
+ export function createAccount(bookId, account) {
18
12
  return __awaiter(this, void 0, void 0, function* () {
19
- var response = yield new http_api_request_1.HttpBooksApiV5Request(`${bookId}/accounts`).setMethod('POST').setPayload(account).fetch();
13
+ var response = yield new HttpBooksApiV5Request(`${bookId}/accounts`).setMethod('POST').setPayload(account).fetch();
20
14
  return response.data;
21
15
  });
22
16
  }
23
- function updateAccount(bookId, account) {
17
+ export function updateAccount(bookId, account) {
24
18
  return __awaiter(this, void 0, void 0, function* () {
25
19
  var payload = JSON.stringify(account);
26
- var response = yield new http_api_request_1.HttpBooksApiV5Request(`${bookId}/accounts`).setMethod('PUT').setPayload(payload).fetch();
20
+ var response = yield new HttpBooksApiV5Request(`${bookId}/accounts`).setMethod('PUT').setPayload(payload).fetch();
27
21
  return response.data;
28
22
  });
29
23
  }
30
- function deleteAccount(bookId, account) {
24
+ export function deleteAccount(bookId, account) {
31
25
  return __awaiter(this, void 0, void 0, function* () {
32
- var response = yield new http_api_request_1.HttpBooksApiV5Request(`${bookId}/accounts/${account.id}`).setMethod('DELETE').fetch();
26
+ var response = yield new HttpBooksApiV5Request(`${bookId}/accounts/${account.id}`).setMethod('DELETE').fetch();
33
27
  return response.data;
34
28
  });
35
29
  }
36
- function getAccount(bookId, idOrName) {
30
+ export function getAccount(bookId, idOrName) {
37
31
  return __awaiter(this, void 0, void 0, function* () {
38
- var response = yield new http_api_request_1.HttpBooksApiV5Request(`${bookId}/accounts/${encodeURIComponent(idOrName)}`).setMethod('GET').fetch();
32
+ var response = yield new HttpBooksApiV5Request(`${bookId}/accounts/${encodeURIComponent(idOrName)}`).setMethod('GET').fetch();
39
33
  return response.data;
40
34
  });
41
35
  }
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
2
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
3
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -8,26 +7,22 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
8
  });
10
9
  };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.createApp = createApp;
13
- exports.updateApp = updateApp;
14
- exports.patchApp = patchApp;
15
- const http_api_request_1 = require("./http-api-request");
16
- function createApp(app) {
10
+ import { HttpApiRequest } from "./http-api-request.js";
11
+ export function createApp(app) {
17
12
  return __awaiter(this, void 0, void 0, function* () {
18
- var response = yield new http_api_request_1.HttpApiRequest(`v5/apps`).setMethod('POST').setPayload(app).fetch();
13
+ var response = yield new HttpApiRequest(`v5/apps`).setMethod('POST').setPayload(app).fetch();
19
14
  return response.data;
20
15
  });
21
16
  }
22
- function updateApp(app) {
17
+ export function updateApp(app) {
23
18
  return __awaiter(this, void 0, void 0, function* () {
24
- var response = yield new http_api_request_1.HttpApiRequest(`v5/apps`).setMethod('PUT').setPayload(app).fetch();
19
+ var response = yield new HttpApiRequest(`v5/apps`).setMethod('PUT').setPayload(app).fetch();
25
20
  return response.data;
26
21
  });
27
22
  }
28
- function patchApp(app) {
23
+ export function patchApp(app) {
29
24
  return __awaiter(this, void 0, void 0, function* () {
30
- var response = yield new http_api_request_1.HttpApiRequest(`v5/apps`).setMethod('PATCH').setPayload(app).fetch();
25
+ var response = yield new HttpApiRequest(`v5/apps`).setMethod('PATCH').setPayload(app).fetch();
31
26
  return response.data;
32
27
  });
33
28
  }
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
2
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
3
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -8,12 +7,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
8
  });
10
9
  };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.getBalances = getBalances;
13
- const http_api_request_1 = require("./http-api-request");
14
- function getBalances(bookId, query) {
10
+ import { HttpBooksApiV5Request } from "./http-api-request.js";
11
+ export function getBalances(bookId, query) {
15
12
  return __awaiter(this, void 0, void 0, function* () {
16
- var response = yield new http_api_request_1.HttpBooksApiV5Request(`${bookId}/balances`).addParam('query', query).addParam('time', Date.now()).fetch();
13
+ var response = yield new HttpBooksApiV5Request(`${bookId}/balances`).addParam('query', query).addParam('time', Date.now()).fetch();
17
14
  return response.data;
18
15
  });
19
16
  }
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
2
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
3
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -8,29 +7,25 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
8
  });
10
9
  };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.loadBook = loadBook;
13
- exports.updateBook = updateBook;
14
- exports.audit = audit;
15
- const http_api_request_1 = require("./http-api-request");
16
- function loadBook(bookId) {
10
+ import { HttpBooksApiV5Request } from "./http-api-request.js";
11
+ export function loadBook(bookId) {
17
12
  return __awaiter(this, void 0, void 0, function* () {
18
13
  if (bookId == null) {
19
14
  throw new Error("Book id null!");
20
15
  }
21
- let response = yield new http_api_request_1.HttpBooksApiV5Request(bookId).fetch();
16
+ let response = yield new HttpBooksApiV5Request(bookId).fetch();
22
17
  return response.data;
23
18
  });
24
19
  }
25
- function updateBook(bookId, book) {
20
+ export function updateBook(bookId, book) {
26
21
  return __awaiter(this, void 0, void 0, function* () {
27
- var response = yield new http_api_request_1.HttpBooksApiV5Request(`${bookId}`).setMethod('PUT').setPayload(book).fetch();
22
+ var response = yield new HttpBooksApiV5Request(`${bookId}`).setMethod('PUT').setPayload(book).fetch();
28
23
  return response.data;
29
24
  });
30
25
  }
31
- function audit(bookId) {
26
+ export function audit(bookId) {
32
27
  return __awaiter(this, void 0, void 0, function* () {
33
- new http_api_request_1.HttpBooksApiV5Request(`${bookId}/audit`).setMethod('PATCH').fetch();
28
+ new HttpBooksApiV5Request(`${bookId}/audit`).setMethod('PATCH').fetch();
34
29
  });
35
30
  }
36
31
  //# sourceMappingURL=book-service.js.map
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
2
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
3
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -8,61 +7,57 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
8
  });
10
9
  };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.getConnection = getConnection;
13
- exports.listConnections = listConnections;
14
- exports.createConnection = createConnection;
15
- exports.updateConnection = updateConnection;
16
- exports.deleteConnection = deleteConnection;
17
- exports.listIntegrations = listIntegrations;
18
- const http_api_request_1 = require("./http-api-request");
19
- function getConnection(id) {
10
+ import { HttpApiV5Request } from "./http-api-request.js";
11
+ export function getConnection(id) {
20
12
  return __awaiter(this, void 0, void 0, function* () {
21
- const res = yield new http_api_request_1.HttpApiV5Request(`user/connections/${id}`)
13
+ const res = yield new HttpApiV5Request(`user/connections/${id}`)
22
14
  .setMethod('GET')
23
15
  .fetch();
24
16
  return res.data;
25
17
  });
26
18
  }
27
- function listConnections() {
19
+ export function listConnections() {
28
20
  return __awaiter(this, void 0, void 0, function* () {
29
21
  var _a;
30
- const res = yield new http_api_request_1.HttpApiV5Request(`user/connections`)
22
+ const res = yield new HttpApiV5Request(`user/connections`)
31
23
  .setMethod('GET')
32
24
  .fetch();
33
25
  return ((_a = res === null || res === void 0 ? void 0 : res.data) === null || _a === void 0 ? void 0 : _a.items) || [];
34
26
  });
35
27
  }
36
- function createConnection(connection) {
28
+ export function createConnection(connection) {
37
29
  return __awaiter(this, void 0, void 0, function* () {
38
- const res = yield new http_api_request_1.HttpApiV5Request(`user/connections`)
30
+ const res = yield new HttpApiV5Request(`user/connections`)
39
31
  .setPayload(connection)
40
32
  .setMethod('POST')
41
33
  .fetch();
42
34
  return res.data;
43
35
  });
44
36
  }
45
- function updateConnection(connection) {
37
+ export function updateConnection(connection) {
46
38
  return __awaiter(this, void 0, void 0, function* () {
47
- const res = yield new http_api_request_1.HttpApiV5Request(`user/connections`)
39
+ const res = yield new HttpApiV5Request(`user/connections`)
48
40
  .setPayload(connection)
49
41
  .setMethod('PUT')
50
42
  .fetch();
51
43
  return res.data;
52
44
  });
53
45
  }
54
- function deleteConnection(id) {
46
+ export function deleteConnection(id) {
55
47
  return __awaiter(this, void 0, void 0, function* () {
56
- const res = yield new http_api_request_1.HttpApiV5Request(`user/connections/${id}`)
48
+ const res = yield new HttpApiV5Request(`user/connections/${id}`)
57
49
  .setMethod('DELETE')
58
50
  .fetch();
59
51
  return res.data;
60
52
  });
61
53
  }
62
- function listIntegrations(connectionId) {
54
+ export function listIntegrations(connectionId) {
63
55
  return __awaiter(this, void 0, void 0, function* () {
64
56
  var _a;
65
- const res = yield new http_api_request_1.HttpApiV5Request(`user/connections/${connectionId}/integrations`)
57
+ if (!connectionId) {
58
+ return [];
59
+ }
60
+ const res = yield new HttpApiV5Request(`user/connections/${connectionId}/integrations`)
66
61
  .setMethod('GET')
67
62
  .fetch();
68
63
  return ((_a = res === null || res === void 0 ? void 0 : res.data) === null || _a === void 0 ? void 0 : _a.items) || [];
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
2
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
3
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -8,19 +7,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
8
  });
10
9
  };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.createFile = createFile;
13
- exports.getFile = getFile;
14
- const http_api_request_1 = require("./http-api-request");
15
- function createFile(bookId, file) {
10
+ import { HttpBooksApiV5Request } from "./http-api-request.js";
11
+ export function createFile(bookId, file) {
16
12
  return __awaiter(this, void 0, void 0, function* () {
17
- var response = yield new http_api_request_1.HttpBooksApiV5Request(`${bookId}/files`).setMethod('POST').setPayload(file).fetch();
13
+ var response = yield new HttpBooksApiV5Request(`${bookId}/files`).setMethod('POST').setPayload(file).fetch();
18
14
  return response.data;
19
15
  });
20
16
  }
21
- function getFile(bookId, id) {
17
+ export function getFile(bookId, id) {
22
18
  return __awaiter(this, void 0, void 0, function* () {
23
- var response = yield new http_api_request_1.HttpBooksApiV5Request(`${bookId}/files/${id}`).setMethod('GET').fetch();
19
+ var response = yield new HttpBooksApiV5Request(`${bookId}/files/${id}`).setMethod('GET').fetch();
24
20
  return response.data;
25
21
  });
26
22
  }
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
2
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
3
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -8,43 +7,35 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
8
  });
10
9
  };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.createGroup = createGroup;
13
- exports.updateGroup = updateGroup;
14
- exports.deleteGroup = deleteGroup;
15
- exports.getGroupsByAccountId = getGroupsByAccountId;
16
- exports.getGroups = getGroups;
17
- exports.getGroup = getGroup;
18
- exports.getAccounts = getAccounts;
19
- const http_api_request_1 = require("./http-api-request");
20
- function createGroup(bookId, group) {
10
+ import { HttpBooksApiV5Request } from "./http-api-request.js";
11
+ export function createGroup(bookId, group) {
21
12
  return __awaiter(this, void 0, void 0, function* () {
22
- var response = yield new http_api_request_1.HttpBooksApiV5Request(`${bookId}/groups`).setMethod('POST').setPayload(group).fetch();
13
+ var response = yield new HttpBooksApiV5Request(`${bookId}/groups`).setMethod('POST').setPayload(group).fetch();
23
14
  return response.data;
24
15
  });
25
16
  }
26
- function updateGroup(bookId, group) {
17
+ export function updateGroup(bookId, group) {
27
18
  return __awaiter(this, void 0, void 0, function* () {
28
- var response = yield new http_api_request_1.HttpBooksApiV5Request(`${bookId}/groups`).setMethod('PUT').setPayload(group).fetch();
19
+ var response = yield new HttpBooksApiV5Request(`${bookId}/groups`).setMethod('PUT').setPayload(group).fetch();
29
20
  return response.data;
30
21
  });
31
22
  }
32
- function deleteGroup(bookId, group) {
23
+ export function deleteGroup(bookId, group) {
33
24
  return __awaiter(this, void 0, void 0, function* () {
34
- var response = yield new http_api_request_1.HttpBooksApiV5Request(`${bookId}/groups/${group.id}`).setMethod('DELETE').fetch();
25
+ var response = yield new HttpBooksApiV5Request(`${bookId}/groups/${group.id}`).setMethod('DELETE').fetch();
35
26
  return response.data;
36
27
  });
37
28
  }
38
- function getGroupsByAccountId(bookId, accountId) {
29
+ export function getGroupsByAccountId(bookId, accountId) {
39
30
  return __awaiter(this, void 0, void 0, function* () {
40
31
  var _a;
41
- var response = yield new http_api_request_1.HttpBooksApiV5Request(`${bookId}/accounts/${accountId}/groups`).setMethod('GET').fetch();
32
+ var response = yield new HttpBooksApiV5Request(`${bookId}/accounts/${accountId}/groups`).setMethod('GET').fetch();
42
33
  return ((_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.items) || [];
43
34
  });
44
35
  }
45
- function getGroups(bookId) {
36
+ export function getGroups(bookId) {
46
37
  return __awaiter(this, void 0, void 0, function* () {
47
- var response = yield new http_api_request_1.HttpBooksApiV5Request(`${bookId}/groups`).setMethod('GET').fetch();
38
+ var response = yield new HttpBooksApiV5Request(`${bookId}/groups`).setMethod('GET').fetch();
48
39
  var groupsPlain = response.data;
49
40
  if (!(groupsPlain === null || groupsPlain === void 0 ? void 0 : groupsPlain.items)) {
50
41
  return [];
@@ -52,15 +43,18 @@ function getGroups(bookId) {
52
43
  return groupsPlain.items;
53
44
  });
54
45
  }
55
- function getGroup(bookId, idOrName) {
46
+ export function getGroup(bookId, idOrName) {
56
47
  return __awaiter(this, void 0, void 0, function* () {
57
- var response = yield new http_api_request_1.HttpBooksApiV5Request(`${bookId}/groups/${encodeURIComponent(idOrName)}`).setMethod('GET').fetch();
48
+ var response = yield new HttpBooksApiV5Request(`${bookId}/groups/${encodeURIComponent(idOrName)}`).setMethod('GET').fetch();
58
49
  return response.data;
59
50
  });
60
51
  }
61
- function getAccounts(bookId, idOrName) {
52
+ export function getAccounts(bookId, idOrName) {
62
53
  return __awaiter(this, void 0, void 0, function* () {
63
- var response = yield new http_api_request_1.HttpBooksApiV5Request(`${bookId}/groups/${encodeURIComponent(idOrName)}/accounts`).setMethod('GET').fetch();
54
+ if (!idOrName) {
55
+ return [];
56
+ }
57
+ var response = yield new HttpBooksApiV5Request(`${bookId}/groups/${encodeURIComponent(idOrName)}/accounts`).setMethod('GET').fetch();
64
58
  var accountsPlain = response.data;
65
59
  if (!(accountsPlain === null || accountsPlain === void 0 ? void 0 : accountsPlain.items)) {
66
60
  return [];