@cloudbase/js-sdk 2.5.15-beta.0 → 2.5.18-beta.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.
package/index.d.ts CHANGED
@@ -1,3 +1,7 @@
1
+ import { CloudbaseAdapter } from '@cloudbase/adapter-interface';
2
+ import { ICloudbaseUpgradedConfig, ICloudbase } from '@cloudbase/types';
3
+ import { authModels } from './oauth/src';
4
+
1
5
  type KV<T> = {
2
6
  [key: string]: T;
3
7
  };
@@ -8,7 +12,7 @@ type ExcludeOf<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
8
12
  * module
9
13
  */
10
14
  declare namespace cloudbase {
11
-
15
+
12
16
  interface SimpleStorage {
13
17
  getItem: (key: string) => Promise<string | null>;
14
18
  removeItem: (key: string) => Promise<void>;
@@ -22,15 +26,17 @@ declare namespace cloudbase {
22
26
  env: string;
23
27
  region?: string;
24
28
  timeout?: number;
25
- persistence?: cloudbase.auth.Persistence;
29
+ persistence?: Persistence;
30
+ oauthClient?: any
26
31
  debug?: boolean;
27
- clientId?: string;
28
- storage?: SimpleStorage;
32
+ _fromApp?: ICloudbase;
33
+ clientId?: string
34
+ oauthInstance?: any;
29
35
  }
30
36
 
31
37
  interface ICloudbaseExtension {
32
38
  name: string;
33
- invoke(opts: any, app: cloudbase.app.App): Promise<any>;
39
+ invoke(opts: any, app: ICloudbase): Promise<any>;
34
40
  }
35
41
 
36
42
  interface Listeners {
@@ -82,8 +88,10 @@ declare namespace cloudbase {
82
88
  * @return {!cloudbase.app.App} 初始化成功的Cloudbase实例
83
89
  */
84
90
  function init(config: ICloudbaseConfig): cloudbase.app.App;
91
+
92
+ function updateConfig(config: ICloudbaseUpgradedConfig): void;
85
93
  /**
86
- * 使用适配器,使用方式参考 {@link https://docs.cloudbase.net/api-reference/webv2/adapter.html#di-1-bu-an-zhuang-bing-yin-ru-gua-pei-qi}
94
+ * 使用适配器,使用方式参考 {@link https://docs.cloudbase.net/api-reference/webv3/adapter#%E7%AC%AC-1-%E6%AD%A5%E5%AE%89%E8%A3%85%E5%B9%B6%E5%BC%95%E5%85%A5%E9%80%82%E9%85%8D%E5%99%A8}
87
95
  *
88
96
  * @example
89
97
  * ```javascript
@@ -96,7 +104,7 @@ declare namespace cloudbase {
96
104
  *
97
105
  * @param adapters 适配器对象,入参可以为单个适配器对象,也可以是多个适配器对象的数组
98
106
  */
99
- function useAdapters(adapters: any): void;
107
+ function useAdapters(adapters: CloudbaseAdapter | CloudbaseAdapter[]): void;
100
108
  /**
101
109
  * 注册扩展能力插件,使用方式参考 {@link https://docs.cloudbase.net/extension/abilities/image-examination.html#shi-yong-kuo-zhan}
102
110
  *
@@ -173,7 +181,7 @@ declare namespace cloudbase.app {
173
181
  /**
174
182
  * 创建Auth对象
175
183
  *
176
- * {@link https://docs.cloudbase.net/api-reference/webv2/authentication.html#app-auth}
184
+ * {@link https://docs.cloudbase.net/api-reference/webv3/authentication#appauth}
177
185
  *
178
186
  * @example
179
187
  * ```javascript
@@ -196,7 +204,7 @@ declare namespace cloudbase.app {
196
204
  /**
197
205
  * 调用云函数
198
206
  *
199
- * {@link https://docs.cloudbase.net/api-reference/webv2/functions.html#callfunction}
207
+ * {@link https://docs.cloudbase.net/api-reference/webv3/functions#callfunction}
200
208
  *
201
209
  * @example
202
210
  * ```javascript
@@ -221,11 +229,11 @@ declare namespace cloudbase.app {
221
229
  *
222
230
  * @return Promise-函数执行结果
223
231
  */
224
- callFunction(options: cloudbase.functions.ICallFunctionOptions): Promise<cloudbase.functions.ICallFunctionResponse>;
232
+ callFunction(options: cloudbase.functions.ICallFunctionOptions, callback?: Function): Promise<cloudbase.functions.ICallFunctionResponse>;
225
233
  /**
226
234
  * 云存储-上传文件
227
235
  *
228
- * {@link https://docs.cloudbase.net/api-reference/webv2/storage.html#uploadfile}
236
+ * {@link https://docs.cloudbase.net/api-reference/webv3/storage#uploadfile}
229
237
  *
230
238
  * @example
231
239
  * ```javascript
@@ -252,11 +260,11 @@ declare namespace cloudbase.app {
252
260
  *
253
261
  * @return Promise-上传结果
254
262
  */
255
- uploadFile(params: cloudbase.storage.ICloudbaseUploadFileParams): Promise<cloudbase.storage.ICloudbaseUploadFileResult>;
263
+ uploadFile(params: cloudbase.storage.ICloudbaseUploadFileParams, callback?: Function): Promise<cloudbase.storage.ICloudbaseUploadFileResult>;
256
264
  /**
257
265
  * 云存储-下载文件
258
266
  *
259
- * {@link https://docs.cloudbase.net/api-reference/webv2/storage.html#downloadfile}
267
+ * {@link https://docs.cloudbase.net/api-reference/webv3/storage#downloadfile}
260
268
  *
261
269
  * @example
262
270
  * ```javascript
@@ -273,11 +281,11 @@ declare namespace cloudbase.app {
273
281
  *
274
282
  * @return Promise-下载结果
275
283
  */
276
- downloadFile(params: cloudbase.storage.ICloudbaseDownloadFileParams): Promise<cloudbase.storage.ICloudbaseDownloadFileResult>;
284
+ downloadFile(params: cloudbase.storage.ICloudbaseDownloadFileParams, callback?: Function): Promise<cloudbase.storage.ICloudbaseDownloadFileResult>;
277
285
  /**
278
286
  * 云存储-获取文件的下载链接
279
287
  *
280
- * {@link https://docs.cloudbase.net/api-reference/webv2/storage.html#gettempfileurl}
288
+ * {@link https://docs.cloudbase.net/api-reference/webv3/storage#gettempfileurl}
281
289
  *
282
290
  * @example
283
291
  * ```javascript
@@ -302,11 +310,11 @@ declare namespace cloudbase.app {
302
310
  *
303
311
  * @return Promise-文件下载链接
304
312
  */
305
- getTempFileURL(params: cloudbase.storage.ICloudbaseGetTempFileURLParams): Promise<cloudbase.storage.ICloudbaseGetTempFileURLResult>;
313
+ getTempFileURL(params: cloudbase.storage.ICloudbaseGetTempFileURLParams, callback?: Function): Promise<cloudbase.storage.ICloudbaseGetTempFileURLResult>;
306
314
  /**
307
315
  * 云存储-删除文件
308
316
  *
309
- * {@link https://docs.cloudbase.net/api-reference/webv2/storage.html#deletefile}
317
+ * {@link https://docs.cloudbase.net/api-reference/webv3/storage#deletefile}
310
318
  *
311
319
  * @example
312
320
  * ```javascript
@@ -326,11 +334,19 @@ declare namespace cloudbase.app {
326
334
  *
327
335
  * @return Promise-删除结果
328
336
  */
329
- deleteFile(params: cloudbase.storage.ICloudbaseDeleteFileParams): Promise<cloudbase.storage.ICloudbaseDeleteFileResult>;
337
+ deleteFile(params: cloudbase.storage.ICloudbaseDeleteFileParams, callback?: Function): Promise<cloudbase.storage.ICloudbaseDeleteFileResult>;
338
+ /**
339
+ * 云存储-获取上传元信息
340
+ *
341
+ *
342
+ * @param params
343
+ * @param callback
344
+ */
345
+ getUploadMetadata(params: cloudbase.storage.ICloudbaseGetUploadMetadataParams, callback?: Function): Promise<any>;
330
346
  /**
331
347
  * 获取数据库实例
332
348
  *
333
- * {@link https://docs.cloudbase.net/api-reference/webv2/database.html#huo-qu-shu-ju-ku-shi-li}
349
+ * {@link https://docs.cloudbase.net/api-reference/webv3/database#%E8%8E%B7%E5%8F%96%E6%95%B0%E6%8D%AE%E5%BA%93%E5%AE%9E%E4%BE%8B}
334
350
  *
335
351
  * @example
336
352
  * ```javascript
@@ -344,7 +360,7 @@ declare namespace cloudbase.app {
344
360
  */
345
361
  database(): cloudbase.database.App;
346
362
  /**
347
- * 调用扩展能力插件功能,使用方式参考 {@link https://docs.cloudbase.net/extension/abilities/image-examination.html#shi-yong-kuo-zhan}
363
+ * 调用扩展能力插件功能
348
364
  *
349
365
  * @example
350
366
  * ```javascript
@@ -384,405 +400,51 @@ declare namespace cloudbase.auth {
384
400
  interface ILoginState {
385
401
  /**
386
402
  * 当前登录用户的信息
387
- *
388
- * {@link https://docs.cloudbase.net/api-reference/webv2/authentication.html#loginstate-user}
389
403
  */
390
404
  user: IUser;
391
- /**
392
- * 当前是否为匿名登录
393
- *
394
- * {@link https://docs.cloudbase.net/api-reference/webv2/authentication.html#loginstate-isanonymousauth}
395
- */
396
- isAnonymousAuth: boolean;
397
- /**
398
- * 当前是否为自定义登录
399
- *
400
- * {@link https://docs.cloudbase.net/api-reference/webv2/authentication.html#loginstate-iscustomauth}
401
- */
402
- isCustomAuth: boolean;
403
- /**
404
- * 当前是否为微信登录
405
- *
406
- * {@link https://docs.cloudbase.net/api-reference/webv2/authentication.html#loginstate-isweixinauth}
407
- */
408
- isWeixinAuth: boolean;
409
- /**
410
- * 当前是否为用户名密码登录
411
- *
412
- * {@link https://docs.cloudbase.net/api-reference/webv2/authentication.html#loginstate-isusernameauth}
413
- */
414
- isUsernameAuth: boolean;
415
- /**
416
- * 当前的登录类型
417
- *
418
- * {@link https://docs.cloudbase.net/api-reference/webv2/authentication.html#loginstate-logintype}
419
- */
420
- loginType: string;
421
405
  }
422
406
 
423
- interface IWeixinAuthProvider {
424
- /**
425
- * 跳转到微信登录页面
426
- *
427
- * {@link https://docs.cloudbase.net/api-reference/webv2/authentication.html#weixinauthprovider-signinwithredirect}
428
- *
429
- * @example
430
- * ```javascript
431
- * const app = cloudbase.init({
432
- * env: "xxxx-yyy"
433
- * });
434
- * app.auth().weixinAuthProvider({
435
- * appid: "...",
436
- * scope: "snsapi_base"
437
- * }).signInWithRedirect();
438
- * ```
439
- *
440
- */
441
- signInWithRedirect(): void;
442
- /**
443
- * 微信登录页面重定向回来后,使用重定向的返回值登录,并获取登录态
444
- *
445
- * {@link https://docs.cloudbase.net/api-reference/webv2/authentication.html#weixinauthprovider-getredirectresult}
446
- *
447
- * @example
448
- * ```javascript
449
- * const app = cloudbase.init({
450
- * env: "xxxx-yyy"
451
- * });
452
- * app
453
- * .auth()
454
- * .weixinAuthProvider({
455
- * appid: "...",
456
- * scope: "snsapi_base"
457
- * })
458
- * .getRedirectResult()
459
- * .then(loginState=>{
460
- * // ...
461
- * });
462
- * ```
463
- *
464
- * @param options
465
- * @param options.createUser 【可选】当微信 openid 没有对应的云开发用户时,是否自动创建一个新的云开发用户,默认`true`
466
- * @param options.syncUserInfo 【可选】同步微信账号信息作为云开发用户信息,默认`false`
467
- *
468
- * @return Promise-登录态信息
469
- */
470
- getRedirectResult(options?: {
471
- createUser?: boolean;
472
- syncUserInfo?: boolean
473
- }): Promise<ILoginState>;
474
- /**
475
- * 获取微信重定向绑定结果
476
- *
477
- * {@link https://docs.cloudbase.net/api-reference/webv2/authentication.html#weixinauthprovider-getlinkredirectresult}
478
- *
479
- * @example
480
- * ```javascript
481
- * const app = cloudbase.init({
482
- * env: "xxxx-yyy"
483
- * });
484
- * const auth = app.auth();
485
- * // 用户以任意一种登录方式(除微信登录)登录云开发之后
486
- * const provider = auth.weixinAuthProvider({
487
- * appid: "....",
488
- * scope: "snsapi_base"
489
- * });
490
- * // 重定向到提供方的页面进行登录
491
- * auth.currentUser.linkWithRedirect(provider);
492
- * // 用户在微信的页面登录之后,会被重定向回您的页面。然后,可以在页面加载时通过调用 Provider.getLinkRedirectResult() 来获取关联结果:
493
- * provider
494
- * .getLinkRedirectResult()
495
- * .then((result) => {
496
- * // 关联成功
497
- * });
498
- * ```
499
- *
500
- * @param options
501
- * @param options.withUnionId 【可选】如果为 `true`,且存在微信 UnionID,则会一同绑定微信 UnionID
502
- *
503
- * @return Promise-登录态信息
504
- */
505
- getLinkRedirectResult(options?: {
506
- withUnionId?: boolean
507
- }): Promise<void>;
407
+ interface ICredential {
408
+ accessToken?: string;
409
+ accessTokenExpire?: string;
508
410
  }
509
411
 
510
- interface ICustomAuthProvider {
511
- /**
512
- * 使用自定义登录凭据 `ticket` 登录云开发
513
- *
514
- * {@link https://docs.cloudbase.net/api-reference/webv2/authentication.html#customauthprovider-signin}
515
- *
516
- * @example
517
- * ```javascript
518
- * const app = cloudbase.init({
519
- * env: "xxxx-yyy"
520
- * });
521
- * const auth = app.auth()
522
- * // 获取自定义登录 ticket
523
- * // 将 your-api 替换成获取 ticket 的 URL
524
- * const ticket = await fetch("your-api");
525
- * auth
526
- * .customAuthProvider()
527
- * .signIn(ticket)
528
- * .then(loginState=>{
529
- * // ...
530
- * });
531
- * ```
532
- *
533
- * @param ticket 自定义登录凭据
534
- *
535
- * @return Promise-登录态信息
536
- */
537
- signIn(ticket: string): Promise<ILoginState>;
412
+ interface IAuthProvider {
413
+ signInWithRedirect: () => any;
538
414
  }
539
415
 
540
- interface IAnonymousAuthProvider {
541
- /**
542
- * 匿名登录云开发
543
- *
544
- * {@link https://docs.cloudbase.net/api-reference/webv2/authentication.html#anonymousauthprovider-signin}
545
- *
546
- * @example
547
- * ```javascript
548
- * const app = cloudbase.init({
549
- * env: "xxxx-yyy"
550
- * });
551
- * const auth = app.auth()
552
- * auth
553
- * .anonymousAuthProvider()
554
- * .signIn()
555
- * .then(loginState=>{
556
- * // ...
557
- * });
558
- * ```
559
- *
560
- * @return Promise-登录态信息
561
- */
562
- signIn(): Promise<ILoginState>;
563
- }
564
416
  /**
565
- * User Info
417
+ * 用户信息
566
418
  */
567
419
  interface IUserInfo {
568
- /**
569
- * 云开发用户的全局唯一 ID
570
- *
571
- * {@link https://docs.cloudbase.net/api-reference/webv2/authentication.html#user-uid}
572
- */
573
420
  uid?: string;
574
- /**
575
- * 表示当前的登录类型
576
- *
577
- * {@link https://docs.cloudbase.net/api-reference/webv2/authentication.html#user-logintype}
578
- */
579
421
  loginType?: string;
580
- /**
581
- * 此用户绑定的微信 openid
582
- *
583
- * {@link https://docs.cloudbase.net/api-reference/webv2/authentication.html#user-openid}
584
- */
585
422
  openid?: string;
586
- /**
587
- * 此用户绑定的微信 openid
588
- *
589
- * {@link https://docs.cloudbase.net/api-reference/webv2/authentication.html#user-wxopenid}
590
- */
591
423
  wxOpenId?: string;
592
- /**
593
- * 此用户绑定的微信开放平台 openid
594
- *
595
- * {@link https://docs.cloudbase.net/api-reference/webv2/authentication.html#user-wxpublicid}
596
- */
597
424
  wxPublicId?: string;
598
- /**
599
- * 此用户绑定的微信 unionid
600
- *
601
- * {@link https://docs.cloudbase.net/api-reference/webv2/authentication.html#user-unionid}
602
- */
603
425
  unionId?: string;
604
- /**
605
- * 此用户对应的 QQ 小程序 openid
606
- *
607
- * {@link https://docs.cloudbase.net/api-reference/webv2/authentication.html#user-qqminiopenid}
608
- */
609
426
  qqMiniOpenId?: string;
610
- /**
611
- * 此用户绑定的自定义登录 customUserId
612
- *
613
- * {@link https://docs.cloudbase.net/api-reference/webv2/authentication.html#user-customuserid}
614
- */
615
427
  customUserId?: string;
616
- /**
617
- * 用户昵称
618
- *
619
- * {@link https://docs.cloudbase.net/api-reference/webv2/authentication.html#user-nickname}
620
- */
621
- nickName?: string;
622
- /**
623
- * 用户性别
624
- *
625
- * {@link https://docs.cloudbase.net/api-reference/webv2/authentication.html#user-gender}
626
- */
428
+ name?: string;
627
429
  gender?: string;
628
- /**
629
- * 用户头像图片URL
630
- *
631
- * {@link https://docs.cloudbase.net/api-reference/webv2/authentication.html#user-avatarurl}
632
- */
633
- avatarUrl?: string;
634
- /**
635
- * 用户邮箱
636
- *
637
- * {@link https://docs.cloudbase.net/api-reference/webv2/authentication.html#user-email}
638
- */
639
430
  email?: string;
640
- /**
641
- * 用户名
642
- *
643
- * {@link https://docs.cloudbase.net/api-reference/webv2/authentication.html#user-username}
644
- */
645
431
  username?: string;
646
- /**
647
- * 是否设置了密码
648
- *
649
- * {@link https://docs.cloudbase.net/api-reference/webv2/authentication.html#user-haspassword}
650
- */
651
432
  hasPassword?: boolean;
652
- /**
653
- * 用户地理位置
654
- *
655
- * {@link https://docs.cloudbase.net/api-reference/webv2/authentication.html#user-location}
656
- */
657
433
  location?: {
658
- /**
659
- * 国家
660
- */
661
434
  country?: string;
662
- /**
663
- * 省
664
- */
665
435
  province?: string;
666
- /**
667
- * 城市
668
- */
669
436
  city?: string;
670
437
  };
438
+ country?: string;
439
+ province?: string;
440
+ city?: string;
671
441
  }
672
442
 
673
443
  interface IUser extends IUserInfo {
674
- /**
675
- * 将当前账户与自定义登录 `ticket` 进行绑定,绑定之后便可以通过自定义登录登录当前云开发账户
676
- *
677
- * {@link https://docs.cloudbase.net/api-reference/webv2/authentication.html#user-linkwithticket}
678
- *
679
- * @example
680
- * ```javascript
681
- * const app = cloudbase.init({
682
- * env: "xxxx-yyy"
683
- * });
684
- * const user = app.auth().currentUser;
685
- * // ticket 为获取到的自定义登录 Ticket
686
- * user
687
- * .linkWithTicket(ticket)
688
- * .then(() => {
689
- * // 绑定成功
690
- * });
691
- * ```
692
- *
693
- * @param ticket 自定义登录凭证
694
- *
695
- * @return Promise
696
- */
697
- linkWithTicket(ticket: string): Promise<void>;
698
- /**
699
- * 将当前账户与第三方鉴权提供方,以重定向的形式,进行绑定,绑定之后便可以通过第三方鉴权提供方登录当前的云开发账户
700
- *
701
- * {@link https://docs.cloudbase.net/api-reference/webv2/authentication.html#user-linkwithredirect}
702
- *
703
- * @example
704
- * ```javascript
705
- * const app = cloudbase.init({
706
- * env: "xxxx-yyy"
707
- * });
708
- * const auth = app.auth();
709
- * const user = auth.currentUser;
710
- * const provider = auth.weixinAuthProvider({
711
- * appid: "",
712
- * scope: ""
713
- * });
714
- * // 调用之后,网页会被重定向至第三方登录页面
715
- * user.linkWithRedirect(provider);
716
- * ```
717
- *
718
- * @param provider 第三方鉴权Provider实例
719
- *
720
- */
721
- linkWithRedirect(provider: any): void;
722
- /**
723
- * 获取已绑定的用户信息
724
- *
725
- * @example
726
- * ```javascript
727
- * const app = cloudbase.init({
728
- * env: "xxxx-yyy"
729
- * });
730
- * const auth = app.auth();
731
- * const user = auth.currentUser;
732
- * user
733
- * .getLinkedUidList()
734
- * .then(info=>{});
735
- * ```
736
- *
737
- * @param provider 第三方鉴权Provider实例
738
- *
739
- * @return Promise-已绑定的用户信息
740
- */
741
- getLinkedUidList(): Promise<{ hasPrimaryUid: boolean, users: IUserInfo[] }>;
742
- /**
743
- * 设置微信主账号,通常搭配和 User.getLinkedUidList() 使用,用于在同个微信 UnionID 对应的多个云开发账号中,设置其中一个为主账号
744
- *
745
- * @example
746
- * ```javascript
747
- * const app = cloudbase.init({
748
- * env: "xxxx-yyy"
749
- * });
750
- * const auth = app.auth();
751
- * const user = auth.currentUser;
752
- * user.setPrimaryUid('your-uid').then(()=>{});
753
- * ```
754
- *
755
- * @param uid 云开发用户的唯一ID
756
- *
757
- * @return Promise
758
- */
759
- setPrimaryUid(uid: string): Promise<void>;
760
- /**
761
- * 解绑某个登录方式
762
- *
763
- * {@link https://docs.cloudbase.net/api-reference/webv2/authentication.html#user-unlink}
764
- *
765
- * @example
766
- * ```javascript
767
- * const app = cloudbase.init({
768
- * env: "xxxx-yyy"
769
- * });
770
- * const auth = app.auth();
771
- * const user = auth.currentUser;
772
- * // 解绑自定义登录
773
- * user.unlink('CUSTOM');
774
- * ```
775
- *
776
- * @param loginType 被解绑的登录方式
777
- *
778
- * @return Promise
779
- *
780
- */
781
- unlink(loginType: 'CUSTOM' | 'WECHAT-OPEN' | 'WECHAT-PUBLIC' | 'WECHAT-UNION' | 'EMAIL'): Promise<void>;
782
444
  /**
783
445
  * 更新用户信息
784
446
  *
785
- * {@link https://docs.cloudbase.net/api-reference/webv2/authentication.html#user-update}
447
+ * {@link https://docs.cloudbase.net/api-reference/webv3/authentication#userupdate}
786
448
  *
787
449
  * @example
788
450
  * ```javascript
@@ -805,7 +467,7 @@ declare namespace cloudbase.auth {
805
467
  /**
806
468
  * 刷新本地用户信息
807
469
  *
808
- * {@link https://docs.cloudbase.net/api-reference/webv2/authentication.html#user-refresh}
470
+ * {@link https://docs.cloudbase.net/api-reference/webv3/authentication#userrefresh}
809
471
  *
810
472
  * @example
811
473
  * ```javascript
@@ -822,86 +484,25 @@ declare namespace cloudbase.auth {
822
484
  */
823
485
  refresh(): Promise<IUserInfo>;
824
486
  /**
825
- * 修改密码。如果用户之前没有设置过密码,那么无需填写 oldPassword
826
- *
827
- * {@link https://docs.cloudbase.net/api-reference/webv2/authentication.html#user-updatepassword}
828
- *
829
- * @example
830
- * ```javascript
831
- * const app = cloudbase.init({
832
- * env: "xxxx-yyy"
833
- * });
834
- * const auth = app.auth();
835
- * const user = auth.currentUser;
836
- * user
837
- * .updatePassword("new_password", "old_password")
838
- * .then(()=>{});
839
- * ```
840
- *
841
- * @param newPassword 新密码
842
- * @param oldPassword 旧密码
843
- *
844
- * @return Promise
845
- */
846
- updatePassword(newPassword: string, oldPassword?: string): Promise<void>;
847
- /**
848
- * 修改登录邮箱
849
- *
850
- * {@link https://docs.cloudbase.net/api-reference/webv2/authentication.html#user-updateemail}
851
- *
852
- * @example
853
- * ```javascript
854
- * const app = cloudbase.init({
855
- * env: "xxxx-yyy"
856
- * });
857
- * const auth = app.auth();
858
- * const user = auth.currentUser;
859
- * user
860
- * .updateEmail("new_email@foo.com")
861
- * .then(()=>{});
862
- * ```
863
- *
864
- * @param newEmail 新邮箱地址
865
- *
866
- * @return Promise
487
+ * 同步获取本地用户信息
867
488
  */
868
- updateEmail(newEmail: string): Promise<void>;
489
+ checkLocalInfo: () => void;
869
490
  /**
870
- * 修改用户名
871
- *
872
- * {@link https://docs.cloudbase.net/api-reference/webv2/authentication.html#user-updateusername}
873
- *
874
- * @example
875
- * ```javascript
876
- * const app = cloudbase.init({
877
- * env: "xxxx-yyy"
878
- * });
879
- * const auth = app.auth();
880
- * const user = auth.currentUser;
881
- * user
882
- * .updateUsername("new_username")
883
- * .then(()=>{});
884
- * ```
885
- *
886
- * @param username 新用户名
887
- *
888
- * @return Promise
491
+ * 异步获取本地用户信息
889
492
  */
890
- updateUsername(username: string): Promise<void>;
891
- }
892
-
893
- interface signInWithPhoneParams {
894
- phoneNumber: string
895
- phoneCode?: string
896
- password?: string
897
- signMethod?: string
493
+ checkLocalInfoAsync: () => Promise<void>;
494
+ linkWithTicket?: (ticket: string) => Promise<void>;
495
+ linkWithRedirect?: (provider: IAuthProvider) => void;
496
+ getLinkedUidList?: () => Promise<{ hasPrimaryUid: boolean, users: IUserInfo[] }>;
497
+ setPrimaryUid?: (uid: string) => Promise<void>;
498
+ unlink?: (loginType: 'CUSTOM' | 'WECHAT-OPEN' | 'WECHAT-PUBLIC' | 'WECHAT-UNION') => Promise<void>;
898
499
  }
899
500
 
900
501
  interface App {
901
502
  /**
902
503
  * 获取当前登录的用户信息-同步操作
903
504
  *
904
- * {@link https://docs.cloudbase.net/api-reference/webv2/authentication.html#auth-hasloginstate}
505
+ * {@link https://docs.cloudbase.net/api-reference/webv3/authentication.html#auth-hasloginstate}
905
506
  *
906
507
  * @example
907
508
  * ```javascript
@@ -915,7 +516,7 @@ declare namespace cloudbase.auth {
915
516
  */
916
517
  currentUser: IUser | null;
917
518
  /**
918
- * 获取当前登录的用户信息-异步操作,文档 {@link https://docs.cloudbase.net/api-reference/webv2/authentication.html#auth-hasloginstate}
519
+ * 获取当前登录的用户信息-异步操作,文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authgetcurrentuser}
919
520
  *
920
521
  * @example
921
522
  * ```javascript
@@ -930,10 +531,99 @@ declare namespace cloudbase.auth {
930
531
  * @return Promise-用户信息,如果未登录返回`null`
931
532
  */
932
533
  getCurrentUser(): Promise<IUser | null>
534
+ /**
535
+ * 绑定手机号码
536
+ *
537
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authbindphonenumber}
538
+ *
539
+ * @param params
540
+ */
541
+ bindPhoneNumber(params: authModels.BindPhoneRequest): Promise<void>
542
+ /**
543
+ * 绑定邮箱
544
+ *
545
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authbindemail}
546
+ *
547
+ * @param params
548
+ */
549
+ bindEmail(params: authModels.BindEmailRequest): Promise<void>
550
+ /**
551
+ * 解除三方绑定
552
+ *
553
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authunbindprovider}
554
+ *
555
+ * @param params
556
+ */
557
+ unbindProvider(params: authModels.UnbindProviderRequest): Promise<void>
558
+
559
+ /**
560
+ * 验证码验证
561
+ *
562
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authverify}
563
+ *
564
+ * @param params
565
+ */
566
+ verify(params: authModels.VerifyRequest): Promise<authModels.VerifyResponse>
567
+ /**
568
+ * 获取验证码
569
+ *
570
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authgetverification}
571
+ *
572
+ * @param params
573
+ */
574
+ getVerification(params: authModels.GetVerificationRequest): Promise<authModels.GetVerificationResponse>
575
+ /**
576
+ * 匿名登录
577
+ *
578
+ *
579
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authsigninanonymously}
580
+ *
581
+ */
582
+ signInAnonymously(data: { provider_token?: string }): Promise<LoginState>
583
+ /**
584
+ * 设置获取自定义登录 ticket 的函数
585
+ *
586
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authsetcustomsignfunc}
587
+ *
588
+ *
589
+ * @param getTickFn
590
+ */
591
+ setCustomSignFunc(getTickFn: authModels.GetCustomSignTicketFn): void
592
+ /**
593
+ * 使用自定义登录 ticket 登录
594
+ *
595
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authsigninwithcustomticket}
596
+ */
597
+ signInWithCustomTicket(): Promise<LoginState>
598
+ /**
599
+ * 用户登录,目前支持手机号,邮箱,用户名密码登录
600
+ *
601
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authsignin}
602
+ */
603
+ signIn(params: authModels.SignInRequest): Promise<LoginState>
604
+ /**
605
+ * 用户注册,目前支持手机号验证码注册,邮箱验证码注册
606
+ *
607
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authsignup}
608
+ */
609
+ signUp(params: authModels.SignUpRequest): Promise<LoginState>
610
+ /**
611
+ * 设置密码(已登录状态下,更新用户密码)
612
+ *
613
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authsetpassword}
614
+ *
615
+ */
616
+ setPassword(params: authModels.SetPasswordRequest): Promise<void>
617
+ /**
618
+ * 获取用户信息
619
+ *
620
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authgetuserinfo}
621
+ */
622
+ getUserInfo(): Promise<IUserInfo>
933
623
  /**
934
624
  * 获取本地登录态-同步操作
935
625
  *
936
- * {@link https://docs.cloudbase.net/api-reference/webv2/authentication.html#auth-hasloginstate}
626
+ * {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authhasloginstate}
937
627
  *
938
628
  * @example
939
629
  * ```javascript
@@ -949,7 +639,7 @@ declare namespace cloudbase.auth {
949
639
  /**
950
640
  * 获取本地登录态-异步操作
951
641
  *
952
- * {@link https://docs.cloudbase.net/api-reference/webv2/authentication.html#auth-getloginstate}
642
+ * {@link https://docs.cloudbase.net/api-reference/webv3/authentication.html#auth-getloginstate}
953
643
  *
954
644
  * @example
955
645
  * ```javascript
@@ -965,209 +655,86 @@ declare namespace cloudbase.auth {
965
655
  */
966
656
  getLoginState(): Promise<ILoginState | null>;
967
657
  /**
968
- * 获取 HTTP 鉴权header-同步操作
969
- *
970
- * {@link https://docs.cloudbase.net/api-reference/webv2/authentication.html#auth-getauthheader}
971
- *
972
- * @example
973
- * ```javascript
974
- * const app = cloudbase.init({
975
- * env: "xxxx-yyy"
976
- * });
977
- * const authHeader = app.auth().getAuthHeader();
978
- * ```
979
- *
980
- * @return HTTP鉴权header
658
+ * @deprecated
981
659
  */
982
- getAuthHeader(): { 'x-cloudbase-credentials': string } | null;
660
+ getAuthHeader(): {}
983
661
  /**
984
- * 获取 HTTP 鉴权header-异步操作
985
- *
986
- * {@link https://docs.cloudbase.net/api-reference/webv2/authentication.html#auth-getauthheaderasync}
987
- *
988
- * @example
989
- * ```javascript
990
- * const app = cloudbase.init({
991
- * env: "xxxx-yyy"
992
- * });
993
- * app.auth().getAuthHeaderAsync().then(authHeader=>{
994
- * // ...
995
- * });
996
- * ```
997
- *
998
- * @return Promise-HTTP鉴权header
662
+ * 为已有账户绑定第三方账户
663
+ *
664
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authbindwithprovider}
999
665
  */
1000
- getAuthHeaderAsync(): Promise<{ 'x-cloudbase-credentials': string } | null>;
666
+ bindWithProvider(params: authModels.BindWithProviderRequest,): Promise<void>
1001
667
  /**
1002
- * 监听登录状态改变事件
1003
- *
1004
- * {@link https://docs.cloudbase.net/api-reference/webv2/authentication.html#auth-onloginstatechanged}
1005
- *
1006
- * @example
1007
- * ```javascript
1008
- * const app = cloudbase.init({
1009
- * env: "xxxx-yyy"
1010
- * });
1011
- * app.auth().onLoginStateChanged(loginState=>{
1012
- * // ...
1013
- * });
1014
- * ```
1015
- *
1016
- * @param callback 回调函数,当登录状态改变后被执行
668
+ * 查询用户(自定义登录场景和匿名登录场景,不支持使用该接口查询用户信息)
669
+ *
670
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authqueryuser}
671
+ *
1017
672
  */
1018
- onLoginStateChanged(callback: Function): void;
673
+ queryUser(queryObj: authModels.QueryUserProfileRequest): Promise<authModels.QueryUserProfileResponse>
1019
674
  /**
1020
- * 监听登录态过期事件
1021
- *
1022
- * {@link https://docs.cloudbase.net/api-reference/webv2/authentication.html#auth-onloginstateexpired}
1023
- *
1024
- * @example
1025
- * ```javascript
1026
- * const app = cloudbase.init({
1027
- * env: "xxxx-yyy"
1028
- * });
1029
- * app.auth().onLoginStateExpired(()=>{
1030
- * // ...
1031
- * });
1032
- * ```
1033
- *
1034
- * @param callback 回调函数,当登录态过期后被执行
675
+ * 获取当前登录用户的访问凭证
676
+ *
677
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authgetaccesstoken}
1035
678
  */
1036
- onLoginStateExpired(callback: Function): void;
679
+ getAccessToken(): Promise<{ accessToken: string, env: string }>
1037
680
  /**
1038
- * 监听令牌刷新事件
1039
- *
1040
- * {@link https://docs.cloudbase.net/api-reference/webv2/authentication.html#auth-onaccesstokenrefreshed}
1041
- *
1042
- * @example
1043
- * ```javascript
1044
- * const app = cloudbase.init({
1045
- * env: "xxxx-yyy"
1046
- * });
1047
- * app.auth().onAccessTokenRefreshed(()=>{
1048
- * // ...
1049
- * });
1050
- * ```
1051
- *
1052
- * @param callback 回调函数,当access_token刷新后被执行
681
+ * 提供第三方平台登录 token
682
+ *
683
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authgrantprovidertoken}
1053
684
  */
1054
- onAccessTokenRefreshed(callback: Function): void;
685
+ grantProviderToken(params: authModels.GrantProviderTokenRequest): Promise<authModels.GrantProviderTokenResponse>
686
+ patchProviderToken(params: authModels.PatchProviderTokenRequest): Promise<authModels.PatchProviderTokenResponse>
1055
687
  /**
1056
- * 监听匿名转正事件
1057
- *
1058
- * {@link https://docs.cloudbase.net/api-reference/webv2/authentication.html#auth-onanonymousconverted}
1059
- *
1060
- * @example
1061
- * ```javascript
1062
- * const app = cloudbase.init({
1063
- * env: "xxxx-yyy"
1064
- * });
1065
- * app.auth().onAnonymousConverted(()=>{
1066
- * // ...
1067
- * });
1068
- * ```
1069
- *
1070
- * @param callback 回调函数,当匿名用户被转化为正式用户后被执行
688
+ * 第三方平台登录
689
+ *
690
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authsigninwithprovider}
1071
691
  */
1072
- onAnonymousConverted(callback: Function): void;
692
+ signInWithProvider(params: authModels.SignInWithProviderRequest): Promise<LoginState>
693
+ grantToken(params: authModels.GrantTokenRequest): Promise<LoginState>
1073
694
  /**
1074
- * 监听登录类型改变事件
1075
- *
1076
- * {@link https://docs.cloudbase.net/api-reference/webv2/authentication.html#auth-onlogintypechanged}
1077
- *
1078
- * @example
1079
- * ```javascript
1080
- * const app = cloudbase.init({
1081
- * env: "xxxx-yyy"
1082
- * });
1083
- * app.auth().onLoginTypeChanged(()=>{
1084
- * // ...
1085
- * });
1086
- * ```
1087
- *
1088
- * @param callback 回调函数,当登录类型改变后被执行
695
+ * 生成第三方平台授权 Uri (如微信二维码扫码授权网页)
696
+ *
697
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authgenproviderredirecturi}
1089
698
  */
1090
- onLoginTypeChanged(callback: Function): void;
699
+ genProviderRedirectUri(params: authModels.GenProviderRedirectUriRequest): Promise<authModels.GenProviderRedirectUriResponse>
1091
700
  /**
1092
- * 接收一个回调函数,并且会在刷新短期访问令牌前调用此回调函数,根据返回值决定是否要刷新短期访问令牌。
1093
- *
1094
- * {@link https://docs.cloudbase.net/api-reference/webv2/authentication.html#auth-shouldrefreshaccesstoken}
1095
- *
1096
- * @example
1097
- * ```javascript
1098
- * const app = cloudbase.init({
1099
- * env: "xxxx-yyy"
1100
- * });
1101
- * app.auth().shouldRefreshAccessToken(()=>{
1102
- * // ...
1103
- * });
1104
- * ```
1105
- *
1106
- * @param callback 在刷新短期访问令牌前调用此回调函数
701
+ * 重置密码(用户忘记密码无法登录时,可使用该接口强制设置密码)
702
+ *
703
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authresetpassword}
1107
704
  */
1108
- shouldRefreshAccessToken(hook: Function): void;
705
+ resetPassword(params: authModels.ResetPasswordRequest): Promise<void>
706
+ deviceAuthorize(params: authModels.DeviceAuthorizeRequest): Promise<authModels.DeviceAuthorizeResponse>
1109
707
  /**
1110
- * 创建微信登录Provider实例
1111
- *
1112
- * {@link https://docs.cloudbase.net/authentication/wechat-login.html#wei-xin-deng-lu-liu-cheng}
1113
- *
1114
- * @example
1115
- * ```javascript
1116
- * const app = cloudbase.init({
1117
- * env: "xxxx-yyy"
1118
- * });
1119
- * const provider = app.auth().weixinAuthProvider({
1120
- * appid: 'AppId',
1121
- * scope: '授权类型'
1122
- * });
1123
- * ```
1124
- *
1125
- * @param options
1126
- * @param options.appid 微信公众平台/开放平台的 AppId
1127
- * @param options.scope 授权类型
1128
- *
1129
- * @return 微信登录Provider实例
708
+ * 通过 sudo 接口获取高级操作权限,如修改用户密码,修改手机号,邮箱等操作
709
+ *
710
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authsudo}
1130
711
  */
1131
- weixinAuthProvider(options: {
1132
- appid: string;
1133
- scope: 'snsapi_base' | 'snsapi_userinfo' | 'snsapi_login';
1134
- }): IWeixinAuthProvider;
712
+ sudo(params: authModels.SudoRequest): Promise<authModels.SudoResponse>
1135
713
  /**
1136
- * 创建自定义登录Provider实例
1137
- *
1138
- * {@link https://docs.cloudbase.net/authentication/wechat-login.html#wei-xin-deng-lu-liu-cheng}
1139
- *
1140
- * @example
1141
- * ```javascript
1142
- * const app = cloudbase.init({
1143
- * env: "xxxx-yyy"
1144
- * });
1145
- * const provider = app.auth().customAuthProvider();
1146
- * ```
1147
- *
1148
- * @return 自定义登录Provider实例
714
+ * 删除用户
715
+ *
716
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authdeleteme}
1149
717
  */
1150
- customAuthProvider(): ICustomAuthProvider;
718
+ deleteMe(params: authModels.WithSudoRequest): Promise<authModels.UserProfile>
1151
719
  /**
1152
- * 创建匿名登录Provider实例
1153
- *
1154
- * {@link https://docs.cloudbase.net/authentication/wechat-login.html#wei-xin-deng-lu-liu-cheng}
1155
- *
1156
- * @example
1157
- * ```javascript
1158
- * const app = cloudbase.init({
1159
- * env: "xxxx-yyy"
1160
- * });
1161
- * const provider = app.auth().anonymousAuthProvider();
1162
- * ```
1163
- *
1164
- * @return 匿名登录Provider实例
720
+ * 获取第三方绑定列表
721
+ *
722
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authgetproviders}
723
+ */
724
+ getProviders(): Promise<authModels.UserProfileProvider>
725
+ /**
726
+ * 用于查询用户是否为匿名登录状态
727
+ *
728
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authloginscope}
1165
729
  */
1166
- anonymousAuthProvider(): IAnonymousAuthProvider;
730
+ loginScope(): Promise<string>
731
+ loginGroups(): Promise<string[]>
732
+ onLoginStateChanged(callback: Function)
733
+ createLoginState(): Promise<LoginState>
1167
734
  /**
1168
735
  * 退出登录,请注意,匿名登录不支持退出
1169
736
  *
1170
- * {@link https://docs.cloudbase.net/api-reference/webv2/authentication.html#auth-signout}
737
+ * {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authsignout}
1171
738
  *
1172
739
  * @example
1173
740
  * ```javascript
@@ -1180,104 +747,10 @@ declare namespace cloudbase.auth {
1180
747
  * @return Promise
1181
748
  */
1182
749
  signOut(): Promise<void>;
1183
- /**
1184
- * 使用邮箱和密码登录云开发
1185
- *
1186
- * {@link https://docs.cloudbase.net/api-reference/webv2/authentication.html#auth-signinwithemailandpassword}
1187
- *
1188
- * @example
1189
- * ```javascript
1190
- * const app = cloudbase.init({
1191
- * env: "xxxx-yyy"
1192
- * });
1193
- * const auth = app.auth();
1194
- * const email = "foo@bar.com";
1195
- * const password = "your_awesome_password";
1196
- * auth.signInWithEmailAndPassword(email, password).then(loginState=>{
1197
- * // ...
1198
- * });
1199
- * ```
1200
- *
1201
- * @param email 邮箱地址
1202
- * @param password 登录密码
1203
- *
1204
- * @return Promise-登录态信息
1205
- */
1206
- signInWithEmailAndPassword(email: string, password: string): Promise<ILoginState>;
1207
- /**
1208
- * 使用邮箱和密码注册一个云开发账户,调用后,会自动向注册邮箱发送邮箱验证邮件
1209
- *
1210
- * {@link https://docs.cloudbase.net/api-reference/webv2/authentication.html#auth-signupwithemailandpassword}
1211
- *
1212
- * @example
1213
- * ```javascript
1214
- * const app = cloudbase.init({
1215
- * env: "xxxx-yyy"
1216
- * });
1217
- * const auth = app.auth();
1218
- * const email = "foo@bar.com";
1219
- * const password = "your_awesome_password";
1220
- * auth.signUpWithEmailAndPassword(email, password).then(()=>{
1221
- * // ...
1222
- * });
1223
- * ```
1224
- *
1225
- * @param email 邮箱地址
1226
- * @param password 登录密码
1227
- *
1228
- * @return Promise
1229
- */
1230
- signUpWithEmailAndPassword(email: string, password: string): Promise<void>;
1231
- /**
1232
- * 发送重置密码的邮件
1233
- *
1234
- * {@link https://docs.cloudbase.net/api-reference/webv2/authentication.html#auth-sendpasswordresetemail}
1235
- *
1236
- * @example
1237
- * ```javascript
1238
- * const app = cloudbase.init({
1239
- * env: "xxxx-yyy"
1240
- * });
1241
- * const auth = app.auth();
1242
- * const email = "foo@bar.com";
1243
- * auth.sendPasswordResetEmail(email).then(()=>{
1244
- * // ...
1245
- * });
1246
- * ```
1247
- *
1248
- * @param email 邮箱地址
1249
- *
1250
- * @return Promise
1251
- */
1252
- sendPasswordResetEmail(email: string): Promise<void>;
1253
- /**
1254
- * 使用用户名密码登录云开发
1255
- *
1256
- * {@link https://docs.cloudbase.net/api-reference/webv2/authentication.html#auth-signinwithusernameandpassword}
1257
- *
1258
- * @example
1259
- * ```javascript
1260
- * const app = cloudbase.init({
1261
- * env: "xxxx-yyy"
1262
- * });
1263
- * const auth = app.auth();
1264
- * const username = "your_awesome_username";
1265
- * const password = "your_awesome_password";
1266
- * auth.signInWithUsernameAndPassword(username, password).then(loginState=>{
1267
- * // ...
1268
- * });
1269
- * ```
1270
- *
1271
- * @param username 用户名
1272
- * @param password 登录密码
1273
- *
1274
- * @return Promise-登录态信息
1275
- */
1276
- signInWithUsernameAndPassword(username: string, password: string): Promise<ILoginState>;
1277
750
  /**
1278
751
  * 检查用户名是否被绑定过
1279
752
  *
1280
- * {@link https://docs.cloudbase.net/api-reference/webv2/authentication.html#auth-isusernameregistered}
753
+ * {@link https://docs.cloudbase.net/api-reference/webv3/authentication.html#authisusernameregistered}
1281
754
  *
1282
755
  * @example
1283
756
  * ```javascript
@@ -1296,13 +769,6 @@ declare namespace cloudbase.auth {
1296
769
  * @return Promise-用户是否被绑定
1297
770
  */
1298
771
  isUsernameRegistered(username: string): Promise<boolean>;
1299
-
1300
- sendPhoneCode(phoneNumber: string): Promise<boolean>;
1301
-
1302
- signUpWithPhoneCode(phoneNumber: string, phoneCode: string, password: string): Promise<void>;
1303
-
1304
- signInWithPhoneCodeOrPassword(params: signInWithPhoneParams): Promise<ILoginState>;
1305
-
1306
772
  }
1307
773
  }
1308
774
  /**
@@ -1390,6 +856,7 @@ declare namespace cloudbase.storage {
1390
856
  authorization: string;
1391
857
  fileId: string;
1392
858
  cosFileId: string;
859
+ download_url: string
1393
860
  }
1394
861
 
1395
862
  interface ICloudbaseFileMetaDataRes {
@@ -1412,7 +879,7 @@ declare namespace cloudbase.database {
1412
879
  /**
1413
880
  * 关闭实时推送
1414
881
  *
1415
- * {@link https://docs.cloudbase.net/api-reference/webv2/database.html#shu-ju-ku-shi-shi-tui-song}
882
+ * {@link https://docs.cloudbase.net/api-reference/webv3/database.html#shu-ju-ku-shi-shi-tui-song}
1416
883
  *
1417
884
  * @example
1418
885
  * // 启动监听
@@ -1457,7 +924,7 @@ declare namespace cloudbase.database {
1457
924
  /**
1458
925
  * 开启实时推送
1459
926
  *
1460
- * {@link https://docs.cloudbase.net/api-reference/webv2/database.html#shu-ju-ku-shi-shi-tui-song}
927
+ * {@link https://docs.cloudbase.net/api-reference/webv3/database#%E6%95%B0%E6%8D%AE%E5%BA%93%E5%AE%9E%E6%97%B6%E6%8E%A8%E9%80%81}
1461
928
  *
1462
929
  * @example
1463
930
  * const ref = db
@@ -1486,15 +953,15 @@ declare namespace cloudbase.database {
1486
953
  /**
1487
954
  * 插入一条文档
1488
955
  *
1489
- * {@link https://docs.cloudbase.net/api-reference/webv2/database.html#add}
956
+ * {@link https://docs.cloudbase.net/api-reference/webv3/database#add}
1490
957
  *
1491
958
  * @param data 文档数据
1492
959
  */
1493
- add(data: object): Promise<Pick<SetRes, 'code' | 'message'>>;
960
+ add(data: Object): Promise<Pick<SetRes, 'code' | 'message'>>;
1494
961
  /**
1495
962
  * 获取一条文档的引用
1496
963
  *
1497
- * {@link https://docs.cloudbase.net/api-reference/webv2/database.html#record-document}
964
+ * {@link https://docs.cloudbase.net/api-reference/webv3/database#record--document}
1498
965
  *
1499
966
  * @param id 文档ID
1500
967
  */
@@ -1518,7 +985,7 @@ declare namespace cloudbase.database {
1518
985
  /**
1519
986
  * 表示字段等于某个值
1520
987
  *
1521
- * {@link https://docs.cloudbase.net/api-reference/webv2/database.html#eq}
988
+ * {@link https://docs.cloudbase.net/api-reference/webv3/database#eq}
1522
989
  *
1523
990
  * @example
1524
991
  * const _ = db.command;
@@ -1529,11 +996,11 @@ declare namespace cloudbase.database {
1529
996
  * @param val 接受一个字面量 (literal),可以是 `number`, `boolean`, `string`, `object`, `array`
1530
997
  *
1531
998
  */
1532
- eq(val: number | string | boolean | object | any[]): any;
999
+ eq(val: number | string | boolean | Object | any[]): any;
1533
1000
  /**
1534
1001
  * 表示字段不等于某个值
1535
1002
  *
1536
- * {@link https://docs.cloudbase.net/api-reference/webv2/database.html#neq}
1003
+ * {@link https://docs.cloudbase.net/api-reference/webv3/database#neq}
1537
1004
  *
1538
1005
  * @example
1539
1006
  * const _ = db.command;
@@ -1544,11 +1011,11 @@ declare namespace cloudbase.database {
1544
1011
  * @param val 接受一个字面量 (literal),可以是 `number`, `boolean`, `string`, `object`, `array`
1545
1012
  *
1546
1013
  */
1547
- neq(val: number | string | boolean | object | any[]): any;
1014
+ neq(val: number | string | boolean | Object | any[]): any;
1548
1015
  /**
1549
1016
  * 字段大于指定值
1550
1017
  *
1551
- * {@link https://docs.cloudbase.net/api-reference/webv2/database.html#gt}
1018
+ * {@link https://docs.cloudbase.net/api-reference/webv3/database#gt}
1552
1019
  *
1553
1020
  * @example
1554
1021
  * const _ = db.command;
@@ -1563,7 +1030,7 @@ declare namespace cloudbase.database {
1563
1030
  /**
1564
1031
  * 字段大于或等于指定值
1565
1032
  *
1566
- * {@link https://docs.cloudbase.net/api-reference/webv2/database.html#neq}
1033
+ * {@link https://docs.cloudbase.net/api-reference/webv3/database#neq}
1567
1034
  *
1568
1035
  * @example
1569
1036
  * const _ = db.command;
@@ -1578,7 +1045,7 @@ declare namespace cloudbase.database {
1578
1045
  /**
1579
1046
  * 字段小于指定值
1580
1047
  *
1581
- * {@link https://docs.cloudbase.net/api-reference/webv2/database.html#lt}
1048
+ * {@link https://docs.cloudbase.net/api-reference/webv3/database#lt}
1582
1049
  *
1583
1050
  * @example
1584
1051
  * const _ = db.command;
@@ -1593,7 +1060,7 @@ declare namespace cloudbase.database {
1593
1060
  /**
1594
1061
  * 字段小于或等于指定值
1595
1062
  *
1596
- * {@link https://docs.cloudbase.net/api-reference/webv2/database.html#lte}
1063
+ * {@link https://docs.cloudbase.net/api-reference/webv3/database#lte}
1597
1064
  *
1598
1065
  * @example
1599
1066
  * const _ = db.command;
@@ -1608,7 +1075,7 @@ declare namespace cloudbase.database {
1608
1075
  /**
1609
1076
  * 字段值在给定的数组中
1610
1077
  *
1611
- * {@link https://docs.cloudbase.net/api-reference/webv2/database.html#in}
1078
+ * {@link https://docs.cloudbase.net/api-reference/webv3/database#in}
1612
1079
  *
1613
1080
  * @example
1614
1081
  * const _ = db.command;
@@ -1623,7 +1090,7 @@ declare namespace cloudbase.database {
1623
1090
  /**
1624
1091
  * 字段值不在给定的数组中
1625
1092
  *
1626
- * {@link https://docs.cloudbase.net/api-reference/webv2/database.html#nin}
1093
+ * {@link https://docs.cloudbase.net/api-reference/webv3/database#nin}
1627
1094
  *
1628
1095
  * @example
1629
1096
  * const _ = db.command;
@@ -1638,7 +1105,7 @@ declare namespace cloudbase.database {
1638
1105
  /**
1639
1106
  * 表示需同时满足指定的两个或以上的条件
1640
1107
  *
1641
- * {@link https://docs.cloudbase.net/api-reference/webv2/database.html#and}
1108
+ * {@link https://docs.cloudbase.net/api-reference/webv3/database#and}
1642
1109
  *
1643
1110
  * @example
1644
1111
  * const _ = db.command;
@@ -1653,7 +1120,7 @@ declare namespace cloudbase.database {
1653
1120
  /**
1654
1121
  * 表示需满足所有指定条件中的至少一个
1655
1122
  *
1656
- * {@link https://docs.cloudbase.net/api-reference/webv2/database.html#or}
1123
+ * {@link https://docs.cloudbase.net/api-reference/webv3/database#or}
1657
1124
  *
1658
1125
  * @example
1659
1126
  * const _ = db.command;
@@ -1668,7 +1135,7 @@ declare namespace cloudbase.database {
1668
1135
  /**
1669
1136
  * 用于设定字段等于指定值
1670
1137
  *
1671
- * {@link https://docs.cloudbase.net/api-reference/webv2/database.html#set}
1138
+ * {@link https://docs.cloudbase.net/api-reference/webv3/database#set}
1672
1139
  *
1673
1140
  * @example
1674
1141
  * const _ = db.command;
@@ -1689,7 +1156,7 @@ declare namespace cloudbase.database {
1689
1156
  /**
1690
1157
  * 用于指示字段自增某个值
1691
1158
  *
1692
- * {@link https://docs.cloudbase.net/api-reference/webv2/database.html#inc}
1159
+ * {@link https://docs.cloudbase.net/api-reference/webv3/database#inc}
1693
1160
  *
1694
1161
  * @example
1695
1162
  * const _ = db.command;
@@ -1708,7 +1175,7 @@ declare namespace cloudbase.database {
1708
1175
  /**
1709
1176
  * 用于指示字段自乘某个值
1710
1177
  *
1711
- * {@link https://docs.cloudbase.net/api-reference/webv2/database.html#mul}
1178
+ * {@link https://docs.cloudbase.net/api-reference/webv3/database#mul}
1712
1179
  *
1713
1180
  * @example
1714
1181
  * const _ = db.command;
@@ -1727,7 +1194,7 @@ declare namespace cloudbase.database {
1727
1194
  /**
1728
1195
  * 用于表示删除某个字段
1729
1196
  *
1730
- * {@link https://docs.cloudbase.net/api-reference/webv2/database.html#remove}
1197
+ * {@link https://docs.cloudbase.net/api-reference/webv3/database#remove}
1731
1198
  *
1732
1199
  * @example
1733
1200
  * const _ = db.command;
@@ -1742,7 +1209,7 @@ declare namespace cloudbase.database {
1742
1209
  /**
1743
1210
  * 向数组尾部追加元素
1744
1211
  *
1745
- * {@link https://docs.cloudbase.net/api-reference/webv2/database.html#remove}
1212
+ * {@link https://docs.cloudbase.net/api-reference/webv3/database#push}
1746
1213
  *
1747
1214
  * @example
1748
1215
  * const _ = db.command;
@@ -1758,7 +1225,7 @@ declare namespace cloudbase.database {
1758
1225
  /**
1759
1226
  * 删除数组尾部元素
1760
1227
  *
1761
- * {@link https://docs.cloudbase.net/api-reference/webv2/database.html#remove}
1228
+ * {@link https://docs.cloudbase.net/api-reference/webv3/database#pop}
1762
1229
  *
1763
1230
  * @example
1764
1231
  * const _ = db.command;
@@ -1773,7 +1240,7 @@ declare namespace cloudbase.database {
1773
1240
  /**
1774
1241
  * 向数组头部添加元素
1775
1242
  *
1776
- * {@link https://docs.cloudbase.net/api-reference/webv2/database.html#remove}
1243
+ * {@link https://docs.cloudbase.net/api-reference/webv3/database#unshift}
1777
1244
  *
1778
1245
  * @example
1779
1246
  * const _ = db.command;
@@ -1789,7 +1256,7 @@ declare namespace cloudbase.database {
1789
1256
  /**
1790
1257
  * 删除数组头部元素
1791
1258
  *
1792
- * {@link https://docs.cloudbase.net/api-reference/webv2/database.html#remove}
1259
+ * {@link https://docs.cloudbase.net/api-reference/webv3/database#shift}
1793
1260
  *
1794
1261
  * @example
1795
1262
  * const _ = db.command;
@@ -1804,7 +1271,7 @@ declare namespace cloudbase.database {
1804
1271
  /**
1805
1272
  * 按从近到远的顺序,找出字段值在给定点的附近的文档
1806
1273
  *
1807
- * {@link https://docs.cloudbase.net/api-reference/webv2/database.html#geo-cao-zuo-fu}
1274
+ * {@link https://docs.cloudbase.net/api-reference/webv3/database#geonear}
1808
1275
  *
1809
1276
  * @example
1810
1277
  * const _ = db.command;
@@ -1825,7 +1292,7 @@ declare namespace cloudbase.database {
1825
1292
  /**
1826
1293
  * 找出字段值在指定 Polygon / MultiPolygon 内的文档,无排序
1827
1294
  *
1828
- * {@link https://docs.cloudbase.net/api-reference/webv2/database.html#geo-cao-zuo-fu}
1295
+ * {@link https://docs.cloudbase.net/api-reference/webv3/database#geowithin}
1829
1296
  *
1830
1297
  * @example
1831
1298
  * const _ = db.command;
@@ -1844,7 +1311,7 @@ declare namespace cloudbase.database {
1844
1311
  /**
1845
1312
  * 找出字段值和给定的地理位置图形相交的文档
1846
1313
  *
1847
- * {@link https://docs.cloudbase.net/api-reference/webv2/database.html#geo-cao-zuo-fu}
1314
+ * {@link https://docs.cloudbase.net/api-reference/webv3/database#geointersects}
1848
1315
  *
1849
1316
  * @example
1850
1317
  * const _ = db.command;
@@ -1866,7 +1333,7 @@ declare namespace cloudbase.database {
1866
1333
  /**
1867
1334
  * 更新文档,如果要更新的文档不存在时新增一个文档
1868
1335
  *
1869
- * {@link https://docs.cloudbase.net/api-reference/webv2/database.html#update-set}
1336
+ * {@link https://docs.cloudbase.net/api-reference/webv3/database.html#update-set}
1870
1337
  *
1871
1338
  * @example
1872
1339
  * collection
@@ -1878,11 +1345,11 @@ declare namespace cloudbase.database {
1878
1345
  *
1879
1346
  * @return Promise
1880
1347
  */
1881
- set(data: object): Promise<SetRes>;
1348
+ set(data: Object): Promise<SetRes>;
1882
1349
  /**
1883
1350
  * 获取查询结果
1884
1351
  *
1885
- * {@link https://docs.cloudbase.net/api-reference/webv2/database.html#get}
1352
+ * {@link https://docs.cloudbase.net/api-reference/webv3/database#get}
1886
1353
  *
1887
1354
  * @example
1888
1355
  * collection
@@ -1896,7 +1363,7 @@ declare namespace cloudbase.database {
1896
1363
  /**
1897
1364
  * 更新文档,如果要更新的文档不存在什么也不会做
1898
1365
  *
1899
- * {@link https://docs.cloudbase.net/api-reference/webv2/database.html#update-set}
1366
+ * {@link https://docs.cloudbase.net/api-reference/webv3/database#update--set}
1900
1367
  *
1901
1368
  * @example
1902
1369
  * collection
@@ -1908,11 +1375,11 @@ declare namespace cloudbase.database {
1908
1375
  *
1909
1376
  * @return Promise
1910
1377
  */
1911
- update(data: object): Promise<SetRes>;
1378
+ update(data: Object): Promise<SetRes>;
1912
1379
  /**
1913
1380
  * 删除一条文档
1914
1381
  *
1915
- * {@link https://docs.cloudbase.net/api-reference/webv2/database.html#remove-2}
1382
+ * {@link https://docs.cloudbase.net/api-reference/webv3/database.html#remove-2}
1916
1383
  *
1917
1384
  * @example
1918
1385
  * collection
@@ -1969,7 +1436,7 @@ declare namespace cloudbase.database {
1969
1436
  /**
1970
1437
  * 获取数据库查询结果
1971
1438
  *
1972
- * {@link https://docs.cloudbase.net/api-reference/webv2/database.html#get}
1439
+ * {@link https://docs.cloudbase.net/api-reference/webv3/database.html#get}
1973
1440
  *
1974
1441
  * @example
1975
1442
  * collection
@@ -1985,7 +1452,7 @@ declare namespace cloudbase.database {
1985
1452
  /**
1986
1453
  * 更新数据库文档
1987
1454
  *
1988
- * {@link https://docs.cloudbase.net/api-reference/webv2/database.html#update-set}
1455
+ * {@link https://docs.cloudbase.net/api-reference/webv3/database.html#update-set}
1989
1456
  *
1990
1457
  * @example
1991
1458
  * collection
@@ -1999,11 +1466,11 @@ declare namespace cloudbase.database {
1999
1466
  *
2000
1467
  * @return Promise-查询结果
2001
1468
  */
2002
- update(data: any): Promise<UpdateRes>
1469
+ update(data: Object): Promise<UpdateRes>
2003
1470
  /**
2004
1471
  * 获取数据库查询结果的数目
2005
1472
  *
2006
- * {@link https://docs.cloudbase.net/api-reference/webv2/database.html#count}
1473
+ * {@link https://docs.cloudbase.net/api-reference/webv3/database#count}
2007
1474
  *
2008
1475
  * @example
2009
1476
  * collection
@@ -2019,7 +1486,7 @@ declare namespace cloudbase.database {
2019
1486
  /**
2020
1487
  * 设置过滤条件
2021
1488
  *
2022
- * {@link https://docs.cloudbase.net/api-reference/webv2/database.html#where}
1489
+ * {@link https://docs.cloudbase.net/api-reference/webv3/database#where}
2023
1490
  *
2024
1491
  * @example
2025
1492
  * collection
@@ -2030,11 +1497,11 @@ declare namespace cloudbase.database {
2030
1497
  * @param query 可接收对象作为参数,表示筛选出拥有和传入对象相同的 key-value 的文档
2031
1498
  *
2032
1499
  */
2033
- where(query: object): ExcludeOf<IQuery, 'where'>;
1500
+ where(query: Object): ExcludeOf<IQuery, 'where'>;
2034
1501
  /**
2035
1502
  * 指定查询结果集数量上限
2036
1503
  *
2037
- * {@link https://docs.cloudbase.net/api-reference/webv2/database.html#limit}
1504
+ * {@link https://docs.cloudbase.net/api-reference/webv3/database#limit}
2038
1505
  *
2039
1506
  * @example
2040
1507
  * collection
@@ -2049,7 +1516,7 @@ declare namespace cloudbase.database {
2049
1516
  /**
2050
1517
  * 指定查询返回结果时从指定序列后的结果开始返回,常用于分页
2051
1518
  *
2052
- * {@link https://docs.cloudbase.net/api-reference/webv2/database.html#skip}
1519
+ * {@link https://docs.cloudbase.net/api-reference/webv3/database#skip}
2053
1520
  *
2054
1521
  * @example
2055
1522
  * collection
@@ -2064,7 +1531,7 @@ declare namespace cloudbase.database {
2064
1531
  /**
2065
1532
  * 指定查询排序条件
2066
1533
  *
2067
- * {@link https://docs.cloudbase.net/api-reference/webv2/database.html#orderby}
1534
+ * {@link https://docs.cloudbase.net/api-reference/webv3/database#orderby}
2068
1535
  *
2069
1536
  * @example
2070
1537
  * collection
@@ -2076,11 +1543,11 @@ declare namespace cloudbase.database {
2076
1543
  * @param field 排序的字段
2077
1544
  * @param orderType 排序的顺序,升序(asc) 或 降序(desc)
2078
1545
  */
2079
- orderBy(field: string, orderType: string): ExcludeOf<IQuery, 'where'>;
1546
+ orderBy(field: string, orderType: 'desc' | 'asc'): ExcludeOf<IQuery, 'where'>;
2080
1547
  /**
2081
1548
  * 指定返回结果中文档需返回的字段
2082
1549
  *
2083
- * {@link https://docs.cloudbase.net/api-reference/webv2/database.html#field}
1550
+ * {@link https://docs.cloudbase.net/api-reference/webv3/database#field}
2084
1551
  *
2085
1552
  * @example
2086
1553
  * collection
@@ -2091,11 +1558,11 @@ declare namespace cloudbase.database {
2091
1558
  *
2092
1559
  * @param projection 要过滤的字段集合,不返回传 false,返回传 true
2093
1560
  */
2094
- field(projection: object): ExcludeOf<IQuery, 'where'>;
1561
+ field(projection: Object): ExcludeOf<IQuery, 'where'>;
2095
1562
  /**
2096
1563
  * 删除查询到的结果
2097
1564
  *
2098
- * {@link https://docs.cloudbase.net/api-reference/webv2/database.html#field}
1565
+ * {@link https://docs.cloudbase.net/api-reference/webv3/database#remove-1}
2099
1566
  *
2100
1567
  * @example
2101
1568
  * collection
@@ -2121,7 +1588,7 @@ declare namespace cloudbase.database {
2121
1588
  /**
2122
1589
  * 用于表示地理位置点
2123
1590
  *
2124
- * {@link https://docs.cloudbase.net/api-reference/webv2/database.html#point}
1591
+ * {@link https://docs.cloudbase.net/api-reference/webv3/database#point}
2125
1592
  *
2126
1593
  * @example
2127
1594
  * const point = new db.Geo.Point(lng,lat);
@@ -2137,7 +1604,7 @@ declare namespace cloudbase.database {
2137
1604
  /**
2138
1605
  * 用于表示地理路径,是由两个或者更多的 Point 组成的线段
2139
1606
  *
2140
- * {@link https://docs.cloudbase.net/api-reference/webv2/database.html#linestring}
1607
+ * {@link https://docs.cloudbase.net/api-reference/webv3/database#linestring}
2141
1608
  *
2142
1609
  * @example
2143
1610
  * const point = new db.Geo.LineString([pointA,pointB]);
@@ -2152,7 +1619,7 @@ declare namespace cloudbase.database {
2152
1619
  /**
2153
1620
  * 用于表示地理上的一个多边形
2154
1621
  *
2155
- * {@link https://docs.cloudbase.net/api-reference/webv2/database.html#polygon}
1622
+ * {@link https://docs.cloudbase.net/api-reference/webv3/database#polygon}
2156
1623
  *
2157
1624
  * @example
2158
1625
  * const point = new db.Geo.Polygon([lineStringA,lineStringB]);
@@ -2167,7 +1634,7 @@ declare namespace cloudbase.database {
2167
1634
  /**
2168
1635
  * 用于表示多个点 Point 的集合
2169
1636
  *
2170
- * {@link https://docs.cloudbase.net/api-reference/webv2/database.html#multipoint}
1637
+ * {@link https://docs.cloudbase.net/api-reference/webv3/database#multipoint}
2171
1638
  *
2172
1639
  * @example
2173
1640
  * const point = new db.Geo.MultiPoint([pointA,pointB]);
@@ -2182,7 +1649,7 @@ declare namespace cloudbase.database {
2182
1649
  /**
2183
1650
  * 用于表示多个地理路径 LineString 的集合
2184
1651
  *
2185
- * {@link https://docs.cloudbase.net/api-reference/webv2/database.html#multilinestring}
1652
+ * {@link https://docs.cloudbase.net/api-reference/webv3/database#multilinestring}
2186
1653
  *
2187
1654
  * @example
2188
1655
  * const point = new db.Geo.MultiLineString([lineA,lineB]);
@@ -2197,7 +1664,7 @@ declare namespace cloudbase.database {
2197
1664
  /**
2198
1665
  * 用于表示多个地理多边形 Polygon 的集合
2199
1666
  *
2200
- * {@link https://docs.cloudbase.net/api-reference/webv2/database.html#multipolygon}
1667
+ * {@link https://docs.cloudbase.net/api-reference/webv3/database#multipolygon}
2201
1668
  *
2202
1669
  * @example
2203
1670
  * const point = new db.Geo.MultiPolygon([polygonA,polygonB]);
@@ -2227,19 +1694,19 @@ declare namespace cloudbase.database {
2227
1694
  /**
2228
1695
  * 数据库指令
2229
1696
  *
2230
- * {@link https://docs.cloudbase.net/api-reference/webv2/database.html#query-command}
1697
+ * {@link https://docs.cloudbase.net/api-reference/webv3/database#%E6%9F%A5%E8%AF%A2%E6%8C%87%E4%BB%A4}
2231
1698
  */
2232
1699
  command: ICommand;
2233
1700
  /**
2234
1701
  * 数据库Geo地理位置
2235
1702
  *
2236
- * {@link https://docs.cloudbase.net/api-reference/webv2/database.html#geo-shu-ju-lei-xing}
1703
+ * {@link https://docs.cloudbase.net/api-reference/webv3/database.html#geo-shu-ju-lei-xing}
2237
1704
  */
2238
1705
  Geo: IGeo;
2239
1706
  /**
2240
1707
  * 根据正则表达式进行筛选
2241
1708
  *
2242
- * {@link https://docs.cloudbase.net/api-reference/webv2/database.html#regexp}
1709
+ * {@link https://docs.cloudbase.net/api-reference/webv3/database.html#regexp}
2243
1710
  *
2244
1711
  * @example
2245
1712
  * db.collection('articles').where({
@@ -2257,7 +1724,7 @@ declare namespace cloudbase.database {
2257
1724
  /**
2258
1725
  * 创建集合的引用
2259
1726
  *
2260
- * {@link https://docs.cloudbase.net/api-reference/webv2/database.html#collection}
1727
+ * {@link https://docs.cloudbase.net/api-reference/webv3/database.html#collection}
2261
1728
  *
2262
1729
  * @example
2263
1730
  * const coll = db.collection('demo');