@fluid-topics/public-api 1.0.25 → 1.0.27
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/.yarnrc +1 -0
- package/dist/cjs/index.js +12 -0
- package/dist/cjs/types/ft-common/public.js +9 -10
- package/dist/cjs/types/ft-server/public.js +32 -1
- package/dist/fluidtopics.min.js +1 -1
- package/dist/mjs/index.d.ts +5 -1
- package/dist/mjs/index.js +12 -0
- package/dist/mjs/types/ft-common/public.d.ts +5 -7
- package/dist/mjs/types/ft-common/public.js +7 -8
- package/dist/mjs/types/ft-server/public.d.ts +24 -0
- package/dist/mjs/types/ft-server/public.js +27 -0
- package/package.json +1 -1
package/.yarnrc
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
--frozen-lockfile true
|
package/dist/cjs/index.js
CHANGED
|
@@ -109,6 +109,9 @@ class FluidTopicsApi {
|
|
|
109
109
|
getTableOfContent(mapId) {
|
|
110
110
|
return this.get(`/api/khub/maps/${mapId}/toc`);
|
|
111
111
|
}
|
|
112
|
+
getPages(mapId) {
|
|
113
|
+
return this.get(`/api/khub/maps/${mapId}/pages`);
|
|
114
|
+
}
|
|
112
115
|
getTopic(mapId, topicContentId) {
|
|
113
116
|
return this.get(`/api/khub/maps/${mapId}/topics/${topicContentId}`);
|
|
114
117
|
}
|
|
@@ -160,18 +163,27 @@ class FluidTopicsApi {
|
|
|
160
163
|
unrateMap(mapId) {
|
|
161
164
|
return this.delete(`/api/khub/maps/${mapId}/rating`);
|
|
162
165
|
}
|
|
166
|
+
sendMapFeedback(mapId, message) {
|
|
167
|
+
return this.post(`/api/khub/maps/${mapId}/feedback`, { message });
|
|
168
|
+
}
|
|
163
169
|
rateTopic(mapId, tocId, type, value) {
|
|
164
170
|
return this.post(`/api/khub/maps/${mapId}/topics/${tocId}/rating`, { type, value });
|
|
165
171
|
}
|
|
166
172
|
unrateTopic(mapId, tocId) {
|
|
167
173
|
return this.delete(`/api/khub/maps/${mapId}/topics/${tocId}/rating`);
|
|
168
174
|
}
|
|
175
|
+
sendTopicFeedback(mapId, tocId, message) {
|
|
176
|
+
return this.post(`/api/khub/maps/${mapId}/topics/${tocId}/feedback`, { message });
|
|
177
|
+
}
|
|
169
178
|
rateDocument(docId, type, value) {
|
|
170
179
|
return this.post(`/api/khub/documents/${docId}/rating`, { type, value });
|
|
171
180
|
}
|
|
172
181
|
unrateDocument(docId) {
|
|
173
182
|
return this.delete(`/api/khub/documents/${docId}/rating`);
|
|
174
183
|
}
|
|
184
|
+
sendDocumentFeedback(docId, message) {
|
|
185
|
+
return this.post(`/api/khub/documents/${docId}/feedback`, { message });
|
|
186
|
+
}
|
|
175
187
|
get(endpoint) {
|
|
176
188
|
return this.makeRequest("GET", endpoint);
|
|
177
189
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isFtTopicResource = exports.isFtSpellcheck = exports.isFtSearchSortCriterion = exports.isFtSearchFacetEntry = exports.isFtSearchFacetConf = exports.isFtSearchFacet = exports.isFtSearchResultType = exports.FtSearchResultType = exports.isFtSearchResultTopic = exports.isFtSearchResultMap = exports.isFtSearchResultUnstructuredDocument = exports.isFtSearchResultClusterEntry = exports.isFtSearchResultCluster = exports.isFtSearchRequest = exports.isFtSearchPrior = exports.isFtSearchResults = exports.isFtCollectionDocumentType = exports.FtCollectionDocumentType = exports.isFtPageRequest = exports.isFtOpenMode = exports.FtOpenMode = exports.isFtEditorialType = exports.FtEditorialType = exports.isFtSearchResultsPageInfo = exports.isFtSearchPreset = exports.isFtSearchFilter = exports.isFtSearchPreferencesConfiguration = exports.isFtMetadataPreferenceConfiguration = exports.isFtMapResource = exports.isFtTopicsRatingSummary = exports.isFtTopicRating = exports.isFtRatingSummary = exports.isFtRatingCreation = exports.isFtPublicationRatingSummary = exports.isFtPublicationRating = exports.isFtRatingType = exports.FtRatingType = exports.isFtMetadata = exports.isFtSearchLocales = exports.isFtSearchLocale = exports.
|
|
3
|
+
exports.isFtTopicResource = exports.isFtSpellcheck = exports.isFtSearchSortCriterion = exports.isFtSearchFacetEntry = exports.isFtSearchFacetConf = exports.isFtSearchFacet = exports.isFtSearchResultType = exports.FtSearchResultType = exports.isFtSearchResultTopic = exports.isFtSearchResultMap = exports.isFtSearchResultUnstructuredDocument = exports.isFtSearchResultClusterEntry = exports.isFtSearchResultCluster = exports.isFtSearchRequest = exports.isFtSearchPrior = exports.isFtSearchResults = exports.isFtCollectionDocumentType = exports.FtCollectionDocumentType = exports.isFtPageRequest = exports.isFtOpenMode = exports.FtOpenMode = exports.isFtEditorialType = exports.FtEditorialType = exports.isFtSearchResultsPageInfo = exports.isFtSearchPreset = exports.isFtSearchFilter = exports.isFtSearchPreferencesConfiguration = exports.isFtMetadataPreferenceConfiguration = exports.isFtMapResource = exports.isFtTopicsRatingSummary = exports.isFtTopicRating = exports.isFtRatingSummary = exports.isFtRatingCreation = exports.isFtPublicationRatingSummary = exports.isFtPublicationRating = exports.isFtRatingType = exports.FtRatingType = exports.isFtMetadata = exports.isFtSearchLocales = exports.isFtSearchLocale = exports.isFtFeedbackCreation = exports.isFtTopicContentTarget = exports.FtTopicContentTarget = exports.isFtUnstructuredDocument = exports.isFtTopic = exports.isFtTocNode = exports.isFtMapStyles = exports.isFtMap = exports.isFtCollectionDocument = exports.isFtCredentials = void 0;
|
|
4
4
|
exports.isFtAuthenticationIdentifier = exports.isFtSuggestResults = exports.isFtSuggestResult = exports.isFtSuggestRequest = void 0;
|
|
5
5
|
const isObject = (o) => typeof o === "object" && o != null;
|
|
6
6
|
const isBoolean = (o) => typeof o === "boolean";
|
|
@@ -65,18 +65,9 @@ const isFtTocNode = (o) => {
|
|
|
65
65
|
&& ((Array.isArray(o.children)
|
|
66
66
|
&& o.children.every((v) => (0, exports.isFtTocNode)(v))))
|
|
67
67
|
&& (isString(o.contentId))
|
|
68
|
-
&& (o.page == null || (0, exports.isFtTocPage)(o.page))
|
|
69
68
|
&& (isString(o.title));
|
|
70
69
|
};
|
|
71
70
|
exports.isFtTocNode = isFtTocNode;
|
|
72
|
-
const isFtTocPage = (o) => {
|
|
73
|
-
return isObject(o)
|
|
74
|
-
&& (isBoolean(o.visible))
|
|
75
|
-
&& (isBoolean(o.onItsOwn))
|
|
76
|
-
&& (o.parentsVisibility == null || (Array.isArray(o.parentsVisibility)
|
|
77
|
-
&& o.parentsVisibility.every((v) => isBoolean(v))));
|
|
78
|
-
};
|
|
79
|
-
exports.isFtTocPage = isFtTocPage;
|
|
80
71
|
const isFtTopic = (o) => {
|
|
81
72
|
return isObject(o)
|
|
82
73
|
&& ((Array.isArray(o.metadata)
|
|
@@ -123,6 +114,11 @@ const isFtTopicContentTarget = (o) => {
|
|
|
123
114
|
return ["THIRD_PARTY", "OFF_THE_GRID", "CONTENT_PACKAGER", "PAGES", "DESIGNED_READER"].includes(o);
|
|
124
115
|
};
|
|
125
116
|
exports.isFtTopicContentTarget = isFtTopicContentTarget;
|
|
117
|
+
const isFtFeedbackCreation = (o) => {
|
|
118
|
+
return isObject(o)
|
|
119
|
+
&& (isString(o.message));
|
|
120
|
+
};
|
|
121
|
+
exports.isFtFeedbackCreation = isFtFeedbackCreation;
|
|
126
122
|
const isFtSearchLocale = (o) => {
|
|
127
123
|
return isObject(o)
|
|
128
124
|
&& (isNumber(o.count))
|
|
@@ -140,6 +136,9 @@ const isFtMetadata = (o) => {
|
|
|
140
136
|
return isObject(o)
|
|
141
137
|
&& ((Array.isArray(o.values)
|
|
142
138
|
&& o.values.every((v) => isString(v))))
|
|
139
|
+
&& (o.hierarchicalValues == null || (Array.isArray(o.hierarchicalValues)
|
|
140
|
+
&& o.hierarchicalValues.every((v) => (Array.isArray(v)
|
|
141
|
+
&& v.every((v) => isString(v))))))
|
|
143
142
|
&& (isString(o.label))
|
|
144
143
|
&& (isString(o.key));
|
|
145
144
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isFtMapAttachment = exports.isFtUserProfile = exports.isFtSession = exports.isFtAuthenticatedSession = void 0;
|
|
3
|
+
exports.isFtPaginationConfiguration = exports.isFtPaginatedTocNode = exports.isFtPaginatedToc = exports.isFtPageConfiguration = exports.isFtMapAttachment = exports.isFtUserProfile = exports.isFtSession = exports.isFtAuthenticatedSession = 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";
|
|
@@ -36,3 +36,34 @@ const isFtMapAttachment = (o) => {
|
|
|
36
36
|
&& (o.viewerUrl == null || isString(o.viewerUrl));
|
|
37
37
|
};
|
|
38
38
|
exports.isFtMapAttachment = isFtMapAttachment;
|
|
39
|
+
const isFtPageConfiguration = (o) => {
|
|
40
|
+
return isObject(o)
|
|
41
|
+
&& (o.parentsVisibility == null || (Array.isArray(o.parentsVisibility)
|
|
42
|
+
&& o.parentsVisibility.every((v) => isBoolean(v))))
|
|
43
|
+
&& (isBoolean(o.isVisible));
|
|
44
|
+
};
|
|
45
|
+
exports.isFtPageConfiguration = isFtPageConfiguration;
|
|
46
|
+
const isFtPaginatedToc = (o) => {
|
|
47
|
+
return isObject(o)
|
|
48
|
+
&& ((0, exports.isFtPaginationConfiguration)(o.configuration))
|
|
49
|
+
&& ((Array.isArray(o.paginatedToc)
|
|
50
|
+
&& o.paginatedToc.every((v) => (0, exports.isFtPaginatedTocNode)(v))));
|
|
51
|
+
};
|
|
52
|
+
exports.isFtPaginatedToc = isFtPaginatedToc;
|
|
53
|
+
const isFtPaginatedTocNode = (o) => {
|
|
54
|
+
return isObject(o)
|
|
55
|
+
&& (o.prettyUrl == null || isString(o.prettyUrl))
|
|
56
|
+
&& (o.pageToc == null || (Array.isArray(o.pageToc)))
|
|
57
|
+
&& (o.tocId == null || isString(o.tocId))
|
|
58
|
+
&& ((Array.isArray(o.children)
|
|
59
|
+
&& o.children.every((v) => (0, exports.isFtPaginatedTocNode)(v))))
|
|
60
|
+
&& (o.pageConfiguration == null || (0, exports.isFtPageConfiguration)(o.pageConfiguration))
|
|
61
|
+
&& (o.contentId == null || isString(o.contentId))
|
|
62
|
+
&& (o.title == null || isString(o.title));
|
|
63
|
+
};
|
|
64
|
+
exports.isFtPaginatedTocNode = isFtPaginatedTocNode;
|
|
65
|
+
const isFtPaginationConfiguration = (o) => {
|
|
66
|
+
return isObject(o)
|
|
67
|
+
&& (isBoolean(o.splitCurrentPageToc));
|
|
68
|
+
};
|
|
69
|
+
exports.isFtPaginationConfiguration = isFtPaginationConfiguration;
|
package/dist/fluidtopics.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).fluidtopics={})}(this,(function(e){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},r={exports:{}},a={exports:{}};!function(e,t){var r=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==r)return r;throw new Error("unable to locate global object")}();e.exports=t=r.fetch,r.fetch&&(t.default=r.fetch.bind(r)),t.Headers=r.Headers,t.Request=r.Request,t.Response=r.Response}(a,a.exports),function(e,t){const r=a.exports,i=r.default||r,n=function(e,t){return/^\/\//.test(e)&&(e="https:"+e),i.call(this,e,t)};n.ponyfill=!0,e.exports=t=n,t.fetch=n,t.Headers=r.Headers,t.Request=r.Request,t.Response=r.Response,t.default=n}(r,r.exports);const i=r.exports,n=i.fetch.bind({});n.polyfill=!0,t.fetch||(t.fetch=n,t.Response=i.Response,t.Headers=i.Headers,t.Request=i.Request);const s=e=>"object"==typeof e&&null!=e,l=e=>"boolean"==typeof e,o=e=>"number"==typeof e,u=e=>"string"==typeof e,c=e=>s(e)&&u(e.topicStylesheetUrl)&&u(e.titleStylesheetUrl)&&Array.isArray(e.customCssClasses)&&e.customCssClasses.every((e=>u(e))),p=e=>s(e)&&(null==e.prettyUrl||u(e.prettyUrl))&&u(e.tocId)&&Array.isArray(e.children)&&e.children.every((e=>p(e)))&&u(e.contentId)&&(null==e.page||d(e.page))&&u(e.title),d=e=>s(e)&&l(e.visible)&&l(e.onItsOwn)&&(null==e.parentsVisibility||Array.isArray(e.parentsVisibility)&&e.parentsVisibility.every((e=>l(e))));var h;e.FtTopicContentTarget=void 0,(h=e.FtTopicContentTarget||(e.FtTopicContentTarget={})).THIRD_PARTY="THIRD_PARTY",h.OFF_THE_GRID="OFF_THE_GRID",h.CONTENT_PACKAGER="CONTENT_PACKAGER",h.PAGES="PAGES",h.DESIGNED_READER="DESIGNED_READER";const y=e=>s(e)&&o(e.count)&&u(e.label)&&(null==e.lang||u(e.lang)),g=e=>s(e)&&Array.isArray(e.values)&&e.values.every((e=>u(e)))&&u(e.label)&&u(e.key);var f;e.FtRatingType=void 0,(f=e.FtRatingType||(e.FtRatingType={})).STARS="STARS",f.LIKE="LIKE",f.DICHOTOMOUS="DICHOTOMOUS",f.NO_RATING="NO_RATING";const m=e=>["STARS","LIKE","DICHOTOMOUS","NO_RATING"].includes(e),A=e=>s(e)&&u(e.date)&&m(e.type)&&o(e.value),T=e=>s(e)&&(null==e.rating||A(e.rating))&&m(e.type),b=e=>s(e)&&u(e.date)&&u(e.tocId)&&m(e.type)&&o(e.value),R=e=>s(e)&&Array.isArray(e.ratings)&&e.ratings.every((e=>b(e)))&&m(e.type),S=e=>s(e)&&Array.isArray(e.filter)&&e.filter.every((e=>u(e)))&&Array.isArray(e.prior)&&e.prior.every((e=>u(e))),F=e=>s(e)&&l(e.negative)&&Array.isArray(e.values)&&e.values.every((e=>u(e)))&&u(e.key),v=e=>s(e)&&o(e.totalResultsCount)&&l(e.lastPage)&&o(e.currentPage)&&o(e.totalClustersCount);var E;e.FtEditorialType=void 0,(E=e.FtEditorialType||(e.FtEditorialType={})).ARTICLE="ARTICLE",E.BOOK="BOOK";const C=e=>["ARTICLE","BOOK"].includes(e);var U;e.FtOpenMode=void 0,(U=e.FtOpenMode||(e.FtOpenMode={})).FLUIDTOPICS="FLUIDTOPICS",U.EXTERNAL="EXTERNAL";const O=e=>["FLUIDTOPICS","EXTERNAL"].includes(e),D=e=>s(e)&&(null==e.perPage||o(e.perPage))&&o(e.page);var P;e.FtCollectionDocumentType=void 0,(P=e.FtCollectionDocumentType||(e.FtCollectionDocumentType={})).MAP="MAP",P.DOCUMENT="DOCUMENT",P.TOPIC="TOPIC",P.PERSONAL_BOOK="PERSONAL_BOOK",P.SHARED_BOOK="SHARED_BOOK";const I=e=>["MAP","DOCUMENT","TOPIC","PERSONAL_BOOK","SHARED_BOOK"].includes(e),w=e=>s(e)&&o(e.weight)&&u(e.value)&&u(e.key),M=e=>s(e)&&Array.isArray(e.entries)&&e.entries.every((e=>k(e)))&&(null==e.metadataVariableAxis||u(e.metadataVariableAxis)),k=e=>s(e)&&(null==e.document||L(e.document))&&(null==e.topic||$(e.topic))&&_(e.type)&&(null==e.map||N(e.map)),L=e=>s(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>g(e)))&&O(e.openMode)&&u(e.documentUrl)&&u(e.mimeType)&&u(e.title)&&(null==e.lastPublicationDate||u(e.lastPublicationDate))&&u(e.viewerUrl)&&u(e.contentUrl)&&u(e.filename)&&u(e.htmlTitle)&&(null==e.originUrl||u(e.originUrl))&&u(e.documentId)&&u(e.lastEditionDate)&&u(e.htmlExcerpt),N=e=>s(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>g(e)))&&(null==e.openMode||O(e.openMode))&&C(e.editorialType)&&u(e.title)&&(null==e.lastPublicationDate||u(e.lastPublicationDate))&&u(e.htmlTitle)&&(null==e.originUrl||u(e.originUrl))&&u(e.mapUrl)&&u(e.readerUrl)&&u(e.mapId)&&(null==e.lastEditionDate||u(e.lastEditionDate))&&u(e.htmlExcerpt),$=e=>s(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>g(e)))&&O(e.openMode)&&u(e.contentId)&&Array.isArray(e.resources)&&e.resources.every((e=>j(e)))&&u(e.title)&&u(e.mapTitle)&&u(e.topicUrl)&&u(e.contentUrl)&&u(e.htmlTitle)&&Array.isArray(e.breadcrumb)&&e.breadcrumb.every((e=>u(e)))&&u(e.tocId)&&(null==e.originUrl||u(e.originUrl))&&u(e.readerUrl)&&u(e.mapId)&&(null==e.lastEditionDate||u(e.lastEditionDate))&&u(e.htmlExcerpt);var x;e.FtSearchResultType=void 0,(x=e.FtSearchResultType||(e.FtSearchResultType={})).MAP="MAP",x.DOCUMENT="DOCUMENT",x.TOPIC="TOPIC";const _=e=>["MAP","DOCUMENT","TOPIC"].includes(e),H=e=>s(e)&&l(e.hierarchical)&&u(e.label)&&l(e.multiSelectionable)&&u(e.key)&&Array.isArray(e.rootNodes)&&e.rootNodes.every((e=>q(e))),B=e=>s(e)&&(null==e.maxDepth||o(e.maxDepth))&&u(e.id),q=e=>s(e)&&o(e.totalResultsCount)&&l(e.descendantSelected)&&Array.isArray(e.childNodes)&&e.childNodes.every((e=>q(e)))&&u(e.label)&&u(e.value)&&l(e.selected),G=e=>s(e)&&u(e.key),K=e=>s(e)&&u(e.suggestedQuery)&&u(e.htmlSuggestedQuery),j=e=>s(e)&&u(e.filename)&&u(e.resourceUrl)&&u(e.id)&&u(e.mimeType)&&u(e.resourceContentUrl)&&u(e.viewerUrl),V=e=>s(e)&&(null==e.filenameExtension||u(e.filenameExtension))&&(null==e.editorialType||C(e.editorialType))&&(null==e.mimeType||u(e.mimeType))&&_(e.type)&&u(e.value),z=e=>"object"==typeof e&&null!=e,J=e=>"boolean"==typeof e,X=e=>"number"==typeof e,Y=e=>"string"==typeof e,Q=e=>z(e)&&(null==e.emailAddress||Y(e.emailAddress))&&(null==e.displayName||Y(e.displayName))&&Array.isArray(e.roles)&&Y(e.userId),W="undefined"==typeof window?globalThis:window;function Z(e){let t={};for(let r in e){let a=e[r];("object"!=typeof a||Array.isArray(a))&&(a={prior:a});for(let e of["prior","filter"])a[e]=Array.isArray(a[e])?a[e]:[a[e]],a[e]=a[e].map((e=>null!=e?""+e:"")).filter((e=>""!==e));t[r]=a}return t}function ee(e){return`${e}-FluidTopicsUnauthenticatedUserSearchPreferences`}const te="undefined"==typeof window?globalThis:window;class re extends Error{status;statusText;body;constructor(e,t,r){super(`${e} - ${t}: ${r}`),this.status=e,this.statusText=t,this.body=r}}async function ae(e){if(!e.ok)throw new re(e.status,e.statusText,await e.text());return e}function ie(e){return"application/json"===e.headers.get("Content-Type")?e.json():e.text()}class ne{tenantBaseUrl;ftCallingApp;authorization={};searchLabel;get defaultHeaders(){return{...this.authorization,...this.searchLabel,"Ft-Calling-App":this.ftCallingApp}}constructor(e,t,r){e=e??te.__gwt_ft_moduleBase??te.fluidtopicsclient?.__moduleBase??te.__gwt_activeModules?.fluidtopicsclient?.moduleBase,this.tenantBaseUrl=e.trim().replace(/\/$/,""),r&&void 0!==te.location&&te.location.href.startsWith(this.tenantBaseUrl+"/")?this.ftCallingApp=t:this.ftCallingApp=`ft-public-api/${t}`}setApiKey(e){this.authorization={Authorization:"Bearer "+e}}setCredentials(e,t){var r;this.authorization={Authorization:"Basic "+(r=`${e}:${t}`,"undefined"!=typeof Buffer?Buffer.from(r).toString("base64"):btoa(r))}}clearAuthentication(){this.authorization=void 0}setSearchLabel(e){this.searchLabel={"FT-search-label":e}}clearSearchLabel(){this.searchLabel=void 0}login(e,t){let r={login:e,password:t,rememberMe:!0};return this.post("/api/authentication/login",r).then((r=>(this.setCredentials(e,t),r)))}logout(){return this.post("/api/authentication/logout").then((()=>this.clearAuthentication()))}getCurrentSession(){return this.get("/api/authentication/current-session")}getMap(e){return this.get(`/api/khub/maps/${e}`)}getTableOfContent(e){return this.get(`/api/khub/maps/${e}/toc`)}getTopic(e,t){return this.get(`/api/khub/maps/${e}/topics/${t}`)}getTopicHTMLContent(e,t,r){return this.get(`/api/khub/maps/${e}/topics/${t}/content${r?"?target="+r:""}`)}getMapAttachments(e){return this.get(`/api/khub/maps/${e}/attachments`)}getMapAttachmentContent(e,t){return this.fetchRawData(`/api/khub/maps/${e}/attachments/${t}/content`)}getMapResources(e){return this.get(`/api/khub/maps/${e}/resources`)}getMapResourceContent(e,t){return this.fetchRawData(`/api/khub/maps/${e}/resources/${t}/content`)}getUnstructuredDocument(e){return this.get(`/api/khub/documents/${e}`)}getUnstructuredDocumentContent(e){return this.fetchRawData(`/api/khub/documents/${e}/content`)}getUnstructuredDocumentTextContent(e){return this.get(`/api/khub/documents/${e}/content/text`)}getCollectionDocuments(e,t){return this.get(`/api/users/${e}/collections/${t}/documents`)}getSuggestions(e){return this.post("/api/khub/suggest",e)}search(e){return this.post("/api/khub/clustered-search",e)}getAvailableSearchLocales(){return this.get("/api/khub/locales")}getMapRating(e){return this.get(`/api/khub/maps/${e}/rating`)}getDocumentRating(e){return this.get(`/api/khub/documents/${e}/rating`)}rateMap(e,t,r){return this.post(`/api/khub/maps/${e}/rating`,{type:t,value:r})}unrateMap(e){return this.delete(`/api/khub/maps/${e}/rating`)}rateTopic(e,t,r,a){return this.post(`/api/khub/maps/${e}/topics/${t}/rating`,{type:r,value:a})}unrateTopic(e,t){return this.delete(`/api/khub/maps/${e}/topics/${t}/rating`)}rateDocument(e,t,r){return this.post(`/api/khub/documents/${e}/rating`,{type:t,value:r})}unrateDocument(e){return this.delete(`/api/khub/documents/${e}/rating`)}get(e){return this.makeRequest("GET",e)}post(e,t){return this.makeRequest("POST",e,t)}put(e,t){return this.makeRequest("PUT",e,t)}delete(e){return this.makeRequest("DELETE",e)}async fetch(e,t){const r=t;return e.startsWith("/")||(e="/"+e),await fetch(this.tenantBaseUrl+e,{...r??{},headers:{...this.defaultHeaders,...r?.headers??{}}})}async upload(e,t,r,a=(()=>{})){return new Promise(((i,n)=>{let s=new XMLHttpRequest;s.onload=()=>{if(s.status>=200&&s.status<300){let e="application/json"===s.getResponseHeader("Content-Type")?JSON.parse(s.responseText):s.responseText;i(e)}else n(new re(s.status,s.statusText,s.responseText))},s.upload.onprogress=e=>a(e),s.open(e,this.tenantBaseUrl+t,!0),s.send(r)}))}makeRequest(e,t,r){return this.fetch(t,{method:e,headers:{...null!=r?{"Content-Type":"application/json"}:{}},body:null!=r?JSON.stringify(r):void 0}).then(ae).then(ie)}fetchRawData(e){return fetch(this.tenantBaseUrl+e,{headers:this.defaultHeaders}).then(ae).then((e=>e.arrayBuffer()))}}e.FluidTopicsApi=ne,e.HttpError=re,e.addUnauthenticatedUserSearchPreferencesChangeHandler=function(e,t){if(W.localStorage){const r=ee(e),a=e=>{e.storageArea===W.localStorage&&e.key===r&&t(JSON.parse(e.newValue??"{}"))};return W.addEventListener("storage",a),{removeHandler:()=>W.removeEventListener("storage",a)}}console.error("Cannot handle unauthenticated preferences: local storage is unavailable.")},e.default=ne,e.getUnauthenticatedUserSearchPreferences=function(e){if(W.localStorage)return JSON.parse(W.localStorage.getItem(ee(e))??"{}");console.error("Cannot get unauthenticated preferences: local storage is unavailable.")},e.isFtAuthenticatedSession=e=>z(e)&&Q(e.profile),e.isFtAuthenticationIdentifier=e=>s(e)&&u(e.identifier)&&u(e.realm),e.isFtCollectionDocument=e=>s(e)&&l(e.deleted)&&(null==e.apiUrl||u(e.apiUrl))&&(null==e.portalUrl||u(e.portalUrl))&&u(e.id)&&u(e.title)&&I(e.type),e.isFtCollectionDocumentType=I,e.isFtCredentials=e=>s(e)&&u(e.password)&&(null==e.newPassword||u(e.newPassword))&&l(e.rememberMe)&&u(e.login),e.isFtEditorialType=C,e.isFtMap=e=>s(e)&&(null==e.prettyUrl||u(e.prettyUrl))&&Array.isArray(e.metadata)&&e.metadata.every((e=>g(e)))&&O(e.openMode)&&u(e.topicsApiEndpoint)&&(null==e.description||u(e.description))&&u(e.attachmentsApiEndpoint)&&C(e.editorialType)&&u(e.baseId)&&u(e.clusterId)&&(null==e.shouldSplitCurrentPageToc||l(e.shouldSplitCurrentPageToc))&&u(e.title)&&u(e.lastPublication)&&u(e.lastEdition)&&u(e.originId)&&u(e.rightsApiEndpoint)&&c(e.contentStyles)&&(null==e.originUrl||u(e.originUrl))&&u(e.readerUrl)&&(null==e.khubVersion||u(e.khubVersion))&&u(e.id)&&(null==e.lang||u(e.lang)),e.isFtMapAttachment=e=>z(e)&&Y(e.file)&&(null==e.size||X(e.size))&&J(e.externalLink)&&Y(e.name)&&Y(e.id)&&(null==e.mimeType||Y(e.mimeType))&&(null==e.viewerUrl||Y(e.viewerUrl)),e.isFtMapResource=e=>s(e)&&u(e.contentUrl)&&u(e.filename)&&u(e.id)&&u(e.mimeType),e.isFtMapStyles=c,e.isFtMetadata=g,e.isFtMetadataPreferenceConfiguration=S,e.isFtOpenMode=O,e.isFtPageRequest=D,e.isFtPublicationRating=A,e.isFtPublicationRatingSummary=T,e.isFtRatingCreation=e=>s(e)&&m(e.type)&&o(e.value),e.isFtRatingSummary=e=>s(e)&&(null==e.topics||R(e.topics))&&T(e.publication),e.isFtRatingType=m,e.isFtSearchFacet=H,e.isFtSearchFacetConf=B,e.isFtSearchFacetEntry=q,e.isFtSearchFilter=F,e.isFtSearchLocale=y,e.isFtSearchLocales=e=>s(e)&&Array.isArray(e.contentLocales)&&e.contentLocales.every((e=>y(e))),e.isFtSearchPreferencesConfiguration=e=>s(e)&&s(e.metadata)&&Object.keys(e.metadata).every((e=>u(e)))&&Object.values(e.metadata).every((e=>S(e))),e.isFtSearchPreset=e=>s(e)&&u(e.name)&&Array.isArray(e.filters)&&e.filters.every((e=>F(e)))&&o(e.priority)&&(null==e.contentLocale||u(e.contentLocale)),e.isFtSearchPrior=w,e.isFtSearchRequest=e=>s(e)&&u(e.query)&&D(e.paging)&&Array.isArray(e.filters)&&e.filters.every((e=>F(e)))&&Array.isArray(e.sort)&&e.sort.every((e=>G(e)))&&(null==e.uiLocale||u(e.uiLocale))&&(null==e.contentLocale||u(e.contentLocale))&&(null==e.priors||Array.isArray(e.priors)&&e.priors.every((e=>w(e))))&&Array.isArray(e.facets)&&e.facets.every((e=>B(e))),e.isFtSearchResultCluster=M,e.isFtSearchResultClusterEntry=k,e.isFtSearchResultMap=N,e.isFtSearchResultTopic=$,e.isFtSearchResultType=_,e.isFtSearchResultUnstructuredDocument=L,e.isFtSearchResults=e=>s(e)&&(null==e.spellcheck||K(e.spellcheck))&&v(e.paging)&&Array.isArray(e.results)&&e.results.every((e=>M(e)))&&Array.isArray(e.facets)&&e.facets.every((e=>H(e))),e.isFtSearchResultsPageInfo=v,e.isFtSearchSortCriterion=G,e.isFtSession=e=>z(e)&&X(e.idleTimeoutInMillis)&&(null==e.profile||Q(e.profile))&&J(e.sessionAuthenticated),e.isFtSpellcheck=K,e.isFtSuggestRequest=e=>s(e)&&u(e.input)&&Array.isArray(e.filters)&&e.filters.every((e=>F(e)))&&Array.isArray(e.sort)&&e.sort.every((e=>G(e)))&&(null==e.maxCount||o(e.maxCount))&&(null==e.contentLocale||u(e.contentLocale)),e.isFtSuggestResult=V,e.isFtSuggestResults=e=>s(e)&&Array.isArray(e.suggestions)&&e.suggestions.every((e=>V(e))),e.isFtTocNode=p,e.isFtTocPage=d,e.isFtTopic=e=>s(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>g(e)))&&u(e.id)&&u(e.contentApiEndpoint)&&u(e.title),e.isFtTopicContentTarget=e=>["THIRD_PARTY","OFF_THE_GRID","CONTENT_PACKAGER","PAGES","DESIGNED_READER"].includes(e),e.isFtTopicRating=b,e.isFtTopicResource=j,e.isFtTopicsRatingSummary=R,e.isFtUnstructuredDocument=e=>s(e)&&(null==e.prettyUrl||u(e.prettyUrl))&&Array.isArray(e.metadata)&&e.metadata.every((e=>g(e)))&&u(e.openMode)&&(null==e.description||u(e.description))&&u(e.mimeType)&&(null==e.baseId||u(e.baseId))&&(null==e.clusterId||u(e.clusterId))&&u(e.contentApiEndpoint)&&u(e.title)&&(null==e.lastPublication||u(e.lastPublication))&&u(e.viewerUrl)&&u(e.lastEdition)&&u(e.filename)&&(null==e.originId||u(e.originId))&&u(e.rightsApiEndpoint)&&(null==e.originUrl||u(e.originUrl))&&(null==e.khubVersion||u(e.khubVersion))&&u(e.id)&&(null==e.lang||u(e.lang)),e.isFtUserProfile=Q,e.setUnauthenticatedUserSearchPreferences=function(e,t){if(W.localStorage){let r={...t,metadata:Z(t.metadata??{})};const a=ee(e),i=JSON.stringify(r);return W.localStorage.setItem(a,i),W.dispatchEvent(new StorageEvent("storage",{key:a,newValue:i,storageArea:W.localStorage,url:W.location.href})),r}console.error("Cannot set unauthenticated preferences: local storage is unavailable.")}}));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).fluidtopics={})}(this,(function(e){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},r={exports:{}},a={exports:{}};!function(e,t){var r=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==r)return r;throw new Error("unable to locate global object")}();e.exports=t=r.fetch,r.fetch&&(t.default=r.fetch.bind(r)),t.Headers=r.Headers,t.Request=r.Request,t.Response=r.Response}(a,a.exports),function(e,t){const r=a.exports,i=r.default||r,n=function(e,t){return/^\/\//.test(e)&&(e="https:"+e),i.call(this,e,t)};n.ponyfill=!0,e.exports=t=n,t.fetch=n,t.Headers=r.Headers,t.Request=r.Request,t.Response=r.Response,t.default=n}(r,r.exports);const i=r.exports,n=i.fetch.bind({});n.polyfill=!0,t.fetch||(t.fetch=n,t.Response=i.Response,t.Headers=i.Headers,t.Request=i.Request);const s=e=>"object"==typeof e&&null!=e,l=e=>"boolean"==typeof e,o=e=>"number"==typeof e,u=e=>"string"==typeof e,c=e=>s(e)&&u(e.topicStylesheetUrl)&&u(e.titleStylesheetUrl)&&Array.isArray(e.customCssClasses)&&e.customCssClasses.every((e=>u(e))),p=e=>s(e)&&(null==e.prettyUrl||u(e.prettyUrl))&&u(e.tocId)&&Array.isArray(e.children)&&e.children.every((e=>p(e)))&&u(e.contentId)&&u(e.title);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)))&&(null==e.hierarchicalValues||Array.isArray(e.hierarchicalValues)&&e.hierarchicalValues.every((e=>Array.isArray(e)&&e.every((e=>u(e))))))&&u(e.label)&&u(e.key);var g;e.FtRatingType=void 0,(g=e.FtRatingType||(e.FtRatingType={})).STARS="STARS",g.LIKE="LIKE",g.DICHOTOMOUS="DICHOTOMOUS",g.NO_RATING="NO_RATING";const f=e=>["STARS","LIKE","DICHOTOMOUS","NO_RATING"].includes(e),m=e=>s(e)&&u(e.date)&&f(e.type)&&o(e.value),A=e=>s(e)&&(null==e.rating||m(e.rating))&&f(e.type),T=e=>s(e)&&u(e.date)&&u(e.tocId)&&f(e.type)&&o(e.value),b=e=>s(e)&&Array.isArray(e.ratings)&&e.ratings.every((e=>T(e)))&&f(e.type),F=e=>s(e)&&Array.isArray(e.filter)&&e.filter.every((e=>u(e)))&&Array.isArray(e.prior)&&e.prior.every((e=>u(e))),R=e=>s(e)&&l(e.negative)&&Array.isArray(e.values)&&e.values.every((e=>u(e)))&&u(e.key),S=e=>s(e)&&o(e.totalResultsCount)&&l(e.lastPage)&&o(e.currentPage)&&o(e.totalClustersCount);var v;e.FtEditorialType=void 0,(v=e.FtEditorialType||(e.FtEditorialType={})).ARTICLE="ARTICLE",v.BOOK="BOOK";const C=e=>["ARTICLE","BOOK"].includes(e);var E;e.FtOpenMode=void 0,(E=e.FtOpenMode||(e.FtOpenMode={})).FLUIDTOPICS="FLUIDTOPICS",E.EXTERNAL="EXTERNAL";const U=e=>["FLUIDTOPICS","EXTERNAL"].includes(e),O=e=>s(e)&&(null==e.perPage||o(e.perPage))&&o(e.page);var P;e.FtCollectionDocumentType=void 0,(P=e.FtCollectionDocumentType||(e.FtCollectionDocumentType={})).MAP="MAP",P.DOCUMENT="DOCUMENT",P.TOPIC="TOPIC",P.PERSONAL_BOOK="PERSONAL_BOOK",P.SHARED_BOOK="SHARED_BOOK";const D=e=>["MAP","DOCUMENT","TOPIC","PERSONAL_BOOK","SHARED_BOOK"].includes(e),I=e=>s(e)&&o(e.weight)&&u(e.value)&&u(e.key),k=e=>s(e)&&Array.isArray(e.entries)&&e.entries.every((e=>M(e)))&&(null==e.metadataVariableAxis||u(e.metadataVariableAxis)),M=e=>s(e)&&(null==e.document||w(e.document))&&(null==e.topic||L(e.topic))&&x(e.type)&&(null==e.map||$(e.map)),w=e=>s(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>y(e)))&&U(e.openMode)&&u(e.documentUrl)&&u(e.mimeType)&&u(e.title)&&(null==e.lastPublicationDate||u(e.lastPublicationDate))&&u(e.viewerUrl)&&u(e.contentUrl)&&u(e.filename)&&u(e.htmlTitle)&&(null==e.originUrl||u(e.originUrl))&&u(e.documentId)&&u(e.lastEditionDate)&&u(e.htmlExcerpt),$=e=>s(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>y(e)))&&(null==e.openMode||U(e.openMode))&&C(e.editorialType)&&u(e.title)&&(null==e.lastPublicationDate||u(e.lastPublicationDate))&&u(e.htmlTitle)&&(null==e.originUrl||u(e.originUrl))&&u(e.mapUrl)&&u(e.readerUrl)&&u(e.mapId)&&(null==e.lastEditionDate||u(e.lastEditionDate))&&u(e.htmlExcerpt),L=e=>s(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>y(e)))&&U(e.openMode)&&u(e.contentId)&&Array.isArray(e.resources)&&e.resources.every((e=>K(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 N;e.FtSearchResultType=void 0,(N=e.FtSearchResultType||(e.FtSearchResultType={})).MAP="MAP",N.DOCUMENT="DOCUMENT",N.TOPIC="TOPIC";const x=e=>["MAP","DOCUMENT","TOPIC"].includes(e),_=e=>s(e)&&l(e.hierarchical)&&u(e.label)&&l(e.multiSelectionable)&&u(e.key)&&Array.isArray(e.rootNodes)&&e.rootNodes.every((e=>B(e))),H=e=>s(e)&&(null==e.maxDepth||o(e.maxDepth))&&u(e.id),B=e=>s(e)&&o(e.totalResultsCount)&&l(e.descendantSelected)&&Array.isArray(e.childNodes)&&e.childNodes.every((e=>B(e)))&&u(e.label)&&u(e.value)&&l(e.selected),q=e=>s(e)&&u(e.key),G=e=>s(e)&&u(e.suggestedQuery)&&u(e.htmlSuggestedQuery),K=e=>s(e)&&u(e.filename)&&u(e.resourceUrl)&&u(e.id)&&u(e.mimeType)&&u(e.resourceContentUrl)&&u(e.viewerUrl),V=e=>s(e)&&(null==e.filenameExtension||u(e.filenameExtension))&&(null==e.editorialType||C(e.editorialType))&&(null==e.mimeType||u(e.mimeType))&&x(e.type)&&u(e.value),j=e=>"object"==typeof e&&null!=e,z=e=>"boolean"==typeof e,J=e=>"number"==typeof e,X=e=>"string"==typeof e,Y=e=>j(e)&&(null==e.emailAddress||X(e.emailAddress))&&(null==e.displayName||X(e.displayName))&&Array.isArray(e.roles)&&X(e.userId),Q=e=>j(e)&&(null==e.parentsVisibility||Array.isArray(e.parentsVisibility)&&e.parentsVisibility.every((e=>z(e))))&&z(e.isVisible),W=e=>j(e)&&(null==e.prettyUrl||X(e.prettyUrl))&&(null==e.pageToc||Array.isArray(e.pageToc))&&(null==e.tocId||X(e.tocId))&&Array.isArray(e.children)&&e.children.every((e=>W(e)))&&(null==e.pageConfiguration||Q(e.pageConfiguration))&&(null==e.contentId||X(e.contentId))&&(null==e.title||X(e.title)),Z=e=>j(e)&&z(e.splitCurrentPageToc),ee="undefined"==typeof window?globalThis:window;function te(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 re(e){return`${e}-FluidTopicsUnauthenticatedUserSearchPreferences`}const ae="undefined"==typeof window?globalThis:window;class ie extends Error{status;statusText;body;constructor(e,t,r){super(`${e} - ${t}: ${r}`),this.status=e,this.statusText=t,this.body=r}}async function ne(e){if(!e.ok)throw new ie(e.status,e.statusText,await e.text());return e}function se(e){return"application/json"===e.headers.get("Content-Type")?e.json():e.text()}class le{tenantBaseUrl;ftCallingApp;authorization={};searchLabel;get defaultHeaders(){return{...this.authorization,...this.searchLabel,"Ft-Calling-App":this.ftCallingApp}}constructor(e,t,r){e=e??ae.__gwt_ft_moduleBase??ae.fluidtopicsclient?.__moduleBase??ae.__gwt_activeModules?.fluidtopicsclient?.moduleBase,this.tenantBaseUrl=e.trim().replace(/\/$/,""),r&&void 0!==ae.location&&ae.location.href.startsWith(this.tenantBaseUrl+"/")?this.ftCallingApp=t:this.ftCallingApp=`ft-public-api/${t}`}setApiKey(e){this.authorization={Authorization:"Bearer "+e}}setCredentials(e,t){var r;this.authorization={Authorization:"Basic "+(r=`${e}:${t}`,"undefined"!=typeof Buffer?Buffer.from(r).toString("base64"):btoa(r))}}clearAuthentication(){this.authorization=void 0}setSearchLabel(e){this.searchLabel={"FT-search-label":e}}clearSearchLabel(){this.searchLabel=void 0}login(e,t){let r={login:e,password:t,rememberMe:!0};return this.post("/api/authentication/login",r).then((r=>(this.setCredentials(e,t),r)))}logout(){return this.post("/api/authentication/logout").then((()=>this.clearAuthentication()))}getCurrentSession(){return this.get("/api/authentication/current-session")}getMap(e){return this.get(`/api/khub/maps/${e}`)}getTableOfContent(e){return this.get(`/api/khub/maps/${e}/toc`)}getPages(e){return this.get(`/api/khub/maps/${e}/pages`)}getTopic(e,t){return this.get(`/api/khub/maps/${e}/topics/${t}`)}getTopicHTMLContent(e,t,r){return this.get(`/api/khub/maps/${e}/topics/${t}/content${r?"?target="+r:""}`)}getMapAttachments(e){return this.get(`/api/khub/maps/${e}/attachments`)}getMapAttachmentContent(e,t){return this.fetchRawData(`/api/khub/maps/${e}/attachments/${t}/content`)}getMapResources(e){return this.get(`/api/khub/maps/${e}/resources`)}getMapResourceContent(e,t){return this.fetchRawData(`/api/khub/maps/${e}/resources/${t}/content`)}getUnstructuredDocument(e){return this.get(`/api/khub/documents/${e}`)}getUnstructuredDocumentContent(e){return this.fetchRawData(`/api/khub/documents/${e}/content`)}getUnstructuredDocumentTextContent(e){return this.get(`/api/khub/documents/${e}/content/text`)}getCollectionDocuments(e,t){return this.get(`/api/users/${e}/collections/${t}/documents`)}getSuggestions(e){return this.post("/api/khub/suggest",e)}search(e){return this.post("/api/khub/clustered-search",e)}getAvailableSearchLocales(){return this.get("/api/khub/locales")}getMapRating(e){return this.get(`/api/khub/maps/${e}/rating`)}getDocumentRating(e){return this.get(`/api/khub/documents/${e}/rating`)}rateMap(e,t,r){return this.post(`/api/khub/maps/${e}/rating`,{type:t,value:r})}unrateMap(e){return this.delete(`/api/khub/maps/${e}/rating`)}sendMapFeedback(e,t){return this.post(`/api/khub/maps/${e}/feedback`,{message:t})}rateTopic(e,t,r,a){return this.post(`/api/khub/maps/${e}/topics/${t}/rating`,{type:r,value:a})}unrateTopic(e,t){return this.delete(`/api/khub/maps/${e}/topics/${t}/rating`)}sendTopicFeedback(e,t,r){return this.post(`/api/khub/maps/${e}/topics/${t}/feedback`,{message:r})}rateDocument(e,t,r){return this.post(`/api/khub/documents/${e}/rating`,{type:t,value:r})}unrateDocument(e){return this.delete(`/api/khub/documents/${e}/rating`)}sendDocumentFeedback(e,t){return this.post(`/api/khub/documents/${e}/feedback`,{message:t})}get(e){return this.makeRequest("GET",e)}post(e,t){return this.makeRequest("POST",e,t)}put(e,t){return this.makeRequest("PUT",e,t)}delete(e){return this.makeRequest("DELETE",e)}async fetch(e,t){const r=t;return e.startsWith("/")||(e="/"+e),await fetch(this.tenantBaseUrl+e,{...r??{},headers:{...this.defaultHeaders,...r?.headers??{}}})}async upload(e,t,r,a=(()=>{})){return new Promise(((i,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 ie(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(ne).then(se)}fetchRawData(e){return fetch(this.tenantBaseUrl+e,{headers:this.defaultHeaders}).then(ne).then((e=>e.arrayBuffer()))}}e.FluidTopicsApi=le,e.HttpError=ie,e.addUnauthenticatedUserSearchPreferencesChangeHandler=function(e,t){if(ee.localStorage){const r=re(e),a=e=>{e.storageArea===ee.localStorage&&e.key===r&&t(JSON.parse(e.newValue??"{}"))};return ee.addEventListener("storage",a),{removeHandler:()=>ee.removeEventListener("storage",a)}}console.error("Cannot handle unauthenticated preferences: local storage is unavailable.")},e.default=le,e.getUnauthenticatedUserSearchPreferences=function(e){if(ee.localStorage)return JSON.parse(ee.localStorage.getItem(re(e))??"{}");console.error("Cannot get unauthenticated preferences: local storage is unavailable.")},e.isFtAuthenticatedSession=e=>j(e)&&Y(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)&&D(e.type),e.isFtCollectionDocumentType=D,e.isFtCredentials=e=>s(e)&&u(e.password)&&(null==e.newPassword||u(e.newPassword))&&l(e.rememberMe)&&u(e.login),e.isFtEditorialType=C,e.isFtFeedbackCreation=e=>s(e)&&u(e.message),e.isFtMap=e=>s(e)&&(null==e.prettyUrl||u(e.prettyUrl))&&Array.isArray(e.metadata)&&e.metadata.every((e=>y(e)))&&U(e.openMode)&&u(e.topicsApiEndpoint)&&(null==e.description||u(e.description))&&u(e.attachmentsApiEndpoint)&&C(e.editorialType)&&u(e.baseId)&&u(e.clusterId)&&(null==e.shouldSplitCurrentPageToc||l(e.shouldSplitCurrentPageToc))&&u(e.title)&&u(e.lastPublication)&&u(e.lastEdition)&&u(e.originId)&&u(e.rightsApiEndpoint)&&c(e.contentStyles)&&(null==e.originUrl||u(e.originUrl))&&u(e.readerUrl)&&(null==e.khubVersion||u(e.khubVersion))&&u(e.id)&&(null==e.lang||u(e.lang)),e.isFtMapAttachment=e=>j(e)&&X(e.file)&&(null==e.size||J(e.size))&&z(e.externalLink)&&X(e.name)&&X(e.id)&&(null==e.mimeType||X(e.mimeType))&&(null==e.viewerUrl||X(e.viewerUrl)),e.isFtMapResource=e=>s(e)&&u(e.contentUrl)&&u(e.filename)&&u(e.id)&&u(e.mimeType),e.isFtMapStyles=c,e.isFtMetadata=y,e.isFtMetadataPreferenceConfiguration=F,e.isFtOpenMode=U,e.isFtPageConfiguration=Q,e.isFtPageRequest=O,e.isFtPaginatedToc=e=>j(e)&&Z(e.configuration)&&Array.isArray(e.paginatedToc)&&e.paginatedToc.every((e=>W(e))),e.isFtPaginatedTocNode=W,e.isFtPaginationConfiguration=Z,e.isFtPublicationRating=m,e.isFtPublicationRatingSummary=A,e.isFtRatingCreation=e=>s(e)&&f(e.type)&&o(e.value),e.isFtRatingSummary=e=>s(e)&&(null==e.topics||b(e.topics))&&A(e.publication),e.isFtRatingType=f,e.isFtSearchFacet=_,e.isFtSearchFacetConf=H,e.isFtSearchFacetEntry=B,e.isFtSearchFilter=R,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=>R(e)))&&o(e.priority)&&(null==e.contentLocale||u(e.contentLocale)),e.isFtSearchPrior=I,e.isFtSearchRequest=e=>s(e)&&u(e.query)&&O(e.paging)&&Array.isArray(e.filters)&&e.filters.every((e=>R(e)))&&Array.isArray(e.sort)&&e.sort.every((e=>q(e)))&&(null==e.uiLocale||u(e.uiLocale))&&(null==e.contentLocale||u(e.contentLocale))&&(null==e.priors||Array.isArray(e.priors)&&e.priors.every((e=>I(e))))&&Array.isArray(e.facets)&&e.facets.every((e=>H(e))),e.isFtSearchResultCluster=k,e.isFtSearchResultClusterEntry=M,e.isFtSearchResultMap=$,e.isFtSearchResultTopic=L,e.isFtSearchResultType=x,e.isFtSearchResultUnstructuredDocument=w,e.isFtSearchResults=e=>s(e)&&(null==e.spellcheck||G(e.spellcheck))&&S(e.paging)&&Array.isArray(e.results)&&e.results.every((e=>k(e)))&&Array.isArray(e.facets)&&e.facets.every((e=>_(e))),e.isFtSearchResultsPageInfo=S,e.isFtSearchSortCriterion=q,e.isFtSession=e=>j(e)&&J(e.idleTimeoutInMillis)&&(null==e.profile||Y(e.profile))&&z(e.sessionAuthenticated),e.isFtSpellcheck=G,e.isFtSuggestRequest=e=>s(e)&&u(e.input)&&Array.isArray(e.filters)&&e.filters.every((e=>R(e)))&&Array.isArray(e.sort)&&e.sort.every((e=>q(e)))&&(null==e.maxCount||o(e.maxCount))&&(null==e.contentLocale||u(e.contentLocale)),e.isFtSuggestResult=V,e.isFtSuggestResults=e=>s(e)&&Array.isArray(e.suggestions)&&e.suggestions.every((e=>V(e))),e.isFtTocNode=p,e.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.isFtTopicRating=T,e.isFtTopicResource=K,e.isFtTopicsRatingSummary=b,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=Y,e.setUnauthenticatedUserSearchPreferences=function(e,t){if(ee.localStorage){let r={...t,metadata:te(t.metadata??{})};const a=re(e),i=JSON.stringify(r);return ee.localStorage.setItem(a,i),ee.dispatchEvent(new StorageEvent("storage",{key:a,newValue:i,storageArea:ee.localStorage,url:ee.location.href})),r}console.error("Cannot set unauthenticated preferences: local storage is unavailable.")}}));
|
package/dist/mjs/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "cross-fetch/polyfill";
|
|
2
2
|
import { FtCollectionDocument, FtMap, FtMapResource, FtRatingSummary, FtRatingType, FtSearchLocales, FtSearchRequest, FtSearchResults, FtSuggestRequest, FtSuggestResults, FtTocNode, FtTopic, FtTopicContentTarget, FtTopicContentTargetKeys, FtUnstructuredDocument } from "./types/ft-common/public";
|
|
3
|
-
import { FtAuthenticatedSession, FtMapAttachment, FtSession } from "./types/ft-server/public";
|
|
3
|
+
import { FtAuthenticatedSession, FtMapAttachment, FtPaginatedToc, FtSession } from "./types/ft-server/public";
|
|
4
4
|
export * from "./types/ft-common/public";
|
|
5
5
|
export * from "./types/ft-server/public";
|
|
6
6
|
export * from "./preferences/unauthenticated-preferences";
|
|
@@ -27,6 +27,7 @@ export declare class FluidTopicsApi {
|
|
|
27
27
|
getCurrentSession(): Promise<FtSession>;
|
|
28
28
|
getMap(mapId: string): Promise<FtMap>;
|
|
29
29
|
getTableOfContent(mapId: string): Promise<Array<FtTocNode>>;
|
|
30
|
+
getPages(mapId: string): Promise<FtPaginatedToc>;
|
|
30
31
|
getTopic(mapId: string, topicContentId: string): Promise<FtTopic>;
|
|
31
32
|
getTopicHTMLContent(mapId: string, topicContentId: string, target?: FtTopicContentTarget | FtTopicContentTargetKeys): Promise<string>;
|
|
32
33
|
getMapAttachments(mapId: string): Promise<Array<FtMapAttachment>>;
|
|
@@ -44,10 +45,13 @@ export declare class FluidTopicsApi {
|
|
|
44
45
|
getDocumentRating(docId: string): Promise<FtRatingSummary>;
|
|
45
46
|
rateMap(mapId: string, type: FtRatingType, value: number): Promise<void>;
|
|
46
47
|
unrateMap(mapId: string): Promise<void>;
|
|
48
|
+
sendMapFeedback(mapId: string, message: string): Promise<void>;
|
|
47
49
|
rateTopic(mapId: string, tocId: string, type: FtRatingType, value: number): Promise<void>;
|
|
48
50
|
unrateTopic(mapId: string, tocId: string): Promise<void>;
|
|
51
|
+
sendTopicFeedback(mapId: string, tocId: string, message: string): Promise<void>;
|
|
49
52
|
rateDocument(docId: string, type: FtRatingType, value: number): Promise<void>;
|
|
50
53
|
unrateDocument(docId: string): Promise<void>;
|
|
54
|
+
sendDocumentFeedback(docId: string, message: string): Promise<void>;
|
|
51
55
|
get<T>(endpoint: string): Promise<T>;
|
|
52
56
|
post<T>(endpoint: string, data?: any): Promise<T>;
|
|
53
57
|
put<T>(endpoint: string, data?: any): Promise<T>;
|
package/dist/mjs/index.js
CHANGED
|
@@ -89,6 +89,9 @@ export class FluidTopicsApi {
|
|
|
89
89
|
getTableOfContent(mapId) {
|
|
90
90
|
return this.get(`/api/khub/maps/${mapId}/toc`);
|
|
91
91
|
}
|
|
92
|
+
getPages(mapId) {
|
|
93
|
+
return this.get(`/api/khub/maps/${mapId}/pages`);
|
|
94
|
+
}
|
|
92
95
|
getTopic(mapId, topicContentId) {
|
|
93
96
|
return this.get(`/api/khub/maps/${mapId}/topics/${topicContentId}`);
|
|
94
97
|
}
|
|
@@ -140,18 +143,27 @@ export class FluidTopicsApi {
|
|
|
140
143
|
unrateMap(mapId) {
|
|
141
144
|
return this.delete(`/api/khub/maps/${mapId}/rating`);
|
|
142
145
|
}
|
|
146
|
+
sendMapFeedback(mapId, message) {
|
|
147
|
+
return this.post(`/api/khub/maps/${mapId}/feedback`, { message });
|
|
148
|
+
}
|
|
143
149
|
rateTopic(mapId, tocId, type, value) {
|
|
144
150
|
return this.post(`/api/khub/maps/${mapId}/topics/${tocId}/rating`, { type, value });
|
|
145
151
|
}
|
|
146
152
|
unrateTopic(mapId, tocId) {
|
|
147
153
|
return this.delete(`/api/khub/maps/${mapId}/topics/${tocId}/rating`);
|
|
148
154
|
}
|
|
155
|
+
sendTopicFeedback(mapId, tocId, message) {
|
|
156
|
+
return this.post(`/api/khub/maps/${mapId}/topics/${tocId}/feedback`, { message });
|
|
157
|
+
}
|
|
149
158
|
rateDocument(docId, type, value) {
|
|
150
159
|
return this.post(`/api/khub/documents/${docId}/rating`, { type, value });
|
|
151
160
|
}
|
|
152
161
|
unrateDocument(docId) {
|
|
153
162
|
return this.delete(`/api/khub/documents/${docId}/rating`);
|
|
154
163
|
}
|
|
164
|
+
sendDocumentFeedback(docId, message) {
|
|
165
|
+
return this.post(`/api/khub/documents/${docId}/feedback`, { message });
|
|
166
|
+
}
|
|
155
167
|
get(endpoint) {
|
|
156
168
|
return this.makeRequest("GET", endpoint);
|
|
157
169
|
}
|
|
@@ -49,16 +49,9 @@ export interface FtTocNode {
|
|
|
49
49
|
tocId: string;
|
|
50
50
|
children: Array<FtTocNode>;
|
|
51
51
|
contentId: string;
|
|
52
|
-
page?: FtTocPage;
|
|
53
52
|
title: string;
|
|
54
53
|
}
|
|
55
54
|
export declare const isFtTocNode: (o: any) => o is FtTocNode;
|
|
56
|
-
export interface FtTocPage {
|
|
57
|
-
visible: boolean;
|
|
58
|
-
onItsOwn: boolean;
|
|
59
|
-
parentsVisibility?: Array<boolean>;
|
|
60
|
-
}
|
|
61
|
-
export declare const isFtTocPage: (o: any) => o is FtTocPage;
|
|
62
55
|
export interface FtTopic {
|
|
63
56
|
metadata: Array<FtMetadata>;
|
|
64
57
|
id: string;
|
|
@@ -97,6 +90,10 @@ export declare enum FtTopicContentTarget {
|
|
|
97
90
|
}
|
|
98
91
|
export declare type FtTopicContentTargetKeys = keyof typeof FtTopicContentTarget;
|
|
99
92
|
export declare const isFtTopicContentTarget: (o: any) => o is FtTopicContentTarget;
|
|
93
|
+
export interface FtFeedbackCreation {
|
|
94
|
+
message: string;
|
|
95
|
+
}
|
|
96
|
+
export declare const isFtFeedbackCreation: (o: any) => o is FtFeedbackCreation;
|
|
100
97
|
export interface FtSearchLocale {
|
|
101
98
|
count: number;
|
|
102
99
|
label: string;
|
|
@@ -109,6 +106,7 @@ export interface FtSearchLocales {
|
|
|
109
106
|
export declare const isFtSearchLocales: (o: any) => o is FtSearchLocales;
|
|
110
107
|
export interface FtMetadata {
|
|
111
108
|
values: Array<string>;
|
|
109
|
+
hierarchicalValues?: Array<Array<string>>;
|
|
112
110
|
label: string;
|
|
113
111
|
key: string;
|
|
114
112
|
}
|
|
@@ -57,16 +57,8 @@ export const isFtTocNode = (o) => {
|
|
|
57
57
|
&& ((Array.isArray(o.children)
|
|
58
58
|
&& o.children.every((v) => isFtTocNode(v))))
|
|
59
59
|
&& (isString(o.contentId))
|
|
60
|
-
&& (o.page == null || isFtTocPage(o.page))
|
|
61
60
|
&& (isString(o.title));
|
|
62
61
|
};
|
|
63
|
-
export const isFtTocPage = (o) => {
|
|
64
|
-
return isObject(o)
|
|
65
|
-
&& (isBoolean(o.visible))
|
|
66
|
-
&& (isBoolean(o.onItsOwn))
|
|
67
|
-
&& (o.parentsVisibility == null || (Array.isArray(o.parentsVisibility)
|
|
68
|
-
&& o.parentsVisibility.every((v) => isBoolean(v))));
|
|
69
|
-
};
|
|
70
62
|
export const isFtTopic = (o) => {
|
|
71
63
|
return isObject(o)
|
|
72
64
|
&& ((Array.isArray(o.metadata)
|
|
@@ -110,6 +102,10 @@ export var FtTopicContentTarget;
|
|
|
110
102
|
export const isFtTopicContentTarget = (o) => {
|
|
111
103
|
return ["THIRD_PARTY", "OFF_THE_GRID", "CONTENT_PACKAGER", "PAGES", "DESIGNED_READER"].includes(o);
|
|
112
104
|
};
|
|
105
|
+
export const isFtFeedbackCreation = (o) => {
|
|
106
|
+
return isObject(o)
|
|
107
|
+
&& (isString(o.message));
|
|
108
|
+
};
|
|
113
109
|
export const isFtSearchLocale = (o) => {
|
|
114
110
|
return isObject(o)
|
|
115
111
|
&& (isNumber(o.count))
|
|
@@ -125,6 +121,9 @@ export const isFtMetadata = (o) => {
|
|
|
125
121
|
return isObject(o)
|
|
126
122
|
&& ((Array.isArray(o.values)
|
|
127
123
|
&& o.values.every((v) => isString(v))))
|
|
124
|
+
&& (o.hierarchicalValues == null || (Array.isArray(o.hierarchicalValues)
|
|
125
|
+
&& o.hierarchicalValues.every((v) => (Array.isArray(v)
|
|
126
|
+
&& v.every((v) => isString(v))))))
|
|
128
127
|
&& (isString(o.label))
|
|
129
128
|
&& (isString(o.key));
|
|
130
129
|
};
|
|
@@ -27,3 +27,27 @@ export interface FtMapAttachment {
|
|
|
27
27
|
viewerUrl?: string;
|
|
28
28
|
}
|
|
29
29
|
export declare const isFtMapAttachment: (o: any) => o is FtMapAttachment;
|
|
30
|
+
export interface FtPageConfiguration {
|
|
31
|
+
parentsVisibility?: Array<boolean>;
|
|
32
|
+
isVisible: boolean;
|
|
33
|
+
}
|
|
34
|
+
export declare const isFtPageConfiguration: (o: any) => o is FtPageConfiguration;
|
|
35
|
+
export interface FtPaginatedToc {
|
|
36
|
+
configuration: FtPaginationConfiguration;
|
|
37
|
+
paginatedToc: Array<FtPaginatedTocNode>;
|
|
38
|
+
}
|
|
39
|
+
export declare const isFtPaginatedToc: (o: any) => o is FtPaginatedToc;
|
|
40
|
+
export interface FtPaginatedTocNode {
|
|
41
|
+
prettyUrl?: string;
|
|
42
|
+
pageToc?: Array<any>;
|
|
43
|
+
tocId?: string;
|
|
44
|
+
children: Array<FtPaginatedTocNode>;
|
|
45
|
+
pageConfiguration?: FtPageConfiguration;
|
|
46
|
+
contentId?: string;
|
|
47
|
+
title?: string;
|
|
48
|
+
}
|
|
49
|
+
export declare const isFtPaginatedTocNode: (o: any) => o is FtPaginatedTocNode;
|
|
50
|
+
export interface FtPaginationConfiguration {
|
|
51
|
+
splitCurrentPageToc: boolean;
|
|
52
|
+
}
|
|
53
|
+
export declare const isFtPaginationConfiguration: (o: any) => o is FtPaginationConfiguration;
|
|
@@ -29,3 +29,30 @@ export const isFtMapAttachment = (o) => {
|
|
|
29
29
|
&& (o.mimeType == null || isString(o.mimeType))
|
|
30
30
|
&& (o.viewerUrl == null || isString(o.viewerUrl));
|
|
31
31
|
};
|
|
32
|
+
export const isFtPageConfiguration = (o) => {
|
|
33
|
+
return isObject(o)
|
|
34
|
+
&& (o.parentsVisibility == null || (Array.isArray(o.parentsVisibility)
|
|
35
|
+
&& o.parentsVisibility.every((v) => isBoolean(v))))
|
|
36
|
+
&& (isBoolean(o.isVisible));
|
|
37
|
+
};
|
|
38
|
+
export const isFtPaginatedToc = (o) => {
|
|
39
|
+
return isObject(o)
|
|
40
|
+
&& (isFtPaginationConfiguration(o.configuration))
|
|
41
|
+
&& ((Array.isArray(o.paginatedToc)
|
|
42
|
+
&& o.paginatedToc.every((v) => isFtPaginatedTocNode(v))));
|
|
43
|
+
};
|
|
44
|
+
export const isFtPaginatedTocNode = (o) => {
|
|
45
|
+
return isObject(o)
|
|
46
|
+
&& (o.prettyUrl == null || isString(o.prettyUrl))
|
|
47
|
+
&& (o.pageToc == null || (Array.isArray(o.pageToc)))
|
|
48
|
+
&& (o.tocId == null || isString(o.tocId))
|
|
49
|
+
&& ((Array.isArray(o.children)
|
|
50
|
+
&& o.children.every((v) => isFtPaginatedTocNode(v))))
|
|
51
|
+
&& (o.pageConfiguration == null || isFtPageConfiguration(o.pageConfiguration))
|
|
52
|
+
&& (o.contentId == null || isString(o.contentId))
|
|
53
|
+
&& (o.title == null || isString(o.title));
|
|
54
|
+
};
|
|
55
|
+
export const isFtPaginationConfiguration = (o) => {
|
|
56
|
+
return isObject(o)
|
|
57
|
+
&& (isBoolean(o.splitCurrentPageToc));
|
|
58
|
+
};
|