@fluid-topics/public-api 1.0.13 → 1.0.16
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/dist/cjs/index.js +35 -2
- package/dist/cjs/types/ft-common/public.js +230 -2
- package/dist/fluidtopics.min.js +1 -1
- package/dist/mjs/index.d.ts +6 -2
- package/dist/mjs/index.js +33 -2
- package/dist/mjs/types/ft-common/public.d.ts +188 -1
- package/dist/mjs/types/ft-common/public.js +206 -1
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -47,10 +47,15 @@ function getBody(response) {
|
|
|
47
47
|
return response.headers.get("Content-Type") === "application/json" ? response.json() : response.text();
|
|
48
48
|
}
|
|
49
49
|
class FluidTopicsApi {
|
|
50
|
-
constructor(tenantBaseUrl, integrationIdentifier) {
|
|
50
|
+
constructor(tenantBaseUrl, integrationIdentifier, overrideIdentifierIfOnTenant) {
|
|
51
51
|
this.authorization = {};
|
|
52
52
|
this.tenantBaseUrl = tenantBaseUrl.trim().replace(/\/$/, "");
|
|
53
|
-
|
|
53
|
+
if (overrideIdentifierIfOnTenant && typeof window !== "undefined" && window.location.href.startsWith(tenantBaseUrl)) {
|
|
54
|
+
this.ftCallingApp = integrationIdentifier;
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
this.ftCallingApp = `ft-public-api/${integrationIdentifier}`;
|
|
58
|
+
}
|
|
54
59
|
}
|
|
55
60
|
get defaultHeaders() {
|
|
56
61
|
return Object.assign(Object.assign({}, this.authorization), { "Ft-Calling-App": this.ftCallingApp });
|
|
@@ -116,6 +121,15 @@ class FluidTopicsApi {
|
|
|
116
121
|
getCollectionDocuments(userId, collectionId) {
|
|
117
122
|
return this.get(`/api/users/${userId}/collections/${collectionId}/documents`);
|
|
118
123
|
}
|
|
124
|
+
getSuggestions(request) {
|
|
125
|
+
return this.post("/api/khub/suggest", request);
|
|
126
|
+
}
|
|
127
|
+
search(request) {
|
|
128
|
+
return this.post("/api/khub/clustered-search", request);
|
|
129
|
+
}
|
|
130
|
+
getAvailableSearchLocales() {
|
|
131
|
+
return this.get("/api/khub/locales");
|
|
132
|
+
}
|
|
119
133
|
get(endpoint) {
|
|
120
134
|
return this.makeRequest("GET", endpoint);
|
|
121
135
|
}
|
|
@@ -138,6 +152,25 @@ class FluidTopicsApi {
|
|
|
138
152
|
return yield fetch(this.tenantBaseUrl + endpoint, Object.assign(Object.assign({}, (requestInit !== null && requestInit !== void 0 ? requestInit : {})), { headers: Object.assign(Object.assign({}, this.defaultHeaders), ((_a = requestInit === null || requestInit === void 0 ? void 0 : requestInit.headers) !== null && _a !== void 0 ? _a : {})) }));
|
|
139
153
|
});
|
|
140
154
|
}
|
|
155
|
+
upload(method, endpoint, body, onProgress = () => { }) {
|
|
156
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
157
|
+
return new Promise((resolve, reject) => {
|
|
158
|
+
let xhr = new XMLHttpRequest();
|
|
159
|
+
xhr.onload = () => {
|
|
160
|
+
if (xhr.status >= 200 && xhr.status < 300) {
|
|
161
|
+
let data = xhr.getResponseHeader("Content-Type") === "application/json" ? JSON.parse(xhr.responseText) : xhr.responseText;
|
|
162
|
+
resolve(data);
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
reject(new HttpError(xhr.status, xhr.statusText, xhr.responseText));
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
xhr.upload.onprogress = (e) => onProgress(e);
|
|
169
|
+
xhr.open(method, this.tenantBaseUrl + endpoint, true);
|
|
170
|
+
xhr.send(body);
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
}
|
|
141
174
|
makeRequest(method, endpoint, data) {
|
|
142
175
|
return this.fetch(endpoint, {
|
|
143
176
|
method: method,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isFtAuthenticationIdentifier = exports.isFtSearchResultType = exports.FtSearchResultType = exports.isFtOpenMode = exports.FtOpenMode = exports.isFtEditorialType = exports.FtEditorialType = exports.isFtMapResource = exports.isFtMetadata = exports.isFtTopicContentTarget = exports.FtTopicContentTarget = exports.isFtUnstructuredDocument = exports.isFtTopic = exports.isFtTocNode = exports.isFtMap = exports.isFtCollectionDocument = exports.isFtCredentials = void 0;
|
|
3
|
+
exports.isFtAuthenticationIdentifier = exports.isFtSuggestResults = exports.isFtSuggestResult = exports.isFtSuggestRequest = exports.isFtTopicResource = exports.isFtSpellcheck = exports.isFtSearchSortCriterion = exports.isFtSearchFacetEntry = exports.isFtSearchFacetConf = exports.isFtSearchFacet = exports.isFtSearchResultType = exports.FtSearchResultType = exports.isFtSearchResultTopic = exports.isFtSearchResultMap = exports.isFtSearchResultUnstructuredDocument = exports.isFtSearchResultClusterEntry = exports.isFtSearchResultCluster = exports.isFtSearchRequest = exports.isFtSearchResults = exports.isFtCollectionDocumentType = exports.FtCollectionDocumentType = exports.isFtPageRequest = exports.isFtOpenMode = exports.FtOpenMode = exports.isFtEditorialType = exports.FtEditorialType = exports.isFtSearchResultsPageInfo = exports.isFtSearchPreset = exports.isFtSearchFilter = exports.isFtMapResource = exports.isFtMetadata = exports.isFtSearchLocales = exports.isFtSearchLocale = exports.isFtTopicContentTarget = exports.FtTopicContentTarget = exports.isFtUnstructuredDocument = exports.isFtTopic = exports.isFtTocNode = exports.isFtMap = exports.isFtCollectionDocument = exports.isFtCredentials = void 0;
|
|
4
4
|
const isObject = (o) => typeof o === "object" && o != null;
|
|
5
5
|
const isBoolean = (o) => typeof o === "boolean";
|
|
6
6
|
const isNumber = (o) => typeof o === "number";
|
|
@@ -20,7 +20,7 @@ const isFtCollectionDocument = (o) => {
|
|
|
20
20
|
&& (o.portalUrl == null || isString(o.portalUrl))
|
|
21
21
|
&& (isString(o.id))
|
|
22
22
|
&& (isString(o.title))
|
|
23
|
-
&& ((0, exports.
|
|
23
|
+
&& ((0, exports.isFtCollectionDocumentType)(o.type));
|
|
24
24
|
};
|
|
25
25
|
exports.isFtCollectionDocument = isFtCollectionDocument;
|
|
26
26
|
const isFtMap = (o) => {
|
|
@@ -99,6 +99,19 @@ const isFtTopicContentTarget = (o) => {
|
|
|
99
99
|
return ["THIRD_PARTY", "OFF_THE_GRID"].includes(o);
|
|
100
100
|
};
|
|
101
101
|
exports.isFtTopicContentTarget = isFtTopicContentTarget;
|
|
102
|
+
const isFtSearchLocale = (o) => {
|
|
103
|
+
return isObject(o)
|
|
104
|
+
&& (isNumber(o.count))
|
|
105
|
+
&& (isString(o.label))
|
|
106
|
+
&& (o.lang == null || isString(o.lang));
|
|
107
|
+
};
|
|
108
|
+
exports.isFtSearchLocale = isFtSearchLocale;
|
|
109
|
+
const isFtSearchLocales = (o) => {
|
|
110
|
+
return isObject(o)
|
|
111
|
+
&& ((Array.isArray(o.contentLocales)
|
|
112
|
+
&& o.contentLocales.every((v) => (0, exports.isFtSearchLocale)(v))));
|
|
113
|
+
};
|
|
114
|
+
exports.isFtSearchLocales = isFtSearchLocales;
|
|
102
115
|
const isFtMetadata = (o) => {
|
|
103
116
|
return isObject(o)
|
|
104
117
|
&& ((Array.isArray(o.values)
|
|
@@ -115,6 +128,30 @@ const isFtMapResource = (o) => {
|
|
|
115
128
|
&& (isString(o.mimeType));
|
|
116
129
|
};
|
|
117
130
|
exports.isFtMapResource = isFtMapResource;
|
|
131
|
+
const isFtSearchFilter = (o) => {
|
|
132
|
+
return isObject(o)
|
|
133
|
+
&& (isBoolean(o.negative))
|
|
134
|
+
&& ((Array.isArray(o.values)
|
|
135
|
+
&& o.values.every((v) => isString(v))))
|
|
136
|
+
&& (isString(o.key));
|
|
137
|
+
};
|
|
138
|
+
exports.isFtSearchFilter = isFtSearchFilter;
|
|
139
|
+
const isFtSearchPreset = (o) => {
|
|
140
|
+
return isObject(o)
|
|
141
|
+
&& (isString(o.name))
|
|
142
|
+
&& ((Array.isArray(o.filters)
|
|
143
|
+
&& o.filters.every((v) => (0, exports.isFtSearchFilter)(v))))
|
|
144
|
+
&& (o.contentLocale == null || isString(o.contentLocale));
|
|
145
|
+
};
|
|
146
|
+
exports.isFtSearchPreset = isFtSearchPreset;
|
|
147
|
+
const isFtSearchResultsPageInfo = (o) => {
|
|
148
|
+
return isObject(o)
|
|
149
|
+
&& (isNumber(o.totalResultsCount))
|
|
150
|
+
&& (isBoolean(o.lastPage))
|
|
151
|
+
&& (isNumber(o.currentPage))
|
|
152
|
+
&& (isNumber(o.totalClustersCount));
|
|
153
|
+
};
|
|
154
|
+
exports.isFtSearchResultsPageInfo = isFtSearchResultsPageInfo;
|
|
118
155
|
// From: WsEditorialType
|
|
119
156
|
var FtEditorialType;
|
|
120
157
|
(function (FtEditorialType) {
|
|
@@ -135,6 +172,123 @@ const isFtOpenMode = (o) => {
|
|
|
135
172
|
return ["FLUIDTOPICS", "EXTERNAL"].includes(o);
|
|
136
173
|
};
|
|
137
174
|
exports.isFtOpenMode = isFtOpenMode;
|
|
175
|
+
const isFtPageRequest = (o) => {
|
|
176
|
+
return isObject(o)
|
|
177
|
+
&& (o.perPage == null || isNumber(o.perPage))
|
|
178
|
+
&& (isNumber(o.page));
|
|
179
|
+
};
|
|
180
|
+
exports.isFtPageRequest = isFtPageRequest;
|
|
181
|
+
// From: WsPublicCollectionDocumentType
|
|
182
|
+
var FtCollectionDocumentType;
|
|
183
|
+
(function (FtCollectionDocumentType) {
|
|
184
|
+
FtCollectionDocumentType["MAP"] = "MAP";
|
|
185
|
+
FtCollectionDocumentType["DOCUMENT"] = "DOCUMENT";
|
|
186
|
+
FtCollectionDocumentType["TOPIC"] = "TOPIC";
|
|
187
|
+
FtCollectionDocumentType["PERSONAL_BOOK"] = "PERSONAL_BOOK";
|
|
188
|
+
FtCollectionDocumentType["SHARED_BOOK"] = "SHARED_BOOK";
|
|
189
|
+
})(FtCollectionDocumentType = exports.FtCollectionDocumentType || (exports.FtCollectionDocumentType = {}));
|
|
190
|
+
const isFtCollectionDocumentType = (o) => {
|
|
191
|
+
return ["MAP", "DOCUMENT", "TOPIC", "PERSONAL_BOOK", "SHARED_BOOK"].includes(o);
|
|
192
|
+
};
|
|
193
|
+
exports.isFtCollectionDocumentType = isFtCollectionDocumentType;
|
|
194
|
+
const isFtSearchResults = (o) => {
|
|
195
|
+
return isObject(o)
|
|
196
|
+
&& (o.spellcheck == null || (0, exports.isFtSpellcheck)(o.spellcheck))
|
|
197
|
+
&& ((0, exports.isFtSearchResultsPageInfo)(o.paging))
|
|
198
|
+
&& ((Array.isArray(o.results)
|
|
199
|
+
&& o.results.every((v) => (0, exports.isFtSearchResultCluster)(v))))
|
|
200
|
+
&& ((Array.isArray(o.facets)
|
|
201
|
+
&& o.facets.every((v) => (0, exports.isFtSearchFacet)(v))));
|
|
202
|
+
};
|
|
203
|
+
exports.isFtSearchResults = isFtSearchResults;
|
|
204
|
+
const isFtSearchRequest = (o) => {
|
|
205
|
+
return isObject(o)
|
|
206
|
+
&& (isString(o.query))
|
|
207
|
+
&& ((0, exports.isFtPageRequest)(o.paging))
|
|
208
|
+
&& ((Array.isArray(o.filters)
|
|
209
|
+
&& o.filters.every((v) => (0, exports.isFtSearchFilter)(v))))
|
|
210
|
+
&& ((Array.isArray(o.sort)
|
|
211
|
+
&& o.sort.every((v) => (0, exports.isFtSearchSortCriterion)(v))))
|
|
212
|
+
&& (o.uiLocale == null || isString(o.uiLocale))
|
|
213
|
+
&& (o.contentLocale == null || isString(o.contentLocale))
|
|
214
|
+
&& ((Array.isArray(o.facets)
|
|
215
|
+
&& o.facets.every((v) => (0, exports.isFtSearchFacetConf)(v))));
|
|
216
|
+
};
|
|
217
|
+
exports.isFtSearchRequest = isFtSearchRequest;
|
|
218
|
+
const isFtSearchResultCluster = (o) => {
|
|
219
|
+
return isObject(o)
|
|
220
|
+
&& ((Array.isArray(o.entries)
|
|
221
|
+
&& o.entries.every((v) => (0, exports.isFtSearchResultClusterEntry)(v))))
|
|
222
|
+
&& (o.metadataVariableAxis == null || isString(o.metadataVariableAxis));
|
|
223
|
+
};
|
|
224
|
+
exports.isFtSearchResultCluster = isFtSearchResultCluster;
|
|
225
|
+
const isFtSearchResultClusterEntry = (o) => {
|
|
226
|
+
return isObject(o)
|
|
227
|
+
&& (o.document == null || (0, exports.isFtSearchResultUnstructuredDocument)(o.document))
|
|
228
|
+
&& (o.topic == null || (0, exports.isFtSearchResultTopic)(o.topic))
|
|
229
|
+
&& ((0, exports.isFtSearchResultType)(o.type))
|
|
230
|
+
&& (o.map == null || (0, exports.isFtSearchResultMap)(o.map));
|
|
231
|
+
};
|
|
232
|
+
exports.isFtSearchResultClusterEntry = isFtSearchResultClusterEntry;
|
|
233
|
+
const isFtSearchResultUnstructuredDocument = (o) => {
|
|
234
|
+
return isObject(o)
|
|
235
|
+
&& ((Array.isArray(o.metadata)
|
|
236
|
+
&& o.metadata.every((v) => (0, exports.isFtMetadata)(v))))
|
|
237
|
+
&& ((0, exports.isFtOpenMode)(o.openMode))
|
|
238
|
+
&& (isString(o.documentUrl))
|
|
239
|
+
&& (isString(o.mimeType))
|
|
240
|
+
&& (isString(o.title))
|
|
241
|
+
&& (o.lastPublicationDate == null || isString(o.lastPublicationDate))
|
|
242
|
+
&& (isString(o.viewerUrl))
|
|
243
|
+
&& (isString(o.contentUrl))
|
|
244
|
+
&& (isString(o.filename))
|
|
245
|
+
&& (isString(o.htmlTitle))
|
|
246
|
+
&& (o.originUrl == null || isString(o.originUrl))
|
|
247
|
+
&& (isString(o.documentId))
|
|
248
|
+
&& (isString(o.lastEditionDate))
|
|
249
|
+
&& (isString(o.htmlExcerpt));
|
|
250
|
+
};
|
|
251
|
+
exports.isFtSearchResultUnstructuredDocument = isFtSearchResultUnstructuredDocument;
|
|
252
|
+
const isFtSearchResultMap = (o) => {
|
|
253
|
+
return isObject(o)
|
|
254
|
+
&& ((Array.isArray(o.metadata)
|
|
255
|
+
&& o.metadata.every((v) => (0, exports.isFtMetadata)(v))))
|
|
256
|
+
&& ((0, exports.isFtOpenMode)(o.openMode))
|
|
257
|
+
&& ((0, exports.isFtEditorialType)(o.editorialType))
|
|
258
|
+
&& (isString(o.title))
|
|
259
|
+
&& (o.lastPublicationDate == null || isString(o.lastPublicationDate))
|
|
260
|
+
&& (isString(o.htmlTitle))
|
|
261
|
+
&& (o.originUrl == null || isString(o.originUrl))
|
|
262
|
+
&& (isString(o.mapUrl))
|
|
263
|
+
&& (isString(o.readerUrl))
|
|
264
|
+
&& (isString(o.mapId))
|
|
265
|
+
&& (o.lastEditionDate == null || isString(o.lastEditionDate))
|
|
266
|
+
&& (isString(o.htmlExcerpt));
|
|
267
|
+
};
|
|
268
|
+
exports.isFtSearchResultMap = isFtSearchResultMap;
|
|
269
|
+
const isFtSearchResultTopic = (o) => {
|
|
270
|
+
return isObject(o)
|
|
271
|
+
&& ((Array.isArray(o.metadata)
|
|
272
|
+
&& o.metadata.every((v) => (0, exports.isFtMetadata)(v))))
|
|
273
|
+
&& ((0, exports.isFtOpenMode)(o.openMode))
|
|
274
|
+
&& (isString(o.contentId))
|
|
275
|
+
&& ((Array.isArray(o.resources)
|
|
276
|
+
&& o.resources.every((v) => (0, exports.isFtTopicResource)(v))))
|
|
277
|
+
&& (isString(o.title))
|
|
278
|
+
&& (isString(o.mapTitle))
|
|
279
|
+
&& (isString(o.topicUrl))
|
|
280
|
+
&& (isString(o.contentUrl))
|
|
281
|
+
&& (isString(o.htmlTitle))
|
|
282
|
+
&& ((Array.isArray(o.breadcrumb)
|
|
283
|
+
&& o.breadcrumb.every((v) => isString(v))))
|
|
284
|
+
&& (isString(o.tocId))
|
|
285
|
+
&& (o.originUrl == null || isString(o.originUrl))
|
|
286
|
+
&& (isString(o.readerUrl))
|
|
287
|
+
&& (isString(o.mapId))
|
|
288
|
+
&& (o.lastEditionDate == null || isString(o.lastEditionDate))
|
|
289
|
+
&& (isString(o.htmlExcerpt));
|
|
290
|
+
};
|
|
291
|
+
exports.isFtSearchResultTopic = isFtSearchResultTopic;
|
|
138
292
|
// From: WsPublicSearchResultType
|
|
139
293
|
var FtSearchResultType;
|
|
140
294
|
(function (FtSearchResultType) {
|
|
@@ -146,6 +300,80 @@ const isFtSearchResultType = (o) => {
|
|
|
146
300
|
return ["MAP", "DOCUMENT", "TOPIC"].includes(o);
|
|
147
301
|
};
|
|
148
302
|
exports.isFtSearchResultType = isFtSearchResultType;
|
|
303
|
+
const isFtSearchFacet = (o) => {
|
|
304
|
+
return isObject(o)
|
|
305
|
+
&& (isBoolean(o.hierarchical))
|
|
306
|
+
&& (isString(o.label))
|
|
307
|
+
&& (isBoolean(o.multiSelectionable))
|
|
308
|
+
&& (isString(o.key))
|
|
309
|
+
&& ((Array.isArray(o.rootNodes)
|
|
310
|
+
&& o.rootNodes.every((v) => (0, exports.isFtSearchFacetEntry)(v))));
|
|
311
|
+
};
|
|
312
|
+
exports.isFtSearchFacet = isFtSearchFacet;
|
|
313
|
+
const isFtSearchFacetConf = (o) => {
|
|
314
|
+
return isObject(o)
|
|
315
|
+
&& (o.maxDepth == null || isNumber(o.maxDepth))
|
|
316
|
+
&& (isString(o.id));
|
|
317
|
+
};
|
|
318
|
+
exports.isFtSearchFacetConf = isFtSearchFacetConf;
|
|
319
|
+
const isFtSearchFacetEntry = (o) => {
|
|
320
|
+
return isObject(o)
|
|
321
|
+
&& (isNumber(o.totalResultsCount))
|
|
322
|
+
&& (isBoolean(o.descendantSelected))
|
|
323
|
+
&& ((Array.isArray(o.childNodes)
|
|
324
|
+
&& o.childNodes.every((v) => (0, exports.isFtSearchFacetEntry)(v))))
|
|
325
|
+
&& (isString(o.label))
|
|
326
|
+
&& (isString(o.value))
|
|
327
|
+
&& (isBoolean(o.selected));
|
|
328
|
+
};
|
|
329
|
+
exports.isFtSearchFacetEntry = isFtSearchFacetEntry;
|
|
330
|
+
const isFtSearchSortCriterion = (o) => {
|
|
331
|
+
return isObject(o)
|
|
332
|
+
&& (isString(o.key));
|
|
333
|
+
};
|
|
334
|
+
exports.isFtSearchSortCriterion = isFtSearchSortCriterion;
|
|
335
|
+
const isFtSpellcheck = (o) => {
|
|
336
|
+
return isObject(o)
|
|
337
|
+
&& (isString(o.suggestedQuery))
|
|
338
|
+
&& (isString(o.htmlSuggestedQuery));
|
|
339
|
+
};
|
|
340
|
+
exports.isFtSpellcheck = isFtSpellcheck;
|
|
341
|
+
const isFtTopicResource = (o) => {
|
|
342
|
+
return isObject(o)
|
|
343
|
+
&& (isString(o.filename))
|
|
344
|
+
&& (isString(o.resourceUrl))
|
|
345
|
+
&& (isString(o.id))
|
|
346
|
+
&& (isString(o.mimeType))
|
|
347
|
+
&& (isString(o.resourceContentUrl))
|
|
348
|
+
&& (isString(o.viewerUrl));
|
|
349
|
+
};
|
|
350
|
+
exports.isFtTopicResource = isFtTopicResource;
|
|
351
|
+
const isFtSuggestRequest = (o) => {
|
|
352
|
+
return isObject(o)
|
|
353
|
+
&& (isString(o.input))
|
|
354
|
+
&& ((Array.isArray(o.filters)
|
|
355
|
+
&& o.filters.every((v) => (0, exports.isFtSearchFilter)(v))))
|
|
356
|
+
&& ((Array.isArray(o.sort)
|
|
357
|
+
&& o.sort.every((v) => (0, exports.isFtSearchSortCriterion)(v))))
|
|
358
|
+
&& (o.maxCount == null || isNumber(o.maxCount))
|
|
359
|
+
&& (o.contentLocale == null || isString(o.contentLocale));
|
|
360
|
+
};
|
|
361
|
+
exports.isFtSuggestRequest = isFtSuggestRequest;
|
|
362
|
+
const isFtSuggestResult = (o) => {
|
|
363
|
+
return isObject(o)
|
|
364
|
+
&& (o.filenameExtension == null || isString(o.filenameExtension))
|
|
365
|
+
&& (o.editorialType == null || (0, exports.isFtEditorialType)(o.editorialType))
|
|
366
|
+
&& (o.mimeType == null || isString(o.mimeType))
|
|
367
|
+
&& ((0, exports.isFtSearchResultType)(o.type))
|
|
368
|
+
&& (isString(o.value));
|
|
369
|
+
};
|
|
370
|
+
exports.isFtSuggestResult = isFtSuggestResult;
|
|
371
|
+
const isFtSuggestResults = (o) => {
|
|
372
|
+
return isObject(o)
|
|
373
|
+
&& ((Array.isArray(o.suggestions)
|
|
374
|
+
&& o.suggestions.every((v) => (0, exports.isFtSuggestResult)(v))));
|
|
375
|
+
};
|
|
376
|
+
exports.isFtSuggestResults = isFtSuggestResults;
|
|
149
377
|
const isFtAuthenticationIdentifier = (o) => {
|
|
150
378
|
return isObject(o)
|
|
151
379
|
&& (isString(o.identifier))
|
package/dist/fluidtopics.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).fluidtopics={})}(this,(function(t){"use strict";var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n={exports:{}},i={exports:{}};!function(t,e){var n=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==n)return n;throw new Error("unable to locate global object")}();t.exports=e=n.fetch,n.fetch&&(e.default=n.fetch.bind(n)),e.Headers=n.Headers,e.Request=n.Request,e.Response=n.Response}(i,i.exports),function(t,e){const n=i.exports,r=n.default||n,s=function(t,e){return/^\/\//.test(t)&&(t="https:"+t),r.call(this,t,e)};s.ponyfill=!0,t.exports=e=s,e.fetch=s,e.Headers=n.Headers,e.Request=n.Request,e.Response=n.Response,e.default=s}(n,n.exports);const r=n.exports,s=r.fetch.bind({});s.polyfill=!0,e.fetch||(e.fetch=s,e.Response=r.Response,e.Headers=r.Headers,e.Request=r.Request);const a=t=>"object"==typeof t&&null!=t,o=t=>"boolean"==typeof t,l=t=>"string"==typeof t,u=t=>a(t)&&l(t.tocId)&&Array.isArray(t.children)&&t.children.every((t=>u(t)))&&l(t.contentId)&&l(t.title);var p;t.FtTopicContentTarget=void 0,(p=t.FtTopicContentTarget||(t.FtTopicContentTarget={})).THIRD_PARTY="THIRD_PARTY",p.OFF_THE_GRID="OFF_THE_GRID";const d=t=>a(t)&&Array.isArray(t.values)&&t.values.every((t=>l(t)))&&l(t.label)&&l(t.key);var c;t.FtEditorialType=void 0,(c=t.FtEditorialType||(t.FtEditorialType={})).ARTICLE="ARTICLE",c.BOOK="BOOK";const h=t=>["ARTICLE","BOOK"].includes(t);var f;t.FtOpenMode=void 0,(f=t.FtOpenMode||(t.FtOpenMode={})).FLUIDTOPICS="FLUIDTOPICS",f.EXTERNAL="EXTERNAL";const y=t=>["FLUIDTOPICS","EXTERNAL"].includes(t);var T;t.FtSearchResultType=void 0,(T=t.FtSearchResultType||(t.FtSearchResultType={})).MAP="MAP",T.DOCUMENT="DOCUMENT",T.TOPIC="TOPIC";const g=t=>["MAP","DOCUMENT","TOPIC"].includes(t),m=t=>"object"==typeof t&&null!=t,b=t=>"string"==typeof t,A=t=>m(t)&&(null==t.emailAddress||b(t.emailAddress))&&(null==t.displayName||b(t.displayName))&&Array.isArray(t.roles)&&b(t.userId);class R extends Error{status;statusText;body;constructor(t,e,n){super(`${t} - ${e}: ${n}`),this.status=t,this.statusText=e,this.body=n}}async function F(t){if(!t.ok)throw new R(t.status,t.statusText,await t.text());return t}function E(t){return"application/json"===t.headers.get("Content-Type")?t.json():t.text()}class C{tenantBaseUrl;ftCallingApp;authorization={};get defaultHeaders(){return{...this.authorization,"Ft-Calling-App":this.ftCallingApp}}constructor(t,e){this.tenantBaseUrl=t.trim().replace(/\/$/,""),this.ftCallingApp=`ft-public-api/${e}`}setApiKey(t){this.authorization={Authorization:"Bearer "+t}}setCredentials(t,e){var n;this.authorization={Authorization:"Basic "+(n=`${t}:${e}`,"undefined"!=typeof Buffer?Buffer.from(n).toString("base64"):btoa(n))}}clearAuthentication(){this.authorization={}}login(t,e){let n={login:t,password:e,rememberMe:!0};return this.post("/api/authentication/login",n).then((n=>(this.setCredentials(t,e),n)))}logout(){return this.post("/api/authentication/logout").then((()=>this.clearAuthentication()))}getMap(t){return this.get(`/api/khub/maps/${t}`)}getTableOfContent(t){return this.get(`/api/khub/maps/${t}/toc`)}getTopic(t,e){return this.get(`/api/khub/maps/${t}/topics/${e}`)}getTopicHTMLContent(t,e,n){return this.get(`/api/khub/maps/${t}/topics/${e}/content${n?"?target="+n:""}`)}getMapAttachments(t){return this.get(`/api/khub/maps/${t}/attachments`)}getMapAttachmentContent(t,e){return this.fetchRawData(`/api/khub/maps/${t}/attachments/${e}/content`)}getMapResources(t){return this.get(`/api/khub/maps/${t}/resources`)}getMapResourceContent(t,e){return this.fetchRawData(`/api/khub/maps/${t}/resources/${e}/content`)}getUnstructuredDocument(t){return this.get(`/api/khub/documents/${t}`)}getUnstructuredDocumentContent(t){return this.fetchRawData(`/api/khub/documents/${t}/content`)}getUnstructuredDocumentTextContent(t){return this.get(`/api/khub/documents/${t}/content/text`)}getCollectionDocuments(t,e){return this.get(`/api/users/${t}/collections/${e}/documents`)}get(t){return this.makeRequest("GET",t)}post(t,e){return this.makeRequest("POST",t,e)}put(t,e){return this.makeRequest("PUT",t,e)}delete(t){return this.makeRequest("DELETE",t)}async fetch(t,e){const n=e;return t.startsWith("/")||(t="/"+t),await fetch(this.tenantBaseUrl+t,{...n??{},headers:{...this.defaultHeaders,...n?.headers??{}}})}makeRequest(t,e,n){return this.fetch(e,{method:t,headers:{...null!=n?{"Content-Type":"application/json"}:{}},body:null!=n?JSON.stringify(n):void 0}).then(F).then(E)}fetchRawData(t){return fetch(this.tenantBaseUrl+t,{headers:this.defaultHeaders}).then(F).then((t=>t.arrayBuffer()))}}t.FluidTopicsApi=C,t.HttpError=R,t.default=C,t.isFtAuthenticatedSession=t=>m(t)&&A(t.profile),t.isFtAuthenticationIdentifier=t=>a(t)&&l(t.identifier)&&l(t.realm),t.isFtCollectionDocument=t=>a(t)&&o(t.deleted)&&(null==t.apiUrl||l(t.apiUrl))&&(null==t.portalUrl||l(t.portalUrl))&&l(t.id)&&l(t.title)&&g(t.type),t.isFtCredentials=t=>a(t)&&l(t.password)&&(null==t.newPassword||l(t.newPassword))&&o(t.rememberMe)&&l(t.login),t.isFtEditorialType=h,t.isFtMap=t=>a(t)&&(null==t.prettyUrl||l(t.prettyUrl))&&Array.isArray(t.metadata)&&t.metadata.every((t=>d(t)))&&y(t.openMode)&&l(t.topicsApiEndpoint)&&(null==t.description||l(t.description))&&l(t.attachmentsApiEndpoint)&&h(t.editorialType)&&l(t.baseId)&&l(t.clusterId)&&l(t.title)&&l(t.lastPublication)&&l(t.lastEdition)&&l(t.originId)&&l(t.rightsApiEndpoint)&&(null==t.originUrl||l(t.originUrl))&&l(t.readerUrl)&&(null==t.khubVersion||l(t.khubVersion))&&l(t.id)&&(null==t.lang||l(t.lang)),t.isFtMapAttachment=t=>m(t)&&b(t.file)&&(null==t.size||(t=>"number"==typeof t)(t.size))&&(t=>"boolean"==typeof t)(t.externalLink)&&b(t.name)&&b(t.id)&&(null==t.mimeType||b(t.mimeType))&&(null==t.viewerUrl||b(t.viewerUrl)),t.isFtMapResource=t=>a(t)&&l(t.contentUrl)&&l(t.filename)&&l(t.id)&&l(t.mimeType),t.isFtMetadata=d,t.isFtOpenMode=y,t.isFtSearchResultType=g,t.isFtTocNode=u,t.isFtTopic=t=>a(t)&&Array.isArray(t.metadata)&&t.metadata.every((t=>d(t)))&&l(t.id)&&l(t.contentApiEndpoint)&&l(t.title),t.isFtTopicContentTarget=t=>["THIRD_PARTY","OFF_THE_GRID"].includes(t),t.isFtUnstructuredDocument=t=>a(t)&&(null==t.prettyUrl||l(t.prettyUrl))&&Array.isArray(t.metadata)&&t.metadata.every((t=>d(t)))&&l(t.openMode)&&(null==t.description||l(t.description))&&l(t.mimeType)&&(null==t.baseId||l(t.baseId))&&(null==t.clusterId||l(t.clusterId))&&l(t.contentApiEndpoint)&&l(t.title)&&(null==t.lastPublication||l(t.lastPublication))&&l(t.viewerUrl)&&l(t.lastEdition)&&l(t.filename)&&(null==t.originId||l(t.originId))&&l(t.rightsApiEndpoint)&&(null==t.originUrl||l(t.originUrl))&&(null==t.khubVersion||l(t.khubVersion))&&l(t.id)&&(null==t.lang||l(t.lang)),t.isFtUserProfile=A}));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).fluidtopics={})}(this,(function(e){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},r={exports:{}},i={exports:{}};!function(e,t){var r=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==r)return r;throw new Error("unable to locate global object")}();e.exports=t=r.fetch,r.fetch&&(t.default=r.fetch.bind(r)),t.Headers=r.Headers,t.Request=r.Request,t.Response=r.Response}(i,i.exports),function(e,t){const r=i.exports,a=r.default||r,n=function(e,t){return/^\/\//.test(e)&&(e="https:"+e),a.call(this,e,t)};n.ponyfill=!0,e.exports=t=n,t.fetch=n,t.Headers=r.Headers,t.Request=r.Request,t.Response=r.Response,t.default=n}(r,r.exports);const a=r.exports,n=a.fetch.bind({});n.polyfill=!0,t.fetch||(t.fetch=n,t.Response=a.Response,t.Headers=a.Headers,t.Request=a.Request);const s=e=>"object"==typeof e&&null!=e,l=e=>"boolean"==typeof e,o=e=>"number"==typeof e,u=e=>"string"==typeof e,c=e=>s(e)&&u(e.tocId)&&Array.isArray(e.children)&&e.children.every((e=>c(e)))&&u(e.contentId)&&u(e.title);var p;e.FtTopicContentTarget=void 0,(p=e.FtTopicContentTarget||(e.FtTopicContentTarget={})).THIRD_PARTY="THIRD_PARTY",p.OFF_THE_GRID="OFF_THE_GRID";const d=e=>s(e)&&o(e.count)&&u(e.label)&&(null==e.lang||u(e.lang)),h=e=>s(e)&&Array.isArray(e.values)&&e.values.every((e=>u(e)))&&u(e.label)&&u(e.key),y=e=>s(e)&&l(e.negative)&&Array.isArray(e.values)&&e.values.every((e=>u(e)))&&u(e.key),f=e=>s(e)&&o(e.totalResultsCount)&&l(e.lastPage)&&o(e.currentPage)&&o(e.totalClustersCount);var m;e.FtEditorialType=void 0,(m=e.FtEditorialType||(e.FtEditorialType={})).ARTICLE="ARTICLE",m.BOOK="BOOK";const g=e=>["ARTICLE","BOOK"].includes(e);var A;e.FtOpenMode=void 0,(A=e.FtOpenMode||(e.FtOpenMode={})).FLUIDTOPICS="FLUIDTOPICS",A.EXTERNAL="EXTERNAL";const T=e=>["FLUIDTOPICS","EXTERNAL"].includes(e),F=e=>s(e)&&(null==e.perPage||o(e.perPage))&&o(e.page);var b;e.FtCollectionDocumentType=void 0,(b=e.FtCollectionDocumentType||(e.FtCollectionDocumentType={})).MAP="MAP",b.DOCUMENT="DOCUMENT",b.TOPIC="TOPIC",b.PERSONAL_BOOK="PERSONAL_BOOK",b.SHARED_BOOK="SHARED_BOOK";const R=e=>["MAP","DOCUMENT","TOPIC","PERSONAL_BOOK","SHARED_BOOK"].includes(e),C=e=>s(e)&&Array.isArray(e.entries)&&e.entries.every((e=>E(e)))&&(null==e.metadataVariableAxis||u(e.metadataVariableAxis)),E=e=>s(e)&&(null==e.document||U(e.document))&&(null==e.topic||O(e.topic))&&S(e.type)&&(null==e.map||v(e.map)),U=e=>s(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>h(e)))&&T(e.openMode)&&u(e.documentUrl)&&u(e.mimeType)&&u(e.title)&&(null==e.lastPublicationDate||u(e.lastPublicationDate))&&u(e.viewerUrl)&&u(e.contentUrl)&&u(e.filename)&&u(e.htmlTitle)&&(null==e.originUrl||u(e.originUrl))&&u(e.documentId)&&u(e.lastEditionDate)&&u(e.htmlExcerpt),v=e=>s(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>h(e)))&&T(e.openMode)&&g(e.editorialType)&&u(e.title)&&(null==e.lastPublicationDate||u(e.lastPublicationDate))&&u(e.htmlTitle)&&(null==e.originUrl||u(e.originUrl))&&u(e.mapUrl)&&u(e.readerUrl)&&u(e.mapId)&&(null==e.lastEditionDate||u(e.lastEditionDate))&&u(e.htmlExcerpt),O=e=>s(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>h(e)))&&T(e.openMode)&&u(e.contentId)&&Array.isArray(e.resources)&&e.resources.every((e=>k(e)))&&u(e.title)&&u(e.mapTitle)&&u(e.topicUrl)&&u(e.contentUrl)&&u(e.htmlTitle)&&Array.isArray(e.breadcrumb)&&e.breadcrumb.every((e=>u(e)))&&u(e.tocId)&&(null==e.originUrl||u(e.originUrl))&&u(e.readerUrl)&&u(e.mapId)&&(null==e.lastEditionDate||u(e.lastEditionDate))&&u(e.htmlExcerpt);var D;e.FtSearchResultType=void 0,(D=e.FtSearchResultType||(e.FtSearchResultType={})).MAP="MAP",D.DOCUMENT="DOCUMENT",D.TOPIC="TOPIC";const S=e=>["MAP","DOCUMENT","TOPIC"].includes(e),P=e=>s(e)&&l(e.hierarchical)&&u(e.label)&&l(e.multiSelectionable)&&u(e.key)&&Array.isArray(e.rootNodes)&&e.rootNodes.every((e=>w(e))),I=e=>s(e)&&(null==e.maxDepth||o(e.maxDepth))&&u(e.id),w=e=>s(e)&&o(e.totalResultsCount)&&l(e.descendantSelected)&&Array.isArray(e.childNodes)&&e.childNodes.every((e=>w(e)))&&u(e.label)&&u(e.value)&&l(e.selected),x=e=>s(e)&&u(e.key),M=e=>s(e)&&u(e.suggestedQuery)&&u(e.htmlSuggestedQuery),k=e=>s(e)&&u(e.filename)&&u(e.resourceUrl)&&u(e.id)&&u(e.mimeType)&&u(e.resourceContentUrl)&&u(e.viewerUrl),L=e=>s(e)&&(null==e.filenameExtension||u(e.filenameExtension))&&(null==e.editorialType||g(e.editorialType))&&(null==e.mimeType||u(e.mimeType))&&S(e.type)&&u(e.value),$=e=>"object"==typeof e&&null!=e,H=e=>"string"==typeof e,N=e=>$(e)&&(null==e.emailAddress||H(e.emailAddress))&&(null==e.displayName||H(e.displayName))&&Array.isArray(e.roles)&&H(e.userId);class B extends Error{status;statusText;body;constructor(e,t,r){super(`${e} - ${t}: ${r}`),this.status=e,this.statusText=t,this.body=r}}async function q(e){if(!e.ok)throw new B(e.status,e.statusText,await e.text());return e}function _(e){return"application/json"===e.headers.get("Content-Type")?e.json():e.text()}class K{tenantBaseUrl;ftCallingApp;authorization={};get defaultHeaders(){return{...this.authorization,"Ft-Calling-App":this.ftCallingApp}}constructor(e,t,r){this.tenantBaseUrl=e.trim().replace(/\/$/,""),r&&"undefined"!=typeof window&&window.location.href.startsWith(e)?this.ftCallingApp=t:this.ftCallingApp=`ft-public-api/${t}`}setApiKey(e){this.authorization={Authorization:"Bearer "+e}}setCredentials(e,t){var r;this.authorization={Authorization:"Basic "+(r=`${e}:${t}`,"undefined"!=typeof Buffer?Buffer.from(r).toString("base64"):btoa(r))}}clearAuthentication(){this.authorization={}}login(e,t){let r={login:e,password:t,rememberMe:!0};return this.post("/api/authentication/login",r).then((r=>(this.setCredentials(e,t),r)))}logout(){return this.post("/api/authentication/logout").then((()=>this.clearAuthentication()))}getMap(e){return this.get(`/api/khub/maps/${e}`)}getTableOfContent(e){return this.get(`/api/khub/maps/${e}/toc`)}getTopic(e,t){return this.get(`/api/khub/maps/${e}/topics/${t}`)}getTopicHTMLContent(e,t,r){return this.get(`/api/khub/maps/${e}/topics/${t}/content${r?"?target="+r:""}`)}getMapAttachments(e){return this.get(`/api/khub/maps/${e}/attachments`)}getMapAttachmentContent(e,t){return this.fetchRawData(`/api/khub/maps/${e}/attachments/${t}/content`)}getMapResources(e){return this.get(`/api/khub/maps/${e}/resources`)}getMapResourceContent(e,t){return this.fetchRawData(`/api/khub/maps/${e}/resources/${t}/content`)}getUnstructuredDocument(e){return this.get(`/api/khub/documents/${e}`)}getUnstructuredDocumentContent(e){return this.fetchRawData(`/api/khub/documents/${e}/content`)}getUnstructuredDocumentTextContent(e){return this.get(`/api/khub/documents/${e}/content/text`)}getCollectionDocuments(e,t){return this.get(`/api/users/${e}/collections/${t}/documents`)}getSuggestions(e){return this.post("/api/khub/suggest",e)}search(e){return this.post("/api/khub/clustered-search",e)}getAvailableSearchLocales(){return this.get("/api/khub/locales")}get(e){return this.makeRequest("GET",e)}post(e,t){return this.makeRequest("POST",e,t)}put(e,t){return this.makeRequest("PUT",e,t)}delete(e){return this.makeRequest("DELETE",e)}async fetch(e,t){const r=t;return e.startsWith("/")||(e="/"+e),await fetch(this.tenantBaseUrl+e,{...r??{},headers:{...this.defaultHeaders,...r?.headers??{}}})}async upload(e,t,r,i=(()=>{})){return new Promise(((a,n)=>{let s=new XMLHttpRequest;s.onload=()=>{if(s.status>=200&&s.status<300){let e="application/json"===s.getResponseHeader("Content-Type")?JSON.parse(s.responseText):s.responseText;a(e)}else n(new B(s.status,s.statusText,s.responseText))},s.upload.onprogress=e=>i(e),s.open(e,this.tenantBaseUrl+t,!0),s.send(r)}))}makeRequest(e,t,r){return this.fetch(t,{method:e,headers:{...null!=r?{"Content-Type":"application/json"}:{}},body:null!=r?JSON.stringify(r):void 0}).then(q).then(_)}fetchRawData(e){return fetch(this.tenantBaseUrl+e,{headers:this.defaultHeaders}).then(q).then((e=>e.arrayBuffer()))}}e.FluidTopicsApi=K,e.HttpError=B,e.default=K,e.isFtAuthenticatedSession=e=>$(e)&&N(e.profile),e.isFtAuthenticationIdentifier=e=>s(e)&&u(e.identifier)&&u(e.realm),e.isFtCollectionDocument=e=>s(e)&&l(e.deleted)&&(null==e.apiUrl||u(e.apiUrl))&&(null==e.portalUrl||u(e.portalUrl))&&u(e.id)&&u(e.title)&&R(e.type),e.isFtCollectionDocumentType=R,e.isFtCredentials=e=>s(e)&&u(e.password)&&(null==e.newPassword||u(e.newPassword))&&l(e.rememberMe)&&u(e.login),e.isFtEditorialType=g,e.isFtMap=e=>s(e)&&(null==e.prettyUrl||u(e.prettyUrl))&&Array.isArray(e.metadata)&&e.metadata.every((e=>h(e)))&&T(e.openMode)&&u(e.topicsApiEndpoint)&&(null==e.description||u(e.description))&&u(e.attachmentsApiEndpoint)&&g(e.editorialType)&&u(e.baseId)&&u(e.clusterId)&&u(e.title)&&u(e.lastPublication)&&u(e.lastEdition)&&u(e.originId)&&u(e.rightsApiEndpoint)&&(null==e.originUrl||u(e.originUrl))&&u(e.readerUrl)&&(null==e.khubVersion||u(e.khubVersion))&&u(e.id)&&(null==e.lang||u(e.lang)),e.isFtMapAttachment=e=>$(e)&&H(e.file)&&(null==e.size||(e=>"number"==typeof e)(e.size))&&(e=>"boolean"==typeof e)(e.externalLink)&&H(e.name)&&H(e.id)&&(null==e.mimeType||H(e.mimeType))&&(null==e.viewerUrl||H(e.viewerUrl)),e.isFtMapResource=e=>s(e)&&u(e.contentUrl)&&u(e.filename)&&u(e.id)&&u(e.mimeType),e.isFtMetadata=h,e.isFtOpenMode=T,e.isFtPageRequest=F,e.isFtSearchFacet=P,e.isFtSearchFacetConf=I,e.isFtSearchFacetEntry=w,e.isFtSearchFilter=y,e.isFtSearchLocale=d,e.isFtSearchLocales=e=>s(e)&&Array.isArray(e.contentLocales)&&e.contentLocales.every((e=>d(e))),e.isFtSearchPreset=e=>s(e)&&u(e.name)&&Array.isArray(e.filters)&&e.filters.every((e=>y(e)))&&(null==e.contentLocale||u(e.contentLocale)),e.isFtSearchRequest=e=>s(e)&&u(e.query)&&F(e.paging)&&Array.isArray(e.filters)&&e.filters.every((e=>y(e)))&&Array.isArray(e.sort)&&e.sort.every((e=>x(e)))&&(null==e.uiLocale||u(e.uiLocale))&&(null==e.contentLocale||u(e.contentLocale))&&Array.isArray(e.facets)&&e.facets.every((e=>I(e))),e.isFtSearchResultCluster=C,e.isFtSearchResultClusterEntry=E,e.isFtSearchResultMap=v,e.isFtSearchResultTopic=O,e.isFtSearchResultType=S,e.isFtSearchResultUnstructuredDocument=U,e.isFtSearchResults=e=>s(e)&&(null==e.spellcheck||M(e.spellcheck))&&f(e.paging)&&Array.isArray(e.results)&&e.results.every((e=>C(e)))&&Array.isArray(e.facets)&&e.facets.every((e=>P(e))),e.isFtSearchResultsPageInfo=f,e.isFtSearchSortCriterion=x,e.isFtSpellcheck=M,e.isFtSuggestRequest=e=>s(e)&&u(e.input)&&Array.isArray(e.filters)&&e.filters.every((e=>y(e)))&&Array.isArray(e.sort)&&e.sort.every((e=>x(e)))&&(null==e.maxCount||o(e.maxCount))&&(null==e.contentLocale||u(e.contentLocale)),e.isFtSuggestResult=L,e.isFtSuggestResults=e=>s(e)&&Array.isArray(e.suggestions)&&e.suggestions.every((e=>L(e))),e.isFtTocNode=c,e.isFtTopic=e=>s(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>h(e)))&&u(e.id)&&u(e.contentApiEndpoint)&&u(e.title),e.isFtTopicContentTarget=e=>["THIRD_PARTY","OFF_THE_GRID"].includes(e),e.isFtTopicResource=k,e.isFtUnstructuredDocument=e=>s(e)&&(null==e.prettyUrl||u(e.prettyUrl))&&Array.isArray(e.metadata)&&e.metadata.every((e=>h(e)))&&u(e.openMode)&&(null==e.description||u(e.description))&&u(e.mimeType)&&(null==e.baseId||u(e.baseId))&&(null==e.clusterId||u(e.clusterId))&&u(e.contentApiEndpoint)&&u(e.title)&&(null==e.lastPublication||u(e.lastPublication))&&u(e.viewerUrl)&&u(e.lastEdition)&&u(e.filename)&&(null==e.originId||u(e.originId))&&u(e.rightsApiEndpoint)&&(null==e.originUrl||u(e.originUrl))&&(null==e.khubVersion||u(e.khubVersion))&&u(e.id)&&(null==e.lang||u(e.lang)),e.isFtUserProfile=N}));
|
package/dist/mjs/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "cross-fetch/polyfill";
|
|
2
|
-
import { FtCollectionDocument, FtMap, FtMapResource, FtTocNode, FtTopic, FtTopicContentTarget, FtUnstructuredDocument } from "./types/ft-common/public";
|
|
2
|
+
import { FtCollectionDocument, FtMap, FtMapResource, FtSearchLocales, FtSearchRequest, FtSearchResults, FtSuggestRequest, FtSuggestResults, FtTocNode, FtTopic, FtTopicContentTarget, FtUnstructuredDocument } from "./types/ft-common/public";
|
|
3
3
|
import { FtAuthenticatedSession, FtMapAttachment } from "./types/ft-server/public";
|
|
4
4
|
export * from "./types/ft-common/public";
|
|
5
5
|
export * from "./types/ft-server/public";
|
|
@@ -14,7 +14,7 @@ export declare class FluidTopicsApi {
|
|
|
14
14
|
private readonly ftCallingApp;
|
|
15
15
|
private authorization;
|
|
16
16
|
private get defaultHeaders();
|
|
17
|
-
constructor(tenantBaseUrl: string, integrationIdentifier: string);
|
|
17
|
+
constructor(tenantBaseUrl: string, integrationIdentifier: string, overrideIdentifierIfOnTenant?: boolean);
|
|
18
18
|
setApiKey(apiKey: string): void;
|
|
19
19
|
setCredentials(login: string, password: string): void;
|
|
20
20
|
clearAuthentication(): void;
|
|
@@ -32,11 +32,15 @@ export declare class FluidTopicsApi {
|
|
|
32
32
|
getUnstructuredDocumentContent(documentId: string): Promise<ArrayBuffer>;
|
|
33
33
|
getUnstructuredDocumentTextContent(documentId: string): Promise<string>;
|
|
34
34
|
getCollectionDocuments(userId: string, collectionId: string): Promise<Array<FtCollectionDocument>>;
|
|
35
|
+
getSuggestions(request: FtSuggestRequest): Promise<FtSuggestResults>;
|
|
36
|
+
search(request: FtSearchRequest): Promise<FtSearchResults>;
|
|
37
|
+
getAvailableSearchLocales(): Promise<FtSearchLocales>;
|
|
35
38
|
get<T>(endpoint: string): Promise<T>;
|
|
36
39
|
post<T>(endpoint: string, data?: any): Promise<T>;
|
|
37
40
|
put<T>(endpoint: string, data?: any): Promise<T>;
|
|
38
41
|
delete<T>(endpoint: string): Promise<T>;
|
|
39
42
|
fetch<FetchRequestInit, FetchResponse>(endpoint: string, init?: FetchRequestInit): Promise<FetchResponse>;
|
|
43
|
+
upload<T>(method: string, endpoint: string, body: Document | XMLHttpRequestBodyInit, onProgress?: (e: ProgressEvent) => void): Promise<T>;
|
|
40
44
|
private makeRequest;
|
|
41
45
|
private fetchRawData;
|
|
42
46
|
}
|
package/dist/mjs/index.js
CHANGED
|
@@ -34,9 +34,14 @@ export class FluidTopicsApi {
|
|
|
34
34
|
"Ft-Calling-App": this.ftCallingApp
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
|
-
constructor(tenantBaseUrl, integrationIdentifier) {
|
|
37
|
+
constructor(tenantBaseUrl, integrationIdentifier, overrideIdentifierIfOnTenant) {
|
|
38
38
|
this.tenantBaseUrl = tenantBaseUrl.trim().replace(/\/$/, "");
|
|
39
|
-
|
|
39
|
+
if (overrideIdentifierIfOnTenant && typeof window !== "undefined" && window.location.href.startsWith(tenantBaseUrl)) {
|
|
40
|
+
this.ftCallingApp = integrationIdentifier;
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
this.ftCallingApp = `ft-public-api/${integrationIdentifier}`;
|
|
44
|
+
}
|
|
40
45
|
}
|
|
41
46
|
setApiKey(apiKey) {
|
|
42
47
|
this.authorization = { "Authorization": "Bearer " + apiKey };
|
|
@@ -99,6 +104,15 @@ export class FluidTopicsApi {
|
|
|
99
104
|
getCollectionDocuments(userId, collectionId) {
|
|
100
105
|
return this.get(`/api/users/${userId}/collections/${collectionId}/documents`);
|
|
101
106
|
}
|
|
107
|
+
getSuggestions(request) {
|
|
108
|
+
return this.post("/api/khub/suggest", request);
|
|
109
|
+
}
|
|
110
|
+
search(request) {
|
|
111
|
+
return this.post("/api/khub/clustered-search", request);
|
|
112
|
+
}
|
|
113
|
+
getAvailableSearchLocales() {
|
|
114
|
+
return this.get("/api/khub/locales");
|
|
115
|
+
}
|
|
102
116
|
get(endpoint) {
|
|
103
117
|
return this.makeRequest("GET", endpoint);
|
|
104
118
|
}
|
|
@@ -124,6 +138,23 @@ export class FluidTopicsApi {
|
|
|
124
138
|
}
|
|
125
139
|
});
|
|
126
140
|
}
|
|
141
|
+
async upload(method, endpoint, body, onProgress = () => { }) {
|
|
142
|
+
return new Promise((resolve, reject) => {
|
|
143
|
+
let xhr = new XMLHttpRequest();
|
|
144
|
+
xhr.onload = () => {
|
|
145
|
+
if (xhr.status >= 200 && xhr.status < 300) {
|
|
146
|
+
let data = xhr.getResponseHeader("Content-Type") === "application/json" ? JSON.parse(xhr.responseText) : xhr.responseText;
|
|
147
|
+
resolve(data);
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
reject(new HttpError(xhr.status, xhr.statusText, xhr.responseText));
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
xhr.upload.onprogress = (e) => onProgress(e);
|
|
154
|
+
xhr.open(method, this.tenantBaseUrl + endpoint, true);
|
|
155
|
+
xhr.send(body);
|
|
156
|
+
});
|
|
157
|
+
}
|
|
127
158
|
makeRequest(method, endpoint, data) {
|
|
128
159
|
return this.fetch(endpoint, {
|
|
129
160
|
method: method,
|
|
@@ -11,7 +11,7 @@ export interface FtCollectionDocument {
|
|
|
11
11
|
portalUrl?: string;
|
|
12
12
|
id: string;
|
|
13
13
|
title: string;
|
|
14
|
-
type:
|
|
14
|
+
type: FtCollectionDocumentType;
|
|
15
15
|
}
|
|
16
16
|
export declare const isFtCollectionDocument: (o: any) => o is FtCollectionDocument;
|
|
17
17
|
export interface FtMap {
|
|
@@ -77,6 +77,16 @@ export declare enum FtTopicContentTarget {
|
|
|
77
77
|
OFF_THE_GRID = "OFF_THE_GRID"
|
|
78
78
|
}
|
|
79
79
|
export declare const isFtTopicContentTarget: (o: any) => o is FtTopicContentTarget;
|
|
80
|
+
export interface FtSearchLocale {
|
|
81
|
+
count: number;
|
|
82
|
+
label: string;
|
|
83
|
+
lang?: string;
|
|
84
|
+
}
|
|
85
|
+
export declare const isFtSearchLocale: (o: any) => o is FtSearchLocale;
|
|
86
|
+
export interface FtSearchLocales {
|
|
87
|
+
contentLocales: Array<FtSearchLocale>;
|
|
88
|
+
}
|
|
89
|
+
export declare const isFtSearchLocales: (o: any) => o is FtSearchLocales;
|
|
80
90
|
export interface FtMetadata {
|
|
81
91
|
values: Array<string>;
|
|
82
92
|
label: string;
|
|
@@ -90,6 +100,25 @@ export interface FtMapResource {
|
|
|
90
100
|
mimeType: string;
|
|
91
101
|
}
|
|
92
102
|
export declare const isFtMapResource: (o: any) => o is FtMapResource;
|
|
103
|
+
export interface FtSearchFilter {
|
|
104
|
+
negative: boolean;
|
|
105
|
+
values: Array<string>;
|
|
106
|
+
key: string;
|
|
107
|
+
}
|
|
108
|
+
export declare const isFtSearchFilter: (o: any) => o is FtSearchFilter;
|
|
109
|
+
export interface FtSearchPreset {
|
|
110
|
+
name: string;
|
|
111
|
+
filters: Array<FtSearchFilter>;
|
|
112
|
+
contentLocale?: string;
|
|
113
|
+
}
|
|
114
|
+
export declare const isFtSearchPreset: (o: any) => o is FtSearchPreset;
|
|
115
|
+
export interface FtSearchResultsPageInfo {
|
|
116
|
+
totalResultsCount: number;
|
|
117
|
+
lastPage: boolean;
|
|
118
|
+
currentPage: number;
|
|
119
|
+
totalClustersCount: number;
|
|
120
|
+
}
|
|
121
|
+
export declare const isFtSearchResultsPageInfo: (o: any) => o is FtSearchResultsPageInfo;
|
|
93
122
|
export declare enum FtEditorialType {
|
|
94
123
|
ARTICLE = "ARTICLE",
|
|
95
124
|
BOOK = "BOOK"
|
|
@@ -100,12 +129,170 @@ export declare enum FtOpenMode {
|
|
|
100
129
|
EXTERNAL = "EXTERNAL"
|
|
101
130
|
}
|
|
102
131
|
export declare const isFtOpenMode: (o: any) => o is FtOpenMode;
|
|
132
|
+
export interface FtPageRequest {
|
|
133
|
+
perPage?: number;
|
|
134
|
+
page: number;
|
|
135
|
+
}
|
|
136
|
+
export declare const isFtPageRequest: (o: any) => o is FtPageRequest;
|
|
137
|
+
export declare enum FtCollectionDocumentType {
|
|
138
|
+
MAP = "MAP",
|
|
139
|
+
DOCUMENT = "DOCUMENT",
|
|
140
|
+
TOPIC = "TOPIC",
|
|
141
|
+
PERSONAL_BOOK = "PERSONAL_BOOK",
|
|
142
|
+
SHARED_BOOK = "SHARED_BOOK"
|
|
143
|
+
}
|
|
144
|
+
export declare const isFtCollectionDocumentType: (o: any) => o is FtCollectionDocumentType;
|
|
145
|
+
export interface FtSearchResults {
|
|
146
|
+
spellcheck?: FtSpellcheck;
|
|
147
|
+
paging: FtSearchResultsPageInfo;
|
|
148
|
+
results: Array<FtSearchResultCluster>;
|
|
149
|
+
facets: Array<FtSearchFacet>;
|
|
150
|
+
}
|
|
151
|
+
export declare const isFtSearchResults: (o: any) => o is FtSearchResults;
|
|
152
|
+
export interface FtSearchRequest {
|
|
153
|
+
query: string;
|
|
154
|
+
paging: FtPageRequest;
|
|
155
|
+
filters: Array<FtSearchFilter>;
|
|
156
|
+
sort: Array<FtSearchSortCriterion>;
|
|
157
|
+
uiLocale?: string;
|
|
158
|
+
contentLocale?: string;
|
|
159
|
+
facets: Array<FtSearchFacetConf>;
|
|
160
|
+
}
|
|
161
|
+
export declare const isFtSearchRequest: (o: any) => o is FtSearchRequest;
|
|
162
|
+
export interface FtSearchResultCluster {
|
|
163
|
+
entries: Array<FtSearchResultClusterEntry>;
|
|
164
|
+
metadataVariableAxis?: string;
|
|
165
|
+
}
|
|
166
|
+
export declare const isFtSearchResultCluster: (o: any) => o is FtSearchResultCluster;
|
|
167
|
+
export interface FtSearchResultClusterEntry {
|
|
168
|
+
document?: FtSearchResultUnstructuredDocument;
|
|
169
|
+
topic?: FtSearchResultTopic;
|
|
170
|
+
type: FtSearchResultType;
|
|
171
|
+
map?: FtSearchResultMap;
|
|
172
|
+
}
|
|
173
|
+
export declare const isFtSearchResultClusterEntry: (o: any) => o is FtSearchResultClusterEntry;
|
|
174
|
+
export interface FtSearchResultUnstructuredDocument {
|
|
175
|
+
metadata: Array<FtMetadata>;
|
|
176
|
+
openMode: FtOpenMode;
|
|
177
|
+
documentUrl: string;
|
|
178
|
+
mimeType: string;
|
|
179
|
+
source: any;
|
|
180
|
+
title: string;
|
|
181
|
+
lastPublicationDate?: string;
|
|
182
|
+
viewerUrl: string;
|
|
183
|
+
contentUrl: string;
|
|
184
|
+
filename: string;
|
|
185
|
+
htmlTitle: string;
|
|
186
|
+
originUrl?: string;
|
|
187
|
+
documentId: string;
|
|
188
|
+
lastEditionDate: string;
|
|
189
|
+
htmlExcerpt: string;
|
|
190
|
+
}
|
|
191
|
+
export declare const isFtSearchResultUnstructuredDocument: (o: any) => o is FtSearchResultUnstructuredDocument;
|
|
192
|
+
export interface FtSearchResultMap {
|
|
193
|
+
metadata: Array<FtMetadata>;
|
|
194
|
+
openMode: FtOpenMode;
|
|
195
|
+
editorialType: FtEditorialType;
|
|
196
|
+
source?: any;
|
|
197
|
+
title: string;
|
|
198
|
+
lastPublicationDate?: string;
|
|
199
|
+
htmlTitle: string;
|
|
200
|
+
originUrl?: string;
|
|
201
|
+
mapUrl: string;
|
|
202
|
+
readerUrl: string;
|
|
203
|
+
mapId: string;
|
|
204
|
+
lastEditionDate?: string;
|
|
205
|
+
htmlExcerpt: string;
|
|
206
|
+
}
|
|
207
|
+
export declare const isFtSearchResultMap: (o: any) => o is FtSearchResultMap;
|
|
208
|
+
export interface FtSearchResultTopic {
|
|
209
|
+
metadata: Array<FtMetadata>;
|
|
210
|
+
openMode: FtOpenMode;
|
|
211
|
+
contentId: string;
|
|
212
|
+
resources: Array<FtTopicResource>;
|
|
213
|
+
source?: any;
|
|
214
|
+
title: string;
|
|
215
|
+
mapTitle: string;
|
|
216
|
+
topicUrl: string;
|
|
217
|
+
contentUrl: string;
|
|
218
|
+
htmlTitle: string;
|
|
219
|
+
breadcrumb: Array<string>;
|
|
220
|
+
tocId: string;
|
|
221
|
+
originUrl?: string;
|
|
222
|
+
readerUrl: string;
|
|
223
|
+
mapId: string;
|
|
224
|
+
lastEditionDate?: string;
|
|
225
|
+
htmlExcerpt: string;
|
|
226
|
+
}
|
|
227
|
+
export declare const isFtSearchResultTopic: (o: any) => o is FtSearchResultTopic;
|
|
103
228
|
export declare enum FtSearchResultType {
|
|
104
229
|
MAP = "MAP",
|
|
105
230
|
DOCUMENT = "DOCUMENT",
|
|
106
231
|
TOPIC = "TOPIC"
|
|
107
232
|
}
|
|
108
233
|
export declare const isFtSearchResultType: (o: any) => o is FtSearchResultType;
|
|
234
|
+
export interface FtSearchFacet {
|
|
235
|
+
hierarchical: boolean;
|
|
236
|
+
label: string;
|
|
237
|
+
multiSelectionable: boolean;
|
|
238
|
+
key: string;
|
|
239
|
+
rootNodes: Array<FtSearchFacetEntry>;
|
|
240
|
+
}
|
|
241
|
+
export declare const isFtSearchFacet: (o: any) => o is FtSearchFacet;
|
|
242
|
+
export interface FtSearchFacetConf {
|
|
243
|
+
maxDepth?: number;
|
|
244
|
+
id: string;
|
|
245
|
+
}
|
|
246
|
+
export declare const isFtSearchFacetConf: (o: any) => o is FtSearchFacetConf;
|
|
247
|
+
export interface FtSearchFacetEntry {
|
|
248
|
+
totalResultsCount: number;
|
|
249
|
+
descendantSelected: boolean;
|
|
250
|
+
childNodes: Array<FtSearchFacetEntry>;
|
|
251
|
+
label: string;
|
|
252
|
+
value: string;
|
|
253
|
+
selected: boolean;
|
|
254
|
+
}
|
|
255
|
+
export declare const isFtSearchFacetEntry: (o: any) => o is FtSearchFacetEntry;
|
|
256
|
+
export interface FtSearchSortCriterion {
|
|
257
|
+
type: any;
|
|
258
|
+
key: string;
|
|
259
|
+
order: any;
|
|
260
|
+
}
|
|
261
|
+
export declare const isFtSearchSortCriterion: (o: any) => o is FtSearchSortCriterion;
|
|
262
|
+
export interface FtSpellcheck {
|
|
263
|
+
suggestedQuery: string;
|
|
264
|
+
htmlSuggestedQuery: string;
|
|
265
|
+
}
|
|
266
|
+
export declare const isFtSpellcheck: (o: any) => o is FtSpellcheck;
|
|
267
|
+
export interface FtTopicResource {
|
|
268
|
+
filename: string;
|
|
269
|
+
resourceUrl: string;
|
|
270
|
+
id: string;
|
|
271
|
+
mimeType: string;
|
|
272
|
+
resourceContentUrl: string;
|
|
273
|
+
viewerUrl: string;
|
|
274
|
+
}
|
|
275
|
+
export declare const isFtTopicResource: (o: any) => o is FtTopicResource;
|
|
276
|
+
export interface FtSuggestRequest {
|
|
277
|
+
input: string;
|
|
278
|
+
filters: Array<FtSearchFilter>;
|
|
279
|
+
sort: Array<FtSearchSortCriterion>;
|
|
280
|
+
maxCount?: number;
|
|
281
|
+
contentLocale?: string;
|
|
282
|
+
}
|
|
283
|
+
export declare const isFtSuggestRequest: (o: any) => o is FtSuggestRequest;
|
|
284
|
+
export interface FtSuggestResult {
|
|
285
|
+
filenameExtension?: string;
|
|
286
|
+
editorialType?: FtEditorialType;
|
|
287
|
+
mimeType?: string;
|
|
288
|
+
type: FtSearchResultType;
|
|
289
|
+
value: string;
|
|
290
|
+
}
|
|
291
|
+
export declare const isFtSuggestResult: (o: any) => o is FtSuggestResult;
|
|
292
|
+
export interface FtSuggestResults {
|
|
293
|
+
suggestions: Array<FtSuggestResult>;
|
|
294
|
+
}
|
|
295
|
+
export declare const isFtSuggestResults: (o: any) => o is FtSuggestResults;
|
|
109
296
|
export interface FtAuthenticationIdentifier {
|
|
110
297
|
identifier: string;
|
|
111
298
|
realm: string;
|
|
@@ -16,7 +16,7 @@ export const isFtCollectionDocument = (o) => {
|
|
|
16
16
|
&& (o.portalUrl == null || isString(o.portalUrl))
|
|
17
17
|
&& (isString(o.id))
|
|
18
18
|
&& (isString(o.title))
|
|
19
|
-
&& (
|
|
19
|
+
&& (isFtCollectionDocumentType(o.type));
|
|
20
20
|
};
|
|
21
21
|
export const isFtMap = (o) => {
|
|
22
22
|
return isObject(o)
|
|
@@ -89,6 +89,17 @@ export var FtTopicContentTarget;
|
|
|
89
89
|
export const isFtTopicContentTarget = (o) => {
|
|
90
90
|
return ["THIRD_PARTY", "OFF_THE_GRID"].includes(o);
|
|
91
91
|
};
|
|
92
|
+
export const isFtSearchLocale = (o) => {
|
|
93
|
+
return isObject(o)
|
|
94
|
+
&& (isNumber(o.count))
|
|
95
|
+
&& (isString(o.label))
|
|
96
|
+
&& (o.lang == null || isString(o.lang));
|
|
97
|
+
};
|
|
98
|
+
export const isFtSearchLocales = (o) => {
|
|
99
|
+
return isObject(o)
|
|
100
|
+
&& ((Array.isArray(o.contentLocales)
|
|
101
|
+
&& o.contentLocales.every((v) => isFtSearchLocale(v))));
|
|
102
|
+
};
|
|
92
103
|
export const isFtMetadata = (o) => {
|
|
93
104
|
return isObject(o)
|
|
94
105
|
&& ((Array.isArray(o.values)
|
|
@@ -103,6 +114,27 @@ export const isFtMapResource = (o) => {
|
|
|
103
114
|
&& (isString(o.id))
|
|
104
115
|
&& (isString(o.mimeType));
|
|
105
116
|
};
|
|
117
|
+
export const isFtSearchFilter = (o) => {
|
|
118
|
+
return isObject(o)
|
|
119
|
+
&& (isBoolean(o.negative))
|
|
120
|
+
&& ((Array.isArray(o.values)
|
|
121
|
+
&& o.values.every((v) => isString(v))))
|
|
122
|
+
&& (isString(o.key));
|
|
123
|
+
};
|
|
124
|
+
export const isFtSearchPreset = (o) => {
|
|
125
|
+
return isObject(o)
|
|
126
|
+
&& (isString(o.name))
|
|
127
|
+
&& ((Array.isArray(o.filters)
|
|
128
|
+
&& o.filters.every((v) => isFtSearchFilter(v))))
|
|
129
|
+
&& (o.contentLocale == null || isString(o.contentLocale));
|
|
130
|
+
};
|
|
131
|
+
export const isFtSearchResultsPageInfo = (o) => {
|
|
132
|
+
return isObject(o)
|
|
133
|
+
&& (isNumber(o.totalResultsCount))
|
|
134
|
+
&& (isBoolean(o.lastPage))
|
|
135
|
+
&& (isNumber(o.currentPage))
|
|
136
|
+
&& (isNumber(o.totalClustersCount));
|
|
137
|
+
};
|
|
106
138
|
// From: WsEditorialType
|
|
107
139
|
export var FtEditorialType;
|
|
108
140
|
(function (FtEditorialType) {
|
|
@@ -121,6 +153,114 @@ export var FtOpenMode;
|
|
|
121
153
|
export const isFtOpenMode = (o) => {
|
|
122
154
|
return ["FLUIDTOPICS", "EXTERNAL"].includes(o);
|
|
123
155
|
};
|
|
156
|
+
export const isFtPageRequest = (o) => {
|
|
157
|
+
return isObject(o)
|
|
158
|
+
&& (o.perPage == null || isNumber(o.perPage))
|
|
159
|
+
&& (isNumber(o.page));
|
|
160
|
+
};
|
|
161
|
+
// From: WsPublicCollectionDocumentType
|
|
162
|
+
export var FtCollectionDocumentType;
|
|
163
|
+
(function (FtCollectionDocumentType) {
|
|
164
|
+
FtCollectionDocumentType["MAP"] = "MAP";
|
|
165
|
+
FtCollectionDocumentType["DOCUMENT"] = "DOCUMENT";
|
|
166
|
+
FtCollectionDocumentType["TOPIC"] = "TOPIC";
|
|
167
|
+
FtCollectionDocumentType["PERSONAL_BOOK"] = "PERSONAL_BOOK";
|
|
168
|
+
FtCollectionDocumentType["SHARED_BOOK"] = "SHARED_BOOK";
|
|
169
|
+
})(FtCollectionDocumentType || (FtCollectionDocumentType = {}));
|
|
170
|
+
export const isFtCollectionDocumentType = (o) => {
|
|
171
|
+
return ["MAP", "DOCUMENT", "TOPIC", "PERSONAL_BOOK", "SHARED_BOOK"].includes(o);
|
|
172
|
+
};
|
|
173
|
+
export const isFtSearchResults = (o) => {
|
|
174
|
+
return isObject(o)
|
|
175
|
+
&& (o.spellcheck == null || isFtSpellcheck(o.spellcheck))
|
|
176
|
+
&& (isFtSearchResultsPageInfo(o.paging))
|
|
177
|
+
&& ((Array.isArray(o.results)
|
|
178
|
+
&& o.results.every((v) => isFtSearchResultCluster(v))))
|
|
179
|
+
&& ((Array.isArray(o.facets)
|
|
180
|
+
&& o.facets.every((v) => isFtSearchFacet(v))));
|
|
181
|
+
};
|
|
182
|
+
export const isFtSearchRequest = (o) => {
|
|
183
|
+
return isObject(o)
|
|
184
|
+
&& (isString(o.query))
|
|
185
|
+
&& (isFtPageRequest(o.paging))
|
|
186
|
+
&& ((Array.isArray(o.filters)
|
|
187
|
+
&& o.filters.every((v) => isFtSearchFilter(v))))
|
|
188
|
+
&& ((Array.isArray(o.sort)
|
|
189
|
+
&& o.sort.every((v) => isFtSearchSortCriterion(v))))
|
|
190
|
+
&& (o.uiLocale == null || isString(o.uiLocale))
|
|
191
|
+
&& (o.contentLocale == null || isString(o.contentLocale))
|
|
192
|
+
&& ((Array.isArray(o.facets)
|
|
193
|
+
&& o.facets.every((v) => isFtSearchFacetConf(v))));
|
|
194
|
+
};
|
|
195
|
+
export const isFtSearchResultCluster = (o) => {
|
|
196
|
+
return isObject(o)
|
|
197
|
+
&& ((Array.isArray(o.entries)
|
|
198
|
+
&& o.entries.every((v) => isFtSearchResultClusterEntry(v))))
|
|
199
|
+
&& (o.metadataVariableAxis == null || isString(o.metadataVariableAxis));
|
|
200
|
+
};
|
|
201
|
+
export const isFtSearchResultClusterEntry = (o) => {
|
|
202
|
+
return isObject(o)
|
|
203
|
+
&& (o.document == null || isFtSearchResultUnstructuredDocument(o.document))
|
|
204
|
+
&& (o.topic == null || isFtSearchResultTopic(o.topic))
|
|
205
|
+
&& (isFtSearchResultType(o.type))
|
|
206
|
+
&& (o.map == null || isFtSearchResultMap(o.map));
|
|
207
|
+
};
|
|
208
|
+
export const isFtSearchResultUnstructuredDocument = (o) => {
|
|
209
|
+
return isObject(o)
|
|
210
|
+
&& ((Array.isArray(o.metadata)
|
|
211
|
+
&& o.metadata.every((v) => isFtMetadata(v))))
|
|
212
|
+
&& (isFtOpenMode(o.openMode))
|
|
213
|
+
&& (isString(o.documentUrl))
|
|
214
|
+
&& (isString(o.mimeType))
|
|
215
|
+
&& (isString(o.title))
|
|
216
|
+
&& (o.lastPublicationDate == null || isString(o.lastPublicationDate))
|
|
217
|
+
&& (isString(o.viewerUrl))
|
|
218
|
+
&& (isString(o.contentUrl))
|
|
219
|
+
&& (isString(o.filename))
|
|
220
|
+
&& (isString(o.htmlTitle))
|
|
221
|
+
&& (o.originUrl == null || isString(o.originUrl))
|
|
222
|
+
&& (isString(o.documentId))
|
|
223
|
+
&& (isString(o.lastEditionDate))
|
|
224
|
+
&& (isString(o.htmlExcerpt));
|
|
225
|
+
};
|
|
226
|
+
export const isFtSearchResultMap = (o) => {
|
|
227
|
+
return isObject(o)
|
|
228
|
+
&& ((Array.isArray(o.metadata)
|
|
229
|
+
&& o.metadata.every((v) => isFtMetadata(v))))
|
|
230
|
+
&& (isFtOpenMode(o.openMode))
|
|
231
|
+
&& (isFtEditorialType(o.editorialType))
|
|
232
|
+
&& (isString(o.title))
|
|
233
|
+
&& (o.lastPublicationDate == null || isString(o.lastPublicationDate))
|
|
234
|
+
&& (isString(o.htmlTitle))
|
|
235
|
+
&& (o.originUrl == null || isString(o.originUrl))
|
|
236
|
+
&& (isString(o.mapUrl))
|
|
237
|
+
&& (isString(o.readerUrl))
|
|
238
|
+
&& (isString(o.mapId))
|
|
239
|
+
&& (o.lastEditionDate == null || isString(o.lastEditionDate))
|
|
240
|
+
&& (isString(o.htmlExcerpt));
|
|
241
|
+
};
|
|
242
|
+
export const isFtSearchResultTopic = (o) => {
|
|
243
|
+
return isObject(o)
|
|
244
|
+
&& ((Array.isArray(o.metadata)
|
|
245
|
+
&& o.metadata.every((v) => isFtMetadata(v))))
|
|
246
|
+
&& (isFtOpenMode(o.openMode))
|
|
247
|
+
&& (isString(o.contentId))
|
|
248
|
+
&& ((Array.isArray(o.resources)
|
|
249
|
+
&& o.resources.every((v) => isFtTopicResource(v))))
|
|
250
|
+
&& (isString(o.title))
|
|
251
|
+
&& (isString(o.mapTitle))
|
|
252
|
+
&& (isString(o.topicUrl))
|
|
253
|
+
&& (isString(o.contentUrl))
|
|
254
|
+
&& (isString(o.htmlTitle))
|
|
255
|
+
&& ((Array.isArray(o.breadcrumb)
|
|
256
|
+
&& o.breadcrumb.every((v) => isString(v))))
|
|
257
|
+
&& (isString(o.tocId))
|
|
258
|
+
&& (o.originUrl == null || isString(o.originUrl))
|
|
259
|
+
&& (isString(o.readerUrl))
|
|
260
|
+
&& (isString(o.mapId))
|
|
261
|
+
&& (o.lastEditionDate == null || isString(o.lastEditionDate))
|
|
262
|
+
&& (isString(o.htmlExcerpt));
|
|
263
|
+
};
|
|
124
264
|
// From: WsPublicSearchResultType
|
|
125
265
|
export var FtSearchResultType;
|
|
126
266
|
(function (FtSearchResultType) {
|
|
@@ -131,6 +271,71 @@ export var FtSearchResultType;
|
|
|
131
271
|
export const isFtSearchResultType = (o) => {
|
|
132
272
|
return ["MAP", "DOCUMENT", "TOPIC"].includes(o);
|
|
133
273
|
};
|
|
274
|
+
export const isFtSearchFacet = (o) => {
|
|
275
|
+
return isObject(o)
|
|
276
|
+
&& (isBoolean(o.hierarchical))
|
|
277
|
+
&& (isString(o.label))
|
|
278
|
+
&& (isBoolean(o.multiSelectionable))
|
|
279
|
+
&& (isString(o.key))
|
|
280
|
+
&& ((Array.isArray(o.rootNodes)
|
|
281
|
+
&& o.rootNodes.every((v) => isFtSearchFacetEntry(v))));
|
|
282
|
+
};
|
|
283
|
+
export const isFtSearchFacetConf = (o) => {
|
|
284
|
+
return isObject(o)
|
|
285
|
+
&& (o.maxDepth == null || isNumber(o.maxDepth))
|
|
286
|
+
&& (isString(o.id));
|
|
287
|
+
};
|
|
288
|
+
export const isFtSearchFacetEntry = (o) => {
|
|
289
|
+
return isObject(o)
|
|
290
|
+
&& (isNumber(o.totalResultsCount))
|
|
291
|
+
&& (isBoolean(o.descendantSelected))
|
|
292
|
+
&& ((Array.isArray(o.childNodes)
|
|
293
|
+
&& o.childNodes.every((v) => isFtSearchFacetEntry(v))))
|
|
294
|
+
&& (isString(o.label))
|
|
295
|
+
&& (isString(o.value))
|
|
296
|
+
&& (isBoolean(o.selected));
|
|
297
|
+
};
|
|
298
|
+
export const isFtSearchSortCriterion = (o) => {
|
|
299
|
+
return isObject(o)
|
|
300
|
+
&& (isString(o.key));
|
|
301
|
+
};
|
|
302
|
+
export const isFtSpellcheck = (o) => {
|
|
303
|
+
return isObject(o)
|
|
304
|
+
&& (isString(o.suggestedQuery))
|
|
305
|
+
&& (isString(o.htmlSuggestedQuery));
|
|
306
|
+
};
|
|
307
|
+
export const isFtTopicResource = (o) => {
|
|
308
|
+
return isObject(o)
|
|
309
|
+
&& (isString(o.filename))
|
|
310
|
+
&& (isString(o.resourceUrl))
|
|
311
|
+
&& (isString(o.id))
|
|
312
|
+
&& (isString(o.mimeType))
|
|
313
|
+
&& (isString(o.resourceContentUrl))
|
|
314
|
+
&& (isString(o.viewerUrl));
|
|
315
|
+
};
|
|
316
|
+
export const isFtSuggestRequest = (o) => {
|
|
317
|
+
return isObject(o)
|
|
318
|
+
&& (isString(o.input))
|
|
319
|
+
&& ((Array.isArray(o.filters)
|
|
320
|
+
&& o.filters.every((v) => isFtSearchFilter(v))))
|
|
321
|
+
&& ((Array.isArray(o.sort)
|
|
322
|
+
&& o.sort.every((v) => isFtSearchSortCriterion(v))))
|
|
323
|
+
&& (o.maxCount == null || isNumber(o.maxCount))
|
|
324
|
+
&& (o.contentLocale == null || isString(o.contentLocale));
|
|
325
|
+
};
|
|
326
|
+
export const isFtSuggestResult = (o) => {
|
|
327
|
+
return isObject(o)
|
|
328
|
+
&& (o.filenameExtension == null || isString(o.filenameExtension))
|
|
329
|
+
&& (o.editorialType == null || isFtEditorialType(o.editorialType))
|
|
330
|
+
&& (o.mimeType == null || isString(o.mimeType))
|
|
331
|
+
&& (isFtSearchResultType(o.type))
|
|
332
|
+
&& (isString(o.value));
|
|
333
|
+
};
|
|
334
|
+
export const isFtSuggestResults = (o) => {
|
|
335
|
+
return isObject(o)
|
|
336
|
+
&& ((Array.isArray(o.suggestions)
|
|
337
|
+
&& o.suggestions.every((v) => isFtSuggestResult(v))));
|
|
338
|
+
};
|
|
134
339
|
export const isFtAuthenticationIdentifier = (o) => {
|
|
135
340
|
return isObject(o)
|
|
136
341
|
&& (isString(o.identifier))
|