resolved type errors and other proc. app build error
This commit is contained in:
@@ -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),
|
||||
|
||||
@@ -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({
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user