@cloudbase/js-sdk 3.9.3 → 3.9.5-alpha.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/core.d.ts CHANGED
@@ -38,6 +38,7 @@ declare namespace cloudbase {
38
38
  type OrmClient = import('@cloudbase/js-sdk/model').OrmClient
39
39
  type OrmRawQueryClient = import('@cloudbase/js-sdk/model').OrmRawQueryClient
40
40
  type IMySqlClient = import('@cloudbase/js-sdk/mysql').IMySqlClient
41
+ type RealtimeClient = import('@cloudbase/realtime-js').RealtimeClient
41
42
  type AI = import('@cloudbase/js-sdk/ai').AI
42
43
  type CloudbaseAdapter = import('@cloudbase/adapter-interface').CloudbaseAdapter
43
44
  type ResponseObject = import('@cloudbase/adapter-interface').ResponseObject
@@ -596,7 +597,7 @@ declare namespace cloudbase.app {
596
597
  * '文件A的fileID',
597
598
  * {
598
599
  * fileID: '文件B的fileID',
599
- * maxAge: 600 // 文件B的链接有效期,单位`ms`
600
+ * maxAge: 600 // 兼容字段,传统模式不会用它生成下载链接
600
601
  * }
601
602
  * ]
602
603
  * });
@@ -605,7 +606,7 @@ declare namespace cloudbase.app {
605
606
  * @param params
606
607
  * @param params.fileList 要下载的文件数组,数组元素可以是`string`或`Object`,如果是`string`代表文件ID,如果是`Object`可配置以下信息
607
608
  * @param params.fileList[].fileID 要下载的文件ID
608
- * @param params.fileList[].maxAge 下载链接的有效期,单位`ms`
609
+ * @param params.fileList[].maxAge 过期时间。传统模式不会用它生成下载链接,TTL 传入无效。需要可控过期请改用 `app.storage.from(bucketId).createSignedUrl(path, expiresIn)`(PG 模式下可用)。
609
610
  *
610
611
  * @return Promise-文件下载链接
611
612
  *
@@ -751,6 +752,26 @@ declare namespace cloudbase.app {
751
752
  mysql: IMySqlClient
752
753
  rdb: IMySqlClient
753
754
 
755
+ /**
756
+ * Realtime 客户端(Broadcast / Presence / Postgres CDC)
757
+ *
758
+ * WebSocket 地址为 `wss://{GW}/v1/realtime/websocket?apikey={accessToken}&vsn=1.0.0`。
759
+ *
760
+ * 浏览器 / Node / 微信小程序均通过 `app.realtime()` 获取客户端。
761
+ * 小程序不要单独 `new RealtimeClient()`,需使用已注册 adapter 的 `wsClass`。
762
+ * 使用前需先登录(如 `auth.signInAnonymously()`);没有登录态时会在控制台提示。
763
+ *
764
+ * @example
765
+ * ```javascript
766
+ * const app = cloudbase.init({ env: 'xxxx-yyy' })
767
+ * const realtime = app.realtime()
768
+ * const channel = realtime.channel('room')
769
+ * channel.on('broadcast', { event: 'cursor-pos' }, (payload) => console.log(payload))
770
+ * channel.subscribe()
771
+ * ```
772
+ */
773
+ realtime(): RealtimeClient
774
+
754
775
  ai(options?: { baseUrl?: string }): AI
755
776
 
756
777
  apis: ICloudbaseApis
@@ -1956,6 +1977,10 @@ declare namespace cloudbase.storage {
1956
1977
 
1957
1978
  interface ICloudbaseFileInfo {
1958
1979
  fileID: string
1980
+ /**
1981
+ * 仅为兼容字段。传统模式不会用它生成下载链接,TTL 传入无效。
1982
+ * 需要可控过期请改用 `app.storage.from(bucketId).createSignedUrl(path, expiresIn)`(PG 模式下可用)。
1983
+ */
1959
1984
  maxAge: number
1960
1985
  }
1961
1986
 
@@ -2278,7 +2303,7 @@ declare namespace cloudbase.storage {
2278
2303
  * 创建签名下载 URL
2279
2304
  *
2280
2305
  * @param path 文件路径
2281
- * @param expiresIn 有效期(秒)
2306
+ * @param expiresIn 过期时间。传统模式不会用它生成下载链接,TTL 传入无效。需要可控过期请改用 `from(bucketId).createSignedUrl`(PG 模式下可用)。
2282
2307
  * @param options 可选配置
2283
2308
  */
2284
2309
  createSignedUrl(
@@ -2297,7 +2322,7 @@ declare namespace cloudbase.storage {
2297
2322
  * 批量创建签名下载 URL
2298
2323
  *
2299
2324
  * @param paths 文件路径数组
2300
- * @param expiresIn 有效期(秒)
2325
+ * @param expiresIn 过期时间。传统模式不会用它生成下载链接,TTL 传入无效。需要可控过期请改用 `from(bucketId).createSignedUrls`(PG 模式下可用)。
2301
2326
  */
2302
2327
  createSignedUrls(
2303
2328
  paths: string[],