bkper-js 1.38.0 → 1.39.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/lib/index.d.ts +4 -0
- package/lib/model/Book.js +2 -1
- package/lib/model/Query.js +26 -0
- package/lib/service/book-service.js +0 -7
- package/lib/service/query-service.js +24 -0
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
package/lib/model/Book.js
CHANGED
|
@@ -9,6 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import * as AccountService from '../service/account-service.js';
|
|
11
11
|
import * as BookService from '../service/book-service.js';
|
|
12
|
+
import * as QueryService from '../service/query-service.js';
|
|
12
13
|
import * as BalancesService from '../service/balances-service.js';
|
|
13
14
|
import * as FileService from '../service/file-service.js';
|
|
14
15
|
import * as GroupService from '../service/group-service.js';
|
|
@@ -866,7 +867,7 @@ export class Book {
|
|
|
866
867
|
getSavedQueries() {
|
|
867
868
|
return __awaiter(this, void 0, void 0, function* () {
|
|
868
869
|
if (this.queries == null) {
|
|
869
|
-
const queryPayloads = yield
|
|
870
|
+
const queryPayloads = yield QueryService.getSavedQueries(this.getId());
|
|
870
871
|
this.queries = queryPayloads.map(payload => new Query(this, payload));
|
|
871
872
|
}
|
|
872
873
|
return this.queries;
|
package/lib/model/Query.js
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import * as QueryService from '../service/query-service.js';
|
|
1
11
|
/**
|
|
2
12
|
* Defines a saved Query in a [[Book]].
|
|
3
13
|
*
|
|
@@ -34,5 +44,21 @@ export class Query {
|
|
|
34
44
|
getQuery() {
|
|
35
45
|
return this.payload.query;
|
|
36
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* Perform delete group.
|
|
49
|
+
*/
|
|
50
|
+
remove() {
|
|
51
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
+
const queryId = this.getId();
|
|
53
|
+
if (!queryId) {
|
|
54
|
+
throw new Error("Query id null!");
|
|
55
|
+
}
|
|
56
|
+
this.payload = yield QueryService.deleteSavedQuery(this.book.getId(), queryId);
|
|
57
|
+
if (this.book.queries) {
|
|
58
|
+
this.book.queries = this.book.queries.filter(q => q.getId() !== queryId);
|
|
59
|
+
}
|
|
60
|
+
return this;
|
|
61
|
+
});
|
|
62
|
+
}
|
|
37
63
|
}
|
|
38
64
|
//# sourceMappingURL=Query.js.map
|
|
@@ -56,11 +56,4 @@ export function getApps(bookId) {
|
|
|
56
56
|
return ((_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.items) || [];
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
|
-
export function getSavedQueries(bookId) {
|
|
60
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
61
|
-
var _a;
|
|
62
|
-
let response = yield new HttpBooksApiV5Request(`${bookId}/queries`).setMethod('GET').fetch();
|
|
63
|
-
return ((_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.items) || [];
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
59
|
//# sourceMappingURL=book-service.js.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { HttpBooksApiV5Request } from "./http-api-request.js";
|
|
11
|
+
export function getSavedQueries(bookId) {
|
|
12
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
13
|
+
var _a;
|
|
14
|
+
let response = yield new HttpBooksApiV5Request(`${bookId}/queries`).setMethod('GET').fetch();
|
|
15
|
+
return ((_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.items) || [];
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
export function deleteSavedQuery(bookId, queryId) {
|
|
19
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
let response = yield new HttpBooksApiV5Request(`${bookId}/queries/${queryId}`).setMethod('DELETE').fetch();
|
|
21
|
+
return response.data;
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=query-service.js.map
|