@fluid-topics/public-api 1.0.32 → 1.0.33
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 +8 -0
- package/dist/cjs/types/ft-common/public.js +34 -2
- package/dist/cjs/types/ft-server/public.js +1 -30
- package/dist/fluidtopics.min.js +1 -1
- package/dist/mjs/index.d.ts +11 -5
- package/dist/mjs/index.js +8 -0
- package/dist/mjs/types/ft-common/public.d.ts +40 -15
- package/dist/mjs/types/ft-common/public.js +28 -0
- package/dist/mjs/types/ft-server/public.d.ts +0 -25
- package/dist/mjs/types/ft-server/public.js +0 -25
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -135,6 +135,11 @@ class FluidTopicsApi {
|
|
|
135
135
|
contextName: (contextName) => ({
|
|
136
136
|
endpoint: `api/messages/${locale}/fluid-topics/${contextName}`,
|
|
137
137
|
})
|
|
138
|
+
},
|
|
139
|
+
custom: {
|
|
140
|
+
contextName: (contextName) => ({
|
|
141
|
+
endpoint: `api/messages/${locale}/custom/${contextName}`,
|
|
142
|
+
})
|
|
138
143
|
}
|
|
139
144
|
})
|
|
140
145
|
},
|
|
@@ -278,6 +283,9 @@ class FluidTopicsApi {
|
|
|
278
283
|
getFluidTopicsMessageContext(locale, name) {
|
|
279
284
|
return this.get(this.endpoints.messages.locale(locale).fluidTopics.contextName(name).endpoint);
|
|
280
285
|
}
|
|
286
|
+
getCustomMessageContext(locale, name) {
|
|
287
|
+
return this.get(this.endpoints.messages.locale(locale).custom.contextName(name).endpoint);
|
|
288
|
+
}
|
|
281
289
|
get(endpoint) {
|
|
282
290
|
return this.makeRequest("GET", endpoint);
|
|
283
291
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.isFtAuthenticationIdentifier = exports.isFtUserRole = exports.FtUserRole = exports.isFtSuggestResults = exports.isFtSuggestResult = exports.isFtSuggestRequest = exports.isFtTopicResource = exports.isFtSpellcheck = exports.isFtSearchSortCriterion = exports.isFtSearchFacetEntry = void 0;
|
|
3
|
+
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.isFtUiLocale = exports.isFtMessageContext = exports.isFtSearchLocales = exports.isFtSearchLocale = exports.isFtFeedbackCreation = exports.isFtTopicContentTarget = exports.FtTopicContentTarget = exports.isFtUnstructuredDocument = exports.isFtTopic = exports.isFtTocNode = exports.isFtMapStyles = exports.isFtMap = exports.isFtCollectionDocument = exports.isFtPersonalBookTopicLinkCreation = exports.isFtPersonalBookNodeCreation = exports.isFtPersonalBookCreation = exports.isFtCredentials = void 0;
|
|
4
|
+
exports.isFtUserProfile = exports.isFtSession = exports.isFtAuthenticatedSession = exports.isFtAuthenticationIdentifier = exports.isFtUserRole = exports.FtUserRole = exports.isFtSuggestResults = exports.isFtSuggestResult = exports.isFtSuggestRequest = exports.isFtTopicResource = exports.isFtSpellcheck = exports.isFtSearchSortCriterion = exports.isFtSearchFacetEntry = exports.isFtSearchFacetConf = void 0;
|
|
5
5
|
const isObject = (o) => typeof o === "object" && o != null;
|
|
6
6
|
const isBoolean = (o) => typeof o === "boolean";
|
|
7
7
|
const isNumber = (o) => typeof o === "number";
|
|
@@ -157,6 +157,15 @@ const isFtSearchLocales = (o) => {
|
|
|
157
157
|
&& o.contentLocales.every((v) => (0, exports.isFtSearchLocale)(v))));
|
|
158
158
|
};
|
|
159
159
|
exports.isFtSearchLocales = isFtSearchLocales;
|
|
160
|
+
const isFtMessageContext = (o) => {
|
|
161
|
+
return isObject(o)
|
|
162
|
+
&& (isString(o.name))
|
|
163
|
+
&& ((isObject(o.messages)
|
|
164
|
+
&& Object.keys(o.messages).every((k) => isString(k))
|
|
165
|
+
&& Object.values(o.messages).every((v) => isString(v))))
|
|
166
|
+
&& (isString(o.locale));
|
|
167
|
+
};
|
|
168
|
+
exports.isFtMessageContext = isFtMessageContext;
|
|
160
169
|
const isFtUiLocale = (o) => {
|
|
161
170
|
return isObject(o)
|
|
162
171
|
&& (isString(o.displayName))
|
|
@@ -539,3 +548,26 @@ const isFtAuthenticationIdentifier = (o) => {
|
|
|
539
548
|
&& (isString(o.realm));
|
|
540
549
|
};
|
|
541
550
|
exports.isFtAuthenticationIdentifier = isFtAuthenticationIdentifier;
|
|
551
|
+
const isFtAuthenticatedSession = (o) => {
|
|
552
|
+
return isObject(o)
|
|
553
|
+
&& ((0, exports.isFtAuthenticationIdentifier)(o.authenticationIdentifier))
|
|
554
|
+
&& ((0, exports.isFtUserProfile)(o.profile));
|
|
555
|
+
};
|
|
556
|
+
exports.isFtAuthenticatedSession = isFtAuthenticatedSession;
|
|
557
|
+
const isFtSession = (o) => {
|
|
558
|
+
return isObject(o)
|
|
559
|
+
&& (o.authenticationIdentifier == null || (0, exports.isFtAuthenticationIdentifier)(o.authenticationIdentifier))
|
|
560
|
+
&& (isNumber(o.idleTimeoutInMillis))
|
|
561
|
+
&& ((0, exports.isFtUserProfile)(o.profile))
|
|
562
|
+
&& (isBoolean(o.sessionAuthenticated));
|
|
563
|
+
};
|
|
564
|
+
exports.isFtSession = isFtSession;
|
|
565
|
+
const isFtUserProfile = (o) => {
|
|
566
|
+
return isObject(o)
|
|
567
|
+
&& (o.emailAddress == null || isString(o.emailAddress))
|
|
568
|
+
&& (o.displayName == null || isString(o.displayName))
|
|
569
|
+
&& ((Array.isArray(o.roles)
|
|
570
|
+
&& o.roles.every((v) => (0, exports.isFtUserRole)(v))))
|
|
571
|
+
&& (o.userId == null || isString(o.userId));
|
|
572
|
+
};
|
|
573
|
+
exports.isFtUserProfile = isFtUserProfile;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.isFtPaginationConfiguration = exports.isFtPaginatedTocNode = exports.isFtPaginatedToc = exports.isFtPageConfiguration = exports.isFtMapAttachment = exports.isFtReaderFeedbackConfiguration = exports.isFtReaderConfiguration = void 0;
|
|
4
4
|
const isObject = (o) => typeof o === "object" && o != null;
|
|
5
5
|
const isBoolean = (o) => typeof o === "boolean";
|
|
6
6
|
const isNumber = (o) => typeof o === "number";
|
|
@@ -21,26 +21,6 @@ const isFtReaderFeedbackConfiguration = (o) => {
|
|
|
21
21
|
&& o.subjectMetadataIds.every((v) => isString(v))));
|
|
22
22
|
};
|
|
23
23
|
exports.isFtReaderFeedbackConfiguration = isFtReaderFeedbackConfiguration;
|
|
24
|
-
const isFtAuthenticatedSession = (o) => {
|
|
25
|
-
return isObject(o)
|
|
26
|
-
&& ((0, exports.isFtUserProfile)(o.profile));
|
|
27
|
-
};
|
|
28
|
-
exports.isFtAuthenticatedSession = isFtAuthenticatedSession;
|
|
29
|
-
const isFtSession = (o) => {
|
|
30
|
-
return isObject(o)
|
|
31
|
-
&& (isNumber(o.idleTimeoutInMillis))
|
|
32
|
-
&& ((0, exports.isFtUserProfile)(o.profile))
|
|
33
|
-
&& (isBoolean(o.sessionAuthenticated));
|
|
34
|
-
};
|
|
35
|
-
exports.isFtSession = isFtSession;
|
|
36
|
-
const isFtUserProfile = (o) => {
|
|
37
|
-
return isObject(o)
|
|
38
|
-
&& (o.emailAddress == null || isString(o.emailAddress))
|
|
39
|
-
&& (o.displayName == null || isString(o.displayName))
|
|
40
|
-
&& ((Array.isArray(o.roles)))
|
|
41
|
-
&& (o.userId == null || isString(o.userId));
|
|
42
|
-
};
|
|
43
|
-
exports.isFtUserProfile = isFtUserProfile;
|
|
44
24
|
const isFtMapAttachment = (o) => {
|
|
45
25
|
return isObject(o)
|
|
46
26
|
&& (isString(o.file))
|
|
@@ -84,12 +64,3 @@ const isFtPaginationConfiguration = (o) => {
|
|
|
84
64
|
&& (isBoolean(o.splitCurrentPageToc));
|
|
85
65
|
};
|
|
86
66
|
exports.isFtPaginationConfiguration = isFtPaginationConfiguration;
|
|
87
|
-
const isFtMessageContext = (o) => {
|
|
88
|
-
return isObject(o)
|
|
89
|
-
&& (isString(o.name))
|
|
90
|
-
&& ((isObject(o.messages)
|
|
91
|
-
&& Object.keys(o.messages).every((k) => isString(k))
|
|
92
|
-
&& Object.values(o.messages).every((v) => isString(v))))
|
|
93
|
-
&& (isString(o.locale));
|
|
94
|
-
};
|
|
95
|
-
exports.isFtMessageContext = isFtMessageContext;
|
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:{},i={exports:{}},s={exports:{}};!function(e,t){var i=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==i)return i;throw new Error("unable to locate global object")}();e.exports=t=i.fetch,i.fetch&&(t.default=i.fetch.bind(i)),t.Headers=i.Headers,t.Request=i.Request,t.Response=i.Response}(s,s.exports),function(e,t){const i=s.exports,a=i.default||i,n=function(e,t){return/^\/\//.test(e)&&(e="https:"+e),a.call(this,e,t)};n.ponyfill=!0,e.exports=t=n,t.fetch=n,t.Headers=i.Headers,t.Request=i.Request,t.Response=i.Response,t.default=n}(i,i.exports);const a=i.exports,n=a.fetch.bind({});n.polyfill=!0,t.fetch||(t.fetch=n,t.Response=a.Response,t.Headers=a.Headers,t.Request=a.Request);const r=e=>"object"==typeof e&&null!=e,o=e=>"boolean"==typeof e,l=e=>"number"==typeof e,u=e=>"string"==typeof e,c=e=>r(e)&&u(e.notes)&&Array.isArray(e.children)&&e.children.every((e=>c(e)))&&(null==e.topicLink||d(e.topicLink))&&u(e.title)&&(null==e.htmlContent||u(e.htmlContent)),d=e=>r(e)&&u(e.tocId)&&u(e.contentId)&&u(e.mapId),p=e=>r(e)&&u(e.topicStylesheetUrl)&&u(e.titleStylesheetUrl)&&Array.isArray(e.customCssClasses)&&e.customCssClasses.every((e=>u(e))),h=e=>r(e)&&(null==e.prettyUrl||u(e.prettyUrl))&&(null==e.hasRating||o(e.hasRating))&&u(e.tocId)&&Array.isArray(e.children)&&e.children.every((e=>h(e)))&&u(e.contentId)&&u(e.title);var y;e.FtTopicContentTarget=void 0,(y=e.FtTopicContentTarget||(e.FtTopicContentTarget={})).THIRD_PARTY="THIRD_PARTY",y.OFF_THE_GRID="OFF_THE_GRID",y.CONTENT_PACKAGER="CONTENT_PACKAGER",y.PAGES="PAGES",y.DESIGNED_READER="DESIGNED_READER";const g=e=>r(e)&&l(e.count)&&u(e.label)&&(null==e.lang||u(e.lang)),m=e=>r(e)&&Array.isArray(e.values)&&e.values.every((e=>u(e)))&&(null==e.hierarchicalValues||Array.isArray(e.hierarchicalValues)&&e.hierarchicalValues.every((e=>Array.isArray(e)&&e.every((e=>u(e))))))&&u(e.label)&&u(e.key);var A;e.FtRatingType=void 0,(A=e.FtRatingType||(e.FtRatingType={})).STARS="STARS",A.LIKE="LIKE",A.DICHOTOMOUS="DICHOTOMOUS",A.NO_RATING="NO_RATING";const f=e=>["STARS","LIKE","DICHOTOMOUS","NO_RATING"].includes(e),R=e=>r(e)&&u(e.date)&&f(e.type)&&l(e.value),E=e=>r(e)&&(null==e.rating||R(e.rating))&&f(e.type),T=e=>r(e)&&u(e.date)&&u(e.tocId)&&f(e.type)&&l(e.value),S=e=>r(e)&&Array.isArray(e.ratings)&&e.ratings.every((e=>T(e)))&&f(e.type),b=e=>r(e)&&Array.isArray(e.filter)&&e.filter.every((e=>u(e)))&&Array.isArray(e.prior)&&e.prior.every((e=>u(e))),I=e=>r(e)&&o(e.negative)&&Array.isArray(e.values)&&e.values.every((e=>u(e)))&&u(e.key),U=e=>r(e)&&l(e.totalResultsCount)&&o(e.lastPage)&&l(e.currentPage)&&l(e.totalClustersCount);var F;e.FtEditorialType=void 0,(F=e.FtEditorialType||(e.FtEditorialType={})).ARTICLE="ARTICLE",F.BOOK="BOOK";const C=e=>["ARTICLE","BOOK"].includes(e);var O;e.FtOpenMode=void 0,(O=e.FtOpenMode||(e.FtOpenMode={})).FLUIDTOPICS="FLUIDTOPICS",O.EXTERNAL="EXTERNAL";const _=e=>["FLUIDTOPICS","EXTERNAL"].includes(e),v=e=>r(e)&&(null==e.perPage||l(e.perPage))&&l(e.page);var k;e.FtCollectionDocumentType=void 0,(k=e.FtCollectionDocumentType||(e.FtCollectionDocumentType={})).MAP="MAP",k.DOCUMENT="DOCUMENT",k.TOPIC="TOPIC",k.PERSONAL_BOOK="PERSONAL_BOOK",k.SHARED_BOOK="SHARED_BOOK";const P=e=>["MAP","DOCUMENT","TOPIC","PERSONAL_BOOK","SHARED_BOOK"].includes(e),D=e=>r(e)&&l(e.weight)&&u(e.value)&&u(e.key),N=e=>r(e)&&Array.isArray(e.entries)&&e.entries.every((e=>L(e)))&&(null==e.metadataVariableAxis||u(e.metadataVariableAxis)),L=e=>r(e)&&(null==e.document||M(e.document))&&(null==e.topic||w(e.topic))&&x(e.type)&&(null==e.map||B(e.map)),M=e=>r(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>m(e)))&&_(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),B=e=>r(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>m(e)))&&(null==e.openMode||_(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),w=e=>r(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>m(e)))&&_(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 H;e.FtSearchResultType=void 0,(H=e.FtSearchResultType||(e.FtSearchResultType={})).MAP="MAP",H.DOCUMENT="DOCUMENT",H.TOPIC="TOPIC";const x=e=>["MAP","DOCUMENT","TOPIC"].includes(e),$=e=>r(e)&&o(e.hierarchical)&&u(e.label)&&o(e.multiSelectionable)&&u(e.key)&&Array.isArray(e.rootNodes)&&e.rootNodes.every((e=>V(e))),K=e=>r(e)&&(null==e.maxDepth||l(e.maxDepth))&&u(e.id),V=e=>r(e)&&l(e.totalResultsCount)&&o(e.descendantSelected)&&Array.isArray(e.childNodes)&&e.childNodes.every((e=>V(e)))&&u(e.label)&&u(e.value)&&o(e.selected),G=e=>r(e)&&u(e.key),q=e=>r(e)&&u(e.suggestedQuery)&&u(e.htmlSuggestedQuery),j=e=>r(e)&&u(e.filename)&&u(e.resourceUrl)&&u(e.id)&&u(e.mimeType)&&u(e.resourceContentUrl)&&u(e.viewerUrl),z=e=>r(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);var X;e.FtUserRole=void 0,(X=e.FtUserRole||(e.FtUserRole={})).PERSONAL_BOOK_USER="PERSONAL_BOOK_USER",X.PERSONAL_BOOK_SHARE_USER="PERSONAL_BOOK_SHARE_USER",X.HTML_EXPORT_USER="HTML_EXPORT_USER",X.PDF_EXPORT_USER="PDF_EXPORT_USER",X.SAVED_SEARCH_USER="SAVED_SEARCH_USER",X.COLLECTION_USER="COLLECTION_USER",X.OFFLINE_USER="OFFLINE_USER",X.ANALYTICS_USER="ANALYTICS_USER",X.BETA_USER="BETA_USER",X.DEBUG_USER="DEBUG_USER",X.PRINT_USER="PRINT_USER",X.RATING_USER="RATING_USER",X.FEEDBACK_USER="FEEDBACK_USER",X.CONTENT_PUBLISHER="CONTENT_PUBLISHER",X.KHUB_ADMIN="KHUB_ADMIN",X.USERS_ADMIN="USERS_ADMIN",X.PORTAL_ADMIN="PORTAL_ADMIN",X.ADMIN="ADMIN",X.DEVELOPER="DEVELOPER";const Y=e=>"object"==typeof e&&null!=e,J=e=>"boolean"==typeof e,Q=e=>"number"==typeof e,W=e=>"string"==typeof e,Z=e=>Y(e)&&J(e.mailsSentByFluidTopics)&&Array.isArray(e.recipients)&&e.recipients.every((e=>W(e)))&&Array.isArray(e.subjectMetadataIds)&&e.subjectMetadataIds.every((e=>W(e))),ee=e=>Y(e)&&(null==e.emailAddress||W(e.emailAddress))&&(null==e.displayName||W(e.displayName))&&Array.isArray(e.roles)&&(null==e.userId||W(e.userId)),te=e=>Y(e)&&(null==e.parentsVisibility||Array.isArray(e.parentsVisibility)&&e.parentsVisibility.every((e=>J(e))))&&J(e.isVisible),ie=e=>Y(e)&&(null==e.prettyUrl||W(e.prettyUrl))&&(null==e.hasRating||J(e.hasRating))&&(null==e.pageToc||Array.isArray(e.pageToc))&&(null==e.tocId||W(e.tocId))&&Array.isArray(e.children)&&e.children.every((e=>ie(e)))&&(null==e.pageConfiguration||te(e.pageConfiguration))&&(null==e.contentId||W(e.contentId))&&(null==e.title||W(e.title)),se=e=>Y(e)&&J(e.splitCurrentPageToc),ae="undefined"==typeof window?globalThis:window;function ne(e){let t={};for(let i in e){let s=e[i];("object"!=typeof s||Array.isArray(s))&&(s={prior:s});for(let e of["prior","filter"])s[e]=Array.isArray(s[e])?s[e]:[s[e]],s[e]=s[e].map((e=>null!=e?""+e:"")).filter((e=>""!==e));t[i]=s}return t}function re(e){return`${e}-FluidTopicsUnauthenticatedUserSearchPreferences`}const oe="undefined"==typeof window?globalThis:window;class le extends Error{status;statusText;body;constructor(e,t,i){super(`${e} - ${t}: ${i}`),this.status=e,this.statusText=t,this.body=i}}async function ue(e){if(!e.ok)throw new le(e.status,e.statusText,await e.text());return e}function ce(e){return"application/json"===e.headers.get("Content-Type")?e.json():e.text()}class de{tenantBaseUrl;ftCallingApp;authorization;searchLabel;endpoints={authentication:{login:"api/authentication/login",logout:"api/authentication/logout",currentSession:"api/authentication/current-session"},khub:{maps:{mapId:e=>({info:`api/khub/maps/${e}`,toc:`api/khub/maps/${e}/toc`,pages:`api/khub/maps/${e}/pages`,feedback:`api/khub/maps/${e}/feedback`,rating:`api/khub/maps/${e}/rating`,attachments:{list:`api/khub/maps/${e}/attachments`,attachmentId:t=>({content:`api/khub/maps/${e}/attachments/${t}/content`})},resources:{list:`api/khub/maps/${e}/resources`,resourceId:t=>({content:`api/khub/maps/${e}/resources/${t}/content`})},topics:{contentId:t=>({info:`api/khub/maps/${e}/topics/${t}`,content:`api/khub/maps/${e}/topics/${t}/content`}),tocId:t=>({feedback:`api/khub/maps/${e}/topics/${t}/feedback`,rating:`api/khub/maps/${e}/topics/${t}/rating`})}})},documents:{documentId:e=>({info:`api/khub/documents/${e}`,content:`api/khub/documents/${e}/content`,text:`api/khub/documents/${e}/content/text`,feedback:`api/khub/documents/${e}/feedback`,rating:`api/khub/documents/${e}/rating`})},suggest:"api/khub/suggest",clusteredSearch:"api/khub/clustered-search",locales:"api/khub/locales"},users:{userId:e=>({collections:{collectionId:t=>({documents:`api/users/${e}/collections/${t}/documents`})}})},stylesheets:{fonts:"api/stylesheets/fonts.css",theme:"api/stylesheets/theme.css",content:{title:"api/stylesheets/content/title.css",topic:"api/stylesheets/content/topic.css"}},configuration:{reader:"api/configuration/reader"},locales:{ui:"api/locales/ui"},messages:{locale:e=>({fluidTopics:{contextName:t=>({endpoint:`api/messages/${e}/fluid-topics/${t}`})}})}};get defaultHeaders(){return{...this.authorization,...this.searchLabel,"Ft-Calling-App":this.ftCallingApp}}constructor(e,t,i){e=(e??oe.__gwt_ft_moduleBase??oe.fluidtopicsclient?.__moduleBase??oe.__gwt_activeModules?.fluidtopicsclient?.moduleBase??"").trim(),this.tenantBaseUrl=e.endsWith("/")?e:e+"/",i&&void 0!==oe.location&&oe.location.href.startsWith(this.tenantBaseUrl)?this.ftCallingApp=t:this.ftCallingApp=`ft-public-api/${t}`}setApiKey(e){this.authorization={Authorization:"Bearer "+e}}setCredentials(e,t){var i;this.authorization={Authorization:"Basic "+(i=`${e}:${t}`,"undefined"!=typeof Buffer?Buffer.from(i).toString("base64"):btoa(i))}}clearAuthentication(){this.authorization=void 0}setSearchLabel(e){this.searchLabel={"FT-search-label":e}}clearSearchLabel(){this.searchLabel=void 0}login(e,t){let i={login:e,password:t,rememberMe:!0};return this.post(this.endpoints.authentication.login,i).then((i=>(this.setCredentials(e,t),i)))}logout(){return this.post(this.endpoints.authentication.logout).then((()=>this.clearAuthentication()))}getCurrentSession(){return this.get(this.endpoints.authentication.currentSession)}getReaderConfiguration(){return this.get(this.endpoints.configuration.reader)}getMap(e){return this.get(this.endpoints.khub.maps.mapId(e).info)}getTableOfContent(e){return this.get(this.endpoints.khub.maps.mapId(e).toc)}getPages(e){return this.get(this.endpoints.khub.maps.mapId(e).pages)}getTopic(e,t){return this.get(this.endpoints.khub.maps.mapId(e).topics.contentId(t).info)}getTopicHTMLContent(e,t,i){return this.get(this.endpoints.khub.maps.mapId(e).topics.contentId(t).content+(i?"?target="+i:""))}getMapAttachments(e){return this.get(this.endpoints.khub.maps.mapId(e).attachments.list)}getMapAttachmentContent(e,t){return this.fetchRawData(this.endpoints.khub.maps.mapId(e).attachments.attachmentId(t).content)}getMapResources(e){return this.get(this.endpoints.khub.maps.mapId(e).resources.list)}getMapResourceContent(e,t){return this.fetchRawData(this.endpoints.khub.maps.mapId(e).resources.resourceId(t).content)}getUnstructuredDocument(e){return this.get(this.endpoints.khub.documents.documentId(e).info)}getUnstructuredDocumentContent(e){return this.fetchRawData(this.endpoints.khub.documents.documentId(e).content)}getUnstructuredDocumentTextContent(e){return this.get(this.endpoints.khub.documents.documentId(e).text)}getCollectionDocuments(e,t){return this.get(this.endpoints.users.userId(e).collections.collectionId(t).documents)}getSuggestions(e){return this.post(this.endpoints.khub.suggest,e)}search(e){return this.post(this.endpoints.khub.clusteredSearch,e)}getAvailableSearchLocales(){return this.get(this.endpoints.khub.locales)}getAvailableUiLocales(){return this.get(this.endpoints.khub.locales)}getMapRating(e){return this.get(this.endpoints.khub.maps.mapId(e).rating)}rateMap(e,t,i){return this.post(this.endpoints.khub.maps.mapId(e).rating,{type:t,value:i})}unrateMap(e){return this.delete(this.endpoints.khub.maps.mapId(e).rating)}sendMapFeedback(e,t){return this.post(this.endpoints.khub.maps.mapId(e).feedback,{message:t})}rateTopic(e,t,i,s){return this.post(this.endpoints.khub.maps.mapId(e).topics.tocId(t).rating,{type:i,value:s})}unrateTopic(e,t){return this.delete(this.endpoints.khub.maps.mapId(e).topics.tocId(t).rating)}sendTopicFeedback(e,t,i){return this.post(this.endpoints.khub.maps.mapId(e).topics.tocId(t).feedback,{message:i})}getDocumentRating(e){return this.get(this.endpoints.khub.documents.documentId(e).rating)}rateDocument(e,t,i){return this.post(this.endpoints.khub.documents.documentId(e).rating,{type:t,value:i})}unrateDocument(e){return this.delete(this.endpoints.khub.documents.documentId(e).rating)}sendDocumentFeedback(e,t){return this.post(this.endpoints.khub.documents.documentId(e).feedback,{message:t})}getFluidTopicsMessageContext(e,t){return this.get(this.endpoints.messages.locale(e).fluidTopics.contextName(t).endpoint)}get(e){return this.makeRequest("GET",e)}post(e,t){return this.makeRequest("POST",e,t)}put(e,t){return this.makeRequest("PUT",e,t)}delete(e){return this.makeRequest("DELETE",e)}makeAbsolute(e){return this.tenantBaseUrl+e.replace(/^\//,"")}async fetch(e,t){const i=t;return await fetch(this.makeAbsolute(e),{...i??{},headers:{...this.defaultHeaders,...i?.headers??{}}})}upload(e,t,i,s=(()=>{})){return"undefined"!=typeof XMLHttpRequest?new Promise(((a,n)=>{let r=new XMLHttpRequest;r.onload=()=>{if(r.status>=200&&r.status<300){let e="application/json"===r.getResponseHeader("Content-Type")?JSON.parse(r.responseText):r.responseText;a(e)}else n(new le(r.status,r.statusText,r.responseText))},r.upload.onprogress=e=>s(e),r.open(e,this.makeAbsolute(t),!0),r.send(i)})):this.fetch(t,{method:e,body:i}).then(ue).then(ce)}makeRequest(e,t,i){return this.fetch(t,{method:e,headers:{...null!=i?{"Content-Type":"application/json"}:{}},body:null!=i?JSON.stringify(i):void 0,credentials:null==this.authorization?"include":void 0}).then(ue).then(ce)}fetchRawData(e){return fetch(this.makeAbsolute(e),{headers:this.defaultHeaders,credentials:null==this.authorization?"include":void 0}).then(ue).then((e=>e.arrayBuffer()))}}e.FluidTopicsApi=de,e.HttpError=le,e.addUnauthenticatedUserSearchPreferencesChangeHandler=function(e,t){if(ae.localStorage){const i=re(e),s=e=>{e.storageArea===ae.localStorage&&e.key===i&&t(JSON.parse(e.newValue??"{}"))};return ae.addEventListener("storage",s),{removeHandler:()=>ae.removeEventListener("storage",s)}}console.error("Cannot handle unauthenticated preferences: local storage is unavailable.")},e.default=de,e.getUnauthenticatedUserSearchPreferences=function(e){if(ae.localStorage)return JSON.parse(ae.localStorage.getItem(re(e))??"{}");console.error("Cannot get unauthenticated preferences: local storage is unavailable.")},e.isFtAuthenticatedSession=e=>Y(e)&&ee(e.profile),e.isFtAuthenticationIdentifier=e=>r(e)&&u(e.identifier)&&u(e.realm),e.isFtCollectionDocument=e=>r(e)&&o(e.deleted)&&(null==e.apiUrl||u(e.apiUrl))&&(null==e.portalUrl||u(e.portalUrl))&&u(e.id)&&u(e.title)&&P(e.type),e.isFtCollectionDocumentType=P,e.isFtCredentials=e=>r(e)&&u(e.password)&&(null==e.newPassword||u(e.newPassword))&&o(e.rememberMe)&&u(e.login),e.isFtEditorialType=C,e.isFtFeedbackCreation=e=>r(e)&&u(e.message),e.isFtMap=e=>r(e)&&(null==e.prettyUrl||u(e.prettyUrl))&&Array.isArray(e.metadata)&&e.metadata.every((e=>m(e)))&&_(e.openMode)&&u(e.topicsApiEndpoint)&&(null==e.description||u(e.description))&&u(e.attachmentsApiEndpoint)&&C(e.editorialType)&&u(e.baseId)&&u(e.clusterId)&&u(e.title)&&u(e.lastPublication)&&u(e.lastEdition)&&u(e.originId)&&u(e.rightsApiEndpoint)&&p(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=>Y(e)&&W(e.file)&&(null==e.size||Q(e.size))&&J(e.externalLink)&&W(e.name)&&W(e.id)&&(null==e.mimeType||W(e.mimeType))&&(null==e.viewerUrl||W(e.viewerUrl)),e.isFtMapResource=e=>r(e)&&u(e.contentUrl)&&u(e.filename)&&u(e.id)&&u(e.mimeType),e.isFtMapStyles=p,e.isFtMessageContext=e=>Y(e)&&W(e.name)&&Y(e.messages)&&Object.keys(e.messages).every((e=>W(e)))&&Object.values(e.messages).every((e=>W(e)))&&W(e.locale),e.isFtMetadata=m,e.isFtMetadataPreferenceConfiguration=b,e.isFtOpenMode=_,e.isFtPageConfiguration=te,e.isFtPageRequest=v,e.isFtPaginatedToc=e=>Y(e)&&se(e.configuration)&&Array.isArray(e.paginatedToc)&&e.paginatedToc.every((e=>ie(e))),e.isFtPaginatedTocNode=ie,e.isFtPaginationConfiguration=se,e.isFtPersonalBookCreation=e=>r(e)&&Array.isArray(e.nodes)&&e.nodes.every((e=>c(e)))&&u(e.description)&&u(e.title),e.isFtPersonalBookNodeCreation=c,e.isFtPersonalBookTopicLinkCreation=d,e.isFtPublicationRating=R,e.isFtPublicationRatingSummary=E,e.isFtRatingCreation=e=>r(e)&&f(e.type)&&l(e.value),e.isFtRatingSummary=e=>r(e)&&(null==e.topics||S(e.topics))&&E(e.publication),e.isFtRatingType=f,e.isFtReaderConfiguration=e=>Y(e)&&Z(e.feedback)&&Q(e.loadAfterLastVisibleTopic)&&Q(e.loadBeforeFirstVisibleTopic),e.isFtReaderFeedbackConfiguration=Z,e.isFtSearchFacet=$,e.isFtSearchFacetConf=K,e.isFtSearchFacetEntry=V,e.isFtSearchFilter=I,e.isFtSearchLocale=g,e.isFtSearchLocales=e=>r(e)&&Array.isArray(e.contentLocales)&&e.contentLocales.every((e=>g(e))),e.isFtSearchPreferencesConfiguration=e=>r(e)&&r(e.metadata)&&Object.keys(e.metadata).every((e=>u(e)))&&Object.values(e.metadata).every((e=>b(e))),e.isFtSearchPreset=e=>r(e)&&u(e.name)&&Array.isArray(e.filters)&&e.filters.every((e=>I(e)))&&l(e.priority)&&(null==e.contentLocale||u(e.contentLocale)),e.isFtSearchPrior=D,e.isFtSearchRequest=e=>r(e)&&u(e.query)&&v(e.paging)&&Array.isArray(e.filters)&&e.filters.every((e=>I(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=>D(e))))&&Array.isArray(e.facets)&&e.facets.every((e=>K(e))),e.isFtSearchResultCluster=N,e.isFtSearchResultClusterEntry=L,e.isFtSearchResultMap=B,e.isFtSearchResultTopic=w,e.isFtSearchResultType=x,e.isFtSearchResultUnstructuredDocument=M,e.isFtSearchResults=e=>r(e)&&(null==e.spellcheck||q(e.spellcheck))&&U(e.paging)&&Array.isArray(e.results)&&e.results.every((e=>N(e)))&&Array.isArray(e.facets)&&e.facets.every((e=>$(e))),e.isFtSearchResultsPageInfo=U,e.isFtSearchSortCriterion=G,e.isFtSession=e=>Y(e)&&Q(e.idleTimeoutInMillis)&&ee(e.profile)&&J(e.sessionAuthenticated),e.isFtSpellcheck=q,e.isFtSuggestRequest=e=>r(e)&&u(e.input)&&Array.isArray(e.filters)&&e.filters.every((e=>I(e)))&&Array.isArray(e.sort)&&e.sort.every((e=>G(e)))&&(null==e.maxCount||l(e.maxCount))&&(null==e.contentLocale||u(e.contentLocale)),e.isFtSuggestResult=z,e.isFtSuggestResults=e=>r(e)&&Array.isArray(e.suggestions)&&e.suggestions.every((e=>z(e))),e.isFtTocNode=h,e.isFtTopic=e=>r(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>m(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=j,e.isFtTopicsRatingSummary=S,e.isFtUiLocale=e=>r(e)&&u(e.displayName)&&u(e.languageTag)&&o(e.translated),e.isFtUnstructuredDocument=e=>r(e)&&(null==e.prettyUrl||u(e.prettyUrl))&&Array.isArray(e.metadata)&&e.metadata.every((e=>m(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=ee,e.isFtUserRole=e=>["PERSONAL_BOOK_USER","PERSONAL_BOOK_SHARE_USER","HTML_EXPORT_USER","PDF_EXPORT_USER","SAVED_SEARCH_USER","COLLECTION_USER","OFFLINE_USER","ANALYTICS_USER","BETA_USER","DEBUG_USER","PRINT_USER","RATING_USER","FEEDBACK_USER","CONTENT_PUBLISHER","KHUB_ADMIN","USERS_ADMIN","PORTAL_ADMIN","ADMIN","DEVELOPER"].includes(e),e.setUnauthenticatedUserSearchPreferences=function(e,t){if(ae.localStorage){let i={...t,metadata:ne(t.metadata??{})};const s=re(e),a=JSON.stringify(i);return ae.localStorage.setItem(s,a),ae.dispatchEvent(new StorageEvent("storage",{key:s,newValue:a,storageArea:ae.localStorage,url:ae.location.href})),i}console.error("Cannot set unauthenticated preferences: local storage is unavailable.")}}));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).fluidtopics={})}(this,(function(e){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},i={exports:{}},s={exports:{}};!function(e,t){var i=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==i)return i;throw new Error("unable to locate global object")}();e.exports=t=i.fetch,i.fetch&&(t.default=i.fetch.bind(i)),t.Headers=i.Headers,t.Request=i.Request,t.Response=i.Response}(s,s.exports),function(e,t){const i=s.exports,a=i.default||i,n=function(e,t){return/^\/\//.test(e)&&(e="https:"+e),a.call(this,e,t)};n.ponyfill=!0,e.exports=t=n,t.fetch=n,t.Headers=i.Headers,t.Request=i.Request,t.Response=i.Response,t.default=n}(i,i.exports);const a=i.exports,n=a.fetch.bind({});n.polyfill=!0,t.fetch||(t.fetch=n,t.Response=a.Response,t.Headers=a.Headers,t.Request=a.Request);const r=e=>"object"==typeof e&&null!=e,o=e=>"boolean"==typeof e,l=e=>"number"==typeof e,u=e=>"string"==typeof e,c=e=>r(e)&&u(e.notes)&&Array.isArray(e.children)&&e.children.every((e=>c(e)))&&(null==e.topicLink||d(e.topicLink))&&u(e.title)&&(null==e.htmlContent||u(e.htmlContent)),d=e=>r(e)&&u(e.tocId)&&u(e.contentId)&&u(e.mapId),p=e=>r(e)&&u(e.topicStylesheetUrl)&&u(e.titleStylesheetUrl)&&Array.isArray(e.customCssClasses)&&e.customCssClasses.every((e=>u(e))),h=e=>r(e)&&(null==e.prettyUrl||u(e.prettyUrl))&&(null==e.hasRating||o(e.hasRating))&&u(e.tocId)&&Array.isArray(e.children)&&e.children.every((e=>h(e)))&&u(e.contentId)&&u(e.title);var y;e.FtTopicContentTarget=void 0,(y=e.FtTopicContentTarget||(e.FtTopicContentTarget={})).THIRD_PARTY="THIRD_PARTY",y.OFF_THE_GRID="OFF_THE_GRID",y.CONTENT_PACKAGER="CONTENT_PACKAGER",y.PAGES="PAGES",y.DESIGNED_READER="DESIGNED_READER";const g=e=>r(e)&&l(e.count)&&u(e.label)&&(null==e.lang||u(e.lang)),m=e=>r(e)&&Array.isArray(e.values)&&e.values.every((e=>u(e)))&&(null==e.hierarchicalValues||Array.isArray(e.hierarchicalValues)&&e.hierarchicalValues.every((e=>Array.isArray(e)&&e.every((e=>u(e))))))&&u(e.label)&&u(e.key);var A;e.FtRatingType=void 0,(A=e.FtRatingType||(e.FtRatingType={})).STARS="STARS",A.LIKE="LIKE",A.DICHOTOMOUS="DICHOTOMOUS",A.NO_RATING="NO_RATING";const f=e=>["STARS","LIKE","DICHOTOMOUS","NO_RATING"].includes(e),R=e=>r(e)&&u(e.date)&&f(e.type)&&l(e.value),E=e=>r(e)&&(null==e.rating||R(e.rating))&&f(e.type),T=e=>r(e)&&u(e.date)&&u(e.tocId)&&f(e.type)&&l(e.value),S=e=>r(e)&&Array.isArray(e.ratings)&&e.ratings.every((e=>T(e)))&&f(e.type),b=e=>r(e)&&Array.isArray(e.filter)&&e.filter.every((e=>u(e)))&&Array.isArray(e.prior)&&e.prior.every((e=>u(e))),I=e=>r(e)&&o(e.negative)&&Array.isArray(e.values)&&e.values.every((e=>u(e)))&&u(e.key),U=e=>r(e)&&l(e.totalResultsCount)&&o(e.lastPage)&&l(e.currentPage)&&l(e.totalClustersCount);var F;e.FtEditorialType=void 0,(F=e.FtEditorialType||(e.FtEditorialType={})).ARTICLE="ARTICLE",F.BOOK="BOOK";const C=e=>["ARTICLE","BOOK"].includes(e);var O;e.FtOpenMode=void 0,(O=e.FtOpenMode||(e.FtOpenMode={})).FLUIDTOPICS="FLUIDTOPICS",O.EXTERNAL="EXTERNAL";const _=e=>["FLUIDTOPICS","EXTERNAL"].includes(e),v=e=>r(e)&&(null==e.perPage||l(e.perPage))&&l(e.page);var k;e.FtCollectionDocumentType=void 0,(k=e.FtCollectionDocumentType||(e.FtCollectionDocumentType={})).MAP="MAP",k.DOCUMENT="DOCUMENT",k.TOPIC="TOPIC",k.PERSONAL_BOOK="PERSONAL_BOOK",k.SHARED_BOOK="SHARED_BOOK";const P=e=>["MAP","DOCUMENT","TOPIC","PERSONAL_BOOK","SHARED_BOOK"].includes(e),D=e=>r(e)&&l(e.weight)&&u(e.value)&&u(e.key),N=e=>r(e)&&Array.isArray(e.entries)&&e.entries.every((e=>L(e)))&&(null==e.metadataVariableAxis||u(e.metadataVariableAxis)),L=e=>r(e)&&(null==e.document||M(e.document))&&(null==e.topic||w(e.topic))&&H(e.type)&&(null==e.map||B(e.map)),M=e=>r(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>m(e)))&&_(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),B=e=>r(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>m(e)))&&(null==e.openMode||_(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),w=e=>r(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>m(e)))&&_(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 H=e=>["MAP","DOCUMENT","TOPIC"].includes(e),$=e=>r(e)&&o(e.hierarchical)&&u(e.label)&&o(e.multiSelectionable)&&u(e.key)&&Array.isArray(e.rootNodes)&&e.rootNodes.every((e=>V(e))),K=e=>r(e)&&(null==e.maxDepth||l(e.maxDepth))&&u(e.id),V=e=>r(e)&&l(e.totalResultsCount)&&o(e.descendantSelected)&&Array.isArray(e.childNodes)&&e.childNodes.every((e=>V(e)))&&u(e.label)&&u(e.value)&&o(e.selected),G=e=>r(e)&&u(e.key),q=e=>r(e)&&u(e.suggestedQuery)&&u(e.htmlSuggestedQuery),j=e=>r(e)&&u(e.filename)&&u(e.resourceUrl)&&u(e.id)&&u(e.mimeType)&&u(e.resourceContentUrl)&&u(e.viewerUrl),z=e=>r(e)&&(null==e.filenameExtension||u(e.filenameExtension))&&(null==e.editorialType||C(e.editorialType))&&(null==e.mimeType||u(e.mimeType))&&H(e.type)&&u(e.value);var X;e.FtUserRole=void 0,(X=e.FtUserRole||(e.FtUserRole={})).PERSONAL_BOOK_USER="PERSONAL_BOOK_USER",X.PERSONAL_BOOK_SHARE_USER="PERSONAL_BOOK_SHARE_USER",X.HTML_EXPORT_USER="HTML_EXPORT_USER",X.PDF_EXPORT_USER="PDF_EXPORT_USER",X.SAVED_SEARCH_USER="SAVED_SEARCH_USER",X.COLLECTION_USER="COLLECTION_USER",X.OFFLINE_USER="OFFLINE_USER",X.ANALYTICS_USER="ANALYTICS_USER",X.BETA_USER="BETA_USER",X.DEBUG_USER="DEBUG_USER",X.PRINT_USER="PRINT_USER",X.RATING_USER="RATING_USER",X.FEEDBACK_USER="FEEDBACK_USER",X.CONTENT_PUBLISHER="CONTENT_PUBLISHER",X.KHUB_ADMIN="KHUB_ADMIN",X.USERS_ADMIN="USERS_ADMIN",X.PORTAL_ADMIN="PORTAL_ADMIN",X.ADMIN="ADMIN",X.DEVELOPER="DEVELOPER";const Y=e=>["PERSONAL_BOOK_USER","PERSONAL_BOOK_SHARE_USER","HTML_EXPORT_USER","PDF_EXPORT_USER","SAVED_SEARCH_USER","COLLECTION_USER","OFFLINE_USER","ANALYTICS_USER","BETA_USER","DEBUG_USER","PRINT_USER","RATING_USER","FEEDBACK_USER","CONTENT_PUBLISHER","KHUB_ADMIN","USERS_ADMIN","PORTAL_ADMIN","ADMIN","DEVELOPER"].includes(e),J=e=>r(e)&&u(e.identifier)&&u(e.realm),Q=e=>r(e)&&(null==e.emailAddress||u(e.emailAddress))&&(null==e.displayName||u(e.displayName))&&Array.isArray(e.roles)&&e.roles.every((e=>Y(e)))&&(null==e.userId||u(e.userId)),W=e=>"object"==typeof e&&null!=e,Z=e=>"boolean"==typeof e,ee=e=>"number"==typeof e,te=e=>"string"==typeof e,ie=e=>W(e)&&Z(e.mailsSentByFluidTopics)&&Array.isArray(e.recipients)&&e.recipients.every((e=>te(e)))&&Array.isArray(e.subjectMetadataIds)&&e.subjectMetadataIds.every((e=>te(e))),se=e=>W(e)&&(null==e.parentsVisibility||Array.isArray(e.parentsVisibility)&&e.parentsVisibility.every((e=>Z(e))))&&Z(e.isVisible),ae=e=>W(e)&&(null==e.prettyUrl||te(e.prettyUrl))&&(null==e.hasRating||Z(e.hasRating))&&(null==e.pageToc||Array.isArray(e.pageToc))&&(null==e.tocId||te(e.tocId))&&Array.isArray(e.children)&&e.children.every((e=>ae(e)))&&(null==e.pageConfiguration||se(e.pageConfiguration))&&(null==e.contentId||te(e.contentId))&&(null==e.title||te(e.title)),ne=e=>W(e)&&Z(e.splitCurrentPageToc),re="undefined"==typeof window?globalThis:window;function oe(e){let t={};for(let i in e){let s=e[i];("object"!=typeof s||Array.isArray(s))&&(s={prior:s});for(let e of["prior","filter"])s[e]=Array.isArray(s[e])?s[e]:[s[e]],s[e]=s[e].map((e=>null!=e?""+e:"")).filter((e=>""!==e));t[i]=s}return t}function le(e){return`${e}-FluidTopicsUnauthenticatedUserSearchPreferences`}const ue="undefined"==typeof window?globalThis:window;class ce extends Error{status;statusText;body;constructor(e,t,i){super(`${e} - ${t}: ${i}`),this.status=e,this.statusText=t,this.body=i}}async function de(e){if(!e.ok)throw new ce(e.status,e.statusText,await e.text());return e}function pe(e){return"application/json"===e.headers.get("Content-Type")?e.json():e.text()}class he{tenantBaseUrl;ftCallingApp;authorization;searchLabel;endpoints={authentication:{login:"api/authentication/login",logout:"api/authentication/logout",currentSession:"api/authentication/current-session"},khub:{maps:{mapId:e=>({info:`api/khub/maps/${e}`,toc:`api/khub/maps/${e}/toc`,pages:`api/khub/maps/${e}/pages`,feedback:`api/khub/maps/${e}/feedback`,rating:`api/khub/maps/${e}/rating`,attachments:{list:`api/khub/maps/${e}/attachments`,attachmentId:t=>({content:`api/khub/maps/${e}/attachments/${t}/content`})},resources:{list:`api/khub/maps/${e}/resources`,resourceId:t=>({content:`api/khub/maps/${e}/resources/${t}/content`})},topics:{contentId:t=>({info:`api/khub/maps/${e}/topics/${t}`,content:`api/khub/maps/${e}/topics/${t}/content`}),tocId:t=>({feedback:`api/khub/maps/${e}/topics/${t}/feedback`,rating:`api/khub/maps/${e}/topics/${t}/rating`})}})},documents:{documentId:e=>({info:`api/khub/documents/${e}`,content:`api/khub/documents/${e}/content`,text:`api/khub/documents/${e}/content/text`,feedback:`api/khub/documents/${e}/feedback`,rating:`api/khub/documents/${e}/rating`})},suggest:"api/khub/suggest",clusteredSearch:"api/khub/clustered-search",locales:"api/khub/locales"},users:{userId:e=>({collections:{collectionId:t=>({documents:`api/users/${e}/collections/${t}/documents`})}})},stylesheets:{fonts:"api/stylesheets/fonts.css",theme:"api/stylesheets/theme.css",content:{title:"api/stylesheets/content/title.css",topic:"api/stylesheets/content/topic.css"}},configuration:{reader:"api/configuration/reader"},locales:{ui:"api/locales/ui"},messages:{locale:e=>({fluidTopics:{contextName:t=>({endpoint:`api/messages/${e}/fluid-topics/${t}`})},custom:{contextName:t=>({endpoint:`api/messages/${e}/custom/${t}`})}})}};get defaultHeaders(){return{...this.authorization,...this.searchLabel,"Ft-Calling-App":this.ftCallingApp}}constructor(e,t,i){e=(e??ue.__gwt_ft_moduleBase??ue.fluidtopicsclient?.__moduleBase??ue.__gwt_activeModules?.fluidtopicsclient?.moduleBase??"").trim(),this.tenantBaseUrl=e.endsWith("/")?e:e+"/",i&&void 0!==ue.location&&ue.location.href.startsWith(this.tenantBaseUrl)?this.ftCallingApp=t:this.ftCallingApp=`ft-public-api/${t}`}setApiKey(e){this.authorization={Authorization:"Bearer "+e}}setCredentials(e,t){var i;this.authorization={Authorization:"Basic "+(i=`${e}:${t}`,"undefined"!=typeof Buffer?Buffer.from(i).toString("base64"):btoa(i))}}clearAuthentication(){this.authorization=void 0}setSearchLabel(e){this.searchLabel={"FT-search-label":e}}clearSearchLabel(){this.searchLabel=void 0}login(e,t){let i={login:e,password:t,rememberMe:!0};return this.post(this.endpoints.authentication.login,i).then((i=>(this.setCredentials(e,t),i)))}logout(){return this.post(this.endpoints.authentication.logout).then((()=>this.clearAuthentication()))}getCurrentSession(){return this.get(this.endpoints.authentication.currentSession)}getReaderConfiguration(){return this.get(this.endpoints.configuration.reader)}getMap(e){return this.get(this.endpoints.khub.maps.mapId(e).info)}getTableOfContent(e){return this.get(this.endpoints.khub.maps.mapId(e).toc)}getPages(e){return this.get(this.endpoints.khub.maps.mapId(e).pages)}getTopic(e,t){return this.get(this.endpoints.khub.maps.mapId(e).topics.contentId(t).info)}getTopicHTMLContent(e,t,i){return this.get(this.endpoints.khub.maps.mapId(e).topics.contentId(t).content+(i?"?target="+i:""))}getMapAttachments(e){return this.get(this.endpoints.khub.maps.mapId(e).attachments.list)}getMapAttachmentContent(e,t){return this.fetchRawData(this.endpoints.khub.maps.mapId(e).attachments.attachmentId(t).content)}getMapResources(e){return this.get(this.endpoints.khub.maps.mapId(e).resources.list)}getMapResourceContent(e,t){return this.fetchRawData(this.endpoints.khub.maps.mapId(e).resources.resourceId(t).content)}getUnstructuredDocument(e){return this.get(this.endpoints.khub.documents.documentId(e).info)}getUnstructuredDocumentContent(e){return this.fetchRawData(this.endpoints.khub.documents.documentId(e).content)}getUnstructuredDocumentTextContent(e){return this.get(this.endpoints.khub.documents.documentId(e).text)}getCollectionDocuments(e,t){return this.get(this.endpoints.users.userId(e).collections.collectionId(t).documents)}getSuggestions(e){return this.post(this.endpoints.khub.suggest,e)}search(e){return this.post(this.endpoints.khub.clusteredSearch,e)}getAvailableSearchLocales(){return this.get(this.endpoints.khub.locales)}getAvailableUiLocales(){return this.get(this.endpoints.khub.locales)}getMapRating(e){return this.get(this.endpoints.khub.maps.mapId(e).rating)}rateMap(e,t,i){return this.post(this.endpoints.khub.maps.mapId(e).rating,{type:t,value:i})}unrateMap(e){return this.delete(this.endpoints.khub.maps.mapId(e).rating)}sendMapFeedback(e,t){return this.post(this.endpoints.khub.maps.mapId(e).feedback,{message:t})}rateTopic(e,t,i,s){return this.post(this.endpoints.khub.maps.mapId(e).topics.tocId(t).rating,{type:i,value:s})}unrateTopic(e,t){return this.delete(this.endpoints.khub.maps.mapId(e).topics.tocId(t).rating)}sendTopicFeedback(e,t,i){return this.post(this.endpoints.khub.maps.mapId(e).topics.tocId(t).feedback,{message:i})}getDocumentRating(e){return this.get(this.endpoints.khub.documents.documentId(e).rating)}rateDocument(e,t,i){return this.post(this.endpoints.khub.documents.documentId(e).rating,{type:t,value:i})}unrateDocument(e){return this.delete(this.endpoints.khub.documents.documentId(e).rating)}sendDocumentFeedback(e,t){return this.post(this.endpoints.khub.documents.documentId(e).feedback,{message:t})}getFluidTopicsMessageContext(e,t){return this.get(this.endpoints.messages.locale(e).fluidTopics.contextName(t).endpoint)}getCustomMessageContext(e,t){return this.get(this.endpoints.messages.locale(e).custom.contextName(t).endpoint)}get(e){return this.makeRequest("GET",e)}post(e,t){return this.makeRequest("POST",e,t)}put(e,t){return this.makeRequest("PUT",e,t)}delete(e){return this.makeRequest("DELETE",e)}makeAbsolute(e){return this.tenantBaseUrl+e.replace(/^\//,"")}async fetch(e,t){const i=t;return await fetch(this.makeAbsolute(e),{...i??{},headers:{...this.defaultHeaders,...i?.headers??{}}})}upload(e,t,i,s=(()=>{})){return"undefined"!=typeof XMLHttpRequest?new Promise(((a,n)=>{let r=new XMLHttpRequest;r.onload=()=>{if(r.status>=200&&r.status<300){let e="application/json"===r.getResponseHeader("Content-Type")?JSON.parse(r.responseText):r.responseText;a(e)}else n(new ce(r.status,r.statusText,r.responseText))},r.upload.onprogress=e=>s(e),r.open(e,this.makeAbsolute(t),!0),r.send(i)})):this.fetch(t,{method:e,body:i}).then(de).then(pe)}makeRequest(e,t,i){return this.fetch(t,{method:e,headers:{...null!=i?{"Content-Type":"application/json"}:{}},body:null!=i?JSON.stringify(i):void 0,credentials:null==this.authorization?"include":void 0}).then(de).then(pe)}fetchRawData(e){return fetch(this.makeAbsolute(e),{headers:this.defaultHeaders,credentials:null==this.authorization?"include":void 0}).then(de).then((e=>e.arrayBuffer()))}}e.FluidTopicsApi=he,e.HttpError=ce,e.addUnauthenticatedUserSearchPreferencesChangeHandler=function(e,t){if(re.localStorage){const i=le(e),s=e=>{e.storageArea===re.localStorage&&e.key===i&&t(JSON.parse(e.newValue??"{}"))};return re.addEventListener("storage",s),{removeHandler:()=>re.removeEventListener("storage",s)}}console.error("Cannot handle unauthenticated preferences: local storage is unavailable.")},e.default=he,e.getUnauthenticatedUserSearchPreferences=function(e){if(re.localStorage)return JSON.parse(re.localStorage.getItem(le(e))??"{}");console.error("Cannot get unauthenticated preferences: local storage is unavailable.")},e.isFtAuthenticatedSession=e=>r(e)&&J(e.authenticationIdentifier)&&Q(e.profile),e.isFtAuthenticationIdentifier=J,e.isFtCollectionDocument=e=>r(e)&&o(e.deleted)&&(null==e.apiUrl||u(e.apiUrl))&&(null==e.portalUrl||u(e.portalUrl))&&u(e.id)&&u(e.title)&&P(e.type),e.isFtCollectionDocumentType=P,e.isFtCredentials=e=>r(e)&&u(e.password)&&(null==e.newPassword||u(e.newPassword))&&o(e.rememberMe)&&u(e.login),e.isFtEditorialType=C,e.isFtFeedbackCreation=e=>r(e)&&u(e.message),e.isFtMap=e=>r(e)&&(null==e.prettyUrl||u(e.prettyUrl))&&Array.isArray(e.metadata)&&e.metadata.every((e=>m(e)))&&_(e.openMode)&&u(e.topicsApiEndpoint)&&(null==e.description||u(e.description))&&u(e.attachmentsApiEndpoint)&&C(e.editorialType)&&u(e.baseId)&&u(e.clusterId)&&u(e.title)&&u(e.lastPublication)&&u(e.lastEdition)&&u(e.originId)&&u(e.rightsApiEndpoint)&&p(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=>W(e)&&te(e.file)&&(null==e.size||ee(e.size))&&Z(e.externalLink)&&te(e.name)&&te(e.id)&&(null==e.mimeType||te(e.mimeType))&&(null==e.viewerUrl||te(e.viewerUrl)),e.isFtMapResource=e=>r(e)&&u(e.contentUrl)&&u(e.filename)&&u(e.id)&&u(e.mimeType),e.isFtMapStyles=p,e.isFtMessageContext=e=>r(e)&&u(e.name)&&r(e.messages)&&Object.keys(e.messages).every((e=>u(e)))&&Object.values(e.messages).every((e=>u(e)))&&u(e.locale),e.isFtMetadata=m,e.isFtMetadataPreferenceConfiguration=b,e.isFtOpenMode=_,e.isFtPageConfiguration=se,e.isFtPageRequest=v,e.isFtPaginatedToc=e=>W(e)&&ne(e.configuration)&&Array.isArray(e.paginatedToc)&&e.paginatedToc.every((e=>ae(e))),e.isFtPaginatedTocNode=ae,e.isFtPaginationConfiguration=ne,e.isFtPersonalBookCreation=e=>r(e)&&Array.isArray(e.nodes)&&e.nodes.every((e=>c(e)))&&u(e.description)&&u(e.title),e.isFtPersonalBookNodeCreation=c,e.isFtPersonalBookTopicLinkCreation=d,e.isFtPublicationRating=R,e.isFtPublicationRatingSummary=E,e.isFtRatingCreation=e=>r(e)&&f(e.type)&&l(e.value),e.isFtRatingSummary=e=>r(e)&&(null==e.topics||S(e.topics))&&E(e.publication),e.isFtRatingType=f,e.isFtReaderConfiguration=e=>W(e)&&ie(e.feedback)&&ee(e.loadAfterLastVisibleTopic)&&ee(e.loadBeforeFirstVisibleTopic),e.isFtReaderFeedbackConfiguration=ie,e.isFtSearchFacet=$,e.isFtSearchFacetConf=K,e.isFtSearchFacetEntry=V,e.isFtSearchFilter=I,e.isFtSearchLocale=g,e.isFtSearchLocales=e=>r(e)&&Array.isArray(e.contentLocales)&&e.contentLocales.every((e=>g(e))),e.isFtSearchPreferencesConfiguration=e=>r(e)&&r(e.metadata)&&Object.keys(e.metadata).every((e=>u(e)))&&Object.values(e.metadata).every((e=>b(e))),e.isFtSearchPreset=e=>r(e)&&u(e.name)&&Array.isArray(e.filters)&&e.filters.every((e=>I(e)))&&l(e.priority)&&(null==e.contentLocale||u(e.contentLocale)),e.isFtSearchPrior=D,e.isFtSearchRequest=e=>r(e)&&u(e.query)&&v(e.paging)&&Array.isArray(e.filters)&&e.filters.every((e=>I(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=>D(e))))&&Array.isArray(e.facets)&&e.facets.every((e=>K(e))),e.isFtSearchResultCluster=N,e.isFtSearchResultClusterEntry=L,e.isFtSearchResultMap=B,e.isFtSearchResultTopic=w,e.isFtSearchResultType=H,e.isFtSearchResultUnstructuredDocument=M,e.isFtSearchResults=e=>r(e)&&(null==e.spellcheck||q(e.spellcheck))&&U(e.paging)&&Array.isArray(e.results)&&e.results.every((e=>N(e)))&&Array.isArray(e.facets)&&e.facets.every((e=>$(e))),e.isFtSearchResultsPageInfo=U,e.isFtSearchSortCriterion=G,e.isFtSession=e=>r(e)&&(null==e.authenticationIdentifier||J(e.authenticationIdentifier))&&l(e.idleTimeoutInMillis)&&Q(e.profile)&&o(e.sessionAuthenticated),e.isFtSpellcheck=q,e.isFtSuggestRequest=e=>r(e)&&u(e.input)&&Array.isArray(e.filters)&&e.filters.every((e=>I(e)))&&Array.isArray(e.sort)&&e.sort.every((e=>G(e)))&&(null==e.maxCount||l(e.maxCount))&&(null==e.contentLocale||u(e.contentLocale)),e.isFtSuggestResult=z,e.isFtSuggestResults=e=>r(e)&&Array.isArray(e.suggestions)&&e.suggestions.every((e=>z(e))),e.isFtTocNode=h,e.isFtTopic=e=>r(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>m(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=j,e.isFtTopicsRatingSummary=S,e.isFtUiLocale=e=>r(e)&&u(e.displayName)&&u(e.languageTag)&&o(e.translated),e.isFtUnstructuredDocument=e=>r(e)&&(null==e.prettyUrl||u(e.prettyUrl))&&Array.isArray(e.metadata)&&e.metadata.every((e=>m(e)))&&u(e.openMode)&&(null==e.description||u(e.description))&&u(e.mimeType)&&(null==e.baseId||u(e.baseId))&&(null==e.clusterId||u(e.clusterId))&&u(e.contentApiEndpoint)&&u(e.title)&&(null==e.lastPublication||u(e.lastPublication))&&u(e.viewerUrl)&&u(e.lastEdition)&&u(e.filename)&&(null==e.originId||u(e.originId))&&u(e.rightsApiEndpoint)&&(null==e.originUrl||u(e.originUrl))&&(null==e.khubVersion||u(e.khubVersion))&&u(e.id)&&(null==e.lang||u(e.lang)),e.isFtUserProfile=Q,e.isFtUserRole=Y,e.setUnauthenticatedUserSearchPreferences=function(e,t){if(re.localStorage){let i={...t,metadata:oe(t.metadata??{})};const s=le(e),a=JSON.stringify(i);return re.localStorage.setItem(s,a),re.dispatchEvent(new StorageEvent("storage",{key:s,newValue:a,storageArea:re.localStorage,url:re.location.href})),i}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
|
-
import { FtCollectionDocument, FtMap, FtMapResource, FtRatingSummary, FtRatingType, FtSearchLocales, FtSearchRequest, FtSearchResults, FtSuggestRequest, FtSuggestResults, FtTocNode, FtTopic, FtTopicContentTarget, FtTopicContentTargetKeys, FtUiLocale, FtUnstructuredDocument } from "./types/ft-common/public";
|
|
3
|
-
import {
|
|
2
|
+
import { FtAuthenticatedSession, FtCollectionDocument, FtMap, FtMapResource, FtMessageContext, FtRatingSummary, FtRatingType, FtRatingTypeKeys, FtSearchLocales, FtSearchRequest, FtSearchResults, FtSession, FtSuggestRequest, FtSuggestResults, FtTocNode, FtTopic, FtTopicContentTarget, FtTopicContentTargetKeys, FtUiLocale, FtUnstructuredDocument } from "./types/ft-common/public";
|
|
3
|
+
import { FtMapAttachment, FtPaginatedToc, FtReaderConfiguration } 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";
|
|
@@ -96,6 +96,11 @@ export declare class FluidTopicsApi {
|
|
|
96
96
|
endpoint: string;
|
|
97
97
|
};
|
|
98
98
|
};
|
|
99
|
+
custom: {
|
|
100
|
+
contextName: (contextName: string) => {
|
|
101
|
+
endpoint: string;
|
|
102
|
+
};
|
|
103
|
+
};
|
|
99
104
|
};
|
|
100
105
|
};
|
|
101
106
|
};
|
|
@@ -128,17 +133,18 @@ export declare class FluidTopicsApi {
|
|
|
128
133
|
getAvailableSearchLocales(): Promise<FtSearchLocales>;
|
|
129
134
|
getAvailableUiLocales(): Promise<Array<FtUiLocale>>;
|
|
130
135
|
getMapRating(mapId: string): Promise<FtRatingSummary>;
|
|
131
|
-
rateMap(mapId: string, type: FtRatingType, value: number): Promise<void>;
|
|
136
|
+
rateMap(mapId: string, type: FtRatingType | FtRatingTypeKeys, value: number): Promise<void>;
|
|
132
137
|
unrateMap(mapId: string): Promise<void>;
|
|
133
138
|
sendMapFeedback(mapId: string, message: string): Promise<void>;
|
|
134
|
-
rateTopic(mapId: string, tocId: string, type: FtRatingType, value: number): Promise<void>;
|
|
139
|
+
rateTopic(mapId: string, tocId: string, type: FtRatingType | FtRatingTypeKeys, value: number): Promise<void>;
|
|
135
140
|
unrateTopic(mapId: string, tocId: string): Promise<void>;
|
|
136
141
|
sendTopicFeedback(mapId: string, tocId: string, message: string): Promise<void>;
|
|
137
142
|
getDocumentRating(docId: string): Promise<FtRatingSummary>;
|
|
138
|
-
rateDocument(docId: string, type: FtRatingType, value: number): Promise<void>;
|
|
143
|
+
rateDocument(docId: string, type: FtRatingType | FtRatingTypeKeys, value: number): Promise<void>;
|
|
139
144
|
unrateDocument(docId: string): Promise<void>;
|
|
140
145
|
sendDocumentFeedback(docId: string, message: string): Promise<void>;
|
|
141
146
|
getFluidTopicsMessageContext(locale: string, name: string): Promise<FtMessageContext>;
|
|
147
|
+
getCustomMessageContext(locale: string, name: string): Promise<FtMessageContext>;
|
|
142
148
|
get<T>(endpoint: string): Promise<T>;
|
|
143
149
|
post<T>(endpoint: string, data?: any): Promise<T>;
|
|
144
150
|
put<T>(endpoint: string, data?: any): Promise<T>;
|
package/dist/mjs/index.js
CHANGED
|
@@ -111,6 +111,11 @@ export class FluidTopicsApi {
|
|
|
111
111
|
contextName: (contextName) => ({
|
|
112
112
|
endpoint: `api/messages/${locale}/fluid-topics/${contextName}`,
|
|
113
113
|
})
|
|
114
|
+
},
|
|
115
|
+
custom: {
|
|
116
|
+
contextName: (contextName) => ({
|
|
117
|
+
endpoint: `api/messages/${locale}/custom/${contextName}`,
|
|
118
|
+
})
|
|
114
119
|
}
|
|
115
120
|
})
|
|
116
121
|
},
|
|
@@ -259,6 +264,9 @@ export class FluidTopicsApi {
|
|
|
259
264
|
getFluidTopicsMessageContext(locale, name) {
|
|
260
265
|
return this.get(this.endpoints.messages.locale(locale).fluidTopics.contextName(name).endpoint);
|
|
261
266
|
}
|
|
267
|
+
getCustomMessageContext(locale, name) {
|
|
268
|
+
return this.get(this.endpoints.messages.locale(locale).custom.contextName(name).endpoint);
|
|
269
|
+
}
|
|
262
270
|
get(endpoint) {
|
|
263
271
|
return this.makeRequest("GET", endpoint);
|
|
264
272
|
}
|
|
@@ -32,17 +32,17 @@ export interface FtCollectionDocument {
|
|
|
32
32
|
portalUrl?: string;
|
|
33
33
|
id: string;
|
|
34
34
|
title: string;
|
|
35
|
-
type: FtCollectionDocumentType;
|
|
35
|
+
type: FtCollectionDocumentTypeKeys | FtCollectionDocumentType;
|
|
36
36
|
}
|
|
37
37
|
export declare const isFtCollectionDocument: (o: any) => o is FtCollectionDocument;
|
|
38
38
|
export interface FtMap {
|
|
39
39
|
prettyUrl?: string;
|
|
40
40
|
metadata: Array<FtMetadata>;
|
|
41
|
-
openMode: FtOpenMode;
|
|
41
|
+
openMode: FtOpenModeKeys | FtOpenMode;
|
|
42
42
|
topicsApiEndpoint: string;
|
|
43
43
|
description?: string;
|
|
44
44
|
attachmentsApiEndpoint: string;
|
|
45
|
-
editorialType: FtEditorialType;
|
|
45
|
+
editorialType: FtEditorialTypeKeys | FtEditorialType;
|
|
46
46
|
baseId: string;
|
|
47
47
|
clusterId: string;
|
|
48
48
|
title: string;
|
|
@@ -125,6 +125,12 @@ export interface FtSearchLocales {
|
|
|
125
125
|
contentLocales: Array<FtSearchLocale>;
|
|
126
126
|
}
|
|
127
127
|
export declare const isFtSearchLocales: (o: any) => o is FtSearchLocales;
|
|
128
|
+
export interface FtMessageContext {
|
|
129
|
+
name: string;
|
|
130
|
+
messages: Record<string, string>;
|
|
131
|
+
locale: string;
|
|
132
|
+
}
|
|
133
|
+
export declare const isFtMessageContext: (o: any) => o is FtMessageContext;
|
|
128
134
|
export interface FtUiLocale {
|
|
129
135
|
displayName: string;
|
|
130
136
|
languageTag: string;
|
|
@@ -148,17 +154,17 @@ export declare type FtRatingTypeKeys = keyof typeof FtRatingType;
|
|
|
148
154
|
export declare const isFtRatingType: (o: any) => o is FtRatingType;
|
|
149
155
|
export interface FtPublicationRating {
|
|
150
156
|
date: Date | string;
|
|
151
|
-
type: FtRatingType;
|
|
157
|
+
type: FtRatingTypeKeys | FtRatingType;
|
|
152
158
|
value: number;
|
|
153
159
|
}
|
|
154
160
|
export declare const isFtPublicationRating: (o: any) => o is FtPublicationRating;
|
|
155
161
|
export interface FtPublicationRatingSummary {
|
|
156
162
|
rating?: FtPublicationRating;
|
|
157
|
-
type: FtRatingType;
|
|
163
|
+
type: FtRatingTypeKeys | FtRatingType;
|
|
158
164
|
}
|
|
159
165
|
export declare const isFtPublicationRatingSummary: (o: any) => o is FtPublicationRatingSummary;
|
|
160
166
|
export interface FtRatingCreation {
|
|
161
|
-
type: FtRatingType;
|
|
167
|
+
type: FtRatingTypeKeys | FtRatingType;
|
|
162
168
|
value: number;
|
|
163
169
|
}
|
|
164
170
|
export declare const isFtRatingCreation: (o: any) => o is FtRatingCreation;
|
|
@@ -170,13 +176,13 @@ export declare const isFtRatingSummary: (o: any) => o is FtRatingSummary;
|
|
|
170
176
|
export interface FtTopicRating {
|
|
171
177
|
date: Date | string;
|
|
172
178
|
tocId: string;
|
|
173
|
-
type: FtRatingType;
|
|
179
|
+
type: FtRatingTypeKeys | FtRatingType;
|
|
174
180
|
value: number;
|
|
175
181
|
}
|
|
176
182
|
export declare const isFtTopicRating: (o: any) => o is FtTopicRating;
|
|
177
183
|
export interface FtTopicsRatingSummary {
|
|
178
184
|
ratings: Array<FtTopicRating>;
|
|
179
|
-
type: FtRatingType;
|
|
185
|
+
type: FtRatingTypeKeys | FtRatingType;
|
|
180
186
|
}
|
|
181
187
|
export declare const isFtTopicsRatingSummary: (o: any) => o is FtTopicsRatingSummary;
|
|
182
188
|
export interface FtMapResource {
|
|
@@ -274,13 +280,13 @@ export declare const isFtSearchResultCluster: (o: any) => o is FtSearchResultClu
|
|
|
274
280
|
export interface FtSearchResultClusterEntry {
|
|
275
281
|
document?: FtSearchResultUnstructuredDocument;
|
|
276
282
|
topic?: FtSearchResultTopic;
|
|
277
|
-
type: FtSearchResultType;
|
|
283
|
+
type: FtSearchResultTypeKeys | FtSearchResultType;
|
|
278
284
|
map?: FtSearchResultMap;
|
|
279
285
|
}
|
|
280
286
|
export declare const isFtSearchResultClusterEntry: (o: any) => o is FtSearchResultClusterEntry;
|
|
281
287
|
export interface FtSearchResultUnstructuredDocument {
|
|
282
288
|
metadata: Array<FtMetadata>;
|
|
283
|
-
openMode: FtOpenMode;
|
|
289
|
+
openMode: FtOpenModeKeys | FtOpenMode;
|
|
284
290
|
documentUrl: string;
|
|
285
291
|
mimeType: string;
|
|
286
292
|
source: any;
|
|
@@ -298,8 +304,8 @@ export interface FtSearchResultUnstructuredDocument {
|
|
|
298
304
|
export declare const isFtSearchResultUnstructuredDocument: (o: any) => o is FtSearchResultUnstructuredDocument;
|
|
299
305
|
export interface FtSearchResultMap {
|
|
300
306
|
metadata: Array<FtMetadata>;
|
|
301
|
-
openMode?: FtOpenMode;
|
|
302
|
-
editorialType: FtEditorialType;
|
|
307
|
+
openMode?: FtOpenModeKeys | FtOpenMode;
|
|
308
|
+
editorialType: FtEditorialTypeKeys | FtEditorialType;
|
|
303
309
|
source?: any;
|
|
304
310
|
title: string;
|
|
305
311
|
lastPublicationDate?: string;
|
|
@@ -314,7 +320,7 @@ export interface FtSearchResultMap {
|
|
|
314
320
|
export declare const isFtSearchResultMap: (o: any) => o is FtSearchResultMap;
|
|
315
321
|
export interface FtSearchResultTopic {
|
|
316
322
|
metadata: Array<FtMetadata>;
|
|
317
|
-
openMode: FtOpenMode;
|
|
323
|
+
openMode: FtOpenModeKeys | FtOpenMode;
|
|
318
324
|
contentId: string;
|
|
319
325
|
resources: Array<FtTopicResource>;
|
|
320
326
|
source?: any;
|
|
@@ -391,9 +397,9 @@ export interface FtSuggestRequest {
|
|
|
391
397
|
export declare const isFtSuggestRequest: (o: any) => o is FtSuggestRequest;
|
|
392
398
|
export interface FtSuggestResult {
|
|
393
399
|
filenameExtension?: string;
|
|
394
|
-
editorialType?: FtEditorialType;
|
|
400
|
+
editorialType?: FtEditorialTypeKeys | FtEditorialType;
|
|
395
401
|
mimeType?: string;
|
|
396
|
-
type: FtSearchResultType;
|
|
402
|
+
type: FtSearchResultTypeKeys | FtSearchResultType;
|
|
397
403
|
value: string;
|
|
398
404
|
}
|
|
399
405
|
export declare const isFtSuggestResult: (o: any) => o is FtSuggestResult;
|
|
@@ -429,3 +435,22 @@ export interface FtAuthenticationIdentifier {
|
|
|
429
435
|
realm: string;
|
|
430
436
|
}
|
|
431
437
|
export declare const isFtAuthenticationIdentifier: (o: any) => o is FtAuthenticationIdentifier;
|
|
438
|
+
export interface FtAuthenticatedSession {
|
|
439
|
+
authenticationIdentifier: FtAuthenticationIdentifier;
|
|
440
|
+
profile: FtUserProfile;
|
|
441
|
+
}
|
|
442
|
+
export declare const isFtAuthenticatedSession: (o: any) => o is FtAuthenticatedSession;
|
|
443
|
+
export interface FtSession {
|
|
444
|
+
authenticationIdentifier?: FtAuthenticationIdentifier;
|
|
445
|
+
idleTimeoutInMillis: number;
|
|
446
|
+
profile: FtUserProfile;
|
|
447
|
+
sessionAuthenticated: boolean;
|
|
448
|
+
}
|
|
449
|
+
export declare const isFtSession: (o: any) => o is FtSession;
|
|
450
|
+
export interface FtUserProfile {
|
|
451
|
+
emailAddress?: string;
|
|
452
|
+
displayName?: string;
|
|
453
|
+
roles: Array<FtUserRoleKeys | FtUserRole>;
|
|
454
|
+
userId?: string;
|
|
455
|
+
}
|
|
456
|
+
export declare const isFtUserProfile: (o: any) => o is FtUserProfile;
|
|
@@ -139,6 +139,14 @@ export const isFtSearchLocales = (o) => {
|
|
|
139
139
|
&& ((Array.isArray(o.contentLocales)
|
|
140
140
|
&& o.contentLocales.every((v) => isFtSearchLocale(v))));
|
|
141
141
|
};
|
|
142
|
+
export const isFtMessageContext = (o) => {
|
|
143
|
+
return isObject(o)
|
|
144
|
+
&& (isString(o.name))
|
|
145
|
+
&& ((isObject(o.messages)
|
|
146
|
+
&& Object.keys(o.messages).every((k) => isString(k))
|
|
147
|
+
&& Object.values(o.messages).every((v) => isString(v))))
|
|
148
|
+
&& (isString(o.locale));
|
|
149
|
+
};
|
|
142
150
|
export const isFtUiLocale = (o) => {
|
|
143
151
|
return isObject(o)
|
|
144
152
|
&& (isString(o.displayName))
|
|
@@ -482,3 +490,23 @@ export const isFtAuthenticationIdentifier = (o) => {
|
|
|
482
490
|
&& (isString(o.identifier))
|
|
483
491
|
&& (isString(o.realm));
|
|
484
492
|
};
|
|
493
|
+
export const isFtAuthenticatedSession = (o) => {
|
|
494
|
+
return isObject(o)
|
|
495
|
+
&& (isFtAuthenticationIdentifier(o.authenticationIdentifier))
|
|
496
|
+
&& (isFtUserProfile(o.profile));
|
|
497
|
+
};
|
|
498
|
+
export const isFtSession = (o) => {
|
|
499
|
+
return isObject(o)
|
|
500
|
+
&& (o.authenticationIdentifier == null || isFtAuthenticationIdentifier(o.authenticationIdentifier))
|
|
501
|
+
&& (isNumber(o.idleTimeoutInMillis))
|
|
502
|
+
&& (isFtUserProfile(o.profile))
|
|
503
|
+
&& (isBoolean(o.sessionAuthenticated));
|
|
504
|
+
};
|
|
505
|
+
export const isFtUserProfile = (o) => {
|
|
506
|
+
return isObject(o)
|
|
507
|
+
&& (o.emailAddress == null || isString(o.emailAddress))
|
|
508
|
+
&& (o.displayName == null || isString(o.displayName))
|
|
509
|
+
&& ((Array.isArray(o.roles)
|
|
510
|
+
&& o.roles.every((v) => isFtUserRole(v))))
|
|
511
|
+
&& (o.userId == null || isString(o.userId));
|
|
512
|
+
};
|
|
@@ -10,25 +10,6 @@ export interface FtReaderFeedbackConfiguration {
|
|
|
10
10
|
subjectMetadataIds: Array<string>;
|
|
11
11
|
}
|
|
12
12
|
export declare const isFtReaderFeedbackConfiguration: (o: any) => o is FtReaderFeedbackConfiguration;
|
|
13
|
-
export interface FtAuthenticatedSession {
|
|
14
|
-
authenticationIdentifier: any;
|
|
15
|
-
profile: FtUserProfile;
|
|
16
|
-
}
|
|
17
|
-
export declare const isFtAuthenticatedSession: (o: any) => o is FtAuthenticatedSession;
|
|
18
|
-
export interface FtSession {
|
|
19
|
-
authenticationIdentifier?: any;
|
|
20
|
-
idleTimeoutInMillis: number;
|
|
21
|
-
profile: FtUserProfile;
|
|
22
|
-
sessionAuthenticated: boolean;
|
|
23
|
-
}
|
|
24
|
-
export declare const isFtSession: (o: any) => o is FtSession;
|
|
25
|
-
export interface FtUserProfile {
|
|
26
|
-
emailAddress?: string;
|
|
27
|
-
displayName?: string;
|
|
28
|
-
roles: Array<any>;
|
|
29
|
-
userId?: string;
|
|
30
|
-
}
|
|
31
|
-
export declare const isFtUserProfile: (o: any) => o is FtUserProfile;
|
|
32
13
|
export interface FtMapAttachment {
|
|
33
14
|
file: string;
|
|
34
15
|
size?: number;
|
|
@@ -64,9 +45,3 @@ export interface FtPaginationConfiguration {
|
|
|
64
45
|
splitCurrentPageToc: boolean;
|
|
65
46
|
}
|
|
66
47
|
export declare const isFtPaginationConfiguration: (o: any) => o is FtPaginationConfiguration;
|
|
67
|
-
export interface FtMessageContext {
|
|
68
|
-
name: string;
|
|
69
|
-
messages: Record<string, string>;
|
|
70
|
-
locale: string;
|
|
71
|
-
}
|
|
72
|
-
export declare const isFtMessageContext: (o: any) => o is FtMessageContext;
|
|
@@ -16,23 +16,6 @@ export const isFtReaderFeedbackConfiguration = (o) => {
|
|
|
16
16
|
&& ((Array.isArray(o.subjectMetadataIds)
|
|
17
17
|
&& o.subjectMetadataIds.every((v) => isString(v))));
|
|
18
18
|
};
|
|
19
|
-
export const isFtAuthenticatedSession = (o) => {
|
|
20
|
-
return isObject(o)
|
|
21
|
-
&& (isFtUserProfile(o.profile));
|
|
22
|
-
};
|
|
23
|
-
export const isFtSession = (o) => {
|
|
24
|
-
return isObject(o)
|
|
25
|
-
&& (isNumber(o.idleTimeoutInMillis))
|
|
26
|
-
&& (isFtUserProfile(o.profile))
|
|
27
|
-
&& (isBoolean(o.sessionAuthenticated));
|
|
28
|
-
};
|
|
29
|
-
export const isFtUserProfile = (o) => {
|
|
30
|
-
return isObject(o)
|
|
31
|
-
&& (o.emailAddress == null || isString(o.emailAddress))
|
|
32
|
-
&& (o.displayName == null || isString(o.displayName))
|
|
33
|
-
&& ((Array.isArray(o.roles)))
|
|
34
|
-
&& (o.userId == null || isString(o.userId));
|
|
35
|
-
};
|
|
36
19
|
export const isFtMapAttachment = (o) => {
|
|
37
20
|
return isObject(o)
|
|
38
21
|
&& (isString(o.file))
|
|
@@ -71,11 +54,3 @@ export const isFtPaginationConfiguration = (o) => {
|
|
|
71
54
|
return isObject(o)
|
|
72
55
|
&& (isBoolean(o.splitCurrentPageToc));
|
|
73
56
|
};
|
|
74
|
-
export const isFtMessageContext = (o) => {
|
|
75
|
-
return isObject(o)
|
|
76
|
-
&& (isString(o.name))
|
|
77
|
-
&& ((isObject(o.messages)
|
|
78
|
-
&& Object.keys(o.messages).every((k) => isString(k))
|
|
79
|
-
&& Object.values(o.messages).every((v) => isString(v))))
|
|
80
|
-
&& (isString(o.locale));
|
|
81
|
-
};
|