bkper-js 2.29.3 → 2.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -15,16 +15,20 @@ It provides a set of classes and functions to interact with the Bkper API, inclu
15
15
 
16
16
  ### Add the package:
17
17
 
18
- ```
18
+ ```bash tab="npm"
19
19
  npm i -S bkper-js
20
20
  ```
21
- or
22
- ```
23
- yarn add bkper-js
21
+
22
+ ```bash tab="bun"
23
+ bun add bkper-js
24
24
  ```
25
- or
25
+
26
+ ```bash tab="pnpm"
27
+ pnpm add bkper-js
26
28
  ```
27
- bun add bkper-js
29
+
30
+ ```bash tab="yarn"
31
+ yarn add bkper-js
28
32
  ```
29
33
 
30
34
  ## Usage
@@ -39,7 +43,7 @@ import { getOAuthToken } from 'bkper';
39
43
 
40
44
  // Configure with CLI authentication
41
45
  Bkper.setConfig({
42
- oauthTokenProvider: async () => getOAuthToken()
46
+ oauthTokenProvider: async () => getOAuthToken(),
43
47
  });
44
48
 
45
49
  // Create Bkper instance
@@ -54,7 +58,7 @@ const books = await bkper.getBooks();
54
58
  console.log(`You have ${books.length} books`);
55
59
  ```
56
60
 
57
- First, login via CLI: `bkper login`
61
+ First, login via CLI: `bkper auth login`
58
62
 
59
63
  ### Web Applications
60
64
 
@@ -66,8 +70,8 @@ import { BkperAuth } from '@bkper/web-auth';
66
70
 
67
71
  // Initialize authentication
68
72
  const auth = new BkperAuth({
69
- onLoginSuccess: () => initializeApp(),
70
- onLoginRequired: () => showLoginButton()
73
+ onLoginSuccess: () => initializeApp(),
74
+ onLoginRequired: () => showLoginButton(),
71
75
  });
72
76
 
73
77
  // Restore session on app load
@@ -75,7 +79,7 @@ await auth.init();
75
79
 
76
80
  // Configure Bkper with web auth
77
81
  Bkper.setConfig({
78
- oauthTokenProvider: async () => auth.getAccessToken()
82
+ oauthTokenProvider: async () => auth.getAccessToken(),
79
83
  });
80
84
 
81
85
  // Create Bkper instance and use it
@@ -91,8 +95,7 @@ API keys are optional and only needed for dedicated quota limits. If not provide
91
95
 
92
96
  ```typescript
93
97
  Bkper.setConfig({
94
- oauthTokenProvider: async () => getOAuthToken(),
95
- apiKeyProvider: async () => process.env.BKPER_API_KEY // Optional - for dedicated quota
98
+ oauthTokenProvider: async () => getOAuthToken(),
99
+ apiKeyProvider: async () => process.env.BKPER_API_KEY, // Optional - for dedicated quota
96
100
  });
97
101
  ```
98
-
package/lib/index.d.ts CHANGED
@@ -13,6 +13,10 @@
13
13
  *
14
14
  * An Account can be grouped by [[Groups]].
15
15
  *
16
+ * @remarks
17
+ * `Account` has no `getBalance()` method. To retrieve account balances, use
18
+ * {@link Book.getBalancesReport} and read the resulting {@link BalancesContainer}.
19
+ *
16
20
  * @public
17
21
  */
18
22
  export declare class Account extends ResourceProperty<bkper.Account> {
@@ -1826,6 +1830,14 @@ export declare class Book extends ResourceProperty<bkper.Book> {
1826
1830
  * @returns The created Accounts
1827
1831
  */
1828
1832
  batchCreateAccounts(accounts: Account[]): Promise<Account[]>;
1833
+ /**
1834
+ * Delete [[Accounts]] on the Book, in batch.
1835
+ *
1836
+ * @param accounts - The accounts to be deleted
1837
+ *
1838
+ * @returns The deleted Accounts
1839
+ */
1840
+ batchDeleteAccounts(accounts: Account[]): Promise<Account[]>;
1829
1841
  /**
1830
1842
  * Create [[Groups]] on the Book, in batch.
1831
1843
  *
@@ -1835,7 +1847,7 @@ export declare class Book extends ResourceProperty<bkper.Book> {
1835
1847
  */
1836
1848
  batchCreateGroups(groups: Group[]): Promise<Group[]>;
1837
1849
  /**
1838
- * Trigger [Balances Audit](https://help.bkper.com/en/articles/4412038-balances-audit) async process.
1850
+ * Trigger Balances Audit async process.
1839
1851
  */
1840
1852
  audit(): void;
1841
1853
  /**
@@ -3230,8 +3242,6 @@ export declare enum Periodicity {
3230
3242
  /**
3231
3243
  * Enum representing permissions of user in the Book
3232
3244
  *
3233
- * Learn more at [share article](https://help.bkper.com/en/articles/2569153-share-your-book-with-your-peers).
3234
- *
3235
3245
  * @public
3236
3246
  */
3237
3247
  export declare enum Permission {
@@ -18,6 +18,10 @@ import { ResourceProperty } from './ResourceProperty.js';
18
18
  *
19
19
  * An Account can be grouped by [[Groups]].
20
20
  *
21
+ * @remarks
22
+ * `Account` has no `getBalance()` method. To retrieve account balances, use
23
+ * {@link Book.getBalancesReport} and read the resulting {@link BalancesContainer}.
24
+ *
21
25
  * @public
22
26
  */
23
27
  export class Account extends ResourceProperty {
package/lib/model/Book.js CHANGED
@@ -574,6 +574,32 @@ export class Book extends ResourceProperty {
574
574
  return [];
575
575
  });
576
576
  }
577
+ /**
578
+ * Delete [[Accounts]] on the Book, in batch.
579
+ *
580
+ * @param accounts - The accounts to be deleted
581
+ *
582
+ * @returns The deleted Accounts
583
+ */
584
+ batchDeleteAccounts(accounts) {
585
+ return __awaiter(this, void 0, void 0, function* () {
586
+ if (accounts.length > 0) {
587
+ const accountList = {
588
+ items: accounts.map(a => a.json()),
589
+ };
590
+ const payloads = yield AccountService.deleteAccounts(this.getId(), accountList, this.getConfig());
591
+ const deletedAccounts = [];
592
+ for (const payload of payloads) {
593
+ const account = new Account(this, payload);
594
+ deletedAccounts.push(account);
595
+ this.setAccount(payload, true);
596
+ }
597
+ this.clearCache();
598
+ return deletedAccounts;
599
+ }
600
+ return [];
601
+ });
602
+ }
577
603
  /**
578
604
  * Create [[Groups]] on the Book, in batch.
579
605
  *
@@ -599,7 +625,7 @@ export class Book extends ResourceProperty {
599
625
  });
600
626
  }
601
627
  /**
602
- * Trigger [Balances Audit](https://help.bkper.com/en/articles/4412038-balances-audit) async process.
628
+ * Trigger Balances Audit async process.
603
629
  */
604
630
  audit() {
605
631
  BookService.audit(this.getId(), this.getConfig());
@@ -37,8 +37,6 @@ export var DecimalSeparator;
37
37
  /**
38
38
  * Enum representing permissions of user in the Book
39
39
  *
40
- * Learn more at [share article](https://help.bkper.com/en/articles/2569153-share-your-book-with-your-peers).
41
- *
42
40
  * @public
43
41
  */
44
42
  export var Permission;
@@ -34,6 +34,13 @@ export function deleteAccount(bookId, account, config) {
34
34
  return response.data;
35
35
  });
36
36
  }
37
+ export function deleteAccounts(bookId, payload, config) {
38
+ return __awaiter(this, void 0, void 0, function* () {
39
+ var _a;
40
+ const response = yield new HttpBooksApiV5Request(`${bookId}/accounts/delete/batch`, config).setMethod('POST').setPayload(payload).fetch();
41
+ return ((_a = response.data) === null || _a === void 0 ? void 0 : _a.items) || [];
42
+ });
43
+ }
37
44
  export function getAccount(bookId, idOrName, config) {
38
45
  return __awaiter(this, void 0, void 0, function* () {
39
46
  let response = yield new HttpBooksApiV5Request(`${bookId}/accounts/${encodeURIComponent(idOrName)}`, config).setMethod('GET').fetch();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bkper-js",
3
- "version": "2.29.3",
3
+ "version": "2.30.0",
4
4
  "description": "Javascript client for Bkper REST API",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.js",
@@ -35,7 +35,7 @@
35
35
  "postversion": "git push --tags && yarn publish --new-version $npm_package_version && git push && echo \"Successfully released version $npm_package_version!\""
36
36
  },
37
37
  "dependencies": {
38
- "@bkper/bkper-api-types": "^5.36.0",
38
+ "@bkper/bkper-api-types": "^5.37.0",
39
39
  "big.js": "^6.0.3",
40
40
  "dayjs": "^1.10.3",
41
41
  "luxon": "^1.25.0",