librechat-data-provider 0.8.402 → 0.8.404
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/index.es.js +1 -1
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/react-query/index.es.js +1 -1
- package/dist/react-query/index.es.js.map +1 -1
- package/dist/types/accessPermissions.d.ts +744 -0
- package/dist/types/actions.d.ts +118 -0
- package/dist/types/api-endpoints.d.ts +150 -0
- package/dist/types/artifacts.d.ts +97 -0
- package/dist/types/azure.d.ts +22 -0
- package/dist/types/bedrock.d.ts +1220 -0
- package/dist/types/config.d.ts +14849 -0
- package/dist/types/config.spec.d.ts +1 -0
- package/dist/types/createPayload.d.ts +5 -0
- package/dist/types/data-service.d.ts +287 -0
- package/dist/types/feedback.d.ts +36 -0
- package/dist/types/file-config.d.ts +263 -0
- package/dist/types/file-config.spec.d.ts +1 -0
- package/dist/types/generate.d.ts +597 -0
- package/dist/types/headers-helpers.d.ts +2 -0
- package/{src/index.ts → dist/types/index.d.ts} +0 -15
- package/dist/types/keys.d.ts +92 -0
- package/dist/types/mcp.d.ts +2760 -0
- package/dist/types/messages.d.ts +10 -0
- package/dist/types/models.d.ts +1547 -0
- package/dist/types/parameterSettings.d.ts +69 -0
- package/dist/types/parsers.d.ts +110 -0
- package/dist/types/permissions.d.ts +522 -0
- package/dist/types/react-query/react-query-service.d.ts +85 -0
- package/dist/types/request.d.ts +25 -0
- package/dist/types/roles.d.ts +554 -0
- package/dist/types/roles.spec.d.ts +1 -0
- package/dist/types/schemas.d.ts +5110 -0
- package/dist/types/schemas.spec.d.ts +1 -0
- package/dist/types/types/agents.d.ts +433 -0
- package/dist/types/types/assistants.d.ts +547 -0
- package/dist/types/types/files.d.ts +172 -0
- package/dist/types/types/graph.d.ts +135 -0
- package/{src/types/mcpServers.ts → dist/types/types/mcpServers.d.ts} +12 -18
- package/dist/types/types/mutations.d.ts +209 -0
- package/dist/types/types/queries.d.ts +169 -0
- package/dist/types/types/runs.d.ts +36 -0
- package/dist/types/types/web.d.ts +520 -0
- package/dist/types/types.d.ts +503 -0
- package/dist/types/utils.d.ts +12 -0
- package/package.json +5 -1
- package/babel.config.js +0 -4
- package/check_updates.sh +0 -52
- package/jest.config.js +0 -19
- package/react-query/package-lock.json +0 -292
- package/react-query/package.json +0 -10
- package/rollup.config.js +0 -74
- package/server-rollup.config.js +0 -40
- package/specs/actions.spec.ts +0 -2533
- package/specs/api-endpoints-subdir.spec.ts +0 -140
- package/specs/api-endpoints.spec.ts +0 -74
- package/specs/azure.spec.ts +0 -844
- package/specs/bedrock.spec.ts +0 -862
- package/specs/filetypes.spec.ts +0 -175
- package/specs/generate.spec.ts +0 -770
- package/specs/headers-helpers.spec.ts +0 -24
- package/specs/mcp.spec.ts +0 -147
- package/specs/openapiSpecs.ts +0 -524
- package/specs/parsers.spec.ts +0 -601
- package/specs/request-interceptor.spec.ts +0 -304
- package/specs/utils.spec.ts +0 -196
- package/src/accessPermissions.ts +0 -346
- package/src/actions.ts +0 -813
- package/src/api-endpoints.ts +0 -440
- package/src/artifacts.ts +0 -3104
- package/src/azure.ts +0 -328
- package/src/bedrock.ts +0 -425
- package/src/config.spec.ts +0 -315
- package/src/config.ts +0 -2006
- package/src/createPayload.ts +0 -46
- package/src/data-service.ts +0 -1087
- package/src/feedback.ts +0 -141
- package/src/file-config.spec.ts +0 -1248
- package/src/file-config.ts +0 -764
- package/src/generate.ts +0 -634
- package/src/headers-helpers.ts +0 -13
- package/src/keys.ts +0 -99
- package/src/mcp.ts +0 -271
- package/src/messages.ts +0 -50
- package/src/models.ts +0 -69
- package/src/parameterSettings.ts +0 -1111
- package/src/parsers.ts +0 -563
- package/src/permissions.ts +0 -188
- package/src/react-query/react-query-service.ts +0 -566
- package/src/request.ts +0 -171
- package/src/roles.spec.ts +0 -132
- package/src/roles.ts +0 -225
- package/src/schemas.spec.ts +0 -355
- package/src/schemas.ts +0 -1234
- package/src/types/agents.ts +0 -470
- package/src/types/assistants.ts +0 -654
- package/src/types/files.ts +0 -191
- package/src/types/graph.ts +0 -145
- package/src/types/mutations.ts +0 -422
- package/src/types/queries.ts +0 -208
- package/src/types/runs.ts +0 -40
- package/src/types/web.ts +0 -588
- package/src/types.ts +0 -676
- package/src/utils.ts +0 -85
- package/tsconfig.json +0 -28
- package/tsconfig.spec.json +0 -10
- /package/{src/react-query/index.ts → dist/types/react-query/index.d.ts} +0 -0
- /package/{src/types/index.ts → dist/types/types/index.d.ts} +0 -0
package/src/file-config.ts
DELETED
|
@@ -1,764 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import type { EndpointFileConfig, FileConfig } from './types/files';
|
|
3
|
-
import { EModelEndpoint, isAgentsEndpoint, isDocumentSupportedProvider } from './schemas';
|
|
4
|
-
import { normalizeEndpointName } from './utils';
|
|
5
|
-
|
|
6
|
-
export const supportsFiles = {
|
|
7
|
-
[EModelEndpoint.openAI]: true,
|
|
8
|
-
[EModelEndpoint.google]: true,
|
|
9
|
-
[EModelEndpoint.assistants]: true,
|
|
10
|
-
[EModelEndpoint.azureAssistants]: true,
|
|
11
|
-
[EModelEndpoint.agents]: true,
|
|
12
|
-
[EModelEndpoint.azureOpenAI]: true,
|
|
13
|
-
[EModelEndpoint.anthropic]: true,
|
|
14
|
-
[EModelEndpoint.custom]: true,
|
|
15
|
-
[EModelEndpoint.bedrock]: true,
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export const excelFileTypes = [
|
|
19
|
-
'application/vnd.ms-excel',
|
|
20
|
-
'application/msexcel',
|
|
21
|
-
'application/x-msexcel',
|
|
22
|
-
'application/x-ms-excel',
|
|
23
|
-
'application/x-excel',
|
|
24
|
-
'application/x-dos_ms_excel',
|
|
25
|
-
'application/xls',
|
|
26
|
-
'application/x-xls',
|
|
27
|
-
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
28
|
-
];
|
|
29
|
-
|
|
30
|
-
export const fullMimeTypesList = [
|
|
31
|
-
'text/x-c',
|
|
32
|
-
'text/x-c++',
|
|
33
|
-
'application/csv',
|
|
34
|
-
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
|
35
|
-
'text/html',
|
|
36
|
-
'text/x-java',
|
|
37
|
-
'application/json',
|
|
38
|
-
'text/markdown',
|
|
39
|
-
'application/pdf',
|
|
40
|
-
'text/x-php',
|
|
41
|
-
'application/vnd.openxmlformats-officedocument.presentationml.presentation',
|
|
42
|
-
'text/x-python',
|
|
43
|
-
'text/x-script.python',
|
|
44
|
-
'text/x-ruby',
|
|
45
|
-
'text/x-tex',
|
|
46
|
-
'text/plain',
|
|
47
|
-
'text/css',
|
|
48
|
-
'text/vtt',
|
|
49
|
-
'image/jpeg',
|
|
50
|
-
'text/javascript',
|
|
51
|
-
'image/gif',
|
|
52
|
-
'image/png',
|
|
53
|
-
'image/heic',
|
|
54
|
-
'image/heif',
|
|
55
|
-
'application/x-tar',
|
|
56
|
-
'application/x-sh',
|
|
57
|
-
'application/typescript',
|
|
58
|
-
'application/sql',
|
|
59
|
-
'application/yaml',
|
|
60
|
-
'application/vnd.coffeescript',
|
|
61
|
-
'application/xml',
|
|
62
|
-
'application/zip',
|
|
63
|
-
'application/x-parquet',
|
|
64
|
-
'application/vnd.oasis.opendocument.text',
|
|
65
|
-
'application/vnd.oasis.opendocument.spreadsheet',
|
|
66
|
-
'application/vnd.oasis.opendocument.presentation',
|
|
67
|
-
'application/vnd.oasis.opendocument.graphics',
|
|
68
|
-
'image/svg',
|
|
69
|
-
'image/svg+xml',
|
|
70
|
-
// Video formats
|
|
71
|
-
'video/mp4',
|
|
72
|
-
'video/avi',
|
|
73
|
-
'video/mov',
|
|
74
|
-
'video/wmv',
|
|
75
|
-
'video/flv',
|
|
76
|
-
'video/webm',
|
|
77
|
-
'video/mkv',
|
|
78
|
-
'video/m4v',
|
|
79
|
-
'video/3gp',
|
|
80
|
-
'video/ogv',
|
|
81
|
-
// Audio formats
|
|
82
|
-
'audio/mp3',
|
|
83
|
-
'audio/wav',
|
|
84
|
-
'audio/ogg',
|
|
85
|
-
'audio/m4a',
|
|
86
|
-
'audio/aac',
|
|
87
|
-
'audio/flac',
|
|
88
|
-
'audio/wma',
|
|
89
|
-
'audio/opus',
|
|
90
|
-
'audio/mpeg',
|
|
91
|
-
...excelFileTypes,
|
|
92
|
-
];
|
|
93
|
-
|
|
94
|
-
export const codeInterpreterMimeTypesList = [
|
|
95
|
-
'text/x-c',
|
|
96
|
-
'text/x-c++',
|
|
97
|
-
'application/csv',
|
|
98
|
-
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
|
99
|
-
'text/html',
|
|
100
|
-
'text/x-java',
|
|
101
|
-
'application/json',
|
|
102
|
-
'text/markdown',
|
|
103
|
-
'application/pdf',
|
|
104
|
-
'text/x-php',
|
|
105
|
-
'application/vnd.openxmlformats-officedocument.presentationml.presentation',
|
|
106
|
-
'text/x-python',
|
|
107
|
-
'text/x-script.python',
|
|
108
|
-
'text/x-ruby',
|
|
109
|
-
'text/x-tex',
|
|
110
|
-
'text/plain',
|
|
111
|
-
'text/css',
|
|
112
|
-
'image/jpeg',
|
|
113
|
-
'text/javascript',
|
|
114
|
-
'image/gif',
|
|
115
|
-
'image/png',
|
|
116
|
-
'image/heic',
|
|
117
|
-
'image/heif',
|
|
118
|
-
'application/x-tar',
|
|
119
|
-
'application/typescript',
|
|
120
|
-
'application/xml',
|
|
121
|
-
'application/zip',
|
|
122
|
-
'application/x-parquet',
|
|
123
|
-
...excelFileTypes,
|
|
124
|
-
];
|
|
125
|
-
|
|
126
|
-
export const retrievalMimeTypesList = [
|
|
127
|
-
'text/x-c',
|
|
128
|
-
'text/x-c++',
|
|
129
|
-
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
|
130
|
-
'text/html',
|
|
131
|
-
'text/x-java',
|
|
132
|
-
'application/json',
|
|
133
|
-
'text/markdown',
|
|
134
|
-
'application/pdf',
|
|
135
|
-
'text/x-php',
|
|
136
|
-
'application/vnd.openxmlformats-officedocument.presentationml.presentation',
|
|
137
|
-
'text/x-python',
|
|
138
|
-
'text/x-script.python',
|
|
139
|
-
'text/x-ruby',
|
|
140
|
-
'text/x-tex',
|
|
141
|
-
'text/plain',
|
|
142
|
-
];
|
|
143
|
-
|
|
144
|
-
export const imageExtRegex = /\.(jpg|jpeg|png|gif|webp|heic|heif)$/i;
|
|
145
|
-
|
|
146
|
-
/** @see https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_DocumentBlock.html */
|
|
147
|
-
export type BedrockDocumentFormat =
|
|
148
|
-
| 'pdf'
|
|
149
|
-
| 'csv'
|
|
150
|
-
| 'doc'
|
|
151
|
-
| 'docx'
|
|
152
|
-
| 'xls'
|
|
153
|
-
| 'xlsx'
|
|
154
|
-
| 'html'
|
|
155
|
-
| 'txt'
|
|
156
|
-
| 'md';
|
|
157
|
-
|
|
158
|
-
/** Maps MIME types to Bedrock Converse API document format values */
|
|
159
|
-
export const bedrockDocumentFormats: Record<string, BedrockDocumentFormat> = {
|
|
160
|
-
'application/pdf': 'pdf',
|
|
161
|
-
'text/csv': 'csv',
|
|
162
|
-
'application/csv': 'csv',
|
|
163
|
-
'application/msword': 'doc',
|
|
164
|
-
'application/vnd.openxmlformats-officedocument.wordprocessingml.document': 'docx',
|
|
165
|
-
'application/vnd.ms-excel': 'xls',
|
|
166
|
-
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': 'xlsx',
|
|
167
|
-
'text/html': 'html',
|
|
168
|
-
'text/plain': 'txt',
|
|
169
|
-
'text/markdown': 'md',
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
export const isBedrockDocumentType = (mimeType?: string): boolean =>
|
|
173
|
-
mimeType != null && mimeType in bedrockDocumentFormats;
|
|
174
|
-
|
|
175
|
-
/** File extensions accepted by Bedrock document uploads (for input accept attributes) */
|
|
176
|
-
export const bedrockDocumentExtensions =
|
|
177
|
-
'.pdf,.csv,.doc,.docx,.xls,.xlsx,.html,.htm,.txt,.md,application/pdf,text/csv,application/csv,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,text/html,text/plain,text/markdown';
|
|
178
|
-
|
|
179
|
-
export const excelMimeTypes =
|
|
180
|
-
/^application\/(vnd\.ms-excel|msexcel|x-msexcel|x-ms-excel|x-excel|x-dos_ms_excel|xls|x-xls|vnd\.openxmlformats-officedocument\.spreadsheetml\.sheet)$/;
|
|
181
|
-
|
|
182
|
-
export const textMimeTypes =
|
|
183
|
-
/^(text\/(x-c|x-csharp|tab-separated-values|x-c\+\+|x-h|x-java|html|markdown|x-php|x-python|x-script\.python|x-ruby|x-tex|plain|css|vtt|javascript|csv|xml))$/;
|
|
184
|
-
|
|
185
|
-
export const applicationMimeTypes =
|
|
186
|
-
/^(application\/(epub\+zip|csv|json|msword|pdf|x-tar|x-sh|typescript|sql|yaml|x-parquet|vnd\.apache\.parquet|vnd\.coffeescript|vnd\.openxmlformats-officedocument\.(wordprocessingml\.document|presentationml\.presentation|spreadsheetml\.sheet)|vnd\.oasis\.opendocument\.(text|spreadsheet|presentation|graphics)|xml|zip))$/;
|
|
187
|
-
|
|
188
|
-
export const imageMimeTypes = /^image\/(jpeg|gif|png|webp|heic|heif)$/;
|
|
189
|
-
|
|
190
|
-
export const audioMimeTypes =
|
|
191
|
-
/^audio\/(mp3|mpeg|mpeg3|wav|wave|x-wav|ogg|vorbis|mp4|m4a|x-m4a|flac|x-flac|webm|aac|wma|opus)$/;
|
|
192
|
-
|
|
193
|
-
export const videoMimeTypes = /^video\/(mp4|avi|mov|wmv|flv|webm|mkv|m4v|3gp|ogv)$/;
|
|
194
|
-
|
|
195
|
-
export const defaultOCRMimeTypes = [
|
|
196
|
-
imageMimeTypes,
|
|
197
|
-
excelMimeTypes,
|
|
198
|
-
/^application\/pdf$/,
|
|
199
|
-
/^application\/vnd\.openxmlformats-officedocument\.(wordprocessingml\.document|presentationml\.presentation)$/,
|
|
200
|
-
/^application\/vnd\.ms-(word|powerpoint)$/,
|
|
201
|
-
/^application\/epub\+zip$/,
|
|
202
|
-
/^application\/vnd\.oasis\.opendocument\.(text|spreadsheet|presentation|graphics)$/,
|
|
203
|
-
];
|
|
204
|
-
|
|
205
|
-
/** MIME types handled by the built-in document parser (pdf, docx, excel variants, ods/odt) */
|
|
206
|
-
export const documentParserMimeTypes = [
|
|
207
|
-
excelMimeTypes,
|
|
208
|
-
/^application\/pdf$/,
|
|
209
|
-
/^application\/vnd\.openxmlformats-officedocument\.wordprocessingml\.document$/,
|
|
210
|
-
/^application\/vnd\.oasis\.opendocument\.spreadsheet$/,
|
|
211
|
-
/^application\/vnd\.oasis\.opendocument\.text$/,
|
|
212
|
-
];
|
|
213
|
-
|
|
214
|
-
export const defaultTextMimeTypes = [/^[\w.-]+\/[\w.-]+$/];
|
|
215
|
-
|
|
216
|
-
export const defaultSTTMimeTypes = [audioMimeTypes];
|
|
217
|
-
|
|
218
|
-
export const supportedMimeTypes = [
|
|
219
|
-
textMimeTypes,
|
|
220
|
-
excelMimeTypes,
|
|
221
|
-
applicationMimeTypes,
|
|
222
|
-
imageMimeTypes,
|
|
223
|
-
videoMimeTypes,
|
|
224
|
-
audioMimeTypes,
|
|
225
|
-
/** Supported by LC Code Interpreter API */
|
|
226
|
-
/^image\/(svg|svg\+xml)$/,
|
|
227
|
-
];
|
|
228
|
-
|
|
229
|
-
export const codeInterpreterMimeTypes = [
|
|
230
|
-
textMimeTypes,
|
|
231
|
-
excelMimeTypes,
|
|
232
|
-
applicationMimeTypes,
|
|
233
|
-
imageMimeTypes,
|
|
234
|
-
];
|
|
235
|
-
|
|
236
|
-
export const codeTypeMapping: { [key: string]: string } = {
|
|
237
|
-
c: 'text/x-c', // .c - C source
|
|
238
|
-
cs: 'text/x-csharp', // .cs - C# source
|
|
239
|
-
cpp: 'text/x-c++', // .cpp - C++ source
|
|
240
|
-
h: 'text/x-h', // .h - C/C++ header
|
|
241
|
-
md: 'text/markdown', // .md - Markdown
|
|
242
|
-
php: 'text/x-php', // .php - PHP source
|
|
243
|
-
py: 'text/x-python', // .py - Python source
|
|
244
|
-
rb: 'text/x-ruby', // .rb - Ruby source
|
|
245
|
-
tex: 'text/x-tex', // .tex - LaTeX source
|
|
246
|
-
java: 'text/x-java', // .java - Java source
|
|
247
|
-
js: 'text/javascript', // .js - JavaScript source
|
|
248
|
-
sh: 'application/x-sh', // .sh - Shell script
|
|
249
|
-
ts: 'application/typescript', // .ts - TypeScript source
|
|
250
|
-
tar: 'application/x-tar', // .tar - Tar archive
|
|
251
|
-
zip: 'application/zip', // .zip - ZIP archive
|
|
252
|
-
txt: 'text/plain', // .txt - Plain text file
|
|
253
|
-
log: 'text/plain', // .log - Log file
|
|
254
|
-
csv: 'text/csv', // .csv - Comma-separated values
|
|
255
|
-
tsv: 'text/tab-separated-values', // .tsv - Tab-separated values
|
|
256
|
-
parquet: 'application/x-parquet', // .parquet - Apache Parquet columnar storage
|
|
257
|
-
json: 'application/json', // .json - JSON file
|
|
258
|
-
xml: 'application/xml', // .xml - XML file
|
|
259
|
-
html: 'text/html', // .html - HTML file
|
|
260
|
-
htm: 'text/html', // .htm - HTML file
|
|
261
|
-
css: 'text/css', // .css - CSS file
|
|
262
|
-
yml: 'application/yaml', // .yml - YAML
|
|
263
|
-
yaml: 'application/yaml', // .yaml - YAML
|
|
264
|
-
sql: 'application/sql', // .sql - SQL (IANA registered)
|
|
265
|
-
dart: 'text/plain', // .dart - Dart source
|
|
266
|
-
coffee: 'application/vnd.coffeescript', // .coffee - CoffeeScript (IANA registered)
|
|
267
|
-
go: 'text/plain', // .go - Go source
|
|
268
|
-
rs: 'text/plain', // .rs - Rust source
|
|
269
|
-
swift: 'text/plain', // .swift - Swift source
|
|
270
|
-
kt: 'text/plain', // .kt - Kotlin source
|
|
271
|
-
kts: 'text/plain', // .kts - Kotlin script
|
|
272
|
-
scala: 'text/plain', // .scala - Scala source
|
|
273
|
-
lua: 'text/plain', // .lua - Lua source
|
|
274
|
-
r: 'text/plain', // .r - R source
|
|
275
|
-
pl: 'text/plain', // .pl - Perl source
|
|
276
|
-
pm: 'text/plain', // .pm - Perl module
|
|
277
|
-
groovy: 'text/plain', // .groovy - Groovy source
|
|
278
|
-
gradle: 'text/plain', // .gradle - Gradle build script
|
|
279
|
-
clj: 'text/plain', // .clj - Clojure source
|
|
280
|
-
cljs: 'text/plain', // .cljs - ClojureScript source
|
|
281
|
-
cljc: 'text/plain', // .cljc - Clojure common source
|
|
282
|
-
elm: 'text/plain', // .elm - Elm source
|
|
283
|
-
erl: 'text/plain', // .erl - Erlang source
|
|
284
|
-
hrl: 'text/plain', // .hrl - Erlang header
|
|
285
|
-
ex: 'text/plain', // .ex - Elixir source
|
|
286
|
-
exs: 'text/plain', // .exs - Elixir script
|
|
287
|
-
hs: 'text/plain', // .hs - Haskell source
|
|
288
|
-
lhs: 'text/plain', // .lhs - Literate Haskell source
|
|
289
|
-
ml: 'text/plain', // .ml - OCaml source
|
|
290
|
-
mli: 'text/plain', // .mli - OCaml interface
|
|
291
|
-
fs: 'text/plain', // .fs - F# source
|
|
292
|
-
fsx: 'text/plain', // .fsx - F# script
|
|
293
|
-
lisp: 'text/plain', // .lisp - Lisp source
|
|
294
|
-
cl: 'text/plain', // .cl - Common Lisp source
|
|
295
|
-
scm: 'text/plain', // .scm - Scheme source
|
|
296
|
-
rkt: 'text/plain', // .rkt - Racket source
|
|
297
|
-
jsx: 'text/plain', // .jsx - React JSX
|
|
298
|
-
tsx: 'text/plain', // .tsx - React TSX
|
|
299
|
-
vue: 'text/plain', // .vue - Vue component
|
|
300
|
-
svelte: 'text/plain', // .svelte - Svelte component
|
|
301
|
-
astro: 'text/plain', // .astro - Astro component
|
|
302
|
-
scss: 'text/plain', // .scss - SCSS source
|
|
303
|
-
sass: 'text/plain', // .sass - Sass source
|
|
304
|
-
less: 'text/plain', // .less - Less source
|
|
305
|
-
styl: 'text/plain', // .styl - Stylus source
|
|
306
|
-
toml: 'text/plain', // .toml - TOML config
|
|
307
|
-
ini: 'text/plain', // .ini - INI config
|
|
308
|
-
cfg: 'text/plain', // .cfg - Config file
|
|
309
|
-
conf: 'text/plain', // .conf - Config file
|
|
310
|
-
env: 'text/plain', // .env - Environment file
|
|
311
|
-
properties: 'text/plain', // .properties - Java properties
|
|
312
|
-
graphql: 'text/plain', // .graphql - GraphQL schema/query
|
|
313
|
-
gql: 'text/plain', // .gql - GraphQL schema/query
|
|
314
|
-
proto: 'text/plain', // .proto - Protocol Buffers
|
|
315
|
-
dockerfile: 'text/plain', // Dockerfile
|
|
316
|
-
makefile: 'text/plain', // Makefile
|
|
317
|
-
cmake: 'text/plain', // .cmake - CMake script
|
|
318
|
-
rake: 'text/plain', // .rake - Rake task
|
|
319
|
-
gemspec: 'text/plain', // .gemspec - Ruby gem spec
|
|
320
|
-
bash: 'text/plain', // .bash - Bash script
|
|
321
|
-
zsh: 'text/plain', // .zsh - Zsh script
|
|
322
|
-
fish: 'text/plain', // .fish - Fish script
|
|
323
|
-
ps1: 'text/plain', // .ps1 - PowerShell script
|
|
324
|
-
psm1: 'text/plain', // .psm1 - PowerShell module
|
|
325
|
-
bat: 'text/plain', // .bat - Batch script
|
|
326
|
-
cmd: 'text/plain', // .cmd - Windows command script
|
|
327
|
-
asm: 'text/plain', // .asm - Assembly source
|
|
328
|
-
s: 'text/plain', // .s - Assembly source
|
|
329
|
-
v: 'text/plain', // .v - V or Verilog source
|
|
330
|
-
zig: 'text/plain', // .zig - Zig source
|
|
331
|
-
nim: 'text/plain', // .nim - Nim source
|
|
332
|
-
cr: 'text/plain', // .cr - Crystal source
|
|
333
|
-
d: 'text/plain', // .d - D source
|
|
334
|
-
pas: 'text/plain', // .pas - Pascal source
|
|
335
|
-
pp: 'text/plain', // .pp - Pascal/Puppet source
|
|
336
|
-
f90: 'text/plain', // .f90 - Fortran 90 source
|
|
337
|
-
f95: 'text/plain', // .f95 - Fortran 95 source
|
|
338
|
-
f03: 'text/plain', // .f03 - Fortran 2003 source
|
|
339
|
-
jl: 'text/plain', // .jl - Julia source
|
|
340
|
-
m: 'text/plain', // .m - Objective-C/MATLAB source
|
|
341
|
-
mm: 'text/plain', // .mm - Objective-C++ source
|
|
342
|
-
ada: 'text/plain', // .ada - Ada source
|
|
343
|
-
adb: 'text/plain', // .adb - Ada body
|
|
344
|
-
ads: 'text/plain', // .ads - Ada spec
|
|
345
|
-
cob: 'text/plain', // .cob - COBOL source
|
|
346
|
-
cbl: 'text/plain', // .cbl - COBOL source
|
|
347
|
-
tcl: 'text/plain', // .tcl - Tcl source
|
|
348
|
-
awk: 'text/plain', // .awk - AWK script
|
|
349
|
-
sed: 'text/plain', // .sed - Sed script
|
|
350
|
-
odt: 'application/vnd.oasis.opendocument.text', // .odt - OpenDocument Text
|
|
351
|
-
ods: 'application/vnd.oasis.opendocument.spreadsheet', // .ods - OpenDocument Spreadsheet
|
|
352
|
-
odp: 'application/vnd.oasis.opendocument.presentation', // .odp - OpenDocument Presentation
|
|
353
|
-
odg: 'application/vnd.oasis.opendocument.graphics', // .odg - OpenDocument Graphics
|
|
354
|
-
};
|
|
355
|
-
|
|
356
|
-
/** Maps image extensions to MIME types for formats browsers may not recognize */
|
|
357
|
-
export const imageTypeMapping: { [key: string]: string } = {
|
|
358
|
-
heic: 'image/heic',
|
|
359
|
-
heif: 'image/heif',
|
|
360
|
-
};
|
|
361
|
-
|
|
362
|
-
/** Normalizes non-standard MIME types that browsers may report to their canonical forms */
|
|
363
|
-
export const mimeTypeAliases: Readonly<Record<string, string>> = {
|
|
364
|
-
'text/x-python-script': 'text/x-python',
|
|
365
|
-
};
|
|
366
|
-
|
|
367
|
-
/**
|
|
368
|
-
* Infers the MIME type from a file's extension when the browser doesn't recognize it,
|
|
369
|
-
* and normalizes known non-standard MIME type aliases to their canonical forms.
|
|
370
|
-
* @param fileName - The file name including its extension
|
|
371
|
-
* @param currentType - The MIME type reported by the browser (may be empty string)
|
|
372
|
-
* @returns The normalized or inferred MIME type; empty string if unresolvable
|
|
373
|
-
*/
|
|
374
|
-
export function inferMimeType(fileName: string, currentType: string): string {
|
|
375
|
-
if (currentType) {
|
|
376
|
-
return mimeTypeAliases[currentType] ?? currentType;
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
const extension = fileName.split('.').pop()?.toLowerCase() ?? '';
|
|
380
|
-
return codeTypeMapping[extension] || imageTypeMapping[extension] || currentType;
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
export const retrievalMimeTypes = [
|
|
384
|
-
/^(text\/(x-c|x-c\+\+|x-h|html|x-java|markdown|x-php|x-python|x-script\.python|x-ruby|x-tex|plain|vtt|xml))$/,
|
|
385
|
-
/^(application\/(json|pdf|vnd\.openxmlformats-officedocument\.(wordprocessingml\.document|presentationml\.presentation)))$/,
|
|
386
|
-
];
|
|
387
|
-
|
|
388
|
-
export const megabyte = 1024 * 1024;
|
|
389
|
-
/** Helper function to get megabytes value */
|
|
390
|
-
export const mbToBytes = (mb: number): number => mb * megabyte;
|
|
391
|
-
|
|
392
|
-
const defaultSizeLimit = mbToBytes(512);
|
|
393
|
-
const defaultTokenLimit = 100000;
|
|
394
|
-
const assistantsFileConfig = {
|
|
395
|
-
fileLimit: 10,
|
|
396
|
-
fileSizeLimit: defaultSizeLimit,
|
|
397
|
-
totalSizeLimit: defaultSizeLimit,
|
|
398
|
-
supportedMimeTypes,
|
|
399
|
-
disabled: false,
|
|
400
|
-
};
|
|
401
|
-
|
|
402
|
-
export const fileConfig = {
|
|
403
|
-
endpoints: {
|
|
404
|
-
[EModelEndpoint.assistants]: assistantsFileConfig,
|
|
405
|
-
[EModelEndpoint.azureAssistants]: assistantsFileConfig,
|
|
406
|
-
[EModelEndpoint.agents]: assistantsFileConfig,
|
|
407
|
-
[EModelEndpoint.anthropic]: {
|
|
408
|
-
fileLimit: 10,
|
|
409
|
-
fileSizeLimit: defaultSizeLimit,
|
|
410
|
-
totalSizeLimit: defaultSizeLimit,
|
|
411
|
-
supportedMimeTypes,
|
|
412
|
-
disabled: false,
|
|
413
|
-
},
|
|
414
|
-
default: {
|
|
415
|
-
fileLimit: 10,
|
|
416
|
-
fileSizeLimit: defaultSizeLimit,
|
|
417
|
-
totalSizeLimit: defaultSizeLimit,
|
|
418
|
-
supportedMimeTypes,
|
|
419
|
-
disabled: false,
|
|
420
|
-
},
|
|
421
|
-
},
|
|
422
|
-
serverFileSizeLimit: defaultSizeLimit,
|
|
423
|
-
avatarSizeLimit: mbToBytes(2),
|
|
424
|
-
fileTokenLimit: defaultTokenLimit,
|
|
425
|
-
clientImageResize: {
|
|
426
|
-
enabled: false,
|
|
427
|
-
maxWidth: 1900,
|
|
428
|
-
maxHeight: 1900,
|
|
429
|
-
quality: 0.92,
|
|
430
|
-
},
|
|
431
|
-
ocr: {
|
|
432
|
-
supportedMimeTypes: defaultOCRMimeTypes,
|
|
433
|
-
},
|
|
434
|
-
text: {
|
|
435
|
-
supportedMimeTypes: defaultTextMimeTypes,
|
|
436
|
-
},
|
|
437
|
-
stt: {
|
|
438
|
-
supportedMimeTypes: defaultSTTMimeTypes,
|
|
439
|
-
},
|
|
440
|
-
checkType: function (fileType: string, supportedTypes: RegExp[] = supportedMimeTypes) {
|
|
441
|
-
return supportedTypes.some((regex) => regex.test(fileType));
|
|
442
|
-
},
|
|
443
|
-
};
|
|
444
|
-
|
|
445
|
-
const supportedMimeTypesSchema = z
|
|
446
|
-
.array(z.any())
|
|
447
|
-
.optional()
|
|
448
|
-
.refine(
|
|
449
|
-
(mimeTypes) => {
|
|
450
|
-
if (!mimeTypes) {
|
|
451
|
-
return true;
|
|
452
|
-
}
|
|
453
|
-
return mimeTypes.every(
|
|
454
|
-
(mimeType) => mimeType instanceof RegExp || typeof mimeType === 'string',
|
|
455
|
-
);
|
|
456
|
-
},
|
|
457
|
-
{
|
|
458
|
-
message: 'Each mimeType must be a string or a RegExp object.',
|
|
459
|
-
},
|
|
460
|
-
);
|
|
461
|
-
|
|
462
|
-
export const endpointFileConfigSchema = z.object({
|
|
463
|
-
disabled: z.boolean().optional(),
|
|
464
|
-
fileLimit: z.number().min(0).optional(),
|
|
465
|
-
fileSizeLimit: z.number().min(0).optional(),
|
|
466
|
-
totalSizeLimit: z.number().min(0).optional(),
|
|
467
|
-
supportedMimeTypes: supportedMimeTypesSchema.optional(),
|
|
468
|
-
});
|
|
469
|
-
|
|
470
|
-
export const fileConfigSchema = z.object({
|
|
471
|
-
endpoints: z.record(endpointFileConfigSchema).optional(),
|
|
472
|
-
serverFileSizeLimit: z.number().min(0).optional(),
|
|
473
|
-
avatarSizeLimit: z.number().min(0).optional(),
|
|
474
|
-
fileTokenLimit: z.number().min(0).optional(),
|
|
475
|
-
imageGeneration: z
|
|
476
|
-
.object({
|
|
477
|
-
percentage: z.number().min(0).max(100).optional(),
|
|
478
|
-
px: z.number().min(0).optional(),
|
|
479
|
-
})
|
|
480
|
-
.optional(),
|
|
481
|
-
clientImageResize: z
|
|
482
|
-
.object({
|
|
483
|
-
enabled: z.boolean().optional(),
|
|
484
|
-
maxWidth: z.number().min(0).optional(),
|
|
485
|
-
maxHeight: z.number().min(0).optional(),
|
|
486
|
-
quality: z.number().min(0).max(1).optional(),
|
|
487
|
-
})
|
|
488
|
-
.optional(),
|
|
489
|
-
ocr: z
|
|
490
|
-
.object({
|
|
491
|
-
supportedMimeTypes: supportedMimeTypesSchema.optional(),
|
|
492
|
-
})
|
|
493
|
-
.optional(),
|
|
494
|
-
text: z
|
|
495
|
-
.object({
|
|
496
|
-
supportedMimeTypes: supportedMimeTypesSchema.optional(),
|
|
497
|
-
})
|
|
498
|
-
.optional(),
|
|
499
|
-
});
|
|
500
|
-
|
|
501
|
-
export type TFileConfig = z.infer<typeof fileConfigSchema>;
|
|
502
|
-
|
|
503
|
-
/** Helper function to safely convert string patterns to RegExp objects */
|
|
504
|
-
export const convertStringsToRegex = (patterns: string[]): RegExp[] =>
|
|
505
|
-
patterns.reduce((acc: RegExp[], pattern) => {
|
|
506
|
-
try {
|
|
507
|
-
const regex = new RegExp(pattern);
|
|
508
|
-
acc.push(regex);
|
|
509
|
-
} catch (error) {
|
|
510
|
-
console.error(`Invalid regex pattern "${pattern}" skipped.`, error);
|
|
511
|
-
}
|
|
512
|
-
return acc;
|
|
513
|
-
}, []);
|
|
514
|
-
|
|
515
|
-
/**
|
|
516
|
-
* Gets the appropriate endpoint file configuration with standardized lookup logic.
|
|
517
|
-
*
|
|
518
|
-
* @param params - Object containing fileConfig, endpoint, and optional conversationEndpoint
|
|
519
|
-
* @param params.fileConfig - The merged file configuration
|
|
520
|
-
* @param params.endpoint - The endpoint name to look up
|
|
521
|
-
* @param params.conversationEndpoint - Optional conversation endpoint for additional context
|
|
522
|
-
* @returns The endpoint file configuration or undefined
|
|
523
|
-
*/
|
|
524
|
-
/**
|
|
525
|
-
* Merges an endpoint config with the default config to ensure all fields are populated.
|
|
526
|
-
* For document-supported providers, uses the comprehensive MIME type list (includes videos/audio).
|
|
527
|
-
*/
|
|
528
|
-
function mergeWithDefault(
|
|
529
|
-
endpointConfig: EndpointFileConfig,
|
|
530
|
-
defaultConfig: EndpointFileConfig,
|
|
531
|
-
endpoint?: string | null,
|
|
532
|
-
): EndpointFileConfig {
|
|
533
|
-
/** Use comprehensive MIME types for document-supported providers */
|
|
534
|
-
const defaultMimeTypes = isDocumentSupportedProvider(endpoint)
|
|
535
|
-
? supportedMimeTypes
|
|
536
|
-
: defaultConfig.supportedMimeTypes;
|
|
537
|
-
|
|
538
|
-
return {
|
|
539
|
-
disabled: endpointConfig.disabled ?? defaultConfig.disabled,
|
|
540
|
-
fileLimit: endpointConfig.fileLimit ?? defaultConfig.fileLimit,
|
|
541
|
-
fileSizeLimit: endpointConfig.fileSizeLimit ?? defaultConfig.fileSizeLimit,
|
|
542
|
-
totalSizeLimit: endpointConfig.totalSizeLimit ?? defaultConfig.totalSizeLimit,
|
|
543
|
-
supportedMimeTypes: endpointConfig.supportedMimeTypes ?? defaultMimeTypes,
|
|
544
|
-
};
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
export function getEndpointFileConfig(params: {
|
|
548
|
-
fileConfig?: FileConfig | null;
|
|
549
|
-
endpoint?: string | null;
|
|
550
|
-
endpointType?: string | null;
|
|
551
|
-
}): EndpointFileConfig {
|
|
552
|
-
const { fileConfig: mergedFileConfig, endpoint, endpointType } = params;
|
|
553
|
-
|
|
554
|
-
if (!mergedFileConfig?.endpoints) {
|
|
555
|
-
return fileConfig.endpoints.default;
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
/** Compute an effective default by merging user-configured default over the base default */
|
|
559
|
-
const baseDefaultConfig = fileConfig.endpoints.default;
|
|
560
|
-
const userDefaultConfig = mergedFileConfig.endpoints.default;
|
|
561
|
-
const defaultConfig = userDefaultConfig
|
|
562
|
-
? mergeWithDefault(userDefaultConfig, baseDefaultConfig, 'default')
|
|
563
|
-
: baseDefaultConfig;
|
|
564
|
-
|
|
565
|
-
const normalizedEndpoint = normalizeEndpointName(endpoint ?? '');
|
|
566
|
-
const standardEndpoints = new Set([
|
|
567
|
-
'default',
|
|
568
|
-
EModelEndpoint.agents,
|
|
569
|
-
EModelEndpoint.assistants,
|
|
570
|
-
EModelEndpoint.azureAssistants,
|
|
571
|
-
EModelEndpoint.openAI,
|
|
572
|
-
EModelEndpoint.azureOpenAI,
|
|
573
|
-
EModelEndpoint.anthropic,
|
|
574
|
-
EModelEndpoint.google,
|
|
575
|
-
EModelEndpoint.bedrock,
|
|
576
|
-
]);
|
|
577
|
-
|
|
578
|
-
const normalizedEndpointType = normalizeEndpointName(endpointType ?? '');
|
|
579
|
-
const isCustomEndpoint =
|
|
580
|
-
endpointType === EModelEndpoint.custom ||
|
|
581
|
-
(!standardEndpoints.has(normalizedEndpointType) &&
|
|
582
|
-
normalizedEndpoint &&
|
|
583
|
-
!standardEndpoints.has(normalizedEndpoint));
|
|
584
|
-
|
|
585
|
-
if (isCustomEndpoint) {
|
|
586
|
-
/** 1. Check direct endpoint lookup (could be normalized or not) */
|
|
587
|
-
if (endpoint && mergedFileConfig.endpoints[endpoint]) {
|
|
588
|
-
return mergeWithDefault(mergedFileConfig.endpoints[endpoint], defaultConfig, endpoint);
|
|
589
|
-
}
|
|
590
|
-
/** 2. Check normalized endpoint lookup (skip standard endpoint keys) */
|
|
591
|
-
for (const key in mergedFileConfig.endpoints) {
|
|
592
|
-
if (!standardEndpoints.has(key) && normalizeEndpointName(key) === normalizedEndpoint) {
|
|
593
|
-
return mergeWithDefault(mergedFileConfig.endpoints[key], defaultConfig, key);
|
|
594
|
-
}
|
|
595
|
-
}
|
|
596
|
-
/** 3. Fallback to generic 'custom' config if any */
|
|
597
|
-
if (mergedFileConfig.endpoints[EModelEndpoint.custom]) {
|
|
598
|
-
return mergeWithDefault(
|
|
599
|
-
mergedFileConfig.endpoints[EModelEndpoint.custom],
|
|
600
|
-
defaultConfig,
|
|
601
|
-
endpoint,
|
|
602
|
-
);
|
|
603
|
-
}
|
|
604
|
-
/** 4. Fallback to 'agents' (all custom endpoints are non-assistants) */
|
|
605
|
-
if (mergedFileConfig.endpoints[EModelEndpoint.agents]) {
|
|
606
|
-
return mergeWithDefault(
|
|
607
|
-
mergedFileConfig.endpoints[EModelEndpoint.agents],
|
|
608
|
-
defaultConfig,
|
|
609
|
-
endpoint,
|
|
610
|
-
);
|
|
611
|
-
}
|
|
612
|
-
/** 5. Fallback to default */
|
|
613
|
-
return defaultConfig;
|
|
614
|
-
}
|
|
615
|
-
|
|
616
|
-
/** Check endpointType first (most reliable for standard endpoints) */
|
|
617
|
-
if (endpointType && mergedFileConfig.endpoints[endpointType]) {
|
|
618
|
-
return mergeWithDefault(mergedFileConfig.endpoints[endpointType], defaultConfig, endpointType);
|
|
619
|
-
}
|
|
620
|
-
|
|
621
|
-
/** Check direct endpoint lookup */
|
|
622
|
-
if (endpoint && mergedFileConfig.endpoints[endpoint]) {
|
|
623
|
-
return mergeWithDefault(mergedFileConfig.endpoints[endpoint], defaultConfig, endpoint);
|
|
624
|
-
}
|
|
625
|
-
|
|
626
|
-
/** Check normalized endpoint */
|
|
627
|
-
if (normalizedEndpoint && mergedFileConfig.endpoints[normalizedEndpoint]) {
|
|
628
|
-
return mergeWithDefault(
|
|
629
|
-
mergedFileConfig.endpoints[normalizedEndpoint],
|
|
630
|
-
defaultConfig,
|
|
631
|
-
normalizedEndpoint,
|
|
632
|
-
);
|
|
633
|
-
}
|
|
634
|
-
|
|
635
|
-
/** Fallback to agents if endpoint is explicitly agents */
|
|
636
|
-
const isAgents = isAgentsEndpoint(normalizedEndpointType || normalizedEndpoint);
|
|
637
|
-
if (isAgents && mergedFileConfig.endpoints[EModelEndpoint.agents]) {
|
|
638
|
-
return mergeWithDefault(
|
|
639
|
-
mergedFileConfig.endpoints[EModelEndpoint.agents],
|
|
640
|
-
defaultConfig,
|
|
641
|
-
EModelEndpoint.agents,
|
|
642
|
-
);
|
|
643
|
-
}
|
|
644
|
-
|
|
645
|
-
/** Return default config */
|
|
646
|
-
return defaultConfig;
|
|
647
|
-
}
|
|
648
|
-
|
|
649
|
-
export function mergeFileConfig(dynamic: z.infer<typeof fileConfigSchema> | undefined): FileConfig {
|
|
650
|
-
const mergedConfig: FileConfig = {
|
|
651
|
-
...fileConfig,
|
|
652
|
-
endpoints: {
|
|
653
|
-
...fileConfig.endpoints,
|
|
654
|
-
},
|
|
655
|
-
ocr: {
|
|
656
|
-
...fileConfig.ocr,
|
|
657
|
-
supportedMimeTypes: fileConfig.ocr?.supportedMimeTypes || [],
|
|
658
|
-
},
|
|
659
|
-
text: {
|
|
660
|
-
...fileConfig.text,
|
|
661
|
-
supportedMimeTypes: fileConfig.text?.supportedMimeTypes || [],
|
|
662
|
-
},
|
|
663
|
-
stt: {
|
|
664
|
-
...fileConfig.stt,
|
|
665
|
-
supportedMimeTypes: fileConfig.stt?.supportedMimeTypes || [],
|
|
666
|
-
},
|
|
667
|
-
};
|
|
668
|
-
if (!dynamic) {
|
|
669
|
-
return mergedConfig;
|
|
670
|
-
}
|
|
671
|
-
|
|
672
|
-
if (dynamic.serverFileSizeLimit !== undefined) {
|
|
673
|
-
mergedConfig.serverFileSizeLimit = mbToBytes(dynamic.serverFileSizeLimit);
|
|
674
|
-
}
|
|
675
|
-
|
|
676
|
-
if (dynamic.avatarSizeLimit !== undefined) {
|
|
677
|
-
mergedConfig.avatarSizeLimit = mbToBytes(dynamic.avatarSizeLimit);
|
|
678
|
-
}
|
|
679
|
-
|
|
680
|
-
if (dynamic.fileTokenLimit !== undefined) {
|
|
681
|
-
mergedConfig.fileTokenLimit = dynamic.fileTokenLimit;
|
|
682
|
-
}
|
|
683
|
-
|
|
684
|
-
// Merge clientImageResize configuration
|
|
685
|
-
if (dynamic.clientImageResize !== undefined) {
|
|
686
|
-
mergedConfig.clientImageResize = {
|
|
687
|
-
...mergedConfig.clientImageResize,
|
|
688
|
-
...dynamic.clientImageResize,
|
|
689
|
-
};
|
|
690
|
-
}
|
|
691
|
-
|
|
692
|
-
if (dynamic.ocr !== undefined) {
|
|
693
|
-
mergedConfig.ocr = {
|
|
694
|
-
...mergedConfig.ocr,
|
|
695
|
-
...dynamic.ocr,
|
|
696
|
-
};
|
|
697
|
-
if (dynamic.ocr.supportedMimeTypes) {
|
|
698
|
-
mergedConfig.ocr.supportedMimeTypes = convertStringsToRegex(dynamic.ocr.supportedMimeTypes);
|
|
699
|
-
}
|
|
700
|
-
}
|
|
701
|
-
|
|
702
|
-
if (dynamic.text !== undefined) {
|
|
703
|
-
mergedConfig.text = {
|
|
704
|
-
...mergedConfig.text,
|
|
705
|
-
...dynamic.text,
|
|
706
|
-
};
|
|
707
|
-
if (dynamic.text.supportedMimeTypes) {
|
|
708
|
-
mergedConfig.text.supportedMimeTypes = convertStringsToRegex(dynamic.text.supportedMimeTypes);
|
|
709
|
-
}
|
|
710
|
-
}
|
|
711
|
-
|
|
712
|
-
if (!dynamic.endpoints) {
|
|
713
|
-
return mergedConfig;
|
|
714
|
-
}
|
|
715
|
-
|
|
716
|
-
for (const key in dynamic.endpoints) {
|
|
717
|
-
const dynamicEndpoint = (dynamic.endpoints as Record<string, EndpointFileConfig>)[key];
|
|
718
|
-
|
|
719
|
-
/** Deep copy the base endpoint config if it exists to prevent mutation */
|
|
720
|
-
if (!mergedConfig.endpoints[key]) {
|
|
721
|
-
mergedConfig.endpoints[key] = {};
|
|
722
|
-
} else {
|
|
723
|
-
mergedConfig.endpoints[key] = { ...mergedConfig.endpoints[key] };
|
|
724
|
-
}
|
|
725
|
-
|
|
726
|
-
const mergedEndpoint = mergedConfig.endpoints[key];
|
|
727
|
-
|
|
728
|
-
if (dynamicEndpoint.disabled === true) {
|
|
729
|
-
mergedEndpoint.disabled = true;
|
|
730
|
-
mergedEndpoint.fileLimit = 0;
|
|
731
|
-
mergedEndpoint.fileSizeLimit = 0;
|
|
732
|
-
mergedEndpoint.totalSizeLimit = 0;
|
|
733
|
-
mergedEndpoint.supportedMimeTypes = [];
|
|
734
|
-
continue;
|
|
735
|
-
}
|
|
736
|
-
|
|
737
|
-
if (dynamicEndpoint.fileSizeLimit !== undefined) {
|
|
738
|
-
mergedEndpoint.fileSizeLimit = mbToBytes(dynamicEndpoint.fileSizeLimit);
|
|
739
|
-
}
|
|
740
|
-
|
|
741
|
-
if (dynamicEndpoint.totalSizeLimit !== undefined) {
|
|
742
|
-
mergedEndpoint.totalSizeLimit = mbToBytes(dynamicEndpoint.totalSizeLimit);
|
|
743
|
-
}
|
|
744
|
-
|
|
745
|
-
const configKeys = ['fileLimit'] as const;
|
|
746
|
-
configKeys.forEach((field) => {
|
|
747
|
-
if (dynamicEndpoint[field] !== undefined) {
|
|
748
|
-
mergedEndpoint[field] = dynamicEndpoint[field];
|
|
749
|
-
}
|
|
750
|
-
});
|
|
751
|
-
|
|
752
|
-
if (dynamicEndpoint.disabled !== undefined) {
|
|
753
|
-
mergedEndpoint.disabled = dynamicEndpoint.disabled;
|
|
754
|
-
}
|
|
755
|
-
|
|
756
|
-
if (dynamicEndpoint.supportedMimeTypes) {
|
|
757
|
-
mergedEndpoint.supportedMimeTypes = convertStringsToRegex(
|
|
758
|
-
dynamicEndpoint.supportedMimeTypes as unknown as string[],
|
|
759
|
-
);
|
|
760
|
-
}
|
|
761
|
-
}
|
|
762
|
-
|
|
763
|
-
return mergedConfig;
|
|
764
|
-
}
|