Skip to content

Commit 30bd96a

Browse files
committed
improve: Add TailorDB file type definitions
1 parent 770b033 commit 30bd96a

1 file changed

Lines changed: 91 additions & 0 deletions

File tree

packages/types/tailor.d.ts

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,99 @@ declare namespace Tailordb {
2626
| "CREATE";
2727
}
2828

29+
/**
30+
* File stream iterator for TailorDB file downloads
31+
*/
32+
interface TailordbFileStreamIterator {
33+
/**
34+
* Get next chunk from the stream
35+
*/
36+
next(): Promise<{ done: boolean; value?: any }>;
37+
38+
/**
39+
* Close the stream session
40+
*/
41+
close(): Promise<void>;
42+
43+
/**
44+
* AsyncIterator symbol for for-await-of loops
45+
*/
46+
[Symbol.asyncIterator](): TailordbFileStreamIterator;
47+
}
48+
2949
declare const tailordb: {
3050
Client: typeof Tailordb.Client;
51+
file: {
52+
/**
53+
* Upload file to TailorDB
54+
*/
55+
upload(
56+
namespace: string,
57+
typeName: string,
58+
fieldName: string,
59+
recordId: string,
60+
data: string | ArrayBuffer | Uint8Array | number[],
61+
options?: {
62+
contentType?: string;
63+
}
64+
): Promise<{
65+
metadata: {
66+
fileSize: number;
67+
sha256sum: string;
68+
}
69+
}>;
70+
71+
/**
72+
* Download file from TailorDB
73+
*/
74+
download(
75+
namespace: string,
76+
typeName: string,
77+
fieldName: string,
78+
recordId: string
79+
): Promise<{
80+
data: Uint8Array;
81+
metadata: {
82+
contentType: string;
83+
fileSize: number;
84+
}
85+
}>;
86+
87+
/**
88+
* Open download stream for large files
89+
*/
90+
openDownloadStream(
91+
namespace: string,
92+
typeName: string,
93+
fieldName: string,
94+
recordId: string
95+
): Promise<TailordbFileStreamIterator>;
96+
97+
/**
98+
* Delete file from TailorDB
99+
*/
100+
delete(
101+
namespace: string,
102+
typeName: string,
103+
fieldName: string,
104+
recordId: string
105+
): Promise<boolean>;
106+
107+
/**
108+
* Get file metadata from TailorDB
109+
*/
110+
getMetadata(
111+
namespace: string,
112+
typeName: string,
113+
fieldName: string,
114+
recordId: string
115+
): Promise<{
116+
contentType: string;
117+
fileSize: number;
118+
sha256sum: string;
119+
lastUploadedAt: string;
120+
}>;
121+
};
31122
};
32123

33124
declare namespace tailor.secretmanager {

0 commit comments

Comments
 (0)