@fluid-topics/public-api 1.0.14 → 1.0.15
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 +7 -2
- package/dist/cjs/types/ft-common/public.js +9 -1
- package/dist/fluidtopics.min.js +1 -1
- package/dist/mjs/index.d.ts +1 -1
- package/dist/mjs/index.js +7 -2
- package/dist/mjs/types/ft-common/public.d.ts +6 -0
- package/dist/mjs/types/ft-common/public.js +7 -0
- package/package.json +1 -1
- package/dist/cjs/index.cjs +0 -166
- package/dist/cjs/types/ft-common/public.cjs +0 -374
- package/dist/cjs/types/ft-server/public.cjs +0 -31
- package/dist/mjs/index.mjs +0 -153
- package/dist/mjs/types/ft-common/public.mjs +0 -336
- package/dist/mjs/types/ft-server/public.mjs +0 -25
package/dist/cjs/index.js
CHANGED
|
@@ -47,10 +47,15 @@ function getBody(response) {
|
|
|
47
47
|
return response.headers.get("Content-Type") === "application/json" ? response.json() : response.text();
|
|
48
48
|
}
|
|
49
49
|
class FluidTopicsApi {
|
|
50
|
-
constructor(tenantBaseUrl, integrationIdentifier) {
|
|
50
|
+
constructor(tenantBaseUrl, integrationIdentifier, overrideIdentifierIfOnTenant) {
|
|
51
51
|
this.authorization = {};
|
|
52
52
|
this.tenantBaseUrl = tenantBaseUrl.trim().replace(/\/$/, "");
|
|
53
|
-
|
|
53
|
+
if (overrideIdentifierIfOnTenant && typeof window !== "undefined" && window.location.href.startsWith(tenantBaseUrl)) {
|
|
54
|
+
this.ftCallingApp = integrationIdentifier;
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
this.ftCallingApp = `ft-public-api/${integrationIdentifier}`;
|
|
58
|
+
}
|
|
54
59
|
}
|
|
55
60
|
get defaultHeaders() {
|
|
56
61
|
return Object.assign(Object.assign({}, this.authorization), { "Ft-Calling-App": this.ftCallingApp });
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isFtAuthenticationIdentifier = exports.isFtSuggestResults = exports.isFtSuggestResult = exports.isFtSuggestRequest = 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.isFtSearchResults = exports.isFtCollectionDocumentType = exports.FtCollectionDocumentType = exports.isFtPageRequest = exports.isFtOpenMode = exports.FtOpenMode = exports.isFtEditorialType = exports.FtEditorialType = exports.isFtSearchResultsPageInfo = exports.isFtSearchFilter = exports.isFtMapResource = exports.isFtMetadata = exports.isFtSearchLocales = exports.isFtSearchLocale = exports.isFtTopicContentTarget = exports.FtTopicContentTarget = exports.isFtUnstructuredDocument = exports.isFtTopic = exports.isFtTocNode = exports.isFtMap = exports.isFtCollectionDocument = exports.isFtCredentials = void 0;
|
|
3
|
+
exports.isFtAuthenticationIdentifier = exports.isFtSuggestResults = exports.isFtSuggestResult = exports.isFtSuggestRequest = 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.isFtSearchResults = exports.isFtCollectionDocumentType = exports.FtCollectionDocumentType = exports.isFtPageRequest = exports.isFtOpenMode = exports.FtOpenMode = exports.isFtEditorialType = exports.FtEditorialType = exports.isFtSearchResultsPageInfo = exports.isFtSearchPreset = exports.isFtSearchFilter = exports.isFtMapResource = exports.isFtMetadata = exports.isFtSearchLocales = exports.isFtSearchLocale = exports.isFtTopicContentTarget = exports.FtTopicContentTarget = exports.isFtUnstructuredDocument = exports.isFtTopic = exports.isFtTocNode = exports.isFtMap = exports.isFtCollectionDocument = exports.isFtCredentials = 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";
|
|
@@ -136,6 +136,14 @@ const isFtSearchFilter = (o) => {
|
|
|
136
136
|
&& (isString(o.key));
|
|
137
137
|
};
|
|
138
138
|
exports.isFtSearchFilter = isFtSearchFilter;
|
|
139
|
+
const isFtSearchPreset = (o) => {
|
|
140
|
+
return isObject(o)
|
|
141
|
+
&& (isString(o.name))
|
|
142
|
+
&& ((Array.isArray(o.filters)
|
|
143
|
+
&& o.filters.every((v) => (0, exports.isFtSearchFilter)(v))))
|
|
144
|
+
&& (o.contentLocale == null || isString(o.contentLocale));
|
|
145
|
+
};
|
|
146
|
+
exports.isFtSearchPreset = isFtSearchPreset;
|
|
139
147
|
const isFtSearchResultsPageInfo = (o) => {
|
|
140
148
|
return isObject(o)
|
|
141
149
|
&& (isNumber(o.totalResultsCount))
|
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:{}},i={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}(i,i.exports),function(e,t){const r=i.exports,a=r.default||r,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=r.Headers,t.Request=r.Request,t.Response=r.Response,t.default=n}(r,r.exports);const a=r.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 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.tocId)&&Array.isArray(e.children)&&e.children.every((e=>c(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";const d=e=>s(e)&&o(e.count)&&u(e.label)&&(null==e.lang||u(e.lang)),h=e=>s(e)&&Array.isArray(e.values)&&e.values.every((e=>u(e)))&&u(e.label)&&u(e.key),y=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 f;e.FtEditorialType=void 0,(f=e.FtEditorialType||(e.FtEditorialType={})).ARTICLE="ARTICLE",f.BOOK="BOOK";const g=e=>["ARTICLE","BOOK"].includes(e);var A;e.FtOpenMode=void 0,(A=e.FtOpenMode||(e.FtOpenMode={})).FLUIDTOPICS="FLUIDTOPICS",A.EXTERNAL="EXTERNAL";const T=e=>["FLUIDTOPICS","EXTERNAL"].includes(e),F=e=>s(e)&&(null==e.perPage||o(e.perPage))&&o(e.page);var b;e.FtCollectionDocumentType=void 0,(b=e.FtCollectionDocumentType||(e.FtCollectionDocumentType={})).MAP="MAP",b.DOCUMENT="DOCUMENT",b.TOPIC="TOPIC",b.PERSONAL_BOOK="PERSONAL_BOOK",b.SHARED_BOOK="SHARED_BOOK";const R=e=>["MAP","DOCUMENT","TOPIC","PERSONAL_BOOK","SHARED_BOOK"].includes(e),E=e=>s(e)&&Array.isArray(e.entries)&&e.entries.every((e=>C(e)))&&(null==e.metadataVariableAxis||u(e.metadataVariableAxis)),C=e=>s(e)&&(null==e.document||U(e.document))&&(null==e.topic||O(e.topic))&&S(e.type)&&(null==e.map||v(e.map)),U=e=>s(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>h(e)))&&T(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),v=e=>s(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>h(e)))&&T(e.openMode)&&g(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),O=e=>s(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>h(e)))&&T(e.openMode)&&u(e.contentId)&&Array.isArray(e.resources)&&e.resources.every((e=>w(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 S=e=>["MAP","DOCUMENT","TOPIC"].includes(e),I=e=>s(e)&&l(e.hierarchical)&&u(e.label)&&l(e.multiSelectionable)&&u(e.key)&&Array.isArray(e.rootNodes)&&e.rootNodes.every((e=>M(e))),P=e=>s(e)&&(null==e.maxDepth||o(e.maxDepth))&&u(e.id),M=e=>s(e)&&o(e.totalResultsCount)&&l(e.descendantSelected)&&Array.isArray(e.childNodes)&&e.childNodes.every((e=>M(e)))&&u(e.label)&&u(e.value)&&l(e.selected),k=e=>s(e)&&u(e.key),x=e=>s(e)&&u(e.suggestedQuery)&&u(e.htmlSuggestedQuery),w=e=>s(e)&&u(e.filename)&&u(e.resourceUrl)&&u(e.id)&&u(e.mimeType)&&u(e.resourceContentUrl)&&u(e.viewerUrl),L=e=>s(e)&&(null==e.filenameExtension||u(e.filenameExtension))&&(null==e.editorialType||g(e.editorialType))&&(null==e.mimeType||u(e.mimeType))&&S(e.type)&&u(e.value),$=e=>"object"==typeof e&&null!=e,H=e=>"string"==typeof e,N=e=>$(e)&&(null==e.emailAddress||H(e.emailAddress))&&(null==e.displayName||H(e.displayName))&&Array.isArray(e.roles)&&H(e.userId);class B extends Error{status;statusText;body;constructor(e,t,r){super(`${e} - ${t}: ${r}`),this.status=e,this.statusText=t,this.body=r}}async function q(e){if(!e.ok)throw new B(e.status,e.statusText,await e.text());return e}function _(e){return"application/json"===e.headers.get("Content-Type")?e.json():e.text()}class K{tenantBaseUrl;ftCallingApp;authorization={};get defaultHeaders(){return{...this.authorization,"Ft-Calling-App":this.ftCallingApp}}constructor(e,t){this.tenantBaseUrl=e.trim().replace(/\/$/,""),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()))}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??{}}})}makeRequest(e,t,r){return this.fetch(t,{method:e,headers:{...null!=r?{"Content-Type":"application/json"}:{}},body:null!=r?JSON.stringify(r):void 0}).then(q).then(_)}fetchRawData(e){return fetch(this.tenantBaseUrl+e,{headers:this.defaultHeaders}).then(q).then((e=>e.arrayBuffer()))}}e.FluidTopicsApi=K,e.HttpError=B,e.default=K,e.isFtAuthenticatedSession=e=>$(e)&&N(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=g,e.isFtMap=e=>s(e)&&(null==e.prettyUrl||u(e.prettyUrl))&&Array.isArray(e.metadata)&&e.metadata.every((e=>h(e)))&&T(e.openMode)&&u(e.topicsApiEndpoint)&&(null==e.description||u(e.description))&&u(e.attachmentsApiEndpoint)&&g(e.editorialType)&&u(e.baseId)&&u(e.clusterId)&&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=>$(e)&&H(e.file)&&(null==e.size||(e=>"number"==typeof e)(e.size))&&(e=>"boolean"==typeof e)(e.externalLink)&&H(e.name)&&H(e.id)&&(null==e.mimeType||H(e.mimeType))&&(null==e.viewerUrl||H(e.viewerUrl)),e.isFtMapResource=e=>s(e)&&u(e.contentUrl)&&u(e.filename)&&u(e.id)&&u(e.mimeType),e.isFtMetadata=h,e.isFtOpenMode=T,e.isFtPageRequest=F,e.isFtSearchFacet=I,e.isFtSearchFacetConf=P,e.isFtSearchFacetEntry=M,e.isFtSearchFilter=y,e.isFtSearchLocale=d,e.isFtSearchLocales=e=>s(e)&&Array.isArray(e.contentLocales)&&e.contentLocales.every((e=>d(e))),e.isFtSearchRequest=e=>s(e)&&u(e.query)&&F(e.paging)&&Array.isArray(e.filters)&&e.filters.every((e=>y(e)))&&Array.isArray(e.sort)&&e.sort.every((e=>k(e)))&&(null==e.uiLocale||u(e.uiLocale))&&(null==e.contentLocale||u(e.contentLocale))&&Array.isArray(e.facets)&&e.facets.every((e=>P(e))),e.isFtSearchResultCluster=E,e.isFtSearchResultClusterEntry=C,e.isFtSearchResultMap=v,e.isFtSearchResultTopic=O,e.isFtSearchResultType=S,e.isFtSearchResultUnstructuredDocument=U,e.isFtSearchResults=e=>s(e)&&(null==e.spellcheck||x(e.spellcheck))&&m(e.paging)&&Array.isArray(e.results)&&e.results.every((e=>E(e)))&&Array.isArray(e.facets)&&e.facets.every((e=>I(e))),e.isFtSearchResultsPageInfo=m,e.isFtSearchSortCriterion=k,e.isFtSpellcheck=x,e.isFtSuggestRequest=e=>s(e)&&u(e.input)&&Array.isArray(e.filters)&&e.filters.every((e=>y(e)))&&Array.isArray(e.sort)&&e.sort.every((e=>k(e)))&&(null==e.maxCount||o(e.maxCount))&&(null==e.contentLocale||u(e.contentLocale)),e.isFtSuggestResult=L,e.isFtSuggestResults=e=>s(e)&&Array.isArray(e.suggestions)&&e.suggestions.every((e=>L(e))),e.isFtTocNode=c,e.isFtTopic=e=>s(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>h(e)))&&u(e.id)&&u(e.contentApiEndpoint)&&u(e.title),e.isFtTopicContentTarget=e=>["THIRD_PARTY","OFF_THE_GRID"].includes(e),e.isFtTopicResource=w,e.isFtUnstructuredDocument=e=>s(e)&&(null==e.prettyUrl||u(e.prettyUrl))&&Array.isArray(e.metadata)&&e.metadata.every((e=>h(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=N}));
|
|
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:{}},i={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}(i,i.exports),function(e,t){const r=i.exports,a=r.default||r,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=r.Headers,t.Request=r.Request,t.Response=r.Response,t.default=n}(r,r.exports);const a=r.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 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.tocId)&&Array.isArray(e.children)&&e.children.every((e=>c(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";const d=e=>s(e)&&o(e.count)&&u(e.label)&&(null==e.lang||u(e.lang)),h=e=>s(e)&&Array.isArray(e.values)&&e.values.every((e=>u(e)))&&u(e.label)&&u(e.key),y=e=>s(e)&&l(e.negative)&&Array.isArray(e.values)&&e.values.every((e=>u(e)))&&u(e.key),f=e=>s(e)&&o(e.totalResultsCount)&&l(e.lastPage)&&o(e.currentPage)&&o(e.totalClustersCount);var m;e.FtEditorialType=void 0,(m=e.FtEditorialType||(e.FtEditorialType={})).ARTICLE="ARTICLE",m.BOOK="BOOK";const g=e=>["ARTICLE","BOOK"].includes(e);var A;e.FtOpenMode=void 0,(A=e.FtOpenMode||(e.FtOpenMode={})).FLUIDTOPICS="FLUIDTOPICS",A.EXTERNAL="EXTERNAL";const T=e=>["FLUIDTOPICS","EXTERNAL"].includes(e),F=e=>s(e)&&(null==e.perPage||o(e.perPage))&&o(e.page);var b;e.FtCollectionDocumentType=void 0,(b=e.FtCollectionDocumentType||(e.FtCollectionDocumentType={})).MAP="MAP",b.DOCUMENT="DOCUMENT",b.TOPIC="TOPIC",b.PERSONAL_BOOK="PERSONAL_BOOK",b.SHARED_BOOK="SHARED_BOOK";const R=e=>["MAP","DOCUMENT","TOPIC","PERSONAL_BOOK","SHARED_BOOK"].includes(e),C=e=>s(e)&&Array.isArray(e.entries)&&e.entries.every((e=>E(e)))&&(null==e.metadataVariableAxis||u(e.metadataVariableAxis)),E=e=>s(e)&&(null==e.document||U(e.document))&&(null==e.topic||O(e.topic))&&S(e.type)&&(null==e.map||v(e.map)),U=e=>s(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>h(e)))&&T(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),v=e=>s(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>h(e)))&&T(e.openMode)&&g(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),O=e=>s(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>h(e)))&&T(e.openMode)&&u(e.contentId)&&Array.isArray(e.resources)&&e.resources.every((e=>x(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 S=e=>["MAP","DOCUMENT","TOPIC"].includes(e),I=e=>s(e)&&l(e.hierarchical)&&u(e.label)&&l(e.multiSelectionable)&&u(e.key)&&Array.isArray(e.rootNodes)&&e.rootNodes.every((e=>M(e))),P=e=>s(e)&&(null==e.maxDepth||o(e.maxDepth))&&u(e.id),M=e=>s(e)&&o(e.totalResultsCount)&&l(e.descendantSelected)&&Array.isArray(e.childNodes)&&e.childNodes.every((e=>M(e)))&&u(e.label)&&u(e.value)&&l(e.selected),w=e=>s(e)&&u(e.key),k=e=>s(e)&&u(e.suggestedQuery)&&u(e.htmlSuggestedQuery),x=e=>s(e)&&u(e.filename)&&u(e.resourceUrl)&&u(e.id)&&u(e.mimeType)&&u(e.resourceContentUrl)&&u(e.viewerUrl),L=e=>s(e)&&(null==e.filenameExtension||u(e.filenameExtension))&&(null==e.editorialType||g(e.editorialType))&&(null==e.mimeType||u(e.mimeType))&&S(e.type)&&u(e.value),$=e=>"object"==typeof e&&null!=e,H=e=>"string"==typeof e,N=e=>$(e)&&(null==e.emailAddress||H(e.emailAddress))&&(null==e.displayName||H(e.displayName))&&Array.isArray(e.roles)&&H(e.userId);class B extends Error{status;statusText;body;constructor(e,t,r){super(`${e} - ${t}: ${r}`),this.status=e,this.statusText=t,this.body=r}}async function q(e){if(!e.ok)throw new B(e.status,e.statusText,await e.text());return e}function _(e){return"application/json"===e.headers.get("Content-Type")?e.json():e.text()}class K{tenantBaseUrl;ftCallingApp;authorization={};get defaultHeaders(){return{...this.authorization,"Ft-Calling-App":this.ftCallingApp}}constructor(e,t,r){this.tenantBaseUrl=e.trim().replace(/\/$/,""),r&&"undefined"!=typeof window&&window.location.href.startsWith(e)?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()))}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??{}}})}makeRequest(e,t,r){return this.fetch(t,{method:e,headers:{...null!=r?{"Content-Type":"application/json"}:{}},body:null!=r?JSON.stringify(r):void 0}).then(q).then(_)}fetchRawData(e){return fetch(this.tenantBaseUrl+e,{headers:this.defaultHeaders}).then(q).then((e=>e.arrayBuffer()))}}e.FluidTopicsApi=K,e.HttpError=B,e.default=K,e.isFtAuthenticatedSession=e=>$(e)&&N(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=g,e.isFtMap=e=>s(e)&&(null==e.prettyUrl||u(e.prettyUrl))&&Array.isArray(e.metadata)&&e.metadata.every((e=>h(e)))&&T(e.openMode)&&u(e.topicsApiEndpoint)&&(null==e.description||u(e.description))&&u(e.attachmentsApiEndpoint)&&g(e.editorialType)&&u(e.baseId)&&u(e.clusterId)&&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=>$(e)&&H(e.file)&&(null==e.size||(e=>"number"==typeof e)(e.size))&&(e=>"boolean"==typeof e)(e.externalLink)&&H(e.name)&&H(e.id)&&(null==e.mimeType||H(e.mimeType))&&(null==e.viewerUrl||H(e.viewerUrl)),e.isFtMapResource=e=>s(e)&&u(e.contentUrl)&&u(e.filename)&&u(e.id)&&u(e.mimeType),e.isFtMetadata=h,e.isFtOpenMode=T,e.isFtPageRequest=F,e.isFtSearchFacet=I,e.isFtSearchFacetConf=P,e.isFtSearchFacetEntry=M,e.isFtSearchFilter=y,e.isFtSearchLocale=d,e.isFtSearchLocales=e=>s(e)&&Array.isArray(e.contentLocales)&&e.contentLocales.every((e=>d(e))),e.isFtSearchPreset=e=>s(e)&&u(e.name)&&Array.isArray(e.filters)&&e.filters.every((e=>y(e)))&&(null==e.contentLocale||u(e.contentLocale)),e.isFtSearchRequest=e=>s(e)&&u(e.query)&&F(e.paging)&&Array.isArray(e.filters)&&e.filters.every((e=>y(e)))&&Array.isArray(e.sort)&&e.sort.every((e=>w(e)))&&(null==e.uiLocale||u(e.uiLocale))&&(null==e.contentLocale||u(e.contentLocale))&&Array.isArray(e.facets)&&e.facets.every((e=>P(e))),e.isFtSearchResultCluster=C,e.isFtSearchResultClusterEntry=E,e.isFtSearchResultMap=v,e.isFtSearchResultTopic=O,e.isFtSearchResultType=S,e.isFtSearchResultUnstructuredDocument=U,e.isFtSearchResults=e=>s(e)&&(null==e.spellcheck||k(e.spellcheck))&&f(e.paging)&&Array.isArray(e.results)&&e.results.every((e=>C(e)))&&Array.isArray(e.facets)&&e.facets.every((e=>I(e))),e.isFtSearchResultsPageInfo=f,e.isFtSearchSortCriterion=w,e.isFtSpellcheck=k,e.isFtSuggestRequest=e=>s(e)&&u(e.input)&&Array.isArray(e.filters)&&e.filters.every((e=>y(e)))&&Array.isArray(e.sort)&&e.sort.every((e=>w(e)))&&(null==e.maxCount||o(e.maxCount))&&(null==e.contentLocale||u(e.contentLocale)),e.isFtSuggestResult=L,e.isFtSuggestResults=e=>s(e)&&Array.isArray(e.suggestions)&&e.suggestions.every((e=>L(e))),e.isFtTocNode=c,e.isFtTopic=e=>s(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>h(e)))&&u(e.id)&&u(e.contentApiEndpoint)&&u(e.title),e.isFtTopicContentTarget=e=>["THIRD_PARTY","OFF_THE_GRID"].includes(e),e.isFtTopicResource=x,e.isFtUnstructuredDocument=e=>s(e)&&(null==e.prettyUrl||u(e.prettyUrl))&&Array.isArray(e.metadata)&&e.metadata.every((e=>h(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=N}));
|
package/dist/mjs/index.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export declare class FluidTopicsApi {
|
|
|
14
14
|
private readonly ftCallingApp;
|
|
15
15
|
private authorization;
|
|
16
16
|
private get defaultHeaders();
|
|
17
|
-
constructor(tenantBaseUrl: string, integrationIdentifier: string);
|
|
17
|
+
constructor(tenantBaseUrl: string, integrationIdentifier: string, overrideIdentifierIfOnTenant?: boolean);
|
|
18
18
|
setApiKey(apiKey: string): void;
|
|
19
19
|
setCredentials(login: string, password: string): void;
|
|
20
20
|
clearAuthentication(): void;
|
package/dist/mjs/index.js
CHANGED
|
@@ -34,9 +34,14 @@ export class FluidTopicsApi {
|
|
|
34
34
|
"Ft-Calling-App": this.ftCallingApp
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
|
-
constructor(tenantBaseUrl, integrationIdentifier) {
|
|
37
|
+
constructor(tenantBaseUrl, integrationIdentifier, overrideIdentifierIfOnTenant) {
|
|
38
38
|
this.tenantBaseUrl = tenantBaseUrl.trim().replace(/\/$/, "");
|
|
39
|
-
|
|
39
|
+
if (overrideIdentifierIfOnTenant && typeof window !== "undefined" && window.location.href.startsWith(tenantBaseUrl)) {
|
|
40
|
+
this.ftCallingApp = integrationIdentifier;
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
this.ftCallingApp = `ft-public-api/${integrationIdentifier}`;
|
|
44
|
+
}
|
|
40
45
|
}
|
|
41
46
|
setApiKey(apiKey) {
|
|
42
47
|
this.authorization = { "Authorization": "Bearer " + apiKey };
|
|
@@ -106,6 +106,12 @@ export interface FtSearchFilter {
|
|
|
106
106
|
key: string;
|
|
107
107
|
}
|
|
108
108
|
export declare const isFtSearchFilter: (o: any) => o is FtSearchFilter;
|
|
109
|
+
export interface FtSearchPreset {
|
|
110
|
+
name: string;
|
|
111
|
+
filters: Array<FtSearchFilter>;
|
|
112
|
+
contentLocale?: string;
|
|
113
|
+
}
|
|
114
|
+
export declare const isFtSearchPreset: (o: any) => o is FtSearchPreset;
|
|
109
115
|
export interface FtSearchResultsPageInfo {
|
|
110
116
|
totalResultsCount: number;
|
|
111
117
|
lastPage: boolean;
|
|
@@ -121,6 +121,13 @@ export const isFtSearchFilter = (o) => {
|
|
|
121
121
|
&& o.values.every((v) => isString(v))))
|
|
122
122
|
&& (isString(o.key));
|
|
123
123
|
};
|
|
124
|
+
export const isFtSearchPreset = (o) => {
|
|
125
|
+
return isObject(o)
|
|
126
|
+
&& (isString(o.name))
|
|
127
|
+
&& ((Array.isArray(o.filters)
|
|
128
|
+
&& o.filters.every((v) => isFtSearchFilter(v))))
|
|
129
|
+
&& (o.contentLocale == null || isString(o.contentLocale));
|
|
130
|
+
};
|
|
124
131
|
export const isFtSearchResultsPageInfo = (o) => {
|
|
125
132
|
return isObject(o)
|
|
126
133
|
&& (isNumber(o.totalResultsCount))
|
package/package.json
CHANGED
package/dist/cjs/index.cjs
DELETED
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
-
};
|
|
12
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.FluidTopicsApi = exports.HttpError = void 0;
|
|
23
|
-
require("cross-fetch/polyfill");
|
|
24
|
-
__exportStar(require("./types/ft-common/public"), exports);
|
|
25
|
-
__exportStar(require("./types/ft-server/public"), exports);
|
|
26
|
-
function toBase64(s) {
|
|
27
|
-
return typeof Buffer !== "undefined" ? Buffer.from(s).toString("base64") : btoa(s);
|
|
28
|
-
}
|
|
29
|
-
class HttpError extends Error {
|
|
30
|
-
constructor(status, statusText, body) {
|
|
31
|
-
super(`${status} - ${statusText}: ${body}`);
|
|
32
|
-
this.status = status;
|
|
33
|
-
this.statusText = statusText;
|
|
34
|
-
this.body = body;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
exports.HttpError = HttpError;
|
|
38
|
-
function handleError(response) {
|
|
39
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
-
if (!response.ok) {
|
|
41
|
-
throw new HttpError(response.status, response.statusText, yield response.text());
|
|
42
|
-
}
|
|
43
|
-
return response;
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
function getBody(response) {
|
|
47
|
-
return response.headers.get("Content-Type") === "application/json" ? response.json() : response.text();
|
|
48
|
-
}
|
|
49
|
-
class FluidTopicsApi {
|
|
50
|
-
constructor(tenantBaseUrl, integrationIdentifier) {
|
|
51
|
-
this.authorization = {};
|
|
52
|
-
this.tenantBaseUrl = tenantBaseUrl.trim().replace(/\/$/, "");
|
|
53
|
-
this.ftCallingApp = `ft-public-api/${integrationIdentifier}`;
|
|
54
|
-
}
|
|
55
|
-
get defaultHeaders() {
|
|
56
|
-
return Object.assign(Object.assign({}, this.authorization), { "Ft-Calling-App": this.ftCallingApp });
|
|
57
|
-
}
|
|
58
|
-
setApiKey(apiKey) {
|
|
59
|
-
this.authorization = { "Authorization": "Bearer " + apiKey };
|
|
60
|
-
}
|
|
61
|
-
setCredentials(login, password) {
|
|
62
|
-
this.authorization = { "Authorization": "Basic " + toBase64(`${login}:${password}`) };
|
|
63
|
-
}
|
|
64
|
-
clearAuthentication() {
|
|
65
|
-
this.authorization = {};
|
|
66
|
-
}
|
|
67
|
-
login(login, password) {
|
|
68
|
-
let credentials = {
|
|
69
|
-
login: login,
|
|
70
|
-
password: password,
|
|
71
|
-
rememberMe: true
|
|
72
|
-
};
|
|
73
|
-
return this.post(`/api/authentication/login`, credentials)
|
|
74
|
-
.then(result => {
|
|
75
|
-
this.setCredentials(login, password);
|
|
76
|
-
return result;
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
logout() {
|
|
80
|
-
return this.post(`/api/authentication/logout`)
|
|
81
|
-
.then(() => this.clearAuthentication());
|
|
82
|
-
}
|
|
83
|
-
getMap(mapId) {
|
|
84
|
-
return this.get(`/api/khub/maps/${mapId}`);
|
|
85
|
-
}
|
|
86
|
-
getTableOfContent(mapId) {
|
|
87
|
-
return this.get(`/api/khub/maps/${mapId}/toc`);
|
|
88
|
-
}
|
|
89
|
-
getTopic(mapId, topicContentId) {
|
|
90
|
-
return this.get(`/api/khub/maps/${mapId}/topics/${topicContentId}`);
|
|
91
|
-
}
|
|
92
|
-
getTopicHTMLContent(mapId, topicContentId, target) {
|
|
93
|
-
return this.get(`/api/khub/maps/${mapId}/topics/${topicContentId}/content${target ? "?target=" + target : ""}`);
|
|
94
|
-
}
|
|
95
|
-
getMapAttachments(mapId) {
|
|
96
|
-
return this.get(`/api/khub/maps/${mapId}/attachments`);
|
|
97
|
-
}
|
|
98
|
-
getMapAttachmentContent(mapId, attachmentId) {
|
|
99
|
-
return this.fetchRawData(`/api/khub/maps/${mapId}/attachments/${attachmentId}/content`);
|
|
100
|
-
}
|
|
101
|
-
getMapResources(mapId) {
|
|
102
|
-
return this.get(`/api/khub/maps/${mapId}/resources`);
|
|
103
|
-
}
|
|
104
|
-
getMapResourceContent(mapId, resourceId) {
|
|
105
|
-
return this.fetchRawData(`/api/khub/maps/${mapId}/resources/${resourceId}/content`);
|
|
106
|
-
}
|
|
107
|
-
getUnstructuredDocument(documentId) {
|
|
108
|
-
return this.get(`/api/khub/documents/${documentId}`);
|
|
109
|
-
}
|
|
110
|
-
getUnstructuredDocumentContent(documentId) {
|
|
111
|
-
return this.fetchRawData(`/api/khub/documents/${documentId}/content`);
|
|
112
|
-
}
|
|
113
|
-
getUnstructuredDocumentTextContent(documentId) {
|
|
114
|
-
return this.get(`/api/khub/documents/${documentId}/content/text`);
|
|
115
|
-
}
|
|
116
|
-
getCollectionDocuments(userId, collectionId) {
|
|
117
|
-
return this.get(`/api/users/${userId}/collections/${collectionId}/documents`);
|
|
118
|
-
}
|
|
119
|
-
getSuggestions(request) {
|
|
120
|
-
return this.post("/api/khub/suggest", request);
|
|
121
|
-
}
|
|
122
|
-
search(request) {
|
|
123
|
-
return this.post("/api/khub/clustered-search", request);
|
|
124
|
-
}
|
|
125
|
-
getAvailableSearchLocales() {
|
|
126
|
-
return this.get("/api/khub/locales");
|
|
127
|
-
}
|
|
128
|
-
get(endpoint) {
|
|
129
|
-
return this.makeRequest("GET", endpoint);
|
|
130
|
-
}
|
|
131
|
-
post(endpoint, data) {
|
|
132
|
-
return this.makeRequest("POST", endpoint, data);
|
|
133
|
-
}
|
|
134
|
-
put(endpoint, data) {
|
|
135
|
-
return this.makeRequest("PUT", endpoint, data);
|
|
136
|
-
}
|
|
137
|
-
delete(endpoint) {
|
|
138
|
-
return this.makeRequest("DELETE", endpoint);
|
|
139
|
-
}
|
|
140
|
-
fetch(endpoint, init) {
|
|
141
|
-
var _a;
|
|
142
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
143
|
-
const requestInit = init;
|
|
144
|
-
if (!endpoint.startsWith("/")) {
|
|
145
|
-
endpoint = "/" + endpoint;
|
|
146
|
-
}
|
|
147
|
-
return yield fetch(this.tenantBaseUrl + endpoint, Object.assign(Object.assign({}, (requestInit !== null && requestInit !== void 0 ? requestInit : {})), { headers: Object.assign(Object.assign({}, this.defaultHeaders), ((_a = requestInit === null || requestInit === void 0 ? void 0 : requestInit.headers) !== null && _a !== void 0 ? _a : {})) }));
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
makeRequest(method, endpoint, data) {
|
|
151
|
-
return this.fetch(endpoint, {
|
|
152
|
-
method: method,
|
|
153
|
-
headers: Object.assign({}, (data != null ? { "Content-Type": "application/json" } : {})),
|
|
154
|
-
body: data != null ? JSON.stringify(data) : undefined
|
|
155
|
-
})
|
|
156
|
-
.then(handleError)
|
|
157
|
-
.then(getBody);
|
|
158
|
-
}
|
|
159
|
-
fetchRawData(endpoint) {
|
|
160
|
-
return fetch(this.tenantBaseUrl + endpoint, { headers: this.defaultHeaders })
|
|
161
|
-
.then(handleError)
|
|
162
|
-
.then(response => response.arrayBuffer());
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
exports.FluidTopicsApi = FluidTopicsApi;
|
|
166
|
-
exports.default = FluidTopicsApi;
|
|
@@ -1,374 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isFtAuthenticationIdentifier = exports.isFtSuggestResults = exports.isFtSuggestResult = exports.isFtSuggestRequest = 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.isFtSearchResults = exports.isFtCollectionDocumentType = exports.FtCollectionDocumentType = exports.isFtPageRequest = exports.isFtOpenMode = exports.FtOpenMode = exports.isFtEditorialType = exports.FtEditorialType = exports.isFtSearchResultsPageInfo = exports.isFtSearchFilter = exports.isFtMapResource = exports.isFtMetadata = exports.isFtSearchLocales = exports.isFtSearchLocale = exports.isFtTopicContentTarget = exports.FtTopicContentTarget = exports.isFtUnstructuredDocument = exports.isFtTopic = exports.isFtTocNode = exports.isFtMap = exports.isFtCollectionDocument = exports.isFtCredentials = void 0;
|
|
4
|
-
const isObject = (o) => typeof o === "object" && o != null;
|
|
5
|
-
const isBoolean = (o) => typeof o === "boolean";
|
|
6
|
-
const isNumber = (o) => typeof o === "number";
|
|
7
|
-
const isString = (o) => typeof o === "string";
|
|
8
|
-
const isFtCredentials = (o) => {
|
|
9
|
-
return isObject(o)
|
|
10
|
-
&& (isString(o.password))
|
|
11
|
-
&& (o.newPassword == null || isString(o.newPassword))
|
|
12
|
-
&& (isBoolean(o.rememberMe))
|
|
13
|
-
&& (isString(o.login));
|
|
14
|
-
};
|
|
15
|
-
exports.isFtCredentials = isFtCredentials;
|
|
16
|
-
const isFtCollectionDocument = (o) => {
|
|
17
|
-
return isObject(o)
|
|
18
|
-
&& (isBoolean(o.deleted))
|
|
19
|
-
&& (o.apiUrl == null || isString(o.apiUrl))
|
|
20
|
-
&& (o.portalUrl == null || isString(o.portalUrl))
|
|
21
|
-
&& (isString(o.id))
|
|
22
|
-
&& (isString(o.title))
|
|
23
|
-
&& ((0, exports.isFtCollectionDocumentType)(o.type));
|
|
24
|
-
};
|
|
25
|
-
exports.isFtCollectionDocument = isFtCollectionDocument;
|
|
26
|
-
const isFtMap = (o) => {
|
|
27
|
-
return isObject(o)
|
|
28
|
-
&& (o.prettyUrl == null || isString(o.prettyUrl))
|
|
29
|
-
&& ((Array.isArray(o.metadata)
|
|
30
|
-
&& o.metadata.every((v) => (0, exports.isFtMetadata)(v))))
|
|
31
|
-
&& ((0, exports.isFtOpenMode)(o.openMode))
|
|
32
|
-
&& (isString(o.topicsApiEndpoint))
|
|
33
|
-
&& (o.description == null || isString(o.description))
|
|
34
|
-
&& (isString(o.attachmentsApiEndpoint))
|
|
35
|
-
&& ((0, exports.isFtEditorialType)(o.editorialType))
|
|
36
|
-
&& (isString(o.baseId))
|
|
37
|
-
&& (isString(o.clusterId))
|
|
38
|
-
&& (isString(o.title))
|
|
39
|
-
&& (isString(o.lastPublication))
|
|
40
|
-
&& (isString(o.lastEdition))
|
|
41
|
-
&& (isString(o.originId))
|
|
42
|
-
&& (isString(o.rightsApiEndpoint))
|
|
43
|
-
&& (o.originUrl == null || isString(o.originUrl))
|
|
44
|
-
&& (isString(o.readerUrl))
|
|
45
|
-
&& (o.khubVersion == null || isString(o.khubVersion))
|
|
46
|
-
&& (isString(o.id))
|
|
47
|
-
&& (o.lang == null || isString(o.lang));
|
|
48
|
-
};
|
|
49
|
-
exports.isFtMap = isFtMap;
|
|
50
|
-
const isFtTocNode = (o) => {
|
|
51
|
-
return isObject(o)
|
|
52
|
-
&& (isString(o.tocId))
|
|
53
|
-
&& ((Array.isArray(o.children)
|
|
54
|
-
&& o.children.every((v) => (0, exports.isFtTocNode)(v))))
|
|
55
|
-
&& (isString(o.contentId))
|
|
56
|
-
&& (isString(o.title));
|
|
57
|
-
};
|
|
58
|
-
exports.isFtTocNode = isFtTocNode;
|
|
59
|
-
const isFtTopic = (o) => {
|
|
60
|
-
return isObject(o)
|
|
61
|
-
&& ((Array.isArray(o.metadata)
|
|
62
|
-
&& o.metadata.every((v) => (0, exports.isFtMetadata)(v))))
|
|
63
|
-
&& (isString(o.id))
|
|
64
|
-
&& (isString(o.contentApiEndpoint))
|
|
65
|
-
&& (isString(o.title));
|
|
66
|
-
};
|
|
67
|
-
exports.isFtTopic = isFtTopic;
|
|
68
|
-
const isFtUnstructuredDocument = (o) => {
|
|
69
|
-
return isObject(o)
|
|
70
|
-
&& (o.prettyUrl == null || isString(o.prettyUrl))
|
|
71
|
-
&& ((Array.isArray(o.metadata)
|
|
72
|
-
&& o.metadata.every((v) => (0, exports.isFtMetadata)(v))))
|
|
73
|
-
&& (isString(o.openMode))
|
|
74
|
-
&& (o.description == null || isString(o.description))
|
|
75
|
-
&& (isString(o.mimeType))
|
|
76
|
-
&& (o.baseId == null || isString(o.baseId))
|
|
77
|
-
&& (o.clusterId == null || isString(o.clusterId))
|
|
78
|
-
&& (isString(o.contentApiEndpoint))
|
|
79
|
-
&& (isString(o.title))
|
|
80
|
-
&& (o.lastPublication == null || isString(o.lastPublication))
|
|
81
|
-
&& (isString(o.viewerUrl))
|
|
82
|
-
&& (isString(o.lastEdition))
|
|
83
|
-
&& (isString(o.filename))
|
|
84
|
-
&& (o.originId == null || isString(o.originId))
|
|
85
|
-
&& (isString(o.rightsApiEndpoint))
|
|
86
|
-
&& (o.originUrl == null || isString(o.originUrl))
|
|
87
|
-
&& (o.khubVersion == null || isString(o.khubVersion))
|
|
88
|
-
&& (isString(o.id))
|
|
89
|
-
&& (o.lang == null || isString(o.lang));
|
|
90
|
-
};
|
|
91
|
-
exports.isFtUnstructuredDocument = isFtUnstructuredDocument;
|
|
92
|
-
// From: WsTopicContentTarget
|
|
93
|
-
var FtTopicContentTarget;
|
|
94
|
-
(function (FtTopicContentTarget) {
|
|
95
|
-
FtTopicContentTarget["THIRD_PARTY"] = "THIRD_PARTY";
|
|
96
|
-
FtTopicContentTarget["OFF_THE_GRID"] = "OFF_THE_GRID";
|
|
97
|
-
})(FtTopicContentTarget = exports.FtTopicContentTarget || (exports.FtTopicContentTarget = {}));
|
|
98
|
-
const isFtTopicContentTarget = (o) => {
|
|
99
|
-
return ["THIRD_PARTY", "OFF_THE_GRID"].includes(o);
|
|
100
|
-
};
|
|
101
|
-
exports.isFtTopicContentTarget = isFtTopicContentTarget;
|
|
102
|
-
const isFtSearchLocale = (o) => {
|
|
103
|
-
return isObject(o)
|
|
104
|
-
&& (isNumber(o.count))
|
|
105
|
-
&& (isString(o.label))
|
|
106
|
-
&& (o.lang == null || isString(o.lang));
|
|
107
|
-
};
|
|
108
|
-
exports.isFtSearchLocale = isFtSearchLocale;
|
|
109
|
-
const isFtSearchLocales = (o) => {
|
|
110
|
-
return isObject(o)
|
|
111
|
-
&& ((Array.isArray(o.contentLocales)
|
|
112
|
-
&& o.contentLocales.every((v) => (0, exports.isFtSearchLocale)(v))));
|
|
113
|
-
};
|
|
114
|
-
exports.isFtSearchLocales = isFtSearchLocales;
|
|
115
|
-
const isFtMetadata = (o) => {
|
|
116
|
-
return isObject(o)
|
|
117
|
-
&& ((Array.isArray(o.values)
|
|
118
|
-
&& o.values.every((v) => isString(v))))
|
|
119
|
-
&& (isString(o.label))
|
|
120
|
-
&& (isString(o.key));
|
|
121
|
-
};
|
|
122
|
-
exports.isFtMetadata = isFtMetadata;
|
|
123
|
-
const isFtMapResource = (o) => {
|
|
124
|
-
return isObject(o)
|
|
125
|
-
&& (isString(o.contentUrl))
|
|
126
|
-
&& (isString(o.filename))
|
|
127
|
-
&& (isString(o.id))
|
|
128
|
-
&& (isString(o.mimeType));
|
|
129
|
-
};
|
|
130
|
-
exports.isFtMapResource = isFtMapResource;
|
|
131
|
-
const isFtSearchFilter = (o) => {
|
|
132
|
-
return isObject(o)
|
|
133
|
-
&& (isBoolean(o.negative))
|
|
134
|
-
&& ((Array.isArray(o.values)
|
|
135
|
-
&& o.values.every((v) => isString(v))))
|
|
136
|
-
&& (isString(o.key));
|
|
137
|
-
};
|
|
138
|
-
exports.isFtSearchFilter = isFtSearchFilter;
|
|
139
|
-
const isFtSearchResultsPageInfo = (o) => {
|
|
140
|
-
return isObject(o)
|
|
141
|
-
&& (isNumber(o.totalResultsCount))
|
|
142
|
-
&& (isBoolean(o.lastPage))
|
|
143
|
-
&& (isNumber(o.currentPage))
|
|
144
|
-
&& (isNumber(o.totalClustersCount));
|
|
145
|
-
};
|
|
146
|
-
exports.isFtSearchResultsPageInfo = isFtSearchResultsPageInfo;
|
|
147
|
-
// From: WsEditorialType
|
|
148
|
-
var FtEditorialType;
|
|
149
|
-
(function (FtEditorialType) {
|
|
150
|
-
FtEditorialType["ARTICLE"] = "ARTICLE";
|
|
151
|
-
FtEditorialType["BOOK"] = "BOOK";
|
|
152
|
-
})(FtEditorialType = exports.FtEditorialType || (exports.FtEditorialType = {}));
|
|
153
|
-
const isFtEditorialType = (o) => {
|
|
154
|
-
return ["ARTICLE", "BOOK"].includes(o);
|
|
155
|
-
};
|
|
156
|
-
exports.isFtEditorialType = isFtEditorialType;
|
|
157
|
-
// From: WsOpenMode
|
|
158
|
-
var FtOpenMode;
|
|
159
|
-
(function (FtOpenMode) {
|
|
160
|
-
FtOpenMode["FLUIDTOPICS"] = "FLUIDTOPICS";
|
|
161
|
-
FtOpenMode["EXTERNAL"] = "EXTERNAL";
|
|
162
|
-
})(FtOpenMode = exports.FtOpenMode || (exports.FtOpenMode = {}));
|
|
163
|
-
const isFtOpenMode = (o) => {
|
|
164
|
-
return ["FLUIDTOPICS", "EXTERNAL"].includes(o);
|
|
165
|
-
};
|
|
166
|
-
exports.isFtOpenMode = isFtOpenMode;
|
|
167
|
-
const isFtPageRequest = (o) => {
|
|
168
|
-
return isObject(o)
|
|
169
|
-
&& (o.perPage == null || isNumber(o.perPage))
|
|
170
|
-
&& (isNumber(o.page));
|
|
171
|
-
};
|
|
172
|
-
exports.isFtPageRequest = isFtPageRequest;
|
|
173
|
-
// From: WsPublicCollectionDocumentType
|
|
174
|
-
var FtCollectionDocumentType;
|
|
175
|
-
(function (FtCollectionDocumentType) {
|
|
176
|
-
FtCollectionDocumentType["MAP"] = "MAP";
|
|
177
|
-
FtCollectionDocumentType["DOCUMENT"] = "DOCUMENT";
|
|
178
|
-
FtCollectionDocumentType["TOPIC"] = "TOPIC";
|
|
179
|
-
FtCollectionDocumentType["PERSONAL_BOOK"] = "PERSONAL_BOOK";
|
|
180
|
-
FtCollectionDocumentType["SHARED_BOOK"] = "SHARED_BOOK";
|
|
181
|
-
})(FtCollectionDocumentType = exports.FtCollectionDocumentType || (exports.FtCollectionDocumentType = {}));
|
|
182
|
-
const isFtCollectionDocumentType = (o) => {
|
|
183
|
-
return ["MAP", "DOCUMENT", "TOPIC", "PERSONAL_BOOK", "SHARED_BOOK"].includes(o);
|
|
184
|
-
};
|
|
185
|
-
exports.isFtCollectionDocumentType = isFtCollectionDocumentType;
|
|
186
|
-
const isFtSearchResults = (o) => {
|
|
187
|
-
return isObject(o)
|
|
188
|
-
&& (o.spellcheck == null || (0, exports.isFtSpellcheck)(o.spellcheck))
|
|
189
|
-
&& ((0, exports.isFtSearchResultsPageInfo)(o.paging))
|
|
190
|
-
&& ((Array.isArray(o.results)
|
|
191
|
-
&& o.results.every((v) => (0, exports.isFtSearchResultCluster)(v))))
|
|
192
|
-
&& ((Array.isArray(o.facets)
|
|
193
|
-
&& o.facets.every((v) => (0, exports.isFtSearchFacet)(v))));
|
|
194
|
-
};
|
|
195
|
-
exports.isFtSearchResults = isFtSearchResults;
|
|
196
|
-
const isFtSearchRequest = (o) => {
|
|
197
|
-
return isObject(o)
|
|
198
|
-
&& (isString(o.query))
|
|
199
|
-
&& ((0, exports.isFtPageRequest)(o.paging))
|
|
200
|
-
&& ((Array.isArray(o.filters)
|
|
201
|
-
&& o.filters.every((v) => (0, exports.isFtSearchFilter)(v))))
|
|
202
|
-
&& ((Array.isArray(o.sort)
|
|
203
|
-
&& o.sort.every((v) => (0, exports.isFtSearchSortCriterion)(v))))
|
|
204
|
-
&& (o.uiLocale == null || isString(o.uiLocale))
|
|
205
|
-
&& (o.contentLocale == null || isString(o.contentLocale))
|
|
206
|
-
&& ((Array.isArray(o.facets)
|
|
207
|
-
&& o.facets.every((v) => (0, exports.isFtSearchFacetConf)(v))));
|
|
208
|
-
};
|
|
209
|
-
exports.isFtSearchRequest = isFtSearchRequest;
|
|
210
|
-
const isFtSearchResultCluster = (o) => {
|
|
211
|
-
return isObject(o)
|
|
212
|
-
&& ((Array.isArray(o.entries)
|
|
213
|
-
&& o.entries.every((v) => (0, exports.isFtSearchResultClusterEntry)(v))))
|
|
214
|
-
&& (o.metadataVariableAxis == null || isString(o.metadataVariableAxis));
|
|
215
|
-
};
|
|
216
|
-
exports.isFtSearchResultCluster = isFtSearchResultCluster;
|
|
217
|
-
const isFtSearchResultClusterEntry = (o) => {
|
|
218
|
-
return isObject(o)
|
|
219
|
-
&& (o.document == null || (0, exports.isFtSearchResultUnstructuredDocument)(o.document))
|
|
220
|
-
&& (o.topic == null || (0, exports.isFtSearchResultTopic)(o.topic))
|
|
221
|
-
&& ((0, exports.isFtSearchResultType)(o.type))
|
|
222
|
-
&& (o.map == null || (0, exports.isFtSearchResultMap)(o.map));
|
|
223
|
-
};
|
|
224
|
-
exports.isFtSearchResultClusterEntry = isFtSearchResultClusterEntry;
|
|
225
|
-
const isFtSearchResultUnstructuredDocument = (o) => {
|
|
226
|
-
return isObject(o)
|
|
227
|
-
&& ((Array.isArray(o.metadata)
|
|
228
|
-
&& o.metadata.every((v) => (0, exports.isFtMetadata)(v))))
|
|
229
|
-
&& ((0, exports.isFtOpenMode)(o.openMode))
|
|
230
|
-
&& (isString(o.documentUrl))
|
|
231
|
-
&& (isString(o.mimeType))
|
|
232
|
-
&& (isString(o.title))
|
|
233
|
-
&& (o.lastPublicationDate == null || isString(o.lastPublicationDate))
|
|
234
|
-
&& (isString(o.viewerUrl))
|
|
235
|
-
&& (isString(o.contentUrl))
|
|
236
|
-
&& (isString(o.filename))
|
|
237
|
-
&& (isString(o.htmlTitle))
|
|
238
|
-
&& (o.originUrl == null || isString(o.originUrl))
|
|
239
|
-
&& (isString(o.documentId))
|
|
240
|
-
&& (isString(o.lastEditionDate))
|
|
241
|
-
&& (isString(o.htmlExcerpt));
|
|
242
|
-
};
|
|
243
|
-
exports.isFtSearchResultUnstructuredDocument = isFtSearchResultUnstructuredDocument;
|
|
244
|
-
const isFtSearchResultMap = (o) => {
|
|
245
|
-
return isObject(o)
|
|
246
|
-
&& ((Array.isArray(o.metadata)
|
|
247
|
-
&& o.metadata.every((v) => (0, exports.isFtMetadata)(v))))
|
|
248
|
-
&& ((0, exports.isFtOpenMode)(o.openMode))
|
|
249
|
-
&& ((0, exports.isFtEditorialType)(o.editorialType))
|
|
250
|
-
&& (isString(o.title))
|
|
251
|
-
&& (o.lastPublicationDate == null || isString(o.lastPublicationDate))
|
|
252
|
-
&& (isString(o.htmlTitle))
|
|
253
|
-
&& (o.originUrl == null || isString(o.originUrl))
|
|
254
|
-
&& (isString(o.mapUrl))
|
|
255
|
-
&& (isString(o.readerUrl))
|
|
256
|
-
&& (isString(o.mapId))
|
|
257
|
-
&& (o.lastEditionDate == null || isString(o.lastEditionDate))
|
|
258
|
-
&& (isString(o.htmlExcerpt));
|
|
259
|
-
};
|
|
260
|
-
exports.isFtSearchResultMap = isFtSearchResultMap;
|
|
261
|
-
const isFtSearchResultTopic = (o) => {
|
|
262
|
-
return isObject(o)
|
|
263
|
-
&& ((Array.isArray(o.metadata)
|
|
264
|
-
&& o.metadata.every((v) => (0, exports.isFtMetadata)(v))))
|
|
265
|
-
&& ((0, exports.isFtOpenMode)(o.openMode))
|
|
266
|
-
&& (isString(o.contentId))
|
|
267
|
-
&& ((Array.isArray(o.resources)
|
|
268
|
-
&& o.resources.every((v) => (0, exports.isFtTopicResource)(v))))
|
|
269
|
-
&& (isString(o.title))
|
|
270
|
-
&& (isString(o.mapTitle))
|
|
271
|
-
&& (isString(o.topicUrl))
|
|
272
|
-
&& (isString(o.contentUrl))
|
|
273
|
-
&& (isString(o.htmlTitle))
|
|
274
|
-
&& ((Array.isArray(o.breadcrumb)
|
|
275
|
-
&& o.breadcrumb.every((v) => isString(v))))
|
|
276
|
-
&& (isString(o.tocId))
|
|
277
|
-
&& (o.originUrl == null || isString(o.originUrl))
|
|
278
|
-
&& (isString(o.readerUrl))
|
|
279
|
-
&& (isString(o.mapId))
|
|
280
|
-
&& (o.lastEditionDate == null || isString(o.lastEditionDate))
|
|
281
|
-
&& (isString(o.htmlExcerpt));
|
|
282
|
-
};
|
|
283
|
-
exports.isFtSearchResultTopic = isFtSearchResultTopic;
|
|
284
|
-
// From: WsPublicSearchResultType
|
|
285
|
-
var FtSearchResultType;
|
|
286
|
-
(function (FtSearchResultType) {
|
|
287
|
-
FtSearchResultType["MAP"] = "MAP";
|
|
288
|
-
FtSearchResultType["DOCUMENT"] = "DOCUMENT";
|
|
289
|
-
FtSearchResultType["TOPIC"] = "TOPIC";
|
|
290
|
-
})(FtSearchResultType = exports.FtSearchResultType || (exports.FtSearchResultType = {}));
|
|
291
|
-
const isFtSearchResultType = (o) => {
|
|
292
|
-
return ["MAP", "DOCUMENT", "TOPIC"].includes(o);
|
|
293
|
-
};
|
|
294
|
-
exports.isFtSearchResultType = isFtSearchResultType;
|
|
295
|
-
const isFtSearchFacet = (o) => {
|
|
296
|
-
return isObject(o)
|
|
297
|
-
&& (isBoolean(o.hierarchical))
|
|
298
|
-
&& (isString(o.label))
|
|
299
|
-
&& (isBoolean(o.multiSelectionable))
|
|
300
|
-
&& (isString(o.key))
|
|
301
|
-
&& ((Array.isArray(o.rootNodes)
|
|
302
|
-
&& o.rootNodes.every((v) => (0, exports.isFtSearchFacetEntry)(v))));
|
|
303
|
-
};
|
|
304
|
-
exports.isFtSearchFacet = isFtSearchFacet;
|
|
305
|
-
const isFtSearchFacetConf = (o) => {
|
|
306
|
-
return isObject(o)
|
|
307
|
-
&& (o.maxDepth == null || isNumber(o.maxDepth))
|
|
308
|
-
&& (isString(o.id));
|
|
309
|
-
};
|
|
310
|
-
exports.isFtSearchFacetConf = isFtSearchFacetConf;
|
|
311
|
-
const isFtSearchFacetEntry = (o) => {
|
|
312
|
-
return isObject(o)
|
|
313
|
-
&& (isNumber(o.totalResultsCount))
|
|
314
|
-
&& (isBoolean(o.descendantSelected))
|
|
315
|
-
&& ((Array.isArray(o.childNodes)
|
|
316
|
-
&& o.childNodes.every((v) => (0, exports.isFtSearchFacetEntry)(v))))
|
|
317
|
-
&& (isString(o.label))
|
|
318
|
-
&& (isString(o.value))
|
|
319
|
-
&& (isBoolean(o.selected));
|
|
320
|
-
};
|
|
321
|
-
exports.isFtSearchFacetEntry = isFtSearchFacetEntry;
|
|
322
|
-
const isFtSearchSortCriterion = (o) => {
|
|
323
|
-
return isObject(o)
|
|
324
|
-
&& (isString(o.key));
|
|
325
|
-
};
|
|
326
|
-
exports.isFtSearchSortCriterion = isFtSearchSortCriterion;
|
|
327
|
-
const isFtSpellcheck = (o) => {
|
|
328
|
-
return isObject(o)
|
|
329
|
-
&& (isString(o.suggestedQuery))
|
|
330
|
-
&& (isString(o.htmlSuggestedQuery));
|
|
331
|
-
};
|
|
332
|
-
exports.isFtSpellcheck = isFtSpellcheck;
|
|
333
|
-
const isFtTopicResource = (o) => {
|
|
334
|
-
return isObject(o)
|
|
335
|
-
&& (isString(o.filename))
|
|
336
|
-
&& (isString(o.resourceUrl))
|
|
337
|
-
&& (isString(o.id))
|
|
338
|
-
&& (isString(o.mimeType))
|
|
339
|
-
&& (isString(o.resourceContentUrl))
|
|
340
|
-
&& (isString(o.viewerUrl));
|
|
341
|
-
};
|
|
342
|
-
exports.isFtTopicResource = isFtTopicResource;
|
|
343
|
-
const isFtSuggestRequest = (o) => {
|
|
344
|
-
return isObject(o)
|
|
345
|
-
&& (isString(o.input))
|
|
346
|
-
&& ((Array.isArray(o.filters)
|
|
347
|
-
&& o.filters.every((v) => (0, exports.isFtSearchFilter)(v))))
|
|
348
|
-
&& ((Array.isArray(o.sort)
|
|
349
|
-
&& o.sort.every((v) => (0, exports.isFtSearchSortCriterion)(v))))
|
|
350
|
-
&& (o.maxCount == null || isNumber(o.maxCount))
|
|
351
|
-
&& (o.contentLocale == null || isString(o.contentLocale));
|
|
352
|
-
};
|
|
353
|
-
exports.isFtSuggestRequest = isFtSuggestRequest;
|
|
354
|
-
const isFtSuggestResult = (o) => {
|
|
355
|
-
return isObject(o)
|
|
356
|
-
&& (o.filenameExtension == null || isString(o.filenameExtension))
|
|
357
|
-
&& (o.editorialType == null || (0, exports.isFtEditorialType)(o.editorialType))
|
|
358
|
-
&& (o.mimeType == null || isString(o.mimeType))
|
|
359
|
-
&& ((0, exports.isFtSearchResultType)(o.type))
|
|
360
|
-
&& (isString(o.value));
|
|
361
|
-
};
|
|
362
|
-
exports.isFtSuggestResult = isFtSuggestResult;
|
|
363
|
-
const isFtSuggestResults = (o) => {
|
|
364
|
-
return isObject(o)
|
|
365
|
-
&& ((Array.isArray(o.suggestions)
|
|
366
|
-
&& o.suggestions.every((v) => (0, exports.isFtSuggestResult)(v))));
|
|
367
|
-
};
|
|
368
|
-
exports.isFtSuggestResults = isFtSuggestResults;
|
|
369
|
-
const isFtAuthenticationIdentifier = (o) => {
|
|
370
|
-
return isObject(o)
|
|
371
|
-
&& (isString(o.identifier))
|
|
372
|
-
&& (isString(o.realm));
|
|
373
|
-
};
|
|
374
|
-
exports.isFtAuthenticationIdentifier = isFtAuthenticationIdentifier;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isFtMapAttachment = exports.isFtUserProfile = exports.isFtAuthenticatedSession = void 0;
|
|
4
|
-
const isObject = (o) => typeof o === "object" && o != null;
|
|
5
|
-
const isBoolean = (o) => typeof o === "boolean";
|
|
6
|
-
const isNumber = (o) => typeof o === "number";
|
|
7
|
-
const isString = (o) => typeof o === "string";
|
|
8
|
-
const isFtAuthenticatedSession = (o) => {
|
|
9
|
-
return isObject(o)
|
|
10
|
-
&& ((0, exports.isFtUserProfile)(o.profile));
|
|
11
|
-
};
|
|
12
|
-
exports.isFtAuthenticatedSession = isFtAuthenticatedSession;
|
|
13
|
-
const isFtUserProfile = (o) => {
|
|
14
|
-
return isObject(o)
|
|
15
|
-
&& (o.emailAddress == null || isString(o.emailAddress))
|
|
16
|
-
&& (o.displayName == null || isString(o.displayName))
|
|
17
|
-
&& ((Array.isArray(o.roles)))
|
|
18
|
-
&& (isString(o.userId));
|
|
19
|
-
};
|
|
20
|
-
exports.isFtUserProfile = isFtUserProfile;
|
|
21
|
-
const isFtMapAttachment = (o) => {
|
|
22
|
-
return isObject(o)
|
|
23
|
-
&& (isString(o.file))
|
|
24
|
-
&& (o.size == null || isNumber(o.size))
|
|
25
|
-
&& (isBoolean(o.externalLink))
|
|
26
|
-
&& (isString(o.name))
|
|
27
|
-
&& (isString(o.id))
|
|
28
|
-
&& (o.mimeType == null || isString(o.mimeType))
|
|
29
|
-
&& (o.viewerUrl == null || isString(o.viewerUrl));
|
|
30
|
-
};
|
|
31
|
-
exports.isFtMapAttachment = isFtMapAttachment;
|
package/dist/mjs/index.mjs
DELETED
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import "cross-fetch/polyfill";
|
|
2
|
-
export * from "./types/ft-common/public";
|
|
3
|
-
export * from "./types/ft-server/public";
|
|
4
|
-
function toBase64(s) {
|
|
5
|
-
return typeof Buffer !== "undefined" ? Buffer.from(s).toString("base64") : btoa(s);
|
|
6
|
-
}
|
|
7
|
-
export class HttpError extends Error {
|
|
8
|
-
status;
|
|
9
|
-
statusText;
|
|
10
|
-
body;
|
|
11
|
-
constructor(status, statusText, body) {
|
|
12
|
-
super(`${status} - ${statusText}: ${body}`);
|
|
13
|
-
this.status = status;
|
|
14
|
-
this.statusText = statusText;
|
|
15
|
-
this.body = body;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
async function handleError(response) {
|
|
19
|
-
if (!response.ok) {
|
|
20
|
-
throw new HttpError(response.status, response.statusText, await response.text());
|
|
21
|
-
}
|
|
22
|
-
return response;
|
|
23
|
-
}
|
|
24
|
-
function getBody(response) {
|
|
25
|
-
return response.headers.get("Content-Type") === "application/json" ? response.json() : response.text();
|
|
26
|
-
}
|
|
27
|
-
export class FluidTopicsApi {
|
|
28
|
-
tenantBaseUrl;
|
|
29
|
-
ftCallingApp;
|
|
30
|
-
authorization = {};
|
|
31
|
-
get defaultHeaders() {
|
|
32
|
-
return {
|
|
33
|
-
...this.authorization,
|
|
34
|
-
"Ft-Calling-App": this.ftCallingApp
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
constructor(tenantBaseUrl, integrationIdentifier) {
|
|
38
|
-
this.tenantBaseUrl = tenantBaseUrl.trim().replace(/\/$/, "");
|
|
39
|
-
this.ftCallingApp = `ft-public-api/${integrationIdentifier}`;
|
|
40
|
-
}
|
|
41
|
-
setApiKey(apiKey) {
|
|
42
|
-
this.authorization = { "Authorization": "Bearer " + apiKey };
|
|
43
|
-
}
|
|
44
|
-
setCredentials(login, password) {
|
|
45
|
-
this.authorization = { "Authorization": "Basic " + toBase64(`${login}:${password}`) };
|
|
46
|
-
}
|
|
47
|
-
clearAuthentication() {
|
|
48
|
-
this.authorization = {};
|
|
49
|
-
}
|
|
50
|
-
login(login, password) {
|
|
51
|
-
let credentials = {
|
|
52
|
-
login: login,
|
|
53
|
-
password: password,
|
|
54
|
-
rememberMe: true
|
|
55
|
-
};
|
|
56
|
-
return this.post(`/api/authentication/login`, credentials)
|
|
57
|
-
.then(result => {
|
|
58
|
-
this.setCredentials(login, password);
|
|
59
|
-
return result;
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
logout() {
|
|
63
|
-
return this.post(`/api/authentication/logout`)
|
|
64
|
-
.then(() => this.clearAuthentication());
|
|
65
|
-
}
|
|
66
|
-
getMap(mapId) {
|
|
67
|
-
return this.get(`/api/khub/maps/${mapId}`);
|
|
68
|
-
}
|
|
69
|
-
getTableOfContent(mapId) {
|
|
70
|
-
return this.get(`/api/khub/maps/${mapId}/toc`);
|
|
71
|
-
}
|
|
72
|
-
getTopic(mapId, topicContentId) {
|
|
73
|
-
return this.get(`/api/khub/maps/${mapId}/topics/${topicContentId}`);
|
|
74
|
-
}
|
|
75
|
-
getTopicHTMLContent(mapId, topicContentId, target) {
|
|
76
|
-
return this.get(`/api/khub/maps/${mapId}/topics/${topicContentId}/content${target ? "?target=" + target : ""}`);
|
|
77
|
-
}
|
|
78
|
-
getMapAttachments(mapId) {
|
|
79
|
-
return this.get(`/api/khub/maps/${mapId}/attachments`);
|
|
80
|
-
}
|
|
81
|
-
getMapAttachmentContent(mapId, attachmentId) {
|
|
82
|
-
return this.fetchRawData(`/api/khub/maps/${mapId}/attachments/${attachmentId}/content`);
|
|
83
|
-
}
|
|
84
|
-
getMapResources(mapId) {
|
|
85
|
-
return this.get(`/api/khub/maps/${mapId}/resources`);
|
|
86
|
-
}
|
|
87
|
-
getMapResourceContent(mapId, resourceId) {
|
|
88
|
-
return this.fetchRawData(`/api/khub/maps/${mapId}/resources/${resourceId}/content`);
|
|
89
|
-
}
|
|
90
|
-
getUnstructuredDocument(documentId) {
|
|
91
|
-
return this.get(`/api/khub/documents/${documentId}`);
|
|
92
|
-
}
|
|
93
|
-
getUnstructuredDocumentContent(documentId) {
|
|
94
|
-
return this.fetchRawData(`/api/khub/documents/${documentId}/content`);
|
|
95
|
-
}
|
|
96
|
-
getUnstructuredDocumentTextContent(documentId) {
|
|
97
|
-
return this.get(`/api/khub/documents/${documentId}/content/text`);
|
|
98
|
-
}
|
|
99
|
-
getCollectionDocuments(userId, collectionId) {
|
|
100
|
-
return this.get(`/api/users/${userId}/collections/${collectionId}/documents`);
|
|
101
|
-
}
|
|
102
|
-
getSuggestions(request) {
|
|
103
|
-
return this.post("/api/khub/suggest", request);
|
|
104
|
-
}
|
|
105
|
-
search(request) {
|
|
106
|
-
return this.post("/api/khub/clustered-search", request);
|
|
107
|
-
}
|
|
108
|
-
getAvailableSearchLocales() {
|
|
109
|
-
return this.get("/api/khub/locales");
|
|
110
|
-
}
|
|
111
|
-
get(endpoint) {
|
|
112
|
-
return this.makeRequest("GET", endpoint);
|
|
113
|
-
}
|
|
114
|
-
post(endpoint, data) {
|
|
115
|
-
return this.makeRequest("POST", endpoint, data);
|
|
116
|
-
}
|
|
117
|
-
put(endpoint, data) {
|
|
118
|
-
return this.makeRequest("PUT", endpoint, data);
|
|
119
|
-
}
|
|
120
|
-
delete(endpoint) {
|
|
121
|
-
return this.makeRequest("DELETE", endpoint);
|
|
122
|
-
}
|
|
123
|
-
async fetch(endpoint, init) {
|
|
124
|
-
const requestInit = init;
|
|
125
|
-
if (!endpoint.startsWith("/")) {
|
|
126
|
-
endpoint = "/" + endpoint;
|
|
127
|
-
}
|
|
128
|
-
return await fetch(this.tenantBaseUrl + endpoint, {
|
|
129
|
-
...(requestInit ?? {}),
|
|
130
|
-
headers: {
|
|
131
|
-
...this.defaultHeaders,
|
|
132
|
-
...(requestInit?.headers ?? {})
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
makeRequest(method, endpoint, data) {
|
|
137
|
-
return this.fetch(endpoint, {
|
|
138
|
-
method: method,
|
|
139
|
-
headers: {
|
|
140
|
-
...(data != null ? { "Content-Type": "application/json" } : {})
|
|
141
|
-
},
|
|
142
|
-
body: data != null ? JSON.stringify(data) : undefined
|
|
143
|
-
})
|
|
144
|
-
.then(handleError)
|
|
145
|
-
.then(getBody);
|
|
146
|
-
}
|
|
147
|
-
fetchRawData(endpoint) {
|
|
148
|
-
return fetch(this.tenantBaseUrl + endpoint, { headers: this.defaultHeaders })
|
|
149
|
-
.then(handleError)
|
|
150
|
-
.then(response => response.arrayBuffer());
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
export default FluidTopicsApi;
|
|
@@ -1,336 +0,0 @@
|
|
|
1
|
-
const isObject = (o) => typeof o === "object" && o != null;
|
|
2
|
-
const isBoolean = (o) => typeof o === "boolean";
|
|
3
|
-
const isNumber = (o) => typeof o === "number";
|
|
4
|
-
const isString = (o) => typeof o === "string";
|
|
5
|
-
export const isFtCredentials = (o) => {
|
|
6
|
-
return isObject(o)
|
|
7
|
-
&& (isString(o.password))
|
|
8
|
-
&& (o.newPassword == null || isString(o.newPassword))
|
|
9
|
-
&& (isBoolean(o.rememberMe))
|
|
10
|
-
&& (isString(o.login));
|
|
11
|
-
};
|
|
12
|
-
export const isFtCollectionDocument = (o) => {
|
|
13
|
-
return isObject(o)
|
|
14
|
-
&& (isBoolean(o.deleted))
|
|
15
|
-
&& (o.apiUrl == null || isString(o.apiUrl))
|
|
16
|
-
&& (o.portalUrl == null || isString(o.portalUrl))
|
|
17
|
-
&& (isString(o.id))
|
|
18
|
-
&& (isString(o.title))
|
|
19
|
-
&& (isFtCollectionDocumentType(o.type));
|
|
20
|
-
};
|
|
21
|
-
export const isFtMap = (o) => {
|
|
22
|
-
return isObject(o)
|
|
23
|
-
&& (o.prettyUrl == null || isString(o.prettyUrl))
|
|
24
|
-
&& ((Array.isArray(o.metadata)
|
|
25
|
-
&& o.metadata.every((v) => isFtMetadata(v))))
|
|
26
|
-
&& (isFtOpenMode(o.openMode))
|
|
27
|
-
&& (isString(o.topicsApiEndpoint))
|
|
28
|
-
&& (o.description == null || isString(o.description))
|
|
29
|
-
&& (isString(o.attachmentsApiEndpoint))
|
|
30
|
-
&& (isFtEditorialType(o.editorialType))
|
|
31
|
-
&& (isString(o.baseId))
|
|
32
|
-
&& (isString(o.clusterId))
|
|
33
|
-
&& (isString(o.title))
|
|
34
|
-
&& (isString(o.lastPublication))
|
|
35
|
-
&& (isString(o.lastEdition))
|
|
36
|
-
&& (isString(o.originId))
|
|
37
|
-
&& (isString(o.rightsApiEndpoint))
|
|
38
|
-
&& (o.originUrl == null || isString(o.originUrl))
|
|
39
|
-
&& (isString(o.readerUrl))
|
|
40
|
-
&& (o.khubVersion == null || isString(o.khubVersion))
|
|
41
|
-
&& (isString(o.id))
|
|
42
|
-
&& (o.lang == null || isString(o.lang));
|
|
43
|
-
};
|
|
44
|
-
export const isFtTocNode = (o) => {
|
|
45
|
-
return isObject(o)
|
|
46
|
-
&& (isString(o.tocId))
|
|
47
|
-
&& ((Array.isArray(o.children)
|
|
48
|
-
&& o.children.every((v) => isFtTocNode(v))))
|
|
49
|
-
&& (isString(o.contentId))
|
|
50
|
-
&& (isString(o.title));
|
|
51
|
-
};
|
|
52
|
-
export const isFtTopic = (o) => {
|
|
53
|
-
return isObject(o)
|
|
54
|
-
&& ((Array.isArray(o.metadata)
|
|
55
|
-
&& o.metadata.every((v) => isFtMetadata(v))))
|
|
56
|
-
&& (isString(o.id))
|
|
57
|
-
&& (isString(o.contentApiEndpoint))
|
|
58
|
-
&& (isString(o.title));
|
|
59
|
-
};
|
|
60
|
-
export const isFtUnstructuredDocument = (o) => {
|
|
61
|
-
return isObject(o)
|
|
62
|
-
&& (o.prettyUrl == null || isString(o.prettyUrl))
|
|
63
|
-
&& ((Array.isArray(o.metadata)
|
|
64
|
-
&& o.metadata.every((v) => isFtMetadata(v))))
|
|
65
|
-
&& (isString(o.openMode))
|
|
66
|
-
&& (o.description == null || isString(o.description))
|
|
67
|
-
&& (isString(o.mimeType))
|
|
68
|
-
&& (o.baseId == null || isString(o.baseId))
|
|
69
|
-
&& (o.clusterId == null || isString(o.clusterId))
|
|
70
|
-
&& (isString(o.contentApiEndpoint))
|
|
71
|
-
&& (isString(o.title))
|
|
72
|
-
&& (o.lastPublication == null || isString(o.lastPublication))
|
|
73
|
-
&& (isString(o.viewerUrl))
|
|
74
|
-
&& (isString(o.lastEdition))
|
|
75
|
-
&& (isString(o.filename))
|
|
76
|
-
&& (o.originId == null || isString(o.originId))
|
|
77
|
-
&& (isString(o.rightsApiEndpoint))
|
|
78
|
-
&& (o.originUrl == null || isString(o.originUrl))
|
|
79
|
-
&& (o.khubVersion == null || isString(o.khubVersion))
|
|
80
|
-
&& (isString(o.id))
|
|
81
|
-
&& (o.lang == null || isString(o.lang));
|
|
82
|
-
};
|
|
83
|
-
// From: WsTopicContentTarget
|
|
84
|
-
export var FtTopicContentTarget;
|
|
85
|
-
(function (FtTopicContentTarget) {
|
|
86
|
-
FtTopicContentTarget["THIRD_PARTY"] = "THIRD_PARTY";
|
|
87
|
-
FtTopicContentTarget["OFF_THE_GRID"] = "OFF_THE_GRID";
|
|
88
|
-
})(FtTopicContentTarget || (FtTopicContentTarget = {}));
|
|
89
|
-
export const isFtTopicContentTarget = (o) => {
|
|
90
|
-
return ["THIRD_PARTY", "OFF_THE_GRID"].includes(o);
|
|
91
|
-
};
|
|
92
|
-
export const isFtSearchLocale = (o) => {
|
|
93
|
-
return isObject(o)
|
|
94
|
-
&& (isNumber(o.count))
|
|
95
|
-
&& (isString(o.label))
|
|
96
|
-
&& (o.lang == null || isString(o.lang));
|
|
97
|
-
};
|
|
98
|
-
export const isFtSearchLocales = (o) => {
|
|
99
|
-
return isObject(o)
|
|
100
|
-
&& ((Array.isArray(o.contentLocales)
|
|
101
|
-
&& o.contentLocales.every((v) => isFtSearchLocale(v))));
|
|
102
|
-
};
|
|
103
|
-
export const isFtMetadata = (o) => {
|
|
104
|
-
return isObject(o)
|
|
105
|
-
&& ((Array.isArray(o.values)
|
|
106
|
-
&& o.values.every((v) => isString(v))))
|
|
107
|
-
&& (isString(o.label))
|
|
108
|
-
&& (isString(o.key));
|
|
109
|
-
};
|
|
110
|
-
export const isFtMapResource = (o) => {
|
|
111
|
-
return isObject(o)
|
|
112
|
-
&& (isString(o.contentUrl))
|
|
113
|
-
&& (isString(o.filename))
|
|
114
|
-
&& (isString(o.id))
|
|
115
|
-
&& (isString(o.mimeType));
|
|
116
|
-
};
|
|
117
|
-
export const isFtSearchFilter = (o) => {
|
|
118
|
-
return isObject(o)
|
|
119
|
-
&& (isBoolean(o.negative))
|
|
120
|
-
&& ((Array.isArray(o.values)
|
|
121
|
-
&& o.values.every((v) => isString(v))))
|
|
122
|
-
&& (isString(o.key));
|
|
123
|
-
};
|
|
124
|
-
export const isFtSearchResultsPageInfo = (o) => {
|
|
125
|
-
return isObject(o)
|
|
126
|
-
&& (isNumber(o.totalResultsCount))
|
|
127
|
-
&& (isBoolean(o.lastPage))
|
|
128
|
-
&& (isNumber(o.currentPage))
|
|
129
|
-
&& (isNumber(o.totalClustersCount));
|
|
130
|
-
};
|
|
131
|
-
// From: WsEditorialType
|
|
132
|
-
export var FtEditorialType;
|
|
133
|
-
(function (FtEditorialType) {
|
|
134
|
-
FtEditorialType["ARTICLE"] = "ARTICLE";
|
|
135
|
-
FtEditorialType["BOOK"] = "BOOK";
|
|
136
|
-
})(FtEditorialType || (FtEditorialType = {}));
|
|
137
|
-
export const isFtEditorialType = (o) => {
|
|
138
|
-
return ["ARTICLE", "BOOK"].includes(o);
|
|
139
|
-
};
|
|
140
|
-
// From: WsOpenMode
|
|
141
|
-
export var FtOpenMode;
|
|
142
|
-
(function (FtOpenMode) {
|
|
143
|
-
FtOpenMode["FLUIDTOPICS"] = "FLUIDTOPICS";
|
|
144
|
-
FtOpenMode["EXTERNAL"] = "EXTERNAL";
|
|
145
|
-
})(FtOpenMode || (FtOpenMode = {}));
|
|
146
|
-
export const isFtOpenMode = (o) => {
|
|
147
|
-
return ["FLUIDTOPICS", "EXTERNAL"].includes(o);
|
|
148
|
-
};
|
|
149
|
-
export const isFtPageRequest = (o) => {
|
|
150
|
-
return isObject(o)
|
|
151
|
-
&& (o.perPage == null || isNumber(o.perPage))
|
|
152
|
-
&& (isNumber(o.page));
|
|
153
|
-
};
|
|
154
|
-
// From: WsPublicCollectionDocumentType
|
|
155
|
-
export var FtCollectionDocumentType;
|
|
156
|
-
(function (FtCollectionDocumentType) {
|
|
157
|
-
FtCollectionDocumentType["MAP"] = "MAP";
|
|
158
|
-
FtCollectionDocumentType["DOCUMENT"] = "DOCUMENT";
|
|
159
|
-
FtCollectionDocumentType["TOPIC"] = "TOPIC";
|
|
160
|
-
FtCollectionDocumentType["PERSONAL_BOOK"] = "PERSONAL_BOOK";
|
|
161
|
-
FtCollectionDocumentType["SHARED_BOOK"] = "SHARED_BOOK";
|
|
162
|
-
})(FtCollectionDocumentType || (FtCollectionDocumentType = {}));
|
|
163
|
-
export const isFtCollectionDocumentType = (o) => {
|
|
164
|
-
return ["MAP", "DOCUMENT", "TOPIC", "PERSONAL_BOOK", "SHARED_BOOK"].includes(o);
|
|
165
|
-
};
|
|
166
|
-
export const isFtSearchResults = (o) => {
|
|
167
|
-
return isObject(o)
|
|
168
|
-
&& (o.spellcheck == null || isFtSpellcheck(o.spellcheck))
|
|
169
|
-
&& (isFtSearchResultsPageInfo(o.paging))
|
|
170
|
-
&& ((Array.isArray(o.results)
|
|
171
|
-
&& o.results.every((v) => isFtSearchResultCluster(v))))
|
|
172
|
-
&& ((Array.isArray(o.facets)
|
|
173
|
-
&& o.facets.every((v) => isFtSearchFacet(v))));
|
|
174
|
-
};
|
|
175
|
-
export const isFtSearchRequest = (o) => {
|
|
176
|
-
return isObject(o)
|
|
177
|
-
&& (isString(o.query))
|
|
178
|
-
&& (isFtPageRequest(o.paging))
|
|
179
|
-
&& ((Array.isArray(o.filters)
|
|
180
|
-
&& o.filters.every((v) => isFtSearchFilter(v))))
|
|
181
|
-
&& ((Array.isArray(o.sort)
|
|
182
|
-
&& o.sort.every((v) => isFtSearchSortCriterion(v))))
|
|
183
|
-
&& (o.uiLocale == null || isString(o.uiLocale))
|
|
184
|
-
&& (o.contentLocale == null || isString(o.contentLocale))
|
|
185
|
-
&& ((Array.isArray(o.facets)
|
|
186
|
-
&& o.facets.every((v) => isFtSearchFacetConf(v))));
|
|
187
|
-
};
|
|
188
|
-
export const isFtSearchResultCluster = (o) => {
|
|
189
|
-
return isObject(o)
|
|
190
|
-
&& ((Array.isArray(o.entries)
|
|
191
|
-
&& o.entries.every((v) => isFtSearchResultClusterEntry(v))))
|
|
192
|
-
&& (o.metadataVariableAxis == null || isString(o.metadataVariableAxis));
|
|
193
|
-
};
|
|
194
|
-
export const isFtSearchResultClusterEntry = (o) => {
|
|
195
|
-
return isObject(o)
|
|
196
|
-
&& (o.document == null || isFtSearchResultUnstructuredDocument(o.document))
|
|
197
|
-
&& (o.topic == null || isFtSearchResultTopic(o.topic))
|
|
198
|
-
&& (isFtSearchResultType(o.type))
|
|
199
|
-
&& (o.map == null || isFtSearchResultMap(o.map));
|
|
200
|
-
};
|
|
201
|
-
export const isFtSearchResultUnstructuredDocument = (o) => {
|
|
202
|
-
return isObject(o)
|
|
203
|
-
&& ((Array.isArray(o.metadata)
|
|
204
|
-
&& o.metadata.every((v) => isFtMetadata(v))))
|
|
205
|
-
&& (isFtOpenMode(o.openMode))
|
|
206
|
-
&& (isString(o.documentUrl))
|
|
207
|
-
&& (isString(o.mimeType))
|
|
208
|
-
&& (isString(o.title))
|
|
209
|
-
&& (o.lastPublicationDate == null || isString(o.lastPublicationDate))
|
|
210
|
-
&& (isString(o.viewerUrl))
|
|
211
|
-
&& (isString(o.contentUrl))
|
|
212
|
-
&& (isString(o.filename))
|
|
213
|
-
&& (isString(o.htmlTitle))
|
|
214
|
-
&& (o.originUrl == null || isString(o.originUrl))
|
|
215
|
-
&& (isString(o.documentId))
|
|
216
|
-
&& (isString(o.lastEditionDate))
|
|
217
|
-
&& (isString(o.htmlExcerpt));
|
|
218
|
-
};
|
|
219
|
-
export const isFtSearchResultMap = (o) => {
|
|
220
|
-
return isObject(o)
|
|
221
|
-
&& ((Array.isArray(o.metadata)
|
|
222
|
-
&& o.metadata.every((v) => isFtMetadata(v))))
|
|
223
|
-
&& (isFtOpenMode(o.openMode))
|
|
224
|
-
&& (isFtEditorialType(o.editorialType))
|
|
225
|
-
&& (isString(o.title))
|
|
226
|
-
&& (o.lastPublicationDate == null || isString(o.lastPublicationDate))
|
|
227
|
-
&& (isString(o.htmlTitle))
|
|
228
|
-
&& (o.originUrl == null || isString(o.originUrl))
|
|
229
|
-
&& (isString(o.mapUrl))
|
|
230
|
-
&& (isString(o.readerUrl))
|
|
231
|
-
&& (isString(o.mapId))
|
|
232
|
-
&& (o.lastEditionDate == null || isString(o.lastEditionDate))
|
|
233
|
-
&& (isString(o.htmlExcerpt));
|
|
234
|
-
};
|
|
235
|
-
export const isFtSearchResultTopic = (o) => {
|
|
236
|
-
return isObject(o)
|
|
237
|
-
&& ((Array.isArray(o.metadata)
|
|
238
|
-
&& o.metadata.every((v) => isFtMetadata(v))))
|
|
239
|
-
&& (isFtOpenMode(o.openMode))
|
|
240
|
-
&& (isString(o.contentId))
|
|
241
|
-
&& ((Array.isArray(o.resources)
|
|
242
|
-
&& o.resources.every((v) => isFtTopicResource(v))))
|
|
243
|
-
&& (isString(o.title))
|
|
244
|
-
&& (isString(o.mapTitle))
|
|
245
|
-
&& (isString(o.topicUrl))
|
|
246
|
-
&& (isString(o.contentUrl))
|
|
247
|
-
&& (isString(o.htmlTitle))
|
|
248
|
-
&& ((Array.isArray(o.breadcrumb)
|
|
249
|
-
&& o.breadcrumb.every((v) => isString(v))))
|
|
250
|
-
&& (isString(o.tocId))
|
|
251
|
-
&& (o.originUrl == null || isString(o.originUrl))
|
|
252
|
-
&& (isString(o.readerUrl))
|
|
253
|
-
&& (isString(o.mapId))
|
|
254
|
-
&& (o.lastEditionDate == null || isString(o.lastEditionDate))
|
|
255
|
-
&& (isString(o.htmlExcerpt));
|
|
256
|
-
};
|
|
257
|
-
// From: WsPublicSearchResultType
|
|
258
|
-
export var FtSearchResultType;
|
|
259
|
-
(function (FtSearchResultType) {
|
|
260
|
-
FtSearchResultType["MAP"] = "MAP";
|
|
261
|
-
FtSearchResultType["DOCUMENT"] = "DOCUMENT";
|
|
262
|
-
FtSearchResultType["TOPIC"] = "TOPIC";
|
|
263
|
-
})(FtSearchResultType || (FtSearchResultType = {}));
|
|
264
|
-
export const isFtSearchResultType = (o) => {
|
|
265
|
-
return ["MAP", "DOCUMENT", "TOPIC"].includes(o);
|
|
266
|
-
};
|
|
267
|
-
export const isFtSearchFacet = (o) => {
|
|
268
|
-
return isObject(o)
|
|
269
|
-
&& (isBoolean(o.hierarchical))
|
|
270
|
-
&& (isString(o.label))
|
|
271
|
-
&& (isBoolean(o.multiSelectionable))
|
|
272
|
-
&& (isString(o.key))
|
|
273
|
-
&& ((Array.isArray(o.rootNodes)
|
|
274
|
-
&& o.rootNodes.every((v) => isFtSearchFacetEntry(v))));
|
|
275
|
-
};
|
|
276
|
-
export const isFtSearchFacetConf = (o) => {
|
|
277
|
-
return isObject(o)
|
|
278
|
-
&& (o.maxDepth == null || isNumber(o.maxDepth))
|
|
279
|
-
&& (isString(o.id));
|
|
280
|
-
};
|
|
281
|
-
export const isFtSearchFacetEntry = (o) => {
|
|
282
|
-
return isObject(o)
|
|
283
|
-
&& (isNumber(o.totalResultsCount))
|
|
284
|
-
&& (isBoolean(o.descendantSelected))
|
|
285
|
-
&& ((Array.isArray(o.childNodes)
|
|
286
|
-
&& o.childNodes.every((v) => isFtSearchFacetEntry(v))))
|
|
287
|
-
&& (isString(o.label))
|
|
288
|
-
&& (isString(o.value))
|
|
289
|
-
&& (isBoolean(o.selected));
|
|
290
|
-
};
|
|
291
|
-
export const isFtSearchSortCriterion = (o) => {
|
|
292
|
-
return isObject(o)
|
|
293
|
-
&& (isString(o.key));
|
|
294
|
-
};
|
|
295
|
-
export const isFtSpellcheck = (o) => {
|
|
296
|
-
return isObject(o)
|
|
297
|
-
&& (isString(o.suggestedQuery))
|
|
298
|
-
&& (isString(o.htmlSuggestedQuery));
|
|
299
|
-
};
|
|
300
|
-
export const isFtTopicResource = (o) => {
|
|
301
|
-
return isObject(o)
|
|
302
|
-
&& (isString(o.filename))
|
|
303
|
-
&& (isString(o.resourceUrl))
|
|
304
|
-
&& (isString(o.id))
|
|
305
|
-
&& (isString(o.mimeType))
|
|
306
|
-
&& (isString(o.resourceContentUrl))
|
|
307
|
-
&& (isString(o.viewerUrl));
|
|
308
|
-
};
|
|
309
|
-
export const isFtSuggestRequest = (o) => {
|
|
310
|
-
return isObject(o)
|
|
311
|
-
&& (isString(o.input))
|
|
312
|
-
&& ((Array.isArray(o.filters)
|
|
313
|
-
&& o.filters.every((v) => isFtSearchFilter(v))))
|
|
314
|
-
&& ((Array.isArray(o.sort)
|
|
315
|
-
&& o.sort.every((v) => isFtSearchSortCriterion(v))))
|
|
316
|
-
&& (o.maxCount == null || isNumber(o.maxCount))
|
|
317
|
-
&& (o.contentLocale == null || isString(o.contentLocale));
|
|
318
|
-
};
|
|
319
|
-
export const isFtSuggestResult = (o) => {
|
|
320
|
-
return isObject(o)
|
|
321
|
-
&& (o.filenameExtension == null || isString(o.filenameExtension))
|
|
322
|
-
&& (o.editorialType == null || isFtEditorialType(o.editorialType))
|
|
323
|
-
&& (o.mimeType == null || isString(o.mimeType))
|
|
324
|
-
&& (isFtSearchResultType(o.type))
|
|
325
|
-
&& (isString(o.value));
|
|
326
|
-
};
|
|
327
|
-
export const isFtSuggestResults = (o) => {
|
|
328
|
-
return isObject(o)
|
|
329
|
-
&& ((Array.isArray(o.suggestions)
|
|
330
|
-
&& o.suggestions.every((v) => isFtSuggestResult(v))));
|
|
331
|
-
};
|
|
332
|
-
export const isFtAuthenticationIdentifier = (o) => {
|
|
333
|
-
return isObject(o)
|
|
334
|
-
&& (isString(o.identifier))
|
|
335
|
-
&& (isString(o.realm));
|
|
336
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
const isObject = (o) => typeof o === "object" && o != null;
|
|
2
|
-
const isBoolean = (o) => typeof o === "boolean";
|
|
3
|
-
const isNumber = (o) => typeof o === "number";
|
|
4
|
-
const isString = (o) => typeof o === "string";
|
|
5
|
-
export const isFtAuthenticatedSession = (o) => {
|
|
6
|
-
return isObject(o)
|
|
7
|
-
&& (isFtUserProfile(o.profile));
|
|
8
|
-
};
|
|
9
|
-
export const isFtUserProfile = (o) => {
|
|
10
|
-
return isObject(o)
|
|
11
|
-
&& (o.emailAddress == null || isString(o.emailAddress))
|
|
12
|
-
&& (o.displayName == null || isString(o.displayName))
|
|
13
|
-
&& ((Array.isArray(o.roles)))
|
|
14
|
-
&& (isString(o.userId));
|
|
15
|
-
};
|
|
16
|
-
export const isFtMapAttachment = (o) => {
|
|
17
|
-
return isObject(o)
|
|
18
|
-
&& (isString(o.file))
|
|
19
|
-
&& (o.size == null || isNumber(o.size))
|
|
20
|
-
&& (isBoolean(o.externalLink))
|
|
21
|
-
&& (isString(o.name))
|
|
22
|
-
&& (isString(o.id))
|
|
23
|
-
&& (o.mimeType == null || isString(o.mimeType))
|
|
24
|
-
&& (o.viewerUrl == null || isString(o.viewerUrl));
|
|
25
|
-
};
|