@dereekb/firebase-server 12.7.0 → 13.0.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.
Files changed (343) hide show
  1. package/LICENSE +1 -1
  2. package/index.cjs.default.js +1 -0
  3. package/index.cjs.js +2859 -0
  4. package/index.cjs.mjs +2 -0
  5. package/index.esm.js +2699 -0
  6. package/mailgun/index.cjs.default.js +1 -0
  7. package/mailgun/{src/lib/auth.mailgun.js → index.cjs.js} +6 -6
  8. package/mailgun/index.cjs.mjs +2 -0
  9. package/mailgun/index.esm.js +39 -0
  10. package/mailgun/package.json +20 -5
  11. package/model/index.cjs.default.js +1 -0
  12. package/model/index.cjs.js +4767 -0
  13. package/model/index.cjs.mjs +2 -0
  14. package/model/index.d.ts +1 -0
  15. package/model/index.esm.js +4630 -0
  16. package/model/package.json +28 -4
  17. package/model/src/lib/notification/notification.module.d.ts +10 -10
  18. package/model/src/lib/storagefile/storagefile.task.service.handler.d.ts +3 -14
  19. package/package.json +49 -47
  20. package/src/lib/auth/auth.context.d.ts +1 -1
  21. package/src/lib/auth/auth.service.d.ts +1 -1
  22. package/src/lib/function/assert.d.ts +2 -2
  23. package/src/lib/function/context.d.ts +1 -1
  24. package/src/lib/function/error.d.ts +0 -8
  25. package/src/lib/index.d.ts +1 -0
  26. package/src/lib/nest/app.d.ts +1 -1
  27. package/src/lib/nest/development/development.app.function.d.ts +1 -2
  28. package/src/lib/nest/function/call.d.ts +1 -1
  29. package/src/lib/nest/function/context.d.ts +0 -4
  30. package/src/lib/nest/function/index.d.ts +0 -1
  31. package/src/lib/nest/function/nest.d.ts +1 -1
  32. package/src/lib/nest/function/v2/blocking.d.ts +3 -2
  33. package/src/lib/nest/model/crud.assert.function.d.ts +0 -4
  34. package/src/lib/storage/storage.d.ts +1 -1
  35. package/src/lib/type.d.ts +9 -0
  36. package/test/index.cjs.default.js +1 -0
  37. package/test/index.cjs.js +1258 -0
  38. package/test/index.cjs.mjs +2 -0
  39. package/test/index.d.ts +1 -0
  40. package/test/index.esm.js +1181 -0
  41. package/test/package.json +31 -4
  42. package/test/src/lib/firebase/firebase.admin.auth.d.ts +22 -13
  43. package/test/src/lib/firebase/firebase.admin.collection.d.ts +6 -6
  44. package/test/src/lib/firebase/firebase.admin.d.ts +10 -10
  45. package/test/src/lib/firebase/firebase.admin.function.d.ts +9 -9
  46. package/test/src/lib/firebase/firebase.admin.nest.d.ts +8 -8
  47. package/test/src/lib/firebase/firebase.admin.nest.function.d.ts +9 -9
  48. package/test/src/lib/firebase/firebase.test.d.ts +30 -0
  49. package/test/src/lib/firebase/index.d.ts +1 -1
  50. package/test/src/lib/firestore/firestore.admin.d.ts +3 -3
  51. package/test/src/lib/firestore/firestore.d.ts +2 -2
  52. package/test/src/lib/storage/storage.admin.d.ts +3 -3
  53. package/test/src/lib/storage/storage.d.ts +2 -2
  54. package/zoho/LICENSE +1 -1
  55. package/zoho/index.cjs.default.js +1 -0
  56. package/zoho/index.cjs.js +82 -85
  57. package/zoho/index.cjs.mjs +2 -0
  58. package/zoho/index.d.ts +1 -0
  59. package/zoho/index.esm.js +84 -87
  60. package/zoho/package.json +15 -15
  61. package/CHANGELOG.md +0 -2237
  62. package/mailgun/src/index.js +0 -5
  63. package/mailgun/src/index.js.map +0 -1
  64. package/mailgun/src/lib/auth.mailgun.js.map +0 -1
  65. package/mailgun/src/lib/index.js +0 -5
  66. package/mailgun/src/lib/index.js.map +0 -1
  67. package/model/src/index.js +0 -5
  68. package/model/src/index.js.map +0 -1
  69. package/model/src/lib/index.js +0 -7
  70. package/model/src/lib/index.js.map +0 -1
  71. package/model/src/lib/mailgun/index.js +0 -5
  72. package/model/src/lib/mailgun/index.js.map +0 -1
  73. package/model/src/lib/mailgun/notification.send.service.mailgun.js +0 -68
  74. package/model/src/lib/mailgun/notification.send.service.mailgun.js.map +0 -1
  75. package/model/src/lib/notification/index.js +0 -20
  76. package/model/src/lib/notification/index.js.map +0 -1
  77. package/model/src/lib/notification/notification.action.init.service.js +0 -230
  78. package/model/src/lib/notification/notification.action.init.service.js.map +0 -1
  79. package/model/src/lib/notification/notification.action.service.js +0 -1487
  80. package/model/src/lib/notification/notification.action.service.js.map +0 -1
  81. package/model/src/lib/notification/notification.config.js +0 -13
  82. package/model/src/lib/notification/notification.config.js.map +0 -1
  83. package/model/src/lib/notification/notification.config.service.js +0 -60
  84. package/model/src/lib/notification/notification.config.service.js.map +0 -1
  85. package/model/src/lib/notification/notification.create.run.js +0 -59
  86. package/model/src/lib/notification/notification.create.run.js.map +0 -1
  87. package/model/src/lib/notification/notification.error.js +0 -87
  88. package/model/src/lib/notification/notification.error.js.map +0 -1
  89. package/model/src/lib/notification/notification.expedite.service.js +0 -112
  90. package/model/src/lib/notification/notification.expedite.service.js.map +0 -1
  91. package/model/src/lib/notification/notification.module.js +0 -106
  92. package/model/src/lib/notification/notification.module.js.map +0 -1
  93. package/model/src/lib/notification/notification.send.js +0 -3
  94. package/model/src/lib/notification/notification.send.js.map +0 -1
  95. package/model/src/lib/notification/notification.send.service.js +0 -10
  96. package/model/src/lib/notification/notification.send.service.js.map +0 -1
  97. package/model/src/lib/notification/notification.send.service.notificationsummary.js +0 -104
  98. package/model/src/lib/notification/notification.send.service.notificationsummary.js.map +0 -1
  99. package/model/src/lib/notification/notification.send.service.text.js +0 -29
  100. package/model/src/lib/notification/notification.send.service.text.js.map +0 -1
  101. package/model/src/lib/notification/notification.task.service.handler.js +0 -65
  102. package/model/src/lib/notification/notification.task.service.handler.js.map +0 -1
  103. package/model/src/lib/notification/notification.task.service.js +0 -10
  104. package/model/src/lib/notification/notification.task.service.js.map +0 -1
  105. package/model/src/lib/notification/notification.task.service.util.js +0 -27
  106. package/model/src/lib/notification/notification.task.service.util.js.map +0 -1
  107. package/model/src/lib/notification/notification.task.subtask.handler.js +0 -256
  108. package/model/src/lib/notification/notification.task.subtask.handler.js.map +0 -1
  109. package/model/src/lib/notification/notification.util.js +0 -478
  110. package/model/src/lib/notification/notification.util.js.map +0 -1
  111. package/model/src/lib/storagefile/index.js +0 -12
  112. package/model/src/lib/storagefile/index.js.map +0 -1
  113. package/model/src/lib/storagefile/storagefile.action.init.service.js +0 -155
  114. package/model/src/lib/storagefile/storagefile.action.init.service.js.map +0 -1
  115. package/model/src/lib/storagefile/storagefile.action.server.js +0 -797
  116. package/model/src/lib/storagefile/storagefile.action.server.js.map +0 -1
  117. package/model/src/lib/storagefile/storagefile.error.js +0 -106
  118. package/model/src/lib/storagefile/storagefile.error.js.map +0 -1
  119. package/model/src/lib/storagefile/storagefile.module.js +0 -64
  120. package/model/src/lib/storagefile/storagefile.module.js.map +0 -1
  121. package/model/src/lib/storagefile/storagefile.task.service.handler.js +0 -287
  122. package/model/src/lib/storagefile/storagefile.task.service.handler.js.map +0 -1
  123. package/model/src/lib/storagefile/storagefile.upload.service.initializer.js +0 -180
  124. package/model/src/lib/storagefile/storagefile.upload.service.initializer.js.map +0 -1
  125. package/model/src/lib/storagefile/storagefile.upload.service.js +0 -10
  126. package/model/src/lib/storagefile/storagefile.upload.service.js.map +0 -1
  127. package/model/src/lib/storagefile/storagefile.util.js +0 -54
  128. package/model/src/lib/storagefile/storagefile.util.js.map +0 -1
  129. package/src/index.js +0 -5
  130. package/src/index.js.map +0 -1
  131. package/src/lib/auth/auth.context.js +0 -13
  132. package/src/lib/auth/auth.context.js.map +0 -1
  133. package/src/lib/auth/auth.service.error.js +0 -34
  134. package/src/lib/auth/auth.service.error.js.map +0 -1
  135. package/src/lib/auth/auth.service.js +0 -427
  136. package/src/lib/auth/auth.service.js.map +0 -1
  137. package/src/lib/auth/auth.util.js +0 -23
  138. package/src/lib/auth/auth.util.js.map +0 -1
  139. package/src/lib/auth/index.js +0 -8
  140. package/src/lib/auth/index.js.map +0 -1
  141. package/src/lib/env/env.service.js +0 -7
  142. package/src/lib/env/env.service.js.map +0 -1
  143. package/src/lib/env/index.js +0 -5
  144. package/src/lib/env/index.js.map +0 -1
  145. package/src/lib/firestore/array.js +0 -34
  146. package/src/lib/firestore/array.js.map +0 -1
  147. package/src/lib/firestore/driver.accessor.batch.js +0 -93
  148. package/src/lib/firestore/driver.accessor.batch.js.map +0 -1
  149. package/src/lib/firestore/driver.accessor.default.js +0 -62
  150. package/src/lib/firestore/driver.accessor.default.js.map +0 -1
  151. package/src/lib/firestore/driver.accessor.js +0 -50
  152. package/src/lib/firestore/driver.accessor.js.map +0 -1
  153. package/src/lib/firestore/driver.accessor.transaction.js +0 -96
  154. package/src/lib/firestore/driver.accessor.transaction.js.map +0 -1
  155. package/src/lib/firestore/driver.js +0 -14
  156. package/src/lib/firestore/driver.js.map +0 -1
  157. package/src/lib/firestore/driver.query.js +0 -55
  158. package/src/lib/firestore/driver.query.js.map +0 -1
  159. package/src/lib/firestore/firestore.js +0 -10
  160. package/src/lib/firestore/firestore.js.map +0 -1
  161. package/src/lib/firestore/increment.js +0 -17
  162. package/src/lib/firestore/increment.js.map +0 -1
  163. package/src/lib/firestore/index.js +0 -9
  164. package/src/lib/firestore/index.js.map +0 -1
  165. package/src/lib/function/assert.js +0 -68
  166. package/src/lib/function/assert.js.map +0 -1
  167. package/src/lib/function/context.js +0 -14
  168. package/src/lib/function/context.js.map +0 -1
  169. package/src/lib/function/error.auth.js +0 -25
  170. package/src/lib/function/error.auth.js.map +0 -1
  171. package/src/lib/function/error.js +0 -221
  172. package/src/lib/function/error.js.map +0 -1
  173. package/src/lib/function/index.js +0 -9
  174. package/src/lib/function/index.js.map +0 -1
  175. package/src/lib/function/type.js +0 -3
  176. package/src/lib/function/type.js.map +0 -1
  177. package/src/lib/index.js +0 -11
  178. package/src/lib/index.js.map +0 -1
  179. package/src/lib/nest/app.js +0 -114
  180. package/src/lib/nest/app.js.map +0 -1
  181. package/src/lib/nest/auth/auth.module.js +0 -60
  182. package/src/lib/nest/auth/auth.module.js.map +0 -1
  183. package/src/lib/nest/auth/auth.util.js +0 -72
  184. package/src/lib/nest/auth/auth.util.js.map +0 -1
  185. package/src/lib/nest/auth/index.js +0 -6
  186. package/src/lib/nest/auth/index.js.map +0 -1
  187. package/src/lib/nest/development/development.app.function.js +0 -38
  188. package/src/lib/nest/development/development.app.function.js.map +0 -1
  189. package/src/lib/nest/development/development.assert.function.js +0 -3
  190. package/src/lib/nest/development/development.assert.function.js.map +0 -1
  191. package/src/lib/nest/development/development.function.js +0 -41
  192. package/src/lib/nest/development/development.function.js.map +0 -1
  193. package/src/lib/nest/development/development.schedule.function.error.js +0 -35
  194. package/src/lib/nest/development/development.schedule.function.error.js.map +0 -1
  195. package/src/lib/nest/development/development.schedule.function.js +0 -54
  196. package/src/lib/nest/development/development.schedule.function.js.map +0 -1
  197. package/src/lib/nest/development/index.js +0 -9
  198. package/src/lib/nest/development/index.js.map +0 -1
  199. package/src/lib/nest/env/env.service.js +0 -19
  200. package/src/lib/nest/env/env.service.js.map +0 -1
  201. package/src/lib/nest/env/env.util.js +0 -12
  202. package/src/lib/nest/env/env.util.js.map +0 -1
  203. package/src/lib/nest/env/index.js +0 -6
  204. package/src/lib/nest/env/index.js.map +0 -1
  205. package/src/lib/nest/firebase/firebase.module.js +0 -17
  206. package/src/lib/nest/firebase/firebase.module.js.map +0 -1
  207. package/src/lib/nest/firebase/index.js +0 -5
  208. package/src/lib/nest/firebase/index.js.map +0 -1
  209. package/src/lib/nest/firestore/firestore.module.js +0 -86
  210. package/src/lib/nest/firestore/firestore.module.js.map +0 -1
  211. package/src/lib/nest/firestore/index.js +0 -5
  212. package/src/lib/nest/firestore/index.js.map +0 -1
  213. package/src/lib/nest/function/call.js +0 -46
  214. package/src/lib/nest/function/call.js.map +0 -1
  215. package/src/lib/nest/function/context.js +0 -79
  216. package/src/lib/nest/function/context.js.map +0 -1
  217. package/src/lib/nest/function/index.js +0 -10
  218. package/src/lib/nest/function/index.js.map +0 -1
  219. package/src/lib/nest/function/nest.js +0 -17
  220. package/src/lib/nest/function/nest.js.map +0 -1
  221. package/src/lib/nest/function/schedule.js +0 -8
  222. package/src/lib/nest/function/schedule.js.map +0 -1
  223. package/src/lib/nest/function/v1/call.d.ts +0 -59
  224. package/src/lib/nest/function/v1/call.js +0 -55
  225. package/src/lib/nest/function/v1/call.js.map +0 -1
  226. package/src/lib/nest/function/v1/event.d.ts +0 -80
  227. package/src/lib/nest/function/v1/event.js +0 -52
  228. package/src/lib/nest/function/v1/event.js.map +0 -1
  229. package/src/lib/nest/function/v1/index.d.ts +0 -3
  230. package/src/lib/nest/function/v1/index.js +0 -7
  231. package/src/lib/nest/function/v1/index.js.map +0 -1
  232. package/src/lib/nest/function/v1/schedule.d.ts +0 -47
  233. package/src/lib/nest/function/v1/schedule.js +0 -68
  234. package/src/lib/nest/function/v1/schedule.js.map +0 -1
  235. package/src/lib/nest/function/v2/blocking.js +0 -38
  236. package/src/lib/nest/function/v2/blocking.js.map +0 -1
  237. package/src/lib/nest/function/v2/call.js +0 -31
  238. package/src/lib/nest/function/v2/call.js.map +0 -1
  239. package/src/lib/nest/function/v2/event.js +0 -25
  240. package/src/lib/nest/function/v2/event.js.map +0 -1
  241. package/src/lib/nest/function/v2/index.js +0 -9
  242. package/src/lib/nest/function/v2/index.js.map +0 -1
  243. package/src/lib/nest/function/v2/schedule.js +0 -56
  244. package/src/lib/nest/function/v2/schedule.js.map +0 -1
  245. package/src/lib/nest/function/v2/taskqueue.js +0 -26
  246. package/src/lib/nest/function/v2/taskqueue.js.map +0 -1
  247. package/src/lib/nest/index.js +0 -15
  248. package/src/lib/nest/index.js.map +0 -1
  249. package/src/lib/nest/middleware/appcheck.decorator.js +0 -12
  250. package/src/lib/nest/middleware/appcheck.decorator.js.map +0 -1
  251. package/src/lib/nest/middleware/appcheck.js +0 -3
  252. package/src/lib/nest/middleware/appcheck.js.map +0 -1
  253. package/src/lib/nest/middleware/appcheck.middleware.js +0 -74
  254. package/src/lib/nest/middleware/appcheck.middleware.js.map +0 -1
  255. package/src/lib/nest/middleware/appcheck.module.js +0 -21
  256. package/src/lib/nest/middleware/appcheck.module.js.map +0 -1
  257. package/src/lib/nest/middleware/globalprefix.js +0 -11
  258. package/src/lib/nest/middleware/globalprefix.js.map +0 -1
  259. package/src/lib/nest/middleware/index.js +0 -10
  260. package/src/lib/nest/middleware/index.js.map +0 -1
  261. package/src/lib/nest/middleware/rawbody.middleware.js +0 -16
  262. package/src/lib/nest/middleware/rawbody.middleware.js.map +0 -1
  263. package/src/lib/nest/middleware/webhook.js +0 -24
  264. package/src/lib/nest/middleware/webhook.js.map +0 -1
  265. package/src/lib/nest/model/call.model.function.js +0 -73
  266. package/src/lib/nest/model/call.model.function.js.map +0 -1
  267. package/src/lib/nest/model/create.model.function.js +0 -27
  268. package/src/lib/nest/model/create.model.function.js.map +0 -1
  269. package/src/lib/nest/model/crud.assert.function.js +0 -3
  270. package/src/lib/nest/model/crud.assert.function.js.map +0 -1
  271. package/src/lib/nest/model/delete.model.function.js +0 -27
  272. package/src/lib/nest/model/delete.model.function.js.map +0 -1
  273. package/src/lib/nest/model/index.js +0 -11
  274. package/src/lib/nest/model/index.js.map +0 -1
  275. package/src/lib/nest/model/permission.error.js +0 -24
  276. package/src/lib/nest/model/permission.error.js.map +0 -1
  277. package/src/lib/nest/model/read.model.function.js +0 -27
  278. package/src/lib/nest/model/read.model.function.js.map +0 -1
  279. package/src/lib/nest/model/specifier.function.js +0 -35
  280. package/src/lib/nest/model/specifier.function.js.map +0 -1
  281. package/src/lib/nest/model/update.model.function.js +0 -27
  282. package/src/lib/nest/model/update.model.function.js.map +0 -1
  283. package/src/lib/nest/nest.provider.js +0 -89
  284. package/src/lib/nest/nest.provider.js.map +0 -1
  285. package/src/lib/nest/storage/index.js +0 -5
  286. package/src/lib/nest/storage/index.js.map +0 -1
  287. package/src/lib/nest/storage/storage.module.js +0 -112
  288. package/src/lib/nest/storage/storage.module.js.map +0 -1
  289. package/src/lib/storage/driver.accessor.js +0 -299
  290. package/src/lib/storage/driver.accessor.js.map +0 -1
  291. package/src/lib/storage/driver.js +0 -12
  292. package/src/lib/storage/driver.js.map +0 -1
  293. package/src/lib/storage/index.js +0 -8
  294. package/src/lib/storage/index.js.map +0 -1
  295. package/src/lib/storage/storage.js +0 -20
  296. package/src/lib/storage/storage.js.map +0 -1
  297. package/src/lib/storage/storage.service.js +0 -26
  298. package/src/lib/storage/storage.service.js.map +0 -1
  299. package/test/src/index.js +0 -5
  300. package/test/src/index.js.map +0 -1
  301. package/test/src/lib/firebase/firebase.admin.auth.js +0 -260
  302. package/test/src/lib/firebase/firebase.admin.auth.js.map +0 -1
  303. package/test/src/lib/firebase/firebase.admin.collection.js +0 -108
  304. package/test/src/lib/firebase/firebase.admin.collection.js.map +0 -1
  305. package/test/src/lib/firebase/firebase.admin.function.js +0 -132
  306. package/test/src/lib/firebase/firebase.admin.function.js.map +0 -1
  307. package/test/src/lib/firebase/firebase.admin.js +0 -174
  308. package/test/src/lib/firebase/firebase.admin.js.map +0 -1
  309. package/test/src/lib/firebase/firebase.admin.nest.function.callable.context.js +0 -42
  310. package/test/src/lib/firebase/firebase.admin.nest.function.callable.context.js.map +0 -1
  311. package/test/src/lib/firebase/firebase.admin.nest.function.cloud.context.js +0 -40
  312. package/test/src/lib/firebase/firebase.admin.nest.function.cloud.context.js.map +0 -1
  313. package/test/src/lib/firebase/firebase.admin.nest.function.js +0 -64
  314. package/test/src/lib/firebase/firebase.admin.nest.function.js.map +0 -1
  315. package/test/src/lib/firebase/firebase.admin.nest.js +0 -107
  316. package/test/src/lib/firebase/firebase.admin.nest.js.map +0 -1
  317. package/test/src/lib/firebase/firebase.admin.test.server.js +0 -37
  318. package/test/src/lib/firebase/firebase.admin.test.server.js.map +0 -1
  319. package/test/src/lib/firebase/firebase.function.js +0 -58
  320. package/test/src/lib/firebase/firebase.function.js.map +0 -1
  321. package/test/src/lib/firebase/firebase.jest.d.ts +0 -21
  322. package/test/src/lib/firebase/firebase.jest.js +0 -45
  323. package/test/src/lib/firebase/firebase.jest.js.map +0 -1
  324. package/test/src/lib/firebase/firebase.js +0 -74
  325. package/test/src/lib/firebase/firebase.js.map +0 -1
  326. package/test/src/lib/firebase/index.js +0 -15
  327. package/test/src/lib/firebase/index.js.map +0 -1
  328. package/test/src/lib/firestore/firestore.admin.js +0 -21
  329. package/test/src/lib/firestore/firestore.admin.js.map +0 -1
  330. package/test/src/lib/firestore/firestore.js +0 -57
  331. package/test/src/lib/firestore/firestore.js.map +0 -1
  332. package/test/src/lib/firestore/index.js +0 -6
  333. package/test/src/lib/firestore/index.js.map +0 -1
  334. package/test/src/lib/index.js +0 -7
  335. package/test/src/lib/index.js.map +0 -1
  336. package/test/src/lib/storage/index.js +0 -6
  337. package/test/src/lib/storage/index.js.map +0 -1
  338. package/test/src/lib/storage/storage.admin.js +0 -21
  339. package/test/src/lib/storage/storage.admin.js.map +0 -1
  340. package/test/src/lib/storage/storage.js +0 -59
  341. package/test/src/lib/storage/storage.js.map +0 -1
  342. /package/{zoho/index.cjs.d.ts → index.d.ts} +0 -0
  343. /package/{zoho/index.esm.d.ts → mailgun/index.d.ts} +0 -0
@@ -0,0 +1,1258 @@
1
+ 'use strict';
2
+
3
+ var util = require('@dereekb/util');
4
+ var test = require('@dereekb/util/test');
5
+ var jsonwebtoken = require('jsonwebtoken');
6
+ var firebase = require('@dereekb/firebase');
7
+ var admin = require('firebase-admin');
8
+ var functions = require('firebase-functions-test');
9
+ var test$1 = require('@dereekb/firebase/test');
10
+ var firebaseServer = require('@dereekb/firebase-server');
11
+ var firestore = require('@google-cloud/firestore');
12
+ var storage = require('@google-cloud/storage');
13
+ var testing = require('@nestjs/testing');
14
+ var nestjs = require('@dereekb/nestjs');
15
+ var https = require('firebase-functions/v1/https');
16
+ var makeError = require('make-error');
17
+
18
+ class AuthorizedUserTestContextFixture extends test.AbstractChildTestContextFixture {
19
+ // MARK: AuthorizedUserTestContext (Forwarded)
20
+ get uid() {
21
+ return this.instance.uid;
22
+ }
23
+ loadUserRecord() {
24
+ return this.instance.loadUserRecord();
25
+ }
26
+ loadUserEmailAndPhone() {
27
+ return this.instance.loadUserEmailAndPhone();
28
+ }
29
+ loadIdToken() {
30
+ return this.instance.loadIdToken();
31
+ }
32
+ loadDecodedIdToken() {
33
+ return this.instance.loadDecodedIdToken();
34
+ }
35
+ makeContextOptions() {
36
+ return this.instance.makeContextOptions();
37
+ }
38
+ callWrappedFunction(fn, params, skipJsonConversion) {
39
+ return this.instance.callWrappedFunction(fn, params, skipJsonConversion);
40
+ }
41
+ callCloudFunction(fn, params, skipJsonConversion = false) {
42
+ return this.instance.callCloudFunction(fn, params, skipJsonConversion);
43
+ }
44
+ }
45
+ function convertParamsToParsedJsonObjectAndBack(object) {
46
+ const paramsAsJson = JSON.parse(JSON.stringify(object));
47
+ return paramsAsJson;
48
+ }
49
+ class AuthorizedUserTestContextInstance {
50
+ uid;
51
+ testContext;
52
+ constructor(uid, testContext) {
53
+ this.uid = uid;
54
+ this.testContext = testContext;
55
+ }
56
+ loadUserRecord() {
57
+ return this.testContext.auth.getUser(this.uid);
58
+ }
59
+ async loadUserEmailAndPhone() {
60
+ const record = await this.loadUserRecord();
61
+ return {
62
+ email: record.email,
63
+ phone: record.phoneNumber
64
+ };
65
+ }
66
+ loadIdToken() {
67
+ return this.loadUserRecord().then((record) => createEncodedTestFirestoreTokenForUserRecord(this.testContext.auth, record));
68
+ }
69
+ loadDecodedIdToken() {
70
+ return this.loadIdToken().then(decodeEncodedCreateCustomTokenResult);
71
+ }
72
+ makeContextOptions() {
73
+ return this.loadUserRecord().then((record) => createTestFunctionContextOptions(this.testContext.auth, record));
74
+ }
75
+ /**
76
+ * Calls a wrapped function with the input params and the context from makeContextOptions().
77
+ *
78
+ * @param fn
79
+ * @param params
80
+ * @param skipJsonConversion
81
+ */
82
+ callWrappedFunction(fn, params, skipJsonConversion) {
83
+ // Parse to JSON then back to simulate sending JSON to the server, and the server parsing it as a POJO.
84
+ const parsedParams = params == null || skipJsonConversion ? params : convertParamsToParsedJsonObjectAndBack(params);
85
+ return this.makeContextOptions().then((options) => fn(parsedParams, options));
86
+ }
87
+ callCloudFunction(fn, params, skipJsonConversion = false) {
88
+ if (params != null && params.scheduleTime) {
89
+ // Workaround for https://github.com/firebase/firebase-functions-test/issues/210
90
+ const scheduleTime = params.scheduleTime;
91
+ delete params.scheduleTime;
92
+ params.timestamp = scheduleTime;
93
+ }
94
+ return this.callWrappedFunction(fn, params, skipJsonConversion);
95
+ }
96
+ /**
97
+ * Calls a wrapped gen 2 auth blocking function with the input params and context options from makeContextOptions().
98
+ *
99
+ * @param fn
100
+ * @param userRecord
101
+ * @param eventType
102
+ * @param eventOverride
103
+ * @param skipJsonConversion
104
+ * @returns
105
+ */
106
+ callAuthBlockingFunction(fn, userRecord, eventType, eventOverride, skipJsonConversion = false) {
107
+ const timestamp = new Date().toISOString();
108
+ const event = {
109
+ ipAddress: '127.0.0.1',
110
+ userAgent: 'testing',
111
+ eventId: '0',
112
+ params: {},
113
+ resource: { service: 'dbx-test', name: 'fake-resource' },
114
+ timestamp,
115
+ ...eventOverride,
116
+ data: userRecord,
117
+ eventType
118
+ };
119
+ return this.callCloudFunction(fn, event, skipJsonConversion);
120
+ }
121
+ /**
122
+ * @deprecated gen 1
123
+ *
124
+ * @param fn
125
+ * @param params
126
+ * @param contextOptions
127
+ * @param skipJsonConversion
128
+ * @returns
129
+ */
130
+ callEventCloudFunction(fn, params, contextOptions, skipJsonConversion = false) {
131
+ const parsedParams = params == null || skipJsonConversion ? params : convertParamsToParsedJsonObjectAndBack(params);
132
+ return this.makeContextOptions().then((options) => fn(parsedParams, contextOptions ? { ...contextOptions, ...options } : options));
133
+ }
134
+ }
135
+ /**
136
+ * Convenience function for using authorizedUserContextFactory directly and passing buildTests.
137
+ */
138
+ function authorizedUserContext(config, buildTests) {
139
+ authorizedUserContextFactory(config)({ f: config.f }, buildTests);
140
+ }
141
+ const AUTHORIZED_USER_RANDOM_EMAIL_FACTORY = util.randomEmailFactory();
142
+ const AUTHORIZED_USER_RANDOM_PHONE_NUMBER_FACTORY = util.randomPhoneNumberFactory();
143
+ /**
144
+ * Creates a new Jest Context that has a random user for authorization for use in firebase server tests.
145
+ */
146
+ function authorizedUserContextFactory(config) {
147
+ const { uid: uidGetter, makeInstance = (uid, testInstance) => new AuthorizedUserTestContextInstance(uid, testInstance), makeFixture = (f) => new AuthorizedUserTestContextFixture(f), makeUserDetails = () => ({}), initUser } = config;
148
+ const makeUid = uidGetter ? util.asGetter(uidGetter) : testUidFactory;
149
+ return (params, buildTests) => {
150
+ const { f, user: inputUserGetterOrValue, addContactInfo: inputAddContactInfoGetterOrValue, template: inputTemplateGetterOrValue } = params;
151
+ const inputAddContactInfoGetter = util.asGetter(inputAddContactInfoGetterOrValue);
152
+ const inputUserGetter = util.asGetter(inputUserGetterOrValue);
153
+ const templateGetter = util.asGetter(inputTemplateGetterOrValue);
154
+ return test.useTestContextFixture({
155
+ fixture: makeFixture(f),
156
+ buildTests,
157
+ initInstance: async () => {
158
+ const inputAddContactInfo = await inputAddContactInfoGetter();
159
+ const inputUser = await inputUserGetter();
160
+ const inputTemplate = await templateGetter();
161
+ const uid = inputUser?.uid || makeUid();
162
+ const { details, claims, addContactInfo: userDetailsAddContactInfo } = { ...makeUserDetails(uid, params), ...inputTemplate };
163
+ const { phoneNumber: detailsPhoneNumber, email: detailsEmail } = details ?? {}; // keep details if provided
164
+ const addContactInfo = inputAddContactInfo || userDetailsAddContactInfo;
165
+ const auth = f.instance.auth;
166
+ let email;
167
+ let phoneNumber;
168
+ if (addContactInfo) {
169
+ email = detailsEmail ?? AUTHORIZED_USER_RANDOM_EMAIL_FACTORY();
170
+ phoneNumber = detailsPhoneNumber ?? AUTHORIZED_USER_RANDOM_PHONE_NUMBER_FACTORY();
171
+ }
172
+ else {
173
+ email = detailsEmail;
174
+ phoneNumber = detailsPhoneNumber ?? undefined;
175
+ }
176
+ const userRecord = await auth.createUser({
177
+ uid,
178
+ displayName: 'Test Person',
179
+ ...details,
180
+ email,
181
+ phoneNumber,
182
+ ...inputUser
183
+ });
184
+ if (claims) {
185
+ await auth.setCustomUserClaims(uid, claims);
186
+ }
187
+ const instance = await makeInstance(uid, f.instance, params, userRecord);
188
+ if (initUser) {
189
+ await initUser(instance, params);
190
+ }
191
+ return instance;
192
+ },
193
+ destroyInstance: async (instance) => {
194
+ const app = instance.testContext.app;
195
+ const uid = instance.uid;
196
+ await app.auth().deleteUser(uid);
197
+ }
198
+ });
199
+ };
200
+ }
201
+ /**
202
+ * Incrementing number factory for generating test UID values.
203
+ *
204
+ * Has the format 'test-uid-<number>'
205
+ */
206
+ const testUidFactory = util.mapGetter(util.incrementingNumberFactory(), (i) => `${new Date().getTime()}0${i}`);
207
+ /**
208
+ * Creates a CallableContextOptions with auth attached corresponding to the input UserRecord.
209
+ *
210
+ * @param auth
211
+ * @param userRecord
212
+ * @returns
213
+ */
214
+ async function createTestFunctionContextOptions(auth, userRecord) {
215
+ const authData = await createTestFunctionContextAuthData(auth, userRecord);
216
+ const contextOptions = {
217
+ auth: authData
218
+ };
219
+ return contextOptions;
220
+ }
221
+ /**
222
+ * Creates AuthData from the input auth and user record.
223
+ *
224
+ * @param auth
225
+ * @param userRecord
226
+ * @returns
227
+ */
228
+ async function createTestFunctionContextAuthData(auth, userRecord) {
229
+ const token = await createTestFirestoreTokenForUserRecord(auth, userRecord);
230
+ const authData = {
231
+ uid: token.uid,
232
+ token,
233
+ rawToken: ''
234
+ };
235
+ return authData;
236
+ }
237
+ /**
238
+ * Creates and decodes a firestore token used for testing.
239
+ *
240
+ * @param auth
241
+ * @param userRecord
242
+ * @returns
243
+ */
244
+ function createTestFirestoreTokenForUserRecord(auth, userRecord) {
245
+ return createEncodedTestFirestoreTokenForUserRecord(auth, userRecord).then(decodeEncodedCreateCustomTokenResult);
246
+ }
247
+ /**
248
+ * Creates an encoded firestore token used for testing.
249
+ *
250
+ * @param auth
251
+ * @param userRecord
252
+ * @returns
253
+ */
254
+ function createEncodedTestFirestoreTokenForUserRecord(auth, userRecord) {
255
+ // TODO: Consider replacing createCustomToken, as the custom claims are put into an object called claims in the JWT, instead of spread over. The decodeEncodedCreateCustomTokenResult() function handles this issue, but it may not be expected.
256
+ return auth.createCustomToken(userRecord.uid, testFirestoreClaimsFromUserRecord(userRecord));
257
+ }
258
+ function decodeEncodedCreateCustomTokenResult(token) {
259
+ const decoded = jsonwebtoken.decode(token);
260
+ const decodedToken = {
261
+ ...decoded,
262
+ ...decoded.claims,
263
+ auth_time: decoded.iat,
264
+ firebase: decoded.claims?.firebase ?? {}
265
+ };
266
+ delete decodedToken.claims; // remove the "claims" item if it exists.
267
+ return decodedToken;
268
+ }
269
+ function testFirestoreClaimsFromUserRecord(userRecord) {
270
+ // Copy claims to be similar to DecodedIdToken pieces.
271
+ const baseClaims = {
272
+ picture: userRecord.photoURL,
273
+ email: userRecord.email,
274
+ email_verified: userRecord.emailVerified ?? false,
275
+ firebase: {
276
+ sign_in_provider: '@dereekb/firebase-server/test',
277
+ identities: []
278
+ }
279
+ };
280
+ const customClaims = userRecord.customClaims;
281
+ const claims = {
282
+ ...customClaims,
283
+ ...baseClaims
284
+ };
285
+ return claims;
286
+ }
287
+
288
+ class ModelTestContextFixture extends test.AbstractChildTestContextFixture {
289
+ // MARK: ModelTestContext (Forwarded)
290
+ get documentId() {
291
+ return this.instance.documentId;
292
+ }
293
+ get documentKey() {
294
+ return this.instance.documentKey;
295
+ }
296
+ get documentFlatKey() {
297
+ return this.instance.documentFlatKey;
298
+ }
299
+ get documentTwoWayFlatKey() {
300
+ return this.instance.documentTwoWayFlatKey;
301
+ }
302
+ get documentRef() {
303
+ return this.instance.documentRef;
304
+ }
305
+ get document() {
306
+ return this.instance.document;
307
+ }
308
+ }
309
+ class ModelTestContextInstance {
310
+ collection;
311
+ ref;
312
+ testContext;
313
+ constructor(collection, ref, testContext) {
314
+ this.collection = collection;
315
+ this.ref = ref;
316
+ this.testContext = testContext;
317
+ }
318
+ get documentId() {
319
+ return this.ref.id;
320
+ }
321
+ get documentKey() {
322
+ return this.ref.path;
323
+ }
324
+ get documentFlatKey() {
325
+ return firebase.flatFirestoreModelKey(this.documentKey);
326
+ }
327
+ get documentTwoWayFlatKey() {
328
+ return firebase.twoWayFlatFirestoreModelKey(this.documentKey);
329
+ }
330
+ get documentRef() {
331
+ return this.ref;
332
+ }
333
+ get document() {
334
+ return this.collection.documentAccessor().loadDocument(this.ref);
335
+ }
336
+ }
337
+ /**
338
+ * Creates a new Test Context that has a random user for authorization for use in firebase server tests.
339
+ */
340
+ function modelTestContextFactory(config) {
341
+ const { getCollection, collectionForDocument, makeRef = (collection) => {
342
+ const accessor = collection.documentAccessor();
343
+ if (accessor.newDocument == null) {
344
+ throw new Error('collection passed to makeRef() was not a full FirestoreCollection. Either supply a custom makeRef() function or a FirestoreCollection that has newDocument() available on the documentAccessor.');
345
+ }
346
+ return accessor.newDocument().documentRef;
347
+ }, makeInstance = (collection, ref, testInstance) => new ModelTestContextInstance(collection, ref, testInstance), makeFixture = (f) => new ModelTestContextFixture(f), initDocument, destroyInstance } = config;
348
+ return (params, buildTests) => {
349
+ const { f } = params;
350
+ return test.useTestContextFixture({
351
+ fixture: makeFixture(f),
352
+ buildTests,
353
+ initInstance: async () => {
354
+ const parentInstance = f.instance;
355
+ let ref;
356
+ let collection;
357
+ let init;
358
+ if (params.doc) {
359
+ const doc = await util.getValueFromGetter(params.doc);
360
+ if (!collectionForDocument) {
361
+ throw new Error('collectionForDocument() is required when using ModelTestContextDocumentRefParams values as input.');
362
+ }
363
+ collection = collectionForDocument(parentInstance, doc);
364
+ const expectedCollectionName = collection.documentAccessor().modelIdentity.collectionName;
365
+ if (expectedCollectionName !== doc.modelIdentity.collectionName) {
366
+ throw new Error(`Input doc is in a different collection (${doc.modelIdentity.collectionName}) than expected (${expectedCollectionName}).`);
367
+ }
368
+ ref = doc.documentRef;
369
+ init = false;
370
+ }
371
+ else {
372
+ collection = getCollection(parentInstance, params);
373
+ ref = await makeRef(collection, params, parentInstance);
374
+ init = true;
375
+ }
376
+ const instance = await makeInstance(collection, ref, parentInstance);
377
+ if (init && initDocument) {
378
+ await initDocument(instance, params);
379
+ }
380
+ return instance;
381
+ },
382
+ destroyInstance
383
+ });
384
+ };
385
+ }
386
+
387
+ let adminEnvironmentInitialized = false;
388
+ function isAdminEnvironmentInitialized() {
389
+ return adminEnvironmentInitialized;
390
+ }
391
+ function generateNewProjectId() {
392
+ const projectId = 'firebase-test-' + new Date().getTime();
393
+ return projectId;
394
+ }
395
+ function rollNewGCloudProjectEnvironmentVariable() {
396
+ const projectId = generateNewProjectId();
397
+ process.env.GCLOUD_TEST_PROJECT = projectId;
398
+ process.env.GCLOUD_PROJECT = projectId;
399
+ applyFirebaseGCloudTestProjectIdToFirebaseConfigEnv();
400
+ return projectId;
401
+ }
402
+ function getGCloudProjectId() {
403
+ return process.env.GCLOUD_PROJECT;
404
+ }
405
+ function getGCloudTestProjectId() {
406
+ return process.env.GCLOUD_TEST_PROJECT;
407
+ }
408
+ /**
409
+ * Applies the current GCLOUD_PROJECT to FIREBASE_CONFIG.
410
+ *
411
+ * This is done as some external testing libraries (firebase-functions-test) will overwrite but we want to enforce using our project id
412
+ * so that each component can also
413
+ */
414
+ function applyFirebaseGCloudTestProjectIdToFirebaseConfigEnv() {
415
+ // firebase-functions-test overwrites this each time.
416
+ // https://github.com/firebase/firebase-functions-test/blob/acb068f4c086f3355b2960b9e9e5895716c7f8cc/src/lifecycle.ts#L37
417
+ const testProjectId = getGCloudTestProjectId();
418
+ // console.log('Test project: ', testProjectId);
419
+ if (!testProjectId) {
420
+ throw new Error('No test project id was available in the environment. Did you call initFirebaseAdminTestEnvironment() first?');
421
+ }
422
+ const config = JSON.parse(process.env.FIREBASE_CONFIG ?? '{}');
423
+ config.projectId = testProjectId;
424
+ process.env.FIREBASE_CONFIG = JSON.stringify(config);
425
+ process.env.GCLOUD_PROJECT = testProjectId; // re-apply to GCLOUD_PROJECT too
426
+ return testProjectId;
427
+ }
428
+ /**
429
+ * Should be called before calling/using adminFirebaseTestBuilder(). This should only be called once.
430
+ */
431
+ function initFirebaseAdminTestEnvironment(config) {
432
+ function crashForEmulator(emulator) {
433
+ throw new Error(`Emulator for ${emulator} was not set null or to a host. Crashing to prevent contamination.`);
434
+ }
435
+ function configureEmulator(emulator, envKey) {
436
+ const emulatorConfig = config.emulators[emulator];
437
+ if (emulatorConfig) {
438
+ process.env[envKey] = emulatorConfig;
439
+ }
440
+ else if (config.emulators.firestore !== null) {
441
+ crashForEmulator(emulator);
442
+ }
443
+ }
444
+ rollNewGCloudProjectEnvironmentVariable();
445
+ configureEmulator('auth', 'FIREBASE_AUTH_EMULATOR_HOST');
446
+ configureEmulator('firestore', 'FIRESTORE_EMULATOR_HOST');
447
+ configureEmulator('storage', 'FIREBASE_STORAGE_EMULATOR_HOST');
448
+ applyFirebaseGCloudTestProjectIdToFirebaseConfigEnv();
449
+ adminEnvironmentInitialized = true;
450
+ }
451
+
452
+ function makeGoogleFirestoreContext(drivers, firestore) {
453
+ const context = firebase.firestoreContextFactory(drivers)(firestore);
454
+ context.drivers = drivers;
455
+ return context;
456
+ }
457
+ class GoogleCloudTestFirestoreInstance extends test$1.TestFirestoreInstance {
458
+ constructor(drivers, firestore) {
459
+ super(makeGoogleFirestoreContext(drivers, firestore));
460
+ }
461
+ }
462
+ class GoogleCloudTestFirestoreContextFixture extends test$1.TestFirestoreContextFixture {
463
+ }
464
+ let COUNTER$1 = 0;
465
+ /**
466
+ * A TestContextBuilderFunction for building firestore test context factories using @google-cloud/firestore. This means SERVER TESTING ONLY. For client testing, look at @dereekb/firestore.
467
+ *
468
+ * This is used to build a @google-cloud/firestore Firestore instance for testing and point it to the emulators.
469
+ *
470
+ * If you need all of Firebase (firebase-admin library), look at adminFirebaseAdminTestBuilder() instead.
471
+ */
472
+ const googleCloudTestFirestoreBuilder = test.testContextBuilder({
473
+ buildConfig: (input) => {
474
+ const config = {
475
+ host: input?.host ?? 'localhost',
476
+ port: input?.port ?? 0
477
+ };
478
+ return config;
479
+ },
480
+ buildFixture: () => new GoogleCloudTestFirestoreContextFixture(),
481
+ setupInstance: async (config) => {
482
+ const random = Math.floor(Math.random() * 10000);
483
+ const drivers = test$1.makeTestingFirestoreDrivers(firebaseServer.googleCloudFirestoreDrivers());
484
+ const projectId = `test-${COUNTER$1++}-${Date.now()}-${random}`.substring(0, 30);
485
+ const firestore$1 = new firestore.Firestore({
486
+ projectId,
487
+ host: config.host,
488
+ port: config.port,
489
+ maxIdleChannels: 0
490
+ });
491
+ return new GoogleCloudTestFirestoreInstance(drivers, firestore$1);
492
+ },
493
+ teardownInstance: async (instance, config) => {
494
+ await instance.firestore.terminate();
495
+ }
496
+ });
497
+
498
+ function makeGoogleFirebaseStorageContext(drivers, firebaseStorage, defaultBucketId) {
499
+ const context = firebase.firebaseStorageContextFactory(drivers)(firebaseStorage, { defaultBucketId });
500
+ context.drivers = drivers;
501
+ return context;
502
+ }
503
+ class GoogleCloudTestFirebaseStorageInstance extends test$1.TestFirebaseStorageInstance {
504
+ constructor(drivers, firebaseStorage, defaultBucketId) {
505
+ super(makeGoogleFirebaseStorageContext(drivers, firebaseStorage, defaultBucketId));
506
+ }
507
+ }
508
+ class GoogleCloudTestFirebaseStorageContextFixture extends test$1.TestFirebaseStorageContextFixture {
509
+ }
510
+ let COUNTER = 0;
511
+ /**
512
+ * A TestContextBuilderFunction for building firebase storage test context factories using @google-cloud/storage. This means SERVER TESTING ONLY. For client testing, look at @dereekb/firestore.
513
+ *
514
+ * This is used to build a @google-cloud/storage FirebaseStorage instance for testing and point it to the emulators.
515
+ *
516
+ * If you need all of Firebase (firebase-admin library), look at adminFirebaseAdminTestBuilder() instead.
517
+ */
518
+ const googleCloudTestFirebaseStorageBuilder = test.testContextBuilder({
519
+ buildConfig: (input) => {
520
+ const config = {
521
+ host: input?.host ?? 'localhost',
522
+ port: input?.port ?? 0
523
+ };
524
+ if (!config.port) {
525
+ throw new Error('Port for host is required.');
526
+ }
527
+ return config;
528
+ },
529
+ buildFixture: () => new GoogleCloudTestFirebaseStorageContextFixture(),
530
+ setupInstance: async (config) => {
531
+ const drivers = test$1.makeTestingFirebaseStorageDrivers(firebaseServer.googleCloudFirebaseStorageDrivers());
532
+ const projectId = `firebase-storage-server-test-${new Date().getTime()}-${COUNTER++}`;
533
+ const firebaseStorage = new storage.Storage({
534
+ projectId,
535
+ // ensure http:// is provided so the library doesn't default to/try https://
536
+ apiEndpoint: `http://${config.host}:${config.port}`
537
+ });
538
+ const defaultBucketId = projectId;
539
+ return new GoogleCloudTestFirebaseStorageInstance(drivers, firebaseStorage, defaultBucketId);
540
+ },
541
+ teardownInstance: async (instance, config) => {
542
+ // nothing to teardown
543
+ }
544
+ });
545
+
546
+ class FirebaseAdminTestContextFixture extends test.AbstractTestContextFixture {
547
+ // MARK: FirebaseAdminTestContext (Forwarded)
548
+ get app() {
549
+ return this.instance.app;
550
+ }
551
+ get auth() {
552
+ return this.instance.auth;
553
+ }
554
+ get firestore() {
555
+ return this.instance.firestore;
556
+ }
557
+ get firestoreInstance() {
558
+ return this.instance.firestoreInstance;
559
+ }
560
+ get firestoreContext() {
561
+ return this.instance.firestoreContext;
562
+ }
563
+ get storage() {
564
+ return this.instance.storage;
565
+ }
566
+ get storageInstance() {
567
+ return this.instance.storageInstance;
568
+ }
569
+ get storageContext() {
570
+ return this.instance.storageContext;
571
+ }
572
+ get fnWrapper() {
573
+ return this.instance.fnWrapper;
574
+ }
575
+ }
576
+ // MARK: FirebaseAdminTestBuilder
577
+ class FirebaseAdminTestContextInstance {
578
+ app;
579
+ getTestFirestoreInstance = util.cachedGetter(() => {
580
+ const drivers = test$1.makeTestingFirestoreDrivers(firebaseServer.googleCloudFirestoreDrivers());
581
+ return new GoogleCloudTestFirestoreInstance(drivers, this.firestore);
582
+ });
583
+ getTestFirebaseStorageInstance = util.cachedGetter(() => {
584
+ const drivers = test$1.makeTestingFirebaseStorageDrivers(firebaseServer.googleCloudFirebaseStorageDrivers());
585
+ const defaultBucketId = this.app.options.storageBucket;
586
+ return new GoogleCloudTestFirebaseStorageInstance(drivers, this.storage, defaultBucketId);
587
+ });
588
+ constructor(app) {
589
+ this.app = app;
590
+ }
591
+ get auth() {
592
+ return this.app.auth();
593
+ }
594
+ get firestore() {
595
+ return this.app.firestore();
596
+ }
597
+ get firestoreInstance() {
598
+ return this.getTestFirestoreInstance();
599
+ }
600
+ get firestoreContext() {
601
+ return this.firestoreInstance.firestoreContext;
602
+ }
603
+ get storage() {
604
+ return firebaseServer.googleCloudStorageFromFirebaseAdminStorage(this.app.storage());
605
+ }
606
+ get storageInstance() {
607
+ return this.getTestFirebaseStorageInstance();
608
+ }
609
+ get storageContext() {
610
+ return this.storageInstance.storageContext;
611
+ }
612
+ get fnWrapper() {
613
+ throw new Error('wrapCloudFunction is unsupported by this type.');
614
+ }
615
+ }
616
+ class AbstractFirebaseAdminTestContextInstanceChild {
617
+ parent;
618
+ constructor(parent) {
619
+ this.parent = parent;
620
+ }
621
+ // MARK: FirebaseAdminTestContext (Forwarded)
622
+ get app() {
623
+ return this.parent.app;
624
+ }
625
+ get auth() {
626
+ return this.parent.auth;
627
+ }
628
+ get firestore() {
629
+ return this.parent.firestore;
630
+ }
631
+ get firestoreInstance() {
632
+ return this.parent.firestoreInstance;
633
+ }
634
+ get firestoreContext() {
635
+ return this.parent.firestoreContext;
636
+ }
637
+ get storage() {
638
+ return this.parent.storage;
639
+ }
640
+ get storageInstance() {
641
+ return this.parent.storageInstance;
642
+ }
643
+ get storageContext() {
644
+ return this.parent.storageContext;
645
+ }
646
+ get fnWrapper() {
647
+ return this.parent.fnWrapper;
648
+ }
649
+ }
650
+ /**
651
+ * A TestContextBuilderFunction for building firebase test context factories using firebase-admin.
652
+ *
653
+ * This can be used to easily build a testing context that sets up RulesTestEnvironment for tests that sets itself up and tears itself down.
654
+ */
655
+ const firebaseAdminTestBuilder = test.testContextBuilder({
656
+ buildConfig: (input) => {
657
+ const config = {
658
+ ...input
659
+ };
660
+ return config;
661
+ },
662
+ buildFixture: () => new FirebaseAdminTestContextFixture(),
663
+ setupInstance: async (config) => {
664
+ if (!isAdminEnvironmentInitialized()) {
665
+ throw new Error('Call initFirebaseAdminTestEnvironment() from @dereekb/firebase-server was not called before using adminFirebaseTestBuilder().');
666
+ }
667
+ const projectId = generateNewProjectId();
668
+ const storageBucket = 'b-' + projectId;
669
+ const app = admin.initializeApp({ projectId, storageBucket });
670
+ return new FirebaseAdminTestContextInstance(app);
671
+ },
672
+ teardownInstance: async (instance, config) => {
673
+ await instance.app.delete(); // clean up the instance
674
+ }
675
+ });
676
+ const firebaseAdminTestContextFactory = firebaseAdminTestBuilder({});
677
+ // MARK: Firestore Context
678
+ /**
679
+ * Convenience function to build a TestFirestoreContextFactory from a FirebaseAdminTestContextFactory.
680
+ *
681
+ * This is useful for composing child tests that will benefit from the firestore testing context, but want the full app available.
682
+ *
683
+ * @param factory
684
+ * @returns
685
+ */
686
+ function firebaseAdminFirestoreContextFixture(factory) {
687
+ return (buildTests) => {
688
+ factory((f) => firebaseAdminFirestoreContextWithFixture(f, buildTests));
689
+ };
690
+ }
691
+ function firebaseAdminFirestoreContextWithFixture(f, buildTests) {
692
+ test.useTestContextFixture({
693
+ fixture: new test$1.TestFirestoreContextFixture(),
694
+ /**
695
+ * Build tests by passing the fixture to the testing functions.
696
+ *
697
+ * This will inject all tests and sub testing lifecycle items.
698
+ */
699
+ buildTests,
700
+ initInstance: () => f.instance.getTestFirestoreInstance()
701
+ });
702
+ }
703
+
704
+ function firebaseAdminCloudFunctionWrapper(instance) {
705
+ const wrapV1CloudFunction = (x) => {
706
+ return instance.wrap(x);
707
+ };
708
+ const wrapV2CallableRequest = (x) => {
709
+ const wrappedCloudFunction = instance.wrap(x);
710
+ // context is marked optional here to better match the gen 1 callable function signature
711
+ return async (data, context) => {
712
+ const request = {
713
+ ...context,
714
+ data,
715
+ // NOTE: These will typically not be used/available as they are express.js properties that are not available or useful to the handlers
716
+ rawRequest: context?.rawRequest ?? {},
717
+ acceptsStreaming: false
718
+ };
719
+ const result = (await wrappedCloudFunction(request));
720
+ return result;
721
+ };
722
+ };
723
+ const wrapV2CloudFunction = (x) => {
724
+ return instance.wrap(x);
725
+ };
726
+ const wrapBlockingFunction = ((blockingFunction) => {
727
+ return instance.wrap(blockingFunction);
728
+ });
729
+ const wrapCloudFunction = (x) => {
730
+ return instance.wrap(x);
731
+ };
732
+ const wrapper = {
733
+ wrapV1CloudFunction,
734
+ wrapV2CloudFunction,
735
+ wrapV2CallableRequest,
736
+ wrapCallableRequest: wrapV2CallableRequest,
737
+ wrapBlockingFunction,
738
+ wrapCloudFunction
739
+ };
740
+ return wrapper;
741
+ }
742
+ function wrapCloudFunctionV1ForTests(wrapper, getter) {
743
+ return () => wrapper.wrapV1CloudFunction(getter());
744
+ }
745
+ function wrapCallableRequestForTests(wrapper, getter) {
746
+ return () => wrapper.wrapCallableRequest(getter());
747
+ }
748
+
749
+ // MARK: FirebaseAdminFunctionTestBuilder
750
+ let functionsInitialized = false;
751
+ /**
752
+ * firebase-functions-test uses a singleton internally, so we must track the reference to properly tear it down too.
753
+ */
754
+ let firebaseFunctionsTestInstance;
755
+ function setupFirebaseAdminFunctionTestSingleton(reroll = false) {
756
+ if (!isAdminEnvironmentInitialized()) {
757
+ throw new Error('initFirebaseAdminTestEnvironment() was not called.');
758
+ }
759
+ if (firebaseFunctionsTestInstance) {
760
+ firebaseFunctionsTestInstance.cleanup(); // destroy the old instance if it is up.
761
+ }
762
+ firebaseFunctionsTestInstance = functions();
763
+ if (reroll) {
764
+ rollNewGCloudProjectEnvironmentVariable();
765
+ }
766
+ else {
767
+ applyFirebaseGCloudTestProjectIdToFirebaseConfigEnv();
768
+ }
769
+ functionsInitialized = true;
770
+ return firebaseFunctionsTestInstance;
771
+ }
772
+ function rerollFirebaseAdminFunctionTestSingleton() {
773
+ return setupFirebaseAdminFunctionTestSingleton(true);
774
+ }
775
+ class FirebaseAdminFunctionTestContextFixture extends test.AbstractTestContextFixture {
776
+ // MARK: FirebaseAdminTestContext (Forwarded)
777
+ get app() {
778
+ return this.instance.app;
779
+ }
780
+ get auth() {
781
+ return this.instance.auth;
782
+ }
783
+ get firestore() {
784
+ return this.instance.firestore;
785
+ }
786
+ get firestoreInstance() {
787
+ return this.instance.firestoreInstance;
788
+ }
789
+ get firestoreContext() {
790
+ return this.instance.firestoreContext;
791
+ }
792
+ get storage() {
793
+ return this.instance.storage;
794
+ }
795
+ get storageInstance() {
796
+ return this.instance.storageInstance;
797
+ }
798
+ get storageContext() {
799
+ return this.instance.storageContext;
800
+ }
801
+ get fnWrapper() {
802
+ return this.instance.fnWrapper;
803
+ }
804
+ }
805
+ class FirebaseAdminFunctionTestContextInstance extends FirebaseAdminTestContextInstance {
806
+ instance;
807
+ _fnWrapper = util.cachedGetter(() => firebaseAdminCloudFunctionWrapper(this.instance));
808
+ constructor(instance, app) {
809
+ super(app);
810
+ this.instance = instance;
811
+ }
812
+ get fnWrapper() {
813
+ return this._fnWrapper();
814
+ }
815
+ }
816
+ exports.DEFAULT_FIREBASE_ADMIN_FUNCTION_TEST_USE_FUNCTION_SINGLETON_CONTEXT = false;
817
+ function setDefaultFirebaseAdminFunctionTestUseFunctionSingleton(use) {
818
+ exports.DEFAULT_FIREBASE_ADMIN_FUNCTION_TEST_USE_FUNCTION_SINGLETON_CONTEXT = use;
819
+ }
820
+ /**
821
+ * A TestContextBuilderFunction for building firebase test context factories using firebase-admin.
822
+ *
823
+ * This can be used to easily build a testing context that sets up RulesTestEnvironment for tests that sets itself up and tears itself down.
824
+ */
825
+ const firebaseAdminFunctionTestBuilder = test.testContextBuilder({
826
+ buildConfig: (input) => {
827
+ const config = {
828
+ ...input,
829
+ useFunctionSingletonContext: input?.useFunctionSingletonContext ?? exports.DEFAULT_FIREBASE_ADMIN_FUNCTION_TEST_USE_FUNCTION_SINGLETON_CONTEXT
830
+ };
831
+ return config;
832
+ },
833
+ buildFixture: () => new FirebaseAdminFunctionTestContextFixture(),
834
+ setupInstance: async (config) => {
835
+ if (!isAdminEnvironmentInitialized()) {
836
+ throw new Error('initFirebaseAdminTestEnvironment() (in @dereekb/firebase-server package) was not called before using adminFirebaseTestBuilder().');
837
+ }
838
+ if (config.useFunctionSingletonContext) {
839
+ if (!functionsInitialized) {
840
+ throw new Error('Call setupFirebaseAdminFunctionTestSingleton() (in @dereekb/firebase-server package) if using functions in a singleton context (useFunctionSingletonContext = true/undefined).');
841
+ }
842
+ }
843
+ else if (config.useFunctionSingletonContext === false) {
844
+ firebaseFunctionsTestInstance = rerollFirebaseAdminFunctionTestSingleton();
845
+ }
846
+ const projectId = getGCloudTestProjectId();
847
+ const storageBucket = 'b-' + projectId;
848
+ const app = admin.initializeApp({ projectId, storageBucket });
849
+ return new FirebaseAdminFunctionTestContextInstance(firebaseFunctionsTestInstance, app);
850
+ },
851
+ teardownInstance: async (instance, config) => {
852
+ if (config.useFunctionSingletonContext === false) {
853
+ try {
854
+ await instance.app.delete(); // will be called in cleanup
855
+ firebaseFunctionsTestInstance.cleanup();
856
+ }
857
+ catch (e) {
858
+ // do nothing
859
+ }
860
+ firebaseFunctionsTestInstance = undefined;
861
+ }
862
+ }
863
+ });
864
+ const firebaseAdminFunctionTestContextFactory = firebaseAdminFunctionTestBuilder({});
865
+
866
+ class FirebaseAdminNestTestContextFixture extends test.AbstractChildTestContextFixture {
867
+ // MARK: Forwarded
868
+ get nest() {
869
+ return this.instance.nest;
870
+ }
871
+ get nestAppPromiseGetter() {
872
+ return this.instance.nestAppPromiseGetter;
873
+ }
874
+ get(typeOrToken, options) {
875
+ return this.instance.get(typeOrToken, options);
876
+ }
877
+ }
878
+ class FirebaseAdminNestTestContextInstance extends AbstractFirebaseAdminTestContextInstanceChild {
879
+ nest;
880
+ nestAppPromiseGetter = () => Promise.resolve(this.nest);
881
+ constructor(parent, nest) {
882
+ super(parent);
883
+ this.nest = nest;
884
+ }
885
+ get(typeOrToken, options) {
886
+ return options ? this.nest.get(typeOrToken, options) : this.nest.get(typeOrToken);
887
+ }
888
+ }
889
+ function firebaseAdminNestContextFixture(config, factory) {
890
+ return (buildTests) => {
891
+ factory((f) => firebaseAdminNestContextWithFixture(config, f, buildTests));
892
+ };
893
+ }
894
+ class FirebaseAdminNestRootModule {
895
+ }
896
+ function firebaseAdminNestContextWithFixture(config, f, buildTests) {
897
+ const { nestModules, makeProviders = () => [], forceStorageBucket = false, defaultStorageBucket: inputDefaultStorageBucket, envConfig, injectFirebaseServerAppTokenProvider, injectServerEnvServiceProvider, makeFixture = (parent) => new FirebaseAdminNestTestContextFixture(parent), makeInstance = (instance, nest) => new FirebaseAdminNestTestContextInstance(instance, nest), initInstance } = config;
898
+ test.useTestContextFixture({
899
+ fixture: makeFixture(f),
900
+ /**
901
+ * Build tests by passing the fixture to the testing functions.
902
+ *
903
+ * This will inject all tests and sub Jest lifecycle items.
904
+ */
905
+ buildTests,
906
+ initInstance: async () => {
907
+ const imports = util.asArray(nestModules);
908
+ const providers = makeProviders(f.instance) ?? [];
909
+ const defaultStorageBucket = inputDefaultStorageBucket ?? f.instance.app.options.storageBucket;
910
+ // Inject the serverEnvTokenProvider and optionally the FirebaseServerEnvService
911
+ if (injectServerEnvServiceProvider !== false || envConfig != null) {
912
+ providers.push(nestjs.serverEnvTokenProvider(envConfig || { production: false }));
913
+ if (injectServerEnvServiceProvider !== false) {
914
+ providers.push({
915
+ provide: firebaseServer.FirebaseServerEnvService,
916
+ useClass: firebaseServer.DefaultFirebaseServerEnvService
917
+ }, {
918
+ provide: nestjs.ServerEnvironmentService,
919
+ useExisting: firebaseServer.FirebaseServerEnvService
920
+ });
921
+ }
922
+ }
923
+ // Inject the firebaseServerAppTokenProvider
924
+ if (injectFirebaseServerAppTokenProvider) {
925
+ providers.push(firebaseServer.firebaseServerAppTokenProvider(util.asGetter(f.instance.app)));
926
+ }
927
+ if (defaultStorageBucket) {
928
+ providers.push(firebaseServer.firebaseServerStorageDefaultBucketIdTokenProvider({
929
+ defaultBucketId: defaultStorageBucket,
930
+ forceBucket: forceStorageBucket
931
+ }));
932
+ }
933
+ const rootModule = {
934
+ module: FirebaseAdminNestRootModule,
935
+ providers,
936
+ exports: providers,
937
+ global: true
938
+ };
939
+ const builder = testing.Test.createTestingModule({
940
+ imports: [rootModule, ...imports]
941
+ });
942
+ const nest = await builder.compile();
943
+ const instance = makeInstance(f.instance, nest);
944
+ if (initInstance) {
945
+ await initInstance(instance);
946
+ }
947
+ return instance;
948
+ },
949
+ destroyInstance: async (instance) => {
950
+ await instance.nest.close();
951
+ }
952
+ });
953
+ }
954
+ function firebaseAdminNestContextFactory(config) {
955
+ return firebaseAdminNestContextFixture(config, firebaseAdminTestContextFactory);
956
+ }
957
+
958
+ function wrapCloudFunctionForNestTestsGetter(wrapper, fn) {
959
+ return wrapCloudFunctionV1ForTests(wrapper.fnWrapper, () => fn(wrapper.nestAppPromiseGetter));
960
+ }
961
+ function wrapCallableRequestForNestTestsGetter(wrapper, fn) {
962
+ return wrapCallableRequestForTests(wrapper.fnWrapper, () => fn(wrapper.nestAppPromiseGetter));
963
+ }
964
+ class FirebaseAdminFunctionNestTestContextFixture extends FirebaseAdminNestTestContextFixture {
965
+ // MARK: FirebaseAdminTestContext (Forwarded)
966
+ wrapCloudFunctionForNestTests(fn) {
967
+ return this.wrapCloudFunctionForNestTestsGetter(fn)();
968
+ }
969
+ wrapCloudFunctionForNestTestsGetter(fn) {
970
+ return wrapCloudFunctionForNestTestsGetter(this, fn);
971
+ }
972
+ wrapCallableRequestForNestTests(fn) {
973
+ return this.wrapCallableRequestForNestTestsGetter(fn)();
974
+ }
975
+ wrapCallableRequestForNestTestsGetter(fn) {
976
+ return wrapCallableRequestForNestTestsGetter(this, fn);
977
+ }
978
+ // MARK: FirebaseAdminCloudFunctionWrapperSource
979
+ get fnWrapper() {
980
+ return this.parent.instance.fnWrapper;
981
+ }
982
+ }
983
+ class FirebaseAdminFunctionNestTestContextInstance extends FirebaseAdminNestTestContextInstance {
984
+ // MARK: FirebaseAdminTestContext (Forwarded)
985
+ get fnWrapper() {
986
+ return this.parent.fnWrapper;
987
+ }
988
+ }
989
+ function firebaseAdminFunctionNestContextFixture(config, factory) {
990
+ return (buildTests) => {
991
+ factory((f) => firebaseAdminFunctionNestContextWithFixture(config, f, buildTests));
992
+ };
993
+ }
994
+ class FirebaseAdminFunctionNestRootModule {
995
+ }
996
+ function firebaseAdminFunctionNestContextWithFixture(config, f, buildTests) {
997
+ const mergedConfig = {
998
+ makeFixture: (parent) => new FirebaseAdminFunctionNestTestContextFixture(parent),
999
+ makeInstance: (instance, nest) => new FirebaseAdminFunctionNestTestContextInstance(instance, nest),
1000
+ ...config
1001
+ };
1002
+ return firebaseAdminNestContextWithFixture(mergedConfig, f, buildTests);
1003
+ }
1004
+ function firebaseAdminFunctionNestContextFactory(config) {
1005
+ return firebaseAdminFunctionNestContextFixture(config, firebaseAdminFunctionTestContextFactory);
1006
+ }
1007
+
1008
+ const CallableRequestTestMultipleFixtureSuffix = 'WrappedFn';
1009
+ function isCallableRequestTestSingleConfig(config) {
1010
+ const isSingle = Boolean(config.fn);
1011
+ return isSingle;
1012
+ }
1013
+ function callableRequestTest(config, buildTests) {
1014
+ if (isCallableRequestTestSingleConfig(config)) {
1015
+ const { f, fn } = config;
1016
+ test.useTestFunctionFixture({
1017
+ fn: () => {
1018
+ const x = wrapCallableRequestForNestTestsGetter(f, fn)();
1019
+ return x;
1020
+ }
1021
+ }, buildTests);
1022
+ }
1023
+ else {
1024
+ const { f, fns: inputFns } = config;
1025
+ const mappedFns = util.mapObjectMap(inputFns, (fn) => () => wrapCallableRequestForNestTestsGetter(f, fn)());
1026
+ const fns = {};
1027
+ Object.keys(mappedFns).forEach((key) => {
1028
+ fns[`${key}${CallableRequestTestMultipleFixtureSuffix}`] = mappedFns[key];
1029
+ });
1030
+ test.useTestFunctionMapFixture({
1031
+ fns
1032
+ }, buildTests);
1033
+ }
1034
+ }
1035
+ function describeCallableRequestTest(label, config, buildTests) {
1036
+ describe(label, () => {
1037
+ callableRequestTest(config, buildTests);
1038
+ });
1039
+ }
1040
+
1041
+ function isCloudFunctionTestSingleConfig(config) {
1042
+ const isSingle = Boolean(config.fn);
1043
+ return isSingle;
1044
+ }
1045
+ function cloudFunctionTest(config, buildTests) {
1046
+ if (isCloudFunctionTestSingleConfig(config)) {
1047
+ const { f, fn } = config;
1048
+ test.useTestFunctionFixture({
1049
+ fn: () => {
1050
+ const x = wrapCloudFunctionForNestTestsGetter(f, fn)();
1051
+ return x;
1052
+ }
1053
+ }, buildTests);
1054
+ }
1055
+ else {
1056
+ const { f, fns: inputFns } = config;
1057
+ const mappedFns = util.mapObjectMap(inputFns, (fn) => () => wrapCloudFunctionForNestTestsGetter(f, fn)());
1058
+ const fns = {};
1059
+ Object.keys(mappedFns).forEach((key) => {
1060
+ fns[`${key}CloudFn`] = mappedFns[key];
1061
+ });
1062
+ test.useTestFunctionMapFixture({
1063
+ fns
1064
+ }, buildTests);
1065
+ }
1066
+ }
1067
+ function describeCloudFunctionTest(label, config, buildTests) {
1068
+ describe(label, () => {
1069
+ cloudFunctionTest(config, buildTests);
1070
+ });
1071
+ }
1072
+
1073
+ function initFirebaseServerAdminTestEnvironment() {
1074
+ initFirebaseAdminTestEnvironment({
1075
+ emulators: {
1076
+ auth: '0.0.0.0:9903',
1077
+ firestore: '0.0.0.0:9904',
1078
+ storage: '0.0.0.0:9906'
1079
+ }
1080
+ });
1081
+ }
1082
+ function describeFirestoreTest(s) {
1083
+ let collection;
1084
+ beforeEach(() => {
1085
+ collection = test$1.mockItemFirestoreCollection(s.firestoreContext);
1086
+ });
1087
+ describe('firestore', () => {
1088
+ it('should interact with the firestore.', async () => {
1089
+ const document = collection.documentAccessor().newDocument();
1090
+ const setData = {
1091
+ value: 'a',
1092
+ test: true
1093
+ };
1094
+ await document.accessor.set(setData);
1095
+ const exists = await document.accessor.exists();
1096
+ expect(exists).toBe(true);
1097
+ const snapshot = await document.accessor.get();
1098
+ const data = snapshot.data();
1099
+ expect(data).toBeDefined();
1100
+ });
1101
+ });
1102
+ }
1103
+
1104
+ /**
1105
+ * Error thrown when the error type was different than the expected type.
1106
+ */
1107
+ class ExpectedHttpErrorWithSpecificServerErrorCode extends makeError.BaseError {
1108
+ httpError;
1109
+ expectedErrorCode;
1110
+ constructor(httpError, expectedErrorCode) {
1111
+ const { code } = httpError.details;
1112
+ super(`Expected HttpError with an error code of "${expectedErrorCode}", but recieved "${code}" instead.`);
1113
+ this.httpError = httpError;
1114
+ this.expectedErrorCode = expectedErrorCode;
1115
+ }
1116
+ }
1117
+ /**
1118
+ * Creates a ExpectFailAssertionFunction that asserts the encountered error is of the expected type using the instanceof keyword.
1119
+ *
1120
+ * Throws a ExpectedErrorOfSpecificTypeError if the input is not a HttpsError.
1121
+ * Throws a ExpectedHttpErrorWithSpecificServerErrorCode if the input's server error data has a different error code.
1122
+ *
1123
+ * @param expectedType
1124
+ * @returns
1125
+ */
1126
+ function expectFailAssertHttpErrorServerErrorCode(expectedCode) {
1127
+ return (error) => {
1128
+ if (error instanceof https.HttpsError) {
1129
+ const { code } = error.details;
1130
+ if (code !== expectedCode) {
1131
+ throw new ExpectedHttpErrorWithSpecificServerErrorCode(error, expectedCode);
1132
+ }
1133
+ }
1134
+ else {
1135
+ throw new test.ExpectedErrorOfSpecificTypeError(error, https.HttpsError);
1136
+ }
1137
+ return true;
1138
+ };
1139
+ }
1140
+ // MARK: Compat
1141
+ /**
1142
+ * @deprecated Use ExpectedHttpErrorWithSpecificServerErrorCode from shared instead. This is kept for backwards compatibility.
1143
+ */
1144
+ class JestExpectedHttpErrorWithSpecificServerErrorCode extends ExpectedHttpErrorWithSpecificServerErrorCode {
1145
+ }
1146
+ /**
1147
+ * @deprecated Use expectFailAssertHttpErrorServerErrorCode from shared instead. This is kept for backwards compatibility.
1148
+ */
1149
+ const jestExpectFailAssertHttpErrorServerErrorCode = expectFailAssertHttpErrorServerErrorCode;
1150
+
1151
+ /**
1152
+ * Default firestore admin factory.
1153
+ *
1154
+ * Host of localhost, port 9904
1155
+ */
1156
+ const adminFirestoreFactory = googleCloudTestFirestoreBuilder({
1157
+ host: 'localhost',
1158
+ port: 9904
1159
+ });
1160
+ /**
1161
+ * Convenience mock instance for tests within an authorized context.
1162
+ *
1163
+ * Uses @google-cloud/firestore
1164
+ */
1165
+ const dbxComponentsAdminTestWithMockItemCollection = test$1.testWithMockItemCollectionFixture()(adminFirestoreFactory);
1166
+
1167
+ /**
1168
+ * Default firestore admin factory.
1169
+ *
1170
+ * Host of localhost, port 9906
1171
+ */
1172
+ const adminFirebaseStorageFactory = googleCloudTestFirebaseStorageBuilder({
1173
+ host: '0.0.0.0',
1174
+ port: 9906
1175
+ });
1176
+ /**
1177
+ * Convenience mock instance for tests within an authorized context.
1178
+ *
1179
+ * Uses @google-cloud/firestore
1180
+ */
1181
+ const dbxComponentsAdminTestWithMockItemStorage = test$1.testWithMockItemStorageFixture()(adminFirebaseStorageFactory);
1182
+
1183
+ exports.AUTHORIZED_USER_RANDOM_EMAIL_FACTORY = AUTHORIZED_USER_RANDOM_EMAIL_FACTORY;
1184
+ exports.AUTHORIZED_USER_RANDOM_PHONE_NUMBER_FACTORY = AUTHORIZED_USER_RANDOM_PHONE_NUMBER_FACTORY;
1185
+ exports.AbstractFirebaseAdminTestContextInstanceChild = AbstractFirebaseAdminTestContextInstanceChild;
1186
+ exports.AuthorizedUserTestContextFixture = AuthorizedUserTestContextFixture;
1187
+ exports.AuthorizedUserTestContextInstance = AuthorizedUserTestContextInstance;
1188
+ exports.CallableRequestTestMultipleFixtureSuffix = CallableRequestTestMultipleFixtureSuffix;
1189
+ exports.ExpectedHttpErrorWithSpecificServerErrorCode = ExpectedHttpErrorWithSpecificServerErrorCode;
1190
+ exports.FirebaseAdminFunctionNestRootModule = FirebaseAdminFunctionNestRootModule;
1191
+ exports.FirebaseAdminFunctionNestTestContextFixture = FirebaseAdminFunctionNestTestContextFixture;
1192
+ exports.FirebaseAdminFunctionNestTestContextInstance = FirebaseAdminFunctionNestTestContextInstance;
1193
+ exports.FirebaseAdminFunctionTestContextFixture = FirebaseAdminFunctionTestContextFixture;
1194
+ exports.FirebaseAdminFunctionTestContextInstance = FirebaseAdminFunctionTestContextInstance;
1195
+ exports.FirebaseAdminNestRootModule = FirebaseAdminNestRootModule;
1196
+ exports.FirebaseAdminNestTestContextFixture = FirebaseAdminNestTestContextFixture;
1197
+ exports.FirebaseAdminNestTestContextInstance = FirebaseAdminNestTestContextInstance;
1198
+ exports.FirebaseAdminTestContextFixture = FirebaseAdminTestContextFixture;
1199
+ exports.FirebaseAdminTestContextInstance = FirebaseAdminTestContextInstance;
1200
+ exports.GoogleCloudTestFirebaseStorageContextFixture = GoogleCloudTestFirebaseStorageContextFixture;
1201
+ exports.GoogleCloudTestFirebaseStorageInstance = GoogleCloudTestFirebaseStorageInstance;
1202
+ exports.GoogleCloudTestFirestoreContextFixture = GoogleCloudTestFirestoreContextFixture;
1203
+ exports.GoogleCloudTestFirestoreInstance = GoogleCloudTestFirestoreInstance;
1204
+ exports.JestExpectedHttpErrorWithSpecificServerErrorCode = JestExpectedHttpErrorWithSpecificServerErrorCode;
1205
+ exports.ModelTestContextFixture = ModelTestContextFixture;
1206
+ exports.ModelTestContextInstance = ModelTestContextInstance;
1207
+ exports.adminFirebaseStorageFactory = adminFirebaseStorageFactory;
1208
+ exports.adminFirestoreFactory = adminFirestoreFactory;
1209
+ exports.applyFirebaseGCloudTestProjectIdToFirebaseConfigEnv = applyFirebaseGCloudTestProjectIdToFirebaseConfigEnv;
1210
+ exports.authorizedUserContext = authorizedUserContext;
1211
+ exports.authorizedUserContextFactory = authorizedUserContextFactory;
1212
+ exports.callableRequestTest = callableRequestTest;
1213
+ exports.cloudFunctionTest = cloudFunctionTest;
1214
+ exports.createEncodedTestFirestoreTokenForUserRecord = createEncodedTestFirestoreTokenForUserRecord;
1215
+ exports.createTestFirestoreTokenForUserRecord = createTestFirestoreTokenForUserRecord;
1216
+ exports.createTestFunctionContextAuthData = createTestFunctionContextAuthData;
1217
+ exports.createTestFunctionContextOptions = createTestFunctionContextOptions;
1218
+ exports.dbxComponentsAdminTestWithMockItemCollection = dbxComponentsAdminTestWithMockItemCollection;
1219
+ exports.dbxComponentsAdminTestWithMockItemStorage = dbxComponentsAdminTestWithMockItemStorage;
1220
+ exports.decodeEncodedCreateCustomTokenResult = decodeEncodedCreateCustomTokenResult;
1221
+ exports.describeCallableRequestTest = describeCallableRequestTest;
1222
+ exports.describeCloudFunctionTest = describeCloudFunctionTest;
1223
+ exports.describeFirestoreTest = describeFirestoreTest;
1224
+ exports.expectFailAssertHttpErrorServerErrorCode = expectFailAssertHttpErrorServerErrorCode;
1225
+ exports.firebaseAdminFirestoreContextFixture = firebaseAdminFirestoreContextFixture;
1226
+ exports.firebaseAdminFirestoreContextWithFixture = firebaseAdminFirestoreContextWithFixture;
1227
+ exports.firebaseAdminFunctionNestContextFactory = firebaseAdminFunctionNestContextFactory;
1228
+ exports.firebaseAdminFunctionNestContextFixture = firebaseAdminFunctionNestContextFixture;
1229
+ exports.firebaseAdminFunctionNestContextWithFixture = firebaseAdminFunctionNestContextWithFixture;
1230
+ exports.firebaseAdminFunctionTestBuilder = firebaseAdminFunctionTestBuilder;
1231
+ exports.firebaseAdminFunctionTestContextFactory = firebaseAdminFunctionTestContextFactory;
1232
+ exports.firebaseAdminNestContextFactory = firebaseAdminNestContextFactory;
1233
+ exports.firebaseAdminNestContextFixture = firebaseAdminNestContextFixture;
1234
+ exports.firebaseAdminNestContextWithFixture = firebaseAdminNestContextWithFixture;
1235
+ exports.firebaseAdminTestBuilder = firebaseAdminTestBuilder;
1236
+ exports.firebaseAdminTestContextFactory = firebaseAdminTestContextFactory;
1237
+ exports.generateNewProjectId = generateNewProjectId;
1238
+ exports.getGCloudProjectId = getGCloudProjectId;
1239
+ exports.getGCloudTestProjectId = getGCloudTestProjectId;
1240
+ exports.googleCloudTestFirebaseStorageBuilder = googleCloudTestFirebaseStorageBuilder;
1241
+ exports.googleCloudTestFirestoreBuilder = googleCloudTestFirestoreBuilder;
1242
+ exports.initFirebaseAdminTestEnvironment = initFirebaseAdminTestEnvironment;
1243
+ exports.initFirebaseServerAdminTestEnvironment = initFirebaseServerAdminTestEnvironment;
1244
+ exports.isAdminEnvironmentInitialized = isAdminEnvironmentInitialized;
1245
+ exports.isCallableRequestTestSingleConfig = isCallableRequestTestSingleConfig;
1246
+ exports.isCloudFunctionTestSingleConfig = isCloudFunctionTestSingleConfig;
1247
+ exports.jestExpectFailAssertHttpErrorServerErrorCode = jestExpectFailAssertHttpErrorServerErrorCode;
1248
+ exports.makeGoogleFirebaseStorageContext = makeGoogleFirebaseStorageContext;
1249
+ exports.makeGoogleFirestoreContext = makeGoogleFirestoreContext;
1250
+ exports.modelTestContextFactory = modelTestContextFactory;
1251
+ exports.rerollFirebaseAdminFunctionTestSingleton = rerollFirebaseAdminFunctionTestSingleton;
1252
+ exports.rollNewGCloudProjectEnvironmentVariable = rollNewGCloudProjectEnvironmentVariable;
1253
+ exports.setDefaultFirebaseAdminFunctionTestUseFunctionSingleton = setDefaultFirebaseAdminFunctionTestUseFunctionSingleton;
1254
+ exports.setupFirebaseAdminFunctionTestSingleton = setupFirebaseAdminFunctionTestSingleton;
1255
+ exports.testFirestoreClaimsFromUserRecord = testFirestoreClaimsFromUserRecord;
1256
+ exports.testUidFactory = testUidFactory;
1257
+ exports.wrapCallableRequestForNestTestsGetter = wrapCallableRequestForNestTestsGetter;
1258
+ exports.wrapCloudFunctionForNestTestsGetter = wrapCloudFunctionForNestTestsGetter;