bkper-js 1.36.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 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
  /**
@@ -1764,6 +1769,20 @@ export declare class Group {
1764
1769
  * @returns This Group, for chainning.
1765
1770
  */
1766
1771
  setName(name: string): Group;
1772
+ /**
1773
+ * Tells if the Group is locked by the Book owner.
1774
+ *
1775
+ * @returns True if the Group is locked.
1776
+ */
1777
+ isLocked(): boolean;
1778
+ /**
1779
+ * Sets the locked state of the Group.
1780
+ *
1781
+ * @param locked - The locked state of the Group.
1782
+ *
1783
+ * @returns This Group, for chainning.
1784
+ */
1785
+ setLocked(locked: boolean): Group;
1767
1786
  /**
1768
1787
  * @returns The name of this group without spaces and special characters
1769
1788
  */
@@ -2237,6 +2256,35 @@ export declare enum Permission {
2237
2256
  OWNER = "OWNER"
2238
2257
  }
2239
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
+
2240
2288
  /**
2241
2289
  * This class defines a Template.
2242
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
@@ -55,6 +55,28 @@ export class Group {
55
55
  this.payload.name = name;
56
56
  return this;
57
57
  }
58
+ /**
59
+ * Tells if the Group is locked by the Book owner.
60
+ *
61
+ * @returns True if the Group is locked.
62
+ */
63
+ isLocked() {
64
+ if (this.payload.locked == null) {
65
+ return false;
66
+ }
67
+ return this.payload.locked;
68
+ }
69
+ /**
70
+ * Sets the locked state of the Group.
71
+ *
72
+ * @param locked - The locked state of the Group.
73
+ *
74
+ * @returns This Group, for chainning.
75
+ */
76
+ setLocked(locked) {
77
+ this.payload.locked = locked;
78
+ return this;
79
+ }
58
80
  /**
59
81
  * @returns The name of this group without spaces and special characters
60
82
  */
@@ -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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bkper-js",
3
- "version": "1.36.0",
3
+ "version": "1.38.0",
4
4
  "description": "Javascript client for Bkper REST API",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.js",