@fluid-topics/public-api 1.0.48 → 1.0.49
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/build/rollup/fluidtopics.min.js +1 -1
- package/package.json +1 -1
- package/.yarnrc +0 -1
- package/build/cjs/index.js +0 -373
- package/build/cjs/preferences/unauthenticated-preferences.js +0 -67
- package/build/cjs/roles/roles.js +0 -31
- package/build/cjs/types/ft-common/public.js +0 -742
- package/build/cjs/types/ft-server/public.js +0 -69
- package/build/mjs/index.d.ts +0 -168
- package/build/mjs/index.js +0 -358
- package/build/mjs/preferences/unauthenticated-preferences.d.ts +0 -9
- package/build/mjs/preferences/unauthenticated-preferences.js +0 -61
- package/build/mjs/roles/roles.d.ts +0 -2
- package/build/mjs/roles/roles.js +0 -25
- package/build/mjs/types/ft-common/public.d.ts +0 -579
- package/build/mjs/types/ft-common/public.js +0 -666
- package/build/mjs/types/ft-server/public.d.ts +0 -50
- package/build/mjs/types/ft-server/public.js +0 -59
- package/dist/cjs/index.js +0 -373
- package/dist/cjs/package.json +0 -3
- package/dist/cjs/preferences/unauthenticated-preferences.js +0 -67
- package/dist/cjs/roles/roles.js +0 -31
- package/dist/cjs/types/ft-common/public.js +0 -742
- package/dist/cjs/types/ft-server/public.js +0 -69
- package/dist/fluidtopics.min.js +0 -1
- package/dist/mjs/index.d.ts +0 -168
- package/dist/mjs/index.js +0 -358
- package/dist/mjs/package.json +0 -3
- package/dist/mjs/preferences/unauthenticated-preferences.d.ts +0 -9
- package/dist/mjs/preferences/unauthenticated-preferences.js +0 -61
- package/dist/mjs/roles/roles.d.ts +0 -2
- package/dist/mjs/roles/roles.js +0 -25
- package/dist/mjs/types/ft-common/public.d.ts +0 -579
- package/dist/mjs/types/ft-common/public.js +0 -666
- package/dist/mjs/types/ft-server/public.d.ts +0 -50
- package/dist/mjs/types/ft-server/public.js +0 -59
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
export interface FtReaderConfiguration {
|
|
2
|
-
feedback: FtReaderFeedbackConfiguration;
|
|
3
|
-
loadAfterLastVisibleTopic: number;
|
|
4
|
-
loadBeforeFirstVisibleTopic: number;
|
|
5
|
-
}
|
|
6
|
-
export declare const isFtReaderConfiguration: (o: any) => o is FtReaderConfiguration;
|
|
7
|
-
export interface FtReaderFeedbackConfiguration {
|
|
8
|
-
mailsSentByFluidTopics: boolean;
|
|
9
|
-
mailsSentByFluidTopicsForUnauthenticatedUsers: boolean;
|
|
10
|
-
recipients: Array<string>;
|
|
11
|
-
bodyMetadataIds: Array<string>;
|
|
12
|
-
subjectMetadataIds: Array<string>;
|
|
13
|
-
}
|
|
14
|
-
export declare const isFtReaderFeedbackConfiguration: (o: any) => o is FtReaderFeedbackConfiguration;
|
|
15
|
-
export interface FtMapAttachment {
|
|
16
|
-
file: string;
|
|
17
|
-
size?: number;
|
|
18
|
-
externalLink: boolean;
|
|
19
|
-
name: string;
|
|
20
|
-
id: string;
|
|
21
|
-
mimeType?: string;
|
|
22
|
-
viewerUrl?: string;
|
|
23
|
-
}
|
|
24
|
-
export declare const isFtMapAttachment: (o: any) => o is FtMapAttachment;
|
|
25
|
-
export interface FtPageConfiguration {
|
|
26
|
-
parentsVisibility?: Array<boolean>;
|
|
27
|
-
isVisible: boolean;
|
|
28
|
-
}
|
|
29
|
-
export declare const isFtPageConfiguration: (o: any) => o is FtPageConfiguration;
|
|
30
|
-
export interface FtPaginatedToc {
|
|
31
|
-
configuration: FtPaginationConfiguration;
|
|
32
|
-
paginatedToc: Array<FtPaginatedTocNode>;
|
|
33
|
-
}
|
|
34
|
-
export declare const isFtPaginatedToc: (o: any) => o is FtPaginatedToc;
|
|
35
|
-
export interface FtPaginatedTocNode {
|
|
36
|
-
prettyUrl?: string;
|
|
37
|
-
hasRating?: boolean;
|
|
38
|
-
pageToc?: Array<any>;
|
|
39
|
-
tocId?: string;
|
|
40
|
-
children: Array<FtPaginatedTocNode>;
|
|
41
|
-
pageConfiguration?: FtPageConfiguration;
|
|
42
|
-
origin?: any;
|
|
43
|
-
contentId?: string;
|
|
44
|
-
title?: string;
|
|
45
|
-
}
|
|
46
|
-
export declare const isFtPaginatedTocNode: (o: any) => o is FtPaginatedTocNode;
|
|
47
|
-
export interface FtPaginationConfiguration {
|
|
48
|
-
splitCurrentPageToc: boolean;
|
|
49
|
-
}
|
|
50
|
-
export declare const isFtPaginationConfiguration: (o: any) => o is FtPaginationConfiguration;
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
const isObject = (o) => typeof o === "object" && o != null;
|
|
2
|
-
const isBoolean = (o) => typeof o === "boolean";
|
|
3
|
-
const isNumber = (o) => typeof o === "number";
|
|
4
|
-
const isString = (o) => typeof o === "string";
|
|
5
|
-
export const isFtReaderConfiguration = (o) => {
|
|
6
|
-
return isObject(o)
|
|
7
|
-
&& (isFtReaderFeedbackConfiguration(o.feedback))
|
|
8
|
-
&& (isNumber(o.loadAfterLastVisibleTopic))
|
|
9
|
-
&& (isNumber(o.loadBeforeFirstVisibleTopic));
|
|
10
|
-
};
|
|
11
|
-
export const isFtReaderFeedbackConfiguration = (o) => {
|
|
12
|
-
return isObject(o)
|
|
13
|
-
&& (isBoolean(o.mailsSentByFluidTopics))
|
|
14
|
-
&& (isBoolean(o.mailsSentByFluidTopicsForUnauthenticatedUsers))
|
|
15
|
-
&& ((Array.isArray(o.recipients)
|
|
16
|
-
&& o.recipients.every((v) => isString(v))))
|
|
17
|
-
&& ((Array.isArray(o.bodyMetadataIds)
|
|
18
|
-
&& o.bodyMetadataIds.every((v) => isString(v))))
|
|
19
|
-
&& ((Array.isArray(o.subjectMetadataIds)
|
|
20
|
-
&& o.subjectMetadataIds.every((v) => isString(v))));
|
|
21
|
-
};
|
|
22
|
-
export const isFtMapAttachment = (o) => {
|
|
23
|
-
return isObject(o)
|
|
24
|
-
&& (isString(o.file))
|
|
25
|
-
&& (o.size == null || isNumber(o.size))
|
|
26
|
-
&& (isBoolean(o.externalLink))
|
|
27
|
-
&& (isString(o.name))
|
|
28
|
-
&& (isString(o.id))
|
|
29
|
-
&& (o.mimeType == null || isString(o.mimeType))
|
|
30
|
-
&& (o.viewerUrl == null || isString(o.viewerUrl));
|
|
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.hasRating == null || isBoolean(o.hasRating))
|
|
48
|
-
&& (o.pageToc == null || (Array.isArray(o.pageToc)))
|
|
49
|
-
&& (o.tocId == null || isString(o.tocId))
|
|
50
|
-
&& ((Array.isArray(o.children)
|
|
51
|
-
&& o.children.every((v) => isFtPaginatedTocNode(v))))
|
|
52
|
-
&& (o.pageConfiguration == null || isFtPageConfiguration(o.pageConfiguration))
|
|
53
|
-
&& (o.contentId == null || isString(o.contentId))
|
|
54
|
-
&& (o.title == null || isString(o.title));
|
|
55
|
-
};
|
|
56
|
-
export const isFtPaginationConfiguration = (o) => {
|
|
57
|
-
return isObject(o)
|
|
58
|
-
&& (isBoolean(o.splitCurrentPageToc));
|
|
59
|
-
};
|
package/dist/cjs/index.js
DELETED
|
@@ -1,373 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
17
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
18
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
19
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
20
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
21
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
22
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
23
|
-
});
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.FluidTopicsApi = exports.HttpError = void 0;
|
|
27
|
-
require("cross-fetch/polyfill");
|
|
28
|
-
const wnd = (typeof window === "undefined" ? globalThis : window);
|
|
29
|
-
__exportStar(require("./types/ft-common/public"), exports);
|
|
30
|
-
__exportStar(require("./types/ft-server/public"), exports);
|
|
31
|
-
__exportStar(require("./roles/roles"), exports);
|
|
32
|
-
__exportStar(require("./preferences/unauthenticated-preferences"), exports);
|
|
33
|
-
function toBase64(s) {
|
|
34
|
-
return typeof Buffer !== "undefined" ? Buffer.from(s).toString("base64") : btoa(s);
|
|
35
|
-
}
|
|
36
|
-
class HttpError extends Error {
|
|
37
|
-
constructor(status, statusText, body) {
|
|
38
|
-
super(`${status} - ${statusText}: ${body}`);
|
|
39
|
-
this.status = status;
|
|
40
|
-
this.statusText = statusText;
|
|
41
|
-
this.body = body;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
exports.HttpError = HttpError;
|
|
45
|
-
function handleError(response) {
|
|
46
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
-
if (!response.ok) {
|
|
48
|
-
throw new HttpError(response.status, response.statusText, yield response.text());
|
|
49
|
-
}
|
|
50
|
-
return response;
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
function getBody(response) {
|
|
54
|
-
return response.headers.get("Content-Type") === "application/json" ? response.json() : response.text();
|
|
55
|
-
}
|
|
56
|
-
class FluidTopicsApi {
|
|
57
|
-
get defaultHeaders() {
|
|
58
|
-
return Object.assign(Object.assign(Object.assign({}, this.authorization), this.searchLabel), { "Ft-Calling-App": this.ftCallingApp });
|
|
59
|
-
}
|
|
60
|
-
constructor(tenantBaseUrl, integrationIdentifier, overrideIdentifierIfOnTenant) {
|
|
61
|
-
var _a, _b, _c, _d, _e, _f;
|
|
62
|
-
this.endpoints = {
|
|
63
|
-
authentication: {
|
|
64
|
-
login: `api/authentication/login`,
|
|
65
|
-
logout: `api/authentication/logout`,
|
|
66
|
-
currentSession: `api/authentication/current-session`,
|
|
67
|
-
},
|
|
68
|
-
khub: {
|
|
69
|
-
maps: {
|
|
70
|
-
mapId: (mapId) => ({
|
|
71
|
-
info: `api/khub/maps/${mapId}`,
|
|
72
|
-
toc: `api/khub/maps/${mapId}/toc`,
|
|
73
|
-
pages: `api/khub/maps/${mapId}/pages`,
|
|
74
|
-
feedback: `api/khub/maps/${mapId}/feedback`,
|
|
75
|
-
rating: `api/khub/maps/${mapId}/rating`,
|
|
76
|
-
attachments: {
|
|
77
|
-
list: `api/khub/maps/${mapId}/attachments`,
|
|
78
|
-
attachmentId: (attachmentId) => ({
|
|
79
|
-
content: `api/khub/maps/${mapId}/attachments/${attachmentId}/content`,
|
|
80
|
-
})
|
|
81
|
-
},
|
|
82
|
-
resources: {
|
|
83
|
-
list: `api/khub/maps/${mapId}/resources`,
|
|
84
|
-
resourceId: (resourceId) => ({
|
|
85
|
-
content: `api/khub/maps/${mapId}/resources/${resourceId}/content`,
|
|
86
|
-
})
|
|
87
|
-
},
|
|
88
|
-
topics: {
|
|
89
|
-
contentId: (contentId) => ({
|
|
90
|
-
info: `api/khub/maps/${mapId}/topics/${contentId}`,
|
|
91
|
-
content: `api/khub/maps/${mapId}/topics/${contentId}/content`,
|
|
92
|
-
}),
|
|
93
|
-
tocId: (tocId) => ({
|
|
94
|
-
feedback: `api/khub/maps/${mapId}/topics/${tocId}/feedback`,
|
|
95
|
-
rating: `api/khub/maps/${mapId}/topics/${tocId}/rating`,
|
|
96
|
-
})
|
|
97
|
-
},
|
|
98
|
-
})
|
|
99
|
-
},
|
|
100
|
-
documents: {
|
|
101
|
-
documentId: (documentId) => ({
|
|
102
|
-
info: `api/khub/documents/${documentId}`,
|
|
103
|
-
content: `api/khub/documents/${documentId}/content`,
|
|
104
|
-
text: `api/khub/documents/${documentId}/content/text`,
|
|
105
|
-
feedback: `api/khub/documents/${documentId}/feedback`,
|
|
106
|
-
rating: `api/khub/documents/${documentId}/rating`,
|
|
107
|
-
})
|
|
108
|
-
},
|
|
109
|
-
suggest: `api/khub/suggest`,
|
|
110
|
-
clusteredSearch: `api/khub/clustered-search`,
|
|
111
|
-
locales: `api/khub/locales`,
|
|
112
|
-
},
|
|
113
|
-
users: {
|
|
114
|
-
userId: (userId) => ({
|
|
115
|
-
collections: {
|
|
116
|
-
collectionId: (collectionId) => ({
|
|
117
|
-
documents: `api/users/${userId}/collections/${collectionId}/documents`,
|
|
118
|
-
})
|
|
119
|
-
},
|
|
120
|
-
searches: {
|
|
121
|
-
list: `api/users/${userId}/searches`
|
|
122
|
-
},
|
|
123
|
-
bookmarks: {
|
|
124
|
-
list: `api/users/${userId}/bookmarks`
|
|
125
|
-
}
|
|
126
|
-
}),
|
|
127
|
-
},
|
|
128
|
-
stylesheets: {
|
|
129
|
-
fonts: `api/stylesheets/fonts.css`,
|
|
130
|
-
theme: `api/stylesheets/theme.css`,
|
|
131
|
-
content: {
|
|
132
|
-
title: `api/stylesheets/content/title.css`,
|
|
133
|
-
topic: `api/stylesheets/content/topic.css`,
|
|
134
|
-
},
|
|
135
|
-
},
|
|
136
|
-
configuration: {
|
|
137
|
-
reader: `api/configuration/reader`
|
|
138
|
-
},
|
|
139
|
-
locales: {
|
|
140
|
-
ui: `api/locales/ui`
|
|
141
|
-
},
|
|
142
|
-
messages: {
|
|
143
|
-
locale: (locale) => ({
|
|
144
|
-
fluidTopics: {
|
|
145
|
-
contextName: (contextName) => ({
|
|
146
|
-
endpoint: `api/messages/${locale}/fluid-topics/${contextName}`,
|
|
147
|
-
})
|
|
148
|
-
},
|
|
149
|
-
custom: {
|
|
150
|
-
contextName: (contextName) => ({
|
|
151
|
-
endpoint: `api/messages/${locale}/custom/${contextName}`,
|
|
152
|
-
})
|
|
153
|
-
}
|
|
154
|
-
})
|
|
155
|
-
},
|
|
156
|
-
};
|
|
157
|
-
//@ts-ignore
|
|
158
|
-
tenantBaseUrl = ((_f = (_c = (_a = tenantBaseUrl !== null && tenantBaseUrl !== void 0 ? tenantBaseUrl : wnd.__gwt_ft_moduleBase) !== null && _a !== void 0 ? _a : (_b = wnd.fluidtopicsclient) === null || _b === void 0 ? void 0 : _b.__moduleBase) !== null && _c !== void 0 ? _c : (_e = (_d = wnd.__gwt_activeModules) === null || _d === void 0 ? void 0 : _d.fluidtopicsclient) === null || _e === void 0 ? void 0 : _e.moduleBase) !== null && _f !== void 0 ? _f : "").trim();
|
|
159
|
-
this.tenantBaseUrl = tenantBaseUrl.endsWith("/") ? tenantBaseUrl : tenantBaseUrl + "/";
|
|
160
|
-
if (overrideIdentifierIfOnTenant && typeof wnd.location !== "undefined" && wnd.location.href.startsWith(this.tenantBaseUrl)) {
|
|
161
|
-
this.ftCallingApp = integrationIdentifier;
|
|
162
|
-
}
|
|
163
|
-
else {
|
|
164
|
-
this.ftCallingApp = `ft-public-api/${integrationIdentifier}`;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
setApiKey(apiKey) {
|
|
168
|
-
this.authorization = { "Authorization": "Bearer " + apiKey };
|
|
169
|
-
}
|
|
170
|
-
setCredentials(login, password) {
|
|
171
|
-
this.authorization = { "Authorization": "Basic " + toBase64(`${login}:${password}`) };
|
|
172
|
-
}
|
|
173
|
-
clearAuthentication() {
|
|
174
|
-
this.authorization = undefined;
|
|
175
|
-
}
|
|
176
|
-
setSearchLabel(searchLabel) {
|
|
177
|
-
this.searchLabel = { "FT-search-label": searchLabel };
|
|
178
|
-
}
|
|
179
|
-
clearSearchLabel() {
|
|
180
|
-
this.searchLabel = undefined;
|
|
181
|
-
}
|
|
182
|
-
login(login, password) {
|
|
183
|
-
let credentials = {
|
|
184
|
-
login: login,
|
|
185
|
-
password: password,
|
|
186
|
-
rememberMe: true
|
|
187
|
-
};
|
|
188
|
-
return this.post(this.endpoints.authentication.login, credentials)
|
|
189
|
-
.then(result => {
|
|
190
|
-
this.setCredentials(login, password);
|
|
191
|
-
return result;
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
logout() {
|
|
195
|
-
return this.post(this.endpoints.authentication.logout)
|
|
196
|
-
.then(() => this.clearAuthentication());
|
|
197
|
-
}
|
|
198
|
-
getCurrentSession() {
|
|
199
|
-
return this.get(this.endpoints.authentication.currentSession);
|
|
200
|
-
}
|
|
201
|
-
getReaderConfiguration() {
|
|
202
|
-
return this.get(this.endpoints.configuration.reader);
|
|
203
|
-
}
|
|
204
|
-
getMap(mapId, v) {
|
|
205
|
-
return this.get(this.endpoints.khub.maps.mapId(mapId).info, v);
|
|
206
|
-
}
|
|
207
|
-
getTableOfContent(mapId, v) {
|
|
208
|
-
return this.get(this.endpoints.khub.maps.mapId(mapId).toc, v);
|
|
209
|
-
}
|
|
210
|
-
getPages(mapId, v) {
|
|
211
|
-
return this.get(this.endpoints.khub.maps.mapId(mapId).pages, v);
|
|
212
|
-
}
|
|
213
|
-
getTopic(mapId, topicContentId, v) {
|
|
214
|
-
return this.get(this.endpoints.khub.maps.mapId(mapId).topics.contentId(topicContentId).info, v);
|
|
215
|
-
}
|
|
216
|
-
getTopicHTMLContent(mapId, topicContentId, target, v) {
|
|
217
|
-
return this.get(this.endpoints.khub.maps.mapId(mapId).topics.contentId(topicContentId).content + (target ? "?target=" + target : ""), v);
|
|
218
|
-
}
|
|
219
|
-
getMapAttachments(mapId, v) {
|
|
220
|
-
return this.get(this.endpoints.khub.maps.mapId(mapId).attachments.list, v);
|
|
221
|
-
}
|
|
222
|
-
getMapAttachmentContent(mapId, attachmentId, v) {
|
|
223
|
-
return this.fetchRawData(this.endpoints.khub.maps.mapId(mapId).attachments.attachmentId(attachmentId).content, v);
|
|
224
|
-
}
|
|
225
|
-
getMapResources(mapId, v) {
|
|
226
|
-
return this.get(this.endpoints.khub.maps.mapId(mapId).resources.list, v);
|
|
227
|
-
}
|
|
228
|
-
getMapResourceContent(mapId, resourceId, v) {
|
|
229
|
-
return this.fetchRawData(this.endpoints.khub.maps.mapId(mapId).resources.resourceId(resourceId).content, v);
|
|
230
|
-
}
|
|
231
|
-
getUnstructuredDocument(documentId, v) {
|
|
232
|
-
return this.get(this.endpoints.khub.documents.documentId(documentId).info, v);
|
|
233
|
-
}
|
|
234
|
-
getUnstructuredDocumentContent(documentId, v) {
|
|
235
|
-
return this.fetchRawData(this.endpoints.khub.documents.documentId(documentId).content, v);
|
|
236
|
-
}
|
|
237
|
-
getUnstructuredDocumentTextContent(documentId, v) {
|
|
238
|
-
return this.get(this.endpoints.khub.documents.documentId(documentId).text, v);
|
|
239
|
-
}
|
|
240
|
-
getCollectionDocuments(userId, collectionId) {
|
|
241
|
-
return this.get(this.endpoints.users.userId(userId).collections.collectionId(collectionId).documents);
|
|
242
|
-
}
|
|
243
|
-
getSuggestions(request) {
|
|
244
|
-
return this.post(this.endpoints.khub.suggest, request);
|
|
245
|
-
}
|
|
246
|
-
search(request) {
|
|
247
|
-
return this.post(this.endpoints.khub.clusteredSearch, request);
|
|
248
|
-
}
|
|
249
|
-
getAvailableSearchLocales() {
|
|
250
|
-
return this.get(this.endpoints.khub.locales);
|
|
251
|
-
}
|
|
252
|
-
getAvailableUiLocales() {
|
|
253
|
-
return this.get(this.endpoints.khub.locales);
|
|
254
|
-
}
|
|
255
|
-
getMapRating(mapId) {
|
|
256
|
-
return this.get(this.endpoints.khub.maps.mapId(mapId).rating);
|
|
257
|
-
}
|
|
258
|
-
rateMap(mapId, type, value) {
|
|
259
|
-
return this.post(this.endpoints.khub.maps.mapId(mapId).rating, { type, value });
|
|
260
|
-
}
|
|
261
|
-
unrateMap(mapId) {
|
|
262
|
-
return this.delete(this.endpoints.khub.maps.mapId(mapId).rating);
|
|
263
|
-
}
|
|
264
|
-
sendMapFeedback(mapId, message, from) {
|
|
265
|
-
return this.post(this.endpoints.khub.maps.mapId(mapId).feedback, { message, from });
|
|
266
|
-
}
|
|
267
|
-
rateTopic(mapId, tocId, type, value) {
|
|
268
|
-
return this.post(this.endpoints.khub.maps.mapId(mapId).topics.tocId(tocId).rating, {
|
|
269
|
-
type, value
|
|
270
|
-
});
|
|
271
|
-
}
|
|
272
|
-
unrateTopic(mapId, tocId) {
|
|
273
|
-
return this.delete(this.endpoints.khub.maps.mapId(mapId).topics.tocId(tocId).rating);
|
|
274
|
-
}
|
|
275
|
-
sendTopicFeedback(mapId, tocId, message, from) {
|
|
276
|
-
return this.post(this.endpoints.khub.maps.mapId(mapId).topics.tocId(tocId).feedback, { message, from });
|
|
277
|
-
}
|
|
278
|
-
getDocumentRating(docId) {
|
|
279
|
-
return this.get(this.endpoints.khub.documents.documentId(docId).rating);
|
|
280
|
-
}
|
|
281
|
-
rateDocument(docId, type, value) {
|
|
282
|
-
return this.post(this.endpoints.khub.documents.documentId(docId).rating, { type, value });
|
|
283
|
-
}
|
|
284
|
-
unrateDocument(docId) {
|
|
285
|
-
return this.delete(this.endpoints.khub.documents.documentId(docId).rating);
|
|
286
|
-
}
|
|
287
|
-
sendDocumentFeedback(docId, message, from) {
|
|
288
|
-
return this.post(this.endpoints.khub.documents.documentId(docId).feedback, { message, from });
|
|
289
|
-
}
|
|
290
|
-
getFluidTopicsMessageContext(locale, name) {
|
|
291
|
-
return this.get(this.endpoints.messages.locale(locale).fluidTopics.contextName(name).endpoint);
|
|
292
|
-
}
|
|
293
|
-
getCustomMessageContext(locale, name) {
|
|
294
|
-
return this.get(this.endpoints.messages.locale(locale).custom.contextName(name).endpoint);
|
|
295
|
-
}
|
|
296
|
-
listMySearches(userId) {
|
|
297
|
-
return this.get(this.endpoints.users.userId(userId).searches.list);
|
|
298
|
-
}
|
|
299
|
-
listMyBookmarks(userId) {
|
|
300
|
-
return this.get(this.endpoints.users.userId(userId).bookmarks.list);
|
|
301
|
-
}
|
|
302
|
-
get(endpoint, v) {
|
|
303
|
-
return this.makeRequest("GET", this.withVersion(endpoint, v));
|
|
304
|
-
}
|
|
305
|
-
post(endpoint, data) {
|
|
306
|
-
return this.makeRequest("POST", endpoint, data);
|
|
307
|
-
}
|
|
308
|
-
put(endpoint, data) {
|
|
309
|
-
return this.makeRequest("PUT", endpoint, data);
|
|
310
|
-
}
|
|
311
|
-
delete(endpoint) {
|
|
312
|
-
return this.makeRequest("DELETE", endpoint);
|
|
313
|
-
}
|
|
314
|
-
makeAbsolute(endpoint) {
|
|
315
|
-
return endpoint.startsWith(this.tenantBaseUrl) ? endpoint : (this.tenantBaseUrl + endpoint.replace(/^\//, ""));
|
|
316
|
-
}
|
|
317
|
-
fetch(endpoint, init) {
|
|
318
|
-
var _a;
|
|
319
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
320
|
-
const requestInit = init;
|
|
321
|
-
return yield fetch(this.makeAbsolute(endpoint), Object.assign(Object.assign({}, (requestInit !== null && requestInit !== void 0 ? requestInit : {})), { headers: Object.assign(Object.assign({}, this.defaultHeaders), ((_a = requestInit === null || requestInit === void 0 ? void 0 : requestInit.headers) !== null && _a !== void 0 ? _a : {})) }));
|
|
322
|
-
});
|
|
323
|
-
}
|
|
324
|
-
upload(method, endpoint, body, onProgress = () => undefined) {
|
|
325
|
-
if (typeof XMLHttpRequest !== "undefined") {
|
|
326
|
-
return new Promise((resolve, reject) => {
|
|
327
|
-
let xhr = new XMLHttpRequest();
|
|
328
|
-
xhr.onload = () => {
|
|
329
|
-
if (xhr.status >= 200 && xhr.status < 300) {
|
|
330
|
-
let data = xhr.getResponseHeader("Content-Type") === "application/json" ? JSON.parse(xhr.responseText) : xhr.responseText;
|
|
331
|
-
resolve(data);
|
|
332
|
-
}
|
|
333
|
-
else {
|
|
334
|
-
reject(new HttpError(xhr.status, xhr.statusText, xhr.responseText));
|
|
335
|
-
}
|
|
336
|
-
};
|
|
337
|
-
xhr.upload.onprogress = (e) => onProgress(e);
|
|
338
|
-
xhr.open(method, this.makeAbsolute(endpoint), true);
|
|
339
|
-
xhr.send(body);
|
|
340
|
-
});
|
|
341
|
-
}
|
|
342
|
-
else {
|
|
343
|
-
return this.fetch(endpoint, { method, body }).then(handleError).then(getBody);
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
makeRequest(method, endpoint, data) {
|
|
347
|
-
return this.fetch(endpoint, {
|
|
348
|
-
method: method,
|
|
349
|
-
headers: Object.assign({}, (data != null ? { "Content-Type": "application/json" } : {})),
|
|
350
|
-
body: data != null ? JSON.stringify(data) : undefined,
|
|
351
|
-
credentials: this.authorization == null ? "include" : undefined
|
|
352
|
-
})
|
|
353
|
-
.then(handleError)
|
|
354
|
-
.then(getBody);
|
|
355
|
-
}
|
|
356
|
-
fetchRawData(endpoint, v) {
|
|
357
|
-
return fetch(this.withVersion(endpoint, v), {
|
|
358
|
-
headers: this.defaultHeaders,
|
|
359
|
-
credentials: this.authorization == null ? "include" : undefined
|
|
360
|
-
})
|
|
361
|
-
.then(handleError)
|
|
362
|
-
.then(response => response.arrayBuffer());
|
|
363
|
-
}
|
|
364
|
-
withVersion(endpoint, v) {
|
|
365
|
-
let url = new URL(this.makeAbsolute(endpoint));
|
|
366
|
-
if (v) {
|
|
367
|
-
url.searchParams.append("v", v);
|
|
368
|
-
}
|
|
369
|
-
return url.toString();
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
exports.FluidTopicsApi = FluidTopicsApi;
|
|
373
|
-
exports.default = FluidTopicsApi;
|
package/dist/cjs/package.json
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.addUnauthenticatedUserSearchPreferencesChangeHandler = exports.getUnauthenticatedUserSearchPreferences = exports.setUnauthenticatedUserSearchPreferences = void 0;
|
|
4
|
-
const wnd = (typeof window === "undefined" ? globalThis : window);
|
|
5
|
-
function normalizeMetadataPreferences(metadata) {
|
|
6
|
-
let normalized = {};
|
|
7
|
-
for (let key in metadata) {
|
|
8
|
-
let values = metadata[key];
|
|
9
|
-
if (typeof values !== "object" || Array.isArray(values)) {
|
|
10
|
-
values = { prior: values };
|
|
11
|
-
}
|
|
12
|
-
for (let property of ["prior", "filter"]) {
|
|
13
|
-
values[property] = Array.isArray(values[property]) ? values[property] : [values[property]];
|
|
14
|
-
values[property] = values[property]
|
|
15
|
-
.map(v => v != null ? "" + v : "")
|
|
16
|
-
.filter(v => v !== "");
|
|
17
|
-
}
|
|
18
|
-
normalized[key] = values;
|
|
19
|
-
}
|
|
20
|
-
return normalized;
|
|
21
|
-
}
|
|
22
|
-
function getStorageKey(tenantBaseUrl) {
|
|
23
|
-
return `${tenantBaseUrl}-FluidTopicsUnauthenticatedUserSearchPreferences`;
|
|
24
|
-
}
|
|
25
|
-
function setUnauthenticatedUserSearchPreferences(tenantBaseUrl, input) {
|
|
26
|
-
var _a;
|
|
27
|
-
if (wnd.localStorage) {
|
|
28
|
-
let preferences = Object.assign(Object.assign({}, input), { metadata: normalizeMetadataPreferences((_a = input.metadata) !== null && _a !== void 0 ? _a : {}) });
|
|
29
|
-
const key = getStorageKey(tenantBaseUrl);
|
|
30
|
-
const newValue = JSON.stringify(preferences);
|
|
31
|
-
wnd.localStorage.setItem(key, newValue);
|
|
32
|
-
wnd.dispatchEvent(new StorageEvent("storage", {
|
|
33
|
-
key,
|
|
34
|
-
newValue,
|
|
35
|
-
storageArea: wnd.localStorage,
|
|
36
|
-
url: wnd.location.href
|
|
37
|
-
}));
|
|
38
|
-
return preferences;
|
|
39
|
-
}
|
|
40
|
-
console.error("Cannot set unauthenticated preferences: local storage is unavailable.");
|
|
41
|
-
}
|
|
42
|
-
exports.setUnauthenticatedUserSearchPreferences = setUnauthenticatedUserSearchPreferences;
|
|
43
|
-
function getUnauthenticatedUserSearchPreferences(tenantBaseUrl) {
|
|
44
|
-
var _a;
|
|
45
|
-
if (wnd.localStorage) {
|
|
46
|
-
return JSON.parse((_a = wnd.localStorage.getItem(getStorageKey(tenantBaseUrl))) !== null && _a !== void 0 ? _a : "{}");
|
|
47
|
-
}
|
|
48
|
-
console.error("Cannot get unauthenticated preferences: local storage is unavailable.");
|
|
49
|
-
}
|
|
50
|
-
exports.getUnauthenticatedUserSearchPreferences = getUnauthenticatedUserSearchPreferences;
|
|
51
|
-
function addUnauthenticatedUserSearchPreferencesChangeHandler(tenantBaseUrl, handler) {
|
|
52
|
-
if (wnd.localStorage) {
|
|
53
|
-
const key = getStorageKey(tenantBaseUrl);
|
|
54
|
-
const eventListener = (event) => {
|
|
55
|
-
var _a;
|
|
56
|
-
if (event.storageArea === wnd.localStorage && event.key === key) {
|
|
57
|
-
handler(JSON.parse((_a = event.newValue) !== null && _a !== void 0 ? _a : "{}"));
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
wnd.addEventListener("storage", eventListener);
|
|
61
|
-
return {
|
|
62
|
-
removeHandler: () => wnd.removeEventListener("storage", eventListener)
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
console.error("Cannot handle unauthenticated preferences: local storage is unavailable.");
|
|
66
|
-
}
|
|
67
|
-
exports.addUnauthenticatedUserSearchPreferencesChangeHandler = addUnauthenticatedUserSearchPreferencesChangeHandler;
|
package/dist/cjs/roles/roles.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.userHasRole = void 0;
|
|
4
|
-
const public_1 = require("../types/ft-common/public");
|
|
5
|
-
const rolesInheritance = {
|
|
6
|
-
[public_1.FtUserRole.PERSONAL_BOOK_SHARE_USER]: [public_1.FtUserRole.PERSONAL_BOOK_USER],
|
|
7
|
-
[public_1.FtUserRole.HTML_EXPORT_USER]: [public_1.FtUserRole.PERSONAL_BOOK_USER],
|
|
8
|
-
[public_1.FtUserRole.PDF_EXPORT_USER]: [public_1.FtUserRole.PERSONAL_BOOK_USER],
|
|
9
|
-
[public_1.FtUserRole.KHUB_ADMIN]: [public_1.FtUserRole.CONTENT_PUBLISHER],
|
|
10
|
-
[public_1.FtUserRole.ADMIN]: [public_1.FtUserRole.KHUB_ADMIN, public_1.FtUserRole.USERS_ADMIN, public_1.FtUserRole.PORTAL_ADMIN],
|
|
11
|
-
[public_1.FtUserRole.DEVELOPER]: [public_1.FtUserRole.BETA_USER, public_1.FtUserRole.DEBUG_USER],
|
|
12
|
-
};
|
|
13
|
-
function roleMatches(actual, expected) {
|
|
14
|
-
var _a;
|
|
15
|
-
return actual === expected || ((_a = rolesInheritance[actual]) !== null && _a !== void 0 ? _a : []).some((inherited) => roleMatches(inherited, expected));
|
|
16
|
-
}
|
|
17
|
-
function userHasRole(sessionOrProfileOrRoles, expectedRole) {
|
|
18
|
-
var _a;
|
|
19
|
-
if (sessionOrProfileOrRoles == null) {
|
|
20
|
-
return false;
|
|
21
|
-
}
|
|
22
|
-
const roles = Array.isArray(sessionOrProfileOrRoles)
|
|
23
|
-
? sessionOrProfileOrRoles
|
|
24
|
-
: Array.isArray(sessionOrProfileOrRoles.roles)
|
|
25
|
-
? sessionOrProfileOrRoles.roles
|
|
26
|
-
: Array.isArray((_a = sessionOrProfileOrRoles.profile) === null || _a === void 0 ? void 0 : _a.roles)
|
|
27
|
-
? sessionOrProfileOrRoles.profile.roles
|
|
28
|
-
: [];
|
|
29
|
-
return roles.some(role => roleMatches(role, expectedRole));
|
|
30
|
-
}
|
|
31
|
-
exports.userHasRole = userHasRole;
|