bkper-js 1.39.0 → 1.40.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 +10 -1
- package/lib/model/Query.js +31 -1
- package/lib/service/query-service.js +12 -0
- package/package.json +2 -2
package/lib/index.d.ts
CHANGED
|
@@ -2284,9 +2284,18 @@ export declare class Query {
|
|
|
2284
2284
|
*/
|
|
2285
2285
|
getQuery(): string | undefined;
|
|
2286
2286
|
/**
|
|
2287
|
-
* Perform
|
|
2287
|
+
* Perform create new Query.
|
|
2288
|
+
*/
|
|
2289
|
+
create(): Promise<Query>;
|
|
2290
|
+
/**
|
|
2291
|
+
* Perform update Query, applying pending changes.
|
|
2292
|
+
*/
|
|
2293
|
+
update(): Promise<Query>;
|
|
2294
|
+
/**
|
|
2295
|
+
* Perform delete Query.
|
|
2288
2296
|
*/
|
|
2289
2297
|
remove(): Promise<Query>;
|
|
2298
|
+
|
|
2290
2299
|
}
|
|
2291
2300
|
|
|
2292
2301
|
/**
|
package/lib/model/Query.js
CHANGED
|
@@ -45,7 +45,27 @@ export class Query {
|
|
|
45
45
|
return this.payload.query;
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
48
|
-
* Perform
|
|
48
|
+
* Perform create new Query.
|
|
49
|
+
*/
|
|
50
|
+
create() {
|
|
51
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
+
this.payload = yield QueryService.createSavedQuery(this.book.getId(), this.payload);
|
|
53
|
+
this.updateQueryCache();
|
|
54
|
+
return this;
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Perform update Query, applying pending changes.
|
|
59
|
+
*/
|
|
60
|
+
update() {
|
|
61
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
this.payload = yield QueryService.updateSavedQuery(this.book.getId(), this.payload);
|
|
63
|
+
this.updateQueryCache();
|
|
64
|
+
return this;
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Perform delete Query.
|
|
49
69
|
*/
|
|
50
70
|
remove() {
|
|
51
71
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -54,8 +74,18 @@ export class Query {
|
|
|
54
74
|
throw new Error("Query id null!");
|
|
55
75
|
}
|
|
56
76
|
this.payload = yield QueryService.deleteSavedQuery(this.book.getId(), queryId);
|
|
77
|
+
this.updateQueryCache(true);
|
|
57
78
|
return this;
|
|
58
79
|
});
|
|
59
80
|
}
|
|
81
|
+
/** @internal */
|
|
82
|
+
updateQueryCache(deleted) {
|
|
83
|
+
if (this.book.queries) {
|
|
84
|
+
this.book.queries = this.book.queries.filter(q => q.getId() !== this.getId());
|
|
85
|
+
if (!deleted) {
|
|
86
|
+
this.book.queries.push(this);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
60
90
|
}
|
|
61
91
|
//# sourceMappingURL=Query.js.map
|
|
@@ -15,6 +15,18 @@ export function getSavedQueries(bookId) {
|
|
|
15
15
|
return ((_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.items) || [];
|
|
16
16
|
});
|
|
17
17
|
}
|
|
18
|
+
export function createSavedQuery(bookId, query) {
|
|
19
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
let response = yield new HttpBooksApiV5Request(`${bookId}/queries`).setMethod('POST').setPayload(query).fetch();
|
|
21
|
+
return response.data;
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
export function updateSavedQuery(bookId, query) {
|
|
25
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
let response = yield new HttpBooksApiV5Request(`${bookId}/queries`).setMethod('PUT').setPayload(query).fetch();
|
|
27
|
+
return response.data;
|
|
28
|
+
});
|
|
29
|
+
}
|
|
18
30
|
export function deleteSavedQuery(bookId, queryId) {
|
|
19
31
|
return __awaiter(this, void 0, void 0, function* () {
|
|
20
32
|
let response = yield new HttpBooksApiV5Request(`${bookId}/queries/${queryId}`).setMethod('DELETE').fetch();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bkper-js",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.40.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.
|
|
37
|
+
"@bkper/bkper-api-types": "^5.19.0"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@google-cloud/local-auth": "^3.0.1",
|