bkper-js 1.39.1 → 1.41.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 +26 -1
- package/lib/model/Query.js +53 -4
- package/lib/service/query-service.js +12 -0
- package/package.json +2 -2
package/lib/index.d.ts
CHANGED
|
@@ -2279,14 +2279,39 @@ export declare class Query {
|
|
|
2279
2279
|
* @return The title of this saved Query
|
|
2280
2280
|
*/
|
|
2281
2281
|
getTitle(): string | undefined;
|
|
2282
|
+
/**
|
|
2283
|
+
* Sets the title of this saved Query.
|
|
2284
|
+
*
|
|
2285
|
+
* @param title The title of this saved Query
|
|
2286
|
+
*
|
|
2287
|
+
* @returns This Query, for chaining
|
|
2288
|
+
*/
|
|
2289
|
+
setTitle(title: string): Query;
|
|
2282
2290
|
/**
|
|
2283
2291
|
* @return This Query string to be executed
|
|
2284
2292
|
*/
|
|
2285
2293
|
getQuery(): string | undefined;
|
|
2286
2294
|
/**
|
|
2287
|
-
*
|
|
2295
|
+
* Sets the query string associated with this saved Query.
|
|
2296
|
+
*
|
|
2297
|
+
* @param query The query string to be executed
|
|
2298
|
+
*
|
|
2299
|
+
* @returns This Query, for chaining
|
|
2300
|
+
*/
|
|
2301
|
+
setQuery(query: string): Query;
|
|
2302
|
+
/**
|
|
2303
|
+
* Perform create new Query.
|
|
2304
|
+
*/
|
|
2305
|
+
create(): Promise<Query>;
|
|
2306
|
+
/**
|
|
2307
|
+
* Perform update Query, applying pending changes.
|
|
2308
|
+
*/
|
|
2309
|
+
update(): Promise<Query>;
|
|
2310
|
+
/**
|
|
2311
|
+
* Perform delete Query.
|
|
2288
2312
|
*/
|
|
2289
2313
|
remove(): Promise<Query>;
|
|
2314
|
+
|
|
2290
2315
|
}
|
|
2291
2316
|
|
|
2292
2317
|
/**
|
package/lib/model/Query.js
CHANGED
|
@@ -38,6 +38,17 @@ export class Query {
|
|
|
38
38
|
getTitle() {
|
|
39
39
|
return this.payload.title;
|
|
40
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* Sets the title of this saved Query.
|
|
43
|
+
*
|
|
44
|
+
* @param title The title of this saved Query
|
|
45
|
+
*
|
|
46
|
+
* @returns This Query, for chaining
|
|
47
|
+
*/
|
|
48
|
+
setTitle(title) {
|
|
49
|
+
this.payload.title = title;
|
|
50
|
+
return this;
|
|
51
|
+
}
|
|
41
52
|
/**
|
|
42
53
|
* @return This Query string to be executed
|
|
43
54
|
*/
|
|
@@ -45,7 +56,38 @@ export class Query {
|
|
|
45
56
|
return this.payload.query;
|
|
46
57
|
}
|
|
47
58
|
/**
|
|
48
|
-
*
|
|
59
|
+
* Sets the query string associated with this saved Query.
|
|
60
|
+
*
|
|
61
|
+
* @param query The query string to be executed
|
|
62
|
+
*
|
|
63
|
+
* @returns This Query, for chaining
|
|
64
|
+
*/
|
|
65
|
+
setQuery(query) {
|
|
66
|
+
this.payload.query = query;
|
|
67
|
+
return this;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Perform create new Query.
|
|
71
|
+
*/
|
|
72
|
+
create() {
|
|
73
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
74
|
+
this.payload = yield QueryService.createSavedQuery(this.book.getId(), this.payload);
|
|
75
|
+
this.updateQueryCache();
|
|
76
|
+
return this;
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Perform update Query, applying pending changes.
|
|
81
|
+
*/
|
|
82
|
+
update() {
|
|
83
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
84
|
+
this.payload = yield QueryService.updateSavedQuery(this.book.getId(), this.payload);
|
|
85
|
+
this.updateQueryCache();
|
|
86
|
+
return this;
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Perform delete Query.
|
|
49
91
|
*/
|
|
50
92
|
remove() {
|
|
51
93
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -54,11 +96,18 @@ export class Query {
|
|
|
54
96
|
throw new Error("Query id null!");
|
|
55
97
|
}
|
|
56
98
|
this.payload = yield QueryService.deleteSavedQuery(this.book.getId(), queryId);
|
|
57
|
-
|
|
58
|
-
this.book.queries = this.book.queries.filter(q => q.getId() !== queryId);
|
|
59
|
-
}
|
|
99
|
+
this.updateQueryCache(true);
|
|
60
100
|
return this;
|
|
61
101
|
});
|
|
62
102
|
}
|
|
103
|
+
/** @internal */
|
|
104
|
+
updateQueryCache(deleted) {
|
|
105
|
+
if (this.book.queries) {
|
|
106
|
+
this.book.queries = this.book.queries.filter(q => q.getId() !== this.getId());
|
|
107
|
+
if (!deleted) {
|
|
108
|
+
this.book.queries.push(this);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
63
112
|
}
|
|
64
113
|
//# 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.41.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",
|