bkper-js 1.37.0 → 1.38.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/lib/index.d.ts +34 -0
- package/lib/index.js +1 -0
- package/lib/model/Book.js +13 -0
- package/lib/model/Query.js +38 -0
- package/lib/service/book-service.js +7 -0
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -724,6 +724,7 @@ export declare class Book {
|
|
|
724
724
|
|
|
725
725
|
|
|
726
726
|
|
|
727
|
+
|
|
727
728
|
constructor(payload?: bkper.Book);
|
|
728
729
|
/**
|
|
729
730
|
* @returns An immutable copy of the json payload
|
|
@@ -1113,6 +1114,10 @@ export declare class Book {
|
|
|
1113
1114
|
* ```
|
|
1114
1115
|
*/
|
|
1115
1116
|
getBalancesReport(query: string): Promise<BalancesReport>;
|
|
1117
|
+
/**
|
|
1118
|
+
* @return The saved queries from this book
|
|
1119
|
+
*/
|
|
1120
|
+
getSavedQueries(): Promise<Query[]>;
|
|
1116
1121
|
}
|
|
1117
1122
|
|
|
1118
1123
|
/**
|
|
@@ -2251,6 +2256,35 @@ export declare enum Permission {
|
|
|
2251
2256
|
OWNER = "OWNER"
|
|
2252
2257
|
}
|
|
2253
2258
|
|
|
2259
|
+
/**
|
|
2260
|
+
* Defines a saved Query in a [[Book]].
|
|
2261
|
+
*
|
|
2262
|
+
* Queries can be saved on Books by users.
|
|
2263
|
+
*
|
|
2264
|
+
* @public
|
|
2265
|
+
*/
|
|
2266
|
+
export declare class Query {
|
|
2267
|
+
payload: bkper.Query;
|
|
2268
|
+
|
|
2269
|
+
constructor(book: Book, payload?: bkper.Query);
|
|
2270
|
+
/**
|
|
2271
|
+
* @returns The wrapped plain json object
|
|
2272
|
+
*/
|
|
2273
|
+
json(): bkper.Query;
|
|
2274
|
+
/**
|
|
2275
|
+
* @returns The Query universal identifier
|
|
2276
|
+
*/
|
|
2277
|
+
getId(): string | undefined;
|
|
2278
|
+
/**
|
|
2279
|
+
* @return The title of this saved Query
|
|
2280
|
+
*/
|
|
2281
|
+
getTitle(): string | undefined;
|
|
2282
|
+
/**
|
|
2283
|
+
* @return This Query string to be executed
|
|
2284
|
+
*/
|
|
2285
|
+
getQuery(): string | undefined;
|
|
2286
|
+
}
|
|
2287
|
+
|
|
2254
2288
|
/**
|
|
2255
2289
|
* This class defines a Template.
|
|
2256
2290
|
*
|
package/lib/index.js
CHANGED
|
@@ -19,6 +19,7 @@ export { File } from './model/File.js';
|
|
|
19
19
|
export { Group } from './model/Group.js';
|
|
20
20
|
export { Integration } from './model/Integration.js';
|
|
21
21
|
export { Message } from './model/Message.js';
|
|
22
|
+
export { Query } from './model/Query.js';
|
|
22
23
|
export { Template } from './model/Template.js';
|
|
23
24
|
export { Transaction } from './model/Transaction.js';
|
|
24
25
|
export { TransactionList } from './model/TransactionList.js';
|
package/lib/model/Book.js
CHANGED
|
@@ -27,6 +27,7 @@ import { Transaction } from './Transaction.js';
|
|
|
27
27
|
import { TransactionList } from './TransactionList.js';
|
|
28
28
|
import { BalancesReport } from './BalancesReport.js';
|
|
29
29
|
import { App } from './App.js';
|
|
30
|
+
import { Query } from './Query.js';
|
|
30
31
|
/**
|
|
31
32
|
*
|
|
32
33
|
* A Book represents [General Ledger](https://en.wikipedia.org/wiki/General_ledger) for a company or business, but can also represent a [Ledger](https://en.wikipedia.org/wiki/Ledger) for a project or department
|
|
@@ -859,5 +860,17 @@ export class Book {
|
|
|
859
860
|
return new BalancesReport(this, balances);
|
|
860
861
|
});
|
|
861
862
|
}
|
|
863
|
+
/**
|
|
864
|
+
* @return The saved queries from this book
|
|
865
|
+
*/
|
|
866
|
+
getSavedQueries() {
|
|
867
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
868
|
+
if (this.queries == null) {
|
|
869
|
+
const queryPayloads = yield BookService.getSavedQueries(this.getId());
|
|
870
|
+
this.queries = queryPayloads.map(payload => new Query(this, payload));
|
|
871
|
+
}
|
|
872
|
+
return this.queries;
|
|
873
|
+
});
|
|
874
|
+
}
|
|
862
875
|
}
|
|
863
876
|
//# sourceMappingURL=Book.js.map
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Defines a saved Query in a [[Book]].
|
|
3
|
+
*
|
|
4
|
+
* Queries can be saved on Books by users.
|
|
5
|
+
*
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export class Query {
|
|
9
|
+
constructor(book, payload) {
|
|
10
|
+
this.book = book;
|
|
11
|
+
this.payload = payload || {};
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* @returns The wrapped plain json object
|
|
15
|
+
*/
|
|
16
|
+
json() {
|
|
17
|
+
return Object.assign({}, this.payload);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* @returns The Query universal identifier
|
|
21
|
+
*/
|
|
22
|
+
getId() {
|
|
23
|
+
return this.payload.id;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* @return The title of this saved Query
|
|
27
|
+
*/
|
|
28
|
+
getTitle() {
|
|
29
|
+
return this.payload.title;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* @return This Query string to be executed
|
|
33
|
+
*/
|
|
34
|
+
getQuery() {
|
|
35
|
+
return this.payload.query;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=Query.js.map
|
|
@@ -56,4 +56,11 @@ 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
|
+
}
|
|
59
66
|
//# sourceMappingURL=book-service.js.map
|