@eka-care/medassist-core 1.0.4 → 1.0.5
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.
|
@@ -44,6 +44,12 @@ export declare class Filemanager {
|
|
|
44
44
|
* @returns string - the file name to use for upload
|
|
45
45
|
*/
|
|
46
46
|
getUploadFileName(): string;
|
|
47
|
+
/**
|
|
48
|
+
* Validate file types
|
|
49
|
+
* @param file The file to validate
|
|
50
|
+
* @returns boolean - true if file type is supported
|
|
51
|
+
*/
|
|
52
|
+
validateFileType(file: File): boolean;
|
|
47
53
|
/**
|
|
48
54
|
* Clears the pending files
|
|
49
55
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"File.d.ts","sourceRoot":"","sources":["../../../src/media/file/File.ts"],"names":[],"mappings":"AAMA,qBAAa,WAAW;IACtB,OAAO,CAAC,YAAY,CAAc;IAClC,OAAO,CAAC,cAAc,CAAC,CAAc;IACrC,OAAO,CAAC,aAAa,CAAc;IAEnC;;OAEG;IACI,iBAAiB,
|
|
1
|
+
{"version":3,"file":"File.d.ts","sourceRoot":"","sources":["../../../src/media/file/File.ts"],"names":[],"mappings":"AAMA,qBAAa,WAAW;IACtB,OAAO,CAAC,YAAY,CAAc;IAClC,OAAO,CAAC,cAAc,CAAC,CAAc;IACrC,OAAO,CAAC,aAAa,CAAc;IAEnC;;OAEG;IACI,iBAAiB,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI;IAkB/D;;OAEG;IAEI,mBAAmB,IAAI;QAC5B,KAAK,EAAE,IAAI,EAAE,CAAC;QACd,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;KAChB;IAQD;;OAEG;IACU,yBAAyB,CACpC,aAAa,EAAE,MAAM,EAAE,GACtB,OAAO,CAAC,MAAM,CAAC;IA2ElB;;;;;OAKG;IACU,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IActC;;;;;OAKG;IACI,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI;IAIrD;;;;OAIG;IACI,cAAc,IAAI,OAAO;IAIhC;;;;OAIG;IACI,iBAAiB,IAAI,MAAM;IAOlC;;;;OAIG;IACI,gBAAgB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO;IAgB5C;;OAEG;IACI,sBAAsB,IAAI,IAAI;CAKtC"}
|
package/dist/media/file/File.js
CHANGED
|
@@ -21,12 +21,18 @@ class Filemanager {
|
|
|
21
21
|
if (this.pendingFiles.length > 0) {
|
|
22
22
|
this.clearPendingFilesState();
|
|
23
23
|
}
|
|
24
|
-
|
|
24
|
+
const validFiles = files.filter((file) => this.validateFileType(file));
|
|
25
|
+
if (validFiles.length === 0) {
|
|
26
|
+
throw new Error_1.FileError("No valid files provided", {
|
|
27
|
+
context: { stage: "setFilesForUpload" },
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
this.pendingFiles = validFiles;
|
|
25
31
|
if (message && message.trim()) {
|
|
26
32
|
this.pendingMessage = message;
|
|
27
33
|
}
|
|
28
34
|
this.pendingFormat =
|
|
29
|
-
|
|
35
|
+
validFiles.length > 1 ? "zip" : validFiles?.[0]?.type?.split("/")?.[1] || "unknown";
|
|
30
36
|
}
|
|
31
37
|
/**
|
|
32
38
|
* Get the pending file state
|
|
@@ -143,6 +149,26 @@ class Filemanager {
|
|
|
143
149
|
}
|
|
144
150
|
return this.pendingFiles[0]?.name || "file";
|
|
145
151
|
}
|
|
152
|
+
/**
|
|
153
|
+
* Validate file types
|
|
154
|
+
* @param file The file to validate
|
|
155
|
+
* @returns boolean - true if file type is supported
|
|
156
|
+
*/
|
|
157
|
+
validateFileType(file) {
|
|
158
|
+
const validFormats = [
|
|
159
|
+
"application/pdf",
|
|
160
|
+
"image/jpeg",
|
|
161
|
+
"image/png",
|
|
162
|
+
"image/jpg",
|
|
163
|
+
"image/tiff",
|
|
164
|
+
"text/plain",
|
|
165
|
+
"text/markdown",
|
|
166
|
+
"image/heif",
|
|
167
|
+
"image/heic",
|
|
168
|
+
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
169
|
+
];
|
|
170
|
+
return validFormats.includes(file.type);
|
|
171
|
+
}
|
|
146
172
|
/**
|
|
147
173
|
* Clears the pending files
|
|
148
174
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eka-care/medassist-core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "TypeScript SDK for real-time medical chatbot experiences with session management, WebSocket connectivity, and media handling",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|