bkper-js 2.39.0 → 2.40.1
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/dist/bkper.min.js +1 -1
- package/dist/bkper.min.js.map +3 -3
- package/lib/index.d.ts +65 -6
- package/lib/model/Book.js +32 -21
- package/lib/model/ListEventsOptions.js +2 -0
- package/lib/service/event-service.js +2 -1
- package/package.json +2 -2
package/lib/index.d.ts
CHANGED
|
@@ -2037,19 +2037,30 @@ export declare class Book extends ResourceProperty<bkper.Book> {
|
|
|
2037
2037
|
* @returns The number of matching transactions
|
|
2038
2038
|
*/
|
|
2039
2039
|
countTransactions(query?: string): Promise<number | undefined>;
|
|
2040
|
+
/**
|
|
2041
|
+
* Lists events in the Book based on the provided options.
|
|
2042
|
+
*
|
|
2043
|
+
* @param options - The event list options
|
|
2044
|
+
*
|
|
2045
|
+
* @returns An [[EventList]] object containing the list of events
|
|
2046
|
+
*/
|
|
2047
|
+
listEvents(options: ListEventsOptions): Promise<EventList>;
|
|
2040
2048
|
/**
|
|
2041
2049
|
* Lists events in the Book based on the provided parameters.
|
|
2042
2050
|
*
|
|
2043
|
-
* @
|
|
2044
|
-
*
|
|
2045
|
-
* @param
|
|
2046
|
-
* @param
|
|
2047
|
-
* @param
|
|
2048
|
-
* @param
|
|
2051
|
+
* @deprecated Use `listEvents(options)` instead.
|
|
2052
|
+
*
|
|
2053
|
+
* @param afterDate - The start date (inclusive) for the events search range, in [RFC3339](https://en.wikipedia.org/wiki/ISO_8601#RFC_3339) format.
|
|
2054
|
+
* @param beforeDate - The end date (exclusive) for the events search range, in [RFC3339](https://en.wikipedia.org/wiki/ISO_8601#RFC_3339) format.
|
|
2055
|
+
* @param onError - Whether to filter events by error responses. `true` returns events with at least one error response. `false` returns events with no error responses. `null` or `undefined` includes events regardless of error responses. Ignored when `resourceId` is set.
|
|
2056
|
+
* @param resourceId - The ID of the event's resource (Transaction, Account, or Group). When set, `onError` is ignored.
|
|
2057
|
+
* @param limit - The maximum number of events to return. Defaults to `50`, maximum is `200`.
|
|
2058
|
+
* @param cursor - The cursor for pagination.
|
|
2049
2059
|
*
|
|
2050
2060
|
* @returns An [[EventList]] object containing the list of events
|
|
2051
2061
|
*/
|
|
2052
2062
|
listEvents(afterDate: string | null, beforeDate: string | null, onError: boolean | null, resourceId: string | null, limit: number, cursor?: string): Promise<EventList>;
|
|
2063
|
+
|
|
2053
2064
|
/**
|
|
2054
2065
|
* Retrieve a transaction by id.
|
|
2055
2066
|
*
|
|
@@ -3281,6 +3292,54 @@ export declare class Integration extends ResourceProperty<bkper.Integration> {
|
|
|
3281
3292
|
remove(): Promise<Integration>;
|
|
3282
3293
|
}
|
|
3283
3294
|
|
|
3295
|
+
/**
|
|
3296
|
+
* Options for listing events in a Book.
|
|
3297
|
+
*
|
|
3298
|
+
* @public
|
|
3299
|
+
*/
|
|
3300
|
+
export declare interface ListEventsOptions {
|
|
3301
|
+
/**
|
|
3302
|
+
* The start date (inclusive) for the events search range, in [RFC3339](https://en.wikipedia.org/wiki/ISO_8601#RFC_3339) format.
|
|
3303
|
+
*/
|
|
3304
|
+
afterDate?: string;
|
|
3305
|
+
/**
|
|
3306
|
+
* The end date (exclusive) for the events search range, in [RFC3339](https://en.wikipedia.org/wiki/ISO_8601#RFC_3339) format.
|
|
3307
|
+
*/
|
|
3308
|
+
beforeDate?: string;
|
|
3309
|
+
/**
|
|
3310
|
+
* The ID of the event's resource (Transaction, Account, or Group).
|
|
3311
|
+
*
|
|
3312
|
+
* When set, `onError` and `type` are ignored.
|
|
3313
|
+
*/
|
|
3314
|
+
resourceId?: string;
|
|
3315
|
+
/**
|
|
3316
|
+
* Whether to filter events by error responses.
|
|
3317
|
+
*
|
|
3318
|
+
* `true` returns events with at least one error response.
|
|
3319
|
+
* `false` returns events with no error responses.
|
|
3320
|
+
* `null` or `undefined` includes events regardless of error responses.
|
|
3321
|
+
*
|
|
3322
|
+
* Ignored when `resourceId` is set. When set, `type` is ignored.
|
|
3323
|
+
*/
|
|
3324
|
+
onError?: boolean;
|
|
3325
|
+
/**
|
|
3326
|
+
* The event type to filter by.
|
|
3327
|
+
*
|
|
3328
|
+
* Ignored when `resourceId` or `onError` is set.
|
|
3329
|
+
*/
|
|
3330
|
+
type?: EventType;
|
|
3331
|
+
/**
|
|
3332
|
+
* The maximum number of events to return.
|
|
3333
|
+
*
|
|
3334
|
+
* Defaults to `50`, maximum is `200`.
|
|
3335
|
+
*/
|
|
3336
|
+
limit: number;
|
|
3337
|
+
/**
|
|
3338
|
+
* The cursor for pagination.
|
|
3339
|
+
*/
|
|
3340
|
+
cursor?: string;
|
|
3341
|
+
}
|
|
3342
|
+
|
|
3284
3343
|
/**
|
|
3285
3344
|
* Enum that represents how an App menu opens.
|
|
3286
3345
|
*
|
package/lib/model/Book.js
CHANGED
|
@@ -558,15 +558,19 @@ export class Book extends ResourceProperty {
|
|
|
558
558
|
*/
|
|
559
559
|
mergeTransactions(transaction1, transaction2) {
|
|
560
560
|
return __awaiter(this, void 0, void 0, function* () {
|
|
561
|
-
const transactionId1 = typeof transaction1 === 'string'
|
|
562
|
-
|
|
563
|
-
|
|
561
|
+
const transactionId1 = typeof transaction1 === 'string'
|
|
562
|
+
? transaction1
|
|
563
|
+
: transaction1 instanceof Transaction
|
|
564
|
+
? transaction1.getId()
|
|
565
|
+
: transaction1.id;
|
|
564
566
|
if (transactionId1 == null || transactionId1.trim() === '') {
|
|
565
567
|
throw new Error('The first transaction must provide an id for merge.');
|
|
566
568
|
}
|
|
567
|
-
const transactionId2 = typeof transaction2 === 'string'
|
|
568
|
-
|
|
569
|
-
|
|
569
|
+
const transactionId2 = typeof transaction2 === 'string'
|
|
570
|
+
? transaction2
|
|
571
|
+
: transaction2 instanceof Transaction
|
|
572
|
+
? transaction2.getId()
|
|
573
|
+
: transaction2.id;
|
|
570
574
|
if (transactionId2 == null || transactionId2.trim() === '') {
|
|
571
575
|
throw new Error('The second transaction must provide an id for merge.');
|
|
572
576
|
}
|
|
@@ -1178,22 +1182,29 @@ export class Book extends ResourceProperty {
|
|
|
1178
1182
|
return count.total;
|
|
1179
1183
|
});
|
|
1180
1184
|
}
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1185
|
+
listEvents(optionsOrAfterDate, beforeDate, onError, resourceId, limit, cursor) {
|
|
1186
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1187
|
+
const isOptions = typeof optionsOrAfterDate === 'object' && optionsOrAfterDate !== null;
|
|
1188
|
+
if (isOptions) {
|
|
1189
|
+
return this.listEventsWithOptions(optionsOrAfterDate);
|
|
1190
|
+
}
|
|
1191
|
+
const options = {
|
|
1192
|
+
afterDate: optionsOrAfterDate !== null && optionsOrAfterDate !== void 0 ? optionsOrAfterDate : undefined,
|
|
1193
|
+
beforeDate: beforeDate !== null && beforeDate !== void 0 ? beforeDate : undefined,
|
|
1194
|
+
resourceId: resourceId !== null && resourceId !== void 0 ? resourceId : undefined,
|
|
1195
|
+
onError: onError !== null && onError !== void 0 ? onError : undefined,
|
|
1196
|
+
type: undefined,
|
|
1197
|
+
limit: limit !== null && limit !== void 0 ? limit : 50,
|
|
1198
|
+
cursor,
|
|
1199
|
+
};
|
|
1200
|
+
return this.listEventsWithOptions(options);
|
|
1201
|
+
});
|
|
1202
|
+
}
|
|
1203
|
+
/** @internal */
|
|
1204
|
+
listEventsWithOptions(options) {
|
|
1194
1205
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1195
|
-
const
|
|
1196
|
-
return new EventList(this,
|
|
1206
|
+
const eventList = yield EventService.listEvents(this, options.afterDate, options.beforeDate, options.onError, options.resourceId, options.type, options.limit, options.cursor, this.getConfig());
|
|
1207
|
+
return new EventList(this, eventList);
|
|
1197
1208
|
});
|
|
1198
1209
|
}
|
|
1199
1210
|
/**
|
|
@@ -8,13 +8,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { HttpBooksApiV5Request } from "./http-api-request.js";
|
|
11
|
-
export function listEvents(book, afterDate, beforeDate, onError, resourceId, limit, cursor, config) {
|
|
11
|
+
export function listEvents(book, afterDate, beforeDate, onError, resourceId, eventType, limit, cursor, config) {
|
|
12
12
|
return __awaiter(this, void 0, void 0, function* () {
|
|
13
13
|
let request = new HttpBooksApiV5Request(`${book.getId()}/events`, config);
|
|
14
14
|
request.addParam('after', afterDate);
|
|
15
15
|
request.addParam('before', beforeDate);
|
|
16
16
|
request.addParam('error', onError);
|
|
17
17
|
request.addParam('resoureId', resourceId);
|
|
18
|
+
request.addParam('type', eventType);
|
|
18
19
|
request.addParam('limit', limit);
|
|
19
20
|
if (cursor != null) {
|
|
20
21
|
request.setHeader('cursor', cursor);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bkper-js",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.40.1",
|
|
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.43.0",
|
|
42
42
|
"big.js": "^6.0.3",
|
|
43
43
|
"dayjs": "^1.10.3",
|
|
44
44
|
"luxon": "^1.25.0",
|