bkper-js 1.31.0 → 1.32.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 +8 -0
- package/lib/model/App.js +29 -4
- package/lib/service/app-service.js +6 -0
- package/package.json +2 -2
package/lib/index.d.ts
CHANGED
|
@@ -381,6 +381,14 @@ export declare class App {
|
|
|
381
381
|
* @return The events bound to this App
|
|
382
382
|
*/
|
|
383
383
|
getEvents(): EventType[] | undefined;
|
|
384
|
+
/**
|
|
385
|
+
* @return True if this App is conversational
|
|
386
|
+
*/
|
|
387
|
+
isConversational(): boolean;
|
|
388
|
+
/**
|
|
389
|
+
* @return The conversation url of this App
|
|
390
|
+
*/
|
|
391
|
+
chat(conversation: Conversation): Promise<Conversation | undefined>;
|
|
384
392
|
/**
|
|
385
393
|
* @return The logo url of this App
|
|
386
394
|
*/
|
package/lib/model/App.js
CHANGED
|
@@ -7,7 +7,8 @@ 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
|
|
10
|
+
import * as AppService from '../service/app-service.js';
|
|
11
|
+
import { Conversation } from "./Conversation.js";
|
|
11
12
|
/**
|
|
12
13
|
* Defines an App on Bkper.
|
|
13
14
|
*
|
|
@@ -71,6 +72,30 @@ export class App {
|
|
|
71
72
|
getEvents() {
|
|
72
73
|
return this.payload.events;
|
|
73
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* @return True if this App is conversational
|
|
77
|
+
*/
|
|
78
|
+
isConversational() {
|
|
79
|
+
return this.payload.conversational || false;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* @return The conversation url of this App
|
|
83
|
+
*/
|
|
84
|
+
chat(conversation) {
|
|
85
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
86
|
+
if (!this.isConversational()) {
|
|
87
|
+
throw new Error(`App ${this.getName()} is not conversational`);
|
|
88
|
+
}
|
|
89
|
+
const appId = this.getId();
|
|
90
|
+
if (appId) {
|
|
91
|
+
const response = yield AppService.chat(appId, conversation.json());
|
|
92
|
+
if (response) {
|
|
93
|
+
return new Conversation(response);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return undefined;
|
|
97
|
+
});
|
|
98
|
+
}
|
|
74
99
|
/**
|
|
75
100
|
* @return The logo url of this App
|
|
76
101
|
*/
|
|
@@ -132,7 +157,7 @@ export class App {
|
|
|
132
157
|
*/
|
|
133
158
|
create() {
|
|
134
159
|
return __awaiter(this, void 0, void 0, function* () {
|
|
135
|
-
yield createApp(this.payload);
|
|
160
|
+
yield AppService.createApp(this.payload);
|
|
136
161
|
return this;
|
|
137
162
|
});
|
|
138
163
|
}
|
|
@@ -141,7 +166,7 @@ export class App {
|
|
|
141
166
|
*/
|
|
142
167
|
patch() {
|
|
143
168
|
return __awaiter(this, void 0, void 0, function* () {
|
|
144
|
-
yield patchApp(this.payload);
|
|
169
|
+
yield AppService.patchApp(this.payload);
|
|
145
170
|
return this;
|
|
146
171
|
});
|
|
147
172
|
}
|
|
@@ -150,7 +175,7 @@ export class App {
|
|
|
150
175
|
*/
|
|
151
176
|
update() {
|
|
152
177
|
return __awaiter(this, void 0, void 0, function* () {
|
|
153
|
-
yield updateApp(this.payload);
|
|
178
|
+
yield AppService.updateApp(this.payload);
|
|
154
179
|
return this;
|
|
155
180
|
});
|
|
156
181
|
}
|
|
@@ -29,6 +29,12 @@ export function getConversations() {
|
|
|
29
29
|
return ((_a = response.data) === null || _a === void 0 ? void 0 : _a.items) || [];
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
|
+
export function chat(appId, conversation) {
|
|
33
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
+
const response = yield new HttpApiRequest(`v5/apps/${appId}/conversations`).setMethod('POST').setPayload(conversation).fetch();
|
|
35
|
+
return response.data;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
32
38
|
export function createApp(app) {
|
|
33
39
|
return __awaiter(this, void 0, void 0, function* () {
|
|
34
40
|
var response = yield new HttpApiRequest(`v5/apps`).setMethod('POST').setPayload(app).fetch();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bkper-js",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.32.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.15.
|
|
37
|
+
"@bkper/bkper-api-types": "^5.15.3"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@google-cloud/local-auth": "^3.0.1",
|