bkper-js 2.16.0 → 2.16.2

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 ADDED
@@ -0,0 +1,385 @@
1
+ ### **Changelog**
2
+
3
+ See what's new and what has changed in bkper-js
4
+
5
+ ## 2025
6
+
7
+ **October 2025**
8
+
9
+ - Files attached to transactions are now created internally when transaction is persisted
10
+ - Added `Transaction.removeFile`
11
+ - Added `Book.countTransactions`
12
+ - Added `Book.remove`
13
+
14
+ **September 2025**
15
+
16
+ - **v2.8.0 - INTERNAL REFACTOR:**
17
+ - Introduced abstract `Resource` class for all model entities
18
+ - Improved config management with `getConfig()` pattern for config resolution
19
+ - Enhanced type safety with explicit Config type usage throughout
20
+ - Standardized `json()` method across resources for consistent JSON serialization
21
+ - Maintained full backward compatibility - no breaking changes to existing APIs
22
+ - Added `Account.isBalanceVerified`
23
+ - Added `App.getOwnerWebsiteUrl`
24
+ - Added `App.getReadme`
25
+ - Added `App.getRepositoryUrl`
26
+ - Added `App.getWebsiteUrl`
27
+ - Added `App.isInstallable`
28
+ - Added `App.isRepositoryPrivate`
29
+ - Added `Book.getCollaborators`
30
+ - Added `Book.getBacklog`
31
+ - Added `Backlog`
32
+ - Added `Backlog.getCount`
33
+ - Added `Collaborator`
34
+ - Added `Collaborator.json`
35
+ - Added `Collaborator.getId`
36
+ - Added `Collaborator.getEmail`
37
+ - Added `Collaborator.getPermission`
38
+ - Added `Collaborator.setEmail`
39
+ - Added `Collaborator.setPermission`
40
+ - Added `Collaborator.create`
41
+ - Added `Collaborator.update`
42
+ - Added `Collaborator.remove`
43
+ - Added `Group.isBalanceVerified`
44
+ - Deprecated `Integration.getLogo`
45
+ - Added `Integration.getLogoUrl`
46
+ - Added `Integration.getLogoUrlDark`
47
+ - Added `Transaction.getCreatedBy`
48
+ - Replaced axios with native Fetch API for better compatibility with multiple environments
49
+
50
+ **August 2025**
51
+
52
+ - Added `File.getProperties`
53
+ - Added `File.setProperties`
54
+ - Added `File.getProperty`
55
+ - Added `File.setProperty`
56
+ - Added `File.deleteProperty`
57
+
58
+ **July 2025**
59
+
60
+ - **BREAKING CHANGE:** Refactored `Bkper` class from static methods to constructor-based pattern
61
+ - **BREAKING CHANGE:** Removed deprecated methods: `Transaction.remove()`, `Transaction.restore()`, `Account.getBalance()`, `Account.getBalanceRaw()`
62
+ - **MIGRATION:** Use `transaction.trash()` and `transaction.untrash()` instead of `remove()` and `restore()`
63
+ - **MIGRATION:** Use `Book.getBalancesReport()` instead of `Account.getBalance()` methods
64
+ - Added `Balance` class back for improved balance reporting
65
+ - Added `BalancesDataTableBuilder` for building balance data tables
66
+ - Added `BalanceType` enum with TOTAL, PERIOD, and CUMULATIVE options
67
+ - Added `includeGroups` parameter to `Bkper.getBook()` method for selective group loading
68
+
69
+ **June 2025**
70
+
71
+ - Added `Book.copy`
72
+ - Added `Transaction.getUpdatedAt`
73
+ - Added `Transaction.getUpdatedAtFormatted`
74
+
75
+ **May 2025**
76
+
77
+ - Added `Group.isLocked`
78
+ - Added `Group.setLocked`
79
+ - Added `Query`
80
+ - Added `Query.json`
81
+ - Added `Query.getId`
82
+ - Added `Query.getTitle`
83
+ - Added `Query.setTitle`
84
+ - Added `Query.getQuery`
85
+ - Added `Query.setQuery`
86
+ - Added `Query.create`
87
+ - Added `Query.update`
88
+ - Added `Query.remove`
89
+ - Added `Book.getSavedQueries`
90
+ - Added `Book.batchPostTransactions`
91
+ - Added `Book.batchCheckTransactions`
92
+ - Added `Book.batchUncheckTransactions`
93
+ - Added `Book.batchUpdateTransactions`
94
+ - Added `Book.batchUntrashTransactions`
95
+
96
+ **April 2025**
97
+
98
+ - Added `Book.batchCreateAccounts`
99
+ - Added `Book.batchCreateGroups`
100
+
101
+ **March 2025**
102
+
103
+ - Added `Agent.getLogoUrlDark`
104
+ - Added `App.getFilePatterns`
105
+ - Added `App.getLogoUrlDark`
106
+ - Added `App.getOwnerLogoUrl`
107
+ - Added `App.getOwnerName`
108
+ - Added `App.isPublished`
109
+ - Added `Transaction.getAgentName`
110
+ - Added `Transaction.getAgentLogoUrl`
111
+ - Added `Transaction.getAgentLogoUrlDark`
112
+
113
+ **February 2025**
114
+
115
+ - Added `EventType` enum
116
+ - Added `BotResponseType` enum
117
+ - Added `Agent`
118
+ - Added `Agent.getId`
119
+ - Added `Agent.getLogoUrl`
120
+ - Added `Agent.getName`
121
+ - Added `Agent.json`
122
+ - Added `App.getDescription`
123
+ - Added `App.getEvents`
124
+ - Added `App.getLogoUrl`
125
+ - Added `App.getName`
126
+ - Added `App.hasEvents`
127
+ - Added `Book.batchReplayEvents`
128
+ - Added `Book.getApps`
129
+ - Added `BotResponse`
130
+ - Added `BotResponse.getAgentId`
131
+ - Added `BotResponse.getCreatedAt`
132
+ - Added `BotResponse.getEvent`
133
+ - Added `BotResponse.getMessage`
134
+ - Added `BotResponse.getType`
135
+ - Added `BotResponse.remove`
136
+ - Added `BotResponse.replay`
137
+ - Added `Event.getAgent`
138
+ - Added `Event.getBook`
139
+ - Added `Event.getBotResponses`
140
+ - Added `Event.getCreatedAt`
141
+ - Added `Event.getId`
142
+ - Added `Event.getType`
143
+ - Added `Event.getUser`
144
+ - Added `Event.hasErrorResponse`
145
+ - Added `User.getAvatarUrl`
146
+
147
+ **January 2025**
148
+
149
+ - Added `BalancesContainer`
150
+ - Added `BalancesContainer.getName`
151
+ - Added `BalancesContainer.getNormalizedName`
152
+ - Added `BalancesContainer.getGroup`
153
+ - Added `BalancesContainer.getAccount`
154
+ - Added `BalancesContainer.getParent`
155
+ - Added `BalancesContainer.getDepth`
156
+ - Added `BalancesContainer.isCredit`
157
+ - Added `BalancesContainer.isPermanent`
158
+ - Added `BalancesContainer.isFromAccount`
159
+ - Added `BalancesContainer.isFromGroup`
160
+ - Added `BalancesContainer.hasGroupBalances`
161
+ - Added `BalancesContainer.getCumulativeBalance`
162
+ - Added `BalancesContainer.getCumulativeBalanceRaw`
163
+ - Added `BalancesContainer.getCumulativeBalanceText`
164
+ - Added `BalancesContainer.getCumulativeBalanceRawText`
165
+ - Added `BalancesContainer.getPeriodBalance`
166
+ - Added `BalancesContainer.getPeriodBalanceRaw`
167
+ - Added `BalancesContainer.getPeriodBalanceText`
168
+ - Added `BalancesContainer.getPeriodBalanceRawText`
169
+ - Added `BalancesContainer.getBalancesContainers`
170
+ - Added `BalancesContainer.getBalancesContainer`
171
+ - Added `BalancesReport`
172
+ - Added `BalancesReport.getBook`
173
+ - Added `BalancesReport.getPeriod`
174
+ - Added `BalancesReport.getBalancesContainers`
175
+ - Added `BalancesReport.getBalancesContainer`
176
+ - Added `Book.getAutoPost`
177
+ - Added `Book.setAutoPost`
178
+ - Added `Group.isCredit`
179
+ - Added `Group.isMixed`
180
+ - Added `User.getPlan`
181
+ - Added `User.hasBillingEnabled`
182
+
183
+ ## 2024
184
+
185
+ **December 2024**
186
+
187
+ - Added `Book.listEvents`
188
+ - Added `EventList`
189
+ - Added `EventList.getCursor`
190
+ - Added `EventList.getFirst`
191
+ - Added `EventList.getItems`
192
+ - Added `EventList.size`
193
+ - Added `Group.isPermanent`
194
+ - Added `Group.hasParent`
195
+ - Added `Group.getChildren`
196
+ - Added `Group.getDescendants`
197
+ - Added `Group.getDescendantTreeIds`
198
+ - Added `Group.hasChildren`
199
+ - Added `Group.isLeaf`
200
+ - Added `Group.isRoot`
201
+ - Added `Group.getDepth`
202
+ - Added `Group.getRoot`
203
+ - Added `Group.getRootName`
204
+ - Added `Group.hasAccounts`
205
+
206
+ **November 2024**
207
+
208
+ - Added `Transaction.trash`
209
+ - Added `Transaction.untrash`
210
+ - Added `Transaction.getAmountFormatted`
211
+ - Added `Transaction.isLocked`
212
+ - Removed `Transaction.remove` from `Transaction`
213
+ - Removed `Transaction.restore` from `Transaction`
214
+
215
+ **October 2024**
216
+
217
+ - Exposed `payload` property on all objects from `bkper-js` interface
218
+ - Added `Collection.addBooks`
219
+ - Added `Collection.create`
220
+ - Added `Collection.getOwnerUsername`
221
+ - Added `Collection.getPermission`
222
+ - Added `Collection.getUpdatedAt`
223
+ - Added `Collection.remove`
224
+ - Added `Collection.removeBooks`
225
+ - Added `Collection.setName`
226
+ - Added `Collection.update`
227
+ - Added `Bkper.getBillingPortalUrl`
228
+ - Added `Connection.getDateAddedMs`
229
+ - Added `Connection.getLogo`
230
+ - Added `Connection.remove`
231
+ - Added `Integration.getAddedBy`
232
+ - Added `Integration.getAgentId`
233
+ - Added `Integration.getDateAddedMs`
234
+ - Added `Integration.getLastUpdateMs`
235
+ - Added `Integration.getLogo`
236
+ - Added `Integration.remove`
237
+ - Added `TransactionList` returned from `Book.listTransactions`
238
+ - Removed `TransactionIterator` from `Transaction`
239
+ - Removed `newTransaction` from `Book`. Use `Transaction` constructor instead
240
+ - Removed `newAccount` from `Book`. Use `Account` constructor instead
241
+ - Removed `newGroup` from `Book`. Use `Group` constructor instead
242
+ - Removed `newFile` from `Book`. Use `File` constructor instead
243
+
244
+ **September 2024**
245
+
246
+ - Extracted `bkper-js` from `bkper` as a standalone library.
247
+ - Added `Config.requestRetryHandler`
248
+ - Added `Visibility` enum
249
+ - Added `App.json`
250
+ - Added `Bkper.getApps`
251
+ - Added `Bkper.getBooks`
252
+ - Added `Bkper.getTemplates`
253
+ - Added `Bkper.newBook`
254
+ - Added `Book.getTotalTransactions`
255
+ - Added `Book.getTotalTransactionsCurrentMonth`
256
+ - Added `Book.getTotalTransactionsCurrentYear`
257
+ - Added `Book.getVisibility`
258
+ - Added `Book.create`
259
+ - Added `Collection.json`
260
+ - Added `Template`
261
+ - Added `Template.getBookId`
262
+ - Added `Template.getBookLink`
263
+ - Added `Template.getCategory`
264
+ - Added `Template.getDescription`
265
+ - Added `Template.getImageUrl`
266
+ - Added `Template.getName`
267
+ - Added `Template.getSheetsLink`
268
+ - Added `Template.getTimesUsed`
269
+ - Added `Template.json`
270
+ - Added `User.getEmail`
271
+ - Added `User.getHostedDomain`
272
+ - Added `User.isFree`
273
+ - Added `User.hasStartedTrial`
274
+ - Added `User.getDaysLeftInTrial`
275
+ - Added `User.hasUsedConnections`
276
+ - Added `User.json`
277
+
278
+ **January 2024**
279
+
280
+ - Added `Transaction.setChecked`
281
+
282
+ ## 2023
283
+
284
+ **June 2023**
285
+
286
+ - Added `Bkper.getUser`
287
+ - Added `Bkper.setConfig`
288
+ - Added `Book.batchTrashTransactions`
289
+ - Added `Book.createIntegration`
290
+ - Added `Book.getIntegrations`
291
+ - Added `Book.updateIntegration`
292
+ - Added `Config` interface
293
+ - Added `Connection`
294
+ - Added `Connection.clearTokenProperties`
295
+ - Added `Connection.create`
296
+ - Added `Connection.deleteProperty`
297
+ - Added `Connection.getAgentId`
298
+ - Added `Connection.getEmail`
299
+ - Added `Connection.getId`
300
+ - Added `Connection.getIntegrations`
301
+ - Added `Connection.getName`
302
+ - Added `Connection.getProperties`
303
+ - Added `Connection.getProperty`
304
+ - Added `Connection.getPropertyKeys`
305
+ - Added `Connection.getType`
306
+ - Added `Connection.getUUID`
307
+ - Added `Connection.json`
308
+ - Added `Connection.setAgentId`
309
+ - Added `Connection.setName`
310
+ - Added `Connection.setProperties`
311
+ - Added `Connection.setProperty`
312
+ - Added `Connection.setType`
313
+ - Added `Connection.setUUID`
314
+ - Added `Integration`
315
+ - Added `Integration.deleteProperty`
316
+ - Added `Integration.getBookId`
317
+ - Added `Integration.getId`
318
+ - Added `Integration.getName`
319
+ - Added `Integration.getProperties`
320
+ - Added `Integration.getProperty`
321
+ - Added `Integration.json`
322
+ - Added `Integration.setProperties`
323
+ - Added `Integration.setProperty`
324
+ - Added `User`
325
+ - Added `User.getConnection`
326
+ - Added `User.getConnections`
327
+ - Added `User.getFullName`
328
+ - Added `User.getId`
329
+ - Added `User.getName`
330
+ - Deprecated `Bkper.setApiKey`
331
+ - Deprecated `Bkper.setOAuthTokenProvider`
332
+
333
+ ## 2022
334
+
335
+ **September 2022**
336
+
337
+ - Deprecated `Account.getBalance`
338
+
339
+ **May 2022**
340
+
341
+ - Added `Book.parseDate`
342
+
343
+ **April 2022**
344
+
345
+ - Added `Book.getClosingDate`
346
+ - Added `Book.setClosingDate`
347
+
348
+ ## 2021
349
+
350
+ **October 2021**
351
+
352
+ - Added `Book.getGroupsByAccount`
353
+
354
+ **May 2021**
355
+
356
+ - Added `Group.getParent`
357
+ - Added `Group.setParent`
358
+ - **BREAKING CHANGE:** Removed `AccountsDataTableBuilder`
359
+ - **BREAKING CHANGE:** Removed `BalancesDataTableBuilder`
360
+ - **BREAKING CHANGE:** Removed `TransactionsDataTableBuilder`
361
+ - **BREAKING CHANGE:** Removed `BalancesReport`
362
+ - **BREAKING CHANGE:** Removed `Balance`
363
+ - **BREAKING CHANGE:** Removed `BalancesContainer`
364
+
365
+ **April 2021**
366
+
367
+ - Added `Book.getLockDate`
368
+ - Added `Book.setLockDate`
369
+
370
+ **March 2021**
371
+
372
+ - **BREAKING CHANGE:** Removed `BalanceCheckedType`
373
+
374
+ **February 2021**
375
+
376
+ - Added `Book.getPeriod`
377
+ - Added `Book.setPeriod`
378
+ - Added `Book.getPeriodStartMonth`
379
+ - Added `Book.setPeriodStartMonth`
380
+ - Added `Book.getPageSize`
381
+ - Added `Book.setPageSize`
382
+
383
+ **January 2021**
384
+
385
+ - `bkper` client library published
package/lib/index.d.ts CHANGED
@@ -1199,6 +1199,12 @@ export declare class Bkper {
1199
1199
  * If not provided, uses the global configuration set via setConfig().
1200
1200
  */
1201
1201
  constructor(config?: Config);
1202
+ /**
1203
+ * Gets the current instance configuration.
1204
+ *
1205
+ * @returns The Config object for this Bkper instance
1206
+ */
1207
+ getConfig(): Config;
1202
1208
  /**
1203
1209
  * Gets the [[Book]] with the specified bookId from url param.
1204
1210
  *
@@ -65,6 +65,14 @@ export class Bkper {
65
65
  constructor(config) {
66
66
  this.config = config || Bkper.globalConfig;
67
67
  }
68
+ /**
69
+ * Gets the current instance configuration.
70
+ *
71
+ * @returns The Config object for this Bkper instance
72
+ */
73
+ getConfig() {
74
+ return this.config;
75
+ }
68
76
  /**
69
77
  * Gets the [[Book]] with the specified bookId from url param.
70
78
  *
@@ -117,7 +125,7 @@ export class Bkper {
117
125
  getApps() {
118
126
  return __awaiter(this, void 0, void 0, function* () {
119
127
  let apps = yield AppService.getApps(this.config);
120
- return apps.map((app) => new App(app));
128
+ return apps.map((app) => new App(app, this.config));
121
129
  });
122
130
  }
123
131
  /**
@@ -128,7 +136,7 @@ export class Bkper {
128
136
  getTemplates() {
129
137
  return __awaiter(this, void 0, void 0, function* () {
130
138
  let templates = yield TemplateService.getTemplates(this.config);
131
- return templates.map((template) => new Template(template));
139
+ return templates.map((template) => new Template(template, this.config));
132
140
  });
133
141
  }
134
142
  /**
package/lib/model/Book.js CHANGED
@@ -192,7 +192,7 @@ export class Book extends ResourceProperty {
192
192
  */
193
193
  getCollection() {
194
194
  if (this.payload.collection != null && this.collection == null) {
195
- this.collection = new Collection(this.payload.collection);
195
+ this.collection = new Collection(this.payload.collection, this.config);
196
196
  }
197
197
  return this.collection;
198
198
  }
@@ -612,7 +612,7 @@ export class Book extends ResourceProperty {
612
612
  return this.apps;
613
613
  }
614
614
  const appsPlain = yield BookService.getApps(this.getId(), this.getConfig());
615
- this.apps = appsPlain.map((a) => new App(a));
615
+ this.apps = appsPlain.map((a) => new App(a, this.config));
616
616
  return this.apps;
617
617
  });
618
618
  }
@@ -624,7 +624,7 @@ export class Book extends ResourceProperty {
624
624
  getIntegrations() {
625
625
  return __awaiter(this, void 0, void 0, function* () {
626
626
  const integrationsPlain = yield IntegrationService.listIntegrations(this.getId(), this.getConfig());
627
- const integrations = integrationsPlain.map((i) => new Integration(i));
627
+ const integrations = integrationsPlain.map((i) => new Integration(i, this.config));
628
628
  return integrations;
629
629
  });
630
630
  }
@@ -643,7 +643,7 @@ export class Book extends ResourceProperty {
643
643
  else {
644
644
  integration = yield IntegrationService.createIntegration(this.getId(), integration, this.getConfig());
645
645
  }
646
- return new Integration(integration);
646
+ return new Integration(integration, this.config);
647
647
  });
648
648
  }
649
649
  /**
@@ -661,7 +661,7 @@ export class Book extends ResourceProperty {
661
661
  else {
662
662
  integration = yield IntegrationService.updateIntegration(this.getId(), integration, this.getConfig());
663
663
  }
664
- return new Integration(integration);
664
+ return new Integration(integration, this.config);
665
665
  });
666
666
  }
667
667
  /**
@@ -1100,7 +1100,7 @@ export class Book extends ResourceProperty {
1100
1100
  copy(name, copyTransactions, fromDate) {
1101
1101
  return __awaiter(this, void 0, void 0, function* () {
1102
1102
  const copiedBookPayload = yield BookService.copyBook(this.getId(), name, copyTransactions, fromDate, this.getConfig());
1103
- return new Book(copiedBookPayload);
1103
+ return new Book(copiedBookPayload, this.config);
1104
1104
  });
1105
1105
  }
1106
1106
  /**
@@ -1188,7 +1188,7 @@ export class Book extends ResourceProperty {
1188
1188
  getBacklog() {
1189
1189
  return __awaiter(this, void 0, void 0, function* () {
1190
1190
  const backlogPayload = yield EventService.getBacklog(this, this.getConfig());
1191
- return new Backlog(backlogPayload);
1191
+ return new Backlog(backlogPayload, this.config);
1192
1192
  });
1193
1193
  }
1194
1194
  }
@@ -81,7 +81,7 @@ export class Collection extends Resource {
81
81
  return books;
82
82
  }
83
83
  for (const bookPayload of this.payload.books) {
84
- let book = new Book(bookPayload);
84
+ let book = new Book(bookPayload, this.config);
85
85
  books.push(book);
86
86
  }
87
87
  return books;
@@ -99,7 +99,7 @@ export class Collection extends Resource {
99
99
  if (collectionId && books.length > 0) {
100
100
  const bookList = { items: books.map((b) => b.json()) };
101
101
  let addedBooks = yield CollectionService.addBooksToCollection(collectionId, bookList, this.getConfig());
102
- return addedBooks.map((book) => new Book(book));
102
+ return addedBooks.map((book) => new Book(book, this.config));
103
103
  }
104
104
  return [];
105
105
  });
@@ -117,7 +117,7 @@ export class Collection extends Resource {
117
117
  if (collectionId && books.length > 0) {
118
118
  const bookList = { items: books.map((b) => b.json()) };
119
119
  let removedBooks = yield CollectionService.removeBooksFromCollection(collectionId, bookList, this.getConfig());
120
- return removedBooks.map((book) => new Book(book));
120
+ return removedBooks.map((book) => new Book(book, this.config));
121
121
  }
122
122
  return [];
123
123
  });
@@ -160,7 +160,7 @@ export class Collection extends Resource {
160
160
  remove() {
161
161
  return __awaiter(this, void 0, void 0, function* () {
162
162
  let books = yield CollectionService.deleteCollection(this.payload, this.getConfig());
163
- return books.map((book) => new Book(book));
163
+ return books.map((book) => new Book(book, this.config));
164
164
  });
165
165
  }
166
166
  }
@@ -153,7 +153,7 @@ export class Connection extends ResourceProperty {
153
153
  return [];
154
154
  }
155
155
  const integrationsPlain = yield ConnectionService.listIntegrations(id, this.getConfig());
156
- const integrations = integrationsPlain.map((i) => new Integration(i));
156
+ const integrations = integrationsPlain.map((i) => new Integration(i, this.config));
157
157
  return integrations;
158
158
  });
159
159
  }
@@ -45,7 +45,7 @@ export class Event {
45
45
  * @returns The user who performed the Event
46
46
  */
47
47
  getUser() {
48
- return this.payload.user ? new User(this.payload.user) : undefined;
48
+ return this.payload.user ? new User(this.payload.user, this.book.getConfig()) : undefined;
49
49
  }
50
50
  /**
51
51
  * Gets the Agent who performed the Event.
package/lib/model/User.js CHANGED
@@ -133,7 +133,7 @@ export class User extends Resource {
133
133
  getConnections() {
134
134
  return __awaiter(this, void 0, void 0, function* () {
135
135
  const json = yield ConnectionService.listConnections(this.getConfig());
136
- return json.map((c) => new Connection(c));
136
+ return json.map((c) => new Connection(c, this.config));
137
137
  });
138
138
  }
139
139
  /**
@@ -146,7 +146,7 @@ export class User extends Resource {
146
146
  getConnection(id) {
147
147
  return __awaiter(this, void 0, void 0, function* () {
148
148
  const json = yield ConnectionService.getConnection(id, this.getConfig());
149
- return new Connection(json);
149
+ return new Connection(json, this.config);
150
150
  });
151
151
  }
152
152
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bkper-js",
3
- "version": "2.16.0",
3
+ "version": "2.16.2",
4
4
  "description": "Javascript client for Bkper REST API",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.js",