@fluid-topics/public-api 1.0.11 → 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 +9 -0
- package/dist/cjs/types/ft-common/public.js +199 -1
- package/dist/fluidtopics.min.js +1 -1
- package/dist/mjs/index.d.ts +4 -1
- package/dist/mjs/index.js +9 -0
- package/dist/mjs/types/ft-common/public.d.ts +166 -0
- package/dist/mjs/types/ft-common/public.js +178 -0
- package/package.json +2 -2
package/dist/cjs/index.js
CHANGED
|
@@ -107,6 +107,15 @@ class FluidTopicsApi {
|
|
|
107
107
|
getCollectionDocuments(userId, collectionId) {
|
|
108
108
|
return this.get(`/api/users/${userId}/collections/${collectionId}/documents`);
|
|
109
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
|
+
}
|
|
110
119
|
get(endpoint) {
|
|
111
120
|
return this.makeRequest("GET", endpoint);
|
|
112
121
|
}
|
|
@@ -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.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";
|
|
@@ -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
|
+
&& (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,14 @@ 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;
|
|
118
139
|
// From: WsEditorialType
|
|
119
140
|
var FtEditorialType;
|
|
120
141
|
(function (FtEditorialType) {
|
|
@@ -135,6 +156,109 @@ const isFtOpenMode = (o) => {
|
|
|
135
156
|
return ["FLUIDTOPICS", "EXTERNAL"].includes(o);
|
|
136
157
|
};
|
|
137
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;
|
|
138
262
|
// From: WsPublicSearchResultType
|
|
139
263
|
var FtSearchResultType;
|
|
140
264
|
(function (FtSearchResultType) {
|
|
@@ -146,6 +270,80 @@ const isFtSearchResultType = (o) => {
|
|
|
146
270
|
return ["MAP", "DOCUMENT", "TOPIC"].includes(o);
|
|
147
271
|
};
|
|
148
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;
|
|
149
347
|
const isFtAuthenticationIdentifier = (o) => {
|
|
150
348
|
return isObject(o)
|
|
151
349
|
&& (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,A=t=>"string"==typeof t,b=t=>m(t)&&(null==t.emailAddress||A(t.emailAddress))&&(null==t.displayName||A(t.displayName))&&Array.isArray(t.roles)&&A(t.userId);async function R(t){if(!t.ok)throw new Error(`${t.status} - ${t.statusText}: ${await t.text()}`);return t}function F(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(R).then(F)}fetchRawData(t){return fetch(this.tenantBaseUrl+t,{headers:this.defaultHeaders}).then(R).then((t=>t.arrayBuffer()))}}t.FluidTopicsApi=C,t.default=C,t.isFtAuthenticatedSession=t=>m(t)&&b(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)&&A(t.file)&&(null==t.size||(t=>"number"==typeof t)(t.size))&&(t=>"boolean"==typeof t)(t.externalLink)&&A(t.name)&&A(t.id)&&(null==t.mimeType||A(t.mimeType))&&(null==t.viewerUrl||A(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=b}));
|
|
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=$}));
|
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";
|
|
@@ -26,6 +26,9 @@ export declare class FluidTopicsApi {
|
|
|
26
26
|
getUnstructuredDocumentContent(documentId: string): Promise<ArrayBuffer>;
|
|
27
27
|
getUnstructuredDocumentTextContent(documentId: string): Promise<string>;
|
|
28
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>;
|
|
29
32
|
get<T>(endpoint: string): Promise<T>;
|
|
30
33
|
post<T>(endpoint: string, data?: any): Promise<T>;
|
|
31
34
|
put<T>(endpoint: string, data?: any): Promise<T>;
|
package/dist/mjs/index.js
CHANGED
|
@@ -88,6 +88,15 @@ export class FluidTopicsApi {
|
|
|
88
88
|
getCollectionDocuments(userId, collectionId) {
|
|
89
89
|
return this.get(`/api/users/${userId}/collections/${collectionId}/documents`);
|
|
90
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
|
+
}
|
|
91
100
|
get(endpoint) {
|
|
92
101
|
return this.makeRequest("GET", endpoint);
|
|
93
102
|
}
|
|
@@ -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,12 @@ 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;
|
|
93
109
|
export declare enum FtEditorialType {
|
|
94
110
|
ARTICLE = "ARTICLE",
|
|
95
111
|
BOOK = "BOOK"
|
|
@@ -100,12 +116,162 @@ export declare enum FtOpenMode {
|
|
|
100
116
|
EXTERNAL = "EXTERNAL"
|
|
101
117
|
}
|
|
102
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;
|
|
103
207
|
export declare enum FtSearchResultType {
|
|
104
208
|
MAP = "MAP",
|
|
105
209
|
DOCUMENT = "DOCUMENT",
|
|
106
210
|
TOPIC = "TOPIC"
|
|
107
211
|
}
|
|
108
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;
|
|
109
275
|
export interface FtAuthenticationIdentifier {
|
|
110
276
|
identifier: string;
|
|
111
277
|
realm: string;
|
|
@@ -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
|
+
&& (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,13 @@ 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
|
+
};
|
|
106
124
|
// From: WsEditorialType
|
|
107
125
|
export var FtEditorialType;
|
|
108
126
|
(function (FtEditorialType) {
|
|
@@ -121,6 +139,101 @@ export var FtOpenMode;
|
|
|
121
139
|
export const isFtOpenMode = (o) => {
|
|
122
140
|
return ["FLUIDTOPICS", "EXTERNAL"].includes(o);
|
|
123
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
|
+
};
|
|
124
237
|
// From: WsPublicSearchResultType
|
|
125
238
|
export var FtSearchResultType;
|
|
126
239
|
(function (FtSearchResultType) {
|
|
@@ -131,6 +244,71 @@ export var FtSearchResultType;
|
|
|
131
244
|
export const isFtSearchResultType = (o) => {
|
|
132
245
|
return ["MAP", "DOCUMENT", "TOPIC"].includes(o);
|
|
133
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
|
+
};
|
|
134
312
|
export const isFtAuthenticationIdentifier = (o) => {
|
|
135
313
|
return isObject(o)
|
|
136
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.
|
|
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.
|
|
20
|
+
"cross-fetch": "^3.1.5"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@rollup/plugin-commonjs": "^20.0.0",
|