bkper 4.12.31 → 4.13.1

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.
Files changed (58) hide show
  1. package/README.md +4 -1
  2. package/lib/auth/local-auth-service.d.ts.map +1 -1
  3. package/lib/auth/local-auth-service.js +83 -66
  4. package/lib/auth/local-auth-service.js.map +1 -1
  5. package/lib/cli.js +2 -0
  6. package/lib/cli.js.map +1 -1
  7. package/lib/commands/cli-helpers.d.ts +4 -0
  8. package/lib/commands/cli-helpers.d.ts.map +1 -1
  9. package/lib/commands/cli-helpers.js +8 -2
  10. package/lib/commands/cli-helpers.js.map +1 -1
  11. package/lib/commands/files/get.d.ts +14 -0
  12. package/lib/commands/files/get.d.ts.map +1 -0
  13. package/lib/commands/files/get.js +34 -0
  14. package/lib/commands/files/get.js.map +1 -0
  15. package/lib/commands/files/index.d.ts +3 -0
  16. package/lib/commands/files/index.d.ts.map +1 -0
  17. package/lib/commands/files/index.js +3 -0
  18. package/lib/commands/files/index.js.map +1 -0
  19. package/lib/commands/files/register.d.ts +3 -0
  20. package/lib/commands/files/register.d.ts.map +1 -0
  21. package/lib/commands/files/register.js +42 -0
  22. package/lib/commands/files/register.js.map +1 -0
  23. package/lib/commands/files/upload.d.ts +18 -0
  24. package/lib/commands/files/upload.d.ts.map +1 -0
  25. package/lib/commands/files/upload.js +94 -0
  26. package/lib/commands/files/upload.js.map +1 -0
  27. package/lib/commands/transactions/create.d.ts +9 -0
  28. package/lib/commands/transactions/create.d.ts.map +1 -1
  29. package/lib/commands/transactions/create.js +30 -1
  30. package/lib/commands/transactions/create.js.map +1 -1
  31. package/lib/commands/transactions/index.d.ts +2 -2
  32. package/lib/commands/transactions/index.d.ts.map +1 -1
  33. package/lib/commands/transactions/index.js +1 -1
  34. package/lib/commands/transactions/index.js.map +1 -1
  35. package/lib/commands/transactions/merge.d.ts +7 -12
  36. package/lib/commands/transactions/merge.d.ts.map +1 -1
  37. package/lib/commands/transactions/merge.js +7 -34
  38. package/lib/commands/transactions/merge.js.map +1 -1
  39. package/lib/commands/transactions/register.d.ts.map +1 -1
  40. package/lib/commands/transactions/register.js +7 -13
  41. package/lib/commands/transactions/register.js.map +1 -1
  42. package/lib/docs/bkper-js.md +1 -1
  43. package/lib/docs/cli-reference.md +4 -1
  44. package/lib/docs/data-management.md +45 -1
  45. package/lib/docs/index.md +2 -2
  46. package/lib/utils/local-file.d.ts +11 -0
  47. package/lib/utils/local-file.d.ts.map +1 -0
  48. package/lib/utils/local-file.js +55 -0
  49. package/lib/utils/local-file.js.map +1 -0
  50. package/package.json +3 -2
  51. package/lib/domain/transaction/merge-operation.d.ts +0 -48
  52. package/lib/domain/transaction/merge-operation.d.ts.map +0 -1
  53. package/lib/domain/transaction/merge-operation.js +0 -194
  54. package/lib/domain/transaction/merge-operation.js.map +0 -1
  55. package/lib/domain/transaction/merge-types.d.ts +0 -25
  56. package/lib/domain/transaction/merge-types.d.ts.map +0 -1
  57. package/lib/domain/transaction/merge-types.js +0 -8
  58. package/lib/domain/transaction/merge-types.js.map +0 -1
@@ -7,10 +7,29 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
+ import { File as BkperFile, Transaction } from 'bkper-js';
10
11
  import { getBkperInstance } from '../../bkper-factory.js';
11
- import { Transaction } from 'bkper-js';
12
+ import { readLocalFilePayload } from '../../utils/local-file.js';
12
13
  import { parsePropertyFlag } from '../../utils/properties.js';
13
14
  import { throwIfErrors } from '../../utils/validation.js';
15
+ /**
16
+ * Resolves the single supported --file value for transaction create.
17
+ *
18
+ * @param filePaths - Parsed --file option values
19
+ * @param hasStdinInput - Whether stdin JSON input was provided
20
+ * @returns The single file path, if any
21
+ */
22
+ export function resolveCreateTransactionFilePath(filePaths, hasStdinInput) {
23
+ const errors = [];
24
+ if (filePaths && filePaths.length > 1) {
25
+ errors.push('Option --file may only be provided once');
26
+ }
27
+ if (hasStdinInput && filePaths && filePaths.length > 0) {
28
+ errors.push('Option --file is only supported for single transaction create and cannot be used with stdin input');
29
+ }
30
+ throwIfErrors(errors);
31
+ return filePaths === null || filePaths === void 0 ? void 0 : filePaths[0];
32
+ }
14
33
  /**
15
34
  * Creates a new transaction in the specified book.
16
35
  *
@@ -74,6 +93,16 @@ export function createTransaction(bookId, options) {
74
93
  }
75
94
  }
76
95
  }
96
+ if (options.file) {
97
+ try {
98
+ const payload = yield readLocalFilePayload(options.file);
99
+ const file = new BkperFile(book, payload);
100
+ tx.addFile(file);
101
+ }
102
+ catch (err) {
103
+ errors.push(err.message);
104
+ }
105
+ }
77
106
  throwIfErrors(errors);
78
107
  return tx.create();
79
108
  });
@@ -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,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAgB1D;;;;;;GAMG;AACH,MAAM,UAAgB,iBAAiB,CACnC,MAAc,EACd,OAAiC;;QAEjC,MAAM,KAAK,GAAG,gBAAgB,EAAE,CAAC;QACjC,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAEzC,MAAM,MAAM,GAAa,EAAE,CAAC;QAE5B,MAAM,EAAE,GAAG,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC;QAEjC,IAAI,OAAO,CAAC,IAAI;YAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAC3C,IAAI,OAAO,CAAC,MAAM;YAAE,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAC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OAAO,CAAC,IAAI,CAAC,CAAC;YACrB,CAAC;YAAC,OAAO,GAAY,EAAE,CAAC;gBACpB,MAAM,CAAC,IAAI,CAAE,GAAa,CAAC,OAAO,CAAC,CAAC;YACxC,CAAC;QACL,CAAC;QAED,aAAa,CAAC,MAAM,CAAC,CAAC;QAEtB,OAAO,EAAE,CAAC,MAAM,EAAE,CAAC;IACvB,CAAC;CAAA"}
@@ -1,10 +1,10 @@
1
1
  export { listTransactions, listTransactionsFormatted, ListTransactionsOptions, ListTransactionsResult, } from './list.js';
2
- export { createTransaction, CreateTransactionOptions } from './create.js';
2
+ export { createTransaction, CreateTransactionOptions, resolveCreateTransactionFilePath, } 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
- export { mergeTransactions, MergeResult } from './merge.js';
7
+ export { mergeTransactions } from './merge.js';
8
8
  export { batchCreateTransactions } from './batch-create.js';
9
9
  export { batchUpdateTransactions } from './batch-update.js';
10
10
  //# 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,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;AAC5D,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC"}
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,EACH,iBAAiB,EACjB,wBAAwB,EACxB,gCAAgC,GACnC,MAAM,aAAa,CAAC;AACrB,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,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC"}
@@ -1,5 +1,5 @@
1
1
  export { listTransactions, listTransactionsFormatted, } from './list.js';
2
- export { createTransaction } from './create.js';
2
+ export { createTransaction, resolveCreateTransactionFilePath, } from './create.js';
3
3
  export { updateTransaction } from './update.js';
4
4
  export { postTransaction } from './post.js';
5
5
  export { checkTransaction } from './check.js';
@@ -1 +1 @@
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;AAC5D,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC"}
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,EACH,iBAAiB,EAEjB,gCAAgC,GACnC,MAAM,aAAa,CAAC;AACrB,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;AAC/C,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC"}
@@ -1,20 +1,15 @@
1
1
  import { Transaction } from 'bkper-js';
2
2
  /**
3
- * Result of merging two transactions.
4
- */
5
- export interface MergeResult {
6
- mergedTransaction: Transaction;
7
- revertedTransactionId: string;
8
- auditRecord: string | null;
9
- }
10
- /**
11
- * Merges two transactions by updating one and trashing the other.
12
- * Fails if the transaction amounts differ.
3
+ * Merges two transactions using the canonical server-side merge operation.
4
+ *
5
+ * The returned transaction is the new merged transaction created synchronously
6
+ * by the backend. Cleanup of the two original transactions happens
7
+ * asynchronously on the server.
13
8
  *
14
9
  * @param bookId - The book ID containing both transactions
15
10
  * @param transactionId1 - The ID of the first transaction
16
11
  * @param transactionId2 - The ID of the second transaction
17
- * @returns The merge result with the updated transaction and reverted ID
12
+ * @returns The canonical merged transaction
18
13
  */
19
- export declare function mergeTransactions(bookId: string, transactionId1: string, transactionId2: string): Promise<MergeResult>;
14
+ export declare function mergeTransactions(bookId: string, transactionId1: string, transactionId2: string): Promise<Transaction>;
20
15
  //# sourceMappingURL=merge.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"merge.d.ts","sourceRoot":"","sources":["../../../src/commands/transactions/merge.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAIvC;;GAEG;AACH,MAAM,WAAW,WAAW;IACxB,iBAAiB,EAAE,WAAW,CAAC;IAC/B,qBAAqB,EAAE,MAAM,CAAC;IAC9B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAED;;;;;;;;GAQG;AACH,wBAAsB,iBAAiB,CACnC,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,MAAM,EACtB,cAAc,EAAE,MAAM,GACvB,OAAO,CAAC,WAAW,CAAC,CAuCtB"}
1
+ {"version":3,"file":"merge.d.ts","sourceRoot":"","sources":["../../../src/commands/transactions/merge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAGvC;;;;;;;;;;;GAWG;AACH,wBAAsB,iBAAiB,CACnC,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,MAAM,EACtB,cAAc,EAAE,MAAM,GACvB,OAAO,CAAC,WAAW,CAAC,CAItB"}
@@ -8,50 +8,23 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { getBkperInstance } from '../../bkper-factory.js';
11
- import { TransactionMergeOperation } from '../../domain/transaction/merge-operation.js';
12
- import { throwIfErrors } from '../../utils/validation.js';
13
11
  /**
14
- * Merges two transactions by updating one and trashing the other.
15
- * Fails if the transaction amounts differ.
12
+ * Merges two transactions using the canonical server-side merge operation.
13
+ *
14
+ * The returned transaction is the new merged transaction created synchronously
15
+ * by the backend. Cleanup of the two original transactions happens
16
+ * asynchronously on the server.
16
17
  *
17
18
  * @param bookId - The book ID containing both transactions
18
19
  * @param transactionId1 - The ID of the first transaction
19
20
  * @param transactionId2 - The ID of the second transaction
20
- * @returns The merge result with the updated transaction and reverted ID
21
+ * @returns The canonical merged transaction
21
22
  */
22
23
  export function mergeTransactions(bookId, transactionId1, transactionId2) {
23
24
  return __awaiter(this, void 0, void 0, function* () {
24
25
  const bkper = getBkperInstance();
25
26
  const book = yield bkper.getBook(bookId);
26
- const [tx1, tx2] = yield Promise.all([
27
- book.getTransaction(transactionId1),
28
- book.getTransaction(transactionId2),
29
- ]);
30
- const errors = [];
31
- if (!tx1) {
32
- errors.push(`Transaction not found: ${transactionId1}`);
33
- }
34
- if (!tx2) {
35
- errors.push(`Transaction not found: ${transactionId2}`);
36
- }
37
- throwIfErrors(errors);
38
- // After validation, tx1 and tx2 are guaranteed to be defined
39
- const mergeOp = new TransactionMergeOperation(book, tx1, tx2);
40
- if (mergeOp.record) {
41
- throw new Error(`Cannot merge: amounts differ. ${mergeOp.record}`);
42
- }
43
- // Apply merged data to the edit transaction
44
- mergeOp.applyMergedData();
45
- // Update the edit transaction and trash the revert transaction
46
- const [updated] = yield Promise.all([
47
- mergeOp.editTransaction.update(),
48
- mergeOp.revertTransaction.trash(),
49
- ]);
50
- return {
51
- mergedTransaction: updated,
52
- revertedTransactionId: mergeOp.revertTransaction.getId() || '',
53
- auditRecord: mergeOp.record,
54
- };
27
+ return book.mergeTransactions(transactionId1, transactionId2);
55
28
  });
56
29
  }
57
30
  //# sourceMappingURL=merge.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"merge.js","sourceRoot":"","sources":["../../../src/commands/transactions/merge.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,OAAO,EAAE,yBAAyB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H,OAAO;YACH,iBAAiB,EAAE,OAAO;YAC1B,qBAAqB,EAAE,OAAO,CAAC,iBAAiB,CAAC,KAAK,EAAE,IAAI,EAAE;YAC9D,WAAW,EAAE,OAAO,CAAC,MAAM;SAC9B,CAAC;IACN,CAAC;CAAA"}
1
+ {"version":3,"file":"merge.js","sourceRoot":"","sources":["../../../src/commands/transactions/merge.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D;;;;;;;;;;;GAWG;AACH,MAAM,UAAgB,iBAAiB,CACnC,MAAc,EACd,cAAsB,EACtB,cAAsB;;QAEtB,MAAM,KAAK,GAAG,gBAAgB,EAAE,CAAC;QACjC,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACzC,OAAO,IAAI,CAAC,iBAAiB,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC;IAClE,CAAC;CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../../src/commands/transactions/register.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAkBzC,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAiMlE"}
1
+ {"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../../src/commands/transactions/register.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAmBzC,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAyLlE"}
@@ -8,11 +8,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { withAction } from '../action.js';
11
- import { collectProperty } from '../cli-helpers.js';
11
+ import { collectProperty, collectRepeatable } from '../cli-helpers.js';
12
12
  import { renderListResult, renderItem } from '../../render/index.js';
13
13
  import { validateRequiredOptions, throwIfErrors } from '../../utils/validation.js';
14
14
  import { parseStdinItems } from '../../input/index.js';
15
- import { listTransactionsFormatted, createTransaction, updateTransaction, postTransaction, checkTransaction, trashTransaction, mergeTransactions, batchCreateTransactions, batchUpdateTransactions, } from './index.js';
15
+ import { listTransactionsFormatted, createTransaction, updateTransaction, postTransaction, checkTransaction, trashTransaction, mergeTransactions, batchCreateTransactions, batchUpdateTransactions, resolveCreateTransactionFilePath, } from './index.js';
16
16
  export function registerTransactionCommands(program) {
17
17
  const transactionCommand = program.command('transaction').description('Manage Transactions');
18
18
  transactionCommand
@@ -43,9 +43,11 @@ export function registerTransactionCommands(program) {
43
43
  .option('--to <to>', 'Debit account (destination)')
44
44
  .option('--url <url>', 'URL (repeatable)', collectProperty)
45
45
  .option('--remote-id <remoteId>', 'Remote ID (repeatable)', collectProperty)
46
+ .option('--file <path>', 'Attach a local file (single-create only)', collectRepeatable)
46
47
  .option('-p, --property <key=value>', 'Set a property (repeatable, empty value deletes)', collectProperty)
47
48
  .action(options => withAction('creating transaction', (format) => __awaiter(this, void 0, void 0, function* () {
48
49
  const stdinData = !process.stdin.isTTY ? yield parseStdinItems() : null;
50
+ const filePath = resolveCreateTransactionFilePath(options.file, stdinData !== null);
49
51
  if (stdinData && stdinData.items.length > 0) {
50
52
  throwIfErrors(validateRequiredOptions(options, [{ name: 'book', flag: '--book' }]));
51
53
  yield batchCreateTransactions(options.book, stdinData.items, options.property);
@@ -64,6 +66,7 @@ export function registerTransactionCommands(program) {
64
66
  url: options.url,
65
67
  remoteId: options.remoteId,
66
68
  property: options.property,
69
+ file: filePath,
67
70
  });
68
71
  renderItem(transaction.json(), format);
69
72
  }
@@ -139,17 +142,8 @@ export function registerTransactionCommands(program) {
139
142
  .option('-b, --book <bookId>', 'Book ID')
140
143
  .action((transactionId1, transactionId2, options) => withAction('merging transactions', (format) => __awaiter(this, void 0, void 0, function* () {
141
144
  throwIfErrors(validateRequiredOptions(options, [{ name: 'book', flag: '--book' }]));
142
- const result = yield mergeTransactions(options.book, transactionId1, transactionId2);
143
- if (format === 'json' || format === 'csv') {
144
- console.log(JSON.stringify({
145
- mergedTransaction: result.mergedTransaction.json(),
146
- revertedTransactionId: result.revertedTransactionId,
147
- auditRecord: result.auditRecord,
148
- }, null, 2));
149
- }
150
- else {
151
- renderItem(result.mergedTransaction.json(), 'table');
152
- }
145
+ const transaction = yield mergeTransactions(options.book, transactionId1, transactionId2);
146
+ renderItem(transaction.json(), format);
153
147
  }))());
154
148
  }
155
149
  //# sourceMappingURL=register.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"register.js","sourceRoot":"","sources":["../../../src/commands/transactions/register.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AACnF,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EACH,yBAAyB,EACzB,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,uBAAuB,EACvB,uBAAuB,GAC1B,MAAM,YAAY,CAAC;AAEpB,MAAM,UAAU,2BAA2B,CAAC,OAAgB;IACxD,MAAM,kBAAkB,GAAG,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,WAAW,CAAC,qBAAqB,CAAC,CAAC;IAE7F,kBAAkB;SACb,OAAO,CAAC,MAAM,CAAC;SACf,WAAW,CAAC,6BAA6B,CAAC;SAC1C,MAAM,CAAC,qBAAqB,EAAE,SAAS,CAAC;SACxC,MAAM,CAAC,qBAAqB,EAAE,cAAc,CAAC;SAC7C,MAAM,CAAC,kBAAkB,EAAE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IAEN,kBAAkB;SACb,OAAO,CAAC,yCAAyC,CAAC;SAClD,WAAW,CAAC,wBAAwB,CAAC;SACrC,MAAM,CAAC,qBAAqB,EAAE,SAAS,CAAC;SACxC,MAAM,CAAC,CAAC,cAAsB,EAAE,cAAsB,EAAE,OAAO,EAAE,EAAE,CAChE,UAAU,CAAC,sBAAsB,EAAE,CAAM,MAAM,EAAC,EAAE;QAC9C,aAAa,CAAC,uBAAuB,CAAC,OAAO,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
+ {"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,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EAAE,uBAAuB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,cAAc,EACd,cAAc,CACjB,CAAC;QACF,UAAU,CAAC,WAAW,CAAC,IAAI,EAAE,EAAE,MAAM,CAAC,CAAC;IAC3C,CAAC,CAAA,CAAC,EAAE,CACP,CAAC;AACV,CAAC"}
@@ -120,7 +120,7 @@ const bkper = new Bkper();
120
120
  const books = await bkper.getBooks();
121
121
  ```
122
122
 
123
- See the [@bkper/web-auth documentation](https://bkper.com/docs/auth-sdk) for more details.
123
+ See the [@bkper/web-auth documentation](https://bkper.com/docs/api/bkper-web-auth) for more details.
124
124
 
125
125
  ### API Key (Optional)
126
126
 
@@ -137,10 +137,13 @@ Pi-specific extensions are loaded from Pi extension folders (for example `.pi/ex
137
137
 
138
138
  ## Data Management
139
139
 
140
- Manage books, accounts, transactions, and balances.
140
+ Manage books, files, accounts, transactions, and balances.
141
141
 
142
142
  ```bash
143
143
  bkper book list
144
+ bkper file upload ./receipt.pdf -b <bookId>
145
+ bkper file get <fileId> -b <bookId>
146
+ bkper transaction create -b <bookId> --description "Team lunch" --file ./receipt.pdf
144
147
  bkper account list -b <bookId>
145
148
  bkper transaction list -b <bookId> -q 'on:2025' --format csv
146
149
  bkper balance list -b <bookId> -q 'on:2025-12-31' --format csv
@@ -1,6 +1,6 @@
1
1
  # Data Management
2
2
 
3
- Interact with books, accounts, transactions, and balances using the `bkper` CLI.
3
+ Interact with books, files, accounts, transactions, and balances using the `bkper` CLI.
4
4
 
5
5
  All commands that operate within a book use `-b, --book <bookId>` to specify the book context.
6
6
 
@@ -155,6 +155,39 @@ Avoid using the same name for a Group and an Account in the same Book.
155
155
 
156
156
  ---
157
157
 
158
+ ## Files
159
+
160
+ Upload local files to a book and optionally route them with properties.
161
+
162
+ ```bash
163
+ # Upload a file to a book
164
+ bkper file upload ./receipt.jpg -b abc123
165
+
166
+ # Get a file by id
167
+ bkper file get file_123 -b abc123
168
+
169
+ # Upload and resolve an account to canonical account_id
170
+ bkper file upload ./statement.pdf -b abc123 --account "Credit Card"
171
+
172
+ # Upload with workflow properties
173
+ bkper file upload ./statement.pdf -b abc123 \
174
+ -p statement_period=2025-01 -p group_id=grp_123
175
+ ```
176
+
177
+ Use `-p group_id=...` for group-based routing. The CLI infers `contentType` from the local filename when possible, so PDFs are uploaded as `application/pdf` instead of a generic binary type. It rejects `--account` together with raw `-p account_id=...` and forbids `-p upload_method=...` because that property is reserved for transaction attachments.
178
+
179
+ <details>
180
+ <summary>Command reference</summary>
181
+
182
+ - `file get <fileId> -b <bookId>` - Get a file by ID
183
+ - `file upload <path> -b <bookId>` - Upload a local file to a book
184
+ - `--account <accountIdOrName>` - Resolve an account by name or id and persist canonical `account_id=<resolvedAccountId>`
185
+ - `-p, --property <key=value>` - Set a property (repeatable, empty value deletes)
186
+
187
+ </details>
188
+
189
+ ---
190
+
158
191
  ## Transactions
159
192
 
160
193
  Record, query, and manage financial transactions.
@@ -167,6 +200,13 @@ bkper transaction create -b abc123 --description "Office supplies"
167
200
  bkper transaction create -b abc123 --date 2025-01-15 --amount 100.50 \
168
201
  --from "Bank Account" --to "Office Supplies" --description "Printer paper"
169
202
 
203
+ # Create a transaction with one local attachment
204
+ bkper transaction create -b abc123 --date 2025-01-15 --amount 23.90 \
205
+ --from "Cash" --to "Meals" --description "Team lunch" --file ./receipt.pdf
206
+
207
+ # Create a file-only draft for receipt capture
208
+ bkper transaction create -b abc123 --file ./invoice.pdf
209
+
170
210
  # List transactions for a full year (on:YYYY)
171
211
  bkper transaction list -b abc123 -q 'on:2025'
172
212
 
@@ -205,6 +245,7 @@ bkper transaction merge tx_123 tx_456 -b abc123
205
245
  - `--to <to>` - Debit account (destination)
206
246
  - `--url <url>` - URL (repeatable)
207
247
  - `--remote-id <remoteId>` - Remote ID (repeatable)
248
+ - `--file <path>` - Attach one local file during single-create mode only
208
249
  - `-p, --property <key=value>` - Set a property (repeatable, empty value deletes)
209
250
  - `transaction update [transactionId] -b <bookId>` - Update a transaction (or batch update via stdin)
210
251
  - `--date <date>` - Transaction date
@@ -222,6 +263,7 @@ bkper transaction merge tx_123 tx_456 -b abc123
222
263
 
223
264
  </details>
224
265
 
266
+
225
267
  ---
226
268
 
227
269
  ## Balances
@@ -367,6 +409,8 @@ CSV is significantly more token-efficient than JSON for tabular data, and for wi
367
409
 
368
410
  Write commands (`account create`, `transaction create`) accept JSON data piped via stdin for batch operations. The `transaction update` command also accepts stdin for batch updates. The input format follows the [Bkper API Types](https://raw.githubusercontent.com/bkper/bkper-api-types/refs/heads/master/index.d.ts) exactly -- a single JSON object or an array of objects.
369
411
 
412
+ `transaction create --file` is not available in stdin batch mode. Use single-create commands when attaching a local file.
413
+
370
414
  ```bash
371
415
  # Create transactions
372
416
  echo '[{
package/lib/docs/index.md CHANGED
@@ -2,10 +2,10 @@
2
2
 
3
3
  Reference docs for Bkper tasks. Load only the specific doc(s) relevant to the task — do not load all of them. All docs are in the same directory as this index.
4
4
 
5
- - **data-management.md** — CLI reference for managing financial data: books, accounts, groups, transactions, per-account balance queries, query operators (on:, after:, before:, account:, group:), output formats (table/json/csv), batch operations via stdin/piping, collections.
5
+ - **data-management.md** — CLI reference for managing financial data and files: books, accounts, groups, files, transactions, per-account balance queries, query operators (on:, after:, before:, account:, group:), output formats (table/json/csv), batch operations via stdin/piping, collections.
6
6
  - **app-management.md** — CLI reference for building and deploying Bkper apps: dev/build/deploy workflow, app install/uninstall, secrets management, app logs, bkper.yaml configuration reference (identity, branding, events, menu integration, deployment).
7
7
  - **app-building.md** — Full app-building reference: architecture (packages, client/server/events), development loop, event handlers, deployment patterns, the Bkper Platform, and self-hosted alternatives. Includes authentication patterns for web clients (`@bkper/web-auth`), event handlers (`bkper-oauth-token` headers), and local development. Load this for scaffolding apps, understanding app structure, or debugging the dev/build/deploy lifecycle.
8
8
  - **financial-statements.md** — Step-by-step workflow for aggregate financial reports (balance sheet, P&L): root group discovery, query patterns, date semantics (before: vs after:+before:), common mistakes to avoid.
9
9
  - **taxes.md** — Deterministic workflow for tax position and filing summaries: discovering tax-relevant groups, period-based balance queries, persisting a local tax runner. Jurisdiction-agnostic — outputs raw period balances, leaving rate/application to the user.
10
10
  - **bkper-js.md** — bkper-js Node.js/browser SDK: Bkper, Book, Account, Transaction, Group, Balance classes, all methods, getBalancesReport, OAuth configuration, library setup.
11
- - **bkper-api-types.md** — Bkper REST API TypeScript interfaces: Book, Account, Transaction, Group, Balance, Collection — field names and types used by the API and bkper-js.
11
+ - **bkper-api-types.md** — Bkper REST API TypeScript interfaces: Book, Account, Transaction, Group, Balance, Collection, File — field names and types used by the API and bkper-js.
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Reads a local file from disk and returns a Bkper File payload.
3
+ *
4
+ * The payload preserves the local basename as the file name and encodes the
5
+ * content as base64, ready to be passed to `new File(book, payload)`.
6
+ *
7
+ * @param localPath - Local filesystem path
8
+ * @returns File payload suitable for Bkper uploads
9
+ */
10
+ export declare function readLocalFilePayload(localPath: string): Promise<bkper.File>;
11
+ //# sourceMappingURL=local-file.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"local-file.d.ts","sourceRoot":"","sources":["../../src/utils/local-file.ts"],"names":[],"mappings":"AAIA;;;;;;;;GAQG;AACH,wBAAsB,oBAAoB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAgCjF"}
@@ -0,0 +1,55 @@
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 { readFile, stat } from 'node:fs/promises';
11
+ import mime from 'mime';
12
+ import path from 'node:path';
13
+ /**
14
+ * Reads a local file from disk and returns a Bkper File payload.
15
+ *
16
+ * The payload preserves the local basename as the file name and encodes the
17
+ * content as base64, ready to be passed to `new File(book, payload)`.
18
+ *
19
+ * @param localPath - Local filesystem path
20
+ * @returns File payload suitable for Bkper uploads
21
+ */
22
+ export function readLocalFilePayload(localPath) {
23
+ return __awaiter(this, void 0, void 0, function* () {
24
+ let fileStats;
25
+ try {
26
+ fileStats = yield stat(localPath);
27
+ }
28
+ catch (err) {
29
+ const error = err;
30
+ if (error.code === 'ENOENT') {
31
+ throw new Error(`Local file not found: ${localPath}`);
32
+ }
33
+ throw new Error(`Local file is not readable: ${localPath}`);
34
+ }
35
+ if (!fileStats.isFile()) {
36
+ throw new Error(`Local path is not a regular file: ${localPath}`);
37
+ }
38
+ let content;
39
+ try {
40
+ content = yield readFile(localPath);
41
+ }
42
+ catch (_a) {
43
+ throw new Error(`Local file is not readable: ${localPath}`);
44
+ }
45
+ const contentType = mime.getType(localPath);
46
+ return {
47
+ createdAt: `${Date.now()}`,
48
+ name: path.basename(localPath),
49
+ contentType: contentType || undefined,
50
+ size: fileStats.size,
51
+ content: content.toString('base64'),
52
+ };
53
+ });
54
+ }
55
+ //# sourceMappingURL=local-file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"local-file.js","sourceRoot":"","sources":["../../src/utils/local-file.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B;;;;;;;;GAQG;AACH,MAAM,UAAgB,oBAAoB,CAAC,SAAiB;;QACxD,IAAI,SAAS,CAAC;QACd,IAAI,CAAC;YACD,SAAS,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,CAAC;QACtC,CAAC;QAAC,OAAO,GAAY,EAAE,CAAC;YACpB,MAAM,KAAK,GAAG,GAA4B,CAAC;YAC3C,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;gBAC1B,MAAM,IAAI,KAAK,CAAC,yBAAyB,SAAS,EAAE,CAAC,CAAC;YAC1D,CAAC;YACD,MAAM,IAAI,KAAK,CAAC,+BAA+B,SAAS,EAAE,CAAC,CAAC;QAChE,CAAC;QAED,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CAAC,qCAAqC,SAAS,EAAE,CAAC,CAAC;QACtE,CAAC;QAED,IAAI,OAAe,CAAC;QACpB,IAAI,CAAC;YACD,OAAO,GAAG,MAAM,QAAQ,CAAC,SAAS,CAAC,CAAC;QACxC,CAAC;QAAC,WAAM,CAAC;YACL,MAAM,IAAI,KAAK,CAAC,+BAA+B,SAAS,EAAE,CAAC,CAAC;QAChE,CAAC;QAED,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAE5C,OAAO;YACH,SAAS,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE,EAAE;YAC1B,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC;YAC9B,WAAW,EAAE,WAAW,IAAI,SAAS;YACrC,IAAI,EAAE,SAAS,CAAC,IAAI;YACpB,OAAO,EAAE,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC;SACtC,CAAC;IACN,CAAC;CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bkper",
3
- "version": "4.12.31",
3
+ "version": "4.13.1",
4
4
  "description": "Command line client for Bkper",
5
5
  "bin": {
6
6
  "bkper": "./lib/cli.js"
@@ -53,11 +53,12 @@
53
53
  "dependencies": {
54
54
  "@earendil-works/pi-coding-agent": "0.74.0",
55
55
  "@earendil-works/pi-tui": "0.74.0",
56
- "bkper-js": "^2.33.1",
56
+ "bkper-js": "^2.34.2",
57
57
  "commander": "^13.1.0",
58
58
  "dotenv": "^8.2.0",
59
59
  "esbuild": "^0.27.2",
60
60
  "google-auth-library": "^10.5.0",
61
+ "mime": "^4.1.0",
61
62
  "open": "^10.1.0",
62
63
  "openapi-fetch": "^0.15.0",
63
64
  "tar": "^7.0.0",
@@ -1,48 +0,0 @@
1
- /**
2
- * Transaction Merge Operation - Domain Logic
3
- *
4
- * Pure business logic for merging two transactions into one.
5
- * This class contains no dependencies on MCP, HTTP, or other infrastructure concerns.
6
- * It operates on Transaction domain objects from bkper-js.
7
- */
8
- import { Transaction, Book } from 'bkper-js';
9
- import { MergedTransactionData } from './merge-types.js';
10
- /**
11
- * Represents the result of a transaction merge operation
12
- *
13
- * Determines which transaction to keep (edit) vs discard (revert),
14
- * then intelligently merges data from both transactions.
15
- */
16
- export declare class TransactionMergeOperation {
17
- private book;
18
- editTransaction: Transaction;
19
- revertTransaction: Transaction;
20
- mergedData: MergedTransactionData;
21
- record: string | null;
22
- private static readonly WORD_SPLITTER;
23
- constructor(book: Book, transaction1: Transaction, transaction2: Transaction);
24
- /**
25
- * Merges data from both transactions into a single transaction data object
26
- * @returns Merged transaction data
27
- */
28
- private merge;
29
- /**
30
- * Merges two descriptions intelligently, avoiding duplicate words
31
- * @param desc1 First description (from edit transaction)
32
- * @param desc2 Second description (from revert transaction)
33
- * @returns Merged description with unique words
34
- */
35
- private mergeDescription;
36
- /**
37
- * Trims and normalizes whitespace in text
38
- * @param text Text to trim
39
- * @returns Trimmed text with normalized whitespace
40
- */
41
- private trim;
42
- /**
43
- * Apply the merged data to the edit transaction
44
- * This mutates the edit transaction object with the merged data
45
- */
46
- applyMergedData(): void;
47
- }
48
- //# sourceMappingURL=merge-operation.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"merge-operation.d.ts","sourceRoot":"","sources":["../../../src/domain/transaction/merge-operation.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAEzD;;;;;GAKG;AACH,qBAAa,yBAAyB;IAS9B,OAAO,CAAC,IAAI;IART,eAAe,EAAE,WAAW,CAAC;IAC7B,iBAAiB,EAAE,WAAW,CAAC;IAC/B,UAAU,EAAE,qBAAqB,CAAC;IAClC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAQ;IAEpC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAa;gBAGtC,IAAI,EAAE,IAAI,EAClB,YAAY,EAAE,WAAW,EACzB,YAAY,EAAE,WAAW;IA8B7B;;;OAGG;IACH,OAAO,CAAC,KAAK;IA8Eb;;;;;OAKG;IACH,OAAO,CAAC,gBAAgB;IAcxB;;;;OAIG;IACH,OAAO,CAAC,IAAI;IAIZ;;;OAGG;IACH,eAAe,IAAI,IAAI;CAsD1B"}