bkper-js 2.5.1 → 2.7.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 CHANGED
@@ -8,6 +8,11 @@ See what's new and what has changed in bkper-js
8
8
  **August 2025**
9
9
 
10
10
  * Added `Transaction.setFiles`
11
+ * Added `File.getProperties`
12
+ * Added `File.setProperties`
13
+ * Added `File.getProperty`
14
+ * Added `File.setProperty`
15
+ * Added `File.deleteProperty`
11
16
 
12
17
  **July 2025**
13
18
 
package/lib/index.d.ts CHANGED
@@ -1271,6 +1271,7 @@ export declare class Book {
1271
1271
 
1272
1272
 
1273
1273
 
1274
+
1274
1275
  constructor(payload?: bkper.Book);
1275
1276
  /**
1276
1277
  * Gets an immutable copy of the JSON payload for this Book.
@@ -1498,6 +1499,14 @@ export declare class Book {
1498
1499
  * @returns The visibility of the book
1499
1500
  */
1500
1501
  getVisibility(): Visibility;
1502
+ /**
1503
+ * Sets the visibility of the book.
1504
+ *
1505
+ * @param visibility - The visibility to set
1506
+ *
1507
+ * @returns This Book, for chaining
1508
+ */
1509
+ setVisibility(visibility: Visibility): Book;
1501
1510
  /**
1502
1511
  * Gets the custom properties stored in this Book.
1503
1512
  *
@@ -1722,6 +1731,7 @@ export declare class Book {
1722
1731
 
1723
1732
 
1724
1733
 
1734
+
1725
1735
  /**
1726
1736
  * Lists transactions in the Book based on the provided query, limit, and cursor, for pagination.
1727
1737
  *
@@ -1809,6 +1819,12 @@ export declare class Book {
1809
1819
  * @returns The saved queries from this book
1810
1820
  */
1811
1821
  getSavedQueries(): Promise<Query[]>;
1822
+ /**
1823
+ * Gets all collaborators of this Book.
1824
+ *
1825
+ * @returns Array of Collaborator objects
1826
+ */
1827
+ getCollaborators(): Promise<Collaborator[]>;
1812
1828
  }
1813
1829
 
1814
1830
  /**
@@ -1886,6 +1902,77 @@ export declare enum BotResponseType {
1886
1902
  ERROR = "ERROR"
1887
1903
  }
1888
1904
 
1905
+ /**
1906
+ * This class defines a Collaborator of a [[Book]].
1907
+ *
1908
+ * A Collaborator represents a user that has been granted access to a Book with specific permissions.
1909
+ *
1910
+ * @public
1911
+ */
1912
+ export declare class Collaborator {
1913
+ payload: bkper.Collaborator;
1914
+
1915
+ 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;
1922
+ /**
1923
+ * Gets the Collaborator internal id.
1924
+ *
1925
+ * @returns The Collaborator internal id
1926
+ */
1927
+ getId(): string | undefined;
1928
+ /**
1929
+ * Gets the Collaborator email address.
1930
+ *
1931
+ * @returns The Collaborator email address
1932
+ */
1933
+ getEmail(): string | undefined;
1934
+ /**
1935
+ * Sets the email address of the Collaborator.
1936
+ *
1937
+ * @param email - The email address to set
1938
+ *
1939
+ * @returns This Collaborator, for chaining
1940
+ */
1941
+ setEmail(email: string): Collaborator;
1942
+ /**
1943
+ * Gets the permission level of the Collaborator.
1944
+ *
1945
+ * @returns The permission level
1946
+ */
1947
+ getPermission(): Permission | undefined;
1948
+ /**
1949
+ * Sets the permission level of the Collaborator.
1950
+ *
1951
+ * @param permission - The permission level to set
1952
+ *
1953
+ * @returns This Collaborator, for chaining
1954
+ */
1955
+ setPermission(permission: Permission): Collaborator;
1956
+ /**
1957
+ * Performs create new Collaborator.
1958
+ *
1959
+ * @returns Promise with the created Collaborator
1960
+ */
1961
+ create(message?: string): Promise<Collaborator>;
1962
+ /**
1963
+ * Performs update Collaborator.
1964
+ *
1965
+ * @returns Promise with the updated Collaborator
1966
+ */
1967
+ update(): Promise<Collaborator>;
1968
+ /**
1969
+ * Performs remove Collaborator.
1970
+ *
1971
+ * @returns Promise with the removed Collaborator
1972
+ */
1973
+ remove(): Promise<Collaborator>;
1974
+ }
1975
+
1889
1976
  /**
1890
1977
  * This class defines a Collection of [[Books]].
1891
1978
  *
@@ -2491,6 +2578,49 @@ export declare class File {
2491
2578
  * @returns The file size in bytes
2492
2579
  */
2493
2580
  getSize(): number | undefined;
2581
+ /**
2582
+ * Gets the custom properties stored in this File.
2583
+ *
2584
+ * @returns The custom properties object
2585
+ */
2586
+ getProperties(): {
2587
+ [key: string]: string;
2588
+ };
2589
+ /**
2590
+ * Sets the custom properties of the File.
2591
+ *
2592
+ * @param properties - Object with key/value pair properties
2593
+ *
2594
+ * @returns This File, for chaining
2595
+ */
2596
+ setProperties(properties: {
2597
+ [key: string]: string;
2598
+ }): File;
2599
+ /**
2600
+ * Gets the property value for given keys. First property found will be retrieved.
2601
+ *
2602
+ * @param keys - The property key
2603
+ *
2604
+ * @returns The property value or undefined if not found
2605
+ */
2606
+ getProperty(...keys: string[]): string | undefined;
2607
+ /**
2608
+ * Sets a custom property in the File.
2609
+ *
2610
+ * @param key - The property key
2611
+ * @param value - The property value
2612
+ *
2613
+ * @returns This File, for chaining
2614
+ */
2615
+ setProperty(key: string, value: string | null): File;
2616
+ /**
2617
+ * Deletes a custom property.
2618
+ *
2619
+ * @param key - The property key
2620
+ *
2621
+ * @returns This File, for chaining
2622
+ */
2623
+ deleteProperty(key: string): File;
2494
2624
  /**
2495
2625
  * Perform create new File.
2496
2626
  *
package/lib/index.js CHANGED
@@ -14,6 +14,7 @@ export { BalancesDataTableBuilder } from './model/BalancesDataTableBuilder.js';
14
14
  export { BalancesReport } from './model/BalancesReport.js';
15
15
  export { Bkper } from './model/Bkper.js';
16
16
  export { Book } from './model/Book.js';
17
+ export { Collaborator } from './model/Collaborator.js';
17
18
  export { Collection } from './model/Collection.js';
18
19
  export { Connection } from './model/Connection.js';
19
20
  export { Conversation } from './model/Conversation.js';
package/lib/model/Book.js CHANGED
@@ -16,8 +16,10 @@ import * as GroupService from '../service/group-service.js';
16
16
  import * as IntegrationService from '../service/integration-service.js';
17
17
  import * as TransactionService from '../service/transaction-service.js';
18
18
  import * as EventService from '../service/event-service.js';
19
+ import * as CollaboratorService from '../service/collaborator-service.js';
19
20
  import * as Utils from '../utils.js';
20
21
  import { Account } from './Account.js';
22
+ import { Collaborator } from './Collaborator.js';
21
23
  import { Collection } from './Collection.js';
22
24
  import { Permission } from './Enums.js';
23
25
  import { EventList } from './EventList.js';
@@ -360,6 +362,17 @@ export class Book {
360
362
  getVisibility() {
361
363
  return this.payload.visibility;
362
364
  }
365
+ /**
366
+ * Sets the visibility of the book.
367
+ *
368
+ * @param visibility - The visibility to set
369
+ *
370
+ * @returns This Book, for chaining
371
+ */
372
+ setVisibility(visibility) {
373
+ this.payload.visibility = visibility;
374
+ return this;
375
+ }
363
376
  /**
364
377
  * Gets the custom properties stored in this Book.
365
378
  *
@@ -929,6 +942,10 @@ export class Book {
929
942
  this.nameAccountMap = undefined;
930
943
  }
931
944
  /** @internal */
945
+ clearCollaboratorCache() {
946
+ this.collaborators = undefined;
947
+ }
948
+ /** @internal */
932
949
  setAccount(account, remove) {
933
950
  const accountPayloads = this.payload.accounts || [];
934
951
  if (remove) {
@@ -1103,5 +1120,19 @@ export class Book {
1103
1120
  return this.queries;
1104
1121
  });
1105
1122
  }
1123
+ /**
1124
+ * Gets all collaborators of this Book.
1125
+ *
1126
+ * @returns Array of Collaborator objects
1127
+ */
1128
+ getCollaborators() {
1129
+ return __awaiter(this, void 0, void 0, function* () {
1130
+ if (!this.collaborators) {
1131
+ const collaboratorPayloads = yield CollaboratorService.listCollaborators(this.getId());
1132
+ this.collaborators = collaboratorPayloads.map(payload => new Collaborator(this, payload));
1133
+ }
1134
+ return this.collaborators;
1135
+ });
1136
+ }
1106
1137
  }
1107
1138
  //# sourceMappingURL=Book.js.map
@@ -0,0 +1,118 @@
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 * as CollaboratorService from '../service/collaborator-service.js';
11
+ /**
12
+ * This class defines a Collaborator of a [[Book]].
13
+ *
14
+ * A Collaborator represents a user that has been granted access to a Book with specific permissions.
15
+ *
16
+ * @public
17
+ */
18
+ export class Collaborator {
19
+ constructor(book, payload) {
20
+ this.book = book;
21
+ this.payload = payload || {};
22
+ }
23
+ /**
24
+ * Gets an immutable copy of the JSON payload.
25
+ *
26
+ * @returns An immutable copy of the json payload
27
+ */
28
+ json() {
29
+ return Object.assign({}, this.payload);
30
+ }
31
+ /**
32
+ * Gets the Collaborator internal id.
33
+ *
34
+ * @returns The Collaborator internal id
35
+ */
36
+ getId() {
37
+ return this.payload.id;
38
+ }
39
+ /**
40
+ * Gets the Collaborator email address.
41
+ *
42
+ * @returns The Collaborator email address
43
+ */
44
+ getEmail() {
45
+ return this.payload.email;
46
+ }
47
+ /**
48
+ * Sets the email address of the Collaborator.
49
+ *
50
+ * @param email - The email address to set
51
+ *
52
+ * @returns This Collaborator, for chaining
53
+ */
54
+ setEmail(email) {
55
+ this.payload.email = email;
56
+ return this;
57
+ }
58
+ /**
59
+ * Gets the permission level of the Collaborator.
60
+ *
61
+ * @returns The permission level
62
+ */
63
+ getPermission() {
64
+ return this.payload.permission;
65
+ }
66
+ /**
67
+ * Sets the permission level of the Collaborator.
68
+ *
69
+ * @param permission - The permission level to set
70
+ *
71
+ * @returns This Collaborator, for chaining
72
+ */
73
+ setPermission(permission) {
74
+ this.payload.permission = permission;
75
+ return this;
76
+ }
77
+ /**
78
+ * Performs create new Collaborator.
79
+ *
80
+ * @returns Promise with the created Collaborator
81
+ */
82
+ create(message) {
83
+ return __awaiter(this, void 0, void 0, function* () {
84
+ this.payload = yield CollaboratorService.addOrUpdateCollaborator(this.book.getId(), this.payload, message);
85
+ this.book.clearCollaboratorCache();
86
+ return this;
87
+ });
88
+ }
89
+ /**
90
+ * Performs update Collaborator.
91
+ *
92
+ * @returns Promise with the updated Collaborator
93
+ */
94
+ update() {
95
+ return __awaiter(this, void 0, void 0, function* () {
96
+ this.payload = yield CollaboratorService.addOrUpdateCollaborator(this.book.getId(), this.payload);
97
+ this.book.clearCollaboratorCache();
98
+ return this;
99
+ });
100
+ }
101
+ /**
102
+ * Performs remove Collaborator.
103
+ *
104
+ * @returns Promise with the removed Collaborator
105
+ */
106
+ remove() {
107
+ return __awaiter(this, void 0, void 0, function* () {
108
+ const email = this.getEmail();
109
+ if (!email) {
110
+ throw new Error('Collaborator email is required');
111
+ }
112
+ this.payload = yield CollaboratorService.removeCollaborator(this.book.getId(), email);
113
+ this.book.clearCollaboratorCache();
114
+ return this;
115
+ });
116
+ }
117
+ }
118
+ //# sourceMappingURL=Collaborator.js.map
package/lib/model/File.js CHANGED
@@ -119,6 +119,74 @@ export class File {
119
119
  getSize() {
120
120
  return this.payload.size;
121
121
  }
122
+ /**
123
+ * Gets the custom properties stored in this File.
124
+ *
125
+ * @returns The custom properties object
126
+ */
127
+ getProperties() {
128
+ return this.payload.properties != null ? Object.assign({}, this.payload.properties) : {};
129
+ }
130
+ /**
131
+ * Sets the custom properties of the File.
132
+ *
133
+ * @param properties - Object with key/value pair properties
134
+ *
135
+ * @returns This File, for chaining
136
+ */
137
+ setProperties(properties) {
138
+ this.payload.properties = Object.assign({}, properties);
139
+ return this;
140
+ }
141
+ /**
142
+ * Gets the property value for given keys. First property found will be retrieved.
143
+ *
144
+ * @param keys - The property key
145
+ *
146
+ * @returns The property value or undefined if not found
147
+ */
148
+ getProperty(...keys) {
149
+ for (let index = 0; index < keys.length; index++) {
150
+ const key = keys[index];
151
+ let value = this.payload.properties != null ? this.payload.properties[key] : null;
152
+ if (value != null && value.trim() != '') {
153
+ return value;
154
+ }
155
+ }
156
+ return undefined;
157
+ }
158
+ /**
159
+ * Sets a custom property in the File.
160
+ *
161
+ * @param key - The property key
162
+ * @param value - The property value
163
+ *
164
+ * @returns This File, for chaining
165
+ */
166
+ setProperty(key, value) {
167
+ if (key == null || key.trim() == '') {
168
+ return this;
169
+ }
170
+ if (this.payload.properties == null) {
171
+ this.payload.properties = {};
172
+ }
173
+ if (!value) {
174
+ value = '';
175
+ }
176
+ this.payload.properties[key] = value;
177
+ return this;
178
+ }
179
+ /**
180
+ * Deletes a custom property.
181
+ *
182
+ * @param key - The property key
183
+ *
184
+ * @returns This File, for chaining
185
+ */
186
+ deleteProperty(key) {
187
+ this.setProperty(key, null);
188
+ return this;
189
+ }
122
190
  /**
123
191
  * Perform create new File.
124
192
  *
@@ -0,0 +1,34 @@
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 { HttpBooksApiV5Request } from './http-api-request.js';
11
+ export function listCollaborators(bookId) {
12
+ return __awaiter(this, void 0, void 0, function* () {
13
+ var _a;
14
+ const response = yield new HttpBooksApiV5Request(`${bookId}/collaborators`).setMethod('GET').fetch();
15
+ return ((_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.items) || [];
16
+ });
17
+ }
18
+ export function addOrUpdateCollaborator(bookId, collaborator, message) {
19
+ return __awaiter(this, void 0, void 0, function* () {
20
+ let request = new HttpBooksApiV5Request(`${bookId}/collaborators`).setMethod('POST').setPayload(collaborator);
21
+ if (message) {
22
+ request = request.addParam('message', message);
23
+ }
24
+ const response = yield request.fetch();
25
+ return response.data;
26
+ });
27
+ }
28
+ export function removeCollaborator(bookId, email) {
29
+ return __awaiter(this, void 0, void 0, function* () {
30
+ const response = yield new HttpBooksApiV5Request(`${bookId}/collaborators/${email}`).setMethod('DELETE').fetch();
31
+ return response.data;
32
+ });
33
+ }
34
+ //# sourceMappingURL=collaborator-service.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bkper-js",
3
- "version": "2.5.1",
3
+ "version": "2.7.0",
4
4
  "description": "Javascript client for Bkper REST API",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.js",
@@ -34,10 +34,9 @@
34
34
  "postversion": "git push --tags && yarn publish --new-version $npm_package_version && git push && echo \"Successfully released version $npm_package_version!\""
35
35
  },
36
36
  "peerDependencies": {
37
- "@bkper/bkper-api-types": "^5.23.1"
37
+ "@bkper/bkper-api-types": "^5.25.0"
38
38
  },
39
39
  "dependencies": {
40
- "@google-cloud/local-auth": "^3.0.1",
41
40
  "axios": "^1.7.7",
42
41
  "big.js": "^6.0.3",
43
42
  "dayjs": "^1.10.3",