@fluid-topics/public-api 1.0.23 → 1.0.25
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 +24 -0
- package/dist/cjs/types/ft-common/public.js +63 -1
- package/dist/fluidtopics.min.js +1 -1
- package/dist/mjs/index.d.ts +10 -2
- package/dist/mjs/index.js +24 -0
- package/dist/mjs/types/ft-common/public.d.ts +48 -0
- package/dist/mjs/types/ft-common/public.js +53 -0
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -148,6 +148,30 @@ class FluidTopicsApi {
|
|
|
148
148
|
getAvailableSearchLocales() {
|
|
149
149
|
return this.get("/api/khub/locales");
|
|
150
150
|
}
|
|
151
|
+
getMapRating(mapId) {
|
|
152
|
+
return this.get(`/api/khub/maps/${mapId}/rating`);
|
|
153
|
+
}
|
|
154
|
+
getDocumentRating(docId) {
|
|
155
|
+
return this.get(`/api/khub/documents/${docId}/rating`);
|
|
156
|
+
}
|
|
157
|
+
rateMap(mapId, type, value) {
|
|
158
|
+
return this.post(`/api/khub/maps/${mapId}/rating`, { type, value });
|
|
159
|
+
}
|
|
160
|
+
unrateMap(mapId) {
|
|
161
|
+
return this.delete(`/api/khub/maps/${mapId}/rating`);
|
|
162
|
+
}
|
|
163
|
+
rateTopic(mapId, tocId, type, value) {
|
|
164
|
+
return this.post(`/api/khub/maps/${mapId}/topics/${tocId}/rating`, { type, value });
|
|
165
|
+
}
|
|
166
|
+
unrateTopic(mapId, tocId) {
|
|
167
|
+
return this.delete(`/api/khub/maps/${mapId}/topics/${tocId}/rating`);
|
|
168
|
+
}
|
|
169
|
+
rateDocument(docId, type, value) {
|
|
170
|
+
return this.post(`/api/khub/documents/${docId}/rating`, { type, value });
|
|
171
|
+
}
|
|
172
|
+
unrateDocument(docId) {
|
|
173
|
+
return this.delete(`/api/khub/documents/${docId}/rating`);
|
|
174
|
+
}
|
|
151
175
|
get(endpoint) {
|
|
152
176
|
return this.makeRequest("GET", endpoint);
|
|
153
177
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
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.isFtSearchPrior = exports.isFtSearchResults = exports.isFtCollectionDocumentType = exports.FtCollectionDocumentType = exports.isFtPageRequest = exports.isFtOpenMode = exports.FtOpenMode = exports.isFtEditorialType = exports.FtEditorialType = exports.isFtSearchResultsPageInfo = exports.isFtSearchPreset = exports.isFtSearchFilter = exports.isFtSearchPreferencesConfiguration = exports.isFtMetadataPreferenceConfiguration = exports.isFtMapResource = exports.isFtTopicsRatingSummary = exports.isFtTopicRating = exports.isFtRatingSummary = exports.isFtRatingCreation = exports.isFtPublicationRatingSummary = exports.isFtPublicationRating = exports.isFtRatingType = exports.FtRatingType = exports.isFtMetadata = exports.isFtSearchLocales = exports.isFtSearchLocale = exports.isFtTopicContentTarget = exports.FtTopicContentTarget = exports.isFtUnstructuredDocument = exports.isFtTopic = exports.isFtTocPage = exports.isFtTocNode = exports.isFtMapStyles = exports.isFtMap = exports.isFtCollectionDocument = exports.isFtCredentials = void 0;
|
|
4
|
+
exports.isFtAuthenticationIdentifier = exports.isFtSuggestResults = exports.isFtSuggestResult = exports.isFtSuggestRequest = void 0;
|
|
4
5
|
const isObject = (o) => typeof o === "object" && o != null;
|
|
5
6
|
const isBoolean = (o) => typeof o === "boolean";
|
|
6
7
|
const isNumber = (o) => typeof o === "number";
|
|
@@ -41,6 +42,7 @@ const isFtMap = (o) => {
|
|
|
41
42
|
&& (isString(o.lastEdition))
|
|
42
43
|
&& (isString(o.originId))
|
|
43
44
|
&& (isString(o.rightsApiEndpoint))
|
|
45
|
+
&& ((0, exports.isFtMapStyles)(o.contentStyles))
|
|
44
46
|
&& (o.originUrl == null || isString(o.originUrl))
|
|
45
47
|
&& (isString(o.readerUrl))
|
|
46
48
|
&& (o.khubVersion == null || isString(o.khubVersion))
|
|
@@ -48,6 +50,14 @@ const isFtMap = (o) => {
|
|
|
48
50
|
&& (o.lang == null || isString(o.lang));
|
|
49
51
|
};
|
|
50
52
|
exports.isFtMap = isFtMap;
|
|
53
|
+
const isFtMapStyles = (o) => {
|
|
54
|
+
return isObject(o)
|
|
55
|
+
&& (isString(o.topicStylesheetUrl))
|
|
56
|
+
&& (isString(o.titleStylesheetUrl))
|
|
57
|
+
&& ((Array.isArray(o.customCssClasses)
|
|
58
|
+
&& o.customCssClasses.every((v) => isString(v))));
|
|
59
|
+
};
|
|
60
|
+
exports.isFtMapStyles = isFtMapStyles;
|
|
51
61
|
const isFtTocNode = (o) => {
|
|
52
62
|
return isObject(o)
|
|
53
63
|
&& (o.prettyUrl == null || isString(o.prettyUrl))
|
|
@@ -134,6 +144,58 @@ const isFtMetadata = (o) => {
|
|
|
134
144
|
&& (isString(o.key));
|
|
135
145
|
};
|
|
136
146
|
exports.isFtMetadata = isFtMetadata;
|
|
147
|
+
// From: RatingType
|
|
148
|
+
var FtRatingType;
|
|
149
|
+
(function (FtRatingType) {
|
|
150
|
+
FtRatingType["STARS"] = "STARS";
|
|
151
|
+
FtRatingType["LIKE"] = "LIKE";
|
|
152
|
+
FtRatingType["DICHOTOMOUS"] = "DICHOTOMOUS";
|
|
153
|
+
FtRatingType["NO_RATING"] = "NO_RATING";
|
|
154
|
+
})(FtRatingType = exports.FtRatingType || (exports.FtRatingType = {}));
|
|
155
|
+
const isFtRatingType = (o) => {
|
|
156
|
+
return ["STARS", "LIKE", "DICHOTOMOUS", "NO_RATING"].includes(o);
|
|
157
|
+
};
|
|
158
|
+
exports.isFtRatingType = isFtRatingType;
|
|
159
|
+
const isFtPublicationRating = (o) => {
|
|
160
|
+
return isObject(o)
|
|
161
|
+
&& (isString(o.date))
|
|
162
|
+
&& ((0, exports.isFtRatingType)(o.type))
|
|
163
|
+
&& (isNumber(o.value));
|
|
164
|
+
};
|
|
165
|
+
exports.isFtPublicationRating = isFtPublicationRating;
|
|
166
|
+
const isFtPublicationRatingSummary = (o) => {
|
|
167
|
+
return isObject(o)
|
|
168
|
+
&& (o.rating == null || (0, exports.isFtPublicationRating)(o.rating))
|
|
169
|
+
&& ((0, exports.isFtRatingType)(o.type));
|
|
170
|
+
};
|
|
171
|
+
exports.isFtPublicationRatingSummary = isFtPublicationRatingSummary;
|
|
172
|
+
const isFtRatingCreation = (o) => {
|
|
173
|
+
return isObject(o)
|
|
174
|
+
&& ((0, exports.isFtRatingType)(o.type))
|
|
175
|
+
&& (isNumber(o.value));
|
|
176
|
+
};
|
|
177
|
+
exports.isFtRatingCreation = isFtRatingCreation;
|
|
178
|
+
const isFtRatingSummary = (o) => {
|
|
179
|
+
return isObject(o)
|
|
180
|
+
&& (o.topics == null || (0, exports.isFtTopicsRatingSummary)(o.topics))
|
|
181
|
+
&& ((0, exports.isFtPublicationRatingSummary)(o.publication));
|
|
182
|
+
};
|
|
183
|
+
exports.isFtRatingSummary = isFtRatingSummary;
|
|
184
|
+
const isFtTopicRating = (o) => {
|
|
185
|
+
return isObject(o)
|
|
186
|
+
&& (isString(o.date))
|
|
187
|
+
&& (isString(o.tocId))
|
|
188
|
+
&& ((0, exports.isFtRatingType)(o.type))
|
|
189
|
+
&& (isNumber(o.value));
|
|
190
|
+
};
|
|
191
|
+
exports.isFtTopicRating = isFtTopicRating;
|
|
192
|
+
const isFtTopicsRatingSummary = (o) => {
|
|
193
|
+
return isObject(o)
|
|
194
|
+
&& ((Array.isArray(o.ratings)
|
|
195
|
+
&& o.ratings.every((v) => (0, exports.isFtTopicRating)(v))))
|
|
196
|
+
&& ((0, exports.isFtRatingType)(o.type));
|
|
197
|
+
};
|
|
198
|
+
exports.isFtTopicsRatingSummary = isFtTopicsRatingSummary;
|
|
137
199
|
const isFtMapResource = (o) => {
|
|
138
200
|
return isObject(o)
|
|
139
201
|
&& (isString(o.contentUrl))
|
package/dist/fluidtopics.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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:{}},a={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}(a,a.exports),function(e,t){const r=a.exports,i=r.default||r,n=function(e,t){return/^\/\//.test(e)&&(e="https:"+e),i.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 i=r.exports,n=i.fetch.bind({});n.polyfill=!0,t.fetch||(t.fetch=n,t.Response=i.Response,t.Headers=i.Headers,t.Request=i.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)&&(null==e.prettyUrl||u(e.prettyUrl))&&u(e.tocId)&&Array.isArray(e.children)&&e.children.every((e=>c(e)))&&u(e.contentId)&&(null==e.page||p(e.page))&&u(e.title),p=e=>s(e)&&l(e.visible)&&l(e.onItsOwn)&&(null==e.parentsVisibility||Array.isArray(e.parentsVisibility)&&e.parentsVisibility.every((e=>l(e))));var d;e.FtTopicContentTarget=void 0,(d=e.FtTopicContentTarget||(e.FtTopicContentTarget={})).THIRD_PARTY="THIRD_PARTY",d.OFF_THE_GRID="OFF_THE_GRID",d.CONTENT_PACKAGER="CONTENT_PACKAGER",d.PAGES="PAGES",d.DESIGNED_READER="DESIGNED_READER";const h=e=>s(e)&&o(e.count)&&u(e.label)&&(null==e.lang||u(e.lang)),y=e=>s(e)&&Array.isArray(e.values)&&e.values.every((e=>u(e)))&&u(e.label)&&u(e.key),f=e=>s(e)&&Array.isArray(e.filter)&&e.filter.every((e=>u(e)))&&Array.isArray(e.prior)&&e.prior.every((e=>u(e))),g=e=>s(e)&&l(e.negative)&&Array.isArray(e.values)&&e.values.every((e=>u(e)))&&u(e.key),m=e=>s(e)&&o(e.totalResultsCount)&&l(e.lastPage)&&o(e.currentPage)&&o(e.totalClustersCount);var A;e.FtEditorialType=void 0,(A=e.FtEditorialType||(e.FtEditorialType={})).ARTICLE="ARTICLE",A.BOOK="BOOK";const T=e=>["ARTICLE","BOOK"].includes(e);var b;e.FtOpenMode=void 0,(b=e.FtOpenMode||(e.FtOpenMode={})).FLUIDTOPICS="FLUIDTOPICS",b.EXTERNAL="EXTERNAL";const E=e=>["FLUIDTOPICS","EXTERNAL"].includes(e),F=e=>s(e)&&(null==e.perPage||o(e.perPage))&&o(e.page);var R;e.FtCollectionDocumentType=void 0,(R=e.FtCollectionDocumentType||(e.FtCollectionDocumentType={})).MAP="MAP",R.DOCUMENT="DOCUMENT",R.TOPIC="TOPIC",R.PERSONAL_BOOK="PERSONAL_BOOK",R.SHARED_BOOK="SHARED_BOOK";const v=e=>["MAP","DOCUMENT","TOPIC","PERSONAL_BOOK","SHARED_BOOK"].includes(e),S=e=>s(e)&&o(e.weight)&&u(e.value)&&u(e.key),C=e=>s(e)&&Array.isArray(e.entries)&&e.entries.every((e=>U(e)))&&(null==e.metadataVariableAxis||u(e.metadataVariableAxis)),U=e=>s(e)&&(null==e.document||P(e.document))&&(null==e.topic||D(e.topic))&&I(e.type)&&(null==e.map||O(e.map)),P=e=>s(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>y(e)))&&E(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),O=e=>s(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>y(e)))&&(null==e.openMode||E(e.openMode))&&T(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),D=e=>s(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>y(e)))&&E(e.openMode)&&u(e.contentId)&&Array.isArray(e.resources)&&e.resources.every((e=>_(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 w;e.FtSearchResultType=void 0,(w=e.FtSearchResultType||(e.FtSearchResultType={})).MAP="MAP",w.DOCUMENT="DOCUMENT",w.TOPIC="TOPIC";const I=e=>["MAP","DOCUMENT","TOPIC"].includes(e),M=e=>s(e)&&l(e.hierarchical)&&u(e.label)&&l(e.multiSelectionable)&&u(e.key)&&Array.isArray(e.rootNodes)&&e.rootNodes.every((e=>k(e))),L=e=>s(e)&&(null==e.maxDepth||o(e.maxDepth))&&u(e.id),k=e=>s(e)&&o(e.totalResultsCount)&&l(e.descendantSelected)&&Array.isArray(e.childNodes)&&e.childNodes.every((e=>k(e)))&&u(e.label)&&u(e.value)&&l(e.selected),x=e=>s(e)&&u(e.key),N=e=>s(e)&&u(e.suggestedQuery)&&u(e.htmlSuggestedQuery),_=e=>s(e)&&u(e.filename)&&u(e.resourceUrl)&&u(e.id)&&u(e.mimeType)&&u(e.resourceContentUrl)&&u(e.viewerUrl),$=e=>s(e)&&(null==e.filenameExtension||u(e.filenameExtension))&&(null==e.editorialType||T(e.editorialType))&&(null==e.mimeType||u(e.mimeType))&&I(e.type)&&u(e.value),H=e=>"object"==typeof e&&null!=e,B=e=>"boolean"==typeof e,q=e=>"number"==typeof e,G=e=>"string"==typeof e,K=e=>H(e)&&(null==e.emailAddress||G(e.emailAddress))&&(null==e.displayName||G(e.displayName))&&Array.isArray(e.roles)&&G(e.userId),j="undefined"==typeof window?globalThis:window;function V(e){let t={};for(let r in e){let a=e[r];("object"!=typeof a||Array.isArray(a))&&(a={prior:a});for(let e of["prior","filter"])a[e]=Array.isArray(a[e])?a[e]:[a[e]],a[e]=a[e].map((e=>null!=e?""+e:"")).filter((e=>""!==e));t[r]=a}return t}function z(e){return`${e}-FluidTopicsUnauthenticatedUserSearchPreferences`}const J="undefined"==typeof window?globalThis:window;class X extends Error{status;statusText;body;constructor(e,t,r){super(`${e} - ${t}: ${r}`),this.status=e,this.statusText=t,this.body=r}}async function Y(e){if(!e.ok)throw new X(e.status,e.statusText,await e.text());return e}function Q(e){return"application/json"===e.headers.get("Content-Type")?e.json():e.text()}class W{tenantBaseUrl;ftCallingApp;authorization={};searchLabel;get defaultHeaders(){return{...this.authorization,...this.searchLabel,"Ft-Calling-App":this.ftCallingApp}}constructor(e,t,r){e=e??J.__gwt_ft_moduleBase??J.fluidtopicsclient?.__moduleBase??J.__gwt_activeModules?.fluidtopicsclient?.moduleBase,this.tenantBaseUrl=e.trim().replace(/\/$/,""),r&&void 0!==J.location&&J.location.href.startsWith(this.tenantBaseUrl+"/")?this.ftCallingApp=t:this.ftCallingApp=`ft-public-api/${t}`}setApiKey(e){this.authorization={Authorization:"Bearer "+e}}setCredentials(e,t){var r;this.authorization={Authorization:"Basic "+(r=`${e}:${t}`,"undefined"!=typeof Buffer?Buffer.from(r).toString("base64"):btoa(r))}}clearAuthentication(){this.authorization=void 0}setSearchLabel(e){this.searchLabel={"FT-search-label":e}}clearSearchLabel(){this.searchLabel=void 0}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()))}getCurrentSession(){return this.get("/api/authentication/current-session")}getMap(e){return this.get(`/api/khub/maps/${e}`)}getTableOfContent(e){return this.get(`/api/khub/maps/${e}/toc`)}getTopic(e,t){return this.get(`/api/khub/maps/${e}/topics/${t}`)}getTopicHTMLContent(e,t,r){return this.get(`/api/khub/maps/${e}/topics/${t}/content${r?"?target="+r:""}`)}getMapAttachments(e){return this.get(`/api/khub/maps/${e}/attachments`)}getMapAttachmentContent(e,t){return this.fetchRawData(`/api/khub/maps/${e}/attachments/${t}/content`)}getMapResources(e){return this.get(`/api/khub/maps/${e}/resources`)}getMapResourceContent(e,t){return this.fetchRawData(`/api/khub/maps/${e}/resources/${t}/content`)}getUnstructuredDocument(e){return this.get(`/api/khub/documents/${e}`)}getUnstructuredDocumentContent(e){return this.fetchRawData(`/api/khub/documents/${e}/content`)}getUnstructuredDocumentTextContent(e){return this.get(`/api/khub/documents/${e}/content/text`)}getCollectionDocuments(e,t){return this.get(`/api/users/${e}/collections/${t}/documents`)}getSuggestions(e){return this.post("/api/khub/suggest",e)}search(e){return this.post("/api/khub/clustered-search",e)}getAvailableSearchLocales(){return this.get("/api/khub/locales")}get(e){return this.makeRequest("GET",e)}post(e,t){return this.makeRequest("POST",e,t)}put(e,t){return this.makeRequest("PUT",e,t)}delete(e){return this.makeRequest("DELETE",e)}async fetch(e,t){const r=t;return e.startsWith("/")||(e="/"+e),await fetch(this.tenantBaseUrl+e,{...r??{},headers:{...this.defaultHeaders,...r?.headers??{}}})}async upload(e,t,r,a=(()=>{})){return new Promise(((i,n)=>{let s=new XMLHttpRequest;s.onload=()=>{if(s.status>=200&&s.status<300){let e="application/json"===s.getResponseHeader("Content-Type")?JSON.parse(s.responseText):s.responseText;i(e)}else n(new X(s.status,s.statusText,s.responseText))},s.upload.onprogress=e=>a(e),s.open(e,this.tenantBaseUrl+t,!0),s.send(r)}))}makeRequest(e,t,r){return this.fetch(t,{method:e,headers:{...null!=r?{"Content-Type":"application/json"}:{}},body:null!=r?JSON.stringify(r):void 0}).then(Y).then(Q)}fetchRawData(e){return fetch(this.tenantBaseUrl+e,{headers:this.defaultHeaders}).then(Y).then((e=>e.arrayBuffer()))}}e.FluidTopicsApi=W,e.HttpError=X,e.addUnauthenticatedUserSearchPreferencesChangeHandler=function(e,t){if(j.localStorage){const r=z(e),a=e=>{e.storageArea===j.localStorage&&e.key===r&&t(JSON.parse(e.newValue??"{}"))};return j.addEventListener("storage",a),{removeHandler:()=>j.removeEventListener("storage",a)}}console.error("Cannot handle unauthenticated preferences: local storage is unavailable.")},e.default=W,e.getUnauthenticatedUserSearchPreferences=function(e){if(j.localStorage)return JSON.parse(j.localStorage.getItem(z(e))??"{}");console.error("Cannot get unauthenticated preferences: local storage is unavailable.")},e.isFtAuthenticatedSession=e=>H(e)&&K(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)&&v(e.type),e.isFtCollectionDocumentType=v,e.isFtCredentials=e=>s(e)&&u(e.password)&&(null==e.newPassword||u(e.newPassword))&&l(e.rememberMe)&&u(e.login),e.isFtEditorialType=T,e.isFtMap=e=>s(e)&&(null==e.prettyUrl||u(e.prettyUrl))&&Array.isArray(e.metadata)&&e.metadata.every((e=>y(e)))&&E(e.openMode)&&u(e.topicsApiEndpoint)&&(null==e.description||u(e.description))&&u(e.attachmentsApiEndpoint)&&T(e.editorialType)&&u(e.baseId)&&u(e.clusterId)&&(null==e.shouldSplitCurrentPageToc||l(e.shouldSplitCurrentPageToc))&&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=>H(e)&&G(e.file)&&(null==e.size||q(e.size))&&B(e.externalLink)&&G(e.name)&&G(e.id)&&(null==e.mimeType||G(e.mimeType))&&(null==e.viewerUrl||G(e.viewerUrl)),e.isFtMapResource=e=>s(e)&&u(e.contentUrl)&&u(e.filename)&&u(e.id)&&u(e.mimeType),e.isFtMetadata=y,e.isFtMetadataPreferenceConfiguration=f,e.isFtOpenMode=E,e.isFtPageRequest=F,e.isFtSearchFacet=M,e.isFtSearchFacetConf=L,e.isFtSearchFacetEntry=k,e.isFtSearchFilter=g,e.isFtSearchLocale=h,e.isFtSearchLocales=e=>s(e)&&Array.isArray(e.contentLocales)&&e.contentLocales.every((e=>h(e))),e.isFtSearchPreferencesConfiguration=e=>s(e)&&s(e.metadata)&&Object.keys(e.metadata).every((e=>u(e)))&&Object.values(e.metadata).every((e=>f(e))),e.isFtSearchPreset=e=>s(e)&&u(e.name)&&Array.isArray(e.filters)&&e.filters.every((e=>g(e)))&&o(e.priority)&&(null==e.contentLocale||u(e.contentLocale)),e.isFtSearchPrior=S,e.isFtSearchRequest=e=>s(e)&&u(e.query)&&F(e.paging)&&Array.isArray(e.filters)&&e.filters.every((e=>g(e)))&&Array.isArray(e.sort)&&e.sort.every((e=>x(e)))&&(null==e.uiLocale||u(e.uiLocale))&&(null==e.contentLocale||u(e.contentLocale))&&(null==e.priors||Array.isArray(e.priors)&&e.priors.every((e=>S(e))))&&Array.isArray(e.facets)&&e.facets.every((e=>L(e))),e.isFtSearchResultCluster=C,e.isFtSearchResultClusterEntry=U,e.isFtSearchResultMap=O,e.isFtSearchResultTopic=D,e.isFtSearchResultType=I,e.isFtSearchResultUnstructuredDocument=P,e.isFtSearchResults=e=>s(e)&&(null==e.spellcheck||N(e.spellcheck))&&m(e.paging)&&Array.isArray(e.results)&&e.results.every((e=>C(e)))&&Array.isArray(e.facets)&&e.facets.every((e=>M(e))),e.isFtSearchResultsPageInfo=m,e.isFtSearchSortCriterion=x,e.isFtSession=e=>H(e)&&q(e.idleTimeoutInMillis)&&(null==e.profile||K(e.profile))&&B(e.sessionAuthenticated),e.isFtSpellcheck=N,e.isFtSuggestRequest=e=>s(e)&&u(e.input)&&Array.isArray(e.filters)&&e.filters.every((e=>g(e)))&&Array.isArray(e.sort)&&e.sort.every((e=>x(e)))&&(null==e.maxCount||o(e.maxCount))&&(null==e.contentLocale||u(e.contentLocale)),e.isFtSuggestResult=$,e.isFtSuggestResults=e=>s(e)&&Array.isArray(e.suggestions)&&e.suggestions.every((e=>$(e))),e.isFtTocNode=c,e.isFtTocPage=p,e.isFtTopic=e=>s(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>y(e)))&&u(e.id)&&u(e.contentApiEndpoint)&&u(e.title),e.isFtTopicContentTarget=e=>["THIRD_PARTY","OFF_THE_GRID","CONTENT_PACKAGER","PAGES","DESIGNED_READER"].includes(e),e.isFtTopicResource=_,e.isFtUnstructuredDocument=e=>s(e)&&(null==e.prettyUrl||u(e.prettyUrl))&&Array.isArray(e.metadata)&&e.metadata.every((e=>y(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=K,e.setUnauthenticatedUserSearchPreferences=function(e,t){if(j.localStorage){let r={...t,metadata:V(t.metadata??{})};const a=z(e),i=JSON.stringify(r);return j.localStorage.setItem(a,i),j.dispatchEvent(new StorageEvent("storage",{key:a,newValue:i,storageArea:j.localStorage,url:j.location.href})),r}console.error("Cannot set unauthenticated preferences: local storage is unavailable.")}}));
|
|
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:{}},a={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}(a,a.exports),function(e,t){const r=a.exports,i=r.default||r,n=function(e,t){return/^\/\//.test(e)&&(e="https:"+e),i.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 i=r.exports,n=i.fetch.bind({});n.polyfill=!0,t.fetch||(t.fetch=n,t.Response=i.Response,t.Headers=i.Headers,t.Request=i.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.topicStylesheetUrl)&&u(e.titleStylesheetUrl)&&Array.isArray(e.customCssClasses)&&e.customCssClasses.every((e=>u(e))),p=e=>s(e)&&(null==e.prettyUrl||u(e.prettyUrl))&&u(e.tocId)&&Array.isArray(e.children)&&e.children.every((e=>p(e)))&&u(e.contentId)&&(null==e.page||d(e.page))&&u(e.title),d=e=>s(e)&&l(e.visible)&&l(e.onItsOwn)&&(null==e.parentsVisibility||Array.isArray(e.parentsVisibility)&&e.parentsVisibility.every((e=>l(e))));var h;e.FtTopicContentTarget=void 0,(h=e.FtTopicContentTarget||(e.FtTopicContentTarget={})).THIRD_PARTY="THIRD_PARTY",h.OFF_THE_GRID="OFF_THE_GRID",h.CONTENT_PACKAGER="CONTENT_PACKAGER",h.PAGES="PAGES",h.DESIGNED_READER="DESIGNED_READER";const y=e=>s(e)&&o(e.count)&&u(e.label)&&(null==e.lang||u(e.lang)),g=e=>s(e)&&Array.isArray(e.values)&&e.values.every((e=>u(e)))&&u(e.label)&&u(e.key);var f;e.FtRatingType=void 0,(f=e.FtRatingType||(e.FtRatingType={})).STARS="STARS",f.LIKE="LIKE",f.DICHOTOMOUS="DICHOTOMOUS",f.NO_RATING="NO_RATING";const m=e=>["STARS","LIKE","DICHOTOMOUS","NO_RATING"].includes(e),A=e=>s(e)&&u(e.date)&&m(e.type)&&o(e.value),T=e=>s(e)&&(null==e.rating||A(e.rating))&&m(e.type),b=e=>s(e)&&u(e.date)&&u(e.tocId)&&m(e.type)&&o(e.value),R=e=>s(e)&&Array.isArray(e.ratings)&&e.ratings.every((e=>b(e)))&&m(e.type),S=e=>s(e)&&Array.isArray(e.filter)&&e.filter.every((e=>u(e)))&&Array.isArray(e.prior)&&e.prior.every((e=>u(e))),F=e=>s(e)&&l(e.negative)&&Array.isArray(e.values)&&e.values.every((e=>u(e)))&&u(e.key),v=e=>s(e)&&o(e.totalResultsCount)&&l(e.lastPage)&&o(e.currentPage)&&o(e.totalClustersCount);var E;e.FtEditorialType=void 0,(E=e.FtEditorialType||(e.FtEditorialType={})).ARTICLE="ARTICLE",E.BOOK="BOOK";const C=e=>["ARTICLE","BOOK"].includes(e);var U;e.FtOpenMode=void 0,(U=e.FtOpenMode||(e.FtOpenMode={})).FLUIDTOPICS="FLUIDTOPICS",U.EXTERNAL="EXTERNAL";const O=e=>["FLUIDTOPICS","EXTERNAL"].includes(e),D=e=>s(e)&&(null==e.perPage||o(e.perPage))&&o(e.page);var P;e.FtCollectionDocumentType=void 0,(P=e.FtCollectionDocumentType||(e.FtCollectionDocumentType={})).MAP="MAP",P.DOCUMENT="DOCUMENT",P.TOPIC="TOPIC",P.PERSONAL_BOOK="PERSONAL_BOOK",P.SHARED_BOOK="SHARED_BOOK";const I=e=>["MAP","DOCUMENT","TOPIC","PERSONAL_BOOK","SHARED_BOOK"].includes(e),w=e=>s(e)&&o(e.weight)&&u(e.value)&&u(e.key),M=e=>s(e)&&Array.isArray(e.entries)&&e.entries.every((e=>k(e)))&&(null==e.metadataVariableAxis||u(e.metadataVariableAxis)),k=e=>s(e)&&(null==e.document||L(e.document))&&(null==e.topic||$(e.topic))&&_(e.type)&&(null==e.map||N(e.map)),L=e=>s(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>g(e)))&&O(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),N=e=>s(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>g(e)))&&(null==e.openMode||O(e.openMode))&&C(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),$=e=>s(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>g(e)))&&O(e.openMode)&&u(e.contentId)&&Array.isArray(e.resources)&&e.resources.every((e=>j(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 x;e.FtSearchResultType=void 0,(x=e.FtSearchResultType||(e.FtSearchResultType={})).MAP="MAP",x.DOCUMENT="DOCUMENT",x.TOPIC="TOPIC";const _=e=>["MAP","DOCUMENT","TOPIC"].includes(e),H=e=>s(e)&&l(e.hierarchical)&&u(e.label)&&l(e.multiSelectionable)&&u(e.key)&&Array.isArray(e.rootNodes)&&e.rootNodes.every((e=>q(e))),B=e=>s(e)&&(null==e.maxDepth||o(e.maxDepth))&&u(e.id),q=e=>s(e)&&o(e.totalResultsCount)&&l(e.descendantSelected)&&Array.isArray(e.childNodes)&&e.childNodes.every((e=>q(e)))&&u(e.label)&&u(e.value)&&l(e.selected),G=e=>s(e)&&u(e.key),K=e=>s(e)&&u(e.suggestedQuery)&&u(e.htmlSuggestedQuery),j=e=>s(e)&&u(e.filename)&&u(e.resourceUrl)&&u(e.id)&&u(e.mimeType)&&u(e.resourceContentUrl)&&u(e.viewerUrl),V=e=>s(e)&&(null==e.filenameExtension||u(e.filenameExtension))&&(null==e.editorialType||C(e.editorialType))&&(null==e.mimeType||u(e.mimeType))&&_(e.type)&&u(e.value),z=e=>"object"==typeof e&&null!=e,J=e=>"boolean"==typeof e,X=e=>"number"==typeof e,Y=e=>"string"==typeof e,Q=e=>z(e)&&(null==e.emailAddress||Y(e.emailAddress))&&(null==e.displayName||Y(e.displayName))&&Array.isArray(e.roles)&&Y(e.userId),W="undefined"==typeof window?globalThis:window;function Z(e){let t={};for(let r in e){let a=e[r];("object"!=typeof a||Array.isArray(a))&&(a={prior:a});for(let e of["prior","filter"])a[e]=Array.isArray(a[e])?a[e]:[a[e]],a[e]=a[e].map((e=>null!=e?""+e:"")).filter((e=>""!==e));t[r]=a}return t}function ee(e){return`${e}-FluidTopicsUnauthenticatedUserSearchPreferences`}const te="undefined"==typeof window?globalThis:window;class re extends Error{status;statusText;body;constructor(e,t,r){super(`${e} - ${t}: ${r}`),this.status=e,this.statusText=t,this.body=r}}async function ae(e){if(!e.ok)throw new re(e.status,e.statusText,await e.text());return e}function ie(e){return"application/json"===e.headers.get("Content-Type")?e.json():e.text()}class ne{tenantBaseUrl;ftCallingApp;authorization={};searchLabel;get defaultHeaders(){return{...this.authorization,...this.searchLabel,"Ft-Calling-App":this.ftCallingApp}}constructor(e,t,r){e=e??te.__gwt_ft_moduleBase??te.fluidtopicsclient?.__moduleBase??te.__gwt_activeModules?.fluidtopicsclient?.moduleBase,this.tenantBaseUrl=e.trim().replace(/\/$/,""),r&&void 0!==te.location&&te.location.href.startsWith(this.tenantBaseUrl+"/")?this.ftCallingApp=t:this.ftCallingApp=`ft-public-api/${t}`}setApiKey(e){this.authorization={Authorization:"Bearer "+e}}setCredentials(e,t){var r;this.authorization={Authorization:"Basic "+(r=`${e}:${t}`,"undefined"!=typeof Buffer?Buffer.from(r).toString("base64"):btoa(r))}}clearAuthentication(){this.authorization=void 0}setSearchLabel(e){this.searchLabel={"FT-search-label":e}}clearSearchLabel(){this.searchLabel=void 0}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()))}getCurrentSession(){return this.get("/api/authentication/current-session")}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")}getMapRating(e){return this.get(`/api/khub/maps/${e}/rating`)}getDocumentRating(e){return this.get(`/api/khub/documents/${e}/rating`)}rateMap(e,t,r){return this.post(`/api/khub/maps/${e}/rating`,{type:t,value:r})}unrateMap(e){return this.delete(`/api/khub/maps/${e}/rating`)}rateTopic(e,t,r,a){return this.post(`/api/khub/maps/${e}/topics/${t}/rating`,{type:r,value:a})}unrateTopic(e,t){return this.delete(`/api/khub/maps/${e}/topics/${t}/rating`)}rateDocument(e,t,r){return this.post(`/api/khub/documents/${e}/rating`,{type:t,value:r})}unrateDocument(e){return this.delete(`/api/khub/documents/${e}/rating`)}get(e){return this.makeRequest("GET",e)}post(e,t){return this.makeRequest("POST",e,t)}put(e,t){return this.makeRequest("PUT",e,t)}delete(e){return this.makeRequest("DELETE",e)}async fetch(e,t){const r=t;return e.startsWith("/")||(e="/"+e),await fetch(this.tenantBaseUrl+e,{...r??{},headers:{...this.defaultHeaders,...r?.headers??{}}})}async upload(e,t,r,a=(()=>{})){return new Promise(((i,n)=>{let s=new XMLHttpRequest;s.onload=()=>{if(s.status>=200&&s.status<300){let e="application/json"===s.getResponseHeader("Content-Type")?JSON.parse(s.responseText):s.responseText;i(e)}else n(new re(s.status,s.statusText,s.responseText))},s.upload.onprogress=e=>a(e),s.open(e,this.tenantBaseUrl+t,!0),s.send(r)}))}makeRequest(e,t,r){return this.fetch(t,{method:e,headers:{...null!=r?{"Content-Type":"application/json"}:{}},body:null!=r?JSON.stringify(r):void 0}).then(ae).then(ie)}fetchRawData(e){return fetch(this.tenantBaseUrl+e,{headers:this.defaultHeaders}).then(ae).then((e=>e.arrayBuffer()))}}e.FluidTopicsApi=ne,e.HttpError=re,e.addUnauthenticatedUserSearchPreferencesChangeHandler=function(e,t){if(W.localStorage){const r=ee(e),a=e=>{e.storageArea===W.localStorage&&e.key===r&&t(JSON.parse(e.newValue??"{}"))};return W.addEventListener("storage",a),{removeHandler:()=>W.removeEventListener("storage",a)}}console.error("Cannot handle unauthenticated preferences: local storage is unavailable.")},e.default=ne,e.getUnauthenticatedUserSearchPreferences=function(e){if(W.localStorage)return JSON.parse(W.localStorage.getItem(ee(e))??"{}");console.error("Cannot get unauthenticated preferences: local storage is unavailable.")},e.isFtAuthenticatedSession=e=>z(e)&&Q(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)&&I(e.type),e.isFtCollectionDocumentType=I,e.isFtCredentials=e=>s(e)&&u(e.password)&&(null==e.newPassword||u(e.newPassword))&&l(e.rememberMe)&&u(e.login),e.isFtEditorialType=C,e.isFtMap=e=>s(e)&&(null==e.prettyUrl||u(e.prettyUrl))&&Array.isArray(e.metadata)&&e.metadata.every((e=>g(e)))&&O(e.openMode)&&u(e.topicsApiEndpoint)&&(null==e.description||u(e.description))&&u(e.attachmentsApiEndpoint)&&C(e.editorialType)&&u(e.baseId)&&u(e.clusterId)&&(null==e.shouldSplitCurrentPageToc||l(e.shouldSplitCurrentPageToc))&&u(e.title)&&u(e.lastPublication)&&u(e.lastEdition)&&u(e.originId)&&u(e.rightsApiEndpoint)&&c(e.contentStyles)&&(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=>z(e)&&Y(e.file)&&(null==e.size||X(e.size))&&J(e.externalLink)&&Y(e.name)&&Y(e.id)&&(null==e.mimeType||Y(e.mimeType))&&(null==e.viewerUrl||Y(e.viewerUrl)),e.isFtMapResource=e=>s(e)&&u(e.contentUrl)&&u(e.filename)&&u(e.id)&&u(e.mimeType),e.isFtMapStyles=c,e.isFtMetadata=g,e.isFtMetadataPreferenceConfiguration=S,e.isFtOpenMode=O,e.isFtPageRequest=D,e.isFtPublicationRating=A,e.isFtPublicationRatingSummary=T,e.isFtRatingCreation=e=>s(e)&&m(e.type)&&o(e.value),e.isFtRatingSummary=e=>s(e)&&(null==e.topics||R(e.topics))&&T(e.publication),e.isFtRatingType=m,e.isFtSearchFacet=H,e.isFtSearchFacetConf=B,e.isFtSearchFacetEntry=q,e.isFtSearchFilter=F,e.isFtSearchLocale=y,e.isFtSearchLocales=e=>s(e)&&Array.isArray(e.contentLocales)&&e.contentLocales.every((e=>y(e))),e.isFtSearchPreferencesConfiguration=e=>s(e)&&s(e.metadata)&&Object.keys(e.metadata).every((e=>u(e)))&&Object.values(e.metadata).every((e=>S(e))),e.isFtSearchPreset=e=>s(e)&&u(e.name)&&Array.isArray(e.filters)&&e.filters.every((e=>F(e)))&&o(e.priority)&&(null==e.contentLocale||u(e.contentLocale)),e.isFtSearchPrior=w,e.isFtSearchRequest=e=>s(e)&&u(e.query)&&D(e.paging)&&Array.isArray(e.filters)&&e.filters.every((e=>F(e)))&&Array.isArray(e.sort)&&e.sort.every((e=>G(e)))&&(null==e.uiLocale||u(e.uiLocale))&&(null==e.contentLocale||u(e.contentLocale))&&(null==e.priors||Array.isArray(e.priors)&&e.priors.every((e=>w(e))))&&Array.isArray(e.facets)&&e.facets.every((e=>B(e))),e.isFtSearchResultCluster=M,e.isFtSearchResultClusterEntry=k,e.isFtSearchResultMap=N,e.isFtSearchResultTopic=$,e.isFtSearchResultType=_,e.isFtSearchResultUnstructuredDocument=L,e.isFtSearchResults=e=>s(e)&&(null==e.spellcheck||K(e.spellcheck))&&v(e.paging)&&Array.isArray(e.results)&&e.results.every((e=>M(e)))&&Array.isArray(e.facets)&&e.facets.every((e=>H(e))),e.isFtSearchResultsPageInfo=v,e.isFtSearchSortCriterion=G,e.isFtSession=e=>z(e)&&X(e.idleTimeoutInMillis)&&(null==e.profile||Q(e.profile))&&J(e.sessionAuthenticated),e.isFtSpellcheck=K,e.isFtSuggestRequest=e=>s(e)&&u(e.input)&&Array.isArray(e.filters)&&e.filters.every((e=>F(e)))&&Array.isArray(e.sort)&&e.sort.every((e=>G(e)))&&(null==e.maxCount||o(e.maxCount))&&(null==e.contentLocale||u(e.contentLocale)),e.isFtSuggestResult=V,e.isFtSuggestResults=e=>s(e)&&Array.isArray(e.suggestions)&&e.suggestions.every((e=>V(e))),e.isFtTocNode=p,e.isFtTocPage=d,e.isFtTopic=e=>s(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>g(e)))&&u(e.id)&&u(e.contentApiEndpoint)&&u(e.title),e.isFtTopicContentTarget=e=>["THIRD_PARTY","OFF_THE_GRID","CONTENT_PACKAGER","PAGES","DESIGNED_READER"].includes(e),e.isFtTopicRating=b,e.isFtTopicResource=j,e.isFtTopicsRatingSummary=R,e.isFtUnstructuredDocument=e=>s(e)&&(null==e.prettyUrl||u(e.prettyUrl))&&Array.isArray(e.metadata)&&e.metadata.every((e=>g(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=Q,e.setUnauthenticatedUserSearchPreferences=function(e,t){if(W.localStorage){let r={...t,metadata:Z(t.metadata??{})};const a=ee(e),i=JSON.stringify(r);return W.localStorage.setItem(a,i),W.dispatchEvent(new StorageEvent("storage",{key:a,newValue:i,storageArea:W.localStorage,url:W.location.href})),r}console.error("Cannot set unauthenticated preferences: local storage is unavailable.")}}));
|
package/dist/mjs/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "cross-fetch/polyfill";
|
|
2
|
-
import { FtCollectionDocument, FtMap, FtMapResource, FtSearchLocales, FtSearchRequest, FtSearchResults, FtSuggestRequest, FtSuggestResults, FtTocNode, FtTopic, FtTopicContentTarget, FtTopicContentTargetKeys, FtUnstructuredDocument } from "./types/ft-common/public";
|
|
2
|
+
import { FtCollectionDocument, FtMap, FtMapResource, FtRatingSummary, FtRatingType, FtSearchLocales, FtSearchRequest, FtSearchResults, FtSuggestRequest, FtSuggestResults, FtTocNode, FtTopic, FtTopicContentTarget, FtTopicContentTargetKeys, FtUnstructuredDocument } from "./types/ft-common/public";
|
|
3
3
|
import { FtAuthenticatedSession, FtMapAttachment, FtSession } from "./types/ft-server/public";
|
|
4
4
|
export * from "./types/ft-common/public";
|
|
5
5
|
export * from "./types/ft-server/public";
|
|
@@ -11,7 +11,7 @@ export declare class HttpError extends Error {
|
|
|
11
11
|
constructor(status: number, statusText: string, body: string);
|
|
12
12
|
}
|
|
13
13
|
export declare class FluidTopicsApi {
|
|
14
|
-
|
|
14
|
+
readonly tenantBaseUrl: string;
|
|
15
15
|
private readonly ftCallingApp;
|
|
16
16
|
private authorization;
|
|
17
17
|
private searchLabel;
|
|
@@ -40,6 +40,14 @@ export declare class FluidTopicsApi {
|
|
|
40
40
|
getSuggestions(request: FtSuggestRequest): Promise<FtSuggestResults>;
|
|
41
41
|
search(request: FtSearchRequest): Promise<FtSearchResults>;
|
|
42
42
|
getAvailableSearchLocales(): Promise<FtSearchLocales>;
|
|
43
|
+
getMapRating(mapId: string): Promise<FtRatingSummary>;
|
|
44
|
+
getDocumentRating(docId: string): Promise<FtRatingSummary>;
|
|
45
|
+
rateMap(mapId: string, type: FtRatingType, value: number): Promise<void>;
|
|
46
|
+
unrateMap(mapId: string): Promise<void>;
|
|
47
|
+
rateTopic(mapId: string, tocId: string, type: FtRatingType, value: number): Promise<void>;
|
|
48
|
+
unrateTopic(mapId: string, tocId: string): Promise<void>;
|
|
49
|
+
rateDocument(docId: string, type: FtRatingType, value: number): Promise<void>;
|
|
50
|
+
unrateDocument(docId: string): Promise<void>;
|
|
43
51
|
get<T>(endpoint: string): Promise<T>;
|
|
44
52
|
post<T>(endpoint: string, data?: any): Promise<T>;
|
|
45
53
|
put<T>(endpoint: string, data?: any): Promise<T>;
|
package/dist/mjs/index.js
CHANGED
|
@@ -128,6 +128,30 @@ export class FluidTopicsApi {
|
|
|
128
128
|
getAvailableSearchLocales() {
|
|
129
129
|
return this.get("/api/khub/locales");
|
|
130
130
|
}
|
|
131
|
+
getMapRating(mapId) {
|
|
132
|
+
return this.get(`/api/khub/maps/${mapId}/rating`);
|
|
133
|
+
}
|
|
134
|
+
getDocumentRating(docId) {
|
|
135
|
+
return this.get(`/api/khub/documents/${docId}/rating`);
|
|
136
|
+
}
|
|
137
|
+
rateMap(mapId, type, value) {
|
|
138
|
+
return this.post(`/api/khub/maps/${mapId}/rating`, { type, value });
|
|
139
|
+
}
|
|
140
|
+
unrateMap(mapId) {
|
|
141
|
+
return this.delete(`/api/khub/maps/${mapId}/rating`);
|
|
142
|
+
}
|
|
143
|
+
rateTopic(mapId, tocId, type, value) {
|
|
144
|
+
return this.post(`/api/khub/maps/${mapId}/topics/${tocId}/rating`, { type, value });
|
|
145
|
+
}
|
|
146
|
+
unrateTopic(mapId, tocId) {
|
|
147
|
+
return this.delete(`/api/khub/maps/${mapId}/topics/${tocId}/rating`);
|
|
148
|
+
}
|
|
149
|
+
rateDocument(docId, type, value) {
|
|
150
|
+
return this.post(`/api/khub/documents/${docId}/rating`, { type, value });
|
|
151
|
+
}
|
|
152
|
+
unrateDocument(docId) {
|
|
153
|
+
return this.delete(`/api/khub/documents/${docId}/rating`);
|
|
154
|
+
}
|
|
131
155
|
get(endpoint) {
|
|
132
156
|
return this.makeRequest("GET", endpoint);
|
|
133
157
|
}
|
|
@@ -30,6 +30,7 @@ export interface FtMap {
|
|
|
30
30
|
lastEdition: string;
|
|
31
31
|
originId: string;
|
|
32
32
|
rightsApiEndpoint: string;
|
|
33
|
+
contentStyles: FtMapStyles;
|
|
33
34
|
originUrl?: string;
|
|
34
35
|
readerUrl: string;
|
|
35
36
|
khubVersion?: string;
|
|
@@ -37,6 +38,12 @@ export interface FtMap {
|
|
|
37
38
|
lang?: string;
|
|
38
39
|
}
|
|
39
40
|
export declare const isFtMap: (o: any) => o is FtMap;
|
|
41
|
+
export interface FtMapStyles {
|
|
42
|
+
topicStylesheetUrl: string;
|
|
43
|
+
titleStylesheetUrl: string;
|
|
44
|
+
customCssClasses: Array<string>;
|
|
45
|
+
}
|
|
46
|
+
export declare const isFtMapStyles: (o: any) => o is FtMapStyles;
|
|
40
47
|
export interface FtTocNode {
|
|
41
48
|
prettyUrl?: string;
|
|
42
49
|
tocId: string;
|
|
@@ -106,6 +113,47 @@ export interface FtMetadata {
|
|
|
106
113
|
key: string;
|
|
107
114
|
}
|
|
108
115
|
export declare const isFtMetadata: (o: any) => o is FtMetadata;
|
|
116
|
+
export declare enum FtRatingType {
|
|
117
|
+
STARS = "STARS",
|
|
118
|
+
LIKE = "LIKE",
|
|
119
|
+
DICHOTOMOUS = "DICHOTOMOUS",
|
|
120
|
+
NO_RATING = "NO_RATING"
|
|
121
|
+
}
|
|
122
|
+
export declare type FtRatingTypeKeys = keyof typeof FtRatingType;
|
|
123
|
+
export declare const isFtRatingType: (o: any) => o is FtRatingType;
|
|
124
|
+
export interface FtPublicationRating {
|
|
125
|
+
date: Date;
|
|
126
|
+
type: FtRatingType;
|
|
127
|
+
value: number;
|
|
128
|
+
}
|
|
129
|
+
export declare const isFtPublicationRating: (o: any) => o is FtPublicationRating;
|
|
130
|
+
export interface FtPublicationRatingSummary {
|
|
131
|
+
rating?: FtPublicationRating;
|
|
132
|
+
type: FtRatingType;
|
|
133
|
+
}
|
|
134
|
+
export declare const isFtPublicationRatingSummary: (o: any) => o is FtPublicationRatingSummary;
|
|
135
|
+
export interface FtRatingCreation {
|
|
136
|
+
type: FtRatingType;
|
|
137
|
+
value: number;
|
|
138
|
+
}
|
|
139
|
+
export declare const isFtRatingCreation: (o: any) => o is FtRatingCreation;
|
|
140
|
+
export interface FtRatingSummary {
|
|
141
|
+
topics?: FtTopicsRatingSummary;
|
|
142
|
+
publication: FtPublicationRatingSummary;
|
|
143
|
+
}
|
|
144
|
+
export declare const isFtRatingSummary: (o: any) => o is FtRatingSummary;
|
|
145
|
+
export interface FtTopicRating {
|
|
146
|
+
date: Date;
|
|
147
|
+
tocId: string;
|
|
148
|
+
type: FtRatingType;
|
|
149
|
+
value: number;
|
|
150
|
+
}
|
|
151
|
+
export declare const isFtTopicRating: (o: any) => o is FtTopicRating;
|
|
152
|
+
export interface FtTopicsRatingSummary {
|
|
153
|
+
ratings: Array<FtTopicRating>;
|
|
154
|
+
type: FtRatingType;
|
|
155
|
+
}
|
|
156
|
+
export declare const isFtTopicsRatingSummary: (o: any) => o is FtTopicsRatingSummary;
|
|
109
157
|
export interface FtMapResource {
|
|
110
158
|
contentUrl: string;
|
|
111
159
|
filename: string;
|
|
@@ -36,12 +36,20 @@ export const isFtMap = (o) => {
|
|
|
36
36
|
&& (isString(o.lastEdition))
|
|
37
37
|
&& (isString(o.originId))
|
|
38
38
|
&& (isString(o.rightsApiEndpoint))
|
|
39
|
+
&& (isFtMapStyles(o.contentStyles))
|
|
39
40
|
&& (o.originUrl == null || isString(o.originUrl))
|
|
40
41
|
&& (isString(o.readerUrl))
|
|
41
42
|
&& (o.khubVersion == null || isString(o.khubVersion))
|
|
42
43
|
&& (isString(o.id))
|
|
43
44
|
&& (o.lang == null || isString(o.lang));
|
|
44
45
|
};
|
|
46
|
+
export const isFtMapStyles = (o) => {
|
|
47
|
+
return isObject(o)
|
|
48
|
+
&& (isString(o.topicStylesheetUrl))
|
|
49
|
+
&& (isString(o.titleStylesheetUrl))
|
|
50
|
+
&& ((Array.isArray(o.customCssClasses)
|
|
51
|
+
&& o.customCssClasses.every((v) => isString(v))));
|
|
52
|
+
};
|
|
45
53
|
export const isFtTocNode = (o) => {
|
|
46
54
|
return isObject(o)
|
|
47
55
|
&& (o.prettyUrl == null || isString(o.prettyUrl))
|
|
@@ -120,6 +128,51 @@ export const isFtMetadata = (o) => {
|
|
|
120
128
|
&& (isString(o.label))
|
|
121
129
|
&& (isString(o.key));
|
|
122
130
|
};
|
|
131
|
+
// From: RatingType
|
|
132
|
+
export var FtRatingType;
|
|
133
|
+
(function (FtRatingType) {
|
|
134
|
+
FtRatingType["STARS"] = "STARS";
|
|
135
|
+
FtRatingType["LIKE"] = "LIKE";
|
|
136
|
+
FtRatingType["DICHOTOMOUS"] = "DICHOTOMOUS";
|
|
137
|
+
FtRatingType["NO_RATING"] = "NO_RATING";
|
|
138
|
+
})(FtRatingType || (FtRatingType = {}));
|
|
139
|
+
export const isFtRatingType = (o) => {
|
|
140
|
+
return ["STARS", "LIKE", "DICHOTOMOUS", "NO_RATING"].includes(o);
|
|
141
|
+
};
|
|
142
|
+
export const isFtPublicationRating = (o) => {
|
|
143
|
+
return isObject(o)
|
|
144
|
+
&& (isString(o.date))
|
|
145
|
+
&& (isFtRatingType(o.type))
|
|
146
|
+
&& (isNumber(o.value));
|
|
147
|
+
};
|
|
148
|
+
export const isFtPublicationRatingSummary = (o) => {
|
|
149
|
+
return isObject(o)
|
|
150
|
+
&& (o.rating == null || isFtPublicationRating(o.rating))
|
|
151
|
+
&& (isFtRatingType(o.type));
|
|
152
|
+
};
|
|
153
|
+
export const isFtRatingCreation = (o) => {
|
|
154
|
+
return isObject(o)
|
|
155
|
+
&& (isFtRatingType(o.type))
|
|
156
|
+
&& (isNumber(o.value));
|
|
157
|
+
};
|
|
158
|
+
export const isFtRatingSummary = (o) => {
|
|
159
|
+
return isObject(o)
|
|
160
|
+
&& (o.topics == null || isFtTopicsRatingSummary(o.topics))
|
|
161
|
+
&& (isFtPublicationRatingSummary(o.publication));
|
|
162
|
+
};
|
|
163
|
+
export const isFtTopicRating = (o) => {
|
|
164
|
+
return isObject(o)
|
|
165
|
+
&& (isString(o.date))
|
|
166
|
+
&& (isString(o.tocId))
|
|
167
|
+
&& (isFtRatingType(o.type))
|
|
168
|
+
&& (isNumber(o.value));
|
|
169
|
+
};
|
|
170
|
+
export const isFtTopicsRatingSummary = (o) => {
|
|
171
|
+
return isObject(o)
|
|
172
|
+
&& ((Array.isArray(o.ratings)
|
|
173
|
+
&& o.ratings.every((v) => isFtTopicRating(v))))
|
|
174
|
+
&& (isFtRatingType(o.type));
|
|
175
|
+
};
|
|
123
176
|
export const isFtMapResource = (o) => {
|
|
124
177
|
return isObject(o)
|
|
125
178
|
&& (isString(o.contentUrl))
|