Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Fraggle committed Jan 15, 2025
1 parent 106a475 commit e20930c
Show file tree
Hide file tree
Showing 24 changed files with 3,219 additions and 2,716 deletions.
25 changes: 24 additions & 1 deletion .github/workflows/build-and-lint-front.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ on:
- sdks/js/**
- front/**
- .github/workflows/build-and-lint-front.yml

permissions:
contents: read
actions: read
checks: write
jobs:
check-eslint:
runs-on: ubuntu-latest
Expand All @@ -24,3 +27,23 @@ jobs:
run: npm install && npm run build
- working-directory: front
run: npm install && npm run tsc && npm run lint && npm run format:check && npm run docs:check
- name: Install Postgres
uses: CasperWA/postgresql-action@v1.2
with:
postgresql version: "14.13" # See https://hub.docker.com/_/postgres for available versions
postgresql db: front_test
postgresql user: test
postgresql password: test
postgresql port: 5433
- name: Run Tests
working-directory: front
env:
FRONT_DATABASE_URI: "postgres://test:test@localhost:5433/front_test"
NODE_ENV: test
run: npx tsx admin/db.ts && npm run test:ci
- name: Tests Report
uses: dorny/test-reporter@v1
with:
name: Front Tests # Name of the check run which will be created
path: junit-*.xml # Path to test results
reporter: jest-junit # Format of test results
11 changes: 0 additions & 11 deletions front/FixJSDOMEnvironment.ts

This file was deleted.

27 changes: 0 additions & 27 deletions front/jest.config.js

This file was deleted.

12 changes: 0 additions & 12 deletions front/jest.setup.js

This file was deleted.

1 change: 1 addition & 0 deletions front/lib/api/files/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ const getProcessingFunction = ({
case "text/calendar":
case "text/css":
case "text/javascript":
case "text/typescript":
case "application/json":
case "application/xml":
case "application/x-sh":
Expand Down
22 changes: 13 additions & 9 deletions front/lib/api/files/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ConversationType, Result } from "@dust-tt/types";
import { Err, Ok, removeNulls } from "@dust-tt/types";
import { contentTypeForExtension, Err, Ok, removeNulls } from "@dust-tt/types";
import type { File } from "formidable";
import { IncomingForm } from "formidable";
import type { IncomingMessage } from "http";
Expand Down Expand Up @@ -41,15 +41,19 @@ export const parseUploadRequest = async (

// Ensure the file is of the correct type.
filter: function (part) {
if (file.contentType === "text/markdown") {
// some setups do not detect the markdown type and return a content type of application/octet-stream
return (
part.mimetype !== null &&
["text/markdown", "application/octet-stream"].includes(
part.mimetype
)
);
if (
part.mimetype != file.contentType &&
part.mimetype == "application/octet-stream"
) {
const fileExtension = file.fileName.split(".").at(-1)?.toLowerCase();
if (fileExtension) {
// Lookup by extension
return (
contentTypeForExtension("." + fileExtension) === file.contentType
);
}
}

return part.mimetype === file.contentType;
},
});
Expand Down
18 changes: 6 additions & 12 deletions front/lib/file.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
// These are the front-end helpers.

function isMarkdownFile(file: File): boolean {
if (file.type === "") {
const fileExtension = file.name.split(".").at(-1)?.toLowerCase();
// Check if the file extension corresponds to a markdown file
return fileExtension === "md" || fileExtension === "markdown";
}
return file.type === "text/markdown";
}
import { contentTypeForExtension } from "@dust-tt/types";

export function getMimeTypeFromFile(file: File): string {
if (isMarkdownFile(file)) {
return "text/markdown";
const fileExtension = file.name.split(".").at(-1)?.toLowerCase();

if (!file.type && fileExtension) {
// Lookup by extension
return contentTypeForExtension("." + fileExtension) ?? "";
}

return file.type;
Expand Down
Loading

0 comments on commit e20930c

Please sign in to comment.