@telia-ace/knowledge-widget-types-grid 1.0.1

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.
@@ -0,0 +1,75 @@
1
+ import { ContactMethodType as ContactMethod } from '@telia-ace/knowledge-widget-adapters';
2
+ import { Category, DialogItem, Guide, Notification, NotificationList, Tag } from '@telia-ace/knowledge-widget-core';
3
+ import { DataError, ServiceClientQueryType } from './data-client';
4
+ export declare type MatchResult = {
5
+ guides: Guide[];
6
+ matches: number;
7
+ topNotifications: Notification[];
8
+ middleNotifications: Notification[];
9
+ bottomNotifications: Notification[];
10
+ notificationLists: NotificationList[];
11
+ tags: Tag[];
12
+ byCategory: {
13
+ id: string;
14
+ guides: Guide[];
15
+ matches: number;
16
+ }[];
17
+ };
18
+ export declare type TagsResult = Tag[];
19
+ export declare type CategoriesResult = {
20
+ categories: Category[];
21
+ matches: number;
22
+ };
23
+ export declare type NotificationResults = Pick<MatchResult, 'topNotifications' | 'middleNotifications' | 'bottomNotifications' | 'notificationLists'>;
24
+ export declare type GuideResult = {
25
+ guide: {
26
+ id: string;
27
+ title: string;
28
+ body: string;
29
+ modified: string;
30
+ modifiedBy: string | null;
31
+ publishedBy: string | null;
32
+ published: string;
33
+ connection: string;
34
+ categories: number[];
35
+ hasHandover: boolean;
36
+ allowFeedback: boolean;
37
+ seoMetaDescription: string | null;
38
+ seoAllowIndex: boolean | null;
39
+ perspective: string | null;
40
+ perspectives: {
41
+ [key: string]: string;
42
+ };
43
+ translations?: {
44
+ [key: string]: string;
45
+ };
46
+ };
47
+ related: Guide[];
48
+ dialog: DialogItem[];
49
+ contactMethods: ContactMethod[];
50
+ tags: Tag[];
51
+ error?: DataError;
52
+ };
53
+ export declare type ContactsResult = {
54
+ categories: Category[];
55
+ contactMethods: ContactMethod[];
56
+ topNotifications: Notification[];
57
+ middleNotifications: Notification[];
58
+ bottomNotifications: Notification[];
59
+ notificationLists: NotificationList[];
60
+ };
61
+ export declare type SubmissionResult = {
62
+ contactMethod?: ContactMethod;
63
+ valid: boolean;
64
+ };
65
+ export declare const formatLegacyData: (type: ServiceClientQueryType, data: any) => Tag[] | MatchResult | CategoriesResult | ContactMethod | GuideResult | ContactsResult | {
66
+ topNotifications: Notification[];
67
+ middleNotifications: Notification[];
68
+ bottomNotifications: Notification[];
69
+ notificationLists: NotificationList[];
70
+ } | {
71
+ topNotifications?: undefined;
72
+ middleNotifications?: undefined;
73
+ bottomNotifications?: undefined;
74
+ notificationLists?: undefined;
75
+ };
@@ -0,0 +1,308 @@
1
+ "use strict";
2
+ var __read = (this && this.__read) || function (o, n) {
3
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
4
+ if (!m) return o;
5
+ var i = m.call(o), r, ar = [], e;
6
+ try {
7
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
8
+ }
9
+ catch (error) { e = { error: error }; }
10
+ finally {
11
+ try {
12
+ if (r && !r.done && (m = i["return"])) m.call(i);
13
+ }
14
+ finally { if (e) throw e.error; }
15
+ }
16
+ return ar;
17
+ };
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.formatLegacyData = void 0;
20
+ var knowledge_widget_core_1 = require("@telia-ace/knowledge-widget-core");
21
+ var widget_forms_1 = require("@telia-ace/widget-forms");
22
+ var data_client_1 = require("./data-client");
23
+ var convertLegacySymbol = function (symbol) {
24
+ if (symbol) {
25
+ var Type = symbol.Type, Content = symbol.Content;
26
+ if (Type && Content) {
27
+ return { type: Type, content: Content };
28
+ }
29
+ }
30
+ };
31
+ var mapLegacyCategoriesRecursively = function (categories) {
32
+ return categories.map(function (c) {
33
+ var category = {
34
+ id: c.Id.toString(),
35
+ title: c.Name,
36
+ symbol: convertLegacySymbol(c.DefaultIcon),
37
+ activeSymbol: c.ActiveIcon && convertLegacySymbol(c.ActiveIcon),
38
+ description: c.Description || (c.Attributes && c.Attributes.description) || '',
39
+ matches: c.GuidesCount,
40
+ };
41
+ if (c.Children && c.Children.length) {
42
+ category.items = mapLegacyCategoriesRecursively(c.Children);
43
+ }
44
+ return category;
45
+ });
46
+ };
47
+ var mapNotices = function (source, type) {
48
+ return source
49
+ .filter(function (_a) {
50
+ var Type = _a.Type;
51
+ return Type === type;
52
+ })
53
+ .map(function (_a) {
54
+ var Id = _a.Id, Title = _a.Title, Body = _a.Body;
55
+ return ({
56
+ id: Id.toString(),
57
+ title: Title,
58
+ body: Body,
59
+ });
60
+ });
61
+ };
62
+ var mapNotificationLists = function (source) {
63
+ return source.map(function (_a) {
64
+ var Id = _a.Id, Title = _a.Title, DefaultIcon = _a.DefaultIcon, ListNotices = _a.ListNotices, Notices = _a.Notices;
65
+ return ({
66
+ id: Id.toString(),
67
+ title: Title,
68
+ symbol: convertLegacySymbol(DefaultIcon),
69
+ defaultHeaderOptions: {
70
+ visible: !!ListNotices.length,
71
+ },
72
+ notifications: (ListNotices || [])
73
+ .concat(Notices || [])
74
+ .map(function (_a) {
75
+ var Id = _a.Id, Title = _a.Title, Body = _a.Body, Type = _a.Type, Modified = _a.Modified;
76
+ return ({
77
+ id: Id.toString(),
78
+ title: Title,
79
+ body: Body,
80
+ modified: Modified,
81
+ expandable: Type === 'listNotice',
82
+ });
83
+ }),
84
+ });
85
+ });
86
+ };
87
+ var mapContactMethodSettings = function (_a, Validation) {
88
+ 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;
89
+ var Adapter = (Exit || { Adapter: {} }).Adapter;
90
+ 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;
91
+ var settings = {
92
+ id: Id.toString(),
93
+ title: Title,
94
+ description: Description,
95
+ symbol: convertLegacySymbol(DefaultIcon),
96
+ clientName: ClientName === 'custom.adapter' ? CustomClientName : ClientName,
97
+ expanded: true,
98
+ inline: true,
99
+ body: {},
100
+ };
101
+ if (ClientName.indexOf('phone') > -1 || ClientName.indexOf('freetext') > -1) {
102
+ var displayTextBeforeClick = Settings.displayTextBeforeClick, textBeforeClick = Settings.textBeforeClick;
103
+ if (displayTextBeforeClick === 'true') {
104
+ settings.expanded = false;
105
+ settings.title = textBeforeClick;
106
+ }
107
+ if (ClientName.indexOf('phone.text') > -1) {
108
+ settings.body.phoneNumber = Settings.phoneNumber;
109
+ }
110
+ else {
111
+ settings.body.freetext = Settings.freetext;
112
+ }
113
+ }
114
+ if (ClientName.indexOf('chat.popup') > -1 ||
115
+ ClientName.indexOf('link') > -1 ||
116
+ (ClientName === 'custom.adapter' && ExitType === 'custom')) {
117
+ settings.body = Settings;
118
+ settings.body.confirmationFallback = ConfirmationText;
119
+ }
120
+ if (ClientName.indexOf('ace') > -1) {
121
+ settings.body = Settings;
122
+ }
123
+ if (Form && Form.HasValueComponents) {
124
+ if (Validation) {
125
+ settings.body.form = widget_forms_1.FormBuilder.fromLegacyForm(Id.toString(), Form, Validation).get();
126
+ }
127
+ else {
128
+ settings.body.form = widget_forms_1.FormBuilder.fromLegacyForm(Id.toString(), Form).get();
129
+ }
130
+ if (!ExpandFormAutomatically) {
131
+ settings.expanded = settings.inline = false;
132
+ }
133
+ }
134
+ return settings;
135
+ };
136
+ var mapTags = function (tags) {
137
+ if (tags === void 0) { tags = []; }
138
+ return tags.map(function (_a) {
139
+ var Id = _a.Id, Title = _a.Title, TotalMatches = _a.TotalMatches, Symbol = _a.Symbol, DefaultIcon = _a.DefaultIcon, ActiveIcon = _a.ActiveIcon;
140
+ return ({
141
+ id: Id.toString(),
142
+ title: Title,
143
+ matches: TotalMatches,
144
+ symbol: convertLegacySymbol(DefaultIcon || Symbol),
145
+ defaultIcon: convertLegacySymbol(DefaultIcon),
146
+ activeIcon: convertLegacySymbol(ActiveIcon),
147
+ });
148
+ });
149
+ };
150
+ var mapGuides = function (guides) {
151
+ return guides.map(function (_a) {
152
+ var Id = _a.Id, Title = _a.Title, Tags = _a.Tags, FirstPublishedDate = _a.FirstPublishedDate, Modified = _a.Modified;
153
+ return ({
154
+ id: Id.toString(),
155
+ title: Title,
156
+ tags: mapTags(Tags),
157
+ published: FirstPublishedDate,
158
+ modified: Modified,
159
+ });
160
+ });
161
+ };
162
+ var formatLegacyData = function (type, data) {
163
+ switch (type) {
164
+ case data_client_1.ServiceClientQueryType.MatchByCategory:
165
+ case data_client_1.ServiceClientQueryType.Match: {
166
+ var result = {
167
+ guides: [],
168
+ matches: 0,
169
+ topNotifications: [],
170
+ middleNotifications: [],
171
+ bottomNotifications: [],
172
+ notificationLists: [],
173
+ tags: [],
174
+ byCategory: [],
175
+ };
176
+ var Matches = data.Matches, TotalMatches = data.TotalMatches, Notices = data.Notices, NoticeLists = data.NoticeLists, Tags = data.Tags, ByCategory = data.ByCategory;
177
+ result.guides = mapGuides(Matches);
178
+ result.matches = TotalMatches;
179
+ result.byCategory = (ByCategory || []).map(function (_a) {
180
+ var Id = _a.Id, Matches = _a.Matches, TotalMatches = _a.TotalMatches;
181
+ return ({
182
+ id: Id,
183
+ guides: mapGuides(Matches),
184
+ matches: TotalMatches,
185
+ });
186
+ });
187
+ result.tags = mapTags(Tags);
188
+ result.notificationLists = mapNotificationLists(NoticeLists || []);
189
+ result.topNotifications = mapNotices(Notices || [], 'noticeRowTop');
190
+ result.middleNotifications = mapNotices(Notices || [], 'noticeRowMiddle');
191
+ result.bottomNotifications = mapNotices(Notices || [], 'footerNotice');
192
+ return result;
193
+ }
194
+ case data_client_1.ServiceClientQueryType.Categories: {
195
+ var Children = data.Children, GuidesCountTotal = data.GuidesCountTotal;
196
+ var result = {
197
+ categories: mapLegacyCategoriesRecursively(Children || []),
198
+ matches: GuidesCountTotal,
199
+ };
200
+ return result;
201
+ }
202
+ case data_client_1.ServiceClientQueryType.Guide: {
203
+ 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;
204
+ /*
205
+ PerspectiveKey is always null when on the "top level" of a dialog tree
206
+ OR when navigating down a dialog tree in the "Default answer version"
207
+ Note: The "Default answer version" is not the same as a given guides
208
+ default answer version. The "Default answer version" is always the answer
209
+ version in Perspectives with the key "Default".
210
+ */
211
+ var perspective = PerspectiveKey ||
212
+ Object.values(Perspectives).find(function (connection) { return connection === ConnectionId_1; }) ||
213
+ Perspectives['Default'] ||
214
+ null;
215
+ var result_1 = {
216
+ guide: {
217
+ id: Id_1.toString(),
218
+ title: Title_1,
219
+ body: Body,
220
+ modified: Modified,
221
+ published: FirstPublishedDate,
222
+ modifiedBy: ModifiedByDisplayName,
223
+ publishedBy: FirstPublishedByDisplayName,
224
+ connection: ConnectionId_1,
225
+ categories: Categories,
226
+ hasHandover: HandoverExists,
227
+ allowFeedback: EnableFeedback,
228
+ seoMetaDescription: SeoMetaDescription,
229
+ seoAllowIndex: SeoAllowIndex,
230
+ perspectives: Perspectives,
231
+ perspective: perspective,
232
+ translations: Object.keys(Translations_1 || {}).reduce(function (acc, key) {
233
+ acc[key] = Translations_1[key].toString();
234
+ return acc;
235
+ }, {}),
236
+ },
237
+ related: mapGuides(Related || []),
238
+ dialog: [],
239
+ contactMethods: (ContactMethods || []).map(function (cm) { return mapContactMethodSettings(cm); }),
240
+ tags: mapTags(Tags_1),
241
+ };
242
+ (Options || []).forEach(function (_a) {
243
+ var CanAccess = _a.CanAccess, Description = _a.Description, ConnectionId = _a.ConnectionId, Properties = _a.Properties;
244
+ if (!CanAccess) {
245
+ return;
246
+ }
247
+ var item = {
248
+ id: Id_1.toString(),
249
+ title: Description,
250
+ connection: ConnectionId,
251
+ type: knowledge_widget_core_1.DialogItemType.default,
252
+ parent: {
253
+ id: Id_1.toString(),
254
+ title: Title_1,
255
+ tags: mapTags(Tags_1),
256
+ },
257
+ };
258
+ if (Properties.Type === 'Guide' || Properties.Type === 'Link') {
259
+ Properties.Id && (item.id = Properties.Id.toString());
260
+ Properties.Uri && (item.href = Properties.Uri);
261
+ Properties.Target && (item.target = Properties.Target);
262
+ switch (Properties.Type) {
263
+ case 'Guide':
264
+ item.type = knowledge_widget_core_1.DialogItemType.guide;
265
+ break;
266
+ case 'Link':
267
+ item.type = knowledge_widget_core_1.DialogItemType.link;
268
+ break;
269
+ }
270
+ }
271
+ result_1.dialog.push(item);
272
+ });
273
+ return result_1;
274
+ }
275
+ case data_client_1.ServiceClientQueryType.Contacts: {
276
+ var Children = data.Children, Matches = data.Matches, Notices = data.Notices, NoticeLists = data.NoticeLists;
277
+ var result = {
278
+ contactMethods: (Matches || []).map(function (cm) { return mapContactMethodSettings(cm); }),
279
+ categories: mapLegacyCategoriesRecursively(Children || []),
280
+ topNotifications: mapNotices(Notices || [], 'noticeRowTop'),
281
+ middleNotifications: mapNotices(Notices || [], 'noticeRowMiddle'),
282
+ bottomNotifications: mapNotices(Notices || [], 'footerNotice'),
283
+ notificationLists: mapNotificationLists(NoticeLists || []),
284
+ };
285
+ return result;
286
+ }
287
+ case data_client_1.ServiceClientQueryType.ContactMethod: {
288
+ var ContactMethod = data.ContactMethod;
289
+ return mapContactMethodSettings(ContactMethod || {});
290
+ }
291
+ case data_client_1.ServiceClientQueryType.Tags:
292
+ case data_client_1.ServiceClientQueryType.TagsOnGuides: {
293
+ return mapTags(data || []);
294
+ }
295
+ case data_client_1.ServiceClientQueryType.Notifications: {
296
+ var Notices = data.Notices, NoticeLists = data.NoticeLists;
297
+ return {
298
+ topNotifications: mapNotices(Notices || [], 'noticeRowTop'),
299
+ middleNotifications: mapNotices(Notices || [], 'noticeRowMiddle'),
300
+ bottomNotifications: mapNotices(Notices || [], 'footerNotice'),
301
+ notificationLists: mapNotificationLists(NoticeLists || []),
302
+ };
303
+ }
304
+ default:
305
+ return {};
306
+ }
307
+ };
308
+ exports.formatLegacyData = formatLegacyData;
package/lib/index.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export { Component, DetachedComponent, genericComponentStyling, NotFound, } from '@telia-ace/widget-types-grid';
2
+ export * from './data';
3
+ export { GridWidget } from './widget';
package/lib/index.js ADDED
@@ -0,0 +1,25 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.GridWidget = exports.NotFound = exports.genericComponentStyling = exports.DetachedComponent = exports.Component = void 0;
18
+ var widget_types_grid_1 = require("@telia-ace/widget-types-grid");
19
+ Object.defineProperty(exports, "Component", { enumerable: true, get: function () { return widget_types_grid_1.Component; } });
20
+ Object.defineProperty(exports, "DetachedComponent", { enumerable: true, get: function () { return widget_types_grid_1.DetachedComponent; } });
21
+ Object.defineProperty(exports, "genericComponentStyling", { enumerable: true, get: function () { return widget_types_grid_1.genericComponentStyling; } });
22
+ Object.defineProperty(exports, "NotFound", { enumerable: true, get: function () { return widget_types_grid_1.NotFound; } });
23
+ __exportStar(require("./data"), exports);
24
+ var widget_1 = require("./widget");
25
+ Object.defineProperty(exports, "GridWidget", { enumerable: true, get: function () { return widget_1.GridWidget; } });
@@ -0,0 +1,5 @@
1
+ import { Widget } from '@telia-ace/widget-types-grid';
2
+ import { Container } from '@webprovisions/platform';
3
+ export default class ExtendedWidget extends Widget {
4
+ constructor(container: Container);
5
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ var widget_types_grid_1 = require("@telia-ace/widget-types-grid");
19
+ var services_1 = require("./services");
20
+ var ExtendedWidget = /** @class */ (function (_super) {
21
+ __extends(ExtendedWidget, _super);
22
+ function ExtendedWidget(container) {
23
+ var _this = _super.call(this, container) || this;
24
+ _this.container.registerAsync('contactMethods', function () {
25
+ return (0, services_1.createContactMethodPlatform)(_this.container);
26
+ });
27
+ _this.container.registerAsync('dataClient', function () { return (0, services_1.createDataClient)(_this.container); });
28
+ return _this;
29
+ }
30
+ return ExtendedWidget;
31
+ }(widget_types_grid_1.Widget));
32
+ exports.default = ExtendedWidget;
@@ -0,0 +1 @@
1
+ export { default as GridWidget } from './extended-widget';
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.GridWidget = void 0;
7
+ var extended_widget_1 = require("./extended-widget");
8
+ Object.defineProperty(exports, "GridWidget", { enumerable: true, get: function () { return __importDefault(extended_widget_1).default; } });
@@ -0,0 +1,3 @@
1
+ import { Container } from '@webprovisions/platform';
2
+ export declare const createContactMethodPlatform: (container: Container) => Promise<import("@telia-ace/knowledge-widget-adapters/lib/contact-methods/platform").default>;
3
+ export declare const createDataClient: (container: Container) => Promise<import("../data").DataClient>;
@@ -0,0 +1,40 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.createDataClient = exports.createContactMethodPlatform = void 0;
27
+ var createContactMethodPlatform = function (container) {
28
+ return Promise.resolve().then(function () { return __importStar(require('@telia-ace/knowledge-widget-adapters')); }).then(function (_a) {
29
+ var ContactMethodPlatform = _a.ContactMethodPlatform;
30
+ return ContactMethodPlatform.create(container);
31
+ });
32
+ };
33
+ exports.createContactMethodPlatform = createContactMethodPlatform;
34
+ var createDataClient = function (container) {
35
+ return Promise.resolve().then(function () { return __importStar(require('../data')); }).then(function (_a) {
36
+ var DataClient = _a.DataClient;
37
+ return DataClient.create(container);
38
+ });
39
+ };
40
+ exports.createDataClient = createDataClient;
@@ -0,0 +1,91 @@
1
+ import { ServiceClient } from '@telia-ace/knowledge-serviceclient';
2
+ import { Container, EventManager } from '@webprovisions/platform';
3
+ export declare type Subscriber = (...args: any[]) => void;
4
+ export declare enum DataType {
5
+ Guide = "guide",
6
+ Guides = "guides",
7
+ GuidesByCategory = "guides-by-category",
8
+ RowNotifications = "row-notices",
9
+ NotificationLists = "notification-lists",
10
+ GuideCategories = "guide-categories",
11
+ ContactMethodCategories = "contact-method-categories",
12
+ ContactMethod = "contact-method",
13
+ ContactMethods = "contact-methods",
14
+ Tags = "tags",
15
+ TagsOnGuides = "tagsonguides"
16
+ }
17
+ export declare type DataError = {
18
+ status: number;
19
+ message: string;
20
+ };
21
+ export declare enum ServiceClientQueryType {
22
+ Match = "match",
23
+ Categories = "categories",
24
+ Guide = "guide",
25
+ Contacts = "contacts",
26
+ ContactMethod = "contact-method",
27
+ MatchByCategory = "match-by-category",
28
+ Tags = "tags",
29
+ TagsOnGuides = "tagsonguides",
30
+ Notifications = "notifications"
31
+ }
32
+ export declare enum FeedbackType {
33
+ Positive = "Positive",
34
+ Negative = "Negative"
35
+ }
36
+ export declare type QueryParameters = {
37
+ guideId?: string | number;
38
+ categories?: string | number | string[] | number[];
39
+ tagId?: string | number;
40
+ connection?: string;
41
+ contactMethodCategoryId?: string | number;
42
+ contactMethodId?: string | number;
43
+ searchPhrase?: string | number;
44
+ take?: string | number;
45
+ [key: string]: any;
46
+ expandCategories?: 'none' | 'children' | 'descendants';
47
+ sorting?: SortingType;
48
+ guideIds?: string[];
49
+ };
50
+ export declare enum SortingType {
51
+ POPULARITY_DESCENDING = "popularity-descending",
52
+ ALPHABETIC_ASCENDING = "alphabetic-ascending",
53
+ ALPHABETIC_DESCENDING = "alphabetic-descending",
54
+ MODIFIED_ASCENDING = "modified-ascending",
55
+ MODIFIED_DESCENDING = "modified-descending",
56
+ PUBLISHED_ASCENDING = "published-ascending",
57
+ PUBLISHED_DESCENDING = "published-descending"
58
+ }
59
+ export declare type Query = {
60
+ params: QueryParameters;
61
+ resolved: boolean;
62
+ loading: boolean;
63
+ error?: DataError;
64
+ data: any;
65
+ resolvers: {
66
+ resolve: (data: any) => void;
67
+ reject: (data: any) => void;
68
+ }[];
69
+ };
70
+ export declare const determineServiceClientQueryType: (type: DataType) => ServiceClientQueryType;
71
+ export default class DataClient {
72
+ private container;
73
+ private matchingClient;
74
+ private queries;
75
+ private lastTake;
76
+ events: EventManager;
77
+ constructor(container: Container, matchingClient: ServiceClient);
78
+ static getInstance(container: Container): Promise<DataClient>;
79
+ private getUnresolvedQueries;
80
+ fetch(type: DataType, params: QueryParameters): Promise<any>;
81
+ read(type: DataType, options: {
82
+ select?: (data: any) => any;
83
+ }): any[];
84
+ feedback(id: string, connection: string, feedback: FeedbackType): Promise<any>;
85
+ private setLoadingStatus;
86
+ private runQuery;
87
+ handleResponse(data: any, type: ServiceClientQueryType, params: QueryParameters, error?: DataError): void;
88
+ private fetchAllUnresolvedQueries;
89
+ private track;
90
+ static create(container: Container): Promise<DataClient>;
91
+ }