bkper-js 2.35.2 → 2.36.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/README.md +2 -0
- package/dist/bkper.min.js +2 -2
- package/dist/bkper.min.js.map +4 -4
- package/lib/index.d.ts +44 -0
- package/lib/index.js +1 -0
- package/lib/model/Book.js +15 -0
- package/lib/model/FileList.js +52 -0
- package/lib/service/file-service.js +14 -0
- package/package.json +2 -2
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
|
*
|
|
@@ -2849,6 +2858,41 @@ export declare class File extends ResourceProperty<bkper.File> {
|
|
|
2849
2858
|
update(): Promise<File>;
|
|
2850
2859
|
}
|
|
2851
2860
|
|
|
2861
|
+
/**
|
|
2862
|
+
* A list associated with a file query.
|
|
2863
|
+
*
|
|
2864
|
+
* @public
|
|
2865
|
+
*/
|
|
2866
|
+
export declare class FileList {
|
|
2867
|
+
private payload;
|
|
2868
|
+
|
|
2869
|
+
constructor(book: Book, payload: bkper.FileList);
|
|
2870
|
+
/**
|
|
2871
|
+
* Gets the cursor associated with the query for pagination.
|
|
2872
|
+
*
|
|
2873
|
+
* @returns The cursor associated with the query for pagination
|
|
2874
|
+
*/
|
|
2875
|
+
getCursor(): string | undefined;
|
|
2876
|
+
/**
|
|
2877
|
+
* Gets the first File in the list.
|
|
2878
|
+
*
|
|
2879
|
+
* @returns The first File in the list
|
|
2880
|
+
*/
|
|
2881
|
+
getFirst(): File | undefined;
|
|
2882
|
+
/**
|
|
2883
|
+
* Gets the total number of files in the list.
|
|
2884
|
+
*
|
|
2885
|
+
* @returns The total number of files
|
|
2886
|
+
*/
|
|
2887
|
+
size(): number;
|
|
2888
|
+
/**
|
|
2889
|
+
* Gets the files in the list.
|
|
2890
|
+
*
|
|
2891
|
+
* @returns An array of File objects
|
|
2892
|
+
*/
|
|
2893
|
+
getItems(): File[];
|
|
2894
|
+
}
|
|
2895
|
+
|
|
2852
2896
|
/**
|
|
2853
2897
|
* This class defines a Group of [[Accounts]].
|
|
2854
2898
|
*
|
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
|
*
|
|
@@ -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
|
|
@@ -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.
|
|
3
|
+
"version": "2.36.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.
|
|
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",
|