resolved type errors and other proc. app build error

This commit is contained in:
user
2026-03-02 19:23:59 +02:00
parent 6069a16d80
commit be45cc3fa7
7 changed files with 32 additions and 17 deletions

View File

@@ -4,7 +4,7 @@
"scripts": {
"dev": "tsx watch src/index.ts",
"build": "tsc",
"prod": "tsc && node dist/index.js"
"prod": "node dist/index.js"
},
"dependencies": {
"@opentelemetry/api": "^1.9.0",

View File

@@ -17,6 +17,7 @@ RUN pnpm install
COPY apps/processor ./apps/processor
RUN pnpm install
RUN pnpm run build
COPY scripts ./scripts

View File

@@ -4,6 +4,7 @@ import {
GetObjectCommand,
HeadObjectCommand,
ListObjectsV2Command,
type ListObjectsV2CommandOutput,
PutObjectCommand,
S3Client,
} from "@aws-sdk/client-s3";
@@ -493,13 +494,14 @@ export class R2StorageClient {
let continuationToken: string | undefined = undefined;
do {
const command = new ListObjectsV2Command({
const command: ListObjectsV2Command = new ListObjectsV2Command({
Bucket: this.config.bucketName,
Prefix: prefix,
ContinuationToken: continuationToken,
});
const response = await this.s3Client.send(command);
const response: ListObjectsV2CommandOutput =
await this.s3Client.send(command);
const pageKeys =
response.Contents?.map((item) => item.Key).filter(
(key): key is string => Boolean(key),

View File

@@ -108,9 +108,15 @@ export const fileProcessingResultSchema = v.object({
metadata: v.optional(v.record(v.string(), v.any())),
error: v.optional(v.string()),
});
export type FileProcessingResult = v.InferOutput<
typeof fileProcessingResultSchema
>;
export type BinaryFileData = Uint8Array<ArrayBufferLike>;
export type FileProcessingResult = {
processed: boolean;
originalFile?: BinaryFileData;
processedFile?: BinaryFileData;
thumbnail?: BinaryFileData;
metadata?: Record<string, any>;
error?: string;
};
// File Security Result Schema (from utils.ts)
export const fileSecurityResultSchema = v.object({

View File

@@ -1,6 +1,10 @@
import { createHash } from "crypto";
import type { DocumentProcessingOptions, FileProcessingResult } from "../data";
function asByteArray(input: Buffer | Uint8Array): Uint8Array {
return Uint8Array.from(input);
}
/**
* Process documents (PDF, text files, etc.)
*/
@@ -78,8 +82,8 @@ async function processPDF(
return {
processed: true,
originalFile: buffer,
processedFile: buffer, // PDFs typically don't need processing
originalFile: asByteArray(buffer),
processedFile: asByteArray(buffer), // PDFs typically don't need processing
metadata,
};
}
@@ -108,8 +112,8 @@ async function processTextFile(
return {
processed: true,
originalFile: buffer,
processedFile: buffer,
originalFile: asByteArray(buffer),
processedFile: asByteArray(buffer),
metadata,
};
}
@@ -125,8 +129,8 @@ async function processGenericDocument(
return {
processed: true,
originalFile: buffer,
processedFile: buffer,
originalFile: asByteArray(buffer),
processedFile: asByteArray(buffer),
metadata,
};
}

View File

@@ -145,9 +145,11 @@ export async function processImage(
return {
processed: true,
originalFile: inputBuffer,
processedFile: processedBuffer,
thumbnail: thumbnailBuffer,
originalFile: Uint8Array.from(inputBuffer),
processedFile: Uint8Array.from(processedBuffer),
thumbnail: thumbnailBuffer
? Uint8Array.from(thumbnailBuffer)
: undefined,
metadata,
};
} catch (error) {

View File

@@ -49,8 +49,8 @@ export async function processVideo(
return {
processed: true,
originalFile: inputBuffer,
processedFile: inputBuffer, // Videos are typically not re-encoded during upload
originalFile: Uint8Array.from(inputBuffer),
processedFile: Uint8Array.from(inputBuffer), // Videos are typically not re-encoded during upload
metadata,
};
} catch (error) {