@fluid-topics/public-api 1.0.24 → 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 +54 -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 +41 -0
- package/dist/mjs/types/ft-common/public.js +45 -0
- package/package.json +1 -1
- package/.yarnrc +0 -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";
|
|
@@ -143,6 +144,58 @@ const isFtMetadata = (o) => {
|
|
|
143
144
|
&& (isString(o.key));
|
|
144
145
|
};
|
|
145
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;
|
|
146
199
|
const isFtMapResource = (o) => {
|
|
147
200
|
return isObject(o)
|
|
148
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)&&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)),f=e=>s(e)&&Array.isArray(e.values)&&e.values.every((e=>u(e)))&&u(e.label)&&u(e.key),g=e=>s(e)&&Array.isArray(e.filter)&&e.filter.every((e=>u(e)))&&Array.isArray(e.prior)&&e.prior.every((e=>u(e))),m=e=>s(e)&&l(e.negative)&&Array.isArray(e.values)&&e.values.every((e=>u(e)))&&u(e.key),A=e=>s(e)&&o(e.totalResultsCount)&&l(e.lastPage)&&o(e.currentPage)&&o(e.totalClustersCount);var T;e.FtEditorialType=void 0,(T=e.FtEditorialType||(e.FtEditorialType={})).ARTICLE="ARTICLE",T.BOOK="BOOK";const b=e=>["ARTICLE","BOOK"].includes(e);var E;e.FtOpenMode=void 0,(E=e.FtOpenMode||(e.FtOpenMode={})).FLUIDTOPICS="FLUIDTOPICS",E.EXTERNAL="EXTERNAL";const F=e=>["FLUIDTOPICS","EXTERNAL"].includes(e),S=e=>s(e)&&(null==e.perPage||o(e.perPage))&&o(e.page);var v;e.FtCollectionDocumentType=void 0,(v=e.FtCollectionDocumentType||(e.FtCollectionDocumentType={})).MAP="MAP",v.DOCUMENT="DOCUMENT",v.TOPIC="TOPIC",v.PERSONAL_BOOK="PERSONAL_BOOK",v.SHARED_BOOK="SHARED_BOOK";const C=e=>["MAP","DOCUMENT","TOPIC","PERSONAL_BOOK","SHARED_BOOK"].includes(e),R=e=>s(e)&&o(e.weight)&&u(e.value)&&u(e.key),U=e=>s(e)&&Array.isArray(e.entries)&&e.entries.every((e=>P(e)))&&(null==e.metadataVariableAxis||u(e.metadataVariableAxis)),P=e=>s(e)&&(null==e.document||O(e.document))&&(null==e.topic||w(e.topic))&&M(e.type)&&(null==e.map||D(e.map)),O=e=>s(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>f(e)))&&F(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),D=e=>s(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>f(e)))&&(null==e.openMode||F(e.openMode))&&b(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),w=e=>s(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>f(e)))&&F(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 I;e.FtSearchResultType=void 0,(I=e.FtSearchResultType||(e.FtSearchResultType={})).MAP="MAP",I.DOCUMENT="DOCUMENT",I.TOPIC="TOPIC";const M=e=>["MAP","DOCUMENT","TOPIC"].includes(e),L=e=>s(e)&&l(e.hierarchical)&&u(e.label)&&l(e.multiSelectionable)&&u(e.key)&&Array.isArray(e.rootNodes)&&e.rootNodes.every((e=>x(e))),k=e=>s(e)&&(null==e.maxDepth||o(e.maxDepth))&&u(e.id),x=e=>s(e)&&o(e.totalResultsCount)&&l(e.descendantSelected)&&Array.isArray(e.childNodes)&&e.childNodes.every((e=>x(e)))&&u(e.label)&&u(e.value)&&l(e.selected),N=e=>s(e)&&u(e.key),_=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),H=e=>s(e)&&(null==e.filenameExtension||u(e.filenameExtension))&&(null==e.editorialType||b(e.editorialType))&&(null==e.mimeType||u(e.mimeType))&&M(e.type)&&u(e.value),B=e=>"object"==typeof e&&null!=e,q=e=>"boolean"==typeof e,G=e=>"number"==typeof e,K=e=>"string"==typeof e,j=e=>B(e)&&(null==e.emailAddress||K(e.emailAddress))&&(null==e.displayName||K(e.displayName))&&Array.isArray(e.roles)&&K(e.userId),V="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 J(e){return`${e}-FluidTopicsUnauthenticatedUserSearchPreferences`}const X="undefined"==typeof window?globalThis:window;class Y extends Error{status;statusText;body;constructor(e,t,r){super(`${e} - ${t}: ${r}`),this.status=e,this.statusText=t,this.body=r}}async function Q(e){if(!e.ok)throw new Y(e.status,e.statusText,await e.text());return e}function W(e){return"application/json"===e.headers.get("Content-Type")?e.json():e.text()}class Z{tenantBaseUrl;ftCallingApp;authorization={};searchLabel;get defaultHeaders(){return{...this.authorization,...this.searchLabel,"Ft-Calling-App":this.ftCallingApp}}constructor(e,t,r){e=e??X.__gwt_ft_moduleBase??X.fluidtopicsclient?.__moduleBase??X.__gwt_activeModules?.fluidtopicsclient?.moduleBase,this.tenantBaseUrl=e.trim().replace(/\/$/,""),r&&void 0!==X.location&&X.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 Y(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(Q).then(W)}fetchRawData(e){return fetch(this.tenantBaseUrl+e,{headers:this.defaultHeaders}).then(Q).then((e=>e.arrayBuffer()))}}e.FluidTopicsApi=Z,e.HttpError=Y,e.addUnauthenticatedUserSearchPreferencesChangeHandler=function(e,t){if(V.localStorage){const r=J(e),a=e=>{e.storageArea===V.localStorage&&e.key===r&&t(JSON.parse(e.newValue??"{}"))};return V.addEventListener("storage",a),{removeHandler:()=>V.removeEventListener("storage",a)}}console.error("Cannot handle unauthenticated preferences: local storage is unavailable.")},e.default=Z,e.getUnauthenticatedUserSearchPreferences=function(e){if(V.localStorage)return JSON.parse(V.localStorage.getItem(J(e))??"{}");console.error("Cannot get unauthenticated preferences: local storage is unavailable.")},e.isFtAuthenticatedSession=e=>B(e)&&j(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.isFtCollectionDocumentType=C,e.isFtCredentials=e=>s(e)&&u(e.password)&&(null==e.newPassword||u(e.newPassword))&&l(e.rememberMe)&&u(e.login),e.isFtEditorialType=b,e.isFtMap=e=>s(e)&&(null==e.prettyUrl||u(e.prettyUrl))&&Array.isArray(e.metadata)&&e.metadata.every((e=>f(e)))&&F(e.openMode)&&u(e.topicsApiEndpoint)&&(null==e.description||u(e.description))&&u(e.attachmentsApiEndpoint)&&b(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=>B(e)&&K(e.file)&&(null==e.size||G(e.size))&&q(e.externalLink)&&K(e.name)&&K(e.id)&&(null==e.mimeType||K(e.mimeType))&&(null==e.viewerUrl||K(e.viewerUrl)),e.isFtMapResource=e=>s(e)&&u(e.contentUrl)&&u(e.filename)&&u(e.id)&&u(e.mimeType),e.isFtMapStyles=c,e.isFtMetadata=f,e.isFtMetadataPreferenceConfiguration=g,e.isFtOpenMode=F,e.isFtPageRequest=S,e.isFtSearchFacet=L,e.isFtSearchFacetConf=k,e.isFtSearchFacetEntry=x,e.isFtSearchFilter=m,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=>g(e))),e.isFtSearchPreset=e=>s(e)&&u(e.name)&&Array.isArray(e.filters)&&e.filters.every((e=>m(e)))&&o(e.priority)&&(null==e.contentLocale||u(e.contentLocale)),e.isFtSearchPrior=R,e.isFtSearchRequest=e=>s(e)&&u(e.query)&&S(e.paging)&&Array.isArray(e.filters)&&e.filters.every((e=>m(e)))&&Array.isArray(e.sort)&&e.sort.every((e=>N(e)))&&(null==e.uiLocale||u(e.uiLocale))&&(null==e.contentLocale||u(e.contentLocale))&&(null==e.priors||Array.isArray(e.priors)&&e.priors.every((e=>R(e))))&&Array.isArray(e.facets)&&e.facets.every((e=>k(e))),e.isFtSearchResultCluster=U,e.isFtSearchResultClusterEntry=P,e.isFtSearchResultMap=D,e.isFtSearchResultTopic=w,e.isFtSearchResultType=M,e.isFtSearchResultUnstructuredDocument=O,e.isFtSearchResults=e=>s(e)&&(null==e.spellcheck||_(e.spellcheck))&&A(e.paging)&&Array.isArray(e.results)&&e.results.every((e=>U(e)))&&Array.isArray(e.facets)&&e.facets.every((e=>L(e))),e.isFtSearchResultsPageInfo=A,e.isFtSearchSortCriterion=N,e.isFtSession=e=>B(e)&&G(e.idleTimeoutInMillis)&&(null==e.profile||j(e.profile))&&q(e.sessionAuthenticated),e.isFtSpellcheck=_,e.isFtSuggestRequest=e=>s(e)&&u(e.input)&&Array.isArray(e.filters)&&e.filters.every((e=>m(e)))&&Array.isArray(e.sort)&&e.sort.every((e=>N(e)))&&(null==e.maxCount||o(e.maxCount))&&(null==e.contentLocale||u(e.contentLocale)),e.isFtSuggestResult=H,e.isFtSuggestResults=e=>s(e)&&Array.isArray(e.suggestions)&&e.suggestions.every((e=>H(e))),e.isFtTocNode=p,e.isFtTocPage=d,e.isFtTopic=e=>s(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>f(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=>f(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=j,e.setUnauthenticatedUserSearchPreferences=function(e,t){if(V.localStorage){let r={...t,metadata:z(t.metadata??{})};const a=J(e),i=JSON.stringify(r);return V.localStorage.setItem(a,i),V.dispatchEvent(new StorageEvent("storage",{key:a,newValue:i,storageArea:V.localStorage,url:V.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
|
}
|
|
@@ -113,6 +113,47 @@ export interface FtMetadata {
|
|
|
113
113
|
key: string;
|
|
114
114
|
}
|
|
115
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;
|
|
116
157
|
export interface FtMapResource {
|
|
117
158
|
contentUrl: string;
|
|
118
159
|
filename: string;
|
|
@@ -128,6 +128,51 @@ export const isFtMetadata = (o) => {
|
|
|
128
128
|
&& (isString(o.label))
|
|
129
129
|
&& (isString(o.key));
|
|
130
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
|
+
};
|
|
131
176
|
export const isFtMapResource = (o) => {
|
|
132
177
|
return isObject(o)
|
|
133
178
|
&& (isString(o.contentUrl))
|
package/package.json
CHANGED
package/.yarnrc
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
--frozen-lockfile true
|