bkper-js 2.4.0 → 2.5.1

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
  */
@@ -1753,7 +1760,7 @@ export declare class Book {
1753
1760
  *
1754
1761
  * @returns The [[File]] object
1755
1762
  */
1756
- getFile(id: string): Promise<File>;
1763
+ getFile(id: string): Promise<File | undefined>;
1757
1764
  /**
1758
1765
  * Performs create new Book.
1759
1766
  *
@@ -3346,6 +3353,14 @@ export declare class Transaction {
3346
3353
  * @returns The files attached to the transaction
3347
3354
  */
3348
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;
3349
3364
  /**
3350
3365
  * Adds a file attachment to the Transaction.
3351
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
  */
package/lib/model/Book.js CHANGED
@@ -1020,6 +1020,9 @@ export class Book {
1020
1020
  getFile(id) {
1021
1021
  return __awaiter(this, void 0, void 0, function* () {
1022
1022
  let wrapped = yield FileService.getFile(this.getId(), id);
1023
+ if (!wrapped) {
1024
+ return undefined;
1025
+ }
1023
1026
  let file = new File(this, wrapped);
1024
1027
  return file;
1025
1028
  });
@@ -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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bkper-js",
3
- "version": "2.4.0",
3
+ "version": "2.5.1",
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",