tuturuuu 0.0.1 → 0.0.3

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,280 @@
1
+ /**
2
+ * Tuturuuu Storage SDK
3
+ *
4
+ * Official SDK for interacting with Tuturuuu workspace resources
5
+ * including storage (files/folders) and documents.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * import { TuturuuuClient } from 'tuturuuu';
10
+ *
11
+ * const client = new TuturuuuClient('ttr_your_api_key');
12
+ *
13
+ * // List files
14
+ * const files = await client.storage.list({ path: 'documents' });
15
+ *
16
+ * // Upload a file
17
+ * const file = new File(['content'], 'example.txt');
18
+ * await client.storage.upload(file, { path: 'documents' });
19
+ *
20
+ * // Create a document
21
+ * const doc = await client.documents.create({
22
+ * name: 'My Document',
23
+ * content: 'Hello World'
24
+ * });
25
+ * ```
26
+ */
27
+ import type { AnalyticsResponse, CreateDocumentData, CreateFolderResponse, DeleteDocumentResponse, DeleteResponse, DocumentResponse, GetDocumentResponse, ListDocumentsOptions, ListDocumentsResponse, ListStorageOptions, ListStorageResponse, ShareOptions, ShareResponse, UpdateDocumentData, UploadOptions, UploadResponse } from './types';
28
+ /**
29
+ * Configuration options for the Tuturuuu client
30
+ */
31
+ export interface TuturuuuClientConfig {
32
+ apiKey: string;
33
+ baseUrl?: string;
34
+ timeout?: number;
35
+ fetch?: typeof fetch;
36
+ }
37
+ /**
38
+ * Storage operations client
39
+ */
40
+ export declare class StorageClient {
41
+ private client;
42
+ constructor(client: TuturuuuClient);
43
+ /**
44
+ * Lists files and folders in the workspace drive
45
+ *
46
+ * @param options - Options for listing files
47
+ * @returns List of storage objects with pagination
48
+ *
49
+ * @example
50
+ * ```typescript
51
+ * const files = await client.storage.list({
52
+ * path: 'documents',
53
+ * search: 'report',
54
+ * limit: 50,
55
+ * sortBy: 'created_at',
56
+ * sortOrder: 'desc'
57
+ * });
58
+ * ```
59
+ */
60
+ list(options?: ListStorageOptions): Promise<ListStorageResponse>;
61
+ /**
62
+ * Uploads a file to the workspace drive using signed upload URLs
63
+ *
64
+ * This method first requests a signed upload URL from the platform,
65
+ * then uploads the file directly to Supabase Storage. This approach
66
+ * is more efficient and secure than proxying files through the API.
67
+ *
68
+ * @param file - File to upload (File or Blob)
69
+ * @param options - Upload options
70
+ * @returns Upload result with path information
71
+ *
72
+ * @example
73
+ * ```typescript
74
+ * const file = new File(['content'], 'document.pdf');
75
+ * const result = await client.storage.upload(file, {
76
+ * path: 'documents',
77
+ * upsert: true
78
+ * });
79
+ *
80
+ * // For Buffer in Node.js, convert to Blob first:
81
+ * const buffer = Buffer.from('content');
82
+ * const blob = new Blob([buffer]);
83
+ * await client.storage.upload(blob, { path: 'documents' });
84
+ * ```
85
+ */
86
+ upload(file: File | Blob, options?: UploadOptions): Promise<UploadResponse>;
87
+ /**
88
+ * Downloads a file from the workspace drive
89
+ *
90
+ * @param path - Path to the file
91
+ * @returns File blob
92
+ *
93
+ * @example
94
+ * ```typescript
95
+ * const blob = await client.storage.download('documents/report.pdf');
96
+ * ```
97
+ */
98
+ download(path: string): Promise<Blob>;
99
+ /**
100
+ * Deletes files or folders from the workspace drive
101
+ *
102
+ * @param paths - Array of paths to delete
103
+ * @returns Delete result
104
+ *
105
+ * @example
106
+ * ```typescript
107
+ * const result = await client.storage.delete([
108
+ * 'documents/old-report.pdf',
109
+ * 'images/screenshot.png'
110
+ * ]);
111
+ * ```
112
+ */
113
+ delete(paths: string[]): Promise<DeleteResponse>;
114
+ /**
115
+ * Creates a new folder in the workspace drive
116
+ *
117
+ * @param path - Parent path
118
+ * @param name - Folder name
119
+ * @returns Create folder result
120
+ *
121
+ * @example
122
+ * ```typescript
123
+ * const result = await client.storage.createFolder('documents', 'reports');
124
+ * ```
125
+ */
126
+ createFolder(path: string, name: string): Promise<CreateFolderResponse>;
127
+ /**
128
+ * Generates a signed URL for sharing a file
129
+ *
130
+ * @param path - Path to the file
131
+ * @param options - Share options
132
+ * @returns Signed URL with expiration
133
+ *
134
+ * @example
135
+ * ```typescript
136
+ * const result = await client.storage.share('documents/report.pdf', {
137
+ * expiresIn: 3600 // 1 hour
138
+ * });
139
+ * console.log(result.data.signedUrl);
140
+ * ```
141
+ */
142
+ share(path: string, options?: ShareOptions): Promise<ShareResponse>;
143
+ /**
144
+ * Retrieves storage analytics for the workspace
145
+ *
146
+ * @returns Storage usage statistics
147
+ *
148
+ * @example
149
+ * ```typescript
150
+ * const analytics = await client.storage.getAnalytics();
151
+ * console.log(`Used: ${analytics.data.totalSize} bytes`);
152
+ * console.log(`Files: ${analytics.data.fileCount}`);
153
+ * ```
154
+ */
155
+ getAnalytics(): Promise<AnalyticsResponse>;
156
+ }
157
+ /**
158
+ * Documents operations client
159
+ */
160
+ export declare class DocumentsClient {
161
+ private client;
162
+ constructor(client: TuturuuuClient);
163
+ /**
164
+ * Lists documents in the workspace
165
+ *
166
+ * @param options - Options for listing documents
167
+ * @returns List of documents with pagination
168
+ *
169
+ * @example
170
+ * ```typescript
171
+ * const docs = await client.documents.list({
172
+ * search: 'meeting',
173
+ * limit: 20,
174
+ * isPublic: false
175
+ * });
176
+ * ```
177
+ */
178
+ list(options?: ListDocumentsOptions): Promise<ListDocumentsResponse>;
179
+ /**
180
+ * Creates a new document
181
+ *
182
+ * @param data - Document data
183
+ * @returns Created document
184
+ *
185
+ * @example
186
+ * ```typescript
187
+ * const doc = await client.documents.create({
188
+ * name: 'Meeting Notes',
189
+ * content: 'Discussion points...',
190
+ * isPublic: false
191
+ * });
192
+ * ```
193
+ */
194
+ create(data: CreateDocumentData): Promise<DocumentResponse>;
195
+ /**
196
+ * Gets a document by ID
197
+ *
198
+ * @param id - Document ID
199
+ * @returns Document data
200
+ *
201
+ * @example
202
+ * ```typescript
203
+ * const doc = await client.documents.get('doc-id-123');
204
+ * ```
205
+ */
206
+ get(id: string): Promise<GetDocumentResponse>;
207
+ /**
208
+ * Updates a document
209
+ *
210
+ * @param id - Document ID
211
+ * @param data - Update data
212
+ * @returns Updated document
213
+ *
214
+ * @example
215
+ * ```typescript
216
+ * const doc = await client.documents.update('doc-id-123', {
217
+ * name: 'Updated Meeting Notes',
218
+ * content: 'New content...'
219
+ * });
220
+ * ```
221
+ */
222
+ update(id: string, data: UpdateDocumentData): Promise<DocumentResponse>;
223
+ /**
224
+ * Deletes a document
225
+ *
226
+ * @param id - Document ID
227
+ * @returns Delete confirmation
228
+ *
229
+ * @example
230
+ * ```typescript
231
+ * await client.documents.delete('doc-id-123');
232
+ * ```
233
+ */
234
+ delete(id: string): Promise<DeleteDocumentResponse>;
235
+ /**
236
+ * Searches documents by name
237
+ * Alias for list() with search parameter
238
+ *
239
+ * @param query - Search query
240
+ * @param options - Additional list options
241
+ * @returns List of matching documents
242
+ */
243
+ search(query: string, options?: Omit<ListDocumentsOptions, 'search'>): Promise<ListDocumentsResponse>;
244
+ }
245
+ /**
246
+ * Main Tuturuuu SDK client
247
+ */
248
+ export declare class TuturuuuClient {
249
+ readonly apiKey: string;
250
+ readonly baseUrl: string;
251
+ readonly timeout: number;
252
+ readonly fetch: typeof fetch;
253
+ readonly storage: StorageClient;
254
+ readonly documents: DocumentsClient;
255
+ /**
256
+ * Creates a new Tuturuuu client instance
257
+ *
258
+ * @param config - Client configuration
259
+ *
260
+ * @example
261
+ * ```typescript
262
+ * const client = new TuturuuuClient({
263
+ * apiKey: 'ttr_your_api_key',
264
+ * baseUrl: 'https://tuturuuu.com/api/v1', // optional, this is the default
265
+ * timeout: 30000 // optional, default 30s
266
+ * });
267
+ * ```
268
+ */
269
+ constructor(config: string | TuturuuuClientConfig);
270
+ /**
271
+ * Internal method to make HTTP requests
272
+ * @internal
273
+ */
274
+ request<T>(endpoint: string, options?: {
275
+ method?: string;
276
+ body?: string | FormData;
277
+ skipJsonContentType?: boolean;
278
+ }): Promise<T>;
279
+ }
280
+ //# sourceMappingURL=storage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../src/storage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