@cloudbase/js-sdk 2.28.8 → 2.29.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.
Files changed (330) hide show
  1. package/CHANGELOG.md +147 -0
  2. package/ai/dist/index.esm.js +2 -3
  3. package/ai/dist/index.esm.js.map +1 -0
  4. package/ai/dist/index.js +2 -21
  5. package/ai/dist/index.js.map +1 -0
  6. package/apis/dist/index.esm.js +2 -3
  7. package/apis/dist/index.esm.js.map +1 -0
  8. package/apis/dist/index.js +2 -21
  9. package/apis/dist/index.js.map +1 -0
  10. package/app/dist/index.esm.js +2 -11
  11. package/app/dist/index.esm.js.map +1 -0
  12. package/app/dist/index.js +2 -18
  13. package/app/dist/index.js.map +1 -0
  14. package/auth/dist/index.d.ts +2 -2
  15. package/auth/dist/index.esm.js +3 -8
  16. package/auth/dist/index.esm.js.LICENSE.txt +12 -0
  17. package/auth/dist/index.esm.js.map +1 -0
  18. package/auth/dist/index.js +3 -13
  19. package/auth/dist/index.js.LICENSE.txt +12 -0
  20. package/auth/dist/index.js.map +1 -0
  21. package/cloudrun/dist/index.esm.js +2 -3
  22. package/cloudrun/dist/index.esm.js.map +1 -0
  23. package/cloudrun/dist/index.js +2 -21
  24. package/cloudrun/dist/index.js.map +1 -0
  25. package/container/dist/index.d.ts +2 -2
  26. package/container/dist/index.esm.js +2 -8
  27. package/container/dist/index.esm.js.map +1 -0
  28. package/container/dist/index.js +2 -13
  29. package/container/dist/index.js.map +1 -0
  30. package/database/dist/commonjs/aggregate.d.ts +29 -0
  31. package/database/dist/commonjs/aggregate.js +156 -0
  32. package/database/dist/commonjs/collection.d.ts +9 -0
  33. package/database/dist/commonjs/collection.js +49 -0
  34. package/database/dist/commonjs/command.d.ts +175 -0
  35. package/database/dist/commonjs/command.js +299 -0
  36. package/database/dist/commonjs/commands/logic.d.ts +24 -0
  37. package/database/dist/commonjs/commands/logic.js +89 -0
  38. package/database/dist/commonjs/commands/query.d.ts +68 -0
  39. package/database/dist/commonjs/commands/query.js +160 -0
  40. package/database/dist/commonjs/commands/update.d.ts +29 -0
  41. package/database/dist/commonjs/commands/update.js +51 -0
  42. package/database/dist/commonjs/config/app.config.d.ts +6 -0
  43. package/database/dist/commonjs/config/app.config.js +7 -0
  44. package/database/dist/commonjs/config/error.config.d.ts +3 -0
  45. package/database/dist/commonjs/config/error.config.js +16 -0
  46. package/database/dist/commonjs/const/code.d.ts +30 -0
  47. package/database/dist/commonjs/const/code.js +33 -0
  48. package/database/dist/commonjs/constant.d.ts +51 -0
  49. package/database/dist/commonjs/constant.js +75 -0
  50. package/database/dist/commonjs/document.d.ts +11 -0
  51. package/database/dist/commonjs/document.js +260 -0
  52. package/database/dist/commonjs/geo/index.d.ts +6 -0
  53. package/database/dist/commonjs/geo/index.js +22 -0
  54. package/database/dist/commonjs/geo/interface.d.ts +24 -0
  55. package/database/dist/commonjs/geo/interface.js +2 -0
  56. package/database/dist/commonjs/geo/lineString.d.ts +19 -0
  57. package/database/dist/commonjs/geo/lineString.js +86 -0
  58. package/database/dist/commonjs/geo/multiLineString.d.ts +18 -0
  59. package/database/dist/commonjs/geo/multiLineString.js +95 -0
  60. package/database/dist/commonjs/geo/multiPoint.d.ts +18 -0
  61. package/database/dist/commonjs/geo/multiPoint.js +79 -0
  62. package/database/dist/commonjs/geo/multiPolygon.d.ts +18 -0
  63. package/database/dist/commonjs/geo/multiPolygon.js +122 -0
  64. package/database/dist/commonjs/geo/point.d.ts +19 -0
  65. package/database/dist/commonjs/geo/point.js +50 -0
  66. package/database/dist/commonjs/geo/polygon.d.ts +19 -0
  67. package/database/dist/commonjs/geo/polygon.js +109 -0
  68. package/database/dist/commonjs/helper/symbol.d.ts +14 -0
  69. package/database/dist/commonjs/helper/symbol.js +31 -0
  70. package/database/dist/commonjs/index.d.ts +40 -0
  71. package/database/dist/commonjs/index.js +61 -0
  72. package/database/dist/commonjs/lib/util.d.ts +1 -0
  73. package/database/dist/commonjs/lib/util.js +26 -0
  74. package/database/dist/commonjs/operator-map.d.ts +4 -0
  75. package/database/dist/commonjs/operator-map.js +24 -0
  76. package/database/dist/commonjs/query.d.ts +22 -0
  77. package/database/dist/commonjs/query.js +252 -0
  78. package/database/dist/commonjs/regexp/index.d.ts +14 -0
  79. package/database/dist/commonjs/regexp/index.js +33 -0
  80. package/database/dist/commonjs/serializer/common.d.ts +11 -0
  81. package/database/dist/commonjs/serializer/common.js +127 -0
  82. package/database/dist/commonjs/serializer/datatype.d.ts +7 -0
  83. package/database/dist/commonjs/serializer/datatype.js +132 -0
  84. package/database/dist/commonjs/serializer/query.d.ts +7 -0
  85. package/database/dist/commonjs/serializer/query.js +232 -0
  86. package/database/dist/commonjs/serializer/update.d.ts +15 -0
  87. package/database/dist/commonjs/serializer/update.js +142 -0
  88. package/database/dist/commonjs/serverDate/index.d.ts +13 -0
  89. package/database/dist/commonjs/serverDate/index.js +30 -0
  90. package/database/dist/commonjs/transaction/collection.d.ts +7 -0
  91. package/database/dist/commonjs/transaction/collection.js +49 -0
  92. package/database/dist/commonjs/transaction/document.d.ts +27 -0
  93. package/database/dist/commonjs/transaction/document.js +205 -0
  94. package/database/dist/commonjs/transaction/index.d.ts +30 -0
  95. package/database/dist/commonjs/transaction/index.js +215 -0
  96. package/database/dist/commonjs/transaction/query.d.ts +43 -0
  97. package/database/dist/commonjs/transaction/query.js +261 -0
  98. package/database/dist/commonjs/typings/index.d.ts +40 -0
  99. package/database/dist/commonjs/typings/index.js +2 -0
  100. package/database/dist/commonjs/typings/realtime.d.ts +219 -0
  101. package/database/dist/commonjs/typings/realtime.js +2 -0
  102. package/database/dist/commonjs/util.d.ts +9 -0
  103. package/database/dist/commonjs/util.js +145 -0
  104. package/database/dist/commonjs/utils/error.d.ts +38 -0
  105. package/database/dist/commonjs/utils/error.js +91 -0
  106. package/database/dist/commonjs/utils/msg.d.ts +0 -0
  107. package/database/dist/commonjs/utils/msg.js +0 -0
  108. package/database/dist/commonjs/utils/symbol.d.ts +8 -0
  109. package/database/dist/commonjs/utils/symbol.js +58 -0
  110. package/database/dist/commonjs/utils/type.d.ts +13 -0
  111. package/database/dist/commonjs/utils/type.js +34 -0
  112. package/database/dist/commonjs/utils/utils.d.ts +4 -0
  113. package/database/dist/commonjs/utils/utils.js +39 -0
  114. package/database/dist/commonjs/validate.d.ts +1 -0
  115. package/database/dist/commonjs/validate.js +60 -0
  116. package/database/dist/esm/aggregate.d.ts +29 -0
  117. package/database/dist/esm/aggregate.js +154 -0
  118. package/database/dist/esm/collection.d.ts +9 -0
  119. package/database/dist/esm/collection.js +46 -0
  120. package/database/dist/esm/command.d.ts +175 -0
  121. package/database/dist/esm/command.js +296 -0
  122. package/database/dist/esm/commands/logic.d.ts +24 -0
  123. package/database/dist/esm/commands/logic.js +84 -0
  124. package/database/dist/esm/commands/query.d.ts +68 -0
  125. package/database/dist/esm/commands/query.js +154 -0
  126. package/database/dist/esm/commands/update.d.ts +29 -0
  127. package/database/dist/esm/commands/update.js +46 -0
  128. package/database/dist/esm/config/app.config.d.ts +6 -0
  129. package/database/dist/esm/config/app.config.js +5 -0
  130. package/database/dist/esm/config/error.config.d.ts +3 -0
  131. package/database/dist/esm/config/error.config.js +13 -0
  132. package/database/dist/esm/const/code.d.ts +30 -0
  133. package/database/dist/esm/const/code.js +30 -0
  134. package/database/dist/esm/constant.d.ts +51 -0
  135. package/database/dist/esm/constant.js +65 -0
  136. package/database/dist/esm/document.d.ts +11 -0
  137. package/database/dist/esm/document.js +257 -0
  138. package/database/dist/esm/geo/index.d.ts +6 -0
  139. package/database/dist/esm/geo/index.js +6 -0
  140. package/database/dist/esm/geo/interface.d.ts +24 -0
  141. package/database/dist/esm/geo/interface.js +1 -0
  142. package/database/dist/esm/geo/lineString.d.ts +19 -0
  143. package/database/dist/esm/geo/lineString.js +83 -0
  144. package/database/dist/esm/geo/multiLineString.d.ts +18 -0
  145. package/database/dist/esm/geo/multiLineString.js +92 -0
  146. package/database/dist/esm/geo/multiPoint.d.ts +18 -0
  147. package/database/dist/esm/geo/multiPoint.js +76 -0
  148. package/database/dist/esm/geo/multiPolygon.d.ts +18 -0
  149. package/database/dist/esm/geo/multiPolygon.js +119 -0
  150. package/database/dist/esm/geo/point.d.ts +19 -0
  151. package/database/dist/esm/geo/point.js +47 -0
  152. package/database/dist/esm/geo/polygon.d.ts +19 -0
  153. package/database/dist/esm/geo/polygon.js +106 -0
  154. package/database/dist/esm/helper/symbol.d.ts +14 -0
  155. package/database/dist/esm/helper/symbol.js +14 -0
  156. package/database/dist/esm/index.d.ts +40 -0
  157. package/database/dist/esm/index.js +55 -0
  158. package/database/dist/esm/lib/util.d.ts +1 -0
  159. package/database/dist/esm/lib/util.js +22 -0
  160. package/database/dist/esm/operator-map.d.ts +4 -0
  161. package/database/dist/esm/operator-map.js +20 -0
  162. package/database/dist/esm/query.d.ts +22 -0
  163. package/database/dist/esm/query.js +249 -0
  164. package/database/dist/esm/regexp/index.d.ts +14 -0
  165. package/database/dist/esm/regexp/index.js +29 -0
  166. package/database/dist/esm/serializer/common.d.ts +11 -0
  167. package/database/dist/esm/serializer/common.js +118 -0
  168. package/database/dist/esm/serializer/datatype.d.ts +7 -0
  169. package/database/dist/esm/serializer/datatype.js +127 -0
  170. package/database/dist/esm/serializer/query.d.ts +7 -0
  171. package/database/dist/esm/serializer/query.js +229 -0
  172. package/database/dist/esm/serializer/update.d.ts +15 -0
  173. package/database/dist/esm/serializer/update.js +139 -0
  174. package/database/dist/esm/serverDate/index.d.ts +13 -0
  175. package/database/dist/esm/serverDate/index.js +26 -0
  176. package/database/dist/esm/transaction/collection.d.ts +7 -0
  177. package/database/dist/esm/transaction/collection.js +46 -0
  178. package/database/dist/esm/transaction/document.d.ts +27 -0
  179. package/database/dist/esm/transaction/document.js +202 -0
  180. package/database/dist/esm/transaction/index.d.ts +30 -0
  181. package/database/dist/esm/transaction/index.js +210 -0
  182. package/database/dist/esm/transaction/query.d.ts +43 -0
  183. package/database/dist/esm/transaction/query.js +258 -0
  184. package/database/dist/esm/typings/index.d.ts +40 -0
  185. package/database/dist/esm/typings/index.js +1 -0
  186. package/database/dist/esm/typings/realtime.d.ts +219 -0
  187. package/database/dist/esm/typings/realtime.js +1 -0
  188. package/database/dist/esm/util.d.ts +9 -0
  189. package/database/dist/esm/util.js +142 -0
  190. package/database/dist/esm/utils/error.d.ts +38 -0
  191. package/database/dist/esm/utils/error.js +84 -0
  192. package/database/dist/esm/utils/msg.d.ts +0 -0
  193. package/database/dist/esm/utils/msg.js +0 -0
  194. package/database/dist/esm/utils/symbol.d.ts +8 -0
  195. package/database/dist/esm/utils/symbol.js +55 -0
  196. package/database/dist/esm/utils/type.d.ts +13 -0
  197. package/database/dist/esm/utils/type.js +20 -0
  198. package/database/dist/esm/utils/utils.d.ts +4 -0
  199. package/database/dist/esm/utils/utils.js +33 -0
  200. package/database/dist/esm/validate.d.ts +1 -0
  201. package/database/dist/esm/validate.js +57 -0
  202. package/database/package.json +34 -4
  203. package/dist/index.cjs.js +3 -40
  204. package/dist/index.cjs.js.LICENSE.txt +12 -0
  205. package/dist/index.cjs.js.map +1 -0
  206. package/dist/index.d.ts +9 -0
  207. package/dist/index.esm.js +3 -35
  208. package/dist/index.esm.js.LICENSE.txt +12 -0
  209. package/dist/index.esm.js.map +1 -0
  210. package/functions/dist/index.d.ts +2 -2
  211. package/functions/dist/index.esm.js +2 -8
  212. package/functions/dist/index.esm.js.map +1 -0
  213. package/functions/dist/index.js +2 -13
  214. package/functions/dist/index.js.map +1 -0
  215. package/index.d.ts +654 -45
  216. package/miniprogram_dist/ai.js +1 -1
  217. package/miniprogram_dist/apis.js +1 -1
  218. package/miniprogram_dist/app.js +1 -1
  219. package/miniprogram_dist/auth.js +1 -1
  220. package/miniprogram_dist/cloudrun.js +1 -1
  221. package/miniprogram_dist/container.js +1 -1
  222. package/miniprogram_dist/database.js +1 -1
  223. package/miniprogram_dist/functions.js +1 -1
  224. package/miniprogram_dist/index.js +1 -1
  225. package/miniprogram_dist/model.js +1 -1
  226. package/miniprogram_dist/mysql.js +1 -1
  227. package/miniprogram_dist/oauth.js +2 -1
  228. package/miniprogram_dist/realtime.js +1 -1
  229. package/miniprogram_dist/storage.js +1 -1
  230. package/model/dist/index.esm.js +2 -3
  231. package/model/dist/index.esm.js.map +1 -0
  232. package/model/dist/index.js +2 -21
  233. package/model/dist/index.js.map +1 -0
  234. package/mysql/dist/index.esm.js +2 -3
  235. package/mysql/dist/index.esm.js.map +1 -0
  236. package/mysql/dist/index.js +2 -21
  237. package/mysql/dist/index.js.map +1 -0
  238. package/oauth/dist/index.esm.js +3 -3
  239. package/oauth/dist/index.esm.js.LICENSE.txt +12 -0
  240. package/oauth/dist/index.esm.js.map +1 -0
  241. package/oauth/dist/index.js +3 -21
  242. package/oauth/dist/index.js.LICENSE.txt +12 -0
  243. package/oauth/dist/index.js.map +1 -0
  244. package/package.json +113 -20
  245. package/realtime/dist/index.d.ts +2 -2
  246. package/realtime/dist/index.esm.js +2 -8
  247. package/realtime/dist/index.esm.js.map +1 -0
  248. package/realtime/dist/index.js +2 -13
  249. package/realtime/dist/index.js.map +1 -0
  250. package/storage/dist/index.d.ts +2 -2
  251. package/storage/dist/index.esm.js +2 -4
  252. package/storage/dist/index.esm.js.map +1 -0
  253. package/storage/dist/index.js +2 -9
  254. package/storage/dist/index.js.map +1 -0
  255. package/types/analytics.d.ts +51 -0
  256. package/types/auth.d.ts +99 -0
  257. package/types/cache.d.ts +26 -0
  258. package/types/cloudrun.d.ts +9 -0
  259. package/types/component.d.ts +17 -0
  260. package/types/container.d.ts +93 -0
  261. package/types/database.d.ts +31 -0
  262. package/types/events.d.ts +13 -0
  263. package/types/functions.d.ts +40 -0
  264. package/types/index.d.ts +211 -0
  265. package/types/package.json +43 -0
  266. package/types/realtime.d.ts +350 -0
  267. package/types/request.d.ts +30 -0
  268. package/types/storage.d.ts +126 -0
  269. package/utilities/dist/cjs/adapters/index.d.ts +45 -0
  270. package/utilities/dist/cjs/adapters/index.js +68 -0
  271. package/utilities/dist/cjs/adapters/platforms/web.d.ts +20 -0
  272. package/utilities/dist/cjs/adapters/platforms/web.js +286 -0
  273. package/utilities/dist/cjs/constants/common.d.ts +6 -0
  274. package/utilities/dist/cjs/constants/common.js +24 -0
  275. package/utilities/dist/cjs/constants/errors.d.ts +8 -0
  276. package/utilities/dist/cjs/constants/errors.js +12 -0
  277. package/utilities/dist/cjs/constants/index.d.ts +3 -0
  278. package/utilities/dist/cjs/constants/index.js +21 -0
  279. package/utilities/dist/cjs/helpers/decorators.d.ts +11 -0
  280. package/utilities/dist/cjs/helpers/decorators.js +238 -0
  281. package/utilities/dist/cjs/helpers/index.d.ts +1 -0
  282. package/utilities/dist/cjs/helpers/index.js +18 -0
  283. package/utilities/dist/cjs/index.d.ts +13 -0
  284. package/utilities/dist/cjs/index.js +51 -0
  285. package/utilities/dist/cjs/libs/abortController.d.ts +9 -0
  286. package/utilities/dist/cjs/libs/abortController.js +25 -0
  287. package/utilities/dist/cjs/libs/cache.d.ts +17 -0
  288. package/utilities/dist/cjs/libs/cache.js +261 -0
  289. package/utilities/dist/cjs/libs/events.d.ts +27 -0
  290. package/utilities/dist/cjs/libs/events.js +108 -0
  291. package/utilities/dist/cjs/libs/langEvent.d.ts +3 -0
  292. package/utilities/dist/cjs/libs/langEvent.js +7 -0
  293. package/utilities/dist/cjs/libs/util.d.ts +49 -0
  294. package/utilities/dist/cjs/libs/util.js +282 -0
  295. package/utilities/dist/esm/adapters/index.d.ts +45 -0
  296. package/utilities/dist/esm/adapters/index.js +40 -0
  297. package/utilities/dist/esm/adapters/platforms/web.d.ts +20 -0
  298. package/utilities/dist/esm/adapters/platforms/web.js +282 -0
  299. package/utilities/dist/esm/constants/common.d.ts +6 -0
  300. package/utilities/dist/esm/constants/common.js +17 -0
  301. package/utilities/dist/esm/constants/errors.d.ts +8 -0
  302. package/utilities/dist/esm/constants/errors.js +9 -0
  303. package/utilities/dist/esm/constants/index.d.ts +3 -0
  304. package/utilities/dist/esm/constants/index.js +4 -0
  305. package/utilities/dist/esm/helpers/decorators.d.ts +11 -0
  306. package/utilities/dist/esm/helpers/decorators.js +234 -0
  307. package/utilities/dist/esm/helpers/index.d.ts +1 -0
  308. package/utilities/dist/esm/helpers/index.js +2 -0
  309. package/utilities/dist/esm/index.d.ts +13 -0
  310. package/utilities/dist/esm/index.js +14 -0
  311. package/utilities/dist/esm/libs/abortController.d.ts +9 -0
  312. package/utilities/dist/esm/libs/abortController.js +23 -0
  313. package/utilities/dist/esm/libs/cache.d.ts +17 -0
  314. package/utilities/dist/esm/libs/cache.js +258 -0
  315. package/utilities/dist/esm/libs/events.d.ts +27 -0
  316. package/utilities/dist/esm/libs/events.js +102 -0
  317. package/utilities/dist/esm/libs/langEvent.d.ts +3 -0
  318. package/utilities/dist/esm/libs/langEvent.js +4 -0
  319. package/utilities/dist/esm/libs/util.d.ts +49 -0
  320. package/utilities/dist/esm/libs/util.js +254 -0
  321. package/utilities/dist/miniprogram/index.js +1 -0
  322. package/utilities/package.json +26 -0
  323. package/analytics/dist/index.d.ts +0 -2
  324. package/analytics/dist/index.esm.js +0 -4
  325. package/analytics/dist/index.js +0 -9
  326. package/analytics/package.json +0 -6
  327. package/database/dist/index.d.ts +0 -3
  328. package/database/dist/index.esm.js +0 -503
  329. package/database/dist/index.js +0 -509
  330. package/miniprogram_dist/analytics.js +0 -1
@@ -0,0 +1,51 @@
1
+ // report 接口传参结构
2
+ export interface IReportData {
3
+ report_type: string, // 上报场景 如电商 mall,游戏 game
4
+ report_data: {
5
+ action_time?: number, // 非必填 行为发生时,客户端的时间点,单位s
6
+ action_type: string, // 必填 行为类型 如 访问 visit_store,分享 share,加入购物车 add_to_cart等
7
+ click_id?: string, // 非必填 广告平台会在URL增加click_id
8
+ action_param?: { // 非必填
9
+ value?: number, // 非必填 行为所带的参数,转化行为价值(例如金额)
10
+ leads_type?: string // 非必填 行为来源,目前支持PHONE(电话直呼),RESERVE(表单预约)
11
+ },
12
+ product_param?: { // 非必填
13
+ product_yun_type?: string, // 非必填 商品 goods ,优惠券 coupon, 搜索词 search_term
14
+ product_yun_id?: string, // 非必填 商品id
15
+ product_yun_category?: string, // 非必填 商品类目 自定义
16
+ product_yun_keywords?: string, // 非必填 商品关键词
17
+ product_yun_price?: number, // 非必填 商品原价
18
+ product_yun_value?: number, // 非必填 商品成交价
19
+ product_yun_name?: string, // 非必填 商品名
20
+ product_yun_id_ad?: string, // 非必填 广告商品库中商品id
21
+ product_yun_category_ad?: string // 非必填 广告商品库中商品类目
22
+ }
23
+ }
24
+ }
25
+
26
+ // 上报数据结构
27
+ export interface IAnalyticsDataItem {
28
+ analytics_scene: string, // 上报场景 如电商 mall,游戏 game
29
+ analytics_data: { // 场景模板内容,以电商模板举例
30
+ openid?: string, // 必填 用户openid
31
+ wechat_mini_program_appid?: string, // 必填小程序appid
32
+ action_time: number, // 必填 行为发生时,客户端的时间点,单位s
33
+ action_type: string, // 必填 行为类型 如 访问 visit_store,分享 share,加入购物车 add_to_cart等
34
+ click_id?: string, // 非必填 广告平台会在URL增加click_id
35
+ action_param?: { // 非必填
36
+ value?: number, // 非必填 行为所带的参数,转化行为价值(例如金额)
37
+ leads_type?: string // 非必填 行为来源,目前支持PHONE(电话直呼),RESERVE(表单预约)
38
+ },
39
+ product_param?: { // 非必填
40
+ product_yun_type?: string, // 非必填 商品 goods ,优惠券 coupon, 搜索词 search_term
41
+ product_yun_id?: string, // 非必填 商品id
42
+ product_yun_category?: string, // 非必填 商品类目 自定义
43
+ product_yun_keywords?: string, // 非必填 商品关键词
44
+ product_yun_price?: number, // 非必填 商品原价
45
+ product_yun_value?: number, // 非必填 商品成交价
46
+ product_yun_name?: string, // 非必填 商品名
47
+ product_yun_id_ad?: string, // 非必填 广告商品库中商品id
48
+ product_yun_category_ad?: string // 非必填 广告商品库中商品类目
49
+ }
50
+ }
51
+ }
@@ -0,0 +1,99 @@
1
+ import { ICloudbaseConfig, KV, ICloudbase } from '.'
2
+ import { authModels, UserInfo } from '@cloudbase/oauth'
3
+ import { ICloudbaseEventEmitter } from './events'
4
+
5
+ export type ICloudbaseAuthConfig = Pick<
6
+ ICloudbaseConfig,
7
+ | 'env'
8
+ | 'clientId'
9
+ | 'region'
10
+ | 'persistence'
11
+ | 'debug'
12
+ | '_fromApp'
13
+ | 'oauthInstance'
14
+ | 'wxCloud'
15
+ | 'i18n'
16
+ | 'accessKey'
17
+ | 'useWxCloud'
18
+ | 'auth'
19
+ > &
20
+ ICloudbaseConfig['auth']
21
+ & {eventBus?: ICloudbaseEventEmitter}
22
+
23
+ export interface IAccessTokenInfo {
24
+ accessToken: string
25
+ env: string
26
+ }
27
+ export interface ICredential {
28
+ // refreshToken: string;
29
+ accessToken?: string
30
+ accessTokenExpire?: string
31
+ }
32
+ export interface IAuthProvider {
33
+ signInWithRedirect: () => any
34
+ }
35
+ export interface IUserInfo {
36
+ uid?: string
37
+ loginType?: string
38
+ openid?: string
39
+ wxOpenId?: string
40
+ wxPublicId?: string
41
+ unionId?: string
42
+ qqMiniOpenId?: string
43
+ customUserId?: string
44
+ name?: string
45
+ displayName?: string
46
+ gender?: string
47
+ email?: string
48
+ username?: string
49
+ hasPassword?: boolean
50
+ location?: {
51
+ country?: string
52
+ province?: string
53
+ city?: string
54
+ }
55
+ country?: string
56
+ province?: string
57
+ city?: string
58
+ }
59
+ export interface IUser extends IUserInfo {
60
+ checkLocalInfo: () => void
61
+ checkLocalInfoAsync: () => Promise<void>
62
+ linkWithTicket?: (ticket: string) => Promise<void>
63
+ linkWithRedirect?: (provider: IAuthProvider) => void
64
+ getLinkedUidList?: () => Promise<{ hasPrimaryUid: boolean; users: IUserInfo[] }>
65
+ setPrimaryUid?: (uid: string) => Promise<void>
66
+ unlink?: (loginType: 'CUSTOM' | 'WECHAT-OPEN' | 'WECHAT-PUBLIC' | 'WECHAT-UNION') => Promise<void>
67
+ update: (userinfo: authModels.UserProfile) => Promise<void>
68
+ refresh: (params?: { version?: string }) => Promise<authModels.UserInfo>
69
+ }
70
+ export interface ILoginState {
71
+ user: IUser
72
+ }
73
+ export interface ICloudbaseAuth {
74
+ config: ICloudbaseConfig
75
+ loginType: string
76
+ weixinAuthProvider: any
77
+ anonymousAuthProvider: any
78
+ customAuthProvider: any
79
+ getAccessToken: () => IAccessTokenInfo
80
+ getLoginState: () => Promise<ILoginState | null>
81
+ hasLoginState: () => Promise<ILoginState | null>
82
+ getUserInfo: () => Promise<UserInfo & IUser>
83
+ getAuthHeader: () => Promise<KV<string>>
84
+ onLoginStateChanged: (callback: Function) => void
85
+ onLoginStateExpired: (callback: Function) => void
86
+ onAccessTokenRefreshed: (callback: Function) => void
87
+ onAnonymousConverted: (callback: Function) => void
88
+ onLoginTypeChanged: (callback: Function) => void
89
+ shouldRefreshAccessToken: (hook: Function) => void
90
+ /** 当前登录用户,未登录时为 null */
91
+ currentUser: IUser | null
92
+ }
93
+
94
+ type IProvider = new (...args: any[]) => any
95
+
96
+ export interface ICloudbaseAuthModule {
97
+ registerAuth: (app: ICloudbase) => void
98
+ registerProvider: (name: string, provider: IProvider) => void
99
+ }
@@ -0,0 +1,26 @@
1
+ import { ICloudbasePlatformInfo, KV, ICloudbaseConfig } from '.'
2
+
3
+ export type ICacheConfig = Pick < ICloudbaseConfig, 'debug' | 'persistence' > & {
4
+ platformInfo?: ICloudbasePlatformInfo;
5
+ keys?: KV<string>;
6
+ alwaysLocalKeys?: string[];
7
+ };
8
+
9
+ export interface ICloudbaseCache {
10
+ keys: KV<string>;
11
+ mode: 'async' | 'sync';
12
+
13
+ setStore: (key: string, value: any, version?: string) => void;
14
+ setStoreAsync: (key: string, value: any, version?: string) => Promise<void>;
15
+
16
+ getStore: (key: string, version?: string) => any;
17
+ getStoreAsync: (key: string, version?: string) => Promise<any>;
18
+
19
+ removeStore: (key: string) => void;
20
+ removeStoreAsync: (key: string) => Promise<void>;
21
+
22
+ updatePersistence?: (persistence: string) => void;
23
+ updatePersistenceAsync?: (persistence: string) => Promise<void>;
24
+
25
+ clear?: () => void;
26
+ }
@@ -0,0 +1,9 @@
1
+ import { KV } from '.'
2
+
3
+ export interface ICallContainerOptions {
4
+ name: string
5
+ data?: KV<any>
6
+ method?: string
7
+ path?: string
8
+ header?: KV<any>
9
+ }
@@ -0,0 +1,17 @@
1
+ import { ICloudbaseEventEmitter } from './events'
2
+
3
+ export interface ICloudbaseComponent {
4
+ name: string;
5
+ entity: any;
6
+ namespace?: string;
7
+ injectEvents?: {
8
+ bus: ICloudbaseEventEmitter,
9
+ events: string[];
10
+ };
11
+ IIFE?: boolean
12
+ }
13
+
14
+ export interface ICloudbaseHook {
15
+ entity: any;
16
+ target: string;
17
+ }
@@ -0,0 +1,93 @@
1
+ import { ICloudbaseConfig } from '.'
2
+
3
+ export interface IContianerConfig {
4
+ /**
5
+ * wasm sdk 地址
6
+ */
7
+ wasmUrl?: string;
8
+ /**
9
+ * js sdk 地址
10
+ */
11
+ jsUrl?:
12
+ | string
13
+ | {
14
+ vender?: string;
15
+ vm?: string;
16
+ };
17
+ /**
18
+ * 账号ID
19
+ */
20
+ uin: string;
21
+ /**
22
+ * 网关id
23
+ */
24
+ gatewayId: string;
25
+ /**
26
+ * 网关请求 host port
27
+ */
28
+ host: string;
29
+ port: string;
30
+ /**
31
+ * 是否上报数据
32
+ */
33
+ report?: boolean | object;
34
+ /**
35
+ * public key
36
+ */
37
+ publicKey?: string;
38
+ i18n?: ICloudbaseConfig['i18n'];
39
+ }
40
+
41
+ export interface ICallContainerOptions {
42
+ /**
43
+ * 填入业务自定义url和参数
44
+ * 根目录,就是 /
45
+ */
46
+ url: string;
47
+ /**
48
+ * 请求网关api子路由
49
+ */
50
+ pathname?: string;
51
+ /**
52
+ * 按照自己的业务开发,选择对应的方法
53
+ * @default GET
54
+ */
55
+ method?: string;
56
+ /**
57
+ * 设置请求的 header,header 中不能设置 Referer
58
+ */
59
+ header?: Record<string, string>;
60
+ /**
61
+ * 请求参数
62
+ */
63
+ data?: Object;
64
+ /**
65
+ * 超时时间,单位毫秒,默认60000
66
+ */
67
+ timeout?: number;
68
+ /**
69
+ * 超时提示细腻系
70
+ */
71
+ timeoutMsg?: string;
72
+
73
+ /**
74
+ * 响应 parse 类型
75
+ */
76
+ dataType?: 'json' | string;
77
+ /**
78
+ * 响应类型
79
+ */
80
+ responseType?: 'text' | 'arrayBuffer';
81
+ /**
82
+ * 是否上报数据
83
+ */
84
+ report?: boolean;
85
+ /**
86
+ * 请求 withCredentials
87
+ */
88
+ withCredentials?: boolean;
89
+ /**
90
+ * 请求是否为透明模式
91
+ */
92
+ transparent?: boolean;
93
+ }
@@ -0,0 +1,31 @@
1
+ export type DataType = 'init' | 'update' | 'add' | 'remove' | 'replace' | 'limit'
2
+ export type QueueType = 'init' | 'enqueue' | 'dequeue' | 'update'
3
+
4
+ export interface ISingleDBEvent {
5
+ id: number
6
+ dataType: DataType
7
+ queueType: QueueType
8
+ docId: string
9
+ doc: Record<string, any>
10
+ updatedFields?: any
11
+ removedFields?: any
12
+ }
13
+
14
+ export interface IDatabaseServiceContext extends IServiceContext {
15
+ appConfig: IAppConfig
16
+ ws?: any
17
+ }
18
+
19
+ export interface IAppConfig {
20
+ docSizeLimit: number
21
+ realtimePingInterval: number
22
+ realtimePongWaitTimeout: number
23
+ request: any
24
+ }
25
+
26
+ export interface IServiceContext {
27
+ // name: string
28
+ // identifiers: IRuntimeIdentifiers
29
+ // debug: boolean
30
+ env?: string
31
+ }
@@ -0,0 +1,13 @@
1
+ export interface Listeners {
2
+ [key: string]: Function[];
3
+ }
4
+ export interface ICloudbaseEvent {
5
+ name: string;
6
+ target: any;
7
+ data: any;
8
+ }
9
+ export interface ICloudbaseEventEmitter {
10
+ on(name: string, listener: Function): this;
11
+ off(name: string, listener: Function): this;
12
+ fire(event: string | ICloudbaseEvent, data?: any): this;
13
+ }
@@ -0,0 +1,40 @@
1
+ import { KV } from '.'
2
+
3
+ export interface ICallFunctionOptions {
4
+ name: string
5
+ data?: KV<any>
6
+ query?: KV<any>
7
+ search?: string
8
+ parse?: boolean
9
+ // Used for 云函数2.0 CallContainer
10
+ type?: string
11
+ method?: string
12
+ path?: string
13
+ header?: KV<any>
14
+ }
15
+
16
+ export interface ICallFunctionResponse {
17
+ requestId: string
18
+ result: any
19
+ }
20
+
21
+ export type ICallFunction = (options: ICallFunctionOptions, callback?: Function) => Promise<ICallFunctionResponse>
22
+
23
+ export interface IRetryOptions {
24
+ retries?: number
25
+ factor?: number
26
+ minTimeout?: number
27
+ maxTimeout?: number
28
+ randomize?: boolean
29
+ timeouts?: number[]
30
+ timeoutOps?: {
31
+ timeout: number
32
+ cb: function
33
+ }
34
+ }
35
+
36
+ export interface ICustomReqOpts {
37
+ timeout?: number
38
+ retryOptions?: IRetryOptions
39
+ from?: 'node-sdk'
40
+ }
@@ -0,0 +1,211 @@
1
+ import { CloudbaseAdapter, SDKAdapterInterface, ResponseObject } from '@cloudbase/adapter-interface'
2
+ import { ICloudbaseComponent, ICloudbaseHook } from './component'
3
+ import { ICloudbaseRequest } from './request'
4
+ import { ICloudbaseCache } from './cache'
5
+ import { ICloudbaseAuth } from './auth'
6
+ import { ICallFunctionOptions, ICallFunctionResponse } from './functions'
7
+ import {
8
+ ICloudbaseUploadFileParams,
9
+ ICloudbaseUploadFileResult,
10
+ ICloudbaseDeleteFileParams,
11
+ ICloudbaseDeleteFileResult,
12
+ ICloudbaseGetTempFileURLParams,
13
+ ICloudbaseGetTempFileURLResult,
14
+ ICloudbaseDownloadFileParams,
15
+ ICloudbaseDownloadFileResult,
16
+ ICloudbaseCopyFileParams,
17
+ ICloudbaseCopyFileResult,
18
+ } from './storage'
19
+ import { cloudbase } from '../cloudbase/index'
20
+
21
+ export enum LANGS {
22
+ ZH = 'zh-CN',
23
+ EN = 'en-US',
24
+ }
25
+
26
+ export type Persistence = 'local' | 'session' | 'none'
27
+
28
+ export interface KV<T> {
29
+ [key: string]: T
30
+ }
31
+
32
+ export interface KVstring {
33
+ [key: string]: string
34
+ }
35
+
36
+ export type EndPointKey = 'CLOUD_API' | 'GATEWAY'
37
+
38
+ /** 自定义登录凭证信息(从控制台下载的私钥文件) */
39
+ export interface ICredentialsInfo {
40
+ /** 私钥 ID */
41
+ private_key_id: string;
42
+ /** RSA 私钥内容 */
43
+ private_key: string;
44
+ /** 所属环境 ID */
45
+ env_id: string;
46
+ }
47
+
48
+ export interface ICloudbaseConfig {
49
+ env: string
50
+ intl?: boolean,
51
+ region?: string
52
+ timeout?: number
53
+ persistence?: Persistence
54
+ oauthClient?: any
55
+ debug?: boolean
56
+ _fromApp?: ICloudbase
57
+ clientId?: string
58
+ oauthInstance?: any
59
+ wxCloud?: any
60
+ i18n?: {
61
+ t: (text: string) => string
62
+ LANG_HEADER_KEY: string
63
+ lang: LANGS
64
+ }
65
+ accessKey?: string
66
+ endPointMode?: EndPointKey // auth请求域名模式,默认CLOUD_API
67
+ useWxCloud?: boolean // 是否使用微信云开发链路
68
+ auth?: {
69
+ detectSessionInUrl?: boolean
70
+ secretId?: string
71
+ secretKey?: string
72
+ sessionToken?: string
73
+ secretType?: 'SESSION_SECRET' | 'SECRET'
74
+ credentials?: ICredentialsInfo // 自定义登录私钥信息,node端使用
75
+ }
76
+ // @cloudbase/functions-framework 函数上下文,只要求部分字段,只在云函数或云托管中有效
77
+ context?: Readonly<{
78
+ eventID: string
79
+ extendedContext?: {
80
+ envId: string // 环境 ID
81
+ // uin: string // 请求的 UIN
82
+ source: string // 请求来源,如 wx
83
+ accessToken?: string // 调用请求时的 AccessToken
84
+ userId?: string // 请求的用户 ID
85
+ tmpSecret?: {
86
+ // 临时凭证
87
+ secretId: string // secretId
88
+ secretKey: string // secretKey
89
+ token: string // token
90
+ }
91
+ }
92
+ }>
93
+ }
94
+ // 可更新的配置字段
95
+ export type ICloudbaseUpgradedConfig = Pick<ICloudbaseConfig, 'persistence' | 'region' | 'debug'>
96
+
97
+ export interface ICloudbaseExtension {
98
+ name: string
99
+ invoke: (opts: any, app: ICloudbase) => Promise<any>
100
+ }
101
+
102
+ declare type MethodType = 'request' | 'post' | 'get' | 'head' | 'patch' | 'delete' | 'put'
103
+ export interface ICloudbaseApis {
104
+ [apiName: string]: {
105
+ [method in MethodType]: (callApiOptions: ICallApiOptions, opts?: KV<any>) => Promise<ResponseObject['data']>
106
+ }
107
+ }
108
+
109
+ export interface ICloudbase {
110
+ config: ICloudbaseConfig
111
+ platform: ICloudbasePlatformInfo
112
+ cache: ICloudbaseCache
113
+ request: ICloudbaseRequest
114
+ oauthClient: any
115
+ localCache: ICloudbaseCache
116
+ authInstance?: ICloudbaseAuth
117
+ oauthInstance?: any
118
+ apis: ICloudbaseApis
119
+ init: (config: ICloudbaseConfig & { lang?: LANGS }) => cloudbase.app
120
+ updateConfig: (config: ICloudbaseUpgradedConfig) => void
121
+ registerExtension: (ext: ICloudbaseExtension) => void
122
+ invokeExtension: (name: string, opts: any) => Promise<any>
123
+ useAdapters: (adapters: CloudbaseAdapter | CloudbaseAdapter[], options?: any) => void
124
+ registerComponent: (component: ICloudbaseComponent) => void
125
+ registerHook: (hook: ICloudbaseHook) => void
126
+ registerVersion: (version: string) => void
127
+ fire?: (...args: any[]) => void
128
+ updateLang?: (lang: LANGS) => void
129
+ /**
130
+ * 检查当前 Cloudbase 实例是否已完成初始化
131
+ * @returns 是否已初始化
132
+ */
133
+ isInitialized?: () => boolean
134
+ getEndPointWithKey?: (key: EndPointKey) => {
135
+ BASE_URL: string
136
+ PROTOCOL: string
137
+ }
138
+ auth?: (options?: { persistence: cloudbase.auth.Persistence }) => cloudbase.auth.App
139
+
140
+ // ---- 云函数 ----
141
+ /** 调用云函数 */
142
+ callFunction?: (options: ICallFunctionOptions, callback?: Function) => Promise<ICallFunctionResponse>
143
+
144
+ // ---- 数据库 ----
145
+ /** 获取数据库实例 */
146
+ database?: (dbConfig?: { instance?: string; database?: string }) => cloudbase.database.App
147
+
148
+ // ---- 云存储 ----
149
+ /** Storage 命名空间实例(from 分流 + Bucket 管理) */
150
+ storage?: cloudbase.storage.StorageClient
151
+ /** 上传文件 */
152
+ uploadFile?: (params: ICloudbaseUploadFileParams, callback?: Function) => Promise<ICloudbaseUploadFileResult>
153
+ /** 下载文件 */
154
+ downloadFile?: (params: ICloudbaseDownloadFileParams, callback?: Function) => Promise<ICloudbaseDownloadFileResult>
155
+ /** 删除云端文件 */
156
+ deleteFile?: (params: ICloudbaseDeleteFileParams, callback?: Function) => Promise<ICloudbaseDeleteFileResult>
157
+ /** 获取文件临时下载链接 */
158
+ getTempFileURL?: (params: ICloudbaseGetTempFileURLParams, callback?: Function) => Promise<ICloudbaseGetTempFileURLResult>
159
+ /** 复制/移动文件 */
160
+ copyFile?: (params: ICloudbaseCopyFileParams, callback?: Function) => Promise<ICloudbaseCopyFileResult>
161
+ }
162
+
163
+ /**
164
+ * Node.js 端适配器扩展方法
165
+ */
166
+ export interface INodeAdapterExtend {
167
+ /**
168
+ * 从环境变量中获取腾讯云临时密钥信息
169
+ * 用于 API 请求签名
170
+ */
171
+ getSecretInfo?: (config?: ICloudbaseConfig) => {
172
+ env: string
173
+ secretId: string
174
+ secretKey: string
175
+ sessionToken: string
176
+ accessKey: string
177
+ secretType: string
178
+ }
179
+ /**
180
+ * 初始化 Node.js 端工具方法,挂载到 js-sdk app 实例上
181
+ * 包含:auth 相关方法、模板消息推送、context 解析
182
+ */
183
+ nodeTool?: (
184
+ /** js-sdk cloudbase 实例 */
185
+ app: any,
186
+ /** 配置信息,包含认证凭证和环境 ID */
187
+ config: ICloudbaseConfig,
188
+ ) => void
189
+ }
190
+ export interface ICloudbasePlatformInfo {
191
+ adapter?: SDKAdapterInterface & INodeAdapterExtend
192
+ runtime?: string
193
+ }
194
+
195
+ export interface IGenericError<T extends string, P = any> extends Error {
196
+ type: T
197
+ payload: P
198
+ generic: boolean
199
+ }
200
+
201
+ export interface ICallApiOptions {
202
+ /** api标识 */
203
+ name?: string
204
+ /** 请求的path */
205
+ path?: string
206
+ method?: string
207
+ headers?: KV<any>
208
+ /** 请求体,根据content-type可以是不同类型 */
209
+ body?: KV<any> | string
210
+ token?: string
211
+ }
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@cloudbase/types",
3
+ "version": "2.29.0",
4
+ "description": "cloudbase javascript sdk types",
5
+ "files": [
6
+ "index.js",
7
+ "index.d.ts",
8
+ "cache.d.ts",
9
+ "events.d.ts",
10
+ "request.d.ts",
11
+ "auth.d.ts",
12
+ "component.d.ts",
13
+ "functions.d.ts",
14
+ "cloudrun.d.ts",
15
+ "storage.d.ts",
16
+ "realtime.d.ts",
17
+ "database.d.ts"
18
+ ],
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "https://github.com/TencentCloudBase/cloudbase-js-sdk"
22
+ },
23
+ "keywords": [
24
+ "cloudbase",
25
+ "Cloudbase",
26
+ "CloudBase",
27
+ "tcb",
28
+ "TCB",
29
+ "serverless",
30
+ "Serverless",
31
+ "javascript",
32
+ "typescript"
33
+ ],
34
+ "author": "",
35
+ "license": "Apache-2.0",
36
+ "publishConfig": {
37
+ "access": "public"
38
+ },
39
+ "dependencies": {
40
+ "@cloudbase/adapter-interface": "^0.7.1"
41
+ },
42
+ "gitHead": "859557576897d4778857c12fb8d7fe8ca1f3a052"
43
+ }