@cloudbase/js-sdk 3.0.0 → 3.0.2

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,86 +1,148 @@
1
- import { CloudbaseAdapter } from '@cloudbase/adapter-interface';
2
- import { ICloudbaseUpgradedConfig, ICloudbase, Persistence } from '@cloudbase/types';
3
1
  import { OrmClient, OrmRawQueryClient } from '@cloudbase/model';
2
+ import { IMySqlClient } from '@cloudbase/mysql';
4
3
  import { authModels } from '@cloudbase/oauth';
4
+ import type {
5
+ SignInRes,
6
+ GetUserRes,
7
+ CommonRes,
8
+ SignInWithOtpRes,
9
+ SignInOAuthRes,
10
+ GetClaimsRes,
11
+ ResetPasswordForEmailRes,
12
+ GetUserIdentitiesRes,
13
+ LinkIdentityRes,
14
+ ReauthenticateRes,
15
+ ResendRes,
16
+ UpdateUserWithVerificationRes,
17
+ OnAuthStateChangeCallback,
18
+ SignInWithPasswordReq,
19
+ SignInWithIdTokenReq,
20
+ SignInWithOAuthReq,
21
+ VerifyOAuthReq,
22
+ VerifyOtpReq,
23
+ LinkIdentityReq,
24
+ UnlinkIdentityReq,
25
+ UpdateUserReq,
26
+ SignInWithOtpReq,
27
+ ResetPasswordForOldReq,
28
+ ResendReq,
29
+ SetSessionReq,
30
+ DeleteMeReq,
31
+ SignUpRes
32
+ } from '@cloudbase/auth';
5
33
  import { AI } from '@cloudbase/ai';
34
+ import { CloudbaseAdapter, ResponseObject } from '@cloudbase/adapter-interface'
35
+ import { ICloudbaseUpgradedConfig, ICloudbase, Persistence } from '@cloudbase/types'
36
+ import { LANGS } from '@cloudbase/types'
37
+ import { ICustomReqOpts } from '@cloudbase/types/functions'
6
38
 
7
39
  type KV<T> = {
8
- [key: string]: T;
9
- };
40
+ [key: string]: T
41
+ }
42
+
43
+ type ExcludeOf<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>
44
+
45
+
46
+ declare type MethodType = 'request' | 'post' | 'get' | 'head' | 'patch' | 'delete' | 'put'
47
+
48
+ interface ICallApiOptions {
49
+ /** 请求的path */
50
+ path?: string
51
+ /**请求方法 */
52
+ method?: MethodType
53
+ /**请求头 */
54
+ headers?: KV<any>
55
+ /** 请求体,根据content-type可以是不同类型 */
56
+ body?: KV<any> | string
57
+ /**可传token,如果没有传值,则默认用当前登录的token */
58
+ token?: string
59
+ }
10
60
 
11
- type ExcludeOf<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
61
+ interface ICloudbaseApis {
62
+ [apiName: string]: {
63
+ [method in MethodType]: (callApiOptions: ICallApiOptions, opts?: KV<any>) => Promise<ResponseObject['data']>
64
+ }
65
+ }
12
66
 
13
67
  /**
14
68
  * module
15
69
  */
16
70
  declare namespace cloudbase {
17
-
18
71
  interface SimpleStorage {
19
- getItem: (key: string) => Promise<string | null>;
20
- removeItem: (key: string) => Promise<void>;
21
- setItem: (key: string, value: string) => Promise<void>;
22
- getItemSync: (key: string) => string | null;
23
- removeItemSync: (key: string) => void;
24
- setItemSync: (key: string, value: string) => void;
72
+ getItem: (key: string) => Promise<string | null>
73
+ removeItem: (key: string) => Promise<void>
74
+ setItem: (key: string, value: string) => Promise<void>
75
+ getItemSync: (key: string) => string | null
76
+ removeItemSync: (key: string) => void
77
+ setItemSync: (key: string, value: string) => void
25
78
  }
26
79
 
27
80
  interface ICloudbaseConfig {
28
- env: string;
29
- region?: string;
30
- timeout?: number;
31
- persistence?: Persistence;
81
+ env: string
82
+ region?: string
83
+ timeout?: number
84
+ persistence?: Persistence
32
85
  oauthClient?: any
33
- debug?: boolean;
34
- _fromApp?: ICloudbase;
86
+ debug?: boolean
87
+ _fromApp?: ICloudbase
35
88
  clientId?: string
36
- oauthInstance?: any;
89
+ oauthInstance?: any
90
+ wxCloud?: any
91
+ i18n?: {
92
+ t: (text: string) => string
93
+ LANG_HEADER_KEY: string
94
+ lang: LANGS
95
+ }
96
+ accessKey?: string
97
+ endPointMode?: EndPointKey
98
+ lang?: LANGS
37
99
  }
38
100
 
39
101
  interface ICloudbaseExtension {
40
- name: string;
41
- invoke(opts: any, app: ICloudbase): Promise<any>;
102
+ name: string
103
+ invoke(opts: any, app: ICloudbase): Promise<any>
42
104
  }
43
105
 
44
106
  interface Listeners {
45
- [key: string]: Function[];
107
+ [key: string]: Function[]
46
108
  }
47
109
 
48
110
  interface ICloudbaseEvent {
49
- name: string;
50
- target: any;
51
- data: any;
111
+ name: string
112
+ target: any
113
+ data: any
52
114
  }
53
115
 
54
116
  interface ICloudbaseEventEmitter {
55
- on(name: string, listener: Function): this;
56
- off(name: string, listener: Function): this;
57
- fire(event: string | ICloudbaseEvent, data?: any): this;
117
+ on(name: string, listener: Function): this
118
+ off(name: string, listener: Function): this
119
+ fire(event: string | ICloudbaseEvent, data?: any): this
58
120
  }
59
121
 
60
122
  interface ICloudbaseComponent {
61
- name: string;
62
- entity: any;
63
- namespace?: string;
123
+ name: string
124
+ entity: any
125
+ namespace?: string
64
126
  injectEvents?: {
65
- bus: ICloudbaseEventEmitter,
66
- events: string[];
67
- };
127
+ bus: ICloudbaseEventEmitter
128
+ events: string[]
129
+ }
68
130
  IIFE?: boolean
69
131
  }
70
132
 
71
133
  interface ICloudbaseHook {
72
- entity: any;
73
- target: string;
134
+ entity: any
135
+ target: string
74
136
  }
75
137
 
76
- type EndPointKey = 'CLOUD_API' | 'GATEWAY';
138
+ type EndPointKey = 'CLOUD_API' | 'GATEWAY'
77
139
 
78
140
  interface ISetEndPointWithKey {
79
- key: EndPointKey;
80
- url?: string;
81
- protocol?: 'http' | 'https';
141
+ key: EndPointKey
142
+ url?: string
143
+ protocol?: 'http' | 'https'
82
144
  }
83
-
145
+
84
146
  /**
85
147
  * 初始化Cloudbase
86
148
  *
@@ -98,9 +160,11 @@ declare namespace cloudbase {
98
160
  *
99
161
  * @return {!cloudbase.app.App} 初始化成功的Cloudbase实例
100
162
  */
101
- function init(config: ICloudbaseConfig): cloudbase.app.App;
163
+ function init(config: ICloudbaseConfig): cloudbase.app.App
102
164
 
103
- function updateConfig(config: ICloudbaseUpgradedConfig): void;
165
+ function updateConfig(config: ICloudbaseUpgradedConfig): void
166
+
167
+ function updateLang(lang: LANGS): void
104
168
  /**
105
169
  * 使用适配器,使用方式参考 {@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}
106
170
  *
@@ -116,7 +180,7 @@ declare namespace cloudbase {
116
180
  * @param adapters 适配器对象,入参可以为单个适配器对象,也可以是多个适配器对象的数组
117
181
  * @param options 适配器参数,可以在genAdapter中获取到该参数
118
182
  */
119
- function useAdapters(adapters: CloudbaseAdapter | CloudbaseAdapter[], options?: any): void;
183
+ function useAdapters(adapters: CloudbaseAdapter | CloudbaseAdapter[], options?: any): void
120
184
  /**
121
185
  * 注册扩展能力插件,使用方式参考 {@link https://docs.cloudbase.net/extension/abilities/image-examination.html#shi-yong-kuo-zhan}
122
186
  *
@@ -127,7 +191,7 @@ declare namespace cloudbase {
127
191
  *
128
192
  * @param ext 扩展能力插件对象
129
193
  */
130
- function registerExtension(ext: ICloudbaseExtension): void;
194
+ function registerExtension(ext: ICloudbaseExtension): void
131
195
  /**
132
196
  * 【谨慎操作】注册SDK的版本
133
197
  *
@@ -138,7 +202,7 @@ declare namespace cloudbase {
138
202
  *
139
203
  * @param version SDK版本
140
204
  */
141
- function registerVersion(version: string): void;
205
+ function registerVersion(version: string): void
142
206
  /**
143
207
  * 【谨慎操作】注册SDK的名称
144
208
  *
@@ -149,7 +213,7 @@ declare namespace cloudbase {
149
213
  *
150
214
  * @param name SDK名称
151
215
  */
152
- function registerSdkName(name: string): void;
216
+ function registerSdkName(name: string): void
153
217
  /**
154
218
  * 【谨慎操作】修改SDK请求的云开发服务地址
155
219
  *
@@ -161,21 +225,21 @@ declare namespace cloudbase {
161
225
  * @param url 服务地址
162
226
  * @param protocol 【可选】强制使用某种协议,默认与主站协议一致
163
227
  */
164
- function registerEndPoint(url: string, protocol?: 'http' | 'https'): void;
228
+ function registerEndPoint(url: string, protocol?: 'http' | 'https'): void
165
229
  /**
166
230
  * 【谨慎操作】修改SDK请求的「云开发/网关」服务地址
167
231
  *
168
232
  * @example
169
233
  * ```javascript
170
- * cloudbase.registerEndPointWithKey({
171
- * key: "GATEWAY",
172
- * url: "",
234
+ * cloudbase.registerEndPointWithKey({
235
+ * key: "GATEWAY",
236
+ * url: "",
173
237
  * protocol: ""
174
238
  * });
175
239
  * ```
176
240
  *
177
241
  */
178
- function registerEndPointWithKey(props: ISetEndPointWithKey): void;
242
+ function registerEndPointWithKey(props: ISetEndPointWithKey): void
179
243
  /**
180
244
  * 【谨慎操作】注册功能模块
181
245
  *
@@ -186,7 +250,7 @@ declare namespace cloudbase {
186
250
  *
187
251
  * @param component 功能模块对象
188
252
  */
189
- function registerComponent(component: ICloudbaseComponent): void;
253
+ function registerComponent(component: ICloudbaseComponent): void
190
254
  /**
191
255
  * 【谨慎操作】注册hook
192
256
  *
@@ -197,9 +261,9 @@ declare namespace cloudbase {
197
261
  *
198
262
  * @param hook hook对象
199
263
  */
200
- function registerHook(hook: ICloudbaseHook): void;
264
+ function registerHook(hook: ICloudbaseHook): void
201
265
 
202
- export interface models extends OrmClient, OrmRawQueryClient { }
266
+ export interface models extends OrmClient, OrmRawQueryClient {}
203
267
  }
204
268
  /**
205
269
  * instance
@@ -226,9 +290,7 @@ declare namespace cloudbase.app {
226
290
  *
227
291
  * @return {!cloudbase.auth.App} Auth实例
228
292
  */
229
- auth(options?: {
230
- persistence: cloudbase.auth.Persistence
231
- }): cloudbase.auth.App;
293
+ auth: ((options?: { persistence: cloudbase.auth.Persistence }) => cloudbase.auth.App) & cloudbase.auth.App
232
294
  /**
233
295
  * 调用云函数
234
296
  *
@@ -257,7 +319,49 @@ declare namespace cloudbase.app {
257
319
  *
258
320
  * @return Promise-函数执行结果
259
321
  */
260
- callFunction(options: cloudbase.functions.ICallFunctionOptions, callback?: Function): Promise<cloudbase.functions.ICallFunctionResponse>;
322
+ callFunction(
323
+ options: cloudbase.functions.ICallFunctionOptions,
324
+ callback?: Function,
325
+ customReqOpts?: ICustomReqOpts,
326
+ ): Promise<cloudbase.functions.ICallFunctionResponse>
327
+ /**
328
+ * 调用云托管
329
+ *
330
+ * {@link https://docs.cloudbase.net/api-reference/webv3/cloudrun}
331
+ *
332
+ * @example
333
+ * ```javascript
334
+ * const app = cloudbase.init({
335
+ * env: 'your-envid'
336
+ * });
337
+ * app
338
+ * .callContainer({
339
+ * name: 'helloworld',
340
+ * method: 'POST',
341
+ * path: '/abc',
342
+ * header:{
343
+ * 'Content-Type': 'application/json; charset=utf-8'
344
+ * },
345
+ * data: {
346
+ * key1: 'test value 1',
347
+ * key2: 'test value 2'
348
+ * },
349
+ * })
350
+ * .then((res) => {
351
+ * console.log(res)
352
+ * });
353
+ * ```
354
+ *
355
+ * @param options 被调用的云托管信息
356
+ * @param options.name 云托管的名称
357
+ * @param options.data 【可选】云托管的参数,默认为空
358
+ *
359
+ * @return Promise-云托管执行结果
360
+ */
361
+ callContainer(
362
+ options: cloudbase.functions.ICallFunctionOptions,
363
+ customReqOpts?: ICustomReqOpts,
364
+ ): Promise<ResponseObject>
261
365
  /**
262
366
  * 云存储-上传文件
263
367
  *
@@ -288,7 +392,10 @@ declare namespace cloudbase.app {
288
392
  *
289
393
  * @return Promise-上传结果
290
394
  */
291
- uploadFile(params: cloudbase.storage.ICloudbaseUploadFileParams, callback?: Function): Promise<cloudbase.storage.ICloudbaseUploadFileResult>;
395
+ uploadFile(
396
+ params: cloudbase.storage.ICloudbaseUploadFileParams,
397
+ callback?: Function,
398
+ ): Promise<cloudbase.storage.ICloudbaseUploadFileResult>
292
399
  /**
293
400
  * 云存储-下载文件
294
401
  *
@@ -309,7 +416,40 @@ declare namespace cloudbase.app {
309
416
  *
310
417
  * @return Promise-下载结果
311
418
  */
312
- downloadFile(params: cloudbase.storage.ICloudbaseDownloadFileParams, callback?: Function): Promise<cloudbase.storage.ICloudbaseDownloadFileResult>;
419
+ downloadFile(
420
+ params: cloudbase.storage.ICloudbaseDownloadFileParams,
421
+ callback?: Function,
422
+ ): Promise<cloudbase.storage.ICloudbaseDownloadFileResult>
423
+ /**
424
+ * 云存储-批量复制文件
425
+ *
426
+ *
427
+ * @example
428
+ * ```javascript
429
+ * const app = cloudbase.init({
430
+ * env: 'your-envid'
431
+ * });
432
+ * app.copyFile({
433
+ * fileList: [
434
+ * {
435
+ * srcPath: '源文件的绝对路径,包含文件名。例如 foo/bar.jpg、foo/bar/baz.jpg 等,不能包含除[0-9 , a-z , A-Z]、/、!、-、_、.、、*和中文以外的字符,使用 / 字符来实现类似传统文件系统的层级结构',
436
+ * dstPath: '目标文件的绝对路径,包含文件名。例如 foo/bar.jpg、foo/bar/baz.jpg 等,不能包含除[0-9 , a-z , A-Z]、/、!、-、_、.、、*和中文以外的字符,使用 / 字符来实现类似传统文件系统的层级结构',
437
+ * overwrite: '当目标文件已经存在时,是否允许覆盖已有文件,默认 true',
438
+ * removeOriginal: '复制文件后是否删除源文件,默认 false'
439
+ * }
440
+ * ]
441
+ * });
442
+ * ```
443
+ *
444
+ * @param params
445
+ * @param params.fileList 要复制的文件信息组成的数组
446
+ *
447
+ * @return Promise-复制结果
448
+ */
449
+ copyFile(
450
+ params: cloudbase.storage.ICloudbaseCopyFileParams,
451
+ callback?: Function,
452
+ ): Promise<cloudbase.storage.ICloudbaseCopyFileResult>
313
453
  /**
314
454
  * 云存储-获取文件的下载链接
315
455
  *
@@ -338,7 +478,10 @@ declare namespace cloudbase.app {
338
478
  *
339
479
  * @return Promise-文件下载链接
340
480
  */
341
- getTempFileURL(params: cloudbase.storage.ICloudbaseGetTempFileURLParams, callback?: Function): Promise<cloudbase.storage.ICloudbaseGetTempFileURLResult>;
481
+ getTempFileURL(
482
+ params: cloudbase.storage.ICloudbaseGetTempFileURLParams,
483
+ callback?: Function,
484
+ ): Promise<cloudbase.storage.ICloudbaseGetTempFileURLResult>
342
485
  /**
343
486
  * 云存储-删除文件
344
487
  *
@@ -362,15 +505,23 @@ declare namespace cloudbase.app {
362
505
  *
363
506
  * @return Promise-删除结果
364
507
  */
365
- deleteFile(params: cloudbase.storage.ICloudbaseDeleteFileParams, callback?: Function): Promise<cloudbase.storage.ICloudbaseDeleteFileResult>;
508
+ deleteFile(
509
+ params: cloudbase.storage.ICloudbaseDeleteFileParams,
510
+ callback?: Function,
511
+ ): Promise<cloudbase.storage.ICloudbaseDeleteFileResult>
512
+
513
+ getFileInfo(
514
+ params: cloudbase.storage.ICloudbaseGetTempFileURLParams,
515
+ callback?: Function,
516
+ ): Promise<cloudbase.storage.ICloudbaseGetTempFileURLResult>
366
517
  /**
367
518
  * 云存储-获取上传元信息
368
- *
369
- *
370
- * @param params
371
- * @param callback
519
+ *
520
+ *
521
+ * @param params
522
+ * @param callback
372
523
  */
373
- getUploadMetadata(params: cloudbase.storage.ICloudbaseGetUploadMetadataParams, callback?: Function): Promise<any>;
524
+ getUploadMetadata(params: cloudbase.storage.ICloudbaseGetUploadMetadataParams, callback?: Function): Promise<any>
374
525
  /**
375
526
  * 获取数据库实例
376
527
  *
@@ -386,7 +537,7 @@ declare namespace cloudbase.app {
386
537
  *
387
538
  * @return 数据库实例
388
539
  */
389
- database(): cloudbase.database.App;
540
+ database(dbConfig?: object): cloudbase.database.App
390
541
  /**
391
542
  * 调用扩展能力插件功能
392
543
  *
@@ -408,9 +559,9 @@ declare namespace cloudbase.app {
408
559
  *
409
560
  * @return Promise-扩展能力插件执行结果
410
561
  */
411
- invokeExtension(name: string, opts: any): Promise<any>;
562
+ invokeExtension(name: string, opts: any): Promise<any>
412
563
 
413
- eventBus: any;
564
+ eventBus: any
414
565
 
415
566
  /**
416
567
  * 调用 数据模型 SDK
@@ -429,63 +580,82 @@ declare namespace cloudbase.app {
429
580
  models.$runSQL() // 执行原生 SQL 语句
430
581
  * ```
431
582
  */
432
- models: OrmClient & OrmRawQueryClient;
583
+ models: OrmClient & OrmRawQueryClient
584
+
585
+ /**
586
+ * MySQL 数据库
587
+ *
588
+ * @example
589
+ * ```javascript
590
+ * const app = cloudbase.init({
591
+ * env: "xxxx-yyy"
592
+ * });
593
+ *
594
+ * app.mysql().from('todos').select().then((res) => {
595
+ * console.log(res.data);
596
+ * });
597
+ * ```
598
+ */
599
+ mysql: IMySqlClient;
600
+ rdb: IMySqlClient;
433
601
 
434
602
  ai(): AI;
603
+
604
+ apis: ICloudbaseApis;
435
605
  }
436
606
  }
437
607
  /**
438
608
  * auth
439
609
  */
440
610
  declare namespace cloudbase.auth {
441
- type Persistence = 'local' | 'session' | 'none';
611
+ type Persistence = 'local' | 'session' | 'none'
442
612
 
443
613
  interface IAccessTokenInfo {
444
- accessToken: string;
445
- env: string;
614
+ accessToken: string
615
+ env: string
446
616
  }
447
617
 
448
618
  interface ILoginState {
449
619
  /**
450
620
  * 当前登录用户的信息
451
621
  */
452
- user: IUser;
622
+ user: IUser
453
623
  }
454
624
 
455
625
  interface ICredential {
456
- accessToken?: string;
457
- accessTokenExpire?: string;
626
+ accessToken?: string
627
+ accessTokenExpire?: string
458
628
  }
459
629
 
460
630
  interface IAuthProvider {
461
- signInWithRedirect: () => any;
631
+ signInWithRedirect: () => any
462
632
  }
463
633
 
464
634
  /**
465
635
  * 用户信息
466
636
  */
467
637
  interface IUserInfo {
468
- uid?: string;
469
- loginType?: string;
470
- openid?: string;
471
- wxOpenId?: string;
472
- wxPublicId?: string;
473
- unionId?: string;
474
- qqMiniOpenId?: string;
475
- customUserId?: string;
476
- name?: string;
477
- gender?: string;
478
- email?: string;
479
- username?: string;
480
- hasPassword?: boolean;
638
+ uid?: string
639
+ loginType?: string
640
+ openid?: string
641
+ wxOpenId?: string
642
+ wxPublicId?: string
643
+ unionId?: string
644
+ qqMiniOpenId?: string
645
+ customUserId?: string
646
+ name?: string
647
+ gender?: string
648
+ email?: string
649
+ username?: string
650
+ hasPassword?: boolean
481
651
  location?: {
482
- country?: string;
483
- province?: string;
484
- city?: string;
485
- };
486
- country?: string;
487
- province?: string;
488
- city?: string;
652
+ country?: string
653
+ province?: string
654
+ city?: string
655
+ }
656
+ country?: string
657
+ province?: string
658
+ city?: string
489
659
  }
490
660
 
491
661
  interface IUser extends IUserInfo {
@@ -511,7 +681,7 @@ declare namespace cloudbase.auth {
511
681
  * @return Promise
512
682
  *
513
683
  */
514
- update(userinfo: IUserInfo): Promise<void>;
684
+ update(userinfo: IUserInfo): Promise<void>
515
685
  /**
516
686
  * 刷新本地用户信息
517
687
  *
@@ -530,27 +700,27 @@ declare namespace cloudbase.auth {
530
700
  * @return Promise-刷新后的用户信息
531
701
  *
532
702
  */
533
- refresh(): Promise<IUserInfo>;
703
+ refresh(): Promise<IUserInfo>
534
704
  /**
535
705
  * 同步获取本地用户信息
536
706
  */
537
- checkLocalInfo: () => void;
707
+ checkLocalInfo: () => void
538
708
  /**
539
709
  * 异步获取本地用户信息
540
710
  */
541
- checkLocalInfoAsync: () => Promise<void>;
542
- linkWithTicket?: (ticket: string) => Promise<void>;
543
- linkWithRedirect?: (provider: IAuthProvider) => void;
544
- getLinkedUidList?: () => Promise<{ hasPrimaryUid: boolean, users: IUserInfo[] }>;
545
- setPrimaryUid?: (uid: string) => Promise<void>;
546
- unlink?: (loginType: 'CUSTOM' | 'WECHAT-OPEN' | 'WECHAT-PUBLIC' | 'WECHAT-UNION') => Promise<void>;
711
+ checkLocalInfoAsync: () => Promise<void>
712
+ linkWithTicket?: (ticket: string) => Promise<void>
713
+ linkWithRedirect?: (provider: IAuthProvider) => void
714
+ getLinkedUidList?: () => Promise<{ hasPrimaryUid: boolean; users: IUserInfo[] }>
715
+ setPrimaryUid?: (uid: string) => Promise<void>
716
+ unlink?: (loginType: 'CUSTOM' | 'WECHAT-OPEN' | 'WECHAT-PUBLIC' | 'WECHAT-UNION') => Promise<void>
547
717
  }
548
718
 
549
719
  interface App {
550
720
  /**
551
721
  * 获取当前登录的用户信息-同步操作
552
722
  *
553
- * {@link https://docs.cloudbase.net/api-reference/webv3/authentication.html#auth-hasloginstate}
723
+ * {@link https://docs.cloudbase.net/api-reference/webv2/authentication#authhasloginstate}
554
724
  *
555
725
  * @example
556
726
  * ```javascript
@@ -562,9 +732,9 @@ declare namespace cloudbase.auth {
562
732
  *
563
733
  * @return 用户信息,如果未登录返回`null`
564
734
  */
565
- currentUser: IUser | null;
735
+ currentUser: IUser | null
566
736
  /**
567
- * 获取当前登录的用户信息-异步操作,文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authgetcurrentuser}
737
+ * 获取当前登录的用户信息-异步操作,文档 {@link https://docs.cloudbase.net/api-reference/webv2/authentication#authgetcurrentuser}
568
738
  *
569
739
  * @example
570
740
  * ```javascript
@@ -581,97 +751,139 @@ declare namespace cloudbase.auth {
581
751
  getCurrentUser(): Promise<IUser | null>
582
752
  /**
583
753
  * 绑定手机号码
584
- *
585
- * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authbindphonenumber}
586
- *
587
- * @param params
754
+ *
755
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv2/authentication#authbindphonenumber}
756
+ *
757
+ * @param params
588
758
  */
589
759
  bindPhoneNumber(params: authModels.BindPhoneRequest): Promise<void>
590
760
  /**
591
761
  * 绑定邮箱
592
- *
593
- * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authbindemail}
594
- *
595
- * @param params
762
+ *
763
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv2/authentication#authbindemail}
764
+ *
765
+ * @param params
596
766
  */
597
767
  bindEmail(params: authModels.BindEmailRequest): Promise<void>
598
768
  /**
599
769
  * 解除三方绑定
600
- *
601
- * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authunbindprovider}
602
- *
603
- * @param params
770
+ *
771
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv2/authentication#authunbindprovider}
772
+ *
773
+ * @param params
604
774
  */
605
775
  unbindProvider(params: authModels.UnbindProviderRequest): Promise<void>
606
776
 
607
777
  /**
608
778
  * 验证码验证
609
- *
610
- * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authverify}
611
- *
612
- * @param params
779
+ *
780
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv2/authentication#authverify}
781
+ *
782
+ * @param params
613
783
  */
614
784
  verify(params: authModels.VerifyRequest): Promise<authModels.VerifyResponse>
615
785
  /**
616
786
  * 获取验证码
617
- *
618
- * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authgetverification}
619
- *
620
- * @param params
787
+ *
788
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv2/authentication#authgetverification}
789
+ *
790
+ * @param params
791
+ * @param options
621
792
  */
622
- getVerification(params: authModels.GetVerificationRequest): Promise<authModels.GetVerificationResponse>
793
+ getVerification(params: authModels.GetVerificationRequest, options?: { withCaptcha: boolean }): Promise<authModels.GetVerificationResponse>
623
794
  /**
624
795
  * 匿名登录
625
- *
626
- *
627
- * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authsigninanonymously}
628
- *
796
+ *
797
+ *
798
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv2/authentication#authsigninanonymously}
799
+ *
629
800
  */
630
- signInAnonymously(data?: { provider_token?: string }): Promise<ILoginState>
801
+ signInAnonymously(data?: { provider_token?: string }): Promise<SignInRes>
631
802
  /**
632
- * 设置获取自定义登录 ticket 的函数
633
- *
634
- * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authsetcustomsignfunc}
635
- *
636
- *
637
- * @param getTickFn
803
+ * 小程序匿名登录
804
+ *
805
+ * @param params
638
806
  */
639
- setCustomSignFunc(getTickFn: authModels.GetCustomSignTicketFn): void
807
+ signInAnonymouslyInWx(params?: { useWxCloud?: boolean }): Promise<ILoginState>
640
808
  /**
641
- * 使用自定义登录 ticket 登录
642
- *
643
- * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authsigninwithcustomticket}
809
+ * 小程序绑定OpenID
810
+ *
811
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv2/authentication#authbindopenid}
812
+ *
644
813
  */
645
- signInWithCustomTicket(): Promise<ILoginState>
814
+ bindOpenId(): Promise<void>
646
815
  /**
647
- * 用户登录,目前支持手机号,邮箱,用户名密码登录
648
- *
649
- * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authsignin}
816
+ * 小程序unionId静默登录
817
+ *
818
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv2/authentication#authsigninwithunionid}
819
+ *
650
820
  */
651
- signIn(params: authModels.SignInRequest): Promise<ILoginState>
821
+ signInWithUnionId(): Promise<ILoginState>
652
822
  /**
653
- * 用户注册,目前支持手机号验证码注册,邮箱验证码注册
654
- *
655
- * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authsignup}
823
+ * 短信验证码登录
824
+ *
825
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv2/authentication#authsigninwithsms}
826
+ *
827
+ * @param params
656
828
  */
657
- signUp(params: authModels.SignUpRequest): Promise<ILoginState>
829
+ signInWithSms(params: {
830
+ verificationInfo?: { verification_id: string; is_user: boolean }
831
+ verificationCode?: string
832
+ phoneNum?: string
833
+ bindInfo?: any
834
+ }): Promise<ILoginState>
835
+ /**
836
+ * 邮箱验证码登录
837
+ *
838
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv2/authentication#authsigninwithemail}
839
+ *
840
+ * @param params
841
+ */
842
+ signInWithEmail(params: {
843
+ verificationInfo?: { verification_id: string; is_user: boolean }
844
+ verificationCode?: string
845
+ email?: string
846
+ bindInfo?: any
847
+ }): Promise<ILoginState>
848
+ /**
849
+ * 设置获取自定义登录 ticket 的函数
850
+ *
851
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv2/authentication#authsetcustomsignfunc}
852
+ *
853
+ *
854
+ * @param getTickFn
855
+ */
856
+ setCustomSignFunc(getTickFn: authModels.GetCustomSignTicketFn): void
658
857
  /**
659
858
  * 设置密码(已登录状态下,更新用户密码)
660
- *
661
- * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authsetpassword}
662
- *
859
+ *
860
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv2/authentication#authsetpassword}
861
+ *
663
862
  */
664
863
  setPassword(params: authModels.SetPasswordRequest): Promise<void>
665
864
  /**
666
865
  * 获取用户信息
667
- *
668
- * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authgetuserinfo}
866
+ *
867
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv2/authentication#authgetuserinfo}
669
868
  */
670
869
  getUserInfo(): Promise<IUserInfo>
870
+ /**
871
+ * 获取微搭插件用户信息
872
+ *
873
+ */
874
+ getWedaUserInfo(): Promise<any>
875
+ /**
876
+ * 更新用户基本信息
877
+ *
878
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv2/authentication#authupdateuserbasicinfo}
879
+ *
880
+ * @param params
881
+ */
882
+ updateUserBasicInfo(params: authModels.ModifyUserBasicInfoRequest): Promise<void>
671
883
  /**
672
884
  * 获取本地登录态-同步操作
673
885
  *
674
- * {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authhasloginstate}
886
+ * {@link https://docs.cloudbase.net/api-reference/webv2/authentication#authhasloginstate}
675
887
  *
676
888
  * @example
677
889
  * ```javascript
@@ -683,11 +895,11 @@ declare namespace cloudbase.auth {
683
895
  *
684
896
  * @return 登录态信息,如果未登录返回`null`
685
897
  */
686
- hasLoginState(): ILoginState | null;
898
+ hasLoginState(): ILoginState | null
687
899
  /**
688
900
  * 获取本地登录态-异步操作
689
901
  *
690
- * {@link https://docs.cloudbase.net/api-reference/webv3/authentication.html#auth-getloginstate}
902
+ * {@link https://docs.cloudbase.net/api-reference/webv2/authentication.html#auth-getloginstate}
691
903
  *
692
904
  * @example
693
905
  * ```javascript
@@ -701,104 +913,153 @@ declare namespace cloudbase.auth {
701
913
  *
702
914
  * @return Promise-登录态信息,如果未登录返回`null`
703
915
  */
704
- getLoginState(): Promise<ILoginState | null>;
916
+ getLoginState(): Promise<ILoginState | null>
705
917
  /**
706
918
  * @deprecated
707
919
  */
708
920
  getAuthHeader(): {}
709
921
  /**
710
922
  * 为已有账户绑定第三方账户
711
- *
712
- * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authbindwithprovider}
923
+ *
924
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv2/authentication#authbindwithprovider}
713
925
  */
714
- bindWithProvider(params: authModels.BindWithProviderRequest,): Promise<void>
926
+ bindWithProvider(params: authModels.BindWithProviderRequest): Promise<void>
715
927
  /**
716
928
  * 查询用户(自定义登录场景和匿名登录场景,不支持使用该接口查询用户信息)
717
- *
718
- * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authqueryuser}
719
- *
929
+ *
930
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv2/authentication#authqueryuser}
931
+ *
720
932
  */
721
933
  queryUser(queryObj: authModels.QueryUserProfileRequest): Promise<authModels.QueryUserProfileResponse>
722
934
  /**
723
935
  * 获取当前登录用户的访问凭证
724
- *
725
- * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authgetaccesstoken}
936
+ *
937
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv2/authentication#authgetaccesstoken}
726
938
  */
727
- getAccessToken(): Promise<{ accessToken: string, env: string }>
939
+ getAccessToken(): Promise<{ accessToken: string; env: string }>
728
940
  /**
729
941
  * 提供第三方平台登录 token
730
- *
731
- * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authgrantprovidertoken}
942
+ *
943
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv2/authentication#authgrantprovidertoken}
732
944
  */
733
945
  grantProviderToken(params: authModels.GrantProviderTokenRequest): Promise<authModels.GrantProviderTokenResponse>
734
946
  patchProviderToken(params: authModels.PatchProviderTokenRequest): Promise<authModels.PatchProviderTokenResponse>
735
947
  /**
736
948
  * 第三方平台登录
737
- *
738
- * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authsigninwithprovider}
949
+ *
950
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv2/authentication#authsigninwithprovider}
739
951
  */
740
952
  signInWithProvider(params: authModels.SignInWithProviderRequest): Promise<ILoginState>
953
+ /**
954
+ * 微信登录
955
+ */
956
+ signInWithWechat(params?: any): Promise<ILoginState>
741
957
  grantToken(params: authModels.GrantTokenRequest): Promise<ILoginState>
742
958
  /**
743
959
  * 生成第三方平台授权 Uri (如微信二维码扫码授权网页)
744
- *
745
- * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authgenproviderredirecturi}
960
+ *
961
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv2/authentication#authgenproviderredirecturi}
746
962
  */
747
- genProviderRedirectUri(params: authModels.GenProviderRedirectUriRequest): Promise<authModels.GenProviderRedirectUriResponse>
963
+ genProviderRedirectUri(
964
+ params: authModels.GenProviderRedirectUriRequest,
965
+ ): Promise<authModels.GenProviderRedirectUriResponse>
748
966
  /**
749
967
  * 重置密码(用户忘记密码无法登录时,可使用该接口强制设置密码)
750
- *
751
- * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authresetpassword}
968
+ *
969
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv2/authentication#authresetpassword}
752
970
  */
753
971
  resetPassword(params: authModels.ResetPasswordRequest): Promise<void>
754
972
  deviceAuthorize(params: authModels.DeviceAuthorizeRequest): Promise<authModels.DeviceAuthorizeResponse>
755
973
  /**
756
974
  * 通过 sudo 接口获取高级操作权限,如修改用户密码,修改手机号,邮箱等操作
757
- *
758
- * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authsudo}
975
+ *
976
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv2/authentication#authsudo}
759
977
  */
760
978
  sudo(params: authModels.SudoRequest): Promise<authModels.SudoResponse>
761
979
  /**
762
980
  * 删除用户
763
- *
764
- * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authdeleteme}
981
+ *
982
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv2/authentication#authdeleteme}
765
983
  */
766
984
  deleteMe(params: authModels.WithSudoRequest): Promise<authModels.UserProfile>
767
985
  /**
768
986
  * 获取第三方绑定列表
769
- *
770
- * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authgetproviders}
987
+ *
988
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv2/authentication#authgetproviders}
771
989
  */
772
990
  getProviders(): Promise<authModels.UserProfileProvider>
773
991
  /**
774
992
  * 用于查询用户是否为匿名登录状态
775
- *
776
- * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authloginscope}
993
+ *
994
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv2/authentication#authloginscope}
777
995
  */
778
996
  loginScope(): Promise<string>
779
997
  loginGroups(): Promise<string[]>
780
998
  onLoginStateChanged(callback: Function)
781
- createLoginState(): Promise<ILoginState>
999
+ createLoginState(params?: { version?: string; query?: any }, options?: { asyncRefreshUser?: boolean; userInfo?: any }): Promise<ILoginState>
782
1000
  /**
783
- * 退出登录,请注意,匿名登录不支持退出
1001
+ * 强制刷新token
784
1002
  *
785
- * {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authsignout}
1003
+ * @param params
1004
+ */
1005
+ refreshTokenForce(params: { version?: string }): Promise<authModels.Credentials>
1006
+ /**
1007
+ * 获取身份信息
786
1008
  *
787
- * @example
788
- * ```javascript
789
- * const app = cloudbase.init({
790
- * env: "xxxx-yyy"
791
- * });
792
- * app.auth().signOut().then(()=>{});
793
- * ```
1009
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv2/authentication#authgetcredentials}
1010
+ */
1011
+ getCredentials(): Promise<authModels.Credentials>
1012
+ /**
1013
+ * 写入身份信息
794
1014
  *
795
- * @return Promise
1015
+ * @param credentials
1016
+ */
1017
+ setCredentials(credentials: authModels.Credentials): Promise<void>
1018
+ /**
1019
+ * 获取身份源类型
1020
+ *
1021
+ */
1022
+ getProviderSubType(): Promise<authModels.ProviderSubType>
1023
+ /**
1024
+ * 创建验证码数据
1025
+ *
1026
+ * @param params
1027
+ */
1028
+ createCaptchaData(params: { state: string; redirect_uri?: string }): Promise<any>
1029
+ /**
1030
+ * 验证验证码数据
1031
+ *
1032
+ * @param params
1033
+ */
1034
+ verifyCaptchaData(params: { token: string; key: string }): Promise<any>
1035
+ /**
1036
+ * 修改密码
1037
+ *
1038
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv2/authentication#authmodifypassword}
1039
+ *
1040
+ * @param params
1041
+ */
1042
+ modifyPassword(params: authModels.ModifyUserBasicInfoRequest): Promise<void>
1043
+ /**
1044
+ * 未登录状态修改密码
1045
+ *
1046
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv2/authentication#authmodifypasswordwithoutlogin}
1047
+ *
1048
+ * @param params
1049
+ */
1050
+ modifyPasswordWithoutLogin(params: authModels.ModifyPasswordWithoutLoginRequest): Promise<void>
1051
+ /**
1052
+ * 获取用户行为日志
1053
+ *
1054
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv2/authentication#authgetuserbehaviorlog}
1055
+ *
1056
+ * @param params
796
1057
  */
797
- signOut(): Promise<void>;
1058
+ getUserBehaviorLog(params: authModels.GetUserBehaviorLog): Promise<authModels.GetUserBehaviorLogRes>
798
1059
  /**
799
1060
  * 检查用户名是否被绑定过
800
1061
  *
801
- * {@link https://docs.cloudbase.net/api-reference/webv3/authentication.html#authisusernameregistered}
1062
+ * {@link https://docs.cloudbase.net/api-reference/webv2/authentication.html#authisusernameregistered}
802
1063
  *
803
1064
  * @example
804
1065
  * ```javascript
@@ -816,9 +1077,236 @@ declare namespace cloudbase.auth {
816
1077
  *
817
1078
  * @return Promise-用户是否被绑定
818
1079
  */
819
- isUsernameRegistered(username: string): Promise<boolean>;
820
- getMiniProgramQrCode(params: authModels.GetMiniProgramCodeRequest): Promise<authModels.GetMiniProgramCodeResponse>
821
- getMiniProgramQrCodeStatus(params: authModels.CheckMiniProgramCodeRequest): Promise<authModels.CheckMiniProgramCodeResponse>
1080
+ isUsernameRegistered(username: string): Promise<boolean>
1081
+ getMiniProgramQrCode(params: authModels.GetMiniProgramQrCodeRequest): Promise<authModels.GetMiniProgramQrCodeResponse>
1082
+ getMiniProgramQrCodeStatus(
1083
+ params: authModels.GetMiniProgramQrCodeStatusRequest,
1084
+ ): Promise<authModels.GetMiniProgramQrCodeStatusResponse>
1085
+ /**
1086
+ * 跳转到默认登录页
1087
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv2/authentication#authtodefaultloginpage}
1088
+ * @param params
1089
+ */
1090
+ toDefaultLoginPage(params?: authModels.ToDefaultLoginPage): Promise<CommonRes>
1091
+
1092
+
1093
+ /**
1094
+ * 退出登录
1095
+ *
1096
+ * {@link https://docs.cloudbase.net/api-reference/webv3/authentication#signout}
1097
+ *
1098
+ * @example
1099
+ * ```javascript
1100
+ * const app = cloudbase.init({
1101
+ * env: "xxxx-yyy"
1102
+ * });
1103
+ * app.auth.signOut().then(()=>{});
1104
+ * ```
1105
+ *
1106
+ * @return Promise
1107
+ */
1108
+ signOut(params?: authModels.SignoutRequest): Promise<void | authModels.SignoutResponse>
1109
+ /**
1110
+ * 使用自定义登录 ticket 登录
1111
+ *
1112
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#signinwithcustomticket}
1113
+ *
1114
+ * @param getTickFn
1115
+ */
1116
+ signInWithCustomTicket(getTickFn?: authModels.GetCustomSignTicketFn): Promise<ILoginState>
1117
+ /**
1118
+ * 用户登录,目前支持手机号,邮箱,用户名密码登录
1119
+ *
1120
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#signin}
1121
+ */
1122
+ signIn(params: authModels.SignInRequest): Promise<ILoginState>
1123
+ /**
1124
+ * 用户注册,目前支持手机号验证码注册,邮箱验证码注册
1125
+ *
1126
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#signup}
1127
+ */
1128
+ signUp(params: authModels.SignUpRequest): Promise<SignUpRes>
1129
+ /**
1130
+ * 监听认证状态变化
1131
+ *
1132
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#onauthstatechange}
1133
+ *
1134
+ * @param callback
1135
+ */
1136
+ onAuthStateChange(callback: OnAuthStateChangeCallback): { data: { subscription: { id: string; callback: Function; unsubscribe: () => void } } }
1137
+ /**
1138
+ * 使用用户名和密码登录
1139
+ *
1140
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#signinwithpassword}
1141
+ *
1142
+ * @param params
1143
+ */
1144
+ signInWithPassword(params: SignInWithPasswordReq): Promise<SignInRes>
1145
+ /**
1146
+ * 使用第三方平台 ID Token 登录
1147
+ *
1148
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#signinwithidtoken}
1149
+ *
1150
+ * @param params
1151
+ */
1152
+ signInWithIdToken(params: SignInWithIdTokenReq): Promise<SignInRes>
1153
+ /**
1154
+ * 使用一次性密码(OTP)登录
1155
+ *
1156
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#signinwithotp}
1157
+ *
1158
+ * @param params
1159
+ */
1160
+ signInWithOtp(params: SignInWithOtpReq): Promise<SignInWithOtpRes>
1161
+ /**
1162
+ * 校验第三方平台授权登录回调
1163
+ *
1164
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#verifyoauth}
1165
+ *
1166
+ * @param params
1167
+ */
1168
+ verifyOAuth(params?: VerifyOAuthReq): Promise<SignInRes>
1169
+ /**
1170
+ * 生成第三方平台授权 Uri
1171
+ *
1172
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#signinwithoauth}
1173
+ *
1174
+ * @param params
1175
+ */
1176
+ signInWithOAuth(params: SignInWithOAuthReq): Promise<SignInOAuthRes>
1177
+ /**
1178
+ * 获取当前访问令牌中的声明信息
1179
+ *
1180
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#getclaims}
1181
+ */
1182
+ getClaims(): Promise<GetClaimsRes>
1183
+ /**
1184
+ * 通过邮箱重置密码
1185
+ *
1186
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#resetpasswordforemail}
1187
+ *
1188
+ * @param emailOrPhone
1189
+ * @param options
1190
+ */
1191
+ resetPasswordForEmail(emailOrPhone: string, options?: { redirectTo?: string }): Promise<ResetPasswordForEmailRes>
1192
+ /**
1193
+ * 通过旧密码重置密码
1194
+ *
1195
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#resetpasswordforold}
1196
+ *
1197
+ * @param params
1198
+ */
1199
+ resetPasswordForOld(params: ResetPasswordForOldReq): Promise<SignInRes>
1200
+ /**
1201
+ * 验证一次性密码(OTP)
1202
+ *
1203
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#verifyotp}
1204
+ *
1205
+ * @param params
1206
+ */
1207
+ verifyOtp(params: VerifyOtpReq): Promise<SignInRes>
1208
+ /**
1209
+ * 获取当前会话
1210
+ *
1211
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#getsession}
1212
+ */
1213
+ getSession(): Promise<SignInRes>
1214
+ /**
1215
+ * 刷新会话
1216
+ *
1217
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#refreshsession}
1218
+ *
1219
+ * @param refresh_token
1220
+ */
1221
+ refreshSession(refresh_token?: string): Promise<SignInRes>
1222
+ /**
1223
+ * 获取当前用户详细信息
1224
+ *
1225
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#getuser}
1226
+ */
1227
+ getUser(): Promise<GetUserRes>
1228
+ /**
1229
+ * 刷新用户信息
1230
+ *
1231
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#refreshuser}
1232
+ */
1233
+ refreshUser(): Promise<CommonRes>
1234
+ /**
1235
+ * 更新用户信息
1236
+ *
1237
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#updateuser}
1238
+ *
1239
+ * @param params
1240
+ */
1241
+ updateUser(params: UpdateUserReq): Promise<GetUserRes | UpdateUserWithVerificationRes>
1242
+ /**
1243
+ * 获取已绑定的身份源
1244
+ *
1245
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#getuseridentities}
1246
+ */
1247
+ getUserIdentities(): Promise<GetUserIdentitiesRes>
1248
+ /**
1249
+ * 绑定身份源到当前用户
1250
+ *
1251
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#linkidentity}
1252
+ *
1253
+ * @param params
1254
+ */
1255
+ linkIdentity(params: LinkIdentityReq): Promise<LinkIdentityRes>
1256
+ /**
1257
+ * 解绑身份源
1258
+ *
1259
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#unlinkidentity}
1260
+ *
1261
+ * @param params
1262
+ */
1263
+ unlinkIdentity(params: UnlinkIdentityReq): Promise<CommonRes>
1264
+ /**
1265
+ * 重新认证
1266
+ *
1267
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#reauthenticate}
1268
+ */
1269
+ reauthenticate(): Promise<ReauthenticateRes>
1270
+ /**
1271
+ * 重新发送验证码
1272
+ *
1273
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#resend}
1274
+ *
1275
+ * @param params
1276
+ */
1277
+ resend(params: ResendReq): Promise<ResendRes>
1278
+ /**
1279
+ * 使用 access_token 和 refresh_token 设置会话
1280
+ *
1281
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#setsession}
1282
+ *
1283
+ * @param params
1284
+ */
1285
+ setSession(params: SetSessionReq): Promise<SignInRes>
1286
+ /**
1287
+ * 删除当前用户
1288
+ *
1289
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#deleteuser}
1290
+ *
1291
+ * @param params
1292
+ */
1293
+ deleteUser(params: DeleteMeReq): Promise<CommonRes>
1294
+ /**
1295
+ * 小程序 openId 静默登录
1296
+ *
1297
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#signinwithopenid}
1298
+ *
1299
+ * @param params
1300
+ */
1301
+ signInWithOpenId(params?: { useWxCloud?: boolean }): Promise<SignInRes>
1302
+ /**
1303
+ * 小程序手机号授权登录
1304
+ *
1305
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#signinwithphoneauth}
1306
+ *
1307
+ * @param params
1308
+ */
1309
+ signInWithPhoneAuth(params: { phoneCode: string }): Promise<SignInRes>
822
1310
  }
823
1311
  }
824
1312
  /**
@@ -826,16 +1314,16 @@ declare namespace cloudbase.auth {
826
1314
  */
827
1315
  declare namespace cloudbase.functions {
828
1316
  interface ICallFunctionOptions {
829
- name: string;
830
- data?: KV<any>;
831
- query?: KV<any>;
832
- search?: string;
833
- parse?: boolean;
1317
+ name: string
1318
+ data?: KV<any>
1319
+ query?: KV<any>
1320
+ search?: string
1321
+ parse?: boolean
834
1322
  }
835
1323
 
836
1324
  interface ICallFunctionResponse {
837
- requestId: string;
838
- result: any;
1325
+ requestId: string
1326
+ result: any
839
1327
  }
840
1328
  }
841
1329
  /**
@@ -843,75 +1331,101 @@ declare namespace cloudbase.functions {
843
1331
  */
844
1332
  declare namespace cloudbase.storage {
845
1333
  interface ICloudbaseUploadFileParams {
846
- cloudPath: string;
847
- filePath: string;
848
- method?: 'post' | 'put';
849
- headers?: KV<string>;
850
- onUploadProgress?: Function;
1334
+ cloudPath: string
1335
+ filePath?: string
1336
+ method?: 'post' | 'put'
1337
+ headers?: KV<string>
1338
+ onUploadProgress?: Function
1339
+ // 文件内容 Buffer 或 文件可读流, node端使用
1340
+ fileContent?: any
1341
+ customReqOpts?: ICustomReqOpts
851
1342
  }
852
1343
  interface ICloudbaseUploadFileResult {
853
- fileID: string;
854
- requestId: string;
1344
+ fileID: string
1345
+ requestId: string
855
1346
  }
856
1347
  interface ICloudbaseGetUploadMetadataParams {
857
- cloudPath: string;
1348
+ cloudPath: string
1349
+ customReqOpts?: ICustomReqOpts
858
1350
  }
859
1351
  interface ICloudbaseDeleteFileParams {
860
- fileList: string[];
1352
+ fileList: string[]
1353
+ customReqOpts?: ICustomReqOpts
861
1354
  }
862
1355
  interface ICloudbaseDeleteFileResult {
863
- code?: string;
864
- message?: string;
1356
+ code?: string
1357
+ message?: string
865
1358
  fileList?: {
866
- code?: string;
867
- fileID: string;
868
- }[];
869
- requestId?: string;
1359
+ code?: string
1360
+ fileID: string
1361
+ }[]
1362
+ requestId?: string
870
1363
  }
871
1364
 
872
1365
  interface ICloudbaseFileInfo {
873
- fileID: string;
874
- maxAge: number;
1366
+ fileID: string
1367
+ maxAge: number
875
1368
  }
876
1369
 
877
1370
  interface ICloudbaseGetTempFileURLParams {
878
- fileList: string[] | ICloudbaseFileInfo[];
1371
+ fileList: string[] | ICloudbaseFileInfo[]
1372
+ customReqOpts?: ICustomReqOpts
879
1373
  }
880
1374
 
881
1375
  interface ICloudbaseGetTempFileURLResult {
882
- code?: string;
883
- message?: string;
1376
+ code?: string
1377
+ message?: string
884
1378
  fileList?: {
885
- code?: string;
886
- message?: string;
887
- fileID: string;
888
- tempFileURL: string;
889
- download_url?: string;
890
- }[];
891
- requestId?: string;
1379
+ code?: string
1380
+ message?: string
1381
+ fileID: string
1382
+ tempFileURL: string
1383
+ download_url?: string
1384
+ }[]
1385
+ requestId?: string
892
1386
  }
893
1387
  interface ICloudbaseDownloadFileParams {
894
- fileID: string;
895
- tempFilePath?: string;
1388
+ fileID: string
1389
+ tempFilePath?: string
1390
+ customReqOpts?: ICustomReqOpts
896
1391
  }
897
1392
  interface ICloudbaseDownloadFileResult {
898
- code?: string;
899
- message?: string;
900
- fileContent?: any;
901
- requestId?: string;
1393
+ code?: string
1394
+ message?: string
1395
+ fileContent?: any
1396
+ requestId?: string
902
1397
  }
903
1398
  interface ICloudbaseFileMetaData {
904
- url: string;
905
- token: string;
906
- authorization: string;
907
- fileId: string;
908
- cosFileId: string;
1399
+ url: string
1400
+ token: string
1401
+ authorization: string
1402
+ fileId: string
1403
+ cosFileId: string
909
1404
  download_url: string
910
1405
  }
911
1406
 
912
1407
  interface ICloudbaseFileMetaDataRes {
913
- data: ICloudbaseFileMetaData;
914
- requestId: string;
1408
+ data: ICloudbaseFileMetaData
1409
+ requestId: string
1410
+ }
1411
+
1412
+ interface ICloudbaseCopyFileParams {
1413
+ fileList: Array<{
1414
+ srcPath: string
1415
+ dstPath: string
1416
+ overwrite?: boolean
1417
+ removeOriginal?: boolean
1418
+ }>
1419
+ customReqOpts?: ICustomReqOpts
1420
+ }
1421
+
1422
+ interface ICloudbaseCopyFileResult {
1423
+ fileList: Array<{
1424
+ fileId?: string
1425
+ code?: string
1426
+ message?: string
1427
+ }>
1428
+ requestId?: string
915
1429
  }
916
1430
  }
917
1431
 
@@ -949,8 +1463,8 @@ declare namespace cloudbase.database {
949
1463
  */
950
1464
  close: () => void
951
1465
  }
952
- type DataType = 'init' | 'update' | 'add' | 'remove' | 'replace' | 'limit';
953
- type QueueType = 'init' | 'enqueue' | 'dequeue' | 'update';
1466
+ type DataType = 'init' | 'update' | 'add' | 'remove' | 'replace' | 'limit'
1467
+ type QueueType = 'init' | 'enqueue' | 'dequeue' | 'update'
954
1468
  interface ISnapshot {
955
1469
  id: number
956
1470
  docChanges: ISingleDBEvent[]
@@ -968,7 +1482,7 @@ declare namespace cloudbase.database {
968
1482
  removedFields?: any
969
1483
  }
970
1484
 
971
- type SnapshotType = 'init';
1485
+ type SnapshotType = 'init'
972
1486
 
973
1487
  interface IWatchable {
974
1488
  /**
@@ -994,7 +1508,7 @@ declare namespace cloudbase.database {
994
1508
  *
995
1509
  * @return 实时推送进程实例
996
1510
  */
997
- watch(options: IWatchOptions): DBRealtimeListener;
1511
+ watch(options: IWatchOptions): DBRealtimeListener
998
1512
  }
999
1513
  /**
1000
1514
  * collection types
@@ -1007,7 +1521,7 @@ declare namespace cloudbase.database {
1007
1521
  *
1008
1522
  * @param data 文档数据
1009
1523
  */
1010
- add(data: Object): Promise<Pick<SetRes, 'code' | 'message'>>;
1524
+ add(data: Object): Promise<Pick<SetRes, 'code' | 'message'>>
1011
1525
  /**
1012
1526
  * 获取一条文档的引用
1013
1527
  *
@@ -1015,7 +1529,7 @@ declare namespace cloudbase.database {
1015
1529
  *
1016
1530
  * @param id 文档ID
1017
1531
  */
1018
- doc(id: string): IDocument;
1532
+ doc(id: string): IDocument
1019
1533
  }
1020
1534
  /**
1021
1535
  * command types
@@ -1029,7 +1543,7 @@ declare namespace cloudbase.database {
1029
1543
  geometry: IPolygon | IMultiPolygon
1030
1544
  }
1031
1545
  interface IGeoIntersectsOptions {
1032
- geometry: IPoint | ILineString | IMultiPoint | IMultiLineString | IPolygon | IMultiPolygon;
1546
+ geometry: IPoint | ILineString | IMultiPoint | IMultiLineString | IPolygon | IMultiPolygon
1033
1547
  }
1034
1548
  interface ICommand {
1035
1549
  /**
@@ -1046,7 +1560,7 @@ declare namespace cloudbase.database {
1046
1560
  * @param val 接受一个字面量 (literal),可以是 `number`, `boolean`, `string`, `object`, `array`
1047
1561
  *
1048
1562
  */
1049
- eq(val: number | string | boolean | Object | any[]): any;
1563
+ eq(val: number | string | boolean | Object | any[]): any
1050
1564
  /**
1051
1565
  * 表示字段不等于某个值
1052
1566
  *
@@ -1061,7 +1575,7 @@ declare namespace cloudbase.database {
1061
1575
  * @param val 接受一个字面量 (literal),可以是 `number`, `boolean`, `string`, `object`, `array`
1062
1576
  *
1063
1577
  */
1064
- neq(val: number | string | boolean | Object | any[]): any;
1578
+ neq(val: number | string | boolean | Object | any[]): any
1065
1579
  /**
1066
1580
  * 字段大于指定值
1067
1581
  *
@@ -1076,7 +1590,7 @@ declare namespace cloudbase.database {
1076
1590
  * @param val 数字
1077
1591
  *
1078
1592
  */
1079
- gt(val: number): any;
1593
+ gt(val: number): any
1080
1594
  /**
1081
1595
  * 字段大于或等于指定值
1082
1596
  *
@@ -1091,7 +1605,7 @@ declare namespace cloudbase.database {
1091
1605
  * @param val 数字
1092
1606
  *
1093
1607
  */
1094
- gte(val: number): any;
1608
+ gte(val: number): any
1095
1609
  /**
1096
1610
  * 字段小于指定值
1097
1611
  *
@@ -1106,7 +1620,7 @@ declare namespace cloudbase.database {
1106
1620
  * @param val 数字
1107
1621
  *
1108
1622
  */
1109
- lt(val: number): any;
1623
+ lt(val: number): any
1110
1624
  /**
1111
1625
  * 字段小于或等于指定值
1112
1626
  *
@@ -1121,7 +1635,7 @@ declare namespace cloudbase.database {
1121
1635
  * @param val 数字
1122
1636
  *
1123
1637
  */
1124
- lte(val: number): any;
1638
+ lte(val: number): any
1125
1639
  /**
1126
1640
  * 字段值在给定的数组中
1127
1641
  *
@@ -1136,7 +1650,7 @@ declare namespace cloudbase.database {
1136
1650
  * @param list 数组
1137
1651
  *
1138
1652
  */
1139
- in(list: any[]): any;
1653
+ in(list: any[]): any
1140
1654
  /**
1141
1655
  * 字段值不在给定的数组中
1142
1656
  *
@@ -1151,7 +1665,7 @@ declare namespace cloudbase.database {
1151
1665
  * @param list 数组
1152
1666
  *
1153
1667
  */
1154
- nin(list: any[]): any;
1668
+ nin(list: any[]): any
1155
1669
  /**
1156
1670
  * 表示需同时满足指定的两个或以上的条件
1157
1671
  *
@@ -1166,7 +1680,7 @@ declare namespace cloudbase.database {
1166
1680
  * @param args 多个条件
1167
1681
  *
1168
1682
  */
1169
- and(...args: any[]): any;
1683
+ and(...args: any[]): any
1170
1684
  /**
1171
1685
  * 表示需满足所有指定条件中的至少一个
1172
1686
  *
@@ -1181,7 +1695,7 @@ declare namespace cloudbase.database {
1181
1695
  * @param args 多个条件
1182
1696
  *
1183
1697
  */
1184
- or(...args: any[]): any;
1698
+ or(...args: any[]): any
1185
1699
  /**
1186
1700
  * 用于设定字段等于指定值
1187
1701
  *
@@ -1202,7 +1716,7 @@ declare namespace cloudbase.database {
1202
1716
  * @param val 被设定的属性对象
1203
1717
  *
1204
1718
  */
1205
- set(val: any): any;
1719
+ set(val: any): any
1206
1720
  /**
1207
1721
  * 用于指示字段自增某个值
1208
1722
  *
@@ -1221,7 +1735,7 @@ declare namespace cloudbase.database {
1221
1735
  * @param val 自增的值
1222
1736
  *
1223
1737
  */
1224
- inc(val: number): any;
1738
+ inc(val: number): any
1225
1739
  /**
1226
1740
  * 用于指示字段自乘某个值
1227
1741
  *
@@ -1240,7 +1754,7 @@ declare namespace cloudbase.database {
1240
1754
  * @param val 自乘的值
1241
1755
  *
1242
1756
  */
1243
- mul(val: number): any;
1757
+ mul(val: number): any
1244
1758
  /**
1245
1759
  * 用于表示删除某个字段
1246
1760
  *
@@ -1255,7 +1769,7 @@ declare namespace cloudbase.database {
1255
1769
  * });
1256
1770
  *
1257
1771
  */
1258
- remove(): any;
1772
+ remove(): any
1259
1773
  /**
1260
1774
  * 向数组尾部追加元素
1261
1775
  *
@@ -1271,7 +1785,7 @@ declare namespace cloudbase.database {
1271
1785
  *
1272
1786
  * @param val 支持传入单个元素或数组
1273
1787
  */
1274
- push(val: any): any;
1788
+ push(val: any): any
1275
1789
  /**
1276
1790
  * 删除数组尾部元素
1277
1791
  *
@@ -1286,7 +1800,7 @@ declare namespace cloudbase.database {
1286
1800
  * });
1287
1801
  *
1288
1802
  */
1289
- pop(): any;
1803
+ pop(): any
1290
1804
  /**
1291
1805
  * 向数组头部添加元素
1292
1806
  *
@@ -1302,7 +1816,7 @@ declare namespace cloudbase.database {
1302
1816
  *
1303
1817
  * @param val 支持传入单个元素或数组
1304
1818
  */
1305
- unshift(val: any): any;
1819
+ unshift(val: any): any
1306
1820
  /**
1307
1821
  * 删除数组头部元素
1308
1822
  *
@@ -1317,7 +1831,7 @@ declare namespace cloudbase.database {
1317
1831
  * });
1318
1832
  *
1319
1833
  */
1320
- shift(): any;
1834
+ shift(): any
1321
1835
  /**
1322
1836
  * 按从近到远的顺序,找出字段值在给定点的附近的文档
1323
1837
  *
@@ -1338,7 +1852,7 @@ declare namespace cloudbase.database {
1338
1852
  * @param options.maxDistance 【可选】最大距离,米为单位
1339
1853
  * @param options.minDistance 【可选】最小距离,米为单位
1340
1854
  */
1341
- geoNear(options: IGeoNearOptions): any;
1855
+ geoNear(options: IGeoNearOptions): any
1342
1856
  /**
1343
1857
  * 找出字段值在指定 Polygon / MultiPolygon 内的文档,无排序
1344
1858
  *
@@ -1357,7 +1871,7 @@ declare namespace cloudbase.database {
1357
1871
  * @param options
1358
1872
  * @param options.geometry 地理位置
1359
1873
  */
1360
- geoWithin(options: IGeoWithinOptions): any;
1874
+ geoWithin(options: IGeoWithinOptions): any
1361
1875
  /**
1362
1876
  * 找出字段值和给定的地理位置图形相交的文档
1363
1877
  *
@@ -1374,7 +1888,7 @@ declare namespace cloudbase.database {
1374
1888
  * @param options
1375
1889
  * @param options.geometry 地理位置
1376
1890
  */
1377
- geoIntersects(options: IGeoIntersectsOptions): any;
1891
+ geoIntersects(options: IGeoIntersectsOptions): any
1378
1892
  }
1379
1893
  /**
1380
1894
  * document types
@@ -1395,7 +1909,7 @@ declare namespace cloudbase.database {
1395
1909
  *
1396
1910
  * @return Promise
1397
1911
  */
1398
- set(data: Object): Promise<SetRes>;
1912
+ set(data: Object): Promise<SetRes>
1399
1913
  /**
1400
1914
  * 获取查询结果
1401
1915
  *
@@ -1409,7 +1923,7 @@ declare namespace cloudbase.database {
1409
1923
  *
1410
1924
  * @return Promise-查询结果
1411
1925
  */
1412
- get(): Promise<GetRes>;
1926
+ get(): Promise<GetRes>
1413
1927
  /**
1414
1928
  * 更新文档,如果要更新的文档不存在什么也不会做
1415
1929
  *
@@ -1425,7 +1939,7 @@ declare namespace cloudbase.database {
1425
1939
  *
1426
1940
  * @return Promise
1427
1941
  */
1428
- update(data: Object): Promise<SetRes>;
1942
+ update(data: Object): Promise<SetRes>
1429
1943
  /**
1430
1944
  * 删除一条文档
1431
1945
  *
@@ -1439,31 +1953,31 @@ declare namespace cloudbase.database {
1439
1953
  *
1440
1954
  * @return Promise
1441
1955
  */
1442
- remove(): Promise<any>;
1956
+ remove(): Promise<any>
1443
1957
  }
1444
1958
  /**
1445
1959
  * query types
1446
1960
  */
1447
1961
  interface SetRes {
1448
- code?: string;
1449
- message?: string;
1450
- updated?: number;
1451
- upsertedId?: number;
1452
- requestId: string;
1962
+ code?: string
1963
+ message?: string
1964
+ updated?: number
1965
+ upsertedId?: number
1966
+ requestId: string
1453
1967
  }
1454
1968
  interface GetRes {
1455
- data: any[];
1456
- requestId: string;
1457
- code?: string;
1458
- message?: string;
1969
+ data: any[]
1970
+ requestId: string
1971
+ code?: string
1972
+ message?: string
1459
1973
  }
1460
1974
 
1461
1975
  interface UpdateRes {
1462
1976
  requestId: string
1463
1977
  updated?: number
1464
1978
  upsertId?: string
1465
- code?: string;
1466
- message?: string;
1979
+ code?: string
1980
+ message?: string
1467
1981
  }
1468
1982
 
1469
1983
  interface QueryOrder {
@@ -1495,7 +2009,7 @@ declare namespace cloudbase.database {
1495
2009
  *
1496
2010
  * @return Promise-查询结果
1497
2011
  */
1498
- get(): Promise<GetRes>;
2012
+ get(): Promise<GetRes>
1499
2013
  /**
1500
2014
  * 更新数据库文档
1501
2015
  *
@@ -1529,7 +2043,7 @@ declare namespace cloudbase.database {
1529
2043
  *
1530
2044
  * @return Promise-查询结果
1531
2045
  */
1532
- count(): Promise<any>;
2046
+ count(): Promise<any>
1533
2047
  /**
1534
2048
  * 设置过滤条件
1535
2049
  *
@@ -1544,7 +2058,7 @@ declare namespace cloudbase.database {
1544
2058
  * @param query 可接收对象作为参数,表示筛选出拥有和传入对象相同的 key-value 的文档
1545
2059
  *
1546
2060
  */
1547
- where(query: Object): ExcludeOf<IQuery, 'where'>;
2061
+ where(query: Object): ExcludeOf<IQuery, 'where'>
1548
2062
  /**
1549
2063
  * 指定查询结果集数量上限
1550
2064
  *
@@ -1559,7 +2073,7 @@ declare namespace cloudbase.database {
1559
2073
  *
1560
2074
  * @param limit 查询结果数量上限
1561
2075
  */
1562
- limit(limit: number): ExcludeOf<IQuery, 'where'>;
2076
+ limit(limit: number): ExcludeOf<IQuery, 'where'>
1563
2077
  /**
1564
2078
  * 指定查询返回结果时从指定序列后的结果开始返回,常用于分页
1565
2079
  *
@@ -1574,7 +2088,7 @@ declare namespace cloudbase.database {
1574
2088
  *
1575
2089
  * @param offset 跳过的条目数量
1576
2090
  */
1577
- skip(offset: number): ExcludeOf<IQuery, 'where'>;
2091
+ skip(offset: number): ExcludeOf<IQuery, 'where'>
1578
2092
  /**
1579
2093
  * 指定查询排序条件
1580
2094
  *
@@ -1590,7 +2104,7 @@ declare namespace cloudbase.database {
1590
2104
  * @param field 排序的字段
1591
2105
  * @param orderType 排序的顺序,升序(asc) 或 降序(desc)
1592
2106
  */
1593
- orderBy(field: string, orderType: 'desc' | 'asc'): ExcludeOf<IQuery, 'where'>;
2107
+ orderBy(field: string, orderType: 'desc' | 'asc'): ExcludeOf<IQuery, 'where'>
1594
2108
  /**
1595
2109
  * 指定返回结果中文档需返回的字段
1596
2110
  *
@@ -1605,7 +2119,7 @@ declare namespace cloudbase.database {
1605
2119
  *
1606
2120
  * @param projection 要过滤的字段集合,不返回传 false,返回传 true
1607
2121
  */
1608
- field(projection: Object): ExcludeOf<IQuery, 'where'>;
2122
+ field(projection: Object): ExcludeOf<IQuery, 'where'>
1609
2123
  /**
1610
2124
  * 删除查询到的结果
1611
2125
  *
@@ -1620,17 +2134,17 @@ declare namespace cloudbase.database {
1620
2134
  *
1621
2135
  * @return Promise
1622
2136
  */
1623
- remove(): Promise<any>;
2137
+ remove(): Promise<any>
1624
2138
  }
1625
2139
  /**
1626
2140
  * geo types
1627
2141
  */
1628
- interface IPoint { }
1629
- interface ILineString { }
1630
- interface IPolygon { }
1631
- interface IMultiPoint { }
1632
- interface IMultiLineString { }
1633
- interface IMultiPolygon { }
2142
+ interface IPoint {}
2143
+ interface ILineString {}
2144
+ interface IPolygon {}
2145
+ interface IMultiPoint {}
2146
+ interface IMultiLineString {}
2147
+ interface IMultiPolygon {}
1634
2148
  interface IGeo {
1635
2149
  /**
1636
2150
  * 用于表示地理位置点
@@ -1646,8 +2160,8 @@ declare namespace cloudbase.database {
1646
2160
  * @return Point
1647
2161
  */
1648
2162
  Point: {
1649
- new(longitude: number, latitude: number): IPoint;
1650
- };
2163
+ new (longitude: number, latitude: number): IPoint
2164
+ }
1651
2165
  /**
1652
2166
  * 用于表示地理路径,是由两个或者更多的 Point 组成的线段
1653
2167
  *
@@ -1661,7 +2175,7 @@ declare namespace cloudbase.database {
1661
2175
  * @return LineString
1662
2176
  */
1663
2177
  LineString: {
1664
- new(points: IPoint[]): ILineString;
2178
+ new (points: IPoint[]): ILineString
1665
2179
  }
1666
2180
  /**
1667
2181
  * 用于表示地理上的一个多边形
@@ -1676,7 +2190,7 @@ declare namespace cloudbase.database {
1676
2190
  * @return Polygon
1677
2191
  */
1678
2192
  Polygon: {
1679
- new(lines: ILineString[]): IPolygon;
2193
+ new (lines: ILineString[]): IPolygon
1680
2194
  }
1681
2195
  /**
1682
2196
  * 用于表示多个点 Point 的集合
@@ -1691,7 +2205,7 @@ declare namespace cloudbase.database {
1691
2205
  * @return MultiPoint
1692
2206
  */
1693
2207
  MultiPoint: {
1694
- new(points: IPoint[]): IMultiPoint;
2208
+ new (points: IPoint[]): IMultiPoint
1695
2209
  }
1696
2210
  /**
1697
2211
  * 用于表示多个地理路径 LineString 的集合
@@ -1706,7 +2220,7 @@ declare namespace cloudbase.database {
1706
2220
  * @return MultiLineString
1707
2221
  */
1708
2222
  MultiLineString: {
1709
- new(lines: ILineString[]): IMultiLineString;
2223
+ new (lines: ILineString[]): IMultiLineString
1710
2224
  }
1711
2225
  /**
1712
2226
  * 用于表示多个地理多边形 Polygon 的集合
@@ -1721,18 +2235,18 @@ declare namespace cloudbase.database {
1721
2235
  * @return MultiPolygon
1722
2236
  */
1723
2237
  MultiPolygon: {
1724
- new(polygons: IPolygon[]): IMultiPolygon;
2238
+ new (polygons: IPolygon[]): IMultiPolygon
1725
2239
  }
1726
2240
  }
1727
2241
  /**
1728
2242
  * regexp types
1729
2243
  */
1730
2244
  interface IRegExpOptions {
1731
- regexp: string;
1732
- options?: string;
2245
+ regexp: string
2246
+ options?: string
1733
2247
  }
1734
2248
  interface IRegExp {
1735
- (options: IRegExpOptions): any;
2249
+ (options: IRegExpOptions): any
1736
2250
  }
1737
2251
  /**
1738
2252
  * instance types
@@ -1743,13 +2257,13 @@ declare namespace cloudbase.database {
1743
2257
  *
1744
2258
  * {@link https://docs.cloudbase.net/api-reference/webv3/database#%E6%9F%A5%E8%AF%A2%E6%8C%87%E4%BB%A4}
1745
2259
  */
1746
- command: ICommand;
2260
+ command: ICommand
1747
2261
  /**
1748
2262
  * 数据库Geo地理位置
1749
2263
  *
1750
2264
  * {@link https://docs.cloudbase.net/api-reference/webv3/database.html#geo-shu-ju-lei-xing}
1751
2265
  */
1752
- Geo: IGeo;
2266
+ Geo: IGeo
1753
2267
  /**
1754
2268
  * 根据正则表达式进行筛选
1755
2269
  *
@@ -1767,7 +2281,7 @@ declare namespace cloudbase.database {
1767
2281
  * @param options.regexp 正则表达式Pattern
1768
2282
  * @param options.options 正则表达式Flags
1769
2283
  */
1770
- RegExp: IRegExp;
2284
+ RegExp: IRegExp
1771
2285
  /**
1772
2286
  * 创建集合的引用
1773
2287
  *
@@ -1780,10 +2294,9 @@ declare namespace cloudbase.database {
1780
2294
  *
1781
2295
  * @return 集合的引用
1782
2296
  */
1783
- collection(name: string): ICollection;
2297
+ collection(name: string): ICollection
1784
2298
  }
1785
2299
  }
1786
2300
 
1787
-
1788
- export default cloudbase;
1789
- export as namespace cloudbase;
2301
+ export default cloudbase
2302
+ export as namespace cloudbase