bkper-js 2.13.0 → 2.14.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
@@ -8,6 +8,7 @@ See what's new and what has changed in bkper-js
8
8
 
9
9
  - Files attached to transactions are now created internally when transaction is persisted
10
10
  - Added `Transaction.removeFile`
11
+ - Added `Book.countTransactions`
11
12
 
12
13
  **September 2025**
13
14
 
package/lib/index.d.ts CHANGED
@@ -95,11 +95,11 @@ export declare class Account extends Resource<bkper.Account> {
95
95
  * Sets a custom property in the Account.
96
96
  *
97
97
  * @param key - The property key
98
- * @param value - The property value
98
+ * @param value - The property value, or null/undefined to clean it
99
99
  *
100
100
  * @returns This Account, for chaining
101
101
  */
102
- setProperty(key: string, value: string | null): Account;
102
+ setProperty(key: string, value: string | null | undefined): Account;
103
103
  /**
104
104
  * Deletes a custom property.
105
105
  *
@@ -1578,11 +1578,11 @@ export declare class Book extends Resource<bkper.Book> {
1578
1578
  * Sets a custom property in the Book.
1579
1579
  *
1580
1580
  * @param key - The property key
1581
- * @param value - The property value
1581
+ * @param value - The property value, or null/undefined to clean it
1582
1582
  *
1583
1583
  * @returns This Book, for chaining
1584
1584
  */
1585
- setProperty(key: string, value: string | null): Book;
1585
+ setProperty(key: string, value: string | null | undefined): Book;
1586
1586
  /**
1587
1587
  * Formats a date according to date pattern of the Book.
1588
1588
  *
@@ -1850,6 +1850,14 @@ export declare class Book extends Resource<bkper.Book> {
1850
1850
  * @returns A [[TransactionList]] object containing the list of transactions
1851
1851
  */
1852
1852
  listTransactions(query?: string, limit?: number, cursor?: string): Promise<TransactionList>;
1853
+ /**
1854
+ * Retrieve the number of transactions based on a query.
1855
+ *
1856
+ * @param query - The query string
1857
+ *
1858
+ * @returns The number of matching transactions
1859
+ */
1860
+ countTransactions(query?: string): Promise<number | undefined>;
1853
1861
  /**
1854
1862
  * Lists events in the Book based on the provided parameters.
1855
1863
  *
@@ -2336,11 +2344,11 @@ export declare class Connection extends Resource<bkper.Connection> {
2336
2344
  * Sets a custom property in the Connection.
2337
2345
  *
2338
2346
  * @param key - The property key
2339
- * @param value - The property value
2347
+ * @param value - The property value, or null/undefined to clean it
2340
2348
  *
2341
2349
  * @returns The Connection, for chaining
2342
2350
  */
2343
- setProperty(key: string, value: string | null): Connection;
2351
+ setProperty(key: string, value: string | null | undefined): Connection;
2344
2352
  /**
2345
2353
  * Deletes a custom property stored in the Connection.
2346
2354
  *
@@ -2643,11 +2651,11 @@ export declare class File extends Resource<bkper.File> {
2643
2651
  * Sets a custom property in the File.
2644
2652
  *
2645
2653
  * @param key - The property key
2646
- * @param value - The property value
2654
+ * @param value - The property value, or null/undefined to clean it
2647
2655
  *
2648
2656
  * @returns This File, for chaining
2649
2657
  */
2650
- setProperty(key: string, value: string | null): File;
2658
+ setProperty(key: string, value: string | null | undefined): File;
2651
2659
  /**
2652
2660
  * Deletes a custom property.
2653
2661
  *
@@ -2770,11 +2778,11 @@ export declare class Group extends Resource<bkper.Group> {
2770
2778
  * Sets a custom property in the Group.
2771
2779
  *
2772
2780
  * @param key - The property key
2773
- * @param value - The property value
2781
+ * @param value - The property value, or null/undefined to clean it
2774
2782
  *
2775
2783
  * @returns This Group, for chaining
2776
2784
  */
2777
- setProperty(key: string, value: string | null): Group;
2785
+ setProperty(key: string, value: string | null | undefined): Group;
2778
2786
  /**
2779
2787
  * Delete a custom property
2780
2788
  *
@@ -3021,11 +3029,11 @@ export declare class Integration extends Resource<bkper.Integration> {
3021
3029
  * Sets a custom property in the Integration.
3022
3030
  *
3023
3031
  * @param key - The property key
3024
- * @param value - The property value
3032
+ * @param value - The property value, or null/undefined to clean it
3025
3033
  *
3026
3034
  * @returns The Integration, for chaining
3027
3035
  */
3028
- setProperty(key: string, value: string | null): Integration;
3036
+ setProperty(key: string, value: string | null | undefined): Integration;
3029
3037
  /**
3030
3038
  * Deletes a custom property stored in the Integration.
3031
3039
  *
@@ -3479,11 +3487,11 @@ export declare class Transaction extends Resource<bkper.Transaction> {
3479
3487
  * Sets a custom property in the Transaction.
3480
3488
  *
3481
3489
  * @param key - The property key
3482
- * @param value - The property value
3490
+ * @param value - The property value, or null/undefined to clean it
3483
3491
  *
3484
3492
  * @returns This Transaction, for chaining
3485
3493
  */
3486
- setProperty(key: string, value: string | null): Transaction;
3494
+ setProperty(key: string, value: string | null | undefined): Transaction;
3487
3495
  /**
3488
3496
  * Delete a custom property
3489
3497
  *
@@ -137,7 +137,7 @@ export class Account extends Resource {
137
137
  * Sets a custom property in the Account.
138
138
  *
139
139
  * @param key - The property key
140
- * @param value - The property value
140
+ * @param value - The property value, or null/undefined to clean it
141
141
  *
142
142
  * @returns This Account, for chaining
143
143
  */
package/lib/model/Book.js CHANGED
@@ -420,7 +420,7 @@ export class Book extends Resource {
420
420
  * Sets a custom property in the Book.
421
421
  *
422
422
  * @param key - The property key
423
- * @param value - The property value
423
+ * @param value - The property value, or null/undefined to clean it
424
424
  *
425
425
  * @returns This Book, for chaining
426
426
  */
@@ -1070,6 +1070,19 @@ export class Book extends Resource {
1070
1070
  return new TransactionList(this, transactionsList);
1071
1071
  });
1072
1072
  }
1073
+ /**
1074
+ * Retrieve the number of transactions based on a query.
1075
+ *
1076
+ * @param query - The query string
1077
+ *
1078
+ * @returns The number of matching transactions
1079
+ */
1080
+ countTransactions(query) {
1081
+ return __awaiter(this, void 0, void 0, function* () {
1082
+ const count = yield TransactionService.countTransactions(this.getId(), query, this.getConfig());
1083
+ return count.total;
1084
+ });
1085
+ }
1073
1086
  /**
1074
1087
  * Lists events in the Book based on the provided parameters.
1075
1088
  *
@@ -174,7 +174,7 @@ export class Connection extends Resource {
174
174
  * Sets a custom property in the Connection.
175
175
  *
176
176
  * @param key - The property key
177
- * @param value - The property value
177
+ * @param value - The property value, or null/undefined to clean it
178
178
  *
179
179
  * @returns The Connection, for chaining
180
180
  */
package/lib/model/File.js CHANGED
@@ -165,7 +165,7 @@ export class File extends Resource {
165
165
  * Sets a custom property in the File.
166
166
  *
167
167
  * @param key - The property key
168
- * @param value - The property value
168
+ * @param value - The property value, or null/undefined to clean it
169
169
  *
170
170
  * @returns This File, for chaining
171
171
  */
@@ -180,7 +180,7 @@ export class Group extends Resource {
180
180
  * Sets a custom property in the Group.
181
181
  *
182
182
  * @param key - The property key
183
- * @param value - The property value
183
+ * @param value - The property value, or null/undefined to clean it
184
184
  *
185
185
  * @returns This Group, for chaining
186
186
  */
@@ -147,7 +147,7 @@ export class Integration extends Resource {
147
147
  * Sets a custom property in the Integration.
148
148
  *
149
149
  * @param key - The property key
150
- * @param value - The property value
150
+ * @param value - The property value, or null/undefined to clean it
151
151
  *
152
152
  * @returns The Integration, for chaining
153
153
  */
@@ -371,7 +371,7 @@ export class Transaction extends Resource {
371
371
  * Sets a custom property in the Transaction.
372
372
  *
373
373
  * @param key - The property key
374
- * @param value - The property value
374
+ * @param value - The property value, or null/undefined to clean it
375
375
  *
376
376
  * @returns This Transaction, for chaining
377
377
  */
@@ -713,7 +713,7 @@ export class Transaction extends Resource {
713
713
  let dateObject = Utils.parseDate(date, this.book.getDatePattern(), this.book.getTimeZone());
714
714
  this.payload.date = Utils.formatDateISO(dateObject, this.book.getTimeZone());
715
715
  }
716
- else if (date.indexOf("-")) {
716
+ else if (date.indexOf("-") >= 0) {
717
717
  this.payload.date = date;
718
718
  }
719
719
  }
@@ -126,4 +126,11 @@ export function listTransactions(bookId, query, limit, cursor, config) {
126
126
  return response.data;
127
127
  });
128
128
  }
129
+ export function countTransactions(bookId, query, config) {
130
+ return __awaiter(this, void 0, void 0, function* () {
131
+ const request = new HttpBooksApiV5Request(`${bookId}/transactions/count`, config).setMethod('GET').addParam('query', query);
132
+ const response = yield request.fetch();
133
+ return response.data;
134
+ });
135
+ }
129
136
  //# sourceMappingURL=transaction-service.js.map
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.52.12"
8
+ "packageVersion": "7.53.1"
9
9
  }
10
10
  ]
11
11
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bkper-js",
3
- "version": "2.13.0",
3
+ "version": "2.14.1",
4
4
  "description": "Javascript client for Bkper REST API",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.js",