alepha 0.10.4 → 0.10.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -19
- package/api/files.d.ts +43 -45
- package/api/jobs.d.ts +166 -168
- package/api/users.d.ts +219 -218
- package/bucket.d.ts +81 -4
- package/devtools.d.ts +247 -247
- package/package.json +47 -47
- package/postgres.d.ts +31 -11
- package/react/auth.d.ts +5 -0
- package/react.d.ts +26 -26
- package/server/links.d.ts +29 -29
package/bucket.d.ts
CHANGED
|
@@ -561,11 +561,88 @@ declare class FileNotFoundError extends AlephaError {
|
|
|
561
561
|
readonly status = 404;
|
|
562
562
|
}
|
|
563
563
|
//#endregion
|
|
564
|
+
//#region src/services/FileMetadataService.d.ts
|
|
565
|
+
interface FileMetadata {
|
|
566
|
+
name: string;
|
|
567
|
+
type: string;
|
|
568
|
+
}
|
|
569
|
+
/**
|
|
570
|
+
* Service for encoding/decoding file metadata in storage streams.
|
|
571
|
+
*
|
|
572
|
+
* The metadata is stored at the beginning of the file with the following structure:
|
|
573
|
+
* - 4-byte header: UInt32BE containing the metadata length
|
|
574
|
+
* - N-byte metadata: JSON object containing file metadata (name, type)
|
|
575
|
+
* - Remaining bytes: Actual file content
|
|
576
|
+
*
|
|
577
|
+
* @example
|
|
578
|
+
* ```typescript
|
|
579
|
+
* const service = new FileMetadataService();
|
|
580
|
+
*
|
|
581
|
+
* // Encode metadata and content for storage
|
|
582
|
+
* const { header, metadata } = service.encodeMetadata({
|
|
583
|
+
* name: "document.pdf",
|
|
584
|
+
* type: "application/pdf"
|
|
585
|
+
* });
|
|
586
|
+
*
|
|
587
|
+
* // Decode metadata from stored file
|
|
588
|
+
* const fileHandle = await open(filePath, 'r');
|
|
589
|
+
* const { metadata, contentStart } = await service.decodeMetadata(fileHandle);
|
|
590
|
+
* ```
|
|
591
|
+
*/
|
|
592
|
+
declare class FileMetadataService {
|
|
593
|
+
/**
|
|
594
|
+
* Length of the header containing metadata size (4 bytes for UInt32BE)
|
|
595
|
+
*/
|
|
596
|
+
static readonly METADATA_HEADER_LENGTH = 4;
|
|
597
|
+
/**
|
|
598
|
+
* Encodes file metadata into header and metadata buffers.
|
|
599
|
+
*
|
|
600
|
+
* @param file - The file or metadata to encode
|
|
601
|
+
* @returns Object containing the header buffer and metadata buffer
|
|
602
|
+
*/
|
|
603
|
+
encodeMetadata(file: FileLike | FileMetadata): {
|
|
604
|
+
header: Buffer;
|
|
605
|
+
metadata: Buffer;
|
|
606
|
+
};
|
|
607
|
+
/**
|
|
608
|
+
* Decodes file metadata from a file handle.
|
|
609
|
+
*
|
|
610
|
+
* @param fileHandle - File handle opened for reading
|
|
611
|
+
* @returns Object containing the decoded metadata and content start position
|
|
612
|
+
*/
|
|
613
|
+
decodeMetadata(fileHandle: {
|
|
614
|
+
read: (buffer: Buffer, offset: number, length: number, position: number) => Promise<{
|
|
615
|
+
bytesRead: number;
|
|
616
|
+
}>;
|
|
617
|
+
}): Promise<{
|
|
618
|
+
metadata: FileMetadata;
|
|
619
|
+
contentStart: number;
|
|
620
|
+
}>;
|
|
621
|
+
/**
|
|
622
|
+
* Decodes file metadata from a buffer.
|
|
623
|
+
*
|
|
624
|
+
* @param buffer - Buffer containing the file with metadata
|
|
625
|
+
* @returns Object containing the decoded metadata and content start position
|
|
626
|
+
*/
|
|
627
|
+
decodeMetadataFromBuffer(buffer: Buffer): {
|
|
628
|
+
metadata: FileMetadata;
|
|
629
|
+
contentStart: number;
|
|
630
|
+
};
|
|
631
|
+
/**
|
|
632
|
+
* Creates a complete buffer with metadata header, metadata, and content.
|
|
633
|
+
*
|
|
634
|
+
* @param file - The file to encode
|
|
635
|
+
* @param content - The file content as a buffer
|
|
636
|
+
* @returns Complete buffer ready for storage
|
|
637
|
+
*/
|
|
638
|
+
createFileBuffer(file: FileLike | FileMetadata, content: Buffer): Buffer;
|
|
639
|
+
}
|
|
640
|
+
//#endregion
|
|
564
641
|
//#region src/providers/LocalFileStorageProvider.d.ts
|
|
565
642
|
declare class LocalFileStorageProvider implements FileStorageProvider {
|
|
566
|
-
static METADATA_HEADER_LENGTH: number;
|
|
567
643
|
protected readonly alepha: Alepha;
|
|
568
644
|
protected readonly log: _alepha_logger0.Logger;
|
|
645
|
+
protected readonly metadataService: FileMetadataService;
|
|
569
646
|
options: {
|
|
570
647
|
storagePath: string;
|
|
571
648
|
};
|
|
@@ -574,9 +651,9 @@ declare class LocalFileStorageProvider implements FileStorageProvider {
|
|
|
574
651
|
download(bucketName: string, fileId: string): Promise<FileLike>;
|
|
575
652
|
exists(bucketName: string, fileId: string): Promise<boolean>;
|
|
576
653
|
delete(bucketName: string, fileId: string): Promise<void>;
|
|
577
|
-
protected stat(
|
|
654
|
+
protected stat(bucket: string, fileId: string): Promise<fs.Stats>;
|
|
578
655
|
protected createId(): string;
|
|
579
|
-
protected path(
|
|
656
|
+
protected path(bucket: string, fileId?: string): string;
|
|
580
657
|
protected isErrorNoEntry(error: unknown): boolean;
|
|
581
658
|
}
|
|
582
659
|
declare const fileMetadataSchema: typebox0.TObject<{
|
|
@@ -620,5 +697,5 @@ declare module "alepha" {
|
|
|
620
697
|
*/
|
|
621
698
|
declare const AlephaBucket: _alepha_core1.Service<_alepha_core1.Module<{}>>;
|
|
622
699
|
//#endregion
|
|
623
|
-
export { $bucket, AlephaBucket, BucketDescriptor, BucketDescriptorOptions, BucketFileOptions, FileNotFoundError, FileStorageProvider, LocalFileStorageProvider, MemoryFileStorageProvider, fileMetadataSchema };
|
|
700
|
+
export { $bucket, AlephaBucket, BucketDescriptor, BucketDescriptorOptions, BucketFileOptions, FileMetadata, FileMetadataService, FileNotFoundError, FileStorageProvider, LocalFileStorageProvider, MemoryFileStorageProvider, fileMetadataSchema };
|
|
624
701
|
//# sourceMappingURL=index.d.ts.map
|