pyric 0.0.1 → 0.1.0-alpha.7

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 (786) hide show
  1. package/README.md +52 -1
  2. package/dist/app/index.d.ts +81 -0
  3. package/dist/app/index.d.ts.map +1 -0
  4. package/dist/app/index.js +78 -0
  5. package/dist/app/index.js.map +1 -0
  6. package/dist/auth/index.d.ts +346 -0
  7. package/dist/auth/index.d.ts.map +1 -0
  8. package/dist/auth/index.js +701 -0
  9. package/dist/auth/index.js.map +1 -0
  10. package/dist/auth/prod-backend.d.ts +39 -0
  11. package/dist/auth/prod-backend.d.ts.map +1 -0
  12. package/dist/auth/prod-backend.js +179 -0
  13. package/dist/auth/prod-backend.js.map +1 -0
  14. package/dist/auth/providers.d.ts +107 -0
  15. package/dist/auth/providers.d.ts.map +1 -0
  16. package/dist/auth/providers.js +138 -0
  17. package/dist/auth/providers.js.map +1 -0
  18. package/dist/auth/sandbox-backend.d.ts +769 -0
  19. package/dist/auth/sandbox-backend.d.ts.map +1 -0
  20. package/dist/auth/sandbox-backend.js +1598 -0
  21. package/dist/auth/sandbox-backend.js.map +1 -0
  22. package/dist/auth/target.d.ts +40 -0
  23. package/dist/auth/target.d.ts.map +1 -0
  24. package/dist/auth/target.js +28 -0
  25. package/dist/auth/target.js.map +1 -0
  26. package/dist/auth/types.d.ts +252 -0
  27. package/dist/auth/types.d.ts.map +1 -0
  28. package/dist/auth/types.js +26 -0
  29. package/dist/auth/types.js.map +1 -0
  30. package/dist/database/constraints/atoms.d.ts +29 -0
  31. package/dist/database/constraints/atoms.d.ts.map +1 -0
  32. package/dist/database/constraints/atoms.js +43 -0
  33. package/dist/database/constraints/atoms.js.map +1 -0
  34. package/dist/database/constraints/compose.d.ts +16 -0
  35. package/dist/database/constraints/compose.d.ts.map +1 -0
  36. package/dist/database/constraints/compose.js +15 -0
  37. package/dist/database/constraints/compose.js.map +1 -0
  38. package/dist/database/constraints/data.d.ts +30 -0
  39. package/dist/database/constraints/data.d.ts.map +1 -0
  40. package/dist/database/constraints/data.js +46 -0
  41. package/dist/database/constraints/data.js.map +1 -0
  42. package/dist/database/constraints/document.d.ts +42 -0
  43. package/dist/database/constraints/document.d.ts.map +1 -0
  44. package/dist/database/constraints/document.js +86 -0
  45. package/dist/database/constraints/document.js.map +1 -0
  46. package/dist/database/constraints/game.d.ts +30 -0
  47. package/dist/database/constraints/game.d.ts.map +1 -0
  48. package/dist/database/constraints/game.js +49 -0
  49. package/dist/database/constraints/game.js.map +1 -0
  50. package/dist/database/constraints/index.d.ts +12 -0
  51. package/dist/database/constraints/index.d.ts.map +1 -0
  52. package/dist/database/constraints/index.js +9 -0
  53. package/dist/database/constraints/index.js.map +1 -0
  54. package/dist/database/constraints/policies.d.ts +16 -0
  55. package/dist/database/constraints/policies.d.ts.map +1 -0
  56. package/dist/database/constraints/policies.js +17 -0
  57. package/dist/database/constraints/policies.js.map +1 -0
  58. package/dist/database/constraints/ruleset.d.ts +5 -0
  59. package/dist/database/constraints/ruleset.d.ts.map +1 -0
  60. package/dist/database/constraints/ruleset.js +132 -0
  61. package/dist/database/constraints/ruleset.js.map +1 -0
  62. package/dist/database/constraints/schema.d.ts +17 -0
  63. package/dist/database/constraints/schema.d.ts.map +1 -0
  64. package/dist/database/constraints/schema.js +74 -0
  65. package/dist/database/constraints/schema.js.map +1 -0
  66. package/dist/database/constraints/types.d.ts +22 -0
  67. package/dist/database/constraints/types.d.ts.map +1 -0
  68. package/dist/database/constraints/types.js +2 -0
  69. package/dist/database/constraints/types.js.map +1 -0
  70. package/dist/database/crawl/handler.d.ts +7 -0
  71. package/dist/database/crawl/handler.d.ts.map +1 -0
  72. package/dist/database/crawl/handler.js +91 -0
  73. package/dist/database/crawl/handler.js.map +1 -0
  74. package/dist/database/crawl/semaphore.d.ts +9 -0
  75. package/dist/database/crawl/semaphore.d.ts.map +1 -0
  76. package/dist/database/crawl/semaphore.js +27 -0
  77. package/dist/database/crawl/semaphore.js.map +1 -0
  78. package/dist/database/crawl/spec.d.ts +33 -0
  79. package/dist/database/crawl/spec.d.ts.map +1 -0
  80. package/dist/database/crawl/spec.js +12 -0
  81. package/dist/database/crawl/spec.js.map +1 -0
  82. package/dist/database/data/handler.d.ts +9 -0
  83. package/dist/database/data/handler.d.ts.map +1 -0
  84. package/dist/database/data/handler.js +96 -0
  85. package/dist/database/data/handler.js.map +1 -0
  86. package/dist/database/data/spec.d.ts +77 -0
  87. package/dist/database/data/spec.d.ts.map +1 -0
  88. package/dist/database/data/spec.js +17 -0
  89. package/dist/database/data/spec.js.map +1 -0
  90. package/dist/database/data/validated.d.ts +8 -0
  91. package/dist/database/data/validated.d.ts.map +1 -0
  92. package/dist/database/data/validated.js +99 -0
  93. package/dist/database/data/validated.js.map +1 -0
  94. package/dist/database/grammar/RtdbExpr.ohm +98 -0
  95. package/dist/database/grammar/RtdbExpr.ohm.generated.d.ts +2 -0
  96. package/dist/database/grammar/RtdbExpr.ohm.generated.d.ts.map +1 -0
  97. package/dist/database/grammar/RtdbExpr.ohm.generated.js +103 -0
  98. package/dist/database/grammar/RtdbExpr.ohm.generated.js.map +1 -0
  99. package/dist/database/grammar/RtdbExprParser.d.ts +5 -0
  100. package/dist/database/grammar/RtdbExprParser.d.ts.map +1 -0
  101. package/dist/database/grammar/RtdbExprParser.js +53 -0
  102. package/dist/database/grammar/RtdbExprParser.js.map +1 -0
  103. package/dist/database/grammar/linter.d.ts +3 -0
  104. package/dist/database/grammar/linter.d.ts.map +1 -0
  105. package/dist/database/grammar/linter.js +66 -0
  106. package/dist/database/grammar/linter.js.map +1 -0
  107. package/dist/database/grammar/simulator.d.ts +31 -0
  108. package/dist/database/grammar/simulator.d.ts.map +1 -0
  109. package/dist/database/grammar/simulator.js +255 -0
  110. package/dist/database/grammar/simulator.js.map +1 -0
  111. package/dist/database/grammar/validator.d.ts +3 -0
  112. package/dist/database/grammar/validator.d.ts.map +1 -0
  113. package/dist/database/grammar/validator.js +84 -0
  114. package/dist/database/grammar/validator.js.map +1 -0
  115. package/dist/database/host.d.ts +50 -0
  116. package/dist/database/host.d.ts.map +1 -0
  117. package/dist/database/host.js +41 -0
  118. package/dist/database/host.js.map +1 -0
  119. package/dist/database/index.d.ts +40 -0
  120. package/dist/database/index.d.ts.map +1 -0
  121. package/dist/database/index.js +47 -0
  122. package/dist/database/index.js.map +1 -0
  123. package/dist/database/initialize-from-app.d.ts +28 -0
  124. package/dist/database/initialize-from-app.d.ts.map +1 -0
  125. package/dist/database/initialize-from-app.js +23 -0
  126. package/dist/database/initialize-from-app.js.map +1 -0
  127. package/dist/database/ir/handler.d.ts +6 -0
  128. package/dist/database/ir/handler.d.ts.map +1 -0
  129. package/dist/database/ir/handler.js +52 -0
  130. package/dist/database/ir/handler.js.map +1 -0
  131. package/dist/database/ir/spec.d.ts +25 -0
  132. package/dist/database/ir/spec.d.ts.map +1 -0
  133. package/dist/database/ir/spec.js +11 -0
  134. package/dist/database/ir/spec.js.map +1 -0
  135. package/dist/database/mapper.d.ts +9 -0
  136. package/dist/database/mapper.d.ts.map +1 -0
  137. package/dist/database/mapper.js +115 -0
  138. package/dist/database/mapper.js.map +1 -0
  139. package/dist/database/modular.d.ts +604 -0
  140. package/dist/database/modular.d.ts.map +1 -0
  141. package/dist/database/modular.js +1226 -0
  142. package/dist/database/modular.js.map +1 -0
  143. package/dist/database/replay.d.ts +33 -0
  144. package/dist/database/replay.d.ts.map +1 -0
  145. package/dist/database/replay.js +124 -0
  146. package/dist/database/replay.js.map +1 -0
  147. package/dist/database/resolver.d.ts +4 -0
  148. package/dist/database/resolver.d.ts.map +1 -0
  149. package/dist/database/resolver.js +66 -0
  150. package/dist/database/resolver.js.map +1 -0
  151. package/dist/database/sandbox/backend.d.ts +403 -0
  152. package/dist/database/sandbox/backend.d.ts.map +1 -0
  153. package/dist/database/sandbox/backend.js +1467 -0
  154. package/dist/database/sandbox/backend.js.map +1 -0
  155. package/dist/database/sandbox/data-tree.d.ts +123 -0
  156. package/dist/database/sandbox/data-tree.d.ts.map +1 -0
  157. package/dist/database/sandbox/data-tree.js +310 -0
  158. package/dist/database/sandbox/data-tree.js.map +1 -0
  159. package/dist/database/sandbox/normalize.d.ts +77 -0
  160. package/dist/database/sandbox/normalize.d.ts.map +1 -0
  161. package/dist/database/sandbox/normalize.js +165 -0
  162. package/dist/database/sandbox/normalize.js.map +1 -0
  163. package/dist/database/sandbox/push-id.d.ts +32 -0
  164. package/dist/database/sandbox/push-id.d.ts.map +1 -0
  165. package/dist/database/sandbox/push-id.js +82 -0
  166. package/dist/database/sandbox/push-id.js.map +1 -0
  167. package/dist/database/sandbox/query.d.ts +175 -0
  168. package/dist/database/sandbox/query.d.ts.map +1 -0
  169. package/dist/database/sandbox/query.js +269 -0
  170. package/dist/database/sandbox/query.js.map +1 -0
  171. package/dist/database/sandbox/rules-eval.d.ts +69 -0
  172. package/dist/database/sandbox/rules-eval.d.ts.map +1 -0
  173. package/dist/database/sandbox/rules-eval.js +124 -0
  174. package/dist/database/sandbox/rules-eval.js.map +1 -0
  175. package/dist/database/sandbox/sentinels.d.ts +71 -0
  176. package/dist/database/sandbox/sentinels.d.ts.map +1 -0
  177. package/dist/database/sandbox/sentinels.js +92 -0
  178. package/dist/database/sandbox/sentinels.js.map +1 -0
  179. package/dist/database/simulation/handler.d.ts +6 -0
  180. package/dist/database/simulation/handler.d.ts.map +1 -0
  181. package/dist/database/simulation/handler.js +236 -0
  182. package/dist/database/simulation/handler.js.map +1 -0
  183. package/dist/database/simulation/spec.d.ts +69 -0
  184. package/dist/database/simulation/spec.d.ts.map +1 -0
  185. package/dist/database/simulation/spec.js +25 -0
  186. package/dist/database/simulation/spec.js.map +1 -0
  187. package/dist/database/tools.d.ts +22 -0
  188. package/dist/database/tools.d.ts.map +1 -0
  189. package/dist/database/tools.js +272 -0
  190. package/dist/database/tools.js.map +1 -0
  191. package/dist/database/types.d.ts +210 -0
  192. package/dist/database/types.d.ts.map +1 -0
  193. package/dist/database/types.js +26 -0
  194. package/dist/database/types.js.map +1 -0
  195. package/dist/database/write/handler.d.ts +7 -0
  196. package/dist/database/write/handler.d.ts.map +1 -0
  197. package/dist/database/write/handler.js +42 -0
  198. package/dist/database/write/handler.js.map +1 -0
  199. package/dist/database/write/spec.d.ts +18 -0
  200. package/dist/database/write/spec.d.ts.map +1 -0
  201. package/dist/database/write/spec.js +7 -0
  202. package/dist/database/write/spec.js.map +1 -0
  203. package/dist/firestore/index.d.ts +533 -0
  204. package/dist/firestore/index.d.ts.map +1 -0
  205. package/dist/firestore/index.js +1536 -0
  206. package/dist/firestore/index.js.map +1 -0
  207. package/dist/firestore/tools.d.ts +67 -0
  208. package/dist/firestore/tools.d.ts.map +1 -0
  209. package/dist/firestore/tools.js +318 -0
  210. package/dist/firestore/tools.js.map +1 -0
  211. package/dist/firestore-values/index.d.ts +63 -0
  212. package/dist/firestore-values/index.d.ts.map +1 -0
  213. package/dist/firestore-values/index.js +148 -0
  214. package/dist/firestore-values/index.js.map +1 -0
  215. package/dist/project-scope.d.ts +5 -0
  216. package/dist/project-scope.d.ts.map +1 -0
  217. package/dist/project-scope.js +2 -0
  218. package/dist/project-scope.js.map +1 -0
  219. package/dist/rules/extract.d.ts +28 -0
  220. package/dist/rules/extract.d.ts.map +1 -0
  221. package/dist/rules/extract.js +25 -0
  222. package/dist/rules/extract.js.map +1 -0
  223. package/dist/rules/generators/assembler.d.ts +19 -0
  224. package/dist/rules/generators/assembler.d.ts.map +1 -0
  225. package/dist/rules/generators/assembler.js +292 -0
  226. package/dist/rules/generators/assembler.js.map +1 -0
  227. package/dist/rules/generators/expressions.d.ts +52 -0
  228. package/dist/rules/generators/expressions.d.ts.map +1 -0
  229. package/dist/rules/generators/expressions.js +117 -0
  230. package/dist/rules/generators/expressions.js.map +1 -0
  231. package/dist/rules/generators/grid.d.ts +22 -0
  232. package/dist/rules/generators/grid.d.ts.map +1 -0
  233. package/dist/rules/generators/grid.js +52 -0
  234. package/dist/rules/generators/grid.js.map +1 -0
  235. package/dist/rules/grammar/FirestoreAST.d.ts +129 -0
  236. package/dist/rules/grammar/FirestoreAST.d.ts.map +1 -0
  237. package/dist/rules/grammar/FirestoreAST.js +3 -0
  238. package/dist/rules/grammar/FirestoreAST.js.map +1 -0
  239. package/dist/rules/grammar/FirestoreAssembler.d.ts +5 -0
  240. package/dist/rules/grammar/FirestoreAssembler.d.ts.map +1 -0
  241. package/dist/rules/grammar/FirestoreAssembler.js +158 -0
  242. package/dist/rules/grammar/FirestoreAssembler.js.map +1 -0
  243. package/dist/rules/grammar/FirestoreParser.d.ts +46 -0
  244. package/dist/rules/grammar/FirestoreParser.d.ts.map +1 -0
  245. package/dist/rules/grammar/FirestoreParser.js +409 -0
  246. package/dist/rules/grammar/FirestoreParser.js.map +1 -0
  247. package/dist/rules/grammar/FirestoreRules.ohm +229 -0
  248. package/dist/rules/grammar/FirestoreRules.ohm.generated.d.ts +2 -0
  249. package/dist/rules/grammar/FirestoreRules.ohm.generated.d.ts.map +1 -0
  250. package/dist/rules/grammar/FirestoreRules.ohm.generated.js +234 -0
  251. package/dist/rules/grammar/FirestoreRules.ohm.generated.js.map +1 -0
  252. package/dist/rules/grammar/FirestoreValidator.d.ts +10 -0
  253. package/dist/rules/grammar/FirestoreValidator.d.ts.map +1 -0
  254. package/dist/rules/grammar/FirestoreValidator.js +482 -0
  255. package/dist/rules/grammar/FirestoreValidator.js.map +1 -0
  256. package/dist/rules/index.d.ts +67 -0
  257. package/dist/rules/index.d.ts.map +1 -0
  258. package/dist/rules/index.js +80 -0
  259. package/dist/rules/index.js.map +1 -0
  260. package/dist/rules/indexes/extract/annotation-collect.d.ts +42 -0
  261. package/dist/rules/indexes/extract/annotation-collect.d.ts.map +1 -0
  262. package/dist/rules/indexes/extract/annotation-collect.js +69 -0
  263. package/dist/rules/indexes/extract/annotation-collect.js.map +1 -0
  264. package/dist/rules/indexes/extract/annotations.d.ts +50 -0
  265. package/dist/rules/indexes/extract/annotations.d.ts.map +1 -0
  266. package/dist/rules/indexes/extract/annotations.js +144 -0
  267. package/dist/rules/indexes/extract/annotations.js.map +1 -0
  268. package/dist/rules/indexes/extract/ast.d.ts +54 -0
  269. package/dist/rules/indexes/extract/ast.d.ts.map +1 -0
  270. package/dist/rules/indexes/extract/ast.js +119 -0
  271. package/dist/rules/indexes/extract/ast.js.map +1 -0
  272. package/dist/rules/indexes/extract/classify.d.ts +41 -0
  273. package/dist/rules/indexes/extract/classify.d.ts.map +1 -0
  274. package/dist/rules/indexes/extract/classify.js +138 -0
  275. package/dist/rules/indexes/extract/classify.js.map +1 -0
  276. package/dist/rules/indexes/extract/composite.d.ts +38 -0
  277. package/dist/rules/indexes/extract/composite.d.ts.map +1 -0
  278. package/dist/rules/indexes/extract/composite.js +85 -0
  279. package/dist/rules/indexes/extract/composite.js.map +1 -0
  280. package/dist/rules/indexes/extract/dataflow.d.ts +45 -0
  281. package/dist/rules/indexes/extract/dataflow.d.ts.map +1 -0
  282. package/dist/rules/indexes/extract/dataflow.js +200 -0
  283. package/dist/rules/indexes/extract/dataflow.js.map +1 -0
  284. package/dist/rules/indexes/extract/enumerate.d.ts +41 -0
  285. package/dist/rules/indexes/extract/enumerate.d.ts.map +1 -0
  286. package/dist/rules/indexes/extract/enumerate.js +163 -0
  287. package/dist/rules/indexes/extract/enumerate.js.map +1 -0
  288. package/dist/rules/indexes/extract/extractor.d.ts +3 -0
  289. package/dist/rules/indexes/extract/extractor.d.ts.map +1 -0
  290. package/dist/rules/indexes/extract/extractor.js +274 -0
  291. package/dist/rules/indexes/extract/extractor.js.map +1 -0
  292. package/dist/rules/indexes/extract/types.d.ts +211 -0
  293. package/dist/rules/indexes/extract/types.d.ts.map +1 -0
  294. package/dist/rules/indexes/extract/types.js +14 -0
  295. package/dist/rules/indexes/extract/types.js.map +1 -0
  296. package/dist/rules/indexes/extractHandler.d.ts +16 -0
  297. package/dist/rules/indexes/extractHandler.d.ts.map +1 -0
  298. package/dist/rules/indexes/extractHandler.js +100 -0
  299. package/dist/rules/indexes/extractHandler.js.map +1 -0
  300. package/dist/rules/indexes/extractTool.d.ts +15 -0
  301. package/dist/rules/indexes/extractTool.d.ts.map +1 -0
  302. package/dist/rules/indexes/extractTool.js +55 -0
  303. package/dist/rules/indexes/extractTool.js.map +1 -0
  304. package/dist/rules/indexes/types.d.ts +71 -0
  305. package/dist/rules/indexes/types.d.ts.map +1 -0
  306. package/dist/rules/indexes/types.js +15 -0
  307. package/dist/rules/indexes/types.js.map +1 -0
  308. package/dist/rules/inspect/handler.d.ts +6 -0
  309. package/dist/rules/inspect/handler.d.ts.map +1 -0
  310. package/dist/rules/inspect/handler.js +144 -0
  311. package/dist/rules/inspect/handler.js.map +1 -0
  312. package/dist/rules/inspect/spec.d.ts +37 -0
  313. package/dist/rules/inspect/spec.d.ts.map +1 -0
  314. package/dist/rules/inspect/spec.js +2 -0
  315. package/dist/rules/inspect/spec.js.map +1 -0
  316. package/dist/rules/inspect/tools.d.ts +21 -0
  317. package/dist/rules/inspect/tools.d.ts.map +1 -0
  318. package/dist/rules/inspect/tools.js +21 -0
  319. package/dist/rules/inspect/tools.js.map +1 -0
  320. package/dist/rules/linter/ast-utils.d.ts +97 -0
  321. package/dist/rules/linter/ast-utils.d.ts.map +1 -0
  322. package/dist/rules/linter/ast-utils.js +491 -0
  323. package/dist/rules/linter/ast-utils.js.map +1 -0
  324. package/dist/rules/linter/hallucinations.d.ts +34 -0
  325. package/dist/rules/linter/hallucinations.d.ts.map +1 -0
  326. package/dist/rules/linter/hallucinations.js +334 -0
  327. package/dist/rules/linter/hallucinations.js.map +1 -0
  328. package/dist/rules/linter/linter.d.ts +84 -0
  329. package/dist/rules/linter/linter.d.ts.map +1 -0
  330. package/dist/rules/linter/linter.js +784 -0
  331. package/dist/rules/linter/linter.js.map +1 -0
  332. package/dist/rules/modules/resolver-browser.d.ts +41 -0
  333. package/dist/rules/modules/resolver-browser.d.ts.map +1 -0
  334. package/dist/rules/modules/resolver-browser.js +63 -0
  335. package/dist/rules/modules/resolver-browser.js.map +1 -0
  336. package/dist/rules/modules/resolver-core.d.ts +51 -0
  337. package/dist/rules/modules/resolver-core.d.ts.map +1 -0
  338. package/dist/rules/modules/resolver-core.js +338 -0
  339. package/dist/rules/modules/resolver-core.js.map +1 -0
  340. package/dist/rules/modules/resolver.d.ts +17 -0
  341. package/dist/rules/modules/resolver.d.ts.map +1 -0
  342. package/dist/rules/modules/resolver.js +49 -0
  343. package/dist/rules/modules/resolver.js.map +1 -0
  344. package/dist/rules/modules/stdlib/atomic.rules +52 -0
  345. package/dist/rules/modules/stdlib/atomic.test.json +152 -0
  346. package/dist/rules/modules/stdlib/auth.rules +7 -0
  347. package/dist/rules/modules/stdlib/auth.test.json +53 -0
  348. package/dist/rules/modules/stdlib/content.rules +50 -0
  349. package/dist/rules/modules/stdlib/content.test.json +238 -0
  350. package/dist/rules/modules/stdlib/counters.rules +41 -0
  351. package/dist/rules/modules/stdlib/counters.test.json +254 -0
  352. package/dist/rules/modules/stdlib/geometry.rules +43 -0
  353. package/dist/rules/modules/stdlib/geometry.test.json +200 -0
  354. package/dist/rules/modules/stdlib/joining.rules +49 -0
  355. package/dist/rules/modules/stdlib/joining.test.json +287 -0
  356. package/dist/rules/modules/stdlib/lifecycle.rules +51 -0
  357. package/dist/rules/modules/stdlib/lifecycle.test.json +288 -0
  358. package/dist/rules/modules/stdlib/lobby.rules +44 -0
  359. package/dist/rules/modules/stdlib/lobby.test.json +32 -0
  360. package/dist/rules/modules/stdlib/membership.rules +40 -0
  361. package/dist/rules/modules/stdlib/membership.test.json +107 -0
  362. package/dist/rules/modules/stdlib/spaces.rules +46 -0
  363. package/dist/rules/modules/stdlib/spaces.test.json +392 -0
  364. package/dist/rules/modules/stdlib/state.rules +28 -0
  365. package/dist/rules/modules/stdlib/state.test.json +55 -0
  366. package/dist/rules/modules/stdlib/timing.rules +20 -0
  367. package/dist/rules/modules/stdlib/timing.test.json +106 -0
  368. package/dist/rules/modules/stdlib/transitions.rules +34 -0
  369. package/dist/rules/modules/stdlib/transitions.test.json +86 -0
  370. package/dist/rules/modules/stdlib/turns.rules +27 -0
  371. package/dist/rules/modules/stdlib/turns.test.json +64 -0
  372. package/dist/rules/modules/stdlib/validation.rules +31 -0
  373. package/dist/rules/modules/stdlib/validation.test.json +184 -0
  374. package/dist/rules/modules/stdlib-content.d.ts +11 -0
  375. package/dist/rules/modules/stdlib-content.d.ts.map +1 -0
  376. package/dist/rules/modules/stdlib-content.js +590 -0
  377. package/dist/rules/modules/stdlib-content.js.map +1 -0
  378. package/dist/rules/node.d.ts +17 -0
  379. package/dist/rules/node.d.ts.map +1 -0
  380. package/dist/rules/node.js +21 -0
  381. package/dist/rules/node.js.map +1 -0
  382. package/dist/rules/rtdb.d.ts +28 -0
  383. package/dist/rules/rtdb.d.ts.map +1 -0
  384. package/dist/rules/rtdb.js +15 -0
  385. package/dist/rules/rtdb.js.map +1 -0
  386. package/dist/rules/simulator/evaluator.d.ts +179 -0
  387. package/dist/rules/simulator/evaluator.d.ts.map +1 -0
  388. package/dist/rules/simulator/evaluator.js +1221 -0
  389. package/dist/rules/simulator/evaluator.js.map +1 -0
  390. package/dist/rules/simulator/expression/eval-errors.d.ts +86 -0
  391. package/dist/rules/simulator/expression/eval-errors.d.ts.map +1 -0
  392. package/dist/rules/simulator/expression/eval-errors.js +68 -0
  393. package/dist/rules/simulator/expression/eval-errors.js.map +1 -0
  394. package/dist/rules/simulator/expression/evaluator.d.ts +43 -0
  395. package/dist/rules/simulator/expression/evaluator.d.ts.map +1 -0
  396. package/dist/rules/simulator/expression/evaluator.js +298 -0
  397. package/dist/rules/simulator/expression/evaluator.js.map +1 -0
  398. package/dist/rules/simulator/expression/lexer.d.ts +36 -0
  399. package/dist/rules/simulator/expression/lexer.d.ts.map +1 -0
  400. package/dist/rules/simulator/expression/lexer.js +318 -0
  401. package/dist/rules/simulator/expression/lexer.js.map +1 -0
  402. package/dist/rules/simulator/expression/parser.d.ts +39 -0
  403. package/dist/rules/simulator/expression/parser.d.ts.map +1 -0
  404. package/dist/rules/simulator/expression/parser.js +329 -0
  405. package/dist/rules/simulator/expression/parser.js.map +1 -0
  406. package/dist/rules/simulator/expression/types.d.ts +137 -0
  407. package/dist/rules/simulator/expression/types.d.ts.map +1 -0
  408. package/dist/rules/simulator/expression/types.js +90 -0
  409. package/dist/rules/simulator/expression/types.js.map +1 -0
  410. package/dist/rules/simulator/expression/walk-data.d.ts +52 -0
  411. package/dist/rules/simulator/expression/walk-data.d.ts.map +1 -0
  412. package/dist/rules/simulator/expression/walk-data.js +167 -0
  413. package/dist/rules/simulator/expression/walk-data.js.map +1 -0
  414. package/dist/rules/simulator/firestore-set.d.ts +25 -0
  415. package/dist/rules/simulator/firestore-set.d.ts.map +1 -0
  416. package/dist/rules/simulator/firestore-set.js +89 -0
  417. package/dist/rules/simulator/firestore-set.js.map +1 -0
  418. package/dist/rules/simulator/handler.d.ts +36 -0
  419. package/dist/rules/simulator/handler.d.ts.map +1 -0
  420. package/dist/rules/simulator/handler.js +583 -0
  421. package/dist/rules/simulator/handler.js.map +1 -0
  422. package/dist/rules/simulator/mapdiff.d.ts +29 -0
  423. package/dist/rules/simulator/mapdiff.d.ts.map +1 -0
  424. package/dist/rules/simulator/mapdiff.js +72 -0
  425. package/dist/rules/simulator/mapdiff.js.map +1 -0
  426. package/dist/rules/simulator/project-after-state.d.ts +33 -0
  427. package/dist/rules/simulator/project-after-state.d.ts.map +1 -0
  428. package/dist/rules/simulator/project-after-state.js +88 -0
  429. package/dist/rules/simulator/project-after-state.js.map +1 -0
  430. package/dist/rules/simulator/query-proof.d.ts +80 -0
  431. package/dist/rules/simulator/query-proof.d.ts.map +1 -0
  432. package/dist/rules/simulator/query-proof.js +142 -0
  433. package/dist/rules/simulator/query-proof.js.map +1 -0
  434. package/dist/rules/simulator/value-equality.d.ts +8 -0
  435. package/dist/rules/simulator/value-equality.d.ts.map +1 -0
  436. package/dist/rules/simulator/value-equality.js +40 -0
  437. package/dist/rules/simulator/value-equality.js.map +1 -0
  438. package/dist/rules/simulator/wrappers/base.d.ts +129 -0
  439. package/dist/rules/simulator/wrappers/base.d.ts.map +1 -0
  440. package/dist/rules/simulator/wrappers/base.js +90 -0
  441. package/dist/rules/simulator/wrappers/base.js.map +1 -0
  442. package/dist/rules/simulator/wrappers/bytes.d.ts +45 -0
  443. package/dist/rules/simulator/wrappers/bytes.d.ts.map +1 -0
  444. package/dist/rules/simulator/wrappers/bytes.js +130 -0
  445. package/dist/rules/simulator/wrappers/bytes.js.map +1 -0
  446. package/dist/rules/simulator/wrappers/duration.d.ts +76 -0
  447. package/dist/rules/simulator/wrappers/duration.d.ts.map +1 -0
  448. package/dist/rules/simulator/wrappers/duration.js +176 -0
  449. package/dist/rules/simulator/wrappers/duration.js.map +1 -0
  450. package/dist/rules/simulator/wrappers/float.d.ts +52 -0
  451. package/dist/rules/simulator/wrappers/float.d.ts.map +1 -0
  452. package/dist/rules/simulator/wrappers/float.js +88 -0
  453. package/dist/rules/simulator/wrappers/float.js.map +1 -0
  454. package/dist/rules/simulator/wrappers/latlng.d.ts +40 -0
  455. package/dist/rules/simulator/wrappers/latlng.d.ts.map +1 -0
  456. package/dist/rules/simulator/wrappers/latlng.js +100 -0
  457. package/dist/rules/simulator/wrappers/latlng.js.map +1 -0
  458. package/dist/rules/simulator/wrappers/path.d.ts +75 -0
  459. package/dist/rules/simulator/wrappers/path.d.ts.map +1 -0
  460. package/dist/rules/simulator/wrappers/path.js +158 -0
  461. package/dist/rules/simulator/wrappers/path.js.map +1 -0
  462. package/dist/rules/simulator/wrappers/reference.d.ts +82 -0
  463. package/dist/rules/simulator/wrappers/reference.d.ts.map +1 -0
  464. package/dist/rules/simulator/wrappers/reference.js +145 -0
  465. package/dist/rules/simulator/wrappers/reference.js.map +1 -0
  466. package/dist/rules/simulator/wrappers/timestamp.d.ts +86 -0
  467. package/dist/rules/simulator/wrappers/timestamp.d.ts.map +1 -0
  468. package/dist/rules/simulator/wrappers/timestamp.js +207 -0
  469. package/dist/rules/simulator/wrappers/timestamp.js.map +1 -0
  470. package/dist/rules/simulator/wrappers/vector.d.ts +43 -0
  471. package/dist/rules/simulator/wrappers/vector.d.ts.map +1 -0
  472. package/dist/rules/simulator/wrappers/vector.js +80 -0
  473. package/dist/rules/simulator/wrappers/vector.js.map +1 -0
  474. package/dist/rules/simulator-tools-impl.d.ts +64 -0
  475. package/dist/rules/simulator-tools-impl.d.ts.map +1 -0
  476. package/dist/rules/simulator-tools-impl.js +462 -0
  477. package/dist/rules/simulator-tools-impl.js.map +1 -0
  478. package/dist/rules/simulator.d.ts +20 -0
  479. package/dist/rules/simulator.d.ts.map +1 -0
  480. package/dist/rules/simulator.js +24 -0
  481. package/dist/rules/simulator.js.map +1 -0
  482. package/dist/rules/stdlib-modules.d.ts +73 -0
  483. package/dist/rules/stdlib-modules.d.ts.map +1 -0
  484. package/dist/rules/stdlib-modules.js +849 -0
  485. package/dist/rules/stdlib-modules.js.map +1 -0
  486. package/dist/rules/stdlib-tools.d.ts +19 -0
  487. package/dist/rules/stdlib-tools.d.ts.map +1 -0
  488. package/dist/rules/stdlib-tools.js +164 -0
  489. package/dist/rules/stdlib-tools.js.map +1 -0
  490. package/dist/rules/test/handler.d.ts +9 -0
  491. package/dist/rules/test/handler.d.ts.map +1 -0
  492. package/dist/rules/test/handler.js +124 -0
  493. package/dist/rules/test/handler.js.map +1 -0
  494. package/dist/rules/test/spec.d.ts +517 -0
  495. package/dist/rules/test/spec.d.ts.map +1 -0
  496. package/dist/rules/test/spec.js +227 -0
  497. package/dist/rules/test/spec.js.map +1 -0
  498. package/dist/rules/tools.d.ts +41 -0
  499. package/dist/rules/tools.d.ts.map +1 -0
  500. package/dist/rules/tools.js +124 -0
  501. package/dist/rules/tools.js.map +1 -0
  502. package/dist/rules/write/handler.d.ts +6 -0
  503. package/dist/rules/write/handler.d.ts.map +1 -0
  504. package/dist/rules/write/handler.js +126 -0
  505. package/dist/rules/write/handler.js.map +1 -0
  506. package/dist/rules/write/spec.d.ts +28 -0
  507. package/dist/rules/write/spec.d.ts.map +1 -0
  508. package/dist/rules/write/spec.js +2 -0
  509. package/dist/rules/write/spec.js.map +1 -0
  510. package/dist/sandbox/admin-compat.d.ts +20 -0
  511. package/dist/sandbox/admin-compat.d.ts.map +1 -0
  512. package/dist/sandbox/admin-compat.js +19 -0
  513. package/dist/sandbox/admin-compat.js.map +1 -0
  514. package/dist/sandbox/admin-firestore/error-translation.d.ts +86 -0
  515. package/dist/sandbox/admin-firestore/error-translation.d.ts.map +1 -0
  516. package/dist/sandbox/admin-firestore/error-translation.js +204 -0
  517. package/dist/sandbox/admin-firestore/error-translation.js.map +1 -0
  518. package/dist/sandbox/admin-firestore/index.d.ts +169 -0
  519. package/dist/sandbox/admin-firestore/index.d.ts.map +1 -0
  520. package/dist/sandbox/admin-firestore/index.js +456 -0
  521. package/dist/sandbox/admin-firestore/index.js.map +1 -0
  522. package/dist/sandbox/admin-firestore/remote.d.ts +97 -0
  523. package/dist/sandbox/admin-firestore/remote.d.ts.map +1 -0
  524. package/dist/sandbox/admin-firestore/remote.js +735 -0
  525. package/dist/sandbox/admin-firestore/remote.js.map +1 -0
  526. package/dist/sandbox/branches/index.d.ts +141 -0
  527. package/dist/sandbox/branches/index.d.ts.map +1 -0
  528. package/dist/sandbox/branches/index.js +327 -0
  529. package/dist/sandbox/branches/index.js.map +1 -0
  530. package/dist/sandbox/firestore/admin-compat/batch.d.ts +34 -0
  531. package/dist/sandbox/firestore/admin-compat/batch.d.ts.map +1 -0
  532. package/dist/sandbox/firestore/admin-compat/batch.js +73 -0
  533. package/dist/sandbox/firestore/admin-compat/batch.js.map +1 -0
  534. package/dist/sandbox/firestore/admin-compat/doc-ref.d.ts +38 -0
  535. package/dist/sandbox/firestore/admin-compat/doc-ref.d.ts.map +1 -0
  536. package/dist/sandbox/firestore/admin-compat/doc-ref.js +154 -0
  537. package/dist/sandbox/firestore/admin-compat/doc-ref.js.map +1 -0
  538. package/dist/sandbox/firestore/admin-compat/firestore.d.ts +45 -0
  539. package/dist/sandbox/firestore/admin-compat/firestore.d.ts.map +1 -0
  540. package/dist/sandbox/firestore/admin-compat/firestore.js +114 -0
  541. package/dist/sandbox/firestore/admin-compat/firestore.js.map +1 -0
  542. package/dist/sandbox/firestore/admin-compat/index.d.ts +45 -0
  543. package/dist/sandbox/firestore/admin-compat/index.d.ts.map +1 -0
  544. package/dist/sandbox/firestore/admin-compat/index.js +27 -0
  545. package/dist/sandbox/firestore/admin-compat/index.js.map +1 -0
  546. package/dist/sandbox/firestore/admin-compat/paths.d.ts +37 -0
  547. package/dist/sandbox/firestore/admin-compat/paths.d.ts.map +1 -0
  548. package/dist/sandbox/firestore/admin-compat/paths.js +49 -0
  549. package/dist/sandbox/firestore/admin-compat/paths.js.map +1 -0
  550. package/dist/sandbox/firestore/admin-compat/query.d.ts +261 -0
  551. package/dist/sandbox/firestore/admin-compat/query.d.ts.map +1 -0
  552. package/dist/sandbox/firestore/admin-compat/query.js +704 -0
  553. package/dist/sandbox/firestore/admin-compat/query.js.map +1 -0
  554. package/dist/sandbox/firestore/admin-compat/read-translation.d.ts +8 -0
  555. package/dist/sandbox/firestore/admin-compat/read-translation.d.ts.map +1 -0
  556. package/dist/sandbox/firestore/admin-compat/read-translation.js +59 -0
  557. package/dist/sandbox/firestore/admin-compat/read-translation.js.map +1 -0
  558. package/dist/sandbox/firestore/admin-compat/snapshots.d.ts +39 -0
  559. package/dist/sandbox/firestore/admin-compat/snapshots.d.ts.map +1 -0
  560. package/dist/sandbox/firestore/admin-compat/snapshots.js +50 -0
  561. package/dist/sandbox/firestore/admin-compat/snapshots.js.map +1 -0
  562. package/dist/sandbox/firestore/admin-compat/transaction.d.ts +35 -0
  563. package/dist/sandbox/firestore/admin-compat/transaction.d.ts.map +1 -0
  564. package/dist/sandbox/firestore/admin-compat/transaction.js +88 -0
  565. package/dist/sandbox/firestore/admin-compat/transaction.js.map +1 -0
  566. package/dist/sandbox/firestore/admin-compat/types.d.ts +297 -0
  567. package/dist/sandbox/firestore/admin-compat/types.d.ts.map +1 -0
  568. package/dist/sandbox/firestore/admin-compat/types.js +127 -0
  569. package/dist/sandbox/firestore/admin-compat/types.js.map +1 -0
  570. package/dist/sandbox/firestore/admin-compat/value-order.d.ts +49 -0
  571. package/dist/sandbox/firestore/admin-compat/value-order.d.ts.map +1 -0
  572. package/dist/sandbox/firestore/admin-compat/value-order.js +172 -0
  573. package/dist/sandbox/firestore/admin-compat/value-order.js.map +1 -0
  574. package/dist/sandbox/firestore/auto-id.d.ts +26 -0
  575. package/dist/sandbox/firestore/auto-id.d.ts.map +1 -0
  576. package/dist/sandbox/firestore/auto-id.js +36 -0
  577. package/dist/sandbox/firestore/auto-id.js.map +1 -0
  578. package/dist/sandbox/firestore/converters/bytes-geopoint.d.ts +48 -0
  579. package/dist/sandbox/firestore/converters/bytes-geopoint.d.ts.map +1 -0
  580. package/dist/sandbox/firestore/converters/bytes-geopoint.js +85 -0
  581. package/dist/sandbox/firestore/converters/bytes-geopoint.js.map +1 -0
  582. package/dist/sandbox/firestore/converters/fieldvalue.d.ts +69 -0
  583. package/dist/sandbox/firestore/converters/fieldvalue.d.ts.map +1 -0
  584. package/dist/sandbox/firestore/converters/fieldvalue.js +166 -0
  585. package/dist/sandbox/firestore/converters/fieldvalue.js.map +1 -0
  586. package/dist/sandbox/firestore/converters/reference.d.ts +31 -0
  587. package/dist/sandbox/firestore/converters/reference.d.ts.map +1 -0
  588. package/dist/sandbox/firestore/converters/reference.js +51 -0
  589. package/dist/sandbox/firestore/converters/reference.js.map +1 -0
  590. package/dist/sandbox/firestore/converters/timestamp.d.ts +32 -0
  591. package/dist/sandbox/firestore/converters/timestamp.d.ts.map +1 -0
  592. package/dist/sandbox/firestore/converters/timestamp.js +63 -0
  593. package/dist/sandbox/firestore/converters/timestamp.js.map +1 -0
  594. package/dist/sandbox/firestore/converters/user-timestamp.d.ts +46 -0
  595. package/dist/sandbox/firestore/converters/user-timestamp.d.ts.map +1 -0
  596. package/dist/sandbox/firestore/converters/user-timestamp.js +65 -0
  597. package/dist/sandbox/firestore/converters/user-timestamp.js.map +1 -0
  598. package/dist/sandbox/firestore/converters/vector.d.ts +24 -0
  599. package/dist/sandbox/firestore/converters/vector.d.ts.map +1 -0
  600. package/dist/sandbox/firestore/converters/vector.js +53 -0
  601. package/dist/sandbox/firestore/converters/vector.js.map +1 -0
  602. package/dist/sandbox/firestore/errors.d.ts +82 -0
  603. package/dist/sandbox/firestore/errors.d.ts.map +1 -0
  604. package/dist/sandbox/firestore/errors.js +54 -0
  605. package/dist/sandbox/firestore/errors.js.map +1 -0
  606. package/dist/sandbox/firestore/event-log.d.ts +99 -0
  607. package/dist/sandbox/firestore/event-log.d.ts.map +1 -0
  608. package/dist/sandbox/firestore/event-log.js +67 -0
  609. package/dist/sandbox/firestore/event-log.js.map +1 -0
  610. package/dist/sandbox/firestore/field-merge.d.ts +64 -0
  611. package/dist/sandbox/firestore/field-merge.d.ts.map +1 -0
  612. package/dist/sandbox/firestore/field-merge.js +221 -0
  613. package/dist/sandbox/firestore/field-merge.js.map +1 -0
  614. package/dist/sandbox/firestore/list-query-proof.d.ts +77 -0
  615. package/dist/sandbox/firestore/list-query-proof.d.ts.map +1 -0
  616. package/dist/sandbox/firestore/list-query-proof.js +170 -0
  617. package/dist/sandbox/firestore/list-query-proof.js.map +1 -0
  618. package/dist/sandbox/firestore/local-environment.d.ts +806 -0
  619. package/dist/sandbox/firestore/local-environment.d.ts.map +1 -0
  620. package/dist/sandbox/firestore/local-environment.js +3028 -0
  621. package/dist/sandbox/firestore/local-environment.js.map +1 -0
  622. package/dist/sandbox/firestore/local-state.d.ts +196 -0
  623. package/dist/sandbox/firestore/local-state.d.ts.map +1 -0
  624. package/dist/sandbox/firestore/local-state.js +413 -0
  625. package/dist/sandbox/firestore/local-state.js.map +1 -0
  626. package/dist/sandbox/firestore/overlay-backing.d.ts +44 -0
  627. package/dist/sandbox/firestore/overlay-backing.d.ts.map +1 -0
  628. package/dist/sandbox/firestore/overlay-backing.js +82 -0
  629. package/dist/sandbox/firestore/overlay-backing.js.map +1 -0
  630. package/dist/sandbox/firestore/sentinel-capture.d.ts +30 -0
  631. package/dist/sandbox/firestore/sentinel-capture.d.ts.map +1 -0
  632. package/dist/sandbox/firestore/sentinel-capture.js +61 -0
  633. package/dist/sandbox/firestore/sentinel-capture.js.map +1 -0
  634. package/dist/sandbox/firestore/snapshot-listeners.d.ts +284 -0
  635. package/dist/sandbox/firestore/snapshot-listeners.d.ts.map +1 -0
  636. package/dist/sandbox/firestore/snapshot-listeners.js +194 -0
  637. package/dist/sandbox/firestore/snapshot-listeners.js.map +1 -0
  638. package/dist/sandbox/firestore/topk.d.ts +12 -0
  639. package/dist/sandbox/firestore/topk.d.ts.map +1 -0
  640. package/dist/sandbox/firestore/topk.js +42 -0
  641. package/dist/sandbox/firestore/topk.js.map +1 -0
  642. package/dist/sandbox/firestore/transaction-merge.d.ts +55 -0
  643. package/dist/sandbox/firestore/transaction-merge.d.ts.map +1 -0
  644. package/dist/sandbox/firestore/transaction-merge.js +107 -0
  645. package/dist/sandbox/firestore/transaction-merge.js.map +1 -0
  646. package/dist/sandbox/firestore/transaction-types.d.ts +152 -0
  647. package/dist/sandbox/firestore/transaction-types.d.ts.map +1 -0
  648. package/dist/sandbox/firestore/transaction-types.js +10 -0
  649. package/dist/sandbox/firestore/transaction-types.js.map +1 -0
  650. package/dist/sandbox/firestore/transaction.d.ts +79 -0
  651. package/dist/sandbox/firestore/transaction.d.ts.map +1 -0
  652. package/dist/sandbox/firestore/transaction.js +95 -0
  653. package/dist/sandbox/firestore/transaction.js.map +1 -0
  654. package/dist/sandbox/firestore/value-equality.d.ts +2 -0
  655. package/dist/sandbox/firestore/value-equality.d.ts.map +1 -0
  656. package/dist/sandbox/firestore/value-equality.js +35 -0
  657. package/dist/sandbox/firestore/value-equality.js.map +1 -0
  658. package/dist/sandbox/firestore/value-resolver.d.ts +172 -0
  659. package/dist/sandbox/firestore/value-resolver.d.ts.map +1 -0
  660. package/dist/sandbox/firestore/value-resolver.js +221 -0
  661. package/dist/sandbox/firestore/value-resolver.js.map +1 -0
  662. package/dist/sandbox/firestore/wire-encoder.d.ts +14 -0
  663. package/dist/sandbox/firestore/wire-encoder.d.ts.map +1 -0
  664. package/dist/sandbox/firestore/wire-encoder.js +130 -0
  665. package/dist/sandbox/firestore/wire-encoder.js.map +1 -0
  666. package/dist/sandbox/index.d.ts +50 -0
  667. package/dist/sandbox/index.d.ts.map +1 -0
  668. package/dist/sandbox/index.js +63 -0
  669. package/dist/sandbox/index.js.map +1 -0
  670. package/dist/sandbox/internal/index.d.ts +36 -0
  671. package/dist/sandbox/internal/index.d.ts.map +1 -0
  672. package/dist/sandbox/internal/index.js +72 -0
  673. package/dist/sandbox/internal/index.js.map +1 -0
  674. package/dist/sandbox/internal/sandbox-impl.d.ts +343 -0
  675. package/dist/sandbox/internal/sandbox-impl.d.ts.map +1 -0
  676. package/dist/sandbox/internal/sandbox-impl.js +718 -0
  677. package/dist/sandbox/internal/sandbox-impl.js.map +1 -0
  678. package/dist/sandbox/persistence/backends.d.ts +37 -0
  679. package/dist/sandbox/persistence/backends.d.ts.map +1 -0
  680. package/dist/sandbox/persistence/backends.js +202 -0
  681. package/dist/sandbox/persistence/backends.js.map +1 -0
  682. package/dist/sandbox/persistence/chunk-format.d.ts +58 -0
  683. package/dist/sandbox/persistence/chunk-format.d.ts.map +1 -0
  684. package/dist/sandbox/persistence/chunk-format.js +163 -0
  685. package/dist/sandbox/persistence/chunk-format.js.map +1 -0
  686. package/dist/sandbox/persistence/controller.d.ts +39 -0
  687. package/dist/sandbox/persistence/controller.d.ts.map +1 -0
  688. package/dist/sandbox/persistence/controller.js +605 -0
  689. package/dist/sandbox/persistence/controller.js.map +1 -0
  690. package/dist/sandbox/persistence/index.d.ts +13 -0
  691. package/dist/sandbox/persistence/index.d.ts.map +1 -0
  692. package/dist/sandbox/persistence/index.js +5 -0
  693. package/dist/sandbox/persistence/index.js.map +1 -0
  694. package/dist/sandbox/persistence/serialize.d.ts +53 -0
  695. package/dist/sandbox/persistence/serialize.d.ts.map +1 -0
  696. package/dist/sandbox/persistence/serialize.js +98 -0
  697. package/dist/sandbox/persistence/serialize.js.map +1 -0
  698. package/dist/sandbox/persistence/types.d.ts +118 -0
  699. package/dist/sandbox/persistence/types.d.ts.map +1 -0
  700. package/dist/sandbox/persistence/types.js +15 -0
  701. package/dist/sandbox/persistence/types.js.map +1 -0
  702. package/dist/sandbox/remote.d.ts +118 -0
  703. package/dist/sandbox/remote.d.ts.map +1 -0
  704. package/dist/sandbox/remote.js +60 -0
  705. package/dist/sandbox/remote.js.map +1 -0
  706. package/dist/sandbox/replay/index.d.ts +106 -0
  707. package/dist/sandbox/replay/index.d.ts.map +1 -0
  708. package/dist/sandbox/replay/index.js +246 -0
  709. package/dist/sandbox/replay/index.js.map +1 -0
  710. package/dist/sandbox/sandbox-context.d.ts +40 -0
  711. package/dist/sandbox/sandbox-context.d.ts.map +1 -0
  712. package/dist/sandbox/sandbox-context.js +72 -0
  713. package/dist/sandbox/sandbox-context.js.map +1 -0
  714. package/dist/sandbox/tab-sync/index.d.ts +120 -0
  715. package/dist/sandbox/tab-sync/index.d.ts.map +1 -0
  716. package/dist/sandbox/tab-sync/index.js +272 -0
  717. package/dist/sandbox/tab-sync/index.js.map +1 -0
  718. package/dist/sandbox/types.d.ts +1235 -0
  719. package/dist/sandbox/types.d.ts.map +1 -0
  720. package/dist/sandbox/types.js +46 -0
  721. package/dist/sandbox/types.js.map +1 -0
  722. package/dist/storage/admin/api.d.ts +206 -0
  723. package/dist/storage/admin/api.d.ts.map +1 -0
  724. package/dist/storage/admin/api.js +349 -0
  725. package/dist/storage/admin/api.js.map +1 -0
  726. package/dist/storage/admin/handler.d.ts +29 -0
  727. package/dist/storage/admin/handler.d.ts.map +1 -0
  728. package/dist/storage/admin/handler.js +82 -0
  729. package/dist/storage/admin/handler.js.map +1 -0
  730. package/dist/storage/admin/spec.d.ts +64 -0
  731. package/dist/storage/admin/spec.d.ts.map +1 -0
  732. package/dist/storage/admin/spec.js +8 -0
  733. package/dist/storage/admin/spec.js.map +1 -0
  734. package/dist/storage/admin/tools.d.ts +23 -0
  735. package/dist/storage/admin/tools.d.ts.map +1 -0
  736. package/dist/storage/admin/tools.js +90 -0
  737. package/dist/storage/admin/tools.js.map +1 -0
  738. package/dist/storage/download.d.ts +27 -0
  739. package/dist/storage/download.d.ts.map +1 -0
  740. package/dist/storage/download.js +136 -0
  741. package/dist/storage/download.js.map +1 -0
  742. package/dist/storage/enforce.d.ts +26 -0
  743. package/dist/storage/enforce.d.ts.map +1 -0
  744. package/dist/storage/enforce.js +16 -0
  745. package/dist/storage/enforce.js.map +1 -0
  746. package/dist/storage/errors.d.ts +46 -0
  747. package/dist/storage/errors.d.ts.map +1 -0
  748. package/dist/storage/errors.js +62 -0
  749. package/dist/storage/errors.js.map +1 -0
  750. package/dist/storage/index.d.ts +49 -0
  751. package/dist/storage/index.d.ts.map +1 -0
  752. package/dist/storage/index.js +60 -0
  753. package/dist/storage/index.js.map +1 -0
  754. package/dist/storage/internal.d.ts +18 -0
  755. package/dist/storage/internal.d.ts.map +1 -0
  756. package/dist/storage/internal.js +18 -0
  757. package/dist/storage/internal.js.map +1 -0
  758. package/dist/storage/list.d.ts +17 -0
  759. package/dist/storage/list.d.ts.map +1 -0
  760. package/dist/storage/list.js +91 -0
  761. package/dist/storage/list.js.map +1 -0
  762. package/dist/storage/metadata.d.ts +86 -0
  763. package/dist/storage/metadata.d.ts.map +1 -0
  764. package/dist/storage/metadata.js +167 -0
  765. package/dist/storage/metadata.js.map +1 -0
  766. package/dist/storage/persistence.d.ts +134 -0
  767. package/dist/storage/persistence.d.ts.map +1 -0
  768. package/dist/storage/persistence.js +132 -0
  769. package/dist/storage/persistence.js.map +1 -0
  770. package/dist/storage/reference.d.ts +63 -0
  771. package/dist/storage/reference.d.ts.map +1 -0
  772. package/dist/storage/reference.js +156 -0
  773. package/dist/storage/reference.js.map +1 -0
  774. package/dist/storage/rules.d.ts +176 -0
  775. package/dist/storage/rules.d.ts.map +1 -0
  776. package/dist/storage/rules.js +621 -0
  777. package/dist/storage/rules.js.map +1 -0
  778. package/dist/storage/service.d.ts +139 -0
  779. package/dist/storage/service.d.ts.map +1 -0
  780. package/dist/storage/service.js +241 -0
  781. package/dist/storage/service.js.map +1 -0
  782. package/dist/storage/upload.d.ts +43 -0
  783. package/dist/storage/upload.d.ts.map +1 -0
  784. package/dist/storage/upload.js +235 -0
  785. package/dist/storage/upload.js.map +1 -0
  786. package/package.json +109 -3
@@ -0,0 +1,456 @@
1
+ /**
2
+ * `pyric-admin` — Admin-SDK-shaped chainable Firestore adapter for
3
+ * the Pyric sandbox.
4
+ *
5
+ * `getFirestore(ctx)` returns a `SandboxFirestore` whose operations
6
+ * run under the context's auth identity and against the underlying
7
+ * `LocalEnvironment` of the context's sandbox. Idempotent — a second
8
+ * call with the same `SandboxContext` returns the same wrapper.
9
+ *
10
+ * Wraps the `pyric/sandbox/admin-compat` implementation.
11
+ * Per-operation methods construct a fresh delegate so a
12
+ * `sandbox.reset()` (which swaps the underlying environment) is
13
+ * picked up on the next operation. Refs returned from the wrapper
14
+ * (`DocumentReference`, `Query`) are bound to whichever environment
15
+ * was live when they were obtained — re-acquire them after reset to
16
+ * avoid stale-state confusion.
17
+ */
18
+ import { createCompatFirestore } from 'pyric/sandbox/admin-compat';
19
+ import { isRemoteSandbox, SandboxError } from 'pyric/sandbox';
20
+ import { getInternalEnv } from 'pyric/sandbox/internal';
21
+ import { CONTEXT_SYMBOL, registerOnSnapshotImpl, wrapWithErrorTranslation } from './error-translation.js';
22
+ import { createRemoteFirestore, getRemoteSnapshotRegistrar, registerRemoteOnSnapshotImpl, } from './remote.js';
23
+ export { SandboxError } from 'pyric/sandbox';
24
+ export { FieldValue, Timestamp } from 'pyric/sandbox/admin-compat';
25
+ /**
26
+ * Internal channel for the modular `pyric/firestore` layer to mark a
27
+ * listener as live (identity follows `sandbox.currentUser`) vs frozen
28
+ * (`getFirestore(ctx)`, pinned identity). The chainable adapter sees only
29
+ * a `SandboxContext` per call and can't tell the two apart on its own — the
30
+ * live-vs-frozen distinction lives one layer up. The modular `onSnapshot`
31
+ * stamps this symbol onto the options object it forwards; {@link onSnapshot}
32
+ * here reads + strips it and threads the boolean into
33
+ * `LocalEnvironment.addSnapshotListener`'s `followsCurrentUser` parameter.
34
+ *
35
+ * Symbol-keyed (not a named field) so it never collides with a real
36
+ * `SnapshotListenOptions` field and never leaks to consumer code.
37
+ */
38
+ export const FOLLOWS_CURRENT_USER = Symbol('pyric/firestore/followsCurrentUser');
39
+ /**
40
+ * Idempotency cache. Each `SandboxContext` gets its own handle because
41
+ * each context carries its own auth identity. Cached by reference,
42
+ * garbage-collected with the context.
43
+ */
44
+ const handleCache = new WeakMap();
45
+ /**
46
+ * Build a `SandboxFirestore` that delegates each operation to a freshly
47
+ * constructed compat impl. Constructing the delegate per-call is cheap
48
+ * (no allocation cost beyond the class instance) and ensures the
49
+ * operation reads from whatever environment the sandbox currently
50
+ * exposes — `reset()` propagates without explicit cache invalidation.
51
+ *
52
+ * The handle ignores any per-op `OperationOptions` it receives and
53
+ * always issues operations under `ctx.auth`. To test as a different
54
+ * user, derive a sibling context via `sandbox.withAuth(...)` and
55
+ * attach a service handle to that.
56
+ */
57
+ function buildFirestoreHandle(ctx, bypassRules = false) {
58
+ // Invariant: remote-branded sandboxes are dispatched to the channel-backed
59
+ // arm by getFirestore/getAdminFirestore before this builder runs. Reaching
60
+ // here with a remote ctx means a dispatch bug, not a capability gap.
61
+ if (isRemoteSandbox(ctx.sandbox)) {
62
+ throw new Error('pyric/sandbox/admin-firestore: internal — a remote sandbox context ' +
63
+ 'reached the local engine builder; remote dispatch should have ' +
64
+ 'handled it. Please report this.');
65
+ }
66
+ const delegate = () => createCompatFirestore(getInternalEnv(ctx.sandbox), { auth: ctx.auth, bypassRules });
67
+ return {
68
+ // ── Production-shaped surface ────────────────────────────────────
69
+ collection(path) {
70
+ return delegate().collection(path);
71
+ },
72
+ doc(path) {
73
+ return delegate().doc(path);
74
+ },
75
+ collectionGroup(collectionId) {
76
+ return delegate().collectionGroup(collectionId);
77
+ },
78
+ batch() {
79
+ return delegate().batch();
80
+ },
81
+ runTransaction(fn, _opts) {
82
+ return delegate().runTransaction(fn);
83
+ },
84
+ // ── Sandbox-only surface ─────────────────────────────────────────
85
+ setRules(rules) {
86
+ return getInternalEnv(ctx.sandbox).deployRules(rules);
87
+ },
88
+ seed(options) {
89
+ const env = getInternalEnv(ctx.sandbox);
90
+ // `LocalEnvironment.seed` rebuilds state and returns the lint of
91
+ // the (preserved) ruleset. Pass the current rules through so
92
+ // `db.seed({ documents })` doesn't accidentally clear them.
93
+ return env.seed({
94
+ rules: env.getRules(),
95
+ documents: options?.documents ?? {},
96
+ });
97
+ },
98
+ snapshot() {
99
+ return getInternalEnv(ctx.sandbox).snapshot();
100
+ },
101
+ };
102
+ }
103
+ /**
104
+ * Resolve the Firestore service handle for a context. Idempotent —
105
+ * subsequent calls with the same context return the same wrapper.
106
+ *
107
+ * Requires a `SandboxContext`, never a bare `Sandbox`. Anonymous is
108
+ * `sandbox.withAuth(null)`, written explicitly — every call site
109
+ * states identity.
110
+ *
111
+ * @example
112
+ * ```ts
113
+ * import { initializeSandbox } from 'pyric/sandbox';
114
+ * import { getFirestore } from 'pyric-admin/firestore';
115
+ *
116
+ * const sandbox = initializeSandbox();
117
+ * const db = getFirestore(sandbox.withAuth({ uid: 'alice' }));
118
+ * db.setRules(MY_RULES);
119
+ * db.seed({ documents: { 'tickets/T-1': { ... } } });
120
+ *
121
+ * // Different identity? Different context, same data.
122
+ * const dbAsBob = getFirestore(sandbox.withAuth({ uid: 'bob' }));
123
+ * ```
124
+ */
125
+ export function getFirestore(ctx) {
126
+ const cached = handleCache.get(ctx);
127
+ if (cached)
128
+ return cached;
129
+ // REMOTE ARM (remote sandbox, slice 2): a remote-branded sandbox has no
130
+ // in-process engine — return the channel-backed parallel implementation
131
+ // instead of building the local compat handle. Identity mapping: the
132
+ // context's frozen auth pins the per-op lens — `withAuth(null)` means
133
+ // `{ mode: 'anon' }` (an ABSENT lens would silently resolve to the
134
+ // browser tab's port session), and a signed identity pins
135
+ // `{ mode: 'as', uid, token? }` with the FULL claims token (the worker
136
+ // resolves it via `sandbox.withAuth({ uid, token })`, so custom claims
137
+ // evaluate in rules exactly as on the local arm).
138
+ const fresh = isRemoteSandbox(ctx.sandbox)
139
+ ? createRemoteFirestore(ctx.sandbox, lensForAuth(ctx.auth))
140
+ : // Wrap the raw handle so every operation (and every object returned
141
+ // from it: `DocumentReference`, `Query`, `WriteBatch`, `Transaction`)
142
+ // re-throws compat errors as `SandboxError` with structured
143
+ // `denialContext`. The wrapper also stashes `ctx` on every wrapped
144
+ // value via CONTEXT_SYMBOL so `onSnapshot` can recover it.
145
+ wrapWithErrorTranslation(buildFirestoreHandle(ctx), ctx);
146
+ handleCache.set(ctx, fresh);
147
+ return fresh;
148
+ }
149
+ /** Map a context's frozen `AuthState` to the worker-relay lens the remote
150
+ * arm pins on every op/sub. Never absent — see {@link getFirestore}. */
151
+ function lensForAuth(auth) {
152
+ if (auth === null || auth === undefined)
153
+ return { mode: 'anon' };
154
+ return auth.token === undefined
155
+ ? { mode: 'as', uid: auth.uid }
156
+ : { mode: 'as', uid: auth.uid, token: auth.token };
157
+ }
158
+ /**
159
+ * Idempotency cache for admin (rules-bypassing) handles. Keyed by ctx,
160
+ * SEPARATE from {@link handleCache} so the same `SandboxContext` can vend
161
+ * both a rules-enforced handle (`getFirestore`) and a rules-bypassing one
162
+ * (`getAdminFirestore`) without one clobbering the other.
163
+ */
164
+ const adminHandleCache = new WeakMap();
165
+ export function getAdminFirestore(target) {
166
+ // Admin reads/writes are identity-agnostic (rules are off), so a bare
167
+ // `Sandbox` is accepted as well as a `SandboxContext`. A bare sandbox is
168
+ // normalised to an anonymous ctx — the captured auth is irrelevant since
169
+ // no rule reads `request.auth` on the bypass path.
170
+ const ctx = isSandboxContext(target)
171
+ ? target
172
+ : target.withAuth(null);
173
+ const cached = adminHandleCache.get(ctx);
174
+ if (cached)
175
+ return cached;
176
+ // REMOTE ARM: rules bypass rides the worker's `{ mode: 'admin' }` lens
177
+ // (the same lens Studio's admin surface uses) — identity-agnostic, so
178
+ // the normalised ctx's auth is irrelevant, exactly like the local path.
179
+ const fresh = isRemoteSandbox(ctx.sandbox)
180
+ ? createRemoteFirestore(ctx.sandbox, { mode: 'admin' })
181
+ : wrapWithErrorTranslation(buildFirestoreHandle(ctx, true), ctx);
182
+ adminHandleCache.set(ctx, fresh);
183
+ return fresh;
184
+ }
185
+ /**
186
+ * Brand test for the `SandboxContext` overload of {@link getAdminFirestore}.
187
+ * A `SandboxContext` carries `withAuth` + a `sandbox` back-reference; a bare
188
+ * `Sandbox` carries `withAuth` too but also `admin`/`currentUser`. We test
189
+ * for the `sandbox` property which only the context has.
190
+ */
191
+ function isSandboxContext(target) {
192
+ return (target !== null &&
193
+ typeof target === 'object' &&
194
+ 'sandbox' in target &&
195
+ typeof target.withAuth === 'function');
196
+ }
197
+ // ─── onSnapshot ────────────────────────────────────────────────────────
198
+ //
199
+ // Web-SDK-shaped streaming reads. The four overloads mirror
200
+ // `firebase/firestore`'s `onSnapshot` so existing call sites copied from
201
+ // production code typecheck unchanged.
202
+ //
203
+ // Routing:
204
+ // - `DocumentReference` → `LocalEnvironment.addSnapshotListener`
205
+ // with `target = { kind: 'doc', path }`.
206
+ // - `CollectionReference` (and any `Query` whose collection root is
207
+ // reachable via `.path` or `.parent.path`) → `target = { kind: 'query', collection }`.
208
+ // - Chained queries (`.where`/`.orderBy`/`.limit`) currently route as
209
+ // whole-collection listeners; the simulator fires for any change in
210
+ // the collection, and the callback receives every document. Slice 6
211
+ // will add filter/order honoring at the listener layer.
212
+ //
213
+ // The registering context's `auth` is captured at register time and
214
+ // threaded through to `addSnapshotListener` so notifications evaluate
215
+ // rules under the auth that subscribed — not whatever auth happens to
216
+ // be active when a write triggers dispatch
217
+ // (`addSnapshotListener`'s auth-capture invariant).
218
+ /**
219
+ * Extract a `{ collectionPath }` for query-shaped refs. The compat
220
+ * `QueryImpl` keeps its `collectionPath` as a `protected` field, but
221
+ * `CollectionRefImpl` exposes it via the public `path` getter, and
222
+ * chained queries (the only thing `where`/`orderBy`/`limit` produces)
223
+ * inherit from `QueryImpl` — both expose the same internal field.
224
+ *
225
+ * Read it via a structural lookup rather than `instanceof` so this
226
+ * adapter never has to import the compat impl class (which would create
227
+ * a circular dependency through `pyric/sandbox/admin-compat`).
228
+ *
229
+ * Returns `null` for refs we cannot route (anonymous/foreign Query
230
+ * implementations); the caller throws a clear remediation error.
231
+ */
232
+ function extractCollectionPath(ref) {
233
+ if (ref === null || typeof ref !== 'object')
234
+ return null;
235
+ const obj = ref;
236
+ // CollectionReference exposes `path` publicly.
237
+ if (typeof obj.path === 'string' && obj.path.length > 0)
238
+ return obj.path;
239
+ // QueryImpl keeps it on a protected field; protected is a TypeScript-
240
+ // only restriction at runtime, so this lookup succeeds for anything
241
+ // produced by `db.collection('x').where(...)` etc.
242
+ if (typeof obj.collectionPath === 'string' && obj.collectionPath.length > 0) {
243
+ return obj.collectionPath;
244
+ }
245
+ return null;
246
+ }
247
+ /**
248
+ * Pull the query's `where` / `orderBy` / cursor / `limit` constraints
249
+ * off a query-shaped ref as a pure row transformer (FS-B2), so a
250
+ * filtered `onSnapshot(query(...))` delivers the same membership as a
251
+ * one-shot `getDocs(query(...))`. `QueryImpl.snapshotConstraints()` is a
252
+ * public method on every query produced by `db.collection(...).where(...)`
253
+ * etc.; a bare `CollectionReference` returns `undefined` (no filtering).
254
+ * Structural lookup keeps this adapter from importing the compat class.
255
+ */
256
+ function extractSnapshotConstraints(ref) {
257
+ if (ref !== null && typeof ref === 'object') {
258
+ const fn = ref.snapshotConstraints;
259
+ if (typeof fn === 'function') {
260
+ return fn.call(ref);
261
+ }
262
+ }
263
+ return undefined;
264
+ }
265
+ /**
266
+ * Discriminate a `DocumentReference` from a `Query`/`CollectionReference`.
267
+ * The Admin-shaped `DocumentReference` always has a `parent: CollectionReference`
268
+ * field; `Query` and `CollectionReference` do not have a `parent` field.
269
+ */
270
+ function isDocumentReference(ref) {
271
+ if (ref === null || typeof ref !== 'object')
272
+ return false;
273
+ const obj = ref;
274
+ return (typeof obj.path === 'string' &&
275
+ obj.path.length > 0 &&
276
+ obj.parent !== undefined &&
277
+ obj.parent !== null);
278
+ }
279
+ /**
280
+ * Implementation. The argument shape is normalized into
281
+ * `{ options, onNext, onError, onCompletion }` here, then routed to
282
+ * `LocalEnvironment.addSnapshotListener`.
283
+ *
284
+ * `onCompletion` is accepted but never invoked: the local listener
285
+ * stream has no terminal state. Documented in the `SnapshotObserver`
286
+ * contract.
287
+ *
288
+ * Routing failures (Query without a discoverable collection path, or a
289
+ * ref that is neither doc nor query) throw immediately — they indicate
290
+ * a programming mistake the caller can fix. Per-call rule denials, by
291
+ * contrast, are routed through `onError` (or swallowed if no handler is
292
+ * supplied), matching production `onSnapshot` behavior.
293
+ */
294
+ export function onSnapshot(reference,
295
+ // `any`-typed callback in the impl signature is intentional: each
296
+ // overload narrows the callback to a specific snapshot shape, but
297
+ // function parameter types are contravariant — a `(snap: LiveDoc) => void`
298
+ // is *not* assignable to a `(snap: unknown) => void`. Using `any`
299
+ // here keeps every overload assignable to the impl signature without
300
+ // weakening the public surface (the overloads are what consumers see).
301
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
302
+ arg2,
303
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
304
+ arg3, arg4, arg5) {
305
+ // ── Normalize the (options, observer | callback set) variations. ──
306
+ let options = {};
307
+ let onNext;
308
+ let onError;
309
+ // Detect whether arg2 is the SnapshotListenOptions slot. The options
310
+ // object is the only plain-object value at arg2 that lacks both `next`
311
+ // and an `error` handler shaped like a function — the observer form
312
+ // always has at least one handler. This matches how the Web SDK
313
+ // discriminates.
314
+ const arg2IsOptions = typeof arg2 === 'object' &&
315
+ arg2 !== null &&
316
+ typeof arg2.next !== 'function' &&
317
+ typeof arg2.error !== 'function' &&
318
+ typeof arg2.complete !== 'function';
319
+ if (arg2IsOptions) {
320
+ options = arg2;
321
+ if (typeof arg3 === 'function') {
322
+ onNext = arg3;
323
+ onError = arg4;
324
+ // arg5 is onCompletion — accepted, never invoked (no terminal state).
325
+ }
326
+ else if (typeof arg3 === 'object' && arg3 !== null) {
327
+ const obs = arg3;
328
+ onNext = obs.next;
329
+ onError = obs.error;
330
+ }
331
+ }
332
+ else if (typeof arg2 === 'function') {
333
+ onNext = arg2;
334
+ onError = arg3;
335
+ // arg4 is onCompletion — accepted, never invoked.
336
+ }
337
+ else if (typeof arg2 === 'object' && arg2 !== null) {
338
+ const obs = arg2;
339
+ onNext = obs.next;
340
+ onError = obs.error;
341
+ }
342
+ if (!onNext && !onError) {
343
+ // FS-B14 — prod accepts an observer carrying only `error` (or
344
+ // `complete`); it registers and routes denials to the error handler.
345
+ // Only a fully-empty observer (no next AND no error) is a programming
346
+ // error. Pre-fix this required `next`, so an `{ error: fn }` observer
347
+ // threw "missing next handler".
348
+ throw new TypeError('onSnapshot: missing handler. Provide a callback, or an observer with a ' +
349
+ '`next` and/or `error` method.');
350
+ }
351
+ // The local listener stream has no terminal state, so a `next`-less
352
+ // observer registers purely to receive errors — `onNext` stays undefined
353
+ // and `addSnapshotListener` only fires the error path.
354
+ // ── REMOTE ARM: refs minted by the channel-backed handle carry their
355
+ // own listener registrar — dispatch on it BEFORE any local-engine
356
+ // resolution (`getInternalEnv` rejects remote handles). The registrar
357
+ // pins the handle's auth lens on the worker subscription; error
358
+ // callbacks receive `SandboxError`s with `denialContext` when the
359
+ // worker carried one.
360
+ const remoteRegistrar = getRemoteSnapshotRegistrar(reference);
361
+ if (remoteRegistrar) {
362
+ if (options[FOLLOWS_CURRENT_USER] === true) {
363
+ // The live-listener marker is stamped by the modular browser layer,
364
+ // which never runs against a remote handle — defensive throw so a
365
+ // future mis-wiring fails loudly instead of silently freezing.
366
+ throw new SandboxError('unimplemented', 'onSnapshot: live (follows-current-user) listeners are not supported on a ' +
367
+ 'remote sandbox — remote listeners are frozen to the identity of the ' +
368
+ 'context that created the ref.');
369
+ }
370
+ return remoteRegistrar(options, onNext, onError);
371
+ }
372
+ // ── Resolve the context + target from the ref. ──
373
+ const ctx = contextFromRef(reference);
374
+ const env = getInternalEnv(ctx.sandbox);
375
+ let target;
376
+ if (isDocumentReference(reference)) {
377
+ target = { kind: 'doc', path: reference.path };
378
+ }
379
+ else {
380
+ const collectionPath = extractCollectionPath(reference);
381
+ if (collectionPath === null) {
382
+ throw new TypeError('onSnapshot: could not determine the collection path for this Query. ' +
383
+ 'Pass a CollectionReference or a Query produced by `.where`/`.orderBy`/`.limit` ' +
384
+ 'on a CollectionReference obtained from `getFirestore(ctx)`.');
385
+ }
386
+ // FS-B2 — thread the query's where/orderBy/limit/cursor constraints
387
+ // into the target so the listener delivers a filtered/ordered/limited
388
+ // view (matching getDocs), not the whole collection.
389
+ const constraints = extractSnapshotConstraints(reference);
390
+ target = { kind: 'query', collection: collectionPath, constraints };
391
+ }
392
+ // Read the live-vs-frozen marker the modular layer stamped onto the
393
+ // options object (FOLLOWS_CURRENT_USER), then strip it so it never
394
+ // reaches the listener record's public `options`. Absent ⇒ frozen
395
+ // (the safe default for any direct chainable-adapter caller).
396
+ const followsCurrentUser = options[FOLLOWS_CURRENT_USER] === true;
397
+ if (FOLLOWS_CURRENT_USER in options) {
398
+ const { [FOLLOWS_CURRENT_USER]: _omit, ...rest } = options;
399
+ options = rest;
400
+ }
401
+ // A `next`-less (error-only) observer registers with a no-op data handler
402
+ // so the listener machinery stays on its non-optional callback contract;
403
+ // denials still route to `onError` (FS-B14).
404
+ return env.addSnapshotListener(target, onNext ?? (() => { }), options, ctx.auth, onError, followsCurrentUser);
405
+ }
406
+ /**
407
+ * Recover the {@link SandboxContext} that produced a ref. Refs returned
408
+ * from `db.doc(path)` / `db.collection(path)` are wrapped by
409
+ * `wrapWithErrorTranslation`, which stashes the owning context on the
410
+ * `CONTEXT_SYMBOL` property of every wrapped object. Reading that
411
+ * symbol gives us the auth + sandbox in one step — multiple contexts
412
+ * can share an env, and this lookup correctly picks the one that
413
+ * produced *this* ref.
414
+ */
415
+ function contextFromRef(ref) {
416
+ if (ref === null || typeof ref !== 'object') {
417
+ throw new TypeError('onSnapshot: reference must be a DocumentReference or Query.');
418
+ }
419
+ const ctx = ref[CONTEXT_SYMBOL];
420
+ if (!ctx) {
421
+ throw new TypeError('onSnapshot: reference was not produced by a sandbox context — pass a ref obtained from `getFirestore(ctx)`.');
422
+ }
423
+ return ctx;
424
+ }
425
+ // ─── Chainable `.onSnapshot(...)` shim ─────────────────────────────────
426
+ //
427
+ // The free `onSnapshot(ref, observer)` function above mirrors
428
+ // `firebase/firestore`'s modular shape. The rest of `pyric-admin` is
429
+ // chainable-method-shaped, though, and agents reach for
430
+ // `db.collection(path).where(...).onSnapshot(cb)` more often than the
431
+ // free form. To eliminate the asymmetry without losing the modular
432
+ // surface, we declare a chainable `.onSnapshot(...)` method on
433
+ // DocumentReference/CollectionReference/Query via module augmentation
434
+ // and synthesize the implementation in the error-translation Proxy.
435
+ // Both forms route through the same listener registration.
436
+ //
437
+ // The free function stays exported — both styles are first-class.
438
+ // Augmentation made the chainable `.onSnapshot()` method appear on
439
+ // DocumentReference and Query. Under the consolidated layout (admin-compat
440
+ // and admin-firestore in the same package), the augmentation strict-checks
441
+ // every impl class against this signature, which breaks the impl classes
442
+ // that don't define `.onSnapshot()` directly (the Proxy synthesizes it).
443
+ //
444
+ // Post-cutover behavior: use the free `onSnapshot(ref, observer)` function
445
+ // exported above. The chainable `ref.onSnapshot()` continues to work at
446
+ // runtime via the Proxy in error-translation.ts, but is no longer typed.
447
+ // A future iteration can revive the typed chainable variant by moving the
448
+ // augmentation into a separate consumer-facing declaration file that's
449
+ // excluded from impl compilation.
450
+ // Wire the synthesizer. Done at module init, after `onSnapshot` is
451
+ // fully declared so the function reference is stable. The remote arm's
452
+ // chainable `ref.onSnapshot(...)` late-binds through the same free
453
+ // function (a static back-import from remote.ts would be a cycle).
454
+ registerOnSnapshotImpl(onSnapshot);
455
+ registerRemoteOnSnapshotImpl(onSnapshot);
456
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/sandbox/admin-firestore/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAgBnE,OAAO,EAAE,eAAe,EAAE,YAAY,EAAoE,MAAM,eAAe,CAAC;AAChI,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAC1G,OAAO,EACL,qBAAqB,EACrB,0BAA0B,EAC1B,4BAA4B,GAC7B,MAAM,aAAa,CAAC;AAUrB,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAiC7C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AA2BnE;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAkB,MAAM,CAAC,oCAAoC,CAAC,CAAC;AAyDhG;;;;GAIG;AACH,MAAM,WAAW,GAAG,IAAI,OAAO,EAAoC,CAAC;AAEpE;;;;;;;;;;;GAWG;AACH,SAAS,oBAAoB,CAC3B,GAAmB,EACnB,WAAW,GAAG,KAAK;IAEnB,2EAA2E;IAC3E,2EAA2E;IAC3E,qEAAqE;IACrE,IAAI,eAAe,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;QACjC,MAAM,IAAI,KAAK,CACb,qEAAqE;YACnE,gEAAgE;YAChE,iCAAiC,CACpC,CAAC;IACJ,CAAC;IACD,MAAM,QAAQ,GAAG,GAAc,EAAE,CAC/B,qBAAqB,CAAC,cAAc,CAAC,GAAG,CAA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EAAE;AACF,8DAA8D;AAC9D,qEAAqE;AACrE,wDAAwD;AACxD,sEAAsE;AACtE,mEAAmE;AACnE,+DAA+D;AAC/D,sEAAsE;AACtE,oEAAoE;AACpE,2DAA2D;AAC3D,EAAE;AACF,kEAAkE;AAElE,mEAAmE;AACnE,2EAA2E;AAC3E,2EAA2E;AAC3E,yEAAyE;AACzE,yEAAyE;AACzE,EAAE;AACF,2EAA2E;AAC3E,wEAAwE;AACxE,yEAAyE;AACzE,0EAA0E;AAC1E,uEAAuE;AACvE,kCAAkC;AAElC,mEAAmE;AACnE,uEAAuE;AACvE,mEAAmE;AACnE,mEAAmE;AACnE,sBAAsB,CAAC,UAA8D,CAAC,CAAC;AACvF,4BAA4B,CAAC,UAA8D,CAAC,CAAC"}
@@ -0,0 +1,97 @@
1
+ /**
2
+ * Remote arm of the admin-shaped Firestore surface (remote sandbox,
3
+ * slice 2 / checkpoint 2).
4
+ *
5
+ * A PARALLEL channel-backed implementation of `pyric/sandbox/admin-compat`'s
6
+ * type surface (`Firestore` / `DocumentReference` / `Query` / `WriteBatch` /
7
+ * `Transaction`), per the remote-Firestore spike verdict: the local
8
+ * admin-compat layer is welded to `LocalEnvironment`'s SYNCHRONOUS engine
9
+ * seam and cannot run over a WebSocket, so the remote arm re-implements the
10
+ * SHAPE over `RemoteSandboxChannel.op`/`subscribe` worker-relay frames —
11
+ * exactly the fork `pyric-admin/database` took for RTDB. The two arms share
12
+ * the type surface and the conformance assertions, not the implementation.
13
+ *
14
+ * DEPENDENCY DIRECTION: this module lives in `pyric` and may only consume
15
+ * the STRUCTURAL channel contract from `pyric/sandbox`'s remote seam
16
+ * (`RemoteSandboxChannel` — one loose `op`, one loose `subscribe`). The
17
+ * concrete worker-protocol unions live in `pyric-tools`, which `pyric`
18
+ * cannot import; ops are spelled loosely (`{ method: 'getDoc', path,
19
+ * actAs }`) and kept structurally identical to
20
+ * `pyric-tools/src/serve/worker/protocol.ts`.
21
+ *
22
+ * IDENTITY: every op and every subscription pins an EXPLICIT `actAs` lens.
23
+ * An ABSENT lens resolves worker-side to the browser tab's PORT SESSION —
24
+ * whoever happens to be signed in in the tab — which is never what a
25
+ * server-side handle means. `getAdminFirestore` pins `{ mode: 'admin' }`
26
+ * (rules bypass); `getFirestore(ctx)` pins `{ mode: 'as', uid, token? }`
27
+ * for a signed identity or `{ mode: 'anon' }` for `withAuth(null)`. The
28
+ * `as` lens carries the FULL `AuthState` (uid + custom-claims token): the
29
+ * worker host resolves it via `sandbox.withAuth({ uid, token })`, so there
30
+ * is no identity-fidelity loss versus the local arm.
31
+ *
32
+ * VALUE CODEC: write payloads are encoded CLIENT-side to the plain-JSON
33
+ * marker forms the worker host rehydrates (`prepareWriteData`): admin
34
+ * `FieldValue` sentinels (`{ __type: 'increment', value }`) become wire
35
+ * `SentinelMarker`s (`{ __sentinel: 'increment', n }`), and Timestamp /
36
+ * Date / rules-wrapper scalars become their `toJSON()` marker shapes — so
37
+ * the worker STORES real typed values (rules comparisons and `orderBy`
38
+ * see a Timestamp, not a map). Read payloads arrive as the
39
+ * `SerializedDocData` JSON envelope and are rehydrated with the ONE shared
40
+ * codec (`pyric/firestore-values`' `rehydrateDocValue`) then translated to
41
+ * the compat field shapes (`translateReadData`) — the same shapes the
42
+ * local arm's read path yields.
43
+ *
44
+ * KNOWN CODEC DIVERGENCE (accepted): user data that happens to be SHAPED
45
+ * like a codec marker — a plain map such as `{ __type: 'timestamp',
46
+ * seconds, nanos }` or `{ type: 'firestore/timestamp/1.0', … }` — is
47
+ * TRANSMUTED into the real typed value on the relayed path (the host's
48
+ * `prepareWriteData` / constraint rehydration cannot tell an intentional
49
+ * marker from a lookalike), while an in-page `setDoc` of the same map
50
+ * stores a plain map. This is the persistence codec's own behavior (an
51
+ * IndexedDB save/reload transmutes the same shapes), so the relay is
52
+ * consistent with the sandbox's durability semantics rather than with
53
+ * the in-page live path — marker-shaped user data is already reserved
54
+ * vocabulary in this system.
55
+ *
56
+ * KNOWN CURSOR LIMITS: the wire has no document-key cursor, so snapshot
57
+ * cursors require explicit non-`__name__` orderBy fields and lose the
58
+ * implicit `__name__` tie-break — see {@link cursorValuesFromSnapshot}.
59
+ *
60
+ * TRANSACTIONS: the worker exposes no interactive transaction session; the
61
+ * protocol is optimistic — every `tx.get` is an ordinary `getDoc`/`getDocs`
62
+ * op recorded into a client-held read-set, and ONE `txnCommit` op ships
63
+ * `{ reads, writes }`. The worker re-reads each path inside a real sandbox
64
+ * transaction and compares SERIALIZED JSON STRINGS. The read-set therefore
65
+ * echoes the worker's ORIGINAL `SerializedDocData.json` strings verbatim —
66
+ * re-serializing rehydrated data on this side would risk cross-process
67
+ * key-order/format drift and phantom aborts (livelock under retry). On
68
+ * `{ code: 'aborted' }` the update function is re-run with a fresh
69
+ * transaction, up to {@link TXN_MAX_ATTEMPTS} attempts (the worker client's
70
+ * model, which itself matches the Firestore SDK default).
71
+ */
72
+ import { type AuthLens } from 'pyric/sandbox';
73
+ import type { RemoteSandbox } from 'pyric/sandbox';
74
+ import type { SandboxFirestore } from './index.js';
75
+ type RemoteSnapshotRegistrar = (options: {
76
+ includeMetadataChanges?: boolean;
77
+ }, onNext: ((snapshot: unknown) => void) | undefined, onError: ((error: unknown) => void) | undefined) => () => void;
78
+ /** Is this ref one of the remote arm's (carries the registrar hook)? */
79
+ export declare function getRemoteSnapshotRegistrar(ref: unknown): RemoteSnapshotRegistrar | undefined;
80
+ /**
81
+ * Late-bound reference to the free `onSnapshot` from `index.ts`, backing
82
+ * the chainable `ref.onSnapshot(...)` method on remote refs (parity with
83
+ * the local arm's Proxy-synthesized shim). Registered at module init from
84
+ * `index.ts` — a static import back would be a cycle at runtime.
85
+ */
86
+ type FreeOnSnapshot = (ref: unknown, ...args: unknown[]) => () => void;
87
+ export declare function registerRemoteOnSnapshotImpl(fn: FreeOnSnapshot): void;
88
+ /**
89
+ * Build the channel-backed `SandboxFirestore` for a remote sandbox handle.
90
+ * `lens` is pinned on EVERY op and subscription (see the module header for
91
+ * the identity mapping); path-shape validation matches the local arm so
92
+ * `invalid-argument` failures surface at the call site without a
93
+ * round-trip.
94
+ */
95
+ export declare function createRemoteFirestore(sandbox: RemoteSandbox, lens: AuthLens): SandboxFirestore;
96
+ export {};
97
+ //# sourceMappingURL=remote.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remote.d.ts","sourceRoot":"","sources":["../../../src/sandbox/admin-firestore/remote.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsEG;AAEH,OAAO,EAEL,KAAK,QAAQ,EAGd,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAmCnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAkQnD,KAAK,uBAAuB,GAAG,CAC7B,OAAO,EAAE;IAAE,sBAAsB,CAAC,EAAE,OAAO,CAAA;CAAE,EAC7C,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC,GAAG,SAAS,EACjD,OAAO,EAAE,CAAC,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC,GAAG,SAAS,KAC5C,MAAM,IAAI,CAAC;AAEhB,wEAAwE;AACxE,wBAAgB,0BAA0B,CAAC,GAAG,EAAE,OAAO,GAAG,uBAAuB,GAAG,SAAS,CAI5F;AAED;;;;;GAKG;AACH,KAAK,cAAc,GAAG,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,MAAM,IAAI,CAAC;AAGvE,wBAAgB,4BAA4B,CAAC,EAAE,EAAE,cAAc,GAAG,IAAI,CAErE;AAmgBD;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,aAAa,EACtB,IAAI,EAAE,QAAQ,GACb,gBAAgB,CA6DlB"}