bkper-js 2.41.1 → 2.42.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 +18 -0
- package/lib/model/Bkper.js +14 -0
- package/lib/model/Book.js +15 -0
- package/lib/service/collaborator-service.js +28 -3
- package/package.json +2 -2
package/lib/index.d.ts
CHANGED
|
@@ -1419,6 +1419,14 @@ export declare class Bkper {
|
|
|
1419
1419
|
* @returns The retrieved list of Books
|
|
1420
1420
|
*/
|
|
1421
1421
|
getBooks(query?: string): Promise<Book[]>;
|
|
1422
|
+
/**
|
|
1423
|
+
* Requests access to a Book the current user cannot access.
|
|
1424
|
+
*
|
|
1425
|
+
* @param bookId - The universal Book id
|
|
1426
|
+
* @param permission - The permission requested in the Book
|
|
1427
|
+
* @param message - An optional message to the Book owner
|
|
1428
|
+
*/
|
|
1429
|
+
requestBookAccess(bookId: string, permission: Permission, message?: string): Promise<void>;
|
|
1422
1430
|
/**
|
|
1423
1431
|
* Gets all [[Collections]] the user has access to.
|
|
1424
1432
|
*
|
|
@@ -2133,6 +2141,16 @@ export declare class Book extends ResourceProperty<bkper.Book> {
|
|
|
2133
2141
|
* @returns The saved queries from this book
|
|
2134
2142
|
*/
|
|
2135
2143
|
getSavedQueries(): Promise<Query[]>;
|
|
2144
|
+
/**
|
|
2145
|
+
* Resolves an access request for this Book.
|
|
2146
|
+
*
|
|
2147
|
+
* Resolving the request does not grant access. Call Collaborator.create
|
|
2148
|
+
* on the returned Collaborator to grant access to the Book.
|
|
2149
|
+
*
|
|
2150
|
+
* @param accessRequestId - The access request id
|
|
2151
|
+
* @returns The matching [[Collaborator]] object
|
|
2152
|
+
*/
|
|
2153
|
+
resolveAccessRequest(accessRequestId: string): Promise<Collaborator>;
|
|
2136
2154
|
/**
|
|
2137
2155
|
* Gets all collaborators of this Book.
|
|
2138
2156
|
*
|
package/lib/model/Bkper.js
CHANGED
|
@@ -12,6 +12,7 @@ import { App } from './App.js';
|
|
|
12
12
|
import * as AppService from '../service/app-service.js';
|
|
13
13
|
import * as BookService from '../service/book-service.js';
|
|
14
14
|
import * as CollectionService from '../service/collection-service.js';
|
|
15
|
+
import * as CollaboratorService from '../service/collaborator-service.js';
|
|
15
16
|
import * as UserService from '../service/user-service.js';
|
|
16
17
|
import * as TemplateService from '../service/template-service.js';
|
|
17
18
|
import { User } from './User.js';
|
|
@@ -83,6 +84,19 @@ export class Bkper {
|
|
|
83
84
|
return books.map(book => new Book(book, this.config));
|
|
84
85
|
});
|
|
85
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* Requests access to a Book the current user cannot access.
|
|
89
|
+
*
|
|
90
|
+
* @param bookId - The universal Book id
|
|
91
|
+
* @param permission - The permission requested in the Book
|
|
92
|
+
* @param message - An optional message to the Book owner
|
|
93
|
+
*/
|
|
94
|
+
requestBookAccess(bookId, permission, message) {
|
|
95
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
96
|
+
const trimmedMessage = message === null || message === void 0 ? void 0 : message.trim();
|
|
97
|
+
yield CollaboratorService.requestBookAccess(bookId, permission, trimmedMessage || undefined, this.config);
|
|
98
|
+
});
|
|
99
|
+
}
|
|
86
100
|
/**
|
|
87
101
|
* Gets all [[Collections]] the user has access to.
|
|
88
102
|
*
|
package/lib/model/Book.js
CHANGED
|
@@ -1330,6 +1330,21 @@ export class Book extends ResourceProperty {
|
|
|
1330
1330
|
return this.queries;
|
|
1331
1331
|
});
|
|
1332
1332
|
}
|
|
1333
|
+
/**
|
|
1334
|
+
* Resolves an access request for this Book.
|
|
1335
|
+
*
|
|
1336
|
+
* Resolving the request does not grant access. Call Collaborator.create
|
|
1337
|
+
* on the returned Collaborator to grant access to the Book.
|
|
1338
|
+
*
|
|
1339
|
+
* @param accessRequestId - The access request id
|
|
1340
|
+
* @returns The matching [[Collaborator]] object
|
|
1341
|
+
*/
|
|
1342
|
+
resolveAccessRequest(accessRequestId) {
|
|
1343
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1344
|
+
const payload = yield CollaboratorService.resolveBookAccessRequest(this.getId(), accessRequestId, this.getConfig());
|
|
1345
|
+
return new Collaborator(this, payload);
|
|
1346
|
+
});
|
|
1347
|
+
}
|
|
1333
1348
|
/**
|
|
1334
1349
|
* Gets all collaborators of this Book.
|
|
1335
1350
|
*
|
|
@@ -8,16 +8,39 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { HttpBooksApiV5Request } from './http-api-request.js';
|
|
11
|
+
export function requestBookAccess(bookId, permission, message, config) {
|
|
12
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
13
|
+
let request = new HttpBooksApiV5Request(`${bookId}/collaborators/request`, config)
|
|
14
|
+
.setMethod('POST')
|
|
15
|
+
.addParam('permission', permission);
|
|
16
|
+
if (message) {
|
|
17
|
+
request = request.addParam('message', message);
|
|
18
|
+
}
|
|
19
|
+
yield request.fetch();
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
export function resolveBookAccessRequest(bookId, accessRequestId, config) {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
const response = yield new HttpBooksApiV5Request(`${bookId}/collaborators/request/${encodeURIComponent(accessRequestId)}`, config)
|
|
25
|
+
.setMethod('GET')
|
|
26
|
+
.fetch();
|
|
27
|
+
return response.data;
|
|
28
|
+
});
|
|
29
|
+
}
|
|
11
30
|
export function listCollaborators(bookId, config) {
|
|
12
31
|
return __awaiter(this, void 0, void 0, function* () {
|
|
13
32
|
var _a;
|
|
14
|
-
const response = yield new HttpBooksApiV5Request(`${bookId}/collaborators`, config)
|
|
33
|
+
const response = yield new HttpBooksApiV5Request(`${bookId}/collaborators`, config)
|
|
34
|
+
.setMethod('GET')
|
|
35
|
+
.fetch();
|
|
15
36
|
return ((_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.items) || [];
|
|
16
37
|
});
|
|
17
38
|
}
|
|
18
39
|
export function addOrUpdateCollaborator(bookId, collaborator, message, config) {
|
|
19
40
|
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
-
let request = new HttpBooksApiV5Request(`${bookId}/collaborators`, config)
|
|
41
|
+
let request = new HttpBooksApiV5Request(`${bookId}/collaborators`, config)
|
|
42
|
+
.setMethod('POST')
|
|
43
|
+
.setPayload(collaborator);
|
|
21
44
|
if (message) {
|
|
22
45
|
request = request.addParam('message', message);
|
|
23
46
|
}
|
|
@@ -27,7 +50,9 @@ export function addOrUpdateCollaborator(bookId, collaborator, message, config) {
|
|
|
27
50
|
}
|
|
28
51
|
export function removeCollaborator(bookId, email, config) {
|
|
29
52
|
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
-
const response = yield new HttpBooksApiV5Request(`${bookId}/collaborators/${email}`, config)
|
|
53
|
+
const response = yield new HttpBooksApiV5Request(`${bookId}/collaborators/${email}`, config)
|
|
54
|
+
.setMethod('DELETE')
|
|
55
|
+
.fetch();
|
|
31
56
|
return response.data;
|
|
32
57
|
});
|
|
33
58
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bkper-js",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.42.0",
|
|
4
4
|
"description": "Javascript client for Bkper REST API",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"module": "./lib/index.js",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"release:major": "npm version major -m \"chore(release): v%s\""
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@bkper/bkper-api-types": "^5.
|
|
41
|
+
"@bkper/bkper-api-types": "^5.44.0",
|
|
42
42
|
"big.js": "^6.0.3",
|
|
43
43
|
"dayjs": "^1.10.3",
|
|
44
44
|
"luxon": "^1.25.0",
|