bkper-js 2.35.2 → 2.37.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
@@ -2020,6 +2020,15 @@ export declare class Book extends ResourceProperty<bkper.Book> {
2020
2020
  * @returns A [[TransactionList]] object containing the list of transactions
2021
2021
  */
2022
2022
  listTransactions(query?: string, limit?: number, cursor?: string): Promise<TransactionList>;
2023
+ /**
2024
+ * Lists files in the Book, for pagination.
2025
+ *
2026
+ * @param limit - The maximum number of files to return. Default to 100
2027
+ * @param cursor - The cursor for pagination
2028
+ *
2029
+ * @returns A [[FileList]] object containing the list of files
2030
+ */
2031
+ listFiles(limit?: number, cursor?: string): Promise<FileList>;
2023
2032
  /**
2024
2033
  * Retrieve the number of transactions based on a query.
2025
2034
  *
@@ -2565,7 +2574,7 @@ export declare class Connection extends ResourceProperty<bkper.Connection> {
2565
2574
  *
2566
2575
  * @returns The Connection type
2567
2576
  */
2568
- getType(): "APP" | "BANK" | undefined;
2577
+ getType(): 'APP' | 'BANK' | undefined;
2569
2578
  /**
2570
2579
  * Sets the Connection type.
2571
2580
  *
@@ -2573,7 +2582,7 @@ export declare class Connection extends ResourceProperty<bkper.Connection> {
2573
2582
  *
2574
2583
  * @returns The Connection, for chaining
2575
2584
  */
2576
- setType(type: "APP" | "BANK"): Connection;
2585
+ setType(type: 'APP' | 'BANK'): Connection;
2577
2586
  /**
2578
2587
  * Cleans any token property stored in the Connection.
2579
2588
  */
@@ -2590,6 +2599,12 @@ export declare class Connection extends ResourceProperty<bkper.Connection> {
2590
2599
  * @returns The created Connection, for chaining
2591
2600
  */
2592
2601
  create(): Promise<Connection>;
2602
+ /**
2603
+ * Performs update Connection.
2604
+ *
2605
+ * @returns The updated Connection object
2606
+ */
2607
+ update(): Promise<Connection>;
2593
2608
  /**
2594
2609
  * Performs remove Connection.
2595
2610
  *
@@ -2849,6 +2864,41 @@ export declare class File extends ResourceProperty<bkper.File> {
2849
2864
  update(): Promise<File>;
2850
2865
  }
2851
2866
 
2867
+ /**
2868
+ * A list associated with a file query.
2869
+ *
2870
+ * @public
2871
+ */
2872
+ export declare class FileList {
2873
+ private payload;
2874
+
2875
+ constructor(book: Book, payload: bkper.FileList);
2876
+ /**
2877
+ * Gets the cursor associated with the query for pagination.
2878
+ *
2879
+ * @returns The cursor associated with the query for pagination
2880
+ */
2881
+ getCursor(): string | undefined;
2882
+ /**
2883
+ * Gets the first File in the list.
2884
+ *
2885
+ * @returns The first File in the list
2886
+ */
2887
+ getFirst(): File | undefined;
2888
+ /**
2889
+ * Gets the total number of files in the list.
2890
+ *
2891
+ * @returns The total number of files
2892
+ */
2893
+ size(): number;
2894
+ /**
2895
+ * Gets the files in the list.
2896
+ *
2897
+ * @returns An array of File objects
2898
+ */
2899
+ getItems(): File[];
2900
+ }
2901
+
2852
2902
  /**
2853
2903
  * This class defines a Group of [[Accounts]].
2854
2904
  *
@@ -3153,6 +3203,14 @@ export declare class Integration extends ResourceProperty<bkper.Integration> {
3153
3203
  * @returns The Integration's name
3154
3204
  */
3155
3205
  getName(): string | undefined;
3206
+ /**
3207
+ * Sets the name of the Integration.
3208
+ *
3209
+ * @param name - The name of the Integration
3210
+ *
3211
+ * @returns The Integration, for chaining
3212
+ */
3213
+ setName(name: string): Integration;
3156
3214
  /**
3157
3215
  * Gets the name of the user who added the Integration.
3158
3216
  *
@@ -3197,6 +3255,12 @@ export declare class Integration extends ResourceProperty<bkper.Integration> {
3197
3255
  * @returns The Integration last update date in milliseconds
3198
3256
  */
3199
3257
  getLastUpdateMs(): string | undefined;
3258
+ /**
3259
+ * Performs update Integration.
3260
+ *
3261
+ * @returns The updated Integration object
3262
+ */
3263
+ update(): Promise<Integration>;
3200
3264
  /**
3201
3265
  * Performs remove Integration.
3202
3266
  *
@@ -3413,6 +3477,16 @@ declare abstract class Resource<T = any> {
3413
3477
  * Extends Resource<T> and adds property management methods for entities
3414
3478
  * that have a properties field in their payload.
3415
3479
  *
3480
+ * Custom property keys are normalized and validated by the Bkper API when
3481
+ * resources are persisted:
3482
+ *
3483
+ * - Keys can have up to 30 characters after normalization.
3484
+ * - Keys are normalized to lowercase, spaces become underscores, and unsupported
3485
+ * punctuation is removed.
3486
+ * - Keys ending with an underscore (`_`) are treated as hidden/internal by SDK
3487
+ * visible-property helpers.
3488
+ * - Empty, null, or undefined values clear the property when saved.
3489
+ *
3416
3490
  * @public
3417
3491
  */
3418
3492
  declare abstract class ResourceProperty<T extends {
@@ -3450,6 +3524,10 @@ declare abstract class ResourceProperty<T extends {
3450
3524
  /**
3451
3525
  * Sets a custom property in this resource.
3452
3526
  *
3527
+ * Property keys are normalized and validated by the API when saved. Keep keys
3528
+ * to 30 characters or fewer after normalization. Use a trailing underscore
3529
+ * (`_`) for hidden/internal properties.
3530
+ *
3453
3531
  * @param key - The property key
3454
3532
  * @param value - The property value, or null/undefined to clean it
3455
3533
  *
package/lib/index.js CHANGED
@@ -22,6 +22,7 @@ export { Collaborator } from './model/Collaborator.js';
22
22
  export { Collection } from './model/Collection.js';
23
23
  export { Connection } from './model/Connection.js';
24
24
  export { File } from './model/File.js';
25
+ export { FileList } from './model/FileList.js';
25
26
  export { Group } from './model/Group.js';
26
27
  export { GroupsDataTableBuilder } from './builders/GroupsDataTableBuilder.js';
27
28
  export { Integration } from './model/Integration.js';
package/lib/model/Book.js CHANGED
@@ -25,6 +25,7 @@ import { Collection } from './Collection.js';
25
25
  import { Permission } from './Enums.js';
26
26
  import { EventList } from './EventList.js';
27
27
  import { File } from './File.js';
28
+ import { FileList } from './FileList.js';
28
29
  import { Group } from './Group.js';
29
30
  import { Integration } from './Integration.js';
30
31
  import { Transaction } from './Transaction.js';
@@ -1150,6 +1151,20 @@ export class Book extends ResourceProperty {
1150
1151
  return new TransactionList(this, transactionsList);
1151
1152
  });
1152
1153
  }
1154
+ /**
1155
+ * Lists files in the Book, for pagination.
1156
+ *
1157
+ * @param limit - The maximum number of files to return. Default to 100
1158
+ * @param cursor - The cursor for pagination
1159
+ *
1160
+ * @returns A [[FileList]] object containing the list of files
1161
+ */
1162
+ listFiles(limit, cursor) {
1163
+ return __awaiter(this, void 0, void 0, function* () {
1164
+ const fileList = yield FileService.listFiles(this.getId(), limit, cursor, this.getConfig());
1165
+ return new FileList(this, fileList);
1166
+ });
1167
+ }
1153
1168
  /**
1154
1169
  * Retrieve the number of transactions based on a query.
1155
1170
  *
@@ -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 { ResourceProperty } from "./ResourceProperty.js";
11
- import { Bkper } from "./Bkper.js";
12
- import * as ConnectionService from "../service/connection-service.js";
13
- import { Integration } from "./Integration.js";
10
+ import { ResourceProperty } from './ResourceProperty.js';
11
+ import { Bkper } from './Bkper.js';
12
+ import * as ConnectionService from '../service/connection-service.js';
13
+ import { Integration } from './Integration.js';
14
14
  /**
15
15
  * This class defines a Connection from an [[User]] to an external service.
16
16
  *
@@ -138,8 +138,8 @@ export class Connection extends ResourceProperty {
138
138
  */
139
139
  clearTokenProperties() {
140
140
  this.getPropertyKeys()
141
- .filter((key) => key.includes("token"))
142
- .forEach((key) => this.deleteProperty(key));
141
+ .filter(key => key.includes('token'))
142
+ .forEach(key => this.deleteProperty(key));
143
143
  }
144
144
  /**
145
145
  * Gets the existing [[Integrations]] on the Connection.
@@ -153,7 +153,7 @@ export class Connection extends ResourceProperty {
153
153
  return [];
154
154
  }
155
155
  const integrationsPlain = yield ConnectionService.listIntegrations(id, this.getConfig());
156
- const integrations = integrationsPlain.map((i) => new Integration(i, this.config));
156
+ const integrations = integrationsPlain.map(i => new Integration(i, this.config));
157
157
  return integrations;
158
158
  });
159
159
  }
@@ -168,6 +168,17 @@ export class Connection extends ResourceProperty {
168
168
  return this;
169
169
  });
170
170
  }
171
+ /**
172
+ * Performs update Connection.
173
+ *
174
+ * @returns The updated Connection object
175
+ */
176
+ update() {
177
+ return __awaiter(this, void 0, void 0, function* () {
178
+ this.payload = yield ConnectionService.updateConnection(this.payload, this.getConfig());
179
+ return this;
180
+ });
181
+ }
171
182
  /**
172
183
  * Performs remove Connection.
173
184
  *
@@ -0,0 +1,52 @@
1
+ import { File } from './File.js';
2
+ /**
3
+ * A list associated with a file query.
4
+ *
5
+ * @public
6
+ */
7
+ export class FileList {
8
+ constructor(book, payload) {
9
+ this.book = book;
10
+ this.payload = payload || {};
11
+ }
12
+ /**
13
+ * Gets the cursor associated with the query for pagination.
14
+ *
15
+ * @returns The cursor associated with the query for pagination
16
+ */
17
+ getCursor() {
18
+ return this.payload.cursor;
19
+ }
20
+ /**
21
+ * Gets the first File in the list.
22
+ *
23
+ * @returns The first File in the list
24
+ */
25
+ getFirst() {
26
+ const files = this.getItems();
27
+ return files.length > 0 ? files[0] : undefined;
28
+ }
29
+ /**
30
+ * Gets the total number of files in the list.
31
+ *
32
+ * @returns The total number of files
33
+ */
34
+ size() {
35
+ var _a;
36
+ return ((_a = this.payload.items) === null || _a === void 0 ? void 0 : _a.length) || 0;
37
+ }
38
+ /**
39
+ * Gets the files in the list.
40
+ *
41
+ * @returns An array of File objects
42
+ */
43
+ getItems() {
44
+ var _a;
45
+ const files = [];
46
+ for (const file of (_a = this.payload.items) !== null && _a !== void 0 ? _a : []) {
47
+ files.push(new File(this.book, file));
48
+ }
49
+ return files;
50
+ }
51
+ }
52
+ //# sourceMappingURL=FileList.js.map
@@ -7,9 +7,9 @@ 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 IntegrationService from "../service/integration-service.js";
11
- import { ResourceProperty } from "./ResourceProperty.js";
12
- import { Bkper } from "./Bkper.js";
10
+ import * as IntegrationService from '../service/integration-service.js';
11
+ import { ResourceProperty } from './ResourceProperty.js';
12
+ import { Bkper } from './Bkper.js';
13
13
  /**
14
14
  * This class defines a Integration from an [[User]] to an external service.
15
15
  *
@@ -48,6 +48,17 @@ export class Integration extends ResourceProperty {
48
48
  getName() {
49
49
  return this.payload.name;
50
50
  }
51
+ /**
52
+ * Sets the name of the Integration.
53
+ *
54
+ * @param name - The name of the Integration
55
+ *
56
+ * @returns The Integration, for chaining
57
+ */
58
+ setName(name) {
59
+ this.payload.name = name;
60
+ return this;
61
+ }
51
62
  /**
52
63
  * Gets the name of the user who added the Integration.
53
64
  *
@@ -106,6 +117,20 @@ export class Integration extends ResourceProperty {
106
117
  getLastUpdateMs() {
107
118
  return this.payload.lastUpdateMs;
108
119
  }
120
+ /**
121
+ * Performs update Integration.
122
+ *
123
+ * @returns The updated Integration object
124
+ */
125
+ update() {
126
+ return __awaiter(this, void 0, void 0, function* () {
127
+ const bookId = this.getBookId();
128
+ if (bookId) {
129
+ this.payload = yield IntegrationService.updateIntegration(bookId, this.payload, this.getConfig());
130
+ }
131
+ return this;
132
+ });
133
+ }
109
134
  /**
110
135
  * Performs remove Integration.
111
136
  *
@@ -5,6 +5,16 @@ import { Resource } from "./Resource.js";
5
5
  * Extends Resource<T> and adds property management methods for entities
6
6
  * that have a properties field in their payload.
7
7
  *
8
+ * Custom property keys are normalized and validated by the Bkper API when
9
+ * resources are persisted:
10
+ *
11
+ * - Keys can have up to 30 characters after normalization.
12
+ * - Keys are normalized to lowercase, spaces become underscores, and unsupported
13
+ * punctuation is removed.
14
+ * - Keys ending with an underscore (`_`) are treated as hidden/internal by SDK
15
+ * visible-property helpers.
16
+ * - Empty, null, or undefined values clear the property when saved.
17
+ *
8
18
  * @public
9
19
  */
10
20
  export class ResourceProperty extends Resource {
@@ -62,6 +72,10 @@ export class ResourceProperty extends Resource {
62
72
  /**
63
73
  * Sets a custom property in this resource.
64
74
  *
75
+ * Property keys are normalized and validated by the API when saved. Keep keys
76
+ * to 30 characters or fewer after normalization. Use a trailing underscore
77
+ * (`_`) for hidden/internal properties.
78
+ *
65
79
  * @param key - The property key
66
80
  * @param value - The property value, or null/undefined to clean it
67
81
  *
@@ -20,6 +20,20 @@ export function getFile(bookId, id, config) {
20
20
  return response.data;
21
21
  });
22
22
  }
23
+ export function listFiles(bookId, limit, cursor, config) {
24
+ return __awaiter(this, void 0, void 0, function* () {
25
+ if (!limit) {
26
+ limit = 100;
27
+ }
28
+ const request = new HttpBooksApiV5Request(`${bookId}/files`, config);
29
+ request.addParam('limit', limit);
30
+ if (cursor != null) {
31
+ request.setHeader('cursor', cursor);
32
+ }
33
+ const response = yield request.fetch();
34
+ return response.data;
35
+ });
36
+ }
23
37
  export function updateFile(bookId, file, config) {
24
38
  return __awaiter(this, void 0, void 0, function* () {
25
39
  let response = yield new HttpBooksApiV5Request(`${bookId}/files`, config).setMethod('PUT').setPayload(file).fetch();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bkper-js",
3
- "version": "2.35.2",
3
+ "version": "2.37.0",
4
4
  "description": "Javascript client for Bkper REST API",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.js",
@@ -38,7 +38,7 @@
38
38
  "release:major": "npm version major -m \"chore(release): v%s\""
39
39
  },
40
40
  "dependencies": {
41
- "@bkper/bkper-api-types": "^5.40.2",
41
+ "@bkper/bkper-api-types": "^5.41.0",
42
42
  "big.js": "^6.0.3",
43
43
  "dayjs": "^1.10.3",
44
44
  "luxon": "^1.25.0",