@fluid-topics/public-api 1.0.8 → 1.0.12

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 CHANGED
@@ -20,7 +20,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
20
20
  };
21
21
  Object.defineProperty(exports, "__esModule", { value: true });
22
22
  exports.FluidTopicsApi = void 0;
23
- const cross_fetch_1 = require("cross-fetch");
23
+ require("cross-fetch/polyfill");
24
24
  __exportStar(require("./types/ft-common/public"), exports);
25
25
  __exportStar(require("./types/ft-server/public"), exports);
26
26
  function toBase64(s) {
@@ -28,9 +28,8 @@ function toBase64(s) {
28
28
  }
29
29
  function handleError(response) {
30
30
  return __awaiter(this, void 0, void 0, function* () {
31
- if (response.status < 200 || response.status >= 400) {
32
- console.error("Fluid Topics server returned an error: ", yield getBody(response));
33
- throw new Error(`${response.status}: ${response.statusText}`);
31
+ if (!response.ok) {
32
+ throw new Error(`${response.status} - ${response.statusText}: ${yield response.text()}`);
34
33
  }
35
34
  return response;
36
35
  });
@@ -47,6 +46,9 @@ class FluidTopicsApi {
47
46
  get defaultHeaders() {
48
47
  return Object.assign(Object.assign({}, this.authorization), { "Ft-Calling-App": this.ftCallingApp });
49
48
  }
49
+ setApiKey(apiKey) {
50
+ this.authorization = { "Authorization": "Bearer " + apiKey };
51
+ }
50
52
  setCredentials(login, password) {
51
53
  this.authorization = { "Authorization": "Basic " + toBase64(`${login}:${password}`) };
52
54
  }
@@ -78,14 +80,14 @@ class FluidTopicsApi {
78
80
  getTopic(mapId, topicContentId) {
79
81
  return this.get(`/api/khub/maps/${mapId}/topics/${topicContentId}`);
80
82
  }
81
- getTopicHTMLContent(mapId, topicContentId) {
82
- return this.get(`/api/khub/maps/${mapId}/topics/${topicContentId}/content`);
83
+ getTopicHTMLContent(mapId, topicContentId, target) {
84
+ return this.get(`/api/khub/maps/${mapId}/topics/${topicContentId}/content${target ? "?target=" + target : ""}`);
83
85
  }
84
86
  getMapAttachments(mapId) {
85
87
  return this.get(`/api/khub/maps/${mapId}/attachments`);
86
88
  }
87
89
  getMapAttachmentContent(mapId, attachmentId) {
88
- return this.fetchRawData(`/api/khub/maps/${mapId}/attachments/${attachmentId}`);
90
+ return this.fetchRawData(`/api/khub/maps/${mapId}/attachments/${attachmentId}/content`);
89
91
  }
90
92
  getMapResources(mapId) {
91
93
  return this.get(`/api/khub/maps/${mapId}/resources`);
@@ -99,32 +101,54 @@ class FluidTopicsApi {
99
101
  getUnstructuredDocumentContent(documentId) {
100
102
  return this.fetchRawData(`/api/khub/documents/${documentId}/content`);
101
103
  }
104
+ getUnstructuredDocumentTextContent(documentId) {
105
+ return this.get(`/api/khub/documents/${documentId}/content/text`);
106
+ }
102
107
  getCollectionDocuments(userId, collectionId) {
103
108
  return this.get(`/api/users/${userId}/collections/${collectionId}/documents`);
104
109
  }
110
+ getSuggestions(request) {
111
+ return this.post("/api/khub/suggest", request);
112
+ }
113
+ search(request) {
114
+ return this.post("/api/khub/clustered-search", request);
115
+ }
116
+ getAvailableSearchLocales() {
117
+ return this.get("/api/khub/locales");
118
+ }
105
119
  get(endpoint) {
106
- return this.fetch("GET", endpoint);
120
+ return this.makeRequest("GET", endpoint);
107
121
  }
108
122
  post(endpoint, data) {
109
- return this.fetch("POST", endpoint, data);
123
+ return this.makeRequest("POST", endpoint, data);
110
124
  }
111
125
  put(endpoint, data) {
112
- return this.fetch("PUT", endpoint, data);
126
+ return this.makeRequest("PUT", endpoint, data);
113
127
  }
114
128
  delete(endpoint) {
115
- return this.fetch("DELETE", endpoint);
129
+ return this.makeRequest("DELETE", endpoint);
130
+ }
131
+ fetch(endpoint, init) {
132
+ var _a;
133
+ return __awaiter(this, void 0, void 0, function* () {
134
+ const requestInit = init;
135
+ if (!endpoint.startsWith("/")) {
136
+ endpoint = "/" + endpoint;
137
+ }
138
+ 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
+ });
116
140
  }
117
- fetch(method, endpoint, data) {
118
- return (0, cross_fetch_1.default)(this.tenantBaseUrl + endpoint, {
141
+ makeRequest(method, endpoint, data) {
142
+ return this.fetch(endpoint, {
119
143
  method: method,
120
- headers: Object.assign(Object.assign({}, this.defaultHeaders), (data != null ? { "Content-Type": "application/json" } : {})),
144
+ headers: Object.assign({}, (data != null ? { "Content-Type": "application/json" } : {})),
121
145
  body: data != null ? JSON.stringify(data) : undefined
122
146
  })
123
147
  .then(handleError)
124
148
  .then(getBody);
125
149
  }
126
150
  fetchRawData(endpoint) {
127
- return (0, cross_fetch_1.default)(this.tenantBaseUrl + endpoint, { headers: this.defaultHeaders })
151
+ return fetch(this.tenantBaseUrl + endpoint, { headers: this.defaultHeaders })
128
152
  .then(handleError)
129
153
  .then(response => response.arrayBuffer());
130
154
  }
@@ -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.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.isFtPageRequest = exports.isFtOpenMode = exports.FtOpenMode = exports.isFtEditorialType = exports.FtEditorialType = 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";
@@ -89,6 +89,29 @@ const isFtUnstructuredDocument = (o) => {
89
89
  && (o.lang == null || isString(o.lang));
90
90
  };
91
91
  exports.isFtUnstructuredDocument = isFtUnstructuredDocument;
92
+ // From: WsTopicContentTarget
93
+ var FtTopicContentTarget;
94
+ (function (FtTopicContentTarget) {
95
+ FtTopicContentTarget["THIRD_PARTY"] = "THIRD_PARTY";
96
+ FtTopicContentTarget["OFF_THE_GRID"] = "OFF_THE_GRID";
97
+ })(FtTopicContentTarget = exports.FtTopicContentTarget || (exports.FtTopicContentTarget = {}));
98
+ const isFtTopicContentTarget = (o) => {
99
+ return ["THIRD_PARTY", "OFF_THE_GRID"].includes(o);
100
+ };
101
+ exports.isFtTopicContentTarget = isFtTopicContentTarget;
102
+ const isFtSearchLocale = (o) => {
103
+ return isObject(o)
104
+ && (isNumber(o.count))
105
+ && (isString(o.label))
106
+ && (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;
92
115
  const isFtMetadata = (o) => {
93
116
  return isObject(o)
94
117
  && ((Array.isArray(o.values)
@@ -105,6 +128,14 @@ const isFtMapResource = (o) => {
105
128
  && (isString(o.mimeType));
106
129
  };
107
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;
108
139
  // From: WsEditorialType
109
140
  var FtEditorialType;
110
141
  (function (FtEditorialType) {
@@ -125,6 +156,109 @@ const isFtOpenMode = (o) => {
125
156
  return ["FLUIDTOPICS", "EXTERNAL"].includes(o);
126
157
  };
127
158
  exports.isFtOpenMode = isFtOpenMode;
159
+ const isFtPageRequest = (o) => {
160
+ return isObject(o)
161
+ && (o.perPage == null || isNumber(o.perPage))
162
+ && (isNumber(o.page));
163
+ };
164
+ exports.isFtPageRequest = isFtPageRequest;
165
+ const isFtSearchResults = (o) => {
166
+ return isObject(o)
167
+ && (o.spellcheck == null || (0, exports.isFtSpellcheck)(o.spellcheck))
168
+ && ((Array.isArray(o.results)
169
+ && o.results.every((v) => (0, exports.isFtSearchResultCluster)(v))))
170
+ && ((Array.isArray(o.facets)
171
+ && o.facets.every((v) => (0, exports.isFtSearchFacet)(v))));
172
+ };
173
+ exports.isFtSearchResults = isFtSearchResults;
174
+ const isFtSearchRequest = (o) => {
175
+ return isObject(o)
176
+ && (isString(o.query))
177
+ && ((0, exports.isFtPageRequest)(o.paging))
178
+ && ((Array.isArray(o.filters)
179
+ && o.filters.every((v) => (0, exports.isFtSearchFilter)(v))))
180
+ && ((Array.isArray(o.sort)
181
+ && o.sort.every((v) => (0, exports.isFtSearchSortCriterion)(v))))
182
+ && (o.uiLocale == null || isString(o.uiLocale))
183
+ && (o.contentLocale == null || isString(o.contentLocale))
184
+ && ((Array.isArray(o.facets)
185
+ && o.facets.every((v) => (0, exports.isFtSearchFacetConf)(v))));
186
+ };
187
+ exports.isFtSearchRequest = isFtSearchRequest;
188
+ const isFtSearchResultCluster = (o) => {
189
+ return isObject(o)
190
+ && ((Array.isArray(o.entries)
191
+ && o.entries.every((v) => (0, exports.isFtSearchResultClusterEntry)(v))))
192
+ && (o.metadataVariableAxis == null || isString(o.metadataVariableAxis));
193
+ };
194
+ exports.isFtSearchResultCluster = isFtSearchResultCluster;
195
+ const isFtSearchResultClusterEntry = (o) => {
196
+ return isObject(o)
197
+ && (o.document == null || (0, exports.isFtSearchResultUnstructuredDocument)(o.document))
198
+ && (o.topic == null || (0, exports.isFtSearchResultTopic)(o.topic))
199
+ && ((0, exports.isFtSearchResultType)(o.type))
200
+ && (o.map == null || (0, exports.isFtSearchResultMap)(o.map));
201
+ };
202
+ exports.isFtSearchResultClusterEntry = isFtSearchResultClusterEntry;
203
+ const isFtSearchResultUnstructuredDocument = (o) => {
204
+ return isObject(o)
205
+ && ((Array.isArray(o.metadata)
206
+ && o.metadata.every((v) => (0, exports.isFtMetadata)(v))))
207
+ && ((0, exports.isFtOpenMode)(o.openMode))
208
+ && (isString(o.documentUrl))
209
+ && (isString(o.mimeType))
210
+ && (isString(o.title))
211
+ && (o.lastPublicationDate == null || isString(o.lastPublicationDate))
212
+ && (isString(o.viewerUrl))
213
+ && (isString(o.contentUrl))
214
+ && (isString(o.filename))
215
+ && (isString(o.htmlTitle))
216
+ && (o.originUrl == null || isString(o.originUrl))
217
+ && (isString(o.documentId))
218
+ && (isString(o.lastEditionDate))
219
+ && (isString(o.htmlExcerpt));
220
+ };
221
+ exports.isFtSearchResultUnstructuredDocument = isFtSearchResultUnstructuredDocument;
222
+ const isFtSearchResultMap = (o) => {
223
+ return isObject(o)
224
+ && ((Array.isArray(o.metadata)
225
+ && o.metadata.every((v) => (0, exports.isFtMetadata)(v))))
226
+ && ((0, exports.isFtOpenMode)(o.openMode))
227
+ && ((0, exports.isFtEditorialType)(o.editorialType))
228
+ && (isString(o.title))
229
+ && (o.lastPublicationDate == null || isString(o.lastPublicationDate))
230
+ && (isString(o.htmlTitle))
231
+ && (o.originUrl == null || isString(o.originUrl))
232
+ && (isString(o.mapUrl))
233
+ && (isString(o.readerUrl))
234
+ && (isString(o.mapId))
235
+ && (o.lastEditionDate == null || isString(o.lastEditionDate))
236
+ && (isString(o.htmlExcerpt));
237
+ };
238
+ exports.isFtSearchResultMap = isFtSearchResultMap;
239
+ const isFtSearchResultTopic = (o) => {
240
+ return isObject(o)
241
+ && ((Array.isArray(o.metadata)
242
+ && o.metadata.every((v) => (0, exports.isFtMetadata)(v))))
243
+ && ((0, exports.isFtOpenMode)(o.openMode))
244
+ && (isString(o.contentId))
245
+ && ((Array.isArray(o.resources)
246
+ && o.resources.every((v) => (0, exports.isFtTopicResource)(v))))
247
+ && (isString(o.title))
248
+ && (isString(o.mapTitle))
249
+ && (isString(o.topicUrl))
250
+ && (isString(o.contentUrl))
251
+ && (isString(o.htmlTitle))
252
+ && ((Array.isArray(o.breadcrumb)
253
+ && o.breadcrumb.every((v) => isString(v))))
254
+ && (isString(o.tocId))
255
+ && (o.originUrl == null || isString(o.originUrl))
256
+ && (isString(o.readerUrl))
257
+ && (isString(o.mapId))
258
+ && (o.lastEditionDate == null || isString(o.lastEditionDate))
259
+ && (isString(o.htmlExcerpt));
260
+ };
261
+ exports.isFtSearchResultTopic = isFtSearchResultTopic;
128
262
  // From: WsPublicSearchResultType
129
263
  var FtSearchResultType;
130
264
  (function (FtSearchResultType) {
@@ -136,6 +270,80 @@ const isFtSearchResultType = (o) => {
136
270
  return ["MAP", "DOCUMENT", "TOPIC"].includes(o);
137
271
  };
138
272
  exports.isFtSearchResultType = isFtSearchResultType;
273
+ const isFtSearchFacet = (o) => {
274
+ return isObject(o)
275
+ && (isBoolean(o.hierarchical))
276
+ && (isString(o.label))
277
+ && (isBoolean(o.multiSelectionable))
278
+ && (isString(o.key))
279
+ && ((Array.isArray(o.rootNodes)
280
+ && o.rootNodes.every((v) => (0, exports.isFtSearchFacetEntry)(v))));
281
+ };
282
+ exports.isFtSearchFacet = isFtSearchFacet;
283
+ const isFtSearchFacetConf = (o) => {
284
+ return isObject(o)
285
+ && (o.maxDepth == null || isNumber(o.maxDepth))
286
+ && (isString(o.id));
287
+ };
288
+ exports.isFtSearchFacetConf = isFtSearchFacetConf;
289
+ const isFtSearchFacetEntry = (o) => {
290
+ return isObject(o)
291
+ && (isNumber(o.totalResultsCount))
292
+ && (isBoolean(o.descendantSelected))
293
+ && ((Array.isArray(o.childNodes)
294
+ && o.childNodes.every((v) => (0, exports.isFtSearchFacetEntry)(v))))
295
+ && (isString(o.label))
296
+ && (isString(o.value))
297
+ && (isBoolean(o.selected));
298
+ };
299
+ exports.isFtSearchFacetEntry = isFtSearchFacetEntry;
300
+ const isFtSearchSortCriterion = (o) => {
301
+ return isObject(o)
302
+ && (isString(o.key));
303
+ };
304
+ exports.isFtSearchSortCriterion = isFtSearchSortCriterion;
305
+ const isFtSpellcheck = (o) => {
306
+ return isObject(o)
307
+ && (isString(o.suggestedQuery))
308
+ && (isString(o.htmlSuggestedQuery));
309
+ };
310
+ exports.isFtSpellcheck = isFtSpellcheck;
311
+ const isFtTopicResource = (o) => {
312
+ return isObject(o)
313
+ && (isString(o.filename))
314
+ && (isString(o.resourceUrl))
315
+ && (isString(o.id))
316
+ && (isString(o.mimeType))
317
+ && (isString(o.resourceContentUrl))
318
+ && (isString(o.viewerUrl));
319
+ };
320
+ exports.isFtTopicResource = isFtTopicResource;
321
+ const isFtSuggestRequest = (o) => {
322
+ return isObject(o)
323
+ && (isString(o.input))
324
+ && ((Array.isArray(o.filters)
325
+ && o.filters.every((v) => (0, exports.isFtSearchFilter)(v))))
326
+ && ((Array.isArray(o.sort)
327
+ && o.sort.every((v) => (0, exports.isFtSearchSortCriterion)(v))))
328
+ && (o.maxCount == null || isNumber(o.maxCount))
329
+ && (o.contentLocale == null || isString(o.contentLocale));
330
+ };
331
+ exports.isFtSuggestRequest = isFtSuggestRequest;
332
+ const isFtSuggestResult = (o) => {
333
+ return isObject(o)
334
+ && (o.filenameExtension == null || isString(o.filenameExtension))
335
+ && (o.editorialType == null || (0, exports.isFtEditorialType)(o.editorialType))
336
+ && (o.mimeType == null || isString(o.mimeType))
337
+ && ((0, exports.isFtSearchResultType)(o.type))
338
+ && (isString(o.value));
339
+ };
340
+ exports.isFtSuggestResult = isFtSuggestResult;
341
+ const isFtSuggestResults = (o) => {
342
+ return isObject(o)
343
+ && ((Array.isArray(o.suggestions)
344
+ && o.suggestions.every((v) => (0, exports.isFtSuggestResult)(v))));
345
+ };
346
+ exports.isFtSuggestResults = isFtSuggestResults;
139
347
  const isFtAuthenticationIdentifier = (o) => {
140
348
  return isObject(o)
141
349
  && (isString(o.identifier))
@@ -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:{};function r(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var n={exports:{}};!function(t,r){var n="undefined"!=typeof self?self:e,i=function(){function t(){this.fetch=!1,this.DOMException=n.DOMException}return t.prototype=n,new t}();!function(t){!function(e){var r="URLSearchParams"in t,n="Symbol"in t&&"iterator"in Symbol,i="FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),o="FormData"in t,s="ArrayBuffer"in t;if(s)var a=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],l=ArrayBuffer.isView||function(t){return t&&a.indexOf(Object.prototype.toString.call(t))>-1};function u(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function p(t){return"string"!=typeof t&&(t=String(t)),t}function d(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return n&&(e[Symbol.iterator]=function(){return e}),e}function h(t){this.map={},t instanceof h?t.forEach((function(t,e){this.append(e,t)}),this):Array.isArray(t)?t.forEach((function(t){this.append(t[0],t[1])}),this):t&&Object.getOwnPropertyNames(t).forEach((function(e){this.append(e,t[e])}),this)}function c(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function f(t){return new Promise((function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}}))}function y(t){var e=new FileReader,r=f(e);return e.readAsArrayBuffer(t),r}function b(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function m(){return this.bodyUsed=!1,this._initBody=function(t){var e;this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:i&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:o&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:r&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():s&&i&&((e=t)&&DataView.prototype.isPrototypeOf(e))?(this._bodyArrayBuffer=b(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):s&&(ArrayBuffer.prototype.isPrototypeOf(t)||l(t))?this._bodyArrayBuffer=b(t):this._bodyText=t=Object.prototype.toString.call(t):this._bodyText="",this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):r&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},i&&(this.blob=function(){var t=c(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?c(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(y)}),this.text=function(){var t,e,r,n=c(this);if(n)return n;if(this._bodyBlob)return t=this._bodyBlob,e=new FileReader,r=f(e),e.readAsText(t),r;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),r=new Array(e.length),n=0;n<e.length;n++)r[n]=String.fromCharCode(e[n]);return r.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},o&&(this.formData=function(){return this.text().then(T)}),this.json=function(){return this.text().then(JSON.parse)},this}h.prototype.append=function(t,e){t=u(t),e=p(e);var r=this.map[t];this.map[t]=r?r+", "+e:e},h.prototype.delete=function(t){delete this.map[u(t)]},h.prototype.get=function(t){return t=u(t),this.has(t)?this.map[t]:null},h.prototype.has=function(t){return this.map.hasOwnProperty(u(t))},h.prototype.set=function(t,e){this.map[u(t)]=p(e)},h.prototype.forEach=function(t,e){for(var r in this.map)this.map.hasOwnProperty(r)&&t.call(e,this.map[r],r,this)},h.prototype.keys=function(){var t=[];return this.forEach((function(e,r){t.push(r)})),d(t)},h.prototype.values=function(){var t=[];return this.forEach((function(e){t.push(e)})),d(t)},h.prototype.entries=function(){var t=[];return this.forEach((function(e,r){t.push([r,e])})),d(t)},n&&(h.prototype[Symbol.iterator]=h.prototype.entries);var g=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function A(t,e){var r,n,i=(e=e||{}).body;if(t instanceof A){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new h(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,i||null==t._bodyInit||(i=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||"same-origin",!e.headers&&this.headers||(this.headers=new h(e.headers)),this.method=(r=e.method||this.method||"GET",n=r.toUpperCase(),g.indexOf(n)>-1?n:r),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&i)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(i)}function T(t){var e=new FormData;return t.trim().split("&").forEach((function(t){if(t){var r=t.split("="),n=r.shift().replace(/\+/g," "),i=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(n),decodeURIComponent(i))}})),e}function w(t,e){e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in e?e.statusText:"OK",this.headers=new h(e.headers),this.url=e.url||"",this._initBody(t)}A.prototype.clone=function(){return new A(this,{body:this._bodyInit})},m.call(A.prototype),m.call(w.prototype),w.prototype.clone=function(){return new w(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new h(this.headers),url:this.url})},w.error=function(){var t=new w(null,{status:0,statusText:""});return t.type="error",t};var E=[301,302,303,307,308];w.redirect=function(t,e){if(-1===E.indexOf(e))throw new RangeError("Invalid status code");return new w(null,{status:e,headers:{location:t}})},e.DOMException=t.DOMException;try{new e.DOMException}catch(t){e.DOMException=function(t,e){this.message=t,this.name=e;var r=Error(t);this.stack=r.stack},e.DOMException.prototype=Object.create(Error.prototype),e.DOMException.prototype.constructor=e.DOMException}function v(t,r){return new Promise((function(n,o){var s=new A(t,r);if(s.signal&&s.signal.aborted)return o(new e.DOMException("Aborted","AbortError"));var a=new XMLHttpRequest;function l(){a.abort()}a.onload=function(){var t,e,r={status:a.status,statusText:a.statusText,headers:(t=a.getAllResponseHeaders()||"",e=new h,t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(t){var r=t.split(":"),n=r.shift().trim();if(n){var i=r.join(":").trim();e.append(n,i)}})),e)};r.url="responseURL"in a?a.responseURL:r.headers.get("X-Request-URL");var i="response"in a?a.response:a.responseText;n(new w(i,r))},a.onerror=function(){o(new TypeError("Network request failed"))},a.ontimeout=function(){o(new TypeError("Network request failed"))},a.onabort=function(){o(new e.DOMException("Aborted","AbortError"))},a.open(s.method,s.url,!0),"include"===s.credentials?a.withCredentials=!0:"omit"===s.credentials&&(a.withCredentials=!1),"responseType"in a&&i&&(a.responseType="blob"),s.headers.forEach((function(t,e){a.setRequestHeader(e,t)})),s.signal&&(s.signal.addEventListener("abort",l),a.onreadystatechange=function(){4===a.readyState&&s.signal.removeEventListener("abort",l)}),a.send(void 0===s._bodyInit?null:s._bodyInit)}))}v.polyfill=!0,t.fetch||(t.fetch=v,t.Headers=h,t.Request=A,t.Response=w),e.Headers=h,e.Request=A,e.Response=w,e.fetch=v,Object.defineProperty(e,"__esModule",{value:!0})}({})}(i),i.fetch.ponyfill=!0,delete i.fetch.polyfill;var o=i;(r=o.fetch).default=o.fetch,r.fetch=o.fetch,r.Headers=o.Headers,r.Request=o.Request,r.Response=o.Response,t.exports=r}(n,n.exports);var i=r(n.exports);const o=t=>"object"==typeof t&&null!=t,s=t=>"boolean"==typeof t,a=t=>"string"==typeof t,l=t=>o(t)&&a(t.tocId)&&Array.isArray(t.children)&&t.children.every((t=>l(t)))&&a(t.contentId)&&a(t.title),u=t=>o(t)&&Array.isArray(t.values)&&t.values.every((t=>a(t)))&&a(t.label)&&a(t.key);var p;t.FtEditorialType=void 0,(p=t.FtEditorialType||(t.FtEditorialType={})).ARTICLE="ARTICLE",p.BOOK="BOOK";const d=t=>["ARTICLE","BOOK"].includes(t);var h;t.FtOpenMode=void 0,(h=t.FtOpenMode||(t.FtOpenMode={})).FLUIDTOPICS="FLUIDTOPICS",h.EXTERNAL="EXTERNAL";const c=t=>["FLUIDTOPICS","EXTERNAL"].includes(t);var f;t.FtSearchResultType=void 0,(f=t.FtSearchResultType||(t.FtSearchResultType={})).MAP="MAP",f.DOCUMENT="DOCUMENT",f.TOPIC="TOPIC";const y=t=>["MAP","DOCUMENT","TOPIC"].includes(t),b=t=>"object"==typeof t&&null!=t,m=t=>"string"==typeof t,g=t=>b(t)&&(null==t.emailAddress||m(t.emailAddress))&&(null==t.displayName||m(t.displayName))&&Array.isArray(t.roles)&&m(t.userId);async function A(t){if(t.status<200||t.status>=400)throw console.error("Fluid Topics server returned an error: ",await T(t)),new Error(`${t.status}: ${t.statusText}`);return t}function T(t){return"application/json"===t.headers.get("Content-Type")?t.json():t.text()}class w{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}`}setCredentials(t,e){var r;this.authorization={Authorization:"Basic "+(r=`${t}:${e}`,"undefined"!=typeof Buffer?Buffer.from(r).toString("base64"):btoa(r))}}clearAuthentication(){this.authorization={}}login(t,e){let r={login:t,password:e,rememberMe:!0};return this.post("/api/authentication/login",r).then((r=>(this.setCredentials(t,e),r)))}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){return this.get(`/api/khub/maps/${t}/topics/${e}/content`)}getMapAttachments(t){return this.get(`/api/khub/maps/${t}/attachments`)}getMapAttachmentContent(t,e){return this.fetchRawData(`/api/khub/maps/${t}/attachments/${e}`)}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`)}getCollectionDocuments(t,e){return this.get(`/api/users/${t}/collections/${e}/documents`)}get(t){return this.fetch("GET",t)}post(t,e){return this.fetch("POST",t,e)}put(t,e){return this.fetch("PUT",t,e)}delete(t){return this.fetch("DELETE",t)}fetch(t,e,r){return i(this.tenantBaseUrl+e,{method:t,headers:{...this.defaultHeaders,...null!=r?{"Content-Type":"application/json"}:{}},body:null!=r?JSON.stringify(r):void 0}).then(A).then(T)}fetchRawData(t){return i(this.tenantBaseUrl+t,{headers:this.defaultHeaders}).then(A).then((t=>t.arrayBuffer()))}}t.FluidTopicsApi=w,t.default=w,t.isFtAuthenticatedSession=t=>b(t)&&g(t.profile),t.isFtAuthenticationIdentifier=t=>o(t)&&a(t.identifier)&&a(t.realm),t.isFtCollectionDocument=t=>o(t)&&s(t.deleted)&&(null==t.apiUrl||a(t.apiUrl))&&(null==t.portalUrl||a(t.portalUrl))&&a(t.id)&&a(t.title)&&y(t.type),t.isFtCredentials=t=>o(t)&&a(t.password)&&(null==t.newPassword||a(t.newPassword))&&s(t.rememberMe)&&a(t.login),t.isFtEditorialType=d,t.isFtMap=t=>o(t)&&(null==t.prettyUrl||a(t.prettyUrl))&&Array.isArray(t.metadata)&&t.metadata.every((t=>u(t)))&&c(t.openMode)&&a(t.topicsApiEndpoint)&&(null==t.description||a(t.description))&&a(t.attachmentsApiEndpoint)&&d(t.editorialType)&&a(t.baseId)&&a(t.clusterId)&&a(t.title)&&a(t.lastPublication)&&a(t.lastEdition)&&a(t.originId)&&a(t.rightsApiEndpoint)&&(null==t.originUrl||a(t.originUrl))&&a(t.readerUrl)&&(null==t.khubVersion||a(t.khubVersion))&&a(t.id)&&(null==t.lang||a(t.lang)),t.isFtMapAttachment=t=>b(t)&&m(t.file)&&(null==t.size||(t=>"number"==typeof t)(t.size))&&(t=>"boolean"==typeof t)(t.externalLink)&&m(t.name)&&m(t.id)&&(null==t.mimeType||m(t.mimeType))&&(null==t.viewerUrl||m(t.viewerUrl)),t.isFtMapResource=t=>o(t)&&a(t.contentUrl)&&a(t.filename)&&a(t.id)&&a(t.mimeType),t.isFtMetadata=u,t.isFtOpenMode=c,t.isFtSearchResultType=y,t.isFtTocNode=l,t.isFtTopic=t=>o(t)&&Array.isArray(t.metadata)&&t.metadata.every((t=>u(t)))&&a(t.id)&&a(t.contentApiEndpoint)&&a(t.title),t.isFtUnstructuredDocument=t=>o(t)&&(null==t.prettyUrl||a(t.prettyUrl))&&Array.isArray(t.metadata)&&t.metadata.every((t=>u(t)))&&a(t.openMode)&&(null==t.description||a(t.description))&&a(t.mimeType)&&(null==t.baseId||a(t.baseId))&&(null==t.clusterId||a(t.clusterId))&&a(t.contentApiEndpoint)&&a(t.title)&&(null==t.lastPublication||a(t.lastPublication))&&a(t.viewerUrl)&&a(t.lastEdition)&&a(t.filename)&&(null==t.originId||a(t.originId))&&a(t.rightsApiEndpoint)&&(null==t.originUrl||a(t.originUrl))&&(null==t.khubVersion||a(t.khubVersion))&&a(t.id)&&(null==t.lang||a(t.lang)),t.isFtUserProfile=g}));
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)&&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);var f;e.FtEditorialType=void 0,(f=e.FtEditorialType||(e.FtEditorialType={})).ARTICLE="ARTICLE",f.BOOK="BOOK";const m=e=>["ARTICLE","BOOK"].includes(e);var g;e.FtOpenMode=void 0,(g=e.FtOpenMode||(e.FtOpenMode={})).FLUIDTOPICS="FLUIDTOPICS",g.EXTERNAL="EXTERNAL";const A=e=>["FLUIDTOPICS","EXTERNAL"].includes(e),T=e=>s(e)&&(null==e.perPage||o(e.perPage))&&o(e.page),b=e=>s(e)&&Array.isArray(e.entries)&&e.entries.every((e=>F(e)))&&(null==e.metadataVariableAxis||u(e.metadataVariableAxis)),F=e=>s(e)&&(null==e.document||R(e.document))&&(null==e.topic||v(e.topic))&&C(e.type)&&(null==e.map||U(e.map)),R=e=>s(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>h(e)))&&A(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),U=e=>s(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>h(e)))&&A(e.openMode)&&m(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),v=e=>s(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>h(e)))&&A(e.openMode)&&u(e.contentId)&&Array.isArray(e.resources)&&e.resources.every((e=>x(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 E;e.FtSearchResultType=void 0,(E=e.FtSearchResultType||(e.FtSearchResultType={})).MAP="MAP",E.DOCUMENT="DOCUMENT",E.TOPIC="TOPIC";const C=e=>["MAP","DOCUMENT","TOPIC"].includes(e),I=e=>s(e)&&l(e.hierarchical)&&u(e.label)&&l(e.multiSelectionable)&&u(e.key)&&Array.isArray(e.rootNodes)&&e.rootNodes.every((e=>S(e))),D=e=>s(e)&&(null==e.maxDepth||o(e.maxDepth))&&u(e.id),S=e=>s(e)&&o(e.totalResultsCount)&&l(e.descendantSelected)&&Array.isArray(e.childNodes)&&e.childNodes.every((e=>S(e)))&&u(e.label)&&u(e.value)&&l(e.selected),k=e=>s(e)&&u(e.key),w=e=>s(e)&&u(e.suggestedQuery)&&u(e.htmlSuggestedQuery),x=e=>s(e)&&u(e.filename)&&u(e.resourceUrl)&&u(e.id)&&u(e.mimeType)&&u(e.resourceContentUrl)&&u(e.viewerUrl),M=e=>s(e)&&(null==e.filenameExtension||u(e.filenameExtension))&&(null==e.editorialType||m(e.editorialType))&&(null==e.mimeType||u(e.mimeType))&&C(e.type)&&u(e.value),P=e=>"object"==typeof e&&null!=e,O=e=>"string"==typeof e,$=e=>P(e)&&(null==e.emailAddress||O(e.emailAddress))&&(null==e.displayName||O(e.displayName))&&Array.isArray(e.roles)&&O(e.userId);async function L(e){if(!e.ok)throw new Error(`${e.status} - ${e.statusText}: ${await e.text()}`);return e}function H(e){return"application/json"===e.headers.get("Content-Type")?e.json():e.text()}class q{tenantBaseUrl;ftCallingApp;authorization={};get defaultHeaders(){return{...this.authorization,"Ft-Calling-App":this.ftCallingApp}}constructor(e,t){this.tenantBaseUrl=e.trim().replace(/\/$/,""),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??{}}})}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(L).then(H)}fetchRawData(e){return fetch(this.tenantBaseUrl+e,{headers:this.defaultHeaders}).then(L).then((e=>e.arrayBuffer()))}}e.FluidTopicsApi=q,e.default=q,e.isFtAuthenticatedSession=e=>P(e)&&$(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)&&C(e.type),e.isFtCredentials=e=>s(e)&&u(e.password)&&(null==e.newPassword||u(e.newPassword))&&l(e.rememberMe)&&u(e.login),e.isFtEditorialType=m,e.isFtMap=e=>s(e)&&(null==e.prettyUrl||u(e.prettyUrl))&&Array.isArray(e.metadata)&&e.metadata.every((e=>h(e)))&&A(e.openMode)&&u(e.topicsApiEndpoint)&&(null==e.description||u(e.description))&&u(e.attachmentsApiEndpoint)&&m(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=>P(e)&&O(e.file)&&(null==e.size||(e=>"number"==typeof e)(e.size))&&(e=>"boolean"==typeof e)(e.externalLink)&&O(e.name)&&O(e.id)&&(null==e.mimeType||O(e.mimeType))&&(null==e.viewerUrl||O(e.viewerUrl)),e.isFtMapResource=e=>s(e)&&u(e.contentUrl)&&u(e.filename)&&u(e.id)&&u(e.mimeType),e.isFtMetadata=h,e.isFtOpenMode=A,e.isFtPageRequest=T,e.isFtSearchFacet=I,e.isFtSearchFacetConf=D,e.isFtSearchFacetEntry=S,e.isFtSearchFilter=y,e.isFtSearchLocale=d,e.isFtSearchLocales=e=>s(e)&&Array.isArray(e.contentLocales)&&e.contentLocales.every((e=>d(e))),e.isFtSearchRequest=e=>s(e)&&u(e.query)&&T(e.paging)&&Array.isArray(e.filters)&&e.filters.every((e=>y(e)))&&Array.isArray(e.sort)&&e.sort.every((e=>k(e)))&&(null==e.uiLocale||u(e.uiLocale))&&(null==e.contentLocale||u(e.contentLocale))&&Array.isArray(e.facets)&&e.facets.every((e=>D(e))),e.isFtSearchResultCluster=b,e.isFtSearchResultClusterEntry=F,e.isFtSearchResultMap=U,e.isFtSearchResultTopic=v,e.isFtSearchResultType=C,e.isFtSearchResultUnstructuredDocument=R,e.isFtSearchResults=e=>s(e)&&(null==e.spellcheck||w(e.spellcheck))&&Array.isArray(e.results)&&e.results.every((e=>b(e)))&&Array.isArray(e.facets)&&e.facets.every((e=>I(e))),e.isFtSearchSortCriterion=k,e.isFtSpellcheck=w,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=>k(e)))&&(null==e.maxCount||o(e.maxCount))&&(null==e.contentLocale||u(e.contentLocale)),e.isFtSuggestResult=M,e.isFtSuggestResults=e=>s(e)&&Array.isArray(e.suggestions)&&e.suggestions.every((e=>M(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=x,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=$}));
@@ -1,4 +1,5 @@
1
- import { FtCollectionDocument, FtMap, FtMapResource, FtTocNode, FtTopic, FtUnstructuredDocument } from "./types/ft-common/public";
1
+ import "cross-fetch/polyfill";
2
+ import { FtCollectionDocument, FtMap, FtMapResource, FtSearchLocales, FtSearchRequest, FtSearchResults, FtSuggestRequest, FtSuggestResults, FtTocNode, FtTopic, FtTopicContentTarget, FtUnstructuredDocument } from "./types/ft-common/public";
2
3
  import { FtAuthenticatedSession, FtMapAttachment } from "./types/ft-server/public";
3
4
  export * from "./types/ft-common/public";
4
5
  export * from "./types/ft-server/public";
@@ -8,6 +9,7 @@ export declare class FluidTopicsApi {
8
9
  private authorization;
9
10
  private get defaultHeaders();
10
11
  constructor(tenantBaseUrl: string, integrationIdentifier: string);
12
+ setApiKey(apiKey: string): void;
11
13
  setCredentials(login: string, password: string): void;
12
14
  clearAuthentication(): void;
13
15
  login(login: string, password: string): Promise<FtAuthenticatedSession>;
@@ -15,19 +17,24 @@ export declare class FluidTopicsApi {
15
17
  getMap(mapId: string): Promise<FtMap>;
16
18
  getTableOfContent(mapId: string): Promise<Array<FtTocNode>>;
17
19
  getTopic(mapId: string, topicContentId: string): Promise<FtTopic>;
18
- getTopicHTMLContent(mapId: string, topicContentId: string): Promise<string>;
20
+ getTopicHTMLContent(mapId: string, topicContentId: string, target?: FtTopicContentTarget): Promise<string>;
19
21
  getMapAttachments(mapId: string): Promise<Array<FtMapAttachment>>;
20
22
  getMapAttachmentContent(mapId: string, attachmentId: string): Promise<ArrayBuffer>;
21
23
  getMapResources(mapId: string): Promise<Array<FtMapResource>>;
22
24
  getMapResourceContent(mapId: string, resourceId: string): Promise<ArrayBuffer>;
23
25
  getUnstructuredDocument(documentId: string): Promise<FtUnstructuredDocument>;
24
26
  getUnstructuredDocumentContent(documentId: string): Promise<ArrayBuffer>;
27
+ getUnstructuredDocumentTextContent(documentId: string): Promise<string>;
25
28
  getCollectionDocuments(userId: string, collectionId: string): Promise<Array<FtCollectionDocument>>;
29
+ getSuggestions(request: FtSuggestRequest): Promise<FtSuggestResults>;
30
+ search(request: FtSearchRequest): Promise<FtSearchResults>;
31
+ getAvailableSearchLocales(): Promise<FtSearchLocales>;
26
32
  get<T>(endpoint: string): Promise<T>;
27
33
  post<T>(endpoint: string, data?: any): Promise<T>;
28
34
  put<T>(endpoint: string, data?: any): Promise<T>;
29
35
  delete<T>(endpoint: string): Promise<T>;
30
- private fetch;
36
+ fetch<FetchRequestInit, FetchResponse>(endpoint: string, init?: FetchRequestInit): Promise<FetchResponse>;
37
+ private makeRequest;
31
38
  private fetchRawData;
32
39
  }
33
40
  export default FluidTopicsApi;
package/dist/mjs/index.js CHANGED
@@ -1,13 +1,12 @@
1
- import fetch from "cross-fetch";
1
+ import "cross-fetch/polyfill";
2
2
  export * from "./types/ft-common/public";
3
3
  export * from "./types/ft-server/public";
4
4
  function toBase64(s) {
5
5
  return typeof Buffer !== "undefined" ? Buffer.from(s).toString("base64") : btoa(s);
6
6
  }
7
7
  async function handleError(response) {
8
- if (response.status < 200 || response.status >= 400) {
9
- console.error("Fluid Topics server returned an error: ", await getBody(response));
10
- throw new Error(`${response.status}: ${response.statusText}`);
8
+ if (!response.ok) {
9
+ throw new Error(`${response.status} - ${response.statusText}: ${await response.text()}`);
11
10
  }
12
11
  return response;
13
12
  }
@@ -28,6 +27,9 @@ export class FluidTopicsApi {
28
27
  this.tenantBaseUrl = tenantBaseUrl.trim().replace(/\/$/, "");
29
28
  this.ftCallingApp = `ft-public-api/${integrationIdentifier}`;
30
29
  }
30
+ setApiKey(apiKey) {
31
+ this.authorization = { "Authorization": "Bearer " + apiKey };
32
+ }
31
33
  setCredentials(login, password) {
32
34
  this.authorization = { "Authorization": "Basic " + toBase64(`${login}:${password}`) };
33
35
  }
@@ -59,14 +61,14 @@ export class FluidTopicsApi {
59
61
  getTopic(mapId, topicContentId) {
60
62
  return this.get(`/api/khub/maps/${mapId}/topics/${topicContentId}`);
61
63
  }
62
- getTopicHTMLContent(mapId, topicContentId) {
63
- return this.get(`/api/khub/maps/${mapId}/topics/${topicContentId}/content`);
64
+ getTopicHTMLContent(mapId, topicContentId, target) {
65
+ return this.get(`/api/khub/maps/${mapId}/topics/${topicContentId}/content${target ? "?target=" + target : ""}`);
64
66
  }
65
67
  getMapAttachments(mapId) {
66
68
  return this.get(`/api/khub/maps/${mapId}/attachments`);
67
69
  }
68
70
  getMapAttachmentContent(mapId, attachmentId) {
69
- return this.fetchRawData(`/api/khub/maps/${mapId}/attachments/${attachmentId}`);
71
+ return this.fetchRawData(`/api/khub/maps/${mapId}/attachments/${attachmentId}/content`);
70
72
  }
71
73
  getMapResources(mapId) {
72
74
  return this.get(`/api/khub/maps/${mapId}/resources`);
@@ -80,26 +82,50 @@ export class FluidTopicsApi {
80
82
  getUnstructuredDocumentContent(documentId) {
81
83
  return this.fetchRawData(`/api/khub/documents/${documentId}/content`);
82
84
  }
85
+ getUnstructuredDocumentTextContent(documentId) {
86
+ return this.get(`/api/khub/documents/${documentId}/content/text`);
87
+ }
83
88
  getCollectionDocuments(userId, collectionId) {
84
89
  return this.get(`/api/users/${userId}/collections/${collectionId}/documents`);
85
90
  }
91
+ getSuggestions(request) {
92
+ return this.post("/api/khub/suggest", request);
93
+ }
94
+ search(request) {
95
+ return this.post("/api/khub/clustered-search", request);
96
+ }
97
+ getAvailableSearchLocales() {
98
+ return this.get("/api/khub/locales");
99
+ }
86
100
  get(endpoint) {
87
- return this.fetch("GET", endpoint);
101
+ return this.makeRequest("GET", endpoint);
88
102
  }
89
103
  post(endpoint, data) {
90
- return this.fetch("POST", endpoint, data);
104
+ return this.makeRequest("POST", endpoint, data);
91
105
  }
92
106
  put(endpoint, data) {
93
- return this.fetch("PUT", endpoint, data);
107
+ return this.makeRequest("PUT", endpoint, data);
94
108
  }
95
109
  delete(endpoint) {
96
- return this.fetch("DELETE", endpoint);
110
+ return this.makeRequest("DELETE", endpoint);
111
+ }
112
+ async fetch(endpoint, init) {
113
+ const requestInit = init;
114
+ if (!endpoint.startsWith("/")) {
115
+ endpoint = "/" + endpoint;
116
+ }
117
+ return await fetch(this.tenantBaseUrl + endpoint, {
118
+ ...(requestInit ?? {}),
119
+ headers: {
120
+ ...this.defaultHeaders,
121
+ ...(requestInit?.headers ?? {})
122
+ }
123
+ });
97
124
  }
98
- fetch(method, endpoint, data) {
99
- return fetch(this.tenantBaseUrl + endpoint, {
125
+ makeRequest(method, endpoint, data) {
126
+ return this.fetch(endpoint, {
100
127
  method: method,
101
128
  headers: {
102
- ...this.defaultHeaders,
103
129
  ...(data != null ? { "Content-Type": "application/json" } : {})
104
130
  },
105
131
  body: data != null ? JSON.stringify(data) : undefined
@@ -72,6 +72,21 @@ export interface FtUnstructuredDocument {
72
72
  lang?: string;
73
73
  }
74
74
  export declare const isFtUnstructuredDocument: (o: any) => o is FtUnstructuredDocument;
75
+ export declare enum FtTopicContentTarget {
76
+ THIRD_PARTY = "THIRD_PARTY",
77
+ OFF_THE_GRID = "OFF_THE_GRID"
78
+ }
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;
75
90
  export interface FtMetadata {
76
91
  values: Array<string>;
77
92
  label: string;
@@ -85,6 +100,12 @@ export interface FtMapResource {
85
100
  mimeType: string;
86
101
  }
87
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;
88
109
  export declare enum FtEditorialType {
89
110
  ARTICLE = "ARTICLE",
90
111
  BOOK = "BOOK"
@@ -95,12 +116,162 @@ export declare enum FtOpenMode {
95
116
  EXTERNAL = "EXTERNAL"
96
117
  }
97
118
  export declare const isFtOpenMode: (o: any) => o is FtOpenMode;
119
+ export interface FtPageRequest {
120
+ perPage?: number;
121
+ page: number;
122
+ }
123
+ export declare const isFtPageRequest: (o: any) => o is FtPageRequest;
124
+ export interface FtSearchResults {
125
+ spellcheck?: FtSpellcheck;
126
+ paging: any;
127
+ results: Array<FtSearchResultCluster>;
128
+ facets: Array<FtSearchFacet>;
129
+ }
130
+ export declare const isFtSearchResults: (o: any) => o is FtSearchResults;
131
+ export interface FtSearchRequest {
132
+ query: string;
133
+ paging: FtPageRequest;
134
+ filters: Array<FtSearchFilter>;
135
+ sort: Array<FtSearchSortCriterion>;
136
+ uiLocale?: string;
137
+ contentLocale?: string;
138
+ facets: Array<FtSearchFacetConf>;
139
+ }
140
+ export declare const isFtSearchRequest: (o: any) => o is FtSearchRequest;
141
+ export interface FtSearchResultCluster {
142
+ entries: Array<FtSearchResultClusterEntry>;
143
+ metadataVariableAxis?: string;
144
+ }
145
+ export declare const isFtSearchResultCluster: (o: any) => o is FtSearchResultCluster;
146
+ export interface FtSearchResultClusterEntry {
147
+ document?: FtSearchResultUnstructuredDocument;
148
+ topic?: FtSearchResultTopic;
149
+ type: FtSearchResultType;
150
+ map?: FtSearchResultMap;
151
+ }
152
+ export declare const isFtSearchResultClusterEntry: (o: any) => o is FtSearchResultClusterEntry;
153
+ export interface FtSearchResultUnstructuredDocument {
154
+ metadata: Array<FtMetadata>;
155
+ openMode: FtOpenMode;
156
+ documentUrl: string;
157
+ mimeType: string;
158
+ source: any;
159
+ title: string;
160
+ lastPublicationDate?: string;
161
+ viewerUrl: string;
162
+ contentUrl: string;
163
+ filename: string;
164
+ htmlTitle: string;
165
+ originUrl?: string;
166
+ documentId: string;
167
+ lastEditionDate: string;
168
+ htmlExcerpt: string;
169
+ }
170
+ export declare const isFtSearchResultUnstructuredDocument: (o: any) => o is FtSearchResultUnstructuredDocument;
171
+ export interface FtSearchResultMap {
172
+ metadata: Array<FtMetadata>;
173
+ openMode: FtOpenMode;
174
+ editorialType: FtEditorialType;
175
+ source?: any;
176
+ title: string;
177
+ lastPublicationDate?: string;
178
+ htmlTitle: string;
179
+ originUrl?: string;
180
+ mapUrl: string;
181
+ readerUrl: string;
182
+ mapId: string;
183
+ lastEditionDate?: string;
184
+ htmlExcerpt: string;
185
+ }
186
+ export declare const isFtSearchResultMap: (o: any) => o is FtSearchResultMap;
187
+ export interface FtSearchResultTopic {
188
+ metadata: Array<FtMetadata>;
189
+ openMode: FtOpenMode;
190
+ contentId: string;
191
+ resources: Array<FtTopicResource>;
192
+ source?: any;
193
+ title: string;
194
+ mapTitle: string;
195
+ topicUrl: string;
196
+ contentUrl: string;
197
+ htmlTitle: string;
198
+ breadcrumb: Array<string>;
199
+ tocId: string;
200
+ originUrl?: string;
201
+ readerUrl: string;
202
+ mapId: string;
203
+ lastEditionDate?: string;
204
+ htmlExcerpt: string;
205
+ }
206
+ export declare const isFtSearchResultTopic: (o: any) => o is FtSearchResultTopic;
98
207
  export declare enum FtSearchResultType {
99
208
  MAP = "MAP",
100
209
  DOCUMENT = "DOCUMENT",
101
210
  TOPIC = "TOPIC"
102
211
  }
103
212
  export declare const isFtSearchResultType: (o: any) => o is FtSearchResultType;
213
+ export interface FtSearchFacet {
214
+ hierarchical: boolean;
215
+ label: string;
216
+ multiSelectionable: boolean;
217
+ key: string;
218
+ rootNodes: Array<FtSearchFacetEntry>;
219
+ }
220
+ export declare const isFtSearchFacet: (o: any) => o is FtSearchFacet;
221
+ export interface FtSearchFacetConf {
222
+ maxDepth?: number;
223
+ id: string;
224
+ }
225
+ export declare const isFtSearchFacetConf: (o: any) => o is FtSearchFacetConf;
226
+ export interface FtSearchFacetEntry {
227
+ totalResultsCount: number;
228
+ descendantSelected: boolean;
229
+ childNodes: Array<FtSearchFacetEntry>;
230
+ label: string;
231
+ value: string;
232
+ selected: boolean;
233
+ }
234
+ export declare const isFtSearchFacetEntry: (o: any) => o is FtSearchFacetEntry;
235
+ export interface FtSearchSortCriterion {
236
+ type: any;
237
+ key: string;
238
+ order: any;
239
+ }
240
+ export declare const isFtSearchSortCriterion: (o: any) => o is FtSearchSortCriterion;
241
+ export interface FtSpellcheck {
242
+ suggestedQuery: string;
243
+ htmlSuggestedQuery: string;
244
+ }
245
+ export declare const isFtSpellcheck: (o: any) => o is FtSpellcheck;
246
+ export interface FtTopicResource {
247
+ filename: string;
248
+ resourceUrl: string;
249
+ id: string;
250
+ mimeType: string;
251
+ resourceContentUrl: string;
252
+ viewerUrl: string;
253
+ }
254
+ export declare const isFtTopicResource: (o: any) => o is FtTopicResource;
255
+ export interface FtSuggestRequest {
256
+ input: string;
257
+ filters: Array<FtSearchFilter>;
258
+ sort: Array<FtSearchSortCriterion>;
259
+ maxCount?: number;
260
+ contentLocale?: string;
261
+ }
262
+ export declare const isFtSuggestRequest: (o: any) => o is FtSuggestRequest;
263
+ export interface FtSuggestResult {
264
+ filenameExtension?: string;
265
+ editorialType?: FtEditorialType;
266
+ mimeType?: string;
267
+ type: FtSearchResultType;
268
+ value: string;
269
+ }
270
+ export declare const isFtSuggestResult: (o: any) => o is FtSuggestResult;
271
+ export interface FtSuggestResults {
272
+ suggestions: Array<FtSuggestResult>;
273
+ }
274
+ export declare const isFtSuggestResults: (o: any) => o is FtSuggestResults;
104
275
  export interface FtAuthenticationIdentifier {
105
276
  identifier: string;
106
277
  realm: string;
@@ -80,6 +80,26 @@ export const isFtUnstructuredDocument = (o) => {
80
80
  && (isString(o.id))
81
81
  && (o.lang == null || isString(o.lang));
82
82
  };
83
+ // From: WsTopicContentTarget
84
+ export var FtTopicContentTarget;
85
+ (function (FtTopicContentTarget) {
86
+ FtTopicContentTarget["THIRD_PARTY"] = "THIRD_PARTY";
87
+ FtTopicContentTarget["OFF_THE_GRID"] = "OFF_THE_GRID";
88
+ })(FtTopicContentTarget || (FtTopicContentTarget = {}));
89
+ export const isFtTopicContentTarget = (o) => {
90
+ return ["THIRD_PARTY", "OFF_THE_GRID"].includes(o);
91
+ };
92
+ export const isFtSearchLocale = (o) => {
93
+ return isObject(o)
94
+ && (isNumber(o.count))
95
+ && (isString(o.label))
96
+ && (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
+ };
83
103
  export const isFtMetadata = (o) => {
84
104
  return isObject(o)
85
105
  && ((Array.isArray(o.values)
@@ -94,6 +114,13 @@ export const isFtMapResource = (o) => {
94
114
  && (isString(o.id))
95
115
  && (isString(o.mimeType));
96
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
+ };
97
124
  // From: WsEditorialType
98
125
  export var FtEditorialType;
99
126
  (function (FtEditorialType) {
@@ -112,6 +139,101 @@ export var FtOpenMode;
112
139
  export const isFtOpenMode = (o) => {
113
140
  return ["FLUIDTOPICS", "EXTERNAL"].includes(o);
114
141
  };
142
+ export const isFtPageRequest = (o) => {
143
+ return isObject(o)
144
+ && (o.perPage == null || isNumber(o.perPage))
145
+ && (isNumber(o.page));
146
+ };
147
+ export const isFtSearchResults = (o) => {
148
+ return isObject(o)
149
+ && (o.spellcheck == null || isFtSpellcheck(o.spellcheck))
150
+ && ((Array.isArray(o.results)
151
+ && o.results.every((v) => isFtSearchResultCluster(v))))
152
+ && ((Array.isArray(o.facets)
153
+ && o.facets.every((v) => isFtSearchFacet(v))));
154
+ };
155
+ export const isFtSearchRequest = (o) => {
156
+ return isObject(o)
157
+ && (isString(o.query))
158
+ && (isFtPageRequest(o.paging))
159
+ && ((Array.isArray(o.filters)
160
+ && o.filters.every((v) => isFtSearchFilter(v))))
161
+ && ((Array.isArray(o.sort)
162
+ && o.sort.every((v) => isFtSearchSortCriterion(v))))
163
+ && (o.uiLocale == null || isString(o.uiLocale))
164
+ && (o.contentLocale == null || isString(o.contentLocale))
165
+ && ((Array.isArray(o.facets)
166
+ && o.facets.every((v) => isFtSearchFacetConf(v))));
167
+ };
168
+ export const isFtSearchResultCluster = (o) => {
169
+ return isObject(o)
170
+ && ((Array.isArray(o.entries)
171
+ && o.entries.every((v) => isFtSearchResultClusterEntry(v))))
172
+ && (o.metadataVariableAxis == null || isString(o.metadataVariableAxis));
173
+ };
174
+ export const isFtSearchResultClusterEntry = (o) => {
175
+ return isObject(o)
176
+ && (o.document == null || isFtSearchResultUnstructuredDocument(o.document))
177
+ && (o.topic == null || isFtSearchResultTopic(o.topic))
178
+ && (isFtSearchResultType(o.type))
179
+ && (o.map == null || isFtSearchResultMap(o.map));
180
+ };
181
+ export const isFtSearchResultUnstructuredDocument = (o) => {
182
+ return isObject(o)
183
+ && ((Array.isArray(o.metadata)
184
+ && o.metadata.every((v) => isFtMetadata(v))))
185
+ && (isFtOpenMode(o.openMode))
186
+ && (isString(o.documentUrl))
187
+ && (isString(o.mimeType))
188
+ && (isString(o.title))
189
+ && (o.lastPublicationDate == null || isString(o.lastPublicationDate))
190
+ && (isString(o.viewerUrl))
191
+ && (isString(o.contentUrl))
192
+ && (isString(o.filename))
193
+ && (isString(o.htmlTitle))
194
+ && (o.originUrl == null || isString(o.originUrl))
195
+ && (isString(o.documentId))
196
+ && (isString(o.lastEditionDate))
197
+ && (isString(o.htmlExcerpt));
198
+ };
199
+ export const isFtSearchResultMap = (o) => {
200
+ return isObject(o)
201
+ && ((Array.isArray(o.metadata)
202
+ && o.metadata.every((v) => isFtMetadata(v))))
203
+ && (isFtOpenMode(o.openMode))
204
+ && (isFtEditorialType(o.editorialType))
205
+ && (isString(o.title))
206
+ && (o.lastPublicationDate == null || isString(o.lastPublicationDate))
207
+ && (isString(o.htmlTitle))
208
+ && (o.originUrl == null || isString(o.originUrl))
209
+ && (isString(o.mapUrl))
210
+ && (isString(o.readerUrl))
211
+ && (isString(o.mapId))
212
+ && (o.lastEditionDate == null || isString(o.lastEditionDate))
213
+ && (isString(o.htmlExcerpt));
214
+ };
215
+ export const isFtSearchResultTopic = (o) => {
216
+ return isObject(o)
217
+ && ((Array.isArray(o.metadata)
218
+ && o.metadata.every((v) => isFtMetadata(v))))
219
+ && (isFtOpenMode(o.openMode))
220
+ && (isString(o.contentId))
221
+ && ((Array.isArray(o.resources)
222
+ && o.resources.every((v) => isFtTopicResource(v))))
223
+ && (isString(o.title))
224
+ && (isString(o.mapTitle))
225
+ && (isString(o.topicUrl))
226
+ && (isString(o.contentUrl))
227
+ && (isString(o.htmlTitle))
228
+ && ((Array.isArray(o.breadcrumb)
229
+ && o.breadcrumb.every((v) => isString(v))))
230
+ && (isString(o.tocId))
231
+ && (o.originUrl == null || isString(o.originUrl))
232
+ && (isString(o.readerUrl))
233
+ && (isString(o.mapId))
234
+ && (o.lastEditionDate == null || isString(o.lastEditionDate))
235
+ && (isString(o.htmlExcerpt));
236
+ };
115
237
  // From: WsPublicSearchResultType
116
238
  export var FtSearchResultType;
117
239
  (function (FtSearchResultType) {
@@ -122,6 +244,71 @@ export var FtSearchResultType;
122
244
  export const isFtSearchResultType = (o) => {
123
245
  return ["MAP", "DOCUMENT", "TOPIC"].includes(o);
124
246
  };
247
+ export const isFtSearchFacet = (o) => {
248
+ return isObject(o)
249
+ && (isBoolean(o.hierarchical))
250
+ && (isString(o.label))
251
+ && (isBoolean(o.multiSelectionable))
252
+ && (isString(o.key))
253
+ && ((Array.isArray(o.rootNodes)
254
+ && o.rootNodes.every((v) => isFtSearchFacetEntry(v))));
255
+ };
256
+ export const isFtSearchFacetConf = (o) => {
257
+ return isObject(o)
258
+ && (o.maxDepth == null || isNumber(o.maxDepth))
259
+ && (isString(o.id));
260
+ };
261
+ export const isFtSearchFacetEntry = (o) => {
262
+ return isObject(o)
263
+ && (isNumber(o.totalResultsCount))
264
+ && (isBoolean(o.descendantSelected))
265
+ && ((Array.isArray(o.childNodes)
266
+ && o.childNodes.every((v) => isFtSearchFacetEntry(v))))
267
+ && (isString(o.label))
268
+ && (isString(o.value))
269
+ && (isBoolean(o.selected));
270
+ };
271
+ export const isFtSearchSortCriterion = (o) => {
272
+ return isObject(o)
273
+ && (isString(o.key));
274
+ };
275
+ export const isFtSpellcheck = (o) => {
276
+ return isObject(o)
277
+ && (isString(o.suggestedQuery))
278
+ && (isString(o.htmlSuggestedQuery));
279
+ };
280
+ export const isFtTopicResource = (o) => {
281
+ return isObject(o)
282
+ && (isString(o.filename))
283
+ && (isString(o.resourceUrl))
284
+ && (isString(o.id))
285
+ && (isString(o.mimeType))
286
+ && (isString(o.resourceContentUrl))
287
+ && (isString(o.viewerUrl));
288
+ };
289
+ export const isFtSuggestRequest = (o) => {
290
+ return isObject(o)
291
+ && (isString(o.input))
292
+ && ((Array.isArray(o.filters)
293
+ && o.filters.every((v) => isFtSearchFilter(v))))
294
+ && ((Array.isArray(o.sort)
295
+ && o.sort.every((v) => isFtSearchSortCriterion(v))))
296
+ && (o.maxCount == null || isNumber(o.maxCount))
297
+ && (o.contentLocale == null || isString(o.contentLocale));
298
+ };
299
+ export const isFtSuggestResult = (o) => {
300
+ return isObject(o)
301
+ && (o.filenameExtension == null || isString(o.filenameExtension))
302
+ && (o.editorialType == null || isFtEditorialType(o.editorialType))
303
+ && (o.mimeType == null || isString(o.mimeType))
304
+ && (isFtSearchResultType(o.type))
305
+ && (isString(o.value));
306
+ };
307
+ export const isFtSuggestResults = (o) => {
308
+ return isObject(o)
309
+ && ((Array.isArray(o.suggestions)
310
+ && o.suggestions.every((v) => isFtSuggestResult(v))));
311
+ };
125
312
  export const isFtAuthenticationIdentifier = (o) => {
126
313
  return isObject(o)
127
314
  && (isString(o.identifier))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluid-topics/public-api",
3
- "version": "1.0.8",
3
+ "version": "1.0.12",
4
4
  "description": "Fluid Topics Public API",
5
5
  "author": "Fluid Topics dev team <opensource@antidot.net>",
6
6
  "license": "LGPLv3",
@@ -17,7 +17,7 @@
17
17
  "access": "public"
18
18
  },
19
19
  "dependencies": {
20
- "cross-fetch": "^3.1.4"
20
+ "cross-fetch": "^3.1.5"
21
21
  },
22
22
  "devDependencies": {
23
23
  "@rollup/plugin-commonjs": "^20.0.0",