resolved type errors and other proc. app build error
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "tsx watch src/index.ts",
|
"dev": "tsx watch src/index.ts",
|
||||||
"build": "tsc",
|
"build": "tsc",
|
||||||
"prod": "tsc && node dist/index.js"
|
"prod": "node dist/index.js"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@opentelemetry/api": "^1.9.0",
|
"@opentelemetry/api": "^1.9.0",
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ RUN pnpm install
|
|||||||
COPY apps/processor ./apps/processor
|
COPY apps/processor ./apps/processor
|
||||||
|
|
||||||
RUN pnpm install
|
RUN pnpm install
|
||||||
|
RUN pnpm run build
|
||||||
|
|
||||||
COPY scripts ./scripts
|
COPY scripts ./scripts
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import {
|
|||||||
GetObjectCommand,
|
GetObjectCommand,
|
||||||
HeadObjectCommand,
|
HeadObjectCommand,
|
||||||
ListObjectsV2Command,
|
ListObjectsV2Command,
|
||||||
|
type ListObjectsV2CommandOutput,
|
||||||
PutObjectCommand,
|
PutObjectCommand,
|
||||||
S3Client,
|
S3Client,
|
||||||
} from "@aws-sdk/client-s3";
|
} from "@aws-sdk/client-s3";
|
||||||
@@ -493,13 +494,14 @@ export class R2StorageClient {
|
|||||||
let continuationToken: string | undefined = undefined;
|
let continuationToken: string | undefined = undefined;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
const command = new ListObjectsV2Command({
|
const command: ListObjectsV2Command = new ListObjectsV2Command({
|
||||||
Bucket: this.config.bucketName,
|
Bucket: this.config.bucketName,
|
||||||
Prefix: prefix,
|
Prefix: prefix,
|
||||||
ContinuationToken: continuationToken,
|
ContinuationToken: continuationToken,
|
||||||
});
|
});
|
||||||
|
|
||||||
const response = await this.s3Client.send(command);
|
const response: ListObjectsV2CommandOutput =
|
||||||
|
await this.s3Client.send(command);
|
||||||
const pageKeys =
|
const pageKeys =
|
||||||
response.Contents?.map((item) => item.Key).filter(
|
response.Contents?.map((item) => item.Key).filter(
|
||||||
(key): key is string => Boolean(key),
|
(key): key is string => Boolean(key),
|
||||||
|
|||||||
@@ -108,9 +108,15 @@ export const fileProcessingResultSchema = v.object({
|
|||||||
metadata: v.optional(v.record(v.string(), v.any())),
|
metadata: v.optional(v.record(v.string(), v.any())),
|
||||||
error: v.optional(v.string()),
|
error: v.optional(v.string()),
|
||||||
});
|
});
|
||||||
export type FileProcessingResult = v.InferOutput<
|
export type BinaryFileData = Uint8Array<ArrayBufferLike>;
|
||||||
typeof fileProcessingResultSchema
|
export type FileProcessingResult = {
|
||||||
>;
|
processed: boolean;
|
||||||
|
originalFile?: BinaryFileData;
|
||||||
|
processedFile?: BinaryFileData;
|
||||||
|
thumbnail?: BinaryFileData;
|
||||||
|
metadata?: Record<string, any>;
|
||||||
|
error?: string;
|
||||||
|
};
|
||||||
|
|
||||||
// File Security Result Schema (from utils.ts)
|
// File Security Result Schema (from utils.ts)
|
||||||
export const fileSecurityResultSchema = v.object({
|
export const fileSecurityResultSchema = v.object({
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
import { createHash } from "crypto";
|
import { createHash } from "crypto";
|
||||||
import type { DocumentProcessingOptions, FileProcessingResult } from "../data";
|
import type { DocumentProcessingOptions, FileProcessingResult } from "../data";
|
||||||
|
|
||||||
|
function asByteArray(input: Buffer | Uint8Array): Uint8Array {
|
||||||
|
return Uint8Array.from(input);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process documents (PDF, text files, etc.)
|
* Process documents (PDF, text files, etc.)
|
||||||
*/
|
*/
|
||||||
@@ -78,8 +82,8 @@ async function processPDF(
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
processed: true,
|
processed: true,
|
||||||
originalFile: buffer,
|
originalFile: asByteArray(buffer),
|
||||||
processedFile: buffer, // PDFs typically don't need processing
|
processedFile: asByteArray(buffer), // PDFs typically don't need processing
|
||||||
metadata,
|
metadata,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -108,8 +112,8 @@ async function processTextFile(
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
processed: true,
|
processed: true,
|
||||||
originalFile: buffer,
|
originalFile: asByteArray(buffer),
|
||||||
processedFile: buffer,
|
processedFile: asByteArray(buffer),
|
||||||
metadata,
|
metadata,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -125,8 +129,8 @@ async function processGenericDocument(
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
processed: true,
|
processed: true,
|
||||||
originalFile: buffer,
|
originalFile: asByteArray(buffer),
|
||||||
processedFile: buffer,
|
processedFile: asByteArray(buffer),
|
||||||
metadata,
|
metadata,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -145,9 +145,11 @@ export async function processImage(
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
processed: true,
|
processed: true,
|
||||||
originalFile: inputBuffer,
|
originalFile: Uint8Array.from(inputBuffer),
|
||||||
processedFile: processedBuffer,
|
processedFile: Uint8Array.from(processedBuffer),
|
||||||
thumbnail: thumbnailBuffer,
|
thumbnail: thumbnailBuffer
|
||||||
|
? Uint8Array.from(thumbnailBuffer)
|
||||||
|
: undefined,
|
||||||
metadata,
|
metadata,
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -49,8 +49,8 @@ export async function processVideo(
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
processed: true,
|
processed: true,
|
||||||
originalFile: inputBuffer,
|
originalFile: Uint8Array.from(inputBuffer),
|
||||||
processedFile: inputBuffer, // Videos are typically not re-encoded during upload
|
processedFile: Uint8Array.from(inputBuffer), // Videos are typically not re-encoded during upload
|
||||||
metadata,
|
metadata,
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user