@fluid-topics/public-api 1.0.74 → 1.0.76-alpha
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 +13 -10
- package/dist/cjs/roles/roles.js +7 -7
- package/dist/cjs/types/ft-common/public.js +29 -83
- package/dist/fluidtopics.min.js +1 -1
- package/dist/mjs/index.d.ts +7 -8
- package/dist/mjs/index.js +6 -6
- package/dist/mjs/preferences/unauthenticated-preferences.d.ts +1 -1
- package/dist/mjs/roles/roles.d.ts +1 -1
- package/dist/mjs/roles/roles.js +1 -1
- package/dist/mjs/types/ft-common/public.d.ts +17 -57
- package/dist/mjs/types/ft-common/public.js +25 -72
- package/package.json +2 -2
- package/.npmignore +0 -8
- package/build/cjs/helpers/GenAIChunkReader.js +0 -66
- package/build/cjs/index.js +0 -473
- package/build/cjs/preferences/unauthenticated-preferences.js +0 -67
- package/build/cjs/roles/roles.js +0 -31
- package/build/cjs/types/ft-common/public.js +0 -902
- package/build/cjs/types/ft-server/public.js +0 -146
- package/build/mjs/helpers/GenAIChunkReader.d.ts +0 -19
- package/build/mjs/helpers/GenAIChunkReader.js +0 -37
- package/build/mjs/index.d.ts +0 -191
- package/build/mjs/index.js +0 -432
- package/build/mjs/preferences/unauthenticated-preferences.d.ts +0 -9
- package/build/mjs/preferences/unauthenticated-preferences.js +0 -61
- package/build/mjs/roles/roles.d.ts +0 -2
- package/build/mjs/roles/roles.js +0 -25
- package/build/mjs/types/ft-common/public.d.ts +0 -697
- package/build/mjs/types/ft-common/public.js +0 -809
- package/build/mjs/types/ft-server/public.d.ts +0 -104
- package/build/mjs/types/ft-server/public.js +0 -127
- package/build/rollup/fluidtopics.min.js +0 -1
- package/build/test-results/web-components.xml +0 -12
- package/packages/cjs/package.json +0 -3
- package/packages/mjs/package.json +0 -3
- package/test-browser/helpers/GenAIChunkReader.test.ts +0 -54
- package/vite-plugin.mjs +0 -95
- package/web-test-runner.config.mjs +0 -58
- package/yarn.lock +0 -4132
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
export declare enum FtConfigurationHistoryEntryStatus {
|
|
2
|
-
VALID = "VALID",
|
|
3
|
-
INVALID = "INVALID"
|
|
4
|
-
}
|
|
5
|
-
export type FtConfigurationHistoryEntryStatusKeys = keyof typeof FtConfigurationHistoryEntryStatus;
|
|
6
|
-
export declare const isFtConfigurationHistoryEntryStatus: (o: any) => o is FtConfigurationHistoryEntryStatus;
|
|
7
|
-
export interface FtReaderConfiguration {
|
|
8
|
-
feedback: FtReaderFeedbackConfiguration;
|
|
9
|
-
loadAfterLastVisibleTopic: number;
|
|
10
|
-
relativeTopicPivotMetadata: string;
|
|
11
|
-
loadBeforeFirstVisibleTopic: number;
|
|
12
|
-
relativePivotMetadata: string;
|
|
13
|
-
}
|
|
14
|
-
export declare const isFtReaderConfiguration: (o: any) => o is FtReaderConfiguration;
|
|
15
|
-
export interface FtReaderFeedbackConfiguration {
|
|
16
|
-
mailsSentByFluidTopics: boolean;
|
|
17
|
-
mailsSentByFluidTopicsForUnauthenticatedUsers: boolean;
|
|
18
|
-
recipients: Array<string>;
|
|
19
|
-
bodyMetadataIds: Array<string>;
|
|
20
|
-
subjectMetadataIds: Array<string>;
|
|
21
|
-
}
|
|
22
|
-
export declare const isFtReaderFeedbackConfiguration: (o: any) => o is FtReaderFeedbackConfiguration;
|
|
23
|
-
export interface FtGenAIRating {
|
|
24
|
-
rating: number;
|
|
25
|
-
comment: string;
|
|
26
|
-
queryId: string;
|
|
27
|
-
}
|
|
28
|
-
export declare const isFtGenAIRating: (o: any) => o is FtGenAIRating;
|
|
29
|
-
export interface FtGenAIGenerateInput {
|
|
30
|
-
profileId: string;
|
|
31
|
-
parameters?: Record<string, string>;
|
|
32
|
-
}
|
|
33
|
-
export declare const isFtGenAIGenerateInput: (o: any) => o is FtGenAIGenerateInput;
|
|
34
|
-
export interface FtRagHistory {
|
|
35
|
-
role: string;
|
|
36
|
-
content: string;
|
|
37
|
-
}
|
|
38
|
-
export declare const isFtRagHistory: (o: any) => o is FtRagHistory;
|
|
39
|
-
export interface FtRagInput {
|
|
40
|
-
profileId: string;
|
|
41
|
-
conversationId?: string;
|
|
42
|
-
query: string;
|
|
43
|
-
messages?: Array<FtRagHistory>;
|
|
44
|
-
filters?: Array<FtSemanticSearchFilter>;
|
|
45
|
-
}
|
|
46
|
-
export declare const isFtRagInput: (o: any) => o is FtRagInput;
|
|
47
|
-
export interface FtMapAttachment {
|
|
48
|
-
file: string;
|
|
49
|
-
size?: number;
|
|
50
|
-
externalLink: boolean;
|
|
51
|
-
name: string;
|
|
52
|
-
id: string;
|
|
53
|
-
mimeType?: string;
|
|
54
|
-
viewerUrl?: string;
|
|
55
|
-
}
|
|
56
|
-
export declare const isFtMapAttachment: (o: any) => o is FtMapAttachment;
|
|
57
|
-
export interface FtPageConfiguration {
|
|
58
|
-
parentsVisibility?: Array<boolean>;
|
|
59
|
-
isVisible: boolean;
|
|
60
|
-
}
|
|
61
|
-
export declare const isFtPageConfiguration: (o: any) => o is FtPageConfiguration;
|
|
62
|
-
export interface FtPaginatedToc {
|
|
63
|
-
configuration: FtPaginationConfiguration;
|
|
64
|
-
paginatedToc: Array<FtPaginatedTocNode>;
|
|
65
|
-
}
|
|
66
|
-
export declare const isFtPaginatedToc: (o: any) => o is FtPaginatedToc;
|
|
67
|
-
export interface FtPaginatedTocNode {
|
|
68
|
-
prettyUrl?: string;
|
|
69
|
-
hasRating?: boolean;
|
|
70
|
-
pageToc?: Array<any>;
|
|
71
|
-
tocId?: string;
|
|
72
|
-
children: Array<FtPaginatedTocNode>;
|
|
73
|
-
pageConfiguration?: FtPageConfiguration;
|
|
74
|
-
origin?: any;
|
|
75
|
-
contentId?: string;
|
|
76
|
-
title?: string;
|
|
77
|
-
}
|
|
78
|
-
export declare const isFtPaginatedTocNode: (o: any) => o is FtPaginatedTocNode;
|
|
79
|
-
export interface FtPaginationConfiguration {
|
|
80
|
-
splitCurrentPageToc: boolean;
|
|
81
|
-
}
|
|
82
|
-
export declare const isFtPaginationConfiguration: (o: any) => o is FtPaginationConfiguration;
|
|
83
|
-
export interface FtClusteredSemanticSearchReply {
|
|
84
|
-
documents: Array<FtSemanticSearchResponseItem>;
|
|
85
|
-
clusterId: Array<string>;
|
|
86
|
-
}
|
|
87
|
-
export declare const isFtClusteredSemanticSearchReply: (o: any) => o is FtClusteredSemanticSearchReply;
|
|
88
|
-
export interface FtSemanticSearchResponseItem {
|
|
89
|
-
metadata: Record<string, Array<string>>;
|
|
90
|
-
excerpt: string;
|
|
91
|
-
relevance: number;
|
|
92
|
-
}
|
|
93
|
-
export declare const isFtSemanticSearchResponseItem: (o: any) => o is FtSemanticSearchResponseItem;
|
|
94
|
-
export interface FtSemanticSearchFilter {
|
|
95
|
-
values: Array<string>;
|
|
96
|
-
key: string;
|
|
97
|
-
}
|
|
98
|
-
export declare const isFtSemanticSearchFilter: (o: any) => o is FtSemanticSearchFilter;
|
|
99
|
-
export interface FtSemanticSearchRequest {
|
|
100
|
-
query: string;
|
|
101
|
-
filters?: Array<FtSemanticSearchFilter>;
|
|
102
|
-
nbResults?: number;
|
|
103
|
-
}
|
|
104
|
-
export declare const isFtSemanticSearchRequest: (o: any) => o is FtSemanticSearchRequest;
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
const isObject = (o) => typeof o === "object" && o != null;
|
|
2
|
-
const isBoolean = (o) => typeof o === "boolean";
|
|
3
|
-
const isNumber = (o) => typeof o === "number";
|
|
4
|
-
const isString = (o) => typeof o === "string";
|
|
5
|
-
// From: ConfigurationHistoryEntryStatus
|
|
6
|
-
export var FtConfigurationHistoryEntryStatus;
|
|
7
|
-
(function (FtConfigurationHistoryEntryStatus) {
|
|
8
|
-
FtConfigurationHistoryEntryStatus["VALID"] = "VALID";
|
|
9
|
-
FtConfigurationHistoryEntryStatus["INVALID"] = "INVALID";
|
|
10
|
-
})(FtConfigurationHistoryEntryStatus || (FtConfigurationHistoryEntryStatus = {}));
|
|
11
|
-
export const isFtConfigurationHistoryEntryStatus = (o) => {
|
|
12
|
-
return ["VALID", "INVALID"].includes(o);
|
|
13
|
-
};
|
|
14
|
-
export const isFtReaderConfiguration = (o) => {
|
|
15
|
-
return isObject(o)
|
|
16
|
-
&& (isFtReaderFeedbackConfiguration(o.feedback))
|
|
17
|
-
&& (isNumber(o.loadAfterLastVisibleTopic))
|
|
18
|
-
&& (isString(o.relativeTopicPivotMetadata))
|
|
19
|
-
&& (isNumber(o.loadBeforeFirstVisibleTopic))
|
|
20
|
-
&& (isString(o.relativePivotMetadata));
|
|
21
|
-
};
|
|
22
|
-
export const isFtReaderFeedbackConfiguration = (o) => {
|
|
23
|
-
return isObject(o)
|
|
24
|
-
&& (isBoolean(o.mailsSentByFluidTopics))
|
|
25
|
-
&& (isBoolean(o.mailsSentByFluidTopicsForUnauthenticatedUsers))
|
|
26
|
-
&& ((Array.isArray(o.recipients)
|
|
27
|
-
&& o.recipients.every((v) => isString(v))))
|
|
28
|
-
&& ((Array.isArray(o.bodyMetadataIds)
|
|
29
|
-
&& o.bodyMetadataIds.every((v) => isString(v))))
|
|
30
|
-
&& ((Array.isArray(o.subjectMetadataIds)
|
|
31
|
-
&& o.subjectMetadataIds.every((v) => isString(v))));
|
|
32
|
-
};
|
|
33
|
-
export const isFtGenAIRating = (o) => {
|
|
34
|
-
return isObject(o)
|
|
35
|
-
&& (isNumber(o.rating))
|
|
36
|
-
&& (isString(o.comment))
|
|
37
|
-
&& (isString(o.queryId));
|
|
38
|
-
};
|
|
39
|
-
export const isFtGenAIGenerateInput = (o) => {
|
|
40
|
-
return isObject(o)
|
|
41
|
-
&& (isString(o.profileId))
|
|
42
|
-
&& (o.parameters == null || (isObject(o.parameters)
|
|
43
|
-
&& Object.keys(o.parameters).every((k) => isString(k))
|
|
44
|
-
&& Object.values(o.parameters).every((v) => isString(v))));
|
|
45
|
-
};
|
|
46
|
-
export const isFtRagHistory = (o) => {
|
|
47
|
-
return isObject(o)
|
|
48
|
-
&& (isString(o.role))
|
|
49
|
-
&& (isString(o.content));
|
|
50
|
-
};
|
|
51
|
-
export const isFtRagInput = (o) => {
|
|
52
|
-
return isObject(o)
|
|
53
|
-
&& (isString(o.profileId))
|
|
54
|
-
&& (o.conversationId == null || isString(o.conversationId))
|
|
55
|
-
&& (isString(o.query))
|
|
56
|
-
&& (o.messages == null || (Array.isArray(o.messages)
|
|
57
|
-
&& o.messages.every((v) => isFtRagHistory(v))))
|
|
58
|
-
&& (o.filters == null || (Array.isArray(o.filters)
|
|
59
|
-
&& o.filters.every((v) => isFtSemanticSearchFilter(v))));
|
|
60
|
-
};
|
|
61
|
-
export const isFtMapAttachment = (o) => {
|
|
62
|
-
return isObject(o)
|
|
63
|
-
&& (isString(o.file))
|
|
64
|
-
&& (o.size == null || isNumber(o.size))
|
|
65
|
-
&& (isBoolean(o.externalLink))
|
|
66
|
-
&& (isString(o.name))
|
|
67
|
-
&& (isString(o.id))
|
|
68
|
-
&& (o.mimeType == null || isString(o.mimeType))
|
|
69
|
-
&& (o.viewerUrl == null || isString(o.viewerUrl));
|
|
70
|
-
};
|
|
71
|
-
export const isFtPageConfiguration = (o) => {
|
|
72
|
-
return isObject(o)
|
|
73
|
-
&& (o.parentsVisibility == null || (Array.isArray(o.parentsVisibility)
|
|
74
|
-
&& o.parentsVisibility.every((v) => isBoolean(v))))
|
|
75
|
-
&& (isBoolean(o.isVisible));
|
|
76
|
-
};
|
|
77
|
-
export const isFtPaginatedToc = (o) => {
|
|
78
|
-
return isObject(o)
|
|
79
|
-
&& (isFtPaginationConfiguration(o.configuration))
|
|
80
|
-
&& ((Array.isArray(o.paginatedToc)
|
|
81
|
-
&& o.paginatedToc.every((v) => isFtPaginatedTocNode(v))));
|
|
82
|
-
};
|
|
83
|
-
export const isFtPaginatedTocNode = (o) => {
|
|
84
|
-
return isObject(o)
|
|
85
|
-
&& (o.prettyUrl == null || isString(o.prettyUrl))
|
|
86
|
-
&& (o.hasRating == null || isBoolean(o.hasRating))
|
|
87
|
-
&& (o.pageToc == null || (Array.isArray(o.pageToc)))
|
|
88
|
-
&& (o.tocId == null || isString(o.tocId))
|
|
89
|
-
&& ((Array.isArray(o.children)
|
|
90
|
-
&& o.children.every((v) => isFtPaginatedTocNode(v))))
|
|
91
|
-
&& (o.pageConfiguration == null || isFtPageConfiguration(o.pageConfiguration))
|
|
92
|
-
&& (o.contentId == null || isString(o.contentId))
|
|
93
|
-
&& (o.title == null || isString(o.title));
|
|
94
|
-
};
|
|
95
|
-
export const isFtPaginationConfiguration = (o) => {
|
|
96
|
-
return isObject(o)
|
|
97
|
-
&& (isBoolean(o.splitCurrentPageToc));
|
|
98
|
-
};
|
|
99
|
-
export const isFtClusteredSemanticSearchReply = (o) => {
|
|
100
|
-
return isObject(o)
|
|
101
|
-
&& ((Array.isArray(o.documents)
|
|
102
|
-
&& o.documents.every((v) => isFtSemanticSearchResponseItem(v))))
|
|
103
|
-
&& ((Array.isArray(o.clusterId)
|
|
104
|
-
&& o.clusterId.every((v) => isString(v))));
|
|
105
|
-
};
|
|
106
|
-
export const isFtSemanticSearchResponseItem = (o) => {
|
|
107
|
-
return isObject(o)
|
|
108
|
-
&& ((isObject(o.metadata)
|
|
109
|
-
&& Object.keys(o.metadata).every((k) => isString(k))
|
|
110
|
-
&& Object.values(o.metadata).every((v) => (Array.isArray(v)
|
|
111
|
-
&& v.every((v) => isString(v))))))
|
|
112
|
-
&& (isString(o.excerpt))
|
|
113
|
-
&& (isNumber(o.relevance));
|
|
114
|
-
};
|
|
115
|
-
export const isFtSemanticSearchFilter = (o) => {
|
|
116
|
-
return isObject(o)
|
|
117
|
-
&& ((Array.isArray(o.values)
|
|
118
|
-
&& o.values.every((v) => isString(v))))
|
|
119
|
-
&& (isString(o.key));
|
|
120
|
-
};
|
|
121
|
-
export const isFtSemanticSearchRequest = (o) => {
|
|
122
|
-
return isObject(o)
|
|
123
|
-
&& (isString(o.query))
|
|
124
|
-
&& (o.filters == null || (Array.isArray(o.filters)
|
|
125
|
-
&& o.filters.every((v) => isFtSemanticSearchFilter(v))))
|
|
126
|
-
&& (o.nbResults == null || isNumber(o.nbResults));
|
|
127
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
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="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};!function(e){!function(t){var r={searchParams:"URLSearchParams"in e,iterable:"Symbol"in e&&"iterator"in Symbol,blob:"FileReader"in e&&"Blob"in e&&function(){try{return new Blob,!0}catch(e){return!1}}(),formData:"FormData"in e,arrayBuffer:"ArrayBuffer"in e};if(r.arrayBuffer)var i=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],a=ArrayBuffer.isView||function(e){return e&&i.indexOf(Object.prototype.toString.call(e))>-1};function s(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(e))throw new TypeError("Invalid character in header field name");return e.toLowerCase()}function n(e){return"string"!=typeof e&&(e=String(e)),e}function o(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return r.iterable&&(t[Symbol.iterator]=function(){return t}),t}function l(e){this.map={},e instanceof l?e.forEach((function(e,t){this.append(t,e)}),this):Array.isArray(e)?e.forEach((function(e){this.append(e[0],e[1])}),this):e&&Object.getOwnPropertyNames(e).forEach((function(t){this.append(t,e[t])}),this)}function u(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function c(e){return new Promise((function(t,r){e.onload=function(){t(e.result)},e.onerror=function(){r(e.error)}}))}function d(e){var t=new FileReader,r=c(t);return t.readAsArrayBuffer(e),r}function p(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function h(){return this.bodyUsed=!1,this._initBody=function(e){var t;this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:r.blob&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:r.formData&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:r.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():r.arrayBuffer&&r.blob&&(t=e)&&DataView.prototype.isPrototypeOf(t)?(this._bodyArrayBuffer=p(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):r.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(e)||a(e))?this._bodyArrayBuffer=p(e):this._bodyText=e=Object.prototype.toString.call(e):this._bodyText="",this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):r.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},r.blob&&(this.blob=function(){var e=u(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?u(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(d)}),this.text=function(){var e,t,r,i=u(this);if(i)return i;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,r=c(t),t.readAsText(e),r;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),r=new Array(t.length),i=0;i<t.length;i++)r[i]=String.fromCharCode(t[i]);return r.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},r.formData&&(this.formData=function(){return this.text().then(m)}),this.json=function(){return this.text().then(JSON.parse)},this}l.prototype.append=function(e,t){e=s(e),t=n(t);var r=this.map[e];this.map[e]=r?r+", "+t:t},l.prototype.delete=function(e){delete this.map[s(e)]},l.prototype.get=function(e){return e=s(e),this.has(e)?this.map[e]:null},l.prototype.has=function(e){return this.map.hasOwnProperty(s(e))},l.prototype.set=function(e,t){this.map[s(e)]=n(t)},l.prototype.forEach=function(e,t){for(var r in this.map)this.map.hasOwnProperty(r)&&e.call(t,this.map[r],r,this)},l.prototype.keys=function(){var e=[];return this.forEach((function(t,r){e.push(r)})),o(e)},l.prototype.values=function(){var e=[];return this.forEach((function(t){e.push(t)})),o(e)},l.prototype.entries=function(){var e=[];return this.forEach((function(t,r){e.push([r,t])})),o(e)},r.iterable&&(l.prototype[Symbol.iterator]=l.prototype.entries);var y=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function A(e,t){var r,i,a=(t=t||{}).body;if(e instanceof A){if(e.bodyUsed)throw new TypeError("Already read");this.url=e.url,this.credentials=e.credentials,t.headers||(this.headers=new l(e.headers)),this.method=e.method,this.mode=e.mode,this.signal=e.signal,a||null==e._bodyInit||(a=e._bodyInit,e.bodyUsed=!0)}else this.url=String(e);if(this.credentials=t.credentials||this.credentials||"same-origin",!t.headers&&this.headers||(this.headers=new l(t.headers)),this.method=(r=t.method||this.method||"GET",i=r.toUpperCase(),y.indexOf(i)>-1?i:r),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&a)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(a)}function m(e){var t=new FormData;return e.trim().split("&").forEach((function(e){if(e){var r=e.split("="),i=r.shift().replace(/\+/g," "),a=r.join("=").replace(/\+/g," ");t.append(decodeURIComponent(i),decodeURIComponent(a))}})),t}function E(e,t){t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in t?t.statusText:"OK",this.headers=new l(t.headers),this.url=t.url||"",this._initBody(e)}A.prototype.clone=function(){return new A(this,{body:this._bodyInit})},h.call(A.prototype),h.call(E.prototype),E.prototype.clone=function(){return new E(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new l(this.headers),url:this.url})},E.error=function(){var e=new E(null,{status:0,statusText:""});return e.type="error",e};var f=[301,302,303,307,308];E.redirect=function(e,t){if(-1===f.indexOf(t))throw new RangeError("Invalid status code");return new E(null,{status:t,headers:{location:e}})},t.DOMException=e.DOMException;try{new t.DOMException}catch(e){t.DOMException=function(e,t){this.message=e,this.name=t;var r=Error(e);this.stack=r.stack},t.DOMException.prototype=Object.create(Error.prototype),t.DOMException.prototype.constructor=t.DOMException}function T(e,i){return new Promise((function(a,s){var n=new A(e,i);if(n.signal&&n.signal.aborted)return s(new t.DOMException("Aborted","AbortError"));var o=new XMLHttpRequest;function u(){o.abort()}o.onload=function(){var e,t,r={status:o.status,statusText:o.statusText,headers:(e=o.getAllResponseHeaders()||"",t=new l,e.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(e){var r=e.split(":"),i=r.shift().trim();if(i){var a=r.join(":").trim();t.append(i,a)}})),t)};r.url="responseURL"in o?o.responseURL:r.headers.get("X-Request-URL");var i="response"in o?o.response:o.responseText;a(new E(i,r))},o.onerror=function(){s(new TypeError("Network request failed"))},o.ontimeout=function(){s(new TypeError("Network request failed"))},o.onabort=function(){s(new t.DOMException("Aborted","AbortError"))},o.open(n.method,n.url,!0),"include"===n.credentials?o.withCredentials=!0:"omit"===n.credentials&&(o.withCredentials=!1),"responseType"in o&&r.blob&&(o.responseType="blob"),n.headers.forEach((function(e,t){o.setRequestHeader(t,e)})),n.signal&&(n.signal.addEventListener("abort",u),o.onreadystatechange=function(){4===o.readyState&&n.signal.removeEventListener("abort",u)}),o.send(void 0===n._bodyInit?null:n._bodyInit)}))}T.polyfill=!0,e.fetch||(e.fetch=T,e.Headers=l,e.Request=A,e.Response=E),t.Headers=l,t.Request=A,t.Response=E,t.fetch=T,Object.defineProperty(t,"__esModule",{value:!0})}({})}("undefined"!=typeof self?self:t);class r{reader;decoder=new TextDecoder;partialChunk="";constructor(e){this.reader=e}async*read(){for(;;){const{done:e,value:t}=await this.reader.read();if(e)return void(yield*this.readRemainingChunks());yield*this.readChunksFromValue(t)}}*readRemainingChunks(){yield*this.parseLine(this.partialChunk)}*readChunksFromValue(e){const t=(this.partialChunk+this.decoder.decode(e)).split("\n");this.partialChunk=t.pop();for(let e of t)yield*this.parseLine(e)}*parseLine(e){const[t,r]=e.split(/:(.*)/);"data"==t&&r.length>0&&(yield JSON.parse(r))}}const i=e=>"object"==typeof e&&null!=e,a=e=>"boolean"==typeof e,s=e=>"number"==typeof e,n=e=>"string"==typeof e;var o;e.FtMyLibraryColors=void 0,(o=e.FtMyLibraryColors||(e.FtMyLibraryColors={})).black="black",o.green="green",o.blue="blue",o.purple="purple",o.red="red",o.orange="orange",o.yellow="yellow";const l=e=>["black","green","blue","purple","red","orange","yellow"].includes(e);var u;e.FtTopicOriginType=void 0,(u=e.FtTopicOriginType||(e.FtTopicOriginType={})).OFFICIAL="OFFICIAL",u.PERSONAL="PERSONAL",u.SHARED="SHARED";const c=e=>["OFFICIAL","PERSONAL","SHARED"].includes(e),d=e=>i(e)&&Array.isArray(e.values)&&e.values.every((e=>Array.isArray(e)&&e.every((e=>n(e)))))&&n(e.key),p=e=>i(e)&&n(e.notes)&&Array.isArray(e.children)&&e.children.every((e=>p(e)))&&(null==e.topicLink||h(e.topicLink))&&n(e.title)&&(null==e.htmlContent||n(e.htmlContent)),h=e=>i(e)&&n(e.tocId)&&n(e.contentId)&&n(e.mapId),y=e=>i(e)&&n(e.topicStylesheetUrl)&&n(e.titleStylesheetUrl)&&Array.isArray(e.customCssClasses)&&e.customCssClasses.every((e=>n(e))),A=e=>i(e)&&(null==e.prettyUrl||n(e.prettyUrl))&&(null==e.hasRating||a(e.hasRating))&&n(e.tocId)&&Array.isArray(e.children)&&e.children.every((e=>A(e)))&&(null==e.origin||m(e.origin))&&n(e.contentId)&&n(e.title),m=e=>i(e)&&n(e.mapTitle)&&Array.isArray(e.breadcrumb)&&e.breadcrumb.every((e=>n(e)))&&n(e.tocId)&&n(e.contentId)&&n(e.mapId)&&c(e.type);var E;e.FtTopicContentTarget=void 0,(E=e.FtTopicContentTarget||(e.FtTopicContentTarget={})).THIRD_PARTY="THIRD_PARTY",E.OFF_THE_GRID="OFF_THE_GRID",E.CONTENT_PACKAGER="CONTENT_PACKAGER",E.PAGES="PAGES",E.DESIGNED_READER="DESIGNED_READER";var f;e.FtExternalWebComponentContext=void 0,(f=e.FtExternalWebComponentContext||(e.FtExternalWebComponentContext={})).HOMEPAGE="HOMEPAGE",f.CUSTOM="CUSTOM",f.HEADER="HEADER",f.READER="READER",f.TOPIC_TEMPLATE="TOPIC_TEMPLATE",f.SEARCH="SEARCH",f.SEARCH_RESULT="SEARCH_RESULT";var T;e.FtMetadataHomeLayout=void 0,(T=e.FtMetadataHomeLayout||(e.FtMetadataHomeLayout={})).CLASSIC="CLASSIC",T.CUSTOM="CUSTOM",T.DESIGNER="DESIGNER";const g=e=>i(e)&&s(e.count)&&n(e.label)&&(null==e.lang||n(e.lang));var S;e.FtFacetType=void 0,(S=e.FtFacetType||(e.FtFacetType={})).AND="AND",S.OR="OR",S.MONOVALUED="MONOVALUED";const R=e=>i(e)&&Array.isArray(e.values)&&e.values.every((e=>n(e)))&&(null==e.hierarchicalValues||Array.isArray(e.hierarchicalValues)&&e.hierarchicalValues.every((e=>Array.isArray(e)&&e.every((e=>n(e))))))&&n(e.label)&&n(e.key);var F;e.FtMetadataSortRule=void 0,(F=e.FtMetadataSortRule||(e.FtMetadataSortRule={})).NONE="NONE",F.ALPHABET="ALPHABET",F.VERSION="VERSION";const b=e=>["NONE","ALPHABET","VERSION"].includes(e),O=e=>i(e)&&a(e.date)&&b(e.sortRule)&&n(e.label)&&a(e.reverseSort)&&n(e.key),v=e=>i(e)&&(null==e.periodFilter||null==e.periodFilter||ie(e.periodFilter))&&n(e.query)&&(null==e.scope||me(e.scope))&&(null==e.filters||Array.isArray(e.filters)&&e.filters.every((e=>te(e))))&&Array.isArray(e.sort)&&e.sort.every((e=>Se(e)))&&(null==e.virtualField||V(e.virtualField))&&(null==e.metadataFilters||Array.isArray(e.metadataFilters)&&e.metadataFilters.every((e=>ee(e))))&&(null==e.contentLocale||n(e.contentLocale));var U;e.FtRatingType=void 0,(U=e.FtRatingType||(e.FtRatingType={})).STARS="STARS",U.LIKE="LIKE",U.DICHOTOMOUS="DICHOTOMOUS",U.NO_RATING="NO_RATING";const I=e=>["STARS","LIKE","DICHOTOMOUS","NO_RATING"].includes(e),C=e=>i(e)&&n(e.date)&&I(e.type)&&s(e.value),_=e=>i(e)&&(null==e.rating||C(e.rating))&&I(e.type),L=e=>i(e)&&n(e.date)&&n(e.tocId)&&I(e.type)&&s(e.value),D=e=>i(e)&&Array.isArray(e.ratings)&&e.ratings.every((e=>L(e)))&&I(e.type),P=e=>i(e)&&Array.isArray(e.filter)&&e.filter.every((e=>n(e)))&&Array.isArray(e.prior)&&e.prior.every((e=>n(e)));var N;e.FtPeriodFilterType=void 0,(N=e.FtPeriodFilterType||(e.FtPeriodFilterType={})).LAST_WEEK="LAST_WEEK",N.LAST_MONTH="LAST_MONTH",N.LAST_QUARTER="LAST_QUARTER",N.LAST_YEAR="LAST_YEAR",N.CUSTOM="CUSTOM";const k=e=>["LAST_WEEK","LAST_MONTH","LAST_QUARTER","LAST_YEAR","CUSTOM"].includes(e);var M;e.FtSearchSortCriterionOrder=void 0,(M=e.FtSearchSortCriterionOrder||(e.FtSearchSortCriterionOrder={})).ASC="ASC",M.DESC="DESC";const w=e=>["ASC","DESC"].includes(e);var B;e.FtSearchSortCriterionType=void 0,(B=e.FtSearchSortCriterionType||(e.FtSearchSortCriterionType={})).ALPHA="ALPHA",B.NATURAL="NATURAL";const H=e=>["ALPHA","NATURAL"].includes(e);var x;e.FtVirtualField=void 0,(x=e.FtVirtualField||(e.FtVirtualField={})).EVERYWHERE="EVERYWHERE",x.TITLE_ONLY="TITLE_ONLY",x.NONE="NONE";const V=e=>["EVERYWHERE","TITLE_ONLY","NONE"].includes(e),K=e=>i(e)&&s(e.totalResultsCount)&&a(e.isLastPage)&&s(e.currentPage)&&s(e.totalClustersCount);var $;e.FtEditorialType=void 0,($=e.FtEditorialType||(e.FtEditorialType={})).ARTICLE="ARTICLE",$.BOOK="BOOK",$.SHARED_BOOK="SHARED_BOOK";const G=e=>["ARTICLE","BOOK","SHARED_BOOK"].includes(e);var j;e.FtOpenMode=void 0,(j=e.FtOpenMode||(e.FtOpenMode={})).FLUIDTOPICS="FLUIDTOPICS",j.EXTERNAL="EXTERNAL";const q=e=>["FLUIDTOPICS","EXTERNAL"].includes(e),Y=e=>i(e)&&(null==e.perPage||s(e.perPage))&&s(e.page),W=e=>i(e)&&n(e.key);var X;e.FtCollectionDocumentType=void 0,(X=e.FtCollectionDocumentType||(e.FtCollectionDocumentType={})).MAP="MAP",X.DOCUMENT="DOCUMENT",X.TOPIC="TOPIC",X.PERSONAL_BOOK="PERSONAL_BOOK",X.SHARED_BOOK="SHARED_BOOK";const z=e=>["MAP","DOCUMENT","TOPIC","PERSONAL_BOOK","SHARED_BOOK"].includes(e),J=e=>i(e)&&Z(e.type);var Q;e.FtDateFilterType=void 0,(Q=e.FtDateFilterType||(e.FtDateFilterType={})).LAST_WEEK="LAST_WEEK",Q.LAST_MONTH="LAST_MONTH",Q.LAST_QUARTER="LAST_QUARTER",Q.LAST_YEAR="LAST_YEAR";const Z=e=>["LAST_WEEK","LAST_MONTH","LAST_QUARTER","LAST_YEAR"].includes(e),ee=e=>i(e)&&(null==e.valueFilter||Ee(e.valueFilter))&&(null==e.rangeFilter||ne(e.rangeFilter))&&n(e.label)&&n(e.key)&&(null==e.dateFilter||J(e.dateFilter)),te=e=>i(e)&&a(e.negative)&&Array.isArray(e.values)&&e.values.every((e=>n(e)))&&n(e.label)&&n(e.key),re=e=>i(e)&&a(e.negative)&&Array.isArray(e.values)&&e.values.every((e=>n(e)))&&n(e.key),ie=e=>i(e)&&(null==e.period||se(e.period))&&k(e.periodType)&&(null==e.key||n(e.key)),ae=e=>i(e)&&(null==e.valueFilter||Ee(e.valueFilter))&&(null==e.rangeFilter||ne(e.rangeFilter))&&n(e.key)&&(null==e.dateFilter||J(e.dateFilter)),se=e=>i(e)&&n(e.from)&&n(e.to),ne=e=>i(e)&&n(e.from)&&n(e.to),oe=e=>i(e)&&s(e.weight)&&n(e.value)&&n(e.key),le=e=>i(e)&&Array.isArray(e.entries)&&e.entries.every((e=>ue(e)))&&(null==e.metadataVariableAxis||n(e.metadataVariableAxis)),ue=e=>i(e)&&Array.isArray(e.missingTerms)&&e.missingTerms.every((e=>n(e)))&&(null==e.document||ce(e.document))&&(null==e.topic||pe(e.topic))&&ye(e.type)&&(null==e.map||de(e.map)),ce=e=>i(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>R(e)))&&q(e.openMode)&&n(e.documentUrl)&&n(e.mimeType)&&n(e.title)&&(null==e.lastPublicationDate||n(e.lastPublicationDate))&&n(e.viewerUrl)&&n(e.contentUrl)&&n(e.filename)&&n(e.htmlTitle)&&(null==e.originUrl||n(e.originUrl))&&n(e.documentId)&&n(e.lastEditionDate)&&n(e.htmlExcerpt),de=e=>i(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>R(e)))&&(null==e.openMode||q(e.openMode))&&G(e.editorialType)&&n(e.title)&&(null==e.lastPublicationDate||n(e.lastPublicationDate))&&n(e.htmlTitle)&&(null==e.originUrl||n(e.originUrl))&&n(e.mapUrl)&&n(e.readerUrl)&&n(e.mapId)&&(null==e.lastEditionDate||n(e.lastEditionDate))&&n(e.htmlExcerpt),pe=e=>i(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>R(e)))&&q(e.openMode)&&n(e.contentId)&&Array.isArray(e.resources)&&e.resources.every((e=>Fe(e)))&&n(e.title)&&n(e.mapTitle)&&n(e.topicUrl)&&n(e.contentUrl)&&n(e.htmlTitle)&&Array.isArray(e.breadcrumb)&&e.breadcrumb.every((e=>n(e)))&&n(e.tocId)&&(null==e.originUrl||n(e.originUrl))&&n(e.readerUrl)&&n(e.mapId)&&(null==e.lastEditionDate||n(e.lastEditionDate))&&n(e.htmlExcerpt);var he;e.FtSearchResultType=void 0,(he=e.FtSearchResultType||(e.FtSearchResultType={})).MAP="MAP",he.DOCUMENT="DOCUMENT",he.TOPIC="TOPIC";const ye=e=>["MAP","DOCUMENT","TOPIC"].includes(e);var Ae;e.FtSearchScope=void 0,(Ae=e.FtSearchScope||(e.FtSearchScope={})).DEFAULT="DEFAULT",Ae.DOCUMENTS="DOCUMENTS",Ae.ALL_TOPICS="ALL_TOPICS";const me=e=>["DEFAULT","DOCUMENTS","ALL_TOPICS"].includes(e),Ee=e=>i(e)&&a(e.negative)&&Array.isArray(e.values)&&e.values.every((e=>n(e))),fe=e=>i(e)&&a(e.hierarchical)&&n(e.label)&&a(e.multiSelectionable)&&n(e.key)&&Array.isArray(e.rootNodes)&&e.rootNodes.every((e=>ge(e))),Te=e=>i(e)&&(null==e.maxDepth||s(e.maxDepth))&&n(e.id),ge=e=>i(e)&&s(e.totalResultsCount)&&a(e.descendantSelected)&&Array.isArray(e.childNodes)&&e.childNodes.every((e=>ge(e)))&&n(e.label)&&n(e.value)&&a(e.selected),Se=e=>i(e)&&H(e.type)&&n(e.key)&&w(e.order),Re=e=>i(e)&&n(e.suggestedQuery)&&n(e.htmlSuggestedQuery),Fe=e=>i(e)&&n(e.filename)&&n(e.resourceUrl)&&n(e.id)&&n(e.mimeType)&&n(e.resourceContentUrl)&&n(e.viewerUrl),be=e=>i(e)&&(null==e.filenameExtension||n(e.filenameExtension))&&(null==e.editorialType||G(e.editorialType))&&(null==e.mimeType||n(e.mimeType))&&ye(e.type)&&n(e.value);var Oe;e.FtUserRole=void 0,(Oe=e.FtUserRole||(e.FtUserRole={})).PERSONAL_BOOK_USER="PERSONAL_BOOK_USER",Oe.PERSONAL_BOOK_SHARE_USER="PERSONAL_BOOK_SHARE_USER",Oe.HTML_EXPORT_USER="HTML_EXPORT_USER",Oe.PDF_EXPORT_USER="PDF_EXPORT_USER",Oe.SAVED_SEARCH_USER="SAVED_SEARCH_USER",Oe.COLLECTION_USER="COLLECTION_USER",Oe.OFFLINE_USER="OFFLINE_USER",Oe.ANALYTICS_USER="ANALYTICS_USER",Oe.BETA_USER="BETA_USER",Oe.DEBUG_USER="DEBUG_USER",Oe.PRINT_USER="PRINT_USER",Oe.RATING_USER="RATING_USER",Oe.FEEDBACK_USER="FEEDBACK_USER",Oe.GENERATIVE_AI_USER="GENERATIVE_AI_USER",Oe.CONTENT_PUBLISHER="CONTENT_PUBLISHER",Oe.KHUB_ADMIN="KHUB_ADMIN",Oe.USERS_ADMIN="USERS_ADMIN",Oe.PORTAL_ADMIN="PORTAL_ADMIN",Oe.ADMIN="ADMIN",Oe.DEVELOPER="DEVELOPER";const ve=e=>["PERSONAL_BOOK_USER","PERSONAL_BOOK_SHARE_USER","HTML_EXPORT_USER","PDF_EXPORT_USER","SAVED_SEARCH_USER","COLLECTION_USER","OFFLINE_USER","ANALYTICS_USER","BETA_USER","DEBUG_USER","PRINT_USER","RATING_USER","FEEDBACK_USER","GENERATIVE_AI_USER","CONTENT_PUBLISHER","KHUB_ADMIN","USERS_ADMIN","PORTAL_ADMIN","ADMIN","DEVELOPER"].includes(e),Ue=e=>i(e)&&n(e.identifier)&&n(e.realm),Ie=e=>i(e)&&(null==e.defaultFilters||Array.isArray(e.defaultFilters)&&e.defaultFilters.every((e=>re(e))))&&Array.isArray(e.defaultMetadataFilters)&&e.defaultMetadataFilters.every((e=>ae(e))),Ce=e=>i(e)&&(null==e.emailAddress||n(e.emailAddress))&&(null==e.displayName||n(e.displayName))&&Array.isArray(e.roles)&&e.roles.every((e=>ve(e)))&&(null==e.userId||n(e.userId))&&Array.isArray(e.tags)&&e.tags.every((e=>n(e))),_e=e=>i(e)&&n(e.color)&&Array.isArray(e.text)&&e.text.every((e=>n(e)))&&s(e.opacity),Le=e=>"object"==typeof e&&null!=e,De=e=>"boolean"==typeof e,Pe=e=>"number"==typeof e,Ne=e=>"string"==typeof e;var ke;e.FtConfigurationHistoryEntryStatus=void 0,(ke=e.FtConfigurationHistoryEntryStatus||(e.FtConfigurationHistoryEntryStatus={})).VALID="VALID",ke.INVALID="INVALID";const Me=e=>Le(e)&&De(e.mailsSentByFluidTopics)&&De(e.mailsSentByFluidTopicsForUnauthenticatedUsers)&&Array.isArray(e.recipients)&&e.recipients.every((e=>Ne(e)))&&Array.isArray(e.bodyMetadataIds)&&e.bodyMetadataIds.every((e=>Ne(e)))&&Array.isArray(e.subjectMetadataIds)&&e.subjectMetadataIds.every((e=>Ne(e))),we=e=>Le(e)&&Ne(e.role)&&Ne(e.content),Be=e=>Le(e)&&(null==e.parentsVisibility||Array.isArray(e.parentsVisibility)&&e.parentsVisibility.every((e=>De(e))))&&De(e.isVisible),He=e=>Le(e)&&(null==e.prettyUrl||Ne(e.prettyUrl))&&(null==e.hasRating||De(e.hasRating))&&(null==e.pageToc||Array.isArray(e.pageToc))&&(null==e.tocId||Ne(e.tocId))&&Array.isArray(e.children)&&e.children.every((e=>He(e)))&&(null==e.pageConfiguration||Be(e.pageConfiguration))&&(null==e.contentId||Ne(e.contentId))&&(null==e.title||Ne(e.title)),xe=e=>Le(e)&&De(e.splitCurrentPageToc),Ve=e=>Le(e)&&Le(e.metadata)&&Object.keys(e.metadata).every((e=>Ne(e)))&&Object.values(e.metadata).every((e=>Array.isArray(e)&&e.every((e=>Ne(e)))))&&Ne(e.excerpt)&&Pe(e.relevance),Ke=e=>Le(e)&&Array.isArray(e.values)&&e.values.every((e=>Ne(e)))&&Ne(e.key),$e={[e.FtUserRole.PERSONAL_BOOK_SHARE_USER]:[e.FtUserRole.PERSONAL_BOOK_USER],[e.FtUserRole.HTML_EXPORT_USER]:[e.FtUserRole.PERSONAL_BOOK_USER],[e.FtUserRole.PDF_EXPORT_USER]:[e.FtUserRole.PERSONAL_BOOK_USER],[e.FtUserRole.KHUB_ADMIN]:[e.FtUserRole.CONTENT_PUBLISHER],[e.FtUserRole.ADMIN]:[e.FtUserRole.KHUB_ADMIN,e.FtUserRole.USERS_ADMIN,e.FtUserRole.PORTAL_ADMIN],[e.FtUserRole.DEVELOPER]:[e.FtUserRole.BETA_USER,e.FtUserRole.DEBUG_USER]};function Ge(e,t){return e===t||($e[e]??[]).some((e=>Ge(e,t)))}const je="undefined"==typeof window?globalThis:window;function qe(e){let t={};for(let r in e){let i=e[r];("object"!=typeof i||Array.isArray(i))&&(i={prior:i});for(let e of["prior","filter"])i[e]=Array.isArray(i[e])?i[e]:[i[e]],i[e]=i[e].map((e=>null!=e?""+e:"")).filter((e=>""!==e));t[r]=i}return t}function Ye(e){return`${e}-FluidTopicsUnauthenticatedUserSearchPreferences`}const We="undefined"==typeof window?globalThis:window;class Xe extends Error{method;endpoint;status;statusText;body;constructor(e,t,r,i,a){super(`${e} ${t} -> ${r} - ${i}: ${a}`),this.method=e,this.endpoint=t,this.status=r,this.statusText=i,this.body=a}}class ze extends CustomEvent{constructor(e){super("ft-api-http-error",{detail:e})}}async function Je(e,t,r){if(!r.ok){let i={method:e,endpoint:t,status:r.status,statusText:r.statusText,body:await r.text()};throw"function"==typeof We.dispatchEvent&&We.dispatchEvent(new ze(i)),new Xe(i.method,i.endpoint,i.status,i.statusText,i.body)}return r}function Qe(e){return"application/json"===e.headers.get("Content-Type")?e.json():e.text()}class Ze{tenantBaseUrl;tenantBaseUrlNoTrailingSlash;ftCallingApp;authorization;searchLabel;endpoints={authentication:{login:"api/authentication/login",logout:"api/authentication/logout",currentSession:"api/authentication/current-session"},khub:{maps:{mapId:e=>({info:`api/khub/maps/${e}`,toc:`api/khub/maps/${e}/toc`,pages:`api/khub/maps/${e}/pages`,feedback:`api/khub/maps/${e}/feedback`,rating:`api/khub/maps/${e}/rating`,attachments:{list:`api/khub/maps/${e}/attachments`,attachmentId:t=>({content:`api/khub/maps/${e}/attachments/${t}/content`})},resources:{list:`api/khub/maps/${e}/resources`,resourceId:t=>({content:`api/khub/maps/${e}/resources/${t}/content`})},topics:{contentId:t=>({info:`api/khub/maps/${e}/topics/${t}`,content:`api/khub/maps/${e}/topics/${t}/content`}),tocId:t=>({feedback:`api/khub/maps/${e}/topics/${t}/feedback`,rating:`api/khub/maps/${e}/topics/${t}/rating`})}})},documents:{documentId:e=>({info:`api/khub/documents/${e}`,content:`api/khub/documents/${e}/content`,text:`api/khub/documents/${e}/content/text`,feedback:`api/khub/documents/${e}/feedback`,rating:`api/khub/documents/${e}/rating`})},semantic:{search:"api/khub/semantic/search",clusteredSearch:"api/khub/semantic/clustered-search"},suggest:"api/khub/suggest",clusteredSearch:"api/khub/clustered-search",locales:"api/khub/locales"},users:{userId:e=>({collections:{collectionId:t=>({documents:`api/users/${e}/collections/${t}/documents`})},searches:{list:`api/users/${e}/searches`},bookmarks:{list:`api/users/${e}/bookmarks`}})},stylesheets:{fonts:"stylesheets/fonts.css",theme:"stylesheets/theme.css",content:{title:"stylesheets/content/title.css",topic:"stylesheets/content/topic.css"}},configuration:{reader:"api/configuration/reader",metadata:"api/configuration/metadata"},locales:{ui:"api/locales/ui"},messages:{locale:e=>({fluidTopics:{contextName:t=>({endpoint:`api/messages/${e}/fluid-topics/${t}`})},custom:{contextName:t=>({endpoint:`api/messages/${e}/custom/${t}`})}})},ai:{generate:"api/ai/generate",sendFeedback:"api/ai/rate",chat:"/api/ai/rag/chat"}};get defaultHeaders(){return{...this.authorization,...this.searchLabel,"Ft-Calling-App":this.ftCallingApp}}constructor(e,t,r){e=(e??We.fluidTopicsBaseUrl??We.__gwt_ft_moduleBase??"").trim(),this.tenantBaseUrl=e.endsWith("/")?e:e+"/",this.tenantBaseUrlNoTrailingSlash=this.tenantBaseUrl.replace(/\/$/,""),r&&void 0!==We.location&&We.location.href.startsWith(this.tenantBaseUrl)?this.ftCallingApp=t:this.ftCallingApp=`ft-public-api/${t}`}setApiKey(e){this.authorization={Authorization:"Bearer "+e}}setCredentials(e,t){var r;this.authorization={Authorization:"Basic "+(r=`${e}:${t}`,"undefined"!=typeof Buffer?Buffer.from(r).toString("base64"):btoa(r))}}clearAuthentication(){this.authorization=void 0}setSearchLabel(e){this.searchLabel={"FT-search-label":e}}clearSearchLabel(){this.searchLabel=void 0}login(e,t){let r={login:e,password:t,rememberMe:!0};return this.post(this.endpoints.authentication.login,r).then((r=>(this.setCredentials(e,t),r)))}logout(){return this.post(this.endpoints.authentication.logout).then((()=>this.clearAuthentication()))}getCurrentSession(){return this.get(this.endpoints.authentication.currentSession)}getReaderConfiguration(){return this.get(this.endpoints.configuration.reader)}getMap(e,t){return this.get(this.endpoints.khub.maps.mapId(e).info,t)}getTableOfContent(e,t){return this.get(this.endpoints.khub.maps.mapId(e).toc,t)}getPages(e,t){return this.get(this.endpoints.khub.maps.mapId(e).pages,t)}getTopic(e,t,r){return this.get(this.endpoints.khub.maps.mapId(e).topics.contentId(t).info,r)}getTopicHTMLContent(e,t,r,i){return this.get(this.endpoints.khub.maps.mapId(e).topics.contentId(t).content+(r?"?target="+r:""),i)}getMapAttachments(e,t){return this.get(this.endpoints.khub.maps.mapId(e).attachments.list,t)}getMapAttachmentContent(e,t,r){return this.fetchRawData(this.endpoints.khub.maps.mapId(e).attachments.attachmentId(t).content,r)}getMapResources(e,t){return this.get(this.endpoints.khub.maps.mapId(e).resources.list,t)}getMapResourceContent(e,t,r){return this.fetchRawData(this.endpoints.khub.maps.mapId(e).resources.resourceId(t).content,r)}getUnstructuredDocument(e,t){return this.get(this.endpoints.khub.documents.documentId(e).info,t)}getUnstructuredDocumentContent(e,t){return this.fetchRawData(this.endpoints.khub.documents.documentId(e).content,t)}getUnstructuredDocumentTextContent(e,t){return this.get(this.endpoints.khub.documents.documentId(e).text,t)}getCollectionDocuments(e,t){return this.get(this.endpoints.users.userId(e).collections.collectionId(t).documents)}getSuggestions(e){return this.post(this.endpoints.khub.suggest,e)}search(e){return this.post(this.endpoints.khub.clusteredSearch,e)}getAvailableSearchLocales(){return this.get(this.endpoints.khub.locales)}getAvailableUiLocales(){return this.get(this.endpoints.locales.ui)}getMetadataConfiguration(){return this.get(this.endpoints.configuration.metadata)}getMapRating(e){return this.get(this.endpoints.khub.maps.mapId(e).rating)}rateMap(e,t,r){return this.post(this.endpoints.khub.maps.mapId(e).rating,{type:t,value:r})}unrateMap(e){return this.delete(this.endpoints.khub.maps.mapId(e).rating)}sendMapFeedback(e,t,r){return this.post(this.endpoints.khub.maps.mapId(e).feedback,{message:t,from:r})}rateTopic(e,t,r,i){return this.post(this.endpoints.khub.maps.mapId(e).topics.tocId(t).rating,{type:r,value:i})}unrateTopic(e,t){return this.delete(this.endpoints.khub.maps.mapId(e).topics.tocId(t).rating)}sendTopicFeedback(e,t,r,i){return this.post(this.endpoints.khub.maps.mapId(e).topics.tocId(t).feedback,{message:r,from:i})}getDocumentRating(e){return this.get(this.endpoints.khub.documents.documentId(e).rating)}rateDocument(e,t,r){return this.post(this.endpoints.khub.documents.documentId(e).rating,{type:t,value:r})}unrateDocument(e){return this.delete(this.endpoints.khub.documents.documentId(e).rating)}sendDocumentFeedback(e,t,r){return this.post(this.endpoints.khub.documents.documentId(e).feedback,{message:t,from:r})}semanticSearch(e){return this.post(this.endpoints.khub.semantic.search,{request:e})}clusteredSemanticSearch(e){return this.post(this.endpoints.khub.semantic.clusteredSearch,{request:e})}getFluidTopicsMessageContext(e,t){return this.get(this.endpoints.messages.locale(e).fluidTopics.contextName(t).endpoint)}getCustomMessageContext(e,t){return this.get(this.endpoints.messages.locale(e).custom.contextName(t).endpoint)}listMySearches(e){return this.get(this.endpoints.users.userId(e).searches.list)}listMyBookmarks(e){return this.get(this.endpoints.users.userId(e).bookmarks.list)}async*generate(e,t){const i=await this.fetch(this.endpoints.ai.generate,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({profileId:e,parameters:t}),credentials:null==this.authorization?"include":void 0});await Je("POST",this.endpoints.ai.generate,i);const a=new r(i.body.getReader());yield*a.read()}async*chat(e){const t=await this.fetch(this.endpoints.ai.chat,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e),credentials:null==this.authorization?"include":void 0});await Je("POST",this.endpoints.ai.chat,t);const i=new r(t.body.getReader());yield*i.read()}sendFeedback(e){return this.post(this.endpoints.ai.sendFeedback,e)}get(e,t){return this.makeRequest("GET",this.withVersion(e,t))}post(e,t){return this.makeRequest("POST",e,t)}put(e,t){return this.makeRequest("PUT",e,t)}delete(e){return this.makeRequest("DELETE",e)}makeAbsolute(e){return e.startsWith(this.tenantBaseUrl)||e===this.tenantBaseUrlNoTrailingSlash?e:this.tenantBaseUrl+e.replace(/^\//,"")}async fetch(e,t){const r=t;return await fetch(this.makeAbsolute(e),{...r??{},headers:{...this.defaultHeaders,...r?.headers??{}}})}upload(e,t,r,i=(()=>{})){return"undefined"!=typeof XMLHttpRequest?new Promise(((a,s)=>{let n=new XMLHttpRequest;n.onload=()=>{if(n.status>=200&&n.status<300){let e="application/json"===n.getResponseHeader("Content-Type")?JSON.parse(n.responseText):n.responseText;a(e)}else s(new Xe("GET",t,n.status,n.statusText,n.responseText))},n.upload.onprogress=e=>i(e),n.open(e,this.makeAbsolute(t),!0),n.send(r)})):this.fetch(t,{method:e,body:r}).then((r=>Je(e,t,r))).then(Qe)}makeRequest(e,t,r){return this.fetch(t,{method:e,headers:{...null!=r?{"Content-Type":"application/json"}:{}},body:null!=r?JSON.stringify(r):void 0,credentials:null==this.authorization?"include":void 0}).then((r=>Je(e,t,r))).then(Qe)}fetchRawData(e,t){return fetch(this.withVersion(e,t),{headers:this.defaultHeaders,credentials:null==this.authorization?"include":void 0}).then((t=>Je("GET",e,t))).then((e=>e.arrayBuffer()))}withVersion(e,t){let r=new URL(this.makeAbsolute(e));return t&&r.searchParams.append("v",t),r.toString()}}e.FluidTopicsApi=Ze,e.HttpError=Xe,e.HttpErrorEvent=ze,e.addUnauthenticatedUserSearchPreferencesChangeHandler=function(e,t){if(je.localStorage){const r=Ye(e),i=e=>{e.storageArea===je.localStorage&&e.key===r&&t(JSON.parse(e.newValue??"{}"))};return je.addEventListener("storage",i),{removeHandler:()=>je.removeEventListener("storage",i)}}console.error("Cannot handle unauthenticated preferences: local storage is unavailable.")},e.default=Ze,e.getUnauthenticatedUserSearchPreferences=function(e){if(je.localStorage)return JSON.parse(je.localStorage.getItem(Ye(e))??"{}");console.error("Cannot get unauthenticated preferences: local storage is unavailable.")},e.isFtAuthenticatedSession=e=>i(e)&&Ue(e.authenticationIdentifier)&&Ce(e.profile),e.isFtAuthenticationIdentifier=Ue,e.isFtBookmark=e=>i(e)&&n(e.mapTitle)&&l(e.color)&&Array.isArray(e.breadcrumb)&&e.breadcrumb.every((e=>n(e)))&&n(e.tocId)&&n(e.lastUpdate)&&n(e.readerUrl)&&n(e.mapId)&&n(e.id)&&n(e.title)&&n(e.creationDate),e.isFtClusteredSemanticSearchReply=e=>Le(e)&&Array.isArray(e.documents)&&e.documents.every((e=>Ve(e)))&&Array.isArray(e.clusterId)&&e.clusterId.every((e=>Ne(e))),e.isFtCollectionDocument=e=>i(e)&&a(e.deleted)&&(null==e.apiUrl||n(e.apiUrl))&&(null==e.portalUrl||n(e.portalUrl))&&n(e.id)&&n(e.title)&&z(e.type),e.isFtCollectionDocumentType=z,e.isFtConfigurationHistoryEntryStatus=e=>["VALID","INVALID"].includes(e),e.isFtCredentials=e=>i(e)&&n(e.password)&&(null==e.newPassword||n(e.newPassword))&&a(e.rememberMe)&&n(e.login),e.isFtDateFilter=J,e.isFtDateFilterType=Z,e.isFtEditorialType=G,e.isFtExternalWebComponentContext=e=>["HOMEPAGE","CUSTOM","HEADER","READER","TOPIC_TEMPLATE","SEARCH","SEARCH_RESULT"].includes(e),e.isFtFacetType=e=>["AND","OR","MONOVALUED"].includes(e),e.isFtFeedbackCreation=e=>i(e)&&(null==e.from||n(e.from))&&n(e.message),e.isFtGenAIGenerateInput=e=>Le(e)&&Ne(e.profileId)&&(null==e.parameters||Le(e.parameters)&&Object.keys(e.parameters).every((e=>Ne(e)))&&Object.values(e.parameters).every((e=>Ne(e)))),e.isFtGenAIRating=e=>Le(e)&&Pe(e.rating)&&Ne(e.comment)&&Ne(e.queryId),e.isFtHttpErrorDetails=e=>i(e)&&n(e.endpoint)&&n(e.method)&&n(e.statusText)&&n(e.body)&&s(e.status),e.isFtLabeledMetadataFilter=ee,e.isFtLegacyLabeledMetadataFilter=te,e.isFtLegacyMetadataFilter=re,e.isFtMap=e=>i(e)&&(null==e.prettyUrl||n(e.prettyUrl))&&Array.isArray(e.metadata)&&e.metadata.every((e=>R(e)))&&(null==e.watermark||_e(e.watermark))&&q(e.openMode)&&(null==e.topicsApiEndpoint||n(e.topicsApiEndpoint))&&(null==e.description||n(e.description))&&(null==e.attachmentsApiEndpoint||n(e.attachmentsApiEndpoint))&&G(e.editorialType)&&n(e.baseId)&&n(e.clusterId)&&n(e.title)&&n(e.lastPublication)&&a(e.pbkConfidential)&&n(e.lastEdition)&&n(e.originId)&&(null==e.rightsApiEndpoint||n(e.rightsApiEndpoint))&&y(e.contentStyles)&&(null==e.originUrl||n(e.originUrl))&&n(e.fingerprint)&&n(e.readerUrl)&&(null==e.khubVersion||n(e.khubVersion))&&n(e.id)&&(null==e.lang||n(e.lang)),e.isFtMapAttachment=e=>Le(e)&&Ne(e.file)&&(null==e.size||Pe(e.size))&&De(e.externalLink)&&Ne(e.name)&&Ne(e.id)&&(null==e.mimeType||Ne(e.mimeType))&&(null==e.viewerUrl||Ne(e.viewerUrl)),e.isFtMapResource=e=>i(e)&&n(e.contentUrl)&&n(e.filename)&&n(e.id)&&n(e.mimeType),e.isFtMapStyles=y,e.isFtMessageContext=e=>i(e)&&n(e.name)&&i(e.messages)&&Object.keys(e.messages).every((e=>n(e)))&&Object.values(e.messages).every((e=>n(e)))&&n(e.locale),e.isFtMetadata=R,e.isFtMetadataConfiguration=e=>i(e)&&Array.isArray(e.descriptors)&&e.descriptors.every((e=>O(e))),e.isFtMetadataDescriptor=O,e.isFtMetadataFilter=ae,e.isFtMetadataHomeLayout=e=>["CLASSIC","CUSTOM","DESIGNER"].includes(e),e.isFtMetadataPreferenceConfiguration=P,e.isFtMetadataSortRule=b,e.isFtMyLibraryColors=l,e.isFtMySearch=e=>i(e)&&v(e.searchRequest)&&l(e.color)&&a(e.alert)&&n(e.description)&&n(e.id)&&n(e.ownerId)&&n(e.title)&&n(e.creationDate),e.isFtMySearchRequest=v,e.isFtOpenMode=q,e.isFtPageConfiguration=Be,e.isFtPageRequest=Y,e.isFtPaginatedToc=e=>Le(e)&&xe(e.configuration)&&Array.isArray(e.paginatedToc)&&e.paginatedToc.every((e=>He(e))),e.isFtPaginatedTocNode=He,e.isFtPaginationConfiguration=xe,e.isFtPeriod=se,e.isFtPeriodFilter=ie,e.isFtPeriodFilterType=k,e.isFtPersonalBookCreation=e=>i(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>d(e)))&&Array.isArray(e.nodes)&&e.nodes.every((e=>p(e)))&&n(e.description)&&n(e.title),e.isFtPersonalBookMetadataUpdate=d,e.isFtPersonalBookNodeCreation=p,e.isFtPersonalBookTopicLinkCreation=h,e.isFtPublicClusterSortCriterion=W,e.isFtPublicationRating=C,e.isFtPublicationRatingSummary=_,e.isFtRagHistory=we,e.isFtRagInput=e=>Le(e)&&Ne(e.profileId)&&(null==e.conversationId||Ne(e.conversationId))&&Ne(e.query)&&(null==e.messages||Array.isArray(e.messages)&&e.messages.every((e=>we(e))))&&(null==e.filters||Array.isArray(e.filters)&&e.filters.every((e=>Ke(e)))),e.isFtRangeFilter=ne,e.isFtRatingCreation=e=>i(e)&&I(e.type)&&s(e.value),e.isFtRatingSummary=e=>i(e)&&(null==e.topics||D(e.topics))&&_(e.publication),e.isFtRatingType=I,e.isFtReaderConfiguration=e=>Le(e)&&Me(e.feedback)&&Pe(e.loadAfterLastVisibleTopic)&&Ne(e.relativeTopicPivotMetadata)&&Pe(e.loadBeforeFirstVisibleTopic)&&Ne(e.relativePivotMetadata),e.isFtReaderFeedbackConfiguration=Me,e.isFtSearchFacet=fe,e.isFtSearchFacetConf=Te,e.isFtSearchFacetEntry=ge,e.isFtSearchLocale=g,e.isFtSearchLocales=e=>i(e)&&Array.isArray(e.contentLocales)&&e.contentLocales.every((e=>g(e))),e.isFtSearchPreferences=Ie,e.isFtSearchPreferencesConfiguration=e=>i(e)&&i(e.metadata)&&Object.keys(e.metadata).every((e=>n(e)))&&Object.values(e.metadata).every((e=>P(e))),e.isFtSearchPreset=e=>i(e)&&n(e.name)&&s(e.priority)&&(null==e.contentLocale||n(e.contentLocale))&&Array.isArray(e.metadataFilters)&&e.metadataFilters.every((e=>ae(e))),e.isFtSearchPrior=oe,e.isFtSearchRequest=e=>i(e)&&(null==e.periodFilter||null==e.periodFilter||ie(e.periodFilter))&&n(e.query)&&Y(e.paging)&&(null==e.filters||Array.isArray(e.filters)&&e.filters.every((e=>re(e))))&&Array.isArray(e.sort)&&e.sort.every((e=>Se(e)))&&(null==e.virtualField||V(e.virtualField))&&Array.isArray(e.metadataFilters)&&e.metadataFilters.every((e=>ae(e)))&&Array.isArray(e.facets)&&e.facets.every((e=>Te(e)))&&(null==e.scope||me(e.scope))&&(null==e.uiLocale||n(e.uiLocale))&&(null==e.contentLocale||n(e.contentLocale))&&(null==e.priors||Array.isArray(e.priors)&&e.priors.every((e=>oe(e))))&&(null==e.clusterSortCriterions||Array.isArray(e.clusterSortCriterions)&&e.clusterSortCriterions.every((e=>W(e)))),e.isFtSearchResultCluster=le,e.isFtSearchResultClusterEntry=ue,e.isFtSearchResultMap=de,e.isFtSearchResultTopic=pe,e.isFtSearchResultType=ye,e.isFtSearchResultUnstructuredDocument=ce,e.isFtSearchResults=e=>i(e)&&(null==e.spellcheck||Re(e.spellcheck))&&K(e.paging)&&Array.isArray(e.results)&&e.results.every((e=>le(e)))&&Array.isArray(e.facets)&&e.facets.every((e=>fe(e))),e.isFtSearchResultsPageInfo=K,e.isFtSearchScope=me,e.isFtSearchSortCriterion=Se,e.isFtSearchSortCriterionOrder=w,e.isFtSearchSortCriterionType=H,e.isFtSemanticSearchFilter=Ke,e.isFtSemanticSearchRequest=e=>Le(e)&&Ne(e.query)&&(null==e.filters||Array.isArray(e.filters)&&e.filters.every((e=>Ke(e))))&&(null==e.nbResults||Pe(e.nbResults)),e.isFtSemanticSearchResponseItem=Ve,e.isFtSession=e=>i(e)&&(null==e.authenticationIdentifier||Ue(e.authenticationIdentifier))&&s(e.idleTimeoutInMillis)&&Ce(e.profile)&&a(e.sessionAuthenticated)&&Ie(e.searchPreferences),e.isFtSpellcheck=Re,e.isFtSuggestRequest=e=>i(e)&&n(e.input)&&(null==e.scope||me(e.scope))&&Array.isArray(e.sort)&&e.sort.every((e=>Se(e)))&&(null==e.maxCount||s(e.maxCount))&&(null==e.contentLocale||n(e.contentLocale))&&Array.isArray(e.metadataFilters)&&e.metadataFilters.every((e=>ae(e))),e.isFtSuggestResult=be,e.isFtSuggestResults=e=>i(e)&&Array.isArray(e.suggestions)&&e.suggestions.every((e=>be(e))),e.isFtTocNode=A,e.isFtTopic=e=>i(e)&&Array.isArray(e.metadata)&&e.metadata.every((e=>R(e)))&&n(e.id)&&n(e.contentApiEndpoint)&&n(e.title),e.isFtTopicContentTarget=e=>["THIRD_PARTY","OFF_THE_GRID","CONTENT_PACKAGER","PAGES","DESIGNED_READER"].includes(e),e.isFtTopicOrigin=m,e.isFtTopicOriginType=c,e.isFtTopicRating=L,e.isFtTopicResource=Fe,e.isFtTopicsRatingSummary=D,e.isFtUiLocale=e=>i(e)&&n(e.displayName)&&n(e.languageTag)&&a(e.translated),e.isFtUnstructuredDocument=e=>i(e)&&(null==e.prettyUrl||n(e.prettyUrl))&&Array.isArray(e.metadata)&&e.metadata.every((e=>R(e)))&&n(e.openMode)&&(null==e.description||n(e.description))&&n(e.mimeType)&&(null==e.baseId||n(e.baseId))&&(null==e.clusterId||n(e.clusterId))&&n(e.contentApiEndpoint)&&n(e.title)&&(null==e.lastPublication||n(e.lastPublication))&&n(e.viewerUrl)&&n(e.lastEdition)&&n(e.filename)&&(null==e.originId||n(e.originId))&&n(e.rightsApiEndpoint)&&(null==e.originUrl||n(e.originUrl))&&(null==e.khubVersion||n(e.khubVersion))&&n(e.id)&&(null==e.lang||n(e.lang)),e.isFtUserProfile=Ce,e.isFtUserRole=ve,e.isFtValueFilter=Ee,e.isFtVirtualField=V,e.isFtWatermark=_e,e.setUnauthenticatedUserSearchPreferences=function(e,t){if(je.localStorage){let r={...t,metadata:qe(t.metadata??{})};const i=Ye(e),a=JSON.stringify(r);return je.localStorage.setItem(i,a),je.dispatchEvent(new StorageEvent("storage",{key:i,newValue:a,storageArea:je.localStorage,url:je.location.href})),r}console.error("Cannot set unauthenticated preferences: local storage is unavailable.")},e.userHasRole=function(e,t){return null!=e&&(Array.isArray(e)?e:Array.isArray(e.roles)?e.roles:Array.isArray(e.profile?.roles)?e.profile.roles:[]).some((e=>Ge(e,t)))}}));
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<testsuites>
|
|
3
|
-
<testsuite name="Chromium_playwright_/test-browser/helpers/GenAIChunkReader.test.ts" id="0" tests="2" skipped="0" errors="0" failures="0" time="0.002">
|
|
4
|
-
<properties>
|
|
5
|
-
<property name="test.fileName" value="test-browser/helpers/GenAIChunkReader.test.ts"/>
|
|
6
|
-
<property name="browser.name" value="Chromium"/>
|
|
7
|
-
<property name="browser.launcher" value="playwright"/>
|
|
8
|
-
</properties>
|
|
9
|
-
<testcase name="should wait for complete chunks" time="0.002" classname="GenAIChunkReader" file="test-browser/helpers/GenAIChunkReader.test.ts"/>
|
|
10
|
-
<testcase name="should ignore non-data chunks" time="0" classname="GenAIChunkReader" file="test-browser/helpers/GenAIChunkReader.test.ts"/>
|
|
11
|
-
</testsuite>
|
|
12
|
-
</testsuites>
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { expect } from "@open-wc/testing"
|
|
2
|
-
import { GenAIChunkReader } from "../../src/helpers/GenAIChunkReader"
|
|
3
|
-
|
|
4
|
-
class FakeStream implements ReadableStreamDefaultReader<Uint8Array> {
|
|
5
|
-
readonly closed: Promise<undefined>
|
|
6
|
-
readonly encoder = new TextEncoder()
|
|
7
|
-
|
|
8
|
-
constructor(readonly chunks: string[]) {
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
cancel(reason?: any): Promise<void> {
|
|
12
|
-
return Promise.resolve(undefined)
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
read() {
|
|
16
|
-
if (this.chunks.length === 0) {
|
|
17
|
-
return Promise.resolve({ done: true, value: undefined })
|
|
18
|
-
}
|
|
19
|
-
const chunk = this.chunks.shift()
|
|
20
|
-
let value: Uint8Array = this.encoder.encode(chunk)
|
|
21
|
-
return Promise.resolve({ done: false, value })
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
releaseLock(): void {
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
describe(GenAIChunkReader.name, () => {
|
|
30
|
-
it("should wait for complete chunks", async () => {
|
|
31
|
-
const stream = new FakeStream([
|
|
32
|
-
`data:{`,
|
|
33
|
-
`"foo`,
|
|
34
|
-
`":"bar"}\n`,
|
|
35
|
-
`data:{"foo":"quz"}\n`
|
|
36
|
-
])
|
|
37
|
-
const generator = new GenAIChunkReader(stream).read()
|
|
38
|
-
|
|
39
|
-
expect((await generator.next()).value).to.deep.equal({ "foo": "bar" })
|
|
40
|
-
expect((await generator.next()).value).to.deep.equal({ "foo": "quz" })
|
|
41
|
-
expect((await generator.next()).done).to.be.true
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
it("should ignore non-data chunks", async () => {
|
|
45
|
-
const stream = new FakeStream([
|
|
46
|
-
`patate:{"foo":"bar"}\n`,
|
|
47
|
-
`data:{"foo":"quz"}\n`
|
|
48
|
-
])
|
|
49
|
-
const generator = new GenAIChunkReader(stream).read()
|
|
50
|
-
|
|
51
|
-
expect((await generator.next()).value).to.deep.equal({ "foo": "quz" })
|
|
52
|
-
expect((await generator.next()).done).to.be.true
|
|
53
|
-
})
|
|
54
|
-
})
|
package/vite-plugin.mjs
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import http from "node:http"
|
|
2
|
-
import {existsSync} from "node:fs"
|
|
3
|
-
import {createServer} from "vite"
|
|
4
|
-
|
|
5
|
-
const callWithFileNames = (callback) => ({
|
|
6
|
-
name: "file-name",
|
|
7
|
-
transform(src, id) {
|
|
8
|
-
callback(id)
|
|
9
|
-
},
|
|
10
|
-
})
|
|
11
|
-
|
|
12
|
-
const markExternal = (options) => ({
|
|
13
|
-
name: "mark-external",
|
|
14
|
-
resolveId(path) {
|
|
15
|
-
if (!options.includes(path)) {
|
|
16
|
-
return
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
return {
|
|
20
|
-
id: path,
|
|
21
|
-
external: true
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
const get = url => new Promise((resolve, reject) => {
|
|
27
|
-
const request = http.get(url, (response) => {
|
|
28
|
-
const buffers = []
|
|
29
|
-
let bufferLen = 0
|
|
30
|
-
|
|
31
|
-
response.on("data", chunk => {
|
|
32
|
-
bufferLen += chunk.length
|
|
33
|
-
buffers.push(chunk)
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
response.on("end", () => resolve({
|
|
37
|
-
body: Buffer.concat(buffers, bufferLen),
|
|
38
|
-
headers: response.headers,
|
|
39
|
-
status: response.statusCode,
|
|
40
|
-
}))
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
request.on("error", (err) => reject(err))
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
const proxy = (url) => async ctx => {
|
|
47
|
-
const {body, headers, status} = await get(url + ctx.originalUrl)
|
|
48
|
-
ctx.set(headers)
|
|
49
|
-
ctx.body = body
|
|
50
|
-
ctx.status = status
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export const vitePlugin = (conf) => {
|
|
54
|
-
let viteServer
|
|
55
|
-
|
|
56
|
-
return {
|
|
57
|
-
name: "vite-plugin",
|
|
58
|
-
|
|
59
|
-
async serverStart({app, fileWatcher}) {
|
|
60
|
-
const plugins = [
|
|
61
|
-
callWithFileNames(id => {
|
|
62
|
-
const file = id.split("?")[0]
|
|
63
|
-
if (!file.startsWith("\0") && existsSync(file)) {
|
|
64
|
-
fileWatcher.add(id)
|
|
65
|
-
}
|
|
66
|
-
}),
|
|
67
|
-
markExternal([
|
|
68
|
-
/* @web/test-runner-commands needs to establish a web-socket
|
|
69
|
-
* connection. It expects a file to be served from the
|
|
70
|
-
* @web/dev-server. So it should be ignored by Vite */
|
|
71
|
-
"/__web-dev-server__web-socket.js",
|
|
72
|
-
]),
|
|
73
|
-
]
|
|
74
|
-
|
|
75
|
-
viteServer = await createServer({
|
|
76
|
-
clearScreen: false,
|
|
77
|
-
plugins,
|
|
78
|
-
/* Disable hmr in favor of the @web/test-runner to take care of
|
|
79
|
-
* restarts. */
|
|
80
|
-
server: {hmr: false},
|
|
81
|
-
...conf
|
|
82
|
-
})
|
|
83
|
-
await viteServer.listen()
|
|
84
|
-
|
|
85
|
-
const vitePort = viteServer.config.server.port
|
|
86
|
-
const viteProtocol = viteServer.config.server.https ? "https" : "http"
|
|
87
|
-
|
|
88
|
-
app.use(proxy(`${viteProtocol}://localhost:${vitePort}`))
|
|
89
|
-
},
|
|
90
|
-
|
|
91
|
-
async serverStop() {
|
|
92
|
-
return viteServer.close()
|
|
93
|
-
},
|
|
94
|
-
}
|
|
95
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import {playwrightLauncher} from '@web/test-runner-playwright';
|
|
2
|
-
import {defaultReporter} from "@web/test-runner";
|
|
3
|
-
import {junitReporter} from "@web/test-runner-junit-reporter";
|
|
4
|
-
import {vitePlugin} from "./vite-plugin.mjs";
|
|
5
|
-
|
|
6
|
-
const ignoredLogs = [
|
|
7
|
-
"[vite] connecting...",
|
|
8
|
-
"[vite] connected.",
|
|
9
|
-
"Lit is in dev mode.",
|
|
10
|
-
"Multiple versions of Lit loaded.",
|
|
11
|
-
"Fluid Topics public API was not found.",
|
|
12
|
-
"scheduled an update (generally because a property was set) after an update completed",
|
|
13
|
-
]
|
|
14
|
-
|
|
15
|
-
export default {
|
|
16
|
-
rootDir: '.',
|
|
17
|
-
files: ['./test-browser/**/*.test.ts'],
|
|
18
|
-
nodeResolve: true,
|
|
19
|
-
preserveSymlinks: true,
|
|
20
|
-
browsers: [
|
|
21
|
-
playwrightLauncher({product: 'chromium'}),
|
|
22
|
-
],
|
|
23
|
-
reporters: [
|
|
24
|
-
defaultReporter({reportTestResults: true, reportTestProgress: true}),
|
|
25
|
-
junitReporter({
|
|
26
|
-
outputPath: './build/test-results/web-components.xml',
|
|
27
|
-
reportLogs: true,
|
|
28
|
-
}),
|
|
29
|
-
],
|
|
30
|
-
plugins: [
|
|
31
|
-
vitePlugin({
|
|
32
|
-
optimizeDeps: {
|
|
33
|
-
disabled: true
|
|
34
|
-
}
|
|
35
|
-
}),
|
|
36
|
-
{
|
|
37
|
-
name: "cross-fetch-plugin",
|
|
38
|
-
async serve(context) {
|
|
39
|
-
if (context.path.includes("cross-fetch")) {
|
|
40
|
-
return `export default {}`;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
],
|
|
45
|
-
filterBrowserLogs: (log) => !(typeof log.args[0] === "string" && ignoredLogs.some(l => log.args[0].includes(l))),
|
|
46
|
-
testRunnerHtml: (testRunnerImport) => `
|
|
47
|
-
<html>
|
|
48
|
-
<body>
|
|
49
|
-
<script type="module">
|
|
50
|
-
window.process = { env: { NODE_ENV: 'test' } };
|
|
51
|
-
</script>
|
|
52
|
-
<script type="module">
|
|
53
|
-
import '${testRunnerImport}';
|
|
54
|
-
</script>
|
|
55
|
-
</body>
|
|
56
|
-
</html>
|
|
57
|
-
`,
|
|
58
|
-
};
|