bkper-js 2.17.1 → 2.18.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 +16 -0
- package/lib/index.d.ts +11 -2
- package/lib/model/Bkper.js +4 -2
- package/lib/service/http-api-request.js +12 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,22 @@ See what's new and what has changed in bkper-js
|
|
|
4
4
|
|
|
5
5
|
## 2025
|
|
6
6
|
|
|
7
|
+
**December 2025**
|
|
8
|
+
- Added `File.update`
|
|
9
|
+
- Added `EventType.FILE_UPDATED`
|
|
10
|
+
|
|
11
|
+
**November 2025**
|
|
12
|
+
- **v2.15.2 - INTERNAL REFACTOR:**
|
|
13
|
+
- Introduced `ResourceProperty` abstract class for model entities that support custom properties
|
|
14
|
+
- Moved shared property methods to ResourceProperty
|
|
15
|
+
- Refactor 7 model classes to extend ResourceProperty instead of Resource
|
|
16
|
+
- Eliminate ~350 lines of duplicated property management code
|
|
17
|
+
- Maintained full backward compatibility - no breaking changes to existing APIs
|
|
18
|
+
- Added `ResourceProperty.setVisibleProperty`
|
|
19
|
+
- Added `ResourceProperty.setVisibleProperties`
|
|
20
|
+
- Added `ResourceProperty.getVisibleProperties`
|
|
21
|
+
- Added `Bkper.getConfig`
|
|
22
|
+
|
|
7
23
|
**October 2025**
|
|
8
24
|
|
|
9
25
|
- Files attached to transactions are now created internally when transaction is persisted
|
package/lib/index.d.ts
CHANGED
|
@@ -1159,7 +1159,8 @@ export declare enum BalanceType {
|
|
|
1159
1159
|
* You can configure the library in two ways:
|
|
1160
1160
|
*
|
|
1161
1161
|
* 1. Using static configuration (traditional approach):
|
|
1162
|
-
*
|
|
1162
|
+
*
|
|
1163
|
+
* ```typescript
|
|
1163
1164
|
* Bkper.setConfig({
|
|
1164
1165
|
* apiKeyProvider: () => process.env.BKPER_API_KEY,
|
|
1165
1166
|
* oauthTokenProvider: () => process.env.BKPER_OAUTH_TOKEN
|
|
@@ -1170,7 +1171,8 @@ export declare enum BalanceType {
|
|
|
1170
1171
|
* ```
|
|
1171
1172
|
*
|
|
1172
1173
|
* 2. Using per-instance configuration (recommended for Cloudflare Workers):
|
|
1173
|
-
*
|
|
1174
|
+
*
|
|
1175
|
+
* ```typescript
|
|
1174
1176
|
* const bkper = new Bkper({
|
|
1175
1177
|
* apiKeyProvider: () => process.env.BKPER_API_KEY,
|
|
1176
1178
|
* oauthTokenProvider: () => process.env.BKPER_OAUTH_TOKEN
|
|
@@ -2132,6 +2134,13 @@ export declare interface Config {
|
|
|
2132
2134
|
* Issue a valid OAuth2 access token with **https://www.googleapis.com/auth/userinfo.email** scope authorized.
|
|
2133
2135
|
*/
|
|
2134
2136
|
oauthTokenProvider?: () => Promise<string | undefined>;
|
|
2137
|
+
/**
|
|
2138
|
+
* Provides the agent ID to identify the calling agent for attribution purposes.
|
|
2139
|
+
*
|
|
2140
|
+
* This ID is sent via the `bkper-agent-id` header with each API request,
|
|
2141
|
+
* allowing the server to attribute actions to the correct agent.
|
|
2142
|
+
*/
|
|
2143
|
+
agentIdProvider?: () => Promise<string | undefined>;
|
|
2135
2144
|
/**
|
|
2136
2145
|
* Provides additional headers to append to the API request
|
|
2137
2146
|
*/
|
package/lib/model/Bkper.js
CHANGED
|
@@ -23,7 +23,8 @@ import { Collection } from "./Collection.js";
|
|
|
23
23
|
* You can configure the library in two ways:
|
|
24
24
|
*
|
|
25
25
|
* 1. Using static configuration (traditional approach):
|
|
26
|
-
*
|
|
26
|
+
*
|
|
27
|
+
* ```typescript
|
|
27
28
|
* Bkper.setConfig({
|
|
28
29
|
* apiKeyProvider: () => process.env.BKPER_API_KEY,
|
|
29
30
|
* oauthTokenProvider: () => process.env.BKPER_OAUTH_TOKEN
|
|
@@ -34,7 +35,8 @@ import { Collection } from "./Collection.js";
|
|
|
34
35
|
* ```
|
|
35
36
|
*
|
|
36
37
|
* 2. Using per-instance configuration (recommended for Cloudflare Workers):
|
|
37
|
-
*
|
|
38
|
+
*
|
|
39
|
+
* ```typescript
|
|
38
40
|
* const bkper = new Bkper({
|
|
39
41
|
* apiKeyProvider: () => process.env.BKPER_API_KEY,
|
|
40
42
|
* oauthTokenProvider: () => process.env.BKPER_OAUTH_TOKEN
|
|
@@ -21,6 +21,7 @@ export class HttpApiRequest extends HttpRequest {
|
|
|
21
21
|
});
|
|
22
22
|
return __awaiter(this, void 0, void 0, function* () {
|
|
23
23
|
this.addCustomHeaders();
|
|
24
|
+
yield this.addAgentIdHeader();
|
|
24
25
|
this.setHeader("Authorization", `Bearer ${yield this.getAccessToken()}`);
|
|
25
26
|
this.addParam("key", yield this.getApiKey());
|
|
26
27
|
try {
|
|
@@ -108,6 +109,17 @@ export class HttpApiRequest extends HttpRequest {
|
|
|
108
109
|
}
|
|
109
110
|
});
|
|
110
111
|
}
|
|
112
|
+
addAgentIdHeader() {
|
|
113
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
114
|
+
const effectiveConfig = this.config;
|
|
115
|
+
if (effectiveConfig.agentIdProvider) {
|
|
116
|
+
const agentId = yield effectiveConfig.agentIdProvider();
|
|
117
|
+
if (agentId) {
|
|
118
|
+
this.setHeader('bkper-agent-id', agentId);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
}
|
|
111
123
|
getApiKey() {
|
|
112
124
|
return __awaiter(this, void 0, void 0, function* () {
|
|
113
125
|
const effectiveConfig = this.config;
|