@fluid-topics/public-api 1.0.20 → 1.0.21
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.
|
@@ -107,9 +107,10 @@ var FtTopicContentTarget;
|
|
|
107
107
|
FtTopicContentTarget["OFF_THE_GRID"] = "OFF_THE_GRID";
|
|
108
108
|
FtTopicContentTarget["CONTENT_PACKAGER"] = "CONTENT_PACKAGER";
|
|
109
109
|
FtTopicContentTarget["PAGES"] = "PAGES";
|
|
110
|
+
FtTopicContentTarget["DESIGNED_READER"] = "DESIGNED_READER";
|
|
110
111
|
})(FtTopicContentTarget = exports.FtTopicContentTarget || (exports.FtTopicContentTarget = {}));
|
|
111
112
|
const isFtTopicContentTarget = (o) => {
|
|
112
|
-
return ["THIRD_PARTY", "OFF_THE_GRID", "CONTENT_PACKAGER", "PAGES"].includes(o);
|
|
113
|
+
return ["THIRD_PARTY", "OFF_THE_GRID", "CONTENT_PACKAGER", "PAGES", "DESIGNED_READER"].includes(o);
|
|
113
114
|
};
|
|
114
115
|
exports.isFtTopicContentTarget = isFtTopicContentTarget;
|
|
115
116
|
const isFtSearchLocale = (o) => {
|
package/dist/fluidtopics.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).fluidtopics={})}(this,(function(e){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},r={exports:{}},a={exports:{}};!function(e,t){var r=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==r)return r;throw new Error("unable to locate global object")}();e.exports=t=r.fetch,r.fetch&&(t.default=r.fetch.bind(r)),t.Headers=r.Headers,t.Request=r.Request,t.Response=r.Response}(a,a.exports),function(e,t){const r=a.exports,i=r.default||r,n=function(e,t){return/^\/\//.test(e)&&(e="https:"+e),i.call(this,e,t)};n.ponyfill=!0,e.exports=t=n,t.fetch=n,t.Headers=r.Headers,t.Request=r.Request,t.Response=r.Response,t.default=n}(r,r.exports);const i=r.exports,n=i.fetch.bind({});n.polyfill=!0,t.fetch||(t.fetch=n,t.Response=i.Response,t.Headers=i.Headers,t.Request=i.Request);const s=e=>"object"==typeof e&&null!=e,l=e=>"boolean"==typeof e,o=e=>"number"==typeof e,u=e=>"string"==typeof e,c=e=>s(e)&&(null==e.prettyUrl||u(e.prettyUrl))&&u(e.tocId)&&Array.isArray(e.children)&&e.children.every((e=>c(e)))&&u(e.contentId)&&(null==e.page||p(e.page))&&u(e.title),p=e=>s(e)&&l(e.visible)&&l(e.onItsOwn)&&(null==e.parentsVisibility||Array.isArray(e.parentsVisibility)&&e.parentsVisibility.every((e=>l(e))));var d;e.FtTopicContentTarget=void 0,(d=e.FtTopicContentTarget||(e.FtTopicContentTarget={})).THIRD_PARTY="THIRD_PARTY",d.OFF_THE_GRID="OFF_THE_GRID",d.CONTENT_PACKAGER="CONTENT_PACKAGER",d.PAGES="PAGES";const h=e=>s(e)&&o(e.count)&&u(e.label)&&(null==e.lang||u(e.lang)),y=e=>s(e)&&Array.isArray(e.values)&&e.values.every((e=>u(e)))&&u(e.label)&&u(e.key),f=e=>s(e)&&Array.isArray(e.filter)&&e.filter.every((e=>u(e)))&&Array.isArray(e.prior)&&e.prior.every((e=>u(e))),g=e=>s(e)&&l(e.negative)&&Array.isArray(e.values)&&e.values.every((e=>u(e)))&&u(e.key),m=e=>s(e)&&o(e.totalResultsCount)&&l(e.lastPage)&&o(e.currentPage)&&o(e.totalClustersCount);var A;e.FtEditorialType=void 0,(A=e.FtEditorialType||(e.FtEditorialType={})).ARTICLE="ARTICLE",A.BOOK="BOOK";const T=e=>["ARTICLE","BOOK"].includes(e);var b;e.FtOpenMode=void 0,(b=e.FtOpenMode||(e.FtOpenMode={})).FLUIDTOPICS="FLUIDTOPICS",b.EXTERNAL="EXTERNAL";const F=e=>["FLUIDTOPICS","EXTERNAL"].includes(e),v=e=>s(e)&&(null==e.perPage||o(e.perPage))&&o(e.page);var C;e.FtCollectionDocumentType=void 0,(C=e.FtCollectionDocumentType||(e.FtCollectionDocumentType={})).MAP="MAP",C.DOCUMENT="DOCUMENT",C.TOPIC="TOPIC",C.PERSONAL_BOOK="PERSONAL_BOOK",C.SHARED_BOOK="SHARED_BOOK";const R=e=>["MAP","DOCUMENT","TOPIC","PERSONAL_BOOK","SHARED_BOOK"].includes(e),E=e=>s(e)&&o(e.weight)&&u(e.value)&&u(e.key),S=e=>s(e)&&Array.isArray(e.entries)&&e.entries.every((e=>U(e)))&&(null==e.metadataVariableAxis||u(e.metadataVariableAxis)),U=e=>s(e)&&(null==e.document||P(e.document))&&(null==e.topic||w(e.topic))&&I(e.type)&&(null==e.map||O(e.map)),P=e=>s(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>y(e)))&&F(e.openMode)&&u(e.documentUrl)&&u(e.mimeType)&&u(e.title)&&(null==e.lastPublicationDate||u(e.lastPublicationDate))&&u(e.viewerUrl)&&u(e.contentUrl)&&u(e.filename)&&u(e.htmlTitle)&&(null==e.originUrl||u(e.originUrl))&&u(e.documentId)&&u(e.lastEditionDate)&&u(e.htmlExcerpt),O=e=>s(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>y(e)))&&(null==e.openMode||F(e.openMode))&&T(e.editorialType)&&u(e.title)&&(null==e.lastPublicationDate||u(e.lastPublicationDate))&&u(e.htmlTitle)&&(null==e.originUrl||u(e.originUrl))&&u(e.mapUrl)&&u(e.readerUrl)&&u(e.mapId)&&(null==e.lastEditionDate||u(e.lastEditionDate))&&u(e.htmlExcerpt),w=e=>s(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>y(e)))&&F(e.openMode)&&u(e.contentId)&&Array.isArray(e.resources)&&e.resources.every((e=>_(e)))&&u(e.title)&&u(e.mapTitle)&&u(e.topicUrl)&&u(e.contentUrl)&&u(e.htmlTitle)&&Array.isArray(e.breadcrumb)&&e.breadcrumb.every((e=>u(e)))&&u(e.tocId)&&(null==e.originUrl||u(e.originUrl))&&u(e.readerUrl)&&u(e.mapId)&&(null==e.lastEditionDate||u(e.lastEditionDate))&&u(e.htmlExcerpt);var D;e.FtSearchResultType=void 0,(D=e.FtSearchResultType||(e.FtSearchResultType={})).MAP="MAP",D.DOCUMENT="DOCUMENT",D.TOPIC="TOPIC";const I=e=>["MAP","DOCUMENT","TOPIC"].includes(e),M=e=>s(e)&&l(e.hierarchical)&&u(e.label)&&l(e.multiSelectionable)&&u(e.key)&&Array.isArray(e.rootNodes)&&e.rootNodes.every((e=>x(e))),k=e=>s(e)&&(null==e.maxDepth||o(e.maxDepth))&&u(e.id),x=e=>s(e)&&o(e.totalResultsCount)&&l(e.descendantSelected)&&Array.isArray(e.childNodes)&&e.childNodes.every((e=>x(e)))&&u(e.label)&&u(e.value)&&l(e.selected),L=e=>s(e)&&u(e.key),N=e=>s(e)&&u(e.suggestedQuery)&&u(e.htmlSuggestedQuery),_=e=>s(e)&&u(e.filename)&&u(e.resourceUrl)&&u(e.id)&&u(e.mimeType)&&u(e.resourceContentUrl)&&u(e.viewerUrl),$=e=>s(e)&&(null==e.filenameExtension||u(e.filenameExtension))&&(null==e.editorialType||T(e.editorialType))&&(null==e.mimeType||u(e.mimeType))&&I(e.type)&&u(e.value),H=e=>"object"==typeof e&&null!=e,B=e=>"boolean"==typeof e,q=e=>"number"==typeof e,K=e=>"string"==typeof e,j=e=>H(e)&&(null==e.emailAddress||K(e.emailAddress))&&(null==e.displayName||K(e.displayName))&&Array.isArray(e.roles)&&K(e.userId),V="undefined"==typeof window?globalThis:window;function G(e){let t={};for(let r in e){let a=e[r];("object"!=typeof a||Array.isArray(a))&&(a={prior:a});for(let e of["prior","filter"])a[e]=Array.isArray(a[e])?a[e]:[a[e]],a[e]=a[e].map((e=>null!=e?""+e:"")).filter((e=>""!==e));t[r]=a}return t}function z(e){return`${e}-FluidTopicsUnauthenticatedUserSearchPreferences`}const J="undefined"==typeof window?globalThis:window;class X extends Error{status;statusText;body;constructor(e,t,r){super(`${e} - ${t}: ${r}`),this.status=e,this.statusText=t,this.body=r}}async function Y(e){if(!e.ok)throw new X(e.status,e.statusText,await e.text());return e}function Q(e){return"application/json"===e.headers.get("Content-Type")?e.json():e.text()}class W{tenantBaseUrl;ftCallingApp;authorization={};get defaultHeaders(){return{...this.authorization,"Ft-Calling-App":this.ftCallingApp}}constructor(e,t,r){e=e??J.__gwt_ft_moduleBase??J.fluidtopicsclient?.__moduleBase??J.__gwt_activeModules?.fluidtopicsclient?.moduleBase,this.tenantBaseUrl=e.trim().replace(/\/$/,""),r&&void 0!==J.location&&J.location.href.startsWith(this.tenantBaseUrl+"/")?this.ftCallingApp=t:this.ftCallingApp=`ft-public-api/${t}`}setApiKey(e){this.authorization={Authorization:"Bearer "+e}}setCredentials(e,t){var r;this.authorization={Authorization:"Basic "+(r=`${e}:${t}`,"undefined"!=typeof Buffer?Buffer.from(r).toString("base64"):btoa(r))}}clearAuthentication(){this.authorization={}}login(e,t){let r={login:e,password:t,rememberMe:!0};return this.post("/api/authentication/login",r).then((r=>(this.setCredentials(e,t),r)))}logout(){return this.post("/api/authentication/logout").then((()=>this.clearAuthentication()))}getCurrentSession(){return this.get("/api/authentication/current-session")}getMap(e){return this.get(`/api/khub/maps/${e}`)}getTableOfContent(e){return this.get(`/api/khub/maps/${e}/toc`)}getTopic(e,t){return this.get(`/api/khub/maps/${e}/topics/${t}`)}getTopicHTMLContent(e,t,r){return this.get(`/api/khub/maps/${e}/topics/${t}/content${r?"?target="+r:""}`)}getMapAttachments(e){return this.get(`/api/khub/maps/${e}/attachments`)}getMapAttachmentContent(e,t){return this.fetchRawData(`/api/khub/maps/${e}/attachments/${t}/content`)}getMapResources(e){return this.get(`/api/khub/maps/${e}/resources`)}getMapResourceContent(e,t){return this.fetchRawData(`/api/khub/maps/${e}/resources/${t}/content`)}getUnstructuredDocument(e){return this.get(`/api/khub/documents/${e}`)}getUnstructuredDocumentContent(e){return this.fetchRawData(`/api/khub/documents/${e}/content`)}getUnstructuredDocumentTextContent(e){return this.get(`/api/khub/documents/${e}/content/text`)}getCollectionDocuments(e,t){return this.get(`/api/users/${e}/collections/${t}/documents`)}getSuggestions(e){return this.post("/api/khub/suggest",e)}search(e){return this.post("/api/khub/clustered-search",e)}getAvailableSearchLocales(){return this.get("/api/khub/locales")}get(e){return this.makeRequest("GET",e)}post(e,t){return this.makeRequest("POST",e,t)}put(e,t){return this.makeRequest("PUT",e,t)}delete(e){return this.makeRequest("DELETE",e)}async fetch(e,t){const r=t;return e.startsWith("/")||(e="/"+e),await fetch(this.tenantBaseUrl+e,{...r??{},headers:{...this.defaultHeaders,...r?.headers??{}}})}async upload(e,t,r,a=(()=>{})){return new Promise(((i,n)=>{let s=new XMLHttpRequest;s.onload=()=>{if(s.status>=200&&s.status<300){let e="application/json"===s.getResponseHeader("Content-Type")?JSON.parse(s.responseText):s.responseText;i(e)}else n(new X(s.status,s.statusText,s.responseText))},s.upload.onprogress=e=>a(e),s.open(e,this.tenantBaseUrl+t,!0),s.send(r)}))}makeRequest(e,t,r){return this.fetch(t,{method:e,headers:{...null!=r?{"Content-Type":"application/json"}:{}},body:null!=r?JSON.stringify(r):void 0}).then(Y).then(Q)}fetchRawData(e){return fetch(this.tenantBaseUrl+e,{headers:this.defaultHeaders}).then(Y).then((e=>e.arrayBuffer()))}}e.FluidTopicsApi=W,e.HttpError=X,e.addUnauthenticatedUserSearchPreferencesChangeHandler=function(e,t){if(V.localStorage){const r=z(e),a=e=>{e.storageArea===V.localStorage&&e.key===r&&t(JSON.parse(e.newValue??"{}"))};return V.addEventListener("storage",a),{removeHandler:()=>V.removeEventListener("storage",a)}}console.error("Cannot handle unauthenticated preferences: local storage is unavailable.")},e.default=W,e.getUnauthenticatedUserSearchPreferences=function(e){if(V.localStorage)return JSON.parse(V.localStorage.getItem(z(e))??"{}");console.error("Cannot get unauthenticated preferences: local storage is unavailable.")},e.isFtAuthenticatedSession=e=>H(e)&&j(e.profile),e.isFtAuthenticationIdentifier=e=>s(e)&&u(e.identifier)&&u(e.realm),e.isFtCollectionDocument=e=>s(e)&&l(e.deleted)&&(null==e.apiUrl||u(e.apiUrl))&&(null==e.portalUrl||u(e.portalUrl))&&u(e.id)&&u(e.title)&&R(e.type),e.isFtCollectionDocumentType=R,e.isFtCredentials=e=>s(e)&&u(e.password)&&(null==e.newPassword||u(e.newPassword))&&l(e.rememberMe)&&u(e.login),e.isFtEditorialType=T,e.isFtMap=e=>s(e)&&(null==e.prettyUrl||u(e.prettyUrl))&&Array.isArray(e.metadata)&&e.metadata.every((e=>y(e)))&&F(e.openMode)&&u(e.topicsApiEndpoint)&&(null==e.description||u(e.description))&&u(e.attachmentsApiEndpoint)&&T(e.editorialType)&&u(e.baseId)&&u(e.clusterId)&&(null==e.shouldSplitCurrentPageToc||l(e.shouldSplitCurrentPageToc))&&u(e.title)&&u(e.lastPublication)&&u(e.lastEdition)&&u(e.originId)&&u(e.rightsApiEndpoint)&&(null==e.originUrl||u(e.originUrl))&&u(e.readerUrl)&&(null==e.khubVersion||u(e.khubVersion))&&u(e.id)&&(null==e.lang||u(e.lang)),e.isFtMapAttachment=e=>H(e)&&K(e.file)&&(null==e.size||q(e.size))&&B(e.externalLink)&&K(e.name)&&K(e.id)&&(null==e.mimeType||K(e.mimeType))&&(null==e.viewerUrl||K(e.viewerUrl)),e.isFtMapResource=e=>s(e)&&u(e.contentUrl)&&u(e.filename)&&u(e.id)&&u(e.mimeType),e.isFtMetadata=y,e.isFtMetadataPreferenceConfiguration=f,e.isFtOpenMode=F,e.isFtPageRequest=v,e.isFtSearchFacet=M,e.isFtSearchFacetConf=k,e.isFtSearchFacetEntry=x,e.isFtSearchFilter=g,e.isFtSearchLocale=h,e.isFtSearchLocales=e=>s(e)&&Array.isArray(e.contentLocales)&&e.contentLocales.every((e=>h(e))),e.isFtSearchPreferencesConfiguration=e=>s(e)&&s(e.metadata)&&Object.keys(e.metadata).every((e=>u(e)))&&Object.values(e.metadata).every((e=>f(e))),e.isFtSearchPreset=e=>s(e)&&u(e.name)&&Array.isArray(e.filters)&&e.filters.every((e=>g(e)))&&(null==e.contentLocale||u(e.contentLocale)),e.isFtSearchPrior=E,e.isFtSearchRequest=e=>s(e)&&u(e.query)&&v(e.paging)&&Array.isArray(e.filters)&&e.filters.every((e=>g(e)))&&Array.isArray(e.sort)&&e.sort.every((e=>L(e)))&&(null==e.uiLocale||u(e.uiLocale))&&(null==e.contentLocale||u(e.contentLocale))&&(null==e.priors||Array.isArray(e.priors)&&e.priors.every((e=>E(e))))&&Array.isArray(e.facets)&&e.facets.every((e=>k(e))),e.isFtSearchResultCluster=S,e.isFtSearchResultClusterEntry=U,e.isFtSearchResultMap=O,e.isFtSearchResultTopic=w,e.isFtSearchResultType=I,e.isFtSearchResultUnstructuredDocument=P,e.isFtSearchResults=e=>s(e)&&(null==e.spellcheck||N(e.spellcheck))&&m(e.paging)&&Array.isArray(e.results)&&e.results.every((e=>S(e)))&&Array.isArray(e.facets)&&e.facets.every((e=>M(e))),e.isFtSearchResultsPageInfo=m,e.isFtSearchSortCriterion=L,e.isFtSession=e=>H(e)&&q(e.idleTimeoutInMillis)&&(null==e.profile||j(e.profile))&&B(e.sessionAuthenticated),e.isFtSpellcheck=N,e.isFtSuggestRequest=e=>s(e)&&u(e.input)&&Array.isArray(e.filters)&&e.filters.every((e=>g(e)))&&Array.isArray(e.sort)&&e.sort.every((e=>L(e)))&&(null==e.maxCount||o(e.maxCount))&&(null==e.contentLocale||u(e.contentLocale)),e.isFtSuggestResult=$,e.isFtSuggestResults=e=>s(e)&&Array.isArray(e.suggestions)&&e.suggestions.every((e=>$(e))),e.isFtTocNode=c,e.isFtTocPage=p,e.isFtTopic=e=>s(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>y(e)))&&u(e.id)&&u(e.contentApiEndpoint)&&u(e.title),e.isFtTopicContentTarget=e=>["THIRD_PARTY","OFF_THE_GRID","CONTENT_PACKAGER","PAGES"].includes(e),e.isFtTopicResource=_,e.isFtUnstructuredDocument=e=>s(e)&&(null==e.prettyUrl||u(e.prettyUrl))&&Array.isArray(e.metadata)&&e.metadata.every((e=>y(e)))&&u(e.openMode)&&(null==e.description||u(e.description))&&u(e.mimeType)&&(null==e.baseId||u(e.baseId))&&(null==e.clusterId||u(e.clusterId))&&u(e.contentApiEndpoint)&&u(e.title)&&(null==e.lastPublication||u(e.lastPublication))&&u(e.viewerUrl)&&u(e.lastEdition)&&u(e.filename)&&(null==e.originId||u(e.originId))&&u(e.rightsApiEndpoint)&&(null==e.originUrl||u(e.originUrl))&&(null==e.khubVersion||u(e.khubVersion))&&u(e.id)&&(null==e.lang||u(e.lang)),e.isFtUserProfile=j,e.setUnauthenticatedUserSearchPreferences=function(e,t){if(V.localStorage){let r={...t,metadata:G(t.metadata??{})};const a=z(e),i=JSON.stringify(r);return V.localStorage.setItem(a,i),V.dispatchEvent(new StorageEvent("storage",{key:a,newValue:i,storageArea:V.localStorage,url:V.location.href})),r}console.error("Cannot set unauthenticated preferences: local storage is unavailable.")}}));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).fluidtopics={})}(this,(function(e){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},r={exports:{}},a={exports:{}};!function(e,t){var r=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==r)return r;throw new Error("unable to locate global object")}();e.exports=t=r.fetch,r.fetch&&(t.default=r.fetch.bind(r)),t.Headers=r.Headers,t.Request=r.Request,t.Response=r.Response}(a,a.exports),function(e,t){const r=a.exports,i=r.default||r,n=function(e,t){return/^\/\//.test(e)&&(e="https:"+e),i.call(this,e,t)};n.ponyfill=!0,e.exports=t=n,t.fetch=n,t.Headers=r.Headers,t.Request=r.Request,t.Response=r.Response,t.default=n}(r,r.exports);const i=r.exports,n=i.fetch.bind({});n.polyfill=!0,t.fetch||(t.fetch=n,t.Response=i.Response,t.Headers=i.Headers,t.Request=i.Request);const s=e=>"object"==typeof e&&null!=e,l=e=>"boolean"==typeof e,o=e=>"number"==typeof e,u=e=>"string"==typeof e,c=e=>s(e)&&(null==e.prettyUrl||u(e.prettyUrl))&&u(e.tocId)&&Array.isArray(e.children)&&e.children.every((e=>c(e)))&&u(e.contentId)&&(null==e.page||p(e.page))&&u(e.title),p=e=>s(e)&&l(e.visible)&&l(e.onItsOwn)&&(null==e.parentsVisibility||Array.isArray(e.parentsVisibility)&&e.parentsVisibility.every((e=>l(e))));var d;e.FtTopicContentTarget=void 0,(d=e.FtTopicContentTarget||(e.FtTopicContentTarget={})).THIRD_PARTY="THIRD_PARTY",d.OFF_THE_GRID="OFF_THE_GRID",d.CONTENT_PACKAGER="CONTENT_PACKAGER",d.PAGES="PAGES",d.DESIGNED_READER="DESIGNED_READER";const h=e=>s(e)&&o(e.count)&&u(e.label)&&(null==e.lang||u(e.lang)),y=e=>s(e)&&Array.isArray(e.values)&&e.values.every((e=>u(e)))&&u(e.label)&&u(e.key),f=e=>s(e)&&Array.isArray(e.filter)&&e.filter.every((e=>u(e)))&&Array.isArray(e.prior)&&e.prior.every((e=>u(e))),g=e=>s(e)&&l(e.negative)&&Array.isArray(e.values)&&e.values.every((e=>u(e)))&&u(e.key),m=e=>s(e)&&o(e.totalResultsCount)&&l(e.lastPage)&&o(e.currentPage)&&o(e.totalClustersCount);var A;e.FtEditorialType=void 0,(A=e.FtEditorialType||(e.FtEditorialType={})).ARTICLE="ARTICLE",A.BOOK="BOOK";const T=e=>["ARTICLE","BOOK"].includes(e);var E;e.FtOpenMode=void 0,(E=e.FtOpenMode||(e.FtOpenMode={})).FLUIDTOPICS="FLUIDTOPICS",E.EXTERNAL="EXTERNAL";const b=e=>["FLUIDTOPICS","EXTERNAL"].includes(e),F=e=>s(e)&&(null==e.perPage||o(e.perPage))&&o(e.page);var R;e.FtCollectionDocumentType=void 0,(R=e.FtCollectionDocumentType||(e.FtCollectionDocumentType={})).MAP="MAP",R.DOCUMENT="DOCUMENT",R.TOPIC="TOPIC",R.PERSONAL_BOOK="PERSONAL_BOOK",R.SHARED_BOOK="SHARED_BOOK";const v=e=>["MAP","DOCUMENT","TOPIC","PERSONAL_BOOK","SHARED_BOOK"].includes(e),C=e=>s(e)&&o(e.weight)&&u(e.value)&&u(e.key),S=e=>s(e)&&Array.isArray(e.entries)&&e.entries.every((e=>U(e)))&&(null==e.metadataVariableAxis||u(e.metadataVariableAxis)),U=e=>s(e)&&(null==e.document||P(e.document))&&(null==e.topic||D(e.topic))&&I(e.type)&&(null==e.map||O(e.map)),P=e=>s(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>y(e)))&&b(e.openMode)&&u(e.documentUrl)&&u(e.mimeType)&&u(e.title)&&(null==e.lastPublicationDate||u(e.lastPublicationDate))&&u(e.viewerUrl)&&u(e.contentUrl)&&u(e.filename)&&u(e.htmlTitle)&&(null==e.originUrl||u(e.originUrl))&&u(e.documentId)&&u(e.lastEditionDate)&&u(e.htmlExcerpt),O=e=>s(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>y(e)))&&(null==e.openMode||b(e.openMode))&&T(e.editorialType)&&u(e.title)&&(null==e.lastPublicationDate||u(e.lastPublicationDate))&&u(e.htmlTitle)&&(null==e.originUrl||u(e.originUrl))&&u(e.mapUrl)&&u(e.readerUrl)&&u(e.mapId)&&(null==e.lastEditionDate||u(e.lastEditionDate))&&u(e.htmlExcerpt),D=e=>s(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>y(e)))&&b(e.openMode)&&u(e.contentId)&&Array.isArray(e.resources)&&e.resources.every((e=>_(e)))&&u(e.title)&&u(e.mapTitle)&&u(e.topicUrl)&&u(e.contentUrl)&&u(e.htmlTitle)&&Array.isArray(e.breadcrumb)&&e.breadcrumb.every((e=>u(e)))&&u(e.tocId)&&(null==e.originUrl||u(e.originUrl))&&u(e.readerUrl)&&u(e.mapId)&&(null==e.lastEditionDate||u(e.lastEditionDate))&&u(e.htmlExcerpt);var w;e.FtSearchResultType=void 0,(w=e.FtSearchResultType||(e.FtSearchResultType={})).MAP="MAP",w.DOCUMENT="DOCUMENT",w.TOPIC="TOPIC";const I=e=>["MAP","DOCUMENT","TOPIC"].includes(e),M=e=>s(e)&&l(e.hierarchical)&&u(e.label)&&l(e.multiSelectionable)&&u(e.key)&&Array.isArray(e.rootNodes)&&e.rootNodes.every((e=>x(e))),k=e=>s(e)&&(null==e.maxDepth||o(e.maxDepth))&&u(e.id),x=e=>s(e)&&o(e.totalResultsCount)&&l(e.descendantSelected)&&Array.isArray(e.childNodes)&&e.childNodes.every((e=>x(e)))&&u(e.label)&&u(e.value)&&l(e.selected),N=e=>s(e)&&u(e.key),L=e=>s(e)&&u(e.suggestedQuery)&&u(e.htmlSuggestedQuery),_=e=>s(e)&&u(e.filename)&&u(e.resourceUrl)&&u(e.id)&&u(e.mimeType)&&u(e.resourceContentUrl)&&u(e.viewerUrl),$=e=>s(e)&&(null==e.filenameExtension||u(e.filenameExtension))&&(null==e.editorialType||T(e.editorialType))&&(null==e.mimeType||u(e.mimeType))&&I(e.type)&&u(e.value),H=e=>"object"==typeof e&&null!=e,B=e=>"boolean"==typeof e,q=e=>"number"==typeof e,G=e=>"string"==typeof e,K=e=>H(e)&&(null==e.emailAddress||G(e.emailAddress))&&(null==e.displayName||G(e.displayName))&&Array.isArray(e.roles)&&G(e.userId),j="undefined"==typeof window?globalThis:window;function V(e){let t={};for(let r in e){let a=e[r];("object"!=typeof a||Array.isArray(a))&&(a={prior:a});for(let e of["prior","filter"])a[e]=Array.isArray(a[e])?a[e]:[a[e]],a[e]=a[e].map((e=>null!=e?""+e:"")).filter((e=>""!==e));t[r]=a}return t}function z(e){return`${e}-FluidTopicsUnauthenticatedUserSearchPreferences`}const J="undefined"==typeof window?globalThis:window;class X extends Error{status;statusText;body;constructor(e,t,r){super(`${e} - ${t}: ${r}`),this.status=e,this.statusText=t,this.body=r}}async function Y(e){if(!e.ok)throw new X(e.status,e.statusText,await e.text());return e}function Q(e){return"application/json"===e.headers.get("Content-Type")?e.json():e.text()}class W{tenantBaseUrl;ftCallingApp;authorization={};get defaultHeaders(){return{...this.authorization,"Ft-Calling-App":this.ftCallingApp}}constructor(e,t,r){e=e??J.__gwt_ft_moduleBase??J.fluidtopicsclient?.__moduleBase??J.__gwt_activeModules?.fluidtopicsclient?.moduleBase,this.tenantBaseUrl=e.trim().replace(/\/$/,""),r&&void 0!==J.location&&J.location.href.startsWith(this.tenantBaseUrl+"/")?this.ftCallingApp=t:this.ftCallingApp=`ft-public-api/${t}`}setApiKey(e){this.authorization={Authorization:"Bearer "+e}}setCredentials(e,t){var r;this.authorization={Authorization:"Basic "+(r=`${e}:${t}`,"undefined"!=typeof Buffer?Buffer.from(r).toString("base64"):btoa(r))}}clearAuthentication(){this.authorization={}}login(e,t){let r={login:e,password:t,rememberMe:!0};return this.post("/api/authentication/login",r).then((r=>(this.setCredentials(e,t),r)))}logout(){return this.post("/api/authentication/logout").then((()=>this.clearAuthentication()))}getCurrentSession(){return this.get("/api/authentication/current-session")}getMap(e){return this.get(`/api/khub/maps/${e}`)}getTableOfContent(e){return this.get(`/api/khub/maps/${e}/toc`)}getTopic(e,t){return this.get(`/api/khub/maps/${e}/topics/${t}`)}getTopicHTMLContent(e,t,r){return this.get(`/api/khub/maps/${e}/topics/${t}/content${r?"?target="+r:""}`)}getMapAttachments(e){return this.get(`/api/khub/maps/${e}/attachments`)}getMapAttachmentContent(e,t){return this.fetchRawData(`/api/khub/maps/${e}/attachments/${t}/content`)}getMapResources(e){return this.get(`/api/khub/maps/${e}/resources`)}getMapResourceContent(e,t){return this.fetchRawData(`/api/khub/maps/${e}/resources/${t}/content`)}getUnstructuredDocument(e){return this.get(`/api/khub/documents/${e}`)}getUnstructuredDocumentContent(e){return this.fetchRawData(`/api/khub/documents/${e}/content`)}getUnstructuredDocumentTextContent(e){return this.get(`/api/khub/documents/${e}/content/text`)}getCollectionDocuments(e,t){return this.get(`/api/users/${e}/collections/${t}/documents`)}getSuggestions(e){return this.post("/api/khub/suggest",e)}search(e){return this.post("/api/khub/clustered-search",e)}getAvailableSearchLocales(){return this.get("/api/khub/locales")}get(e){return this.makeRequest("GET",e)}post(e,t){return this.makeRequest("POST",e,t)}put(e,t){return this.makeRequest("PUT",e,t)}delete(e){return this.makeRequest("DELETE",e)}async fetch(e,t){const r=t;return e.startsWith("/")||(e="/"+e),await fetch(this.tenantBaseUrl+e,{...r??{},headers:{...this.defaultHeaders,...r?.headers??{}}})}async upload(e,t,r,a=(()=>{})){return new Promise(((i,n)=>{let s=new XMLHttpRequest;s.onload=()=>{if(s.status>=200&&s.status<300){let e="application/json"===s.getResponseHeader("Content-Type")?JSON.parse(s.responseText):s.responseText;i(e)}else n(new X(s.status,s.statusText,s.responseText))},s.upload.onprogress=e=>a(e),s.open(e,this.tenantBaseUrl+t,!0),s.send(r)}))}makeRequest(e,t,r){return this.fetch(t,{method:e,headers:{...null!=r?{"Content-Type":"application/json"}:{}},body:null!=r?JSON.stringify(r):void 0}).then(Y).then(Q)}fetchRawData(e){return fetch(this.tenantBaseUrl+e,{headers:this.defaultHeaders}).then(Y).then((e=>e.arrayBuffer()))}}e.FluidTopicsApi=W,e.HttpError=X,e.addUnauthenticatedUserSearchPreferencesChangeHandler=function(e,t){if(j.localStorage){const r=z(e),a=e=>{e.storageArea===j.localStorage&&e.key===r&&t(JSON.parse(e.newValue??"{}"))};return j.addEventListener("storage",a),{removeHandler:()=>j.removeEventListener("storage",a)}}console.error("Cannot handle unauthenticated preferences: local storage is unavailable.")},e.default=W,e.getUnauthenticatedUserSearchPreferences=function(e){if(j.localStorage)return JSON.parse(j.localStorage.getItem(z(e))??"{}");console.error("Cannot get unauthenticated preferences: local storage is unavailable.")},e.isFtAuthenticatedSession=e=>H(e)&&K(e.profile),e.isFtAuthenticationIdentifier=e=>s(e)&&u(e.identifier)&&u(e.realm),e.isFtCollectionDocument=e=>s(e)&&l(e.deleted)&&(null==e.apiUrl||u(e.apiUrl))&&(null==e.portalUrl||u(e.portalUrl))&&u(e.id)&&u(e.title)&&v(e.type),e.isFtCollectionDocumentType=v,e.isFtCredentials=e=>s(e)&&u(e.password)&&(null==e.newPassword||u(e.newPassword))&&l(e.rememberMe)&&u(e.login),e.isFtEditorialType=T,e.isFtMap=e=>s(e)&&(null==e.prettyUrl||u(e.prettyUrl))&&Array.isArray(e.metadata)&&e.metadata.every((e=>y(e)))&&b(e.openMode)&&u(e.topicsApiEndpoint)&&(null==e.description||u(e.description))&&u(e.attachmentsApiEndpoint)&&T(e.editorialType)&&u(e.baseId)&&u(e.clusterId)&&(null==e.shouldSplitCurrentPageToc||l(e.shouldSplitCurrentPageToc))&&u(e.title)&&u(e.lastPublication)&&u(e.lastEdition)&&u(e.originId)&&u(e.rightsApiEndpoint)&&(null==e.originUrl||u(e.originUrl))&&u(e.readerUrl)&&(null==e.khubVersion||u(e.khubVersion))&&u(e.id)&&(null==e.lang||u(e.lang)),e.isFtMapAttachment=e=>H(e)&&G(e.file)&&(null==e.size||q(e.size))&&B(e.externalLink)&&G(e.name)&&G(e.id)&&(null==e.mimeType||G(e.mimeType))&&(null==e.viewerUrl||G(e.viewerUrl)),e.isFtMapResource=e=>s(e)&&u(e.contentUrl)&&u(e.filename)&&u(e.id)&&u(e.mimeType),e.isFtMetadata=y,e.isFtMetadataPreferenceConfiguration=f,e.isFtOpenMode=b,e.isFtPageRequest=F,e.isFtSearchFacet=M,e.isFtSearchFacetConf=k,e.isFtSearchFacetEntry=x,e.isFtSearchFilter=g,e.isFtSearchLocale=h,e.isFtSearchLocales=e=>s(e)&&Array.isArray(e.contentLocales)&&e.contentLocales.every((e=>h(e))),e.isFtSearchPreferencesConfiguration=e=>s(e)&&s(e.metadata)&&Object.keys(e.metadata).every((e=>u(e)))&&Object.values(e.metadata).every((e=>f(e))),e.isFtSearchPreset=e=>s(e)&&u(e.name)&&Array.isArray(e.filters)&&e.filters.every((e=>g(e)))&&(null==e.contentLocale||u(e.contentLocale)),e.isFtSearchPrior=C,e.isFtSearchRequest=e=>s(e)&&u(e.query)&&F(e.paging)&&Array.isArray(e.filters)&&e.filters.every((e=>g(e)))&&Array.isArray(e.sort)&&e.sort.every((e=>N(e)))&&(null==e.uiLocale||u(e.uiLocale))&&(null==e.contentLocale||u(e.contentLocale))&&(null==e.priors||Array.isArray(e.priors)&&e.priors.every((e=>C(e))))&&Array.isArray(e.facets)&&e.facets.every((e=>k(e))),e.isFtSearchResultCluster=S,e.isFtSearchResultClusterEntry=U,e.isFtSearchResultMap=O,e.isFtSearchResultTopic=D,e.isFtSearchResultType=I,e.isFtSearchResultUnstructuredDocument=P,e.isFtSearchResults=e=>s(e)&&(null==e.spellcheck||L(e.spellcheck))&&m(e.paging)&&Array.isArray(e.results)&&e.results.every((e=>S(e)))&&Array.isArray(e.facets)&&e.facets.every((e=>M(e))),e.isFtSearchResultsPageInfo=m,e.isFtSearchSortCriterion=N,e.isFtSession=e=>H(e)&&q(e.idleTimeoutInMillis)&&(null==e.profile||K(e.profile))&&B(e.sessionAuthenticated),e.isFtSpellcheck=L,e.isFtSuggestRequest=e=>s(e)&&u(e.input)&&Array.isArray(e.filters)&&e.filters.every((e=>g(e)))&&Array.isArray(e.sort)&&e.sort.every((e=>N(e)))&&(null==e.maxCount||o(e.maxCount))&&(null==e.contentLocale||u(e.contentLocale)),e.isFtSuggestResult=$,e.isFtSuggestResults=e=>s(e)&&Array.isArray(e.suggestions)&&e.suggestions.every((e=>$(e))),e.isFtTocNode=c,e.isFtTocPage=p,e.isFtTopic=e=>s(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>y(e)))&&u(e.id)&&u(e.contentApiEndpoint)&&u(e.title),e.isFtTopicContentTarget=e=>["THIRD_PARTY","OFF_THE_GRID","CONTENT_PACKAGER","PAGES","DESIGNED_READER"].includes(e),e.isFtTopicResource=_,e.isFtUnstructuredDocument=e=>s(e)&&(null==e.prettyUrl||u(e.prettyUrl))&&Array.isArray(e.metadata)&&e.metadata.every((e=>y(e)))&&u(e.openMode)&&(null==e.description||u(e.description))&&u(e.mimeType)&&(null==e.baseId||u(e.baseId))&&(null==e.clusterId||u(e.clusterId))&&u(e.contentApiEndpoint)&&u(e.title)&&(null==e.lastPublication||u(e.lastPublication))&&u(e.viewerUrl)&&u(e.lastEdition)&&u(e.filename)&&(null==e.originId||u(e.originId))&&u(e.rightsApiEndpoint)&&(null==e.originUrl||u(e.originUrl))&&(null==e.khubVersion||u(e.khubVersion))&&u(e.id)&&(null==e.lang||u(e.lang)),e.isFtUserProfile=K,e.setUnauthenticatedUserSearchPreferences=function(e,t){if(j.localStorage){let r={...t,metadata:V(t.metadata??{})};const a=z(e),i=JSON.stringify(r);return j.localStorage.setItem(a,i),j.dispatchEvent(new StorageEvent("storage",{key:a,newValue:i,storageArea:j.localStorage,url:j.location.href})),r}console.error("Cannot set unauthenticated preferences: local storage is unavailable.")}}));
|
|
@@ -85,7 +85,8 @@ export declare enum FtTopicContentTarget {
|
|
|
85
85
|
THIRD_PARTY = "THIRD_PARTY",
|
|
86
86
|
OFF_THE_GRID = "OFF_THE_GRID",
|
|
87
87
|
CONTENT_PACKAGER = "CONTENT_PACKAGER",
|
|
88
|
-
PAGES = "PAGES"
|
|
88
|
+
PAGES = "PAGES",
|
|
89
|
+
DESIGNED_READER = "DESIGNED_READER"
|
|
89
90
|
}
|
|
90
91
|
export declare const isFtTopicContentTarget: (o: any) => o is FtTopicContentTarget;
|
|
91
92
|
export interface FtSearchLocale {
|
|
@@ -97,9 +97,10 @@ export var FtTopicContentTarget;
|
|
|
97
97
|
FtTopicContentTarget["OFF_THE_GRID"] = "OFF_THE_GRID";
|
|
98
98
|
FtTopicContentTarget["CONTENT_PACKAGER"] = "CONTENT_PACKAGER";
|
|
99
99
|
FtTopicContentTarget["PAGES"] = "PAGES";
|
|
100
|
+
FtTopicContentTarget["DESIGNED_READER"] = "DESIGNED_READER";
|
|
100
101
|
})(FtTopicContentTarget || (FtTopicContentTarget = {}));
|
|
101
102
|
export const isFtTopicContentTarget = (o) => {
|
|
102
|
-
return ["THIRD_PARTY", "OFF_THE_GRID", "CONTENT_PACKAGER", "PAGES"].includes(o);
|
|
103
|
+
return ["THIRD_PARTY", "OFF_THE_GRID", "CONTENT_PACKAGER", "PAGES", "DESIGNED_READER"].includes(o);
|
|
103
104
|
};
|
|
104
105
|
export const isFtSearchLocale = (o) => {
|
|
105
106
|
return isObject(o)
|