bkper 4.0.2 → 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 +4 -1
- 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/cli.js +19 -949
- 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 +8 -0
- 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 +10 -0
- 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 +6 -0
- 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 +8 -0
- 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 +7 -0
- 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 +8 -0
- 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 +8 -2
- 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 +9 -0
- 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 +8 -0
- 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/package.json +1 -1
|
@@ -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,EACj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O,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC;QACpF,MAAM,MAAM,GAAG,MAAM,iBAAiB,CAClC,OAAO,CAAC,IAAI,EACZ,cAAc,EACd,cAAc,CACjB,CAAC;QACF,IAAI,MAAM,KAAK,MAAM,IAAI,MAAM,KAAK,KAAK,EAAE,CAAC;YACxC,OAAO,CAAC,GAAG,CACP,IAAI,CAAC,SAAS,CACV;gBACI,iBAAiB,EAAE,MAAM,CAAC,iBAAiB,CAAC,IAAI,EAAE;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;AAIvC,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,wBAAsB,iBAAiB,CACnC,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,wBAAwB,GAClC,OAAO,CAAC,WAAW,CAAC,CAuDtB"}
|
|
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"}
|
|
@@ -10,6 +10,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import { getBkperInstance } from '../../bkper-factory.js';
|
|
11
11
|
import { parsePropertyFlag } from '../../utils/properties.js';
|
|
12
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
|
+
*/
|
|
13
21
|
export function updateTransaction(bookId, transactionId, options) {
|
|
14
22
|
return __awaiter(this, void 0, void 0, function* () {
|
|
15
23
|
const bkper = getBkperInstance();
|
|
@@ -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,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;
|
|
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,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAe1D;;;;;;;GAOG;AACH,MAAM,UAAgB,iBAAiB,CACnC,MAAc,EACd,aAAqB,EACrB,OAAiC;;QAEjC,MAAM,KAAK,GAAG,gBAAgB,EAAE,CAAC;QACjC,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACzC,MAAM,WAAW,GAAG,MA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AAE,CAAC;YAC5B,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACrC,CAAC;QAED,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;YACnB,KAAK,MAAM,GAAG,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;gBACjC,IAAI,CAAC;oBACD,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAC;oBAC5C,IAAI,KAAK,KAAK,EAAE,EAAE,CAAC;wBACf,WAAW,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;oBACpC,CAAC;yBAAM,CAAC;wBACJ,WAAW,CAAC,WAAW,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;oBACxC,CAAC;gBACL,CAAC;gBAAC,OAAO,GAAY,EAAE,CAAC;oBACpB,MAAM,CAAC,IAAI,CAAE,GAAa,CAAC,OAAO,CAAC,CAAC;gBACxC,CAAC;YACL,CAAC;QACL,CAAC;QAED,aAAa,CAAC,MAAM,CAAC,CAAC;QAEtB,OAAO,WAAW,CAAC,MAAM,EAAE,CAAC;IAChC,CAAC;CAAA"}
|
|
@@ -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,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QACpB,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC;YACpC,SAAS;QACb,CAAC;QAED,MAAM,MAAM,GAA2B,EAAE,CAAC;QAC1C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACtC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACtD,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,MAAM,CA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AAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;YACzB,GAAG,EAAE,CAAC;QACV,CAAC;IACL,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,YAAY,EAAE,GAAG,EAAE,CAAC;AACxD,CAAC;AAED,SAAS,kBAAkB,CACvB,OAAe,EACf,KAAa;IAEb,IAAI,GAAG,GAAG,KAAK,CAAC;IAEhB,OAAO,GAAG,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;QAC1B,MAAM,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;QACxB,IACI,EAAE,KAAK,GAAG;YACV,EAAE,KAAK,IAAI;YACX,CAAC,EAAE,KAAK,IAAI,IAAI,GAAG,GAAG,CAAC,GAAG,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,GAAG,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC,EACxE,CAAC;YACC,MAAM;QACV,CAAC;QACD,GAAG,EAAE,CAAC;IACV,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,SAAS,CAAC,KAAK,EAAE,GAAG,CAAC,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"}
|
|
@@ -0,0 +1,40 @@
|
|
|
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
|
+
export { readStdin } from './stdin-reader.js';
|
|
11
|
+
import { readStdin } from './stdin-reader.js';
|
|
12
|
+
import { detectInputFormat } from './format-detector.js';
|
|
13
|
+
import { parseCsv } from './csv-parser.js';
|
|
14
|
+
export function parseStdinItems() {
|
|
15
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
16
|
+
const content = yield readStdin();
|
|
17
|
+
if (content === null) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
const format = detectInputFormat(content);
|
|
21
|
+
let items;
|
|
22
|
+
if (format === 'json') {
|
|
23
|
+
const parsed = JSON.parse(content);
|
|
24
|
+
if (Array.isArray(parsed)) {
|
|
25
|
+
items = parsed;
|
|
26
|
+
}
|
|
27
|
+
else if (typeof parsed === 'object' && parsed !== null) {
|
|
28
|
+
items = [parsed];
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
throw new Error('JSON input must be an object or an array of objects');
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
items = parseCsv(content);
|
|
36
|
+
}
|
|
37
|
+
return { items, format };
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/input/index.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAG9C,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAe,MAAM,sBAAsB,CAAC;AACtE,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAO3C,MAAM,UAAgB,eAAe;;QACjC,MAAM,OAAO,GAAG,MAAM,SAAS,EAAE,CAAC;QAClC,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;YACnB,OAAO,IAAI,CAAC;QAChB,CAAC;QAED,MAAM,MAAM,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC;QAC1C,IAAI,KAA+B,CAAC;QAEpC,IAAI,MAAM,KAAK,MAAM,EAAE,CAAC;YACpB,MAAM,MAAM,GAAY,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YAC5C,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;gBACxB,KAAK,GAAG,MAAkC,CAAC;YAC/C,CAAC;iBAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;gBACvD,KAAK,GAAG,CAAC,MAAgC,CAAC,CAAC;YAC/C,CAAC;iBAAM,CAAC;gBACJ,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;YAC3E,CAAC;QACL,CAAC;aAAM,CAAC;YACJ,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;QAC9B,CAAC;QAED,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IAC7B,CAAC;CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reads all content from stdin if piped input is available.
|
|
3
|
+
* Returns null if stdin is a TTY (no piped input) or if the input is empty.
|
|
4
|
+
*
|
|
5
|
+
* @returns The trimmed stdin content, or null if no input is available
|
|
6
|
+
*/
|
|
7
|
+
export declare function readStdin(): Promise<string | null>;
|
|
8
|
+
//# sourceMappingURL=stdin-reader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stdin-reader.d.ts","sourceRoot":"","sources":["../../src/input/stdin-reader.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAsB,SAAS,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAsBxD"}
|
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
/**
|
|
11
|
+
* Reads all content from stdin if piped input is available.
|
|
12
|
+
* Returns null if stdin is a TTY (no piped input) or if the input is empty.
|
|
13
|
+
*
|
|
14
|
+
* @returns The trimmed stdin content, or null if no input is available
|
|
15
|
+
*/
|
|
16
|
+
export function readStdin() {
|
|
17
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
if (process.stdin.isTTY) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
return new Promise((resolve, reject) => {
|
|
22
|
+
const chunks = [];
|
|
23
|
+
process.stdin.setEncoding('utf8');
|
|
24
|
+
process.stdin.on('data', (chunk) => {
|
|
25
|
+
chunks.push(chunk);
|
|
26
|
+
});
|
|
27
|
+
process.stdin.on('end', () => {
|
|
28
|
+
const content = chunks.join('').trim();
|
|
29
|
+
resolve(content.length > 0 ? content : null);
|
|
30
|
+
});
|
|
31
|
+
process.stdin.on('error', (err) => {
|
|
32
|
+
reject(err);
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=stdin-reader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stdin-reader.js","sourceRoot":"","sources":["../../src/input/stdin-reader.ts"],"names":[],"mappings":";;;;;;;;;AAAA;;;;;GAKG;AACH,MAAM,UAAgB,SAAS;;QAC3B,IAAI,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;YACtB,OAAO,IAAI,CAAC;QAChB,CAAC;QAED,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACnC,MAAM,MAAM,GAAa,EAAE,CAAC;YAC5B,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;YAElC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAa,EAAE,EAAE;gBACvC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACvB,CAAC,CAAC,CAAC;YAEH,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE;gBACzB,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;gBACvC,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;YACjD,CAAC,CAAC,CAAC;YAEH,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAU,EAAE,EAAE;gBACrC,MAAM,CAAC,GAAG,CAAC,CAAC;YAChB,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACP,CAAC;CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Formats a 2D matrix into an RFC 4180 compliant CSV string.
|
|
3
|
+
*
|
|
4
|
+
* - Row 0 is treated as headers, rows 1+ as data (all rendered identically)
|
|
5
|
+
* - Uses CRLF line endings per RFC 4180
|
|
6
|
+
* - Fields containing commas, double quotes, or newlines are quoted
|
|
7
|
+
* - Double quotes are escaped by doubling them ("")
|
|
8
|
+
* - null/undefined cells are rendered as empty strings
|
|
9
|
+
* - No truncation is applied to any field
|
|
10
|
+
*
|
|
11
|
+
* @param matrix - 2D array where row 0 is headers and rows 1+ are data
|
|
12
|
+
* @returns RFC 4180 CSV string
|
|
13
|
+
*/
|
|
14
|
+
export declare function formatCsv(matrix: unknown[][]): string;
|
|
15
|
+
//# sourceMappingURL=csv-formatter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"csv-formatter.d.ts","sourceRoot":"","sources":["../../src/render/csv-formatter.ts"],"names":[],"mappings":"AAqBA;;;;;;;;;;;;GAYG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,GAAG,MAAM,CAMrD"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Formats a field value according to RFC 4180 rules.
|
|
3
|
+
*
|
|
4
|
+
* - null/undefined become empty string
|
|
5
|
+
* - Fields containing commas, double quotes, or newlines are wrapped in double quotes
|
|
6
|
+
* - Double quotes within a field are escaped by doubling them ("")
|
|
7
|
+
*/
|
|
8
|
+
function formatField(value) {
|
|
9
|
+
if (value == null) {
|
|
10
|
+
return '';
|
|
11
|
+
}
|
|
12
|
+
const str = String(value);
|
|
13
|
+
if (str.includes('"') || str.includes(',') || str.includes('\n') || str.includes('\r')) {
|
|
14
|
+
return '"' + str.replace(/"/g, '""') + '"';
|
|
15
|
+
}
|
|
16
|
+
return str;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Formats a 2D matrix into an RFC 4180 compliant CSV string.
|
|
20
|
+
*
|
|
21
|
+
* - Row 0 is treated as headers, rows 1+ as data (all rendered identically)
|
|
22
|
+
* - Uses CRLF line endings per RFC 4180
|
|
23
|
+
* - Fields containing commas, double quotes, or newlines are quoted
|
|
24
|
+
* - Double quotes are escaped by doubling them ("")
|
|
25
|
+
* - null/undefined cells are rendered as empty strings
|
|
26
|
+
* - No truncation is applied to any field
|
|
27
|
+
*
|
|
28
|
+
* @param matrix - 2D array where row 0 is headers and rows 1+ are data
|
|
29
|
+
* @returns RFC 4180 CSV string
|
|
30
|
+
*/
|
|
31
|
+
export function formatCsv(matrix) {
|
|
32
|
+
if (!matrix || matrix.length === 0) {
|
|
33
|
+
return '';
|
|
34
|
+
}
|
|
35
|
+
return matrix.map(row => row.map(formatField).join(',')).join('\r\n');
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=csv-formatter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"csv-formatter.js","sourceRoot":"","sources":["../../src/render/csv-formatter.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,SAAS,WAAW,CAAC,KAAc;IAC/B,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;QAChB,OAAO,EAAE,CAAC;IACd,CAAC;IAED,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAE1B,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QACrF,OAAO,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,GAAG,CAAC;IAC/C,CAAC;IAED,OAAO,GAAG,CAAC;AACf,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,SAAS,CAAC,MAAmB;IACzC,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACjC,OAAO,EAAE,CAAC;IACd,CAAC;IAED,OAAO,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC1E,CAAC"}
|
package/lib/render/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export { formatTable, formatItem } from './table-formatter.js';
|
|
2
|
-
export {
|
|
2
|
+
export { formatCsv } from './csv-formatter.js';
|
|
3
|
+
export { renderTable, renderItem, renderListResult } from './output.js';
|
|
4
|
+
export type { OutputFormat, ListResult } from './output.js';
|
|
3
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/render/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/render/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACxE,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC"}
|
package/lib/render/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { formatTable, formatItem } from './table-formatter.js';
|
|
2
|
-
export {
|
|
2
|
+
export { formatCsv } from './csv-formatter.js';
|
|
3
|
+
export { renderTable, renderItem, renderListResult } from './output.js';
|
|
3
4
|
//# sourceMappingURL=index.js.map
|
package/lib/render/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/render/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/render/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC"}
|