@rljson/bs 0.0.18 → 0.0.19

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.
@@ -0,0 +1,77 @@
1
+ import { BlobProperties, Bs, DownloadBlobOptions, ListBlobsOptions, ListBlobsResult } from './bs.ts';
2
+ import { Socket } from './socket.ts';
3
+ /**
4
+ * Peer implementation of the Bs interface that communicates over a socket.
5
+ * Allows remote access to a blob storage instance.
6
+ */
7
+ export declare class BsPeer implements Bs {
8
+ private _socket;
9
+ isOpen: boolean;
10
+ constructor(_socket: Socket);
11
+ /**
12
+ * Initializes the Peer connection.
13
+ */
14
+ init(): Promise<void>;
15
+ /**
16
+ * Closes the Peer connection.
17
+ */
18
+ close(): Promise<void>;
19
+ /**
20
+ * Returns a promise that resolves once the Peer connection is ready.
21
+ */
22
+ isReady(): Promise<void>;
23
+ /**
24
+ * Stores a blob from Buffer, string, or ReadableStream and returns properties.
25
+ * @param content - The blob content to store
26
+ * @returns Promise resolving to blob properties
27
+ */
28
+ setBlob(content: Buffer | string | ReadableStream<Uint8Array>): Promise<BlobProperties>;
29
+ /**
30
+ * Retrieves a blob by its ID as a Buffer.
31
+ * @param blobId - The unique identifier of the blob
32
+ * @param options - Download options
33
+ * @returns Promise resolving to blob content and properties
34
+ */
35
+ getBlob(blobId: string, options?: DownloadBlobOptions): Promise<{
36
+ content: Buffer;
37
+ properties: BlobProperties;
38
+ }>;
39
+ /**
40
+ * Retrieves a blob by its ID as a ReadableStream.
41
+ * @param blobId - The unique identifier of the blob
42
+ * @returns Promise resolving to readable stream
43
+ */
44
+ getBlobStream(blobId: string): Promise<ReadableStream<Uint8Array>>;
45
+ /**
46
+ * Deletes a blob by its ID.
47
+ * @param blobId - The unique identifier of the blob
48
+ * @returns Promise that resolves when deletion is complete
49
+ */
50
+ deleteBlob(blobId: string): Promise<void>;
51
+ /**
52
+ * Checks if a blob exists.
53
+ * @param blobId - The unique identifier of the blob
54
+ * @returns Promise resolving to true if blob exists
55
+ */
56
+ blobExists(blobId: string): Promise<boolean>;
57
+ /**
58
+ * Gets blob properties (size, createdAt) without retrieving content.
59
+ * @param blobId - The unique identifier of the blob
60
+ * @returns Promise resolving to blob properties
61
+ */
62
+ getBlobProperties(blobId: string): Promise<BlobProperties>;
63
+ /**
64
+ * Lists all blobs with optional filtering and pagination.
65
+ * @param options - Optional listing configuration
66
+ * @returns Promise resolving to list of blobs
67
+ */
68
+ listBlobs(options?: ListBlobsOptions): Promise<ListBlobsResult>;
69
+ /**
70
+ * Generates a signed URL for temporary blob access.
71
+ * @param blobId - The unique identifier of the blob
72
+ * @param expiresIn - Expiration time in seconds
73
+ * @param permissions - Permissions for the URL
74
+ * @returns Promise resolving to signed URL
75
+ */
76
+ generateSignedUrl(blobId: string, expiresIn: number, permissions?: 'read' | 'delete'): Promise<string>;
77
+ }
@@ -0,0 +1,32 @@
1
+ import { Bs } from './bs.ts';
2
+ import { Socket } from './socket.ts';
3
+ /**
4
+ * Server implementation that exposes a Bs instance over socket connections.
5
+ * Allows multiple clients to access the same blob storage instance remotely.
6
+ */
7
+ export declare class BsServer {
8
+ private readonly _bs;
9
+ private _sockets;
10
+ constructor(_bs: Bs);
11
+ /**
12
+ * Adds a socket to the BsServer instance.
13
+ * @param socket - The socket to add.
14
+ */
15
+ addSocket(socket: Socket): Promise<void>;
16
+ /**
17
+ * Removes a socket from the BsServer instance.
18
+ * @param socket - The socket to remove.
19
+ */
20
+ removeSocket(socket: Socket): void;
21
+ /**
22
+ * Adds a transport layer to the given socket.
23
+ * @param socket - The socket to add the transport layer to.
24
+ */
25
+ private _addTransportLayer;
26
+ /**
27
+ * Generates a transport layer object for the given Bs instance.
28
+ * @param bs - The Bs instance to generate the transport layer for.
29
+ * @returns An object containing methods that correspond to the Bs interface.
30
+ */
31
+ private _generateTransportLayer;
32
+ }