bkper 4.12.6 → 4.12.7

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.
@@ -0,0 +1,1431 @@
1
+ # bkper-js
2
+
3
+ > JavaScript/TypeScript client library for Bkper — classes, interfaces, and type definitions.
4
+
5
+ bkper-js library is a simple and secure way to access the [Bkper REST API](https://bkper.com/docs/api/rest) on Node.js and modern browsers.
6
+
7
+ It provides a set of classes and functions to interact with the Bkper API, including authentication, authorization, and data manipulation.
8
+
9
+ [![npm](https://img.shields.io/npm/v/bkper-js?color=%235889e4)](https://www.npmjs.com/package/bkper-js) [![GitHub](https://img.shields.io/badge/bkper%2Fbkper--js-blue?logo=github)](https://github.com/bkper/bkper-js)
10
+
11
+ ### CDN / Browser
12
+
13
+ The simplest way to use bkper-js in a browser — no build tools, no npm, just a `<script>` tag and a valid access token. Works on **any domain**.
14
+
15
+ ```html
16
+ <script src="https://cdn.jsdelivr.net/npm/bkper-js@2/dist/bkper.min.js"></script>
17
+ <script>
18
+ const { Bkper } = bkperjs;
19
+
20
+ async function listBooks(token) {
21
+ Bkper.setConfig({
22
+ oauthTokenProvider: async () => token,
23
+ });
24
+ const bkper = new Bkper();
25
+ return await bkper.getBooks();
26
+ }
27
+
28
+ // Example: prompt for a token and list books
29
+ document.addEventListener('DOMContentLoaded', () => {
30
+ document.getElementById('go').addEventListener('click', async () => {
31
+ const token = document.getElementById('token').value;
32
+ const books = await listBooks(token);
33
+ document.getElementById('output').textContent = books.map(b => b.getName()).join('\n');
34
+ });
35
+ });
36
+ </script>
37
+
38
+ <input id="token" placeholder="Paste your access token" />
39
+ <button id="go">List Books</button>
40
+ <pre id="output"></pre>
41
+ ```
42
+
43
+ Get an access token with the [Bkper CLI](https://www.npmjs.com/package/bkper):
44
+
45
+ ```bash
46
+ bkper auth login # one-time setup
47
+ bkper auth token # prints a token (valid for 1 hour)
48
+ ```
49
+
50
+ Pin to a specific version by replacing `@2` with e.g. `@2.31.0`.
51
+
52
+ ### Node.js / CLI Scripts
53
+
54
+ For local scripts and CLI tools, use the [bkper](https://www.npmjs.com/package/bkper) CLI package for authentication:
55
+
56
+ ```typescript
57
+ import { Bkper } from 'bkper-js';
58
+ import { getOAuthToken } from 'bkper';
59
+
60
+ // Configure with CLI authentication
61
+ Bkper.setConfig({
62
+ oauthTokenProvider: async () => getOAuthToken(),
63
+ });
64
+
65
+ // Create Bkper instance
66
+ const bkper = new Bkper();
67
+
68
+ // Get a book and work with it
69
+ const book = await bkper.getBook('your-book-id');
70
+ console.log(`Book: ${book.getName()}`);
71
+
72
+ // List all books
73
+ const books = await bkper.getBooks();
74
+ console.log(`You have ${books.length} books`);
75
+ ```
76
+
77
+ First, login via CLI: `bkper auth login`
78
+
79
+ ### npm + Bundler
80
+
81
+ If you are using a bundler (Vite, webpack, esbuild, etc.), install from npm and provide an access token the same way as the CDN example:
82
+
83
+ ```typescript
84
+ import { Bkper } from 'bkper-js';
85
+
86
+ Bkper.setConfig({
87
+ oauthTokenProvider: async () => 'your-access-token',
88
+ });
89
+
90
+ const bkper = new Bkper();
91
+ const books = await bkper.getBooks();
92
+ ```
93
+
94
+ ### Web Applications on \*.bkper.app
95
+
96
+ > **Note:** `@bkper/web-auth` **only works on `*.bkper.app` subdomains**. Its session cookies are scoped to the `.bkper.app` domain and will not work on any other domain. For apps on other domains, use the [CDN / Browser](#cdn--browser) approach with an access token instead.
97
+
98
+ For apps hosted on `*.bkper.app` subdomains, use the [@bkper/web-auth](https://www.npmjs.com/package/@bkper/web-auth) SDK for built-in OAuth login flow:
99
+
100
+ ```typescript
101
+ import { Bkper } from 'bkper-js';
102
+ import { BkperAuth } from '@bkper/web-auth';
103
+
104
+ // Initialize authentication
105
+ const auth = new BkperAuth({
106
+ onLoginSuccess: () => initializeApp(),
107
+ onLoginRequired: () => showLoginButton(),
108
+ });
109
+
110
+ // Restore session on app load
111
+ await auth.init();
112
+
113
+ // Configure Bkper with web auth
114
+ Bkper.setConfig({
115
+ oauthTokenProvider: async () => auth.getAccessToken(),
116
+ });
117
+
118
+ // Create Bkper instance and use it
119
+ const bkper = new Bkper();
120
+ const books = await bkper.getBooks();
121
+ ```
122
+
123
+ See the [@bkper/web-auth documentation](https://bkper.com/docs/auth-sdk) for more details.
124
+
125
+ ### API Key (Optional)
126
+
127
+ API keys are optional and only needed for dedicated quota limits. If not provided, requests use a shared managed quota via the Bkper API proxy.
128
+
129
+ ```typescript
130
+ Bkper.setConfig({
131
+ oauthTokenProvider: async () => getOAuthToken(),
132
+ apiKeyProvider: async () => process.env.BKPER_API_KEY, // Optional - for dedicated quota
133
+ });
134
+ ```
135
+
136
+ ## Classes
137
+
138
+ ### Account *(extends ResourceProperty<bkper.Account>)*
139
+
140
+ This class defines an [Account](https://en.wikipedia.org/wiki/Account_(bookkeeping)) of a `Book`.
141
+
142
+ It maintains a balance of all amount [credited and debited](http://en.wikipedia.org/wiki/Debits_and_credits) in it by `Transactions`.
143
+
144
+ An Account can be grouped by `Groups`.
145
+
146
+ `Account` has no `getBalance()` method. To retrieve account balances, use
147
+ `Book.getBalancesReport` and read the resulting `BalancesContainer`.
148
+
149
+ **Constructor:** `new Account(book: Book, payload?: bkper.Account)`
150
+
151
+ **Properties:**
152
+
153
+ - `payload`: `bkper.Account` — The underlying payload data for this resource
154
+
155
+ **Methods:**
156
+
157
+ - `addGroup(group: bkper.Group | Group)` → `Account` — Adds a group to the Account.
158
+ - `create()` → `Promise<Account>` — Performs create new Account.
159
+ - `deleteProperty(key: string)` → `this` — Deletes a custom property.
160
+ - `getGroups()` / `setGroups(groups: Group[] | bkper.Group[])` → `Promise<Group[]> (set: Group[] | bkper.Group[])` — Gets the `Groups` of this Account.
161
+ - `getId()` → `string | undefined` — Gets the Account internal id.
162
+ - `getName()` / `setName(name: string)` → `string | undefined (set: string)` — Gets the Account name.
163
+ - `getNormalizedName()` → `string` — Gets the normalized name of this Account without spaces or special characters.
164
+ - `getProperties()` / `setProperties(properties: { [key: string]: string })` → `{ [key: string]: string }` — Gets the custom properties stored in this resource.
165
+ - `getProperty(keys: string[])` / `setProperty(key: string, value: string | null | undefined)` → `string | undefined (set: string)` — Gets the property value for given keys. First property found will be retrieved.
166
+ - `getPropertyKeys()` → `string[]` — Gets the custom properties keys stored in this resource.
167
+ - `getType()` / `setType(type: AccountType)` → `AccountType` — Gets the type of this Account.
168
+ - `getVisibleProperties()` / `setVisibleProperties(properties: { [key: string]: string })` → `{ [key: string]: string }` — Gets the visible custom properties stored in this resource.
169
+ Hidden properties (those ending with "_") are excluded from the result.
170
+ - `hasTransactionPosted()` → `boolean | undefined` — Tells if the Account has any transaction already posted.
171
+ - `isArchived()` → `boolean | undefined` — Tells if this Account is archived.
172
+ - `isBalanceVerified()` → `boolean | undefined` — Tells if the balance of this Account has been verified/audited.
173
+ - `isCredit()` → `boolean | undefined` — Tells if the Account has a Credit nature or Debit otherwise.
174
+ - `isInGroup(group: string | Group)` → `Promise<boolean>` — Tells if this Account is in the `Group`.
175
+ - `isPermanent()` → `boolean | undefined` — Tells if the Account is permanent.
176
+ - `json()` → `bkper.Account` — Gets an immutable copy of the JSON payload for this resource.
177
+ - `remove()` → `Promise<Account>` — Performs delete Account.
178
+ - `removeGroup(group: string | Group)` → `Promise<Account>` — Removes a group from the Account.
179
+ - `setArchived(archived: boolean)` → `Account` — Sets Account archived/unarchived.
180
+ - `setVisibleProperty(key: string, value: string | null | undefined)` → `this` — Sets a custom property in this resource, filtering out hidden properties.
181
+ Hidden properties are those whose keys end with an underscore "_".
182
+ - `update()` → `Promise<Account>` — Performs update Account, applying pending changes.
183
+
184
+ **groups**
185
+
186
+ When groups are already embedded in the account payload (e.g. from
187
+ `Bkper.getBook` with includeGroups), resolves them from the
188
+ book's cache instead of making API calls.
189
+
190
+ **hasTransactionPosted**
191
+
192
+ Accounts with transaction posted, even with zero balance, can only be archived.
193
+
194
+ **isCredit**
195
+
196
+ Credit Accounts are just for representation purposes. It increase or decrease the absolute balance. It doesn't affect the overall balance or the behavior of the system.
197
+
198
+ The absolute balance of credit Accounts increase when it participate as a credit/origin in a transaction. Its usually for Accounts that increase the balance of the assets, like revenue Accounts.
199
+
200
+ ```
201
+ Crediting a credit
202
+ Thus ---------------------> Account increases its absolute balance
203
+ Debiting a debit
204
+
205
+
206
+ Debiting a credit
207
+ Thus ---------------------> Account decreases its absolute balance
208
+ Crediting a debit
209
+ ```
210
+
211
+ As a rule of thumb, and for simple understanding, almost all Accounts are Debit nature (NOT credit), except the ones that "offers" amount for the books, like revenue Accounts.
212
+
213
+ **isPermanent**
214
+
215
+ Permanent Accounts are the ones which final balance is relevant and keep its balances over time.
216
+
217
+ They are also called [Real Accounts](http://en.wikipedia.org/wiki/Account_(Accountancy)#Based_on_periodicity_of_flow)
218
+
219
+ Usually represents assets or tangibles, capable of being perceived by the senses or the mind, like bank Accounts, money, debts and so on.
220
+
221
+ ### AccountsDataTableBuilder
222
+
223
+ A AccountsDataTableBuilder is used to setup and build two-dimensional arrays containing accounts.
224
+
225
+ **Constructor:** `new AccountsDataTableBuilder(accounts: Account[])`
226
+
227
+ **Methods:**
228
+
229
+ - `archived(include: boolean)` → `AccountsDataTableBuilder` — Defines whether the archived accounts should be included.
230
+ - `build()` → `Promise<any[][]>` — Builds a two-dimensional array containing all accounts.
231
+ - `groups(include: boolean)` → `AccountsDataTableBuilder` — Defines whether include account groups.
232
+ - `hiddenProperties(include: boolean)` → `AccountsDataTableBuilder` — Defines whether to include hidden properties (keys ending with underscore "_").
233
+ - `ids(include: boolean)` → `AccountsDataTableBuilder` — Defines whether include account ids.
234
+ - `properties(include: boolean)` → `AccountsDataTableBuilder` — Defines whether include custom account properties.
235
+
236
+ ### Agent
237
+
238
+ Defines an Agent on Bkper.
239
+
240
+ An Agent represents an entity (such as an App or Bot) that interacts with Bkper, executing actions on behalf of users.
241
+
242
+ **Constructor:** `new Agent(payload?: bkper.Agent)`
243
+
244
+ **Properties:**
245
+
246
+ - `payload`: `bkper.Agent`
247
+
248
+ **Methods:**
249
+
250
+ - `getId()` → `string | undefined` — Gets the Agent universal identifier.
251
+ - `getLogoUrl()` → `string | undefined` — Gets the Agent logo URL.
252
+ - `getLogoUrlDark()` → `string | undefined` — Gets the Agent logo URL in dark mode.
253
+ - `getName()` → `string | undefined` — Gets the Agent name.
254
+ - `json()` → `bkper.Agent` — Gets the wrapped plain JSON object.
255
+
256
+ ### Amount
257
+
258
+ This class defines an Amount for arbitrary-precision decimal arithmetic.
259
+
260
+ It inherits methods from [big.js](http://mikemcl.github.io/big.js/) library
261
+
262
+ **Constructor:** `new Amount(n: string | number | Amount)`
263
+
264
+ The Amount constructor.
265
+
266
+ **Methods:**
267
+
268
+ - `abs()` → `Amount` — Returns an absolute Amount.
269
+ - `cmp(n: string | number | Amount)` → `-1 | 0 | 1` — Compares this Amount with another value.
270
+ - `div(n: string | number | Amount)` → `Amount` — Divides this Amount by another value.
271
+ - `eq(n: string | number | Amount)` → `boolean` — Checks if this Amount equals another value.
272
+ - `gt(n: string | number | Amount)` → `boolean` — Checks if this Amount is greater than another value.
273
+ - `gte(n: string | number | Amount)` → `boolean` — Checks if this Amount is greater than or equal to another value.
274
+ - `lt(n: string | number | Amount)` → `boolean` — Checks if this Amount is less than another value.
275
+ - `lte(n: string | number | Amount)` → `boolean` — Checks if this Amount is less than or equal to another value.
276
+ - `minus(n: string | number | Amount)` → `Amount` — Subtracts another value from this Amount.
277
+ - `mod(n: string | number | Amount)` → `Amount` — Calculates the modulo (remainder) of dividing this Amount by another value.
278
+ - `plus(n: string | number | Amount)` → `Amount` — Adds another value to this Amount.
279
+ - `round(dp?: number)` → `Amount` — Rounds this Amount to a maximum of dp decimal places.
280
+ - `times(n: string | number | Amount)` → `Amount` — Multiplies this Amount by another value.
281
+ - `toFixed(dp?: number)` → `string` — Returns a string representing the value of this Amount in normal notation to a fixed number of decimal places.
282
+ - `toNumber()` → `number` — Returns a primitive number representing the value of this Amount.
283
+ - `toString()` → `string` — Returns a string representing the value of this Amount.
284
+
285
+ **mod**
286
+
287
+ Similar to % operator
288
+
289
+ ### App *(extends Resource<bkper.App>)*
290
+
291
+ Defines an App on Bkper.
292
+
293
+ Apps can be installed on Books by users.
294
+
295
+ **Constructor:** `new App(payload?: bkper.App, config?: Config)`
296
+
297
+ **Properties:**
298
+
299
+ - `payload`: `bkper.App` — The underlying payload data for this resource
300
+
301
+ **Methods:**
302
+
303
+ - `create()` → `Promise<App>` — Performs the app creation, applying pending changes.
304
+ - `getDescription()` → `string | undefined` — Gets the description of this App.
305
+ - `getDevelopers()` / `setDevelopers(developers?: string)` → `string | undefined (set: string)` — Gets the developers (usernames and domain patterns).
306
+ - `getEvents()` → `EventType[] | undefined` — Gets the events bound to this App.
307
+ - `getFilePatterns()` → `string[] | undefined` — Gets the file patterns the App handles.
308
+ - `getId()` → `string | undefined` — Gets the App universal identifier.
309
+ - `getLogoUrl()` → `string | undefined` — Gets the logo url of this App.
310
+ - `getLogoUrlDark()` → `string | undefined` — Gets the logo url of this App in dark mode.
311
+ - `getMenuPopupHeight()` → `string | undefined` — Gets the menu popup height of this App.
312
+ - `getMenuPopupWidth()` → `string | undefined` — Gets the menu popup width of this App.
313
+ - `getMenuText()` → `string | undefined` — Gets the menu text of this App.
314
+ - `getMenuUrl()` → `string | undefined` — Gets the menu url of this App.
315
+ - `getMenuUrlDev()` → `string | undefined` — Gets the menu development url of this App.
316
+ - `getName()` → `string | undefined` — Gets the name of this App.
317
+ - `getOwnerLogoUrl()` → `string | undefined` — Gets the logo url of the owner of this App.
318
+ - `getOwnerName()` → `string | undefined` — Gets the name of the owner of this App.
319
+ - `getOwnerWebsiteUrl()` → `string | undefined` — Gets the website url of the owner of this App.
320
+ - `getReadme()` / `setReadme(readme?: string)` → `string | undefined (set: string)` — Gets the readme.md file as text.
321
+ - `getRepositoryUrl()` → `string | undefined` — Gets the repository url of this App.
322
+ - `getUsers()` / `setUsers(users?: string)` → `string | undefined (set: string)` — Gets the whitelisted users (usernames and domain patterns).
323
+ - `getWebsiteUrl()` → `string | undefined` — Gets the website url of this App.
324
+ - `hasEvents()` → `boolean` — Checks if this App has events bound to it.
325
+ - `isInstallable()` → `boolean` — Tells if this App is installable.
326
+ - `isPublished()` → `boolean` — Checks if this App is published.
327
+ - `isRepositoryPrivate()` → `boolean | undefined` — Tells if the repository is private.
328
+ - `json()` → `bkper.App` — Gets an immutable copy of the JSON payload for this resource.
329
+ - `setClientSecret(clientSecret?: string)` → `App` — Sets the client secret.
330
+ - `setWebhookUrlDev(webhookUrlDev: string)` → `App` — Sets the webhook url for development.
331
+ - `update()` → `Promise<App>` — Performs a full update of the App, applying pending changes.
332
+
333
+ **create**
334
+
335
+ The App id MUST be unique. If another app is already existing, an error will be thrown.
336
+
337
+ ### Backlog *(extends Resource<bkper.Backlog>)*
338
+
339
+ This class defines the Backlog of a `Book`.
340
+
341
+ A Backlog is a list of pending tasks in a Book
342
+
343
+ **Constructor:** `new Backlog(payload?: bkper.Backlog, config?: Config)`
344
+
345
+ **Properties:**
346
+
347
+ - `payload`: `bkper.Backlog` — The underlying payload data for this resource
348
+
349
+ **Methods:**
350
+
351
+ - `getCount()` → `number | undefined` — Returns the number of pending tasks in this Backlog.
352
+ - `json()` → `bkper.Backlog` — Gets an immutable copy of the JSON payload for this resource.
353
+
354
+ ### Balance
355
+
356
+ Class that represents an `Account` or `Group` balance on a window of time (Day / Month / Year).
357
+
358
+ **Constructor:** `new Balance(container: BalancesContainer, balancePlain: bkper.Balance)`
359
+
360
+ **Properties:**
361
+
362
+ - `payload`: `bkper.Balance`
363
+
364
+ **Methods:**
365
+
366
+ - `getCumulativeBalance()` → `Amount` — The cumulative balance to the date, based on the credit nature of the container
367
+ - `getCumulativeBalanceRaw()` → `Amount` — The raw cumulative balance to the date.
368
+ - `getCumulativeCredit()` → `Amount` — The cumulative credit to the date.
369
+ - `getCumulativeDebit()` → `Amount` — The cumulative debit to the date.
370
+ - `getDate()` → `Date` — Date object constructed based on `Book` time zone offset. Usefull for
371
+ - `getDay()` → `number` — The day of the balance. Days starts on 1 to 31.
372
+ - `getFuzzyDate()` → `number` — The Fuzzy Date of the balance, based on `Periodicity` of the `BalancesReport` query, composed by Year, Month and Day.
373
+ - `getMonth()` → `number` — The month of the balance. Months starts on 1 (January) to 12 (December)
374
+ - `getPeriodBalance()` → `Amount` — The balance on the date period, based on credit nature of the container.
375
+ - `getPeriodBalanceRaw()` → `Amount` — The raw balance on the date period.
376
+ - `getPeriodCredit()` → `Amount` — The credit on the date period.
377
+ - `getPeriodDebit()` → `Amount` — The debit on the date period.
378
+ - `getYear()` → `number` — The year of the balance
379
+
380
+ **getDate**
381
+
382
+ If Month or Day is zero, the date will be constructed with first Month (January) or Day (1) of the next period.
383
+
384
+ **getDay**
385
+
386
+ Day can be 0 (zero) in case of Monthly or Early `Periodicity` of the `BalancesReport`
387
+
388
+ **getFuzzyDate**
389
+
390
+ The format is **YYYYMMDD**. Very usefull for ordering and indexing
391
+
392
+ Month and Day can be 0 (zero), depending on the granularity of the `Periodicity`.
393
+
394
+ *Example:*
395
+
396
+ **20180125** - 25, January, 2018 - DAILY Periodicity
397
+
398
+ **20180100** - January, 2018 - MONTHLY Periodicity
399
+
400
+ **20180000** - 2018 - YEARLY Periodicity
401
+
402
+ **getMonth**
403
+
404
+ Month can be 0 (zero) in case of Early `Periodicity` of the `BalancesReport`
405
+
406
+ ### BalancesDataTableBuilder *(implements BalancesDataTableBuilder)*
407
+
408
+ A BalancesDataTableBuilder is used to setup and build two-dimensional arrays containing balance information.
409
+
410
+ **Constructor:** `new BalancesDataTableBuilder(book: Book, balancesContainers: BalancesContainer[], periodicity: Periodicity)`
411
+
412
+ **Methods:**
413
+
414
+ - `build()` → `any[][]` — Builds an two-dimensional array with the balances.
415
+ - `expanded(expanded: number | boolean)` → `BalancesDataTableBuilder` — Defines whether Groups should expand its child accounts.
416
+ - `formatDates(format: boolean)` → `BalancesDataTableBuilder` — Defines whether the dates should be ISO formatted YYYY-MM-DD. E.g. 2025-01-01
417
+ - `formatValues(format: boolean)` → `BalancesDataTableBuilder` — Defines whether the value should be formatted based on decimal separator of the `Book`.
418
+ - `hiddenProperties(include: boolean)` → `BalancesDataTableBuilder` — Defines whether to include hidden properties (keys ending with underscore "_").
419
+ - `hideDates(hide: boolean)` → `BalancesDataTableBuilder` — Defines whether the dates should be hidden for **PERIOD** or **CUMULATIVE** `BalanceType`.
420
+ - `hideNames(hide: boolean)` → `BalancesDataTableBuilder` — Defines whether the `Accounts` and `Groups` names should be hidden.
421
+ - `period(period: boolean)` → `BalancesDataTableBuilder` — Defines whether should force use of period balances for **TOTAL** `BalanceType`.
422
+ - `properties(include: boolean)` → `BalancesDataTableBuilder` — Defines whether include custom `Accounts` and `Groups` properties.
423
+ - `raw(raw: boolean)` → `BalancesDataTableBuilder` — Defines whether should show raw balances, no matter the credit nature of the Account or Group.
424
+ - `transposed(transposed: boolean)` → `BalancesDataTableBuilder` — Defines whether should rows and columns should be transposed.
425
+ - `trial(trial: boolean)` → `BalancesDataTableBuilder` — Defines whether should split **TOTAL** `BalanceType` into debit and credit.
426
+ - `type(type: BalanceType)` → `BalancesDataTableBuilder` — Fluent method to set the `BalanceType` for the builder.
427
+
428
+ **expanded**
429
+
430
+ true to expand itself
431
+ -1 to expand all subgroups
432
+ -2 to expand all accounts
433
+ 0 to expand nothing
434
+ 1 to expand itself and its first level of children
435
+ 2 to expand itself and its first two levels of children
436
+ etc.
437
+
438
+ **transposed**
439
+
440
+ For **TOTAL** `BalanceType`, the **transposed** table looks like:
441
+
442
+ ```
443
+ _____________________________
444
+ | Expenses | Income | ... |
445
+ | -4568.23 | 5678.93 | ... |
446
+ |___________|_________|_______|
447
+
448
+ ```
449
+ Two rows, and each `Account` or `Group` per column.
450
+
451
+
452
+ For **PERIOD** or **CUMULATIVE** `BalanceType`, the **transposed** table will be a time table, and the format looks like:
453
+
454
+ ```
455
+ _______________________________________________________________
456
+ | | Expenses | Income | ... | ... |
457
+ | 15/01/2014 | -2345.23 | 3452.93 | ... | ... |
458
+ | 15/02/2014 | -2345.93 | 3456.46 | ... | ... |
459
+ | 15/03/2014 | -2456.45 | 3567.87 | ... | ... |
460
+ | ... | ... | ... | ... | ... |
461
+ |____________|____________|____________|____________|___________|
462
+
463
+ ```
464
+
465
+ First column will be each Date, and one column for each `Account` or `Group`.
466
+
467
+ ### BalancesReport
468
+
469
+ Class representing a Balance Report, generated when calling [Book.getBalanceReport](#book_getbalancesreport)
470
+
471
+ **Constructor:** `new BalancesReport(book: Book, payload: bkper.Balances)`
472
+
473
+ **Properties:**
474
+
475
+ - `payload`: `bkper.Balances`
476
+
477
+ **Methods:**
478
+
479
+ - `createDataTable()` → `BalancesDataTableBuilder` — Creates a BalancesDataTableBuilder to generate a two-dimensional array with all `BalancesContainers`.
480
+ - `getBalancesContainer(name: string)` → `BalancesContainer` — Gets a specific `BalancesContainer`.
481
+ - `getBalancesContainers()` → `BalancesContainer[]` — Gets all `BalancesContainers` of the report.
482
+ - `getBook()` → `Book` — Gets the `Book` that generated the report.
483
+ - `getPeriodicity()` → `Periodicity` — Gets the `Periodicity` of the query used to generate the report.
484
+
485
+ ### Billing *(extends Resource<bkper.Billing>)*
486
+
487
+ This class defines the Billing information for a `User`.
488
+
489
+ The Billing information includes the plan, the admin email, and the billing portal URL.
490
+
491
+ **Constructor:** `new Billing(json?: bkper.Billing, config?: Config)`
492
+
493
+ **Properties:**
494
+
495
+ - `payload`: `bkper.Billing` — The underlying payload data for this resource
496
+
497
+ **Methods:**
498
+
499
+ - `getAdminEmail()` → `string | undefined` — Gets the admin email for this User's billing account.
500
+ - `getCheckoutUrl(plan: string, successUrl?: string, cancelUrl?: string, cycle?: string)` → `Promise<string | undefined>` — Gets the URL to redirect the User to the billing checkout.
501
+ - `getCounts()` → `Promise<bkper.Counts>` — Gets the transaction counts associated to the User's billing account.
502
+ - `getDaysLeftInTrial()` → `number | undefined` — Gets the number of days left in User's trial period.
503
+ - `getEmail()` → `string | undefined` — Gets the email for the User.
504
+ - `getHostedDomain()` → `string | undefined` — Gets the hosted domain for the User.
505
+ - `getPlan()` → `string | undefined` — Gets the current plan of the User.
506
+ - `getPortalUrl(returnUrl: string)` → `Promise<string | undefined>` — Gets the URL to redirect the User to the billing portal.
507
+ - `getTotalTransactionsThisMonth()` → `number | undefined` — Gets the number of total transactions this month for the User's billing account.
508
+ - `getTotalTransactionsThisYear()` → `number | undefined` — Gets the number of total transactions this year for the User's billing account.
509
+ - `hasStartedTrial()` → `boolean | undefined` — Tells if the User has started the trial period.
510
+ - `isEnabled()` → `boolean | undefined` — Tells if billing is enabled for the User.
511
+ - `isPlanOverdue()` → `boolean | undefined` — Tells if the User's current plan payment is overdue.
512
+ - `json()` → `bkper.Billing` — Gets an immutable copy of the JSON payload for this resource.
513
+
514
+ ### Bkper
515
+
516
+ This is the main entry point of the [bkper-js](https://www.npmjs.com/package/bkper-js) library.
517
+
518
+ You can configure the library in two ways:
519
+
520
+ 1. Using static configuration (traditional approach):
521
+
522
+ ```typescript
523
+ Bkper.setConfig({
524
+ apiKeyProvider: () => process.env.BKPER_API_KEY,
525
+ oauthTokenProvider: () => process.env.BKPER_OAUTH_TOKEN
526
+ });
527
+
528
+ const bkper = new Bkper();
529
+ const book = await bkper.getBook('bookId');
530
+ ```
531
+
532
+ 2. Using per-instance configuration (recommended for Cloudflare Workers):
533
+
534
+ ```typescript
535
+ const bkper = new Bkper({
536
+ apiKeyProvider: () => process.env.BKPER_API_KEY,
537
+ oauthTokenProvider: () => process.env.BKPER_OAUTH_TOKEN
538
+ });
539
+
540
+ const book = await bkper.getBook('bookId');
541
+ ```
542
+
543
+ **Constructor:** `new Bkper(config?: Config)`
544
+
545
+ Creates a new Bkper instance with the provided configuration.
546
+
547
+ **Methods:**
548
+
549
+ - `getApp(id: string)` → `Promise<App>` — Gets the `App` with the specified id.
550
+ - `getApps()` → `Promise<App[]>` — Gets all `Apps` available for the user.
551
+ - `getBook(id: string, includeAccounts?: boolean, includeGroups?: boolean)` → `Promise<Book>` — Gets the `Book` with the specified bookId from url param.
552
+ - `getBooks(query?: string)` → `Promise<Book[]>` — Gets all `Books` the user has access to.
553
+ - `getCollections()` → `Promise<Collection[]>` — Gets all `Collections` the user has access to.
554
+ - `getConfig()` → `Config` — Gets the current instance configuration.
555
+ - `getTemplates()` → `Promise<Template[]>` — Gets all `Templates` available for the user.
556
+ - `getUser()` → `Promise<User>` — Gets the current logged `User`.
557
+ - `static setConfig(config: Config)` → `void` — Sets the global API configuration for all Bkper operations.
558
+
559
+ **setConfig**
560
+
561
+ WARNING: This configuration will be shared and should NOT be used on shared environments.
562
+
563
+ ### BkperError *(extends Error)*
564
+
565
+ Standard error class for Bkper API errors.
566
+ Extends Error to enable instanceof checks and standard error handling.
567
+
568
+ **Constructor:** `new BkperError(code: number, message: string, reason?: string)`
569
+
570
+ **Properties:**
571
+
572
+ - `readonly code`: `number` — HTTP status code (e.g., 404, 400, 500)
573
+ - `message`: `string`
574
+ - `name`: `string`
575
+ - `readonly reason?`: `string` — Machine-readable reason (e.g., "notFound", "badRequest")
576
+ - `stack?`: `string`
577
+ - `static prepareStackTrace?`: `(err: Error, stackTraces: __global.NodeJS.CallSite[]) => any` — Optional override for formatting stack traces
578
+ - `static stackTraceLimit`: `number`
579
+
580
+ **Methods:**
581
+
582
+ - `static captureStackTrace(targetObject: object, constructorOpt?: Function)` → `void` — Create .stack property on a target object
583
+
584
+ ### Book *(extends ResourceProperty<bkper.Book>)*
585
+
586
+ A Book represents a [General Ledger](https://en.wikipedia.org/wiki/General_ledger) for a company or business, but can also represent a [Ledger](https://en.wikipedia.org/wiki/Ledger) for a project or department
587
+
588
+ It contains all `Accounts` where `Transactions` are recorded/posted;
589
+
590
+ **Constructor:** `new Book(payload?: bkper.Book, config?: Config)`
591
+
592
+ **Properties:**
593
+
594
+ - `payload`: `bkper.Book` — The underlying payload data for this resource
595
+
596
+ **Methods:**
597
+
598
+ - `audit()` → `void` — Trigger [Balances Audit](https://help.bkper.com/en/articles/4412038-balances-audit) async process.
599
+ - `batchCheckTransactions(transactions: Transaction[])` → `Promise<void>` — Batch check `Transactions` on the Book.
600
+ - `batchCreateAccounts(accounts: Account[])` → `Promise<Account[]>` — Create `Accounts` on the Book, in batch.
601
+ - `batchCreateGroups(groups: Group[])` → `Promise<Group[]>` — Create `Groups` on the Book, in batch.
602
+ - `batchCreateTransactions(transactions: Transaction[])` → `Promise<Transaction[]>` — Batch create `Transactions` on the Book.
603
+ - `batchPostTransactions(transactions: Transaction[])` → `Promise<void>` — Batch post `Transactions` on the Book.
604
+ - `batchReplayEvents(events: Event[], errorOnly?: boolean)` → `Promise<void>` — Replay `Events` on the Book, in batch.
605
+ - `batchTrashTransactions(transactions: Transaction[], trashChecked?: boolean)` → `Promise<void>` — Batch trash `Transactions` on the Book.
606
+ - `batchUncheckTransactions(transactions: Transaction[])` → `Promise<void>` — Batch uncheck `Transactions` on the Book.
607
+ - `batchUntrashTransactions(transactions: Transaction[])` → `Promise<void>` — Batch untrash `Transactions` on the Book.
608
+ - `batchUpdateTransactions(transactions: Transaction[], updateChecked?: boolean)` → `Promise<Transaction[]>` — Batch update `Transactions` on the Book.
609
+ - `copy(name: string, copyTransactions?: boolean, fromDate?: number)` → `Promise<Book>` — Creates a copy of this Book
610
+ - `countTransactions(query?: string)` → `Promise<number | undefined>` — Retrieve the number of transactions based on a query.
611
+ - `create()` → `Promise<Book>` — Performs create new Book.
612
+ - `createAccountsDataTable(accounts?: Account[])` → `Promise<AccountsDataTableBuilder>` — Create a `AccountsDataTableBuilder`, to build two dimensional Array representations of `Account` dataset.
613
+ - `createGroupsDataTable(groups?: Group[])` → `Promise<GroupsDataTableBuilder>` — Create a `GroupsDataTableBuilder`, to build two dimensional Array representations of `Group` dataset.
614
+ - `createIntegration(integration: bkper.Integration | Integration)` → `Promise<Integration>` — Creates a new `Integration` in the Book.
615
+ - `createTransactionsDataTable(transactions: Transaction[], account?: Account)` → `TransactionsDataTableBuilder` — Create a `TransactionsDataTableBuilder`, to build two dimensional Array representations of `Transaction` dataset.
616
+ - `formatDate(date: Date, timeZone?: string)` → `string` — Formats a date according to date pattern of the Book.
617
+ - `formatValue(value: number | Amount | null | undefined)` → `string` — Formats a value according to `DecimalSeparator` and fraction digits of the Book.
618
+ - `getAccount(idOrName?: string)` → `Promise<Account | undefined>` — Gets an `Account` object by id or name.
619
+ - `getAccounts()` → `Promise<Account[]>` — Gets all `Accounts` of this Book with full account-group relationships.
620
+ - `getApps()` → `Promise<App[]>` — Retrieve installed `Apps` for this Book.
621
+ - `getAutoPost()` / `setAutoPost(autoPost: boolean)` → `boolean | undefined (set: boolean)` — Gets the auto post status of the Book.
622
+ - `getBacklog()` → `Promise<Backlog>` — Gets the Backlog of this Book.
623
+ - `getBalancesReport(query: string)` → `Promise<BalancesReport>` — Create a `BalancesReport` based on query.
624
+ - `getClosingDate()` / `setClosingDate(closingDate: string | null)` → `string | undefined (set: string | null)` — Gets the closing date of the Book in ISO format yyyy-MM-dd.
625
+ - `getCollaborators()` → `Promise<Collaborator[]>` — Gets all collaborators of this Book.
626
+ - `getCollection()` → `Collection | undefined` — Gets the collection of this Book, if any.
627
+ - `getDatePattern()` / `setDatePattern(datePattern: string)` → `string` — Gets the date pattern of the Book.
628
+ - `getDecimalPlaces()` → `number | undefined` — Gets the number of decimal places supported by this Book.
629
+ - `getDecimalSeparator()` / `setDecimalSeparator(decimalSeparator: DecimalSeparator)` → `DecimalSeparator` — Gets the decimal separator of the Book.
630
+ - `getFile(id: string)` → `Promise<File | undefined>` — Retrieve a file by id.
631
+ - `getFractionDigits()` / `setFractionDigits(fractionDigits: number)` → `number | undefined (set: number)` — Gets the number of fraction digits supported by this Book.
632
+ - `getGroup(idOrName?: string)` → `Promise<Group | undefined>` — Gets a `Group` object by id or name.
633
+ - `getGroups()` → `Promise<Group[]>` — Gets all `Groups` of this Book with complete parent/child hierarchy.
634
+ - `getId()` → `string` — Gets the unique identifier of this Book.
635
+ - `getIntegrations()` → `Promise<Integration[]>` — Gets the existing `Integrations` in the Book.
636
+ - `getLastUpdateMs()` → `number | undefined` — Gets the last update date of the book, in milliseconds.
637
+ - `getLockDate()` / `setLockDate(lockDate: string | null)` → `string | undefined (set: string | null)` — Gets the lock date of the Book in ISO format yyyy-MM-dd.
638
+ - `getName()` / `setName(name: string)` → `string | undefined (set: string)` — Gets the name of this Book.
639
+ - `getOwnerName()` → `string | undefined` — Gets the name of the owner of the Book.
640
+ - `getPageSize()` / `setPageSize(pageSize: number)` → `number | undefined (set: number)` — Gets the transactions pagination page size.
641
+ - `getPeriod()` / `setPeriod(period: Period)` → `Period` — Gets the period slice for balances visualization.
642
+ - `getPeriodStartMonth()` / `setPeriodStartMonth(month: Month)` → `Month` — Gets the start month when YEAR period is set.
643
+ - `getPermission()` → `Permission` — Gets the permission for the current user in this Book.
644
+ - `getSavedQueries()` → `Promise<Query[]>` — Gets the saved queries from this book.
645
+ - `getTimeZone()` / `setTimeZone(timeZone: string)` → `string | undefined (set: string)` — Gets the time zone of the Book.
646
+ - `getTimeZoneOffset()` → `number | undefined` — Gets the time zone offset of the book, in minutes.
647
+ - `getTotalTransactions()` → `number` — Gets the total number of posted transactions.
648
+ - `getTotalTransactionsCurrentMonth()` → `number` — Gets the total number of posted transactions on current month.
649
+ - `getTotalTransactionsCurrentYear()` → `number` — Gets the total number of posted transactions on current year.
650
+ - `getTransaction(id: string)` → `Promise<Transaction | undefined>` — Retrieve a transaction by id.
651
+ - `getVisibility()` / `setVisibility(visibility: Visibility)` → `Visibility` — Gets the visibility of the book.
652
+ - `json()` → `bkper.Book` — Gets an immutable copy of the JSON payload for this resource.
653
+ - `listEvents(afterDate: string | null, beforeDate: string | null, onError: boolean, resourceId: string | null, limit: number, cursor?: string)` → `Promise<EventList>` — Lists events in the Book based on the provided parameters.
654
+ - `listTransactions(query?: string, limit?: number, cursor?: string)` → `Promise<TransactionList>` — Lists transactions in the Book based on the provided query, limit, and cursor, for pagination.
655
+ - `parseDate(date: string)` → `Date` — Parse a date string according to date pattern and timezone of the Book. Also parse ISO yyyy-mm-dd format.
656
+ - `parseValue(value: string)` → `Amount | undefined` — Parse a value string according to `DecimalSeparator` and fraction digits of the Book.
657
+ - `remove()` → `Promise<Book>` — Warning!
658
+ - `round(value: number | Amount)` → `Amount` — Rounds a value according to the number of fraction digits of the Book.
659
+ - `update()` → `Promise<Book>` — Perform update Book, applying pending changes.
660
+ - `updateIntegration(integration: bkper.Integration)` → `Promise<Integration>` — Updates an existing `Integration` in the Book.
661
+
662
+ *Standard property methods (deleteProperty, getProperties, getProperty, getPropertyKeys, getVisibleProperties, setProperties, setProperty, setVisibleProperties, setVisibleProperty) — see Account.*
663
+
664
+ **getAccount**
665
+
666
+ Results are cached to avoid repeated server calls. Account-group relationships
667
+ are included if the full chart was loaded via getAccounts() or when the Book
668
+ was loaded with includeAccounts=true.
669
+
670
+ ```typescript
671
+ // Get individual account (basic data, cached)
672
+ const account = await book.getAccount('Bank Account');
673
+
674
+ // For account-group relationships, use one of these approaches:
675
+ // Option 1: Load book with full data upfront
676
+ const bookWithAccounts = await Bkper.getBook(bookId, true);
677
+ const accountWithGroups = await bookWithAccounts.getAccount('Bank Account');
678
+
679
+ // Option 2: Load full chart when needed
680
+ await book.getAccounts();
681
+ const accountWithGroups2 = await book.getAccount('Bank Account');
682
+ ```
683
+
684
+ **getAccounts**
685
+
686
+ Results are cached for performance. Groups are automatically loaded first
687
+ to ensure proper linking. Consider using Bkper.getBook(id, true) for
688
+ upfront loading when you know you'll need all accounts.
689
+
690
+ ```typescript
691
+ // Load all accounts with complete relationships
692
+ const accounts = await book.getAccounts();
693
+
694
+ // Alternative: Load book with accounts upfront (more efficient)
695
+ const bookWithAccounts = await Bkper.getBook(bookId, true);
696
+ const accounts2 = await bookWithAccounts.getAccounts(); // Already cached
697
+ ```
698
+
699
+ **getBalancesReport**
700
+
701
+ The balances report
702
+
703
+ Example:
704
+
705
+ ```js
706
+ var book = BkperApp.getBook("agtzfmJrcGVyLWhyZHITCxIGTGVkZ2VyGICAgPXjx7oKDA");
707
+
708
+ var balancesReport = book.getBalancesReport("group:'Equity' after:7/2018 before:8/2018");
709
+
710
+ var accountBalance = balancesReport.getBalancesContainer("Bank Account").getCumulativeBalance();
711
+ ```
712
+
713
+ **getGroup**
714
+
715
+ Results are cached to avoid repeated server calls. Parent/child relationships
716
+ are included if all groups were loaded via getGroups() or when the Book was
717
+ loaded with includeGroups=true.
718
+
719
+ ```typescript
720
+ // Get individual group (basic data, cached)
721
+ const group = await book.getGroup('Assets');
722
+
723
+ // For parent/child relationships, use one of these approaches:
724
+ // Option 1: Load book with full hierarchy upfront
725
+ const bookWithGroups = await Bkper.getBook(bookId, false, true);
726
+ const groupWithTree = await bookWithGroups.getGroup('Assets');
727
+
728
+ // Option 2: Load full hierarchy when needed
729
+ await book.getGroups();
730
+ const groupWithTree2 = await book.getGroup('Assets');
731
+ console.log(groupWithTree2.getParent(), groupWithTree2.getChildren());
732
+ ```
733
+
734
+ **getGroups**
735
+
736
+ Results are cached for performance. Group tree relationships are built
737
+ during loading. Consider using Bkper.getBook(id, false, true) for
738
+ upfront loading when you know you'll need all groups.
739
+
740
+ ```typescript
741
+ // Load all groups with complete hierarchy
742
+ const groups = await book.getGroups();
743
+
744
+ // Alternative: Load book with groups upfront (more efficient)
745
+ const bookWithGroups = await Bkper.getBook(bookId, false, true);
746
+ const groups2 = await bookWithGroups.getGroups(); // Already cached
747
+ ```
748
+
749
+ **remove**
750
+
751
+ Deletes this Book and all its data (transactions, accounts, groups). Book owner only.
752
+
753
+ ### BooksDataTableBuilder
754
+
755
+ A BooksDataTableBuilder is used to setup and build two-dimensional arrays containing books.
756
+
757
+ **Constructor:** `new BooksDataTableBuilder(books: Book[])`
758
+
759
+ **Methods:**
760
+
761
+ - `build()` → `any[][]` — Builds a two-dimensional array containing all Books.
762
+ - `hiddenProperties(include: boolean)` → `BooksDataTableBuilder` — Defines whether to include hidden properties (keys ending with underscore "_").
763
+ - `ids(include: boolean)` → `BooksDataTableBuilder` — Defines whether to include book ids.
764
+ - `properties(include: boolean)` → `BooksDataTableBuilder` — Defines whether to include custom book properties.
765
+
766
+ ### BotResponse
767
+
768
+ This class defines a Bot Response associated to an `Event`.
769
+
770
+ **Constructor:** `new BotResponse(event: Event, payload?: bkper.BotResponse)`
771
+
772
+ **Properties:**
773
+
774
+ - `payload`: `bkper.BotResponse`
775
+
776
+ **Methods:**
777
+
778
+ - `getAgentId()` → `string | undefined` — Gets the agent id of this Bot Response.
779
+ - `getCreatedAt()` → `Date | undefined` — Gets the date this Bot Response was created.
780
+ - `getEvent()` → `Event` — Gets the Event this Bot Response is associated to.
781
+ - `getMessage()` → `string | undefined` — Gets the message of this Bot Response.
782
+ - `getType()` → `BotResponseType | undefined` — Gets the type of this Bot Response.
783
+ - `remove()` → `Promise<BotResponse>` — Delete this Bot Response.
784
+ - `replay()` → `Promise<BotResponse>` — Replay this Bot Response.
785
+
786
+ ### Collaborator *(extends Resource<bkper.Collaborator>)*
787
+
788
+ This class defines a Collaborator of a `Book`.
789
+
790
+ A Collaborator represents a user that has been granted access to a Book with specific permissions.
791
+
792
+ **Constructor:** `new Collaborator(book: Book, payload?: bkper.Collaborator)`
793
+
794
+ **Properties:**
795
+
796
+ - `payload`: `bkper.Collaborator` — The underlying payload data for this resource
797
+
798
+ **Methods:**
799
+
800
+ - `create(message?: string)` → `Promise<Collaborator>` — Performs create new Collaborator.
801
+ - `getEmail()` / `setEmail(email: string)` → `string | undefined (set: string)` — Gets the Collaborator email address.
802
+ - `getId()` → `string | undefined` — Gets the Collaborator internal id.
803
+ - `getPermission()` / `setPermission(permission: Permission)` → `Permission | undefined (set: Permission)` — Gets the permission level of the Collaborator.
804
+ - `json()` → `bkper.Collaborator` — Gets an immutable copy of the JSON payload for this resource.
805
+ - `remove()` → `Promise<Collaborator>` — Performs remove Collaborator.
806
+ - `update()` → `Promise<Collaborator>` — Performs update Collaborator.
807
+
808
+ ### Collection *(extends Resource<bkper.Collection>)*
809
+
810
+ This class defines a Collection of `Books`.
811
+
812
+ **Constructor:** `new Collection(payload?: bkper.Collection, config?: Config)`
813
+
814
+ **Properties:**
815
+
816
+ - `payload`: `bkper.Collection` — The underlying payload data for this resource
817
+
818
+ **Methods:**
819
+
820
+ - `addBooks(books: Book[])` → `Promise<Book[]>` — Adds Books to this Collection.
821
+ - `create()` → `Promise<Collection>` — Performs create new Collection.
822
+ - `getBooks()` → `Book[]` — Gets all Books of this collection.
823
+ - `getId()` → `string | undefined` — Gets the unique identifier of this Collection.
824
+ - `getName()` / `setName(name: string)` → `string | undefined (set: string)` — Gets the name of this Collection.
825
+ - `getOwnerUsername()` → `string | undefined` — Gets the username of the owner of this Collection
826
+ - `getPermission()` → `Permission | undefined` — Gets the user permission for this Collection
827
+ - `getUpdatedAt()` → `string | undefined` — Gets the last update date of this Collection
828
+ - `json()` → `bkper.Collection` — Gets an immutable copy of the JSON payload for this resource.
829
+ - `remove()` → `Promise<Book[]>` — Performs delete Collection.
830
+ - `removeBooks(books: Book[])` → `Promise<Book[]>` — Removes Books from this Collection.
831
+ - `update()` → `Promise<Collection>` — Performs update Collection, applying pending changes.
832
+
833
+ ### Connection *(extends ResourceProperty<bkper.Connection>)*
834
+
835
+ This class defines a Connection from an `User` to an external service.
836
+
837
+ **Constructor:** `new Connection(payload?: bkper.Connection, config?: Config)`
838
+
839
+ **Properties:**
840
+
841
+ - `payload`: `bkper.Connection` — The underlying payload data for this resource
842
+
843
+ **Methods:**
844
+
845
+ - `clearTokenProperties()` → `void` — Cleans any token property stored in the Connection.
846
+ - `create()` → `Promise<Connection>` — Performs create new Connection.
847
+ - `getAgentId()` / `setAgentId(agentId: string)` → `string | undefined (set: string)` — Gets the agentId of the Connection.
848
+ - `getDateAddedMs()` → `string | undefined` — Gets the date when the Connection was added.
849
+ - `getEmail()` → `string | undefined` — Gets the email of the owner of the Connection.
850
+ - `getId()` → `string | undefined` — Gets the id of the Connection.
851
+ - `getIntegrations()` → `Promise<Integration[]>` — Gets the existing `Integrations` on the Connection.
852
+ - `getLogo()` → `string | undefined` — Gets the logo of the Connection.
853
+ - `getName()` / `setName(name: string)` → `string | undefined (set: string)` — Gets the name of the Connection.
854
+ - `getType()` / `setType(type: "APP" | "BANK")` → `"APP" | "BANK" | undefined (set: "APP" | "BANK")` — Gets the type of the Connection.
855
+ - `getUUID()` / `setUUID(uuid: string)` → `string | undefined (set: string)` — Gets the universal unique identifier of this Connection.
856
+ - `json()` → `bkper.Connection` — Gets an immutable copy of the JSON payload for this resource.
857
+ - `remove()` → `Promise<Connection>` — Performs remove Connection.
858
+
859
+ *Standard property methods (deleteProperty, getProperties, getProperty, getPropertyKeys, getVisibleProperties, setProperties, setProperty, setVisibleProperties, setVisibleProperty) — see Account.*
860
+
861
+ ### Event
862
+
863
+ This class defines an Event from a `Book`.
864
+
865
+ An event is an object that represents an action (such as posting or deleting a `Transaction`) made by an actor (such as a user or a [Bot](https://bkper.com/apps) acting on behalf of a user).
866
+
867
+ **Constructor:** `new Event(book: Book, payload?: bkper.Event)`
868
+
869
+ **Properties:**
870
+
871
+ - `payload`: `bkper.Event`
872
+
873
+ **Methods:**
874
+
875
+ - `getAgent()` → `Agent | undefined` — Gets the Agent who performed the Event.
876
+ - `getBook()` → `Book` — Gets the book in which the Event was created.
877
+ - `getBotResponses()` → `BotResponse[]` — Gets the Bot Responses associated to this Event.
878
+ - `getCreatedAt()` → `Date | undefined` — Gets the date the Event was created.
879
+ - `getId()` → `string | undefined` — Gets the id of the Event.
880
+ - `getType()` → `EventType | undefined` — Gets the type of the Event.
881
+ - `getUser()` → `User | undefined` — Gets the user who performed the Event.
882
+ - `hasErrorResponse()` → `boolean` — Checks if this Event has at least one Bot Response of type ERROR.
883
+ - `json()` → `bkper.Event` — Gets an immutable copy of the JSON payload for this Event.
884
+
885
+ ### EventList
886
+
887
+ A list associated with an event query.
888
+
889
+ **Constructor:** `new EventList(book: Book, payload: bkper.EventList)`
890
+
891
+ **Methods:**
892
+
893
+ - `getCursor()` → `string | undefined` — Gets the cursor associated with the query for pagination.
894
+ - `getFirst()` → `Event | undefined` — Gets the first Event in the list.
895
+ - `getItems()` → `Event[]` — Get the events in the list.
896
+ - `size()` → `number` — Get the total number of events in the list.
897
+
898
+ ### File *(extends ResourceProperty<bkper.File>)*
899
+
900
+ This class defines a File uploaded to a `Book`.
901
+
902
+ A File can be attached to a `Transaction` or used to import data.
903
+
904
+ **Constructor:** `new File(book: Book, payload?: bkper.File)`
905
+
906
+ **Properties:**
907
+
908
+ - `payload`: `bkper.File` — The underlying payload data for this resource
909
+
910
+ **Methods:**
911
+
912
+ - `create()` → `Promise<File>` — Perform create new File.
913
+ - `getBook()` → `Book` — Gets the Book this File belongs to.
914
+ - `getContent()` / `setContent(content: string)` → `Promise<string | undefined> (set: string)` — Gets the file content Base64 encoded.
915
+ - `getContentType()` / `setContentType(contentType: string)` → `string | undefined (set: string)` — Gets the File content type.
916
+ - `getId()` → `string | undefined` — Gets the File id.
917
+ - `getName()` / `setName(name: string)` → `string | undefined (set: string)` — Gets the File name.
918
+ - `getSize()` → `number | undefined` — Gets the file size in bytes.
919
+ - `getUrl()` → `string | undefined` — Gets the file serving url for accessing via browser.
920
+ - `json()` → `bkper.File` — Gets an immutable copy of the JSON payload for this resource.
921
+ - `update()` → `Promise<File>` — Perform update File, applying pending changes.
922
+
923
+ *Standard property methods (deleteProperty, getProperties, getProperty, getPropertyKeys, getVisibleProperties, setProperties, setProperty, setVisibleProperties, setVisibleProperty) — see Account.*
924
+
925
+ ### Group *(extends ResourceProperty<bkper.Group>)*
926
+
927
+ This class defines a Group of `Accounts`.
928
+
929
+ Accounts can be grouped by different meaning, like Expenses, Revenue, Assets, Liabilities and so on
930
+
931
+ Its useful to keep organized and for high level analysis.
932
+
933
+ **Constructor:** `new Group(book: Book, payload?: bkper.Group)`
934
+
935
+ **Properties:**
936
+
937
+ - `payload`: `bkper.Group` — The underlying payload data for this resource
938
+
939
+ **Methods:**
940
+
941
+ - `create()` → `Promise<Group>` — Performs create new group.
942
+ - `getAccounts()` → `Promise<Account[]>` — Gets all Accounts of this group.
943
+ - `getChildren()` → `Group[]` — Gets the children of the Group.
944
+ - `getDepth()` → `number` — Gets the depth of the Group in the hierarchy.
945
+ - `getDescendants()` → `Set<Group>` — Gets all descendant Groups of the current Group.
946
+ - `getDescendantTreeIds()` → `Set<string>` — Gets the IDs of all descendant Groups in a tree structure.
947
+ - `getId()` → `string | undefined` — Gets the id of this Group.
948
+ - `getName()` / `setName(name: string)` → `string | undefined (set: string)` — Gets the name of this Group.
949
+ - `getNormalizedName()` → `string` — Gets the normalized name of this group without spaces and special characters.
950
+ - `getParent()` / `setParent(group: Group | null | undefined)` → `Group | undefined (set: Group | null | undefined)` — Gets the parent Group.
951
+ - `getRoot()` → `Group` — Gets the root Group of the current Group.
952
+ - `getRootName()` → `string` — Gets the name of the root Group.
953
+ - `getType()` → `AccountType` — Gets the type of the accounts of this group.
954
+ - `hasAccounts()` → `boolean | undefined` — Tells if this group has any account in it.
955
+ - `hasChildren()` → `boolean` — Checks if the Group has any children.
956
+ - `hasParent()` → `boolean` — Checks if the Group has a parent.
957
+ - `isBalanceVerified()` → `Promise<boolean | undefined>` — Tells if the balance of this Group has been verified/audited.
958
+ - `isCredit()` → `boolean | undefined` — Tells if this is a credit (Incoming and Liabilities) group.
959
+ - `isHidden()` → `boolean | undefined` — Tells if the Group is hidden on main transactions menu.
960
+ - `isLeaf()` → `boolean` — Checks if the Group is a leaf node (i.e., has no children).
961
+ - `isLocked()` → `boolean` — Tells if the Group is locked by the Book owner.
962
+ - `isMixed()` → `boolean | undefined` — Tells if this is a mixed (Assets/Liabilities or Incoming/Outgoing) group.
963
+ - `isPermanent()` → `boolean | undefined` — Tells if the Group is permanent.
964
+ - `isRoot()` → `boolean` — Checks if the Group is a root node (i.e., has no parent).
965
+ - `json()` → `bkper.Group` — Gets an immutable copy of the JSON payload for this resource.
966
+ - `remove()` → `Promise<Group>` — Performs delete group.
967
+ - `setHidden(hidden: boolean)` → `Group` — Hide/Show group on main menu.
968
+ - `setLocked(locked: boolean)` → `Group` — Sets the locked state of the Group.
969
+ - `update()` → `Promise<Group>` — Performs update group, applying pending changes.
970
+
971
+ *Standard property methods (deleteProperty, getProperties, getProperty, getPropertyKeys, getVisibleProperties, setProperties, setProperty, setVisibleProperties, setVisibleProperty) — see Account.*
972
+
973
+ ### GroupsDataTableBuilder
974
+
975
+ A GroupsDataTableBuilder is used to setup and build two-dimensional arrays containing groups.
976
+
977
+ **Constructor:** `new GroupsDataTableBuilder(groups: Group[])`
978
+
979
+ **Methods:**
980
+
981
+ - `build()` → `any[][]` — Builds a two-dimensional array containing all Groups.
982
+ - `hiddenProperties(include: boolean)` → `GroupsDataTableBuilder` — Defines whether to include hidden properties (keys ending with underscore "_").
983
+ - `ids(include: boolean)` → `GroupsDataTableBuilder` — Defines whether include group ids.
984
+ - `properties(include: boolean)` → `GroupsDataTableBuilder` — Defines whether include custom group properties.
985
+ - `tree(enable: boolean)` → `GroupsDataTableBuilder` — Defines whether to render groups as an indented tree instead of flat rows with a Parent column.
986
+
987
+ ### Integration *(extends ResourceProperty<bkper.Integration>)*
988
+
989
+ This class defines a Integration from an `User` to an external service.
990
+
991
+ **Constructor:** `new Integration(payload?: bkper.Integration, config?: Config)`
992
+
993
+ **Properties:**
994
+
995
+ - `payload`: `bkper.Integration` — The underlying payload data for this resource
996
+
997
+ **Methods:**
998
+
999
+ - `getAddedBy()` → `string | undefined` — Gets the name of the user who added the Integration.
1000
+ - `getAgentId()` → `string | undefined` — Gets the agent id of the Integration.
1001
+ - `getBookId()` → `string | undefined` — Gets the `Book` id of the Integration.
1002
+ - `getDateAddedMs()` → `string | undefined` — Gets the date when the Integration was added.
1003
+ - `getId()` → `string | undefined` — Gets the id of the Integration.
1004
+ - `getLastUpdateMs()` → `string | undefined` — Gets the date when the Integration was last updated.
1005
+ - `getLogo()` → `string | undefined` — ~~Deprecated: Use getLogoUrl instead.~~ Gets the logo of the Integration.
1006
+ - `getLogoUrl()` → `string | undefined` — Gets the logo url of this Integration.
1007
+ - `getLogoUrlDark()` → `string | undefined` — Gets the logo url of this Integration in dark mode.
1008
+ - `getName()` → `string | undefined` — Gets the name of the Integration.
1009
+ - `json()` → `bkper.Integration` — Gets an immutable copy of the JSON payload for this resource.
1010
+ - `remove()` → `Promise<Integration>` — Performs remove Integration.
1011
+
1012
+ *Standard property methods (deleteProperty, getProperties, getProperty, getPropertyKeys, getVisibleProperties, setProperties, setProperty, setVisibleProperties, setVisibleProperty) — see Account.*
1013
+
1014
+ ### Query *(extends Resource<bkper.Query>)*
1015
+
1016
+ Defines a saved Query in a `Book`.
1017
+
1018
+ Queries can be saved on Books by users.
1019
+
1020
+ **Constructor:** `new Query(book: Book, payload?: bkper.Query)`
1021
+
1022
+ **Properties:**
1023
+
1024
+ - `payload`: `bkper.Query` — The underlying payload data for this resource
1025
+
1026
+ **Methods:**
1027
+
1028
+ - `create()` → `Promise<Query>` — Perform create new Query.
1029
+ - `getId()` → `string | undefined` — Gets the Query universal identifier.
1030
+ - `getQuery()` / `setQuery(query: string)` → `string | undefined (set: string)` — Gets the query string to be executed.
1031
+ - `getTitle()` / `setTitle(title: string)` → `string | undefined (set: string)` — Gets the title of this saved Query.
1032
+ - `json()` → `bkper.Query` — Gets an immutable copy of the JSON payload for this resource.
1033
+ - `remove()` → `Promise<Query>` — Perform delete Query.
1034
+ - `update()` → `Promise<Query>` — Perform update Query, applying pending changes.
1035
+
1036
+ ### Template *(extends Resource<bkper.Template>)*
1037
+
1038
+ This class defines a Template.
1039
+
1040
+ A Template is a pre-configured setup for `Books` and associated Google Sheets that provides users with a starting point for specific accounting or financial management needs.
1041
+
1042
+ **Constructor:** `new Template(json?: bkper.Template, config?: Config)`
1043
+
1044
+ **Properties:**
1045
+
1046
+ - `payload`: `bkper.Template` — The underlying payload data for this resource
1047
+
1048
+ **Methods:**
1049
+
1050
+ - `getBookId()` → `string | undefined` — Gets the bookId of the `Book` associated with the Template.
1051
+ - `getBookLink()` → `string | undefined` — Gets the link of the `Book` associated with the Template.
1052
+ - `getCategory()` → `string | undefined` — Gets the category of the Template.
1053
+ - `getDescription()` → `string | undefined` — Gets the description of the Template.
1054
+ - `getImageUrl()` → `string | undefined` — Gets the url of the image of the Template.
1055
+ - `getName()` → `string | undefined` — Gets the name of the Template.
1056
+ - `getSheetsLink()` → `string | undefined` — Gets the link of the Google Sheets spreadsheet associated with the Template.
1057
+ - `getTimesUsed()` → `number` — Gets the times the Template has been used.
1058
+ - `json()` → `bkper.Template` — Gets an immutable copy of the JSON payload for this resource.
1059
+
1060
+ ### Transaction *(extends ResourceProperty<bkper.Transaction>)*
1061
+
1062
+ This class defines a Transaction between [credit and debit](http://en.wikipedia.org/wiki/Debits_and_credits) `Accounts`.
1063
+
1064
+ A Transaction is the main entity on the [Double Entry](http://en.wikipedia.org/wiki/Double-entry_bookkeeping_system) [Bookkeeping](http://en.wikipedia.org/wiki/Bookkeeping) system.
1065
+
1066
+ **Constructor:** `new Transaction(book: Book, payload?: bkper.Transaction)`
1067
+
1068
+ **Properties:**
1069
+
1070
+ - `payload`: `bkper.Transaction` — The underlying payload data for this resource
1071
+
1072
+ **Methods:**
1073
+
1074
+ - `addFile(file: File)` → `Transaction` — Adds a file attachment to the Transaction.
1075
+ - `addRemoteId(remoteId: string)` → `Transaction` — Add a remote id to the Transaction.
1076
+ - `addUrl(url: string)` → `Transaction` — Add a url to the Transaction. Url starts with https://
1077
+ - `check()` → `Promise<Transaction>` — Perform check transaction.
1078
+ - `create()` → `Promise<Transaction>` — Perform create new draft transaction.
1079
+ - `from(account: bkper.Account | Account | null | undefined)` → `Transaction` — Sets the credit/origin `Account` of this Transaction. Same as setCreditAccount()
1080
+ - `getAccountBalance(raw?: boolean)` → `Promise<Amount | undefined>` — Gets the balance that the `Account` has at that day, when listing transactions of that Account.
1081
+ - `getAgentId()` → `string | undefined` — Gets the unique identifier of the agent that created this transaction.
1082
+ - `getAgentLogoUrl()` → `string | undefined` — Gets the logo URL of the agent that created this transaction.
1083
+ - `getAgentLogoUrlDark()` → `string | undefined` — Gets the dark mode logo URL of the agent that created this transaction.
1084
+ - `getAgentName()` → `string | undefined` — Gets the name of the agent that created this transaction.
1085
+ - `getAmount()` / `setAmount(amount: string | number | Amount)` → `Amount | undefined (set: string | number | Amount)` — Gets the amount of this Transaction.
1086
+ - `getAmountFormatted()` → `string | undefined` — Gets the formatted amount of this Transaction according to the Book format.
1087
+ - `getBook()` → `Book` — Gets the book associated with this transaction.
1088
+ - `getCreatedAt()` → `Date` — Gets the date when the transaction was created.
1089
+ - `getCreatedAtFormatted()` → `string` — Gets the formatted creation date of the transaction.
1090
+ - `getCreatedBy()` → `string | undefined` — Gets the username of the user who created the transaction.
1091
+ - `getCreditAccount()` / `setCreditAccount(account: bkper.Account | Account | null | undefined)` → `Promise<Account | undefined> (set: bkper.Account | Account | null | undefined)` — Gets the credit account associated with this Transaction. Same as origin account
1092
+ - `getCreditAccountName()` → `Promise<string | undefined>` — Gets the name of this Transaction's credit account.
1093
+ - `getCreditAmount(account: string | Account)` → `Promise<Amount | undefined>` — Get the absolute amount of this Transaction if the given account is at the credit side.
1094
+ - `getDate()` / `setDate(date: string | Date)` → `string | undefined (set: string | Date)` — Gets the transaction date in ISO format.
1095
+ - `getDateFormatted()` → `string | undefined` — Gets the transaction date formatted according to the book's date pattern.
1096
+ - `getDateObject()` → `Date` — Gets the transaction date as a Date object in the book's timezone.
1097
+ - `getDateValue()` → `number | undefined` — Gets the transaction date as a numeric value.
1098
+ - `getDebitAccount()` / `setDebitAccount(account: bkper.Account | Account | null | undefined)` → `Promise<Account | undefined> (set: bkper.Account | Account | null | undefined)` — Gets the debit account associated with this Transaction. Same as destination account
1099
+ - `getDebitAccountName()` → `Promise<string | undefined>` — Gets the name of this Transaction's debit account.
1100
+ - `getDebitAmount(account: string | Account)` → `Promise<Amount | undefined>` — Gets the absolute amount of this Transaction if the given account is at the debit side.
1101
+ - `getDescription()` / `setDescription(description: string)` → `string` — Gets the description of this Transaction.
1102
+ - `getFiles()` → `File[]` — Gets all files attached to the transaction.
1103
+ - `getId()` → `string | undefined` — Gets the unique identifier of the transaction.
1104
+ - `getOtherAccount(account: string | Account)` → `Promise<Account | undefined>` — Gets the `Account` at the other side of the transaction given the one in one side.
1105
+ - `getOtherAccountName(account: string | Account)` → `Promise<string | undefined>` — The Account name at the other side of this Transaction given the one in one side.
1106
+ - `getRemoteIds()` → `string[]` — Gets the remote IDs associated with this transaction. Remote ids are used to avoid duplication.
1107
+ - `getStatus()` → `TransactionStatus` — Gets the status of the transaction.
1108
+ - `getTags()` → `string[]` — Gets all hashtags used in the transaction.
1109
+ - `getUpdatedAt()` → `Date` — Gets the date when the transaction was last updated.
1110
+ - `getUpdatedAtFormatted()` → `string` — Gets the formatted last update date of the transaction.
1111
+ - `getUrls()` / `setUrls(urls: string[])` → `string[]` — Gets all URLs associated with the transaction.
1112
+ - `hasTag(tag: string)` → `boolean` — Check if the transaction has the specified tag.
1113
+ - `isChecked()` → `boolean | undefined` — Checks if the transaction is marked as checked.
1114
+ - `isCredit(account?: Account)` → `Promise<boolean>` — Tell if the given account is credit on this Transaction
1115
+ - `isDebit(account?: Account)` → `Promise<boolean>` — Tell if the given account is debit on the Transaction
1116
+ - `isLocked()` → `boolean` — Checks if the transaction is locked by the book's lock or closing date.
1117
+ - `isPosted()` → `boolean | undefined` — Checks if the transaction has been posted to the accounts.
1118
+ - `isTrashed()` → `boolean | undefined` — Checks if the transaction is in the trash.
1119
+ - `json()` → `bkper.Transaction` — Gets an immutable copy of the JSON payload for this resource.
1120
+ - `post()` → `Promise<Transaction>` — Perform post transaction, changing credit and debit `Account` balances.
1121
+ - `removeFile(file: File)` → `Transaction` — Removes a file attachment from the Transaction.
1122
+ - `setChecked(checked: boolean)` → `Transaction` — Set the check state of the Transaction.
1123
+ - `to(account: bkper.Account | Account | null | undefined)` → `Transaction` — Sets the debit/destination `Account` of this Transaction. Same as setDebitAccount()
1124
+ - `trash()` → `Promise<Transaction>` — Trash the transaction.
1125
+ - `uncheck()` → `Promise<Transaction>` — Perform uncheck transaction.
1126
+ - `untrash()` → `Promise<Transaction>` — Untrash the transaction.
1127
+ - `update()` → `Promise<Transaction>` — Update transaction, applying pending changes.
1128
+
1129
+ *Standard property methods (deleteProperty, getProperties, getProperty, getPropertyKeys, getVisibleProperties, setProperties, setProperty, setVisibleProperties, setVisibleProperty) — see Account.*
1130
+
1131
+ **addFile**
1132
+
1133
+ Files not previously created in the Book will be automatically created when the transaction is persisted.
1134
+
1135
+ **getAccountBalance**
1136
+
1137
+ Evolved balances is returned when searching for transactions of a permanent `Account`.
1138
+
1139
+ Only comes with the last posted transaction of the day.
1140
+
1141
+ ### TransactionList
1142
+
1143
+ A list associated with a transaction query.
1144
+
1145
+ **Constructor:** `new TransactionList(book: Book, payload: bkper.TransactionList)`
1146
+
1147
+ **Methods:**
1148
+
1149
+ - `getAccount()` → `Promise<Account | undefined>` — Retrieves the account associated with the query, when filtering by account.
1150
+ - `getCursor()` → `string | undefined` — Gets the cursor associated with the query for pagination.
1151
+ - `getFirst()` → `Transaction | undefined` — Gets the first Transaction in the list.
1152
+ - `getItems()` → `Transaction[]` — Gets the transactions in the list.
1153
+ - `size()` → `number` — Gets the total number of transactions in the list.
1154
+
1155
+ ### TransactionsDataTableBuilder
1156
+
1157
+ A TransactionsDataTableBuilder is used to setup and build two-dimensional arrays containing transactions.
1158
+
1159
+ **Constructor:** `new TransactionsDataTableBuilder(book: Book, transactions: Transaction[], account?: Account)`
1160
+
1161
+ **Methods:**
1162
+
1163
+ - `build()` → `Promise<any[][]>` — Builds a two-dimensional array containing all transactions.
1164
+ - `formatDates(format: boolean)` → `TransactionsDataTableBuilder` — Defines whether the dates should be formatted, based on date pattern of the `Book`.
1165
+ - `formatValues(format: boolean)` → `TransactionsDataTableBuilder` — Defines whether amounts should be formatted based on `DecimalSeparator` of the `Book`.
1166
+ - `getAccount()` → `Account | undefined` — Gets the account used to filter transactions, when applicable.
1167
+ - `hiddenProperties(include: boolean)` → `TransactionsDataTableBuilder` — Defines whether to include hidden properties (keys ending with underscore "_").
1168
+ - `ids(include: boolean)` → `TransactionsDataTableBuilder` — Defines whether to include transaction ids and remote ids.
1169
+ - `includeIds(include: boolean)` → `TransactionsDataTableBuilder` — ~~Deprecated: Use `ids` instead.~~
1170
+ - `includeProperties(include: boolean)` → `TransactionsDataTableBuilder` — ~~Deprecated: Use `properties` instead.~~
1171
+ - `includeUrls(include: boolean)` → `TransactionsDataTableBuilder` — ~~Deprecated: Use `urls` instead.~~
1172
+ - `properties(include: boolean)` → `TransactionsDataTableBuilder` — Defines whether to include custom transaction properties.
1173
+ - `recordedAt(include: boolean)` → `TransactionsDataTableBuilder` — Defines whether to include the "Recorded at" column.
1174
+ - `urls(include: boolean)` → `TransactionsDataTableBuilder` — Defines whether to include attachments and url links.
1175
+
1176
+ ### User *(extends Resource<bkper.User>)*
1177
+
1178
+ This class defines a User on the Bkper platform.
1179
+
1180
+ Users can own and collaborate on `Books`, manage `Collections`, and connect to external services through `Connections`.
1181
+
1182
+ Each User has a unique identity, subscription plan details, and access permissions across the platform.
1183
+
1184
+ **Constructor:** `new User(payload?: bkper.User, config?: Config)`
1185
+
1186
+ **Properties:**
1187
+
1188
+ - `payload`: `bkper.User` — The underlying payload data for this resource
1189
+
1190
+ **Methods:**
1191
+
1192
+ - `getAvatarUrl()` → `string | undefined` — Gets the avatar url of the User.
1193
+ - `getBilling()` → `Promise<Billing>` — Gets the billing information for this User.
1194
+ - `getConnection(id: string)` → `Promise<Connection>` — Gets a `Connection` of the User.
1195
+ - `getConnections()` → `Promise<Connection[]>` — Gets the `Connections` of the User.
1196
+ - `getEmail()` → `string | undefined` — Gets the email of the User.
1197
+ - `getFullName()` → `string | undefined` — Gets the full name of the User.
1198
+ - `getGivenName()` → `string | undefined` — Gets the given name of the User.
1199
+ - `getHostedDomain()` → `string | undefined` — Gets the hosted domain of the User.
1200
+ - `getId()` → `string | undefined` — Gets the id of the User.
1201
+ - `getName()` → `string | undefined` — Gets the name of the User.
1202
+ - `getUsername()` → `string | undefined` — Gets the username of the User.
1203
+ - `hasUsedConnections()` → `boolean | undefined` — Tells if the User has already used `Connections`.
1204
+ - `json()` → `bkper.User` — Gets an immutable copy of the JSON payload for this resource.
1205
+
1206
+ ## Interfaces
1207
+
1208
+ ### BalancesContainer
1209
+
1210
+ The container of balances of an `Account` or `Group`
1211
+
1212
+ The container is composed of a list of `Balances` for a window of time, as well as its period and cumulative totals.
1213
+
1214
+ **Properties:**
1215
+
1216
+ - `getAccount`: `() => Promise<Account | null>` — Gets the `Account` associated with this container.
1217
+ - `getBalances`: `() => Balance[]` — Gets all `Balances` of the container
1218
+ - `getBalancesContainer`: `(name: string) => BalancesContainer` — Gets a specific `BalancesContainer`.
1219
+ - `getBalancesContainers`: `() => BalancesContainer[]` — Gets all child `BalancesContainers`.
1220
+ - `getBalancesReport`: `() => BalancesReport` — Gets the parent `BalancesReport` of the container.
1221
+ - `getCumulativeBalance`: `() => Amount` — Gets the cumulative balance to the date.
1222
+ - `getCumulativeBalanceRaw`: `() => Amount` — Gets the cumulative raw balance to the date.
1223
+ - `getCumulativeBalanceRawText`: `() => string` — Gets the cumulative raw balance formatted according to `Book` decimal format and fraction digits.
1224
+ - `getCumulativeBalanceText`: `() => string` — Gets the cumulative balance formatted according to `Book` decimal format and fraction digits.
1225
+ - `getDepth`: `() => number` — Gets the depth in the parent chain up to the root.
1226
+ - `getGroup`: `() => Promise<Group | null>` — Gets the `Group` associated with this container.
1227
+ - `getName`: `() => string` — Gets the `Account` or `Group` name.
1228
+ - `getNormalizedName`: `() => string` — Gets the `Account` or `Group` name without spaces or special characters.
1229
+ - `getParent`: `() => BalancesContainer | null` — Gets the parent BalanceContainer.
1230
+ - `getPeriodBalance`: `() => Amount` — Gets the balance on the date period.
1231
+ - `getPeriodBalanceRaw`: `() => Amount` — Gets the raw balance on the date period.
1232
+ - `getPeriodBalanceRawText`: `() => string` — Gets the raw balance on the date period formatted according to `Book` decimal format and fraction digits.
1233
+ - `getPeriodBalanceText`: `() => string` — Gets the balance on the date period formatted according to `Book` decimal format and fraction digits.
1234
+ - `hasGroupBalances`: `() => boolean` — Gets whether the balance container is from a parent group.
1235
+ - `isCredit`: `() => boolean | undefined` — Gets the credit nature of the BalancesContainer, based on `Account` or `Group`.
1236
+ - `isFromAccount`: `() => boolean` — Gets whether this balance container is from an `Account`.
1237
+ - `isFromGroup`: `() => boolean` — Gets whether this balance container is from a `Group`.
1238
+ - `isPermanent`: `() => boolean` — Tell if this balance container is permanent, based on the `Account` or `Group`.
1239
+ - `payload`: `bkper.AccountBalances | bkper.GroupBalances`
1240
+
1241
+ **Methods:**
1242
+
1243
+ - `createDataTable()` → `BalancesDataTableBuilder` — Creates a BalancesDataTableBuilder to generate a two-dimensional array with all `BalancesContainers`
1244
+ - `getCumulativeCredit()` → `Amount` — The cumulative credit to the date.
1245
+ - `getCumulativeCreditText()` → `string` — The cumulative credit formatted according to `Book` decimal format and fraction digits.
1246
+ - `getCumulativeDebit()` → `Amount` — The cumulative debit to the date.
1247
+ - `getCumulativeDebitText()` → `string` — The cumulative credit formatted according to `Book` decimal format and fraction digits.
1248
+ - `getPeriodCredit()` → `Amount` — The credit on the date period.
1249
+ - `getPeriodCreditText()` → `string` — The credit on the date period formatted according to `Book` decimal format and fraction digits
1250
+ - `getPeriodDebit()` → `Amount` — The debit on the date period.
1251
+ - `getPeriodDebitText()` → `string` — The debit on the date period formatted according to `Book` decimal format and fraction digits
1252
+ - `getProperties()` → `{ [key: string]: string }` — Gets the custom properties stored in this Account or Group.
1253
+ - `getProperty(keys: string[])` → `string | undefined` — Gets the property value for given keys. First property found will be retrieved
1254
+ - `getPropertyKeys()` → `string[]` — Gets the custom properties keys stored in the associated `Account` or `Group`.
1255
+
1256
+ **getBalancesContainers**
1257
+
1258
+ **NOTE**: Only for Group balance containers. Accounts returns null.
1259
+
1260
+ **isCredit**
1261
+
1262
+ For `Account`, the credit nature will be the same as the one from the Account.
1263
+
1264
+ For `Group`, the credit nature will be the same, if all accounts containing on it has the same credit nature. False if mixed.
1265
+
1266
+ **isPermanent**
1267
+
1268
+ Permanent are the ones which final balance is relevant and keep its balances over time.
1269
+
1270
+ They are also called [Real Accounts](http://en.wikipedia.org/wiki/Account_(accountancy)#Based_on_periodicity_of_flow).
1271
+
1272
+ Usually represents assets or liabilities, capable of being perceived by the senses or the mind, like bank accounts, money, debts and so on.
1273
+
1274
+ ### Config
1275
+
1276
+ This class defines the `Bkper` API Config.
1277
+
1278
+ **Properties:**
1279
+
1280
+ - `agentIdProvider?`: `() => Promise<string | undefined>` — Provides the agent ID to identify the calling agent for attribution purposes.
1281
+ - `apiKeyProvider?`: `() => Promise<string>` — Optional API key for dedicated quota limits.
1282
+ - `oauthTokenProvider?`: `() => Promise<string | undefined>` — Issue a valid OAuth2 access token with **https://www.googleapis.com/auth/userinfo.email** scope authorized.
1283
+ - `requestErrorHandler?`: `(error: any) => any` — Custom request error handler
1284
+ - `requestHeadersProvider?`: `() => Promise<{ [key: string]: string }>` — Provides additional headers to append to the API request
1285
+ - `requestRetryHandler?`: `(status?: number, error?: any, attempt?: number) => Promise<void>` — Custom request retry handler.
1286
+
1287
+ **agentIdProvider**
1288
+
1289
+ This ID is sent via the `bkper-agent-id` header with each API request,
1290
+ allowing the server to attribute actions to the correct agent.
1291
+
1292
+ **apiKeyProvider**
1293
+
1294
+ If not provided, requests use a shared managed quota via the Bkper API proxy.
1295
+ Use your own API key for dedicated quota limits and project-level usage tracking.
1296
+
1297
+ API keys are for project identification only, not for authentication or agent attribution.
1298
+ Agent attribution is handled separately via the `agentIdProvider`.
1299
+
1300
+ **requestRetryHandler**
1301
+
1302
+ This function is called when a request fails and needs to be retried.
1303
+ It provides the HTTP status code, error message, and the number of retry attempts made so far.
1304
+
1305
+ ## Enums
1306
+
1307
+ ### AccountType
1308
+
1309
+ Enum that represents account types.
1310
+
1311
+ - `ASSET` — Asset account type
1312
+ - `INCOMING` — Incoming account type
1313
+ - `LIABILITY` — Liability account type
1314
+ - `OUTGOING` — Outgoing account type
1315
+
1316
+ ### BalanceType
1317
+
1318
+ Enum that represents balance types.
1319
+
1320
+ - `CUMULATIVE` — Cumulative balance
1321
+ - `PERIOD` — Period balance
1322
+ - `TOTAL` — Total balance
1323
+
1324
+ ### BotResponseType
1325
+
1326
+ Enum that represents the type of a Bot Response
1327
+
1328
+ - `ERROR` — Error bot response
1329
+ - `INFO` — Info bot response
1330
+ - `WARNING` — Warning bot response
1331
+
1332
+ ### DecimalSeparator
1333
+
1334
+ Decimal separator of numbers on book
1335
+
1336
+ - `COMMA` — ,
1337
+ - `DOT` — .
1338
+
1339
+ ### EventType
1340
+
1341
+ Enum that represents event types.
1342
+
1343
+ - `ACCOUNT_CREATED`
1344
+ - `ACCOUNT_DELETED`
1345
+ - `ACCOUNT_UPDATED`
1346
+ - `BOOK_DELETED`
1347
+ - `BOOK_UPDATED`
1348
+ - `COLLABORATOR_ADDED`
1349
+ - `COLLABORATOR_REMOVED`
1350
+ - `COLLABORATOR_UPDATED`
1351
+ - `COMMENT_CREATED`
1352
+ - `COMMENT_DELETED`
1353
+ - `FILE_CREATED`
1354
+ - `FILE_UPDATED`
1355
+ - `GROUP_CREATED`
1356
+ - `GROUP_DELETED`
1357
+ - `GROUP_UPDATED`
1358
+ - `INTEGRATION_CREATED`
1359
+ - `INTEGRATION_DELETED`
1360
+ - `INTEGRATION_UPDATED`
1361
+ - `QUERY_CREATED`
1362
+ - `QUERY_DELETED`
1363
+ - `QUERY_UPDATED`
1364
+ - `TRANSACTION_CHECKED`
1365
+ - `TRANSACTION_CREATED`
1366
+ - `TRANSACTION_DELETED`
1367
+ - `TRANSACTION_POSTED`
1368
+ - `TRANSACTION_RESTORED`
1369
+ - `TRANSACTION_UNCHECKED`
1370
+ - `TRANSACTION_UPDATED`
1371
+
1372
+ ### Month
1373
+
1374
+ Enum that represents a Month.
1375
+
1376
+ - `APRIL`
1377
+ - `AUGUST`
1378
+ - `DECEMBER`
1379
+ - `FEBRUARY`
1380
+ - `JANUARY`
1381
+ - `JULY`
1382
+ - `JUNE`
1383
+ - `MARCH`
1384
+ - `MAY`
1385
+ - `NOVEMBER`
1386
+ - `OCTOBER`
1387
+ - `SEPTEMBER`
1388
+
1389
+ ### Period
1390
+
1391
+ Enum that represents a period slice.
1392
+
1393
+ - `MONTH` — Monthly period
1394
+ - `QUARTER` — Quarterly period
1395
+ - `YEAR` — Yearly period
1396
+
1397
+ ### Periodicity
1398
+
1399
+ The Periodicity of the query. It may depend on the level of granularity you write the range params.
1400
+
1401
+ - `DAILY` — Example: after:25/01/1983, before:04/03/2013, after:$d-30, before:$d, after:$d-15/$m
1402
+ - `MONTHLY` — Example: after:jan/2013, before:mar/2013, after:$m-1, before:$m
1403
+ - `YEARLY` — Example: on:2013, after:2013, $y
1404
+
1405
+ ### Permission
1406
+
1407
+ Enum representing permissions of user in the Book
1408
+
1409
+ - `EDITOR` — Manage accounts, transactions, book configuration and sharing
1410
+ - `NONE` — No permission
1411
+ - `OWNER` — Manage everything, including book visibility and deletion. Only one owner per book.
1412
+ - `POSTER` — View transactions, accounts, record and delete drafts
1413
+ - `RECORDER` — Record and delete drafts only. Useful to collect data only
1414
+ - `VIEWER` — View transactions, accounts and balances.
1415
+
1416
+ ### TransactionStatus
1417
+
1418
+ Enum that represents the status of a Transaction.
1419
+
1420
+ - `CHECKED` — Transaction is posted and checked
1421
+ - `DRAFT` — Transaction is a draft, not yet posted
1422
+ - `TRASHED` — Transaction is in the trash
1423
+ - `UNCHECKED` — Transaction is posted but not checked
1424
+
1425
+ ### Visibility
1426
+
1427
+ Enum representing the visibility of a Book
1428
+
1429
+ - `PRIVATE` — The book can be accessed by the owner and collaborators
1430
+ - `PUBLIC` — The book can be accessed by anyone with the link
1431
+