dosyadev 0.1.0

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,711 @@
1
+ interface DosyaClientOptions {
2
+ apiKey: string;
3
+ baseUrl?: string;
4
+ fetch?: typeof globalThis.fetch;
5
+ retry?: RetryOptions;
6
+ onRateLimit?: (info: RateLimitInfo) => void;
7
+ }
8
+ interface RetryOptions {
9
+ maxRetries?: number;
10
+ baseDelay?: number;
11
+ maxDelay?: number;
12
+ }
13
+ interface RateLimitInfo {
14
+ limit: number;
15
+ remaining: number;
16
+ resetAt: number;
17
+ }
18
+ interface PaginationMeta {
19
+ page: number;
20
+ perPage: number;
21
+ totalFiles: number;
22
+ totalPages: number;
23
+ }
24
+ interface ListFilesParams {
25
+ workspaceId: string;
26
+ folderId?: string | null;
27
+ filter?: "all" | "documents" | "videos" | "images";
28
+ sort?: "newest" | "oldest" | "name_asc" | "name_desc" | "largest" | "smallest";
29
+ q?: string;
30
+ deleted?: boolean;
31
+ hidden?: boolean;
32
+ page?: number;
33
+ perPage?: number;
34
+ }
35
+ interface FileListItem {
36
+ id: string;
37
+ name: string;
38
+ sizeBytes: number;
39
+ mimeType: string;
40
+ extension: string | null;
41
+ region: string;
42
+ uploadedBy: string;
43
+ uploaderName: string | null;
44
+ createdAt: number;
45
+ updatedAt: number;
46
+ deletedAt: number | null;
47
+ lockMode: string;
48
+ isHidden: number;
49
+ hiddenMode: string;
50
+ currentVersion: number;
51
+ isSynced: number;
52
+ shareCount: number;
53
+ commentCount: number;
54
+ }
55
+ interface FolderListItem {
56
+ id: string;
57
+ name: string;
58
+ createdAt: number;
59
+ fileCount: number;
60
+ lockMode: string;
61
+ isHidden: number;
62
+ hiddenMode: string;
63
+ isSynced: number;
64
+ }
65
+ interface Breadcrumb {
66
+ id: string;
67
+ name: string;
68
+ }
69
+ interface ListFilesResponse {
70
+ folders: FolderListItem[];
71
+ files: FileListItem[];
72
+ breadcrumbs: Breadcrumb[];
73
+ workspaceId: string;
74
+ folderId: string | null;
75
+ canLock: boolean;
76
+ canHide: boolean;
77
+ folderViewOnly: boolean;
78
+ pagination: PaginationMeta;
79
+ }
80
+ interface FileDetail {
81
+ id: string;
82
+ name: string;
83
+ sizeBytes: number;
84
+ mimeType: string;
85
+ extension: string | null;
86
+ region: string;
87
+ uploadedBy: string;
88
+ uploaderName: string | null;
89
+ folderId: string | null;
90
+ workspaceId: string;
91
+ currentVersion: number;
92
+ lockMode: string;
93
+ isHidden: number;
94
+ hiddenMode: string;
95
+ createdAt: number;
96
+ updatedAt: number;
97
+ deletedAt: number | null;
98
+ }
99
+ interface FileVersion {
100
+ id: string;
101
+ versionNumber: number;
102
+ sizeBytes: number;
103
+ mimeType: string;
104
+ extension: string | null;
105
+ uploadedBy: string;
106
+ uploaderName: string | null;
107
+ createdAt: number;
108
+ }
109
+ type UploadSource = File | Blob | ArrayBuffer | Uint8Array | ReadableStream<Uint8Array>;
110
+ interface UploadParams {
111
+ workspaceId: string;
112
+ fileName: string;
113
+ fileSize: number;
114
+ mimeType?: string;
115
+ region?: string;
116
+ folderId?: string | null;
117
+ fileId?: string | null;
118
+ body: UploadSource;
119
+ onProgress?: (progress: UploadProgress) => void;
120
+ abortSignal?: AbortSignal;
121
+ }
122
+ interface UploadProgress {
123
+ bytesUploaded: number;
124
+ totalBytes: number;
125
+ percent: number;
126
+ partsCompleted?: number;
127
+ totalParts?: number;
128
+ status: "initializing" | "uploading" | "completing" | "complete";
129
+ }
130
+ interface UploadResult {
131
+ file: {
132
+ id: string;
133
+ name: string;
134
+ r2Key: string;
135
+ sizeBytes: number;
136
+ mimeType: string;
137
+ extension: string | null;
138
+ region: string;
139
+ version: number;
140
+ createdAt: number;
141
+ };
142
+ sessionId: string;
143
+ }
144
+ interface UploadInitResponse {
145
+ sessionId: string;
146
+ uploadUrl: string;
147
+ workspaceId: string;
148
+ fileName: string;
149
+ fileSize: number;
150
+ mimeType: string;
151
+ extension: string;
152
+ region: string;
153
+ resumable: {
154
+ partSize: number;
155
+ totalParts: number;
156
+ partUploadUrl: string;
157
+ completeUrl: string;
158
+ statusUrl: string;
159
+ } | null;
160
+ }
161
+ interface UploadStatusResponse {
162
+ sessionId: string;
163
+ status: string;
164
+ sizeBytes: number;
165
+ partSize: number | null;
166
+ totalParts: number | null;
167
+ bytesUploaded: number;
168
+ uploadedParts: number[];
169
+ hasMultipart: boolean;
170
+ }
171
+ interface DownloadOptions {
172
+ version?: number;
173
+ unlockToken?: string;
174
+ }
175
+ interface CreateShareLinkParams {
176
+ expiresInDays?: number;
177
+ password?: string;
178
+ lockMode?: "none" | "view_only" | "full_lock";
179
+ }
180
+ interface ShareEmailParams {
181
+ emails: string[];
182
+ message?: string;
183
+ }
184
+ interface CreateShareBundleParams {
185
+ fileIds: string[];
186
+ expiresInDays?: number;
187
+ password?: string;
188
+ }
189
+ interface ShareLinkDetail {
190
+ id: string;
191
+ fileId: string;
192
+ fileName: string;
193
+ token: string;
194
+ isPasswordProtected: number;
195
+ expiresAt: number | null;
196
+ downloadCount: number;
197
+ createdAt: number;
198
+ createdBy: string;
199
+ status: string;
200
+ }
201
+ interface SharesListResponse {
202
+ links: ShareLinkDetail[];
203
+ stats: {
204
+ total: number;
205
+ active: number;
206
+ expiring: number;
207
+ totalViews: number;
208
+ };
209
+ }
210
+ interface CreateFolderParams {
211
+ workspaceId: string;
212
+ parentId?: string | null;
213
+ name: string;
214
+ }
215
+ interface FolderDetail {
216
+ id: string;
217
+ name: string;
218
+ parentId: string | null;
219
+ workspaceId: string;
220
+ createdAt: number;
221
+ }
222
+ interface FolderTreeItem {
223
+ id: string;
224
+ name: string;
225
+ parentId: string | null;
226
+ fileCount: number;
227
+ }
228
+ interface CreateWorkspaceParams {
229
+ name: string;
230
+ iconInitials?: string;
231
+ iconColor?: string;
232
+ defaultRegion?: string;
233
+ }
234
+ interface UpdateWorkspaceParams {
235
+ name?: string;
236
+ iconInitials?: string;
237
+ iconColor?: string;
238
+ defaultRegion?: string;
239
+ }
240
+ interface WorkspaceListItem {
241
+ id: string;
242
+ name: string;
243
+ slug: string;
244
+ iconInitials: string;
245
+ iconColor: string;
246
+ ownerId: string;
247
+ role: string;
248
+ roleId: string;
249
+ memberCount: number;
250
+ storageUsedBytes: number;
251
+ createdAt: number;
252
+ }
253
+ interface WorkspaceDetail {
254
+ id: string;
255
+ name: string;
256
+ slug: string;
257
+ iconInitials: string;
258
+ iconColor: string;
259
+ iconUrl: string | null;
260
+ ownerId: string;
261
+ storageUsedBytes: number;
262
+ createdAt: number;
263
+ }
264
+ interface WorkspaceSettings {
265
+ maxFileSizeGb: number;
266
+ maxTotalStorageGb: number;
267
+ maxStoragePerMemberGb: number;
268
+ maxConcurrentUploads: number;
269
+ allowedExtensions: string | null;
270
+ blockedExtensions: string | null;
271
+ require2fa: number;
272
+ disableShareLinks: number;
273
+ forceSharePassword: number;
274
+ shareMaxExpiryDays: number | null;
275
+ }
276
+ interface CreateFileRequestParams {
277
+ workspaceId: string;
278
+ folderId?: string | null;
279
+ title?: string;
280
+ message?: string;
281
+ password?: string;
282
+ expiresInDays?: number;
283
+ allowedExtensions?: string;
284
+ maxFileSizeMb?: number;
285
+ maxFiles?: number;
286
+ emails?: string[];
287
+ }
288
+ interface FileRequestDetail {
289
+ id: string;
290
+ token: string;
291
+ url: string;
292
+ title: string | null;
293
+ message: string | null;
294
+ isPasswordProtected: number;
295
+ expiresAt: number | null;
296
+ uploadCount: number;
297
+ createdAt: number;
298
+ }
299
+ interface SearchParams {
300
+ workspaceId: string;
301
+ q: string;
302
+ page?: number;
303
+ perPage?: number;
304
+ }
305
+ interface SearchResponse {
306
+ query: string;
307
+ files: Array<{
308
+ id: string;
309
+ name: string;
310
+ sizeBytes: number;
311
+ mimeType: string;
312
+ extension: string | null;
313
+ createdAt: number;
314
+ }>;
315
+ folders: Array<{
316
+ id: string;
317
+ name: string;
318
+ createdAt: number;
319
+ }>;
320
+ shared: Array<{
321
+ id: string;
322
+ fileName: string;
323
+ token: string;
324
+ createdAt: number;
325
+ }>;
326
+ fileRequests: Array<{
327
+ id: string;
328
+ title: string | null;
329
+ token: string;
330
+ createdAt: number;
331
+ }>;
332
+ pagination: PaginationMeta;
333
+ }
334
+ interface CreateCommentParams {
335
+ workspaceId: string;
336
+ fileId?: string;
337
+ folderId?: string;
338
+ parentId?: string;
339
+ body: string;
340
+ }
341
+ interface CommentDetail {
342
+ id: string;
343
+ body: string;
344
+ userId: string;
345
+ userName: string;
346
+ userAvatar: string | null;
347
+ parentId: string | null;
348
+ createdAt: number;
349
+ updatedAt: number | null;
350
+ }
351
+ interface ListActivityParams {
352
+ workspaceId: string;
353
+ page?: number;
354
+ perPage?: number;
355
+ category?: string;
356
+ action?: string;
357
+ userId?: string;
358
+ }
359
+ interface ActivityEntry {
360
+ id: string;
361
+ workspaceId: string;
362
+ userId: string;
363
+ userName: string | null;
364
+ action: string;
365
+ resourceType: string;
366
+ resourceId: string | null;
367
+ resourceName: string | null;
368
+ metadata: string | null;
369
+ createdAt: number;
370
+ }
371
+ interface ActivityListResponse {
372
+ activities: ActivityEntry[];
373
+ members: Array<{
374
+ id: string;
375
+ name: string;
376
+ email: string;
377
+ avatarUrl: string | null;
378
+ }>;
379
+ pagination: PaginationMeta;
380
+ }
381
+ interface UserProfile {
382
+ id: string;
383
+ email: string;
384
+ name: string;
385
+ initials: string;
386
+ avatarUrl: string | null;
387
+ preferredLanguage: string;
388
+ createdAt: number;
389
+ emailVerifiedAt: number | null;
390
+ workspaceCount: number;
391
+ }
392
+ interface ApiKeyItem {
393
+ id: string;
394
+ name: string;
395
+ scope: string;
396
+ keyPrefix: string;
397
+ lastUsedAt: number | null;
398
+ expiresAt: number | null;
399
+ createdAt: number;
400
+ }
401
+ interface CreateApiKeyParams {
402
+ name: string;
403
+ scope?: "full" | "read" | "upload";
404
+ expiresInDays?: number;
405
+ }
406
+ interface CreatedApiKey {
407
+ id: string;
408
+ name: string;
409
+ scope: string;
410
+ plainKey: string;
411
+ expiresAt: number | null;
412
+ createdAt: number;
413
+ }
414
+ interface LockInfo {
415
+ lockMode: string;
416
+ lockedBy: string | null;
417
+ lockedByName: string | null;
418
+ lockedAt: number | null;
419
+ }
420
+ interface SetLockParams {
421
+ lockMode: "view_only" | "full_lock";
422
+ password?: string;
423
+ }
424
+ interface SetHideParams {
425
+ hiddenMode?: "everyone" | "users" | "roles";
426
+ targetIds?: string[];
427
+ }
428
+ interface RequestOptions {
429
+ method: "GET" | "POST" | "PUT" | "DELETE";
430
+ path: string;
431
+ body?: Record<string, unknown>;
432
+ rawBody?: BodyInit;
433
+ headers?: Record<string, string>;
434
+ query?: Record<string, string | number | boolean | null | undefined>;
435
+ signal?: AbortSignal;
436
+ rawResponse?: boolean;
437
+ }
438
+
439
+ declare class HttpClient {
440
+ readonly baseUrl: string;
441
+ private readonly apiKey;
442
+ private readonly fetchFn;
443
+ private readonly maxRetries;
444
+ private readonly baseDelay;
445
+ private readonly maxDelay;
446
+ private readonly onRateLimit?;
447
+ constructor(options: DosyaClientOptions);
448
+ request<T>(opts: RequestOptions): Promise<T>;
449
+ requestRaw(opts: RequestOptions): Promise<Response>;
450
+ private doFetch;
451
+ private buildUrl;
452
+ private extractRateLimit;
453
+ private getDelay;
454
+ private sleep;
455
+ }
456
+
457
+ declare class FilesResource {
458
+ private readonly http;
459
+ constructor(http: HttpClient);
460
+ list(params: ListFilesParams): Promise<ListFilesResponse>;
461
+ get(fileId: string): Promise<{
462
+ file: FileDetail;
463
+ }>;
464
+ delete(fileId: string): Promise<{
465
+ permanent: boolean;
466
+ }>;
467
+ restore(fileId: string): Promise<void>;
468
+ rename(fileId: string, name: string): Promise<{
469
+ name: string;
470
+ }>;
471
+ move(fileId: string, folderId: string | null): Promise<void>;
472
+ copy(fileId: string, options?: {
473
+ newName?: string;
474
+ folderId?: string | null;
475
+ }): Promise<{
476
+ file: FileDetail;
477
+ }>;
478
+ lock(fileId: string, params: SetLockParams): Promise<void>;
479
+ unlock(fileId: string): Promise<void>;
480
+ hide(fileId: string, params?: SetHideParams): Promise<void>;
481
+ listVersions(fileId: string): Promise<{
482
+ fileName: string;
483
+ currentVersion: number;
484
+ versions: FileVersion[];
485
+ }>;
486
+ restoreVersion(fileId: string, versionNumber: number): Promise<{
487
+ version: number;
488
+ restoredFrom: number;
489
+ }>;
490
+ getShareLinks(fileId: string): Promise<{
491
+ links: ShareLinkDetail[];
492
+ }>;
493
+ createShareLink(fileId: string, params?: CreateShareLinkParams): Promise<{
494
+ link: ShareLinkDetail;
495
+ }>;
496
+ shareByEmail(fileId: string, params: ShareEmailParams): Promise<void>;
497
+ createShareBundle(params: CreateShareBundleParams): Promise<{
498
+ link: {
499
+ id: string;
500
+ token: string;
501
+ url: string;
502
+ fileCount: number;
503
+ expiresAt: number | null;
504
+ createdAt: number;
505
+ };
506
+ }>;
507
+ }
508
+
509
+ declare class FoldersResource {
510
+ private readonly http;
511
+ constructor(http: HttpClient);
512
+ create(params: CreateFolderParams): Promise<{
513
+ folder: FolderDetail;
514
+ createdCount: number;
515
+ createdFolders: FolderDetail[];
516
+ }>;
517
+ get(folderId: string): Promise<{
518
+ folder: FolderDetail;
519
+ }>;
520
+ rename(folderId: string, name: string): Promise<{
521
+ name: string;
522
+ }>;
523
+ delete(folderId: string): Promise<{
524
+ filesAffected: number;
525
+ foldersRemoved: number;
526
+ }>;
527
+ move(folderId: string, parentId: string | null): Promise<void>;
528
+ tree(workspaceId: string): Promise<{
529
+ folders: FolderTreeItem[];
530
+ }>;
531
+ lock(folderId: string, params: SetLockParams): Promise<void>;
532
+ unlock(folderId: string): Promise<void>;
533
+ }
534
+
535
+ declare class UploadResource {
536
+ private readonly http;
537
+ constructor(http: HttpClient);
538
+ file(params: UploadParams): Promise<UploadResult>;
539
+ resume(sessionId: string, body: UploadSource, options?: {
540
+ onProgress?: (progress: UploadProgress) => void;
541
+ abortSignal?: AbortSignal;
542
+ }): Promise<UploadResult>;
543
+ init(params: Omit<UploadParams, "body" | "onProgress" | "abortSignal">): Promise<UploadInitResponse>;
544
+ status(sessionId: string): Promise<UploadStatusResponse>;
545
+ private uploadSingle;
546
+ private uploadMultipart;
547
+ private sourceToBuffer;
548
+ private streamToBuffer;
549
+ }
550
+
551
+ declare class DownloadResource {
552
+ private readonly http;
553
+ constructor(http: HttpClient);
554
+ getUrl(fileId: string, options?: DownloadOptions): Promise<string>;
555
+ arrayBuffer(fileId: string, options?: DownloadOptions): Promise<ArrayBuffer>;
556
+ stream(fileId: string, options?: DownloadOptions): Promise<ReadableStream<Uint8Array>>;
557
+ raw(fileId: string, options?: DownloadOptions): Promise<Response>;
558
+ }
559
+
560
+ declare class SharesResource {
561
+ private readonly http;
562
+ constructor(http: HttpClient);
563
+ list(workspaceId: string): Promise<SharesListResponse>;
564
+ revoke(linkId: string): Promise<void>;
565
+ }
566
+
567
+ declare class WorkspacesResource {
568
+ private readonly http;
569
+ constructor(http: HttpClient);
570
+ list(): Promise<{
571
+ workspaces: WorkspaceListItem[];
572
+ }>;
573
+ get(workspaceId: string): Promise<{
574
+ workspace: WorkspaceDetail;
575
+ settings: WorkspaceSettings | null;
576
+ roleId: string;
577
+ isOwner: boolean;
578
+ }>;
579
+ create(params: CreateWorkspaceParams): Promise<{
580
+ workspace: WorkspaceDetail;
581
+ }>;
582
+ update(workspaceId: string, params: UpdateWorkspaceParams): Promise<void>;
583
+ updateSettings(workspaceId: string, settings: Partial<WorkspaceSettings>): Promise<void>;
584
+ delete(workspaceId: string): Promise<void>;
585
+ }
586
+
587
+ declare class FileRequestsResource {
588
+ private readonly http;
589
+ constructor(http: HttpClient);
590
+ create(params: CreateFileRequestParams): Promise<{
591
+ request: {
592
+ id: string;
593
+ token: string;
594
+ url: string;
595
+ title: string | null;
596
+ expiresAt: number | null;
597
+ };
598
+ }>;
599
+ get(requestId: string): Promise<{
600
+ request: FileRequestDetail;
601
+ }>;
602
+ update(requestId: string, params: {
603
+ title?: string;
604
+ message?: string;
605
+ }): Promise<void>;
606
+ delete(requestId: string): Promise<void>;
607
+ listUploads(requestId: string): Promise<{
608
+ uploads: Array<{
609
+ id: string;
610
+ fileName: string;
611
+ sizeBytes: number;
612
+ mimeType: string;
613
+ uploadedAt: number;
614
+ uploaderEmail: string | null;
615
+ }>;
616
+ }>;
617
+ listRecipients(requestId: string): Promise<{
618
+ recipients: Array<{
619
+ id: string;
620
+ email: string;
621
+ status: string;
622
+ sentAt: number;
623
+ }>;
624
+ }>;
625
+ resend(requestId: string, recipientIds?: string[]): Promise<void>;
626
+ }
627
+
628
+ declare class SearchResource {
629
+ private readonly http;
630
+ constructor(http: HttpClient);
631
+ query(params: SearchParams): Promise<SearchResponse>;
632
+ }
633
+
634
+ declare class CommentsResource {
635
+ private readonly http;
636
+ constructor(http: HttpClient);
637
+ list(params: {
638
+ workspaceId: string;
639
+ fileId?: string;
640
+ folderId?: string;
641
+ }): Promise<{
642
+ comments: CommentDetail[];
643
+ }>;
644
+ create(params: CreateCommentParams): Promise<{
645
+ comment: CommentDetail;
646
+ }>;
647
+ edit(commentId: string, body: string): Promise<{
648
+ body: string;
649
+ updatedAt: number;
650
+ }>;
651
+ delete(commentId: string): Promise<void>;
652
+ }
653
+
654
+ declare class MeResource {
655
+ private readonly http;
656
+ constructor(http: HttpClient);
657
+ profile(): Promise<{
658
+ user: UserProfile;
659
+ }>;
660
+ listApiKeys(): Promise<{
661
+ keys: ApiKeyItem[];
662
+ }>;
663
+ createApiKey(params: CreateApiKeyParams): Promise<{
664
+ key: CreatedApiKey;
665
+ }>;
666
+ deleteApiKey(keyId: string): Promise<void>;
667
+ }
668
+
669
+ declare class ActivityResource {
670
+ private readonly http;
671
+ constructor(http: HttpClient);
672
+ list(params: ListActivityParams): Promise<ActivityListResponse>;
673
+ }
674
+
675
+ declare class DosyaClient {
676
+ readonly files: FilesResource;
677
+ readonly folders: FoldersResource;
678
+ readonly upload: UploadResource;
679
+ readonly download: DownloadResource;
680
+ readonly shares: SharesResource;
681
+ readonly workspaces: WorkspacesResource;
682
+ readonly fileRequests: FileRequestsResource;
683
+ readonly search: SearchResource;
684
+ readonly comments: CommentsResource;
685
+ readonly me: MeResource;
686
+ readonly activity: ActivityResource;
687
+ constructor(options: DosyaClientOptions);
688
+ }
689
+
690
+ declare class DosyaError extends Error {
691
+ constructor(message: string);
692
+ }
693
+ declare class DosyaApiError extends DosyaError {
694
+ readonly status: number;
695
+ readonly errorMessage: string;
696
+ readonly raw: unknown;
697
+ constructor(status: number, errorMessage: string, raw?: unknown);
698
+ }
699
+ declare class DosyaNetworkError extends DosyaError {
700
+ readonly cause: unknown;
701
+ constructor(message: string, options?: {
702
+ cause?: unknown;
703
+ });
704
+ }
705
+ declare class DosyaUploadError extends DosyaError {
706
+ readonly sessionId: string;
707
+ readonly partNumber?: number;
708
+ constructor(message: string, sessionId: string, partNumber?: number);
709
+ }
710
+
711
+ export { type ActivityEntry, type ActivityListResponse, type ApiKeyItem, type Breadcrumb, type CommentDetail, type CreateApiKeyParams, type CreateCommentParams, type CreateFileRequestParams, type CreateFolderParams, type CreateShareBundleParams, type CreateShareLinkParams, type CreateWorkspaceParams, type CreatedApiKey, DosyaApiError, DosyaClient, type DosyaClientOptions, DosyaError, DosyaNetworkError, DosyaUploadError, type DownloadOptions, type FileDetail, type FileListItem, type FileRequestDetail, type FileVersion, type FolderDetail, type FolderListItem, type FolderTreeItem, type ListActivityParams, type ListFilesParams, type ListFilesResponse, type LockInfo, type PaginationMeta, type RateLimitInfo, type RequestOptions, type RetryOptions, type SearchParams, type SearchResponse, type SetHideParams, type SetLockParams, type ShareEmailParams, type ShareLinkDetail, type SharesListResponse, type UpdateWorkspaceParams, type UploadInitResponse, type UploadParams, type UploadProgress, type UploadResult, type UploadSource, type UploadStatusResponse, type UserProfile, type WorkspaceDetail, type WorkspaceListItem, type WorkspaceSettings };