@fluid-topics/public-api 1.0.25 → 1.0.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.js CHANGED
@@ -160,18 +160,27 @@ class FluidTopicsApi {
160
160
  unrateMap(mapId) {
161
161
  return this.delete(`/api/khub/maps/${mapId}/rating`);
162
162
  }
163
+ sendMapFeedback(mapId, message) {
164
+ return this.post(`/api/khub/maps/${mapId}/feedback`, { message });
165
+ }
163
166
  rateTopic(mapId, tocId, type, value) {
164
167
  return this.post(`/api/khub/maps/${mapId}/topics/${tocId}/rating`, { type, value });
165
168
  }
166
169
  unrateTopic(mapId, tocId) {
167
170
  return this.delete(`/api/khub/maps/${mapId}/topics/${tocId}/rating`);
168
171
  }
172
+ sendTopicFeedback(mapId, tocId, message) {
173
+ return this.post(`/api/khub/maps/${mapId}/topics/${tocId}/feedback`, { message });
174
+ }
169
175
  rateDocument(docId, type, value) {
170
176
  return this.post(`/api/khub/documents/${docId}/rating`, { type, value });
171
177
  }
172
178
  unrateDocument(docId) {
173
179
  return this.delete(`/api/khub/documents/${docId}/rating`);
174
180
  }
181
+ sendDocumentFeedback(docId, message) {
182
+ return this.post(`/api/khub/documents/${docId}/feedback`, { message });
183
+ }
175
184
  get(endpoint) {
176
185
  return this.makeRequest("GET", endpoint);
177
186
  }
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
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;
3
+ 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.isFtFeedbackCreation = 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 = exports.isFtTopicResource = void 0;
5
5
  const isObject = (o) => typeof o === "object" && o != null;
6
6
  const isBoolean = (o) => typeof o === "boolean";
7
7
  const isNumber = (o) => typeof o === "number";
@@ -123,6 +123,11 @@ const isFtTopicContentTarget = (o) => {
123
123
  return ["THIRD_PARTY", "OFF_THE_GRID", "CONTENT_PACKAGER", "PAGES", "DESIGNED_READER"].includes(o);
124
124
  };
125
125
  exports.isFtTopicContentTarget = isFtTopicContentTarget;
126
+ const isFtFeedbackCreation = (o) => {
127
+ return isObject(o)
128
+ && (isString(o.message));
129
+ };
130
+ exports.isFtFeedbackCreation = isFtFeedbackCreation;
126
131
  const isFtSearchLocale = (o) => {
127
132
  return isObject(o)
128
133
  && (isNumber(o.count))
@@ -140,6 +145,9 @@ const isFtMetadata = (o) => {
140
145
  return isObject(o)
141
146
  && ((Array.isArray(o.values)
142
147
  && o.values.every((v) => isString(v))))
148
+ && (o.hierarchicalValues == null || (Array.isArray(o.hierarchicalValues)
149
+ && o.hierarchicalValues.every((v) => (Array.isArray(v)
150
+ && v.every((v) => isString(v))))))
143
151
  && (isString(o.label))
144
152
  && (isString(o.key));
145
153
  };
@@ -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)),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.")}}));
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,s=function(e,t){return/^\/\//.test(e)&&(e="https:"+e),i.call(this,e,t)};s.ponyfill=!0,e.exports=t=s,t.fetch=s,t.Headers=r.Headers,t.Request=r.Request,t.Response=r.Response,t.default=s}(r,r.exports);const i=r.exports,s=i.fetch.bind({});s.polyfill=!0,t.fetch||(t.fetch=s,t.Response=i.Response,t.Headers=i.Headers,t.Request=i.Request);const n=e=>"object"==typeof e&&null!=e,l=e=>"boolean"==typeof e,o=e=>"number"==typeof e,u=e=>"string"==typeof e,c=e=>n(e)&&u(e.topicStylesheetUrl)&&u(e.titleStylesheetUrl)&&Array.isArray(e.customCssClasses)&&e.customCssClasses.every((e=>u(e))),p=e=>n(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=>n(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=>n(e)&&o(e.count)&&u(e.label)&&(null==e.lang||u(e.lang)),g=e=>n(e)&&Array.isArray(e.values)&&e.values.every((e=>u(e)))&&(null==e.hierarchicalValues||Array.isArray(e.hierarchicalValues)&&e.hierarchicalValues.every((e=>Array.isArray(e)&&e.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=>n(e)&&u(e.date)&&m(e.type)&&o(e.value),T=e=>n(e)&&(null==e.rating||A(e.rating))&&m(e.type),b=e=>n(e)&&u(e.date)&&u(e.tocId)&&m(e.type)&&o(e.value),R=e=>n(e)&&Array.isArray(e.ratings)&&e.ratings.every((e=>b(e)))&&m(e.type),F=e=>n(e)&&Array.isArray(e.filter)&&e.filter.every((e=>u(e)))&&Array.isArray(e.prior)&&e.prior.every((e=>u(e))),S=e=>n(e)&&l(e.negative)&&Array.isArray(e.values)&&e.values.every((e=>u(e)))&&u(e.key),v=e=>n(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=>n(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),k=e=>n(e)&&o(e.weight)&&u(e.value)&&u(e.key),w=e=>n(e)&&Array.isArray(e.entries)&&e.entries.every((e=>M(e)))&&(null==e.metadataVariableAxis||u(e.metadataVariableAxis)),M=e=>n(e)&&(null==e.document||L(e.document))&&(null==e.topic||N(e.topic))&&_(e.type)&&(null==e.map||$(e.map)),L=e=>n(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),$=e=>n(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),N=e=>n(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=>V(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=>n(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=>n(e)&&(null==e.maxDepth||o(e.maxDepth))&&u(e.id),q=e=>n(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=>n(e)&&u(e.key),K=e=>n(e)&&u(e.suggestedQuery)&&u(e.htmlSuggestedQuery),V=e=>n(e)&&u(e.filename)&&u(e.resourceUrl)&&u(e.id)&&u(e.mimeType)&&u(e.resourceContentUrl)&&u(e.viewerUrl),j=e=>n(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 se{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`)}sendMapFeedback(e,t){return this.post(`/api/khub/maps/${e}/feedback`,{message:t})}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`)}sendTopicFeedback(e,t,r){return this.post(`/api/khub/maps/${e}/topics/${t}/feedback`,{message:r})}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`)}sendDocumentFeedback(e,t){return this.post(`/api/khub/documents/${e}/feedback`,{message:t})}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,s)=>{let n=new XMLHttpRequest;n.onload=()=>{if(n.status>=200&&n.status<300){let e="application/json"===n.getResponseHeader("Content-Type")?JSON.parse(n.responseText):n.responseText;i(e)}else s(new re(n.status,n.statusText,n.responseText))},n.upload.onprogress=e=>a(e),n.open(e,this.tenantBaseUrl+t,!0),n.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=se,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=se,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=>n(e)&&u(e.identifier)&&u(e.realm),e.isFtCollectionDocument=e=>n(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=>n(e)&&u(e.password)&&(null==e.newPassword||u(e.newPassword))&&l(e.rememberMe)&&u(e.login),e.isFtEditorialType=C,e.isFtFeedbackCreation=e=>n(e)&&u(e.message),e.isFtMap=e=>n(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=>n(e)&&u(e.contentUrl)&&u(e.filename)&&u(e.id)&&u(e.mimeType),e.isFtMapStyles=c,e.isFtMetadata=g,e.isFtMetadataPreferenceConfiguration=F,e.isFtOpenMode=O,e.isFtPageRequest=D,e.isFtPublicationRating=A,e.isFtPublicationRatingSummary=T,e.isFtRatingCreation=e=>n(e)&&m(e.type)&&o(e.value),e.isFtRatingSummary=e=>n(e)&&(null==e.topics||R(e.topics))&&T(e.publication),e.isFtRatingType=m,e.isFtSearchFacet=H,e.isFtSearchFacetConf=B,e.isFtSearchFacetEntry=q,e.isFtSearchFilter=S,e.isFtSearchLocale=y,e.isFtSearchLocales=e=>n(e)&&Array.isArray(e.contentLocales)&&e.contentLocales.every((e=>y(e))),e.isFtSearchPreferencesConfiguration=e=>n(e)&&n(e.metadata)&&Object.keys(e.metadata).every((e=>u(e)))&&Object.values(e.metadata).every((e=>F(e))),e.isFtSearchPreset=e=>n(e)&&u(e.name)&&Array.isArray(e.filters)&&e.filters.every((e=>S(e)))&&o(e.priority)&&(null==e.contentLocale||u(e.contentLocale)),e.isFtSearchPrior=k,e.isFtSearchRequest=e=>n(e)&&u(e.query)&&D(e.paging)&&Array.isArray(e.filters)&&e.filters.every((e=>S(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=>k(e))))&&Array.isArray(e.facets)&&e.facets.every((e=>B(e))),e.isFtSearchResultCluster=w,e.isFtSearchResultClusterEntry=M,e.isFtSearchResultMap=$,e.isFtSearchResultTopic=N,e.isFtSearchResultType=_,e.isFtSearchResultUnstructuredDocument=L,e.isFtSearchResults=e=>n(e)&&(null==e.spellcheck||K(e.spellcheck))&&v(e.paging)&&Array.isArray(e.results)&&e.results.every((e=>w(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=>n(e)&&u(e.input)&&Array.isArray(e.filters)&&e.filters.every((e=>S(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=j,e.isFtSuggestResults=e=>n(e)&&Array.isArray(e.suggestions)&&e.suggestions.every((e=>j(e))),e.isFtTocNode=p,e.isFtTocPage=d,e.isFtTopic=e=>n(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=V,e.isFtTopicsRatingSummary=R,e.isFtUnstructuredDocument=e=>n(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.")}}));
@@ -44,10 +44,13 @@ export declare class FluidTopicsApi {
44
44
  getDocumentRating(docId: string): Promise<FtRatingSummary>;
45
45
  rateMap(mapId: string, type: FtRatingType, value: number): Promise<void>;
46
46
  unrateMap(mapId: string): Promise<void>;
47
+ sendMapFeedback(mapId: string, message: string): Promise<void>;
47
48
  rateTopic(mapId: string, tocId: string, type: FtRatingType, value: number): Promise<void>;
48
49
  unrateTopic(mapId: string, tocId: string): Promise<void>;
50
+ sendTopicFeedback(mapId: string, tocId: string, message: string): Promise<void>;
49
51
  rateDocument(docId: string, type: FtRatingType, value: number): Promise<void>;
50
52
  unrateDocument(docId: string): Promise<void>;
53
+ sendDocumentFeedback(docId: string, message: string): Promise<void>;
51
54
  get<T>(endpoint: string): Promise<T>;
52
55
  post<T>(endpoint: string, data?: any): Promise<T>;
53
56
  put<T>(endpoint: string, data?: any): Promise<T>;
package/dist/mjs/index.js CHANGED
@@ -140,18 +140,27 @@ export class FluidTopicsApi {
140
140
  unrateMap(mapId) {
141
141
  return this.delete(`/api/khub/maps/${mapId}/rating`);
142
142
  }
143
+ sendMapFeedback(mapId, message) {
144
+ return this.post(`/api/khub/maps/${mapId}/feedback`, { message });
145
+ }
143
146
  rateTopic(mapId, tocId, type, value) {
144
147
  return this.post(`/api/khub/maps/${mapId}/topics/${tocId}/rating`, { type, value });
145
148
  }
146
149
  unrateTopic(mapId, tocId) {
147
150
  return this.delete(`/api/khub/maps/${mapId}/topics/${tocId}/rating`);
148
151
  }
152
+ sendTopicFeedback(mapId, tocId, message) {
153
+ return this.post(`/api/khub/maps/${mapId}/topics/${tocId}/feedback`, { message });
154
+ }
149
155
  rateDocument(docId, type, value) {
150
156
  return this.post(`/api/khub/documents/${docId}/rating`, { type, value });
151
157
  }
152
158
  unrateDocument(docId) {
153
159
  return this.delete(`/api/khub/documents/${docId}/rating`);
154
160
  }
161
+ sendDocumentFeedback(docId, message) {
162
+ return this.post(`/api/khub/documents/${docId}/feedback`, { message });
163
+ }
155
164
  get(endpoint) {
156
165
  return this.makeRequest("GET", endpoint);
157
166
  }
@@ -97,6 +97,10 @@ export declare enum FtTopicContentTarget {
97
97
  }
98
98
  export declare type FtTopicContentTargetKeys = keyof typeof FtTopicContentTarget;
99
99
  export declare const isFtTopicContentTarget: (o: any) => o is FtTopicContentTarget;
100
+ export interface FtFeedbackCreation {
101
+ message: string;
102
+ }
103
+ export declare const isFtFeedbackCreation: (o: any) => o is FtFeedbackCreation;
100
104
  export interface FtSearchLocale {
101
105
  count: number;
102
106
  label: string;
@@ -109,6 +113,7 @@ export interface FtSearchLocales {
109
113
  export declare const isFtSearchLocales: (o: any) => o is FtSearchLocales;
110
114
  export interface FtMetadata {
111
115
  values: Array<string>;
116
+ hierarchicalValues?: Array<Array<string>>;
112
117
  label: string;
113
118
  key: string;
114
119
  }
@@ -110,6 +110,10 @@ export var FtTopicContentTarget;
110
110
  export const isFtTopicContentTarget = (o) => {
111
111
  return ["THIRD_PARTY", "OFF_THE_GRID", "CONTENT_PACKAGER", "PAGES", "DESIGNED_READER"].includes(o);
112
112
  };
113
+ export const isFtFeedbackCreation = (o) => {
114
+ return isObject(o)
115
+ && (isString(o.message));
116
+ };
113
117
  export const isFtSearchLocale = (o) => {
114
118
  return isObject(o)
115
119
  && (isNumber(o.count))
@@ -125,6 +129,9 @@ export const isFtMetadata = (o) => {
125
129
  return isObject(o)
126
130
  && ((Array.isArray(o.values)
127
131
  && o.values.every((v) => isString(v))))
132
+ && (o.hierarchicalValues == null || (Array.isArray(o.hierarchicalValues)
133
+ && o.hierarchicalValues.every((v) => (Array.isArray(v)
134
+ && v.every((v) => isString(v))))))
128
135
  && (isString(o.label))
129
136
  && (isString(o.key));
130
137
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluid-topics/public-api",
3
- "version": "1.0.25",
3
+ "version": "1.0.26",
4
4
  "description": "Fluid Topics Public API",
5
5
  "author": "Fluid Topics dev team <opensource@antidot.net>",
6
6
  "license": "LGPL-3.0-only",