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,605 @@
1
+ /**
2
+ * Persistence controller — wires a `PersistenceBackend` into a
3
+ * `SandboxImpl`. Owns the debounced auto-flush, the `beforeunload`
4
+ * safety flush, and the restore-on-attach pass.
5
+ *
6
+ * Conceptually orthogonal to the sandbox: the sandbox doesn't know
7
+ * persistence exists until `enablePersistence` constructs a controller
8
+ * and hands it the live sandbox. Disposing the controller detaches
9
+ * every side effect and leaves the sandbox unchanged.
10
+ */
11
+ import { SandboxImpl } from '../internal/sandbox-impl.js';
12
+ import { createIndexedDBBackend, createMemoryBackend } from './backends.js';
13
+ import { serializeToBuckets, deserializeFromBuckets, migrateV2ToRecords, } from './chunk-format.js';
14
+ const DEFAULT_FLUSH_INTERVAL_MS = 250;
15
+ /**
16
+ * Storage key for the persisted auth session uid. One key used across
17
+ * both `local` and `session` stores — the controller reads both (mode-
18
+ * agnostic load) and writes only one (based on the current mode). This
19
+ * mirrors how `pyric dev`'s `SessionStore` worked before the session
20
+ * logic moved here.
21
+ *
22
+ * Prefixed `pyric:sandbox:` so it's immediately grepable and doesn't
23
+ * collide with serve's `pyric:serve:` entries or app-level keys.
24
+ */
25
+ const SESSION_STORAGE_KEY = 'pyric:sandbox:auth-session';
26
+ /**
27
+ * Stable 32-bit FNV-1a content hash of a bucket record, for detecting which
28
+ * buckets changed between flushes. A genuinely changed record almost never
29
+ * hashes equal to its prior content; in the astronomically rare event of a
30
+ * collision the bucket simply re-persists on its next change. Bucket key order
31
+ * is stable across flushes (snapshot iteration order), so an UNCHANGED bucket
32
+ * always hashes identically.
33
+ */
34
+ function hashRecord(record) {
35
+ const s = JSON.stringify(record);
36
+ let h = 0x811c9dc5;
37
+ for (let i = 0; i < s.length; i++) {
38
+ h ^= s.charCodeAt(i);
39
+ h = Math.imul(h, 16777619) >>> 0;
40
+ }
41
+ return h;
42
+ }
43
+ /** Detect a storage-quota-exceeded error across environments (the DOMException
44
+ * name in browsers, a message fallback elsewhere). */
45
+ function isQuotaExceeded(e) {
46
+ if (e && typeof e === 'object') {
47
+ if (e.name === 'QuotaExceededError')
48
+ return true;
49
+ const msg = e.message;
50
+ if (typeof msg === 'string' && /quota/i.test(msg))
51
+ return true;
52
+ }
53
+ return false;
54
+ }
55
+ function pickBackend(options) {
56
+ if (options.injectedBackend)
57
+ return options.injectedBackend;
58
+ const requested = options.backend ?? 'indexedDB';
59
+ if (requested === 'memory')
60
+ return createMemoryBackend();
61
+ // `indexedDB` requested. In non-browser hosts we transparently fall
62
+ // back to memory so calling code paths can share an `enablePersistence`
63
+ // call across browser + test environments without branching.
64
+ if (typeof indexedDB === 'undefined')
65
+ return createMemoryBackend();
66
+ return createIndexedDBBackend();
67
+ }
68
+ /**
69
+ * Construct a controller, restore any prior snapshot, and wire the
70
+ * auto-flush subscription. Returns once restore has completed (callers
71
+ * can `await sandbox.enablePersistence(...)` and be sure the in-memory
72
+ * state reflects the persisted blob).
73
+ *
74
+ * Late service registration: services (e.g. auth) may register with the
75
+ * sandbox AFTER this call returns (the user calls `enablePersistence`
76
+ * then later `getAuth(sandbox)` which triggers `registerPersistableService`).
77
+ * We handle this in two parts:
78
+ * 1. `restore()` returns the raw `services` blob map so the controller
79
+ * can apply it to late-arriving services.
80
+ * 2. `setServiceRegistrationHook` fires on each registration — we
81
+ * immediately apply the saved blob data (if any) AND subscribe the
82
+ * service's change notifier for future flushes.
83
+ */
84
+ export async function attachPersistence(sandbox, rawOptions) {
85
+ const options = {
86
+ ...rawOptions,
87
+ flushIntervalMs: rawOptions.flushIntervalMs ?? DEFAULT_FLUSH_INTERVAL_MS,
88
+ backend: rawOptions.backend ?? 'indexedDB',
89
+ };
90
+ const backend = pickBackend(options);
91
+ // Content hash of each persisted bucket, so a flush writes only the buckets
92
+ // whose content actually changed. restore() seeds it from the records it reads,
93
+ // so the just-restored state is not redundantly re-written on the first flush.
94
+ const lastHashes = new Map();
95
+ // `restore()` returns the raw services blob — the controller keeps this
96
+ // so late-registering services can still receive their saved state even
97
+ // though they weren't in the registry when `restore()` ran.
98
+ const restoredServices = await restore(sandbox, backend, options.key, lastHashes);
99
+ let pendingFlush = null;
100
+ let disposed = false;
101
+ // Track unsubscribers for service change-notification hooks so we can
102
+ // clean up in dispose(). Keyed by service name (not strictly needed,
103
+ // but makes debugging easier).
104
+ const serviceUnsubs = new Map();
105
+ // The actual flush. Reads CURRENT state each time it runs.
106
+ const realFlush = async () => {
107
+ if (disposed)
108
+ return;
109
+ // `sandbox.snapshot()` now includes `{ firestore, services }` — the
110
+ // services map is built live from the registry, so services registered
111
+ // after enablePersistence (late registration) are naturally included.
112
+ const snap = sandbox.snapshot();
113
+ const records = serializeToBuckets(snap.firestore, snap.services, Date.now());
114
+ // Incremental flush: write ONLY the buckets whose content changed since the
115
+ // last flush, and delete buckets that disappeared. Comparison is by content
116
+ // hash, so it is safe by construction: a changed bucket cannot hash equal to
117
+ // its prior content, so no write is ever skipped (no write-site dirty-set to
118
+ // keep in sync). Put changed buckets BEFORE deleting removed ones, and adopt
119
+ // the new hashes only AFTER both land, so a crash mid-flush never loses live
120
+ // data and the next flush simply retries against the unchanged hash state.
121
+ const changed = new Map();
122
+ const nextHashes = new Map();
123
+ for (const [id, rec] of records) {
124
+ const h = hashRecord(rec);
125
+ nextHashes.set(id, h);
126
+ if (lastHashes.get(id) !== h)
127
+ changed.set(id, rec);
128
+ }
129
+ const removed = [...lastHashes.keys()].filter((id) => !records.has(id));
130
+ if (changed.size > 0)
131
+ await backend.putRecords(options.key, changed);
132
+ if (removed.length > 0)
133
+ await backend.deleteRecords(options.key, removed);
134
+ lastHashes.clear();
135
+ for (const [id, h] of nextHashes)
136
+ lastHashes.set(id, h);
137
+ };
138
+ // Serialize flushes on a single chain so two never overlap. Without this, a
139
+ // newer flush that fails while an older one succeeds could adopt a stale
140
+ // snapshot's hashes and silently drop the newer write. Each run waits for the
141
+ // previous (success OR failure) and re-derives changes from current state.
142
+ let flushChain = Promise.resolve();
143
+ const flushNow = () => {
144
+ if (pendingFlush) {
145
+ clearTimeout(pendingFlush);
146
+ pendingFlush = null;
147
+ }
148
+ flushChain = flushChain.then(realFlush, realFlush);
149
+ return flushChain;
150
+ };
151
+ const scheduleFlush = () => {
152
+ if (disposed)
153
+ return;
154
+ if (pendingFlush)
155
+ return;
156
+ pendingFlush = setTimeout(() => {
157
+ pendingFlush = null;
158
+ void flushNow().catch((e) => {
159
+ if (isQuotaExceeded(e)) {
160
+ // Storage is full: retrying will not help until space is freed, so
161
+ // warn loudly instead of busy-looping. The unpersisted changes stay in
162
+ // memory; the next successful flush (after space frees) re-detects them.
163
+ console.warn('[sandbox/persistence] storage quota exceeded; recent changes are kept ' +
164
+ 'in memory only. Free storage or reduce sandbox data to persist them.');
165
+ return;
166
+ }
167
+ console.warn('[sandbox/persistence] auto-flush failed, will retry:', e);
168
+ // A failed flush did not adopt its hashes, so the change is still
169
+ // unpersisted. Re-arm rather than waiting for the next write event, so
170
+ // an idle-after-failure does not leave the change permanently in memory.
171
+ scheduleFlush();
172
+ });
173
+ }, options.flushIntervalMs);
174
+ };
175
+ /**
176
+ * Wire up a service's optional change-notification hook. When a
177
+ * service provides `subscribe`, we call it here so auth-user edits
178
+ * trigger a debounced flush — not only the next Firestore write.
179
+ */
180
+ const attachServiceSubscription = (name, hooks) => {
181
+ if (!hooks.subscribe || serviceUnsubs.has(name))
182
+ return;
183
+ const unsub = hooks.subscribe(() => {
184
+ scheduleFlush();
185
+ });
186
+ serviceUnsubs.set(name, unsub);
187
+ };
188
+ // ─── Session persistence setup ─────────────────────────────────────
189
+ //
190
+ // Session persistence is ONLY active when `options.sessionStorage` is
191
+ // provided. When omitted, the user DB still persists (Phase 1) but the
192
+ // CURRENT SESSION is not restored — no fake durability (Decision 2).
193
+ //
194
+ // The session controller reads/writes a single uid JSON blob to the
195
+ // appropriate web-storage slot based on the auth mode. It discovers
196
+ // the auth service's session hooks by scanning the service registry
197
+ // (and via the late-registration hook for services registered after
198
+ // enablePersistence). Only one session provider is supported today
199
+ // (auth); a second service would need to add its own hooks.
200
+ /** Unsubscribers for session-change hooks; cleared in dispose(). */
201
+ const sessionUnsubs = new Map();
202
+ /**
203
+ * Save the current session uid to the appropriate web-storage slot,
204
+ * or clear both slots on sign-out or NONE mode.
205
+ *
206
+ * Called on every session-change event (sign-in, sign-out, mode change).
207
+ * Reads the CURRENT mode and uid at call time so stale closures can't
208
+ * cause incorrect slot choices (important for mode-migration: a mode
209
+ * change fires a session-change event, and we read the already-updated
210
+ * mode here).
211
+ */
212
+ const saveSession = (sessionHooks) => {
213
+ if (!options.sessionStorage)
214
+ return;
215
+ const { local, session } = options.sessionStorage;
216
+ const uid = sessionHooks.currentUid();
217
+ const mode = sessionHooks.mode();
218
+ if (uid === null || mode === 'NONE') {
219
+ // Signed out, or mode is NONE — clear both stores so no uid lingers
220
+ // across a sign-out or a mode downgrade to NONE.
221
+ local.removeItem(SESSION_STORAGE_KEY);
222
+ session.removeItem(SESSION_STORAGE_KEY);
223
+ return;
224
+ }
225
+ // A session lives in EXACTLY ONE store at any time — clear the other
226
+ // first, then write to the target. This prevents a stale entry in the
227
+ // other store from being picked up on a future reload with a different
228
+ // mode (which would look like the earlier mode's session resuming).
229
+ const payload = JSON.stringify({ uid });
230
+ if (mode === 'LOCAL') {
231
+ session.removeItem(SESSION_STORAGE_KEY); // clear the other slot
232
+ local.setItem(SESSION_STORAGE_KEY, payload);
233
+ }
234
+ else {
235
+ // SESSION
236
+ local.removeItem(SESSION_STORAGE_KEY); // clear the other slot
237
+ session.setItem(SESSION_STORAGE_KEY, payload);
238
+ }
239
+ };
240
+ /**
241
+ * Read back the stored uid from EITHER web-storage slot.
242
+ * Mode-agnostic: reads local then session (same order as serve's
243
+ * `SessionStore.load`). Returns null when nothing is stored or the
244
+ * blob is unparseable (corrupt bytes → silently drop).
245
+ */
246
+ const loadStoredUid = () => {
247
+ if (!options.sessionStorage)
248
+ return null;
249
+ const { local, session } = options.sessionStorage;
250
+ for (const store of [local, session]) {
251
+ const raw = store.getItem(SESSION_STORAGE_KEY);
252
+ if (!raw)
253
+ continue;
254
+ try {
255
+ const parsed = JSON.parse(raw);
256
+ if (parsed && typeof parsed.uid === 'string')
257
+ return parsed.uid;
258
+ }
259
+ catch {
260
+ // Corrupt value — remove it so it doesn't confuse a future load.
261
+ store.removeItem(SESSION_STORAGE_KEY);
262
+ }
263
+ }
264
+ return null;
265
+ };
266
+ /**
267
+ * Clear the stored session from BOTH web-storage slots. Used when a
268
+ * restore fails (user deleted / disabled between sessions) so the
269
+ * stale entry doesn't re-surface on the next reload.
270
+ */
271
+ const clearStoredSession = () => {
272
+ if (!options.sessionStorage)
273
+ return;
274
+ options.sessionStorage.local.removeItem(SESSION_STORAGE_KEY);
275
+ options.sessionStorage.session.removeItem(SESSION_STORAGE_KEY);
276
+ };
277
+ /**
278
+ * Wire up the session-change subscription for a service that provides
279
+ * session hooks. On each fire, re-saves the session uid to the
280
+ * appropriate web-storage slot (handling mode changes transparently —
281
+ * mode changes emit a session-change event, so the controller picks up
282
+ * the new mode without a dedicated migration path).
283
+ *
284
+ * Guarded by `sessionUnsubs.has(name)` so it's idempotent; only the
285
+ * first registration per service name installs the subscription.
286
+ */
287
+ const attachSessionSubscription = (name, hooks) => {
288
+ if (!options.sessionStorage)
289
+ return;
290
+ if (!hooks.session || sessionUnsubs.has(name))
291
+ return;
292
+ const sessionHooks = hooks.session;
293
+ const unsub = sessionHooks.subscribe(() => {
294
+ saveSession(sessionHooks);
295
+ });
296
+ sessionUnsubs.set(name, unsub);
297
+ };
298
+ // Wire up any services already in the registry at attach time
299
+ // (the case where the user called getAuth before enablePersistence).
300
+ if (sandbox instanceof SandboxImpl) {
301
+ for (const [name, hooks] of sandbox.getServiceRegistry()) {
302
+ attachServiceSubscription(name, hooks);
303
+ attachSessionSubscription(name, hooks);
304
+ }
305
+ // Install the late-registration hook so services that register
306
+ // AFTER this point (user calls enablePersistence then getAuth) are
307
+ // also subscribed and their changes flush promptly.
308
+ //
309
+ // Crucially: if there's a saved blob entry for this service name, we
310
+ // apply it now (late restore). Without this, a user who calls
311
+ // `enablePersistence` then `getAuth` would lose their saved users
312
+ // because `restore()` ran before auth was in the registry.
313
+ sandbox.setServiceRegistrationHook((name, hooks) => {
314
+ // Late restore: if the blob had data for this service and it
315
+ // wasn't applied during the initial restore pass (because the
316
+ // service wasn't registered then), apply it now. The user DB
317
+ // must be restored BEFORE the session restore below, so it
318
+ // resolves the uid to an existing record.
319
+ if (restoredServices !== null && name in restoredServices) {
320
+ try {
321
+ hooks.restore(restoredServices[name]);
322
+ }
323
+ catch (e) {
324
+ console.warn(`[sandbox/persistence] late-restore for service '${name}' failed:`, e);
325
+ }
326
+ }
327
+ // Late session restore: if a stored uid was found during attach
328
+ // but no service with session hooks was registered at that time
329
+ // (the common "reload" pattern where getAuth is called after
330
+ // enablePersistence), restore the session now that the service
331
+ // is available. The user DB restore above ran first, so the uid
332
+ // will resolve correctly.
333
+ if (pendingSessionUid !== null && hooks.session) {
334
+ tryRestoreSession(pendingSessionUid, hooks);
335
+ }
336
+ attachServiceSubscription(name, hooks);
337
+ attachSessionSubscription(name, hooks);
338
+ // Schedule a flush so the newly registered service's initial state
339
+ // is captured in the next blob — important for the early-registration
340
+ // case where the service had existing data before enablePersistence.
341
+ scheduleFlush();
342
+ });
343
+ }
344
+ // ─── Session restore ──────────────────────────────────────────────
345
+ //
346
+ // Restore the signed-in session AFTER the user DB / services have been
347
+ // restored (so the uid resolves to an existing record). We do this by
348
+ // reading the stored uid from web-storage and calling `session.restore`
349
+ // on each registered service that provides session hooks.
350
+ //
351
+ // The restore runs in TWO possible paths:
352
+ // 1. Early-registration (getAuth called BEFORE enablePersistence):
353
+ // the auth service is already in the registry when attachPersistence
354
+ // runs, so we can restore here synchronously.
355
+ // 2. Late-registration (getAuth called AFTER enablePersistence, the
356
+ // common "reload" pattern): the registry is empty here, so we store
357
+ // the pending uid in `pendingSessionUid` and restore when the auth
358
+ // service registers via the late-registration hook below.
359
+ //
360
+ // Both paths call `tryRestoreSession` which handles the
361
+ // user-not-found/user-disabled throw + session clear idiom.
362
+ //
363
+ // The session restore must happen AFTER the user DB is restored (so
364
+ // `restoreSession(uid)` can look up the uid), which is why path 2 hangs
365
+ // off the late-registration hook (that hook already applies the user DB
366
+ // restore first — `hooks.restore(restoredServices[name])` runs before
367
+ // we attempt the session).
368
+ /** Uid read from web-storage that still needs a session restore.
369
+ * Non-null only while a service with session hooks hasn't registered yet. */
370
+ let pendingSessionUid = null;
371
+ /** Attempt to restore the session for `uid` via `hooks.session`. On
372
+ * success, the session fires `onAuthStateChanged`. On
373
+ * user-not-found/user-disabled, clears the stored session and logs. */
374
+ const tryRestoreSession = (uid, hooks) => {
375
+ if (!hooks.session)
376
+ return;
377
+ try {
378
+ hooks.session.restore(uid);
379
+ // Session restored — clear the pending marker so we don't retry.
380
+ pendingSessionUid = null;
381
+ }
382
+ catch (e) {
383
+ // `restoreSession` throws `auth/user-not-found` or `auth/user-disabled`
384
+ // when the uid no longer exists or the account was disabled between
385
+ // sessions. Clear the stored session so this stale uid doesn't
386
+ // re-surface on the next reload. Log at warn level so developers
387
+ // see it in the console (matching serve's behavior for the same case).
388
+ console.warn(`[sandbox/persistence] session restore for uid '${uid}' failed — ` +
389
+ `clearing stored session:`, e);
390
+ clearStoredSession();
391
+ pendingSessionUid = null;
392
+ }
393
+ };
394
+ if (options.sessionStorage) {
395
+ const storedUid = loadStoredUid();
396
+ if (storedUid !== null) {
397
+ if (sandbox instanceof SandboxImpl) {
398
+ const registry = sandbox.getServiceRegistry();
399
+ let restored = false;
400
+ for (const [, hooks] of registry) {
401
+ if (!hooks.session)
402
+ continue;
403
+ tryRestoreSession(storedUid, hooks);
404
+ restored = true;
405
+ break; // only one session provider (auth) expected
406
+ }
407
+ if (!restored) {
408
+ // No service with session hooks in the registry yet — stash the uid
409
+ // so the late-registration hook can pick it up when auth registers.
410
+ pendingSessionUid = storedUid;
411
+ }
412
+ }
413
+ }
414
+ }
415
+ const unsubscribe = sandbox.onEvent((event) => {
416
+ if (isPersistableEvent(event))
417
+ scheduleFlush();
418
+ });
419
+ const beforeUnload = () => {
420
+ // Run synchronously on `beforeunload` — the page is leaving and we
421
+ // can't await an async backend write. Memory backend is sync; the
422
+ // IndexedDB backend won't finish in time, but kicking the request
423
+ // off gives it a chance to land in the IndexedDB write queue
424
+ // before tab close. Best-effort; the debounced auto-flush is the
425
+ // primary safety net.
426
+ void flushNow().catch(() => {
427
+ /* swallow — page is leaving */
428
+ });
429
+ };
430
+ if (typeof window !== 'undefined') {
431
+ window.addEventListener('beforeunload', beforeUnload);
432
+ }
433
+ return {
434
+ options,
435
+ flush: flushNow,
436
+ async clear() {
437
+ if (pendingFlush) {
438
+ clearTimeout(pendingFlush);
439
+ pendingFlush = null;
440
+ }
441
+ await backend.clear(options.key);
442
+ // Reset the diff baseline: the backend is now empty, so the next flush
443
+ // must treat every bucket as changed and re-persist the full in-memory
444
+ // state (otherwise untouched buckets stay suppressed and are lost).
445
+ lastHashes.clear();
446
+ },
447
+ dispose() {
448
+ if (disposed)
449
+ return;
450
+ disposed = true;
451
+ if (pendingFlush) {
452
+ clearTimeout(pendingFlush);
453
+ pendingFlush = null;
454
+ }
455
+ unsubscribe();
456
+ // Detach service change-notification subscriptions.
457
+ for (const unsub of serviceUnsubs.values())
458
+ unsub();
459
+ serviceUnsubs.clear();
460
+ // Detach session-change subscriptions.
461
+ for (const unsub of sessionUnsubs.values())
462
+ unsub();
463
+ sessionUnsubs.clear();
464
+ // Detach the late-registration hook.
465
+ if (sandbox instanceof SandboxImpl) {
466
+ sandbox.setServiceRegistrationHook(null);
467
+ }
468
+ if (typeof window !== 'undefined') {
469
+ window.removeEventListener('beforeunload', beforeUnload);
470
+ }
471
+ },
472
+ };
473
+ }
474
+ /**
475
+ * Read the persisted blob for `key` and hydrate every document into
476
+ * the sandbox via the admin write surface, then restore any registered
477
+ * service state from the `services` map.
478
+ *
479
+ * Returns the raw `services` blob map (or `null` if no blob existed)
480
+ * so the controller can apply it to services that register AFTER this
481
+ * call returns (the late-registration case).
482
+ *
483
+ * Restore order: Firestore first, then services. Auth users need to
484
+ * land after Firestore is ready, not before — matches the natural
485
+ * initialization order.
486
+ *
487
+ * Unreadable blobs (parse failure, schema mismatch) are QUARANTINED,
488
+ * not destroyed: the raw blob moves to `<key>:corrupt` and the live
489
+ * key is cleared so the next flush starts fresh. Silent data loss is
490
+ * the worst failure mode for a persistence layer — parking the bytes
491
+ * under a side key keeps a serialization bug debuggable after the
492
+ * fact. Each new corrupt blob overwrites the previous quarantine
493
+ * record (one forensic slot per key is enough).
494
+ *
495
+ * Listeners attached to the sandbox before restore will see each
496
+ * hydrated doc as a fresh notification — intentional. The natural
497
+ * place to call `enablePersistence` is right after `initializeSandbox`,
498
+ * before any listeners attach, so this rarely matters in practice.
499
+ *
500
+ * Each service restore is wrapped in try/catch — a failing service
501
+ * restore must not abort Firestore restore (the core data is more
502
+ * critical). A warning is logged but the sandbox stays usable.
503
+ */
504
+ async function restore(sandbox, backend, key, lastHashes) {
505
+ let ids;
506
+ try {
507
+ ids = await backend.listRecords(key);
508
+ }
509
+ catch (e) {
510
+ console.warn('[sandbox/persistence] backend list failed:', e);
511
+ return null;
512
+ }
513
+ if (ids.length === 0)
514
+ return null;
515
+ const records = [];
516
+ for (const id of ids) {
517
+ try {
518
+ const rec = await backend.getRecord(key, id);
519
+ if (rec !== null)
520
+ records.push([id, rec]);
521
+ }
522
+ catch (e) {
523
+ console.warn(`[sandbox/persistence] failed to read persisted record '${id}':`, e);
524
+ }
525
+ }
526
+ // C4 migrate-on-open: a legacy v2 record is the old single JSON blob (a
527
+ // string); v3 records are objects. Convert any v2 blob to v3 buckets in place,
528
+ // then delete the legacy record so the next open is pure v3.
529
+ const v3Records = [];
530
+ const legacyIds = [];
531
+ let migrated = null;
532
+ for (const [id, rec] of records) {
533
+ if (typeof rec === 'string') {
534
+ const m = migrateV2ToRecords(rec);
535
+ if (m) {
536
+ legacyIds.push(id);
537
+ migrated = m;
538
+ }
539
+ // a string that is not a recognizable v2 blob is unrecognized: skip it.
540
+ }
541
+ else {
542
+ v3Records.push([id, rec]);
543
+ }
544
+ }
545
+ if (migrated) {
546
+ try {
547
+ await backend.putRecords(key, migrated);
548
+ if (legacyIds.length > 0)
549
+ await backend.deleteRecords(key, legacyIds);
550
+ }
551
+ catch (e) {
552
+ console.warn('[sandbox/persistence] v2 migration write failed:', e);
553
+ }
554
+ for (const [id, rec] of migrated)
555
+ v3Records.push([id, rec]);
556
+ }
557
+ // Seed the flush hash state from the effective v3 records, so the first flush
558
+ // does not redundantly re-write the just-restored (or just-migrated) buckets.
559
+ for (const [id, rec] of v3Records)
560
+ lastHashes.set(id, hashRecord(rec));
561
+ const parsed = deserializeFromBuckets(v3Records);
562
+ // 1. Restore Firestore documents first. These are the structural data
563
+ // that services (auth) may depend on being present.
564
+ for (const [path, data] of Object.entries(parsed.firestore)) {
565
+ sandbox.admin.setDocument(path, data);
566
+ }
567
+ // 2. Restore registered service state. Only services that are BOTH in
568
+ // the blob AND currently registered are restored here. Services not
569
+ // yet registered (late registration: enablePersistence before getAuth)
570
+ // receive their data when they register via the hook installed by
571
+ // attachPersistence. Each service restore is isolated so a broken
572
+ // service doesn't kill the entire restore.
573
+ if (sandbox instanceof SandboxImpl) {
574
+ const registry = sandbox.getServiceRegistry();
575
+ for (const [name, data] of Object.entries(parsed.services)) {
576
+ const svc = registry.get(name);
577
+ if (!svc)
578
+ continue; // not yet registered; will be applied via late-restore hook
579
+ try {
580
+ svc.restore(data);
581
+ }
582
+ catch (e) {
583
+ console.warn(`[sandbox/persistence] service '${name}' restore failed — ` +
584
+ `Firestore state is intact; auth users may need to be re-created:`, e);
585
+ }
586
+ }
587
+ }
588
+ // Return the services blob so the controller can apply it to services
589
+ // that register after this call (the late-registration case).
590
+ return parsed.services;
591
+ }
592
+ /**
593
+ * Which SandboxEvents move us toward a "dirty" state worth flushing?
594
+ *
595
+ * Writes (`kind: 'write'`) are the obvious ones. We also flush on
596
+ * `session_boundary` so a `reset()` snapshots the now-empty env — the
597
+ * persisted state then matches the in-memory state instead of holding
598
+ * stale pre-reset data.
599
+ *
600
+ * Read/listener events do not change state and don't trigger a flush.
601
+ */
602
+ function isPersistableEvent(event) {
603
+ return event.kind === 'write' || event.kind === 'session_boundary';
604
+ }
605
+ //# sourceMappingURL=controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"controller.js","sourceRoot":"","sources":["../../../src/sandbox/persistence/controller.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAC5E,OAAO,EACL,kBAAkB,EAClB,sBAAsB,EACtB,kBAAkB,GACnB,MAAM,mBAAmB,CAAC;AAG3B,MAAM,yBAAyB,GAAG,GAAG,CAAC;AAEtC;;;;;;;;;GASG;AACH,MAAM,mBAAmB,GAAG,4BAA4B,CAAC;AAEzD;;;;;;;GAOG;AACH,SAAS,UAAU,CAAC,MAAe;IACjC,MAAM,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IACjC,IAAI,CAAC,GAAG,UAAU,CAAC;IACnB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAClC,CAAC,IAAI,CAAC,CAAC,UAAU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AC,KAAmB;IAC7C,OAAO,KAAK,CAAC,IAAI,KAAK,OAAO,IAAI,KAAK,CAAC,IAAI,KAAK,kBAAkB,CAAC;AACrE,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Persistence module barrel — public surface re-exported from the
3
+ * package root. Backends are exposed so hosts that need a custom
4
+ * adapter (filesystem, remote KV) can compose against the same
5
+ * contract.
6
+ */
7
+ export type { PersistenceBackend, SandboxPersistenceOptions, WebStorageLike } from './types.js';
8
+ export { createIndexedDBBackend, createMemoryBackend, recordBackendOverBlob } from './backends.js';
9
+ export { serializeToBuckets, deserializeFromBuckets, bundleRecords, parseBundle } from './chunk-format.js';
10
+ export { PersistenceSchemaError, rehydrateDocValue } from './serialize.js';
11
+ export type { PersistenceController } from './controller.js';
12
+ export { attachPersistence } from './controller.js';
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/sandbox/persistence/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,YAAY,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAChG,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACnG,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC3G,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAC3E,YAAY,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,5 @@
1
+ export { createIndexedDBBackend, createMemoryBackend, recordBackendOverBlob } from './backends.js';
2
+ export { serializeToBuckets, deserializeFromBuckets, bundleRecords, parseBundle } from './chunk-format.js';
3
+ export { PersistenceSchemaError, rehydrateDocValue } from './serialize.js';
4
+ export { attachPersistence } from './controller.js';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/sandbox/persistence/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACnG,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC3G,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAE3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC"}