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 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
- // Create Bkper instance with configuration
36
- const bkper = new Bkper({
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.get().setConfig({
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
- * Creates a new Bkper instance with the specified API configuration.
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(config: Config);
857
+ constructor();
850
858
  /**
851
859
  * Gets the [[Book]] with the specified bookId from url param.
852
860
  *
@@ -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.get().setConfig({
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
- * Creates a new Bkper instance with the specified API configuration.
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
- constructor(config) {
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
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bkper-js",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
4
4
  "description": "Javascript client for Bkper REST API",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.js",