@cloudbase/js-sdk 3.2.2 → 3.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +3 -0
- package/database/dist/index.esm.js +452 -3
- package/database/dist/index.js +453 -4
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/index.d.ts +36 -105
- package/miniprogram_dist/app.js +1 -1
- package/miniprogram_dist/database.js +1 -1
- package/miniprogram_dist/index.js +1 -1
- package/package.json +15 -15
package/dist/index.cjs.js
CHANGED
|
@@ -14,7 +14,7 @@ var cloudrun_1 = require("@cloudbase/cloudrun");
|
|
|
14
14
|
var mysql_1 = require("@cloudbase/mysql");
|
|
15
15
|
var apis_1 = require("@cloudbase/apis");
|
|
16
16
|
var database_1 = require("./../database");
|
|
17
|
-
var version = "3.
|
|
17
|
+
var version = "3.3.1";
|
|
18
18
|
app_1.default.registerVersion(version);
|
|
19
19
|
try {
|
|
20
20
|
(0, auth_1.registerAuth)(app_1.default);
|
package/dist/index.esm.js
CHANGED
|
@@ -10,7 +10,7 @@ import { registerCloudrun } from '@cloudbase/cloudrun';
|
|
|
10
10
|
import { registerMySQL } from '@cloudbase/mysql';
|
|
11
11
|
import { registerApis } from '@cloudbase/apis';
|
|
12
12
|
import { registerDatabase } from './../database';
|
|
13
|
-
var version = "3.
|
|
13
|
+
var version = "3.3.1";
|
|
14
14
|
cloudbase.registerVersion(version);
|
|
15
15
|
try {
|
|
16
16
|
registerAuth(cloudbase);
|
package/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { OrmClient, OrmRawQueryClient } from '@cloudbase/model'
|
|
2
|
-
import { IMySqlClient } from '@cloudbase/mysql'
|
|
3
|
-
import { authModels } from '@cloudbase/oauth'
|
|
1
|
+
import { OrmClient, OrmRawQueryClient } from '@cloudbase/model'
|
|
2
|
+
import { IMySqlClient } from '@cloudbase/mysql'
|
|
3
|
+
import { authModels } from '@cloudbase/oauth'
|
|
4
4
|
import type {
|
|
5
5
|
SignInRes,
|
|
6
6
|
GetUserRes,
|
|
@@ -28,9 +28,9 @@ import type {
|
|
|
28
28
|
ResendReq,
|
|
29
29
|
SetSessionReq,
|
|
30
30
|
DeleteMeReq,
|
|
31
|
-
SignUpRes
|
|
32
|
-
} from '@cloudbase/auth'
|
|
33
|
-
import { AI } from '@cloudbase/ai'
|
|
31
|
+
SignUpRes,
|
|
32
|
+
} from '@cloudbase/auth'
|
|
33
|
+
import { AI } from '@cloudbase/ai'
|
|
34
34
|
import { CloudbaseAdapter, ResponseObject } from '@cloudbase/adapter-interface'
|
|
35
35
|
import { ICloudbaseUpgradedConfig, ICloudbase, Persistence } from '@cloudbase/types'
|
|
36
36
|
import { LANGS } from '@cloudbase/types'
|
|
@@ -42,7 +42,6 @@ type KV<T> = {
|
|
|
42
42
|
|
|
43
43
|
type ExcludeOf<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>
|
|
44
44
|
|
|
45
|
-
|
|
46
45
|
declare type MethodType = 'request' | 'post' | 'get' | 'head' | 'patch' | 'delete' | 'put'
|
|
47
46
|
|
|
48
47
|
interface ICallApiOptions {
|
|
@@ -608,7 +607,7 @@ declare namespace cloudbase.app {
|
|
|
608
607
|
*
|
|
609
608
|
* @return 数据库实例
|
|
610
609
|
*/
|
|
611
|
-
database(dbConfig?:
|
|
610
|
+
database(dbConfig?: { instance?: string; database?: string }): cloudbase.database.App
|
|
612
611
|
/**
|
|
613
612
|
* 调用扩展能力插件功能
|
|
614
613
|
*
|
|
@@ -655,24 +654,24 @@ declare namespace cloudbase.app {
|
|
|
655
654
|
|
|
656
655
|
/**
|
|
657
656
|
* MySQL 数据库
|
|
658
|
-
*
|
|
657
|
+
*
|
|
659
658
|
* @example
|
|
660
659
|
* ```javascript
|
|
661
660
|
* const app = cloudbase.init({
|
|
662
661
|
* env: "xxxx-yyy"
|
|
663
662
|
* });
|
|
664
|
-
*
|
|
663
|
+
*
|
|
665
664
|
* app.mysql().from('todos').select().then((res) => {
|
|
666
665
|
* console.log(res.data);
|
|
667
666
|
* });
|
|
668
667
|
* ```
|
|
669
668
|
*/
|
|
670
|
-
mysql: IMySqlClient
|
|
671
|
-
rdb: IMySqlClient
|
|
669
|
+
mysql: IMySqlClient
|
|
670
|
+
rdb: IMySqlClient
|
|
672
671
|
|
|
673
|
-
ai(): AI
|
|
672
|
+
ai(): AI
|
|
674
673
|
|
|
675
|
-
apis: ICloudbaseApis
|
|
674
|
+
apis: ICloudbaseApis
|
|
676
675
|
}
|
|
677
676
|
}
|
|
678
677
|
/**
|
|
@@ -861,7 +860,10 @@ declare namespace cloudbase.auth {
|
|
|
861
860
|
* @param params
|
|
862
861
|
* @param options
|
|
863
862
|
*/
|
|
864
|
-
getVerification(
|
|
863
|
+
getVerification(
|
|
864
|
+
params: authModels.GetVerificationRequest,
|
|
865
|
+
options?: { withCaptcha: boolean },
|
|
866
|
+
): Promise<authModels.GetVerificationResponse>
|
|
865
867
|
/**
|
|
866
868
|
* 匿名登录
|
|
867
869
|
*
|
|
@@ -1068,7 +1070,10 @@ declare namespace cloudbase.auth {
|
|
|
1068
1070
|
loginScope(): Promise<string>
|
|
1069
1071
|
loginGroups(): Promise<string[]>
|
|
1070
1072
|
onLoginStateChanged(callback: Function)
|
|
1071
|
-
createLoginState(
|
|
1073
|
+
createLoginState(
|
|
1074
|
+
params?: { version?: string; query?: any },
|
|
1075
|
+
options?: { asyncRefreshUser?: boolean; userInfo?: any },
|
|
1076
|
+
): Promise<ILoginState>
|
|
1072
1077
|
/**
|
|
1073
1078
|
* 强制刷新token
|
|
1074
1079
|
*
|
|
@@ -1150,18 +1155,19 @@ declare namespace cloudbase.auth {
|
|
|
1150
1155
|
* @return Promise-用户是否被绑定
|
|
1151
1156
|
*/
|
|
1152
1157
|
isUsernameRegistered(username: string): Promise<boolean>
|
|
1153
|
-
getMiniProgramQrCode(
|
|
1158
|
+
getMiniProgramQrCode(
|
|
1159
|
+
params: authModels.GetMiniProgramQrCodeRequest,
|
|
1160
|
+
): Promise<authModels.GetMiniProgramQrCodeResponse>
|
|
1154
1161
|
getMiniProgramQrCodeStatus(
|
|
1155
1162
|
params: authModels.GetMiniProgramQrCodeStatusRequest,
|
|
1156
1163
|
): Promise<authModels.GetMiniProgramQrCodeStatusResponse>
|
|
1157
1164
|
/**
|
|
1158
1165
|
* 跳转到默认登录页
|
|
1159
1166
|
* 文档 {@link https://docs.cloudbase.net/api-reference/webv2/authentication#authtodefaultloginpage}
|
|
1160
|
-
* @param params
|
|
1167
|
+
* @param params
|
|
1161
1168
|
*/
|
|
1162
1169
|
toDefaultLoginPage(params?: authModels.ToDefaultLoginPage): Promise<CommonRes>
|
|
1163
1170
|
|
|
1164
|
-
|
|
1165
1171
|
/**
|
|
1166
1172
|
* 退出登录
|
|
1167
1173
|
*
|
|
@@ -1205,7 +1211,9 @@ declare namespace cloudbase.auth {
|
|
|
1205
1211
|
*
|
|
1206
1212
|
* @param callback
|
|
1207
1213
|
*/
|
|
1208
|
-
onAuthStateChange(callback: OnAuthStateChangeCallback): {
|
|
1214
|
+
onAuthStateChange(callback: OnAuthStateChangeCallback): {
|
|
1215
|
+
data: { subscription: { id: string; callback: Function; unsubscribe: () => void } }
|
|
1216
|
+
}
|
|
1209
1217
|
/**
|
|
1210
1218
|
* 使用用户名和密码登录
|
|
1211
1219
|
*
|
|
@@ -3357,91 +3365,14 @@ declare namespace cloudbase.database {
|
|
|
3357
3365
|
* @return 集合的引用
|
|
3358
3366
|
*/
|
|
3359
3367
|
collection(name: string): ICollection
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
*
|
|
3369
|
-
* {@link https://docs.cloudbase.net/api-reference/webv3-next/database#createcollection}
|
|
3370
|
-
*
|
|
3371
|
-
* @example
|
|
3372
|
-
* ```javascript
|
|
3373
|
-
* // 管理端 SDK 或具有管理员权限时可用
|
|
3374
|
-
* const result = await db.createCollection('new-collection')
|
|
3375
|
-
* ```
|
|
3376
|
-
*
|
|
3377
|
-
* @param collName 集合名称
|
|
3378
|
-
*
|
|
3379
|
-
* @return Promise<CreateCollectionRes>
|
|
3380
|
-
*/
|
|
3381
|
-
createCollection(collName: string): Promise<CreateCollectionRes>
|
|
3382
|
-
/**
|
|
3383
|
-
* 构造服务端时间对象
|
|
3384
|
-
*
|
|
3385
|
-
* {@link https://docs.cloudbase.net/api-reference/webv3-next/database#serverdate}
|
|
3386
|
-
*
|
|
3387
|
-
* @example
|
|
3388
|
-
* db.collection('todos').add({
|
|
3389
|
-
* createdAt: db.serverDate()
|
|
3390
|
-
* })
|
|
3391
|
-
*
|
|
3392
|
-
* @param options 可选配置,支持 offset(毫秒偏移量)
|
|
3393
|
-
*
|
|
3394
|
-
* @return 服务端时间对象
|
|
3395
|
-
*/
|
|
3396
|
-
serverDate(options?: { offset?: number }): any
|
|
3397
|
-
/**
|
|
3398
|
-
* 开启一个新事务
|
|
3399
|
-
*
|
|
3400
|
-
* {@link https://docs.cloudbase.net/api-reference/webv3-next/database#starttransaction}
|
|
3401
|
-
*
|
|
3402
|
-
* @example
|
|
3403
|
-
* const transaction = await db.startTransaction()
|
|
3404
|
-
* // ... 事务操作
|
|
3405
|
-
* await transaction.commit()
|
|
3406
|
-
*
|
|
3407
|
-
* @return Promise<ITransaction> 事务对象
|
|
3408
|
-
*/
|
|
3409
|
-
startTransaction(): Promise<ITransaction>
|
|
3410
|
-
/**
|
|
3411
|
-
* 执行事务操作,自动处理提交和回滚
|
|
3412
|
-
*
|
|
3413
|
-
* {@link https://docs.cloudbase.net/api-reference/webv3-next/database#runtransaction}
|
|
3414
|
-
*
|
|
3415
|
-
* @example
|
|
3416
|
-
* const result = await db.runTransaction(async (transaction) => {
|
|
3417
|
-
* const doc = await transaction.collection('accounts').doc('id').get()
|
|
3418
|
-
* await transaction.collection('accounts').doc('id').update({ balance: doc.data.balance - 100 })
|
|
3419
|
-
* return { success: true }
|
|
3420
|
-
* })
|
|
3421
|
-
*
|
|
3422
|
-
* @param callback 事务回调函数
|
|
3423
|
-
* @param times 事务冲突时的重试次数,默认为 3
|
|
3424
|
-
*
|
|
3425
|
-
* @return Promise<any> 事务回调函数的返回值
|
|
3426
|
-
*/
|
|
3427
|
-
runTransaction(callback: (transaction: ITransaction) => Promise<any>, times?: number): Promise<any>
|
|
3428
|
-
/**
|
|
3429
|
-
* 执行 MongoDB 原生命令
|
|
3430
|
-
*
|
|
3431
|
-
* {@link https://docs.cloudbase.net/api-reference/webv3-next/database#runcommands}
|
|
3432
|
-
*
|
|
3433
|
-
* @example
|
|
3434
|
-
* const result = await db.runCommands({
|
|
3435
|
-
* commands: [
|
|
3436
|
-
* { find: 'users', filter: { age: { $gte: 18 } }, limit: 10 }
|
|
3437
|
-
* ]
|
|
3438
|
-
* })
|
|
3439
|
-
*
|
|
3440
|
-
* @param params 命令参数,包含 commands 数组和可选的 transactionId
|
|
3441
|
-
*
|
|
3442
|
-
* @return Promise<IRunCommandsResult>
|
|
3443
|
-
*/
|
|
3444
|
-
runCommands(params: IRunCommandsReq): Promise<IRunCommandsResult>
|
|
3368
|
+
|
|
3369
|
+
runCommands(params: IRunCommandsReq): Promise<{
|
|
3370
|
+
statusCode: number
|
|
3371
|
+
requestId: string
|
|
3372
|
+
list?: Object[][]
|
|
3373
|
+
code?: string
|
|
3374
|
+
message?: string
|
|
3375
|
+
}>
|
|
3445
3376
|
}
|
|
3446
3377
|
}
|
|
3447
3378
|
|