@fluid-topics/public-api 1.0.46 → 1.0.48

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.
@@ -122,18 +122,18 @@ export declare class FluidTopicsApi {
122
122
  logout(): Promise<void>;
123
123
  getCurrentSession(): Promise<FtSession>;
124
124
  getReaderConfiguration(): Promise<FtReaderConfiguration>;
125
- getMap(mapId: string): Promise<FtMap>;
126
- getTableOfContent(mapId: string): Promise<Array<FtTocNode>>;
127
- getPages(mapId: string): Promise<FtPaginatedToc>;
128
- getTopic(mapId: string, topicContentId: string): Promise<FtTopic>;
129
- getTopicHTMLContent(mapId: string, topicContentId: string, target?: FtTopicContentTarget | FtTopicContentTargetKeys): Promise<string>;
130
- getMapAttachments(mapId: string): Promise<Array<FtMapAttachment>>;
131
- getMapAttachmentContent(mapId: string, attachmentId: string): Promise<ArrayBuffer>;
132
- getMapResources(mapId: string): Promise<Array<FtMapResource>>;
133
- getMapResourceContent(mapId: string, resourceId: string): Promise<ArrayBuffer>;
134
- getUnstructuredDocument(documentId: string): Promise<FtUnstructuredDocument>;
135
- getUnstructuredDocumentContent(documentId: string): Promise<ArrayBuffer>;
136
- getUnstructuredDocumentTextContent(documentId: string): Promise<string>;
125
+ getMap(mapId: string, v?: string): Promise<FtMap>;
126
+ getTableOfContent(mapId: string, v?: string): Promise<Array<FtTocNode>>;
127
+ getPages(mapId: string, v?: string): Promise<FtPaginatedToc>;
128
+ getTopic(mapId: string, topicContentId: string, v?: string): Promise<FtTopic>;
129
+ getTopicHTMLContent(mapId: string, topicContentId: string, target?: FtTopicContentTarget | FtTopicContentTargetKeys, v?: string): Promise<string>;
130
+ getMapAttachments(mapId: string, v?: string): Promise<Array<FtMapAttachment>>;
131
+ getMapAttachmentContent(mapId: string, attachmentId: string, v?: string): Promise<ArrayBuffer>;
132
+ getMapResources(mapId: string, v?: string): Promise<Array<FtMapResource>>;
133
+ getMapResourceContent(mapId: string, resourceId: string, v?: string): Promise<ArrayBuffer>;
134
+ getUnstructuredDocument(documentId: string, v?: string): Promise<FtUnstructuredDocument>;
135
+ getUnstructuredDocumentContent(documentId: string, v?: string): Promise<ArrayBuffer>;
136
+ getUnstructuredDocumentTextContent(documentId: string, v?: string): Promise<string>;
137
137
  getCollectionDocuments(userId: string, collectionId: string): Promise<Array<FtCollectionDocument>>;
138
138
  getSuggestions(request: FtSuggestRequest): Promise<FtSuggestResults>;
139
139
  search(request: FtSearchRequest): Promise<FtSearchResults>;
@@ -154,7 +154,7 @@ export declare class FluidTopicsApi {
154
154
  getCustomMessageContext(locale: string, name: string): Promise<FtMessageContext>;
155
155
  listMySearches(userId: string): Promise<FtMySearch[]>;
156
156
  listMyBookmarks(userId: string): Promise<FtBookmark[]>;
157
- get<T>(endpoint: string): Promise<T>;
157
+ get<T>(endpoint: string, v?: string): Promise<T>;
158
158
  post<T>(endpoint: string, data?: any): Promise<T>;
159
159
  put<T>(endpoint: string, data?: any): Promise<T>;
160
160
  delete<T>(endpoint: string): Promise<T>;
@@ -163,5 +163,6 @@ export declare class FluidTopicsApi {
163
163
  upload<T>(method: string, endpoint: string, body: any, onProgress?: (e: any) => void): Promise<T>;
164
164
  private makeRequest;
165
165
  private fetchRawData;
166
+ withVersion(endpoint: string, v: string | undefined): string;
166
167
  }
167
168
  export default FluidTopicsApi;
package/dist/mjs/index.js CHANGED
@@ -182,41 +182,41 @@ export class FluidTopicsApi {
182
182
  getReaderConfiguration() {
183
183
  return this.get(this.endpoints.configuration.reader);
184
184
  }
185
- getMap(mapId) {
186
- return this.get(this.endpoints.khub.maps.mapId(mapId).info);
185
+ getMap(mapId, v) {
186
+ return this.get(this.endpoints.khub.maps.mapId(mapId).info, v);
187
187
  }
188
- getTableOfContent(mapId) {
189
- return this.get(this.endpoints.khub.maps.mapId(mapId).toc);
188
+ getTableOfContent(mapId, v) {
189
+ return this.get(this.endpoints.khub.maps.mapId(mapId).toc, v);
190
190
  }
191
- getPages(mapId) {
192
- return this.get(this.endpoints.khub.maps.mapId(mapId).pages);
191
+ getPages(mapId, v) {
192
+ return this.get(this.endpoints.khub.maps.mapId(mapId).pages, v);
193
193
  }
194
- getTopic(mapId, topicContentId) {
195
- return this.get(this.endpoints.khub.maps.mapId(mapId).topics.contentId(topicContentId).info);
194
+ getTopic(mapId, topicContentId, v) {
195
+ return this.get(this.endpoints.khub.maps.mapId(mapId).topics.contentId(topicContentId).info, v);
196
196
  }
197
- getTopicHTMLContent(mapId, topicContentId, target) {
198
- return this.get(this.endpoints.khub.maps.mapId(mapId).topics.contentId(topicContentId).content + (target ? "?target=" + target : ""));
197
+ getTopicHTMLContent(mapId, topicContentId, target, v) {
198
+ return this.get(this.endpoints.khub.maps.mapId(mapId).topics.contentId(topicContentId).content + (target ? "?target=" + target : ""), v);
199
199
  }
200
- getMapAttachments(mapId) {
201
- return this.get(this.endpoints.khub.maps.mapId(mapId).attachments.list);
200
+ getMapAttachments(mapId, v) {
201
+ return this.get(this.endpoints.khub.maps.mapId(mapId).attachments.list, v);
202
202
  }
203
- getMapAttachmentContent(mapId, attachmentId) {
204
- return this.fetchRawData(this.endpoints.khub.maps.mapId(mapId).attachments.attachmentId(attachmentId).content);
203
+ getMapAttachmentContent(mapId, attachmentId, v) {
204
+ return this.fetchRawData(this.endpoints.khub.maps.mapId(mapId).attachments.attachmentId(attachmentId).content, v);
205
205
  }
206
- getMapResources(mapId) {
207
- return this.get(this.endpoints.khub.maps.mapId(mapId).resources.list);
206
+ getMapResources(mapId, v) {
207
+ return this.get(this.endpoints.khub.maps.mapId(mapId).resources.list, v);
208
208
  }
209
- getMapResourceContent(mapId, resourceId) {
210
- return this.fetchRawData(this.endpoints.khub.maps.mapId(mapId).resources.resourceId(resourceId).content);
209
+ getMapResourceContent(mapId, resourceId, v) {
210
+ return this.fetchRawData(this.endpoints.khub.maps.mapId(mapId).resources.resourceId(resourceId).content, v);
211
211
  }
212
- getUnstructuredDocument(documentId) {
213
- return this.get(this.endpoints.khub.documents.documentId(documentId).info);
212
+ getUnstructuredDocument(documentId, v) {
213
+ return this.get(this.endpoints.khub.documents.documentId(documentId).info, v);
214
214
  }
215
- getUnstructuredDocumentContent(documentId) {
216
- return this.fetchRawData(this.endpoints.khub.documents.documentId(documentId).content);
215
+ getUnstructuredDocumentContent(documentId, v) {
216
+ return this.fetchRawData(this.endpoints.khub.documents.documentId(documentId).content, v);
217
217
  }
218
- getUnstructuredDocumentTextContent(documentId) {
219
- return this.get(this.endpoints.khub.documents.documentId(documentId).text);
218
+ getUnstructuredDocumentTextContent(documentId, v) {
219
+ return this.get(this.endpoints.khub.documents.documentId(documentId).text, v);
220
220
  }
221
221
  getCollectionDocuments(userId, collectionId) {
222
222
  return this.get(this.endpoints.users.userId(userId).collections.collectionId(collectionId).documents);
@@ -280,8 +280,8 @@ export class FluidTopicsApi {
280
280
  listMyBookmarks(userId) {
281
281
  return this.get(this.endpoints.users.userId(userId).bookmarks.list);
282
282
  }
283
- get(endpoint) {
284
- return this.makeRequest("GET", endpoint);
283
+ get(endpoint, v) {
284
+ return this.makeRequest("GET", this.withVersion(endpoint, v));
285
285
  }
286
286
  post(endpoint, data) {
287
287
  return this.makeRequest("POST", endpoint, data);
@@ -293,7 +293,7 @@ export class FluidTopicsApi {
293
293
  return this.makeRequest("DELETE", endpoint);
294
294
  }
295
295
  makeAbsolute(endpoint) {
296
- return this.tenantBaseUrl + endpoint.replace(/^\//, "");
296
+ return endpoint.startsWith(this.tenantBaseUrl) ? endpoint : (this.tenantBaseUrl + endpoint.replace(/^\//, ""));
297
297
  }
298
298
  async fetch(endpoint, init) {
299
299
  const requestInit = init;
@@ -339,13 +339,20 @@ export class FluidTopicsApi {
339
339
  .then(handleError)
340
340
  .then(getBody);
341
341
  }
342
- fetchRawData(endpoint) {
343
- return fetch(this.makeAbsolute(endpoint), {
342
+ fetchRawData(endpoint, v) {
343
+ return fetch(this.withVersion(endpoint, v), {
344
344
  headers: this.defaultHeaders,
345
345
  credentials: this.authorization == null ? "include" : undefined
346
346
  })
347
347
  .then(handleError)
348
348
  .then(response => response.arrayBuffer());
349
349
  }
350
+ withVersion(endpoint, v) {
351
+ let url = new URL(this.makeAbsolute(endpoint));
352
+ if (v) {
353
+ url.searchParams.append("v", v);
354
+ }
355
+ return url.toString();
356
+ }
350
357
  }
351
358
  export default FluidTopicsApi;
@@ -206,8 +206,10 @@ export declare const isFtMySearch: (o: any) => o is FtMySearch;
206
206
  export interface FtMySearchRequest {
207
207
  periodFilter?: FtPeriodFilter;
208
208
  query: string;
209
+ scope?: FtSearchScopeKeys | FtSearchScope;
209
210
  filters: Array<FtLabeledSearchFilter>;
210
211
  sort: Array<FtSearchSortCriterion>;
212
+ virtualField?: FtVirtualFieldKeys | FtVirtualField;
211
213
  contentLocale?: string;
212
214
  }
213
215
  export declare const isFtMySearchRequest: (o: any) => o is FtMySearchRequest;
@@ -311,6 +313,13 @@ export declare enum FtSearchSortCriterionType {
311
313
  }
312
314
  export type FtSearchSortCriterionTypeKeys = keyof typeof FtSearchSortCriterionType;
313
315
  export declare const isFtSearchSortCriterionType: (o: any) => o is FtSearchSortCriterionType;
316
+ export declare enum FtVirtualField {
317
+ EVERYWHERE = "EVERYWHERE",
318
+ TITLE_ONLY = "TITLE_ONLY",
319
+ NONE = "NONE"
320
+ }
321
+ export type FtVirtualFieldKeys = keyof typeof FtVirtualField;
322
+ export declare const isFtVirtualField: (o: any) => o is FtVirtualField;
314
323
  export interface FtSearchResultsPageInfo {
315
324
  totalResultsCount: number;
316
325
  isLastPage: boolean;
@@ -368,11 +377,13 @@ export declare const isFtSearchPrior: (o: any) => o is FtSearchPrior;
368
377
  export interface FtSearchRequest {
369
378
  periodFilter?: FtPeriodFilter;
370
379
  query: string;
380
+ scope?: FtSearchScopeKeys | FtSearchScope;
371
381
  paging: FtPageRequest;
372
382
  filters: Array<FtSearchFilter>;
373
383
  sort: Array<FtSearchSortCriterion>;
374
384
  lastModified?: any;
375
385
  uiLocale?: string;
386
+ virtualField?: FtVirtualFieldKeys | FtVirtualField;
376
387
  contentLocale?: string;
377
388
  priors?: Array<FtSearchPrior>;
378
389
  facets: Array<FtSearchFacetConf>;
@@ -451,6 +462,12 @@ export declare enum FtSearchResultType {
451
462
  }
452
463
  export type FtSearchResultTypeKeys = keyof typeof FtSearchResultType;
453
464
  export declare const isFtSearchResultType: (o: any) => o is FtSearchResultType;
465
+ export declare enum FtSearchScope {
466
+ DEFAULT = "DEFAULT",
467
+ DOCUMENTS = "DOCUMENTS"
468
+ }
469
+ export type FtSearchScopeKeys = keyof typeof FtSearchScope;
470
+ export declare const isFtSearchScope: (o: any) => o is FtSearchScope;
454
471
  export interface FtSearchFacet {
455
472
  hierarchical: boolean;
456
473
  label: string;
@@ -237,10 +237,12 @@ export const isFtMySearchRequest = (o) => {
237
237
  return isObject(o)
238
238
  && (o.periodFilter == null || isFtPeriodFilter(o.periodFilter))
239
239
  && (isString(o.query))
240
+ && (o.scope == null || isFtSearchScope(o.scope))
240
241
  && ((Array.isArray(o.filters)
241
242
  && o.filters.every((v) => isFtLabeledSearchFilter(v))))
242
243
  && ((Array.isArray(o.sort)
243
244
  && o.sort.every((v) => isFtSearchSortCriterion(v))))
245
+ && (o.virtualField == null || isFtVirtualField(o.virtualField))
244
246
  && (o.contentLocale == null || isString(o.contentLocale));
245
247
  };
246
248
  // From: RatingType
@@ -362,6 +364,16 @@ export var FtSearchSortCriterionType;
362
364
  export const isFtSearchSortCriterionType = (o) => {
363
365
  return ["ALPHA", "NATURAL"].includes(o);
364
366
  };
367
+ // From: VirtualField
368
+ export var FtVirtualField;
369
+ (function (FtVirtualField) {
370
+ FtVirtualField["EVERYWHERE"] = "EVERYWHERE";
371
+ FtVirtualField["TITLE_ONLY"] = "TITLE_ONLY";
372
+ FtVirtualField["NONE"] = "NONE";
373
+ })(FtVirtualField || (FtVirtualField = {}));
374
+ export const isFtVirtualField = (o) => {
375
+ return ["EVERYWHERE", "TITLE_ONLY", "NONE"].includes(o);
376
+ };
365
377
  export const isFtSearchResultsPageInfo = (o) => {
366
378
  return isObject(o)
367
379
  && (isNumber(o.totalResultsCount))
@@ -432,12 +444,14 @@ export const isFtSearchRequest = (o) => {
432
444
  return isObject(o)
433
445
  && (o.periodFilter == null || isFtPeriodFilter(o.periodFilter))
434
446
  && (isString(o.query))
447
+ && (o.scope == null || isFtSearchScope(o.scope))
435
448
  && (isFtPageRequest(o.paging))
436
449
  && ((Array.isArray(o.filters)
437
450
  && o.filters.every((v) => isFtSearchFilter(v))))
438
451
  && ((Array.isArray(o.sort)
439
452
  && o.sort.every((v) => isFtSearchSortCriterion(v))))
440
453
  && (o.uiLocale == null || isString(o.uiLocale))
454
+ && (o.virtualField == null || isFtVirtualField(o.virtualField))
441
455
  && (o.contentLocale == null || isString(o.contentLocale))
442
456
  && (o.priors == null || (Array.isArray(o.priors)
443
457
  && o.priors.every((v) => isFtSearchPrior(v))))
@@ -523,6 +537,15 @@ export var FtSearchResultType;
523
537
  export const isFtSearchResultType = (o) => {
524
538
  return ["MAP", "DOCUMENT", "TOPIC"].includes(o);
525
539
  };
540
+ // From: WsPublicSearchScope
541
+ export var FtSearchScope;
542
+ (function (FtSearchScope) {
543
+ FtSearchScope["DEFAULT"] = "DEFAULT";
544
+ FtSearchScope["DOCUMENTS"] = "DOCUMENTS";
545
+ })(FtSearchScope || (FtSearchScope = {}));
546
+ export const isFtSearchScope = (o) => {
547
+ return ["DEFAULT", "DOCUMENTS"].includes(o);
548
+ };
526
549
  export const isFtSearchFacet = (o) => {
527
550
  return isObject(o)
528
551
  && (isBoolean(o.hierarchical))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluid-topics/public-api",
3
- "version": "1.0.46",
3
+ "version": "1.0.48",
4
4
  "description": "Fluid Topics Public API",
5
5
  "author": "Fluid Topics dev team <opensource@antidot.net>",
6
6
  "license": "LGPL-3.0-only",