bkper 4.0.1 → 4.1.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/CHANGELOG.md +51 -28
- package/README.md +52 -4
- package/lib/auth/local-auth-service.d.ts +12 -0
- package/lib/auth/local-auth-service.d.ts.map +1 -1
- package/lib/auth/local-auth-service.js +12 -0
- package/lib/auth/local-auth-service.js.map +1 -1
- package/lib/bkper-factory.d.ts.map +1 -1
- package/lib/bkper-factory.js +5 -0
- package/lib/bkper-factory.js.map +1 -1
- package/lib/cli.js +19 -881
- package/lib/cli.js.map +1 -1
- package/lib/commands/accounts/batch-create.d.ts +10 -0
- package/lib/commands/accounts/batch-create.d.ts.map +1 -0
- package/lib/commands/accounts/batch-create.js +74 -0
- package/lib/commands/accounts/batch-create.js.map +1 -0
- package/lib/commands/accounts/create.d.ts +17 -0
- package/lib/commands/accounts/create.d.ts.map +1 -1
- package/lib/commands/accounts/create.js +24 -5
- package/lib/commands/accounts/create.js.map +1 -1
- package/lib/commands/accounts/delete.d.ts +8 -0
- package/lib/commands/accounts/delete.d.ts.map +1 -1
- package/lib/commands/accounts/delete.js +8 -0
- package/lib/commands/accounts/delete.js.map +1 -1
- package/lib/commands/accounts/get.d.ts +8 -0
- package/lib/commands/accounts/get.d.ts.map +1 -1
- package/lib/commands/accounts/get.js +8 -0
- package/lib/commands/accounts/get.js.map +1 -1
- package/lib/commands/accounts/index.d.ts +2 -1
- package/lib/commands/accounts/index.d.ts.map +1 -1
- package/lib/commands/accounts/index.js +2 -1
- package/lib/commands/accounts/index.js.map +1 -1
- package/lib/commands/accounts/list.d.ts +12 -0
- package/lib/commands/accounts/list.d.ts.map +1 -1
- package/lib/commands/accounts/list.js +25 -0
- package/lib/commands/accounts/list.js.map +1 -1
- package/lib/commands/accounts/register.d.ts +3 -0
- package/lib/commands/accounts/register.d.ts.map +1 -0
- package/lib/commands/accounts/register.js +96 -0
- package/lib/commands/accounts/register.js.map +1 -0
- package/lib/commands/accounts/update.d.ts +18 -0
- package/lib/commands/accounts/update.d.ts.map +1 -1
- package/lib/commands/accounts/update.js +23 -5
- package/lib/commands/accounts/update.js.map +1 -1
- package/lib/commands/action.d.ts +21 -0
- package/lib/commands/action.d.ts.map +1 -0
- package/lib/commands/action.js +36 -0
- package/lib/commands/action.js.map +1 -0
- package/lib/commands/apps/index.d.ts +1 -1
- package/lib/commands/apps/index.d.ts.map +1 -1
- package/lib/commands/apps/index.js +1 -1
- package/lib/commands/apps/index.js.map +1 -1
- package/lib/commands/apps/install.d.ts +7 -0
- package/lib/commands/apps/install.d.ts.map +1 -1
- package/lib/commands/apps/install.js +7 -0
- package/lib/commands/apps/install.js.map +1 -1
- package/lib/commands/apps/list.d.ts +6 -0
- package/lib/commands/apps/list.d.ts.map +1 -1
- package/lib/commands/apps/list.js +20 -0
- package/lib/commands/apps/list.js.map +1 -1
- package/lib/commands/apps/register.d.ts +3 -0
- package/lib/commands/apps/register.d.ts.map +1 -0
- package/lib/commands/apps/register.js +130 -0
- package/lib/commands/apps/register.js.map +1 -0
- package/lib/commands/apps/uninstall.d.ts +8 -0
- package/lib/commands/apps/uninstall.d.ts.map +1 -1
- package/lib/commands/apps/uninstall.js +8 -0
- package/lib/commands/apps/uninstall.js.map +1 -1
- package/lib/commands/balances/list.d.ts +12 -0
- package/lib/commands/balances/list.d.ts.map +1 -1
- package/lib/commands/balances/list.js +16 -1
- package/lib/commands/balances/list.js.map +1 -1
- package/lib/commands/balances/register.d.ts +3 -0
- package/lib/commands/balances/register.d.ts.map +1 -0
- package/lib/commands/balances/register.js +35 -0
- package/lib/commands/balances/register.js.map +1 -0
- package/lib/commands/books/create.d.ts +9 -0
- package/lib/commands/books/create.d.ts.map +1 -1
- package/lib/commands/books/create.js +16 -2
- package/lib/commands/books/create.js.map +1 -1
- package/lib/commands/books/get.d.ts +6 -0
- package/lib/commands/books/get.d.ts.map +1 -1
- package/lib/commands/books/get.js +6 -0
- package/lib/commands/books/get.js.map +1 -1
- package/lib/commands/books/index.d.ts +1 -1
- package/lib/commands/books/index.d.ts.map +1 -1
- package/lib/commands/books/index.js +1 -1
- package/lib/commands/books/index.js.map +1 -1
- package/lib/commands/books/list.d.ts +13 -0
- package/lib/commands/books/list.d.ts.map +1 -1
- package/lib/commands/books/list.js +43 -0
- package/lib/commands/books/list.js.map +1 -1
- package/lib/commands/books/register.d.ts +3 -0
- package/lib/commands/books/register.d.ts.map +1 -0
- package/lib/commands/books/register.js +82 -0
- package/lib/commands/books/register.js.map +1 -0
- package/lib/commands/books/update.d.ts +11 -0
- package/lib/commands/books/update.d.ts.map +1 -1
- package/lib/commands/books/update.js +21 -5
- package/lib/commands/books/update.js.map +1 -1
- package/lib/commands/cli-helpers.d.ts +15 -0
- package/lib/commands/cli-helpers.d.ts.map +1 -0
- package/lib/commands/cli-helpers.js +29 -0
- package/lib/commands/cli-helpers.js.map +1 -0
- package/lib/commands/collections/add-book.d.ts +8 -0
- package/lib/commands/collections/add-book.d.ts.map +1 -1
- package/lib/commands/collections/add-book.js +8 -0
- package/lib/commands/collections/add-book.js.map +1 -1
- package/lib/commands/collections/create.d.ts +9 -0
- package/lib/commands/collections/create.d.ts.map +1 -1
- package/lib/commands/collections/create.js +6 -0
- package/lib/commands/collections/create.js.map +1 -1
- package/lib/commands/collections/delete.d.ts +7 -0
- package/lib/commands/collections/delete.d.ts.map +1 -1
- package/lib/commands/collections/delete.js +7 -0
- package/lib/commands/collections/delete.js.map +1 -1
- package/lib/commands/collections/get.d.ts +7 -0
- package/lib/commands/collections/get.d.ts.map +1 -1
- package/lib/commands/collections/get.js +7 -0
- package/lib/commands/collections/get.js.map +1 -1
- package/lib/commands/collections/index.d.ts +1 -1
- package/lib/commands/collections/index.d.ts.map +1 -1
- package/lib/commands/collections/index.js +1 -1
- package/lib/commands/collections/index.js.map +1 -1
- package/lib/commands/collections/list.d.ts +11 -0
- package/lib/commands/collections/list.d.ts.map +1 -1
- package/lib/commands/collections/list.js +26 -0
- package/lib/commands/collections/list.js.map +1 -1
- package/lib/commands/collections/register.d.ts +3 -0
- package/lib/commands/collections/register.d.ts.map +1 -0
- package/lib/commands/collections/register.js +86 -0
- package/lib/commands/collections/register.js.map +1 -0
- package/lib/commands/collections/remove-book.d.ts +8 -0
- package/lib/commands/collections/remove-book.d.ts.map +1 -1
- package/lib/commands/collections/remove-book.js +8 -0
- package/lib/commands/collections/remove-book.js.map +1 -1
- package/lib/commands/collections/update.d.ts +11 -0
- package/lib/commands/collections/update.d.ts.map +1 -1
- package/lib/commands/collections/update.js +8 -0
- package/lib/commands/collections/update.js.map +1 -1
- package/lib/commands/groups/batch-create.d.ts +10 -0
- package/lib/commands/groups/batch-create.d.ts.map +1 -0
- package/lib/commands/groups/batch-create.js +69 -0
- package/lib/commands/groups/batch-create.js.map +1 -0
- package/lib/commands/groups/create.d.ts +8 -0
- package/lib/commands/groups/create.d.ts.map +1 -1
- package/lib/commands/groups/create.js +23 -5
- package/lib/commands/groups/create.js.map +1 -1
- package/lib/commands/groups/delete.d.ts +7 -0
- package/lib/commands/groups/delete.d.ts.map +1 -1
- package/lib/commands/groups/delete.js +7 -0
- package/lib/commands/groups/delete.js.map +1 -1
- package/lib/commands/groups/get.d.ts +7 -0
- package/lib/commands/groups/get.d.ts.map +1 -1
- package/lib/commands/groups/get.js +7 -0
- package/lib/commands/groups/get.js.map +1 -1
- package/lib/commands/groups/index.d.ts +2 -1
- package/lib/commands/groups/index.d.ts.map +1 -1
- package/lib/commands/groups/index.js +2 -1
- package/lib/commands/groups/index.js.map +1 -1
- package/lib/commands/groups/list.d.ts +12 -0
- package/lib/commands/groups/list.d.ts.map +1 -1
- package/lib/commands/groups/list.js +25 -0
- package/lib/commands/groups/list.js.map +1 -1
- package/lib/commands/groups/register.d.ts +3 -0
- package/lib/commands/groups/register.d.ts.map +1 -0
- package/lib/commands/groups/register.js +90 -0
- package/lib/commands/groups/register.js.map +1 -0
- package/lib/commands/groups/update.d.ts +9 -0
- package/lib/commands/groups/update.d.ts.map +1 -1
- package/lib/commands/groups/update.js +21 -5
- package/lib/commands/groups/update.js.map +1 -1
- package/lib/commands/transactions/batch-create.d.ts +10 -0
- package/lib/commands/transactions/batch-create.d.ts.map +1 -0
- package/lib/commands/transactions/batch-create.js +98 -0
- package/lib/commands/transactions/batch-create.js.map +1 -0
- package/lib/commands/transactions/check.d.ts +7 -0
- package/lib/commands/transactions/check.d.ts.map +1 -1
- package/lib/commands/transactions/check.js +7 -0
- package/lib/commands/transactions/check.js.map +1 -1
- package/lib/commands/transactions/create.d.ts +10 -0
- package/lib/commands/transactions/create.d.ts.map +1 -1
- package/lib/commands/transactions/create.js +31 -9
- package/lib/commands/transactions/create.js.map +1 -1
- package/lib/commands/transactions/index.d.ts +2 -1
- package/lib/commands/transactions/index.d.ts.map +1 -1
- package/lib/commands/transactions/index.js +2 -1
- package/lib/commands/transactions/index.js.map +1 -1
- package/lib/commands/transactions/list.d.ts +20 -0
- package/lib/commands/transactions/list.d.ts.map +1 -1
- package/lib/commands/transactions/list.js +38 -0
- package/lib/commands/transactions/list.js.map +1 -1
- package/lib/commands/transactions/merge.d.ts +12 -0
- package/lib/commands/transactions/merge.d.ts.map +1 -1
- package/lib/commands/transactions/merge.js +15 -2
- package/lib/commands/transactions/merge.js.map +1 -1
- package/lib/commands/transactions/post.d.ts +7 -0
- package/lib/commands/transactions/post.d.ts.map +1 -1
- package/lib/commands/transactions/post.js +7 -0
- package/lib/commands/transactions/post.js.map +1 -1
- package/lib/commands/transactions/register.d.ts +3 -0
- package/lib/commands/transactions/register.d.ts.map +1 -0
- package/lib/commands/transactions/register.js +146 -0
- package/lib/commands/transactions/register.js.map +1 -0
- package/lib/commands/transactions/trash.d.ts +7 -0
- package/lib/commands/transactions/trash.d.ts.map +1 -1
- package/lib/commands/transactions/trash.js +7 -0
- package/lib/commands/transactions/trash.js.map +1 -1
- package/lib/commands/transactions/update.d.ts +11 -0
- package/lib/commands/transactions/update.d.ts.map +1 -1
- package/lib/commands/transactions/update.js +31 -7
- package/lib/commands/transactions/update.js.map +1 -1
- package/lib/input/csv-parser.d.ts +9 -0
- package/lib/input/csv-parser.d.ts.map +1 -0
- package/lib/input/csv-parser.js +110 -0
- package/lib/input/csv-parser.js.map +1 -0
- package/lib/input/format-detector.d.ts +12 -0
- package/lib/input/format-detector.d.ts.map +1 -0
- package/lib/input/format-detector.js +14 -0
- package/lib/input/format-detector.js.map +1 -0
- package/lib/input/index.d.ts +9 -0
- package/lib/input/index.d.ts.map +1 -0
- package/lib/input/index.js +40 -0
- package/lib/input/index.js.map +1 -0
- package/lib/input/stdin-reader.d.ts +8 -0
- package/lib/input/stdin-reader.d.ts.map +1 -0
- package/lib/input/stdin-reader.js +37 -0
- package/lib/input/stdin-reader.js.map +1 -0
- package/lib/render/csv-formatter.d.ts +15 -0
- package/lib/render/csv-formatter.d.ts.map +1 -0
- package/lib/render/csv-formatter.js +37 -0
- package/lib/render/csv-formatter.js.map +1 -0
- package/lib/render/index.d.ts +3 -1
- package/lib/render/index.d.ts.map +1 -1
- package/lib/render/index.js +2 -1
- package/lib/render/index.js.map +1 -1
- package/lib/render/output.d.ts +27 -6
- package/lib/render/output.d.ts.map +1 -1
- package/lib/render/output.js +35 -12
- package/lib/render/output.js.map +1 -1
- package/lib/render/table-formatter.d.ts.map +1 -1
- package/lib/render/table-formatter.js +22 -4
- package/lib/render/table-formatter.js.map +1 -1
- package/lib/utils/validation.d.ts +38 -0
- package/lib/utils/validation.d.ts.map +1 -0
- package/lib/utils/validation.js +46 -0
- package/lib/utils/validation.js.map +1 -0
- package/package.json +1 -1
|
@@ -1,8 +1,20 @@
|
|
|
1
1
|
import { Transaction } from 'bkper-js';
|
|
2
|
+
/**
|
|
3
|
+
* Result of merging two transactions.
|
|
4
|
+
*/
|
|
2
5
|
export interface MergeResult {
|
|
3
6
|
mergedTransaction: Transaction;
|
|
4
7
|
revertedTransactionId: string;
|
|
5
8
|
auditRecord: string | null;
|
|
6
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* Merges two transactions by updating one and trashing the other.
|
|
12
|
+
* Fails if the transaction amounts differ.
|
|
13
|
+
*
|
|
14
|
+
* @param bookId - The book ID containing both transactions
|
|
15
|
+
* @param transactionId1 - The ID of the first transaction
|
|
16
|
+
* @param transactionId2 - The ID of the second transaction
|
|
17
|
+
* @returns The merge result with the updated transaction and reverted ID
|
|
18
|
+
*/
|
|
7
19
|
export declare function mergeTransactions(bookId: string, transactionId1: string, transactionId2: string): Promise<MergeResult>;
|
|
8
20
|
//# sourceMappingURL=merge.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merge.d.ts","sourceRoot":"","sources":["../../../src/commands/transactions/merge.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"merge.d.ts","sourceRoot":"","sources":["../../../src/commands/transactions/merge.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAIvC;;GAEG;AACH,MAAM,WAAW,WAAW;IACxB,iBAAiB,EAAE,WAAW,CAAC;IAC/B,qBAAqB,EAAE,MAAM,CAAC;IAC9B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAED;;;;;;;;GAQG;AACH,wBAAsB,iBAAiB,CACnC,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,MAAM,EACtB,cAAc,EAAE,MAAM,GACvB,OAAO,CAAC,WAAW,CAAC,CAuCtB"}
|
|
@@ -9,6 +9,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import { getBkperInstance } from '../../bkper-factory.js';
|
|
11
11
|
import { TransactionMergeOperation } from '../../domain/transaction/merge-operation.js';
|
|
12
|
+
import { throwIfErrors } from '../../utils/validation.js';
|
|
13
|
+
/**
|
|
14
|
+
* Merges two transactions by updating one and trashing the other.
|
|
15
|
+
* Fails if the transaction amounts differ.
|
|
16
|
+
*
|
|
17
|
+
* @param bookId - The book ID containing both transactions
|
|
18
|
+
* @param transactionId1 - The ID of the first transaction
|
|
19
|
+
* @param transactionId2 - The ID of the second transaction
|
|
20
|
+
* @returns The merge result with the updated transaction and reverted ID
|
|
21
|
+
*/
|
|
12
22
|
export function mergeTransactions(bookId, transactionId1, transactionId2) {
|
|
13
23
|
return __awaiter(this, void 0, void 0, function* () {
|
|
14
24
|
const bkper = getBkperInstance();
|
|
@@ -17,12 +27,15 @@ export function mergeTransactions(bookId, transactionId1, transactionId2) {
|
|
|
17
27
|
book.getTransaction(transactionId1),
|
|
18
28
|
book.getTransaction(transactionId2),
|
|
19
29
|
]);
|
|
30
|
+
const errors = [];
|
|
20
31
|
if (!tx1) {
|
|
21
|
-
|
|
32
|
+
errors.push(`Transaction not found: ${transactionId1}`);
|
|
22
33
|
}
|
|
23
34
|
if (!tx2) {
|
|
24
|
-
|
|
35
|
+
errors.push(`Transaction not found: ${transactionId2}`);
|
|
25
36
|
}
|
|
37
|
+
throwIfErrors(errors);
|
|
38
|
+
// After validation, tx1 and tx2 are guaranteed to be defined
|
|
26
39
|
const mergeOp = new TransactionMergeOperation(book, tx1, tx2);
|
|
27
40
|
if (mergeOp.record) {
|
|
28
41
|
throw new Error(`Cannot merge: amounts differ. ${mergeOp.record}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merge.js","sourceRoot":"","sources":["../../../src/commands/transactions/merge.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,OAAO,EAAE,yBAAyB,EAAE,MAAM,6CAA6C,CAAC;
|
|
1
|
+
{"version":3,"file":"merge.js","sourceRoot":"","sources":["../../../src/commands/transactions/merge.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,OAAO,EAAE,yBAAyB,EAAE,MAAM,6C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AAiB,EAAE,OAAO;YAC1B,qBAAqB,EAAE,OAAO,CAAC,iBAAiB,CAAC,KAAK,EAAE,IAAI,EAAE;YAC9D,WAAW,EAAE,OAAO,CAAC,MAAM;SAC9B,CAAC;IACN,CAAC;CAAA"}
|
|
@@ -1,3 +1,10 @@
|
|
|
1
1
|
import { Transaction } from 'bkper-js';
|
|
2
|
+
/**
|
|
3
|
+
* Posts a draft transaction, making it permanent in the book.
|
|
4
|
+
*
|
|
5
|
+
* @param bookId - The book ID containing the transaction
|
|
6
|
+
* @param transactionId - The ID of the transaction to post
|
|
7
|
+
* @returns The posted transaction
|
|
8
|
+
*/
|
|
2
9
|
export declare function postTransaction(bookId: string, transactionId: string): Promise<Transaction>;
|
|
3
10
|
//# sourceMappingURL=post.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"post.d.ts","sourceRoot":"","sources":["../../../src/commands/transactions/post.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,wBAAsB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAQjG"}
|
|
1
|
+
{"version":3,"file":"post.d.ts","sourceRoot":"","sources":["../../../src/commands/transactions/post.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC;;;;;;GAMG;AACH,wBAAsB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAQjG"}
|
|
@@ -8,6 +8,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { getBkperInstance } from '../../bkper-factory.js';
|
|
11
|
+
/**
|
|
12
|
+
* Posts a draft transaction, making it permanent in the book.
|
|
13
|
+
*
|
|
14
|
+
* @param bookId - The book ID containing the transaction
|
|
15
|
+
* @param transactionId - The ID of the transaction to post
|
|
16
|
+
* @returns The posted transaction
|
|
17
|
+
*/
|
|
11
18
|
export function postTransaction(bookId, transactionId) {
|
|
12
19
|
return __awaiter(this, void 0, void 0, function* () {
|
|
13
20
|
const bkper = getBkperInstance();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"post.js","sourceRoot":"","sources":["../../../src/commands/transactions/post.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG1D,MAAM,UAAgB,eAAe,CAAC,MAAc,EAAE,aAAqB;;QACvE,MAAM,KAAK,GAAG,gBAAgB,EAAE,CAAC;QACjC,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACzC,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC;QAC7D,IAAI,CAAC,WAAW,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,0BAA0B,aAAa,EAAE,CAAC,CAAC;QAC/D,CAAC;QACD,OAAO,WAAW,CAAC,IAAI,EAAE,CAAC;IAC9B,CAAC;CAAA"}
|
|
1
|
+
{"version":3,"file":"post.js","sourceRoot":"","sources":["../../../src/commands/transactions/post.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG1D;;;;;;GAMG;AACH,MAAM,UAAgB,eAAe,CAAC,MAAc,EAAE,aAAqB;;QACvE,MAAM,KAAK,GAAG,gBAAgB,EAAE,CAAC;QACjC,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACzC,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC;QAC7D,IAAI,CAAC,WAAW,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,0BAA0B,aAAa,EAAE,CAAC,CAAC;QAC/D,CAAC;QACD,OAAO,WAAW,CAAC,IAAI,EAAE,CAAC;IAC9B,CAAC;CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../../src/commands/transactions/register.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAiBzC,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAiLlE"}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { withAction } from '../action.js';
|
|
11
|
+
import { collectProperty } from '../cli-helpers.js';
|
|
12
|
+
import { renderListResult, renderItem } from '../../render/index.js';
|
|
13
|
+
import { validateRequiredOptions, throwIfErrors } from '../../utils/validation.js';
|
|
14
|
+
import { parseStdinItems } from '../../input/index.js';
|
|
15
|
+
import { listTransactionsFormatted, createTransaction, updateTransaction, postTransaction, checkTransaction, trashTransaction, mergeTransactions, batchCreateTransactions, } from './index.js';
|
|
16
|
+
export function registerTransactionCommands(program) {
|
|
17
|
+
const transactionCommand = program.command('transaction').description('Manage Transactions');
|
|
18
|
+
transactionCommand
|
|
19
|
+
.command('list')
|
|
20
|
+
.description('List transactions in a book')
|
|
21
|
+
.option('-b, --book <bookId>', 'Book ID')
|
|
22
|
+
.option('-q, --query <query>', 'Search query')
|
|
23
|
+
.option('-l, --limit <limit>', 'Maximum number of results (1-1000)', parseInt)
|
|
24
|
+
.option('-c, --cursor <cursor>', 'Pagination cursor')
|
|
25
|
+
.option('-p, --properties', 'Include custom properties')
|
|
26
|
+
.action(options => withAction('listing transactions', (format) => __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
throwIfErrors(validateRequiredOptions(options, [
|
|
28
|
+
{ name: 'book', flag: '--book' },
|
|
29
|
+
{ name: 'query', flag: '--query' },
|
|
30
|
+
]));
|
|
31
|
+
const result = yield listTransactionsFormatted(options.book, {
|
|
32
|
+
query: options.query,
|
|
33
|
+
limit: options.limit,
|
|
34
|
+
cursor: options.cursor,
|
|
35
|
+
properties: options.properties,
|
|
36
|
+
}, format);
|
|
37
|
+
renderListResult(result, format);
|
|
38
|
+
}))());
|
|
39
|
+
transactionCommand
|
|
40
|
+
.command('create')
|
|
41
|
+
.description('Create a transaction')
|
|
42
|
+
.option('-b, --book <bookId>', 'Book ID')
|
|
43
|
+
.option('--date <date>', 'Transaction date')
|
|
44
|
+
.option('--amount <amount>', 'Transaction amount')
|
|
45
|
+
.option('--description <description>', 'Transaction description')
|
|
46
|
+
.option('--from <from>', 'Credit account (source)')
|
|
47
|
+
.option('--to <to>', 'Debit account (destination)')
|
|
48
|
+
.option('--url <url>', 'URL (repeatable)', collectProperty)
|
|
49
|
+
.option('--remote-id <remoteId>', 'Remote ID (repeatable)', collectProperty)
|
|
50
|
+
.option('-p, --property <key=value>', 'Set a property (repeatable, empty value deletes)', collectProperty)
|
|
51
|
+
.action(options => withAction('creating transaction', (format) => __awaiter(this, void 0, void 0, function* () {
|
|
52
|
+
const stdinData = !process.stdin.isTTY ? yield parseStdinItems() : null;
|
|
53
|
+
if (stdinData && stdinData.items.length > 0) {
|
|
54
|
+
throwIfErrors(validateRequiredOptions(options, [{ name: 'book', flag: '--book' }]));
|
|
55
|
+
yield batchCreateTransactions(options.book, stdinData.items, options.property);
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
throwIfErrors(validateRequiredOptions(options, [
|
|
59
|
+
{ name: 'book', flag: '--book' },
|
|
60
|
+
{ name: 'date', flag: '--date' },
|
|
61
|
+
{ name: 'amount', flag: '--amount' },
|
|
62
|
+
]));
|
|
63
|
+
const transaction = yield createTransaction(options.book, {
|
|
64
|
+
date: options.date,
|
|
65
|
+
amount: options.amount,
|
|
66
|
+
description: options.description,
|
|
67
|
+
from: options.from,
|
|
68
|
+
to: options.to,
|
|
69
|
+
url: options.url,
|
|
70
|
+
remoteId: options.remoteId,
|
|
71
|
+
property: options.property,
|
|
72
|
+
});
|
|
73
|
+
renderItem(transaction.json(), format);
|
|
74
|
+
}
|
|
75
|
+
}))());
|
|
76
|
+
transactionCommand
|
|
77
|
+
.command('post <transactionId>')
|
|
78
|
+
.description('Post a transaction')
|
|
79
|
+
.option('-b, --book <bookId>', 'Book ID')
|
|
80
|
+
.action((transactionId, options) => withAction('posting transaction', (format) => __awaiter(this, void 0, void 0, function* () {
|
|
81
|
+
throwIfErrors(validateRequiredOptions(options, [{ name: 'book', flag: '--book' }]));
|
|
82
|
+
const transaction = yield postTransaction(options.book, transactionId);
|
|
83
|
+
renderItem(transaction.json(), format);
|
|
84
|
+
}))());
|
|
85
|
+
transactionCommand
|
|
86
|
+
.command('update <transactionId>')
|
|
87
|
+
.description('Update a transaction')
|
|
88
|
+
.option('-b, --book <bookId>', 'Book ID')
|
|
89
|
+
.option('--date <date>', 'Transaction date')
|
|
90
|
+
.option('--amount <amount>', 'Transaction amount')
|
|
91
|
+
.option('--description <description>', 'Transaction description')
|
|
92
|
+
.option('--from <from>', 'Credit account (source)')
|
|
93
|
+
.option('--to <to>', 'Debit account (destination)')
|
|
94
|
+
.option('--url <url>', 'URL (repeatable, replaces all)', collectProperty)
|
|
95
|
+
.option('-p, --property <key=value>', 'Set a property (repeatable, empty value deletes)', collectProperty)
|
|
96
|
+
.action((transactionId, options) => withAction('updating transaction', (format) => __awaiter(this, void 0, void 0, function* () {
|
|
97
|
+
throwIfErrors(validateRequiredOptions(options, [{ name: 'book', flag: '--book' }]));
|
|
98
|
+
const transaction = yield updateTransaction(options.book, transactionId, {
|
|
99
|
+
date: options.date,
|
|
100
|
+
amount: options.amount,
|
|
101
|
+
description: options.description,
|
|
102
|
+
from: options.from,
|
|
103
|
+
to: options.to,
|
|
104
|
+
url: options.url,
|
|
105
|
+
property: options.property,
|
|
106
|
+
});
|
|
107
|
+
renderItem(transaction.json(), format);
|
|
108
|
+
}))());
|
|
109
|
+
transactionCommand
|
|
110
|
+
.command('check <transactionId>')
|
|
111
|
+
.description('Check a transaction')
|
|
112
|
+
.option('-b, --book <bookId>', 'Book ID')
|
|
113
|
+
.action((transactionId, options) => withAction('checking transaction', (format) => __awaiter(this, void 0, void 0, function* () {
|
|
114
|
+
throwIfErrors(validateRequiredOptions(options, [{ name: 'book', flag: '--book' }]));
|
|
115
|
+
const transaction = yield checkTransaction(options.book, transactionId);
|
|
116
|
+
renderItem(transaction.json(), format);
|
|
117
|
+
}))());
|
|
118
|
+
transactionCommand
|
|
119
|
+
.command('trash <transactionId>')
|
|
120
|
+
.description('Trash a transaction')
|
|
121
|
+
.option('-b, --book <bookId>', 'Book ID')
|
|
122
|
+
.action((transactionId, options) => withAction('trashing transaction', (format) => __awaiter(this, void 0, void 0, function* () {
|
|
123
|
+
throwIfErrors(validateRequiredOptions(options, [{ name: 'book', flag: '--book' }]));
|
|
124
|
+
const transaction = yield trashTransaction(options.book, transactionId);
|
|
125
|
+
renderItem(transaction.json(), format);
|
|
126
|
+
}))());
|
|
127
|
+
transactionCommand
|
|
128
|
+
.command('merge <transactionId1> <transactionId2>')
|
|
129
|
+
.description('Merge two transactions')
|
|
130
|
+
.option('-b, --book <bookId>', 'Book ID')
|
|
131
|
+
.action((transactionId1, transactionId2, options) => withAction('merging transactions', (format) => __awaiter(this, void 0, void 0, function* () {
|
|
132
|
+
throwIfErrors(validateRequiredOptions(options, [{ name: 'book', flag: '--book' }]));
|
|
133
|
+
const result = yield mergeTransactions(options.book, transactionId1, transactionId2);
|
|
134
|
+
if (format === 'json' || format === 'csv') {
|
|
135
|
+
console.log(JSON.stringify({
|
|
136
|
+
mergedTransaction: result.mergedTransaction.json(),
|
|
137
|
+
revertedTransactionId: result.revertedTransactionId,
|
|
138
|
+
auditRecord: result.auditRecord,
|
|
139
|
+
}, null, 2));
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
renderItem(result.mergedTransaction.json(), 'table');
|
|
143
|
+
}
|
|
144
|
+
}))());
|
|
145
|
+
}
|
|
146
|
+
//# sourceMappingURL=register.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register.js","sourceRoot":"","sources":["../../../src/commands/transactions/register.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AACnF,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EACH,yBAAyB,EACzB,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,uBAAuB,GAC1B,MAAM,YAAY,CAAC;AAEpB,MAAM,UAAU,2BAA2B,CAAC,OAAgB;IACxD,MAAM,kBAAkB,GAAG,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,WAAW,CAAC,qBAAqB,CAAC,CAAC;IAE7F,kBAAkB;SACb,OAAO,CAAC,MAAM,CAAC;SACf,WAAW,CAAC,6BAA6B,CAAC;SAC1C,MAAM,CAAC,qBAAqB,EAAE,SAAS,C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AE;gBAClD,qBAAqB,EAAE,MAAM,CAAC,qBAAqB;gBACnD,WAAW,EAAE,MAAM,CAAC,WAAW;aAClC,EACD,IAAI,EACJ,CAAC,CACJ,CACJ,CAAC;QACN,CAAC;aAAM,CAAC;YACJ,UAAU,CAAC,MAAM,CAAC,iBAAiB,CAAC,IAAI,EAAE,EAAE,OAAO,CAAC,CAAC;QACzD,CAAC;IACL,CAAC,CAAA,CAAC,EAAE,CACP,CAAC;AACV,CAAC"}
|
|
@@ -1,3 +1,10 @@
|
|
|
1
1
|
import { Transaction } from 'bkper-js';
|
|
2
|
+
/**
|
|
3
|
+
* Moves a transaction to the trash.
|
|
4
|
+
*
|
|
5
|
+
* @param bookId - The book ID containing the transaction
|
|
6
|
+
* @param transactionId - The ID of the transaction to trash
|
|
7
|
+
* @returns The trashed transaction
|
|
8
|
+
*/
|
|
2
9
|
export declare function trashTransaction(bookId: string, transactionId: string): Promise<Transaction>;
|
|
3
10
|
//# sourceMappingURL=trash.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trash.d.ts","sourceRoot":"","sources":["../../../src/commands/transactions/trash.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,wBAAsB,gBAAgB,CAClC,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,MAAM,GACtB,OAAO,CAAC,WAAW,CAAC,CAQtB"}
|
|
1
|
+
{"version":3,"file":"trash.d.ts","sourceRoot":"","sources":["../../../src/commands/transactions/trash.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC;;;;;;GAMG;AACH,wBAAsB,gBAAgB,CAClC,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,MAAM,GACtB,OAAO,CAAC,WAAW,CAAC,CAQtB"}
|
|
@@ -8,6 +8,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { getBkperInstance } from '../../bkper-factory.js';
|
|
11
|
+
/**
|
|
12
|
+
* Moves a transaction to the trash.
|
|
13
|
+
*
|
|
14
|
+
* @param bookId - The book ID containing the transaction
|
|
15
|
+
* @param transactionId - The ID of the transaction to trash
|
|
16
|
+
* @returns The trashed transaction
|
|
17
|
+
*/
|
|
11
18
|
export function trashTransaction(bookId, transactionId) {
|
|
12
19
|
return __awaiter(this, void 0, void 0, function* () {
|
|
13
20
|
const bkper = getBkperInstance();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trash.js","sourceRoot":"","sources":["../../../src/commands/transactions/trash.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG1D,MAAM,UAAgB,gBAAgB,CAClC,MAAc,EACd,aAAqB;;QAErB,MAAM,KAAK,GAAG,gBAAgB,EAAE,CAAC;QACjC,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACzC,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC;QAC7D,IAAI,CAAC,WAAW,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,0BAA0B,aAAa,EAAE,CAAC,CAAC;QAC/D,CAAC;QACD,OAAO,WAAW,CAAC,KAAK,EAAE,CAAC;IAC/B,CAAC;CAAA"}
|
|
1
|
+
{"version":3,"file":"trash.js","sourceRoot":"","sources":["../../../src/commands/transactions/trash.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG1D;;;;;;GAMG;AACH,MAAM,UAAgB,gBAAgB,CAClC,MAAc,EACd,aAAqB;;QAErB,MAAM,KAAK,GAAG,gBAAgB,EAAE,CAAC;QACjC,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACzC,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC;QAC7D,IAAI,CAAC,WAAW,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,0BAA0B,aAAa,EAAE,CAAC,CAAC;QAC/D,CAAC;QACD,OAAO,WAAW,CAAC,KAAK,EAAE,CAAC;IAC/B,CAAC;CAAA"}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { Transaction } from 'bkper-js';
|
|
2
|
+
/**
|
|
3
|
+
* Options for updating an existing transaction. All fields are optional.
|
|
4
|
+
*/
|
|
2
5
|
export interface UpdateTransactionOptions {
|
|
3
6
|
date?: string;
|
|
4
7
|
amount?: string | number;
|
|
@@ -8,5 +11,13 @@ export interface UpdateTransactionOptions {
|
|
|
8
11
|
url?: string[];
|
|
9
12
|
property?: string[];
|
|
10
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* Updates an existing transaction with the provided fields.
|
|
16
|
+
*
|
|
17
|
+
* @param bookId - The book ID containing the transaction
|
|
18
|
+
* @param transactionId - The ID of the transaction to update
|
|
19
|
+
* @param options - Fields to update (only provided fields are changed)
|
|
20
|
+
* @returns The updated transaction
|
|
21
|
+
*/
|
|
11
22
|
export declare function updateTransaction(bookId: string, transactionId: string, options: UpdateTransactionOptions): Promise<Transaction>;
|
|
12
23
|
//# sourceMappingURL=update.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../src/commands/transactions/update.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../src/commands/transactions/update.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAIvC;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACrC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACvB;AAED;;;;;;;GAOG;AACH,wBAAsB,iBAAiB,CACnC,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,wBAAwB,GAClC,OAAO,CAAC,WAAW,CAAC,CAuDtB"}
|
|
@@ -9,6 +9,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import { getBkperInstance } from '../../bkper-factory.js';
|
|
11
11
|
import { parsePropertyFlag } from '../../utils/properties.js';
|
|
12
|
+
import { throwIfErrors } from '../../utils/validation.js';
|
|
13
|
+
/**
|
|
14
|
+
* Updates an existing transaction with the provided fields.
|
|
15
|
+
*
|
|
16
|
+
* @param bookId - The book ID containing the transaction
|
|
17
|
+
* @param transactionId - The ID of the transaction to update
|
|
18
|
+
* @param options - Fields to update (only provided fields are changed)
|
|
19
|
+
* @returns The updated transaction
|
|
20
|
+
*/
|
|
12
21
|
export function updateTransaction(bookId, transactionId, options) {
|
|
13
22
|
return __awaiter(this, void 0, void 0, function* () {
|
|
14
23
|
const bkper = getBkperInstance();
|
|
@@ -17,6 +26,7 @@ export function updateTransaction(bookId, transactionId, options) {
|
|
|
17
26
|
if (!transaction) {
|
|
18
27
|
throw new Error(`Transaction not found: ${transactionId}`);
|
|
19
28
|
}
|
|
29
|
+
const errors = [];
|
|
20
30
|
if (options.date !== undefined)
|
|
21
31
|
transaction.setDate(options.date);
|
|
22
32
|
if (options.amount !== undefined)
|
|
@@ -25,28 +35,42 @@ export function updateTransaction(bookId, transactionId, options) {
|
|
|
25
35
|
transaction.setDescription(options.description);
|
|
26
36
|
if (options.from !== undefined) {
|
|
27
37
|
const creditAccount = yield book.getAccount(options.from);
|
|
28
|
-
if (creditAccount)
|
|
38
|
+
if (creditAccount) {
|
|
29
39
|
transaction.setCreditAccount(creditAccount);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
errors.push(`Credit account (--from) not found: ${options.from}`);
|
|
43
|
+
}
|
|
30
44
|
}
|
|
31
45
|
if (options.to !== undefined) {
|
|
32
46
|
const debitAccount = yield book.getAccount(options.to);
|
|
33
|
-
if (debitAccount)
|
|
47
|
+
if (debitAccount) {
|
|
34
48
|
transaction.setDebitAccount(debitAccount);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
errors.push(`Debit account (--to) not found: ${options.to}`);
|
|
52
|
+
}
|
|
35
53
|
}
|
|
36
54
|
if (options.url !== undefined) {
|
|
37
55
|
transaction.setUrls(options.url);
|
|
38
56
|
}
|
|
39
57
|
if (options.property) {
|
|
40
58
|
for (const raw of options.property) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
59
|
+
try {
|
|
60
|
+
const [key, value] = parsePropertyFlag(raw);
|
|
61
|
+
if (value === '') {
|
|
62
|
+
transaction.deleteProperty(key);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
transaction.setProperty(key, value);
|
|
66
|
+
}
|
|
44
67
|
}
|
|
45
|
-
|
|
46
|
-
|
|
68
|
+
catch (err) {
|
|
69
|
+
errors.push(err.message);
|
|
47
70
|
}
|
|
48
71
|
}
|
|
49
72
|
}
|
|
73
|
+
throwIfErrors(errors);
|
|
50
74
|
return transaction.update();
|
|
51
75
|
});
|
|
52
76
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.js","sourceRoot":"","sources":["../../../src/commands/transactions/update.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,OAAO,EAAE,iBAAiB,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 -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parses CSV content into an array of records using the first row as headers.
|
|
3
|
+
* Handles quoted fields, escaped quotes, and CRLF/LF line endings.
|
|
4
|
+
*
|
|
5
|
+
* @param content - Raw CSV string to parse
|
|
6
|
+
* @returns Array of records keyed by header names
|
|
7
|
+
*/
|
|
8
|
+
export declare function parseCsv(content: string): Record<string, string>[];
|
|
9
|
+
//# sourceMappingURL=csv-parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"csv-parser.d.ts","sourceRoot":"","sources":["../../src/input/csv-parser.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAuBlE"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parses CSV content into an array of records using the first row as headers.
|
|
3
|
+
* Handles quoted fields, escaped quotes, and CRLF/LF line endings.
|
|
4
|
+
*
|
|
5
|
+
* @param content - Raw CSV string to parse
|
|
6
|
+
* @returns Array of records keyed by header names
|
|
7
|
+
*/
|
|
8
|
+
export function parseCsv(content) {
|
|
9
|
+
const rows = parseRows(content);
|
|
10
|
+
if (rows.length === 0) {
|
|
11
|
+
return [];
|
|
12
|
+
}
|
|
13
|
+
const headers = rows[0].map(h => h.trim());
|
|
14
|
+
const results = [];
|
|
15
|
+
for (let i = 1; i < rows.length; i++) {
|
|
16
|
+
const row = rows[i];
|
|
17
|
+
if (row.length === 1 && row[0] === '') {
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
const record = {};
|
|
21
|
+
for (let j = 0; j < headers.length; j++) {
|
|
22
|
+
record[headers[j]] = j < row.length ? row[j] : '';
|
|
23
|
+
}
|
|
24
|
+
results.push(record);
|
|
25
|
+
}
|
|
26
|
+
return results;
|
|
27
|
+
}
|
|
28
|
+
function parseRows(content) {
|
|
29
|
+
const rows = [];
|
|
30
|
+
let current = 0;
|
|
31
|
+
while (current < content.length) {
|
|
32
|
+
const { fields, nextPosition } = parseRow(content, current);
|
|
33
|
+
rows.push(fields);
|
|
34
|
+
current = nextPosition;
|
|
35
|
+
}
|
|
36
|
+
return rows;
|
|
37
|
+
}
|
|
38
|
+
function parseRow(content, start) {
|
|
39
|
+
const fields = [];
|
|
40
|
+
let pos = start;
|
|
41
|
+
while (pos < content.length) {
|
|
42
|
+
if (content[pos] === '"') {
|
|
43
|
+
const { value, nextPosition } = parseQuotedField(content, pos);
|
|
44
|
+
fields.push(value);
|
|
45
|
+
pos = nextPosition;
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
const { value, nextPosition } = parseUnquotedField(content, pos);
|
|
49
|
+
fields.push(value);
|
|
50
|
+
pos = nextPosition;
|
|
51
|
+
}
|
|
52
|
+
if (pos >= content.length) {
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
if (content[pos] === ',') {
|
|
56
|
+
pos++;
|
|
57
|
+
if (pos >= content.length ||
|
|
58
|
+
content[pos] === '\n' ||
|
|
59
|
+
(content[pos] === '\r' && content[pos + 1] === '\n')) {
|
|
60
|
+
fields.push('');
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
if (content[pos] === '\r' && pos + 1 < content.length && content[pos + 1] === '\n') {
|
|
66
|
+
pos += 2;
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
if (content[pos] === '\n') {
|
|
70
|
+
pos++;
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return { fields, nextPosition: pos };
|
|
75
|
+
}
|
|
76
|
+
function parseQuotedField(content, start) {
|
|
77
|
+
let pos = start + 1;
|
|
78
|
+
const chars = [];
|
|
79
|
+
while (pos < content.length) {
|
|
80
|
+
if (content[pos] === '"') {
|
|
81
|
+
if (pos + 1 < content.length && content[pos + 1] === '"') {
|
|
82
|
+
chars.push('"');
|
|
83
|
+
pos += 2;
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
pos++;
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
chars.push(content[pos]);
|
|
92
|
+
pos++;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return { value: chars.join(''), nextPosition: pos };
|
|
96
|
+
}
|
|
97
|
+
function parseUnquotedField(content, start) {
|
|
98
|
+
let pos = start;
|
|
99
|
+
while (pos < content.length) {
|
|
100
|
+
const ch = content[pos];
|
|
101
|
+
if (ch === ',' ||
|
|
102
|
+
ch === '\n' ||
|
|
103
|
+
(ch === '\r' && pos + 1 < content.length && content[pos + 1] === '\n')) {
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
pos++;
|
|
107
|
+
}
|
|
108
|
+
return { value: content.substring(start, pos), nextPosition: pos };
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=csv-parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"csv-parser.js","sourceRoot":"","sources":["../../src/input/csv-parser.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,UAAU,QAAQ,CAAC,OAAe;IACpC,MAAM,IAAI,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;IAChC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACpB,OAAO,EAAE,CAAC;IACd,CAAC;IAED,MAAM,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IAC3C,MAAM,OAAO,GAA6B,EAAE,CAAC;IAE7C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACnC,MAAM,G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,EAAE,YAAY,EAAE,GAAG,EAAE,CAAC;AACvE,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Supported input formats for piped data.
|
|
3
|
+
*/
|
|
4
|
+
export type InputFormat = 'json' | 'csv';
|
|
5
|
+
/**
|
|
6
|
+
* Detects whether the input content is JSON or CSV based on the first non-whitespace character.
|
|
7
|
+
*
|
|
8
|
+
* @param content - The raw input string to analyze
|
|
9
|
+
* @returns The detected input format
|
|
10
|
+
*/
|
|
11
|
+
export declare function detectInputFormat(content: string): InputFormat;
|
|
12
|
+
//# sourceMappingURL=format-detector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-detector.d.ts","sourceRoot":"","sources":["../../src/input/format-detector.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,KAAK,CAAC;AAEzC;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW,CAM9D"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Detects whether the input content is JSON or CSV based on the first non-whitespace character.
|
|
3
|
+
*
|
|
4
|
+
* @param content - The raw input string to analyze
|
|
5
|
+
* @returns The detected input format
|
|
6
|
+
*/
|
|
7
|
+
export function detectInputFormat(content) {
|
|
8
|
+
const trimmed = content.trim();
|
|
9
|
+
if (trimmed.startsWith('{') || trimmed.startsWith('[')) {
|
|
10
|
+
return 'json';
|
|
11
|
+
}
|
|
12
|
+
return 'csv';
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=format-detector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-detector.js","sourceRoot":"","sources":["../../src/input/format-detector.ts"],"names":[],"mappings":"AAKA;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAAe;IAC7C,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IAC/B,IAAI,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QACrD,OAAO,MAAM,CAAC;IAClB,CAAC;IACD,OAAO,KAAK,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { readStdin } from './stdin-reader.js';
|
|
2
|
+
export { InputFormat } from './format-detector.js';
|
|
3
|
+
import { InputFormat } from './format-detector.js';
|
|
4
|
+
export interface StdinItems {
|
|
5
|
+
items: Record<string, string>[];
|
|
6
|
+
format: InputFormat;
|
|
7
|
+
}
|
|
8
|
+
export declare function parseStdinItems(): Promise<StdinItems | null>;
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/input/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAGnD,OAAO,EAAqB,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAGtE,MAAM,WAAW,UAAU;IACvB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;IAChC,MAAM,EAAE,WAAW,CAAC;CACvB;AAED,wBAAsB,eAAe,IAAI,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAuBlE"}
|