@fluid-topics/public-api 1.0.29 → 1.0.31

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
@@ -126,6 +126,15 @@ class FluidTopicsApi {
126
126
  configuration: {
127
127
  reader: `api/configuration/reader`
128
128
  },
129
+ messages: {
130
+ locale: (locale) => ({
131
+ fluidTopics: {
132
+ contextName: (contextName) => ({
133
+ endpoint: `api/messages/${locale}/fluid-topics/${contextName}`,
134
+ })
135
+ }
136
+ })
137
+ },
129
138
  };
130
139
  //@ts-ignore
131
140
  tenantBaseUrl = ((_f = (_c = (_a = tenantBaseUrl !== null && tenantBaseUrl !== void 0 ? tenantBaseUrl : wnd.__gwt_ft_moduleBase) !== null && _a !== void 0 ? _a : (_b = wnd.fluidtopicsclient) === null || _b === void 0 ? void 0 : _b.__moduleBase) !== null && _c !== void 0 ? _c : (_e = (_d = wnd.__gwt_activeModules) === null || _d === void 0 ? void 0 : _d.fluidtopicsclient) === null || _e === void 0 ? void 0 : _e.moduleBase) !== null && _f !== void 0 ? _f : "").trim();
@@ -260,6 +269,9 @@ class FluidTopicsApi {
260
269
  sendDocumentFeedback(docId, message) {
261
270
  return this.post(this.endpoints.khub.documents.documentId(docId).feedback, { message });
262
271
  }
272
+ getFluidTopicsMessageContext(locale, name) {
273
+ return this.get(this.endpoints.messages.locale(locale).fluidTopics.contextName(name).endpoint);
274
+ }
263
275
  get(endpoint) {
264
276
  return this.makeRequest("GET", endpoint);
265
277
  }
@@ -1,17 +1,26 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isFtPaginationConfiguration = exports.isFtPaginatedTocNode = exports.isFtPaginatedToc = exports.isFtPageConfiguration = exports.isFtMapAttachment = exports.isFtUserProfile = exports.isFtSession = exports.isFtAuthenticatedSession = exports.isFtReaderConfiguration = void 0;
3
+ exports.isFtMessageContext = exports.isFtPaginationConfiguration = exports.isFtPaginatedTocNode = exports.isFtPaginatedToc = exports.isFtPageConfiguration = exports.isFtMapAttachment = exports.isFtUserProfile = exports.isFtSession = exports.isFtAuthenticatedSession = exports.isFtReaderFeedbackConfiguration = exports.isFtReaderConfiguration = void 0;
4
4
  const isObject = (o) => typeof o === "object" && o != null;
5
5
  const isBoolean = (o) => typeof o === "boolean";
6
6
  const isNumber = (o) => typeof o === "number";
7
7
  const isString = (o) => typeof o === "string";
8
8
  const isFtReaderConfiguration = (o) => {
9
9
  return isObject(o)
10
+ && ((0, exports.isFtReaderFeedbackConfiguration)(o.feedback))
10
11
  && (isNumber(o.loadAfterLastVisibleTopic))
11
- && (isBoolean(o.feedbackMailsSentByFluidTopics))
12
12
  && (isNumber(o.loadBeforeFirstVisibleTopic));
13
13
  };
14
14
  exports.isFtReaderConfiguration = isFtReaderConfiguration;
15
+ const isFtReaderFeedbackConfiguration = (o) => {
16
+ return isObject(o)
17
+ && (isBoolean(o.mailsSentByFluidTopics))
18
+ && ((Array.isArray(o.recipients)
19
+ && o.recipients.every((v) => isString(v))))
20
+ && ((Array.isArray(o.subjectMetadataIds)
21
+ && o.subjectMetadataIds.every((v) => isString(v))));
22
+ };
23
+ exports.isFtReaderFeedbackConfiguration = isFtReaderFeedbackConfiguration;
15
24
  const isFtAuthenticatedSession = (o) => {
16
25
  return isObject(o)
17
26
  && ((0, exports.isFtUserProfile)(o.profile));
@@ -75,3 +84,12 @@ const isFtPaginationConfiguration = (o) => {
75
84
  && (isBoolean(o.splitCurrentPageToc));
76
85
  };
77
86
  exports.isFtPaginationConfiguration = isFtPaginationConfiguration;
87
+ const isFtMessageContext = (o) => {
88
+ return isObject(o)
89
+ && (isString(o.name))
90
+ && ((isObject(o.messages)
91
+ && Object.keys(o.messages).every((k) => isString(k))
92
+ && Object.values(o.messages).every((v) => isString(v))))
93
+ && (isString(o.locale));
94
+ };
95
+ exports.isFtMessageContext = isFtMessageContext;
@@ -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:{},i={exports:{}},n={exports:{}};!function(e,t){var i=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==i)return i;throw new Error("unable to locate global object")}();e.exports=t=i.fetch,i.fetch&&(t.default=i.fetch.bind(i)),t.Headers=i.Headers,t.Request=i.Request,t.Response=i.Response}(n,n.exports),function(e,t){const i=n.exports,a=i.default||i,s=function(e,t){return/^\/\//.test(e)&&(e="https:"+e),a.call(this,e,t)};s.ponyfill=!0,e.exports=t=s,t.fetch=s,t.Headers=i.Headers,t.Request=i.Request,t.Response=i.Response,t.default=s}(i,i.exports);const a=i.exports,s=a.fetch.bind({});s.polyfill=!0,t.fetch||(t.fetch=s,t.Response=a.Response,t.Headers=a.Headers,t.Request=a.Request);const r=e=>"object"==typeof e&&null!=e,o=e=>"boolean"==typeof e,l=e=>"number"==typeof e,u=e=>"string"==typeof e,c=e=>r(e)&&u(e.topicStylesheetUrl)&&u(e.titleStylesheetUrl)&&Array.isArray(e.customCssClasses)&&e.customCssClasses.every((e=>u(e))),d=e=>r(e)&&(null==e.prettyUrl||u(e.prettyUrl))&&(null==e.hasRating||o(e.hasRating))&&u(e.tocId)&&Array.isArray(e.children)&&e.children.every((e=>d(e)))&&u(e.contentId)&&u(e.title);var p;e.FtTopicContentTarget=void 0,(p=e.FtTopicContentTarget||(e.FtTopicContentTarget={})).THIRD_PARTY="THIRD_PARTY",p.OFF_THE_GRID="OFF_THE_GRID",p.CONTENT_PACKAGER="CONTENT_PACKAGER",p.PAGES="PAGES",p.DESIGNED_READER="DESIGNED_READER";const h=e=>r(e)&&l(e.count)&&u(e.label)&&(null==e.lang||u(e.lang)),y=e=>r(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 g;e.FtRatingType=void 0,(g=e.FtRatingType||(e.FtRatingType={})).STARS="STARS",g.LIKE="LIKE",g.DICHOTOMOUS="DICHOTOMOUS",g.NO_RATING="NO_RATING";const m=e=>["STARS","LIKE","DICHOTOMOUS","NO_RATING"].includes(e),A=e=>r(e)&&u(e.date)&&m(e.type)&&l(e.value),f=e=>r(e)&&(null==e.rating||A(e.rating))&&m(e.type),E=e=>r(e)&&u(e.date)&&u(e.tocId)&&m(e.type)&&l(e.value),R=e=>r(e)&&Array.isArray(e.ratings)&&e.ratings.every((e=>E(e)))&&m(e.type),T=e=>r(e)&&Array.isArray(e.filter)&&e.filter.every((e=>u(e)))&&Array.isArray(e.prior)&&e.prior.every((e=>u(e))),S=e=>r(e)&&o(e.negative)&&Array.isArray(e.values)&&e.values.every((e=>u(e)))&&u(e.key),b=e=>r(e)&&l(e.totalResultsCount)&&o(e.lastPage)&&l(e.currentPage)&&l(e.totalClustersCount);var I;e.FtEditorialType=void 0,(I=e.FtEditorialType||(e.FtEditorialType={})).ARTICLE="ARTICLE",I.BOOK="BOOK";const U=e=>["ARTICLE","BOOK"].includes(e);var F;e.FtOpenMode=void 0,(F=e.FtOpenMode||(e.FtOpenMode={})).FLUIDTOPICS="FLUIDTOPICS",F.EXTERNAL="EXTERNAL";const O=e=>["FLUIDTOPICS","EXTERNAL"].includes(e),C=e=>r(e)&&(null==e.perPage||l(e.perPage))&&l(e.page);var _;e.FtCollectionDocumentType=void 0,(_=e.FtCollectionDocumentType||(e.FtCollectionDocumentType={})).MAP="MAP",_.DOCUMENT="DOCUMENT",_.TOPIC="TOPIC",_.PERSONAL_BOOK="PERSONAL_BOOK",_.SHARED_BOOK="SHARED_BOOK";const v=e=>["MAP","DOCUMENT","TOPIC","PERSONAL_BOOK","SHARED_BOOK"].includes(e),P=e=>r(e)&&l(e.weight)&&u(e.value)&&u(e.key),k=e=>r(e)&&Array.isArray(e.entries)&&e.entries.every((e=>D(e)))&&(null==e.metadataVariableAxis||u(e.metadataVariableAxis)),D=e=>r(e)&&(null==e.document||N(e.document))&&(null==e.topic||M(e.topic))&&B(e.type)&&(null==e.map||L(e.map)),N=e=>r(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>y(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),L=e=>r(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>y(e)))&&(null==e.openMode||O(e.openMode))&&U(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),M=e=>r(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>y(e)))&&O(e.openMode)&&u(e.contentId)&&Array.isArray(e.resources)&&e.resources.every((e=>G(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 B=e=>["MAP","DOCUMENT","TOPIC"].includes(e),H=e=>r(e)&&o(e.hierarchical)&&u(e.label)&&o(e.multiSelectionable)&&u(e.key)&&Array.isArray(e.rootNodes)&&e.rootNodes.every((e=>$(e))),x=e=>r(e)&&(null==e.maxDepth||l(e.maxDepth))&&u(e.id),$=e=>r(e)&&l(e.totalResultsCount)&&o(e.descendantSelected)&&Array.isArray(e.childNodes)&&e.childNodes.every((e=>$(e)))&&u(e.label)&&u(e.value)&&o(e.selected),K=e=>r(e)&&u(e.key),V=e=>r(e)&&u(e.suggestedQuery)&&u(e.htmlSuggestedQuery),G=e=>r(e)&&u(e.filename)&&u(e.resourceUrl)&&u(e.id)&&u(e.mimeType)&&u(e.resourceContentUrl)&&u(e.viewerUrl),q=e=>r(e)&&(null==e.filenameExtension||u(e.filenameExtension))&&(null==e.editorialType||U(e.editorialType))&&(null==e.mimeType||u(e.mimeType))&&B(e.type)&&u(e.value);var j;e.FtUserRole=void 0,(j=e.FtUserRole||(e.FtUserRole={})).PERSONAL_BOOK_USER="PERSONAL_BOOK_USER",j.PERSONAL_BOOK_SHARE_USER="PERSONAL_BOOK_SHARE_USER",j.HTML_EXPORT_USER="HTML_EXPORT_USER",j.PDF_EXPORT_USER="PDF_EXPORT_USER",j.SAVED_SEARCH_USER="SAVED_SEARCH_USER",j.COLLECTION_USER="COLLECTION_USER",j.OFFLINE_USER="OFFLINE_USER",j.ANALYTICS_USER="ANALYTICS_USER",j.BETA_USER="BETA_USER",j.DEBUG_USER="DEBUG_USER",j.PRINT_USER="PRINT_USER",j.RATING_USER="RATING_USER",j.FEEDBACK_USER="FEEDBACK_USER",j.CONTENT_PUBLISHER="CONTENT_PUBLISHER",j.KHUB_ADMIN="KHUB_ADMIN",j.USERS_ADMIN="USERS_ADMIN",j.PORTAL_ADMIN="PORTAL_ADMIN",j.ADMIN="ADMIN",j.DEVELOPER="DEVELOPER";const z=e=>"object"==typeof e&&null!=e,X=e=>"boolean"==typeof e,Y=e=>"number"==typeof e,J=e=>"string"==typeof e,Q=e=>z(e)&&(null==e.emailAddress||J(e.emailAddress))&&(null==e.displayName||J(e.displayName))&&Array.isArray(e.roles)&&(null==e.userId||J(e.userId)),W=e=>z(e)&&(null==e.parentsVisibility||Array.isArray(e.parentsVisibility)&&e.parentsVisibility.every((e=>X(e))))&&X(e.isVisible),Z=e=>z(e)&&(null==e.prettyUrl||J(e.prettyUrl))&&(null==e.hasRating||X(e.hasRating))&&(null==e.pageToc||Array.isArray(e.pageToc))&&(null==e.tocId||J(e.tocId))&&Array.isArray(e.children)&&e.children.every((e=>Z(e)))&&(null==e.pageConfiguration||W(e.pageConfiguration))&&(null==e.contentId||J(e.contentId))&&(null==e.title||J(e.title)),ee=e=>z(e)&&X(e.splitCurrentPageToc),te="undefined"==typeof window?globalThis:window;function ie(e){let t={};for(let i in e){let n=e[i];("object"!=typeof n||Array.isArray(n))&&(n={prior:n});for(let e of["prior","filter"])n[e]=Array.isArray(n[e])?n[e]:[n[e]],n[e]=n[e].map((e=>null!=e?""+e:"")).filter((e=>""!==e));t[i]=n}return t}function ne(e){return`${e}-FluidTopicsUnauthenticatedUserSearchPreferences`}const ae="undefined"==typeof window?globalThis:window;class se extends Error{status;statusText;body;constructor(e,t,i){super(`${e} - ${t}: ${i}`),this.status=e,this.statusText=t,this.body=i}}async function re(e){if(!e.ok)throw new se(e.status,e.statusText,await e.text());return e}function oe(e){return"application/json"===e.headers.get("Content-Type")?e.json():e.text()}class le{tenantBaseUrl;ftCallingApp;authorization;searchLabel;endpoints={authentication:{login:"api/authentication/login",logout:"api/authentication/logout",currentSession:"api/authentication/current-session"},khub:{maps:{mapId:e=>({info:`api/khub/maps/${e}`,toc:`api/khub/maps/${e}/toc`,pages:`api/khub/maps/${e}/pages`,feedback:`api/khub/maps/${e}/feedback`,rating:`api/khub/maps/${e}/rating`,attachments:{list:`api/khub/maps/${e}/attachments`,attachmentId:t=>({content:`api/khub/maps/${e}/attachments/${t}/content`})},resources:{list:`api/khub/maps/${e}/resources`,resourceId:t=>({content:`api/khub/maps/${e}/resources/${t}/content`})},topics:{contentId:t=>({info:`api/khub/maps/${e}/topics/${t}`,content:`api/khub/maps/${e}/topics/${t}/content`}),tocId:t=>({feedback:`api/khub/maps/${e}/topics/${t}/feedback`,rating:`api/khub/maps/${e}/topics/${t}/rating`})}})},documents:{documentId:e=>({info:`api/khub/documents/${e}`,content:`api/khub/documents/${e}/content`,text:`api/khub/documents/${e}/content/text`,feedback:`api/khub/documents/${e}/feedback`,rating:`api/khub/documents/${e}/rating`})},suggest:"api/khub/suggest",clusteredSearch:"api/khub/clustered-search",locales:"api/khub/locales"},users:{userId:e=>({collections:{collectionId:t=>({documents:`api/users/${e}/collections/${t}/documents`})}})},stylesheets:{fonts:"api/stylesheets/fonts.css",theme:"api/stylesheets/theme.css",content:{title:"api/stylesheets/content/title.css",topic:"api/stylesheets/content/topic.css"}},configuration:{reader:"api/configuration/reader"}};get defaultHeaders(){return{...this.authorization,...this.searchLabel,"Ft-Calling-App":this.ftCallingApp}}constructor(e,t,i){e=(e??ae.__gwt_ft_moduleBase??ae.fluidtopicsclient?.__moduleBase??ae.__gwt_activeModules?.fluidtopicsclient?.moduleBase??"").trim(),this.tenantBaseUrl=e.endsWith("/")?e:e+"/",i&&void 0!==ae.location&&ae.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 i;this.authorization={Authorization:"Basic "+(i=`${e}:${t}`,"undefined"!=typeof Buffer?Buffer.from(i).toString("base64"):btoa(i))}}clearAuthentication(){this.authorization=void 0}setSearchLabel(e){this.searchLabel={"FT-search-label":e}}clearSearchLabel(){this.searchLabel=void 0}login(e,t){let i={login:e,password:t,rememberMe:!0};return this.post(this.endpoints.authentication.login,i).then((i=>(this.setCredentials(e,t),i)))}logout(){return this.post(this.endpoints.authentication.logout).then((()=>this.clearAuthentication()))}getCurrentSession(){return this.get(this.endpoints.authentication.currentSession)}getReaderConfiguration(){return this.get(this.endpoints.configuration.reader)}getMap(e){return this.get(this.endpoints.khub.maps.mapId(e).info)}getTableOfContent(e){return this.get(this.endpoints.khub.maps.mapId(e).toc)}getPages(e){return this.get(this.endpoints.khub.maps.mapId(e).pages)}getTopic(e,t){return this.get(this.endpoints.khub.maps.mapId(e).topics.contentId(t).info)}getTopicHTMLContent(e,t,i){return this.get(this.endpoints.khub.maps.mapId(e).topics.contentId(t).content+(i?"?target="+i:""))}getMapAttachments(e){return this.get(this.endpoints.khub.maps.mapId(e).attachments.list)}getMapAttachmentContent(e,t){return this.fetchRawData(this.endpoints.khub.maps.mapId(e).attachments.attachmentId(t).content)}getMapResources(e){return this.get(this.endpoints.khub.maps.mapId(e).resources.list)}getMapResourceContent(e,t){return this.fetchRawData(this.endpoints.khub.maps.mapId(e).resources.resourceId(t).content)}getUnstructuredDocument(e){return this.get(this.endpoints.khub.documents.documentId(e).info)}getUnstructuredDocumentContent(e){return this.fetchRawData(this.endpoints.khub.documents.documentId(e).content)}getUnstructuredDocumentTextContent(e){return this.get(this.endpoints.khub.documents.documentId(e).text)}getCollectionDocuments(e,t){return this.get(this.endpoints.users.userId(e).collections.collectionId(t).documents)}getSuggestions(e){return this.post(this.endpoints.khub.suggest,e)}search(e){return this.post(this.endpoints.khub.clusteredSearch,e)}getAvailableSearchLocales(){return this.get(this.endpoints.khub.locales)}getMapRating(e){return this.get(this.endpoints.khub.maps.mapId(e).rating)}rateMap(e,t,i){return this.post(this.endpoints.khub.maps.mapId(e).rating,{type:t,value:i})}unrateMap(e){return this.delete(this.endpoints.khub.maps.mapId(e).rating)}sendMapFeedback(e,t){return this.post(this.endpoints.khub.maps.mapId(e).feedback,{message:t})}rateTopic(e,t,i,n){return this.post(this.endpoints.khub.maps.mapId(e).topics.tocId(t).rating,{type:i,value:n})}unrateTopic(e,t){return this.delete(this.endpoints.khub.maps.mapId(e).topics.tocId(t).rating)}sendTopicFeedback(e,t,i){return this.post(this.endpoints.khub.maps.mapId(e).topics.tocId(t).feedback,{message:i})}getDocumentRating(e){return this.get(this.endpoints.khub.documents.documentId(e).rating)}rateDocument(e,t,i){return this.post(this.endpoints.khub.documents.documentId(e).rating,{type:t,value:i})}unrateDocument(e){return this.delete(this.endpoints.khub.documents.documentId(e).rating)}sendDocumentFeedback(e,t){return this.post(this.endpoints.khub.documents.documentId(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)}makeAbsolute(e){return this.tenantBaseUrl+e.replace(/^\//,"")}async fetch(e,t){const i=t;return await fetch(this.makeAbsolute(e),{...i??{},headers:{...this.defaultHeaders,...i?.headers??{}}})}upload(e,t,i,n=(()=>{})){return"undefined"!=typeof XMLHttpRequest?new Promise(((a,s)=>{let r=new XMLHttpRequest;r.onload=()=>{if(r.status>=200&&r.status<300){let e="application/json"===r.getResponseHeader("Content-Type")?JSON.parse(r.responseText):r.responseText;a(e)}else s(new se(r.status,r.statusText,r.responseText))},r.upload.onprogress=e=>n(e),r.open(e,this.makeAbsolute(t),!0),r.send(i)})):this.fetch(t,{method:e,body:i}).then(re).then(oe)}makeRequest(e,t,i){return this.fetch(t,{method:e,headers:{...null!=i?{"Content-Type":"application/json"}:{}},body:null!=i?JSON.stringify(i):void 0,credentials:null==this.authorization?"include":void 0}).then(re).then(oe)}fetchRawData(e){return fetch(this.makeAbsolute(e),{headers:this.defaultHeaders,credentials:null==this.authorization?"include":void 0}).then(re).then((e=>e.arrayBuffer()))}}e.FluidTopicsApi=le,e.HttpError=se,e.addUnauthenticatedUserSearchPreferencesChangeHandler=function(e,t){if(te.localStorage){const i=ne(e),n=e=>{e.storageArea===te.localStorage&&e.key===i&&t(JSON.parse(e.newValue??"{}"))};return te.addEventListener("storage",n),{removeHandler:()=>te.removeEventListener("storage",n)}}console.error("Cannot handle unauthenticated preferences: local storage is unavailable.")},e.default=le,e.getUnauthenticatedUserSearchPreferences=function(e){if(te.localStorage)return JSON.parse(te.localStorage.getItem(ne(e))??"{}");console.error("Cannot get unauthenticated preferences: local storage is unavailable.")},e.isFtAuthenticatedSession=e=>z(e)&&Q(e.profile),e.isFtAuthenticationIdentifier=e=>r(e)&&u(e.identifier)&&u(e.realm),e.isFtCollectionDocument=e=>r(e)&&o(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=>r(e)&&u(e.password)&&(null==e.newPassword||u(e.newPassword))&&o(e.rememberMe)&&u(e.login),e.isFtEditorialType=U,e.isFtFeedbackCreation=e=>r(e)&&u(e.message),e.isFtMap=e=>r(e)&&(null==e.prettyUrl||u(e.prettyUrl))&&Array.isArray(e.metadata)&&e.metadata.every((e=>y(e)))&&O(e.openMode)&&u(e.topicsApiEndpoint)&&(null==e.description||u(e.description))&&u(e.attachmentsApiEndpoint)&&U(e.editorialType)&&u(e.baseId)&&u(e.clusterId)&&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)&&J(e.file)&&(null==e.size||Y(e.size))&&X(e.externalLink)&&J(e.name)&&J(e.id)&&(null==e.mimeType||J(e.mimeType))&&(null==e.viewerUrl||J(e.viewerUrl)),e.isFtMapResource=e=>r(e)&&u(e.contentUrl)&&u(e.filename)&&u(e.id)&&u(e.mimeType),e.isFtMapStyles=c,e.isFtMetadata=y,e.isFtMetadataPreferenceConfiguration=T,e.isFtOpenMode=O,e.isFtPageConfiguration=W,e.isFtPageRequest=C,e.isFtPaginatedToc=e=>z(e)&&ee(e.configuration)&&Array.isArray(e.paginatedToc)&&e.paginatedToc.every((e=>Z(e))),e.isFtPaginatedTocNode=Z,e.isFtPaginationConfiguration=ee,e.isFtPublicationRating=A,e.isFtPublicationRatingSummary=f,e.isFtRatingCreation=e=>r(e)&&m(e.type)&&l(e.value),e.isFtRatingSummary=e=>r(e)&&(null==e.topics||R(e.topics))&&f(e.publication),e.isFtRatingType=m,e.isFtReaderConfiguration=e=>z(e)&&Y(e.loadAfterLastVisibleTopic)&&X(e.feedbackMailsSentByFluidTopics)&&Y(e.loadBeforeFirstVisibleTopic),e.isFtSearchFacet=H,e.isFtSearchFacetConf=x,e.isFtSearchFacetEntry=$,e.isFtSearchFilter=S,e.isFtSearchLocale=h,e.isFtSearchLocales=e=>r(e)&&Array.isArray(e.contentLocales)&&e.contentLocales.every((e=>h(e))),e.isFtSearchPreferencesConfiguration=e=>r(e)&&r(e.metadata)&&Object.keys(e.metadata).every((e=>u(e)))&&Object.values(e.metadata).every((e=>T(e))),e.isFtSearchPreset=e=>r(e)&&u(e.name)&&Array.isArray(e.filters)&&e.filters.every((e=>S(e)))&&l(e.priority)&&(null==e.contentLocale||u(e.contentLocale)),e.isFtSearchPrior=P,e.isFtSearchRequest=e=>r(e)&&u(e.query)&&C(e.paging)&&Array.isArray(e.filters)&&e.filters.every((e=>S(e)))&&Array.isArray(e.sort)&&e.sort.every((e=>K(e)))&&(null==e.uiLocale||u(e.uiLocale))&&(null==e.contentLocale||u(e.contentLocale))&&(null==e.priors||Array.isArray(e.priors)&&e.priors.every((e=>P(e))))&&Array.isArray(e.facets)&&e.facets.every((e=>x(e))),e.isFtSearchResultCluster=k,e.isFtSearchResultClusterEntry=D,e.isFtSearchResultMap=L,e.isFtSearchResultTopic=M,e.isFtSearchResultType=B,e.isFtSearchResultUnstructuredDocument=N,e.isFtSearchResults=e=>r(e)&&(null==e.spellcheck||V(e.spellcheck))&&b(e.paging)&&Array.isArray(e.results)&&e.results.every((e=>k(e)))&&Array.isArray(e.facets)&&e.facets.every((e=>H(e))),e.isFtSearchResultsPageInfo=b,e.isFtSearchSortCriterion=K,e.isFtSession=e=>z(e)&&Y(e.idleTimeoutInMillis)&&Q(e.profile)&&X(e.sessionAuthenticated),e.isFtSpellcheck=V,e.isFtSuggestRequest=e=>r(e)&&u(e.input)&&Array.isArray(e.filters)&&e.filters.every((e=>S(e)))&&Array.isArray(e.sort)&&e.sort.every((e=>K(e)))&&(null==e.maxCount||l(e.maxCount))&&(null==e.contentLocale||u(e.contentLocale)),e.isFtSuggestResult=q,e.isFtSuggestResults=e=>r(e)&&Array.isArray(e.suggestions)&&e.suggestions.every((e=>q(e))),e.isFtTocNode=d,e.isFtTopic=e=>r(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.isFtTopicRating=E,e.isFtTopicResource=G,e.isFtTopicsRatingSummary=R,e.isFtUnstructuredDocument=e=>r(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=Q,e.isFtUserRole=e=>["PERSONAL_BOOK_USER","PERSONAL_BOOK_SHARE_USER","HTML_EXPORT_USER","PDF_EXPORT_USER","SAVED_SEARCH_USER","COLLECTION_USER","OFFLINE_USER","ANALYTICS_USER","BETA_USER","DEBUG_USER","PRINT_USER","RATING_USER","FEEDBACK_USER","CONTENT_PUBLISHER","KHUB_ADMIN","USERS_ADMIN","PORTAL_ADMIN","ADMIN","DEVELOPER"].includes(e),e.setUnauthenticatedUserSearchPreferences=function(e,t){if(te.localStorage){let i={...t,metadata:ie(t.metadata??{})};const n=ne(e),a=JSON.stringify(i);return te.localStorage.setItem(n,a),te.dispatchEvent(new StorageEvent("storage",{key:n,newValue:a,storageArea:te.localStorage,url:te.location.href})),i}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:{},i={exports:{}},s={exports:{}};!function(e,t){var i=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==i)return i;throw new Error("unable to locate global object")}();e.exports=t=i.fetch,i.fetch&&(t.default=i.fetch.bind(i)),t.Headers=i.Headers,t.Request=i.Request,t.Response=i.Response}(s,s.exports),function(e,t){const i=s.exports,a=i.default||i,n=function(e,t){return/^\/\//.test(e)&&(e="https:"+e),a.call(this,e,t)};n.ponyfill=!0,e.exports=t=n,t.fetch=n,t.Headers=i.Headers,t.Request=i.Request,t.Response=i.Response,t.default=n}(i,i.exports);const a=i.exports,n=a.fetch.bind({});n.polyfill=!0,t.fetch||(t.fetch=n,t.Response=a.Response,t.Headers=a.Headers,t.Request=a.Request);const r=e=>"object"==typeof e&&null!=e,o=e=>"boolean"==typeof e,l=e=>"number"==typeof e,u=e=>"string"==typeof e,c=e=>r(e)&&u(e.topicStylesheetUrl)&&u(e.titleStylesheetUrl)&&Array.isArray(e.customCssClasses)&&e.customCssClasses.every((e=>u(e))),d=e=>r(e)&&(null==e.prettyUrl||u(e.prettyUrl))&&(null==e.hasRating||o(e.hasRating))&&u(e.tocId)&&Array.isArray(e.children)&&e.children.every((e=>d(e)))&&u(e.contentId)&&u(e.title);var p;e.FtTopicContentTarget=void 0,(p=e.FtTopicContentTarget||(e.FtTopicContentTarget={})).THIRD_PARTY="THIRD_PARTY",p.OFF_THE_GRID="OFF_THE_GRID",p.CONTENT_PACKAGER="CONTENT_PACKAGER",p.PAGES="PAGES",p.DESIGNED_READER="DESIGNED_READER";const h=e=>r(e)&&l(e.count)&&u(e.label)&&(null==e.lang||u(e.lang)),y=e=>r(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 g;e.FtRatingType=void 0,(g=e.FtRatingType||(e.FtRatingType={})).STARS="STARS",g.LIKE="LIKE",g.DICHOTOMOUS="DICHOTOMOUS",g.NO_RATING="NO_RATING";const m=e=>["STARS","LIKE","DICHOTOMOUS","NO_RATING"].includes(e),A=e=>r(e)&&u(e.date)&&m(e.type)&&l(e.value),f=e=>r(e)&&(null==e.rating||A(e.rating))&&m(e.type),R=e=>r(e)&&u(e.date)&&u(e.tocId)&&m(e.type)&&l(e.value),E=e=>r(e)&&Array.isArray(e.ratings)&&e.ratings.every((e=>R(e)))&&m(e.type),T=e=>r(e)&&Array.isArray(e.filter)&&e.filter.every((e=>u(e)))&&Array.isArray(e.prior)&&e.prior.every((e=>u(e))),S=e=>r(e)&&o(e.negative)&&Array.isArray(e.values)&&e.values.every((e=>u(e)))&&u(e.key),b=e=>r(e)&&l(e.totalResultsCount)&&o(e.lastPage)&&l(e.currentPage)&&l(e.totalClustersCount);var I;e.FtEditorialType=void 0,(I=e.FtEditorialType||(e.FtEditorialType={})).ARTICLE="ARTICLE",I.BOOK="BOOK";const U=e=>["ARTICLE","BOOK"].includes(e);var F;e.FtOpenMode=void 0,(F=e.FtOpenMode||(e.FtOpenMode={})).FLUIDTOPICS="FLUIDTOPICS",F.EXTERNAL="EXTERNAL";const O=e=>["FLUIDTOPICS","EXTERNAL"].includes(e),C=e=>r(e)&&(null==e.perPage||l(e.perPage))&&l(e.page);var _;e.FtCollectionDocumentType=void 0,(_=e.FtCollectionDocumentType||(e.FtCollectionDocumentType={})).MAP="MAP",_.DOCUMENT="DOCUMENT",_.TOPIC="TOPIC",_.PERSONAL_BOOK="PERSONAL_BOOK",_.SHARED_BOOK="SHARED_BOOK";const v=e=>["MAP","DOCUMENT","TOPIC","PERSONAL_BOOK","SHARED_BOOK"].includes(e),k=e=>r(e)&&l(e.weight)&&u(e.value)&&u(e.key),P=e=>r(e)&&Array.isArray(e.entries)&&e.entries.every((e=>D(e)))&&(null==e.metadataVariableAxis||u(e.metadataVariableAxis)),D=e=>r(e)&&(null==e.document||N(e.document))&&(null==e.topic||M(e.topic))&&B(e.type)&&(null==e.map||L(e.map)),N=e=>r(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>y(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),L=e=>r(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>y(e)))&&(null==e.openMode||O(e.openMode))&&U(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),M=e=>r(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>y(e)))&&O(e.openMode)&&u(e.contentId)&&Array.isArray(e.resources)&&e.resources.every((e=>G(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 B=e=>["MAP","DOCUMENT","TOPIC"].includes(e),H=e=>r(e)&&o(e.hierarchical)&&u(e.label)&&o(e.multiSelectionable)&&u(e.key)&&Array.isArray(e.rootNodes)&&e.rootNodes.every((e=>$(e))),x=e=>r(e)&&(null==e.maxDepth||l(e.maxDepth))&&u(e.id),$=e=>r(e)&&l(e.totalResultsCount)&&o(e.descendantSelected)&&Array.isArray(e.childNodes)&&e.childNodes.every((e=>$(e)))&&u(e.label)&&u(e.value)&&o(e.selected),K=e=>r(e)&&u(e.key),V=e=>r(e)&&u(e.suggestedQuery)&&u(e.htmlSuggestedQuery),G=e=>r(e)&&u(e.filename)&&u(e.resourceUrl)&&u(e.id)&&u(e.mimeType)&&u(e.resourceContentUrl)&&u(e.viewerUrl),q=e=>r(e)&&(null==e.filenameExtension||u(e.filenameExtension))&&(null==e.editorialType||U(e.editorialType))&&(null==e.mimeType||u(e.mimeType))&&B(e.type)&&u(e.value);var j;e.FtUserRole=void 0,(j=e.FtUserRole||(e.FtUserRole={})).PERSONAL_BOOK_USER="PERSONAL_BOOK_USER",j.PERSONAL_BOOK_SHARE_USER="PERSONAL_BOOK_SHARE_USER",j.HTML_EXPORT_USER="HTML_EXPORT_USER",j.PDF_EXPORT_USER="PDF_EXPORT_USER",j.SAVED_SEARCH_USER="SAVED_SEARCH_USER",j.COLLECTION_USER="COLLECTION_USER",j.OFFLINE_USER="OFFLINE_USER",j.ANALYTICS_USER="ANALYTICS_USER",j.BETA_USER="BETA_USER",j.DEBUG_USER="DEBUG_USER",j.PRINT_USER="PRINT_USER",j.RATING_USER="RATING_USER",j.FEEDBACK_USER="FEEDBACK_USER",j.CONTENT_PUBLISHER="CONTENT_PUBLISHER",j.KHUB_ADMIN="KHUB_ADMIN",j.USERS_ADMIN="USERS_ADMIN",j.PORTAL_ADMIN="PORTAL_ADMIN",j.ADMIN="ADMIN",j.DEVELOPER="DEVELOPER";const z=e=>"object"==typeof e&&null!=e,X=e=>"boolean"==typeof e,Y=e=>"number"==typeof e,J=e=>"string"==typeof e,Q=e=>z(e)&&X(e.mailsSentByFluidTopics)&&Array.isArray(e.recipients)&&e.recipients.every((e=>J(e)))&&Array.isArray(e.subjectMetadataIds)&&e.subjectMetadataIds.every((e=>J(e))),W=e=>z(e)&&(null==e.emailAddress||J(e.emailAddress))&&(null==e.displayName||J(e.displayName))&&Array.isArray(e.roles)&&(null==e.userId||J(e.userId)),Z=e=>z(e)&&(null==e.parentsVisibility||Array.isArray(e.parentsVisibility)&&e.parentsVisibility.every((e=>X(e))))&&X(e.isVisible),ee=e=>z(e)&&(null==e.prettyUrl||J(e.prettyUrl))&&(null==e.hasRating||X(e.hasRating))&&(null==e.pageToc||Array.isArray(e.pageToc))&&(null==e.tocId||J(e.tocId))&&Array.isArray(e.children)&&e.children.every((e=>ee(e)))&&(null==e.pageConfiguration||Z(e.pageConfiguration))&&(null==e.contentId||J(e.contentId))&&(null==e.title||J(e.title)),te=e=>z(e)&&X(e.splitCurrentPageToc),ie="undefined"==typeof window?globalThis:window;function se(e){let t={};for(let i in e){let s=e[i];("object"!=typeof s||Array.isArray(s))&&(s={prior:s});for(let e of["prior","filter"])s[e]=Array.isArray(s[e])?s[e]:[s[e]],s[e]=s[e].map((e=>null!=e?""+e:"")).filter((e=>""!==e));t[i]=s}return t}function ae(e){return`${e}-FluidTopicsUnauthenticatedUserSearchPreferences`}const ne="undefined"==typeof window?globalThis:window;class re extends Error{status;statusText;body;constructor(e,t,i){super(`${e} - ${t}: ${i}`),this.status=e,this.statusText=t,this.body=i}}async function oe(e){if(!e.ok)throw new re(e.status,e.statusText,await e.text());return e}function le(e){return"application/json"===e.headers.get("Content-Type")?e.json():e.text()}class ue{tenantBaseUrl;ftCallingApp;authorization;searchLabel;endpoints={authentication:{login:"api/authentication/login",logout:"api/authentication/logout",currentSession:"api/authentication/current-session"},khub:{maps:{mapId:e=>({info:`api/khub/maps/${e}`,toc:`api/khub/maps/${e}/toc`,pages:`api/khub/maps/${e}/pages`,feedback:`api/khub/maps/${e}/feedback`,rating:`api/khub/maps/${e}/rating`,attachments:{list:`api/khub/maps/${e}/attachments`,attachmentId:t=>({content:`api/khub/maps/${e}/attachments/${t}/content`})},resources:{list:`api/khub/maps/${e}/resources`,resourceId:t=>({content:`api/khub/maps/${e}/resources/${t}/content`})},topics:{contentId:t=>({info:`api/khub/maps/${e}/topics/${t}`,content:`api/khub/maps/${e}/topics/${t}/content`}),tocId:t=>({feedback:`api/khub/maps/${e}/topics/${t}/feedback`,rating:`api/khub/maps/${e}/topics/${t}/rating`})}})},documents:{documentId:e=>({info:`api/khub/documents/${e}`,content:`api/khub/documents/${e}/content`,text:`api/khub/documents/${e}/content/text`,feedback:`api/khub/documents/${e}/feedback`,rating:`api/khub/documents/${e}/rating`})},suggest:"api/khub/suggest",clusteredSearch:"api/khub/clustered-search",locales:"api/khub/locales"},users:{userId:e=>({collections:{collectionId:t=>({documents:`api/users/${e}/collections/${t}/documents`})}})},stylesheets:{fonts:"api/stylesheets/fonts.css",theme:"api/stylesheets/theme.css",content:{title:"api/stylesheets/content/title.css",topic:"api/stylesheets/content/topic.css"}},configuration:{reader:"api/configuration/reader"},messages:{locale:e=>({fluidTopics:{contextName:t=>({endpoint:`api/messages/${e}/fluid-topics/${t}`})}})}};get defaultHeaders(){return{...this.authorization,...this.searchLabel,"Ft-Calling-App":this.ftCallingApp}}constructor(e,t,i){e=(e??ne.__gwt_ft_moduleBase??ne.fluidtopicsclient?.__moduleBase??ne.__gwt_activeModules?.fluidtopicsclient?.moduleBase??"").trim(),this.tenantBaseUrl=e.endsWith("/")?e:e+"/",i&&void 0!==ne.location&&ne.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 i;this.authorization={Authorization:"Basic "+(i=`${e}:${t}`,"undefined"!=typeof Buffer?Buffer.from(i).toString("base64"):btoa(i))}}clearAuthentication(){this.authorization=void 0}setSearchLabel(e){this.searchLabel={"FT-search-label":e}}clearSearchLabel(){this.searchLabel=void 0}login(e,t){let i={login:e,password:t,rememberMe:!0};return this.post(this.endpoints.authentication.login,i).then((i=>(this.setCredentials(e,t),i)))}logout(){return this.post(this.endpoints.authentication.logout).then((()=>this.clearAuthentication()))}getCurrentSession(){return this.get(this.endpoints.authentication.currentSession)}getReaderConfiguration(){return this.get(this.endpoints.configuration.reader)}getMap(e){return this.get(this.endpoints.khub.maps.mapId(e).info)}getTableOfContent(e){return this.get(this.endpoints.khub.maps.mapId(e).toc)}getPages(e){return this.get(this.endpoints.khub.maps.mapId(e).pages)}getTopic(e,t){return this.get(this.endpoints.khub.maps.mapId(e).topics.contentId(t).info)}getTopicHTMLContent(e,t,i){return this.get(this.endpoints.khub.maps.mapId(e).topics.contentId(t).content+(i?"?target="+i:""))}getMapAttachments(e){return this.get(this.endpoints.khub.maps.mapId(e).attachments.list)}getMapAttachmentContent(e,t){return this.fetchRawData(this.endpoints.khub.maps.mapId(e).attachments.attachmentId(t).content)}getMapResources(e){return this.get(this.endpoints.khub.maps.mapId(e).resources.list)}getMapResourceContent(e,t){return this.fetchRawData(this.endpoints.khub.maps.mapId(e).resources.resourceId(t).content)}getUnstructuredDocument(e){return this.get(this.endpoints.khub.documents.documentId(e).info)}getUnstructuredDocumentContent(e){return this.fetchRawData(this.endpoints.khub.documents.documentId(e).content)}getUnstructuredDocumentTextContent(e){return this.get(this.endpoints.khub.documents.documentId(e).text)}getCollectionDocuments(e,t){return this.get(this.endpoints.users.userId(e).collections.collectionId(t).documents)}getSuggestions(e){return this.post(this.endpoints.khub.suggest,e)}search(e){return this.post(this.endpoints.khub.clusteredSearch,e)}getAvailableSearchLocales(){return this.get(this.endpoints.khub.locales)}getMapRating(e){return this.get(this.endpoints.khub.maps.mapId(e).rating)}rateMap(e,t,i){return this.post(this.endpoints.khub.maps.mapId(e).rating,{type:t,value:i})}unrateMap(e){return this.delete(this.endpoints.khub.maps.mapId(e).rating)}sendMapFeedback(e,t){return this.post(this.endpoints.khub.maps.mapId(e).feedback,{message:t})}rateTopic(e,t,i,s){return this.post(this.endpoints.khub.maps.mapId(e).topics.tocId(t).rating,{type:i,value:s})}unrateTopic(e,t){return this.delete(this.endpoints.khub.maps.mapId(e).topics.tocId(t).rating)}sendTopicFeedback(e,t,i){return this.post(this.endpoints.khub.maps.mapId(e).topics.tocId(t).feedback,{message:i})}getDocumentRating(e){return this.get(this.endpoints.khub.documents.documentId(e).rating)}rateDocument(e,t,i){return this.post(this.endpoints.khub.documents.documentId(e).rating,{type:t,value:i})}unrateDocument(e){return this.delete(this.endpoints.khub.documents.documentId(e).rating)}sendDocumentFeedback(e,t){return this.post(this.endpoints.khub.documents.documentId(e).feedback,{message:t})}getFluidTopicsMessageContext(e,t){return this.get(this.endpoints.messages.locale(e).fluidTopics.contextName(t).endpoint)}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)}makeAbsolute(e){return this.tenantBaseUrl+e.replace(/^\//,"")}async fetch(e,t){const i=t;return await fetch(this.makeAbsolute(e),{...i??{},headers:{...this.defaultHeaders,...i?.headers??{}}})}upload(e,t,i,s=(()=>{})){return"undefined"!=typeof XMLHttpRequest?new Promise(((a,n)=>{let r=new XMLHttpRequest;r.onload=()=>{if(r.status>=200&&r.status<300){let e="application/json"===r.getResponseHeader("Content-Type")?JSON.parse(r.responseText):r.responseText;a(e)}else n(new re(r.status,r.statusText,r.responseText))},r.upload.onprogress=e=>s(e),r.open(e,this.makeAbsolute(t),!0),r.send(i)})):this.fetch(t,{method:e,body:i}).then(oe).then(le)}makeRequest(e,t,i){return this.fetch(t,{method:e,headers:{...null!=i?{"Content-Type":"application/json"}:{}},body:null!=i?JSON.stringify(i):void 0,credentials:null==this.authorization?"include":void 0}).then(oe).then(le)}fetchRawData(e){return fetch(this.makeAbsolute(e),{headers:this.defaultHeaders,credentials:null==this.authorization?"include":void 0}).then(oe).then((e=>e.arrayBuffer()))}}e.FluidTopicsApi=ue,e.HttpError=re,e.addUnauthenticatedUserSearchPreferencesChangeHandler=function(e,t){if(ie.localStorage){const i=ae(e),s=e=>{e.storageArea===ie.localStorage&&e.key===i&&t(JSON.parse(e.newValue??"{}"))};return ie.addEventListener("storage",s),{removeHandler:()=>ie.removeEventListener("storage",s)}}console.error("Cannot handle unauthenticated preferences: local storage is unavailable.")},e.default=ue,e.getUnauthenticatedUserSearchPreferences=function(e){if(ie.localStorage)return JSON.parse(ie.localStorage.getItem(ae(e))??"{}");console.error("Cannot get unauthenticated preferences: local storage is unavailable.")},e.isFtAuthenticatedSession=e=>z(e)&&W(e.profile),e.isFtAuthenticationIdentifier=e=>r(e)&&u(e.identifier)&&u(e.realm),e.isFtCollectionDocument=e=>r(e)&&o(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=>r(e)&&u(e.password)&&(null==e.newPassword||u(e.newPassword))&&o(e.rememberMe)&&u(e.login),e.isFtEditorialType=U,e.isFtFeedbackCreation=e=>r(e)&&u(e.message),e.isFtMap=e=>r(e)&&(null==e.prettyUrl||u(e.prettyUrl))&&Array.isArray(e.metadata)&&e.metadata.every((e=>y(e)))&&O(e.openMode)&&u(e.topicsApiEndpoint)&&(null==e.description||u(e.description))&&u(e.attachmentsApiEndpoint)&&U(e.editorialType)&&u(e.baseId)&&u(e.clusterId)&&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)&&J(e.file)&&(null==e.size||Y(e.size))&&X(e.externalLink)&&J(e.name)&&J(e.id)&&(null==e.mimeType||J(e.mimeType))&&(null==e.viewerUrl||J(e.viewerUrl)),e.isFtMapResource=e=>r(e)&&u(e.contentUrl)&&u(e.filename)&&u(e.id)&&u(e.mimeType),e.isFtMapStyles=c,e.isFtMessageContext=e=>z(e)&&J(e.name)&&z(e.messages)&&Object.keys(e.messages).every((e=>J(e)))&&Object.values(e.messages).every((e=>J(e)))&&J(e.locale),e.isFtMetadata=y,e.isFtMetadataPreferenceConfiguration=T,e.isFtOpenMode=O,e.isFtPageConfiguration=Z,e.isFtPageRequest=C,e.isFtPaginatedToc=e=>z(e)&&te(e.configuration)&&Array.isArray(e.paginatedToc)&&e.paginatedToc.every((e=>ee(e))),e.isFtPaginatedTocNode=ee,e.isFtPaginationConfiguration=te,e.isFtPublicationRating=A,e.isFtPublicationRatingSummary=f,e.isFtRatingCreation=e=>r(e)&&m(e.type)&&l(e.value),e.isFtRatingSummary=e=>r(e)&&(null==e.topics||E(e.topics))&&f(e.publication),e.isFtRatingType=m,e.isFtReaderConfiguration=e=>z(e)&&Q(e.feedback)&&Y(e.loadAfterLastVisibleTopic)&&Y(e.loadBeforeFirstVisibleTopic),e.isFtReaderFeedbackConfiguration=Q,e.isFtSearchFacet=H,e.isFtSearchFacetConf=x,e.isFtSearchFacetEntry=$,e.isFtSearchFilter=S,e.isFtSearchLocale=h,e.isFtSearchLocales=e=>r(e)&&Array.isArray(e.contentLocales)&&e.contentLocales.every((e=>h(e))),e.isFtSearchPreferencesConfiguration=e=>r(e)&&r(e.metadata)&&Object.keys(e.metadata).every((e=>u(e)))&&Object.values(e.metadata).every((e=>T(e))),e.isFtSearchPreset=e=>r(e)&&u(e.name)&&Array.isArray(e.filters)&&e.filters.every((e=>S(e)))&&l(e.priority)&&(null==e.contentLocale||u(e.contentLocale)),e.isFtSearchPrior=k,e.isFtSearchRequest=e=>r(e)&&u(e.query)&&C(e.paging)&&Array.isArray(e.filters)&&e.filters.every((e=>S(e)))&&Array.isArray(e.sort)&&e.sort.every((e=>K(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=>x(e))),e.isFtSearchResultCluster=P,e.isFtSearchResultClusterEntry=D,e.isFtSearchResultMap=L,e.isFtSearchResultTopic=M,e.isFtSearchResultType=B,e.isFtSearchResultUnstructuredDocument=N,e.isFtSearchResults=e=>r(e)&&(null==e.spellcheck||V(e.spellcheck))&&b(e.paging)&&Array.isArray(e.results)&&e.results.every((e=>P(e)))&&Array.isArray(e.facets)&&e.facets.every((e=>H(e))),e.isFtSearchResultsPageInfo=b,e.isFtSearchSortCriterion=K,e.isFtSession=e=>z(e)&&Y(e.idleTimeoutInMillis)&&W(e.profile)&&X(e.sessionAuthenticated),e.isFtSpellcheck=V,e.isFtSuggestRequest=e=>r(e)&&u(e.input)&&Array.isArray(e.filters)&&e.filters.every((e=>S(e)))&&Array.isArray(e.sort)&&e.sort.every((e=>K(e)))&&(null==e.maxCount||l(e.maxCount))&&(null==e.contentLocale||u(e.contentLocale)),e.isFtSuggestResult=q,e.isFtSuggestResults=e=>r(e)&&Array.isArray(e.suggestions)&&e.suggestions.every((e=>q(e))),e.isFtTocNode=d,e.isFtTopic=e=>r(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.isFtTopicRating=R,e.isFtTopicResource=G,e.isFtTopicsRatingSummary=E,e.isFtUnstructuredDocument=e=>r(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=W,e.isFtUserRole=e=>["PERSONAL_BOOK_USER","PERSONAL_BOOK_SHARE_USER","HTML_EXPORT_USER","PDF_EXPORT_USER","SAVED_SEARCH_USER","COLLECTION_USER","OFFLINE_USER","ANALYTICS_USER","BETA_USER","DEBUG_USER","PRINT_USER","RATING_USER","FEEDBACK_USER","CONTENT_PUBLISHER","KHUB_ADMIN","USERS_ADMIN","PORTAL_ADMIN","ADMIN","DEVELOPER"].includes(e),e.setUnauthenticatedUserSearchPreferences=function(e,t){if(ie.localStorage){let i={...t,metadata:se(t.metadata??{})};const s=ae(e),a=JSON.stringify(i);return ie.localStorage.setItem(s,a),ie.dispatchEvent(new StorageEvent("storage",{key:s,newValue:a,storageArea:ie.localStorage,url:ie.location.href})),i}console.error("Cannot set unauthenticated preferences: local storage is unavailable.")}}));
@@ -1,6 +1,6 @@
1
1
  import "cross-fetch/polyfill";
2
2
  import { FtCollectionDocument, FtMap, FtMapResource, FtRatingSummary, FtRatingType, FtSearchLocales, FtSearchRequest, FtSearchResults, FtSuggestRequest, FtSuggestResults, FtTocNode, FtTopic, FtTopicContentTarget, FtTopicContentTargetKeys, FtUnstructuredDocument } from "./types/ft-common/public";
3
- import { FtAuthenticatedSession, FtMapAttachment, FtPaginatedToc, FtReaderConfiguration, FtSession } from "./types/ft-server/public";
3
+ import { FtAuthenticatedSession, FtMapAttachment, FtMessageContext, FtPaginatedToc, FtReaderConfiguration, FtSession } from "./types/ft-server/public";
4
4
  export * from "./types/ft-common/public";
5
5
  export * from "./types/ft-server/public";
6
6
  export * from "./preferences/unauthenticated-preferences";
@@ -86,6 +86,15 @@ export declare class FluidTopicsApi {
86
86
  configuration: {
87
87
  reader: string;
88
88
  };
89
+ messages: {
90
+ locale: (locale: string) => {
91
+ fluidTopics: {
92
+ contextName: (contextName: string) => {
93
+ endpoint: string;
94
+ };
95
+ };
96
+ };
97
+ };
89
98
  };
90
99
  private get defaultHeaders();
91
100
  constructor(tenantBaseUrl: string, integrationIdentifier: string, overrideIdentifierIfOnTenant?: boolean);
@@ -125,6 +134,7 @@ export declare class FluidTopicsApi {
125
134
  rateDocument(docId: string, type: FtRatingType, value: number): Promise<void>;
126
135
  unrateDocument(docId: string): Promise<void>;
127
136
  sendDocumentFeedback(docId: string, message: string): Promise<void>;
137
+ getFluidTopicsMessageContext(locale: string, name: string): Promise<FtMessageContext>;
128
138
  get<T>(endpoint: string): Promise<T>;
129
139
  post<T>(endpoint: string, data?: any): Promise<T>;
130
140
  put<T>(endpoint: string, data?: any): Promise<T>;
package/dist/mjs/index.js CHANGED
@@ -102,6 +102,15 @@ export class FluidTopicsApi {
102
102
  configuration: {
103
103
  reader: `api/configuration/reader`
104
104
  },
105
+ messages: {
106
+ locale: (locale) => ({
107
+ fluidTopics: {
108
+ contextName: (contextName) => ({
109
+ endpoint: `api/messages/${locale}/fluid-topics/${contextName}`,
110
+ })
111
+ }
112
+ })
113
+ },
105
114
  };
106
115
  get defaultHeaders() {
107
116
  return {
@@ -241,6 +250,9 @@ export class FluidTopicsApi {
241
250
  sendDocumentFeedback(docId, message) {
242
251
  return this.post(this.endpoints.khub.documents.documentId(docId).feedback, { message });
243
252
  }
253
+ getFluidTopicsMessageContext(locale, name) {
254
+ return this.get(this.endpoints.messages.locale(locale).fluidTopics.contextName(name).endpoint);
255
+ }
244
256
  get(endpoint) {
245
257
  return this.makeRequest("GET", endpoint);
246
258
  }
@@ -1,9 +1,15 @@
1
1
  export interface FtReaderConfiguration {
2
+ feedback: FtReaderFeedbackConfiguration;
2
3
  loadAfterLastVisibleTopic: number;
3
- feedbackMailsSentByFluidTopics: boolean;
4
4
  loadBeforeFirstVisibleTopic: number;
5
5
  }
6
6
  export declare const isFtReaderConfiguration: (o: any) => o is FtReaderConfiguration;
7
+ export interface FtReaderFeedbackConfiguration {
8
+ mailsSentByFluidTopics: boolean;
9
+ recipients: Array<string>;
10
+ subjectMetadataIds: Array<string>;
11
+ }
12
+ export declare const isFtReaderFeedbackConfiguration: (o: any) => o is FtReaderFeedbackConfiguration;
7
13
  export interface FtAuthenticatedSession {
8
14
  authenticationIdentifier: any;
9
15
  profile: FtUserProfile;
@@ -58,3 +64,9 @@ export interface FtPaginationConfiguration {
58
64
  splitCurrentPageToc: boolean;
59
65
  }
60
66
  export declare const isFtPaginationConfiguration: (o: any) => o is FtPaginationConfiguration;
67
+ export interface FtMessageContext {
68
+ name: string;
69
+ messages: Record<string, string>;
70
+ locale: string;
71
+ }
72
+ export declare const isFtMessageContext: (o: any) => o is FtMessageContext;
@@ -4,10 +4,18 @@ const isNumber = (o) => typeof o === "number";
4
4
  const isString = (o) => typeof o === "string";
5
5
  export const isFtReaderConfiguration = (o) => {
6
6
  return isObject(o)
7
+ && (isFtReaderFeedbackConfiguration(o.feedback))
7
8
  && (isNumber(o.loadAfterLastVisibleTopic))
8
- && (isBoolean(o.feedbackMailsSentByFluidTopics))
9
9
  && (isNumber(o.loadBeforeFirstVisibleTopic));
10
10
  };
11
+ export const isFtReaderFeedbackConfiguration = (o) => {
12
+ return isObject(o)
13
+ && (isBoolean(o.mailsSentByFluidTopics))
14
+ && ((Array.isArray(o.recipients)
15
+ && o.recipients.every((v) => isString(v))))
16
+ && ((Array.isArray(o.subjectMetadataIds)
17
+ && o.subjectMetadataIds.every((v) => isString(v))));
18
+ };
11
19
  export const isFtAuthenticatedSession = (o) => {
12
20
  return isObject(o)
13
21
  && (isFtUserProfile(o.profile));
@@ -63,3 +71,11 @@ export const isFtPaginationConfiguration = (o) => {
63
71
  return isObject(o)
64
72
  && (isBoolean(o.splitCurrentPageToc));
65
73
  };
74
+ export const isFtMessageContext = (o) => {
75
+ return isObject(o)
76
+ && (isString(o.name))
77
+ && ((isObject(o.messages)
78
+ && Object.keys(o.messages).every((k) => isString(k))
79
+ && Object.values(o.messages).every((v) => isString(v))))
80
+ && (isString(o.locale));
81
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluid-topics/public-api",
3
- "version": "1.0.29",
3
+ "version": "1.0.31",
4
4
  "description": "Fluid Topics Public API",
5
5
  "author": "Fluid Topics dev team <opensource@antidot.net>",
6
6
  "license": "LGPL-3.0-only",