bkper-js 2.32.2 → 2.33.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
@@ -1821,6 +1821,18 @@ export declare class Book extends ResourceProperty<bkper.Book> {
1821
1821
  * @param transactions - The transactions to be untrashed
1822
1822
  */
1823
1823
  batchUntrashTransactions(transactions: Transaction[]): Promise<void>;
1824
+ /**
1825
+ * Merge two [[Transactions]] into a single new canonical transaction.
1826
+ *
1827
+ * The merged transaction is created synchronously. Cleanup of the two
1828
+ * originals is scheduled asynchronously by the backend.
1829
+ *
1830
+ * @param transaction1 - The first transaction to merge
1831
+ * @param transaction2 - The second transaction to merge
1832
+ *
1833
+ * @returns The merged Transaction
1834
+ */
1835
+ mergeTransactions(transaction1: Transaction, transaction2: Transaction): Promise<Transaction>;
1824
1836
  /**
1825
1837
  * Replay [[Events]] on the Book, in batch.
1826
1838
  *
package/lib/model/Book.js CHANGED
@@ -542,6 +542,26 @@ export class Book extends ResourceProperty {
542
542
  yield TransactionService.untrashTransactionsBatch(this.getId(), transactionPayloads, this.getConfig());
543
543
  });
544
544
  }
545
+ /**
546
+ * Merge two [[Transactions]] into a single new canonical transaction.
547
+ *
548
+ * The merged transaction is created synchronously. Cleanup of the two
549
+ * originals is scheduled asynchronously by the backend.
550
+ *
551
+ * @param transaction1 - The first transaction to merge
552
+ * @param transaction2 - The second transaction to merge
553
+ *
554
+ * @returns The merged Transaction
555
+ */
556
+ mergeTransactions(transaction1, transaction2) {
557
+ return __awaiter(this, void 0, void 0, function* () {
558
+ const payload = {
559
+ items: [transaction1.json(), transaction2.json()],
560
+ };
561
+ let operation = yield TransactionService.mergeTransactions(this.getId(), payload, this.getConfig());
562
+ return new Transaction(this, operation.transaction || {});
563
+ });
564
+ }
545
565
  /**
546
566
  * Replay [[Events]] on the Book, in batch.
547
567
  *
@@ -126,6 +126,13 @@ export function listTransactions(bookId, query, limit, cursor, config) {
126
126
  return response.data;
127
127
  });
128
128
  }
129
+ export function mergeTransactions(bookId, transactions, config) {
130
+ return __awaiter(this, void 0, void 0, function* () {
131
+ const payload = Object.assign({}, transactions);
132
+ const response = yield new HttpBooksApiV5Request(`${bookId}/transactions/merge`, config).setMethod('PATCH').setPayload(payload).fetch();
133
+ return response.data;
134
+ });
135
+ }
129
136
  export function countTransactions(bookId, query, config) {
130
137
  return __awaiter(this, void 0, void 0, function* () {
131
138
  const request = new HttpBooksApiV5Request(`${bookId}/transactions/count`, config).setMethod('GET').addParam('query', query);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bkper-js",
3
- "version": "2.32.2",
3
+ "version": "2.33.0",
4
4
  "description": "Javascript client for Bkper REST API",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.js",
@@ -35,7 +35,7 @@
35
35
  "upgrade:api": "bun update @bkper/bkper-api-types --latest"
36
36
  },
37
37
  "dependencies": {
38
- "@bkper/bkper-api-types": "^5.39.1",
38
+ "@bkper/bkper-api-types": "^5.40.0",
39
39
  "big.js": "^6.0.3",
40
40
  "dayjs": "^1.10.3",
41
41
  "luxon": "^1.25.0",