bkper-js 2.5.0 → 2.6.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
@@ -1760,7 +1760,7 @@ export declare class Book {
1760
1760
  *
1761
1761
  * @returns The [[File]] object
1762
1762
  */
1763
- getFile(id: string): Promise<File>;
1763
+ getFile(id: string): Promise<File | undefined>;
1764
1764
  /**
1765
1765
  * Performs create new Book.
1766
1766
  *
@@ -2491,6 +2491,49 @@ export declare class File {
2491
2491
  * @returns The file size in bytes
2492
2492
  */
2493
2493
  getSize(): number | undefined;
2494
+ /**
2495
+ * Gets the custom properties stored in this File.
2496
+ *
2497
+ * @returns The custom properties object
2498
+ */
2499
+ getProperties(): {
2500
+ [key: string]: string;
2501
+ };
2502
+ /**
2503
+ * Sets the custom properties of the File.
2504
+ *
2505
+ * @param properties - Object with key/value pair properties
2506
+ *
2507
+ * @returns This File, for chaining
2508
+ */
2509
+ setProperties(properties: {
2510
+ [key: string]: string;
2511
+ }): File;
2512
+ /**
2513
+ * Gets the property value for given keys. First property found will be retrieved.
2514
+ *
2515
+ * @param keys - The property key
2516
+ *
2517
+ * @returns The property value or undefined if not found
2518
+ */
2519
+ getProperty(...keys: string[]): string | undefined;
2520
+ /**
2521
+ * Sets a custom property in the File.
2522
+ *
2523
+ * @param key - The property key
2524
+ * @param value - The property value
2525
+ *
2526
+ * @returns This File, for chaining
2527
+ */
2528
+ setProperty(key: string, value: string | null): File;
2529
+ /**
2530
+ * Deletes a custom property.
2531
+ *
2532
+ * @param key - The property key
2533
+ *
2534
+ * @returns This File, for chaining
2535
+ */
2536
+ deleteProperty(key: string): File;
2494
2537
  /**
2495
2538
  * Perform create new File.
2496
2539
  *
package/lib/model/Book.js CHANGED
@@ -1020,6 +1020,9 @@ export class Book {
1020
1020
  getFile(id) {
1021
1021
  return __awaiter(this, void 0, void 0, function* () {
1022
1022
  let wrapped = yield FileService.getFile(this.getId(), id);
1023
+ if (!wrapped) {
1024
+ return undefined;
1025
+ }
1023
1026
  let file = new File(this, wrapped);
1024
1027
  return file;
1025
1028
  });
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
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bkper-js",
3
- "version": "2.5.0",
3
+ "version": "2.6.0",
4
4
  "description": "Javascript client for Bkper REST API",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.js",
@@ -34,7 +34,7 @@
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.24.0"
38
38
  },
39
39
  "dependencies": {
40
40
  "@google-cloud/local-auth": "^3.0.1",