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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/commands/groups/list.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/commands/groups/list.ts"],"names":[],"mappings":";;;;;;;;;AAA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AAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAezC,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA4F5D"}
|
|
@@ -0,0 +1,90 @@
|
|
|
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 { listGroupsFormatted, getGroup, createGroup, updateGroup, deleteGroup, batchCreateGroups, } from './index.js';
|
|
16
|
+
export function registerGroupCommands(program) {
|
|
17
|
+
const groupCommand = program.command('group').description('Manage Groups');
|
|
18
|
+
groupCommand
|
|
19
|
+
.command('list')
|
|
20
|
+
.description('List all groups in a book')
|
|
21
|
+
.option('-b, --book <bookId>', 'Book ID')
|
|
22
|
+
.action(options => withAction('listing groups', (format) => __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
throwIfErrors(validateRequiredOptions(options, [{ name: 'book', flag: '--book' }]));
|
|
24
|
+
const result = yield listGroupsFormatted(options.book, format);
|
|
25
|
+
renderListResult(result, format);
|
|
26
|
+
}))());
|
|
27
|
+
groupCommand
|
|
28
|
+
.command('get <idOrName>')
|
|
29
|
+
.description('Get a group by ID or name')
|
|
30
|
+
.option('-b, --book <bookId>', 'Book ID')
|
|
31
|
+
.action((idOrName, options) => withAction('getting group', (format) => __awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
throwIfErrors(validateRequiredOptions(options, [{ name: 'book', flag: '--book' }]));
|
|
33
|
+
const group = yield getGroup(options.book, idOrName);
|
|
34
|
+
renderItem(group.json(), format);
|
|
35
|
+
}))());
|
|
36
|
+
groupCommand
|
|
37
|
+
.command('create')
|
|
38
|
+
.description('Create a new group')
|
|
39
|
+
.option('-b, --book <bookId>', 'Book ID')
|
|
40
|
+
.option('--name <name>', 'Group name')
|
|
41
|
+
.option('--parent <parent>', 'Parent group name or ID')
|
|
42
|
+
.option('--hidden', 'Hide the group')
|
|
43
|
+
.option('-p, --property <key=value>', 'Set a property (repeatable)', collectProperty)
|
|
44
|
+
.action(options => withAction('creating group', (format) => __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
const stdinData = !process.stdin.isTTY ? yield parseStdinItems() : null;
|
|
46
|
+
if (stdinData && stdinData.items.length > 0) {
|
|
47
|
+
throwIfErrors(validateRequiredOptions(options, [{ name: 'book', flag: '--book' }]));
|
|
48
|
+
yield batchCreateGroups(options.book, stdinData.items, options.property);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
throwIfErrors(validateRequiredOptions(options, [
|
|
52
|
+
{ name: 'book', flag: '--book' },
|
|
53
|
+
{ name: 'name', flag: '--name' },
|
|
54
|
+
]));
|
|
55
|
+
const group = yield createGroup(options.book, {
|
|
56
|
+
name: options.name,
|
|
57
|
+
parent: options.parent,
|
|
58
|
+
hidden: options.hidden,
|
|
59
|
+
property: options.property,
|
|
60
|
+
});
|
|
61
|
+
renderItem(group.json(), format);
|
|
62
|
+
}
|
|
63
|
+
}))());
|
|
64
|
+
groupCommand
|
|
65
|
+
.command('update <idOrName>')
|
|
66
|
+
.description('Update a group')
|
|
67
|
+
.option('-b, --book <bookId>', 'Book ID')
|
|
68
|
+
.option('--name <name>', 'Group name')
|
|
69
|
+
.option('--hidden <hidden>', 'Hide status (true/false)')
|
|
70
|
+
.option('-p, --property <key=value>', 'Set a property (repeatable)', collectProperty)
|
|
71
|
+
.action((idOrName, options) => withAction('updating group', (format) => __awaiter(this, void 0, void 0, function* () {
|
|
72
|
+
throwIfErrors(validateRequiredOptions(options, [{ name: 'book', flag: '--book' }]));
|
|
73
|
+
const group = yield updateGroup(options.book, idOrName, {
|
|
74
|
+
name: options.name,
|
|
75
|
+
hidden: options.hidden !== undefined ? options.hidden === 'true' : undefined,
|
|
76
|
+
property: options.property,
|
|
77
|
+
});
|
|
78
|
+
renderItem(group.json(), format);
|
|
79
|
+
}))());
|
|
80
|
+
groupCommand
|
|
81
|
+
.command('delete <idOrName>')
|
|
82
|
+
.description('Delete a group')
|
|
83
|
+
.option('-b, --book <bookId>', 'Book ID')
|
|
84
|
+
.action((idOrName, options) => withAction('deleting group', (format) => __awaiter(this, void 0, void 0, function* () {
|
|
85
|
+
throwIfErrors(validateRequiredOptions(options, [{ name: 'book', flag: '--book' }]));
|
|
86
|
+
const group = yield deleteGroup(options.book, idOrName);
|
|
87
|
+
renderItem(group.json(), format);
|
|
88
|
+
}))());
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=register.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register.js","sourceRoot":"","sources":["../../../src/commands/groups/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,mBAAmB,EACnB,QAAQ,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CAAC,qBAAqB,EAAE,SAAS,CAAC;SACxC,MAAM,CAAC,CAAC,QAAgB,EAAE,OAAO,EAAE,EAAE,CAClC,UAAU,CAAC,gBAAgB,EAAE,CAAM,MAAM,EAAC,EAAE;QACxC,aAAa,CAAC,uBAAuB,CAAC,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC;QACpF,MAAM,KAAK,GAAG,MAAM,WAAW,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QACxD,UAAU,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,MAAM,CAAC,CAAC;IACrC,CAAC,CAAA,CAAC,EAAE,CACP,CAAC;AACV,CAAC"}
|
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
import { Group } from 'bkper-js';
|
|
2
|
+
/** Options for updating an existing group in a book. */
|
|
2
3
|
export interface UpdateGroupOptions {
|
|
3
4
|
name?: string;
|
|
4
5
|
hidden?: boolean;
|
|
5
6
|
property?: string[];
|
|
6
7
|
}
|
|
8
|
+
/**
|
|
9
|
+
* Updates an existing group in the specified book.
|
|
10
|
+
*
|
|
11
|
+
* @param bookId - The ID of the book containing the group
|
|
12
|
+
* @param groupIdOrName - The ID or name of the group to update
|
|
13
|
+
* @param options - Fields to update on the group
|
|
14
|
+
* @returns The updated Group
|
|
15
|
+
*/
|
|
7
16
|
export declare function updateGroup(bookId: string, groupIdOrName: string, options: UpdateGroupOptions): Promise<Group>;
|
|
8
17
|
//# sourceMappingURL=update.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../src/commands/groups/update.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../src/commands/groups/update.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAIjC,wDAAwD;AACxD,MAAM,WAAW,kBAAkB;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACvB;AAED;;;;;;;GAOG;AACH,wBAAsB,WAAW,CAC7B,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,kBAAkB,GAC5B,OAAO,CAAC,KAAK,CAAC,CA+BhB"}
|
|
@@ -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 group in the specified book.
|
|
15
|
+
*
|
|
16
|
+
* @param bookId - The ID of the book containing the group
|
|
17
|
+
* @param groupIdOrName - The ID or name of the group to update
|
|
18
|
+
* @param options - Fields to update on the group
|
|
19
|
+
* @returns The updated Group
|
|
20
|
+
*/
|
|
12
21
|
export function updateGroup(bookId, groupIdOrName, options) {
|
|
13
22
|
return __awaiter(this, void 0, void 0, function* () {
|
|
14
23
|
const bkper = getBkperInstance();
|
|
@@ -17,21 +26,28 @@ export function updateGroup(bookId, groupIdOrName, options) {
|
|
|
17
26
|
if (!group) {
|
|
18
27
|
throw new Error(`Group not found: ${groupIdOrName}`);
|
|
19
28
|
}
|
|
29
|
+
const errors = [];
|
|
20
30
|
if (options.name !== undefined)
|
|
21
31
|
group.setName(options.name);
|
|
22
32
|
if (options.hidden !== undefined)
|
|
23
33
|
group.setHidden(options.hidden);
|
|
24
34
|
if (options.property) {
|
|
25
35
|
for (const raw of options.property) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
36
|
+
try {
|
|
37
|
+
const [key, value] = parsePropertyFlag(raw);
|
|
38
|
+
if (value === '') {
|
|
39
|
+
group.deleteProperty(key);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
group.setProperty(key, value);
|
|
43
|
+
}
|
|
29
44
|
}
|
|
30
|
-
|
|
31
|
-
|
|
45
|
+
catch (err) {
|
|
46
|
+
errors.push(err.message);
|
|
32
47
|
}
|
|
33
48
|
}
|
|
34
49
|
}
|
|
50
|
+
throwIfErrors(errors);
|
|
35
51
|
return group.update();
|
|
36
52
|
});
|
|
37
53
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.js","sourceRoot":"","sources":["../../../src/commands/groups/update.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"update.js","sourceRoot":"","sources":["../../../src/commands/groups/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;AAS1D;;;;;;;GAOG;AACH,MAAM,UAAgB,WAAW,CAC7B,MAAc,EACd,aAAqB,EACrB,OAA2B;;QAE3B,MAAM,KAAK,GAAG,gBAAgB,EAAE,CAAC;QACjC,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACzC,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;QACjD,IAAI,CAAC,KAAK,EAAE,CAAC;YACT,MAAM,IAAI,KAAK,CAAC,oBAAoB,aAAa,EAAE,CAAC,CAAC;QACzD,CAAC;QAED,MAAM,MAAM,GAAa,EAAE,CAAC;QAE5B,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS;YAAE,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAC5D,IAAI,OAAO,CAAC,MAAM,KAAK,SAAS;YAAE,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAElE,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,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;oBAC9B,CAAC;yBAAM,CAAC;wBACJ,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;oBAClC,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,KAAK,CAAC,MAAM,EAAE,CAAC;IAC1B,CAAC;CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates multiple transactions from stdin items using the batch API.
|
|
3
|
+
* Outputs NDJSON (one JSON object per line) as each chunk completes.
|
|
4
|
+
*
|
|
5
|
+
* @param bookId - Target book ID
|
|
6
|
+
* @param items - Parsed stdin items (field-value maps)
|
|
7
|
+
* @param propertyOverrides - CLI --property flags that override stdin fields
|
|
8
|
+
*/
|
|
9
|
+
export declare function batchCreateTransactions(bookId: string, items: Record<string, string>[], propertyOverrides?: string[]): Promise<void>;
|
|
10
|
+
//# sourceMappingURL=batch-create.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"batch-create.d.ts","sourceRoot":"","sources":["../../../src/commands/transactions/batch-create.ts"],"names":[],"mappings":"AAMA;;;;;;;GAOG;AACH,wBAAsB,uBAAuB,CACzC,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,EAC/B,iBAAiB,CAAC,EAAE,MAAM,EAAE,GAC7B,OAAO,CAAC,IAAI,CAAC,CA0Ef"}
|
|
@@ -0,0 +1,98 @@
|
|
|
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 { getBkperInstance } from '../../bkper-factory.js';
|
|
11
|
+
import { Transaction } from 'bkper-js';
|
|
12
|
+
import { parsePropertyFlag } from '../../utils/properties.js';
|
|
13
|
+
const CHUNK_SIZE = 100;
|
|
14
|
+
/**
|
|
15
|
+
* Creates multiple transactions from stdin items using the batch API.
|
|
16
|
+
* Outputs NDJSON (one JSON object per line) as each chunk completes.
|
|
17
|
+
*
|
|
18
|
+
* @param bookId - Target book ID
|
|
19
|
+
* @param items - Parsed stdin items (field-value maps)
|
|
20
|
+
* @param propertyOverrides - CLI --property flags that override stdin fields
|
|
21
|
+
*/
|
|
22
|
+
export function batchCreateTransactions(bookId, items, propertyOverrides) {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
const bkper = getBkperInstance();
|
|
25
|
+
const book = yield bkper.getBook(bookId);
|
|
26
|
+
for (let i = 0; i < items.length; i += CHUNK_SIZE) {
|
|
27
|
+
const chunk = items.slice(i, i + CHUNK_SIZE);
|
|
28
|
+
const transactions = [];
|
|
29
|
+
for (const item of chunk) {
|
|
30
|
+
const tx = new Transaction(book);
|
|
31
|
+
if (item.date)
|
|
32
|
+
tx.setDate(item.date);
|
|
33
|
+
if (item.amount)
|
|
34
|
+
tx.setAmount(item.amount);
|
|
35
|
+
if (item.description)
|
|
36
|
+
tx.setDescription(item.description);
|
|
37
|
+
if (item.from) {
|
|
38
|
+
const creditAccount = yield book.getAccount(item.from);
|
|
39
|
+
if (creditAccount)
|
|
40
|
+
tx.setCreditAccount(creditAccount);
|
|
41
|
+
}
|
|
42
|
+
if (item.to) {
|
|
43
|
+
const debitAccount = yield book.getAccount(item.to);
|
|
44
|
+
if (debitAccount)
|
|
45
|
+
tx.setDebitAccount(debitAccount);
|
|
46
|
+
}
|
|
47
|
+
if (item.url) {
|
|
48
|
+
for (const u of item.url.split(',').map((s) => s.trim())) {
|
|
49
|
+
if (u)
|
|
50
|
+
tx.addUrl(u);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (item.remoteId || item['remote-id'] || item['Remote Id']) {
|
|
54
|
+
const rid = item.remoteId || item['remote-id'] || item['Remote Id'];
|
|
55
|
+
for (const r of rid.split(',').map((s) => s.trim())) {
|
|
56
|
+
if (r)
|
|
57
|
+
tx.addRemoteId(r);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
// Set properties from stdin fields (excluding known fields)
|
|
61
|
+
const knownFields = new Set([
|
|
62
|
+
'date',
|
|
63
|
+
'amount',
|
|
64
|
+
'description',
|
|
65
|
+
'from',
|
|
66
|
+
'to',
|
|
67
|
+
'url',
|
|
68
|
+
'remoteId',
|
|
69
|
+
'remote-id',
|
|
70
|
+
'Remote Id',
|
|
71
|
+
]);
|
|
72
|
+
for (const [key, value] of Object.entries(item)) {
|
|
73
|
+
if (!knownFields.has(key) && value !== '') {
|
|
74
|
+
tx.setProperty(key, value);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
// CLI --property flags override stdin
|
|
78
|
+
if (propertyOverrides) {
|
|
79
|
+
for (const raw of propertyOverrides) {
|
|
80
|
+
const [key, value] = parsePropertyFlag(raw);
|
|
81
|
+
if (value === '') {
|
|
82
|
+
tx.deleteProperty(key);
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
tx.setProperty(key, value);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
transactions.push(tx);
|
|
90
|
+
}
|
|
91
|
+
const results = yield book.batchCreateTransactions(transactions);
|
|
92
|
+
for (const result of results) {
|
|
93
|
+
console.log(JSON.stringify(result.json()));
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=batch-create.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"batch-create.js","sourceRoot":"","sources":["../../../src/commands/transactions/batch-create.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAE9D,MAAM,UAAU,GAAG,GAAG,CAAC;AAEvB;;;;;;;GAOG;AACH,MAAM,UAAgB,uBAAuB,CACzC,MAAc,EACd,KAA+B,EAC/B,iBAA4B;;QAE5B,MAAM,KAAK,GAAG,gBAAgB,EAAE,CAAC;QACjC,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAEzC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,IAAI,UAAU,EAAE,C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AC;wBAC3B,CAAC;6BAAM,CAAC;4BACJ,EAAE,CAAC,WAAW,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;wBAC/B,CAAC;oBACL,CAAC;gBACL,CAAC;gBAED,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YAC1B,CAAC;YAED,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,uBAAuB,CAAC,YAAY,CAAC,CAAC;YACjE,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;gBAC3B,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;YAC/C,CAAC;QACL,CAAC;IACL,CAAC;CAAA"}
|
|
@@ -1,3 +1,10 @@
|
|
|
1
1
|
import { Transaction } from 'bkper-js';
|
|
2
|
+
/**
|
|
3
|
+
* Marks a transaction as checked (reconciled).
|
|
4
|
+
*
|
|
5
|
+
* @param bookId - The book ID containing the transaction
|
|
6
|
+
* @param transactionId - The ID of the transaction to check
|
|
7
|
+
* @returns The checked transaction
|
|
8
|
+
*/
|
|
2
9
|
export declare function checkTransaction(bookId: string, transactionId: string): Promise<Transaction>;
|
|
3
10
|
//# sourceMappingURL=check.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../../src/commands/transactions/check.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":"check.d.ts","sourceRoot":"","sources":["../../../src/commands/transactions/check.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
|
+
* Marks a transaction as checked (reconciled).
|
|
13
|
+
*
|
|
14
|
+
* @param bookId - The book ID containing the transaction
|
|
15
|
+
* @param transactionId - The ID of the transaction to check
|
|
16
|
+
* @returns The checked transaction
|
|
17
|
+
*/
|
|
11
18
|
export function checkTransaction(bookId, transactionId) {
|
|
12
19
|
return __awaiter(this, void 0, void 0, function* () {
|
|
13
20
|
const bkper = getBkperInstance();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"check.js","sourceRoot":"","sources":["../../../src/commands/transactions/check.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":"check.js","sourceRoot":"","sources":["../../../src/commands/transactions/check.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 creating a new transaction in a book.
|
|
4
|
+
*/
|
|
2
5
|
export interface CreateTransactionOptions {
|
|
3
6
|
date: string;
|
|
4
7
|
amount: string | number;
|
|
@@ -9,5 +12,12 @@ export interface CreateTransactionOptions {
|
|
|
9
12
|
remoteId?: string[];
|
|
10
13
|
property?: string[];
|
|
11
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* Creates a new transaction in the specified book.
|
|
17
|
+
*
|
|
18
|
+
* @param bookId - The target book ID
|
|
19
|
+
* @param options - Transaction fields (date, amount, accounts, properties, etc.)
|
|
20
|
+
* @returns The created transaction
|
|
21
|
+
*/
|
|
12
22
|
export declare function createTransaction(bookId: string, options: CreateTransactionOptions): Promise<Transaction>;
|
|
13
23
|
//# sourceMappingURL=create.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/commands/transactions/create.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/commands/transactions/create.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAIvC;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,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;IACpB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACvB;AAED;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CACnC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,wBAAwB,GAClC,OAAO,CAAC,WAAW,CAAC,CA0DtB"}
|
|
@@ -10,22 +10,39 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import { getBkperInstance } from '../../bkper-factory.js';
|
|
11
11
|
import { Transaction } from 'bkper-js';
|
|
12
12
|
import { parsePropertyFlag } from '../../utils/properties.js';
|
|
13
|
+
import { throwIfErrors } from '../../utils/validation.js';
|
|
14
|
+
/**
|
|
15
|
+
* Creates a new transaction in the specified book.
|
|
16
|
+
*
|
|
17
|
+
* @param bookId - The target book ID
|
|
18
|
+
* @param options - Transaction fields (date, amount, accounts, properties, etc.)
|
|
19
|
+
* @returns The created transaction
|
|
20
|
+
*/
|
|
13
21
|
export function createTransaction(bookId, options) {
|
|
14
22
|
return __awaiter(this, void 0, void 0, function* () {
|
|
15
23
|
const bkper = getBkperInstance();
|
|
16
24
|
const book = yield bkper.getBook(bookId);
|
|
25
|
+
const errors = [];
|
|
17
26
|
const tx = new Transaction(book).setDate(options.date).setAmount(options.amount);
|
|
18
27
|
if (options.description)
|
|
19
28
|
tx.setDescription(options.description);
|
|
20
29
|
if (options.from) {
|
|
21
30
|
const creditAccount = yield book.getAccount(options.from);
|
|
22
|
-
if (creditAccount)
|
|
31
|
+
if (creditAccount) {
|
|
23
32
|
tx.setCreditAccount(creditAccount);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
errors.push(`Credit account (--from) not found: ${options.from}`);
|
|
36
|
+
}
|
|
24
37
|
}
|
|
25
38
|
if (options.to) {
|
|
26
39
|
const debitAccount = yield book.getAccount(options.to);
|
|
27
|
-
if (debitAccount)
|
|
40
|
+
if (debitAccount) {
|
|
28
41
|
tx.setDebitAccount(debitAccount);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
errors.push(`Debit account (--to) not found: ${options.to}`);
|
|
45
|
+
}
|
|
29
46
|
}
|
|
30
47
|
if (options.url) {
|
|
31
48
|
for (const u of options.url) {
|
|
@@ -39,17 +56,22 @@ export function createTransaction(bookId, options) {
|
|
|
39
56
|
}
|
|
40
57
|
if (options.property) {
|
|
41
58
|
for (const raw of options.property) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
59
|
+
try {
|
|
60
|
+
const [key, value] = parsePropertyFlag(raw);
|
|
61
|
+
if (value === '') {
|
|
62
|
+
tx.deleteProperty(key);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
tx.setProperty(key, value);
|
|
66
|
+
}
|
|
45
67
|
}
|
|
46
|
-
|
|
47
|
-
|
|
68
|
+
catch (err) {
|
|
69
|
+
errors.push(err.message);
|
|
48
70
|
}
|
|
49
71
|
}
|
|
50
72
|
}
|
|
51
|
-
|
|
52
|
-
return
|
|
73
|
+
throwIfErrors(errors);
|
|
74
|
+
return tx.create();
|
|
53
75
|
});
|
|
54
76
|
}
|
|
55
77
|
//# sourceMappingURL=create.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../src/commands/transactions/create.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MA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AC;CAAA"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
export { listTransactions, ListTransactionsOptions, ListTransactionsResult } from './list.js';
|
|
1
|
+
export { listTransactions, listTransactionsFormatted, ListTransactionsOptions, ListTransactionsResult, } from './list.js';
|
|
2
2
|
export { createTransaction, CreateTransactionOptions } from './create.js';
|
|
3
3
|
export { updateTransaction, UpdateTransactionOptions } from './update.js';
|
|
4
4
|
export { postTransaction } from './post.js';
|
|
5
5
|
export { checkTransaction } from './check.js';
|
|
6
6
|
export { trashTransaction } from './trash.js';
|
|
7
7
|
export { mergeTransactions, MergeResult } from './merge.js';
|
|
8
|
+
export { batchCreateTransactions } from './batch-create.js';
|
|
8
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/transactions/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/transactions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,gBAAgB,EAChB,yBAAyB,EACzB,uBAAuB,EACvB,sBAAsB,GACzB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
export { listTransactions } from './list.js';
|
|
1
|
+
export { listTransactions, listTransactionsFormatted, } from './list.js';
|
|
2
2
|
export { createTransaction } from './create.js';
|
|
3
3
|
export { updateTransaction } from './update.js';
|
|
4
4
|
export { postTransaction } from './post.js';
|
|
5
5
|
export { checkTransaction } from './check.js';
|
|
6
6
|
export { trashTransaction } from './trash.js';
|
|
7
7
|
export { mergeTransactions } from './merge.js';
|
|
8
|
+
export { batchCreateTransactions } from './batch-create.js';
|
|
8
9
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/transactions/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/transactions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,gBAAgB,EAChB,yBAAyB,GAG5B,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,iBAAiB,EAA4B,MAAM,aAAa,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAA4B,MAAM,aAAa,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAe,MAAM,YAAY,CAAC;AAC5D,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -1,14 +1,34 @@
|
|
|
1
1
|
import { Book, Transaction, Account } from 'bkper-js';
|
|
2
|
+
import type { OutputFormat, ListResult } from '../../render/output.js';
|
|
3
|
+
/**
|
|
4
|
+
* Options for querying transactions from a book.
|
|
5
|
+
*/
|
|
2
6
|
export interface ListTransactionsOptions {
|
|
3
7
|
query: string;
|
|
4
8
|
limit?: number;
|
|
5
9
|
cursor?: string;
|
|
10
|
+
properties?: boolean;
|
|
6
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* Result of a transaction listing query, including the book context and pagination cursor.
|
|
14
|
+
*/
|
|
7
15
|
export interface ListTransactionsResult {
|
|
8
16
|
book: Book;
|
|
9
17
|
items: Transaction[];
|
|
10
18
|
account?: Account;
|
|
11
19
|
cursor?: string;
|
|
12
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* Queries transactions from a book using the provided search options.
|
|
23
|
+
*
|
|
24
|
+
* @param bookId - The book ID to query
|
|
25
|
+
* @param options - Query parameters including search string, limit, and cursor
|
|
26
|
+
* @returns The matching transactions with book context and pagination cursor
|
|
27
|
+
*/
|
|
13
28
|
export declare function listTransactions(bookId: string, options: ListTransactionsOptions): Promise<ListTransactionsResult>;
|
|
29
|
+
/**
|
|
30
|
+
* Lists transactions and returns a ListResult ready for rendering.
|
|
31
|
+
* Absorbs TransactionsDataTableBuilder config, JSON wrapping, and cursor footer.
|
|
32
|
+
*/
|
|
33
|
+
export declare function listTransactionsFormatted(bookId: string, options: ListTransactionsOptions, format: OutputFormat): Promise<ListResult>;
|
|
14
34
|
//# sourceMappingURL=list.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/commands/transactions/list.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAmB,MAAM,UAAU,CAAC;AAEvE,MAAM,WAAW,uBAAuB;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/commands/transactions/list.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAmB,MAAM,UAAU,CAAC;AACvE,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEvE;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,OAAO,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACnC,IAAI,EAAE,IAAI,CAAC;IACX,KAAK,EAAE,WAAW,EAAE,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;GAMG;AACH,wBAAsB,gBAAgB,CAClC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,uBAAuB,GACjC,OAAO,CAAC,sBAAsB,CAAC,CAYjC;AAED;;;GAGG;AACH,wBAAsB,yBAAyB,CAC3C,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,uBAAuB,EAChC,MAAM,EAAE,YAAY,GACrB,OAAO,CAAC,UAAU,CAAC,CA2BrB"}
|
|
@@ -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
|
+
* Queries transactions from a book using the provided search options.
|
|
13
|
+
*
|
|
14
|
+
* @param bookId - The book ID to query
|
|
15
|
+
* @param options - Query parameters including search string, limit, and cursor
|
|
16
|
+
* @returns The matching transactions with book context and pagination cursor
|
|
17
|
+
*/
|
|
11
18
|
export function listTransactions(bookId, options) {
|
|
12
19
|
return __awaiter(this, void 0, void 0, function* () {
|
|
13
20
|
const bkper = getBkperInstance();
|
|
@@ -23,4 +30,35 @@ export function listTransactions(bookId, options) {
|
|
|
23
30
|
};
|
|
24
31
|
});
|
|
25
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* Lists transactions and returns a ListResult ready for rendering.
|
|
35
|
+
* Absorbs TransactionsDataTableBuilder config, JSON wrapping, and cursor footer.
|
|
36
|
+
*/
|
|
37
|
+
export function listTransactionsFormatted(bookId, options, format) {
|
|
38
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
const result = yield listTransactions(bookId, options);
|
|
40
|
+
if (format === 'json') {
|
|
41
|
+
return {
|
|
42
|
+
kind: 'json',
|
|
43
|
+
data: {
|
|
44
|
+
items: result.items.map(tx => tx.json()),
|
|
45
|
+
cursor: result.cursor,
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
const builder = result.book.createTransactionsDataTable(result.items, result.account).ids(true);
|
|
50
|
+
if (format === 'csv') {
|
|
51
|
+
builder.properties(true).hiddenProperties(true).urls(true).recordedAt(true);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
builder.formatDates(true).formatValues(true).recordedAt(false);
|
|
55
|
+
if (options.properties) {
|
|
56
|
+
builder.properties(true);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
const matrix = yield builder.build();
|
|
60
|
+
const footer = result.cursor ? `\nNext cursor: ${result.cursor}` : undefined;
|
|
61
|
+
return { kind: 'matrix', matrix, footer };
|
|
62
|
+
});
|
|
63
|
+
}
|
|
26
64
|
//# sourceMappingURL=list.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/commands/transactions/list.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/commands/transactions/list.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAwB1D;;;;;;GAMG;AACH,MAAM,UAAgB,gBAAgB,CAClC,MAAc,EACd,OAAgC;;QAEhC,MAAM,KAAK,GAAG,gBAAgB,EAAE,CAAC;QACjC,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,OAAO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