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/dist/bkper.min.js +1 -1
- package/dist/bkper.min.js.map +3 -3
- package/lib/index.d.ts +5 -10
- package/lib/model/Book.js +20 -25
- package/package.json +1 -1
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
|
|
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(
|
|
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
|
|
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(
|
|
554
|
+
mergeTransactions(primary, secondary) {
|
|
560
555
|
return __awaiter(this, void 0, void 0, function* () {
|
|
561
|
-
const
|
|
562
|
-
?
|
|
563
|
-
:
|
|
564
|
-
?
|
|
565
|
-
:
|
|
566
|
-
if (
|
|
567
|
-
throw new Error('The
|
|
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
|
|
570
|
-
?
|
|
571
|
-
:
|
|
572
|
-
?
|
|
573
|
-
:
|
|
574
|
-
if (
|
|
575
|
-
throw new Error('The
|
|
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: [
|
|
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 || {});
|