bkper-js 2.28.0 → 2.29.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/lib/index.d.ts CHANGED
@@ -182,6 +182,81 @@ export declare class Account extends ResourceProperty<bkper.Account> {
182
182
 
183
183
  }
184
184
 
185
+ /**
186
+ * A AccountsDataTableBuilder is used to setup and build two-dimensional arrays containing accounts.
187
+ *
188
+ * @public
189
+ */
190
+ export declare class AccountsDataTableBuilder {
191
+ private accounts;
192
+ private shouldIncludeArchived;
193
+ private shouldAddGroups;
194
+ private shouldAddProperties;
195
+ private shouldAddIds;
196
+ private shouldAddHiddenProperties;
197
+ private propertyKeys;
198
+ constructor(accounts: Account[]);
199
+ /**
200
+ * Defines whether the archived accounts should be included.
201
+ *
202
+ * @param include - Whether to include archived accounts
203
+ *
204
+ * @returns This builder with respective include archived option, for chaining.
205
+ */
206
+ archived(include: boolean): AccountsDataTableBuilder;
207
+ /**
208
+ * Defines whether include account groups.
209
+ *
210
+ * @param include - Whether to include groups
211
+ *
212
+ * @returns This builder with respective include groups option, for chaining.
213
+ */
214
+ groups(include: boolean): AccountsDataTableBuilder;
215
+ /**
216
+ * Defines whether include custom account properties.
217
+ *
218
+ * @param include - Whether to include properties
219
+ *
220
+ * @returns This builder with respective include properties option, for chaining.
221
+ */
222
+ properties(include: boolean): AccountsDataTableBuilder;
223
+ /**
224
+ * Defines whether include account ids.
225
+ *
226
+ * @param include - Whether to include ids
227
+ *
228
+ * @returns This builder with respective include ids option, for chaining.
229
+ */
230
+ ids(include: boolean): AccountsDataTableBuilder;
231
+ /**
232
+ * Defines whether to include hidden properties (keys ending with underscore "_").
233
+ * Only relevant when {@link properties} is enabled.
234
+ * Default is false — hidden properties are excluded.
235
+ *
236
+ * @param include - Whether to include hidden properties
237
+ *
238
+ * @returns This builder with respective option, for chaining.
239
+ */
240
+ hiddenProperties(include: boolean): AccountsDataTableBuilder;
241
+ private getPropertyKeys;
242
+ private getTypeIndex;
243
+ private getMaxNumberOfGroups;
244
+ /**
245
+ * Sorts groups for an account in hierarchy-path order:
246
+ * 1. Hierarchical groups (those with parent or children) come first, ordered by:
247
+ * - Root group name (alphabetically)
248
+ * - Depth within the hierarchy (parent before child)
249
+ * 2. Free groups (no parent and no children) come last, sorted alphabetically
250
+ */
251
+ private sortGroupsHierarchyPath_;
252
+ /**
253
+ * Builds a two-dimensional array containing all accounts.
254
+ *
255
+ * @returns A promise resolving to a two-dimensional array containing all accounts
256
+ */
257
+ build(): Promise<any[][]>;
258
+ }
259
+
185
260
  /**
186
261
  * Enum that represents account types.
187
262
  *
@@ -939,6 +1014,7 @@ export declare class BalancesDataTableBuilder implements BalancesDataTableBuilde
939
1014
  private shouldPeriod;
940
1015
  private shouldRaw;
941
1016
  private shouldAddProperties;
1017
+ private shouldAddHiddenProperties;
942
1018
  private maxDepth;
943
1019
  private expandAllAccounts;
944
1020
  private expandAllGroups;
@@ -1058,6 +1134,16 @@ export declare class BalancesDataTableBuilder implements BalancesDataTableBuilde
1058
1134
  * @returns This builder with respective include properties option, for chaining.
1059
1135
  */
1060
1136
  properties(include: boolean): BalancesDataTableBuilder;
1137
+ /**
1138
+ * Defines whether to include hidden properties (keys ending with underscore "_").
1139
+ * Only relevant when {@link properties} is enabled.
1140
+ * Default is false — hidden properties are excluded.
1141
+ *
1142
+ * @param include - Whether to include hidden properties
1143
+ *
1144
+ * @returns This builder with respective option, for chaining.
1145
+ */
1146
+ hiddenProperties(include: boolean): BalancesDataTableBuilder;
1061
1147
  /**
1062
1148
  * Defines whether should split **TOTAL** [[BalanceType]] into debit and credit.
1063
1149
  *
@@ -2002,6 +2088,78 @@ export declare class Book extends ResourceProperty<bkper.Book> {
2002
2088
  * @returns The Backlog object
2003
2089
  */
2004
2090
  getBacklog(): Promise<Backlog>;
2091
+ /**
2092
+ * Create a {@link AccountsDataTableBuilder}, to build two dimensional Array representations of {@link Account} dataset.
2093
+ *
2094
+ * @param accounts - Optional array of accounts. If not provided, all accounts will be fetched.
2095
+ *
2096
+ * @returns Accounts data table builder.
2097
+ */
2098
+ createAccountsDataTable(accounts?: Account[]): Promise<AccountsDataTableBuilder>;
2099
+ /**
2100
+ * Create a {@link GroupsDataTableBuilder}, to build two dimensional Array representations of {@link Group} dataset.
2101
+ *
2102
+ * @param groups - Optional array of groups. If not provided, all groups will be fetched.
2103
+ *
2104
+ * @returns Groups data table builder.
2105
+ */
2106
+ createGroupsDataTable(groups?: Group[]): Promise<GroupsDataTableBuilder>;
2107
+ /**
2108
+ * Create a {@link TransactionsDataTableBuilder}, to build two dimensional Array representations of {@link Transaction} dataset.
2109
+ *
2110
+ * @param transactions - Array of transactions to include in the table.
2111
+ * @param account - Optional account for balance column display.
2112
+ *
2113
+ * @returns Transactions data table builder.
2114
+ */
2115
+ createTransactionsDataTable(transactions: Transaction[], account?: Account): TransactionsDataTableBuilder;
2116
+ }
2117
+
2118
+ /**
2119
+ * A BooksDataTableBuilder is used to setup and build two-dimensional arrays containing books.
2120
+ *
2121
+ * @public
2122
+ */
2123
+ export declare class BooksDataTableBuilder {
2124
+ private books;
2125
+ private shouldAddProperties;
2126
+ private shouldAddIds;
2127
+ private shouldAddHiddenProperties;
2128
+ private propertyKeys;
2129
+ constructor(books: Book[]);
2130
+ /**
2131
+ * Defines whether to include custom book properties.
2132
+ *
2133
+ * @param include - Whether to include properties
2134
+ *
2135
+ * @returns This builder with respective include properties option, for chaining.
2136
+ */
2137
+ properties(include: boolean): BooksDataTableBuilder;
2138
+ /**
2139
+ * Defines whether to include book ids.
2140
+ *
2141
+ * @param include - Whether to include ids
2142
+ *
2143
+ * @returns This builder with respective include ids option, for chaining.
2144
+ */
2145
+ ids(include: boolean): BooksDataTableBuilder;
2146
+ /**
2147
+ * Defines whether to include hidden properties (keys ending with underscore "_").
2148
+ * Only relevant when {@link properties} is enabled.
2149
+ * Default is false — hidden properties are excluded.
2150
+ *
2151
+ * @param include - Whether to include hidden properties
2152
+ *
2153
+ * @returns This builder with respective option, for chaining.
2154
+ */
2155
+ hiddenProperties(include: boolean): BooksDataTableBuilder;
2156
+ private mapPropertyKeys;
2157
+ /**
2158
+ * Builds a two-dimensional array containing all Books.
2159
+ *
2160
+ * @returns A two-dimensional array containing all Books
2161
+ */
2162
+ build(): any[][];
2005
2163
  }
2006
2164
 
2007
2165
  /**
@@ -2861,6 +3019,70 @@ export declare class Group extends ResourceProperty<bkper.Group> {
2861
3019
 
2862
3020
  }
2863
3021
 
3022
+ /**
3023
+ * A GroupsDataTableBuilder is used to setup and build two-dimensional arrays containing groups.
3024
+ *
3025
+ * @public
3026
+ */
3027
+ export declare class GroupsDataTableBuilder {
3028
+ private groups;
3029
+ private shouldAddProperties;
3030
+ private shouldAddIds;
3031
+ private shouldAddHiddenProperties;
3032
+ private shouldShowTree;
3033
+ private propertyKeys;
3034
+ constructor(groups: Group[]);
3035
+ /**
3036
+ * Defines whether include custom group properties.
3037
+ *
3038
+ * @param include - Whether to include properties
3039
+ *
3040
+ * @returns This builder with respective include properties option, for chaining.
3041
+ */
3042
+ properties(include: boolean): GroupsDataTableBuilder;
3043
+ /**
3044
+ * Defines whether include group ids.
3045
+ *
3046
+ * @param include - Whether to include ids
3047
+ *
3048
+ * @returns This builder with respective include ids option, for chaining.
3049
+ */
3050
+ ids(include: boolean): GroupsDataTableBuilder;
3051
+ /**
3052
+ * Defines whether to include hidden properties (keys ending with underscore "_").
3053
+ * Only relevant when {@link properties} is enabled.
3054
+ * Default is false — hidden properties are excluded.
3055
+ *
3056
+ * @param include - Whether to include hidden properties
3057
+ *
3058
+ * @returns This builder with respective option, for chaining.
3059
+ */
3060
+ hiddenProperties(include: boolean): GroupsDataTableBuilder;
3061
+ /**
3062
+ * Defines whether to render groups as an indented tree instead of flat rows with a Parent column.
3063
+ * When enabled, child group names are indented by depth level and the Parent column is removed.
3064
+ * Default is false.
3065
+ *
3066
+ * @param enable - Whether to enable tree rendering
3067
+ *
3068
+ * @returns This builder with respective option, for chaining.
3069
+ */
3070
+ tree(enable: boolean): GroupsDataTableBuilder;
3071
+ private mapPropertyKeys;
3072
+ private getStringType;
3073
+ private getTypeIndex;
3074
+ private getHasChildrenIndex;
3075
+ /**
3076
+ * Builds a two-dimensional array containing all Groups.
3077
+ *
3078
+ * @returns A two-dimensional array containing all Groups
3079
+ */
3080
+ build(): any[][];
3081
+ private buildGroupLine;
3082
+ private traverse;
3083
+ private readonly COMPARATOR;
3084
+ }
3085
+
2864
3086
  /**
2865
3087
  * This class defines a Integration from an [[User]] to an external service.
2866
3088
  *
@@ -3375,6 +3597,12 @@ export declare class Transaction extends ResourceProperty<bkper.Transaction> {
3375
3597
  * @returns True if a transaction is locked by the book lock/closing date
3376
3598
  */
3377
3599
  isLocked(): boolean;
3600
+ /**
3601
+ * Gets the status of the transaction.
3602
+ *
3603
+ * @returns The status of the Transaction
3604
+ */
3605
+ getStatus(): TransactionStatus;
3378
3606
  /**
3379
3607
  * Gets all hashtags used in the transaction.
3380
3608
  *
@@ -3736,6 +3964,145 @@ export declare class TransactionList {
3736
3964
  getItems(): Transaction[];
3737
3965
  }
3738
3966
 
3967
+ /**
3968
+ * A TransactionsDataTableBuilder is used to setup and build two-dimensional arrays containing transactions.
3969
+ *
3970
+ * @public
3971
+ */
3972
+ export declare class TransactionsDataTableBuilder {
3973
+ private book;
3974
+ private transactions;
3975
+ private account;
3976
+ private shouldFormatDates;
3977
+ private shouldFormatValues;
3978
+ private shouldAddUrls;
3979
+ private shouldAddProperties;
3980
+ private shouldAddIds;
3981
+ private shouldAddRecordedAt;
3982
+ private shouldAddHiddenProperties;
3983
+ private propertyKeys;
3984
+ private attachmentHeaders;
3985
+ private remoteIdHeaders;
3986
+ constructor(book: Book, transactions: Transaction[], account?: Account);
3987
+ /**
3988
+ * Defines whether the dates should be formatted, based on date pattern of the [[Book]].
3989
+ *
3990
+ * @param format - Whether to format dates
3991
+ *
3992
+ * @returns This builder with respective formatting option, for chaining.
3993
+ */
3994
+ formatDates(format: boolean): TransactionsDataTableBuilder;
3995
+ /**
3996
+ * Defines whether amounts should be formatted based on [[DecimalSeparator]] of the [[Book]].
3997
+ *
3998
+ * @param format - Whether to format values
3999
+ *
4000
+ * @returns This builder with respective formatting option, for chaining.
4001
+ */
4002
+ formatValues(format: boolean): TransactionsDataTableBuilder;
4003
+ /**
4004
+ * Defines whether to include attachments and url links.
4005
+ *
4006
+ * @param include - Whether to include URLs
4007
+ *
4008
+ * @returns This builder with respective option, for chaining.
4009
+ */
4010
+ urls(include: boolean): TransactionsDataTableBuilder;
4011
+ /**
4012
+ * Defines whether to include custom transaction properties.
4013
+ *
4014
+ * @param include - Whether to include properties
4015
+ *
4016
+ * @returns This builder with respective option, for chaining.
4017
+ */
4018
+ properties(include: boolean): TransactionsDataTableBuilder;
4019
+ /**
4020
+ * Defines whether to include transaction ids and remote ids.
4021
+ *
4022
+ * @param include - Whether to include ids
4023
+ *
4024
+ * @returns This builder with respective option, for chaining.
4025
+ */
4026
+ ids(include: boolean): TransactionsDataTableBuilder;
4027
+ /**
4028
+ * Defines whether to include the "Recorded at" column.
4029
+ *
4030
+ * @param include - Whether to include the recorded at column
4031
+ *
4032
+ * @returns This builder with respective option, for chaining.
4033
+ */
4034
+ recordedAt(include: boolean): TransactionsDataTableBuilder;
4035
+ /**
4036
+ * Defines whether to include hidden properties (keys ending with underscore "_").
4037
+ * Only relevant when {@link properties} is enabled.
4038
+ * Default is false — hidden properties are excluded.
4039
+ *
4040
+ * @param include - Whether to include hidden properties
4041
+ *
4042
+ * @returns This builder with respective option, for chaining.
4043
+ */
4044
+ hiddenProperties(include: boolean): TransactionsDataTableBuilder;
4045
+ /**
4046
+ * @deprecated Use {@link urls} instead.
4047
+ */
4048
+ includeUrls(include: boolean): TransactionsDataTableBuilder;
4049
+ /**
4050
+ * @deprecated Use {@link properties} instead.
4051
+ */
4052
+ includeProperties(include: boolean): TransactionsDataTableBuilder;
4053
+ /**
4054
+ * @deprecated Use {@link ids} instead.
4055
+ */
4056
+ includeIds(include: boolean): TransactionsDataTableBuilder;
4057
+ /**
4058
+ * Gets the account used to filter transactions, when applicable.
4059
+ *
4060
+ * @returns The account, when filtering by a single account.
4061
+ */
4062
+ getAccount(): Account | undefined;
4063
+ /**
4064
+ * Builds a two-dimensional array containing all transactions.
4065
+ *
4066
+ * @returns A promise resolving to a two-dimensional array containing all transactions
4067
+ */
4068
+ build(): Promise<any[][]>;
4069
+ private getHeaderLine;
4070
+ private get2DArray_;
4071
+ private shouldShowBalances;
4072
+ private isCreditOnTransaction_;
4073
+ private getPropertyKeys;
4074
+ private getAttachmentHeaders;
4075
+ private getRemoteIdHeaders;
4076
+ private addPropertiesToLine;
4077
+ private addRemoteIdsToLine;
4078
+ private addUrlsToLine;
4079
+ private getUrls;
4080
+ }
4081
+
4082
+ /**
4083
+ * Enum that represents the status of a Transaction.
4084
+ *
4085
+ * @public
4086
+ */
4087
+ export declare enum TransactionStatus {
4088
+ /**
4089
+ * Transaction is in the trash
4090
+ */
4091
+ TRASHED = "TRASHED",
4092
+ /**
4093
+ * Transaction is a draft, not yet posted
4094
+ */
4095
+ DRAFT = "DRAFT",
4096
+ /**
4097
+ * Transaction is posted but not checked
4098
+ */
4099
+ UNCHECKED = "UNCHECKED",
4100
+ /**
4101
+ * Transaction is posted and checked
4102
+ */
4103
+ CHECKED = "CHECKED"
4104
+ }
4105
+
3739
4106
  /**
3740
4107
  * This class defines a User on the Bkper platform.
3741
4108
  *
package/lib/index.js CHANGED
@@ -5,31 +5,35 @@
5
5
  *
6
6
  * @packageDocumentation
7
7
  */
8
- export { Account } from "./model/Account.js";
9
- export { Agent } from "./model/Agent.js";
10
- export { Amount } from "./model/Amount.js";
11
- export { App } from "./model/App.js";
12
- export { Backlog } from "./model/Backlog.js";
13
- export { Balance } from "./model/Balance.js";
14
- export { BalancesDataTableBuilder } from "./model/BalancesDataTableBuilder.js";
15
- export { BalancesReport } from "./model/BalancesReport.js";
16
- export { Billing } from "./model/Billing.js";
17
- export { Bkper } from "./model/Bkper.js";
18
- export { Book } from "./model/Book.js";
19
- export { Collaborator } from "./model/Collaborator.js";
20
- export { Collection } from "./model/Collection.js";
21
- export { Connection } from "./model/Connection.js";
22
- export { File } from "./model/File.js";
23
- export { Group } from "./model/Group.js";
24
- export { Integration } from "./model/Integration.js";
25
- export { Query } from "./model/Query.js";
26
- export { Template } from "./model/Template.js";
27
- export { Transaction } from "./model/Transaction.js";
28
- export { TransactionList } from "./model/TransactionList.js";
29
- export { Event } from "./model/Event.js";
30
- export { BotResponse } from "./model/BotResponse.js";
31
- export { EventList } from "./model/EventList.js";
32
- export { User } from "./model/User.js";
33
- export { Periodicity, DecimalSeparator, Permission, Visibility, AccountType, BalanceType, Period, Month, EventType, BotResponseType, } from "./model/Enums.js";
34
- export { BkperError } from "./model/BkperError.js";
8
+ export { Account } from './model/Account.js';
9
+ export { AccountsDataTableBuilder } from './builders/AccountsDataTableBuilder.js';
10
+ export { Agent } from './model/Agent.js';
11
+ export { Amount } from './model/Amount.js';
12
+ export { App } from './model/App.js';
13
+ export { Backlog } from './model/Backlog.js';
14
+ export { Balance } from './model/Balance.js';
15
+ export { BalancesDataTableBuilder } from './builders/BalancesDataTableBuilder.js';
16
+ export { BalancesReport } from './model/BalancesReport.js';
17
+ export { Billing } from './model/Billing.js';
18
+ export { Bkper } from './model/Bkper.js';
19
+ export { Book } from './model/Book.js';
20
+ export { BooksDataTableBuilder } from './builders/BooksDataTableBuilder.js';
21
+ export { Collaborator } from './model/Collaborator.js';
22
+ export { Collection } from './model/Collection.js';
23
+ export { Connection } from './model/Connection.js';
24
+ export { File } from './model/File.js';
25
+ export { Group } from './model/Group.js';
26
+ export { GroupsDataTableBuilder } from './builders/GroupsDataTableBuilder.js';
27
+ export { Integration } from './model/Integration.js';
28
+ export { Query } from './model/Query.js';
29
+ export { Template } from './model/Template.js';
30
+ export { Transaction } from './model/Transaction.js';
31
+ export { TransactionList } from './model/TransactionList.js';
32
+ export { TransactionsDataTableBuilder } from './builders/TransactionsDataTableBuilder.js';
33
+ export { Event } from './model/Event.js';
34
+ export { BotResponse } from './model/BotResponse.js';
35
+ export { EventList } from './model/EventList.js';
36
+ export { User } from './model/User.js';
37
+ export { Periodicity, DecimalSeparator, Permission, Visibility, AccountType, BalanceType, Period, Month, EventType, BotResponseType, TransactionStatus, } from './model/Enums.js';
38
+ export { BkperError } from './model/BkperError.js';
35
39
  //# sourceMappingURL=index.js.map
@@ -7,10 +7,10 @@ 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 { getRepresentativeValue, normalizeName } from "../utils.js";
11
- import { Amount } from "./Amount.js";
12
- import { Balance } from "./Balance.js";
13
- import { BalancesDataTableBuilder } from "./BalancesDataTableBuilder.js";
10
+ import { getRepresentativeValue, normalizeName } from '../utils.js';
11
+ import { Amount } from './Amount.js';
12
+ import { Balance } from './Balance.js';
13
+ import { BalancesDataTableBuilder } from '../builders/BalancesDataTableBuilder.js';
14
14
  /** @internal */
15
15
  export class AccountBalancesContainer {
16
16
  constructor(parent, balancesReport, payload) {
@@ -7,11 +7,11 @@ 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 { Amount } from "./Amount.js";
11
- import { getRepresentativeValue, normalizeName } from "../utils.js";
12
- import { AccountBalancesContainer } from "./BalancesContainerAccount.js";
13
- import { Balance } from "./Balance.js";
14
- import { BalancesDataTableBuilder } from "./BalancesDataTableBuilder.js";
10
+ import { Amount } from './Amount.js';
11
+ import { getRepresentativeValue, normalizeName } from '../utils.js';
12
+ import { AccountBalancesContainer } from './BalancesContainerAccount.js';
13
+ import { Balance } from './Balance.js';
14
+ import { BalancesDataTableBuilder } from '../builders/BalancesDataTableBuilder.js';
15
15
  /** @internal */
16
16
  export class GroupBalancesContainer {
17
17
  constructor(parent, balancesReport, payload) {
@@ -1,7 +1,7 @@
1
1
  import { normalizeName } from '../utils.js';
2
- import { AccountBalancesContainer } from "./BalancesContainerAccount.js";
3
- import { GroupBalancesContainer } from "./BalancesContainerGroup.js";
4
- import { BalancesDataTableBuilder } from './BalancesDataTableBuilder.js';
2
+ import { AccountBalancesContainer } from './BalancesContainerAccount.js';
3
+ import { GroupBalancesContainer } from './BalancesContainerGroup.js';
4
+ import { BalancesDataTableBuilder } from '../builders/BalancesDataTableBuilder.js';
5
5
  /**
6
6
  * Class representing a Balance Report, generated when calling [Book.getBalanceReport](#book_getbalancesreport)
7
7
  *