Skip to content

Commit f8cdd50

Browse files
committed
feat(web): replace document and blob nodes with file upload node
1 parent 385695f commit f8cdd50

9 files changed

Lines changed: 259 additions & 512 deletions

File tree

apps/api/src/nodes/blob/blob-node.ts

Lines changed: 0 additions & 56 deletions
This file was deleted.
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import { NodeExecution, NodeType } from "@dafthunk/types";
2+
3+
import { ExecutableNode } from "../types";
4+
import { NodeContext } from "../types";
5+
6+
/**
7+
* File node implementation
8+
* This node provides a generic file widget that allows users to upload any file type
9+
* and outputs them as file references (blob type).
10+
* It serves as a unified replacement for the blob and document nodes.
11+
*/
12+
export class FileNode extends ExecutableNode {
13+
public static readonly nodeType: NodeType = {
14+
id: "file",
15+
name: "File Upload",
16+
type: "file",
17+
description: "A generic file widget for uploading any file type",
18+
tags: ["Widget", "File", "Load", "Upload"],
19+
icon: "file",
20+
documentation:
21+
"This node provides a generic file widget for uploading any file type and outputs them as file references. It supports images, audio, documents, and any other file format. The output type is 'blob' but can connect to nodes expecting specific types (image, audio, document, etc.) due to MIME type compatibility.",
22+
inputs: [
23+
{
24+
name: "value",
25+
type: "blob",
26+
description: "Current file as a blob reference",
27+
hidden: true,
28+
},
29+
],
30+
outputs: [
31+
{
32+
name: "file",
33+
type: "blob",
34+
description: "The uploaded file as a blob reference",
35+
},
36+
],
37+
};
38+
39+
async execute(context: NodeContext): Promise<NodeExecution> {
40+
try {
41+
const { value } = context.inputs;
42+
43+
// If no value is provided, fail
44+
if (!value) {
45+
return this.createErrorResult("No file data provided");
46+
}
47+
48+
// Return the file as a blob reference
49+
return this.createSuccessResult({
50+
file: value,
51+
});
52+
} catch (error) {
53+
return this.createErrorResult(
54+
error instanceof Error ? error.message : "Unknown error"
55+
);
56+
}
57+
}
58+
}

apps/api/src/nodes/cloudflare-node-registry.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { WhisperLargeV3TurboNode } from "./audio/whisper-large-v3-turbo-node";
1919
import { WhisperNode } from "./audio/whisper-node";
2020
import { WhisperTinyEnNode } from "./audio/whisper-tiny-en-node";
2121
import { BaseNodeRegistry } from "./base-node-registry";
22-
import { BlobNode } from "./blob/blob-node";
22+
import { FileNode } from "./blob/file-node";
2323
import { CloudflareBrowserContentNode } from "./browser/cloudflare-browser-content-node";
2424
import { CloudflareBrowserJsonNode } from "./browser/cloudflare-browser-json-node";
2525
import { CloudflareBrowserLinksNode } from "./browser/cloudflare-browser-links-node";
@@ -39,7 +39,6 @@ import { ListGuildChannelsDiscordNode } from "./discord/list-guild-channels-disc
3939
import { ListUserGuildsDiscordNode } from "./discord/list-user-guilds-discord-node";
4040
import { SendDMDiscordNode } from "./discord/send-dm-discord-node";
4141
import { SendMessageDiscordNode } from "./discord/send-message-discord-node";
42-
import { DocumentNode } from "./document/document-node";
4342
import { ToMarkdownNode } from "./document/to-markdown-node";
4443
import { ParseEmailNode } from "./email/parse-email-node";
4544
import { ReceiveEmailNode } from "./email/receive-email-node";
@@ -518,8 +517,7 @@ export class CloudflareNodeRegistry extends BaseNodeRegistry {
518517

519518
this.registerImplementation(AudioRecorderNode);
520519
this.registerImplementation(ToMarkdownNode);
521-
this.registerImplementation(BlobNode);
522-
this.registerImplementation(DocumentNode);
520+
this.registerImplementation(FileNode);
523521
this.registerImplementation(HttpRequestNode);
524522

525523
// Conditional registrations based on environment

apps/api/src/nodes/document/document-node.test.ts

Lines changed: 0 additions & 139 deletions
This file was deleted.

apps/api/src/nodes/document/document-node.ts

Lines changed: 0 additions & 56 deletions
This file was deleted.

0 commit comments

Comments
 (0)