bkper-js 1.47.1 → 1.47.2

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
@@ -665,9 +665,10 @@ export declare class Bkper {
665
665
  /**
666
666
  * Gets all [[Books]] the user has access to.
667
667
  *
668
+ * @param query - Optional search term to filter books
668
669
  * @returns The retrieved list of Books
669
670
  */
670
- static getBooks(): Promise<Book[]>;
671
+ static getBooks(query?: string): Promise<Book[]>;
671
672
  /**
672
673
  * Gets all [[Collections]] the user has access to.
673
674
  *
@@ -1165,6 +1166,16 @@ export declare class Book {
1165
1166
  * @returns The created Book object
1166
1167
  */
1167
1168
  create(): Promise<Book>;
1169
+ /**
1170
+ * Creates a copy of this Book
1171
+ *
1172
+ * @param name The name for the copied book
1173
+ * @param copyTransactions True to copy transactions from the source book (user must be the Book owner)
1174
+ * @param fromDate Start date to consider if copying transactions (numeric value in YYYYMMDD format)
1175
+ *
1176
+ * @returns The copied Book object
1177
+ */
1178
+ copy(name: string, copyTransactions?: boolean, fromDate?: number): Promise<Book>;
1168
1179
  /**
1169
1180
  * Perform update Book, applying pending changes.
1170
1181
  */
@@ -57,11 +57,12 @@ export class Bkper {
57
57
  /**
58
58
  * Gets all [[Books]] the user has access to.
59
59
  *
60
+ * @param query - Optional search term to filter books
60
61
  * @returns The retrieved list of Books
61
62
  */
62
- static getBooks() {
63
+ static getBooks(query) {
63
64
  return __awaiter(this, void 0, void 0, function* () {
64
- let books = yield BookService.loadBooks();
65
+ let books = yield BookService.loadBooks(query);
65
66
  return books.map(book => new Book(book));
66
67
  });
67
68
  }
package/lib/model/Book.js CHANGED
@@ -958,6 +958,21 @@ export class Book {
958
958
  return this;
959
959
  });
960
960
  }
961
+ /**
962
+ * Creates a copy of this Book
963
+ *
964
+ * @param name The name for the copied book
965
+ * @param copyTransactions True to copy transactions from the source book (user must be the Book owner)
966
+ * @param fromDate Start date to consider if copying transactions (numeric value in YYYYMMDD format)
967
+ *
968
+ * @returns The copied Book object
969
+ */
970
+ copy(name, copyTransactions, fromDate) {
971
+ return __awaiter(this, void 0, void 0, function* () {
972
+ const copiedBookPayload = yield BookService.copyBook(this.getId(), name, copyTransactions, fromDate);
973
+ return new Book(copiedBookPayload);
974
+ });
975
+ }
961
976
  /**
962
977
  * Perform update Book, applying pending changes.
963
978
  */
@@ -8,9 +8,13 @@ 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 loadBooks() {
11
+ export function loadBooks(query) {
12
12
  return __awaiter(this, void 0, void 0, function* () {
13
- let response = yield new HttpBooksApiV5Request('').fetch();
13
+ let request = new HttpBooksApiV5Request('');
14
+ if (query) {
15
+ request.addParam('query', query);
16
+ }
17
+ let response = yield request.fetch();
14
18
  if (response.data == null) {
15
19
  return [];
16
20
  }
@@ -56,4 +60,17 @@ export function getApps(bookId) {
56
60
  return ((_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.items) || [];
57
61
  });
58
62
  }
63
+ export function copyBook(bookId, name, copyTransactions, fromDate) {
64
+ return __awaiter(this, void 0, void 0, function* () {
65
+ const request = new HttpBooksApiV5Request(`${bookId}/copy`).setMethod('POST').addParam('name', name);
66
+ if (copyTransactions) {
67
+ request.addParam('copyTransactions', copyTransactions);
68
+ if (fromDate) {
69
+ request.addParam('fromDate', fromDate);
70
+ }
71
+ }
72
+ const response = yield request.fetch();
73
+ return response.data;
74
+ });
75
+ }
59
76
  //# sourceMappingURL=book-service.js.map
package/lib/utils.js CHANGED
@@ -126,7 +126,6 @@ export function parseDate(date, pattern, timeZone) {
126
126
  }
127
127
  let dateObject = DateTime.fromFormat(date, pattern, { zone: timeZone }).toJSDate();
128
128
  if (dateObject instanceof Date && !isNaN(dateObject.getTime())) {
129
- console.log(dateObject);
130
129
  return dateObject;
131
130
  }
132
131
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bkper-js",
3
- "version": "1.47.1",
3
+ "version": "1.47.2",
4
4
  "description": "Javascript client for Bkper REST API",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.js",
@@ -34,7 +34,7 @@
34
34
  "postversion": "git push --tags && yarn publish --new-version $npm_package_version && git push && echo \"Successfully released version $npm_package_version!\""
35
35
  },
36
36
  "peerDependencies": {
37
- "@bkper/bkper-api-types": "^5.22.0"
37
+ "@bkper/bkper-api-types": "^5.23.0"
38
38
  },
39
39
  "dependencies": {
40
40
  "@google-cloud/local-auth": "^3.0.1",