firebase-admin-edge 1.1.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (445) hide show
  1. package/README.md +102 -405
  2. package/dist/app-check/app-check-endpoints.d.ts +31 -0
  3. package/dist/app-check/app-check-endpoints.d.ts.map +1 -0
  4. package/dist/app-check/app-check-endpoints.js +75 -0
  5. package/dist/app-check/app-check-endpoints.js.map +1 -0
  6. package/dist/app-check/app-check-jwt.d.ts +16 -0
  7. package/dist/app-check/app-check-jwt.d.ts.map +1 -0
  8. package/dist/app-check/app-check-jwt.js +59 -0
  9. package/dist/app-check/app-check-jwt.js.map +1 -0
  10. package/dist/app-check/app-check.d.ts +43 -0
  11. package/dist/app-check/app-check.d.ts.map +1 -0
  12. package/dist/app-check/app-check.js +141 -0
  13. package/dist/app-check/app-check.js.map +1 -0
  14. package/dist/auth/auth-blocking-types.d.ts +44 -0
  15. package/dist/auth/auth-blocking-types.d.ts.map +1 -0
  16. package/dist/auth/auth-blocking-types.js +2 -0
  17. package/dist/auth/auth-blocking-types.js.map +1 -0
  18. package/dist/auth/auth-config-types.d.ts +146 -0
  19. package/dist/auth/auth-config-types.d.ts.map +1 -0
  20. package/dist/auth/auth-config-types.js +2 -0
  21. package/dist/auth/auth-config-types.js.map +1 -0
  22. package/dist/auth/auth-config.d.ts +15 -0
  23. package/dist/auth/auth-config.d.ts.map +1 -0
  24. package/dist/auth/auth-config.js +413 -0
  25. package/dist/auth/auth-config.js.map +1 -0
  26. package/dist/auth/auth-emulator.d.ts +7 -0
  27. package/dist/auth/auth-emulator.d.ts.map +1 -0
  28. package/dist/auth/auth-emulator.js +24 -0
  29. package/dist/auth/auth-emulator.js.map +1 -0
  30. package/dist/auth/auth-endpoint-errors.d.ts +2 -0
  31. package/dist/auth/auth-endpoint-errors.d.ts.map +1 -1
  32. package/dist/auth/auth-endpoint-errors.js +20 -1
  33. package/dist/auth/auth-endpoint-errors.js.map +1 -1
  34. package/dist/auth/auth-error-codes.d.ts +12 -0
  35. package/dist/auth/auth-error-codes.d.ts.map +1 -1
  36. package/dist/auth/auth-error-codes.js +12 -0
  37. package/dist/auth/auth-error-codes.js.map +1 -1
  38. package/dist/auth/email-action-request.d.ts +40 -0
  39. package/dist/auth/email-action-request.d.ts.map +1 -0
  40. package/dist/auth/email-action-request.js +80 -0
  41. package/dist/auth/email-action-request.js.map +1 -0
  42. package/dist/auth/email-link.d.ts +24 -0
  43. package/dist/auth/email-link.d.ts.map +1 -0
  44. package/dist/auth/email-link.js +103 -0
  45. package/dist/auth/email-link.js.map +1 -0
  46. package/dist/auth/firebase-admin-auth.d.ts +60 -12
  47. package/dist/auth/firebase-admin-auth.d.ts.map +1 -1
  48. package/dist/auth/firebase-admin-auth.js +455 -64
  49. package/dist/auth/firebase-admin-auth.js.map +1 -1
  50. package/dist/auth/firebase-auth-endpoints.d.ts +94 -4
  51. package/dist/auth/firebase-auth-endpoints.d.ts.map +1 -1
  52. package/dist/auth/firebase-auth-endpoints.js +304 -64
  53. package/dist/auth/firebase-auth-endpoints.js.map +1 -1
  54. package/dist/auth/firebase-auth.d.ts +78 -4
  55. package/dist/auth/firebase-auth.d.ts.map +1 -1
  56. package/dist/auth/firebase-auth.js +101 -8
  57. package/dist/auth/firebase-auth.js.map +1 -1
  58. package/dist/auth/firebase-jwt.d.ts +19 -10
  59. package/dist/auth/firebase-jwt.d.ts.map +1 -1
  60. package/dist/auth/firebase-jwt.js +176 -39
  61. package/dist/auth/firebase-jwt.js.map +1 -1
  62. package/dist/auth/firebase-types.d.ts +3 -0
  63. package/dist/auth/firebase-types.d.ts.map +1 -1
  64. package/dist/auth/google-oauth.d.ts +0 -1
  65. package/dist/auth/google-oauth.d.ts.map +1 -1
  66. package/dist/auth/google-oauth.js +16 -86
  67. package/dist/auth/google-oauth.js.map +1 -1
  68. package/dist/auth/project-config-manager.d.ts +10 -0
  69. package/dist/auth/project-config-manager.d.ts.map +1 -0
  70. package/dist/auth/project-config-manager.js +22 -0
  71. package/dist/auth/project-config-manager.js.map +1 -0
  72. package/dist/auth/provider-credential.d.ts +43 -0
  73. package/dist/auth/provider-credential.d.ts.map +1 -0
  74. package/dist/auth/provider-credential.js +107 -0
  75. package/dist/auth/provider-credential.js.map +1 -0
  76. package/dist/auth/provider-session.d.ts +10 -0
  77. package/dist/auth/provider-session.d.ts.map +1 -0
  78. package/dist/auth/provider-session.js +28 -0
  79. package/dist/auth/provider-session.js.map +1 -0
  80. package/dist/auth/tenant-manager.d.ts +17 -0
  81. package/dist/auth/tenant-manager.d.ts.map +1 -0
  82. package/dist/auth/tenant-manager.js +59 -0
  83. package/dist/auth/tenant-manager.js.map +1 -0
  84. package/dist/auth/user-batch.d.ts +21 -0
  85. package/dist/auth/user-batch.d.ts.map +1 -0
  86. package/dist/auth/user-batch.js +49 -0
  87. package/dist/auth/user-batch.js.map +1 -0
  88. package/dist/auth/user-import.d.ts +55 -0
  89. package/dist/auth/user-import.d.ts.map +1 -0
  90. package/dist/auth/user-import.js +208 -0
  91. package/dist/auth/user-import.js.map +1 -0
  92. package/dist/auth/user-request.d.ts +10 -0
  93. package/dist/auth/user-request.d.ts.map +1 -1
  94. package/dist/auth/user-request.js +56 -0
  95. package/dist/auth/user-request.js.map +1 -1
  96. package/dist/db/aggregate.d.ts +49 -0
  97. package/dist/db/aggregate.d.ts.map +1 -0
  98. package/dist/db/aggregate.js +115 -0
  99. package/dist/db/aggregate.js.map +1 -0
  100. package/dist/db/bulk-writer.d.ts +55 -0
  101. package/dist/db/bulk-writer.d.ts.map +1 -0
  102. package/dist/db/bulk-writer.js +257 -0
  103. package/dist/db/bulk-writer.js.map +1 -0
  104. package/dist/db/bundle-builder.d.ts +17 -0
  105. package/dist/db/bundle-builder.d.ts.map +1 -0
  106. package/dist/db/bundle-builder.js +118 -0
  107. package/dist/db/bundle-builder.js.map +1 -0
  108. package/dist/db/bytes.d.ts +12 -0
  109. package/dist/db/bytes.d.ts.map +1 -0
  110. package/dist/db/bytes.js +49 -0
  111. package/dist/db/bytes.js.map +1 -0
  112. package/dist/db/collection-group.d.ts +14 -0
  113. package/dist/db/collection-group.d.ts.map +1 -0
  114. package/dist/db/collection-group.js +43 -0
  115. package/dist/db/collection-group.js.map +1 -0
  116. package/dist/db/collection-reference.d.ts +21 -0
  117. package/dist/db/collection-reference.d.ts.map +1 -0
  118. package/dist/db/collection-reference.js +46 -0
  119. package/dist/db/collection-reference.js.map +1 -0
  120. package/dist/db/document-reference.d.ts +41 -0
  121. package/dist/db/document-reference.d.ts.map +1 -0
  122. package/dist/db/document-reference.js +125 -0
  123. package/dist/db/document-reference.js.map +1 -0
  124. package/dist/db/document-snapshot.d.ts +31 -0
  125. package/dist/db/document-snapshot.d.ts.map +1 -0
  126. package/dist/db/document-snapshot.js +103 -0
  127. package/dist/db/document-snapshot.js.map +1 -0
  128. package/dist/db/explain.d.ts +28 -0
  129. package/dist/db/explain.d.ts.map +1 -0
  130. package/dist/db/explain.js +61 -0
  131. package/dist/db/explain.js.map +1 -0
  132. package/dist/db/field-path.d.ts +10 -0
  133. package/dist/db/field-path.d.ts.map +1 -0
  134. package/dist/db/field-path.js +65 -0
  135. package/dist/db/field-path.js.map +1 -0
  136. package/dist/db/field-value.d.ts +17 -0
  137. package/dist/db/field-value.d.ts.map +1 -0
  138. package/dist/db/field-value.js +57 -0
  139. package/dist/db/field-value.js.map +1 -0
  140. package/dist/db/filter.d.ts +20 -0
  141. package/dist/db/filter.d.ts.map +1 -0
  142. package/dist/db/filter.js +48 -0
  143. package/dist/db/filter.js.map +1 -0
  144. package/dist/db/firestore-converter.d.ts +11 -0
  145. package/dist/db/firestore-converter.d.ts.map +1 -0
  146. package/dist/db/firestore-converter.js +14 -0
  147. package/dist/db/firestore-converter.js.map +1 -0
  148. package/dist/db/firestore-document.d.ts +62 -0
  149. package/dist/db/firestore-document.d.ts.map +1 -0
  150. package/dist/db/firestore-document.js +238 -0
  151. package/dist/db/firestore-document.js.map +1 -0
  152. package/dist/db/firestore-endpoints.d.ts +41 -0
  153. package/dist/db/firestore-endpoints.d.ts.map +1 -0
  154. package/dist/db/firestore-endpoints.js +735 -0
  155. package/dist/db/firestore-endpoints.js.map +1 -0
  156. package/dist/db/firestore-error-codes.d.ts +24 -0
  157. package/dist/db/firestore-error-codes.d.ts.map +1 -0
  158. package/dist/db/firestore-error-codes.js +24 -0
  159. package/dist/db/firestore-error-codes.js.map +1 -0
  160. package/dist/db/firestore-logging.d.ts +23 -0
  161. package/dist/db/firestore-logging.d.ts.map +1 -0
  162. package/dist/db/firestore-logging.js +41 -0
  163. package/dist/db/firestore-logging.js.map +1 -0
  164. package/dist/db/firestore-path.d.ts +4 -0
  165. package/dist/db/firestore-path.d.ts.map +1 -0
  166. package/dist/db/firestore-path.js +37 -0
  167. package/dist/db/firestore-path.js.map +1 -0
  168. package/dist/db/firestore-results.d.ts +12 -0
  169. package/dist/db/firestore-results.d.ts.map +1 -0
  170. package/dist/db/firestore-results.js +19 -0
  171. package/dist/db/firestore-results.js.map +1 -0
  172. package/dist/db/firestore-settings.d.ts +22 -0
  173. package/dist/db/firestore-settings.d.ts.map +1 -0
  174. package/dist/db/firestore-settings.js +83 -0
  175. package/dist/db/firestore-settings.js.map +1 -0
  176. package/dist/db/firestore-telemetry.d.ts +21 -0
  177. package/dist/db/firestore-telemetry.d.ts.map +1 -0
  178. package/dist/db/firestore-telemetry.js +84 -0
  179. package/dist/db/firestore-telemetry.js.map +1 -0
  180. package/dist/db/firestore-types.d.ts +25 -0
  181. package/dist/db/firestore-types.d.ts.map +1 -0
  182. package/dist/db/firestore-types.js +2 -0
  183. package/dist/db/firestore-types.js.map +1 -0
  184. package/dist/db/firestore.d.ts +151 -0
  185. package/dist/db/firestore.d.ts.map +1 -0
  186. package/dist/db/firestore.js +505 -0
  187. package/dist/db/firestore.js.map +1 -0
  188. package/dist/db/geo-point.d.ts +11 -0
  189. package/dist/db/geo-point.d.ts.map +1 -0
  190. package/dist/db/geo-point.js +29 -0
  191. package/dist/db/geo-point.js.map +1 -0
  192. package/dist/db/json-stream.d.ts +3 -0
  193. package/dist/db/json-stream.d.ts.map +1 -0
  194. package/dist/db/json-stream.js +117 -0
  195. package/dist/db/json-stream.js.map +1 -0
  196. package/dist/db/pipeline-expression.d.ts +293 -0
  197. package/dist/db/pipeline-expression.d.ts.map +1 -0
  198. package/dist/db/pipeline-expression.js +1436 -0
  199. package/dist/db/pipeline-expression.js.map +1 -0
  200. package/dist/db/pipeline-query.d.ts +6 -0
  201. package/dist/db/pipeline-query.d.ts.map +1 -0
  202. package/dist/db/pipeline-query.js +91 -0
  203. package/dist/db/pipeline-query.js.map +1 -0
  204. package/dist/db/pipeline.d.ts +120 -0
  205. package/dist/db/pipeline.d.ts.map +1 -0
  206. package/dist/db/pipeline.js +396 -0
  207. package/dist/db/pipeline.js.map +1 -0
  208. package/dist/db/query-document-snapshot.d.ts +2 -0
  209. package/dist/db/query-document-snapshot.d.ts.map +1 -0
  210. package/dist/db/query-document-snapshot.js +2 -0
  211. package/dist/db/query-document-snapshot.js.map +1 -0
  212. package/dist/db/query-partition.d.ts +14 -0
  213. package/dist/db/query-partition.d.ts.map +1 -0
  214. package/dist/db/query-partition.js +32 -0
  215. package/dist/db/query-partition.js.map +1 -0
  216. package/dist/db/query-request.d.ts +96 -0
  217. package/dist/db/query-request.d.ts.map +1 -0
  218. package/dist/db/query-request.js +283 -0
  219. package/dist/db/query-request.js.map +1 -0
  220. package/dist/db/query.d.ts +129 -0
  221. package/dist/db/query.d.ts.map +1 -0
  222. package/dist/db/query.js +468 -0
  223. package/dist/db/query.js.map +1 -0
  224. package/dist/db/recursive-delete.d.ts +6 -0
  225. package/dist/db/recursive-delete.d.ts.map +1 -0
  226. package/dist/db/recursive-delete.js +38 -0
  227. package/dist/db/recursive-delete.js.map +1 -0
  228. package/dist/db/snapshot-listener.d.ts +10 -0
  229. package/dist/db/snapshot-listener.d.ts.map +1 -0
  230. package/dist/db/snapshot-listener.js +71 -0
  231. package/dist/db/snapshot-listener.js.map +1 -0
  232. package/dist/db/timestamp.d.ts +29 -0
  233. package/dist/db/timestamp.d.ts.map +1 -0
  234. package/dist/db/timestamp.js +98 -0
  235. package/dist/db/timestamp.js.map +1 -0
  236. package/dist/db/transaction.d.ts +44 -0
  237. package/dist/db/transaction.d.ts.map +1 -0
  238. package/dist/db/transaction.js +177 -0
  239. package/dist/db/transaction.js.map +1 -0
  240. package/dist/db/value-equality.d.ts +3 -0
  241. package/dist/db/value-equality.d.ts.map +1 -0
  242. package/dist/db/value-equality.js +29 -0
  243. package/dist/db/value-equality.js.map +1 -0
  244. package/dist/db/vector-query.d.ts +38 -0
  245. package/dist/db/vector-query.d.ts.map +1 -0
  246. package/dist/db/vector-query.js +110 -0
  247. package/dist/db/vector-query.js.map +1 -0
  248. package/dist/db/vector-value.d.ts +8 -0
  249. package/dist/db/vector-value.d.ts.map +1 -0
  250. package/dist/db/vector-value.js +25 -0
  251. package/dist/db/vector-value.js.map +1 -0
  252. package/dist/db/write-batch.d.ts +25 -0
  253. package/dist/db/write-batch.d.ts.map +1 -0
  254. package/dist/db/write-batch.js +72 -0
  255. package/dist/db/write-batch.js.map +1 -0
  256. package/dist/db/write-request.d.ts +36 -0
  257. package/dist/db/write-request.d.ts.map +1 -0
  258. package/dist/db/write-request.js +257 -0
  259. package/dist/db/write-request.js.map +1 -0
  260. package/dist/firebase-edge-server.d.ts +143 -36
  261. package/dist/firebase-edge-server.d.ts.map +1 -1
  262. package/dist/firebase-edge-server.js +466 -257
  263. package/dist/firebase-edge-server.js.map +1 -1
  264. package/dist/index.d.ts +6 -0
  265. package/dist/index.d.ts.map +1 -1
  266. package/dist/index.js +5 -0
  267. package/dist/index.js.map +1 -1
  268. package/dist/rest-fetch.d.ts +1 -1
  269. package/dist/rest-fetch.d.ts.map +1 -1
  270. package/dist/storage/storage-acl.d.ts +48 -0
  271. package/dist/storage/storage-acl.d.ts.map +1 -0
  272. package/dist/storage/storage-acl.js +101 -0
  273. package/dist/storage/storage-acl.js.map +1 -0
  274. package/dist/storage/storage-bucket-endpoints.d.ts +10 -0
  275. package/dist/storage/storage-bucket-endpoints.d.ts.map +1 -0
  276. package/dist/storage/storage-bucket-endpoints.js +514 -0
  277. package/dist/storage/storage-bucket-endpoints.js.map +1 -0
  278. package/dist/storage/storage-bucket-types.d.ts +183 -0
  279. package/dist/storage/storage-bucket-types.d.ts.map +1 -0
  280. package/dist/storage/storage-bucket-types.js +2 -0
  281. package/dist/storage/storage-bucket-types.js.map +1 -0
  282. package/dist/storage/storage-bucket.d.ts +122 -0
  283. package/dist/storage/storage-bucket.d.ts.map +1 -0
  284. package/dist/storage/storage-bucket.js +544 -0
  285. package/dist/storage/storage-bucket.js.map +1 -0
  286. package/dist/storage/storage-channel.d.ts +10 -0
  287. package/dist/storage/storage-channel.d.ts.map +1 -0
  288. package/dist/storage/storage-channel.js +15 -0
  289. package/dist/storage/storage-channel.js.map +1 -0
  290. package/dist/storage/storage-checksum.d.ts +35 -0
  291. package/dist/storage/storage-checksum.d.ts.map +1 -0
  292. package/dist/storage/storage-checksum.js +312 -0
  293. package/dist/storage/storage-checksum.js.map +1 -0
  294. package/dist/storage/storage-endpoints.d.ts +14 -0
  295. package/dist/storage/storage-endpoints.d.ts.map +1 -0
  296. package/dist/storage/storage-endpoints.js +721 -0
  297. package/dist/storage/storage-endpoints.js.map +1 -0
  298. package/dist/storage/storage-file.d.ts +126 -0
  299. package/dist/storage/storage-file.d.ts.map +1 -0
  300. package/dist/storage/storage-file.js +604 -0
  301. package/dist/storage/storage-file.js.map +1 -0
  302. package/dist/storage/storage-hmac-key.d.ts +26 -0
  303. package/dist/storage/storage-hmac-key.d.ts.map +1 -0
  304. package/dist/storage/storage-hmac-key.js +45 -0
  305. package/dist/storage/storage-hmac-key.js.map +1 -0
  306. package/dist/storage/storage-iam.d.ts +20 -0
  307. package/dist/storage/storage-iam.d.ts.map +1 -0
  308. package/dist/storage/storage-iam.js +43 -0
  309. package/dist/storage/storage-iam.js.map +1 -0
  310. package/dist/storage/storage-md5.d.ts +11 -0
  311. package/dist/storage/storage-md5.d.ts.map +1 -0
  312. package/dist/storage/storage-md5.js +96 -0
  313. package/dist/storage/storage-md5.js.map +1 -0
  314. package/dist/storage/storage-notification.d.ts +24 -0
  315. package/dist/storage/storage-notification.d.ts.map +1 -0
  316. package/dist/storage/storage-notification.js +40 -0
  317. package/dist/storage/storage-notification.js.map +1 -0
  318. package/dist/storage/storage-progress.d.ts +4 -0
  319. package/dist/storage/storage-progress.d.ts.map +1 -0
  320. package/dist/storage/storage-progress.js +17 -0
  321. package/dist/storage/storage-progress.js.map +1 -0
  322. package/dist/storage/storage-reference-endpoints.d.ts +63 -0
  323. package/dist/storage/storage-reference-endpoints.d.ts.map +1 -0
  324. package/dist/storage/storage-reference-endpoints.js +276 -0
  325. package/dist/storage/storage-reference-endpoints.js.map +1 -0
  326. package/dist/storage/storage-reference-helpers.d.ts +12 -0
  327. package/dist/storage/storage-reference-helpers.d.ts.map +1 -0
  328. package/dist/storage/storage-reference-helpers.js +72 -0
  329. package/dist/storage/storage-reference-helpers.js.map +1 -0
  330. package/dist/storage/storage-reference-signing.d.ts +40 -0
  331. package/dist/storage/storage-reference-signing.d.ts.map +1 -0
  332. package/dist/storage/storage-reference-signing.js +289 -0
  333. package/dist/storage/storage-reference-signing.js.map +1 -0
  334. package/dist/storage/storage-reference-types.d.ts +76 -0
  335. package/dist/storage/storage-reference-types.d.ts.map +1 -0
  336. package/dist/storage/storage-reference-types.js +2 -0
  337. package/dist/storage/storage-reference-types.js.map +1 -0
  338. package/dist/storage/storage-results.d.ts +8 -0
  339. package/dist/storage/storage-results.d.ts.map +1 -0
  340. package/dist/storage/storage-results.js +32 -0
  341. package/dist/storage/storage-results.js.map +1 -0
  342. package/dist/storage/storage-resumable.d.ts +18 -0
  343. package/dist/storage/storage-resumable.d.ts.map +1 -0
  344. package/dist/storage/storage-resumable.js +166 -0
  345. package/dist/storage/storage-resumable.js.map +1 -0
  346. package/dist/storage/storage-retry.d.ts +9 -0
  347. package/dist/storage/storage-retry.d.ts.map +1 -0
  348. package/dist/storage/storage-retry.js +104 -0
  349. package/dist/storage/storage-retry.js.map +1 -0
  350. package/dist/storage/storage-signed-url.d.ts +9 -0
  351. package/dist/storage/storage-signed-url.d.ts.map +1 -0
  352. package/dist/storage/storage-signed-url.js +96 -0
  353. package/dist/storage/storage-signed-url.js.map +1 -0
  354. package/dist/storage/storage-special-endpoints.d.ts +10 -0
  355. package/dist/storage/storage-special-endpoints.d.ts.map +1 -0
  356. package/dist/storage/storage-special-endpoints.js +394 -0
  357. package/dist/storage/storage-special-endpoints.js.map +1 -0
  358. package/dist/storage/storage-special-types.d.ts +154 -0
  359. package/dist/storage/storage-special-types.d.ts.map +1 -0
  360. package/dist/storage/storage-special-types.js +2 -0
  361. package/dist/storage/storage-special-types.js.map +1 -0
  362. package/dist/storage/storage-types.d.ts +251 -0
  363. package/dist/storage/storage-types.d.ts.map +1 -0
  364. package/dist/storage/storage-types.js +2 -0
  365. package/dist/storage/storage-types.js.map +1 -0
  366. package/dist/storage/storage-upload-stream.d.ts +41 -0
  367. package/dist/storage/storage-upload-stream.d.ts.map +1 -0
  368. package/dist/storage/storage-upload-stream.js +335 -0
  369. package/dist/storage/storage-upload-stream.js.map +1 -0
  370. package/dist/storage/storage-xml-signing.d.ts +17 -0
  371. package/dist/storage/storage-xml-signing.d.ts.map +1 -0
  372. package/dist/storage/storage-xml-signing.js +144 -0
  373. package/dist/storage/storage-xml-signing.js.map +1 -0
  374. package/dist/storage/storage.d.ts +152 -0
  375. package/dist/storage/storage.d.ts.map +1 -0
  376. package/dist/storage/storage.js +532 -0
  377. package/dist/storage/storage.js.map +1 -0
  378. package/dist/utils/token-cache.d.ts.map +1 -1
  379. package/dist/utils/token-cache.js +3 -2
  380. package/dist/utils/token-cache.js.map +1 -1
  381. package/package.json +22 -6
  382. package/dist/auth/auth-endpoint-errors.test.d.ts +0 -2
  383. package/dist/auth/auth-endpoint-errors.test.d.ts.map +0 -1
  384. package/dist/auth/auth-endpoint-errors.test.js +0 -411
  385. package/dist/auth/auth-endpoint-errors.test.js.map +0 -1
  386. package/dist/auth/errors.test.d.ts +0 -2
  387. package/dist/auth/errors.test.d.ts.map +0 -1
  388. package/dist/auth/errors.test.js +0 -123
  389. package/dist/auth/errors.test.js.map +0 -1
  390. package/dist/auth/firebase-admin-auth.test.d.ts +0 -2
  391. package/dist/auth/firebase-admin-auth.test.d.ts.map +0 -1
  392. package/dist/auth/firebase-admin-auth.test.js +0 -923
  393. package/dist/auth/firebase-admin-auth.test.js.map +0 -1
  394. package/dist/auth/firebase-auth-endpoints.test.d.ts +0 -2
  395. package/dist/auth/firebase-auth-endpoints.test.d.ts.map +0 -1
  396. package/dist/auth/firebase-auth-endpoints.test.js +0 -957
  397. package/dist/auth/firebase-auth-endpoints.test.js.map +0 -1
  398. package/dist/auth/firebase-auth.test.d.ts +0 -2
  399. package/dist/auth/firebase-auth.test.d.ts.map +0 -1
  400. package/dist/auth/firebase-auth.test.js +0 -167
  401. package/dist/auth/firebase-auth.test.js.map +0 -1
  402. package/dist/auth/firebase-jwt.test.d.ts +0 -2
  403. package/dist/auth/firebase-jwt.test.d.ts.map +0 -1
  404. package/dist/auth/firebase-jwt.test.js +0 -164
  405. package/dist/auth/firebase-jwt.test.js.map +0 -1
  406. package/dist/auth/github-oauth.d.ts +0 -19
  407. package/dist/auth/github-oauth.d.ts.map +0 -1
  408. package/dist/auth/github-oauth.js +0 -145
  409. package/dist/auth/github-oauth.js.map +0 -1
  410. package/dist/auth/github-oauth.test.d.ts +0 -2
  411. package/dist/auth/github-oauth.test.d.ts.map +0 -1
  412. package/dist/auth/github-oauth.test.js +0 -202
  413. package/dist/auth/github-oauth.test.js.map +0 -1
  414. package/dist/auth/google-oauth.test.d.ts +0 -2
  415. package/dist/auth/google-oauth.test.d.ts.map +0 -1
  416. package/dist/auth/google-oauth.test.js +0 -200
  417. package/dist/auth/google-oauth.test.js.map +0 -1
  418. package/dist/auth/oauth.d.ts +0 -3
  419. package/dist/auth/oauth.d.ts.map +0 -1
  420. package/dist/auth/oauth.js +0 -48
  421. package/dist/auth/oauth.js.map +0 -1
  422. package/dist/auth/oauth.test.d.ts +0 -2
  423. package/dist/auth/oauth.test.d.ts.map +0 -1
  424. package/dist/auth/oauth.test.js +0 -109
  425. package/dist/auth/oauth.test.js.map +0 -1
  426. package/dist/auth/user-record.test.d.ts +0 -2
  427. package/dist/auth/user-record.test.d.ts.map +0 -1
  428. package/dist/auth/user-record.test.js +0 -198
  429. package/dist/auth/user-record.test.js.map +0 -1
  430. package/dist/auth/user-request.test.d.ts +0 -2
  431. package/dist/auth/user-request.test.d.ts.map +0 -1
  432. package/dist/auth/user-request.test.js +0 -269
  433. package/dist/auth/user-request.test.js.map +0 -1
  434. package/dist/firebase-edge-errors.test.d.ts +0 -2
  435. package/dist/firebase-edge-errors.test.d.ts.map +0 -1
  436. package/dist/firebase-edge-errors.test.js +0 -72
  437. package/dist/firebase-edge-errors.test.js.map +0 -1
  438. package/dist/firebase-edge-server.test.d.ts +0 -2
  439. package/dist/firebase-edge-server.test.d.ts.map +0 -1
  440. package/dist/firebase-edge-server.test.js +0 -264
  441. package/dist/firebase-edge-server.test.js.map +0 -1
  442. package/dist/rest-fetch.test.d.ts +0 -2
  443. package/dist/rest-fetch.test.d.ts.map +0 -1
  444. package/dist/rest-fetch.test.js +0 -164
  445. package/dist/rest-fetch.test.js.map +0 -1
@@ -0,0 +1,151 @@
1
+ import { type FirestoreResult } from './firestore-results.js';
2
+ export type { FirestoreResult } from './firestore-results.js';
3
+ export { setLogFunction, GrpcStatus } from './firestore-logging.js';
4
+ export type * from './firestore-types.js';
5
+ import { PipelineSource, type PipelineResponse } from './pipeline.js';
6
+ export * as Pipelines from './pipeline.js';
7
+ export { FirestoreErrorInfo } from './firestore-error-codes.js';
8
+ import { FirebaseEdgeError } from '../auth/errors.js';
9
+ import type { CacheConfig } from '../auth/cache-types.js';
10
+ import type { ServiceAccount } from '../auth/firebase-types.js';
11
+ import { type QueryRow } from './firestore-endpoints.js';
12
+ import { WriteBatch } from './write-batch.js';
13
+ import { Transaction } from './transaction.js';
14
+ import { BulkWriter, type BulkWriterOptions } from './bulk-writer.js';
15
+ import { Timestamp } from './timestamp.js';
16
+ import { CollectionGroup } from './collection-group.js';
17
+ import { BundleBuilder } from './bundle-builder.js';
18
+ export { CollectionGroup } from './collection-group.js';
19
+ export { QueryPartition } from './query-partition.js';
20
+ export { BundleBuilder } from './bundle-builder.js';
21
+ export type { BulkWriterOptions } from './bulk-writer.js';
22
+ import { DocumentSnapshot, QueryDocumentSnapshot } from './document-snapshot.js';
23
+ import { type SnapshotDocument, type SnapshotTimestamp } from './firestore-document.js';
24
+ export type { SnapshotDocument, SnapshotTimestamp } from './firestore-document.js';
25
+ import { type QueryOptions } from './query-request.js';
26
+ import { type Settings } from './firestore-settings.js';
27
+ export type { Settings, FirestoreOpenTelemetryOptions } from './firestore-settings.js';
28
+ import { FieldPath } from './field-path.js';
29
+ import type { ExplainOptions } from './explain.js';
30
+ export type { ExplainOptions, ExplainResults, ExplainMetrics, PlanSummary, ExecutionStats } from './explain.js';
31
+ export type { DocumentChange } from './query.js';
32
+ export type { SnapshotListenOptions } from './snapshot-listener.js';
33
+ import type { FirestoreDocument } from './firestore-document.js';
34
+ import type { DocumentData } from './firestore-document.js';
35
+ import type { AggregateSpec, AggregateData } from './aggregate.js';
36
+ import type { WriteOperation, WriteResult } from './write-request.js';
37
+ import { CollectionReference } from './collection-reference.js';
38
+ import { DocumentReference } from './document-reference.js';
39
+ export { DocumentReference } from './document-reference.js';
40
+ export { CollectionReference } from './collection-reference.js';
41
+ export { Query, QuerySnapshot } from './query.js';
42
+ export { DocumentSnapshot } from './document-snapshot.js';
43
+ export { QueryDocumentSnapshot } from './query-document-snapshot.js';
44
+ export type { WhereFilterOp } from './query.js';
45
+ export type { DocumentData } from './firestore-document.js';
46
+ export { WriteBatch } from './write-batch.js';
47
+ export { WriteResult } from './write-request.js';
48
+ export type { SetOptions, Precondition } from './write-batch.js';
49
+ export { Transaction } from './transaction.js';
50
+ export { BulkWriter, BulkWriterError } from './bulk-writer.js';
51
+ export { Timestamp } from './timestamp.js';
52
+ export { VectorValue } from './vector-value.js';
53
+ export { VectorQuery, VectorQuerySnapshot } from './vector-query.js';
54
+ export type { VectorQueryOptions } from './vector-query.js';
55
+ export { GeoPoint } from './geo-point.js';
56
+ export { Bytes } from './bytes.js';
57
+ export { FieldPath } from './field-path.js';
58
+ export { FieldValue } from './field-value.js';
59
+ export { Filter } from './filter.js';
60
+ export { AggregateField, AggregateQuery, AggregateQuerySnapshot } from './aggregate.js';
61
+ export type { AggregateSpec, AggregateData, AggregateType, AggregateFieldType, AggregateSpecData } from './aggregate.js';
62
+ export type { FirestoreDataConverter } from './firestore-converter.js';
63
+ export interface ReadOptions {
64
+ fieldMask?: (string | FieldPath)[];
65
+ }
66
+ export interface ReadWriteTransactionOptions {
67
+ readOnly?: false;
68
+ maxAttempts?: number;
69
+ }
70
+ export interface ReadOnlyTransactionOptions {
71
+ readOnly: true;
72
+ readTime?: Timestamp;
73
+ }
74
+ /** Service-account Firestore operations for edge runtimes. */
75
+ export declare class Firestore {
76
+ private serviceAccountKey;
77
+ private _databaseId;
78
+ private fetch?;
79
+ private cache?;
80
+ private cacheName;
81
+ private telemetry?;
82
+ /** @internal Share operation tracing across references, queries, and writes. */
83
+ _trace<T>(name: string, operation: () => Promise<T>): Promise<T>;
84
+ /** @internal Pipeline streams participate in termination and cancellation. */
85
+ _streamPipeline(request: object, signal: AbortSignal, readTime?: Timestamp): AsyncGenerator<Partial<FirestoreDocument>>;
86
+ pipeline(): PipelineSource;
87
+ /** @internal Coordinate authenticated pipeline execution. */
88
+ _executePipeline(request: object, transaction?: string, readTime?: Timestamp): Promise<PipelineResponse>;
89
+ snapshot_(documentName: string, readTime?: SnapshotTimestamp, encoding?: 'json' | 'protobufJS'): DocumentSnapshot;
90
+ snapshot_(document: SnapshotDocument, readTime: SnapshotTimestamp, encoding?: 'json' | 'protobufJS'): QueryDocumentSnapshot;
91
+ private readonly referenceDatabases;
92
+ get projectId(): string;
93
+ get databaseId(): string;
94
+ /** @internal Serialization option. */
95
+ _useBigInt: boolean;
96
+ /** @internal Decode fully qualified references, including other databases. */
97
+ _reference(name: string): DocumentReference;
98
+ private started;
99
+ private configured;
100
+ private terminated;
101
+ private readonly streams;
102
+ private readonly snapshotListeners;
103
+ /** @internal Register polling cleanup and return a deregistration function. */
104
+ _registerSnapshotListener(stop: () => void): () => void;
105
+ /** @internal Used by write serialization. */
106
+ _ignoreUndefinedProperties: boolean;
107
+ private implicitOrderBy;
108
+ get alwaysUseImplicitOrderBy(): boolean;
109
+ settings(settings: Settings): void;
110
+ toJSON(): {
111
+ projectId: string;
112
+ };
113
+ terminate(): Promise<FirestoreResult<void>>;
114
+ bundle(name?: string): BundleBuilder;
115
+ recursiveDelete(ref: DocumentReference<any> | CollectionReference<any>, bulkWriter?: BulkWriter): Promise<FirestoreResult<void>>;
116
+ collectionGroup(collectionId: string): CollectionGroup;
117
+ getAll<T = DocumentData, DbModelType extends DocumentData = DocumentData>(...referencesOrOptions: (DocumentReference<T, DbModelType> | ReadOptions)[]): Promise<FirestoreResult<DocumentSnapshot<T, DbModelType>[]>>;
118
+ /** @internal Shared bulk read validation for transactions. */
119
+ _getAll<T = DocumentData, DbModelType extends DocumentData = DocumentData>(referencesOrOptions: (DocumentReference<T, DbModelType> | ReadOptions)[], transaction?: string): Promise<DocumentSnapshot<T, DbModelType>[]>;
120
+ listCollections(): Promise<FirestoreResult<CollectionReference[]>>;
121
+ /** @internal */
122
+ _listCollections(path: string): Promise<CollectionReference[]>;
123
+ /** @internal */
124
+ _listDocuments(path: string): Promise<string[]>;
125
+ /** @internal */
126
+ _query(path: string, options: QueryOptions, transaction?: string): Promise<FirestoreDocument[]>;
127
+ /** @internal */
128
+ _streamQuery(path: string, options: QueryOptions, signal: AbortSignal): AsyncGenerator<FirestoreDocument>;
129
+ batch(): WriteBatch;
130
+ /** @internal Explain streams participate in termination and cancellation. */
131
+ _explainQuery(path: string, options: QueryOptions, explain: ExplainOptions, signal: AbortSignal): AsyncGenerator<QueryRow>;
132
+ bulkWriter(options?: BulkWriterOptions): BulkWriter;
133
+ runTransaction<T>(updateFunction: (transaction: Transaction) => Promise<T>, options?: ReadWriteTransactionOptions | ReadOnlyTransactionOptions): Promise<FirestoreResult<T>>;
134
+ /** @internal */
135
+ _documentName(path: string): string;
136
+ /** @internal */
137
+ _partitionQuery(collectionId: string, count: number): Promise<string[]>;
138
+ /** @internal */
139
+ _batchWrite(writes: WriteOperation[]): Promise<(WriteResult | FirebaseEdgeError)[]>;
140
+ /** @internal */
141
+ _commit(writes: WriteOperation[]): Promise<WriteResult[]>;
142
+ /** @internal */
143
+ _aggregate(path: string, options: QueryOptions, spec: AggregateSpec, transaction?: string, explain?: ExplainOptions): Promise<AggregateData>;
144
+ constructor(serviceAccountKey: ServiceAccount, _databaseId?: string, fetch?: typeof globalThis.fetch | undefined, cache?: CacheConfig | undefined, cacheName?: string);
145
+ collection(path: string): CollectionReference;
146
+ doc(path: string): DocumentReference;
147
+ private documentReference;
148
+ private getCachedToken;
149
+ private assertActive;
150
+ }
151
+ //# sourceMappingURL=firestore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"firestore.d.ts","sourceRoot":"","sources":["../../src/db/firestore.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,eAAe,EAGvB,MAAM,wBAAwB,CAAC;AAChC,YAAY,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAG9D,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpE,mBAAmB,sBAAsB,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,KAAK,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACtE,OAAO,KAAK,SAAS,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAE,kBAAkB,EAAE,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Y,EACrB,IAAI,EAAE,aAAa,EACnB,WAAW,CAAC,EAAE,MAAM,EACpB,OAAO,CAAC,EAAE,cAAc,GACzB,OAAO,CAAC,aAAa,CAAC;gBAkBb,iBAAiB,EAAE,cAAc,EACjC,WAAW,SAAc,EACzB,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,YAAA,EAC/B,KAAK,CAAC,EAAE,WAAW,YAAA,EACnB,SAAS,SAAY;IAcjC,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,mBAAmB;IAO7C,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,iBAAiB;IAIpC,OAAO,CAAC,iBAAiB;YAaX,cAAc;IA8B5B,OAAO,CAAC,YAAY;CAQvB"}
@@ -0,0 +1,505 @@
1
+ import { firestoreResult, firestoreData } from './firestore-results.js';
2
+ import { traceFirestoreOperation } from './firestore-telemetry.js';
3
+ export { setLogFunction, GrpcStatus } from './firestore-logging.js';
4
+ import { PipelineSource } from './pipeline.js';
5
+ export * as Pipelines from './pipeline.js';
6
+ import { FirestoreErrorInfo } from './firestore-error-codes.js';
7
+ export { FirestoreErrorInfo } from './firestore-error-codes.js';
8
+ import { FirebaseEdgeError } from '../auth/errors.js';
9
+ import { getToken } from '../auth/google-oauth.js';
10
+ import { getDocument, executePipeline, streamPipeline, runQuery, createDocumentName, commitWrites, batchWrite, beginTransaction, rollbackTransaction, runAggregate, batchGetDocuments, listCollectionIds, listDocumentPaths, streamQuery, partitionQuery, configureFirestoreFetch, streamQueryRows } from './firestore-endpoints.js';
11
+ import { WriteBatch } from './write-batch.js';
12
+ import { Transaction } from './transaction.js';
13
+ import { BulkWriter } from './bulk-writer.js';
14
+ import { Timestamp } from './timestamp.js';
15
+ import { CollectionGroup } from './collection-group.js';
16
+ import { BundleBuilder } from './bundle-builder.js';
17
+ import { deleteRecursively } from './recursive-delete.js';
18
+ export { CollectionGroup } from './collection-group.js';
19
+ export { QueryPartition } from './query-partition.js';
20
+ export { BundleBuilder } from './bundle-builder.js';
21
+ import { DocumentSnapshot, QueryDocumentSnapshot } from './document-snapshot.js';
22
+ import { normalizeSnapshotDocument, normalizeSnapshotTimestamp } from './firestore-document.js';
23
+ import { validateFieldPath } from './query-request.js';
24
+ import { validateSettings } from './firestore-settings.js';
25
+ import { FieldPath } from './field-path.js';
26
+ import { CollectionReference } from './collection-reference.js';
27
+ import { DocumentReference } from './document-reference.js';
28
+ export { DocumentReference } from './document-reference.js';
29
+ export { CollectionReference } from './collection-reference.js';
30
+ export { Query, QuerySnapshot } from './query.js';
31
+ export { DocumentSnapshot } from './document-snapshot.js';
32
+ export { QueryDocumentSnapshot } from './query-document-snapshot.js';
33
+ export { WriteBatch } from './write-batch.js';
34
+ export { WriteResult } from './write-request.js';
35
+ export { Transaction } from './transaction.js';
36
+ export { BulkWriter, BulkWriterError } from './bulk-writer.js';
37
+ export { Timestamp } from './timestamp.js';
38
+ export { VectorValue } from './vector-value.js';
39
+ export { VectorQuery, VectorQuerySnapshot } from './vector-query.js';
40
+ export { GeoPoint } from './geo-point.js';
41
+ export { Bytes } from './bytes.js';
42
+ export { FieldPath } from './field-path.js';
43
+ export { FieldValue } from './field-value.js';
44
+ export { Filter } from './filter.js';
45
+ export { AggregateField, AggregateQuery, AggregateQuerySnapshot } from './aggregate.js';
46
+ /** Service-account Firestore operations for edge runtimes. */
47
+ export class Firestore {
48
+ serviceAccountKey;
49
+ _databaseId;
50
+ fetch;
51
+ cache;
52
+ cacheName;
53
+ telemetry;
54
+ /** @internal Share operation tracing across references, queries, and writes. */
55
+ _trace(name, operation) {
56
+ return traceFirestoreOperation(name, this.telemetry, operation);
57
+ }
58
+ /** @internal Pipeline streams participate in termination and cancellation. */
59
+ async *_streamPipeline(request, signal, readTime) {
60
+ this.assertActive();
61
+ const controller = new AbortController();
62
+ this.streams.add(controller);
63
+ const combined = AbortSignal.any([signal, controller.signal]);
64
+ try {
65
+ const token = await this.getCachedToken();
66
+ combined.throwIfAborted();
67
+ yield* streamPipeline(this.projectId, this.databaseId, request, token.access_token, this.fetch, combined, readTime);
68
+ }
69
+ finally {
70
+ this.streams.delete(controller);
71
+ }
72
+ }
73
+ pipeline() {
74
+ this.assertActive();
75
+ return new PipelineSource(this);
76
+ }
77
+ /** @internal Coordinate authenticated pipeline execution. */
78
+ async _executePipeline(request, transaction, readTime) {
79
+ const token = await this.getCachedToken();
80
+ return executePipeline(this.projectId, this.databaseId, request, token.access_token, this.fetch, transaction, readTime);
81
+ }
82
+ snapshot_(documentOrName, readTime, encoding = 'protobufJS') {
83
+ if (encoding !== 'json' && encoding !== 'protobufJS')
84
+ throw new FirebaseEdgeError({
85
+ ...FirestoreErrorInfo.INVALID_ARGUMENT,
86
+ message: 'Unsupported snapshot encoding. Expected json or protobufJS.'
87
+ });
88
+ this.assertActive();
89
+ const time = readTime === undefined
90
+ ? Timestamp.now()
91
+ : normalizeSnapshotTimestamp(readTime, encoding);
92
+ if (typeof documentOrName === 'string')
93
+ return new DocumentSnapshot(this._reference(documentOrName), undefined, time);
94
+ const document = normalizeSnapshotDocument(documentOrName, encoding);
95
+ document.readTime = time.toString();
96
+ return new QueryDocumentSnapshot(this._reference(document.name), document);
97
+ }
98
+ referenceDatabases = new Map();
99
+ get projectId() {
100
+ return this.serviceAccountKey.project_id;
101
+ }
102
+ get databaseId() {
103
+ return this._databaseId;
104
+ }
105
+ /** @internal Serialization option. */
106
+ _useBigInt = false;
107
+ /** @internal Decode fully qualified references, including other databases. */
108
+ _reference(name) {
109
+ const match = /^projects\/([^/]+)\/databases\/([^/]+)\/documents\/(.+)$/.exec(name);
110
+ if (!match)
111
+ throw new FirebaseEdgeError({
112
+ ...FirestoreErrorInfo.INVALID_RESPONSE,
113
+ message: 'Invalid document reference.'
114
+ });
115
+ const key = `${match[1]}/${match[2]}`;
116
+ const db = match[1] === this.projectId && match[2] === this.databaseId
117
+ ? this
118
+ : (this.referenceDatabases.get(key) ??
119
+ new Firestore({ ...this.serviceAccountKey, project_id: match[1] }, match[2], this.fetch, this.cache, this.cacheName));
120
+ if (db !== this)
121
+ this.referenceDatabases.set(key, db);
122
+ db.telemetry = this.telemetry;
123
+ db._useBigInt = this._useBigInt;
124
+ db._ignoreUndefinedProperties = this._ignoreUndefinedProperties;
125
+ return db.documentReference(match[3]);
126
+ }
127
+ started = false;
128
+ configured = false;
129
+ terminated = false;
130
+ streams = new Set();
131
+ snapshotListeners = new Set();
132
+ /** @internal Register polling cleanup and return a deregistration function. */
133
+ _registerSnapshotListener(stop) {
134
+ this.assertActive();
135
+ this.snapshotListeners.add(stop);
136
+ return () => {
137
+ this.snapshotListeners.delete(stop);
138
+ };
139
+ }
140
+ /** @internal Used by write serialization. */
141
+ _ignoreUndefinedProperties = false;
142
+ implicitOrderBy = false;
143
+ get alwaysUseImplicitOrderBy() {
144
+ return this.implicitOrderBy;
145
+ }
146
+ settings(settings) {
147
+ if (this.started || this.configured || this.terminated)
148
+ throw new FirebaseEdgeError({
149
+ ...FirestoreErrorInfo.FAILED_PRECONDITION,
150
+ message: 'settings() must be called once, before using Firestore.'
151
+ });
152
+ validateSettings(settings);
153
+ const transport = settings.host !== undefined ||
154
+ settings.ssl !== undefined ||
155
+ settings.port !== undefined ||
156
+ settings.openTelemetry !== undefined
157
+ ? configureFirestoreFetch(this.fetch ?? globalThis.fetch, settings.host ?? 'firestore.googleapis.com', settings.ssl, settings.port, settings.openTelemetry)
158
+ : this.fetch;
159
+ this.serviceAccountKey = {
160
+ ...this.serviceAccountKey,
161
+ ...settings.credentials,
162
+ ...(settings.projectId ? { project_id: settings.projectId } : {})
163
+ };
164
+ this._databaseId = settings.databaseId ?? this._databaseId;
165
+ this.fetch = transport;
166
+ this.telemetry = settings.openTelemetry;
167
+ this._ignoreUndefinedProperties =
168
+ settings.ignoreUndefinedProperties ?? false;
169
+ this._useBigInt = settings.useBigInt ?? false;
170
+ this.implicitOrderBy = settings.alwaysUseImplicitOrderBy ?? false;
171
+ this.configured = true;
172
+ }
173
+ toJSON() {
174
+ return { projectId: this.serviceAccountKey.project_id };
175
+ }
176
+ async terminate() {
177
+ return firestoreResult(async () => {
178
+ this.terminated = true;
179
+ for (const stop of this.snapshotListeners) {
180
+ stop();
181
+ }
182
+ this.snapshotListeners.clear();
183
+ for (const controller of this.streams) {
184
+ controller.abort(new FirebaseEdgeError({
185
+ ...FirestoreErrorInfo.FAILED_PRECONDITION,
186
+ message: 'Firestore has been terminated.'
187
+ }));
188
+ }
189
+ this.streams.clear();
190
+ });
191
+ }
192
+ bundle(name) {
193
+ this.assertActive();
194
+ return new BundleBuilder(name);
195
+ }
196
+ async recursiveDelete(ref, bulkWriter) {
197
+ return firestoreResult(async () => {
198
+ return this._trace('Firestore.recursiveDelete', async () => {
199
+ this.assertActive();
200
+ if (!(ref instanceof DocumentReference ||
201
+ ref instanceof CollectionReference) ||
202
+ ref.firestore !== this ||
203
+ (bulkWriter !== undefined &&
204
+ (!(bulkWriter instanceof BulkWriter) ||
205
+ bulkWriter.firestore !== this))) {
206
+ throw new FirebaseEdgeError({
207
+ ...FirestoreErrorInfo.INVALID_ARGUMENT,
208
+ message: 'Reference and BulkWriter must belong to this Firestore instance.'
209
+ });
210
+ }
211
+ const writer = bulkWriter ?? this.bulkWriter();
212
+ try {
213
+ await deleteRecursively(ref, writer);
214
+ }
215
+ finally {
216
+ if (!bulkWriter) {
217
+ await writer.close().then(firestoreData);
218
+ }
219
+ }
220
+ });
221
+ });
222
+ }
223
+ collectionGroup(collectionId) {
224
+ this.assertActive();
225
+ return new CollectionGroup(this, collectionId, (path, options) => this._query(path, options));
226
+ }
227
+ async getAll(...referencesOrOptions) {
228
+ return firestoreResult(async () => {
229
+ return this._trace('Firestore.getAll', async () => {
230
+ return this._getAll(referencesOrOptions);
231
+ });
232
+ });
233
+ }
234
+ /** @internal Shared bulk read validation for transactions. */
235
+ async _getAll(referencesOrOptions, transaction) {
236
+ const args = [...referencesOrOptions];
237
+ const last = args.at(-1);
238
+ const options = last && !(last instanceof DocumentReference)
239
+ ? args.pop()
240
+ : undefined;
241
+ if (!args.length ||
242
+ args.some((ref) => !(ref instanceof DocumentReference) ||
243
+ ref.firestore !== this))
244
+ throw new FirebaseEdgeError({
245
+ ...FirestoreErrorInfo.INVALID_ARGUMENT,
246
+ message: 'getAll requires document references belonging to this Firestore instance.'
247
+ });
248
+ if (options?.fieldMask !== undefined &&
249
+ !Array.isArray(options.fieldMask))
250
+ throw new FirebaseEdgeError({
251
+ ...FirestoreErrorInfo.INVALID_ARGUMENT,
252
+ message: 'fieldMask must be an array.'
253
+ });
254
+ const fields = options?.fieldMask?.map((field) => {
255
+ if (!(field instanceof FieldPath))
256
+ validateFieldPath(field);
257
+ return field.toString();
258
+ });
259
+ const refs = args;
260
+ const token = await this.getCachedToken();
261
+ const readTime = Timestamp.now();
262
+ const documents = await batchGetDocuments(this.serviceAccountKey.project_id, this._databaseId, refs.map((ref) => ref.path), token.access_token, this.fetch, fields, ...(transaction ? [transaction] : []));
263
+ return refs.map((ref, index) => new DocumentSnapshot(ref, documents[index], documents.readTimes?.[index] ?? readTime));
264
+ }
265
+ listCollections() {
266
+ return firestoreResult(async () => {
267
+ return this._trace('Firestore.listCollections', async () => {
268
+ return this._listCollections('');
269
+ });
270
+ });
271
+ }
272
+ /** @internal */
273
+ async _listCollections(path) {
274
+ const token = await this.getCachedToken();
275
+ const ids = await listCollectionIds(this.serviceAccountKey.project_id, this._databaseId, path, token.access_token, this.fetch);
276
+ return ids.map((id) => this.collection(path ? `${path}/${id}` : id));
277
+ }
278
+ /** @internal */
279
+ async _listDocuments(path) {
280
+ const token = await this.getCachedToken();
281
+ return listDocumentPaths(this.serviceAccountKey.project_id, this._databaseId, path, token.access_token, this.fetch);
282
+ }
283
+ /** @internal */
284
+ async _query(path, options, transaction) {
285
+ const token = await this.getCachedToken();
286
+ return runQuery(this.serviceAccountKey.project_id, this._databaseId, path, options, token.access_token, this.fetch, ...(transaction ? [transaction] : []));
287
+ }
288
+ /** @internal */
289
+ async *_streamQuery(path, options, signal) {
290
+ this.assertActive();
291
+ const controller = new AbortController();
292
+ this.streams.add(controller);
293
+ const combined = AbortSignal.any([signal, controller.signal]);
294
+ try {
295
+ const token = await this.getCachedToken();
296
+ combined.throwIfAborted();
297
+ yield* streamQuery(this.serviceAccountKey.project_id, this._databaseId, path, options, token.access_token, this.fetch, combined);
298
+ }
299
+ finally {
300
+ this.streams.delete(controller);
301
+ }
302
+ }
303
+ batch() {
304
+ this.assertActive();
305
+ return new WriteBatch(this, (writes) => this._commit(writes));
306
+ }
307
+ /** @internal Explain streams participate in termination and cancellation. */
308
+ async *_explainQuery(path, options, explain, signal) {
309
+ this.assertActive();
310
+ const controller = new AbortController();
311
+ const combined = AbortSignal.any([signal, controller.signal]);
312
+ this.streams.add(controller);
313
+ try {
314
+ const token = await this.getCachedToken();
315
+ combined.throwIfAborted();
316
+ yield* streamQueryRows(this.projectId, this.databaseId, path, options, token.access_token, this.fetch, combined, explain);
317
+ }
318
+ finally {
319
+ this.streams.delete(controller);
320
+ }
321
+ }
322
+ bulkWriter(options) {
323
+ this.assertActive();
324
+ return new BulkWriter(this, options);
325
+ }
326
+ async runTransaction(updateFunction, options = {}) {
327
+ return firestoreResult(async () => {
328
+ return this._trace('Firestore.runTransaction', async () => {
329
+ if (!options ||
330
+ typeof options !== 'object' ||
331
+ Array.isArray(options) ||
332
+ (options.readOnly !== undefined &&
333
+ typeof options.readOnly !== 'boolean') ||
334
+ ('readTime' in options &&
335
+ options.readTime !== undefined &&
336
+ (options.readOnly !== true ||
337
+ !(options.readTime instanceof Timestamp))) ||
338
+ (options.readOnly === true && 'maxAttempts' in options)) {
339
+ throw new FirebaseEdgeError({
340
+ ...FirestoreErrorInfo.INVALID_ARGUMENT,
341
+ message: 'Invalid transaction options.'
342
+ });
343
+ }
344
+ const attempts = options.readOnly
345
+ ? 1
346
+ : (options.maxAttempts ?? 5);
347
+ if (typeof updateFunction !== 'function' ||
348
+ !Number.isInteger(attempts) ||
349
+ attempts < 1) {
350
+ throw new FirebaseEdgeError({
351
+ ...FirestoreErrorInfo.INVALID_ARGUMENT,
352
+ message: 'A transaction callback and positive maxAttempts are required.'
353
+ });
354
+ }
355
+ const token = await this.getCachedToken();
356
+ for (let attempt = 1;; attempt++) {
357
+ let id;
358
+ let transaction;
359
+ try {
360
+ id = await beginTransaction(this.serviceAccountKey.project_id, this._databaseId, token.access_token, this.fetch, ...(options.readOnly ? [options] : []));
361
+ const transactionId = id;
362
+ transaction = new Transaction(this, async (ref) => {
363
+ this.assertActive();
364
+ const document = await getDocument(this.serviceAccountKey.project_id, this._databaseId, ref.path, token.access_token, this.fetch, transactionId);
365
+ return new DocumentSnapshot(ref, document);
366
+ }, async (writes) => {
367
+ this.assertActive();
368
+ if (options.readOnly) {
369
+ await rollbackTransaction(this.serviceAccountKey.project_id, this._databaseId, transactionId, token.access_token, this.fetch);
370
+ return [];
371
+ }
372
+ return commitWrites(this.serviceAccountKey.project_id, this._databaseId, writes, token.access_token, this.fetch, transactionId);
373
+ }, options.readOnly, transactionId);
374
+ const result = await updateFunction(transaction);
375
+ await transaction._commit();
376
+ return result;
377
+ }
378
+ catch (error) {
379
+ transaction?._close();
380
+ try {
381
+ if (id) {
382
+ await rollbackTransaction(this.serviceAccountKey.project_id, this._databaseId, id, token.access_token, this.fetch);
383
+ }
384
+ }
385
+ catch {
386
+ /* Preserve the original transaction failure. */
387
+ }
388
+ if (!([
389
+ 'firestore/aborted',
390
+ 'firestore/cancelled',
391
+ 'firestore/unknown',
392
+ 'firestore/deadline-exceeded',
393
+ 'firestore/internal',
394
+ 'firestore/unavailable',
395
+ 'firestore/unauthenticated',
396
+ 'firestore/resource-exhausted'
397
+ ].includes(error?.code ?? '') ||
398
+ (error?.code ===
399
+ 'firestore/invalid-argument' &&
400
+ error instanceof Error &&
401
+ /transaction has expired/.test(error.message))) ||
402
+ attempt >= attempts) {
403
+ throw error;
404
+ }
405
+ await new Promise((resolve) => setTimeout(resolve, Math.min(10 * 2 ** (attempt - 1), 1000)));
406
+ }
407
+ }
408
+ });
409
+ });
410
+ }
411
+ /** @internal */
412
+ _documentName(path) {
413
+ return createDocumentName(this.serviceAccountKey.project_id, this._databaseId, path);
414
+ }
415
+ /** @internal */
416
+ async _partitionQuery(collectionId, count) {
417
+ const token = await this.getCachedToken();
418
+ return partitionQuery(this.serviceAccountKey.project_id, this._databaseId, collectionId, count, token.access_token, this.fetch);
419
+ }
420
+ /** @internal */
421
+ async _batchWrite(writes) {
422
+ const token = await this.getCachedToken();
423
+ return batchWrite(this.serviceAccountKey.project_id, this._databaseId, writes, token.access_token, this.fetch);
424
+ }
425
+ /** @internal */
426
+ async _commit(writes) {
427
+ const token = await this.getCachedToken();
428
+ return commitWrites(this.serviceAccountKey.project_id, this._databaseId, writes, token.access_token, this.fetch);
429
+ }
430
+ /** @internal */
431
+ async _aggregate(path, options, spec, transaction, explain) {
432
+ const token = await this.getCachedToken();
433
+ return runAggregate(this.serviceAccountKey.project_id, this._databaseId, path, options, spec, token.access_token, this.fetch, ...(explain
434
+ ? [transaction, explain]
435
+ : transaction
436
+ ? [transaction]
437
+ : []));
438
+ }
439
+ constructor(serviceAccountKey, _databaseId = '(default)', fetch, cache, cacheName = '__cache') {
440
+ this.serviceAccountKey = serviceAccountKey;
441
+ this._databaseId = _databaseId;
442
+ this.fetch = fetch;
443
+ this.cache = cache;
444
+ this.cacheName = cacheName;
445
+ if (!serviceAccountKey?.project_id)
446
+ throw new FirebaseEdgeError({
447
+ ...FirestoreErrorInfo.INVALID_ARGUMENT,
448
+ message: 'A service account project_id is required.'
449
+ });
450
+ if (!_databaseId || _databaseId.includes('/'))
451
+ throw new FirebaseEdgeError({
452
+ ...FirestoreErrorInfo.INVALID_ARGUMENT,
453
+ message: 'A valid Firestore database ID is required.'
454
+ });
455
+ }
456
+ collection(path) {
457
+ this.assertActive();
458
+ return new CollectionReference(this, path, (collectionPath, options) => this._query(collectionPath, options));
459
+ }
460
+ doc(path) {
461
+ this.assertActive();
462
+ return this.documentReference(path);
463
+ }
464
+ documentReference(path) {
465
+ return new DocumentReference(this, path, async (documentPath) => {
466
+ const token = await this.getCachedToken();
467
+ return getDocument(this.serviceAccountKey.project_id, this._databaseId, documentPath, token.access_token, this.fetch);
468
+ });
469
+ }
470
+ async getCachedToken() {
471
+ this.assertActive();
472
+ const cacheKey = `${this.cacheName}:firestore:${this.serviceAccountKey.client_email}`;
473
+ const cached = await this.cache?.getCache(cacheKey);
474
+ this.assertActive();
475
+ if (cached?.access_token) {
476
+ return cached;
477
+ }
478
+ const { data, error } = await getToken(this.serviceAccountKey, this.fetch);
479
+ this.assertActive();
480
+ if (error) {
481
+ throw error;
482
+ }
483
+ if (!data?.access_token) {
484
+ throw new FirebaseEdgeError({
485
+ ...FirestoreErrorInfo.UNAUTHENTICATED,
486
+ message: 'No service account access token returned.'
487
+ });
488
+ }
489
+ const ttlMs = (data.expires_in - 60) * 1000;
490
+ if (Number.isFinite(ttlMs) && ttlMs > 0) {
491
+ await this.cache?.setCache(cacheKey, data, ttlMs);
492
+ }
493
+ this.assertActive();
494
+ return data;
495
+ }
496
+ assertActive() {
497
+ if (this.terminated)
498
+ throw new FirebaseEdgeError({
499
+ ...FirestoreErrorInfo.FAILED_PRECONDITION,
500
+ message: 'Firestore has been terminated.'
501
+ });
502
+ this.started = true;
503
+ }
504
+ }
505
+ //# sourceMappingURL=firestore.js.map