bkper-js 2.43.1 → 2.43.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
@@ -1821,19 +1821,14 @@ export declare class Book extends ResourceProperty<bkper.Book> {
1821
1821
  */
1822
1822
  batchUntrashTransactions(transactions: Transaction[]): Promise<void>;
1823
1823
  /**
1824
- * Merge two [[Transactions]] into a single new canonical transaction.
1825
- *
1826
- * The merged transaction is created synchronously. Cleanup of the two
1827
- * originals is scheduled asynchronously by the backend.
1828
- *
1829
- * @param transaction1 - The first transaction to merge. Accepts a wrapped
1830
- * [[Transaction]], a plain `bkper.Transaction` payload, or a transaction id.
1831
- * @param transaction2 - The second transaction to merge. Accepts a wrapped
1832
- * [[Transaction]], a plain `bkper.Transaction` payload, or a transaction id.
1824
+ * Merge a primary and secondary [[Transaction]]. Submitted primary fields
1825
+ * have highest precedence; an id string sends no field overrides.
1833
1826
  *
1827
+ * @param primary - Primary Transaction, payload, or id.
1828
+ * @param secondary - Secondary Transaction, payload, or id.
1834
1829
  * @returns The merged Transaction
1835
1830
  */
1836
- mergeTransactions(transaction1: Transaction | bkper.Transaction | string, transaction2: Transaction | bkper.Transaction | string): Promise<Transaction>;
1831
+ mergeTransactions(primary: Transaction | bkper.Transaction | string, secondary: Transaction | bkper.Transaction | string): Promise<Transaction>;
1837
1832
  /**
1838
1833
  * Replay [[Events]] on the Book, in batch.
1839
1834
  *
package/lib/model/Book.js CHANGED
@@ -544,38 +544,33 @@ export class Book extends ResourceProperty {
544
544
  });
545
545
  }
546
546
  /**
547
- * Merge two [[Transactions]] into a single new canonical transaction.
548
- *
549
- * The merged transaction is created synchronously. Cleanup of the two
550
- * originals is scheduled asynchronously by the backend.
551
- *
552
- * @param transaction1 - The first transaction to merge. Accepts a wrapped
553
- * [[Transaction]], a plain `bkper.Transaction` payload, or a transaction id.
554
- * @param transaction2 - The second transaction to merge. Accepts a wrapped
555
- * [[Transaction]], a plain `bkper.Transaction` payload, or a transaction id.
547
+ * Merge a primary and secondary [[Transaction]]. Submitted primary fields
548
+ * have highest precedence; an id string sends no field overrides.
556
549
  *
550
+ * @param primary - Primary Transaction, payload, or id.
551
+ * @param secondary - Secondary Transaction, payload, or id.
557
552
  * @returns The merged Transaction
558
553
  */
559
- mergeTransactions(transaction1, transaction2) {
554
+ mergeTransactions(primary, secondary) {
560
555
  return __awaiter(this, void 0, void 0, function* () {
561
- const transactionId1 = typeof transaction1 === 'string'
562
- ? transaction1
563
- : transaction1 instanceof Transaction
564
- ? transaction1.getId()
565
- : transaction1.id;
566
- if (transactionId1 == null || transactionId1.trim() === '') {
567
- throw new Error('The first transaction must provide an id for merge.');
556
+ const primaryPayload = typeof primary === 'string'
557
+ ? { id: primary }
558
+ : primary instanceof Transaction
559
+ ? primary.json()
560
+ : primary;
561
+ if (primaryPayload.id == null || primaryPayload.id.trim() === '') {
562
+ throw new Error('The primary transaction must provide an id for merge.');
568
563
  }
569
- const transactionId2 = typeof transaction2 === 'string'
570
- ? transaction2
571
- : transaction2 instanceof Transaction
572
- ? transaction2.getId()
573
- : transaction2.id;
574
- if (transactionId2 == null || transactionId2.trim() === '') {
575
- throw new Error('The second transaction must provide an id for merge.');
564
+ const secondaryPayload = typeof secondary === 'string'
565
+ ? { id: secondary }
566
+ : secondary instanceof Transaction
567
+ ? secondary.json()
568
+ : secondary;
569
+ if (secondaryPayload.id == null || secondaryPayload.id.trim() === '') {
570
+ throw new Error('The secondary transaction must provide an id for merge.');
576
571
  }
577
572
  const payload = {
578
- items: [{ id: transactionId1 }, { id: transactionId2 }],
573
+ items: [primaryPayload, secondaryPayload],
579
574
  };
580
575
  let operation = yield TransactionService.mergeTransactions(this.getId(), payload, this.getConfig());
581
576
  return new Transaction(this, operation.transaction || {});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bkper-js",
3
- "version": "2.43.1",
3
+ "version": "2.43.2",
4
4
  "description": "Javascript client for Bkper REST API",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.js",