bkper-js 2.7.0 → 2.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/lib/index.d.ts +142 -144
- package/lib/model/Account.js +18 -24
- package/lib/model/App.js +70 -24
- package/lib/model/Bkper.js +42 -30
- package/lib/model/Book.js +107 -102
- package/lib/model/BotResponse.js +2 -2
- package/lib/model/Collaborator.js +10 -14
- package/lib/model/Collection.js +22 -22
- package/lib/model/Connection.js +26 -21
- package/lib/model/Conversation.js +18 -16
- package/lib/model/File.js +17 -20
- package/lib/model/Group.js +27 -24
- package/lib/model/Integration.js +15 -16
- package/lib/model/Message.js +18 -19
- package/lib/model/Query.js +10 -14
- package/lib/model/Resource.js +23 -0
- package/lib/model/Template.js +8 -10
- package/lib/model/Transaction.js +59 -46
- package/lib/model/User.js +12 -15
- package/lib/service/account-service.js +12 -12
- package/lib/service/app-service.js +8 -8
- package/lib/service/balances-service.js +8 -5
- package/lib/service/book-service.js +14 -14
- package/lib/service/collaborator-service.js +6 -6
- package/lib/service/collection-service.js +12 -12
- package/lib/service/connection-service.js +12 -15
- package/lib/service/conversation-service.js +10 -10
- package/lib/service/event-service.js +8 -8
- package/lib/service/file-service.js +4 -4
- package/lib/service/group-service.js +16 -16
- package/lib/service/http-api-request.js +78 -71
- package/lib/service/http-request.js +31 -9
- package/lib/service/integration-service.js +8 -8
- package/lib/service/query-service.js +8 -8
- package/lib/service/template-service.js +2 -2
- package/lib/service/transaction-service.js +32 -32
- package/lib/service/user-service.js +4 -4
- package/package.json +1 -2
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,21 @@ See what's new and what has changed in bkper-js
|
|
|
5
5
|
2025
|
|
6
6
|
----
|
|
7
7
|
|
|
8
|
+
**September 2025**
|
|
9
|
+
|
|
10
|
+
* Added `Collaborator`
|
|
11
|
+
* Added `Collaborator.json`
|
|
12
|
+
* Added `Collaborator.getId`
|
|
13
|
+
* Added `Collaborator.getEmail`
|
|
14
|
+
* Added `Collaborator.getPermission`
|
|
15
|
+
* Added `Collaborator.setEmail`
|
|
16
|
+
* Added `Collaborator.setPermission`
|
|
17
|
+
* Added `Collaborator.create`
|
|
18
|
+
* Added `Collaborator.update`
|
|
19
|
+
* Added `Collaborator.remove`
|
|
20
|
+
* Added `Book.getCollaborators`
|
|
21
|
+
* Replaced axios with native Fetch API for better compatibility with multiple environments
|
|
22
|
+
|
|
8
23
|
**August 2025**
|
|
9
24
|
|
|
10
25
|
* Added `Transaction.setFiles`
|
package/lib/index.d.ts
CHANGED
|
@@ -15,16 +15,10 @@
|
|
|
15
15
|
*
|
|
16
16
|
* @public
|
|
17
17
|
*/
|
|
18
|
-
export declare class Account {
|
|
19
|
-
payload: bkper.Account;
|
|
18
|
+
export declare class Account extends Resource<bkper.Account> {
|
|
20
19
|
|
|
21
20
|
constructor(book: Book, payload?: bkper.Account);
|
|
22
|
-
|
|
23
|
-
* Gets an immutable copy of the JSON payload.
|
|
24
|
-
*
|
|
25
|
-
* @returns An immutable copy of the json payload
|
|
26
|
-
*/
|
|
27
|
-
json(): bkper.Account;
|
|
21
|
+
getConfig(): Config;
|
|
28
22
|
/**
|
|
29
23
|
* Gets the Account internal id.
|
|
30
24
|
*
|
|
@@ -442,15 +436,10 @@ export declare class Amount {
|
|
|
442
436
|
*
|
|
443
437
|
* @public
|
|
444
438
|
*/
|
|
445
|
-
export declare class App {
|
|
446
|
-
|
|
447
|
-
constructor(payload?: bkper.App);
|
|
448
|
-
|
|
449
|
-
* Gets the wrapped plain JSON object.
|
|
450
|
-
*
|
|
451
|
-
* @returns The wrapped plain json object
|
|
452
|
-
*/
|
|
453
|
-
json(): bkper.App;
|
|
439
|
+
export declare class App extends Resource<bkper.App> {
|
|
440
|
+
private config?;
|
|
441
|
+
constructor(payload?: bkper.App, config?: Config);
|
|
442
|
+
getConfig(): Config;
|
|
454
443
|
/**
|
|
455
444
|
* Sets the webhook url for development.
|
|
456
445
|
*
|
|
@@ -497,6 +486,12 @@ export declare class App {
|
|
|
497
486
|
* @returns True if this App is published
|
|
498
487
|
*/
|
|
499
488
|
isPublished(): boolean;
|
|
489
|
+
/**
|
|
490
|
+
* Tells if this App is installable.
|
|
491
|
+
*
|
|
492
|
+
* @returns True if this App is installable
|
|
493
|
+
*/
|
|
494
|
+
isInstallable(): boolean;
|
|
500
495
|
/**
|
|
501
496
|
* Checks if this App is conversational.
|
|
502
497
|
*
|
|
@@ -529,12 +524,6 @@ export declare class App {
|
|
|
529
524
|
* @returns This App for chaining
|
|
530
525
|
*/
|
|
531
526
|
setUserEmails(emails?: string): App;
|
|
532
|
-
/**
|
|
533
|
-
* Gets the name of the owner of this App.
|
|
534
|
-
*
|
|
535
|
-
* @returns The name of the owner of this App
|
|
536
|
-
*/
|
|
537
|
-
getOwnerName(): string | undefined;
|
|
538
527
|
/**
|
|
539
528
|
* Gets the menu url of this App.
|
|
540
529
|
*
|
|
@@ -565,12 +554,24 @@ export declare class App {
|
|
|
565
554
|
* @returns The menu popup height of this App
|
|
566
555
|
*/
|
|
567
556
|
getMenuPopupHeight(): string | undefined;
|
|
557
|
+
/**
|
|
558
|
+
* Gets the name of the owner of this App.
|
|
559
|
+
*
|
|
560
|
+
* @returns The name of the owner of this App
|
|
561
|
+
*/
|
|
562
|
+
getOwnerName(): string | undefined;
|
|
568
563
|
/**
|
|
569
564
|
* Gets the logo url of the owner of this App.
|
|
570
565
|
*
|
|
571
566
|
* @returns The logo url of the owner of this App
|
|
572
567
|
*/
|
|
573
568
|
getOwnerLogoUrl(): string | undefined;
|
|
569
|
+
/**
|
|
570
|
+
* Gets the website url of the owner of this App.
|
|
571
|
+
*
|
|
572
|
+
* @returns The website url of the owner of this App
|
|
573
|
+
*/
|
|
574
|
+
getOwnerWebsiteUrl(): string | undefined;
|
|
574
575
|
/**
|
|
575
576
|
* Gets the file patterns the App handles.
|
|
576
577
|
*
|
|
@@ -594,11 +595,35 @@ export declare class App {
|
|
|
594
595
|
*/
|
|
595
596
|
setClientSecret(clientSecret?: string): App;
|
|
596
597
|
/**
|
|
597
|
-
*
|
|
598
|
+
* Gets the website url of this App.
|
|
599
|
+
*
|
|
600
|
+
* @returns The website url of this App
|
|
601
|
+
*/
|
|
602
|
+
getWebsiteUrl(): string | undefined;
|
|
603
|
+
/**
|
|
604
|
+
* Tells if the repository is private.
|
|
605
|
+
*
|
|
606
|
+
* @returns True if the repository is private
|
|
607
|
+
*/
|
|
608
|
+
isRepositoryPrivate(): boolean | undefined;
|
|
609
|
+
/**
|
|
610
|
+
* Gets the repository url of this App.
|
|
611
|
+
*
|
|
612
|
+
* @returns The repository url of this App
|
|
613
|
+
*/
|
|
614
|
+
getRepositoryUrl(): string | undefined;
|
|
615
|
+
/**
|
|
616
|
+
* Gets the readme.md file as text.
|
|
617
|
+
*
|
|
618
|
+
* @returns The readme text
|
|
619
|
+
*/
|
|
620
|
+
getReadme(): string | undefined;
|
|
621
|
+
/**
|
|
622
|
+
* Sets the readme.md file as text.
|
|
598
623
|
*
|
|
599
624
|
* @param readme - The readme text to set
|
|
600
625
|
*
|
|
601
|
-
* @returns This App for chaining
|
|
626
|
+
* @returns This App, for chaining
|
|
602
627
|
*/
|
|
603
628
|
setReadme(readme?: string): App;
|
|
604
629
|
/**
|
|
@@ -1162,10 +1187,9 @@ export declare enum BalanceType {
|
|
|
1162
1187
|
/**
|
|
1163
1188
|
* This is the main entry point of the [bkper-js](https://www.npmjs.com/package/bkper-js) library.
|
|
1164
1189
|
*
|
|
1165
|
-
* You
|
|
1166
|
-
*
|
|
1167
|
-
* Example:
|
|
1190
|
+
* You can configure the library in two ways:
|
|
1168
1191
|
*
|
|
1192
|
+
* 1. Using static configuration (traditional approach):
|
|
1169
1193
|
* ```javascript
|
|
1170
1194
|
* Bkper.setConfig({
|
|
1171
1195
|
* apiKeyProvider: () => process.env.BKPER_API_KEY,
|
|
@@ -1176,22 +1200,36 @@ export declare enum BalanceType {
|
|
|
1176
1200
|
* const book = await bkper.getBook('bookId');
|
|
1177
1201
|
* ```
|
|
1178
1202
|
*
|
|
1179
|
-
*
|
|
1203
|
+
* 2. Using per-instance configuration (recommended for Cloudflare Workers):
|
|
1204
|
+
* ```javascript
|
|
1205
|
+
* const bkper = new Bkper({
|
|
1206
|
+
* apiKeyProvider: () => process.env.BKPER_API_KEY,
|
|
1207
|
+
* oauthTokenProvider: () => process.env.BKPER_OAUTH_TOKEN
|
|
1208
|
+
* });
|
|
1209
|
+
*
|
|
1210
|
+
* const book = await bkper.getBook('bookId');
|
|
1211
|
+
* ```
|
|
1180
1212
|
*
|
|
1181
1213
|
* @public
|
|
1182
1214
|
*/
|
|
1183
1215
|
export declare class Bkper {
|
|
1216
|
+
|
|
1217
|
+
private config;
|
|
1184
1218
|
/**
|
|
1185
1219
|
* Sets the global API configuration for all Bkper operations.
|
|
1186
1220
|
*
|
|
1221
|
+
* WARNING: This configuration will be shared and should NOT be used on shared environments.
|
|
1222
|
+
*
|
|
1187
1223
|
* @param config - The Config object containing API key and OAuth token providers
|
|
1188
1224
|
*/
|
|
1189
1225
|
static setConfig(config: Config): void;
|
|
1190
1226
|
/**
|
|
1191
|
-
* Creates a new Bkper instance
|
|
1192
|
-
*
|
|
1227
|
+
* Creates a new Bkper instance with the provided configuration.
|
|
1228
|
+
*
|
|
1229
|
+
* @param config - The Config object containing API key and OAuth token providers.
|
|
1230
|
+
* If not provided, uses the global configuration set via setConfig().
|
|
1193
1231
|
*/
|
|
1194
|
-
constructor();
|
|
1232
|
+
constructor(config?: Config);
|
|
1195
1233
|
/**
|
|
1196
1234
|
* Gets the [[Book]] with the specified bookId from url param.
|
|
1197
1235
|
*
|
|
@@ -1262,8 +1300,8 @@ export declare class Bkper {
|
|
|
1262
1300
|
*
|
|
1263
1301
|
* @public
|
|
1264
1302
|
*/
|
|
1265
|
-
export declare class Book {
|
|
1266
|
-
|
|
1303
|
+
export declare class Book extends Resource<bkper.Book> {
|
|
1304
|
+
private config?;
|
|
1267
1305
|
|
|
1268
1306
|
|
|
1269
1307
|
|
|
@@ -1272,13 +1310,8 @@ export declare class Book {
|
|
|
1272
1310
|
|
|
1273
1311
|
|
|
1274
1312
|
|
|
1275
|
-
constructor(payload?: bkper.Book);
|
|
1276
|
-
|
|
1277
|
-
* Gets an immutable copy of the JSON payload for this Book.
|
|
1278
|
-
*
|
|
1279
|
-
* @returns An immutable copy of the JSON payload
|
|
1280
|
-
*/
|
|
1281
|
-
json(): bkper.Book;
|
|
1313
|
+
constructor(payload?: bkper.Book, config?: Config);
|
|
1314
|
+
getConfig(): Config;
|
|
1282
1315
|
/**
|
|
1283
1316
|
* Gets the unique identifier of this Book.
|
|
1284
1317
|
*
|
|
@@ -1909,16 +1942,10 @@ export declare enum BotResponseType {
|
|
|
1909
1942
|
*
|
|
1910
1943
|
* @public
|
|
1911
1944
|
*/
|
|
1912
|
-
export declare class Collaborator {
|
|
1913
|
-
payload: bkper.Collaborator;
|
|
1945
|
+
export declare class Collaborator extends Resource<bkper.Collaborator> {
|
|
1914
1946
|
|
|
1915
1947
|
constructor(book: Book, payload?: bkper.Collaborator);
|
|
1916
|
-
|
|
1917
|
-
* Gets an immutable copy of the JSON payload.
|
|
1918
|
-
*
|
|
1919
|
-
* @returns An immutable copy of the json payload
|
|
1920
|
-
*/
|
|
1921
|
-
json(): bkper.Collaborator;
|
|
1948
|
+
getConfig(): Config;
|
|
1922
1949
|
/**
|
|
1923
1950
|
* Gets the Collaborator internal id.
|
|
1924
1951
|
*
|
|
@@ -1978,15 +2005,10 @@ export declare class Collaborator {
|
|
|
1978
2005
|
*
|
|
1979
2006
|
* @public
|
|
1980
2007
|
*/
|
|
1981
|
-
export declare class Collection {
|
|
1982
|
-
|
|
1983
|
-
constructor(payload?: bkper.Collection);
|
|
1984
|
-
|
|
1985
|
-
* Gets an immutable copy of the JSON payload for this Collection.
|
|
1986
|
-
*
|
|
1987
|
-
* @returns The wrapped plain json object
|
|
1988
|
-
*/
|
|
1989
|
-
json(): bkper.Collection;
|
|
2008
|
+
export declare class Collection extends Resource<bkper.Collection> {
|
|
2009
|
+
private config?;
|
|
2010
|
+
constructor(payload?: bkper.Collection, config?: Config);
|
|
2011
|
+
getConfig(): Config;
|
|
1990
2012
|
/**
|
|
1991
2013
|
* Gets the unique identifier of this Collection.
|
|
1992
2014
|
*
|
|
@@ -2119,15 +2141,10 @@ export declare interface Config {
|
|
|
2119
2141
|
*
|
|
2120
2142
|
* @public
|
|
2121
2143
|
*/
|
|
2122
|
-
export declare class Connection {
|
|
2123
|
-
|
|
2124
|
-
constructor(payload?: bkper.Connection);
|
|
2125
|
-
|
|
2126
|
-
* Gets an immutable copy of the JSON payload for this Connection.
|
|
2127
|
-
*
|
|
2128
|
-
* @returns An immutable copy of the json payload
|
|
2129
|
-
*/
|
|
2130
|
-
json(): bkper.Connection;
|
|
2144
|
+
export declare class Connection extends Resource<bkper.Connection> {
|
|
2145
|
+
private config?;
|
|
2146
|
+
constructor(payload?: bkper.Connection, config?: Config);
|
|
2147
|
+
getConfig(): Config;
|
|
2131
2148
|
/**
|
|
2132
2149
|
* Gets the id of the Connection.
|
|
2133
2150
|
*
|
|
@@ -2288,17 +2305,12 @@ export declare class Connection {
|
|
|
2288
2305
|
*
|
|
2289
2306
|
* @public
|
|
2290
2307
|
*/
|
|
2291
|
-
export declare class Conversation {
|
|
2292
|
-
payload: bkper.Conversation;
|
|
2308
|
+
export declare class Conversation extends Resource<bkper.Conversation> {
|
|
2293
2309
|
|
|
2294
2310
|
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
*
|
|
2299
|
-
* @returns The wrapped plain json object
|
|
2300
|
-
*/
|
|
2301
|
-
json(): bkper.Conversation;
|
|
2311
|
+
private config?;
|
|
2312
|
+
constructor(agent: Agent, payload?: bkper.Conversation, config?: Config);
|
|
2313
|
+
getConfig(): Config;
|
|
2302
2314
|
/**
|
|
2303
2315
|
* Gets the Agent associated to this Conversation.
|
|
2304
2316
|
*
|
|
@@ -2508,16 +2520,10 @@ export declare enum EventType {
|
|
|
2508
2520
|
*
|
|
2509
2521
|
* @public
|
|
2510
2522
|
*/
|
|
2511
|
-
export declare class File {
|
|
2512
|
-
payload: bkper.File;
|
|
2523
|
+
export declare class File extends Resource<bkper.File> {
|
|
2513
2524
|
|
|
2514
2525
|
constructor(book: Book, payload?: bkper.File);
|
|
2515
|
-
|
|
2516
|
-
* Gets an immutable copy of the JSON payload for this File.
|
|
2517
|
-
*
|
|
2518
|
-
* @returns An immutable copy of the json payload
|
|
2519
|
-
*/
|
|
2520
|
-
json(): bkper.File;
|
|
2526
|
+
getConfig(): Config;
|
|
2521
2527
|
/**
|
|
2522
2528
|
* Gets the File id.
|
|
2523
2529
|
*
|
|
@@ -2638,8 +2644,7 @@ export declare class File {
|
|
|
2638
2644
|
*
|
|
2639
2645
|
* @public
|
|
2640
2646
|
*/
|
|
2641
|
-
export declare class Group {
|
|
2642
|
-
payload: bkper.Group;
|
|
2647
|
+
export declare class Group extends Resource<bkper.Group> {
|
|
2643
2648
|
|
|
2644
2649
|
|
|
2645
2650
|
|
|
@@ -2647,12 +2652,7 @@ export declare class Group {
|
|
|
2647
2652
|
|
|
2648
2653
|
|
|
2649
2654
|
constructor(book: Book, payload?: bkper.Group);
|
|
2650
|
-
|
|
2651
|
-
* Gets an immutable copy of the json payload.
|
|
2652
|
-
*
|
|
2653
|
-
* @returns An immutable copy of the json payload
|
|
2654
|
-
*/
|
|
2655
|
-
json(): bkper.Group;
|
|
2655
|
+
getConfig(): Config;
|
|
2656
2656
|
/**
|
|
2657
2657
|
* Gets the id of this Group.
|
|
2658
2658
|
*
|
|
@@ -2890,15 +2890,10 @@ export declare class Group {
|
|
|
2890
2890
|
*
|
|
2891
2891
|
* @public
|
|
2892
2892
|
*/
|
|
2893
|
-
export declare class Integration {
|
|
2894
|
-
|
|
2895
|
-
constructor(payload?: bkper.Integration);
|
|
2896
|
-
|
|
2897
|
-
* Gets an immutable copy of the JSON payload for this Integration.
|
|
2898
|
-
*
|
|
2899
|
-
* @returns An immutable copy of the json payload
|
|
2900
|
-
*/
|
|
2901
|
-
json(): bkper.Integration;
|
|
2893
|
+
export declare class Integration extends Resource<bkper.Integration> {
|
|
2894
|
+
private config?;
|
|
2895
|
+
constructor(payload?: bkper.Integration, config?: Config);
|
|
2896
|
+
getConfig(): Config;
|
|
2902
2897
|
/**
|
|
2903
2898
|
* Gets the [[Book]] id of the Integration.
|
|
2904
2899
|
*
|
|
@@ -3005,17 +3000,11 @@ export declare class Integration {
|
|
|
3005
3000
|
*
|
|
3006
3001
|
* @public
|
|
3007
3002
|
*/
|
|
3008
|
-
export declare class Message {
|
|
3009
|
-
payload: bkper.Message;
|
|
3003
|
+
export declare class Message extends Resource<bkper.Message> {
|
|
3010
3004
|
|
|
3011
3005
|
|
|
3012
|
-
constructor(conversation: Conversation, payload?: bkper.Message);
|
|
3013
|
-
|
|
3014
|
-
* Gets the wrapped plain json object.
|
|
3015
|
-
*
|
|
3016
|
-
* @returns The wrapped plain json object
|
|
3017
|
-
*/
|
|
3018
|
-
json(): bkper.Message;
|
|
3006
|
+
constructor(conversation: Conversation, payload?: bkper.Message, config?: Config);
|
|
3007
|
+
getConfig(): Config;
|
|
3019
3008
|
/**
|
|
3020
3009
|
* Gets the Message universal identifier.
|
|
3021
3010
|
*
|
|
@@ -3218,16 +3207,10 @@ export declare enum Permission {
|
|
|
3218
3207
|
*
|
|
3219
3208
|
* @public
|
|
3220
3209
|
*/
|
|
3221
|
-
export declare class Query {
|
|
3222
|
-
payload: bkper.Query;
|
|
3210
|
+
export declare class Query extends Resource<bkper.Query> {
|
|
3223
3211
|
|
|
3224
3212
|
constructor(book: Book, payload?: bkper.Query);
|
|
3225
|
-
|
|
3226
|
-
* Gets the wrapped plain json object.
|
|
3227
|
-
*
|
|
3228
|
-
* @returns The wrapped plain json object
|
|
3229
|
-
*/
|
|
3230
|
-
json(): bkper.Query;
|
|
3213
|
+
getConfig(): Config;
|
|
3231
3214
|
/**
|
|
3232
3215
|
* Gets the Query universal identifier.
|
|
3233
3216
|
*
|
|
@@ -3284,21 +3267,47 @@ export declare class Query {
|
|
|
3284
3267
|
}
|
|
3285
3268
|
|
|
3286
3269
|
/**
|
|
3287
|
-
*
|
|
3288
|
-
*
|
|
3289
|
-
* A Template is a pre-configured setup for [[Books]] and associated Google Sheets that provides users with a starting point for specific accounting or financial management needs.
|
|
3270
|
+
* Abstract base class for all Bkper resources.
|
|
3271
|
+
* Provides common functionality for config management and JSON serialization.
|
|
3290
3272
|
*
|
|
3291
3273
|
* @public
|
|
3292
3274
|
*/
|
|
3293
|
-
|
|
3294
|
-
payload: bkper.Template;
|
|
3295
|
-
constructor(json?: bkper.Template);
|
|
3275
|
+
declare abstract class Resource<T = any> {
|
|
3296
3276
|
/**
|
|
3297
|
-
*
|
|
3298
|
-
|
|
3277
|
+
* The underlying payload data for this resource
|
|
3278
|
+
*/
|
|
3279
|
+
protected payload: T;
|
|
3280
|
+
/**
|
|
3281
|
+
* Constructs a new Resource
|
|
3282
|
+
* @param payload - The data payload for this resource
|
|
3283
|
+
*/
|
|
3284
|
+
constructor(payload?: T);
|
|
3285
|
+
/**
|
|
3286
|
+
* Gets an immutable copy of the JSON payload for this resource.
|
|
3299
3287
|
* @returns An immutable copy of the json payload
|
|
3300
3288
|
*/
|
|
3301
|
-
json():
|
|
3289
|
+
json(): T;
|
|
3290
|
+
/**
|
|
3291
|
+
* Gets the effective configuration for this resource.
|
|
3292
|
+
* Each resource must implement this to either:
|
|
3293
|
+
* - Return its own config (for root containers like Book, Collection)
|
|
3294
|
+
* - Delegate to its container (for contained resources like Account, Transaction)
|
|
3295
|
+
* @returns The resolved configuration
|
|
3296
|
+
*/
|
|
3297
|
+
abstract getConfig(): Config;
|
|
3298
|
+
}
|
|
3299
|
+
|
|
3300
|
+
/**
|
|
3301
|
+
* This class defines a Template.
|
|
3302
|
+
*
|
|
3303
|
+
* A Template is a pre-configured setup for [[Books]] and associated Google Sheets that provides users with a starting point for specific accounting or financial management needs.
|
|
3304
|
+
*
|
|
3305
|
+
* @public
|
|
3306
|
+
*/
|
|
3307
|
+
export declare class Template extends Resource<bkper.Template> {
|
|
3308
|
+
private config?;
|
|
3309
|
+
constructor(json?: bkper.Template, config?: Config);
|
|
3310
|
+
getConfig(): Config;
|
|
3302
3311
|
/**
|
|
3303
3312
|
* Gets the name of the Template.
|
|
3304
3313
|
*
|
|
@@ -3357,16 +3366,10 @@ export declare class Template {
|
|
|
3357
3366
|
*
|
|
3358
3367
|
* @public
|
|
3359
3368
|
*/
|
|
3360
|
-
export declare class Transaction {
|
|
3361
|
-
payload: bkper.Transaction;
|
|
3369
|
+
export declare class Transaction extends Resource<bkper.Transaction> {
|
|
3362
3370
|
|
|
3363
3371
|
constructor(book: Book, payload?: bkper.Transaction);
|
|
3364
|
-
|
|
3365
|
-
* Gets the JSON representation of the transaction.
|
|
3366
|
-
*
|
|
3367
|
-
* @returns An immutable copy of the json payload
|
|
3368
|
-
*/
|
|
3369
|
-
json(): bkper.Transaction;
|
|
3372
|
+
getConfig(): Config;
|
|
3370
3373
|
/**
|
|
3371
3374
|
* Gets the book associated with this transaction.
|
|
3372
3375
|
*
|
|
@@ -3861,15 +3864,10 @@ export declare class TransactionList {
|
|
|
3861
3864
|
*
|
|
3862
3865
|
* @public
|
|
3863
3866
|
*/
|
|
3864
|
-
export declare class User {
|
|
3865
|
-
|
|
3866
|
-
constructor(payload?: bkper.User);
|
|
3867
|
-
|
|
3868
|
-
* Gets an immutable copy of the JSON payload for this User.
|
|
3869
|
-
*
|
|
3870
|
-
* @returns An immutable copy of the json payload
|
|
3871
|
-
*/
|
|
3872
|
-
json(): bkper.User;
|
|
3867
|
+
export declare class User extends Resource<bkper.User> {
|
|
3868
|
+
private config?;
|
|
3869
|
+
constructor(payload?: bkper.User, config?: Config);
|
|
3870
|
+
getConfig(): Config;
|
|
3873
3871
|
/**
|
|
3874
3872
|
* Gets the id of the User.
|
|
3875
3873
|
*
|
package/lib/model/Account.js
CHANGED
|
@@ -7,10 +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 * as AccountService from
|
|
11
|
-
import * as GroupService from
|
|
12
|
-
import { Group } from
|
|
13
|
-
import { normalizeText } from
|
|
10
|
+
import * as AccountService from "../service/account-service.js";
|
|
11
|
+
import * as GroupService from "../service/group-service.js";
|
|
12
|
+
import { Group } from "./Group.js";
|
|
13
|
+
import { normalizeText } from "../utils.js";
|
|
14
|
+
import { Resource } from "./Resource.js";
|
|
14
15
|
/**
|
|
15
16
|
* This class defines an [Account](https://en.wikipedia.org/wiki/Account_(bookkeeping)) of a [[Book]].
|
|
16
17
|
*
|
|
@@ -20,20 +21,13 @@ import { normalizeText } from '../utils.js';
|
|
|
20
21
|
*
|
|
21
22
|
* @public
|
|
22
23
|
*/
|
|
23
|
-
export class Account {
|
|
24
|
+
export class Account extends Resource {
|
|
24
25
|
constructor(book, payload) {
|
|
26
|
+
super(payload || { createdAt: `${Date.now()}` });
|
|
25
27
|
this.book = book;
|
|
26
|
-
this.payload = payload || {
|
|
27
|
-
createdAt: `${Date.now()}`
|
|
28
|
-
};
|
|
29
28
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
*
|
|
33
|
-
* @returns An immutable copy of the json payload
|
|
34
|
-
*/
|
|
35
|
-
json() {
|
|
36
|
-
return Object.assign({}, this.payload);
|
|
29
|
+
getConfig() {
|
|
30
|
+
return this.book.getConfig();
|
|
37
31
|
}
|
|
38
32
|
/**
|
|
39
33
|
* Gets the Account internal id.
|
|
@@ -124,7 +118,7 @@ export class Account {
|
|
|
124
118
|
for (let index = 0; index < keys.length; index++) {
|
|
125
119
|
const key = keys[index];
|
|
126
120
|
let value = this.payload.properties != null ? this.payload.properties[key] : null;
|
|
127
|
-
if (value != null && value.trim() !=
|
|
121
|
+
if (value != null && value.trim() != "") {
|
|
128
122
|
return value;
|
|
129
123
|
}
|
|
130
124
|
}
|
|
@@ -139,14 +133,14 @@ export class Account {
|
|
|
139
133
|
* @returns This Account, for chaining
|
|
140
134
|
*/
|
|
141
135
|
setProperty(key, value) {
|
|
142
|
-
if (key == null || key.trim() ==
|
|
136
|
+
if (key == null || key.trim() == "") {
|
|
143
137
|
return this;
|
|
144
138
|
}
|
|
145
139
|
if (this.payload.properties == null) {
|
|
146
140
|
this.payload.properties = {};
|
|
147
141
|
}
|
|
148
142
|
if (!value) {
|
|
149
|
-
value =
|
|
143
|
+
value = "";
|
|
150
144
|
}
|
|
151
145
|
this.payload.properties[key] = value;
|
|
152
146
|
return this;
|
|
@@ -241,8 +235,8 @@ export class Account {
|
|
|
241
235
|
if (!id) {
|
|
242
236
|
return [];
|
|
243
237
|
}
|
|
244
|
-
let groups = yield GroupService.getGroupsByAccountId(this.book.getId(), id);
|
|
245
|
-
let groupsObj = groups.map(group => new Group(this.book, group));
|
|
238
|
+
let groups = yield GroupService.getGroupsByAccountId(this.book.getId(), id, this.getConfig());
|
|
239
|
+
let groupsObj = groups.map((group) => new Group(this.book, group));
|
|
246
240
|
return groupsObj;
|
|
247
241
|
});
|
|
248
242
|
}
|
|
@@ -256,7 +250,7 @@ export class Account {
|
|
|
256
250
|
setGroups(groups) {
|
|
257
251
|
this.payload.groups = undefined;
|
|
258
252
|
if (groups != null) {
|
|
259
|
-
groups.forEach(group => this.addGroup(group));
|
|
253
|
+
groups.forEach((group) => this.addGroup(group));
|
|
260
254
|
}
|
|
261
255
|
return this;
|
|
262
256
|
}
|
|
@@ -351,7 +345,7 @@ export class Account {
|
|
|
351
345
|
*/
|
|
352
346
|
create() {
|
|
353
347
|
return __awaiter(this, void 0, void 0, function* () {
|
|
354
|
-
this.payload = yield AccountService.createAccount(this.book.getId(), this.payload);
|
|
348
|
+
this.payload = yield AccountService.createAccount(this.book.getId(), this.payload, this.getConfig());
|
|
355
349
|
this.updateAccountCache();
|
|
356
350
|
return this;
|
|
357
351
|
});
|
|
@@ -363,7 +357,7 @@ export class Account {
|
|
|
363
357
|
*/
|
|
364
358
|
update() {
|
|
365
359
|
return __awaiter(this, void 0, void 0, function* () {
|
|
366
|
-
this.payload = yield AccountService.updateAccount(this.book.getId(), this.payload);
|
|
360
|
+
this.payload = yield AccountService.updateAccount(this.book.getId(), this.payload, this.getConfig());
|
|
367
361
|
this.updateAccountCache();
|
|
368
362
|
return this;
|
|
369
363
|
});
|
|
@@ -375,7 +369,7 @@ export class Account {
|
|
|
375
369
|
*/
|
|
376
370
|
remove() {
|
|
377
371
|
return __awaiter(this, void 0, void 0, function* () {
|
|
378
|
-
this.payload = yield AccountService.deleteAccount(this.book.getId(), this.payload);
|
|
372
|
+
this.payload = yield AccountService.deleteAccount(this.book.getId(), this.payload, this.getConfig());
|
|
379
373
|
this.updateAccountCache(true);
|
|
380
374
|
return this;
|
|
381
375
|
});
|