bkper-js 2.0.0 → 2.1.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/CHANGELOG.md +0 -1
- package/README.md +5 -2
- package/lib/index.d.ts +15 -7
- package/lib/model/Bkper.js +17 -7
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -8,7 +8,6 @@ See what's new and what has changed in bkper-js
|
|
|
8
8
|
**July 2025**
|
|
9
9
|
* **BREAKING CHANGE:** Refactored `Bkper` class from static methods to constructor-based pattern
|
|
10
10
|
* **BREAKING CHANGE:** Removed deprecated methods: `Transaction.remove()`, `Transaction.restore()`, `Account.getBalance()`, `Account.getBalanceRaw()`
|
|
11
|
-
* **MIGRATION:** Replace `Bkper.setConfig(config); Bkper.getBook(id)` with `const bkper = new Bkper(config); bkper.getBook(id)`
|
|
12
11
|
* **MIGRATION:** Use `transaction.trash()` and `transaction.untrash()` instead of `remove()` and `restore()`
|
|
13
12
|
* **MIGRATION:** Use `Book.getBalancesReport()` instead of `Account.getBalance()` methods
|
|
14
13
|
|
package/README.md
CHANGED
|
@@ -32,12 +32,15 @@ bun add bkper-js
|
|
|
32
32
|
```typescript
|
|
33
33
|
import { Bkper } from 'bkper-js';
|
|
34
34
|
|
|
35
|
-
//
|
|
36
|
-
|
|
35
|
+
// Set global configuration
|
|
36
|
+
Bkper.setConfig({
|
|
37
37
|
apiKeyProvider: () => process.env.BKPER_API_KEY,
|
|
38
38
|
oauthTokenProvider: () => process.env.BKPER_OAUTH_TOKEN
|
|
39
39
|
});
|
|
40
40
|
|
|
41
|
+
// Create Bkper instance (uses global config)
|
|
42
|
+
const bkper = new Bkper();
|
|
43
|
+
|
|
41
44
|
// Get a book and work with it
|
|
42
45
|
const book = await bkper.getBook('your-book-id');
|
|
43
46
|
console.log(`Book: ${book.getName()}`);
|
package/lib/index.d.ts
CHANGED
|
@@ -825,28 +825,36 @@ export declare class BalancesReport {
|
|
|
825
825
|
/**
|
|
826
826
|
* This is the main entry point of the [bkper-js](https://www.npmjs.com/package/bkper-js) library.
|
|
827
827
|
*
|
|
828
|
-
* You start by setting the API [[Config]] object.
|
|
828
|
+
* You start by setting the API [[Config]] object using the static setConfig method.
|
|
829
829
|
*
|
|
830
830
|
* Example:
|
|
831
831
|
*
|
|
832
832
|
* ```javascript
|
|
833
|
-
* Bkper.
|
|
833
|
+
* Bkper.setConfig({
|
|
834
834
|
* apiKeyProvider: () => process.env.BKPER_API_KEY,
|
|
835
835
|
* oauthTokenProvider: () => process.env.BKPER_OAUTH_TOKEN
|
|
836
|
-
* })
|
|
836
|
+
* });
|
|
837
|
+
*
|
|
838
|
+
* const bkper = new Bkper();
|
|
839
|
+
* const book = await bkper.getBook('bookId');
|
|
837
840
|
* ```
|
|
838
841
|
*
|
|
839
|
-
* Once the config is set, you can start using the library.
|
|
842
|
+
* Once the config is set, you can create instances and start using the library.
|
|
840
843
|
*
|
|
841
844
|
* @public
|
|
842
845
|
*/
|
|
843
846
|
export declare class Bkper {
|
|
844
847
|
/**
|
|
845
|
-
*
|
|
848
|
+
* Sets the global API configuration for all Bkper operations.
|
|
846
849
|
*
|
|
847
|
-
* @param config - The Config object
|
|
850
|
+
* @param config - The Config object containing API key and OAuth token providers
|
|
851
|
+
*/
|
|
852
|
+
static setConfig(config: Config): void;
|
|
853
|
+
/**
|
|
854
|
+
* Creates a new Bkper instance using the global configuration set via setConfig().
|
|
855
|
+
* Make sure to call Bkper.setConfig() before creating instances.
|
|
848
856
|
*/
|
|
849
|
-
constructor(
|
|
857
|
+
constructor();
|
|
850
858
|
/**
|
|
851
859
|
* Gets the [[Book]] with the specified bookId from url param.
|
|
852
860
|
*
|
package/lib/model/Bkper.js
CHANGED
|
@@ -24,30 +24,40 @@ import { Agent } from "./Agent.js";
|
|
|
24
24
|
/**
|
|
25
25
|
* This is the main entry point of the [bkper-js](https://www.npmjs.com/package/bkper-js) library.
|
|
26
26
|
*
|
|
27
|
-
* You start by setting the API [[Config]] object.
|
|
27
|
+
* You start by setting the API [[Config]] object using the static setConfig method.
|
|
28
28
|
*
|
|
29
29
|
* Example:
|
|
30
30
|
*
|
|
31
31
|
* ```javascript
|
|
32
|
-
* Bkper.
|
|
32
|
+
* Bkper.setConfig({
|
|
33
33
|
* apiKeyProvider: () => process.env.BKPER_API_KEY,
|
|
34
34
|
* oauthTokenProvider: () => process.env.BKPER_OAUTH_TOKEN
|
|
35
|
-
* })
|
|
35
|
+
* });
|
|
36
|
+
*
|
|
37
|
+
* const bkper = new Bkper();
|
|
38
|
+
* const book = await bkper.getBook('bookId');
|
|
36
39
|
* ```
|
|
37
40
|
*
|
|
38
|
-
* Once the config is set, you can start using the library.
|
|
41
|
+
* Once the config is set, you can create instances and start using the library.
|
|
39
42
|
*
|
|
40
43
|
* @public
|
|
41
44
|
*/
|
|
42
45
|
export class Bkper {
|
|
43
46
|
/**
|
|
44
|
-
*
|
|
47
|
+
* Sets the global API configuration for all Bkper operations.
|
|
45
48
|
*
|
|
46
|
-
* @param config - The Config object
|
|
49
|
+
* @param config - The Config object containing API key and OAuth token providers
|
|
47
50
|
*/
|
|
48
|
-
|
|
51
|
+
static setConfig(config) {
|
|
49
52
|
HttpApiRequest.config = config;
|
|
50
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Creates a new Bkper instance using the global configuration set via setConfig().
|
|
56
|
+
* Make sure to call Bkper.setConfig() before creating instances.
|
|
57
|
+
*/
|
|
58
|
+
constructor() {
|
|
59
|
+
// Uses global configuration set via setConfig()
|
|
60
|
+
}
|
|
51
61
|
/**
|
|
52
62
|
* Gets the [[Book]] with the specified bookId from url param.
|
|
53
63
|
*
|