@fluid-topics/public-api 1.0.10 → 1.0.11
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 +2 -2
- package/dist/cjs/types/ft-common/public.js +11 -1
- package/dist/fluidtopics.min.js +1 -1
- package/dist/mjs/index.d.ts +2 -2
- package/dist/mjs/index.js +2 -2
- package/dist/mjs/types/ft-common/public.d.ts +5 -0
- package/dist/mjs/types/ft-common/public.js +9 -0
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -80,8 +80,8 @@ class FluidTopicsApi {
|
|
|
80
80
|
getTopic(mapId, topicContentId) {
|
|
81
81
|
return this.get(`/api/khub/maps/${mapId}/topics/${topicContentId}`);
|
|
82
82
|
}
|
|
83
|
-
getTopicHTMLContent(mapId, topicContentId) {
|
|
84
|
-
return this.get(`/api/khub/maps/${mapId}/topics/${topicContentId}/content`);
|
|
83
|
+
getTopicHTMLContent(mapId, topicContentId, target) {
|
|
84
|
+
return this.get(`/api/khub/maps/${mapId}/topics/${topicContentId}/content${target ? "?target=" + target : ""}`);
|
|
85
85
|
}
|
|
86
86
|
getMapAttachments(mapId) {
|
|
87
87
|
return this.get(`/api/khub/maps/${mapId}/attachments`);
|
|
@@ -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,A=t=>"string"==typeof t,b=t=>m(t)&&(null==t.emailAddress||A(t.emailAddress))&&(null==t.displayName||A(t.displayName))&&Array.isArray(t.roles)&&A(t.userId);async function R(t){if(!t.ok)throw new Error(`${t.status} - ${t.statusText}: ${await t.text()}`);return t}function F(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(R).then(F)}fetchRawData(t){return fetch(this.tenantBaseUrl+t,{headers:this.defaultHeaders}).then(R).then((t=>t.arrayBuffer()))}}t.FluidTopicsApi=C,t.default=C,t.isFtAuthenticatedSession=t=>m(t)&&b(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)&&A(t.file)&&(null==t.size||(t=>"number"==typeof t)(t.size))&&(t=>"boolean"==typeof t)(t.externalLink)&&A(t.name)&&A(t.id)&&(null==t.mimeType||A(t.mimeType))&&(null==t.viewerUrl||A(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=b}));
|
package/dist/mjs/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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";
|
|
@@ -17,7 +17,7 @@ export declare class FluidTopicsApi {
|
|
|
17
17
|
getMap(mapId: string): Promise<FtMap>;
|
|
18
18
|
getTableOfContent(mapId: string): Promise<Array<FtTocNode>>;
|
|
19
19
|
getTopic(mapId: string, topicContentId: string): Promise<FtTopic>;
|
|
20
|
-
getTopicHTMLContent(mapId: string, topicContentId: string): Promise<string>;
|
|
20
|
+
getTopicHTMLContent(mapId: string, topicContentId: string, target?: FtTopicContentTarget): Promise<string>;
|
|
21
21
|
getMapAttachments(mapId: string): Promise<Array<FtMapAttachment>>;
|
|
22
22
|
getMapAttachmentContent(mapId: string, attachmentId: string): Promise<ArrayBuffer>;
|
|
23
23
|
getMapResources(mapId: string): Promise<Array<FtMapResource>>;
|
package/dist/mjs/index.js
CHANGED
|
@@ -61,8 +61,8 @@ export class FluidTopicsApi {
|
|
|
61
61
|
getTopic(mapId, topicContentId) {
|
|
62
62
|
return this.get(`/api/khub/maps/${mapId}/topics/${topicContentId}`);
|
|
63
63
|
}
|
|
64
|
-
getTopicHTMLContent(mapId, topicContentId) {
|
|
65
|
-
return this.get(`/api/khub/maps/${mapId}/topics/${topicContentId}/content`);
|
|
64
|
+
getTopicHTMLContent(mapId, topicContentId, target) {
|
|
65
|
+
return this.get(`/api/khub/maps/${mapId}/topics/${topicContentId}/content${target ? "?target=" + target : ""}`);
|
|
66
66
|
}
|
|
67
67
|
getMapAttachments(mapId) {
|
|
68
68
|
return this.get(`/api/khub/maps/${mapId}/attachments`);
|
|
@@ -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)
|