@telia-ace/knowledge-widget-bot-provider 0.0.1-alpha.6 → 0.0.1-alpha.62
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-esm → dist}/client/chat.client.d.ts +2 -1
- package/{lib → dist}/client/contact-method.client.d.ts +4 -1
- package/{lib → dist}/client/http.client.d.ts +5 -4
- package/{lib → dist}/client/middleware.client.d.ts +4 -3
- package/dist/contact-method.15886c3d.js +66 -0
- package/dist/contact-method.15886c3d.js.map +1 -0
- package/{lib-esm → dist}/contract/custom-component/contact-method-item.d.ts +0 -0
- package/{lib-esm → dist}/contract/custom-component/contact-method-list.d.ts +0 -0
- package/{lib-esm → dist}/contract/custom-component/contact-method.d.ts +0 -0
- package/{lib → dist}/contract/enum/server-entry-type.enum.d.ts +3 -2
- package/{lib-esm → dist}/contract/model/conversation-api-model/list.model.d.ts +0 -0
- package/{lib-esm → dist}/contract/model/conversation-api-model/message.model.d.ts +0 -0
- package/{lib-esm → dist}/contract/model/http/action.model.d.ts +0 -0
- package/{lib-esm → dist}/contract/model/http/client-action.model.d.ts +0 -0
- package/{lib-esm → dist}/contract/model/http/client-envelope.model.d.ts +0 -0
- package/{lib-esm → dist}/contract/model/http/connect-options.model.d.ts +0 -0
- package/{lib-esm → dist}/contract/model/http/global-state.model.d.ts +0 -0
- package/{lib-esm → dist}/contract/model/http/http-client-options.model.d.ts +0 -0
- package/{lib-esm → dist}/contract/model/http/server-entry.model.d.ts +0 -0
- package/{lib-esm → dist}/contract/model/http/server-envelope.model.d.ts +0 -0
- package/{lib-esm → dist}/contract/model/middleware/aggregator-state.model.d.ts +0 -0
- package/{lib-esm → dist}/contract/model/shared/loose-object.model.d.ts +0 -0
- package/{lib-esm → dist}/helper/chat.helper.d.ts +0 -0
- package/{lib-esm → dist}/helper/http.helper.d.ts +1 -1
- package/{lib-esm → dist}/helper/middleware.helper.d.ts +1 -1
- package/{lib-esm → dist}/helper/store.helper.d.ts +0 -0
- package/{lib-esm → dist}/index.d.ts +0 -0
- package/dist/index.js +672 -0
- package/dist/index.js.map +1 -0
- package/{lib-esm → dist}/interface/entry.interface.d.ts +6 -3
- package/{lib-esm → dist}/interface/middleware/paging.interface.d.ts +0 -0
- package/{lib-esm → dist}/interface/middleware/processor.interface.d.ts +0 -0
- package/dist/plugin.d.ts +3 -0
- package/package.json +46 -45
- package/lib/client/chat.client.d.ts +0 -15
- package/lib/client/chat.client.js +0 -80
- package/lib/client/contact-method.client.js +0 -276
- package/lib/client/http.client.js +0 -114
- package/lib/client/middleware.client.js +0 -60
- package/lib/contract/custom-component/contact-method-item.d.ts +0 -8
- package/lib/contract/custom-component/contact-method-item.js +0 -76
- package/lib/contract/custom-component/contact-method-list.d.ts +0 -7
- package/lib/contract/custom-component/contact-method-list.js +0 -41
- package/lib/contract/custom-component/contact-method.d.ts +0 -3
- package/lib/contract/custom-component/contact-method.js +0 -38
- package/lib/contract/enum/server-entry-type.enum.js +0 -10
- package/lib/contract/model/conversation-api-model/list.model.d.ts +0 -5
- package/lib/contract/model/conversation-api-model/list.model.js +0 -2
- package/lib/contract/model/conversation-api-model/message.model.d.ts +0 -7
- package/lib/contract/model/conversation-api-model/message.model.js +0 -2
- package/lib/contract/model/http/action.model.d.ts +0 -3
- package/lib/contract/model/http/action.model.js +0 -2
- package/lib/contract/model/http/client-action.model.d.ts +0 -4
- package/lib/contract/model/http/client-action.model.js +0 -3
- package/lib/contract/model/http/client-envelope.model.d.ts +0 -9
- package/lib/contract/model/http/client-envelope.model.js +0 -2
- package/lib/contract/model/http/connect-options.model.d.ts +0 -5
- package/lib/contract/model/http/connect-options.model.js +0 -2
- package/lib/contract/model/http/global-state.model.d.ts +0 -8
- package/lib/contract/model/http/global-state.model.js +0 -2
- package/lib/contract/model/http/http-client-options.model.d.ts +0 -5
- package/lib/contract/model/http/http-client-options.model.js +0 -2
- package/lib/contract/model/http/server-entry.model.d.ts +0 -11
- package/lib/contract/model/http/server-entry.model.js +0 -2
- package/lib/contract/model/http/server-envelope.model.d.ts +0 -10
- package/lib/contract/model/http/server-envelope.model.js +0 -2
- package/lib/contract/model/middleware/aggregator-state.model.d.ts +0 -4
- package/lib/contract/model/middleware/aggregator-state.model.js +0 -3
- package/lib/contract/model/shared/loose-object.model.d.ts +0 -3
- package/lib/contract/model/shared/loose-object.model.js +0 -2
- package/lib/helper/chat.helper.d.ts +0 -8
- package/lib/helper/chat.helper.js +0 -21
- package/lib/helper/http.helper.d.ts +0 -13
- package/lib/helper/http.helper.js +0 -33
- package/lib/helper/middleware.helper.d.ts +0 -12
- package/lib/helper/middleware.helper.js +0 -72
- package/lib/helper/store.helper.d.ts +0 -22
- package/lib/helper/store.helper.js +0 -80
- package/lib/index.d.ts +0 -2
- package/lib/index.js +0 -8
- package/lib/interface/entry.interface.d.ts +0 -17
- package/lib/interface/entry.interface.js +0 -138
- package/lib/interface/middleware/contact-expanded.interface.d.ts +0 -0
- package/lib/interface/middleware/contact-expanded.interface.js +0 -50
- package/lib/interface/middleware/legacy-contact-methods.interface.d.ts +0 -0
- package/lib/interface/middleware/legacy-contact-methods.interface.js +0 -394
- package/lib/interface/middleware/paging.interface.d.ts +0 -4
- package/lib/interface/middleware/paging.interface.js +0 -55
- package/lib/interface/middleware/processor.interface.d.ts +0 -10
- package/lib/interface/middleware/processor.interface.js +0 -120
- package/lib/plugin.d.ts +0 -3
- package/lib/plugin.js +0 -171
- package/lib-esm/client/chat.client.js +0 -75
- package/lib-esm/client/contact-method.client.d.ts +0 -22
- package/lib-esm/client/contact-method.client.js +0 -270
- package/lib-esm/client/http.client.d.ts +0 -22
- package/lib-esm/client/http.client.js +0 -108
- package/lib-esm/client/middleware.client.d.ts +0 -13
- package/lib-esm/client/middleware.client.js +0 -55
- package/lib-esm/contract/custom-component/contact-method-item.js +0 -51
- package/lib-esm/contract/custom-component/contact-method-list.js +0 -13
- package/lib-esm/contract/custom-component/contact-method.js +0 -33
- package/lib-esm/contract/enum/server-entry-type.enum.d.ts +0 -6
- package/lib-esm/contract/enum/server-entry-type.enum.js +0 -7
- package/lib-esm/contract/model/conversation-api-model/list.model.js +0 -1
- package/lib-esm/contract/model/conversation-api-model/message.model.js +0 -1
- package/lib-esm/contract/model/http/action.model.js +0 -1
- package/lib-esm/contract/model/http/client-action.model.js +0 -2
- package/lib-esm/contract/model/http/client-envelope.model.js +0 -1
- package/lib-esm/contract/model/http/connect-options.model.js +0 -1
- package/lib-esm/contract/model/http/global-state.model.js +0 -1
- package/lib-esm/contract/model/http/http-client-options.model.js +0 -1
- package/lib-esm/contract/model/http/server-entry.model.js +0 -1
- package/lib-esm/contract/model/http/server-envelope.model.js +0 -1
- package/lib-esm/contract/model/middleware/aggregator-state.model.js +0 -2
- package/lib-esm/contract/model/shared/loose-object.model.js +0 -1
- package/lib-esm/helper/chat.helper.js +0 -18
- package/lib-esm/helper/http.helper.js +0 -30
- package/lib-esm/helper/middleware.helper.js +0 -69
- package/lib-esm/helper/store.helper.js +0 -77
- package/lib-esm/index.js +0 -2
- package/lib-esm/interface/entry.interface.js +0 -136
- package/lib-esm/interface/middleware/paging.interface.js +0 -53
- package/lib-esm/interface/middleware/processor.interface.js +0 -118
- package/lib-esm/plugin.d.ts +0 -3
- package/lib-esm/plugin.js +0 -143
package/lib/plugin.js
DELETED
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
35
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
36
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
37
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
38
|
-
function step(op) {
|
|
39
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
40
|
-
while (_) try {
|
|
41
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
42
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
43
|
-
switch (op[0]) {
|
|
44
|
-
case 0: case 1: t = op; break;
|
|
45
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
46
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
47
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
48
|
-
default:
|
|
49
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
50
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
51
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
52
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
53
|
-
if (t[2]) _.ops.pop();
|
|
54
|
-
_.trys.pop(); continue;
|
|
55
|
-
}
|
|
56
|
-
op = body.call(thisArg, _);
|
|
57
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
58
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
62
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
63
|
-
if (!m) return o;
|
|
64
|
-
var i = m.call(o), r, ar = [], e;
|
|
65
|
-
try {
|
|
66
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
67
|
-
}
|
|
68
|
-
catch (error) { e = { error: error }; }
|
|
69
|
-
finally {
|
|
70
|
-
try {
|
|
71
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
72
|
-
}
|
|
73
|
-
finally { if (e) throw e.error; }
|
|
74
|
-
}
|
|
75
|
-
return ar;
|
|
76
|
-
};
|
|
77
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
78
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
79
|
-
};
|
|
80
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
81
|
-
var knowledge_widget_core_1 = require("@telia-ace/knowledge-widget-core");
|
|
82
|
-
var knowledge_widget_types_grid_1 = require("@telia-ace/knowledge-widget-types-grid");
|
|
83
|
-
var widget_conversation_1 = require("@telia-ace/widget-conversation");
|
|
84
|
-
var chat_client_1 = __importDefault(require("./client/chat.client"));
|
|
85
|
-
var contact_method_client_1 = require("./client/contact-method.client");
|
|
86
|
-
var http_client_1 = require("./client/http.client");
|
|
87
|
-
var middleware_client_1 = __importDefault(require("./client/middleware.client"));
|
|
88
|
-
var ConversationPlugin = function (container) { return __awaiter(void 0, void 0, void 0, function () {
|
|
89
|
-
var platform, contactMethodPlatform, dataClient, compPlatform, _a, component, endpoint;
|
|
90
|
-
return __generator(this, function (_b) {
|
|
91
|
-
switch (_b.label) {
|
|
92
|
-
case 0: return [4 /*yield*/, widget_conversation_1.ConversationPlatform.getInstance(container)];
|
|
93
|
-
case 1:
|
|
94
|
-
platform = _b.sent();
|
|
95
|
-
return [4 /*yield*/, container.getAsync('contactMethods')];
|
|
96
|
-
case 2:
|
|
97
|
-
contactMethodPlatform = _b.sent();
|
|
98
|
-
return [4 /*yield*/, knowledge_widget_types_grid_1.DataClient.getInstance(container)];
|
|
99
|
-
case 3:
|
|
100
|
-
dataClient = _b.sent();
|
|
101
|
-
return [4 /*yield*/, knowledge_widget_core_1.ComponentPlatform.getInstance(container)];
|
|
102
|
-
case 4:
|
|
103
|
-
compPlatform = _b.sent();
|
|
104
|
-
_a = __read(compPlatform.nodes.query({ type: 'conversation' }), 1), component = _a[0];
|
|
105
|
-
endpoint = '';
|
|
106
|
-
setTimeout(function () {
|
|
107
|
-
endpoint = component.attributes.properties.knowledgeBotEndpoint;
|
|
108
|
-
});
|
|
109
|
-
platform.registerProvider('chat.bot', function (conversation, component) {
|
|
110
|
-
(0, widget_conversation_1.registerCustomMessageComponent)(container, 'ace-knowledge-contact-method', Promise.resolve().then(function () { return __importStar(require('./contract/custom-component/contact-method')); }));
|
|
111
|
-
var agent = conversation.createAgent({
|
|
112
|
-
name: 'John Doe',
|
|
113
|
-
avatar: 'https://www.site.com/avatar.jpg',
|
|
114
|
-
});
|
|
115
|
-
// pases the user and the agent to the Chat Helper
|
|
116
|
-
chat_client_1.default.initialize(conversation.user, agent);
|
|
117
|
-
// passes the conversation provider to the Contact Method Client
|
|
118
|
-
contact_method_client_1.ContactMethodClient.initialize(dataClient, contactMethodPlatform, agent);
|
|
119
|
-
// passes the container and the widget to the Middleware Store
|
|
120
|
-
middleware_client_1.default.initialize(container, container.get('$widget'));
|
|
121
|
-
// executes to decide on what to do on first load
|
|
122
|
-
var httpClient = new http_client_1.HttpClient(endpoint);
|
|
123
|
-
httpClient.firstHit();
|
|
124
|
-
component.actions.create('evaluate', function (input) {
|
|
125
|
-
var cmClient = new contact_method_client_1.ContactMethodClient();
|
|
126
|
-
cmClient.handleNewForm(input.form, input.form.id);
|
|
127
|
-
});
|
|
128
|
-
component.actions.create('validate', function (input) {
|
|
129
|
-
var cmClient = new contact_method_client_1.ContactMethodClient();
|
|
130
|
-
cmClient.validate(input.form);
|
|
131
|
-
});
|
|
132
|
-
component.actions.create('submit', function (input) {
|
|
133
|
-
var cmClient = new contact_method_client_1.ContactMethodClient();
|
|
134
|
-
cmClient.validate(input.form);
|
|
135
|
-
});
|
|
136
|
-
component.actions.watch('conversation.user-typing', function (input, next) {
|
|
137
|
-
return next(input);
|
|
138
|
-
});
|
|
139
|
-
component.actions.watch('conversation.user-submit', function (input, next) {
|
|
140
|
-
var httpClient = new http_client_1.HttpClient(endpoint);
|
|
141
|
-
httpClient.handlePhrase(input.text);
|
|
142
|
-
return next(input);
|
|
143
|
-
});
|
|
144
|
-
component.actions.watch('conversation.form', function (input, next) {
|
|
145
|
-
return next(input);
|
|
146
|
-
});
|
|
147
|
-
component.actions.watch('conversation.action', function (input, next) {
|
|
148
|
-
var chatClient = new chat_client_1.default();
|
|
149
|
-
var cmClient = new contact_method_client_1.ContactMethodClient();
|
|
150
|
-
if (input === 'contact' || input.split('/').length > 1) {
|
|
151
|
-
cmClient.handleContactMethod(input);
|
|
152
|
-
return next(input);
|
|
153
|
-
}
|
|
154
|
-
var middlewareClient = new middleware_client_1.default();
|
|
155
|
-
// this is an update check, as it requires
|
|
156
|
-
// a lot different logic and no user message
|
|
157
|
-
if (middlewareClient.checkForUpdate(input)) {
|
|
158
|
-
middlewareClient.handleUpdate(input, endpoint);
|
|
159
|
-
return next(input);
|
|
160
|
-
}
|
|
161
|
-
chatClient.printUserMessageAndStoreIt(input);
|
|
162
|
-
var httpClient = new http_client_1.HttpClient(endpoint);
|
|
163
|
-
httpClient.handleInput(input);
|
|
164
|
-
return next(input);
|
|
165
|
-
});
|
|
166
|
-
});
|
|
167
|
-
return [2 /*return*/];
|
|
168
|
-
}
|
|
169
|
-
});
|
|
170
|
-
}); };
|
|
171
|
-
exports.default = ConversationPlugin;
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { v4 as newGuid } from 'uuid';
|
|
2
|
-
import { ServerEntryTypeEnum } from '../contract/enum/server-entry-type.enum';
|
|
3
|
-
import { ChatHelper } from '../helper/chat.helper';
|
|
4
|
-
import { StoreHelper } from '../helper/store.helper';
|
|
5
|
-
import EntryInterface from '../interface/entry.interface';
|
|
6
|
-
var ChatClient = /** @class */ (function () {
|
|
7
|
-
function ChatClient() {
|
|
8
|
-
this.entryInterface = new EntryInterface();
|
|
9
|
-
}
|
|
10
|
-
ChatClient.initialize = function (user, agent) {
|
|
11
|
-
ChatHelper.setUser(user);
|
|
12
|
-
ChatHelper.setAgent(agent);
|
|
13
|
-
};
|
|
14
|
-
ChatClient.prototype.processMessageArrayAndStoreIt = function (messages) {
|
|
15
|
-
var _this = this;
|
|
16
|
-
messages
|
|
17
|
-
.filter(function (o) { return o && o != null; })
|
|
18
|
-
.forEach(function (o) {
|
|
19
|
-
if (o.isUser)
|
|
20
|
-
_this.postUserMessage(o);
|
|
21
|
-
else
|
|
22
|
-
_this.postAgentMessage(o);
|
|
23
|
-
});
|
|
24
|
-
StoreHelper.insertOrUpdateMessageArrayStore(messages);
|
|
25
|
-
};
|
|
26
|
-
ChatClient.prototype.updateMessageArrayAndStoreIt = function (messages) {
|
|
27
|
-
var conversationEntry = undefined;
|
|
28
|
-
messages.forEach(function (o) {
|
|
29
|
-
var message = StoreHelper.getMessage(o.id);
|
|
30
|
-
message === null || message === void 0 ? void 0 : message.conversationEntry.update(o.message);
|
|
31
|
-
conversationEntry = message === null || message === void 0 ? void 0 : message.conversationEntry;
|
|
32
|
-
});
|
|
33
|
-
StoreHelper.insertOrUpdateMessageArrayStore(messages, conversationEntry);
|
|
34
|
-
};
|
|
35
|
-
ChatClient.prototype.printUserMessageAndStoreIt = function (action) {
|
|
36
|
-
if (action == 'next' || action == 'help')
|
|
37
|
-
return;
|
|
38
|
-
var entry = StoreHelper.getEntry(action);
|
|
39
|
-
var message = {
|
|
40
|
-
id: newGuid(),
|
|
41
|
-
message: !entry ? action : this.getTitleFromEntry(entry, action),
|
|
42
|
-
isUser: true,
|
|
43
|
-
};
|
|
44
|
-
this.postUserMessage(message);
|
|
45
|
-
StoreHelper.insertOrUpdateMessageArrayStore([message]);
|
|
46
|
-
};
|
|
47
|
-
ChatClient.prototype.postUserMessage = function (message) {
|
|
48
|
-
ChatHelper.getUser().print(message.message);
|
|
49
|
-
};
|
|
50
|
-
ChatClient.prototype.postAgentMessage = function (message) {
|
|
51
|
-
message.conversationEntry = ChatHelper.getAgent().print(message.message);
|
|
52
|
-
};
|
|
53
|
-
ChatClient.prototype.getTitleFromEntry = function (entry, action) {
|
|
54
|
-
var entryType = ServerEntryTypeEnum[entry.type];
|
|
55
|
-
switch (entryType) {
|
|
56
|
-
case ServerEntryTypeEnum.List:
|
|
57
|
-
return this.getTitleFromList(entry, action);
|
|
58
|
-
case ServerEntryTypeEnum.Text:
|
|
59
|
-
return this.getTitleFromText(entry, action);
|
|
60
|
-
default:
|
|
61
|
-
return '';
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
ChatClient.prototype.getTitleFromText = function (entry, action) {
|
|
65
|
-
if (!!entry.content.items)
|
|
66
|
-
return this.getTitleFromList(entry, action);
|
|
67
|
-
else
|
|
68
|
-
return entry.content.html;
|
|
69
|
-
};
|
|
70
|
-
ChatClient.prototype.getTitleFromList = function (entry, action) {
|
|
71
|
-
return entry.content.items.find(function (o) { return o.actionKey == action; }).title;
|
|
72
|
-
};
|
|
73
|
-
return ChatClient;
|
|
74
|
-
}());
|
|
75
|
-
export default ChatClient;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { ContactMethodPlatform } from '@telia-ace/knowledge-widget-adapters';
|
|
2
|
-
import { DataClient } from '@telia-ace/knowledge-widget-types-grid';
|
|
3
|
-
export declare class ContactMethodClient {
|
|
4
|
-
private static dataClient;
|
|
5
|
-
private static contactMethodPlatform;
|
|
6
|
-
private static contactMessageEntryArray;
|
|
7
|
-
private static agent;
|
|
8
|
-
private chatClient;
|
|
9
|
-
static initialize(dataClient: DataClient, contactMethodPlatform: ContactMethodPlatform, agent: any): void;
|
|
10
|
-
handleNewForm: (errors: any, entry: any) => Promise<void>;
|
|
11
|
-
handleContactMethod: (input?: string) => Promise<void>;
|
|
12
|
-
validate(form: any): void;
|
|
13
|
-
private handleContactCategoryList;
|
|
14
|
-
private handleForm;
|
|
15
|
-
private handleContactMethodList;
|
|
16
|
-
private handleSingleContactMethod;
|
|
17
|
-
private submit;
|
|
18
|
-
private removeForm;
|
|
19
|
-
private printMessage;
|
|
20
|
-
private loadContactMethods;
|
|
21
|
-
private updateForm;
|
|
22
|
-
}
|
|
@@ -1,270 +0,0 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
-
function step(op) {
|
|
26
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
-
while (_) try {
|
|
28
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
-
switch (op[0]) {
|
|
31
|
-
case 0: case 1: t = op; break;
|
|
32
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
-
default:
|
|
36
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
-
if (t[2]) _.ops.pop();
|
|
41
|
-
_.trys.pop(); continue;
|
|
42
|
-
}
|
|
43
|
-
op = body.call(thisArg, _);
|
|
44
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
import { DataType } from '@telia-ace/knowledge-widget-types-grid';
|
|
49
|
-
import { FormBuilder, submitButton } from '@telia-ace/widget-forms';
|
|
50
|
-
import { v4 as uuidv4 } from 'uuid';
|
|
51
|
-
import { StoreHelper } from '../helper/store.helper';
|
|
52
|
-
import ChatClient from './chat.client';
|
|
53
|
-
var ContactMethodClient = /** @class */ (function () {
|
|
54
|
-
function ContactMethodClient() {
|
|
55
|
-
var _this = this;
|
|
56
|
-
this.chatClient = new ChatClient();
|
|
57
|
-
this.handleNewForm = function (errors, entry) { return __awaiter(_this, void 0, void 0, function () {
|
|
58
|
-
return __generator(this, function (_a) {
|
|
59
|
-
this.updateForm(entry.contactMethods, {
|
|
60
|
-
submit: 'Submit',
|
|
61
|
-
errors: errors,
|
|
62
|
-
});
|
|
63
|
-
entry.entry.update({
|
|
64
|
-
contactMethods: entry.contactMethods,
|
|
65
|
-
type: 'ace-knowledge-contact-method',
|
|
66
|
-
noPadding: true,
|
|
67
|
-
});
|
|
68
|
-
return [2 /*return*/];
|
|
69
|
-
});
|
|
70
|
-
}); };
|
|
71
|
-
this.handleContactMethod = function (input) {
|
|
72
|
-
if (input === void 0) { input = ''; }
|
|
73
|
-
return __awaiter(_this, void 0, void 0, function () {
|
|
74
|
-
var contactMethods;
|
|
75
|
-
var _a;
|
|
76
|
-
return __generator(this, function (_b) {
|
|
77
|
-
switch (_b.label) {
|
|
78
|
-
case 0:
|
|
79
|
-
if (!(input == 'contact')) return [3 /*break*/, 2];
|
|
80
|
-
return [4 /*yield*/, this.handleContactCategoryList(input)];
|
|
81
|
-
case 1:
|
|
82
|
-
_b.sent();
|
|
83
|
-
return [3 /*break*/, 4];
|
|
84
|
-
case 2: return [4 /*yield*/, this.loadContactMethods(input.split('/')[1], // type
|
|
85
|
-
input.split('/')[0] // id
|
|
86
|
-
)];
|
|
87
|
-
case 3:
|
|
88
|
-
contactMethods = _b.sent();
|
|
89
|
-
if (!!((_a = contactMethods.body) === null || _a === void 0 ? void 0 : _a.form)) {
|
|
90
|
-
this.handleForm(input, contactMethods);
|
|
91
|
-
}
|
|
92
|
-
else if (!contactMethods.expanded && contactMethods.inline) {
|
|
93
|
-
this.handleSingleContactMethod(contactMethods);
|
|
94
|
-
}
|
|
95
|
-
else if (!!contactMethods.contactMethods) {
|
|
96
|
-
this.handleContactMethodList(input, contactMethods);
|
|
97
|
-
}
|
|
98
|
-
_b.label = 4;
|
|
99
|
-
case 4: return [2 /*return*/];
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
});
|
|
103
|
-
};
|
|
104
|
-
this.handleContactCategoryList = function (input) { return __awaiter(_this, void 0, void 0, function () {
|
|
105
|
-
var newGuid, type, contactMethods;
|
|
106
|
-
return __generator(this, function (_a) {
|
|
107
|
-
switch (_a.label) {
|
|
108
|
-
case 0:
|
|
109
|
-
newGuid = uuidv4();
|
|
110
|
-
type = DataType.ContactMethodCategories;
|
|
111
|
-
return [4 /*yield*/, this.loadContactMethods(type)];
|
|
112
|
-
case 1:
|
|
113
|
-
contactMethods = _a.sent();
|
|
114
|
-
this.chatClient.printUserMessageAndStoreIt(input);
|
|
115
|
-
this.printMessage(newGuid, contactMethods);
|
|
116
|
-
return [2 /*return*/];
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
}); };
|
|
120
|
-
this.updateForm = function (contactMethod, properties) {
|
|
121
|
-
var _a;
|
|
122
|
-
if ((_a = contactMethod === null || contactMethod === void 0 ? void 0 : contactMethod.body) === null || _a === void 0 ? void 0 : _a.form) {
|
|
123
|
-
var body = contactMethod.body;
|
|
124
|
-
var builder = new FormBuilder(body.form);
|
|
125
|
-
if (!body.form.layout || !body.form.layout.submit) {
|
|
126
|
-
builder.createComponent(submitButton(properties.submit, 'submit'));
|
|
127
|
-
}
|
|
128
|
-
if (properties.errors) {
|
|
129
|
-
builder.setValidationErrors(properties.errors);
|
|
130
|
-
}
|
|
131
|
-
return __assign(__assign({}, body), { form: builder.get() });
|
|
132
|
-
}
|
|
133
|
-
return (contactMethod === null || contactMethod === void 0 ? void 0 : contactMethod.body) || {};
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
ContactMethodClient.initialize = function (dataClient, contactMethodPlatform, agent) {
|
|
137
|
-
this.dataClient = dataClient;
|
|
138
|
-
this.contactMethodPlatform = contactMethodPlatform;
|
|
139
|
-
this.agent = agent;
|
|
140
|
-
};
|
|
141
|
-
ContactMethodClient.prototype.validate = function (form) {
|
|
142
|
-
var _this = this;
|
|
143
|
-
var entry = ContactMethodClient.contactMessageEntryArray.find(function (o) { return o.id == form.schema.id; });
|
|
144
|
-
ContactMethodClient.contactMethodPlatform.validate(entry.contactMethods).then(function (result) {
|
|
145
|
-
_this.handleNewForm(result.errors, entry);
|
|
146
|
-
if (result.valid) {
|
|
147
|
-
_this.submit(entry);
|
|
148
|
-
_this.removeForm(entry);
|
|
149
|
-
}
|
|
150
|
-
});
|
|
151
|
-
};
|
|
152
|
-
ContactMethodClient.prototype.handleForm = function (input, contactMethods) {
|
|
153
|
-
var title = input.split('/')[2];
|
|
154
|
-
contactMethods.expanded = true;
|
|
155
|
-
this.updateForm(contactMethods, {
|
|
156
|
-
submit: 'Submit',
|
|
157
|
-
errors: undefined,
|
|
158
|
-
});
|
|
159
|
-
this.printMessage(contactMethods.id, contactMethods, title);
|
|
160
|
-
};
|
|
161
|
-
ContactMethodClient.prototype.handleContactMethodList = function (input, contactMethods) {
|
|
162
|
-
var title = input.split('/')[2];
|
|
163
|
-
var newGuid = uuidv4();
|
|
164
|
-
this.printMessage(newGuid, contactMethods, title);
|
|
165
|
-
};
|
|
166
|
-
ContactMethodClient.prototype.handleSingleContactMethod = function (contactMethods) {
|
|
167
|
-
var entry = ContactMethodClient.contactMessageEntryArray.find(function (o) {
|
|
168
|
-
return o.contactMethods.contactMethods.find(function (t) { return t.id == contactMethods.id; });
|
|
169
|
-
});
|
|
170
|
-
var curCM = entry.contactMethods.contactMethods.find(function (t) { return t.id == contactMethods.id; });
|
|
171
|
-
curCM.expanded = true;
|
|
172
|
-
var message = {
|
|
173
|
-
contactMethods: entry.contactMethods,
|
|
174
|
-
type: 'ace-knowledge-contact-method',
|
|
175
|
-
noPadding: true,
|
|
176
|
-
};
|
|
177
|
-
StoreHelper.insertOrUpdateMessageArrayStore([
|
|
178
|
-
{
|
|
179
|
-
id: entry.id,
|
|
180
|
-
message: message,
|
|
181
|
-
isUser: false,
|
|
182
|
-
},
|
|
183
|
-
]);
|
|
184
|
-
entry.entry.update(message);
|
|
185
|
-
};
|
|
186
|
-
ContactMethodClient.prototype.submit = function (entry) {
|
|
187
|
-
ContactMethodClient.contactMethodPlatform.submit(entry.contactMethods).then(function (result) {
|
|
188
|
-
if (!!result)
|
|
189
|
-
ContactMethodClient.agent.print(result);
|
|
190
|
-
});
|
|
191
|
-
};
|
|
192
|
-
ContactMethodClient.prototype.removeForm = function (entry) {
|
|
193
|
-
entry.entry.remove();
|
|
194
|
-
ContactMethodClient.contactMessageEntryArray.splice(ContactMethodClient.contactMessageEntryArray.indexOf(entry), 1);
|
|
195
|
-
};
|
|
196
|
-
ContactMethodClient.prototype.printMessage = function (newGuid, contactMethods, title) {
|
|
197
|
-
if (title === void 0) { title = undefined; }
|
|
198
|
-
if (ContactMethodClient.contactMessageEntryArray.find(function (o) { return o.id == contactMethods.id; })) {
|
|
199
|
-
var entry = ContactMethodClient.contactMessageEntryArray.find(function (o) { return o.id == contactMethods.id; });
|
|
200
|
-
var message = {
|
|
201
|
-
contactMethods: contactMethods,
|
|
202
|
-
type: 'ace-knowledge-contact-method',
|
|
203
|
-
noPadding: true,
|
|
204
|
-
};
|
|
205
|
-
entry.entry.update(message);
|
|
206
|
-
StoreHelper.insertOrUpdateMessageArrayStore([
|
|
207
|
-
{
|
|
208
|
-
id: entry.guid,
|
|
209
|
-
message: message,
|
|
210
|
-
isUser: false,
|
|
211
|
-
},
|
|
212
|
-
]);
|
|
213
|
-
}
|
|
214
|
-
else {
|
|
215
|
-
if (title)
|
|
216
|
-
this.chatClient.printUserMessageAndStoreIt(title);
|
|
217
|
-
var message = {
|
|
218
|
-
contactMethods: contactMethods,
|
|
219
|
-
type: 'ace-knowledge-contact-method',
|
|
220
|
-
noPadding: true,
|
|
221
|
-
};
|
|
222
|
-
var entry = ContactMethodClient.agent.print(message);
|
|
223
|
-
StoreHelper.insertOrUpdateMessageArrayStore([
|
|
224
|
-
{
|
|
225
|
-
id: newGuid,
|
|
226
|
-
message: message,
|
|
227
|
-
isUser: false,
|
|
228
|
-
},
|
|
229
|
-
]);
|
|
230
|
-
ContactMethodClient.contactMessageEntryArray.push({
|
|
231
|
-
id: newGuid,
|
|
232
|
-
contactMethods: contactMethods,
|
|
233
|
-
entry: entry,
|
|
234
|
-
});
|
|
235
|
-
}
|
|
236
|
-
};
|
|
237
|
-
ContactMethodClient.prototype.loadContactMethods = function (dataType, id) {
|
|
238
|
-
if (id === void 0) { id = undefined; }
|
|
239
|
-
switch (dataType) {
|
|
240
|
-
case DataType.ContactMethodCategories: {
|
|
241
|
-
return ContactMethodClient.dataClient
|
|
242
|
-
.fetch(DataType.ContactMethods, { contactMethodCategoryId: id })
|
|
243
|
-
.then(function (contactMethods) { return contactMethods; });
|
|
244
|
-
}
|
|
245
|
-
case DataType.ContactMethods: {
|
|
246
|
-
if (!!id) {
|
|
247
|
-
return ContactMethodClient.dataClient
|
|
248
|
-
.fetch(DataType.ContactMethod, { contactMethodId: id })
|
|
249
|
-
.then(function (contactMethods) { return contactMethods; });
|
|
250
|
-
}
|
|
251
|
-
else {
|
|
252
|
-
return ContactMethodClient.dataClient
|
|
253
|
-
.fetch(DataType.ContactMethods, {})
|
|
254
|
-
.then(function (contactMethods) { return contactMethods; });
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
case DataType.ContactMethodCategories: {
|
|
258
|
-
return ContactMethodClient.dataClient
|
|
259
|
-
.fetch(DataType.ContactMethods, { contactMethodCategoryId: id })
|
|
260
|
-
.then(function (contactMethods) { return contactMethods; });
|
|
261
|
-
}
|
|
262
|
-
default: {
|
|
263
|
-
return Promise.resolve(undefined);
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
};
|
|
267
|
-
ContactMethodClient.contactMessageEntryArray = [];
|
|
268
|
-
return ContactMethodClient;
|
|
269
|
-
}());
|
|
270
|
-
export { ContactMethodClient };
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { ServerEntry } from '../contract/model/http/server-entry.model';
|
|
2
|
-
export declare class HttpClient {
|
|
3
|
-
private endpointUrl;
|
|
4
|
-
private clientId;
|
|
5
|
-
private projectionPath;
|
|
6
|
-
private apiEndpoint;
|
|
7
|
-
private options;
|
|
8
|
-
private middlewareClient;
|
|
9
|
-
private chatClient;
|
|
10
|
-
constructor(endpoint: string);
|
|
11
|
-
firstHit(): void;
|
|
12
|
-
handleUpdate(action: string): Promise<ServerEntry[]>;
|
|
13
|
-
handleInput(action: string): void;
|
|
14
|
-
handlePhrase(phrase: string): void;
|
|
15
|
-
private postAndHandleTheData;
|
|
16
|
-
private postAndReturnTheData;
|
|
17
|
-
private getHttpOptions;
|
|
18
|
-
private constructInputEnvelope;
|
|
19
|
-
private constructPhraseEnvelope;
|
|
20
|
-
private constructFirstHitEnvelope;
|
|
21
|
-
private handleResponseData;
|
|
22
|
-
}
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { HttpHelper } from '../helper/http.helper';
|
|
2
|
-
import { MiddlewareHelper } from '../helper/middleware.helper';
|
|
3
|
-
import { StoreHelper } from '../helper/store.helper';
|
|
4
|
-
import ChatClient from './chat.client';
|
|
5
|
-
import MiddlewareClient from './middleware.client';
|
|
6
|
-
var HttpClient = /** @class */ (function () {
|
|
7
|
-
function HttpClient(endpoint) {
|
|
8
|
-
this.options = {
|
|
9
|
-
credentials: HttpHelper.getCredentials(),
|
|
10
|
-
clientId: '84d96a63-b8ba-33ec-22d5-515255f866f8',
|
|
11
|
-
};
|
|
12
|
-
this.apiEndpoint = endpoint;
|
|
13
|
-
this.projectionPath = window.location.href;
|
|
14
|
-
this.endpointUrl = HttpHelper.combineUrl(this.projectionPath, 'conversations');
|
|
15
|
-
this.clientId = this.options.clientId;
|
|
16
|
-
this.middlewareClient = new MiddlewareClient();
|
|
17
|
-
this.chatClient = new ChatClient();
|
|
18
|
-
}
|
|
19
|
-
HttpClient.prototype.firstHit = function () {
|
|
20
|
-
var _this = this;
|
|
21
|
-
// On first hit if there are entries stored in the storage, use them
|
|
22
|
-
// Otherwise start a new session
|
|
23
|
-
MiddlewareHelper.getEntrySessionStorage().then(function (o) {
|
|
24
|
-
if (o && o.length > 0)
|
|
25
|
-
_this.chatClient.processMessageArrayAndStoreIt(o);
|
|
26
|
-
else {
|
|
27
|
-
var envelope = _this.constructFirstHitEnvelope();
|
|
28
|
-
_this.postAndHandleTheData(envelope);
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
// for updates, such as paging changes
|
|
33
|
-
HttpClient.prototype.handleUpdate = function (action) {
|
|
34
|
-
var envelope = this.constructInputEnvelope(action);
|
|
35
|
-
return this.postAndReturnTheData(envelope, action).then(function (o) {
|
|
36
|
-
return o.entries;
|
|
37
|
-
});
|
|
38
|
-
};
|
|
39
|
-
// for action clicks
|
|
40
|
-
HttpClient.prototype.handleInput = function (action) {
|
|
41
|
-
var envelope = this.constructInputEnvelope(action);
|
|
42
|
-
this.postAndHandleTheData(envelope, action);
|
|
43
|
-
};
|
|
44
|
-
// for text entries by user
|
|
45
|
-
HttpClient.prototype.handlePhrase = function (phrase) {
|
|
46
|
-
var envelope = this.constructPhraseEnvelope(phrase);
|
|
47
|
-
this.postAndHandleTheData(envelope);
|
|
48
|
-
};
|
|
49
|
-
HttpClient.prototype.postAndHandleTheData = function (envelope, action) {
|
|
50
|
-
var _this = this;
|
|
51
|
-
return fetch(this.apiEndpoint, this.getHttpOptions(envelope))
|
|
52
|
-
.then(function (response) {
|
|
53
|
-
if (response.ok)
|
|
54
|
-
return response.json();
|
|
55
|
-
throw response;
|
|
56
|
-
})
|
|
57
|
-
.then(function (data) {
|
|
58
|
-
_this.handleResponseData(data, action);
|
|
59
|
-
})
|
|
60
|
-
.catch(function (err) { return console.log(err); });
|
|
61
|
-
};
|
|
62
|
-
HttpClient.prototype.postAndReturnTheData = function (envelope, action) {
|
|
63
|
-
return fetch(this.apiEndpoint, this.getHttpOptions(envelope))
|
|
64
|
-
.then(function (response) {
|
|
65
|
-
if (response.ok)
|
|
66
|
-
return response.json();
|
|
67
|
-
throw response;
|
|
68
|
-
})
|
|
69
|
-
.then(function (data) {
|
|
70
|
-
return data;
|
|
71
|
-
})
|
|
72
|
-
.catch(function (err) { return console.log(err); });
|
|
73
|
-
};
|
|
74
|
-
HttpClient.prototype.getHttpOptions = function (envelope) {
|
|
75
|
-
return Object.assign({}, HttpHelper.fetchOptions, {
|
|
76
|
-
body: JSON.stringify(envelope),
|
|
77
|
-
credentials: this.options.credentials,
|
|
78
|
-
});
|
|
79
|
-
};
|
|
80
|
-
HttpClient.prototype.constructInputEnvelope = function (action) {
|
|
81
|
-
return {
|
|
82
|
-
action: StoreHelper.getAction(action),
|
|
83
|
-
localState: StoreHelper.getLocalState(action),
|
|
84
|
-
globalState: StoreHelper.getGlobalState(),
|
|
85
|
-
clientId: this.clientId,
|
|
86
|
-
};
|
|
87
|
-
};
|
|
88
|
-
HttpClient.prototype.constructPhraseEnvelope = function (phrase) {
|
|
89
|
-
return {
|
|
90
|
-
command: { phrase: phrase },
|
|
91
|
-
globalState: StoreHelper.getGlobalState(),
|
|
92
|
-
clientId: this.clientId,
|
|
93
|
-
};
|
|
94
|
-
};
|
|
95
|
-
HttpClient.prototype.constructFirstHitEnvelope = function () {
|
|
96
|
-
return {
|
|
97
|
-
command: { site: this.endpointUrl },
|
|
98
|
-
clientId: this.clientId,
|
|
99
|
-
globalState: {},
|
|
100
|
-
};
|
|
101
|
-
};
|
|
102
|
-
HttpClient.prototype.handleResponseData = function (envelope, action) {
|
|
103
|
-
StoreHelper.setGlobalState(envelope.globalState);
|
|
104
|
-
this.middlewareClient.handleEntries(envelope.entries, action);
|
|
105
|
-
};
|
|
106
|
-
return HttpClient;
|
|
107
|
-
}());
|
|
108
|
-
export { HttpClient };
|