@fluid-topics/public-api 1.0.9 → 1.0.13
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 +35 -14
- package/dist/cjs/types/ft-common/public.js +11 -1
- package/dist/fluidtopics.min.js +1 -1
- package/dist/mjs/index.d.ts +11 -3
- package/dist/mjs/index.js +38 -13
- package/dist/mjs/types/ft-common/public.d.ts +5 -0
- package/dist/mjs/types/ft-common/public.js +9 -0
- package/package.json +2 -2
package/dist/cjs/index.js
CHANGED
|
@@ -19,18 +19,26 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
19
19
|
});
|
|
20
20
|
};
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.FluidTopicsApi = void 0;
|
|
22
|
+
exports.FluidTopicsApi = exports.HttpError = void 0;
|
|
23
23
|
require("cross-fetch/polyfill");
|
|
24
24
|
__exportStar(require("./types/ft-common/public"), exports);
|
|
25
25
|
__exportStar(require("./types/ft-server/public"), exports);
|
|
26
26
|
function toBase64(s) {
|
|
27
27
|
return typeof Buffer !== "undefined" ? Buffer.from(s).toString("base64") : btoa(s);
|
|
28
28
|
}
|
|
29
|
+
class HttpError extends Error {
|
|
30
|
+
constructor(status, statusText, body) {
|
|
31
|
+
super(`${status} - ${statusText}: ${body}`);
|
|
32
|
+
this.status = status;
|
|
33
|
+
this.statusText = statusText;
|
|
34
|
+
this.body = body;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.HttpError = HttpError;
|
|
29
38
|
function handleError(response) {
|
|
30
39
|
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
-
if (response.
|
|
32
|
-
|
|
33
|
-
throw new Error(`${response.status}: ${response.statusText}`);
|
|
40
|
+
if (!response.ok) {
|
|
41
|
+
throw new HttpError(response.status, response.statusText, yield response.text());
|
|
34
42
|
}
|
|
35
43
|
return response;
|
|
36
44
|
});
|
|
@@ -81,14 +89,14 @@ class FluidTopicsApi {
|
|
|
81
89
|
getTopic(mapId, topicContentId) {
|
|
82
90
|
return this.get(`/api/khub/maps/${mapId}/topics/${topicContentId}`);
|
|
83
91
|
}
|
|
84
|
-
getTopicHTMLContent(mapId, topicContentId) {
|
|
85
|
-
return this.get(`/api/khub/maps/${mapId}/topics/${topicContentId}/content`);
|
|
92
|
+
getTopicHTMLContent(mapId, topicContentId, target) {
|
|
93
|
+
return this.get(`/api/khub/maps/${mapId}/topics/${topicContentId}/content${target ? "?target=" + target : ""}`);
|
|
86
94
|
}
|
|
87
95
|
getMapAttachments(mapId) {
|
|
88
96
|
return this.get(`/api/khub/maps/${mapId}/attachments`);
|
|
89
97
|
}
|
|
90
98
|
getMapAttachmentContent(mapId, attachmentId) {
|
|
91
|
-
return this.fetchRawData(`/api/khub/maps/${mapId}/attachments/${attachmentId}`);
|
|
99
|
+
return this.fetchRawData(`/api/khub/maps/${mapId}/attachments/${attachmentId}/content`);
|
|
92
100
|
}
|
|
93
101
|
getMapResources(mapId) {
|
|
94
102
|
return this.get(`/api/khub/maps/${mapId}/resources`);
|
|
@@ -102,25 +110,38 @@ class FluidTopicsApi {
|
|
|
102
110
|
getUnstructuredDocumentContent(documentId) {
|
|
103
111
|
return this.fetchRawData(`/api/khub/documents/${documentId}/content`);
|
|
104
112
|
}
|
|
113
|
+
getUnstructuredDocumentTextContent(documentId) {
|
|
114
|
+
return this.get(`/api/khub/documents/${documentId}/content/text`);
|
|
115
|
+
}
|
|
105
116
|
getCollectionDocuments(userId, collectionId) {
|
|
106
117
|
return this.get(`/api/users/${userId}/collections/${collectionId}/documents`);
|
|
107
118
|
}
|
|
108
119
|
get(endpoint) {
|
|
109
|
-
return this.
|
|
120
|
+
return this.makeRequest("GET", endpoint);
|
|
110
121
|
}
|
|
111
122
|
post(endpoint, data) {
|
|
112
|
-
return this.
|
|
123
|
+
return this.makeRequest("POST", endpoint, data);
|
|
113
124
|
}
|
|
114
125
|
put(endpoint, data) {
|
|
115
|
-
return this.
|
|
126
|
+
return this.makeRequest("PUT", endpoint, data);
|
|
116
127
|
}
|
|
117
128
|
delete(endpoint) {
|
|
118
|
-
return this.
|
|
129
|
+
return this.makeRequest("DELETE", endpoint);
|
|
130
|
+
}
|
|
131
|
+
fetch(endpoint, init) {
|
|
132
|
+
var _a;
|
|
133
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
134
|
+
const requestInit = init;
|
|
135
|
+
if (!endpoint.startsWith("/")) {
|
|
136
|
+
endpoint = "/" + endpoint;
|
|
137
|
+
}
|
|
138
|
+
return yield fetch(this.tenantBaseUrl + endpoint, Object.assign(Object.assign({}, (requestInit !== null && requestInit !== void 0 ? requestInit : {})), { headers: Object.assign(Object.assign({}, this.defaultHeaders), ((_a = requestInit === null || requestInit === void 0 ? void 0 : requestInit.headers) !== null && _a !== void 0 ? _a : {})) }));
|
|
139
|
+
});
|
|
119
140
|
}
|
|
120
|
-
|
|
121
|
-
return fetch(
|
|
141
|
+
makeRequest(method, endpoint, data) {
|
|
142
|
+
return this.fetch(endpoint, {
|
|
122
143
|
method: method,
|
|
123
|
-
headers: Object.assign(
|
|
144
|
+
headers: Object.assign({}, (data != null ? { "Content-Type": "application/json" } : {})),
|
|
124
145
|
body: data != null ? JSON.stringify(data) : undefined
|
|
125
146
|
})
|
|
126
147
|
.then(handleError)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isFtAuthenticationIdentifier = exports.isFtSearchResultType = exports.FtSearchResultType = exports.isFtOpenMode = exports.FtOpenMode = exports.isFtEditorialType = exports.FtEditorialType = exports.isFtMapResource = exports.isFtMetadata = exports.isFtUnstructuredDocument = exports.isFtTopic = exports.isFtTocNode = exports.isFtMap = exports.isFtCollectionDocument = exports.isFtCredentials = void 0;
|
|
3
|
+
exports.isFtAuthenticationIdentifier = exports.isFtSearchResultType = exports.FtSearchResultType = exports.isFtOpenMode = exports.FtOpenMode = exports.isFtEditorialType = exports.FtEditorialType = exports.isFtMapResource = exports.isFtMetadata = exports.isFtTopicContentTarget = exports.FtTopicContentTarget = exports.isFtUnstructuredDocument = exports.isFtTopic = exports.isFtTocNode = exports.isFtMap = exports.isFtCollectionDocument = exports.isFtCredentials = void 0;
|
|
4
4
|
const isObject = (o) => typeof o === "object" && o != null;
|
|
5
5
|
const isBoolean = (o) => typeof o === "boolean";
|
|
6
6
|
const isNumber = (o) => typeof o === "number";
|
|
@@ -89,6 +89,16 @@ const isFtUnstructuredDocument = (o) => {
|
|
|
89
89
|
&& (o.lang == null || isString(o.lang));
|
|
90
90
|
};
|
|
91
91
|
exports.isFtUnstructuredDocument = isFtUnstructuredDocument;
|
|
92
|
+
// From: WsTopicContentTarget
|
|
93
|
+
var FtTopicContentTarget;
|
|
94
|
+
(function (FtTopicContentTarget) {
|
|
95
|
+
FtTopicContentTarget["THIRD_PARTY"] = "THIRD_PARTY";
|
|
96
|
+
FtTopicContentTarget["OFF_THE_GRID"] = "OFF_THE_GRID";
|
|
97
|
+
})(FtTopicContentTarget = exports.FtTopicContentTarget || (exports.FtTopicContentTarget = {}));
|
|
98
|
+
const isFtTopicContentTarget = (o) => {
|
|
99
|
+
return ["THIRD_PARTY", "OFF_THE_GRID"].includes(o);
|
|
100
|
+
};
|
|
101
|
+
exports.isFtTopicContentTarget = isFtTopicContentTarget;
|
|
92
102
|
const isFtMetadata = (o) => {
|
|
93
103
|
return isObject(o)
|
|
94
104
|
&& ((Array.isArray(o.values)
|
package/dist/fluidtopics.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).fluidtopics={})}(this,(function(t){"use strict";var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n={exports:{}},i={exports:{}};!function(t,e){var n=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==n)return n;throw new Error("unable to locate global object")}();t.exports=e=n.fetch,n.fetch&&(e.default=n.fetch.bind(n)),e.Headers=n.Headers,e.Request=n.Request,e.Response=n.Response}(i,i.exports),function(t,e){const n=i.exports,r=n.default||n,s=function(t,e){return/^\/\//.test(t)&&(t="https:"+t),r.call(this,t,e)};s.ponyfill=!0,t.exports=e=s,e.fetch=s,e.Headers=n.Headers,e.Request=n.Request,e.Response=n.Response,e.default=s}(n,n.exports);const r=n.exports,s=r.fetch.bind({});s.polyfill=!0,e.fetch||(e.fetch=s,e.Response=r.Response,e.Headers=r.Headers,e.Request=r.Request);const a=t=>"object"==typeof t&&null!=t,o=t=>"boolean"==typeof t,l=t=>"string"==typeof t,u=t=>a(t)&&l(t.tocId)&&Array.isArray(t.children)&&t.children.every((t=>u(t)))&&l(t.contentId)&&l(t.title);var p;t.FtTopicContentTarget=void 0,(p=t.FtTopicContentTarget||(t.FtTopicContentTarget={})).THIRD_PARTY="THIRD_PARTY",p.OFF_THE_GRID="OFF_THE_GRID";const d=t=>a(t)&&Array.isArray(t.values)&&t.values.every((t=>l(t)))&&l(t.label)&&l(t.key);var c;t.FtEditorialType=void 0,(c=t.FtEditorialType||(t.FtEditorialType={})).ARTICLE="ARTICLE",c.BOOK="BOOK";const h=t=>["ARTICLE","BOOK"].includes(t);var f;t.FtOpenMode=void 0,(f=t.FtOpenMode||(t.FtOpenMode={})).FLUIDTOPICS="FLUIDTOPICS",f.EXTERNAL="EXTERNAL";const y=t=>["FLUIDTOPICS","EXTERNAL"].includes(t);var T;t.FtSearchResultType=void 0,(T=t.FtSearchResultType||(t.FtSearchResultType={})).MAP="MAP",T.DOCUMENT="DOCUMENT",T.TOPIC="TOPIC";const g=t=>["MAP","DOCUMENT","TOPIC"].includes(t),m=t=>"object"==typeof t&&null!=t,b=t=>"string"==typeof t,A=t=>m(t)&&(null==t.emailAddress||b(t.emailAddress))&&(null==t.displayName||b(t.displayName))&&Array.isArray(t.roles)&&b(t.userId);class R extends Error{status;statusText;body;constructor(t,e,n){super(`${t} - ${e}: ${n}`),this.status=t,this.statusText=e,this.body=n}}async function F(t){if(!t.ok)throw new R(t.status,t.statusText,await t.text());return t}function E(t){return"application/json"===t.headers.get("Content-Type")?t.json():t.text()}class C{tenantBaseUrl;ftCallingApp;authorization={};get defaultHeaders(){return{...this.authorization,"Ft-Calling-App":this.ftCallingApp}}constructor(t,e){this.tenantBaseUrl=t.trim().replace(/\/$/,""),this.ftCallingApp=`ft-public-api/${e}`}setApiKey(t){this.authorization={Authorization:"Bearer "+t}}setCredentials(t,e){var n;this.authorization={Authorization:"Basic "+(n=`${t}:${e}`,"undefined"!=typeof Buffer?Buffer.from(n).toString("base64"):btoa(n))}}clearAuthentication(){this.authorization={}}login(t,e){let n={login:t,password:e,rememberMe:!0};return this.post("/api/authentication/login",n).then((n=>(this.setCredentials(t,e),n)))}logout(){return this.post("/api/authentication/logout").then((()=>this.clearAuthentication()))}getMap(t){return this.get(`/api/khub/maps/${t}`)}getTableOfContent(t){return this.get(`/api/khub/maps/${t}/toc`)}getTopic(t,e){return this.get(`/api/khub/maps/${t}/topics/${e}`)}getTopicHTMLContent(t,e,n){return this.get(`/api/khub/maps/${t}/topics/${e}/content${n?"?target="+n:""}`)}getMapAttachments(t){return this.get(`/api/khub/maps/${t}/attachments`)}getMapAttachmentContent(t,e){return this.fetchRawData(`/api/khub/maps/${t}/attachments/${e}/content`)}getMapResources(t){return this.get(`/api/khub/maps/${t}/resources`)}getMapResourceContent(t,e){return this.fetchRawData(`/api/khub/maps/${t}/resources/${e}/content`)}getUnstructuredDocument(t){return this.get(`/api/khub/documents/${t}`)}getUnstructuredDocumentContent(t){return this.fetchRawData(`/api/khub/documents/${t}/content`)}getUnstructuredDocumentTextContent(t){return this.get(`/api/khub/documents/${t}/content/text`)}getCollectionDocuments(t,e){return this.get(`/api/users/${t}/collections/${e}/documents`)}get(t){return this.makeRequest("GET",t)}post(t,e){return this.makeRequest("POST",t,e)}put(t,e){return this.makeRequest("PUT",t,e)}delete(t){return this.makeRequest("DELETE",t)}async fetch(t,e){const n=e;return t.startsWith("/")||(t="/"+t),await fetch(this.tenantBaseUrl+t,{...n??{},headers:{...this.defaultHeaders,...n?.headers??{}}})}makeRequest(t,e,n){return this.fetch(e,{method:t,headers:{...null!=n?{"Content-Type":"application/json"}:{}},body:null!=n?JSON.stringify(n):void 0}).then(F).then(E)}fetchRawData(t){return fetch(this.tenantBaseUrl+t,{headers:this.defaultHeaders}).then(F).then((t=>t.arrayBuffer()))}}t.FluidTopicsApi=C,t.HttpError=R,t.default=C,t.isFtAuthenticatedSession=t=>m(t)&&A(t.profile),t.isFtAuthenticationIdentifier=t=>a(t)&&l(t.identifier)&&l(t.realm),t.isFtCollectionDocument=t=>a(t)&&o(t.deleted)&&(null==t.apiUrl||l(t.apiUrl))&&(null==t.portalUrl||l(t.portalUrl))&&l(t.id)&&l(t.title)&&g(t.type),t.isFtCredentials=t=>a(t)&&l(t.password)&&(null==t.newPassword||l(t.newPassword))&&o(t.rememberMe)&&l(t.login),t.isFtEditorialType=h,t.isFtMap=t=>a(t)&&(null==t.prettyUrl||l(t.prettyUrl))&&Array.isArray(t.metadata)&&t.metadata.every((t=>d(t)))&&y(t.openMode)&&l(t.topicsApiEndpoint)&&(null==t.description||l(t.description))&&l(t.attachmentsApiEndpoint)&&h(t.editorialType)&&l(t.baseId)&&l(t.clusterId)&&l(t.title)&&l(t.lastPublication)&&l(t.lastEdition)&&l(t.originId)&&l(t.rightsApiEndpoint)&&(null==t.originUrl||l(t.originUrl))&&l(t.readerUrl)&&(null==t.khubVersion||l(t.khubVersion))&&l(t.id)&&(null==t.lang||l(t.lang)),t.isFtMapAttachment=t=>m(t)&&b(t.file)&&(null==t.size||(t=>"number"==typeof t)(t.size))&&(t=>"boolean"==typeof t)(t.externalLink)&&b(t.name)&&b(t.id)&&(null==t.mimeType||b(t.mimeType))&&(null==t.viewerUrl||b(t.viewerUrl)),t.isFtMapResource=t=>a(t)&&l(t.contentUrl)&&l(t.filename)&&l(t.id)&&l(t.mimeType),t.isFtMetadata=d,t.isFtOpenMode=y,t.isFtSearchResultType=g,t.isFtTocNode=u,t.isFtTopic=t=>a(t)&&Array.isArray(t.metadata)&&t.metadata.every((t=>d(t)))&&l(t.id)&&l(t.contentApiEndpoint)&&l(t.title),t.isFtTopicContentTarget=t=>["THIRD_PARTY","OFF_THE_GRID"].includes(t),t.isFtUnstructuredDocument=t=>a(t)&&(null==t.prettyUrl||l(t.prettyUrl))&&Array.isArray(t.metadata)&&t.metadata.every((t=>d(t)))&&l(t.openMode)&&(null==t.description||l(t.description))&&l(t.mimeType)&&(null==t.baseId||l(t.baseId))&&(null==t.clusterId||l(t.clusterId))&&l(t.contentApiEndpoint)&&l(t.title)&&(null==t.lastPublication||l(t.lastPublication))&&l(t.viewerUrl)&&l(t.lastEdition)&&l(t.filename)&&(null==t.originId||l(t.originId))&&l(t.rightsApiEndpoint)&&(null==t.originUrl||l(t.originUrl))&&(null==t.khubVersion||l(t.khubVersion))&&l(t.id)&&(null==t.lang||l(t.lang)),t.isFtUserProfile=A}));
|
package/dist/mjs/index.d.ts
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import "cross-fetch/polyfill";
|
|
2
|
-
import { FtCollectionDocument, FtMap, FtMapResource, FtTocNode, FtTopic, FtUnstructuredDocument } from "./types/ft-common/public";
|
|
2
|
+
import { FtCollectionDocument, FtMap, FtMapResource, FtTocNode, FtTopic, FtTopicContentTarget, FtUnstructuredDocument } from "./types/ft-common/public";
|
|
3
3
|
import { FtAuthenticatedSession, FtMapAttachment } from "./types/ft-server/public";
|
|
4
4
|
export * from "./types/ft-common/public";
|
|
5
5
|
export * from "./types/ft-server/public";
|
|
6
|
+
export declare class HttpError extends Error {
|
|
7
|
+
readonly status: number;
|
|
8
|
+
readonly statusText: string;
|
|
9
|
+
readonly body: string;
|
|
10
|
+
constructor(status: number, statusText: string, body: string);
|
|
11
|
+
}
|
|
6
12
|
export declare class FluidTopicsApi {
|
|
7
13
|
private readonly tenantBaseUrl;
|
|
8
14
|
private readonly ftCallingApp;
|
|
@@ -17,19 +23,21 @@ export declare class FluidTopicsApi {
|
|
|
17
23
|
getMap(mapId: string): Promise<FtMap>;
|
|
18
24
|
getTableOfContent(mapId: string): Promise<Array<FtTocNode>>;
|
|
19
25
|
getTopic(mapId: string, topicContentId: string): Promise<FtTopic>;
|
|
20
|
-
getTopicHTMLContent(mapId: string, topicContentId: string): Promise<string>;
|
|
26
|
+
getTopicHTMLContent(mapId: string, topicContentId: string, target?: FtTopicContentTarget): Promise<string>;
|
|
21
27
|
getMapAttachments(mapId: string): Promise<Array<FtMapAttachment>>;
|
|
22
28
|
getMapAttachmentContent(mapId: string, attachmentId: string): Promise<ArrayBuffer>;
|
|
23
29
|
getMapResources(mapId: string): Promise<Array<FtMapResource>>;
|
|
24
30
|
getMapResourceContent(mapId: string, resourceId: string): Promise<ArrayBuffer>;
|
|
25
31
|
getUnstructuredDocument(documentId: string): Promise<FtUnstructuredDocument>;
|
|
26
32
|
getUnstructuredDocumentContent(documentId: string): Promise<ArrayBuffer>;
|
|
33
|
+
getUnstructuredDocumentTextContent(documentId: string): Promise<string>;
|
|
27
34
|
getCollectionDocuments(userId: string, collectionId: string): Promise<Array<FtCollectionDocument>>;
|
|
28
35
|
get<T>(endpoint: string): Promise<T>;
|
|
29
36
|
post<T>(endpoint: string, data?: any): Promise<T>;
|
|
30
37
|
put<T>(endpoint: string, data?: any): Promise<T>;
|
|
31
38
|
delete<T>(endpoint: string): Promise<T>;
|
|
32
|
-
|
|
39
|
+
fetch<FetchRequestInit, FetchResponse>(endpoint: string, init?: FetchRequestInit): Promise<FetchResponse>;
|
|
40
|
+
private makeRequest;
|
|
33
41
|
private fetchRawData;
|
|
34
42
|
}
|
|
35
43
|
export default FluidTopicsApi;
|
package/dist/mjs/index.js
CHANGED
|
@@ -4,10 +4,20 @@ export * from "./types/ft-server/public";
|
|
|
4
4
|
function toBase64(s) {
|
|
5
5
|
return typeof Buffer !== "undefined" ? Buffer.from(s).toString("base64") : btoa(s);
|
|
6
6
|
}
|
|
7
|
+
export class HttpError extends Error {
|
|
8
|
+
status;
|
|
9
|
+
statusText;
|
|
10
|
+
body;
|
|
11
|
+
constructor(status, statusText, body) {
|
|
12
|
+
super(`${status} - ${statusText}: ${body}`);
|
|
13
|
+
this.status = status;
|
|
14
|
+
this.statusText = statusText;
|
|
15
|
+
this.body = body;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
7
18
|
async function handleError(response) {
|
|
8
|
-
if (response.
|
|
9
|
-
|
|
10
|
-
throw new Error(`${response.status}: ${response.statusText}`);
|
|
19
|
+
if (!response.ok) {
|
|
20
|
+
throw new HttpError(response.status, response.statusText, await response.text());
|
|
11
21
|
}
|
|
12
22
|
return response;
|
|
13
23
|
}
|
|
@@ -62,14 +72,14 @@ export class FluidTopicsApi {
|
|
|
62
72
|
getTopic(mapId, topicContentId) {
|
|
63
73
|
return this.get(`/api/khub/maps/${mapId}/topics/${topicContentId}`);
|
|
64
74
|
}
|
|
65
|
-
getTopicHTMLContent(mapId, topicContentId) {
|
|
66
|
-
return this.get(`/api/khub/maps/${mapId}/topics/${topicContentId}/content`);
|
|
75
|
+
getTopicHTMLContent(mapId, topicContentId, target) {
|
|
76
|
+
return this.get(`/api/khub/maps/${mapId}/topics/${topicContentId}/content${target ? "?target=" + target : ""}`);
|
|
67
77
|
}
|
|
68
78
|
getMapAttachments(mapId) {
|
|
69
79
|
return this.get(`/api/khub/maps/${mapId}/attachments`);
|
|
70
80
|
}
|
|
71
81
|
getMapAttachmentContent(mapId, attachmentId) {
|
|
72
|
-
return this.fetchRawData(`/api/khub/maps/${mapId}/attachments/${attachmentId}`);
|
|
82
|
+
return this.fetchRawData(`/api/khub/maps/${mapId}/attachments/${attachmentId}/content`);
|
|
73
83
|
}
|
|
74
84
|
getMapResources(mapId) {
|
|
75
85
|
return this.get(`/api/khub/maps/${mapId}/resources`);
|
|
@@ -83,26 +93,41 @@ export class FluidTopicsApi {
|
|
|
83
93
|
getUnstructuredDocumentContent(documentId) {
|
|
84
94
|
return this.fetchRawData(`/api/khub/documents/${documentId}/content`);
|
|
85
95
|
}
|
|
96
|
+
getUnstructuredDocumentTextContent(documentId) {
|
|
97
|
+
return this.get(`/api/khub/documents/${documentId}/content/text`);
|
|
98
|
+
}
|
|
86
99
|
getCollectionDocuments(userId, collectionId) {
|
|
87
100
|
return this.get(`/api/users/${userId}/collections/${collectionId}/documents`);
|
|
88
101
|
}
|
|
89
102
|
get(endpoint) {
|
|
90
|
-
return this.
|
|
103
|
+
return this.makeRequest("GET", endpoint);
|
|
91
104
|
}
|
|
92
105
|
post(endpoint, data) {
|
|
93
|
-
return this.
|
|
106
|
+
return this.makeRequest("POST", endpoint, data);
|
|
94
107
|
}
|
|
95
108
|
put(endpoint, data) {
|
|
96
|
-
return this.
|
|
109
|
+
return this.makeRequest("PUT", endpoint, data);
|
|
97
110
|
}
|
|
98
111
|
delete(endpoint) {
|
|
99
|
-
return this.
|
|
112
|
+
return this.makeRequest("DELETE", endpoint);
|
|
113
|
+
}
|
|
114
|
+
async fetch(endpoint, init) {
|
|
115
|
+
const requestInit = init;
|
|
116
|
+
if (!endpoint.startsWith("/")) {
|
|
117
|
+
endpoint = "/" + endpoint;
|
|
118
|
+
}
|
|
119
|
+
return await fetch(this.tenantBaseUrl + endpoint, {
|
|
120
|
+
...(requestInit ?? {}),
|
|
121
|
+
headers: {
|
|
122
|
+
...this.defaultHeaders,
|
|
123
|
+
...(requestInit?.headers ?? {})
|
|
124
|
+
}
|
|
125
|
+
});
|
|
100
126
|
}
|
|
101
|
-
|
|
102
|
-
return fetch(
|
|
127
|
+
makeRequest(method, endpoint, data) {
|
|
128
|
+
return this.fetch(endpoint, {
|
|
103
129
|
method: method,
|
|
104
130
|
headers: {
|
|
105
|
-
...this.defaultHeaders,
|
|
106
131
|
...(data != null ? { "Content-Type": "application/json" } : {})
|
|
107
132
|
},
|
|
108
133
|
body: data != null ? JSON.stringify(data) : undefined
|
|
@@ -72,6 +72,11 @@ export interface FtUnstructuredDocument {
|
|
|
72
72
|
lang?: string;
|
|
73
73
|
}
|
|
74
74
|
export declare const isFtUnstructuredDocument: (o: any) => o is FtUnstructuredDocument;
|
|
75
|
+
export declare enum FtTopicContentTarget {
|
|
76
|
+
THIRD_PARTY = "THIRD_PARTY",
|
|
77
|
+
OFF_THE_GRID = "OFF_THE_GRID"
|
|
78
|
+
}
|
|
79
|
+
export declare const isFtTopicContentTarget: (o: any) => o is FtTopicContentTarget;
|
|
75
80
|
export interface FtMetadata {
|
|
76
81
|
values: Array<string>;
|
|
77
82
|
label: string;
|
|
@@ -80,6 +80,15 @@ export const isFtUnstructuredDocument = (o) => {
|
|
|
80
80
|
&& (isString(o.id))
|
|
81
81
|
&& (o.lang == null || isString(o.lang));
|
|
82
82
|
};
|
|
83
|
+
// From: WsTopicContentTarget
|
|
84
|
+
export var FtTopicContentTarget;
|
|
85
|
+
(function (FtTopicContentTarget) {
|
|
86
|
+
FtTopicContentTarget["THIRD_PARTY"] = "THIRD_PARTY";
|
|
87
|
+
FtTopicContentTarget["OFF_THE_GRID"] = "OFF_THE_GRID";
|
|
88
|
+
})(FtTopicContentTarget || (FtTopicContentTarget = {}));
|
|
89
|
+
export const isFtTopicContentTarget = (o) => {
|
|
90
|
+
return ["THIRD_PARTY", "OFF_THE_GRID"].includes(o);
|
|
91
|
+
};
|
|
83
92
|
export const isFtMetadata = (o) => {
|
|
84
93
|
return isObject(o)
|
|
85
94
|
&& ((Array.isArray(o.values)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluid-topics/public-api",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.13",
|
|
4
4
|
"description": "Fluid Topics Public API",
|
|
5
5
|
"author": "Fluid Topics dev team <opensource@antidot.net>",
|
|
6
6
|
"license": "LGPLv3",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"access": "public"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"cross-fetch": "^3.1.
|
|
20
|
+
"cross-fetch": "^3.1.5"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@rollup/plugin-commonjs": "^20.0.0",
|