tuturuuu 0.0.1
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 +270 -0
- package/package.json +47 -0
- package/src/documents.test.ts +523 -0
- package/src/errors.test.ts +278 -0
- package/src/errors.ts +161 -0
- package/src/index.ts +60 -0
- package/src/storage.test.ts +604 -0
- package/src/storage.ts +702 -0
- package/src/types.test.ts +562 -0
- package/src/types.ts +291 -0
package/src/types.ts
ADDED
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for the Tuturuuu SDK
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Storage object returned from list operations
|
|
9
|
+
*/
|
|
10
|
+
export interface StorageObject {
|
|
11
|
+
id?: string;
|
|
12
|
+
name: string;
|
|
13
|
+
createdAt?: string;
|
|
14
|
+
updatedAt?: string;
|
|
15
|
+
lastAccessedAt?: string;
|
|
16
|
+
metadata?: {
|
|
17
|
+
eTag?: string;
|
|
18
|
+
size?: number;
|
|
19
|
+
mimetype?: string;
|
|
20
|
+
cacheControl?: string;
|
|
21
|
+
contentLength?: number;
|
|
22
|
+
httpStatusCode?: number;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* List options for storage listing
|
|
28
|
+
*/
|
|
29
|
+
export interface ListStorageOptions {
|
|
30
|
+
path?: string;
|
|
31
|
+
search?: string;
|
|
32
|
+
limit?: number;
|
|
33
|
+
offset?: number;
|
|
34
|
+
sortBy?: 'name' | 'created_at' | 'updated_at' | 'size';
|
|
35
|
+
sortOrder?: 'asc' | 'desc';
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Upload options for file upload
|
|
40
|
+
*/
|
|
41
|
+
export interface UploadOptions {
|
|
42
|
+
path?: string;
|
|
43
|
+
upsert?: boolean;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Share options for signed URL generation
|
|
48
|
+
*/
|
|
49
|
+
export interface ShareOptions {
|
|
50
|
+
expiresIn?: number; // In seconds
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Pagination metadata
|
|
55
|
+
*/
|
|
56
|
+
export interface Pagination {
|
|
57
|
+
limit: number;
|
|
58
|
+
offset: number;
|
|
59
|
+
total: number; // Total count after filters are applied
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Response for list storage operation
|
|
64
|
+
*/
|
|
65
|
+
export interface ListStorageResponse {
|
|
66
|
+
data: StorageObject[];
|
|
67
|
+
pagination: Pagination;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Path data returned by storage operations
|
|
72
|
+
*/
|
|
73
|
+
export interface PathData {
|
|
74
|
+
path: string;
|
|
75
|
+
fullPath: string;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Generic path response for operations that return path information
|
|
80
|
+
*/
|
|
81
|
+
export interface PathResponse {
|
|
82
|
+
message: string;
|
|
83
|
+
data: PathData;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Response for upload operation
|
|
88
|
+
*/
|
|
89
|
+
export type UploadResponse = PathResponse;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Response for delete operation
|
|
93
|
+
*/
|
|
94
|
+
export interface DeleteResponse {
|
|
95
|
+
message: string;
|
|
96
|
+
data: {
|
|
97
|
+
deleted: number;
|
|
98
|
+
paths: string[];
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Response for create folder operation
|
|
104
|
+
*/
|
|
105
|
+
export type CreateFolderResponse = PathResponse;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Response for share operation
|
|
109
|
+
*/
|
|
110
|
+
export interface ShareResponse {
|
|
111
|
+
message: string;
|
|
112
|
+
data: {
|
|
113
|
+
signedUrl: string;
|
|
114
|
+
expiresAt: string;
|
|
115
|
+
expiresIn: number;
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Storage analytics data
|
|
121
|
+
*/
|
|
122
|
+
export interface StorageAnalytics {
|
|
123
|
+
totalSize: number;
|
|
124
|
+
fileCount: number;
|
|
125
|
+
storageLimit: number;
|
|
126
|
+
usagePercentage: number;
|
|
127
|
+
largestFile: {
|
|
128
|
+
name: string;
|
|
129
|
+
size: number;
|
|
130
|
+
createdAt: string;
|
|
131
|
+
} | null;
|
|
132
|
+
smallestFile: {
|
|
133
|
+
name: string;
|
|
134
|
+
size: number;
|
|
135
|
+
createdAt: string;
|
|
136
|
+
} | null;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Response for analytics operation
|
|
141
|
+
*/
|
|
142
|
+
export interface AnalyticsResponse {
|
|
143
|
+
data: StorageAnalytics;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Document object
|
|
148
|
+
*/
|
|
149
|
+
export interface Document {
|
|
150
|
+
id: string;
|
|
151
|
+
name: string;
|
|
152
|
+
content: string;
|
|
153
|
+
isPublic: boolean;
|
|
154
|
+
createdAt: string;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* List documents options
|
|
159
|
+
*/
|
|
160
|
+
export interface ListDocumentsOptions {
|
|
161
|
+
search?: string;
|
|
162
|
+
limit?: number;
|
|
163
|
+
offset?: number;
|
|
164
|
+
isPublic?: boolean;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Create document data
|
|
169
|
+
*/
|
|
170
|
+
export interface CreateDocumentData {
|
|
171
|
+
name: string;
|
|
172
|
+
content?: string;
|
|
173
|
+
isPublic?: boolean;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Update document data
|
|
178
|
+
*/
|
|
179
|
+
export interface UpdateDocumentData {
|
|
180
|
+
name?: string;
|
|
181
|
+
content?: string;
|
|
182
|
+
isPublic?: boolean;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Response for list documents operation
|
|
187
|
+
*/
|
|
188
|
+
export interface ListDocumentsResponse {
|
|
189
|
+
data: Document[];
|
|
190
|
+
pagination: Pagination;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Response for document operation
|
|
195
|
+
*/
|
|
196
|
+
export interface DocumentResponse {
|
|
197
|
+
message: string;
|
|
198
|
+
data: Document;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Response for get document operation
|
|
203
|
+
*/
|
|
204
|
+
export interface GetDocumentResponse {
|
|
205
|
+
data: Document;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Response for delete document operation
|
|
210
|
+
*/
|
|
211
|
+
export interface DeleteDocumentResponse {
|
|
212
|
+
message: string;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* API error response
|
|
217
|
+
*/
|
|
218
|
+
export interface ApiErrorResponse {
|
|
219
|
+
error: string;
|
|
220
|
+
message: string;
|
|
221
|
+
code?: string;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Zod schemas for validation
|
|
226
|
+
*/
|
|
227
|
+
|
|
228
|
+
export const listStorageOptionsSchema = z
|
|
229
|
+
.object({
|
|
230
|
+
path: z.string(),
|
|
231
|
+
search: z.string(),
|
|
232
|
+
limit: z.number().int().min(1).max(100).finite(),
|
|
233
|
+
offset: z.number().int().min(0).finite(),
|
|
234
|
+
sortBy: z.enum(['name', 'created_at', 'updated_at', 'size']),
|
|
235
|
+
sortOrder: z.enum(['asc', 'desc']),
|
|
236
|
+
})
|
|
237
|
+
.partial();
|
|
238
|
+
|
|
239
|
+
export const uploadOptionsSchema = z
|
|
240
|
+
.object({
|
|
241
|
+
path: z.string(),
|
|
242
|
+
upsert: z.boolean(),
|
|
243
|
+
})
|
|
244
|
+
.partial();
|
|
245
|
+
|
|
246
|
+
export const shareOptionsSchema = z
|
|
247
|
+
.object({
|
|
248
|
+
expiresIn: z.number().int().min(60).max(604800).finite(),
|
|
249
|
+
})
|
|
250
|
+
.partial();
|
|
251
|
+
|
|
252
|
+
export const listDocumentsOptionsSchema = z
|
|
253
|
+
.object({
|
|
254
|
+
search: z.string(),
|
|
255
|
+
limit: z.number().int().min(1).max(100).finite(),
|
|
256
|
+
offset: z.number().int().min(0).finite(),
|
|
257
|
+
isPublic: z.boolean(),
|
|
258
|
+
})
|
|
259
|
+
.partial()
|
|
260
|
+
.superRefine((data, ctx) => {
|
|
261
|
+
if ('limit' in data && data.limit === undefined) {
|
|
262
|
+
ctx.addIssue({
|
|
263
|
+
code: 'invalid_type',
|
|
264
|
+
expected: 'number',
|
|
265
|
+
received: 'undefined',
|
|
266
|
+
path: ['limit'],
|
|
267
|
+
message: 'limit cannot be explicitly undefined',
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
if ('offset' in data && data.offset === undefined) {
|
|
271
|
+
ctx.addIssue({
|
|
272
|
+
code: 'invalid_type',
|
|
273
|
+
expected: 'number',
|
|
274
|
+
received: 'undefined',
|
|
275
|
+
path: ['offset'],
|
|
276
|
+
message: 'offset cannot be explicitly undefined',
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
export const createDocumentDataSchema = z.object({
|
|
282
|
+
name: z.string().min(1).max(255),
|
|
283
|
+
content: z.string().max(100000).optional(),
|
|
284
|
+
isPublic: z.boolean().optional(),
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
export const updateDocumentDataSchema = z.object({
|
|
288
|
+
name: z.string().min(1).max(255).optional(),
|
|
289
|
+
content: z.string().max(100000).optional(),
|
|
290
|
+
isPublic: z.boolean().optional(),
|
|
291
|
+
});
|