@telia-ace/knowledge-widget-types-grid 1.0.13 → 1.0.14
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}/data/data-client.d.ts +0 -0
- package/{lib-esm → dist}/data/index.d.ts +0 -0
- package/{lib-esm → dist}/data/legacy-conversion.d.ts +0 -0
- package/{lib-esm → dist}/index.d.ts +0 -0
- package/dist/index.js +686 -0
- package/dist/index.js.map +1 -0
- package/dist/index2.js +6 -0
- package/dist/index2.js.map +1 -0
- package/{lib-esm → dist}/widget/extended-widget.d.ts +0 -0
- package/{lib-esm → dist}/widget/index.d.ts +0 -0
- package/{lib-esm → dist}/widget/services.d.ts +1 -1
- package/package.json +12 -13
- package/lib/data/data-client.d.ts +0 -91
- package/lib/data/data-client.js +0 -504
- package/lib/data/index.d.ts +0 -3
- package/lib/data/index.js +0 -24
- package/lib/data/legacy-conversion.d.ts +0 -75
- package/lib/data/legacy-conversion.js +0 -308
- package/lib/index.d.ts +0 -3
- package/lib/index.js +0 -25
- package/lib/widget/extended-widget.d.ts +0 -5
- package/lib/widget/extended-widget.js +0 -32
- package/lib/widget/index.d.ts +0 -1
- package/lib/widget/index.js +0 -8
- package/lib/widget/services.d.ts +0 -3
- package/lib/widget/services.js +0 -40
- package/lib-esm/data/data-client.js +0 -500
- package/lib-esm/data/index.js +0 -3
- package/lib-esm/data/legacy-conversion.js +0 -304
- package/lib-esm/index.js +0 -3
- package/lib-esm/widget/extended-widget.js +0 -30
- package/lib-esm/widget/index.js +0 -1
- package/lib-esm/widget/services.js +0 -12
|
@@ -1,304 +0,0 @@
|
|
|
1
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
2
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
3
|
-
if (!m) return o;
|
|
4
|
-
var i = m.call(o), r, ar = [], e;
|
|
5
|
-
try {
|
|
6
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
7
|
-
}
|
|
8
|
-
catch (error) { e = { error: error }; }
|
|
9
|
-
finally {
|
|
10
|
-
try {
|
|
11
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
12
|
-
}
|
|
13
|
-
finally { if (e) throw e.error; }
|
|
14
|
-
}
|
|
15
|
-
return ar;
|
|
16
|
-
};
|
|
17
|
-
import { DialogItemType, } from '@telia-ace/knowledge-widget-core';
|
|
18
|
-
import { FormBuilder } from '@telia-ace/widget-forms';
|
|
19
|
-
import { ServiceClientQueryType } from './data-client';
|
|
20
|
-
var convertLegacySymbol = function (symbol) {
|
|
21
|
-
if (symbol) {
|
|
22
|
-
var Type = symbol.Type, Content = symbol.Content;
|
|
23
|
-
if (Type && Content) {
|
|
24
|
-
return { type: Type, content: Content };
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
var mapLegacyCategoriesRecursively = function (categories) {
|
|
29
|
-
return categories.map(function (c) {
|
|
30
|
-
var category = {
|
|
31
|
-
id: c.Id.toString(),
|
|
32
|
-
title: c.Name,
|
|
33
|
-
symbol: convertLegacySymbol(c.DefaultIcon),
|
|
34
|
-
activeSymbol: c.ActiveIcon && convertLegacySymbol(c.ActiveIcon),
|
|
35
|
-
description: c.Description || (c.Attributes && c.Attributes.description) || '',
|
|
36
|
-
matches: c.GuidesCount,
|
|
37
|
-
};
|
|
38
|
-
if (c.Children && c.Children.length) {
|
|
39
|
-
category.items = mapLegacyCategoriesRecursively(c.Children);
|
|
40
|
-
}
|
|
41
|
-
return category;
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
|
-
var mapNotices = function (source, type) {
|
|
45
|
-
return source
|
|
46
|
-
.filter(function (_a) {
|
|
47
|
-
var Type = _a.Type;
|
|
48
|
-
return Type === type;
|
|
49
|
-
})
|
|
50
|
-
.map(function (_a) {
|
|
51
|
-
var Id = _a.Id, Title = _a.Title, Body = _a.Body;
|
|
52
|
-
return ({
|
|
53
|
-
id: Id.toString(),
|
|
54
|
-
title: Title,
|
|
55
|
-
body: Body,
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
};
|
|
59
|
-
var mapNotificationLists = function (source) {
|
|
60
|
-
return source.map(function (_a) {
|
|
61
|
-
var Id = _a.Id, Title = _a.Title, DefaultIcon = _a.DefaultIcon, ListNotices = _a.ListNotices, Notices = _a.Notices;
|
|
62
|
-
return ({
|
|
63
|
-
id: Id.toString(),
|
|
64
|
-
title: Title,
|
|
65
|
-
symbol: convertLegacySymbol(DefaultIcon),
|
|
66
|
-
defaultHeaderOptions: {
|
|
67
|
-
visible: !!ListNotices.length,
|
|
68
|
-
},
|
|
69
|
-
notifications: (ListNotices || [])
|
|
70
|
-
.concat(Notices || [])
|
|
71
|
-
.map(function (_a) {
|
|
72
|
-
var Id = _a.Id, Title = _a.Title, Body = _a.Body, Type = _a.Type, Modified = _a.Modified;
|
|
73
|
-
return ({
|
|
74
|
-
id: Id.toString(),
|
|
75
|
-
title: Title,
|
|
76
|
-
body: Body,
|
|
77
|
-
modified: Modified,
|
|
78
|
-
expandable: Type === 'listNotice',
|
|
79
|
-
});
|
|
80
|
-
}),
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
};
|
|
84
|
-
var mapContactMethodSettings = function (_a, Validation) {
|
|
85
|
-
var Id = _a.Id, Title = _a.Title, DefaultIcon = _a.DefaultIcon, _b = __read(_a.Exits, 1), Exit = _b[0], ExitType = _a.ExitType, ConfirmationText = _a.ConfirmationText, ExpandFormAutomatically = _a.ExpandFormAutomatically, Form = _a.Form, Description = _a.Description;
|
|
86
|
-
var Adapter = (Exit || { Adapter: {} }).Adapter;
|
|
87
|
-
var _c = Adapter.ClientName, ClientName = _c === void 0 ? '' : _c, _d = Adapter.Settings, Settings = _d === void 0 ? {} : _d, _e = Adapter.CustomClientName, CustomClientName = _e === void 0 ? '' : _e;
|
|
88
|
-
var settings = {
|
|
89
|
-
id: Id.toString(),
|
|
90
|
-
title: Title,
|
|
91
|
-
description: Description,
|
|
92
|
-
symbol: convertLegacySymbol(DefaultIcon),
|
|
93
|
-
clientName: ClientName === 'custom.adapter' ? CustomClientName : ClientName,
|
|
94
|
-
expanded: true,
|
|
95
|
-
inline: true,
|
|
96
|
-
body: {},
|
|
97
|
-
};
|
|
98
|
-
if (ClientName.indexOf('phone') > -1 || ClientName.indexOf('freetext') > -1) {
|
|
99
|
-
var displayTextBeforeClick = Settings.displayTextBeforeClick, textBeforeClick = Settings.textBeforeClick;
|
|
100
|
-
if (displayTextBeforeClick === 'true') {
|
|
101
|
-
settings.expanded = false;
|
|
102
|
-
settings.title = textBeforeClick;
|
|
103
|
-
}
|
|
104
|
-
if (ClientName.indexOf('phone.text') > -1) {
|
|
105
|
-
settings.body.phoneNumber = Settings.phoneNumber;
|
|
106
|
-
}
|
|
107
|
-
else {
|
|
108
|
-
settings.body.freetext = Settings.freetext;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
if (ClientName.indexOf('chat.popup') > -1 ||
|
|
112
|
-
ClientName.indexOf('link') > -1 ||
|
|
113
|
-
(ClientName === 'custom.adapter' && ExitType === 'custom')) {
|
|
114
|
-
settings.body = Settings;
|
|
115
|
-
settings.body.confirmationFallback = ConfirmationText;
|
|
116
|
-
}
|
|
117
|
-
if (ClientName.indexOf('ace') > -1) {
|
|
118
|
-
settings.body = Settings;
|
|
119
|
-
}
|
|
120
|
-
if (Form && Form.HasValueComponents) {
|
|
121
|
-
if (Validation) {
|
|
122
|
-
settings.body.form = FormBuilder.fromLegacyForm(Id.toString(), Form, Validation).get();
|
|
123
|
-
}
|
|
124
|
-
else {
|
|
125
|
-
settings.body.form = FormBuilder.fromLegacyForm(Id.toString(), Form).get();
|
|
126
|
-
}
|
|
127
|
-
if (!ExpandFormAutomatically) {
|
|
128
|
-
settings.expanded = settings.inline = false;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
return settings;
|
|
132
|
-
};
|
|
133
|
-
var mapTags = function (tags) {
|
|
134
|
-
if (tags === void 0) { tags = []; }
|
|
135
|
-
return tags.map(function (_a) {
|
|
136
|
-
var Id = _a.Id, Title = _a.Title, TotalMatches = _a.TotalMatches, Symbol = _a.Symbol, DefaultIcon = _a.DefaultIcon, ActiveIcon = _a.ActiveIcon;
|
|
137
|
-
return ({
|
|
138
|
-
id: Id.toString(),
|
|
139
|
-
title: Title,
|
|
140
|
-
matches: TotalMatches,
|
|
141
|
-
symbol: convertLegacySymbol(DefaultIcon || Symbol),
|
|
142
|
-
defaultIcon: convertLegacySymbol(DefaultIcon),
|
|
143
|
-
activeIcon: convertLegacySymbol(ActiveIcon),
|
|
144
|
-
});
|
|
145
|
-
});
|
|
146
|
-
};
|
|
147
|
-
var mapGuides = function (guides) {
|
|
148
|
-
return guides.map(function (_a) {
|
|
149
|
-
var Id = _a.Id, Title = _a.Title, Tags = _a.Tags, FirstPublishedDate = _a.FirstPublishedDate, Modified = _a.Modified;
|
|
150
|
-
return ({
|
|
151
|
-
id: Id.toString(),
|
|
152
|
-
title: Title,
|
|
153
|
-
tags: mapTags(Tags),
|
|
154
|
-
published: FirstPublishedDate,
|
|
155
|
-
modified: Modified,
|
|
156
|
-
});
|
|
157
|
-
});
|
|
158
|
-
};
|
|
159
|
-
export var formatLegacyData = function (type, data) {
|
|
160
|
-
switch (type) {
|
|
161
|
-
case ServiceClientQueryType.MatchByCategory:
|
|
162
|
-
case ServiceClientQueryType.Match: {
|
|
163
|
-
var result = {
|
|
164
|
-
guides: [],
|
|
165
|
-
matches: 0,
|
|
166
|
-
topNotifications: [],
|
|
167
|
-
middleNotifications: [],
|
|
168
|
-
bottomNotifications: [],
|
|
169
|
-
notificationLists: [],
|
|
170
|
-
tags: [],
|
|
171
|
-
byCategory: [],
|
|
172
|
-
};
|
|
173
|
-
var Matches = data.Matches, TotalMatches = data.TotalMatches, Notices = data.Notices, NoticeLists = data.NoticeLists, Tags = data.Tags, ByCategory = data.ByCategory;
|
|
174
|
-
result.guides = mapGuides(Matches);
|
|
175
|
-
result.matches = TotalMatches;
|
|
176
|
-
result.byCategory = (ByCategory || []).map(function (_a) {
|
|
177
|
-
var Id = _a.Id, Matches = _a.Matches, TotalMatches = _a.TotalMatches;
|
|
178
|
-
return ({
|
|
179
|
-
id: Id,
|
|
180
|
-
guides: mapGuides(Matches),
|
|
181
|
-
matches: TotalMatches,
|
|
182
|
-
});
|
|
183
|
-
});
|
|
184
|
-
result.tags = mapTags(Tags);
|
|
185
|
-
result.notificationLists = mapNotificationLists(NoticeLists || []);
|
|
186
|
-
result.topNotifications = mapNotices(Notices || [], 'noticeRowTop');
|
|
187
|
-
result.middleNotifications = mapNotices(Notices || [], 'noticeRowMiddle');
|
|
188
|
-
result.bottomNotifications = mapNotices(Notices || [], 'footerNotice');
|
|
189
|
-
return result;
|
|
190
|
-
}
|
|
191
|
-
case ServiceClientQueryType.Categories: {
|
|
192
|
-
var Children = data.Children, GuidesCountTotal = data.GuidesCountTotal;
|
|
193
|
-
var result = {
|
|
194
|
-
categories: mapLegacyCategoriesRecursively(Children || []),
|
|
195
|
-
matches: GuidesCountTotal,
|
|
196
|
-
};
|
|
197
|
-
return result;
|
|
198
|
-
}
|
|
199
|
-
case ServiceClientQueryType.Guide: {
|
|
200
|
-
var Id_1 = data.Id, Title_1 = data.Title, Body = data.Body, Related = data.Related, Options = data.Options, ConnectionId_1 = data.ConnectionId, ContactMethods = data.ContactMethods, EnableFeedback = data.EnableFeedback, HandoverExists = data.HandoverExists, FirstPublishedDate = data.FirstPublishedDate, Modified = data.Modified, ModifiedByDisplayName = data.ModifiedByDisplayName, FirstPublishedByDisplayName = data.FirstPublishedByDisplayName, Categories = data.Categories, Tags_1 = data.Tags, SeoMetaDescription = data.SeoMetaDescription, SeoAllowIndex = data.SeoAllowIndex, Perspectives = data.Perspectives, PerspectiveKey = data.PerspectiveKey, Translations_1 = data.Translations;
|
|
201
|
-
/*
|
|
202
|
-
PerspectiveKey is always null when on the "top level" of a dialog tree
|
|
203
|
-
OR when navigating down a dialog tree in the "Default answer version"
|
|
204
|
-
Note: The "Default answer version" is not the same as a given guides
|
|
205
|
-
default answer version. The "Default answer version" is always the answer
|
|
206
|
-
version in Perspectives with the key "Default".
|
|
207
|
-
*/
|
|
208
|
-
var perspective = PerspectiveKey ||
|
|
209
|
-
Object.values(Perspectives).find(function (connection) { return connection === ConnectionId_1; }) ||
|
|
210
|
-
Perspectives['Default'] ||
|
|
211
|
-
null;
|
|
212
|
-
var result_1 = {
|
|
213
|
-
guide: {
|
|
214
|
-
id: Id_1.toString(),
|
|
215
|
-
title: Title_1,
|
|
216
|
-
body: Body,
|
|
217
|
-
modified: Modified,
|
|
218
|
-
published: FirstPublishedDate,
|
|
219
|
-
modifiedBy: ModifiedByDisplayName,
|
|
220
|
-
publishedBy: FirstPublishedByDisplayName,
|
|
221
|
-
connection: ConnectionId_1,
|
|
222
|
-
categories: Categories,
|
|
223
|
-
hasHandover: HandoverExists,
|
|
224
|
-
allowFeedback: EnableFeedback,
|
|
225
|
-
seoMetaDescription: SeoMetaDescription,
|
|
226
|
-
seoAllowIndex: SeoAllowIndex,
|
|
227
|
-
perspectives: Perspectives,
|
|
228
|
-
perspective: perspective,
|
|
229
|
-
translations: Object.keys(Translations_1 || {}).reduce(function (acc, key) {
|
|
230
|
-
acc[key] = Translations_1[key].toString();
|
|
231
|
-
return acc;
|
|
232
|
-
}, {}),
|
|
233
|
-
},
|
|
234
|
-
related: mapGuides(Related || []),
|
|
235
|
-
dialog: [],
|
|
236
|
-
contactMethods: (ContactMethods || []).map(function (cm) { return mapContactMethodSettings(cm); }),
|
|
237
|
-
tags: mapTags(Tags_1),
|
|
238
|
-
};
|
|
239
|
-
(Options || []).forEach(function (_a) {
|
|
240
|
-
var CanAccess = _a.CanAccess, Description = _a.Description, ConnectionId = _a.ConnectionId, Properties = _a.Properties;
|
|
241
|
-
if (!CanAccess) {
|
|
242
|
-
return;
|
|
243
|
-
}
|
|
244
|
-
var item = {
|
|
245
|
-
id: Id_1.toString(),
|
|
246
|
-
title: Description,
|
|
247
|
-
connection: ConnectionId,
|
|
248
|
-
type: DialogItemType.default,
|
|
249
|
-
parent: {
|
|
250
|
-
id: Id_1.toString(),
|
|
251
|
-
title: Title_1,
|
|
252
|
-
tags: mapTags(Tags_1),
|
|
253
|
-
},
|
|
254
|
-
};
|
|
255
|
-
if (Properties.Type === 'Guide' || Properties.Type === 'Link') {
|
|
256
|
-
Properties.Id && (item.id = Properties.Id.toString());
|
|
257
|
-
Properties.Uri && (item.href = Properties.Uri);
|
|
258
|
-
Properties.Target && (item.target = Properties.Target);
|
|
259
|
-
switch (Properties.Type) {
|
|
260
|
-
case 'Guide':
|
|
261
|
-
item.type = DialogItemType.guide;
|
|
262
|
-
break;
|
|
263
|
-
case 'Link':
|
|
264
|
-
item.type = DialogItemType.link;
|
|
265
|
-
break;
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
result_1.dialog.push(item);
|
|
269
|
-
});
|
|
270
|
-
return result_1;
|
|
271
|
-
}
|
|
272
|
-
case ServiceClientQueryType.Contacts: {
|
|
273
|
-
var Children = data.Children, Matches = data.Matches, Notices = data.Notices, NoticeLists = data.NoticeLists;
|
|
274
|
-
var result = {
|
|
275
|
-
contactMethods: (Matches || []).map(function (cm) { return mapContactMethodSettings(cm); }),
|
|
276
|
-
categories: mapLegacyCategoriesRecursively(Children || []),
|
|
277
|
-
topNotifications: mapNotices(Notices || [], 'noticeRowTop'),
|
|
278
|
-
middleNotifications: mapNotices(Notices || [], 'noticeRowMiddle'),
|
|
279
|
-
bottomNotifications: mapNotices(Notices || [], 'footerNotice'),
|
|
280
|
-
notificationLists: mapNotificationLists(NoticeLists || []),
|
|
281
|
-
};
|
|
282
|
-
return result;
|
|
283
|
-
}
|
|
284
|
-
case ServiceClientQueryType.ContactMethod: {
|
|
285
|
-
var ContactMethod = data.ContactMethod;
|
|
286
|
-
return mapContactMethodSettings(ContactMethod || {});
|
|
287
|
-
}
|
|
288
|
-
case ServiceClientQueryType.Tags:
|
|
289
|
-
case ServiceClientQueryType.TagsOnGuides: {
|
|
290
|
-
return mapTags(data || []);
|
|
291
|
-
}
|
|
292
|
-
case ServiceClientQueryType.Notifications: {
|
|
293
|
-
var Notices = data.Notices, NoticeLists = data.NoticeLists;
|
|
294
|
-
return {
|
|
295
|
-
topNotifications: mapNotices(Notices || [], 'noticeRowTop'),
|
|
296
|
-
middleNotifications: mapNotices(Notices || [], 'noticeRowMiddle'),
|
|
297
|
-
bottomNotifications: mapNotices(Notices || [], 'footerNotice'),
|
|
298
|
-
notificationLists: mapNotificationLists(NoticeLists || []),
|
|
299
|
-
};
|
|
300
|
-
}
|
|
301
|
-
default:
|
|
302
|
-
return {};
|
|
303
|
-
}
|
|
304
|
-
};
|
package/lib-esm/index.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
var __extends = (this && this.__extends) || (function () {
|
|
2
|
-
var extendStatics = function (d, b) {
|
|
3
|
-
extendStatics = Object.setPrototypeOf ||
|
|
4
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
6
|
-
return extendStatics(d, b);
|
|
7
|
-
};
|
|
8
|
-
return function (d, b) {
|
|
9
|
-
if (typeof b !== "function" && b !== null)
|
|
10
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
11
|
-
extendStatics(d, b);
|
|
12
|
-
function __() { this.constructor = d; }
|
|
13
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
|
-
};
|
|
15
|
-
})();
|
|
16
|
-
import { Widget } from '@telia-ace/widget-types-grid';
|
|
17
|
-
import { createContactMethodPlatform, createDataClient } from './services';
|
|
18
|
-
var ExtendedWidget = /** @class */ (function (_super) {
|
|
19
|
-
__extends(ExtendedWidget, _super);
|
|
20
|
-
function ExtendedWidget(container) {
|
|
21
|
-
var _this = _super.call(this, container) || this;
|
|
22
|
-
_this.container.registerAsync('contactMethods', function () {
|
|
23
|
-
return createContactMethodPlatform(_this.container);
|
|
24
|
-
});
|
|
25
|
-
_this.container.registerAsync('dataClient', function () { return createDataClient(_this.container); });
|
|
26
|
-
return _this;
|
|
27
|
-
}
|
|
28
|
-
return ExtendedWidget;
|
|
29
|
-
}(Widget));
|
|
30
|
-
export default ExtendedWidget;
|
package/lib-esm/widget/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as GridWidget } from './extended-widget';
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export var createContactMethodPlatform = function (container) {
|
|
2
|
-
return import('@telia-ace/knowledge-widget-adapters').then(function (_a) {
|
|
3
|
-
var ContactMethodPlatform = _a.ContactMethodPlatform;
|
|
4
|
-
return ContactMethodPlatform.create(container);
|
|
5
|
-
});
|
|
6
|
-
};
|
|
7
|
-
export var createDataClient = function (container) {
|
|
8
|
-
return import('../data').then(function (_a) {
|
|
9
|
-
var DataClient = _a.DataClient;
|
|
10
|
-
return DataClient.create(container);
|
|
11
|
-
});
|
|
12
|
-
};
|