beancount 0.2.5 → 0.2.6

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 (66) hide show
  1. package/build/src/classes/Node.mjs +7 -7
  2. package/build/src/classes/nodes/Blankline.mjs +2 -6
  3. package/build/src/classes/nodes/Transaction/Posting.mjs +1 -1
  4. package/build/src/genericParse.d.mts +4 -3
  5. package/build/src/genericParse.mjs +18 -19
  6. package/build/src/main.d.mts +1 -1
  7. package/build/src/parse.d.mts +1 -1
  8. package/build/src/parse.mjs +1 -1
  9. package/build/src/utils/SourceLocation.d.mts +27 -4
  10. package/build/src/utils/splitStringIntoSourceFragments.js +30 -8
  11. package/build/tsconfig.build.tsbuildinfo +1 -1
  12. package/package.json +7 -7
  13. package/build/src/classes/DateEntry.d.mts +0 -47
  14. package/build/src/classes/DateEntry.mjs +0 -60
  15. package/build/src/classes/Entry.d.mts +0 -92
  16. package/build/src/classes/Entry.mjs +0 -107
  17. package/build/src/classes/entryTypes/Balance.d.mts +0 -32
  18. package/build/src/classes/entryTypes/Balance.mjs +0 -50
  19. package/build/src/classes/entryTypes/Blankline.d.mts +0 -24
  20. package/build/src/classes/entryTypes/Blankline.mjs +0 -38
  21. package/build/src/classes/entryTypes/Close.d.mts +0 -20
  22. package/build/src/classes/entryTypes/Close.mjs +0 -31
  23. package/build/src/classes/entryTypes/Comment.d.mts +0 -25
  24. package/build/src/classes/entryTypes/Comment.mjs +0 -42
  25. package/build/src/classes/entryTypes/Commodity.d.mts +0 -20
  26. package/build/src/classes/entryTypes/Commodity.mjs +0 -31
  27. package/build/src/classes/entryTypes/Custom.d.mts +0 -23
  28. package/build/src/classes/entryTypes/Custom.mjs +0 -38
  29. package/build/src/classes/entryTypes/Document.d.mts +0 -22
  30. package/build/src/classes/entryTypes/Document.mjs +0 -34
  31. package/build/src/classes/entryTypes/Event.d.mts +0 -23
  32. package/build/src/classes/entryTypes/Event.mjs +0 -34
  33. package/build/src/classes/entryTypes/Include.d.mts +0 -20
  34. package/build/src/classes/entryTypes/Include.mjs +0 -31
  35. package/build/src/classes/entryTypes/Note.d.mts +0 -22
  36. package/build/src/classes/entryTypes/Note.mjs +0 -34
  37. package/build/src/classes/entryTypes/Open.d.mts +0 -27
  38. package/build/src/classes/entryTypes/Open.mjs +0 -66
  39. package/build/src/classes/entryTypes/Option.d.mts +0 -23
  40. package/build/src/classes/entryTypes/Option.mjs +0 -32
  41. package/build/src/classes/entryTypes/Pad.d.mts +0 -22
  42. package/build/src/classes/entryTypes/Pad.mjs +0 -33
  43. package/build/src/classes/entryTypes/Plugin.d.mts +0 -22
  44. package/build/src/classes/entryTypes/Plugin.mjs +0 -36
  45. package/build/src/classes/entryTypes/Poptag.d.mts +0 -21
  46. package/build/src/classes/entryTypes/Poptag.mjs +0 -34
  47. package/build/src/classes/entryTypes/Price.d.mts +0 -32
  48. package/build/src/classes/entryTypes/Price.mjs +0 -57
  49. package/build/src/classes/entryTypes/Pushtag.d.mts +0 -21
  50. package/build/src/classes/entryTypes/Pushtag.mjs +0 -34
  51. package/build/src/classes/entryTypes/Query.d.mts +0 -22
  52. package/build/src/classes/entryTypes/Query.mjs +0 -34
  53. package/build/src/classes/entryTypes/Transaction/Posting.d.mts +0 -59
  54. package/build/src/classes/entryTypes/Transaction/Posting.mjs +0 -97
  55. package/build/src/classes/entryTypes/Transaction/Tag.d.mts +0 -28
  56. package/build/src/classes/entryTypes/Transaction/Tag.mjs +0 -28
  57. package/build/src/classes/entryTypes/Transaction/index.d.mts +0 -70
  58. package/build/src/classes/entryTypes/Transaction/index.mjs +0 -193
  59. package/build/src/classes/entryTypes/index.d.mts +0 -19
  60. package/build/src/classes/entryTypes/index.mjs +0 -19
  61. package/build/src/entryTypeToClass.d.mts +0 -73
  62. package/build/src/entryTypeToClass.mjs +0 -37
  63. package/build/src/entryTypes.d.mts +0 -10
  64. package/build/src/entryTypes.mjs +0 -29
  65. package/build/src/utils/splitStringIntoUnparsedEntries.d.ts +0 -14
  66. package/build/src/utils/splitStringIntoUnparsedEntries.js +0 -48
@@ -1,19 +0,0 @@
1
- export { Transaction } from './Transaction/index.mjs';
2
- export { Balance } from './Balance.mjs';
3
- export { Blankline } from './Blankline.mjs';
4
- export { Close } from './Close.mjs';
5
- export { Comment } from './Comment.mjs';
6
- export { Commodity } from './Commodity.mjs';
7
- export { Custom } from './Custom.mjs';
8
- export { Document } from './Document.mjs';
9
- export { Event } from './Event.mjs';
10
- export { Include } from './Include.mjs';
11
- export { Note } from './Note.mjs';
12
- export { Open } from './Open.mjs';
13
- export { Option } from './Option.mjs';
14
- export { Pad } from './Pad.mjs';
15
- export { Plugin } from './Plugin.mjs';
16
- export { Price } from './Price.mjs';
17
- export { Poptag } from './Poptag.mjs';
18
- export { Pushtag } from './Pushtag.mjs';
19
- export { Query } from './Query.mjs';
@@ -1,73 +0,0 @@
1
- import { Transaction, Balance, Close, Comment, Commodity, Custom, Document, Event, Include, Note, Open, Option, Pad, Plugin, Poptag, Price, Pushtag, Query, Blankline } from './classes/entryTypes/index.mjs';
2
- import type { DATED_ENTRY_TYPES, NON_DATED_ENTRY_TYPES } from './entryTypes.mjs';
3
- /**
4
- * Union type of all Beancount entry types that include a date field.
5
- * Derived from {@link DATED_ENTRY_TYPES}.
6
- */
7
- export type BeancountDatedEntryType = (typeof DATED_ENTRY_TYPES)[number];
8
- /**
9
- * Union type of all Beancount entry types that do NOT include a date field.
10
- * Derived from {@link NON_DATED_ENTRY_TYPES}.
11
- */
12
- export type BeancountNonDatedEntryType = (typeof NON_DATED_ENTRY_TYPES)[number];
13
- /**
14
- * Union type of all valid Beancount entry type names.
15
- * EntryTypes derived from https://beancount.github.io/docs/beancount_language_syntax.html#directives-1
16
- * Entries can have two additional 'fake' types: 'comment' and 'blankline', see {@link EntryType}
17
- *
18
- * Derived from {@link DATED_ENTRY_TYPES} and {@link NON_DATED_ENTRY_TYPES}.
19
- */
20
- export type BeancountEntryType = BeancountDatedEntryType | BeancountNonDatedEntryType;
21
- export type FakeEntryType = 'comment' | 'blankline';
22
- /**
23
- * Union type of all valid entry type names, including the 'fake' entry types of comment and blankline.
24
- */
25
- export type EntryType = BeancountEntryType | FakeEntryType;
26
- /**
27
- * Mapping of Beancount entry type names to their corresponding class constructors.
28
- * @internal
29
- */
30
- export declare const beancountEntryToClass: {
31
- transaction: typeof Transaction;
32
- balance: typeof Balance;
33
- close: typeof Close;
34
- commodity: typeof Commodity;
35
- custom: typeof Custom;
36
- document: typeof Document;
37
- event: typeof Event;
38
- include: typeof Include;
39
- note: typeof Note;
40
- open: typeof Open;
41
- option: typeof Option;
42
- pad: typeof Pad;
43
- plugin: typeof Plugin;
44
- poptag: typeof Poptag;
45
- price: typeof Price;
46
- pushtag: typeof Pushtag;
47
- query: typeof Query;
48
- };
49
- /**
50
- * Mapping of all entry type names (including 'comment' and 'blankline') to their corresponding class constructors.
51
- * @internal
52
- */
53
- export declare const entryTypeToClass: {
54
- comment: typeof Comment;
55
- blankline: typeof Blankline;
56
- transaction: typeof Transaction;
57
- balance: typeof Balance;
58
- close: typeof Close;
59
- commodity: typeof Commodity;
60
- custom: typeof Custom;
61
- document: typeof Document;
62
- event: typeof Event;
63
- include: typeof Include;
64
- note: typeof Note;
65
- open: typeof Open;
66
- option: typeof Option;
67
- pad: typeof Pad;
68
- plugin: typeof Plugin;
69
- poptag: typeof Poptag;
70
- price: typeof Price;
71
- pushtag: typeof Pushtag;
72
- query: typeof Query;
73
- };
@@ -1,37 +0,0 @@
1
- import { Transaction, Balance, Close, Comment, Commodity, Custom, Document, Event, Include, Note, Open, Option, Pad, Plugin, Poptag, Price, Pushtag, Query, Blankline, } from './classes/entryTypes/index.mjs';
2
- /**
3
- * Mapping of Beancount entry type names to their corresponding class constructors.
4
- * @internal
5
- */
6
- export const beancountEntryToClass = {
7
- transaction: Transaction,
8
- balance: Balance,
9
- close: Close,
10
- commodity: Commodity,
11
- custom: Custom,
12
- document: Document,
13
- event: Event,
14
- include: Include,
15
- note: Note,
16
- open: Open,
17
- option: Option,
18
- pad: Pad,
19
- plugin: Plugin,
20
- poptag: Poptag,
21
- price: Price,
22
- pushtag: Pushtag,
23
- query: Query,
24
- };
25
- // Compile-time assertion: beancountEntryToClass must have all BeancountEntryType keys
26
- beancountEntryToClass;
27
- /**
28
- * Mapping of all entry type names (including 'comment' and 'blankline') to their corresponding class constructors.
29
- * @internal
30
- */
31
- export const entryTypeToClass = {
32
- ...beancountEntryToClass,
33
- comment: Comment,
34
- blankline: Blankline,
35
- };
36
- // Compile-time assertion: entryTypeToClass must have all EntryType keys
37
- beancountEntryToClass;
@@ -1,10 +0,0 @@
1
- /**
2
- * Array of all Beancount entry types that start with a date (YYYY-MM-DD format).
3
- * These entries follow the pattern: `YYYY-MM-DD <type> ...`
4
- */
5
- export declare const DATED_ENTRY_TYPES: readonly ["balance", "close", "commodity", "custom", "document", "event", "note", "open", "pad", "price", "query", "transaction"];
6
- /**
7
- * Array of all Beancount entry types that do NOT start with a date.
8
- * These entries follow the pattern: `<type> ...`
9
- */
10
- export declare const NON_DATED_ENTRY_TYPES: readonly ["include", "option", "plugin", "poptag", "pushtag"];
@@ -1,29 +0,0 @@
1
- /**
2
- * Array of all Beancount entry types that start with a date (YYYY-MM-DD format).
3
- * These entries follow the pattern: `YYYY-MM-DD <type> ...`
4
- */
5
- export const DATED_ENTRY_TYPES = [
6
- 'balance',
7
- 'close',
8
- 'commodity',
9
- 'custom',
10
- 'document',
11
- 'event',
12
- 'note',
13
- 'open',
14
- 'pad',
15
- 'price',
16
- 'query',
17
- 'transaction',
18
- ];
19
- /**
20
- * Array of all Beancount entry types that do NOT start with a date.
21
- * These entries follow the pattern: `<type> ...`
22
- */
23
- export const NON_DATED_ENTRY_TYPES = [
24
- 'include',
25
- 'option',
26
- 'plugin',
27
- 'poptag',
28
- 'pushtag',
29
- ];
@@ -1,14 +0,0 @@
1
- /**
2
- * Splits a Beancount file string into an array of unparsed entry arrays.
3
- * Each entry is represented as an array of strings (tokens).
4
- *
5
- * This function handles:
6
- * - Splitting on blank lines between entries
7
- * - Detecting new entries based on indentation
8
- * - Preserving multi-line strings that span lines
9
- *
10
- * @param input - The complete Beancount file content as a string
11
- * @returns An array where each element is an array of string tokens representing one entry
12
- * @internal
13
- */
14
- export declare const splitStringIntoUnparsedEntries: (input: string) => string[][];
@@ -1,48 +0,0 @@
1
- import { countChar } from './countChar.mjs';
2
- import { stringAwareSplitLine } from './stringAwareSplitLine.mjs';
3
- /**
4
- * Splits a Beancount file string into an array of unparsed entry arrays.
5
- * Each entry is represented as an array of strings (tokens).
6
- *
7
- * This function handles:
8
- * - Splitting on blank lines between entries
9
- * - Detecting new entries based on indentation
10
- * - Preserving multi-line strings that span lines
11
- *
12
- * @param input - The complete Beancount file content as a string
13
- * @returns An array where each element is an array of string tokens representing one entry
14
- * @internal
15
- */
16
- export const splitStringIntoUnparsedEntries = (input) => {
17
- const lines = input.split('\n');
18
- // split up the file into entries
19
- let inEntry = false;
20
- let inString = false;
21
- const unparsedEntries = lines.reduce((acc, line) => {
22
- if (!inString) {
23
- if (line.trim() === '') {
24
- // empty newline, next entry starts
25
- inEntry = false;
26
- }
27
- if (!line.startsWith(' ') && inEntry) {
28
- // no indent, new entry
29
- inEntry = false;
30
- }
31
- if (!inEntry) {
32
- acc.push([]);
33
- inEntry = true;
34
- }
35
- }
36
- acc[acc.length - 1].push(line);
37
- // After a blank line, ensure next line starts a new entry
38
- if (!inString && line.trim() === '') {
39
- inEntry = false;
40
- }
41
- // odd number of ", we're in an unclosed string
42
- if (countChar(line, '"') % 2 === 1) {
43
- inString = !inString;
44
- }
45
- return acc;
46
- }, []);
47
- return unparsedEntries.map((lines) => stringAwareSplitLine(lines.join('\n')));
48
- };