cloud189-sdk 1.0.9 → 1.0.10-beta.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.
@@ -1,889 +0,0 @@
1
- import { CancelableRequest } from 'got/dist/source';
2
- import { Got } from 'got';
3
- import { Logger } from '@netdrive-sdk/log';
4
-
5
- /**
6
- * accessToken 结果
7
- * @public
8
- */
9
- export declare interface AccessTokenResponse {
10
- /**
11
- * accessToken
12
- */
13
- accessToken: string;
14
- /**
15
- * accessToken 的有效期 单位秒
16
- */
17
- expiresIn: number;
18
- }
19
-
20
- /**
21
- * @public
22
- */
23
- export declare interface CacheQuery {
24
- captchaToken: string;
25
- reqId: string;
26
- lt: string;
27
- paramId: string;
28
- }
29
-
30
- /**
31
- * 容量信息
32
- * @public
33
- */
34
- export declare interface CapacityInfo {
35
- /**
36
- * 总空间 单位KB
37
- */
38
- totalSize: number;
39
- /**
40
- * 已使用空间 单位KB
41
- */
42
- usedSize: number;
43
- /**
44
- * 剩余空间 单位KB
45
- */
46
- freeSize: number;
47
- }
48
-
49
- /**
50
- * @public
51
- */
52
- export declare interface ClientSession {
53
- accessToken: string;
54
- sessionKey: string;
55
- }
56
-
57
- /**
58
- * @public
59
- */
60
- export declare class CloudAuthClient {
61
- #private;
62
- readonly authRequest: Got;
63
- constructor();
64
- /**
65
- * 获取加密参数
66
- * @returns
67
- */
68
- getEncrypt(): Promise<{
69
- data: {
70
- pubKey: string;
71
- pre: string;
72
- };
73
- }>;
74
- getLoginForm(): Promise<CacheQuery>;
75
- getSessionForPC(param: {
76
- redirectURL?: string;
77
- accessToken?: string;
78
- }): Promise<TokenSession>;
79
- /**
80
- * 用户名密码登录
81
- * */
82
- loginByPassword(username: string, password: string): Promise<TokenSession>;
83
- /**
84
- * token登录
85
- */
86
- loginByAccessToken(accessToken: string): Promise<TokenSession>;
87
- /**
88
- * sso登录
89
- */
90
- loginBySsoCooike(cookie: string): Promise<TokenSession>;
91
- /**
92
- * 刷新token
93
- */
94
- refreshToken(refreshToken: string): Promise<RefreshTokenSession>;
95
- /**
96
- * Get QR code data for scanning login
97
- * @returns QR code data including uuid for display
98
- */
99
- getQRCode(): Promise<QRCodeData>;
100
- /**
101
- * Check QR code scan status
102
- * @param qrData - QR code data from getQRCode
103
- * @returns status and redirectUrl on success
104
- */
105
- checkQRCodeStatus(qrData: QRCodeData): Promise<QRCodeStatusResponse>;
106
- /**
107
- * QR code login with polling
108
- * @param onQRReady - callback invoked with QR code URL for display
109
- * @param options - polling interval and timeout
110
- * @returns token session
111
- */
112
- loginByQRCode(onQRReady: (qrUrl: string) => void, options?: QRLoginOptions): Promise<TokenSession>;
113
- }
114
-
115
- /**
116
- * 天翼网盘客户端
117
- * @public
118
- */
119
- export declare class CloudClient {
120
- #private;
121
- username: string;
122
- password: string;
123
- ssonCookie: string;
124
- tokenStore: Store;
125
- readonly request: Got;
126
- readonly authClient: CloudAuthClient;
127
- readonly session: ClientSession;
128
- private rsaKey;
129
- private sessionKeyPromise;
130
- private accessTokenPromise;
131
- private generateRsaKeyPromise;
132
- private onQRCodeReady?;
133
- private qrLoginOptions?;
134
- constructor(_options: ConfigurationOptions);
135
- getSession(): Promise<TokenSession>;
136
- /**
137
- * 获取 sessionKey
138
- * @returns sessionKey
139
- */
140
- getSessionKey(): Promise<string>;
141
- /**
142
- * 获取 accessToken
143
- * @returns accessToken
144
- */
145
- getAccessToken(): Promise<string>;
146
- /**
147
- * 获取 RSA key
148
- * @returns RSAKey
149
- */
150
- generateRsaKey(): Promise<RsaKey>;
151
- /**
152
- * 获取用户网盘存储容量信息
153
- * @returns 账号容量结果
154
- */
155
- getUserSizeInfo(): Promise<UserSizeInfoResponse>;
156
- /**
157
- * 个人签到任务
158
- * @returns 签到结果
159
- */
160
- userSign(): Promise<UserSignResponse>;
161
- /**
162
- * 获取家庭信息
163
- * @returns 家庭列表信息
164
- */
165
- getFamilyList(): Promise<FamilyListResponse>;
166
- /**
167
- * 家庭签到任务
168
- * @param familyId - 家庭id
169
- * @returns 签到结果
170
- * @deprecated 已无效
171
- */
172
- familyUserSign(familyId: string): Promise<FamilyUserSignResponse>;
173
- /**
174
- * 获取文件列表
175
- * @param pageQuery - 查询参数
176
- * @returns
177
- */
178
- getListFiles(pageQuery?: PageQuery, familyId?: string): Promise<FileListResponse>;
179
- /**
180
- * 创建文件夹
181
- * @param createFolderRequest - 创建文件夹请求
182
- * @returns
183
- */
184
- createFolder(createFolderRequest: CreateFolderRequest | CreateFamilyFolderRequest): Promise<{
185
- id: string;
186
- name: string;
187
- parentId: string;
188
- }>;
189
- /**
190
- * 重命名文件夹
191
- * @param renameFolderRequest - 重名文件夹请求
192
- * @returns
193
- */
194
- renameFolder(renameFolderRequest: RenameFolderRequest | RenameFamilyFolderRequest): CancelableRequest<unknown>;
195
- /**
196
- * 初始化上传
197
- * @param initMultiUploadRequest - 初始化请求
198
- * @returns
199
- */
200
- initMultiUpload(initMultiUploadRequest: initMultiUploadRequest | initMultiFamilyUploadRequest): Promise<UploadInitResponse>;
201
- /**
202
- * 提交上传
203
- * @param commitMultiUploadRequest - 提交请求
204
- * @returns
205
- */
206
- commitMultiUpload(commitMultiUploadRequest: CommitMultiUploadRequest | CommitMultiFamilyUploadRequest): CancelableRequest<UploadCommitResponse>;
207
- /**
208
- * 检测秒传
209
- * @param params - 检查参数
210
- * @returns
211
- */
212
- checkTransSecond(params: {
213
- fileMd5: string;
214
- sliceMd5: string;
215
- uploadFileId: string;
216
- familyId?: number;
217
- }): CancelableRequest<UploadInitResponse>;
218
- /**
219
- * 文件上传
220
- * @param param - 上传参数
221
- * @param callbacks - 上传回调
222
- * @returns
223
- */
224
- upload(param: {
225
- parentFolderId: string;
226
- filePath: string;
227
- familyId?: string;
228
- }, callbacks?: UploadCallbacks): Promise<{
229
- fileDataExists: number;
230
- file: {
231
- userFileId: string;
232
- fileName: string;
233
- fileSize: number;
234
- fileMd5: string;
235
- createDate: string;
236
- rev: number;
237
- userId: number;
238
- };
239
- code: string;
240
- }>;
241
- /**
242
- * 检测任务状态
243
- * @param type - 任务类型
244
- * @param taskId - 任务Id
245
- * @param maxAttempts - 重试次数
246
- * @param interval - 重试间隔
247
- * @returns
248
- */
249
- checkTaskStatus(type: string, taskId: string, maxAttempts?: number, interval?: number): Promise<{
250
- successedFileIdList?: number[];
251
- taskId: string;
252
- taskStatus: number;
253
- }>;
254
- /**
255
- * 创建任务
256
- * @param createBatchTaskRequest - 创建任务参数
257
- * @returns
258
- */
259
- createBatchTask(createBatchTaskRequest: CreateBatchTaskRequest | CreateFamilyBatchTaskRequest): Promise<{
260
- successedFileIdList?: number[];
261
- taskId: string;
262
- taskStatus: number;
263
- }>;
264
- /**
265
- * 获取文件下载路径
266
- * @param params - 文件参数
267
- * @returns
268
- */
269
- getFileDownloadUrl(params: {
270
- fileId: string;
271
- familyId?: string;
272
- }): CancelableRequest< {
273
- fileDownloadUrl: string;
274
- }>;
275
- }
276
-
277
- /**
278
- * 提交家庭上传请求
279
- * @public
280
- */
281
- export declare interface CommitMultiFamilyUploadRequest extends FamilyRequest, CommitMultiUploadRequest {
282
- }
283
-
284
- /**
285
- * 提交个人上传请求
286
- * @public
287
- */
288
- export declare interface CommitMultiUploadRequest {
289
- fileMd5: string;
290
- sliceMd5: string;
291
- uploadFileId: string;
292
- lazyCheck?: number;
293
- }
294
-
295
- /**
296
- * 客户端初始化参数
297
- * @public
298
- */
299
- export declare interface ConfigurationOptions {
300
- /** Login username */
301
- username?: string;
302
- /** Login password */
303
- password?: string;
304
- /** Token store */
305
- token?: Store;
306
- ssonCookie?: string;
307
- /** Callback invoked with QR code URL when ready for scanning */
308
- onQRCodeReady?: (qrUrl: string) => void;
309
- /** QR code login options */
310
- qrLoginOptions?: QRLoginOptions;
311
- }
312
-
313
- /**
314
- * @public
315
- */
316
- export declare interface CreateBatchTaskRequest {
317
- type: TaskType;
318
- taskInfos: [
319
- {
320
- fileId: string;
321
- fileName?: string;
322
- isFolder: number;
323
- srcParentId?: string;
324
- }
325
- ];
326
- targetFolderId?: string;
327
- }
328
-
329
- /**
330
- * @public
331
- */
332
- export declare interface CreateFamilyBatchTaskRequest extends FamilyRequest, CreateBatchTaskRequest {
333
- }
334
-
335
- /**
336
- * 创建家庭文件夹
337
- * @public
338
- */
339
- export declare interface CreateFamilyFolderRequest extends FamilyRequest, CreateFolderRequest {
340
- }
341
-
342
- /**
343
- * 创建个人文件夹
344
- * @public
345
- */
346
- export declare interface CreateFolderRequest {
347
- parentFolderId: string;
348
- folderName: string;
349
- }
350
-
351
- /**
352
- * 账户家庭信息
353
- * @public
354
- */
355
- export declare interface FamilyListResponse {
356
- familyInfoResp: [
357
- {
358
- /**
359
- * 家庭id
360
- */
361
- familyId: string;
362
- /**
363
- * 家庭名称
364
- */
365
- remarkName: string;
366
- /**
367
- * 类型
368
- */
369
- type: number;
370
- /**
371
- * 用户角色 如果是1 表明当前账户是该账户的主家庭 否则当前账户是其他家庭的成员账户
372
- */
373
- userRole: number;
374
- }
375
- ];
376
- }
377
-
378
- /**
379
- * 家庭请求
380
- * @public
381
- */
382
- export declare interface FamilyRequest {
383
- familyId: string;
384
- }
385
-
386
- /**
387
- * 家庭签到任务结果
388
- * @public
389
- */
390
- export declare interface FamilyUserSignResponse {
391
- /**
392
- * 签到的奖励容量 单位MB
393
- */
394
- bonusSpace: number;
395
- /**
396
- * 签到的家庭id
397
- */
398
- signFamilyId: number;
399
- /**
400
- * 签到的状态
401
- */
402
- signStatus: number;
403
- /**
404
- * 签到的时间
405
- */
406
- signTime: string;
407
- /**
408
- * 签到的用户
409
- */
410
- userId: string;
411
- }
412
-
413
- /**
414
- * 文件项详细信息
415
- * @public
416
- */
417
- export declare interface FileItem {
418
- /** 文件创建时间,格式:YYYY-MM-DD HH:mm:ss */
419
- createDate: string;
420
- /**
421
- * 收藏标签
422
- * 0-未收藏 | 1-已收藏
423
- */
424
- favoriteLabel: number;
425
- /** 文件图标信息 */
426
- icon: {
427
- /** 大尺寸图标URL */
428
- largeUrl: string;
429
- /** 小尺寸图标URL */
430
- smallUrl: string;
431
- };
432
- /** 文件唯一标识ID */
433
- id: string;
434
- /** 最后操作时间,格式:YYYY-MM-DD HH:mm:ss */
435
- lastOpTime: string;
436
- /** 文件MD5哈希值,用于文件校验 */
437
- md5: string;
438
- /**
439
- * 媒体类型
440
- * 1-图片 | 2-视频 | 3-音频 | 4-文档
441
- */
442
- mediaType: number;
443
- /** 文件名 */
444
- name: string;
445
- /**
446
- * 图片方向
447
- * 0-正常 | 1-90° | 2-180° | 3-270°
448
- */
449
- orientation: number;
450
- /** 父目录ID */
451
- parentId: string;
452
- /** 文件版本标识,格式:YYYYMMDDHHmmss */
453
- rev: string;
454
- /** 文件大小(字节) */
455
- size: number;
456
- /**
457
- * 星标标签
458
- * 1-普通 | 2-标星
459
- */
460
- starLabel: number;
461
- }
462
-
463
- /**
464
- * 文件列表数据对象
465
- * @public
466
- */
467
- export declare interface FileListAO {
468
- /** 文件总数 */
469
- count: number;
470
- /** 文件项列表 */
471
- fileList: FileItem[];
472
- /** 文件夹项列表 */
473
- folderList: FolderItem[];
474
- }
475
-
476
- /**
477
- * 文件列表API响应数据结构
478
- * @public
479
- */
480
- export declare interface FileListResponse {
481
- /** 文件列表数据对象 */
482
- fileListAO: FileListAO;
483
- /**
484
- * 最后修订版本号
485
- * 用于增量同步的时间戳或版本标识
486
- */
487
- lastRev: number;
488
- }
489
-
490
- /**
491
- * @public
492
- */
493
- export declare class FileTokenStore extends MemoryStore {
494
- #private;
495
- filePath: string;
496
- constructor(filePath: string);
497
- private ensureTokenDirectory;
498
- update(token: {
499
- accessToken: string;
500
- refreshToken?: string;
501
- expiresIn?: number;
502
- }): Promise<void>;
503
- }
504
-
505
- /**
506
- * 文件夹项详细信息
507
- * @public
508
- */
509
- export declare interface FolderItem {
510
- /** 文件夹创建时间,格式:YYYY-MM-DD HH:mm:ss */
511
- createDate: string;
512
- /** 文件夹内文件数量 */
513
- fileCount: number;
514
- /** 文件夹唯一标识ID */
515
- id: string;
516
- /** 最后操作时间,格式:YYYY-MM-DD HH:mm:ss */
517
- lastOpTime: string;
518
- /** 文件夹名称 */
519
- name: string;
520
- /** 父目录ID */
521
- parentId: string;
522
- /** 文件夹版本标识,格式:YYYYMMDDHHmmss */
523
- rev: string;
524
- /**
525
- * 星标标签
526
- * 1-普通 | 2-标星
527
- */
528
- starLabel: number;
529
- }
530
-
531
- /**
532
- * 初始化家庭上传请求
533
- * @public
534
- */
535
- export declare interface initMultiFamilyUploadRequest extends FamilyRequest, initMultiUploadRequest {
536
- }
537
-
538
- /**
539
- * 初始化个人上传请求
540
- * @public
541
- */
542
- export declare interface initMultiUploadRequest {
543
- parentFolderId: string;
544
- fileName: string;
545
- fileSize: number;
546
- sliceSize: number;
547
- fileMd5?: string;
548
- sliceMd5?: string;
549
- }
550
-
551
- /**
552
- * 日志记录
553
- * @public
554
- */
555
- export declare const logger: Logger;
556
-
557
- /**
558
- * 文件类型
559
- * @public
560
- */
561
- export declare enum MediaType {
562
- ALL = 0,
563
- IMAGE = 1,
564
- MUSIC = 2,
565
- VIDEO = 3,
566
- TXT = 4
567
- }
568
-
569
- /**
570
- * @public
571
- */
572
- export declare class MemoryStore extends Store {
573
- store: {
574
- accessToken: string;
575
- refreshToken: string;
576
- expiresIn: number;
577
- };
578
- constructor();
579
- get(): {
580
- accessToken: string;
581
- refreshToken: string;
582
- expiresIn: number;
583
- };
584
- update(token: {
585
- accessToken: string;
586
- refreshToken?: string;
587
- expiresIn?: number;
588
- }): void;
589
- }
590
-
591
- /**
592
- * @public
593
- */
594
- export declare interface MultiUploadUrlsResponse extends UploadResponse {
595
- uploadUrls: {
596
- [key: PartNumberKey]: {
597
- requestURL: string;
598
- requestHeader: string;
599
- };
600
- };
601
- }
602
-
603
- /**
604
- * 排序类型
605
- * @public
606
- */
607
- export declare enum OrderByType {
608
- NAME = 1,
609
- SIZE = 2,
610
- LAST_OP_TIME = 3
611
- }
612
-
613
- /**
614
- * 分页参数
615
- * @public
616
- */
617
- export declare interface PageQuery {
618
- /**
619
- * 分页大小 默认60
620
- */
621
- pageSize?: number;
622
- /**
623
- * 页码 默认1
624
- */
625
- pageNum?: number;
626
- /**
627
- * 文件类型
628
- * 0 全部 1 图片 2 视频 3 文档
629
- */
630
- mediaType?: MediaType;
631
- /**
632
- * 文件夹Id
633
- */
634
- folderId?: string;
635
- /**
636
- * 未知参数 5
637
- */
638
- iconOption?: number;
639
- /**
640
- * 排序类型
641
- * 1 文件名称 2 文件大小 3 文件修改时间
642
- */
643
- orderBy?: OrderByType;
644
- /**
645
- * 是否倒序
646
- */
647
- descending?: boolean;
648
- }
649
-
650
- /**
651
- * @public
652
- */
653
- export declare type PartNumberKey = `partNumber_${number}`;
654
-
655
- /**
656
- * QR code data returned by getQRCode, used for polling status
657
- * @public
658
- */
659
- export declare interface QRCodeData {
660
- uuid: string;
661
- encryuuid: string;
662
- reqId: string;
663
- lt: string;
664
- paramId: string;
665
- }
666
-
667
- /**
668
- * QR code scan status enum
669
- * @public
670
- */
671
- export declare enum QRCodeStatus {
672
- /** Login success */
673
- SUCCESS = 0,
674
- /** Waiting for user to scan */
675
- WAITING = -106,
676
- /** User scanned, waiting for confirmation on device */
677
- SCANNED = -11002,
678
- /** QR code expired */
679
- EXPIRED = -11001
680
- }
681
-
682
- /**
683
- * QR code status check response
684
- * @public
685
- */
686
- export declare interface QRCodeStatusResponse {
687
- status: QRCodeStatus | number;
688
- redirectUrl?: string;
689
- }
690
-
691
- /**
692
- * QR code login options
693
- * @public
694
- */
695
- export declare interface QRLoginOptions {
696
- /** Polling interval in ms, default 3000 */
697
- pollInterval?: number;
698
- /** Timeout in ms, default 120000 */
699
- timeout?: number;
700
- }
701
-
702
- /**
703
- * @public
704
- */
705
- export declare interface RefreshTokenSession {
706
- expiresIn: number;
707
- accessToken: string;
708
- refreshToken: string;
709
- }
710
-
711
- /**
712
- * 创建家庭文件夹
713
- * @public
714
- */
715
- export declare interface RenameFamilyFolderRequest extends FamilyRequest, RenameFolderRequest {
716
- }
717
-
718
- /**
719
- * 创建个人文件夹
720
- * @public
721
- */
722
- export declare interface RenameFolderRequest {
723
- folderId: string;
724
- folderName: string;
725
- }
726
-
727
- /**
728
- * @public
729
- */
730
- export declare interface RsaKey {
731
- expire: number;
732
- pkId: string;
733
- pubKey: string;
734
- ver: string;
735
- }
736
-
737
- /**
738
- * RsaKey响应
739
- * @public
740
- */
741
- export declare interface RsaKeyResponse extends RsaKey {
742
- res_code: number;
743
- res_message: string;
744
- }
745
-
746
- /**
747
- * @public
748
- */
749
- export declare abstract class Store {
750
- constructor();
751
- abstract get(): {
752
- accessToken: string;
753
- refreshToken: string;
754
- expiresIn: number;
755
- } | Promise<{
756
- accessToken: string;
757
- refreshToken: string;
758
- expiresIn: number;
759
- }>;
760
- abstract update(token: {
761
- accessToken: string;
762
- refreshToken?: string;
763
- expiresIn?: number;
764
- }): void | Promise<void>;
765
- }
766
-
767
- /**
768
- * @public
769
- */
770
- export declare type TaskType = 'DELETE' | 'MOVE' | 'COPY';
771
-
772
- /**
773
- * @public
774
- * accessToken 有效期7天,可以通过refreshToken取新的accessToken
775
- */
776
- export declare interface TokenSession {
777
- res_code: number;
778
- res_message: string;
779
- accessToken: string;
780
- familySessionKey: string;
781
- familySessionSecret: string;
782
- refreshToken: string;
783
- loginName: string;
784
- sessionKey: string;
785
- }
786
-
787
- /**
788
- * @public
789
- */
790
- export declare interface UploadCallbacks {
791
- onProgress?: (progress: number) => void;
792
- onComplete?: (response: any) => void;
793
- onError?: (error: Error) => void;
794
- }
795
-
796
- /**
797
- * @public
798
- */
799
- export declare interface UploadCommitResponse extends UploadResponse {
800
- file: {
801
- userFileId: string;
802
- fileName: string;
803
- fileSize: number;
804
- fileMd5: string;
805
- createDate: string;
806
- rev: number;
807
- userId: number;
808
- };
809
- /**
810
- * 是否快传
811
- */
812
- fileDataExists: number;
813
- }
814
-
815
- /**
816
- * @public
817
- */
818
- export declare interface UploadInitResponse extends UploadResponse {
819
- data: {
820
- uploadType: number;
821
- uploadHost: string;
822
- uploadFileId: string;
823
- fileDataExists: number;
824
- };
825
- }
826
-
827
- /**
828
- * @public
829
- */
830
- export declare interface UploadPartsInfoResponse extends UploadResponse {
831
- data: {
832
- uploadFileId: string;
833
- uploadedPartList: string;
834
- };
835
- }
836
-
837
- /**
838
- * @public
839
- */
840
- export declare interface UploadResponse {
841
- code: string;
842
- }
843
-
844
- /**
845
- * 个人签到结果
846
- * @public
847
- */
848
- export declare interface UserSignResponse {
849
- /**
850
- * 是否已经签到过
851
- */
852
- isSign: boolean;
853
- /**
854
- * 签到获取的容量奖励 单位MB
855
- */
856
- netdiskBonus: number;
857
- }
858
-
859
- /**
860
- * 账户容量信息
861
- * @public
862
- */
863
- export declare interface UserSizeInfoResponse {
864
- /**
865
- * 个人容量信息
866
- */
867
- cloudCapacityInfo: CapacityInfo;
868
- /**
869
- * 家庭容量信息
870
- */
871
- familyCapacityInfo: CapacityInfo;
872
- }
873
-
874
- /**
875
- * 个人任务执行结果
876
- * @public
877
- */
878
- export declare interface UserTaskResponse {
879
- /**
880
- * 错误码
881
- */
882
- errorCode: string;
883
- /**
884
- * 奖励容量 单位MB
885
- */
886
- prizeName: string;
887
- }
888
-
889
- export { }