@cloudbase/js-sdk 3.6.2 → 3.6.3

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.
Files changed (74) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/ai/dist/index.esm.js +1 -1
  3. package/ai/dist/index.esm.js.map +1 -1
  4. package/ai/dist/index.js +1 -1
  5. package/ai/dist/index.js.map +1 -1
  6. package/app/dist/index.esm.js +1 -1
  7. package/app/dist/index.esm.js.map +1 -1
  8. package/app/dist/index.js +1 -1
  9. package/app/dist/index.js.map +1 -1
  10. package/app/dist/index.node.esm.js +1 -1
  11. package/app/dist/index.node.esm.js.map +1 -1
  12. package/app/dist/index.node.js +1 -1
  13. package/app/dist/index.node.js.map +1 -1
  14. package/auth/dist/index.esm.js +1 -1
  15. package/auth/dist/index.esm.js.map +1 -1
  16. package/auth/dist/index.js +1 -1
  17. package/auth/dist/index.js.map +1 -1
  18. package/core.d.ts +4331 -0
  19. package/core.node.d.ts +294 -0
  20. package/dist/index.cjs.js +1 -1
  21. package/dist/index.cjs.js.map +1 -1
  22. package/dist/index.esm.js +1 -1
  23. package/dist/index.esm.js.map +1 -1
  24. package/dist/index.node.cjs.js +1 -1
  25. package/dist/index.node.cjs.js.map +1 -1
  26. package/dist/index.node.esm.js +1 -1
  27. package/dist/index.node.esm.js.map +1 -1
  28. package/index.d.ts +5 -4268
  29. package/index.node.d.ts +13 -0
  30. package/miniprogram_dist/ai/index.d.ts +42 -0
  31. package/miniprogram_dist/ai/index.js +2 -0
  32. package/miniprogram_dist/apis/index.d.ts +5 -0
  33. package/miniprogram_dist/{apis.js → apis/index.js} +1 -1
  34. package/miniprogram_dist/app/index.d.ts +67 -0
  35. package/miniprogram_dist/app/index.js +2 -0
  36. package/miniprogram_dist/auth/index.d.ts +284 -0
  37. package/miniprogram_dist/auth/index.js +2 -0
  38. package/miniprogram_dist/cloudrun/index.d.ts +4 -0
  39. package/miniprogram_dist/cloudrun/index.js +1 -0
  40. package/miniprogram_dist/container/index.d.ts +13 -0
  41. package/miniprogram_dist/container/index.js +1 -0
  42. package/miniprogram_dist/database/index.d.ts +3 -0
  43. package/miniprogram_dist/functions/index.d.ts +2 -0
  44. package/miniprogram_dist/functions/index.js +1 -0
  45. package/miniprogram_dist/index.js +1 -1
  46. package/miniprogram_dist/model/index.d.ts +5 -0
  47. package/miniprogram_dist/model/index.js +1 -0
  48. package/miniprogram_dist/mysql/index.d.ts +3 -0
  49. package/miniprogram_dist/mysql/index.js +1 -0
  50. package/miniprogram_dist/oauth/index.d.ts +22 -0
  51. package/miniprogram_dist/oauth/index.js +2 -0
  52. package/miniprogram_dist/realtime/index.d.ts +2 -0
  53. package/miniprogram_dist/realtime/index.js +1 -0
  54. package/miniprogram_dist/storage/index.d.ts +13 -0
  55. package/miniprogram_dist/{storage.js → storage/index.js} +1 -1
  56. package/oauth/dist/index.esm.js +1 -1
  57. package/oauth/dist/index.esm.js.map +1 -1
  58. package/oauth/dist/index.js +1 -1
  59. package/oauth/dist/index.js.map +1 -1
  60. package/package.json +6 -2
  61. package/types/package.json +1 -1
  62. package/utilities/package.json +2 -2
  63. package/dist/index.d.ts +0 -9
  64. package/miniprogram_dist/ai.js +0 -2
  65. package/miniprogram_dist/app.js +0 -2
  66. package/miniprogram_dist/auth.js +0 -2
  67. package/miniprogram_dist/cloudrun.js +0 -1
  68. package/miniprogram_dist/container.js +0 -1
  69. package/miniprogram_dist/functions.js +0 -1
  70. package/miniprogram_dist/model.js +0 -1
  71. package/miniprogram_dist/mysql.js +0 -1
  72. package/miniprogram_dist/oauth.js +0 -2
  73. package/miniprogram_dist/realtime.js +0 -1
  74. /package/miniprogram_dist/{database.js → database/index.js} +0 -0
package/core.node.d.ts ADDED
@@ -0,0 +1,294 @@
1
+ /// <reference path="./core.d.ts" />
2
+
3
+ /**
4
+ * Node.js 环境专属类型定义(ambient)。
5
+ *
6
+ * 通过声明合并(declaration merging)在共享的 `cloudbase` 命名空间之上追加
7
+ * 仅在 Node.js 运行时可用的接口、常量与方法。仅由 `index.node.d.ts` 引用,
8
+ * 因此这些定义不会出现在 Web/浏览器构建的类型中。
9
+ */
10
+ declare namespace cloudbase {
11
+ /**
12
+ * ICloudbaseConfig 的 Node.js 专属字段(通过声明合并追加)。
13
+ * 这些字段仅在 Node.js 入口(index.node.d.ts)可见,Web 构建不包含。
14
+ */
15
+ interface ICloudbaseConfig {
16
+ /** 密钥 ID(Node.js 端使用) */
17
+ secretId?: string
18
+ /** 密钥(Node.js 端使用) */
19
+ secretKey?: string
20
+ /** 临时会话 Token(Node.js 端使用) */
21
+ sessionToken?: string
22
+ /** 自定义登录密钥 */
23
+ credentials?: { private_key_id: string; private_key: string; env_id?: string; }
24
+ // @cloudbase/functions-framework 函数上下文,只要求部分字段,只在云函数或云托管中有效
25
+ context?: Readonly<{
26
+ eventID: string
27
+ extendedContext?: {
28
+ envId: string // 环境 ID
29
+ // uin: string // 请求的 UIN
30
+ source: string // 请求来源,如 wx
31
+ accessToken?: string // 调用请求时的 AccessToken
32
+ userId?: string // 请求的用户 ID
33
+ tmpSecret?: {
34
+ // 临时凭证
35
+ secretId: string // secretId
36
+ secretKey: string // secretKey
37
+ token: string // token
38
+ }
39
+ }
40
+ }>
41
+ }
42
+
43
+ /**
44
+ * ICloudbaseAuthConfig 的 Node.js 专属字段(通过声明合并追加)。
45
+ */
46
+ interface ICloudbaseAuthConfig {
47
+ /** 密钥 ID(Node.js 端使用) */
48
+ secretId?: string
49
+ /** 密钥(Node.js 端使用) */
50
+ secretKey?: string
51
+ /** 临时会话 Token(Node.js 端使用) */
52
+ sessionToken?: string
53
+ /** 密钥类型 */
54
+ secretType?: 'SESSION_SECRET' | 'SECRET'
55
+ }
56
+
57
+ /**
58
+ * 云函数入口 context 参数结构(仅 Node.js 环境)
59
+ */
60
+ interface IContextParam {
61
+ memory_limit_in_mb: number
62
+ time_limit_in_ms: number
63
+ request_id: string
64
+ /** 老架构环境变量字符串,分号分隔的 key=value */
65
+ environ?: string
66
+ /** 新架构环境变量 JSON 字符串 */
67
+ environment?: string
68
+ function_version: string
69
+ function_name: string
70
+ namespace: string
71
+ }
72
+
73
+ /**
74
+ * 云函数运行时完整环境变量类型汇总(仅 Node.js 环境)
75
+ * 包含 SCF、TCB、微信相关的所有环境变量
76
+ */
77
+ interface ICompleteCloudbaseContext {
78
+ _SCF_TCB_LOG?: string
79
+ LOGINTYPE?: string
80
+ QQ_APPID?: string
81
+ QQ_OPENID?: string
82
+ SCF_NAMESPACE: string
83
+ TCB_CONTEXT_CNFG?: string
84
+ TCB_CONTEXT_KEYS: string[]
85
+ TCB_CUSTOM_USER_ID?: string
86
+ TCB_ENV: string
87
+ TCB_HTTP_CONTEXT?: string
88
+ TCB_ISANONYMOUS_USER?: string
89
+ TCB_ROUTE_KEY?: string
90
+ TCB_SEQID: string
91
+ TCB_SESSIONTOKEN?: string
92
+ TCB_SOURCE_IP?: string
93
+ TCB_SOURCE?: string
94
+ TCB_TRACELOG?: string
95
+ TCB_UUID?: string
96
+ TENCENTCLOUD_RUNENV: string
97
+ TENCENTCLOUD_SECRETID: string
98
+ TENCENTCLOUD_SECRETKEY: string
99
+ TENCENTCLOUD_SESSIONTOKEN: string
100
+ CLOUDBASE_APIKEY: string
101
+ TRIGGER_SRC: string
102
+ WX_API_TOKEN?: string
103
+ WX_APPID?: string
104
+ WX_CLIENTIP?: string
105
+ WX_CLIENTIPV6?: string
106
+ WX_CLOUDBASE_ACCESSTOKEN?: string
107
+ WX_CONTEXT_KEYS: string[]
108
+ WX_OPENID?: string
109
+ WX_TRIGGER_API_TOKEN_V0?: string
110
+ WX_UNIONID?: string
111
+ }
112
+
113
+ /**
114
+ * 自定义登录 Ticket 创建选项(仅 Node.js 环境)
115
+ */
116
+ interface ICreateTicketOpts {
117
+ /** 刷新间隔(毫秒),默认 3600000(1小时) */
118
+ refresh?: number
119
+ /** 过期时间戳(毫秒),默认 7 天后 */
120
+ expire?: number
121
+ }
122
+
123
+ /**
124
+ * 当前请求用户信息(仅 Node.js 环境)
125
+ */
126
+ interface IGetUserInfoResult {
127
+ openId: string
128
+ appId: string
129
+ uid: string
130
+ customUserId: string
131
+ isAnonymous: boolean
132
+ }
133
+
134
+ /**
135
+ * getEndUserInfo 返回结果(仅 Node.js 环境)
136
+ */
137
+ interface IGetEndUserInfoResult {
138
+ userInfo?: {
139
+ openId: string
140
+ appId: string
141
+ uid: string
142
+ customUserId: string
143
+ isAnonymous: boolean
144
+ [key: string]: any
145
+ }
146
+ requestId?: string
147
+ code?: string
148
+ message?: string
149
+ }
150
+
151
+ /**
152
+ * 用户信息查询请求参数(仅 Node.js 环境)
153
+ */
154
+ interface IUserInfoQuery {
155
+ platform?: string
156
+ platformId?: string
157
+ uid?: string
158
+ }
159
+
160
+ /**
161
+ * 模板消息推送请求参数(仅 Node.js 环境)
162
+ */
163
+ interface ITemplateNotifyReq {
164
+ /** 通知策略 ID */
165
+ notifyId: string
166
+ /** 通知模板变量键值对 */
167
+ data?: Record<string, unknown>
168
+ /** 点击消息打开的页面地址 */
169
+ url?: string
170
+ }
171
+
172
+ /**
173
+ * Node 端 Auth Context 解析结果(仅 Node.js 环境)
174
+ */
175
+ interface INodeAuthContext {
176
+ uid?: string
177
+ loginType?: string
178
+ appId?: string
179
+ openId?: string
180
+ }
181
+
182
+ /**
183
+ * SDK 版本号(仅 Node.js 环境下挂载)
184
+ */
185
+ const version: string
186
+ /**
187
+ * 当前环境标记 Symbol(仅 Node.js 环境下挂载)
188
+ */
189
+ const SYMBOL_CURRENT_ENV: symbol
190
+ /**
191
+ * 默认环境标记 Symbol(仅 Node.js 环境下挂载)
192
+ */
193
+ const SYMBOL_DEFAULT_ENV: symbol
194
+ /**
195
+ * 解析并校验云函数入口的 Context 参数(仅 Node.js 环境)
196
+ *
197
+ * @param context 云函数入口传入的 context 对象
198
+ */
199
+ function parseContext(context: IContextParam): Record<string, any>
200
+ /**
201
+ * 获取当前云函数内的所有环境变量(仅 Node.js 环境)
202
+ * 统一从 process.env 和 context 两个来源合并取值
203
+ *
204
+ * @param context 可选,云函数入口的 context 参数
205
+ */
206
+ function getCloudbaseContext(context?: IContextParam): ICompleteCloudbaseContext
207
+ }
208
+
209
+ declare namespace cloudbase.app {
210
+ interface App {
211
+ /**
212
+ * 解析并缓存云函数入口的 Context 参数(仅 Node.js 环境)
213
+ *
214
+ * @param context 云函数入口传入的 context 对象
215
+ */
216
+ parseContext(context: cloudbase.IContextParam): Record<string, any>
217
+ /**
218
+ * 获取当前云函数内的所有环境变量(仅 Node.js 环境)
219
+ *
220
+ * @param context 可选,云函数入口的 context 参数
221
+ */
222
+ getCloudbaseContext(context?: cloudbase.IContextParam): cloudbase.ICompleteCloudbaseContext
223
+ /**
224
+ * 发送订阅消息 / 模板通知(仅 Node.js 环境)
225
+ *
226
+ * @param params 模板通知参数
227
+ * @param opts 可选,请求配置
228
+ */
229
+ sendTemplateNotification(
230
+ params: cloudbase.ITemplateNotifyReq,
231
+ opts?: { timeout?: number },
232
+ ): Promise<cloudbase.functions.ICallFunctionResponse>
233
+ /**
234
+ * 调用微信开放接口(仅 Node.js 环境)
235
+ */
236
+ callWxOpenApi(wxOpenApiOptions: any, opts?: cloudbase.ICustomReqOpts): Promise<any>
237
+ /**
238
+ * 调用微信支付接口(仅 Node.js 环境)
239
+ */
240
+ callWxPayApi(wxOpenApiOptions: any, opts?: cloudbase.ICustomReqOpts): Promise<any>
241
+ /**
242
+ * 调用微信云托管接口(仅 Node.js 环境)
243
+ */
244
+ wxCallContainerApi(wxOpenApiOptions: any, opts?: cloudbase.ICustomReqOpts): Promise<any>
245
+ /**
246
+ * 调用微信兼容开放接口(仅 Node.js 环境)
247
+ */
248
+ callCompatibleWxOpenApi(wxOpenApiOptions: any, opts?: cloudbase.ICustomReqOpts): Promise<any>
249
+ /**
250
+ * 获取文件访问权限(仅 Node.js 环境)
251
+ *
252
+ * @param params 文件列表参数
253
+ * @param opts 可选,请求配置
254
+ */
255
+ getFileAuthority(
256
+ params: { fileList: Array<{ type: string; path: string }> },
257
+ opts?: cloudbase.ICustomReqOpts,
258
+ ): Promise<any>
259
+ /**
260
+ * 调用已开放的 API(仅 Node.js 环境)
261
+ */
262
+ callApis(callApiOptions: any, opts?: cloudbase.ICustomReqOpts): Promise<any>
263
+ }
264
+ }
265
+
266
+ declare namespace cloudbase.auth {
267
+ interface App {
268
+ /**
269
+ * 获取终端用户信息(仅 Node.js 环境)
270
+ * 不传 uid 时返回当前请求用户信息,传 uid 时查询指定用户
271
+ */
272
+ getEndUserInfo(uid?: string): Promise<cloudbase.IGetEndUserInfoResult>
273
+ /**
274
+ * 创建自定义登录 Ticket(仅 Node.js 环境)
275
+ */
276
+ createTicket(uid: string, options?: cloudbase.ICreateTicketOpts): Promise<string>
277
+ /**
278
+ * 按条件查询用户信息(管理端接口,仅 Node.js 环境)
279
+ */
280
+ queryUserInfo(query: cloudbase.IUserInfoQuery): Promise<any>
281
+ /**
282
+ * 获取客户端 IP 地址(仅 Node.js 环境)
283
+ */
284
+ getClientIP(): string
285
+ /**
286
+ * 获取 Auth Context(从运行环境中解析,仅 Node.js 环境)
287
+ */
288
+ getAuthContext(context?: any): cloudbase.INodeAuthContext
289
+ /**
290
+ * 获取客户端凭证(仅 Node.js 环境)
291
+ */
292
+ getClientCredential(opts?: cloudbase.ICustomReqOpts): Promise<any>
293
+ }
294
+ }