bkper-js 2.33.0 → 2.33.1
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 +1 -1
- package/dist/bkper.min.js.map +2 -2
- package/lib/index.d.ts +0 -25
- package/lib/model/Bkper.js +14 -39
- package/lib/service/http-api-request.js +4 -1
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -1354,31 +1354,6 @@ export declare class Billing extends Resource<bkper.Billing> {
|
|
|
1354
1354
|
/**
|
|
1355
1355
|
* This is the main entry point of the [bkper-js](https://www.npmjs.com/package/bkper-js) library.
|
|
1356
1356
|
*
|
|
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
1357
|
* @public
|
|
1383
1358
|
*/
|
|
1384
1359
|
export declare class Bkper {
|
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
|
/**
|
|
@@ -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");
|