bkper-js 2.33.0 → 2.34.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/dist/bkper.min.js +2 -2
- package/dist/bkper.min.js.map +3 -3
- package/lib/index.d.ts +36 -25
- package/lib/index.js +1 -1
- package/lib/model/App.js +22 -0
- package/lib/model/Bkper.js +14 -39
- package/lib/model/Enums.js +20 -0
- package/lib/service/http-api-request.js +4 -1
- package/package.json +6 -3
package/lib/index.d.ts
CHANGED
|
@@ -580,15 +580,31 @@ export declare class App extends Resource<bkper.App> {
|
|
|
580
580
|
* @returns The menu text of this App
|
|
581
581
|
*/
|
|
582
582
|
getMenuText(): string | undefined;
|
|
583
|
+
/**
|
|
584
|
+
* Gets how the app menu opens.
|
|
585
|
+
*
|
|
586
|
+
* @returns The configured app menu open mode, defaults to SIDEBAR
|
|
587
|
+
*/
|
|
588
|
+
getMenuOpenMode(): MenuOpenMode;
|
|
589
|
+
/**
|
|
590
|
+
* Sets how the app menu opens.
|
|
591
|
+
*
|
|
592
|
+
* @param menuOpenMode - The app menu open mode to set
|
|
593
|
+
*
|
|
594
|
+
* @returns This App, for chaining
|
|
595
|
+
*/
|
|
596
|
+
setMenuOpenMode(menuOpenMode?: MenuOpenMode): App;
|
|
583
597
|
/**
|
|
584
598
|
* Gets the menu popup width of this App.
|
|
585
599
|
*
|
|
600
|
+
* @deprecated Use getMenuOpenMode() to decide how the app should open.
|
|
586
601
|
* @returns The menu popup width of this App
|
|
587
602
|
*/
|
|
588
603
|
getMenuPopupWidth(): string | undefined;
|
|
589
604
|
/**
|
|
590
605
|
* Gets the menu popup height of this App.
|
|
591
606
|
*
|
|
607
|
+
* @deprecated Use getMenuOpenMode() to decide how the app should open.
|
|
592
608
|
* @returns The menu popup height of this App
|
|
593
609
|
*/
|
|
594
610
|
getMenuPopupHeight(): string | undefined;
|
|
@@ -1354,31 +1370,6 @@ export declare class Billing extends Resource<bkper.Billing> {
|
|
|
1354
1370
|
/**
|
|
1355
1371
|
* This is the main entry point of the [bkper-js](https://www.npmjs.com/package/bkper-js) library.
|
|
1356
1372
|
*
|
|
1357
|
-
* You can configure the library in two ways:
|
|
1358
|
-
*
|
|
1359
|
-
* 1. Using static configuration (traditional approach):
|
|
1360
|
-
*
|
|
1361
|
-
* ```typescript
|
|
1362
|
-
* Bkper.setConfig({
|
|
1363
|
-
* apiKeyProvider: () => process.env.BKPER_API_KEY,
|
|
1364
|
-
* oauthTokenProvider: () => process.env.BKPER_OAUTH_TOKEN
|
|
1365
|
-
* });
|
|
1366
|
-
*
|
|
1367
|
-
* const bkper = new Bkper();
|
|
1368
|
-
* const book = await bkper.getBook('bookId');
|
|
1369
|
-
* ```
|
|
1370
|
-
*
|
|
1371
|
-
* 2. Using per-instance configuration (recommended for Cloudflare Workers):
|
|
1372
|
-
*
|
|
1373
|
-
* ```typescript
|
|
1374
|
-
* const bkper = new Bkper({
|
|
1375
|
-
* apiKeyProvider: () => process.env.BKPER_API_KEY,
|
|
1376
|
-
* oauthTokenProvider: () => process.env.BKPER_OAUTH_TOKEN
|
|
1377
|
-
* });
|
|
1378
|
-
*
|
|
1379
|
-
* const book = await bkper.getBook('bookId');
|
|
1380
|
-
* ```
|
|
1381
|
-
*
|
|
1382
1373
|
* @public
|
|
1383
1374
|
*/
|
|
1384
1375
|
export declare class Bkper {
|
|
@@ -3206,6 +3197,26 @@ export declare class Integration extends ResourceProperty<bkper.Integration> {
|
|
|
3206
3197
|
remove(): Promise<Integration>;
|
|
3207
3198
|
}
|
|
3208
3199
|
|
|
3200
|
+
/**
|
|
3201
|
+
* Enum that represents how an App menu opens.
|
|
3202
|
+
*
|
|
3203
|
+
* @public
|
|
3204
|
+
*/
|
|
3205
|
+
export declare enum MenuOpenMode {
|
|
3206
|
+
/**
|
|
3207
|
+
* Open inside the sidebar panel.
|
|
3208
|
+
*/
|
|
3209
|
+
SIDEBAR = "SIDEBAR",
|
|
3210
|
+
/**
|
|
3211
|
+
* Open expanded inside the app panel.
|
|
3212
|
+
*/
|
|
3213
|
+
EXPANDED = "EXPANDED",
|
|
3214
|
+
/**
|
|
3215
|
+
* Open in a new browser tab.
|
|
3216
|
+
*/
|
|
3217
|
+
NEW_TAB = "NEW_TAB"
|
|
3218
|
+
}
|
|
3219
|
+
|
|
3209
3220
|
/**
|
|
3210
3221
|
* Enum that represents a Month.
|
|
3211
3222
|
*
|
package/lib/index.js
CHANGED
|
@@ -34,6 +34,6 @@ export { Event } from './model/Event.js';
|
|
|
34
34
|
export { BotResponse } from './model/BotResponse.js';
|
|
35
35
|
export { EventList } from './model/EventList.js';
|
|
36
36
|
export { User } from './model/User.js';
|
|
37
|
-
export { Periodicity, DecimalSeparator, Permission, Visibility, AccountType, BalanceType, Period, Month, EventType, BotResponseType, TransactionStatus, } from './model/Enums.js';
|
|
37
|
+
export { Periodicity, DecimalSeparator, Permission, Visibility, AccountType, BalanceType, Period, Month, EventType, BotResponseType, TransactionStatus, MenuOpenMode, } from './model/Enums.js';
|
|
38
38
|
export { BkperError } from './model/BkperError.js';
|
|
39
39
|
//# sourceMappingURL=index.js.map
|
package/lib/model/App.js
CHANGED
|
@@ -8,6 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import * as AppService from "../service/app-service.js";
|
|
11
|
+
import { MenuOpenMode } from "./Enums.js";
|
|
11
12
|
import { Resource } from "./Resource.js";
|
|
12
13
|
import { Bkper } from "./Bkper.js";
|
|
13
14
|
/**
|
|
@@ -153,9 +154,29 @@ export class App extends Resource {
|
|
|
153
154
|
getMenuText() {
|
|
154
155
|
return this.payload.menuText;
|
|
155
156
|
}
|
|
157
|
+
/**
|
|
158
|
+
* Gets how the app menu opens.
|
|
159
|
+
*
|
|
160
|
+
* @returns The configured app menu open mode, defaults to SIDEBAR
|
|
161
|
+
*/
|
|
162
|
+
getMenuOpenMode() {
|
|
163
|
+
return this.payload.menuOpenMode || MenuOpenMode.SIDEBAR;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Sets how the app menu opens.
|
|
167
|
+
*
|
|
168
|
+
* @param menuOpenMode - The app menu open mode to set
|
|
169
|
+
*
|
|
170
|
+
* @returns This App, for chaining
|
|
171
|
+
*/
|
|
172
|
+
setMenuOpenMode(menuOpenMode) {
|
|
173
|
+
this.payload.menuOpenMode = menuOpenMode;
|
|
174
|
+
return this;
|
|
175
|
+
}
|
|
156
176
|
/**
|
|
157
177
|
* Gets the menu popup width of this App.
|
|
158
178
|
*
|
|
179
|
+
* @deprecated Use getMenuOpenMode() to decide how the app should open.
|
|
159
180
|
* @returns The menu popup width of this App
|
|
160
181
|
*/
|
|
161
182
|
getMenuPopupWidth() {
|
|
@@ -164,6 +185,7 @@ export class App extends Resource {
|
|
|
164
185
|
/**
|
|
165
186
|
* Gets the menu popup height of this App.
|
|
166
187
|
*
|
|
188
|
+
* @deprecated Use getMenuOpenMode() to decide how the app should open.
|
|
167
189
|
* @returns The menu popup height of this App
|
|
168
190
|
*/
|
|
169
191
|
getMenuPopupHeight() {
|
package/lib/model/Bkper.js
CHANGED
|
@@ -7,44 +7,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import { Book } from
|
|
11
|
-
import { App } from
|
|
12
|
-
import * as AppService from
|
|
13
|
-
import * as BookService from
|
|
14
|
-
import * as CollectionService from
|
|
15
|
-
import * as UserService from
|
|
16
|
-
import * as TemplateService from
|
|
17
|
-
import { User } from
|
|
18
|
-
import { Template } from
|
|
19
|
-
import { Collection } from
|
|
10
|
+
import { Book } from './Book.js';
|
|
11
|
+
import { App } from './App.js';
|
|
12
|
+
import * as AppService from '../service/app-service.js';
|
|
13
|
+
import * as BookService from '../service/book-service.js';
|
|
14
|
+
import * as CollectionService from '../service/collection-service.js';
|
|
15
|
+
import * as UserService from '../service/user-service.js';
|
|
16
|
+
import * as TemplateService from '../service/template-service.js';
|
|
17
|
+
import { User } from './User.js';
|
|
18
|
+
import { Template } from './Template.js';
|
|
19
|
+
import { Collection } from './Collection.js';
|
|
20
20
|
/**
|
|
21
21
|
* This is the main entry point of the [bkper-js](https://www.npmjs.com/package/bkper-js) library.
|
|
22
22
|
*
|
|
23
|
-
* You can configure the library in two ways:
|
|
24
|
-
*
|
|
25
|
-
* 1. Using static configuration (traditional approach):
|
|
26
|
-
*
|
|
27
|
-
* ```typescript
|
|
28
|
-
* Bkper.setConfig({
|
|
29
|
-
* apiKeyProvider: () => process.env.BKPER_API_KEY,
|
|
30
|
-
* oauthTokenProvider: () => process.env.BKPER_OAUTH_TOKEN
|
|
31
|
-
* });
|
|
32
|
-
*
|
|
33
|
-
* const bkper = new Bkper();
|
|
34
|
-
* const book = await bkper.getBook('bookId');
|
|
35
|
-
* ```
|
|
36
|
-
*
|
|
37
|
-
* 2. Using per-instance configuration (recommended for Cloudflare Workers):
|
|
38
|
-
*
|
|
39
|
-
* ```typescript
|
|
40
|
-
* const bkper = new Bkper({
|
|
41
|
-
* apiKeyProvider: () => process.env.BKPER_API_KEY,
|
|
42
|
-
* oauthTokenProvider: () => process.env.BKPER_OAUTH_TOKEN
|
|
43
|
-
* });
|
|
44
|
-
*
|
|
45
|
-
* const book = await bkper.getBook('bookId');
|
|
46
|
-
* ```
|
|
47
|
-
*
|
|
48
23
|
* @public
|
|
49
24
|
*/
|
|
50
25
|
export class Bkper {
|
|
@@ -105,7 +80,7 @@ export class Bkper {
|
|
|
105
80
|
getBooks(query) {
|
|
106
81
|
return __awaiter(this, void 0, void 0, function* () {
|
|
107
82
|
let books = yield BookService.loadBooks(query, this.config);
|
|
108
|
-
return books.map(
|
|
83
|
+
return books.map(book => new Book(book, this.config));
|
|
109
84
|
});
|
|
110
85
|
}
|
|
111
86
|
/**
|
|
@@ -116,7 +91,7 @@ export class Bkper {
|
|
|
116
91
|
getCollections() {
|
|
117
92
|
return __awaiter(this, void 0, void 0, function* () {
|
|
118
93
|
let collections = yield CollectionService.loadCollections(this.config);
|
|
119
|
-
return collections.map(
|
|
94
|
+
return collections.map(collection => new Collection(collection, this.config));
|
|
120
95
|
});
|
|
121
96
|
}
|
|
122
97
|
/**
|
|
@@ -127,7 +102,7 @@ export class Bkper {
|
|
|
127
102
|
getApps() {
|
|
128
103
|
return __awaiter(this, void 0, void 0, function* () {
|
|
129
104
|
let apps = yield AppService.getApps(this.config);
|
|
130
|
-
return apps.map(
|
|
105
|
+
return apps.map(app => new App(app, this.config));
|
|
131
106
|
});
|
|
132
107
|
}
|
|
133
108
|
/**
|
|
@@ -151,7 +126,7 @@ export class Bkper {
|
|
|
151
126
|
getTemplates() {
|
|
152
127
|
return __awaiter(this, void 0, void 0, function* () {
|
|
153
128
|
let templates = yield TemplateService.getTemplates(this.config);
|
|
154
|
-
return templates.map(
|
|
129
|
+
return templates.map(template => new Template(template, this.config));
|
|
155
130
|
});
|
|
156
131
|
}
|
|
157
132
|
/**
|
package/lib/model/Enums.js
CHANGED
|
@@ -190,6 +190,26 @@ export var TransactionStatus;
|
|
|
190
190
|
*/
|
|
191
191
|
TransactionStatus["CHECKED"] = "CHECKED";
|
|
192
192
|
})(TransactionStatus || (TransactionStatus = {}));
|
|
193
|
+
/**
|
|
194
|
+
* Enum that represents how an App menu opens.
|
|
195
|
+
*
|
|
196
|
+
* @public
|
|
197
|
+
*/
|
|
198
|
+
export var MenuOpenMode;
|
|
199
|
+
(function (MenuOpenMode) {
|
|
200
|
+
/**
|
|
201
|
+
* Open inside the sidebar panel.
|
|
202
|
+
*/
|
|
203
|
+
MenuOpenMode["SIDEBAR"] = "SIDEBAR";
|
|
204
|
+
/**
|
|
205
|
+
* Open expanded inside the app panel.
|
|
206
|
+
*/
|
|
207
|
+
MenuOpenMode["EXPANDED"] = "EXPANDED";
|
|
208
|
+
/**
|
|
209
|
+
* Open in a new browser tab.
|
|
210
|
+
*/
|
|
211
|
+
MenuOpenMode["NEW_TAB"] = "NEW_TAB";
|
|
212
|
+
})(MenuOpenMode || (MenuOpenMode = {}));
|
|
193
213
|
/**
|
|
194
214
|
* Enum that represents the type of a Bot Response
|
|
195
215
|
*
|
|
@@ -103,7 +103,10 @@ export class HttpApiRequest extends HttpRequest {
|
|
|
103
103
|
});
|
|
104
104
|
}
|
|
105
105
|
shouldRetry(status) {
|
|
106
|
-
|
|
106
|
+
// 401/403 are included so consumers can refresh the OAuth token via
|
|
107
|
+
// requestRetryHandler and have the request re-issued. The retry cap
|
|
108
|
+
// (this.retry < 3) prevents loops on permanent auth failures.
|
|
109
|
+
return status == 401 || status == 403 || status == 408 || status == 429 || (status != null && status >= 500);
|
|
107
110
|
}
|
|
108
111
|
isNetworkError(error) {
|
|
109
112
|
return error instanceof TypeError && error.message.toLowerCase().includes("fetch");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bkper-js",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.34.0",
|
|
4
4
|
"description": "Javascript client for Bkper REST API",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"module": "./lib/index.js",
|
|
@@ -32,10 +32,13 @@
|
|
|
32
32
|
"build:clean-dist": "rimraf dist",
|
|
33
33
|
"build:bundle": "esbuild lib/index.js --bundle --format=iife --global-name=bkperjs --minify --sourcemap --target=es2015 --platform=browser --outfile=dist/bkper.min.js",
|
|
34
34
|
"dev": "tsc -w",
|
|
35
|
-
"upgrade:api": "bun update @bkper/bkper-api-types --latest"
|
|
35
|
+
"upgrade:api": "bun update @bkper/bkper-api-types --latest",
|
|
36
|
+
"release:patch": "npm version patch -m \"chore(release): v%s\"",
|
|
37
|
+
"release:minor": "npm version minor -m \"chore(release): v%s\"",
|
|
38
|
+
"release:major": "npm version major -m \"chore(release): v%s\""
|
|
36
39
|
},
|
|
37
40
|
"dependencies": {
|
|
38
|
-
"@bkper/bkper-api-types": "^5.40.
|
|
41
|
+
"@bkper/bkper-api-types": "^5.40.2",
|
|
39
42
|
"big.js": "^6.0.3",
|
|
40
43
|
"dayjs": "^1.10.3",
|
|
41
44
|
"luxon": "^1.25.0",
|