@fluid-topics/public-api 1.0.7 → 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 CHANGED
@@ -9,24 +9,51 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
9
9
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
10
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
11
  };
12
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
+ return new (P || (P = Promise))(function (resolve, reject) {
15
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
19
+ });
20
+ };
12
21
  Object.defineProperty(exports, "__esModule", { value: true });
13
22
  exports.FluidTopicsApi = void 0;
14
- const axios_1 = require("axios");
23
+ require("cross-fetch/polyfill");
15
24
  __exportStar(require("./types/ft-common/public"), exports);
16
25
  __exportStar(require("./types/ft-server/public"), exports);
26
+ function toBase64(s) {
27
+ return typeof Buffer !== "undefined" ? Buffer.from(s).toString("base64") : btoa(s);
28
+ }
29
+ function handleError(response) {
30
+ return __awaiter(this, void 0, void 0, function* () {
31
+ if (!response.ok) {
32
+ throw new Error(`${response.status} - ${response.statusText}: ${yield response.text()}`);
33
+ }
34
+ return response;
35
+ });
36
+ }
37
+ function getBody(response) {
38
+ return response.headers.get("Content-Type") === "application/json" ? response.json() : response.text();
39
+ }
17
40
  class FluidTopicsApi {
18
41
  constructor(tenantBaseUrl, integrationIdentifier) {
42
+ this.authorization = {};
19
43
  this.tenantBaseUrl = tenantBaseUrl.trim().replace(/\/$/, "");
20
44
  this.ftCallingApp = `ft-public-api/${integrationIdentifier}`;
21
45
  }
46
+ get defaultHeaders() {
47
+ return Object.assign(Object.assign({}, this.authorization), { "Ft-Calling-App": this.ftCallingApp });
48
+ }
49
+ setApiKey(apiKey) {
50
+ this.authorization = { "Authorization": "Bearer " + apiKey };
51
+ }
22
52
  setCredentials(login, password) {
23
- this.auth = {
24
- username: login,
25
- password: password
26
- };
53
+ this.authorization = { "Authorization": "Basic " + toBase64(`${login}:${password}`) };
27
54
  }
28
55
  clearAuthentication() {
29
- this.auth = undefined;
56
+ this.authorization = {};
30
57
  }
31
58
  login(login, password) {
32
59
  let credentials = {
@@ -53,55 +80,68 @@ class FluidTopicsApi {
53
80
  getTopic(mapId, topicContentId) {
54
81
  return this.get(`/api/khub/maps/${mapId}/topics/${topicContentId}`);
55
82
  }
56
- getTopicHTMLContent(mapId, topicContentId) {
57
- 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 : ""}`);
58
85
  }
59
86
  getMapAttachments(mapId) {
60
87
  return this.get(`/api/khub/maps/${mapId}/attachments`);
61
88
  }
62
89
  getMapAttachmentContent(mapId, attachmentId) {
63
- return this.getRawData(`/api/khub/maps/${mapId}/attachments/${attachmentId}`);
90
+ return this.fetchRawData(`/api/khub/maps/${mapId}/attachments/${attachmentId}/content`);
64
91
  }
65
92
  getMapResources(mapId) {
66
93
  return this.get(`/api/khub/maps/${mapId}/resources`);
67
94
  }
68
95
  getMapResourceContent(mapId, resourceId) {
69
- return this.getRawData(`/api/khub/maps/${mapId}/resources/${resourceId}`);
96
+ return this.fetchRawData(`/api/khub/maps/${mapId}/resources/${resourceId}/content`);
70
97
  }
71
98
  getUnstructuredDocument(documentId) {
72
99
  return this.get(`/api/khub/documents/${documentId}`);
73
100
  }
74
101
  getUnstructuredDocumentContent(documentId) {
75
- return this.getRawData(`/api/khub/documents/${documentId}/content`);
102
+ return this.fetchRawData(`/api/khub/documents/${documentId}/content`);
103
+ }
104
+ getUnstructuredDocumentTextContent(documentId) {
105
+ return this.get(`/api/khub/documents/${documentId}/content/text`);
76
106
  }
77
107
  getCollectionDocuments(userId, collectionId) {
78
108
  return this.get(`/api/users/${userId}/collections/${collectionId}/documents`);
79
109
  }
80
- get defaultAxiosConfig() {
81
- return {
82
- auth: this.auth,
83
- headers: {
84
- "Ft-Calling-App": this.ftCallingApp
85
- }
86
- };
87
- }
88
110
  get(endpoint) {
89
- return axios_1.default.get(this.tenantBaseUrl + endpoint, this.defaultAxiosConfig)
90
- .then(response => this.handleResponse(response));
111
+ return this.makeRequest("GET", endpoint);
91
112
  }
92
113
  post(endpoint, data) {
93
- return axios_1.default.post(this.tenantBaseUrl + endpoint, data, this.defaultAxiosConfig)
94
- .then(response => this.handleResponse(response));
114
+ return this.makeRequest("POST", endpoint, data);
95
115
  }
96
- getRawData(endpoint) {
97
- return (0, axios_1.default)(Object.assign(Object.assign({}, this.defaultAxiosConfig), { method: "get", url: this.tenantBaseUrl + endpoint, responseType: "arraybuffer" }))
98
- .then(response => this.handleResponse(response));
116
+ put(endpoint, data) {
117
+ return this.makeRequest("PUT", endpoint, data);
99
118
  }
100
- handleResponse(response) {
101
- if (response.status >= 200 && response.status < 400) {
102
- return response.data;
103
- }
104
- throw new Error(`${response.status}: ${response.statusText}`);
119
+ delete(endpoint) {
120
+ return this.makeRequest("DELETE", endpoint);
121
+ }
122
+ fetch(endpoint, init) {
123
+ var _a;
124
+ return __awaiter(this, void 0, void 0, function* () {
125
+ const requestInit = init;
126
+ if (!endpoint.startsWith("/")) {
127
+ endpoint = "/" + endpoint;
128
+ }
129
+ 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 : {})) }));
130
+ });
131
+ }
132
+ makeRequest(method, endpoint, data) {
133
+ return this.fetch(endpoint, {
134
+ method: method,
135
+ headers: Object.assign({}, (data != null ? { "Content-Type": "application/json" } : {})),
136
+ body: data != null ? JSON.stringify(data) : undefined
137
+ })
138
+ .then(handleError)
139
+ .then(getBody);
140
+ }
141
+ fetchRawData(endpoint) {
142
+ return fetch(this.tenantBaseUrl + endpoint, { headers: this.defaultHeaders })
143
+ .then(handleError)
144
+ .then(response => response.arrayBuffer());
105
145
  }
106
146
  }
107
147
  exports.FluidTopicsApi = FluidTopicsApi;
@@ -1,18 +1,140 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FtSearchResultType = exports.FtOpenMode = exports.FtEditorialType = 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
+ const isObject = (o) => typeof o === "object" && o != null;
5
+ const isBoolean = (o) => typeof o === "boolean";
6
+ const isNumber = (o) => typeof o === "number";
7
+ const isString = (o) => typeof o === "string";
8
+ const isFtCredentials = (o) => {
9
+ return isObject(o)
10
+ && (isString(o.password))
11
+ && (o.newPassword == null || isString(o.newPassword))
12
+ && (isBoolean(o.rememberMe))
13
+ && (isString(o.login));
14
+ };
15
+ exports.isFtCredentials = isFtCredentials;
16
+ const isFtCollectionDocument = (o) => {
17
+ return isObject(o)
18
+ && (isBoolean(o.deleted))
19
+ && (o.apiUrl == null || isString(o.apiUrl))
20
+ && (o.portalUrl == null || isString(o.portalUrl))
21
+ && (isString(o.id))
22
+ && (isString(o.title))
23
+ && ((0, exports.isFtSearchResultType)(o.type));
24
+ };
25
+ exports.isFtCollectionDocument = isFtCollectionDocument;
26
+ const isFtMap = (o) => {
27
+ return isObject(o)
28
+ && (o.prettyUrl == null || isString(o.prettyUrl))
29
+ && ((Array.isArray(o.metadata)
30
+ && o.metadata.every((v) => (0, exports.isFtMetadata)(v))))
31
+ && ((0, exports.isFtOpenMode)(o.openMode))
32
+ && (isString(o.topicsApiEndpoint))
33
+ && (o.description == null || isString(o.description))
34
+ && (isString(o.attachmentsApiEndpoint))
35
+ && ((0, exports.isFtEditorialType)(o.editorialType))
36
+ && (isString(o.baseId))
37
+ && (isString(o.clusterId))
38
+ && (isString(o.title))
39
+ && (isString(o.lastPublication))
40
+ && (isString(o.lastEdition))
41
+ && (isString(o.originId))
42
+ && (isString(o.rightsApiEndpoint))
43
+ && (o.originUrl == null || isString(o.originUrl))
44
+ && (isString(o.readerUrl))
45
+ && (o.khubVersion == null || isString(o.khubVersion))
46
+ && (isString(o.id))
47
+ && (o.lang == null || isString(o.lang));
48
+ };
49
+ exports.isFtMap = isFtMap;
50
+ const isFtTocNode = (o) => {
51
+ return isObject(o)
52
+ && (isString(o.tocId))
53
+ && ((Array.isArray(o.children)
54
+ && o.children.every((v) => (0, exports.isFtTocNode)(v))))
55
+ && (isString(o.contentId))
56
+ && (isString(o.title));
57
+ };
58
+ exports.isFtTocNode = isFtTocNode;
59
+ const isFtTopic = (o) => {
60
+ return isObject(o)
61
+ && ((Array.isArray(o.metadata)
62
+ && o.metadata.every((v) => (0, exports.isFtMetadata)(v))))
63
+ && (isString(o.id))
64
+ && (isString(o.contentApiEndpoint))
65
+ && (isString(o.title));
66
+ };
67
+ exports.isFtTopic = isFtTopic;
68
+ const isFtUnstructuredDocument = (o) => {
69
+ return isObject(o)
70
+ && (o.prettyUrl == null || isString(o.prettyUrl))
71
+ && ((Array.isArray(o.metadata)
72
+ && o.metadata.every((v) => (0, exports.isFtMetadata)(v))))
73
+ && (isString(o.openMode))
74
+ && (o.description == null || isString(o.description))
75
+ && (isString(o.mimeType))
76
+ && (o.baseId == null || isString(o.baseId))
77
+ && (o.clusterId == null || isString(o.clusterId))
78
+ && (isString(o.contentApiEndpoint))
79
+ && (isString(o.title))
80
+ && (o.lastPublication == null || isString(o.lastPublication))
81
+ && (isString(o.viewerUrl))
82
+ && (isString(o.lastEdition))
83
+ && (isString(o.filename))
84
+ && (o.originId == null || isString(o.originId))
85
+ && (isString(o.rightsApiEndpoint))
86
+ && (o.originUrl == null || isString(o.originUrl))
87
+ && (o.khubVersion == null || isString(o.khubVersion))
88
+ && (isString(o.id))
89
+ && (o.lang == null || isString(o.lang));
90
+ };
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;
102
+ const isFtMetadata = (o) => {
103
+ return isObject(o)
104
+ && ((Array.isArray(o.values)
105
+ && o.values.every((v) => isString(v))))
106
+ && (isString(o.label))
107
+ && (isString(o.key));
108
+ };
109
+ exports.isFtMetadata = isFtMetadata;
110
+ const isFtMapResource = (o) => {
111
+ return isObject(o)
112
+ && (isString(o.contentUrl))
113
+ && (isString(o.filename))
114
+ && (isString(o.id))
115
+ && (isString(o.mimeType));
116
+ };
117
+ exports.isFtMapResource = isFtMapResource;
4
118
  // From: WsEditorialType
5
119
  var FtEditorialType;
6
120
  (function (FtEditorialType) {
7
121
  FtEditorialType["ARTICLE"] = "ARTICLE";
8
122
  FtEditorialType["BOOK"] = "BOOK";
9
123
  })(FtEditorialType = exports.FtEditorialType || (exports.FtEditorialType = {}));
124
+ const isFtEditorialType = (o) => {
125
+ return ["ARTICLE", "BOOK"].includes(o);
126
+ };
127
+ exports.isFtEditorialType = isFtEditorialType;
10
128
  // From: WsOpenMode
11
129
  var FtOpenMode;
12
130
  (function (FtOpenMode) {
13
131
  FtOpenMode["FLUIDTOPICS"] = "FLUIDTOPICS";
14
132
  FtOpenMode["EXTERNAL"] = "EXTERNAL";
15
133
  })(FtOpenMode = exports.FtOpenMode || (exports.FtOpenMode = {}));
134
+ const isFtOpenMode = (o) => {
135
+ return ["FLUIDTOPICS", "EXTERNAL"].includes(o);
136
+ };
137
+ exports.isFtOpenMode = isFtOpenMode;
16
138
  // From: WsPublicSearchResultType
17
139
  var FtSearchResultType;
18
140
  (function (FtSearchResultType) {
@@ -20,3 +142,13 @@ var FtSearchResultType;
20
142
  FtSearchResultType["DOCUMENT"] = "DOCUMENT";
21
143
  FtSearchResultType["TOPIC"] = "TOPIC";
22
144
  })(FtSearchResultType = exports.FtSearchResultType || (exports.FtSearchResultType = {}));
145
+ const isFtSearchResultType = (o) => {
146
+ return ["MAP", "DOCUMENT", "TOPIC"].includes(o);
147
+ };
148
+ exports.isFtSearchResultType = isFtSearchResultType;
149
+ const isFtAuthenticationIdentifier = (o) => {
150
+ return isObject(o)
151
+ && (isString(o.identifier))
152
+ && (isString(o.realm));
153
+ };
154
+ exports.isFtAuthenticationIdentifier = isFtAuthenticationIdentifier;
@@ -1,2 +1,31 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isFtMapAttachment = exports.isFtUserProfile = exports.isFtAuthenticatedSession = void 0;
4
+ const isObject = (o) => typeof o === "object" && o != null;
5
+ const isBoolean = (o) => typeof o === "boolean";
6
+ const isNumber = (o) => typeof o === "number";
7
+ const isString = (o) => typeof o === "string";
8
+ const isFtAuthenticatedSession = (o) => {
9
+ return isObject(o)
10
+ && ((0, exports.isFtUserProfile)(o.profile));
11
+ };
12
+ exports.isFtAuthenticatedSession = isFtAuthenticatedSession;
13
+ const isFtUserProfile = (o) => {
14
+ return isObject(o)
15
+ && (o.emailAddress == null || isString(o.emailAddress))
16
+ && (o.displayName == null || isString(o.displayName))
17
+ && ((Array.isArray(o.roles)))
18
+ && (isString(o.userId));
19
+ };
20
+ exports.isFtUserProfile = isFtUserProfile;
21
+ const isFtMapAttachment = (o) => {
22
+ return isObject(o)
23
+ && (isString(o.file))
24
+ && (o.size == null || isNumber(o.size))
25
+ && (isBoolean(o.externalLink))
26
+ && (isString(o.name))
27
+ && (isString(o.id))
28
+ && (o.mimeType == null || isString(o.mimeType))
29
+ && (o.viewerUrl == null || isString(o.viewerUrl));
30
+ };
31
+ exports.isFtMapAttachment = isFtMapAttachment;
@@ -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={exports:{}},n=function(e,t){return function(){for(var n=new Array(arguments.length),r=0;r<n.length;r++)n[r]=arguments[r];return e.apply(t,n)}},r=n,o=Object.prototype.toString;function i(e){return"[object Array]"===o.call(e)}function a(e){return void 0===e}function s(e){return null!==e&&"object"==typeof e}function u(e){if("[object Object]"!==o.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function c(e){return"[object Function]"===o.call(e)}function f(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),i(e))for(var n=0,r=e.length;n<r;n++)t.call(null,e[n],n,e);else for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.call(null,e[o],o,e)}var l={isArray:i,isArrayBuffer:function(e){return"[object ArrayBuffer]"===o.call(e)},isBuffer:function(e){return null!==e&&!a(e)&&null!==e.constructor&&!a(e.constructor)&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)},isFormData:function(e){return"undefined"!=typeof FormData&&e instanceof FormData},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e},isObject:s,isPlainObject:u,isUndefined:a,isDate:function(e){return"[object Date]"===o.call(e)},isFile:function(e){return"[object File]"===o.call(e)},isBlob:function(e){return"[object Blob]"===o.call(e)},isFunction:c,isStream:function(e){return s(e)&&c(e.pipe)},isURLSearchParams:function(e){return"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:f,merge:function e(){var t={};function n(n,r){u(t[r])&&u(n)?t[r]=e(t[r],n):u(n)?t[r]=e({},n):i(n)?t[r]=n.slice():t[r]=n}for(var r=0,o=arguments.length;r<o;r++)f(arguments[r],n);return t},extend:function(e,t,n){return f(t,(function(t,o){e[o]=n&&"function"==typeof t?r(t,n):t})),e},trim:function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")},stripBOM:function(e){return 65279===e.charCodeAt(0)&&(e=e.slice(1)),e}},p=l;function d(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var h=function(e,t,n){if(!t)return e;var r;if(n)r=n(t);else if(p.isURLSearchParams(t))r=t.toString();else{var o=[];p.forEach(t,(function(e,t){null!=e&&(p.isArray(e)?t+="[]":e=[e],p.forEach(e,(function(e){p.isDate(e)?e=e.toISOString():p.isObject(e)&&(e=JSON.stringify(e)),o.push(d(t)+"="+d(e))})))})),r=o.join("&")}if(r){var i=e.indexOf("#");-1!==i&&(e=e.slice(0,i)),e+=(-1===e.indexOf("?")?"?":"&")+r}return e},m=l;function g(){this.handlers=[]}g.prototype.use=function(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!n&&n.synchronous,runWhen:n?n.runWhen:null}),this.handlers.length-1},g.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},g.prototype.forEach=function(e){m.forEach(this.handlers,(function(t){null!==t&&e(t)}))};var y=g,v=l,b=function(e,t,n,r,o){return e.config=t,n&&(e.code=n),e.request=r,e.response=o,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}},e},w=b,x=function(e,t,n,r,o){var i=new Error(e);return w(i,t,n,r,o)},E=x,C=l,j=C.isStandardBrowserEnv()?{write:function(e,t,n,r,o,i){var a=[];a.push(e+"="+encodeURIComponent(t)),C.isNumber(n)&&a.push("expires="+new Date(n).toGMTString()),C.isString(r)&&a.push("path="+r),C.isString(o)&&a.push("domain="+o),!0===i&&a.push("secure"),document.cookie=a.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}},O=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)},T=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e},A=l,S=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"],k=l,R=k.isStandardBrowserEnv()?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");function r(e){var r=e;return t&&(n.setAttribute("href",r),r=n.href),n.setAttribute("href",r),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:"/"===n.pathname.charAt(0)?n.pathname:"/"+n.pathname}}return e=r(window.location.href),function(t){var n=k.isString(t)?r(t):t;return n.protocol===e.protocol&&n.host===e.host}}():function(){return!0},N=l,U=function(e,t,n){var r=n.config.validateStatus;n.status&&r&&!r(n.status)?t(E("Request failed with status code "+n.status,n.config,null,n.request,n)):e(n)},P=j,B=h,L=function(e,t){return e&&!O(t)?T(e,t):t},D=function(e){var t,n,r,o={};return e?(A.forEach(e.split("\n"),(function(e){if(r=e.indexOf(":"),t=A.trim(e.substr(0,r)).toLowerCase(),n=A.trim(e.substr(r+1)),t){if(o[t]&&S.indexOf(t)>=0)return;o[t]="set-cookie"===t?(o[t]?o[t]:[]).concat([n]):o[t]?o[t]+", "+n:n}})),o):o},F=R,M=x,$=function(e){return new Promise((function(t,n){var r=e.data,o=e.headers,i=e.responseType;N.isFormData(r)&&delete o["Content-Type"];var a=new XMLHttpRequest;if(e.auth){var s=e.auth.username||"",u=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";o.Authorization="Basic "+btoa(s+":"+u)}var c=L(e.baseURL,e.url);function f(){if(a){var r="getAllResponseHeaders"in a?D(a.getAllResponseHeaders()):null,o={data:i&&"text"!==i&&"json"!==i?a.response:a.responseText,status:a.status,statusText:a.statusText,headers:r,config:e,request:a};U(t,n,o),a=null}}if(a.open(e.method.toUpperCase(),B(c,e.params,e.paramsSerializer),!0),a.timeout=e.timeout,"onloadend"in a?a.onloadend=f:a.onreadystatechange=function(){a&&4===a.readyState&&(0!==a.status||a.responseURL&&0===a.responseURL.indexOf("file:"))&&setTimeout(f)},a.onabort=function(){a&&(n(M("Request aborted",e,"ECONNABORTED",a)),a=null)},a.onerror=function(){n(M("Network Error",e,null,a)),a=null},a.ontimeout=function(){var t="timeout of "+e.timeout+"ms exceeded";e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),n(M(t,e,e.transitional&&e.transitional.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",a)),a=null},N.isStandardBrowserEnv()){var l=(e.withCredentials||F(c))&&e.xsrfCookieName?P.read(e.xsrfCookieName):void 0;l&&(o[e.xsrfHeaderName]=l)}"setRequestHeader"in a&&N.forEach(o,(function(e,t){void 0===r&&"content-type"===t.toLowerCase()?delete o[t]:a.setRequestHeader(t,e)})),N.isUndefined(e.withCredentials)||(a.withCredentials=!!e.withCredentials),i&&"json"!==i&&(a.responseType=e.responseType),"function"==typeof e.onDownloadProgress&&a.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&a.upload&&a.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then((function(e){a&&(a.abort(),n(e),a=null)})),r||(r=null),a.send(r)}))},q=l,I=function(e,t){v.forEach(e,(function(n,r){r!==t&&r.toUpperCase()===t.toUpperCase()&&(e[t]=n,delete e[r])}))},H=b,J={"Content-Type":"application/x-www-form-urlencoded"};function _(e,t){!q.isUndefined(e)&&q.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var z,X={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(z=$),z),transformRequest:[function(e,t){return I(t,"Accept"),I(t,"Content-Type"),q.isFormData(e)||q.isArrayBuffer(e)||q.isBuffer(e)||q.isStream(e)||q.isFile(e)||q.isBlob(e)?e:q.isArrayBufferView(e)?e.buffer:q.isURLSearchParams(e)?(_(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):q.isObject(e)||t&&"application/json"===t["Content-Type"]?(_(t,"application/json"),function(e,t,n){if(q.isString(e))try{return(t||JSON.parse)(e),q.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(n||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){var t=this.transitional,n=t&&t.silentJSONParsing,r=t&&t.forcedJSONParsing,o=!n&&"json"===this.responseType;if(o||r&&q.isString(e)&&e.length)try{return JSON.parse(e)}catch(e){if(o){if("SyntaxError"===e.name)throw H(e,this,"E_JSON_PARSE");throw e}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(e){return e>=200&&e<300}};X.headers={common:{Accept:"application/json, text/plain, */*"}},q.forEach(["delete","get","head"],(function(e){X.headers[e]={}})),q.forEach(["post","put","patch"],(function(e){X.headers[e]=q.merge(J)}));var V=X,K=l,W=V,G=function(e){return!(!e||!e.__CANCEL__)},Z=l,Q=function(e,t,n){var r=this||W;return K.forEach(n,(function(n){e=n.call(r,e,t)})),e},Y=G,ee=V;function te(e){e.cancelToken&&e.cancelToken.throwIfRequested()}var ne=l,re=function(e,t){t=t||{};var n={},r=["url","method","data"],o=["headers","auth","proxy","params"],i=["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","timeoutMessage","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","decompress","maxContentLength","maxBodyLength","maxRedirects","transport","httpAgent","httpsAgent","cancelToken","socketPath","responseEncoding"],a=["validateStatus"];function s(e,t){return ne.isPlainObject(e)&&ne.isPlainObject(t)?ne.merge(e,t):ne.isPlainObject(t)?ne.merge({},t):ne.isArray(t)?t.slice():t}function u(r){ne.isUndefined(t[r])?ne.isUndefined(e[r])||(n[r]=s(void 0,e[r])):n[r]=s(e[r],t[r])}ne.forEach(r,(function(e){ne.isUndefined(t[e])||(n[e]=s(void 0,t[e]))})),ne.forEach(o,u),ne.forEach(i,(function(r){ne.isUndefined(t[r])?ne.isUndefined(e[r])||(n[r]=s(void 0,e[r])):n[r]=s(void 0,t[r])})),ne.forEach(a,(function(r){r in t?n[r]=s(e[r],t[r]):r in e&&(n[r]=s(void 0,e[r]))}));var c=r.concat(o).concat(i).concat(a),f=Object.keys(e).concat(Object.keys(t)).filter((function(e){return-1===c.indexOf(e)}));return ne.forEach(f,u),n},oe={name:"axios",version:"0.21.4",description:"Promise based HTTP client for the browser and node.js",main:"index.js",scripts:{test:"grunt test",start:"node ./sandbox/server.js",build:"NODE_ENV=production grunt build",preversion:"npm test",version:"npm run build && grunt version && git add -A dist && git add CHANGELOG.md bower.json package.json",postversion:"git push && git push --tags",examples:"node ./examples/server.js",coveralls:"cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",fix:"eslint --fix lib/**/*.js"},repository:{type:"git",url:"https://github.com/axios/axios.git"},keywords:["xhr","http","ajax","promise","node"],author:"Matt Zabriskie",license:"MIT",bugs:{url:"https://github.com/axios/axios/issues"},homepage:"https://axios-http.com",devDependencies:{coveralls:"^3.0.0","es6-promise":"^4.2.4",grunt:"^1.3.0","grunt-banner":"^0.6.0","grunt-cli":"^1.2.0","grunt-contrib-clean":"^1.1.0","grunt-contrib-watch":"^1.0.0","grunt-eslint":"^23.0.0","grunt-karma":"^4.0.0","grunt-mocha-test":"^0.13.3","grunt-ts":"^6.0.0-beta.19","grunt-webpack":"^4.0.2","istanbul-instrumenter-loader":"^1.0.0","jasmine-core":"^2.4.1",karma:"^6.3.2","karma-chrome-launcher":"^3.1.0","karma-firefox-launcher":"^2.1.0","karma-jasmine":"^1.1.1","karma-jasmine-ajax":"^0.1.13","karma-safari-launcher":"^1.0.0","karma-sauce-launcher":"^4.3.6","karma-sinon":"^1.0.5","karma-sourcemap-loader":"^0.3.8","karma-webpack":"^4.0.2","load-grunt-tasks":"^3.5.2",minimist:"^1.2.0",mocha:"^8.2.1",sinon:"^4.5.0","terser-webpack-plugin":"^4.2.3",typescript:"^4.0.5","url-search-params":"^0.10.0",webpack:"^4.44.2","webpack-dev-server":"^3.11.0"},browser:{"./lib/adapters/http.js":"./lib/adapters/xhr.js"},jsdelivr:"dist/axios.min.js",unpkg:"dist/axios.min.js",typings:"./index.d.ts",dependencies:{"follow-redirects":"^1.14.0"},bundlesize:[{path:"./dist/axios.min.js",threshold:"5kB"}]},ie={};["object","boolean","number","function","string","symbol"].forEach((function(e,t){ie[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}}));var ae={},se=oe.version.split(".");function ue(e,t){for(var n=t?t.split("."):se,r=e.split("."),o=0;o<3;o++){if(n[o]>r[o])return!0;if(n[o]<r[o])return!1}return!1}ie.transitional=function(e,t,n){var r=t&&ue(t);function o(e,t){return"[Axios v"+oe.version+"] Transitional option '"+e+"'"+t+(n?". "+n:"")}return function(n,i,a){if(!1===e)throw new Error(o(i," has been removed in "+t));return r&&!ae[i]&&(ae[i]=!0,console.warn(o(i," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(n,i,a)}};var ce={isOlderVersion:ue,assertOptions:function(e,t,n){if("object"!=typeof e)throw new TypeError("options must be an object");for(var r=Object.keys(e),o=r.length;o-- >0;){var i=r[o],a=t[i];if(a){var s=e[i],u=void 0===s||a(s,i,e);if(!0!==u)throw new TypeError("option "+i+" must be "+u)}else if(!0!==n)throw Error("Unknown option "+i)}},validators:ie},fe=l,le=h,pe=y,de=function(e){return te(e),e.headers=e.headers||{},e.data=Q.call(e,e.data,e.headers,e.transformRequest),e.headers=Z.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),Z.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||ee.adapter)(e).then((function(t){return te(e),t.data=Q.call(e,t.data,t.headers,e.transformResponse),t}),(function(t){return Y(t)||(te(e),t&&t.response&&(t.response.data=Q.call(e,t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))},he=re,me=ce,ge=me.validators;function ye(e){this.defaults=e,this.interceptors={request:new pe,response:new pe}}ye.prototype.request=function(e){"string"==typeof e?(e=arguments[1]||{}).url=arguments[0]:e=e||{},(e=he(this.defaults,e)).method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var t=e.transitional;void 0!==t&&me.assertOptions(t,{silentJSONParsing:ge.transitional(ge.boolean,"1.0.0"),forcedJSONParsing:ge.transitional(ge.boolean,"1.0.0"),clarifyTimeoutError:ge.transitional(ge.boolean,"1.0.0")},!1);var n=[],r=!0;this.interceptors.request.forEach((function(t){"function"==typeof t.runWhen&&!1===t.runWhen(e)||(r=r&&t.synchronous,n.unshift(t.fulfilled,t.rejected))}));var o,i=[];if(this.interceptors.response.forEach((function(e){i.push(e.fulfilled,e.rejected)})),!r){var a=[de,void 0];for(Array.prototype.unshift.apply(a,n),a=a.concat(i),o=Promise.resolve(e);a.length;)o=o.then(a.shift(),a.shift());return o}for(var s=e;n.length;){var u=n.shift(),c=n.shift();try{s=u(s)}catch(e){c(e);break}}try{o=de(s)}catch(e){return Promise.reject(e)}for(;i.length;)o=o.then(i.shift(),i.shift());return o},ye.prototype.getUri=function(e){return e=he(this.defaults,e),le(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},fe.forEach(["delete","get","head","options"],(function(e){ye.prototype[e]=function(t,n){return this.request(he(n||{},{method:e,url:t,data:(n||{}).data}))}})),fe.forEach(["post","put","patch"],(function(e){ye.prototype[e]=function(t,n,r){return this.request(he(r||{},{method:e,url:t,data:n}))}}));var ve=ye;function be(e){this.message=e}be.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},be.prototype.__CANCEL__=!0;var we=be,xe=we;function Ee(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise((function(e){t=e}));var n=this;e((function(e){n.reason||(n.reason=new xe(e),t(n.reason))}))}Ee.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},Ee.source=function(){var e;return{token:new Ee((function(t){e=t})),cancel:e}};var Ce=Ee,je=l,Oe=n,Te=ve,Ae=re;function Se(e){var t=new Te(e),n=Oe(Te.prototype.request,t);return je.extend(n,Te.prototype,t),je.extend(n,t),n}var ke=Se(V);ke.Axios=Te,ke.create=function(e){return Se(Ae(ke.defaults,e))},ke.Cancel=we,ke.CancelToken=Ce,ke.isCancel=G,ke.all=function(e){return Promise.all(e)},ke.spread=function(e){return function(t){return e.apply(null,t)}},ke.isAxiosError=function(e){return"object"==typeof e&&!0===e.isAxiosError},t.exports=ke,t.exports.default=ke;var Re,Ne,Ue,Pe=t.exports;e.FtEditorialType=void 0,(Re=e.FtEditorialType||(e.FtEditorialType={})).ARTICLE="ARTICLE",Re.BOOK="BOOK",e.FtOpenMode=void 0,(Ne=e.FtOpenMode||(e.FtOpenMode={})).FLUIDTOPICS="FLUIDTOPICS",Ne.EXTERNAL="EXTERNAL",e.FtSearchResultType=void 0,(Ue=e.FtSearchResultType||(e.FtSearchResultType={})).MAP="MAP",Ue.DOCUMENT="DOCUMENT",Ue.TOPIC="TOPIC";class Be{tenantBaseUrl;ftCallingApp;auth;constructor(e,t){this.tenantBaseUrl=e.trim().replace(/\/$/,""),this.ftCallingApp=`ft-public-api/${t}`}setCredentials(e,t){this.auth={username:e,password:t}}clearAuthentication(){this.auth=void 0}login(e,t){let n={login:e,password:t,rememberMe:!0};return this.post("/api/authentication/login",n).then((n=>(this.setCredentials(e,t),n)))}logout(){return this.post("/api/authentication/logout").then((()=>this.clearAuthentication()))}getMap(e){return this.get(`/api/khub/maps/${e}`)}getTableOfContent(e){return this.get(`/api/khub/maps/${e}/toc`)}getTopic(e,t){return this.get(`/api/khub/maps/${e}/topics/${t}`)}getTopicHTMLContent(e,t){return this.get(`/api/khub/maps/${e}/topics/${t}/content`)}getMapAttachments(e){return this.get(`/api/khub/maps/${e}/attachments`)}getMapAttachmentContent(e,t){return this.getRawData(`/api/khub/maps/${e}/attachments/${t}`)}getMapResources(e){return this.get(`/api/khub/maps/${e}/resources`)}getMapResourceContent(e,t){return this.getRawData(`/api/khub/maps/${e}/resources/${t}`)}getUnstructuredDocument(e){return this.get(`/api/khub/documents/${e}`)}getUnstructuredDocumentContent(e){return this.getRawData(`/api/khub/documents/${e}/content`)}getCollectionDocuments(e,t){return this.get(`/api/users/${e}/collections/${t}/documents`)}get defaultAxiosConfig(){return{auth:this.auth,headers:{"Ft-Calling-App":this.ftCallingApp}}}get(e){return Pe.get(this.tenantBaseUrl+e,this.defaultAxiosConfig).then((e=>this.handleResponse(e)))}post(e,t){return Pe.post(this.tenantBaseUrl+e,t,this.defaultAxiosConfig).then((e=>this.handleResponse(e)))}getRawData(e){return Pe({...this.defaultAxiosConfig,method:"get",url:this.tenantBaseUrl+e,responseType:"arraybuffer"}).then((e=>this.handleResponse(e)))}handleResponse(e){if(e.status>=200&&e.status<400)return e.data;throw new Error(`${e.status}: ${e.statusText}`)}}e.FluidTopicsApi=Be,e.default=Be}));
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}));
@@ -1,12 +1,15 @@
1
- import { FtCollectionDocument, FtMap, FtMapResource, FtTocNode, FtTopic, FtUnstructuredDocument } from "./types/ft-common/public";
1
+ import "cross-fetch/polyfill";
2
+ import { FtCollectionDocument, FtMap, FtMapResource, FtTocNode, FtTopic, FtTopicContentTarget, FtUnstructuredDocument } from "./types/ft-common/public";
2
3
  import { FtAuthenticatedSession, FtMapAttachment } from "./types/ft-server/public";
3
4
  export * from "./types/ft-common/public";
4
5
  export * from "./types/ft-server/public";
5
6
  export declare class FluidTopicsApi {
6
7
  private readonly tenantBaseUrl;
7
8
  private readonly ftCallingApp;
8
- private auth?;
9
+ private authorization;
10
+ private get defaultHeaders();
9
11
  constructor(tenantBaseUrl: string, integrationIdentifier: string);
12
+ setApiKey(apiKey: string): void;
10
13
  setCredentials(login: string, password: string): void;
11
14
  clearAuthentication(): void;
12
15
  login(login: string, password: string): Promise<FtAuthenticatedSession>;
@@ -14,18 +17,21 @@ export declare class FluidTopicsApi {
14
17
  getMap(mapId: string): Promise<FtMap>;
15
18
  getTableOfContent(mapId: string): Promise<Array<FtTocNode>>;
16
19
  getTopic(mapId: string, topicContentId: string): Promise<FtTopic>;
17
- getTopicHTMLContent(mapId: string, topicContentId: string): Promise<string>;
20
+ getTopicHTMLContent(mapId: string, topicContentId: string, target?: FtTopicContentTarget): Promise<string>;
18
21
  getMapAttachments(mapId: string): Promise<Array<FtMapAttachment>>;
19
22
  getMapAttachmentContent(mapId: string, attachmentId: string): Promise<ArrayBuffer>;
20
23
  getMapResources(mapId: string): Promise<Array<FtMapResource>>;
21
24
  getMapResourceContent(mapId: string, resourceId: string): Promise<ArrayBuffer>;
22
25
  getUnstructuredDocument(documentId: string): Promise<FtUnstructuredDocument>;
23
26
  getUnstructuredDocumentContent(documentId: string): Promise<ArrayBuffer>;
27
+ getUnstructuredDocumentTextContent(documentId: string): Promise<string>;
24
28
  getCollectionDocuments(userId: string, collectionId: string): Promise<Array<FtCollectionDocument>>;
25
- private get defaultAxiosConfig();
26
29
  get<T>(endpoint: string): Promise<T>;
27
30
  post<T>(endpoint: string, data?: any): Promise<T>;
28
- private getRawData;
29
- private handleResponse;
31
+ put<T>(endpoint: string, data?: any): Promise<T>;
32
+ delete<T>(endpoint: string): Promise<T>;
33
+ fetch<FetchRequestInit, FetchResponse>(endpoint: string, init?: FetchRequestInit): Promise<FetchResponse>;
34
+ private makeRequest;
35
+ private fetchRawData;
30
36
  }
31
37
  export default FluidTopicsApi;
package/dist/mjs/index.js CHANGED
@@ -1,22 +1,40 @@
1
- import axios from "axios";
1
+ import "cross-fetch/polyfill";
2
2
  export * from "./types/ft-common/public";
3
3
  export * from "./types/ft-server/public";
4
+ function toBase64(s) {
5
+ return typeof Buffer !== "undefined" ? Buffer.from(s).toString("base64") : btoa(s);
6
+ }
7
+ async function handleError(response) {
8
+ if (!response.ok) {
9
+ throw new Error(`${response.status} - ${response.statusText}: ${await response.text()}`);
10
+ }
11
+ return response;
12
+ }
13
+ function getBody(response) {
14
+ return response.headers.get("Content-Type") === "application/json" ? response.json() : response.text();
15
+ }
4
16
  export class FluidTopicsApi {
5
17
  tenantBaseUrl;
6
18
  ftCallingApp;
7
- auth;
19
+ authorization = {};
20
+ get defaultHeaders() {
21
+ return {
22
+ ...this.authorization,
23
+ "Ft-Calling-App": this.ftCallingApp
24
+ };
25
+ }
8
26
  constructor(tenantBaseUrl, integrationIdentifier) {
9
27
  this.tenantBaseUrl = tenantBaseUrl.trim().replace(/\/$/, "");
10
28
  this.ftCallingApp = `ft-public-api/${integrationIdentifier}`;
11
29
  }
30
+ setApiKey(apiKey) {
31
+ this.authorization = { "Authorization": "Bearer " + apiKey };
32
+ }
12
33
  setCredentials(login, password) {
13
- this.auth = {
14
- username: login,
15
- password: password
16
- };
34
+ this.authorization = { "Authorization": "Basic " + toBase64(`${login}:${password}`) };
17
35
  }
18
36
  clearAuthentication() {
19
- this.auth = undefined;
37
+ this.authorization = {};
20
38
  }
21
39
  login(login, password) {
22
40
  let credentials = {
@@ -43,60 +61,73 @@ export class FluidTopicsApi {
43
61
  getTopic(mapId, topicContentId) {
44
62
  return this.get(`/api/khub/maps/${mapId}/topics/${topicContentId}`);
45
63
  }
46
- getTopicHTMLContent(mapId, topicContentId) {
47
- 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 : ""}`);
48
66
  }
49
67
  getMapAttachments(mapId) {
50
68
  return this.get(`/api/khub/maps/${mapId}/attachments`);
51
69
  }
52
70
  getMapAttachmentContent(mapId, attachmentId) {
53
- return this.getRawData(`/api/khub/maps/${mapId}/attachments/${attachmentId}`);
71
+ return this.fetchRawData(`/api/khub/maps/${mapId}/attachments/${attachmentId}/content`);
54
72
  }
55
73
  getMapResources(mapId) {
56
74
  return this.get(`/api/khub/maps/${mapId}/resources`);
57
75
  }
58
76
  getMapResourceContent(mapId, resourceId) {
59
- return this.getRawData(`/api/khub/maps/${mapId}/resources/${resourceId}`);
77
+ return this.fetchRawData(`/api/khub/maps/${mapId}/resources/${resourceId}/content`);
60
78
  }
61
79
  getUnstructuredDocument(documentId) {
62
80
  return this.get(`/api/khub/documents/${documentId}`);
63
81
  }
64
82
  getUnstructuredDocumentContent(documentId) {
65
- return this.getRawData(`/api/khub/documents/${documentId}/content`);
83
+ return this.fetchRawData(`/api/khub/documents/${documentId}/content`);
84
+ }
85
+ getUnstructuredDocumentTextContent(documentId) {
86
+ return this.get(`/api/khub/documents/${documentId}/content/text`);
66
87
  }
67
88
  getCollectionDocuments(userId, collectionId) {
68
89
  return this.get(`/api/users/${userId}/collections/${collectionId}/documents`);
69
90
  }
70
- get defaultAxiosConfig() {
71
- return {
72
- auth: this.auth,
73
- headers: {
74
- "Ft-Calling-App": this.ftCallingApp
75
- }
76
- };
77
- }
78
91
  get(endpoint) {
79
- return axios.get(this.tenantBaseUrl + endpoint, this.defaultAxiosConfig)
80
- .then(response => this.handleResponse(response));
92
+ return this.makeRequest("GET", endpoint);
81
93
  }
82
94
  post(endpoint, data) {
83
- return axios.post(this.tenantBaseUrl + endpoint, data, this.defaultAxiosConfig)
84
- .then(response => this.handleResponse(response));
85
- }
86
- getRawData(endpoint) {
87
- return axios({
88
- ...this.defaultAxiosConfig,
89
- method: "get",
90
- url: this.tenantBaseUrl + endpoint,
91
- responseType: "arraybuffer"
92
- })
93
- .then(response => this.handleResponse(response));
95
+ return this.makeRequest("POST", endpoint, data);
94
96
  }
95
- handleResponse(response) {
96
- if (response.status >= 200 && response.status < 400) {
97
- return response.data;
97
+ put(endpoint, data) {
98
+ return this.makeRequest("PUT", endpoint, data);
99
+ }
100
+ delete(endpoint) {
101
+ return this.makeRequest("DELETE", endpoint);
102
+ }
103
+ async fetch(endpoint, init) {
104
+ const requestInit = init;
105
+ if (!endpoint.startsWith("/")) {
106
+ endpoint = "/" + endpoint;
98
107
  }
99
- throw new Error(`${response.status}: ${response.statusText}`);
108
+ return await fetch(this.tenantBaseUrl + endpoint, {
109
+ ...(requestInit ?? {}),
110
+ headers: {
111
+ ...this.defaultHeaders,
112
+ ...(requestInit?.headers ?? {})
113
+ }
114
+ });
115
+ }
116
+ makeRequest(method, endpoint, data) {
117
+ return this.fetch(endpoint, {
118
+ method: method,
119
+ headers: {
120
+ ...(data != null ? { "Content-Type": "application/json" } : {})
121
+ },
122
+ body: data != null ? JSON.stringify(data) : undefined
123
+ })
124
+ .then(handleError)
125
+ .then(getBody);
126
+ }
127
+ fetchRawData(endpoint) {
128
+ return fetch(this.tenantBaseUrl + endpoint, { headers: this.defaultHeaders })
129
+ .then(handleError)
130
+ .then(response => response.arrayBuffer());
100
131
  }
101
132
  }
102
133
  export default FluidTopicsApi;
@@ -1,23 +1,25 @@
1
1
  export interface FtCredentials {
2
2
  password: string;
3
- newPassword: string | undefined;
3
+ newPassword?: string;
4
4
  rememberMe: boolean;
5
5
  login: string;
6
6
  }
7
+ export declare const isFtCredentials: (o: any) => o is FtCredentials;
7
8
  export interface FtCollectionDocument {
8
9
  deleted: boolean;
9
- apiUrl: string | undefined;
10
- portalUrl: string | undefined;
10
+ apiUrl?: string;
11
+ portalUrl?: string;
11
12
  id: string;
12
13
  title: string;
13
14
  type: FtSearchResultType;
14
15
  }
16
+ export declare const isFtCollectionDocument: (o: any) => o is FtCollectionDocument;
15
17
  export interface FtMap {
16
- prettyUrl: string | undefined;
18
+ prettyUrl?: string;
17
19
  metadata: Array<FtMetadata>;
18
20
  openMode: FtOpenMode;
19
21
  topicsApiEndpoint: string;
20
- description: string | undefined;
22
+ description?: string;
21
23
  attachmentsApiEndpoint: string;
22
24
  editorialType: FtEditorialType;
23
25
  baseId: string;
@@ -27,70 +29,85 @@ export interface FtMap {
27
29
  lastEdition: string;
28
30
  originId: string;
29
31
  rightsApiEndpoint: string;
30
- originUrl: string | undefined;
32
+ originUrl?: string;
31
33
  readerUrl: string;
32
- khubVersion: string | undefined;
34
+ khubVersion?: string;
33
35
  id: string;
34
- lang: string | undefined;
36
+ lang?: string;
35
37
  }
38
+ export declare const isFtMap: (o: any) => o is FtMap;
36
39
  export interface FtTocNode {
37
40
  tocId: string;
38
41
  children: Array<FtTocNode>;
39
42
  contentId: string;
40
43
  title: string;
41
44
  }
45
+ export declare const isFtTocNode: (o: any) => o is FtTocNode;
42
46
  export interface FtTopic {
43
47
  metadata: Array<FtMetadata>;
44
48
  id: string;
45
49
  contentApiEndpoint: string;
46
50
  title: string;
47
51
  }
52
+ export declare const isFtTopic: (o: any) => o is FtTopic;
48
53
  export interface FtUnstructuredDocument {
49
- prettyUrl: string | undefined;
54
+ prettyUrl?: string;
50
55
  metadata: Array<FtMetadata>;
51
56
  openMode: string;
52
- description: string | undefined;
57
+ description?: string;
53
58
  mimeType: string;
54
- baseId: string | undefined;
55
- clusterId: string | undefined;
59
+ baseId?: string;
60
+ clusterId?: string;
56
61
  contentApiEndpoint: string;
57
62
  title: string;
58
- lastPublication: string | undefined;
63
+ lastPublication?: string;
59
64
  viewerUrl: string;
60
65
  lastEdition: string;
61
66
  filename: string;
62
- originId: string | undefined;
67
+ originId?: string;
63
68
  rightsApiEndpoint: string;
64
- originUrl: string | undefined;
65
- khubVersion: string | undefined;
69
+ originUrl?: string;
70
+ khubVersion?: string;
66
71
  id: string;
67
- lang: string | undefined;
72
+ lang?: string;
68
73
  }
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;
69
80
  export interface FtMetadata {
70
81
  values: Array<string>;
71
82
  label: string;
72
83
  key: string;
73
84
  }
85
+ export declare const isFtMetadata: (o: any) => o is FtMetadata;
74
86
  export interface FtMapResource {
75
87
  contentUrl: string;
76
88
  filename: string;
77
89
  id: string;
78
90
  mimeType: string;
79
91
  }
92
+ export declare const isFtMapResource: (o: any) => o is FtMapResource;
80
93
  export declare enum FtEditorialType {
81
94
  ARTICLE = "ARTICLE",
82
95
  BOOK = "BOOK"
83
96
  }
97
+ export declare const isFtEditorialType: (o: any) => o is FtEditorialType;
84
98
  export declare enum FtOpenMode {
85
99
  FLUIDTOPICS = "FLUIDTOPICS",
86
100
  EXTERNAL = "EXTERNAL"
87
101
  }
102
+ export declare const isFtOpenMode: (o: any) => o is FtOpenMode;
88
103
  export declare enum FtSearchResultType {
89
104
  MAP = "MAP",
90
105
  DOCUMENT = "DOCUMENT",
91
106
  TOPIC = "TOPIC"
92
107
  }
108
+ export declare const isFtSearchResultType: (o: any) => o is FtSearchResultType;
93
109
  export interface FtAuthenticationIdentifier {
94
110
  identifier: string;
95
111
  realm: string;
96
112
  }
113
+ export declare const isFtAuthenticationIdentifier: (o: any) => o is FtAuthenticationIdentifier;
@@ -1,15 +1,126 @@
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 isFtCredentials = (o) => {
6
+ return isObject(o)
7
+ && (isString(o.password))
8
+ && (o.newPassword == null || isString(o.newPassword))
9
+ && (isBoolean(o.rememberMe))
10
+ && (isString(o.login));
11
+ };
12
+ export const isFtCollectionDocument = (o) => {
13
+ return isObject(o)
14
+ && (isBoolean(o.deleted))
15
+ && (o.apiUrl == null || isString(o.apiUrl))
16
+ && (o.portalUrl == null || isString(o.portalUrl))
17
+ && (isString(o.id))
18
+ && (isString(o.title))
19
+ && (isFtSearchResultType(o.type));
20
+ };
21
+ export const isFtMap = (o) => {
22
+ return isObject(o)
23
+ && (o.prettyUrl == null || isString(o.prettyUrl))
24
+ && ((Array.isArray(o.metadata)
25
+ && o.metadata.every((v) => isFtMetadata(v))))
26
+ && (isFtOpenMode(o.openMode))
27
+ && (isString(o.topicsApiEndpoint))
28
+ && (o.description == null || isString(o.description))
29
+ && (isString(o.attachmentsApiEndpoint))
30
+ && (isFtEditorialType(o.editorialType))
31
+ && (isString(o.baseId))
32
+ && (isString(o.clusterId))
33
+ && (isString(o.title))
34
+ && (isString(o.lastPublication))
35
+ && (isString(o.lastEdition))
36
+ && (isString(o.originId))
37
+ && (isString(o.rightsApiEndpoint))
38
+ && (o.originUrl == null || isString(o.originUrl))
39
+ && (isString(o.readerUrl))
40
+ && (o.khubVersion == null || isString(o.khubVersion))
41
+ && (isString(o.id))
42
+ && (o.lang == null || isString(o.lang));
43
+ };
44
+ export const isFtTocNode = (o) => {
45
+ return isObject(o)
46
+ && (isString(o.tocId))
47
+ && ((Array.isArray(o.children)
48
+ && o.children.every((v) => isFtTocNode(v))))
49
+ && (isString(o.contentId))
50
+ && (isString(o.title));
51
+ };
52
+ export const isFtTopic = (o) => {
53
+ return isObject(o)
54
+ && ((Array.isArray(o.metadata)
55
+ && o.metadata.every((v) => isFtMetadata(v))))
56
+ && (isString(o.id))
57
+ && (isString(o.contentApiEndpoint))
58
+ && (isString(o.title));
59
+ };
60
+ export const isFtUnstructuredDocument = (o) => {
61
+ return isObject(o)
62
+ && (o.prettyUrl == null || isString(o.prettyUrl))
63
+ && ((Array.isArray(o.metadata)
64
+ && o.metadata.every((v) => isFtMetadata(v))))
65
+ && (isString(o.openMode))
66
+ && (o.description == null || isString(o.description))
67
+ && (isString(o.mimeType))
68
+ && (o.baseId == null || isString(o.baseId))
69
+ && (o.clusterId == null || isString(o.clusterId))
70
+ && (isString(o.contentApiEndpoint))
71
+ && (isString(o.title))
72
+ && (o.lastPublication == null || isString(o.lastPublication))
73
+ && (isString(o.viewerUrl))
74
+ && (isString(o.lastEdition))
75
+ && (isString(o.filename))
76
+ && (o.originId == null || isString(o.originId))
77
+ && (isString(o.rightsApiEndpoint))
78
+ && (o.originUrl == null || isString(o.originUrl))
79
+ && (o.khubVersion == null || isString(o.khubVersion))
80
+ && (isString(o.id))
81
+ && (o.lang == null || isString(o.lang));
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
+ };
92
+ export const isFtMetadata = (o) => {
93
+ return isObject(o)
94
+ && ((Array.isArray(o.values)
95
+ && o.values.every((v) => isString(v))))
96
+ && (isString(o.label))
97
+ && (isString(o.key));
98
+ };
99
+ export const isFtMapResource = (o) => {
100
+ return isObject(o)
101
+ && (isString(o.contentUrl))
102
+ && (isString(o.filename))
103
+ && (isString(o.id))
104
+ && (isString(o.mimeType));
105
+ };
1
106
  // From: WsEditorialType
2
107
  export var FtEditorialType;
3
108
  (function (FtEditorialType) {
4
109
  FtEditorialType["ARTICLE"] = "ARTICLE";
5
110
  FtEditorialType["BOOK"] = "BOOK";
6
111
  })(FtEditorialType || (FtEditorialType = {}));
112
+ export const isFtEditorialType = (o) => {
113
+ return ["ARTICLE", "BOOK"].includes(o);
114
+ };
7
115
  // From: WsOpenMode
8
116
  export var FtOpenMode;
9
117
  (function (FtOpenMode) {
10
118
  FtOpenMode["FLUIDTOPICS"] = "FLUIDTOPICS";
11
119
  FtOpenMode["EXTERNAL"] = "EXTERNAL";
12
120
  })(FtOpenMode || (FtOpenMode = {}));
121
+ export const isFtOpenMode = (o) => {
122
+ return ["FLUIDTOPICS", "EXTERNAL"].includes(o);
123
+ };
13
124
  // From: WsPublicSearchResultType
14
125
  export var FtSearchResultType;
15
126
  (function (FtSearchResultType) {
@@ -17,3 +128,11 @@ export var FtSearchResultType;
17
128
  FtSearchResultType["DOCUMENT"] = "DOCUMENT";
18
129
  FtSearchResultType["TOPIC"] = "TOPIC";
19
130
  })(FtSearchResultType || (FtSearchResultType = {}));
131
+ export const isFtSearchResultType = (o) => {
132
+ return ["MAP", "DOCUMENT", "TOPIC"].includes(o);
133
+ };
134
+ export const isFtAuthenticationIdentifier = (o) => {
135
+ return isObject(o)
136
+ && (isString(o.identifier))
137
+ && (isString(o.realm));
138
+ };
@@ -2,18 +2,21 @@ export interface FtAuthenticatedSession {
2
2
  authenticationIdentifier: any;
3
3
  profile: FtUserProfile;
4
4
  }
5
+ export declare const isFtAuthenticatedSession: (o: any) => o is FtAuthenticatedSession;
5
6
  export interface FtUserProfile {
6
- emailAddress: string | undefined;
7
- displayName: string | undefined;
7
+ emailAddress?: string;
8
+ displayName?: string;
8
9
  roles: Array<any>;
9
10
  userId: string;
10
11
  }
12
+ export declare const isFtUserProfile: (o: any) => o is FtUserProfile;
11
13
  export interface FtMapAttachment {
12
14
  file: string;
13
- size: number | undefined;
15
+ size?: number;
14
16
  externalLink: boolean;
15
17
  name: string;
16
18
  id: string;
17
- mimeType: string | undefined;
18
- viewerUrl: string | undefined;
19
+ mimeType?: string;
20
+ viewerUrl?: string;
19
21
  }
22
+ export declare const isFtMapAttachment: (o: any) => o is FtMapAttachment;
@@ -1 +1,25 @@
1
- export {};
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 isFtAuthenticatedSession = (o) => {
6
+ return isObject(o)
7
+ && (isFtUserProfile(o.profile));
8
+ };
9
+ export const isFtUserProfile = (o) => {
10
+ return isObject(o)
11
+ && (o.emailAddress == null || isString(o.emailAddress))
12
+ && (o.displayName == null || isString(o.displayName))
13
+ && ((Array.isArray(o.roles)))
14
+ && (isString(o.userId));
15
+ };
16
+ export const isFtMapAttachment = (o) => {
17
+ return isObject(o)
18
+ && (isString(o.file))
19
+ && (o.size == null || isNumber(o.size))
20
+ && (isBoolean(o.externalLink))
21
+ && (isString(o.name))
22
+ && (isString(o.id))
23
+ && (o.mimeType == null || isString(o.mimeType))
24
+ && (o.viewerUrl == null || isString(o.viewerUrl));
25
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluid-topics/public-api",
3
- "version": "1.0.7",
3
+ "version": "1.0.11",
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
- "axios": "^0.21.4"
20
+ "cross-fetch": "^3.1.4"
21
21
  },
22
22
  "devDependencies": {
23
23
  "@rollup/plugin-commonjs": "^20.0.0",