@cloudbase/oauth 0.1.1-alpha → 0.1.1-alpha.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.
Files changed (332) hide show
  1. package/Dockerfile +15 -0
  2. package/README.md +1 -1
  3. package/_exmaple/assets/scripts/function/function.ts +99 -0
  4. package/_exmaple/assets/scripts/index.ts +99 -0
  5. package/_exmaple/assets/scripts/request.ts +11 -0
  6. package/_exmaple/index.html +15 -0
  7. package/_exmaple/package.json +33 -0
  8. package/_exmaple/tsconfig.json +71 -0
  9. package/_exmaple/typings.d.ts +0 -0
  10. package/_exmaple/webpack.config.js +42 -0
  11. package/cdnjs/1.0.0/cloudbase.auth.js +1 -0
  12. package/cdnjs/1.0.0/cloudbase.database.js +8 -0
  13. package/cdnjs/1.0.0/cloudbase.full.js +8 -0
  14. package/cdnjs/1.0.0/cloudbase.functions.js +1 -0
  15. package/cdnjs/1.0.0/cloudbase.js +1 -0
  16. package/cdnjs/1.0.0/cloudbase.storage.js +1 -0
  17. package/cdnjs/1.0.1/cloudbase.auth.js +1 -0
  18. package/cdnjs/1.0.1/cloudbase.database.js +8 -0
  19. package/cdnjs/1.0.1/cloudbase.full.js +8 -0
  20. package/cdnjs/1.0.1/cloudbase.functions.js +1 -0
  21. package/cdnjs/1.0.1/cloudbase.js +1 -0
  22. package/cdnjs/1.0.1/cloudbase.storage.js +1 -0
  23. package/cdnjs/1.0.2/cloudbase.auth.js +1 -0
  24. package/cdnjs/1.0.2/cloudbase.database.js +8 -0
  25. package/cdnjs/1.0.2/cloudbase.full.js +8 -0
  26. package/cdnjs/1.0.2/cloudbase.functions.js +1 -0
  27. package/cdnjs/1.0.2/cloudbase.js +1 -0
  28. package/cdnjs/1.0.2/cloudbase.storage.js +1 -0
  29. package/cdnjs/1.0.3/cloudbase.auth.js +1 -0
  30. package/cdnjs/1.0.3/cloudbase.database.js +8 -0
  31. package/cdnjs/1.0.3/cloudbase.full.js +8 -0
  32. package/cdnjs/1.0.3/cloudbase.functions.js +1 -0
  33. package/cdnjs/1.0.3/cloudbase.js +1 -0
  34. package/cdnjs/1.0.3/cloudbase.storage.js +1 -0
  35. package/cdnjs/1.0.4/cloudbase.auth.js +1 -0
  36. package/cdnjs/1.0.4/cloudbase.database.js +8 -0
  37. package/cdnjs/1.0.4/cloudbase.full.js +8 -0
  38. package/cdnjs/1.0.4/cloudbase.functions.js +1 -0
  39. package/cdnjs/1.0.4/cloudbase.js +1 -0
  40. package/cdnjs/1.0.4/cloudbase.storage.js +1 -0
  41. package/cdnjs/1.1.0/cloudbase.auth.js +1 -0
  42. package/cdnjs/1.1.0/cloudbase.database.js +8 -0
  43. package/cdnjs/1.1.0/cloudbase.full.js +8 -0
  44. package/cdnjs/1.1.0/cloudbase.functions.js +1 -0
  45. package/cdnjs/1.1.0/cloudbase.js +1 -0
  46. package/cdnjs/1.1.0/cloudbase.storage.js +1 -0
  47. package/cdnjs/1.1.1/cloudbase.auth.js +1 -0
  48. package/cdnjs/1.1.1/cloudbase.database.js +8 -0
  49. package/cdnjs/1.1.1/cloudbase.full.js +8 -0
  50. package/cdnjs/1.1.1/cloudbase.functions.js +1 -0
  51. package/cdnjs/1.1.1/cloudbase.js +1 -0
  52. package/cdnjs/1.1.1/cloudbase.storage.js +1 -0
  53. package/cdnjs/1.1.2/cloudbase.auth.js +1 -0
  54. package/cdnjs/1.1.2/cloudbase.database.js +8 -0
  55. package/cdnjs/1.1.2/cloudbase.full.js +8 -0
  56. package/cdnjs/1.1.2/cloudbase.functions.js +1 -0
  57. package/cdnjs/1.1.2/cloudbase.js +1 -0
  58. package/cdnjs/1.1.2/cloudbase.storage.js +1 -0
  59. package/cdnjs/1.1.3/cloudbase.auth.js +1 -0
  60. package/cdnjs/1.1.3/cloudbase.database.js +8 -0
  61. package/cdnjs/1.1.3/cloudbase.full.js +8 -0
  62. package/cdnjs/1.1.3/cloudbase.functions.js +1 -0
  63. package/cdnjs/1.1.3/cloudbase.js +1 -0
  64. package/cdnjs/1.1.3/cloudbase.storage.js +1 -0
  65. package/cdnjs/1.1.4/cloudbase.auth.js +1 -0
  66. package/cdnjs/1.1.4/cloudbase.database.js +8 -0
  67. package/cdnjs/1.1.4/cloudbase.full.js +8 -0
  68. package/cdnjs/1.1.4/cloudbase.functions.js +1 -0
  69. package/cdnjs/1.1.4/cloudbase.js +1 -0
  70. package/cdnjs/1.1.4/cloudbase.storage.js +1 -0
  71. package/cdnjs/1.2.1/cloudbase.auth.js +1 -0
  72. package/cdnjs/1.2.1/cloudbase.database.js +8 -0
  73. package/cdnjs/1.2.1/cloudbase.full.js +8 -0
  74. package/cdnjs/1.2.1/cloudbase.functions.js +1 -0
  75. package/cdnjs/1.2.1/cloudbase.js +1 -0
  76. package/cdnjs/1.2.1/cloudbase.storage.js +1 -0
  77. package/cdnjs/1.2.2/cloudbase.auth.js +1 -0
  78. package/cdnjs/1.2.2/cloudbase.database.js +8 -0
  79. package/cdnjs/1.2.2/cloudbase.full.js +8 -0
  80. package/cdnjs/1.2.2/cloudbase.functions.js +1 -0
  81. package/cdnjs/1.2.2/cloudbase.js +1 -0
  82. package/cdnjs/1.2.2/cloudbase.storage.js +1 -0
  83. package/cdnjs/1.2.3/cloudbase.auth.js +1 -0
  84. package/cdnjs/1.2.3/cloudbase.database.js +8 -0
  85. package/cdnjs/1.2.3/cloudbase.full.js +8 -0
  86. package/cdnjs/1.2.3/cloudbase.functions.js +1 -0
  87. package/cdnjs/1.2.3/cloudbase.js +1 -0
  88. package/cdnjs/1.2.3/cloudbase.storage.js +1 -0
  89. package/cdnjs/1.3.0/cloudbase.auth.js +1 -0
  90. package/cdnjs/1.3.0/cloudbase.database.js +8 -0
  91. package/cdnjs/1.3.0/cloudbase.full.js +8 -0
  92. package/cdnjs/1.3.0/cloudbase.functions.js +1 -0
  93. package/cdnjs/1.3.0/cloudbase.js +1 -0
  94. package/cdnjs/1.3.0/cloudbase.realtime.js +1 -0
  95. package/cdnjs/1.3.0/cloudbase.storage.js +1 -0
  96. package/cdnjs/1.3.1/cloudbase.auth.js +1 -0
  97. package/cdnjs/1.3.1/cloudbase.database.js +8 -0
  98. package/cdnjs/1.3.1/cloudbase.full.js +8 -0
  99. package/cdnjs/1.3.1/cloudbase.functions.js +1 -0
  100. package/cdnjs/1.3.1/cloudbase.js +1 -0
  101. package/cdnjs/1.3.1/cloudbase.realtime.js +1 -0
  102. package/cdnjs/1.3.1/cloudbase.storage.js +1 -0
  103. package/cdnjs/1.3.2/cloudbase.auth.js +1 -0
  104. package/cdnjs/1.3.2/cloudbase.database.js +8 -0
  105. package/cdnjs/1.3.2/cloudbase.full.js +8 -0
  106. package/cdnjs/1.3.2/cloudbase.functions.js +1 -0
  107. package/cdnjs/1.3.2/cloudbase.js +1 -0
  108. package/cdnjs/1.3.2/cloudbase.realtime.js +1 -0
  109. package/cdnjs/1.3.2/cloudbase.storage.js +1 -0
  110. package/cdnjs/1.3.3/cloudbase.auth.js +1 -0
  111. package/cdnjs/1.3.3/cloudbase.database.js +8 -0
  112. package/cdnjs/1.3.3/cloudbase.full.js +8 -0
  113. package/cdnjs/1.3.3/cloudbase.functions.js +1 -0
  114. package/cdnjs/1.3.3/cloudbase.js +1 -0
  115. package/cdnjs/1.3.3/cloudbase.realtime.js +1 -0
  116. package/cdnjs/1.3.3/cloudbase.storage.js +1 -0
  117. package/cdnjs/1.3.4-alpha.0/cloudbase.auth.js +1 -0
  118. package/cdnjs/1.3.4-alpha.0/cloudbase.database.js +8 -0
  119. package/cdnjs/1.3.4-alpha.0/cloudbase.full.js +8 -0
  120. package/cdnjs/1.3.4-alpha.0/cloudbase.functions.js +1 -0
  121. package/cdnjs/1.3.4-alpha.0/cloudbase.js +1 -0
  122. package/cdnjs/1.3.4-alpha.0/cloudbase.realtime.js +1 -0
  123. package/cdnjs/1.3.4-alpha.0/cloudbase.storage.js +1 -0
  124. package/cdnjs/1.3.5/cloudbase.analytics.js +1 -0
  125. package/cdnjs/1.3.5/cloudbase.auth.js +1 -0
  126. package/cdnjs/1.3.5/cloudbase.database.js +10 -0
  127. package/cdnjs/1.3.5/cloudbase.full.js +10 -0
  128. package/cdnjs/1.3.5/cloudbase.functions.js +1 -0
  129. package/cdnjs/1.3.5/cloudbase.js +1 -0
  130. package/cdnjs/1.3.5/cloudbase.realtime.js +1 -0
  131. package/cdnjs/1.3.5/cloudbase.storage.js +1 -0
  132. package/cdnjs/1.3.5-alpha.0/cloudbase.auth.js +1 -0
  133. package/cdnjs/1.3.5-alpha.0/cloudbase.database.js +10 -0
  134. package/cdnjs/1.3.5-alpha.0/cloudbase.full.js +10 -0
  135. package/cdnjs/1.3.5-alpha.0/cloudbase.functions.js +1 -0
  136. package/cdnjs/1.3.5-alpha.0/cloudbase.js +1 -0
  137. package/cdnjs/1.3.5-alpha.0/cloudbase.realtime.js +1 -0
  138. package/cdnjs/1.3.5-alpha.0/cloudbase.storage.js +1 -0
  139. package/cdnjs/1.4.0/cloudbase.analytics.js +1 -0
  140. package/cdnjs/1.4.0/cloudbase.auth.js +1 -0
  141. package/cdnjs/1.4.0/cloudbase.database.js +10 -0
  142. package/cdnjs/1.4.0/cloudbase.full.js +10 -0
  143. package/cdnjs/1.4.0/cloudbase.functions.js +1 -0
  144. package/cdnjs/1.4.0/cloudbase.js +1 -0
  145. package/cdnjs/1.4.0/cloudbase.realtime.js +1 -0
  146. package/cdnjs/1.4.0/cloudbase.storage.js +1 -0
  147. package/cdnjs/1.4.1/cloudbase.analytics.js +1 -0
  148. package/cdnjs/1.4.1/cloudbase.auth.js +1 -0
  149. package/cdnjs/1.4.1/cloudbase.database.js +10 -0
  150. package/cdnjs/1.4.1/cloudbase.full.js +10 -0
  151. package/cdnjs/1.4.1/cloudbase.functions.js +1 -0
  152. package/cdnjs/1.4.1/cloudbase.js +1 -0
  153. package/cdnjs/1.4.1/cloudbase.realtime.js +1 -0
  154. package/cdnjs/1.4.1/cloudbase.storage.js +1 -0
  155. package/cdnjs/1.4.1-alpha.0/cloudbase.analytics.js +1 -0
  156. package/cdnjs/1.4.1-alpha.0/cloudbase.auth.js +1 -0
  157. package/cdnjs/1.4.1-alpha.0/cloudbase.database.js +10 -0
  158. package/cdnjs/1.4.1-alpha.0/cloudbase.full.js +10 -0
  159. package/cdnjs/1.4.1-alpha.0/cloudbase.functions.js +1 -0
  160. package/cdnjs/1.4.1-alpha.0/cloudbase.js +1 -0
  161. package/cdnjs/1.4.1-alpha.0/cloudbase.realtime.js +1 -0
  162. package/cdnjs/1.4.1-alpha.0/cloudbase.storage.js +1 -0
  163. package/cdnjs/1.4.2-alpha.0/cloudbase.analytics.js +1 -0
  164. package/cdnjs/1.4.2-alpha.0/cloudbase.auth.js +1 -0
  165. package/cdnjs/1.4.2-alpha.0/cloudbase.database.js +10 -0
  166. package/cdnjs/1.4.2-alpha.0/cloudbase.full.js +10 -0
  167. package/cdnjs/1.4.2-alpha.0/cloudbase.functions.js +1 -0
  168. package/cdnjs/1.4.2-alpha.0/cloudbase.js +1 -0
  169. package/cdnjs/1.4.2-alpha.0/cloudbase.realtime.js +1 -0
  170. package/cdnjs/1.4.2-alpha.0/cloudbase.storage.js +1 -0
  171. package/cdnjs/1.5.0/cloudbase.analytics.js +1 -0
  172. package/cdnjs/1.5.0/cloudbase.auth.js +1 -0
  173. package/cdnjs/1.5.0/cloudbase.database.js +10 -0
  174. package/cdnjs/1.5.0/cloudbase.full.js +10 -0
  175. package/cdnjs/1.5.0/cloudbase.functions.js +1 -0
  176. package/cdnjs/1.5.0/cloudbase.js +1 -0
  177. package/cdnjs/1.5.0/cloudbase.realtime.js +1 -0
  178. package/cdnjs/1.5.0/cloudbase.storage.js +1 -0
  179. package/cdnjs/1.5.1/cloudbase.analytics.js +1 -0
  180. package/cdnjs/1.5.1/cloudbase.auth.js +1 -0
  181. package/cdnjs/1.5.1/cloudbase.database.js +26 -0
  182. package/cdnjs/1.5.1/cloudbase.full.js +26 -0
  183. package/cdnjs/1.5.1/cloudbase.functions.js +1 -0
  184. package/cdnjs/1.5.1/cloudbase.js +1 -0
  185. package/cdnjs/1.5.1/cloudbase.realtime.js +1 -0
  186. package/cdnjs/1.5.1/cloudbase.storage.js +1 -0
  187. package/cdnjs/1.5.1-alpha.0/cloudbase.analytics.js +1 -0
  188. package/cdnjs/1.5.1-alpha.0/cloudbase.auth.js +1 -0
  189. package/cdnjs/1.5.1-alpha.0/cloudbase.database.js +10 -0
  190. package/cdnjs/1.5.1-alpha.0/cloudbase.full.js +10 -0
  191. package/cdnjs/1.5.1-alpha.0/cloudbase.functions.js +1 -0
  192. package/cdnjs/1.5.1-alpha.0/cloudbase.js +1 -0
  193. package/cdnjs/1.5.1-alpha.0/cloudbase.realtime.js +1 -0
  194. package/cdnjs/1.5.1-alpha.0/cloudbase.storage.js +1 -0
  195. package/cdnjs/1.5.3-alpha.0/cloudbase.analytics.js +1 -0
  196. package/cdnjs/1.5.3-alpha.0/cloudbase.auth.js +1 -0
  197. package/cdnjs/1.5.3-alpha.0/cloudbase.database.js +26 -0
  198. package/cdnjs/1.5.3-alpha.0/cloudbase.full.js +26 -0
  199. package/cdnjs/1.5.3-alpha.0/cloudbase.functions.js +1 -0
  200. package/cdnjs/1.5.3-alpha.0/cloudbase.js +1 -0
  201. package/cdnjs/1.5.3-alpha.0/cloudbase.realtime.js +1 -0
  202. package/cdnjs/1.5.3-alpha.0/cloudbase.storage.js +1 -0
  203. package/cdnjs/1.6.0/cloudbase.analytics.js +1 -0
  204. package/cdnjs/1.6.0/cloudbase.auth.js +1 -0
  205. package/cdnjs/1.6.0/cloudbase.database.js +26 -0
  206. package/cdnjs/1.6.0/cloudbase.full.js +26 -0
  207. package/cdnjs/1.6.0/cloudbase.functions.js +1 -0
  208. package/cdnjs/1.6.0/cloudbase.js +1 -0
  209. package/cdnjs/1.6.0/cloudbase.realtime.js +1 -0
  210. package/cdnjs/1.6.0/cloudbase.storage.js +1 -0
  211. package/{CHANGELOG.md → changelog.md} +0 -0
  212. package/dist/README.md +153 -0
  213. package/{app → dist/app}/index.d.ts +1 -0
  214. package/{app → dist/app}/index.js +0 -0
  215. package/dist/app/index.js.map +1 -0
  216. package/{app → dist/app}/internal.d.ts +0 -0
  217. package/{app → dist/app}/internal.js +0 -0
  218. package/{app → dist/app}/internal.js.map +0 -0
  219. package/{app → dist/app}/openuri.d.ts +0 -0
  220. package/{app → dist/app}/openuri.js +2 -1
  221. package/{app → dist/app}/openuri.js.map +1 -1
  222. package/{app → dist/app}/request.d.ts +4 -3
  223. package/{app → dist/app}/request.js +20 -12
  224. package/dist/app/request.js.map +1 -0
  225. package/{app → dist/app}/storage.d.ts +0 -0
  226. package/{app → dist/app}/storage.js +0 -0
  227. package/{app → dist/app}/storage.js.map +0 -0
  228. package/{auth → dist/auth}/consts.d.ts +21 -4
  229. package/{auth → dist/auth}/consts.js +27 -5
  230. package/dist/auth/consts.js.map +1 -0
  231. package/{auth → dist/auth}/index.d.ts +83 -34
  232. package/{auth → dist/auth}/index.js +239 -92
  233. package/dist/auth/index.js.map +1 -0
  234. package/dist/auth/models.d.ts +284 -0
  235. package/{oauthclient → dist/auth}/models.js +1 -0
  236. package/dist/auth/models.js.map +1 -0
  237. package/{captcha → dist/captcha}/index.d.ts +0 -0
  238. package/{captcha → dist/captcha}/index.js +4 -2
  239. package/dist/captcha/index.js.map +1 -0
  240. package/dist/changelog.md +30 -0
  241. package/dist/function/index.d.ts +38 -0
  242. package/dist/function/index.js +80 -0
  243. package/dist/function/index.js.map +1 -0
  244. package/dist/index.d.ts +14 -0
  245. package/dist/index.js +24 -0
  246. package/dist/index.js.map +1 -0
  247. package/{oauthclient → dist/oauthclient}/consts.d.ts +0 -0
  248. package/{oauthclient → dist/oauthclient}/consts.js +0 -0
  249. package/{oauthclient → dist/oauthclient}/consts.js.map +0 -0
  250. package/{oauthclient → dist/oauthclient}/index.d.ts +0 -0
  251. package/{oauthclient → dist/oauthclient}/index.js +2 -2
  252. package/dist/oauthclient/index.js.map +1 -0
  253. package/{oauthclient → dist/oauthclient}/interface.d.ts +4 -0
  254. package/{oauthclient → dist/oauthclient}/interface.js +0 -0
  255. package/{oauthclient → dist/oauthclient}/interface.js.map +1 -1
  256. package/{oauthclient → dist/oauthclient}/models.d.ts +12 -11
  257. package/{auth → dist/oauthclient}/models.js +0 -0
  258. package/{oauthclient → dist/oauthclient}/models.js.map +0 -0
  259. package/{oauthclient → dist/oauthclient}/oauthclient.d.ts +11 -7
  260. package/{oauthclient → dist/oauthclient}/oauthclient.js +27 -12
  261. package/dist/oauthclient/oauthclient.js.map +1 -0
  262. package/dist/package.json +32 -0
  263. package/{utils/single-promise.d.ts → dist/utils/promise.d.ts} +3 -3
  264. package/{utils/single-promise.js → dist/utils/promise.js} +6 -6
  265. package/dist/utils/promise.js.map +1 -0
  266. package/{utils → dist/utils}/uuid.d.ts +0 -0
  267. package/{utils → dist/utils}/uuid.js +0 -0
  268. package/{utils → dist/utils}/uuid.js.map +0 -0
  269. package/docs/dev.md +71 -0
  270. package/docs/errlog.md +79 -0
  271. package/package.json +3 -2
  272. package/publish.sh +2 -0
  273. package/src/app/index.ts +83 -0
  274. package/src/app/internal.ts +26 -0
  275. package/src/app/openuri.ts +111 -0
  276. package/src/app/request.ts +66 -0
  277. package/src/app/storage.ts +58 -0
  278. package/src/auth/consts.ts +74 -0
  279. package/src/auth/index.ts +718 -0
  280. package/src/auth/models.ts +352 -0
  281. package/src/captcha/index.ts +170 -0
  282. package/src/function/index.ts +103 -0
  283. package/src/index.ts +32 -0
  284. package/src/oauthclient/consts.ts +48 -0
  285. package/src/oauthclient/index.ts +33 -0
  286. package/src/oauthclient/interface.ts +34 -0
  287. package/src/oauthclient/models.ts +50 -0
  288. package/src/oauthclient/oauthclient.ts +487 -0
  289. package/src/utils/promise.ts +41 -0
  290. package/src/utils/uuid.ts +11 -0
  291. package/test/e2e/cases/custom-login.test.js +122 -0
  292. package/test/e2e/cases/index.test.js +61 -0
  293. package/test/e2e/cases/login-state.test.js +89 -0
  294. package/test/e2e/environment.js +39 -0
  295. package/test/e2e/global_setup.js +33 -0
  296. package/test/e2e/global_teardown.js +15 -0
  297. package/test/e2e/setup.js +37 -0
  298. package/test/unit/index.test.js +89 -0
  299. package/test/web/cases/auth/index.js +256 -0
  300. package/test/web/cases/database/collection.js +173 -0
  301. package/test/web/cases/database/command.js +754 -0
  302. package/test/web/cases/database/date.js +122 -0
  303. package/test/web/cases/database/db.js +20 -0
  304. package/test/web/cases/database/document.js +160 -0
  305. package/test/web/cases/database/geo-advanced.js +327 -0
  306. package/test/web/cases/database/geo.js +105 -0
  307. package/test/web/cases/database/index.js +315 -0
  308. package/test/web/cases/database/order.js +83 -0
  309. package/test/web/cases/database/realtime.js +102 -0
  310. package/test/web/cases/database/regex.js +140 -0
  311. package/test/web/cases/ext/index.js +88 -0
  312. package/test/web/cases/function/index.js +77 -0
  313. package/test/web/cases/storage/cos.jpeg +0 -0
  314. package/test/web/cases/storage/index.js +207 -0
  315. package/test/web/index.html +63 -0
  316. package/test/web/index.js +109 -0
  317. package/test/web/util.js +80 -0
  318. package/tsconfig.json +35 -0
  319. package/wiki/README.md +75 -0
  320. package/app/index.js.map +0 -1
  321. package/app/request.js.map +0 -1
  322. package/auth/consts.js.map +0 -1
  323. package/auth/index.js.map +0 -1
  324. package/auth/models.d.ts +0 -158
  325. package/auth/models.js.map +0 -1
  326. package/captcha/index.js.map +0 -1
  327. package/index.d.ts +0 -8
  328. package/index.js +0 -17
  329. package/index.js.map +0 -1
  330. package/oauthclient/index.js.map +0 -1
  331. package/oauthclient/oauthclient.js.map +0 -1
  332. package/utils/single-promise.js.map +0 -1
@@ -0,0 +1,140 @@
1
+ // database regex
2
+ import * as assert from 'power-assert';
3
+ import { catchCallback, isSuccess, callbackWithTryCatch } from '../../util';
4
+ import { registerCase } from '.';
5
+
6
+ export function registerRegex(app, collName) {
7
+ const db = app.database();
8
+ const collection = db.collection(collName);
9
+ // const nameList = ["f", "b", "e", "d", "a", "c"];
10
+
11
+ const initialData = {
12
+ name: 'AbCdEfxxxxxxxxxxxxxx1234结尾',
13
+ array: [1, 2, 3, [4, 5, 6], { a: 1, b: { c: 'fjasklfljkas', d: false }}],
14
+ deepObject: {
15
+ 'l-02-01': {
16
+ 'l-03-01': {
17
+ 'l-04-01': {
18
+ level: 1,
19
+ name: 'l-01',
20
+ flag: '0'
21
+ }
22
+ }
23
+ }
24
+ }
25
+ };
26
+ registerCase('database regex: Document - CRUD', async () => {
27
+ await new Promise(async resolve => {
28
+ try {
29
+ // Create
30
+ let res = await collection.add(initialData).catch(callbackWithTryCatch(err => {
31
+ assert(false, { err });
32
+ }, () => {
33
+ resolve();
34
+ }));
35
+ assert(isSuccess(0, res) && res.id, { res });
36
+
37
+ // Read
38
+
39
+ // // 直接使用正则表达式
40
+ res = await collection
41
+ .where({
42
+ name: /^abcdef.*\d+结尾$/i
43
+ })
44
+ .get().catch(callbackWithTryCatch(err => {
45
+ assert(false, { err });
46
+ }, () => {
47
+ resolve();
48
+ }));
49
+ assert(res.data.length > 0, { res });
50
+
51
+ // new db.RegExp
52
+ res = await collection
53
+ .where({
54
+ name: new db.RegExp({
55
+ regexp: '^abcdef.*\\d+结尾$',
56
+ options: 'i'
57
+ })
58
+ })
59
+ .get().catch(callbackWithTryCatch(err => {
60
+ assert(false, { err });
61
+ }, () => {
62
+ resolve();
63
+ }));
64
+ assert(res.data.length > 0, { res });
65
+
66
+ // db.RegExp
67
+ res = await collection
68
+ .where({
69
+ name: db.RegExp({
70
+ regexp: '^abcdef.*\\d+结尾$',
71
+ options: 'i'
72
+ })
73
+ })
74
+ .get().catch(callbackWithTryCatch(err => {
75
+ assert(false, { err });
76
+ }, () => {
77
+ resolve();
78
+ }));
79
+ assert(res.data.length > 0, { res });
80
+
81
+ // // Update(TODO)
82
+ res = await collection
83
+ .where({
84
+ name: db.command.or(new db.RegExp({
85
+ regexp: '^abcdef.*\\d+结尾$',
86
+ options: 'i'
87
+ }), db.RegExp({
88
+ regexp: '^fffffff$',
89
+ options: 'i'
90
+ }))
91
+ })
92
+ .get().catch(callbackWithTryCatch(err => {
93
+ assert(false, { err });
94
+ }, () => {
95
+ resolve();
96
+ }));
97
+ assert(res.data.length > 0, { res });
98
+
99
+ // Update(TODO)
100
+ res = await collection
101
+ .where({
102
+ name: db.command.or(db.RegExp({
103
+ regexp: '^abcdef.*\\d+结尾$',
104
+ options: 'i'
105
+ }), db.RegExp({
106
+ regexp: '^fffffff$',
107
+ options: 'i'
108
+ }))
109
+ })
110
+ .update({
111
+ name: 'ABCDEFxxxx5678结尾'
112
+ }).catch(callbackWithTryCatch(err => {
113
+ assert(false, { err });
114
+ }, () => {
115
+ resolve();
116
+ }));
117
+ assert(res.updated > 0, { res });
118
+
119
+ // Delete
120
+ const deleteRes = await collection
121
+ .where({
122
+ name: db.RegExp({
123
+ regexp: '^abcdef.*\\d+结尾$',
124
+ options: 'i'
125
+ })
126
+ })
127
+ .remove().catch(callbackWithTryCatch(err => {
128
+ assert(false, { err });
129
+ }, () => {
130
+ resolve();
131
+ }));
132
+ assert(deleteRes.deleted > 0, { res: deleteRes });
133
+ } catch (e) {
134
+ catchCallback(e);
135
+ } finally {
136
+ resolve();
137
+ }
138
+ });
139
+ });
140
+ }
@@ -0,0 +1,88 @@
1
+ // function
2
+ import { register } from '../../util';
3
+
4
+ const readFile = async function(file) {
5
+ let reader = new FileReader();
6
+
7
+ let res = await new Promise(resolve => {
8
+ reader.onload = function(e) {
9
+ let arrayBuffer = new Uint8Array(e.target.result);
10
+ resolve(arrayBuffer);
11
+ };
12
+
13
+ reader.readAsArrayBuffer(file);
14
+ });
15
+
16
+ return res;
17
+
18
+ };
19
+
20
+ export function test_ext_ci(app) {
21
+
22
+ register('ci WaterMark', async () => {
23
+ const ops = {
24
+ rules: [{
25
+ fileid: 'qr443.jpg',
26
+ // rule: 'QRcode/cover/0',
27
+ // rule: 'style/test_style'
28
+ rule: {
29
+ mode: 3,
30
+ type: 3,
31
+ text: '12345',
32
+ // image:'ab.png'
33
+ }
34
+ }]
35
+ };
36
+
37
+ let file = document.getElementById('selectFile').files[0];
38
+
39
+ let fileContent = await readFile(file);
40
+
41
+ const res = await app.invokeExtension('CloudInfinite', {
42
+ action: 'WaterMark',
43
+ cloudPath: 'nv_big_fe2.jpg',
44
+ fileContent,
45
+ operations: ops
46
+ });
47
+
48
+ console.log(JSON.stringify(res, null, 4));
49
+ });
50
+
51
+ register('ci ImageProcess', async () => {
52
+
53
+ const ops = {
54
+ rules: [{
55
+ // rule: 'QRcode/cover/0'
56
+ fileid: 'qr40.jpg',
57
+ rule: 'style/test_style'
58
+ }]
59
+ };
60
+
61
+ const res = await app.invokeExtension('CloudInfinite', {
62
+ cloudPath: 'nv_big.jpg',
63
+ action: 'ImageProcess',
64
+ operations: ops
65
+ });
66
+
67
+ console.log(JSON.stringify(res, null, 4));
68
+ });
69
+
70
+ register('ci DetectLabel', async () => {
71
+ const res = await app.invokeExtension('CloudInfinite', {
72
+ action: 'DetectLabel',
73
+ cloudPath: 'ab.png'
74
+ });
75
+
76
+ console.log(JSON.stringify(res, null, 4));
77
+ });
78
+
79
+ register('ci DetectType', async () => {
80
+ const res = await app.invokeExtension('CloudInfinite', {
81
+ action: 'DetectType',
82
+ operations: { type: 'ads' },
83
+ cloudPath: 'ab.png'
84
+ });
85
+
86
+ console.log(JSON.stringify(res, null, 4));
87
+ });
88
+ }
@@ -0,0 +1,77 @@
1
+ // function cases
2
+ import * as assert from 'power-assert';
3
+ import { register, callbackWithTryCatch, isSuccess } from '../../util';
4
+
5
+ function registerCase(msg,fn){
6
+ register('function',msg,fn);
7
+ }
8
+
9
+ export function registerFunctionCases(app) {
10
+ registerCase('function: callFunction in callback parse and query', async () => {
11
+ const data = {
12
+ 'key1': '1',
13
+ 'key2': '2',
14
+ 'userInfo': {
15
+ 'openId': 'ojiig0eH8cPwLHlPym--FUE0Lp_g',
16
+ 'appId': 'wx388a2dcdc79c3238'
17
+
18
+ }
19
+ };
20
+ await new Promise(resolve => {
21
+ app.callFunction(
22
+ {
23
+ name: 'test',
24
+ data,
25
+ parse: true,
26
+ query: {
27
+ env: 'test',
28
+ action: 'call_function',
29
+ field: '中文'
30
+ },
31
+ search: '&exxxxxx'
32
+ },
33
+ callbackWithTryCatch(
34
+ (err, res) => {
35
+ assert(isSuccess(err, res), {
36
+ err,
37
+ res
38
+ });
39
+ },
40
+ () => {
41
+ resolve();
42
+ }
43
+ )
44
+ );
45
+ });
46
+ });
47
+
48
+ registerCase('function: callFunction in callback', async () => {
49
+ const data = {
50
+ 'key1': '1',
51
+ 'key2': '2',
52
+ 'userInfo': {
53
+ 'openId': 'ojiig0eH8cPwLHlPym--FUE0Lp_g',
54
+ 'appId': 'wx388a2dcdc79c3238'
55
+
56
+ }
57
+ };
58
+ await new Promise(resolve => {
59
+ app.callFunction({ name: 'test', data }, callbackWithTryCatch((err, res) => {
60
+ assert(isSuccess(err, res), {
61
+ err,
62
+ res
63
+ });
64
+ }, () => {
65
+ resolve();
66
+ }));
67
+ });
68
+ });
69
+
70
+ registerCase('function: callFunction in promise', async () => {
71
+ await app.callFunction({ name: 'test', data: { hello: 'world' }}).then(callbackWithTryCatch((res) => {
72
+ assert(isSuccess(0, res), { res });
73
+ })).catch(callbackWithTryCatch((err) => {
74
+ assert(false, { err });
75
+ }));
76
+ });
77
+ }
Binary file
@@ -0,0 +1,207 @@
1
+ // storage cases
2
+ import * as assert from 'power-assert';
3
+ import { callbackWithTryCatch, catchCallback, isSuccess, register, printInfo } from '../../util';
4
+
5
+ window['fileIdList'] = [];
6
+
7
+ // const $el_input_file = document.getElementById('file');
8
+
9
+ function registerCase(msg,fn){
10
+ register('storage',msg,fn);
11
+ }
12
+
13
+ export function registerStorageCases(app) {
14
+ let file = new File(['foo'], 'foo.txt', {
15
+ type: 'text/plain',
16
+ });
17
+
18
+ registerCase('storage: uploadFile, getTempFileURL, downloadFile and deleteFile with callback', async () => {
19
+ await new Promise(resolve => {
20
+ app.uploadFile({
21
+ filePath: file,
22
+ cloudPath: 'test'+Date.now(),
23
+ onUploadProgress: (progressEvent) => {
24
+ let percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total);
25
+ printInfo('uploadFile progress: ' + percentCompleted, progressEvent);
26
+ }
27
+ }, async (err, res) => {
28
+ try {
29
+ assert(isSuccess(err, res) && res.fileID, { err, res });
30
+
31
+ let fileId = res.fileID;
32
+
33
+ await Promise.all([
34
+ new Promise(resolve1 => {
35
+ app.getTempFileURL({ fileList: [fileId] }, callbackWithTryCatch((err, res) => {
36
+ assert(isSuccess(err, res) && res.fileList, { err, res });
37
+ }, () => {
38
+ resolve1();
39
+ }));
40
+ }),
41
+ //TODO 下载的实现未确定
42
+ /*new Promise(resolve2 => {
43
+ app.downloadFile({ fileId }, callbackWithTryCatch((err, res) => {
44
+ assert(isSuccess(err, res), { err, res });
45
+ }, () => {
46
+ resolve2();
47
+ }));
48
+ })*/
49
+ ]);
50
+
51
+ app.deleteFile({ fileList: [fileId] }, callbackWithTryCatch((err, res) => {
52
+ assert(isSuccess(err, res) && res.fileList.every(ret => ret.code === 'SUCCESS'), { err, res });
53
+ }));
54
+ } catch (e) {
55
+ catchCallback(e);
56
+ } finally {
57
+ resolve();
58
+ }
59
+ });
60
+ });
61
+ });
62
+
63
+ registerCase('storage: uploadFile, getTempFileURL, downloadFile and deleteFile with promise', async () => {
64
+ await new Promise(async resolve => {
65
+ await app.uploadFile({
66
+ filePath: file,
67
+ cloudPath: 'test'+Date.now(),
68
+ onUploadProgress: (progressEvent) => {
69
+ let percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total);
70
+ printInfo('uploadFile progress: ' + percentCompleted, progressEvent);
71
+ }
72
+ }).then(async res => {
73
+ try {
74
+ assert(isSuccess(0, res) && res.fileID, { res });
75
+
76
+ let fileId = res.fileID;
77
+
78
+ await Promise.all([
79
+ new Promise(resolve1 => {
80
+ app.getTempFileURL({ fileList: [fileId] },callbackWithTryCatch((err,res) => {
81
+ assert(isSuccess(err, res) && res.fileList, { res });
82
+ }, () => {
83
+ resolve1();
84
+ }))
85
+ }),
86
+ //TODO 下载的实现未确定
87
+ /*new Promise(resolve2 => {
88
+ app.downloadFile({ fileId }).then(callbackWithTryCatch(res => {
89
+ assert(isSuccess(0, res), { res });
90
+ }, () => {
91
+ resolve2();
92
+ })).catch(callbackWithTryCatch(err => {
93
+ assert(false, { err });
94
+ }, () => {
95
+ resolve2();
96
+ }));
97
+ })*/
98
+ ]);
99
+
100
+ app.deleteFile({ fileList: [fileId] }).then(callbackWithTryCatch(res => {
101
+ assert(isSuccess(0, res) && res.fileList.every(ret => ret.code === 'SUCCESS'), { res });
102
+ })).catch(callbackWithTryCatch(err => {
103
+ assert(false && res.fileList, { err });
104
+ }));
105
+ } catch (e) {
106
+ catchCallback(e);
107
+ } finally {
108
+ resolve();
109
+ }
110
+ }).catch(callbackWithTryCatch((err) => {
111
+ assert(false, { err });
112
+ }, () => {
113
+ resolve();
114
+ }));
115
+ });
116
+ });
117
+
118
+ registerCase('storage(manual select file): uploadFile, getTempFileURL, downloadFile and deleteFile with callback', async () => {
119
+ await new Promise(resolve => {
120
+ const fileInput = document.getElementById('selectFile');
121
+ const file = fileInput.files[0];
122
+ if (!file) {
123
+ assert(false, 'Please select file first');
124
+ }
125
+ app.uploadFile({
126
+ filePath: file,
127
+ cloudPath: file.name,
128
+ onUploadProgress: (progressEvent) => {
129
+ let percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total);
130
+ printInfo('uploadFile progress: ' + percentCompleted, progressEvent);
131
+ }
132
+ }, async (err, res) => {
133
+ try {
134
+ assert(isSuccess(err, res) && res.fileID, { err, res });
135
+
136
+ const fileId = res.fileID;
137
+
138
+ await Promise.all([
139
+ new Promise(resolve1 => {
140
+ app.getTempFileURL({ fileList: [fileId] }, callbackWithTryCatch((err, res) => {
141
+ assert(isSuccess(err, res) && res.fileList, { err, res });
142
+ }, () => {
143
+ resolve1();
144
+ }));
145
+ })
146
+ ]);
147
+
148
+ app.deleteFile({ fileList: [fileId] }, callbackWithTryCatch((err, res) => {
149
+ assert(isSuccess(err, res) && res.fileList.every(ret => ret.code === 'SUCCESS'), { err, res });
150
+ }));
151
+ } catch (e) {
152
+ catchCallback(e);
153
+ } finally {
154
+ resolve();
155
+ }
156
+ });
157
+ });
158
+ });
159
+
160
+ registerCase('storage(manual select file): uploadFile, getTempFileURL, downloadFile and deleteFile with promise', async () => {
161
+ await new Promise(async resolve => {
162
+ const fileInput = document.getElementById('selectFile');
163
+ const file = fileInput.files[0];
164
+ if (!file) {
165
+ assert(false, 'Please select file first');
166
+ }
167
+ await app.uploadFile({
168
+ filePath: file,
169
+ cloudPath: file.name,
170
+ onUploadProgress: (progressEvent) => {
171
+ let percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total);
172
+ printInfo('uploadFile progress: ' + percentCompleted, progressEvent);
173
+ }
174
+ }).then(async res => {
175
+ try {
176
+ assert(isSuccess(0, res) && res.fileID, { res });
177
+
178
+ const fileId = res.fileID;
179
+
180
+ await Promise.all([
181
+ new Promise(resolve1 => {
182
+ app.getTempFileURL({ fileList: [fileId] },callbackWithTryCatch((err,res) => {
183
+ assert(isSuccess(err, res) && res.fileList, { res });
184
+ }, () => {
185
+ resolve1();
186
+ }))
187
+ })
188
+ ]);
189
+
190
+ app.deleteFile({ fileList: [fileId] }).then(callbackWithTryCatch(res => {
191
+ assert(isSuccess(0, res) && res.fileList.every(ret => ret.code === 'SUCCESS'), { res });
192
+ })).catch(callbackWithTryCatch(err => {
193
+ assert(false && res.fileList, { err });
194
+ }));
195
+ } catch (e) {
196
+ catchCallback(e);
197
+ } finally {
198
+ resolve();
199
+ }
200
+ }).catch(callbackWithTryCatch((err) => {
201
+ assert(false, { err });
202
+ }, () => {
203
+ resolve();
204
+ }));
205
+ });
206
+ });
207
+ }
@@ -0,0 +1,63 @@
1
+ <!DOCTYPE html>
2
+ <html lang="zh-cn">
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5
+ <meta name="apple-mobile-web-app-capable" content="yes" />
6
+ <meta name="format-detection" content="telephone=no" />
7
+ <meta
8
+ name="viewport"
9
+ content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"
10
+ />
11
+ <meta content="telephone=no" name="format-detection" />
12
+ <title>Cloudbase 自动化测试页面</title>
13
+ </head>
14
+
15
+ <body>
16
+ <div>
17
+ <h4>Cloudbase 自动化测试页面</h4>
18
+ <p>
19
+ 本页面支持在微信环境中运行,支持自动化测试 初始化、存储、云函数、数据库
20
+ 功能。
21
+ </p>
22
+
23
+ <h5>测试用例</h5>
24
+ <select id="testCaseSelect" style="max-width: 100%;"></select>
25
+ <button id="runSelectedTestCase">执行选中用例</button>
26
+ <br>
27
+ <br>
28
+
29
+
30
+ <!-- <button id="mockAddDoc">增加</button> -->
31
+
32
+ <!--<select id="testCaseTypeSelect">
33
+ <option value="auth">初始化</option>
34
+ <option value="storage">存储</option>
35
+ <option value="function">云函数</option>
36
+ <option value="database">数据库</option>
37
+ </select>
38
+
39
+ <button id="runSelectedTestCaseType">执行选中类别的全部用例</button>-->
40
+
41
+ <button id="runAllTestCases">执行全部用例</button>
42
+ <input type="checkbox" id="include_auth"/>
43
+ <label for="include_auth">测试Auth</label>
44
+
45
+ <button id="mockAddDoc" style="visibility: hidden;">增加</button>
46
+
47
+ <h5>手动选择上传文件(storage测试必填)</h5>
48
+ <!-- 手动上传文件 -->
49
+ <input type="file" id="selectFile" name="avatar" accept="*">
50
+
51
+
52
+ <!-- <div id="output" class="container">
53
+
54
+ <p>操作结果请见console</p>
55
+ <div id="output" class="container"></div>
56
+ </div> -->
57
+
58
+ <script src="test.js"></script>
59
+ <!-- <script>
60
+ window["initIndex"]();
61
+ </script> -->
62
+ </body>
63
+ </html>
@@ -0,0 +1,109 @@
1
+ import axios from "axios"
2
+ import { env, appid, authUsername, authPassword } from "../../test.config.js"
3
+ import {
4
+ signInWeixin,
5
+ signInCustom,
6
+ signInAnonymous,
7
+ signInWithUsername,
8
+ registerAuthCases,
9
+ signInByPhone
10
+ } from "./cases/auth"
11
+ import { registerFunctionCases } from "./cases/function"
12
+ import { registerStorageCases } from "./cases/storage"
13
+ import { registerDatabaseCases } from "./cases/database"
14
+ import { runAllTestCases, runSelectedTestCase, printInfo } from "./util"
15
+
16
+ import cloudbase from "../../packages/cloudbase"
17
+ // import cloudbase from '../../packages/cloudbase/app';
18
+ // import '../../packages/cloudbase/auth';
19
+ // import '../../packages/cloudbase/database';
20
+ // import '../../packages/cloudbase/realtime';
21
+ // import { test_ext_ci } from './ext_ci';
22
+
23
+ // import * as extCi from '@cloudbase/extension-ci';
24
+
25
+ let app
26
+ let auth
27
+ let loginState
28
+ cloudbase.registerEndPoint("//tcb-pre.tencentcloudapi.com/web")
29
+ // cloudbase.registerEndPoint("//exp.ap-guangzhou.tcb-api.tencentcloudapi.com/web")
30
+ // cloudbase.registerEndPoint("//127.0.0.1:8002/web")
31
+
32
+ async function init() {
33
+ printInfo("web test starting init")
34
+ // 初始化
35
+ app = cloudbase.init({
36
+ env
37
+ // timeout: 150000
38
+ })
39
+
40
+ auth = app.auth({
41
+ persistence: "local"
42
+ })
43
+
44
+ // 公众号微信登录
45
+ // await signInWeixin(auth, appid);
46
+
47
+ // 匿名登录
48
+ await signInAnonymous(auth)
49
+
50
+ // 自定义登录
51
+ // await signInCustom(auth);
52
+
53
+ // 用户名登录
54
+ // await signInWithUsername(auth,{
55
+ // username: authUsername,
56
+ // password: authPassword
57
+ // });
58
+
59
+ // 短信验证码登录
60
+ // await signInByPhone(auth, '13024748409')
61
+ // await signInByPhone(auth, "18202741638")
62
+
63
+ registerFunctionCases(app)
64
+ registerStorageCases(app)
65
+ registerDatabaseCases(app)
66
+ // registerAnalytics(app);
67
+
68
+ initTestCasesIndex()
69
+
70
+ // 广告上报
71
+ // app.analytics({
72
+ // report_type: "mall",
73
+ // report_data: {
74
+ // action_time: new Date().getTime(),
75
+ // action_type: "visit_store"
76
+ // }
77
+ // })
78
+ }
79
+
80
+ /**
81
+ * 初始化用例菜单
82
+ */
83
+ export function initTestCasesIndex() {
84
+ const $el_select = document.getElementById("testCaseSelect")
85
+ const $el_run_selected = document.getElementById("runSelectedTestCase")
86
+ const $el_run_all = document.getElementById("runAllTestCases")
87
+ const $el_include_auth = document.getElementById("include_auth")
88
+
89
+ $el_run_selected.onclick = async function () {
90
+ const mod = $el_select.options[$el_select.selectedIndex].value
91
+ runSelectedTestCase(mod)
92
+ }
93
+
94
+ $el_run_all.onclick = async function () {
95
+ if ($el_include_auth.checked) {
96
+ !window.testCaseList.auth && (await registerAuthCases(auth))
97
+ } else {
98
+ delete window.testCaseList.auth
99
+ }
100
+ runAllTestCases()
101
+ }
102
+
103
+ let htmlStr = ""
104
+ for (const mod in window.testCaseList) {
105
+ htmlStr += `<option value="${mod}">${mod}</option>`
106
+ }
107
+ $el_select.innerHTML = htmlStr
108
+ }
109
+ init()