bkper-js 2.3.0 → 2.5.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.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,10 @@ See what's new and what has changed in bkper-js
5
5
  2025
6
6
  ----
7
7
 
8
+ **August 2025**
9
+
10
+ * Added `Transaction.setFiles`
11
+
8
12
  **July 2025**
9
13
 
10
14
  * **BREAKING CHANGE:** Refactored `Bkper` class from static methods to constructor-based pattern
@@ -14,6 +18,7 @@ See what's new and what has changed in bkper-js
14
18
  * Added `Balance` class back for improved balance reporting
15
19
  * Added `BalancesDataTableBuilder` for building balance data tables
16
20
  * Added `BalanceType` enum with TOTAL, PERIOD, and CUMULATIVE options
21
+ * Added `includeGroups` parameter to `Bkper.getBook()` method for selective group loading
17
22
 
18
23
 
19
24
  **June 2025**
package/lib/index.d.ts CHANGED
@@ -960,8 +960,15 @@ export declare class BalancesDataTableBuilder implements BalancesDataTableBuilde
960
960
  */
961
961
  formatValues(format: boolean): BalancesDataTableBuilder;
962
962
  /**
963
- * Defines whether Groups should expand its child accounts. true to expand itself, -1 to expand all subgroups. -2 to expand all accounts.
963
+ * Defines whether Groups should expand its child accounts.
964
964
  *
965
+ * true to expand itself
966
+ * -1 to expand all subgroups
967
+ * -2 to expand all accounts
968
+ * 0 to expand nothing
969
+ * 1 to expand itself and its first level of children
970
+ * 2 to expand itself and its first two levels of children
971
+ * etc.
965
972
  *
966
973
  * @returns This builder with respective expanded option, for chaining.
967
974
  */
@@ -1190,10 +1197,17 @@ export declare class Bkper {
1190
1197
  *
1191
1198
  * @param id - The universal book id - The same bookId param of URL you access at app.bkper.com
1192
1199
  * @param includeAccounts - Optional parameter to include accounts in the retrieved Book
1200
+ * @param includeGroups - Optional parameter to include groups in the retrieved Book
1201
+ *
1202
+ * If both includeAccounts and includeGroups are false, the Book will be returned with only the basic information.
1203
+ *
1204
+ * If includeAccounts is true, the Book will be returned with the accounts and groups.
1205
+ *
1206
+ * If includeGroups is true, the Book will be returned with the groups.
1193
1207
  *
1194
1208
  * @returns The retrieved Book
1195
1209
  */
1196
- getBook(id: string, includeAccounts?: boolean): Promise<Book>;
1210
+ getBook(id: string, includeAccounts?: boolean, includeGroups?: boolean): Promise<Book>;
1197
1211
  /**
1198
1212
  * Gets all [[Books]] the user has access to.
1199
1213
  *
@@ -3339,6 +3353,14 @@ export declare class Transaction {
3339
3353
  * @returns The files attached to the transaction
3340
3354
  */
3341
3355
  getFiles(): File[];
3356
+ /**
3357
+ * Sets the files attached to the Transaction.
3358
+ *
3359
+ * @param files - The files to set
3360
+ *
3361
+ * @returns This Transaction, for chaining
3362
+ */
3363
+ setFiles(files: File[]): Transaction;
3342
3364
  /**
3343
3365
  * Adds a file attachment to the Transaction.
3344
3366
  *
@@ -60,8 +60,15 @@ export class BalancesDataTableBuilder {
60
60
  return this;
61
61
  }
62
62
  /**
63
- * Defines whether Groups should expand its child accounts. true to expand itself, -1 to expand all subgroups. -2 to expand all accounts.
63
+ * Defines whether Groups should expand its child accounts.
64
64
  *
65
+ * true to expand itself
66
+ * -1 to expand all subgroups
67
+ * -2 to expand all accounts
68
+ * 0 to expand nothing
69
+ * 1 to expand itself and its first level of children
70
+ * 2 to expand itself and its first two levels of children
71
+ * etc.
65
72
  *
66
73
  * @returns This builder with respective expanded option, for chaining.
67
74
  */
@@ -63,12 +63,19 @@ export class Bkper {
63
63
  *
64
64
  * @param id - The universal book id - The same bookId param of URL you access at app.bkper.com
65
65
  * @param includeAccounts - Optional parameter to include accounts in the retrieved Book
66
+ * @param includeGroups - Optional parameter to include groups in the retrieved Book
67
+ *
68
+ * If both includeAccounts and includeGroups are false, the Book will be returned with only the basic information.
69
+ *
70
+ * If includeAccounts is true, the Book will be returned with the accounts and groups.
71
+ *
72
+ * If includeGroups is true, the Book will be returned with the groups.
66
73
  *
67
74
  * @returns The retrieved Book
68
75
  */
69
- getBook(id, includeAccounts) {
76
+ getBook(id, includeAccounts, includeGroups) {
70
77
  return __awaiter(this, void 0, void 0, function* () {
71
- let book = yield BookService.loadBook(id, includeAccounts);
78
+ let book = yield BookService.loadBook(id, includeAccounts, includeGroups);
72
79
  return new Book(book);
73
80
  });
74
81
  }
@@ -214,6 +214,18 @@ export class Transaction {
214
214
  return [];
215
215
  }
216
216
  }
217
+ /**
218
+ * Sets the files attached to the Transaction.
219
+ *
220
+ * @param files - The files to set
221
+ *
222
+ * @returns This Transaction, for chaining
223
+ */
224
+ setFiles(files) {
225
+ const filePayloads = files.map(file => file.payload);
226
+ this.payload.files = [...filePayloads];
227
+ return this;
228
+ }
217
229
  /**
218
230
  * Adds a file attachment to the Transaction.
219
231
  *
@@ -8,9 +8,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { HttpBooksApiV5Request } from "./http-api-request.js";
11
+ import axios from 'axios';
11
12
  export function getBalances(bookId, query) {
12
13
  return __awaiter(this, void 0, void 0, function* () {
13
14
  var response = yield new HttpBooksApiV5Request(`${bookId}/balances`).addParam('query', query).addParam('time', Date.now()).fetch();
15
+ if (response.data.balancesUrl) {
16
+ response = yield axios.get(response.data.balancesUrl);
17
+ }
14
18
  return response.data;
15
19
  });
16
20
  }
@@ -26,13 +26,14 @@ export function loadBooks(query) {
26
26
  return booksJson;
27
27
  });
28
28
  }
29
- export function loadBook(bookId, loadAccounts) {
29
+ export function loadBook(bookId, loadAccounts, loadGroups) {
30
30
  return __awaiter(this, void 0, void 0, function* () {
31
31
  if (bookId == null) {
32
32
  throw new Error("Book id null!");
33
33
  }
34
34
  loadAccounts = loadAccounts || false;
35
- let response = yield new HttpBooksApiV5Request(bookId).addParam('loadAccounts', loadAccounts).fetch();
35
+ loadGroups = loadGroups || false;
36
+ let response = yield new HttpBooksApiV5Request(bookId).addParam('loadAccounts', loadAccounts).addParam('loadGroups', loadGroups).fetch();
36
37
  return response.data;
37
38
  });
38
39
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bkper-js",
3
- "version": "2.3.0",
3
+ "version": "2.5.0",
4
4
  "description": "Javascript client for Bkper REST API",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.js",
@@ -34,7 +34,7 @@
34
34
  "postversion": "git push --tags && yarn publish --new-version $npm_package_version && git push && echo \"Successfully released version $npm_package_version!\""
35
35
  },
36
36
  "peerDependencies": {
37
- "@bkper/bkper-api-types": "^5.23.0"
37
+ "@bkper/bkper-api-types": "^5.23.1"
38
38
  },
39
39
  "dependencies": {
40
40
  "@google-cloud/local-auth": "^3.0.1",