beancount 0.1.0 → 0.2.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.
Files changed (71) hide show
  1. package/README.md +15 -16
  2. package/build/src/benchmark.mjs +1 -1
  3. package/build/src/classes/DatedNode.d.mts +40 -0
  4. package/build/src/classes/DatedNode.mjs +61 -0
  5. package/build/src/classes/Node.d.mts +92 -0
  6. package/build/src/classes/Node.mjs +107 -0
  7. package/build/src/classes/ParseResult.d.mts +75 -75
  8. package/build/src/classes/ParseResult.mjs +96 -98
  9. package/build/src/classes/nodes/Balance.d.mts +32 -0
  10. package/build/src/classes/nodes/Balance.mjs +50 -0
  11. package/build/src/classes/nodes/Blankline.d.mts +23 -0
  12. package/build/src/classes/nodes/Blankline.mjs +37 -0
  13. package/build/src/classes/nodes/Close.d.mts +20 -0
  14. package/build/src/classes/nodes/Close.mjs +31 -0
  15. package/build/src/classes/nodes/Comment.d.mts +25 -0
  16. package/build/src/classes/nodes/Comment.mjs +42 -0
  17. package/build/src/classes/nodes/Commodity.d.mts +20 -0
  18. package/build/src/classes/nodes/Commodity.mjs +31 -0
  19. package/build/src/classes/nodes/Custom.d.mts +23 -0
  20. package/build/src/classes/nodes/Custom.mjs +38 -0
  21. package/build/src/classes/nodes/Document.d.mts +22 -0
  22. package/build/src/classes/nodes/Document.mjs +34 -0
  23. package/build/src/classes/nodes/Event.d.mts +23 -0
  24. package/build/src/classes/nodes/Event.mjs +34 -0
  25. package/build/src/classes/nodes/Include.d.mts +20 -0
  26. package/build/src/classes/nodes/Include.mjs +31 -0
  27. package/build/src/classes/nodes/Note.d.mts +22 -0
  28. package/build/src/classes/nodes/Note.mjs +34 -0
  29. package/build/src/classes/nodes/Open.d.mts +27 -0
  30. package/build/src/classes/nodes/Open.mjs +66 -0
  31. package/build/src/classes/nodes/Option.d.mts +23 -0
  32. package/build/src/classes/nodes/Option.mjs +32 -0
  33. package/build/src/classes/nodes/Pad.d.mts +22 -0
  34. package/build/src/classes/nodes/Pad.mjs +33 -0
  35. package/build/src/classes/nodes/Plugin.d.mts +22 -0
  36. package/build/src/classes/nodes/Plugin.mjs +36 -0
  37. package/build/src/classes/nodes/Poptag.d.mts +21 -0
  38. package/build/src/classes/nodes/Poptag.mjs +34 -0
  39. package/build/src/classes/nodes/Price.d.mts +32 -0
  40. package/build/src/classes/nodes/Price.mjs +57 -0
  41. package/build/src/classes/nodes/Pushtag.d.mts +21 -0
  42. package/build/src/classes/nodes/Pushtag.mjs +34 -0
  43. package/build/src/classes/nodes/Query.d.mts +22 -0
  44. package/build/src/classes/nodes/Query.mjs +34 -0
  45. package/build/src/classes/nodes/Transaction/Posting.d.mts +59 -0
  46. package/build/src/classes/nodes/Transaction/Posting.mjs +97 -0
  47. package/build/src/classes/nodes/Transaction/Tag.d.mts +28 -0
  48. package/build/src/classes/nodes/Transaction/Tag.mjs +28 -0
  49. package/build/src/classes/nodes/Transaction/index.d.mts +70 -0
  50. package/build/src/classes/nodes/Transaction/index.mjs +193 -0
  51. package/build/src/classes/nodes/index.d.mts +19 -0
  52. package/build/src/classes/nodes/index.mjs +19 -0
  53. package/build/src/cli.mjs +4 -4
  54. package/build/src/deserialize.d.mts +54 -54
  55. package/build/src/deserialize.mjs +89 -89
  56. package/build/src/directiveTypes.d.mts +10 -0
  57. package/build/src/directiveTypes.mjs +29 -0
  58. package/build/src/genericParse.d.mts +27 -20
  59. package/build/src/genericParse.mjs +30 -30
  60. package/build/src/main.d.mts +30 -31
  61. package/build/src/main.mjs +30 -30
  62. package/build/src/nodeTypeToClass.d.mts +81 -0
  63. package/build/src/nodeTypeToClass.mjs +37 -0
  64. package/build/src/parse.d.mts +16 -16
  65. package/build/src/parse.mjs +37 -37
  66. package/build/src/parseFile.d.mts +2 -2
  67. package/build/src/parseFile.mjs +11 -11
  68. package/build/src/utils/splitStringIntoSourceFragments.d.ts +14 -0
  69. package/build/src/utils/splitStringIntoSourceFragments.js +48 -0
  70. package/build/tsconfig.build.tsbuildinfo +1 -1
  71. package/package.json +2 -2
@@ -0,0 +1,31 @@
1
+ import { assertNodeConstructor } from '../Node.mjs';
2
+ import { DatedNode } from '../DatedNode.mjs';
3
+ /**
4
+ * Represents a Commodity declaration node.
5
+ * Commodity directives declare the existence of a commodity/currency with metadata.
6
+ */
7
+ export class Commodity extends DatedNode {
8
+ constructor() {
9
+ super(...arguments);
10
+ /** @inheritdoc */
11
+ this.type = 'commodity';
12
+ }
13
+ /**
14
+ * Creates a Commodity instance from a generic parse result.
15
+ * @param genericParseResult - The parsed commodity node data
16
+ * @returns A new Commodity instance
17
+ */
18
+ static fromGenericParseResult(genericParseResult) {
19
+ const currency = genericParseResult.header.trim();
20
+ return new Commodity({
21
+ ...genericParseResult.props,
22
+ currency,
23
+ });
24
+ }
25
+ /** @inheritdoc */
26
+ toString() {
27
+ return `${this.getDateTypePrefix()} ${this.currency}${this.getMetaDataString()}`;
28
+ }
29
+ }
30
+ // Ensure class conforms to NodeConstructor pattern
31
+ assertNodeConstructor(Commodity);
@@ -0,0 +1,23 @@
1
+ import type { GenericParseResultWithDate } from '../../genericParse.mjs';
2
+ import { DatedNode } from '../DatedNode.mjs';
3
+ import { Value } from '../Value.mjs';
4
+ /**
5
+ * Represents a Custom node for user-defined directives.
6
+ * Custom directives allow for extensibility with arbitrary types and values.
7
+ */
8
+ export declare class Custom extends DatedNode {
9
+ /** @inheritdoc */
10
+ type: "custom";
11
+ /** The custom directive type */
12
+ customType: Value;
13
+ /** Optional array of values associated with the custom directive */
14
+ values?: Value[];
15
+ /**
16
+ * Creates a Custom instance from a generic parse result.
17
+ * @param genericParseResult - The parsed custom node data
18
+ * @returns A new Custom instance
19
+ */
20
+ static fromGenericParseResult(genericParseResult: GenericParseResultWithDate): Custom;
21
+ /** @inheritdoc */
22
+ toString(): string;
23
+ }
@@ -0,0 +1,38 @@
1
+ import { assertNodeConstructor } from '../Node.mjs';
2
+ import { DatedNode } from '../DatedNode.mjs';
3
+ import { simpleParseLine } from '../../utils/simpleParseLine.mjs';
4
+ import { Value } from '../Value.mjs';
5
+ /**
6
+ * Represents a Custom node for user-defined directives.
7
+ * Custom directives allow for extensibility with arbitrary types and values.
8
+ */
9
+ export class Custom extends DatedNode {
10
+ constructor() {
11
+ super(...arguments);
12
+ /** @inheritdoc */
13
+ this.type = 'custom';
14
+ }
15
+ /**
16
+ * Creates a Custom instance from a generic parse result.
17
+ * @param genericParseResult - The parsed custom node data
18
+ * @returns A new Custom instance
19
+ */
20
+ static fromGenericParseResult(genericParseResult) {
21
+ const [customType, ...others] = simpleParseLine(genericParseResult.header);
22
+ return new Custom({
23
+ ...genericParseResult.props,
24
+ customType: Value.fromString(customType),
25
+ values: others.length > 0 ? others.map((o) => Value.fromString(o)) : undefined,
26
+ });
27
+ }
28
+ /** @inheritdoc */
29
+ toString() {
30
+ const parts = [`${this.getDateTypePrefix()} ${this.customType.toString()}`];
31
+ if (this.values !== undefined) {
32
+ parts.push(...this.values.map((v) => v.toString()));
33
+ }
34
+ return parts.join(' ') + this.getMetaDataString();
35
+ }
36
+ }
37
+ // Ensure class conforms to NodeConstructor pattern
38
+ assertNodeConstructor(Custom);
@@ -0,0 +1,22 @@
1
+ import type { GenericParseResultWithDate } from '../../genericParse.mjs';
2
+ import { DatedNode } from '../DatedNode.mjs';
3
+ /**
4
+ * Represents a Document node that links an external file to an account.
5
+ * Document directives associate receipts, statements, or other files with accounts.
6
+ */
7
+ export declare class Document extends DatedNode {
8
+ /** @inheritdoc */
9
+ type: "document";
10
+ /** The account the document is associated with */
11
+ account: string;
12
+ /** The file path to the document */
13
+ pathToDocument: string;
14
+ /**
15
+ * Creates a Document instance from a generic parse result.
16
+ * @param genericParseResult - The parsed document node data
17
+ * @returns A new Document instance
18
+ */
19
+ static fromGenericParseResult(genericParseResult: GenericParseResultWithDate): Document;
20
+ /** @inheritdoc */
21
+ toString(): string;
22
+ }
@@ -0,0 +1,34 @@
1
+ import { assertNodeConstructor } from '../Node.mjs';
2
+ import { DatedNode } from '../DatedNode.mjs';
3
+ import { parseString } from '../Value.mjs';
4
+ import { stringAwareParseLine } from '../../utils/stringAwareParseLine.mjs';
5
+ /**
6
+ * Represents a Document node that links an external file to an account.
7
+ * Document directives associate receipts, statements, or other files with accounts.
8
+ */
9
+ export class Document extends DatedNode {
10
+ constructor() {
11
+ super(...arguments);
12
+ /** @inheritdoc */
13
+ this.type = 'document';
14
+ }
15
+ /**
16
+ * Creates a Document instance from a generic parse result.
17
+ * @param genericParseResult - The parsed document node data
18
+ * @returns A new Document instance
19
+ */
20
+ static fromGenericParseResult(genericParseResult) {
21
+ const [account, pathToDocument] = stringAwareParseLine(genericParseResult.header);
22
+ return new Document({
23
+ ...genericParseResult.props,
24
+ account,
25
+ pathToDocument: parseString(pathToDocument),
26
+ });
27
+ }
28
+ /** @inheritdoc */
29
+ toString() {
30
+ return `${this.getDateTypePrefix()} ${this.account} "${this.pathToDocument}"${this.getMetaDataString()}`;
31
+ }
32
+ }
33
+ // Ensure class conforms to NodeConstructor pattern
34
+ assertNodeConstructor(Document);
@@ -0,0 +1,23 @@
1
+ import type { GenericParseResultWithDate } from '../../genericParse.mjs';
2
+ import { DatedNode } from '../DatedNode.mjs';
3
+ import { Value } from '../Value.mjs';
4
+ /**
5
+ * Represents an Event node that records a named event with a value.
6
+ * Event directives track occurrences of specific events over time.
7
+ */
8
+ export declare class Event extends DatedNode {
9
+ /** @inheritdoc */
10
+ type: "event";
11
+ /** The name of the event */
12
+ name: string;
13
+ /** The value associated with the event */
14
+ value: Value;
15
+ /**
16
+ * Creates an Event instance from a generic parse result.
17
+ * @param genericParseResult - The parsed event node data
18
+ * @returns A new Event instance
19
+ */
20
+ static fromGenericParseResult(genericParseResult: GenericParseResultWithDate): Event;
21
+ /** @inheritdoc */
22
+ toString(): string;
23
+ }
@@ -0,0 +1,34 @@
1
+ import { assertNodeConstructor } from '../Node.mjs';
2
+ import { DatedNode } from '../DatedNode.mjs';
3
+ import { parseString, Value } from '../Value.mjs';
4
+ import { stringAwareParseLine } from '../../utils/stringAwareParseLine.mjs';
5
+ /**
6
+ * Represents an Event node that records a named event with a value.
7
+ * Event directives track occurrences of specific events over time.
8
+ */
9
+ export class Event extends DatedNode {
10
+ constructor() {
11
+ super(...arguments);
12
+ /** @inheritdoc */
13
+ this.type = 'event';
14
+ }
15
+ /**
16
+ * Creates an Event instance from a generic parse result.
17
+ * @param genericParseResult - The parsed event node data
18
+ * @returns A new Event instance
19
+ */
20
+ static fromGenericParseResult(genericParseResult) {
21
+ const [name, value] = stringAwareParseLine(genericParseResult.header);
22
+ return new Event({
23
+ ...genericParseResult.props,
24
+ name: parseString(name),
25
+ value: Value.fromString(value),
26
+ });
27
+ }
28
+ /** @inheritdoc */
29
+ toString() {
30
+ return `${this.getDateTypePrefix()} "${this.name}" ${this.value.toString()}${this.getMetaDataString()}`;
31
+ }
32
+ }
33
+ // Ensure class conforms to NodeConstructor pattern
34
+ assertNodeConstructor(Event);
@@ -0,0 +1,20 @@
1
+ import type { GenericParseResult } from '../../genericParse.mjs';
2
+ import { Node } from '../Node.mjs';
3
+ /**
4
+ * Represents an Include node that includes another Beancount file.
5
+ * Include directives allow splitting ledgers across multiple files.
6
+ */
7
+ export declare class Include extends Node {
8
+ /** @inheritdoc */
9
+ type: "include";
10
+ /** The filename/path of the file to include */
11
+ filename: string;
12
+ /**
13
+ * Creates an Include instance from a generic parse result.
14
+ * @param genericParseResult - The parsed include node data
15
+ * @returns A new Include instance
16
+ */
17
+ static fromGenericParseResult(genericParseResult: GenericParseResult): Include;
18
+ /** @inheritdoc */
19
+ toString(): string;
20
+ }
@@ -0,0 +1,31 @@
1
+ import { parseString } from '../Value.mjs';
2
+ import { stringAwareParseLine } from '../../utils/stringAwareParseLine.mjs';
3
+ import { assertNodeConstructor, Node } from '../Node.mjs';
4
+ /**
5
+ * Represents an Include node that includes another Beancount file.
6
+ * Include directives allow splitting ledgers across multiple files.
7
+ */
8
+ export class Include extends Node {
9
+ constructor() {
10
+ super(...arguments);
11
+ /** @inheritdoc */
12
+ this.type = 'include';
13
+ }
14
+ /**
15
+ * Creates an Include instance from a generic parse result.
16
+ * @param genericParseResult - The parsed include node data
17
+ * @returns A new Include instance
18
+ */
19
+ static fromGenericParseResult(genericParseResult) {
20
+ const [filename] = stringAwareParseLine(genericParseResult.header);
21
+ return new Include({
22
+ filename: parseString(filename),
23
+ });
24
+ }
25
+ /** @inheritdoc */
26
+ toString() {
27
+ return `${this.type} "${this.filename}"`;
28
+ }
29
+ }
30
+ // Ensure class conforms to NodeConstructor pattern
31
+ assertNodeConstructor(Include);
@@ -0,0 +1,22 @@
1
+ import type { GenericParseResultWithDate } from '../../genericParse.mjs';
2
+ import { DatedNode } from '../DatedNode.mjs';
3
+ /**
4
+ * Represents a Note node that attaches a comment to an account.
5
+ * Note directives associate free-form text descriptions with accounts at specific dates.
6
+ */
7
+ export declare class Note extends DatedNode {
8
+ /** @inheritdoc */
9
+ type: "note";
10
+ /** The account the note is attached to */
11
+ account: string;
12
+ /** The note description text */
13
+ description: string;
14
+ /**
15
+ * Creates a Note instance from a generic parse result.
16
+ * @param genericParseResult - The parsed note node data
17
+ * @returns A new Note instance
18
+ */
19
+ static fromGenericParseResult(genericParseResult: GenericParseResultWithDate): Note;
20
+ /** @inheritdoc */
21
+ toString(): string;
22
+ }
@@ -0,0 +1,34 @@
1
+ import { assertNodeConstructor } from '../Node.mjs';
2
+ import { DatedNode } from '../DatedNode.mjs';
3
+ import { parseString } from '../Value.mjs';
4
+ import { stringAwareParseLine } from '../../utils/stringAwareParseLine.mjs';
5
+ /**
6
+ * Represents a Note node that attaches a comment to an account.
7
+ * Note directives associate free-form text descriptions with accounts at specific dates.
8
+ */
9
+ export class Note extends DatedNode {
10
+ constructor() {
11
+ super(...arguments);
12
+ /** @inheritdoc */
13
+ this.type = 'note';
14
+ }
15
+ /**
16
+ * Creates a Note instance from a generic parse result.
17
+ * @param genericParseResult - The parsed note node data
18
+ * @returns A new Note instance
19
+ */
20
+ static fromGenericParseResult(genericParseResult) {
21
+ const [account, description] = stringAwareParseLine(genericParseResult.header);
22
+ return new Note({
23
+ ...genericParseResult.props,
24
+ account,
25
+ description: parseString(description),
26
+ });
27
+ }
28
+ /** @inheritdoc */
29
+ toString() {
30
+ return `${this.getDateTypePrefix()} ${this.account} "${this.description}"${this.getMetaDataString()}`;
31
+ }
32
+ }
33
+ // Ensure class conforms to NodeConstructor pattern
34
+ assertNodeConstructor(Note);
@@ -0,0 +1,27 @@
1
+ import type { GenericParseResultWithDate } from '../../genericParse.mjs';
2
+ import { DatedNode } from '../DatedNode.mjs';
3
+ import { FormatOptions } from '../ParseResult.mjs';
4
+ /**
5
+ * Represents an Open node that declares a new account.
6
+ * Open directives define the beginning of an account's lifespan.
7
+ */
8
+ export declare class Open extends DatedNode {
9
+ /** @inheritdoc */
10
+ type: "open";
11
+ /** The account name being opened */
12
+ account: string;
13
+ /** Optional list of allowed currencies for this account */
14
+ constraintCurrencies?: string[];
15
+ /** Optional booking method specification */
16
+ bookingMethod?: string;
17
+ /**
18
+ * Creates an Open instance from a generic parse result.
19
+ * @param genericParseResult - The parsed open node data
20
+ * @returns A new Open instance
21
+ */
22
+ static fromGenericParseResult(genericParseResult: GenericParseResultWithDate): Open;
23
+ /** @inheritdoc */
24
+ toString(): string;
25
+ /** @inheritdoc */
26
+ toFormattedString(formatOptions?: FormatOptions): string;
27
+ }
@@ -0,0 +1,66 @@
1
+ import { assertNodeConstructor } from '../Node.mjs';
2
+ import { DatedNode } from '../DatedNode.mjs';
3
+ import { simpleParseLine } from '../../utils/simpleParseLine.mjs';
4
+ import { parseString } from '../Value.mjs';
5
+ import { defaultFormatOptions } from '../ParseResult.mjs';
6
+ /**
7
+ * Represents an Open node that declares a new account.
8
+ * Open directives define the beginning of an account's lifespan.
9
+ */
10
+ export class Open extends DatedNode {
11
+ constructor() {
12
+ super(...arguments);
13
+ /** @inheritdoc */
14
+ this.type = 'open';
15
+ }
16
+ /**
17
+ * Creates an Open instance from a generic parse result.
18
+ * @param genericParseResult - The parsed open node data
19
+ * @returns A new Open instance
20
+ */
21
+ static fromGenericParseResult(genericParseResult) {
22
+ const [account, ...other] = simpleParseLine(genericParseResult.header);
23
+ let constraintCurrencies, bookingMethod;
24
+ if (other.length === 2) {
25
+ constraintCurrencies = other[0];
26
+ bookingMethod = parseString(other[1]);
27
+ }
28
+ else if (other.length === 1) {
29
+ if (other[0].startsWith('"') && other[0].endsWith('"')) {
30
+ bookingMethod = parseString(other[0]);
31
+ }
32
+ else {
33
+ constraintCurrencies = other[0];
34
+ }
35
+ }
36
+ return new Open({
37
+ ...genericParseResult.props,
38
+ account,
39
+ constraintCurrencies: constraintCurrencies?.split(','),
40
+ bookingMethod,
41
+ });
42
+ }
43
+ /** @inheritdoc */
44
+ toString() {
45
+ return this.toFormattedString({ currencyColumn: 0 });
46
+ }
47
+ /** @inheritdoc */
48
+ toFormattedString(formatOptions = defaultFormatOptions) {
49
+ const parts = [`${this.getDateTypePrefix()} ${this.account}`];
50
+ if (this.constraintCurrencies !== undefined) {
51
+ const paddingLength = formatOptions.currencyColumn -
52
+ parts.join(' ').length -
53
+ this.constraintCurrencies.join(',').length;
54
+ if (paddingLength > 0) {
55
+ parts.push(' '.repeat(paddingLength));
56
+ }
57
+ parts.push(this.constraintCurrencies.join(','));
58
+ }
59
+ if (this.bookingMethod !== undefined) {
60
+ parts.push(`"${this.bookingMethod}"`);
61
+ }
62
+ return parts.join(' ') + this.getMetaDataString();
63
+ }
64
+ }
65
+ // Ensure class conforms to NodeConstructor pattern
66
+ assertNodeConstructor(Open);
@@ -0,0 +1,23 @@
1
+ import type { GenericParseResult } from '../../genericParse.mjs';
2
+ import { Value } from '../Value.mjs';
3
+ import { Node } from '../Node.mjs';
4
+ /**
5
+ * Represents an Option node that sets a Beancount configuration option.
6
+ * Option directives configure various aspects of Beancount's behavior.
7
+ */
8
+ export declare class Option extends Node {
9
+ /** @inheritdoc */
10
+ type: "option";
11
+ /** The option name */
12
+ name: string;
13
+ /** The option value */
14
+ value: Value;
15
+ /**
16
+ * Creates an Option instance from a generic parse result.
17
+ * @param genericParseResult - The parsed option node data
18
+ * @returns A new Option instance
19
+ */
20
+ static fromGenericParseResult(genericParseResult: GenericParseResult): Option;
21
+ /** @inheritdoc */
22
+ toString(): string;
23
+ }
@@ -0,0 +1,32 @@
1
+ import { parseString, Value } from '../Value.mjs';
2
+ import { stringAwareParseLine } from '../../utils/stringAwareParseLine.mjs';
3
+ import { assertNodeConstructor, Node } from '../Node.mjs';
4
+ /**
5
+ * Represents an Option node that sets a Beancount configuration option.
6
+ * Option directives configure various aspects of Beancount's behavior.
7
+ */
8
+ export class Option extends Node {
9
+ constructor() {
10
+ super(...arguments);
11
+ /** @inheritdoc */
12
+ this.type = 'option';
13
+ }
14
+ /**
15
+ * Creates an Option instance from a generic parse result.
16
+ * @param genericParseResult - The parsed option node data
17
+ * @returns A new Option instance
18
+ */
19
+ static fromGenericParseResult(genericParseResult) {
20
+ const [name, value] = stringAwareParseLine(genericParseResult.header);
21
+ return new Option({
22
+ name: parseString(name),
23
+ value: Value.fromString(value),
24
+ });
25
+ }
26
+ /** @inheritdoc */
27
+ toString() {
28
+ return `${this.type} "${this.name}" ${this.value.toString()}`;
29
+ }
30
+ }
31
+ // Ensure class conforms to NodeConstructor pattern
32
+ assertNodeConstructor(Option);
@@ -0,0 +1,22 @@
1
+ import type { GenericParseResultWithDate } from '../../genericParse.mjs';
2
+ import { DatedNode } from '../DatedNode.mjs';
3
+ /**
4
+ * Represents a Pad node that automatically balances accounts.
5
+ * Pad directives insert transactions to bring an account to a specific balance.
6
+ */
7
+ export declare class Pad extends DatedNode {
8
+ /** @inheritdoc */
9
+ type: "pad";
10
+ /** The account to be padded/balanced */
11
+ account: string;
12
+ /** The source account to use for padding */
13
+ accountPad: string;
14
+ /**
15
+ * Creates a Pad instance from a generic parse result.
16
+ * @param genericParseResult - The parsed pad node data
17
+ * @returns A new Pad instance
18
+ */
19
+ static fromGenericParseResult(genericParseResult: GenericParseResultWithDate): Pad;
20
+ /** @inheritdoc */
21
+ toString(): string;
22
+ }
@@ -0,0 +1,33 @@
1
+ import { assertNodeConstructor } from '../Node.mjs';
2
+ import { DatedNode } from '../DatedNode.mjs';
3
+ import { simpleParseLine } from '../../utils/simpleParseLine.mjs';
4
+ /**
5
+ * Represents a Pad node that automatically balances accounts.
6
+ * Pad directives insert transactions to bring an account to a specific balance.
7
+ */
8
+ export class Pad extends DatedNode {
9
+ constructor() {
10
+ super(...arguments);
11
+ /** @inheritdoc */
12
+ this.type = 'pad';
13
+ }
14
+ /**
15
+ * Creates a Pad instance from a generic parse result.
16
+ * @param genericParseResult - The parsed pad node data
17
+ * @returns A new Pad instance
18
+ */
19
+ static fromGenericParseResult(genericParseResult) {
20
+ const [account, accountPad] = simpleParseLine(genericParseResult.header);
21
+ return new Pad({
22
+ ...genericParseResult.props,
23
+ account,
24
+ accountPad,
25
+ });
26
+ }
27
+ /** @inheritdoc */
28
+ toString() {
29
+ return `${this.getDateTypePrefix()} ${this.account} ${this.accountPad}${this.getMetaDataString()}`;
30
+ }
31
+ }
32
+ // Ensure class conforms to NodeConstructor pattern
33
+ assertNodeConstructor(Pad);
@@ -0,0 +1,22 @@
1
+ import type { GenericParseResult } from '../../genericParse.mjs';
2
+ import { Node } from '../Node.mjs';
3
+ /**
4
+ * Represents a Plugin node that loads a Beancount plugin.
5
+ * Plugin directives enable plugins to process the ledger.
6
+ */
7
+ export declare class Plugin extends Node {
8
+ /** @inheritdoc */
9
+ type: "plugin";
10
+ /** The Python module name of the plugin */
11
+ moduleName: string;
12
+ /** Optional configuration string for the plugin */
13
+ config?: string;
14
+ /**
15
+ * Creates a Plugin instance from a generic parse result.
16
+ * @param genericParseResult - The parsed plugin node data
17
+ * @returns A new Plugin instance
18
+ */
19
+ static fromGenericParseResult(genericParseResult: GenericParseResult): Plugin;
20
+ /** @inheritdoc */
21
+ toString(): string;
22
+ }
@@ -0,0 +1,36 @@
1
+ import { parseString } from '../Value.mjs';
2
+ import { stringAwareParseLine } from '../../utils/stringAwareParseLine.mjs';
3
+ import { assertNodeConstructor, Node } from '../Node.mjs';
4
+ /**
5
+ * Represents a Plugin node that loads a Beancount plugin.
6
+ * Plugin directives enable plugins to process the ledger.
7
+ */
8
+ export class Plugin extends Node {
9
+ constructor() {
10
+ super(...arguments);
11
+ /** @inheritdoc */
12
+ this.type = 'plugin';
13
+ }
14
+ /**
15
+ * Creates a Plugin instance from a generic parse result.
16
+ * @param genericParseResult - The parsed plugin node data
17
+ * @returns A new Plugin instance
18
+ */
19
+ static fromGenericParseResult(genericParseResult) {
20
+ const [moduleName, config] = stringAwareParseLine(genericParseResult.header);
21
+ return new Plugin({
22
+ moduleName: parseString(moduleName),
23
+ config: config ? parseString(config) : undefined,
24
+ });
25
+ }
26
+ /** @inheritdoc */
27
+ toString() {
28
+ const parts = [`${this.type} "${this.moduleName}"`];
29
+ if (this.config !== undefined) {
30
+ parts.push(`"${this.config}"`);
31
+ }
32
+ return parts.join(' ');
33
+ }
34
+ }
35
+ // Ensure class conforms to NodeConstructor pattern
36
+ assertNodeConstructor(Plugin);
@@ -0,0 +1,21 @@
1
+ import type { GenericParseResult } from '../../genericParse.mjs';
2
+ import { Node } from '../Node.mjs';
3
+ import { Tag } from './Transaction/Tag.mjs';
4
+ /**
5
+ * Represents a Poptag node that removes a tag from the tag stack.
6
+ * Transactions after this will no longer inherit the popped tag.
7
+ */
8
+ export declare class Poptag extends Node {
9
+ /** @inheritdoc */
10
+ type: "poptag";
11
+ /** The tag being popped from the stack */
12
+ tag: Tag;
13
+ /**
14
+ * Creates a Poptag instance from a generic parse result.
15
+ * @param genericParseResult - The parsed poptag node data
16
+ * @returns A new Poptag instance
17
+ */
18
+ static fromGenericParseResult(genericParseResult: GenericParseResult): Poptag;
19
+ /** @inheritdoc */
20
+ toString(): string;
21
+ }
@@ -0,0 +1,34 @@
1
+ import { simpleParseLine } from '../../utils/simpleParseLine.mjs';
2
+ import { assertNodeConstructor, Node } from '../Node.mjs';
3
+ import { Tag } from './Transaction/Tag.mjs';
4
+ /**
5
+ * Represents a Poptag node that removes a tag from the tag stack.
6
+ * Transactions after this will no longer inherit the popped tag.
7
+ */
8
+ export class Poptag extends Node {
9
+ constructor() {
10
+ super(...arguments);
11
+ /** @inheritdoc */
12
+ this.type = 'poptag';
13
+ }
14
+ /**
15
+ * Creates a Poptag instance from a generic parse result.
16
+ * @param genericParseResult - The parsed poptag node data
17
+ * @returns A new Poptag instance
18
+ */
19
+ static fromGenericParseResult(genericParseResult) {
20
+ const [tagContent] = simpleParseLine(genericParseResult.header);
21
+ return new Poptag({
22
+ tag: new Tag({
23
+ content: tagContent.trim().replace(/^#/, ''),
24
+ fromStack: true,
25
+ }),
26
+ });
27
+ }
28
+ /** @inheritdoc */
29
+ toString() {
30
+ return `poptag #${this.tag.content}`;
31
+ }
32
+ }
33
+ // Ensure class conforms to NodeConstructor pattern
34
+ assertNodeConstructor(Poptag);