pyric 0.0.1 → 0.1.0-alpha.10

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 (1204) hide show
  1. package/LICENSE +216 -0
  2. package/README.md +179 -2
  3. package/README.md.orig +54 -0
  4. package/dist/ai/backend.d.ts +35 -0
  5. package/dist/ai/backend.d.ts.map +1 -0
  6. package/dist/ai/backend.js +42 -0
  7. package/dist/ai/backend.js.map +1 -0
  8. package/dist/ai/broker/broker.d.ts +65 -0
  9. package/dist/ai/broker/broker.d.ts.map +1 -0
  10. package/dist/ai/broker/broker.js +184 -0
  11. package/dist/ai/broker/broker.js.map +1 -0
  12. package/dist/ai/broker/index.d.ts +12 -0
  13. package/dist/ai/broker/index.d.ts.map +1 -0
  14. package/dist/ai/broker/index.js +11 -0
  15. package/dist/ai/broker/index.js.map +1 -0
  16. package/dist/ai/broker/openai-engine.d.ts +175 -0
  17. package/dist/ai/broker/openai-engine.d.ts.map +1 -0
  18. package/dist/ai/broker/openai-engine.js +502 -0
  19. package/dist/ai/broker/openai-engine.js.map +1 -0
  20. package/dist/ai/broker/scripted-engine.d.ts +44 -0
  21. package/dist/ai/broker/scripted-engine.d.ts.map +1 -0
  22. package/dist/ai/broker/scripted-engine.js +218 -0
  23. package/dist/ai/broker/scripted-engine.js.map +1 -0
  24. package/dist/ai/broker/synthesizer.d.ts +100 -0
  25. package/dist/ai/broker/synthesizer.d.ts.map +1 -0
  26. package/dist/ai/broker/synthesizer.js +278 -0
  27. package/dist/ai/broker/synthesizer.js.map +1 -0
  28. package/dist/ai/broker/types.d.ts +210 -0
  29. package/dist/ai/broker/types.d.ts.map +1 -0
  30. package/dist/ai/broker/types.js +20 -0
  31. package/dist/ai/broker/types.js.map +1 -0
  32. package/dist/ai/enums.d.ts +174 -0
  33. package/dist/ai/enums.d.ts.map +1 -0
  34. package/dist/ai/enums.js +155 -0
  35. package/dist/ai/enums.js.map +1 -0
  36. package/dist/ai/errors.d.ts +66 -0
  37. package/dist/ai/errors.d.ts.map +1 -0
  38. package/dist/ai/errors.js +100 -0
  39. package/dist/ai/errors.js.map +1 -0
  40. package/dist/ai/index.d.ts +31 -0
  41. package/dist/ai/index.d.ts.map +1 -0
  42. package/dist/ai/index.js +27 -0
  43. package/dist/ai/index.js.map +1 -0
  44. package/dist/ai/instances.d.ts +15 -0
  45. package/dist/ai/instances.d.ts.map +1 -0
  46. package/dist/ai/instances.js +69 -0
  47. package/dist/ai/instances.js.map +1 -0
  48. package/dist/ai/internal.d.ts +13 -0
  49. package/dist/ai/internal.d.ts.map +1 -0
  50. package/dist/ai/internal.js +45 -0
  51. package/dist/ai/internal.js.map +1 -0
  52. package/dist/ai/models.d.ts +116 -0
  53. package/dist/ai/models.d.ts.map +1 -0
  54. package/dist/ai/models.js +213 -0
  55. package/dist/ai/models.js.map +1 -0
  56. package/dist/ai/request-helpers.d.ts +59 -0
  57. package/dist/ai/request-helpers.d.ts.map +1 -0
  58. package/dist/ai/request-helpers.js +157 -0
  59. package/dist/ai/request-helpers.js.map +1 -0
  60. package/dist/ai/response-helpers.d.ts +41 -0
  61. package/dist/ai/response-helpers.d.ts.map +1 -0
  62. package/dist/ai/response-helpers.js +204 -0
  63. package/dist/ai/response-helpers.js.map +1 -0
  64. package/dist/ai/sandbox-plane.d.ts +41 -0
  65. package/dist/ai/sandbox-plane.d.ts.map +1 -0
  66. package/dist/ai/sandbox-plane.js +159 -0
  67. package/dist/ai/sandbox-plane.js.map +1 -0
  68. package/dist/ai/schema.d.ts +105 -0
  69. package/dist/ai/schema.d.ts.map +1 -0
  70. package/dist/ai/schema.js +174 -0
  71. package/dist/ai/schema.js.map +1 -0
  72. package/dist/ai/scripting.d.ts +53 -0
  73. package/dist/ai/scripting.d.ts.map +1 -0
  74. package/dist/ai/scripting.js +73 -0
  75. package/dist/ai/scripting.js.map +1 -0
  76. package/dist/ai/target.d.ts +20 -0
  77. package/dist/ai/target.d.ts.map +1 -0
  78. package/dist/ai/target.js +29 -0
  79. package/dist/ai/target.js.map +1 -0
  80. package/dist/ai/types.d.ts +400 -0
  81. package/dist/ai/types.d.ts.map +1 -0
  82. package/dist/ai/types.js +10 -0
  83. package/dist/ai/types.js.map +1 -0
  84. package/dist/app/diagnostics.d.ts +29 -0
  85. package/dist/app/diagnostics.d.ts.map +1 -0
  86. package/dist/app/diagnostics.js +88 -0
  87. package/dist/app/diagnostics.js.map +1 -0
  88. package/dist/app/index.d.ts +7 -0
  89. package/dist/app/index.d.ts.map +1 -0
  90. package/dist/app/index.js +5 -0
  91. package/dist/app/index.js.map +1 -0
  92. package/dist/app/internal.d.ts +11 -0
  93. package/dist/app/internal.d.ts.map +1 -0
  94. package/dist/app/internal.js +18 -0
  95. package/dist/app/internal.js.map +1 -0
  96. package/dist/app/options.d.ts +3 -0
  97. package/dist/app/options.d.ts.map +1 -0
  98. package/dist/app/options.js +19 -0
  99. package/dist/app/options.js.map +1 -0
  100. package/dist/app/register.d.ts +4 -0
  101. package/dist/app/register.d.ts.map +1 -0
  102. package/dist/app/register.js +35 -0
  103. package/dist/app/register.js.map +1 -0
  104. package/dist/app/registry.d.ts +12 -0
  105. package/dist/app/registry.d.ts.map +1 -0
  106. package/dist/app/registry.js +147 -0
  107. package/dist/app/registry.js.map +1 -0
  108. package/dist/app/runtime.d.ts +18 -0
  109. package/dist/app/runtime.d.ts.map +1 -0
  110. package/dist/app/runtime.js +119 -0
  111. package/dist/app/runtime.js.map +1 -0
  112. package/dist/app/types.d.ts +21 -0
  113. package/dist/app/types.d.ts.map +1 -0
  114. package/dist/app/types.js +2 -0
  115. package/dist/app/types.js.map +1 -0
  116. package/dist/auth/action-code-url.d.ts +70 -0
  117. package/dist/auth/action-code-url.d.ts.map +1 -0
  118. package/dist/auth/action-code-url.js +124 -0
  119. package/dist/auth/action-code-url.js.map +1 -0
  120. package/dist/auth/action-codes.d.ts +201 -0
  121. package/dist/auth/action-codes.d.ts.map +1 -0
  122. package/dist/auth/action-codes.js +355 -0
  123. package/dist/auth/action-codes.js.map +1 -0
  124. package/dist/auth/auth-errors.d.ts +21 -0
  125. package/dist/auth/auth-errors.d.ts.map +1 -0
  126. package/dist/auth/auth-errors.js +23 -0
  127. package/dist/auth/auth-errors.js.map +1 -0
  128. package/dist/auth/config-tokens.d.ts +90 -0
  129. package/dist/auth/config-tokens.d.ts.map +1 -0
  130. package/dist/auth/config-tokens.js +86 -0
  131. package/dist/auth/config-tokens.js.map +1 -0
  132. package/dist/auth/credentials.d.ts +140 -0
  133. package/dist/auth/credentials.d.ts.map +1 -0
  134. package/dist/auth/credentials.js +194 -0
  135. package/dist/auth/credentials.js.map +1 -0
  136. package/dist/auth/email-link.d.ts +91 -0
  137. package/dist/auth/email-link.d.ts.map +1 -0
  138. package/dist/auth/email-link.js +172 -0
  139. package/dist/auth/email-link.js.map +1 -0
  140. package/dist/auth/enums.d.ts +210 -0
  141. package/dist/auth/enums.d.ts.map +1 -0
  142. package/dist/auth/enums.js +206 -0
  143. package/dist/auth/enums.js.map +1 -0
  144. package/dist/auth/index.d.ts +3 -0
  145. package/dist/auth/index.d.ts.map +1 -0
  146. package/dist/auth/index.js +3 -0
  147. package/dist/auth/index.js.map +1 -0
  148. package/dist/auth/instances.d.ts +14 -0
  149. package/dist/auth/instances.d.ts.map +1 -0
  150. package/dist/auth/instances.js +95 -0
  151. package/dist/auth/instances.js.map +1 -0
  152. package/dist/auth/linking.d.ts +93 -0
  153. package/dist/auth/linking.d.ts.map +1 -0
  154. package/dist/auth/linking.js +189 -0
  155. package/dist/auth/linking.js.map +1 -0
  156. package/dist/auth/modular.d.ts +22 -0
  157. package/dist/auth/modular.d.ts.map +1 -0
  158. package/dist/auth/modular.js +18 -0
  159. package/dist/auth/modular.js.map +1 -0
  160. package/dist/auth/password-policy.d.ts +60 -0
  161. package/dist/auth/password-policy.d.ts.map +1 -0
  162. package/dist/auth/password-policy.js +68 -0
  163. package/dist/auth/password-policy.js.map +1 -0
  164. package/dist/auth/providers.d.ts +153 -0
  165. package/dist/auth/providers.d.ts.map +1 -0
  166. package/dist/auth/providers.js +207 -0
  167. package/dist/auth/providers.js.map +1 -0
  168. package/dist/auth/reauth.d.ts +73 -0
  169. package/dist/auth/reauth.d.ts.map +1 -0
  170. package/dist/auth/reauth.js +148 -0
  171. package/dist/auth/reauth.js.map +1 -0
  172. package/dist/auth/sandbox/driver.d.ts +51 -0
  173. package/dist/auth/sandbox/driver.d.ts.map +1 -0
  174. package/dist/auth/sandbox/driver.js +88 -0
  175. package/dist/auth/sandbox/driver.js.map +1 -0
  176. package/dist/auth/sandbox/persistence.d.ts +7 -0
  177. package/dist/auth/sandbox/persistence.d.ts.map +1 -0
  178. package/dist/auth/sandbox/persistence.js +121 -0
  179. package/dist/auth/sandbox/persistence.js.map +1 -0
  180. package/dist/auth/sandbox/project-store.d.ts +15 -0
  181. package/dist/auth/sandbox/project-store.d.ts.map +1 -0
  182. package/dist/auth/sandbox/project-store.js +17 -0
  183. package/dist/auth/sandbox/project-store.js.map +1 -0
  184. package/dist/auth/sandbox-auth-flow.d.ts +173 -0
  185. package/dist/auth/sandbox-auth-flow.d.ts.map +1 -0
  186. package/dist/auth/sandbox-auth-flow.js +165 -0
  187. package/dist/auth/sandbox-auth-flow.js.map +1 -0
  188. package/dist/auth/sandbox-backend-types.d.ts +197 -0
  189. package/dist/auth/sandbox-backend-types.d.ts.map +1 -0
  190. package/dist/auth/sandbox-backend-types.js +18 -0
  191. package/dist/auth/sandbox-backend-types.js.map +1 -0
  192. package/dist/auth/sandbox-backend.d.ts +811 -0
  193. package/dist/auth/sandbox-backend.d.ts.map +1 -0
  194. package/dist/auth/sandbox-backend.js +2007 -0
  195. package/dist/auth/sandbox-backend.js.map +1 -0
  196. package/dist/auth/sandbox-credential-validators.d.ts +30 -0
  197. package/dist/auth/sandbox-credential-validators.d.ts.map +1 -0
  198. package/dist/auth/sandbox-credential-validators.js +47 -0
  199. package/dist/auth/sandbox-credential-validators.js.map +1 -0
  200. package/dist/auth/sandbox-token.d.ts +24 -0
  201. package/dist/auth/sandbox-token.d.ts.map +1 -0
  202. package/dist/auth/sandbox-token.js +32 -0
  203. package/dist/auth/sandbox-token.js.map +1 -0
  204. package/dist/auth/sign-in.d.ts +14 -0
  205. package/dist/auth/sign-in.d.ts.map +1 -0
  206. package/dist/auth/sign-in.js +140 -0
  207. package/dist/auth/sign-in.js.map +1 -0
  208. package/dist/auth/target.d.ts +29 -0
  209. package/dist/auth/target.d.ts.map +1 -0
  210. package/dist/auth/target.js +23 -0
  211. package/dist/auth/target.js.map +1 -0
  212. package/dist/auth/tokens.d.ts +54 -0
  213. package/dist/auth/tokens.d.ts.map +1 -0
  214. package/dist/auth/tokens.js +142 -0
  215. package/dist/auth/tokens.js.map +1 -0
  216. package/dist/auth/types.d.ts +283 -0
  217. package/dist/auth/types.d.ts.map +1 -0
  218. package/dist/auth/types.js +24 -0
  219. package/dist/auth/types.js.map +1 -0
  220. package/dist/auth/user-lifecycle.d.ts +17 -0
  221. package/dist/auth/user-lifecycle.d.ts.map +1 -0
  222. package/dist/auth/user-lifecycle.js +60 -0
  223. package/dist/auth/user-lifecycle.js.map +1 -0
  224. package/dist/database/index.d.ts +9 -0
  225. package/dist/database/index.d.ts.map +1 -0
  226. package/dist/database/index.js +9 -0
  227. package/dist/database/index.js.map +1 -0
  228. package/dist/database/listener-registry.d.ts +16 -0
  229. package/dist/database/listener-registry.d.ts.map +1 -0
  230. package/dist/database/listener-registry.js +68 -0
  231. package/dist/database/listener-registry.js.map +1 -0
  232. package/dist/database/modular.d.ts +632 -0
  233. package/dist/database/modular.d.ts.map +1 -0
  234. package/dist/database/modular.js +1071 -0
  235. package/dist/database/modular.js.map +1 -0
  236. package/dist/database/replay.d.ts +32 -0
  237. package/dist/database/replay.d.ts.map +1 -0
  238. package/dist/database/replay.js +124 -0
  239. package/dist/database/replay.js.map +1 -0
  240. package/dist/database/sandbox/backend-for.d.ts +10 -0
  241. package/dist/database/sandbox/backend-for.d.ts.map +1 -0
  242. package/dist/database/sandbox/backend-for.js +19 -0
  243. package/dist/database/sandbox/backend-for.js.map +1 -0
  244. package/dist/database/sandbox/backend.d.ts +407 -0
  245. package/dist/database/sandbox/backend.d.ts.map +1 -0
  246. package/dist/database/sandbox/backend.js +1495 -0
  247. package/dist/database/sandbox/backend.js.map +1 -0
  248. package/dist/database/sandbox/data-tree.d.ts +123 -0
  249. package/dist/database/sandbox/data-tree.d.ts.map +1 -0
  250. package/dist/database/sandbox/data-tree.js +310 -0
  251. package/dist/database/sandbox/data-tree.js.map +1 -0
  252. package/dist/database/sandbox/normalize.d.ts +77 -0
  253. package/dist/database/sandbox/normalize.d.ts.map +1 -0
  254. package/dist/database/sandbox/normalize.js +165 -0
  255. package/dist/database/sandbox/normalize.js.map +1 -0
  256. package/dist/database/sandbox/push-id.d.ts +32 -0
  257. package/dist/database/sandbox/push-id.d.ts.map +1 -0
  258. package/dist/database/sandbox/push-id.js +82 -0
  259. package/dist/database/sandbox/push-id.js.map +1 -0
  260. package/dist/database/sandbox/query.d.ts +175 -0
  261. package/dist/database/sandbox/query.d.ts.map +1 -0
  262. package/dist/database/sandbox/query.js +269 -0
  263. package/dist/database/sandbox/query.js.map +1 -0
  264. package/dist/database/sandbox/rules-eval.d.ts +87 -0
  265. package/dist/database/sandbox/rules-eval.d.ts.map +1 -0
  266. package/dist/database/sandbox/rules-eval.js +131 -0
  267. package/dist/database/sandbox/rules-eval.js.map +1 -0
  268. package/dist/database/sandbox/sentinels.d.ts +71 -0
  269. package/dist/database/sandbox/sentinels.d.ts.map +1 -0
  270. package/dist/database/sandbox/sentinels.js +92 -0
  271. package/dist/database/sandbox/sentinels.js.map +1 -0
  272. package/dist/database/sandbox-controls.d.ts +15 -0
  273. package/dist/database/sandbox-controls.d.ts.map +1 -0
  274. package/dist/database/sandbox-controls.js +18 -0
  275. package/dist/database/sandbox-controls.js.map +1 -0
  276. package/dist/firestore/aggregates.d.ts +50 -0
  277. package/dist/firestore/aggregates.d.ts.map +1 -0
  278. package/dist/firestore/aggregates.js +40 -0
  279. package/dist/firestore/aggregates.js.map +1 -0
  280. package/dist/firestore/equality.d.ts +5 -0
  281. package/dist/firestore/equality.d.ts.map +1 -0
  282. package/dist/firestore/equality.js +20 -0
  283. package/dist/firestore/equality.js.map +1 -0
  284. package/dist/firestore/field-values.d.ts +61 -0
  285. package/dist/firestore/field-values.d.ts.map +1 -0
  286. package/dist/firestore/field-values.js +167 -0
  287. package/dist/firestore/field-values.js.map +1 -0
  288. package/dist/firestore/index.d.ts +54 -0
  289. package/dist/firestore/index.d.ts.map +1 -0
  290. package/dist/firestore/index.js +54 -0
  291. package/dist/firestore/index.js.map +1 -0
  292. package/dist/firestore/instances.d.ts +123 -0
  293. package/dist/firestore/instances.d.ts.map +1 -0
  294. package/dist/firestore/instances.js +177 -0
  295. package/dist/firestore/instances.js.map +1 -0
  296. package/dist/firestore/internal/index.d.ts +2 -0
  297. package/dist/firestore/internal/index.d.ts.map +1 -0
  298. package/dist/firestore/internal/index.js +2 -0
  299. package/dist/firestore/internal/index.js.map +1 -0
  300. package/dist/firestore/internal/listener-routing.d.ts +4 -0
  301. package/dist/firestore/internal/listener-routing.d.ts.map +1 -0
  302. package/dist/firestore/internal/listener-routing.js +4 -0
  303. package/dist/firestore/internal/listener-routing.js.map +1 -0
  304. package/dist/firestore/listeners.d.ts +12 -0
  305. package/dist/firestore/listeners.d.ts.map +1 -0
  306. package/dist/firestore/listeners.js +200 -0
  307. package/dist/firestore/listeners.js.map +1 -0
  308. package/dist/firestore/persistence.d.ts +227 -0
  309. package/dist/firestore/persistence.d.ts.map +1 -0
  310. package/dist/firestore/persistence.js +245 -0
  311. package/dist/firestore/persistence.js.map +1 -0
  312. package/dist/firestore/query-constraints.d.ts +72 -0
  313. package/dist/firestore/query-constraints.d.ts.map +1 -0
  314. package/dist/firestore/query-constraints.js +168 -0
  315. package/dist/firestore/query-constraints.js.map +1 -0
  316. package/dist/firestore/reads.d.ts +12 -0
  317. package/dist/firestore/reads.d.ts.map +1 -0
  318. package/dist/firestore/reads.js +32 -0
  319. package/dist/firestore/reads.js.map +1 -0
  320. package/dist/firestore/refs.d.ts +27 -0
  321. package/dist/firestore/refs.d.ts.map +1 -0
  322. package/dist/firestore/refs.js +74 -0
  323. package/dist/firestore/refs.js.map +1 -0
  324. package/dist/firestore/sandbox-controls.d.ts +60 -0
  325. package/dist/firestore/sandbox-controls.d.ts.map +1 -0
  326. package/dist/firestore/sandbox-controls.js +77 -0
  327. package/dist/firestore/sandbox-controls.js.map +1 -0
  328. package/dist/firestore/snapshots.d.ts +71 -0
  329. package/dist/firestore/snapshots.d.ts.map +1 -0
  330. package/dist/firestore/snapshots.js +160 -0
  331. package/dist/firestore/snapshots.js.map +1 -0
  332. package/dist/firestore/state.d.ts +168 -0
  333. package/dist/firestore/state.d.ts.map +1 -0
  334. package/dist/firestore/state.js +260 -0
  335. package/dist/firestore/state.js.map +1 -0
  336. package/dist/firestore/tools.d.ts +71 -0
  337. package/dist/firestore/tools.d.ts.map +1 -0
  338. package/dist/firestore/tools.js +320 -0
  339. package/dist/firestore/tools.js.map +1 -0
  340. package/dist/firestore/transactions.d.ts +4 -0
  341. package/dist/firestore/transactions.d.ts.map +1 -0
  342. package/dist/firestore/transactions.js +14 -0
  343. package/dist/firestore/transactions.js.map +1 -0
  344. package/dist/firestore/types.d.ts +82 -0
  345. package/dist/firestore/types.d.ts.map +1 -0
  346. package/dist/firestore/types.js +15 -0
  347. package/dist/firestore/types.js.map +1 -0
  348. package/dist/firestore/writes.d.ts +43 -0
  349. package/dist/firestore/writes.d.ts.map +1 -0
  350. package/dist/firestore/writes.js +40 -0
  351. package/dist/firestore/writes.js.map +1 -0
  352. package/dist/firestore-values/index.d.ts +63 -0
  353. package/dist/firestore-values/index.d.ts.map +1 -0
  354. package/dist/firestore-values/index.js +148 -0
  355. package/dist/firestore-values/index.js.map +1 -0
  356. package/dist/messaging/broker/broker.d.ts +171 -0
  357. package/dist/messaging/broker/broker.d.ts.map +1 -0
  358. package/dist/messaging/broker/broker.js +400 -0
  359. package/dist/messaging/broker/broker.js.map +1 -0
  360. package/dist/messaging/broker/envelopes.d.ts +96 -0
  361. package/dist/messaging/broker/envelopes.d.ts.map +1 -0
  362. package/dist/messaging/broker/envelopes.js +132 -0
  363. package/dist/messaging/broker/envelopes.js.map +1 -0
  364. package/dist/messaging/broker/index.d.ts +27 -0
  365. package/dist/messaging/broker/index.d.ts.map +1 -0
  366. package/dist/messaging/broker/index.js +21 -0
  367. package/dist/messaging/broker/index.js.map +1 -0
  368. package/dist/messaging/broker/tokens.d.ts +22 -0
  369. package/dist/messaging/broker/tokens.d.ts.map +1 -0
  370. package/dist/messaging/broker/tokens.js +37 -0
  371. package/dist/messaging/broker/tokens.js.map +1 -0
  372. package/dist/messaging/broker/types.d.ts +117 -0
  373. package/dist/messaging/broker/types.d.ts.map +1 -0
  374. package/dist/messaging/broker/types.js +12 -0
  375. package/dist/messaging/broker/types.js.map +1 -0
  376. package/dist/messaging/broker/validate.d.ts +58 -0
  377. package/dist/messaging/broker/validate.d.ts.map +1 -0
  378. package/dist/messaging/broker/validate.js +196 -0
  379. package/dist/messaging/broker/validate.js.map +1 -0
  380. package/dist/messaging/client.d.ts +108 -0
  381. package/dist/messaging/client.d.ts.map +1 -0
  382. package/dist/messaging/client.js +65 -0
  383. package/dist/messaging/client.js.map +1 -0
  384. package/dist/messaging/index.d.ts +3 -0
  385. package/dist/messaging/index.d.ts.map +1 -0
  386. package/dist/messaging/index.js +3 -0
  387. package/dist/messaging/index.js.map +1 -0
  388. package/dist/messaging/instance.d.ts +72 -0
  389. package/dist/messaging/instance.d.ts.map +1 -0
  390. package/dist/messaging/instance.js +93 -0
  391. package/dist/messaging/instance.js.map +1 -0
  392. package/dist/messaging/internal.d.ts +12 -0
  393. package/dist/messaging/internal.d.ts.map +1 -0
  394. package/dist/messaging/internal.js +12 -0
  395. package/dist/messaging/internal.js.map +1 -0
  396. package/dist/messaging/sw.d.ts +49 -0
  397. package/dist/messaging/sw.d.ts.map +1 -0
  398. package/dist/messaging/sw.js +49 -0
  399. package/dist/messaging/sw.js.map +1 -0
  400. package/dist/project-scope.d.ts +5 -0
  401. package/dist/project-scope.d.ts.map +1 -0
  402. package/dist/project-scope.js +2 -0
  403. package/dist/project-scope.js.map +1 -0
  404. package/dist/rules/api/assert.d.ts +39 -0
  405. package/dist/rules/api/assert.d.ts.map +1 -0
  406. package/dist/rules/api/assert.js +93 -0
  407. package/dist/rules/api/assert.js.map +1 -0
  408. package/dist/rules/api/case-types.d.ts +141 -0
  409. package/dist/rules/api/case-types.d.ts.map +1 -0
  410. package/dist/rules/api/case-types.js +13 -0
  411. package/dist/rules/api/case-types.js.map +1 -0
  412. package/dist/rules/api/errors.d.ts +38 -0
  413. package/dist/rules/api/errors.d.ts.map +1 -0
  414. package/dist/rules/api/errors.js +47 -0
  415. package/dist/rules/api/errors.js.map +1 -0
  416. package/dist/rules/api/firestore.d.ts +34 -0
  417. package/dist/rules/api/firestore.d.ts.map +1 -0
  418. package/dist/rules/api/firestore.js +137 -0
  419. package/dist/rules/api/firestore.js.map +1 -0
  420. package/dist/rules/api/issue.d.ts +50 -0
  421. package/dist/rules/api/issue.d.ts.map +1 -0
  422. package/dist/rules/api/issue.js +66 -0
  423. package/dist/rules/api/issue.js.map +1 -0
  424. package/dist/rules/api/lint.d.ts +16 -0
  425. package/dist/rules/api/lint.d.ts.map +1 -0
  426. package/dist/rules/api/lint.js +60 -0
  427. package/dist/rules/api/lint.js.map +1 -0
  428. package/dist/rules/api/rtdb.d.ts +33 -0
  429. package/dist/rules/api/rtdb.d.ts.map +1 -0
  430. package/dist/rules/api/rtdb.js +166 -0
  431. package/dist/rules/api/rtdb.js.map +1 -0
  432. package/dist/rules/api/values.d.ts +51 -0
  433. package/dist/rules/api/values.d.ts.map +1 -0
  434. package/dist/rules/api/values.js +66 -0
  435. package/dist/rules/api/values.js.map +1 -0
  436. package/dist/rules/generators/assembler.d.ts +19 -0
  437. package/dist/rules/generators/assembler.d.ts.map +1 -0
  438. package/dist/rules/generators/assembler.js +292 -0
  439. package/dist/rules/generators/assembler.js.map +1 -0
  440. package/dist/rules/generators/expressions.d.ts +52 -0
  441. package/dist/rules/generators/expressions.d.ts.map +1 -0
  442. package/dist/rules/generators/expressions.js +117 -0
  443. package/dist/rules/generators/expressions.js.map +1 -0
  444. package/dist/rules/generators/grid.d.ts +22 -0
  445. package/dist/rules/generators/grid.d.ts.map +1 -0
  446. package/dist/rules/generators/grid.js +52 -0
  447. package/dist/rules/generators/grid.js.map +1 -0
  448. package/dist/rules/grammar/FirestoreAST.d.ts +129 -0
  449. package/dist/rules/grammar/FirestoreAST.d.ts.map +1 -0
  450. package/dist/rules/grammar/FirestoreAST.js +3 -0
  451. package/dist/rules/grammar/FirestoreAST.js.map +1 -0
  452. package/dist/rules/grammar/FirestoreAssembler.d.ts +5 -0
  453. package/dist/rules/grammar/FirestoreAssembler.d.ts.map +1 -0
  454. package/dist/rules/grammar/FirestoreAssembler.js +158 -0
  455. package/dist/rules/grammar/FirestoreAssembler.js.map +1 -0
  456. package/dist/rules/grammar/FirestoreParser.d.ts +46 -0
  457. package/dist/rules/grammar/FirestoreParser.d.ts.map +1 -0
  458. package/dist/rules/grammar/FirestoreParser.js +409 -0
  459. package/dist/rules/grammar/FirestoreParser.js.map +1 -0
  460. package/dist/rules/grammar/FirestoreRules.ohm +229 -0
  461. package/dist/rules/grammar/FirestoreRules.ohm.generated.d.ts +2 -0
  462. package/dist/rules/grammar/FirestoreRules.ohm.generated.d.ts.map +1 -0
  463. package/dist/rules/grammar/FirestoreRules.ohm.generated.js +234 -0
  464. package/dist/rules/grammar/FirestoreRules.ohm.generated.js.map +1 -0
  465. package/dist/rules/grammar/FirestoreValidator.d.ts +10 -0
  466. package/dist/rules/grammar/FirestoreValidator.d.ts.map +1 -0
  467. package/dist/rules/grammar/FirestoreValidator.js +482 -0
  468. package/dist/rules/grammar/FirestoreValidator.js.map +1 -0
  469. package/dist/rules/index.d.ts +41 -0
  470. package/dist/rules/index.d.ts.map +1 -0
  471. package/dist/rules/index.js +40 -0
  472. package/dist/rules/index.js.map +1 -0
  473. package/dist/rules/indexes/extract/annotation-collect.d.ts +42 -0
  474. package/dist/rules/indexes/extract/annotation-collect.d.ts.map +1 -0
  475. package/dist/rules/indexes/extract/annotation-collect.js +69 -0
  476. package/dist/rules/indexes/extract/annotation-collect.js.map +1 -0
  477. package/dist/rules/indexes/extract/annotations.d.ts +50 -0
  478. package/dist/rules/indexes/extract/annotations.d.ts.map +1 -0
  479. package/dist/rules/indexes/extract/annotations.js +144 -0
  480. package/dist/rules/indexes/extract/annotations.js.map +1 -0
  481. package/dist/rules/indexes/extract/ast.d.ts +54 -0
  482. package/dist/rules/indexes/extract/ast.d.ts.map +1 -0
  483. package/dist/rules/indexes/extract/ast.js +119 -0
  484. package/dist/rules/indexes/extract/ast.js.map +1 -0
  485. package/dist/rules/indexes/extract/classify.d.ts +41 -0
  486. package/dist/rules/indexes/extract/classify.d.ts.map +1 -0
  487. package/dist/rules/indexes/extract/classify.js +138 -0
  488. package/dist/rules/indexes/extract/classify.js.map +1 -0
  489. package/dist/rules/indexes/extract/composite.d.ts +38 -0
  490. package/dist/rules/indexes/extract/composite.d.ts.map +1 -0
  491. package/dist/rules/indexes/extract/composite.js +85 -0
  492. package/dist/rules/indexes/extract/composite.js.map +1 -0
  493. package/dist/rules/indexes/extract/dataflow.d.ts +45 -0
  494. package/dist/rules/indexes/extract/dataflow.d.ts.map +1 -0
  495. package/dist/rules/indexes/extract/dataflow.js +200 -0
  496. package/dist/rules/indexes/extract/dataflow.js.map +1 -0
  497. package/dist/rules/indexes/extract/enumerate.d.ts +41 -0
  498. package/dist/rules/indexes/extract/enumerate.d.ts.map +1 -0
  499. package/dist/rules/indexes/extract/enumerate.js +163 -0
  500. package/dist/rules/indexes/extract/enumerate.js.map +1 -0
  501. package/dist/rules/indexes/extract/extractor.d.ts +3 -0
  502. package/dist/rules/indexes/extract/extractor.d.ts.map +1 -0
  503. package/dist/rules/indexes/extract/extractor.js +274 -0
  504. package/dist/rules/indexes/extract/extractor.js.map +1 -0
  505. package/dist/rules/indexes/extract/types.d.ts +211 -0
  506. package/dist/rules/indexes/extract/types.d.ts.map +1 -0
  507. package/dist/rules/indexes/extract/types.js +14 -0
  508. package/dist/rules/indexes/extract/types.js.map +1 -0
  509. package/dist/rules/indexes/extractHandler.d.ts +16 -0
  510. package/dist/rules/indexes/extractHandler.d.ts.map +1 -0
  511. package/dist/rules/indexes/extractHandler.js +100 -0
  512. package/dist/rules/indexes/extractHandler.js.map +1 -0
  513. package/dist/rules/indexes/extractTool.d.ts +15 -0
  514. package/dist/rules/indexes/extractTool.d.ts.map +1 -0
  515. package/dist/rules/indexes/extractTool.js +55 -0
  516. package/dist/rules/indexes/extractTool.js.map +1 -0
  517. package/dist/rules/indexes/types.d.ts +71 -0
  518. package/dist/rules/indexes/types.d.ts.map +1 -0
  519. package/dist/rules/indexes/types.js +15 -0
  520. package/dist/rules/indexes/types.js.map +1 -0
  521. package/dist/rules/inspect/handler.d.ts +6 -0
  522. package/dist/rules/inspect/handler.d.ts.map +1 -0
  523. package/dist/rules/inspect/handler.js +144 -0
  524. package/dist/rules/inspect/handler.js.map +1 -0
  525. package/dist/rules/inspect/spec.d.ts +37 -0
  526. package/dist/rules/inspect/spec.d.ts.map +1 -0
  527. package/dist/rules/inspect/spec.js +2 -0
  528. package/dist/rules/inspect/spec.js.map +1 -0
  529. package/dist/rules/inspect/tools.d.ts +21 -0
  530. package/dist/rules/inspect/tools.d.ts.map +1 -0
  531. package/dist/rules/inspect/tools.js +21 -0
  532. package/dist/rules/inspect/tools.js.map +1 -0
  533. package/dist/rules/internal/extract.d.ts +28 -0
  534. package/dist/rules/internal/extract.d.ts.map +1 -0
  535. package/dist/rules/internal/extract.js +25 -0
  536. package/dist/rules/internal/extract.js.map +1 -0
  537. package/dist/rules/internal/index.d.ts +82 -0
  538. package/dist/rules/internal/index.d.ts.map +1 -0
  539. package/dist/rules/internal/index.js +103 -0
  540. package/dist/rules/internal/index.js.map +1 -0
  541. package/dist/rules/internal/node.d.ts +18 -0
  542. package/dist/rules/internal/node.d.ts.map +1 -0
  543. package/dist/rules/internal/node.js +27 -0
  544. package/dist/rules/internal/node.js.map +1 -0
  545. package/dist/rules/internal/rtdb.d.ts +20 -0
  546. package/dist/rules/internal/rtdb.d.ts.map +1 -0
  547. package/dist/rules/internal/rtdb.js +15 -0
  548. package/dist/rules/internal/rtdb.js.map +1 -0
  549. package/dist/rules/linter/ast-utils.d.ts +97 -0
  550. package/dist/rules/linter/ast-utils.d.ts.map +1 -0
  551. package/dist/rules/linter/ast-utils.js +491 -0
  552. package/dist/rules/linter/ast-utils.js.map +1 -0
  553. package/dist/rules/linter/hallucinations.d.ts +34 -0
  554. package/dist/rules/linter/hallucinations.d.ts.map +1 -0
  555. package/dist/rules/linter/hallucinations.js +334 -0
  556. package/dist/rules/linter/hallucinations.js.map +1 -0
  557. package/dist/rules/linter/linter.d.ts +84 -0
  558. package/dist/rules/linter/linter.d.ts.map +1 -0
  559. package/dist/rules/linter/linter.js +783 -0
  560. package/dist/rules/linter/linter.js.map +1 -0
  561. package/dist/rules/modules/resolver-browser.d.ts +41 -0
  562. package/dist/rules/modules/resolver-browser.d.ts.map +1 -0
  563. package/dist/rules/modules/resolver-browser.js +63 -0
  564. package/dist/rules/modules/resolver-browser.js.map +1 -0
  565. package/dist/rules/modules/resolver-core.d.ts +51 -0
  566. package/dist/rules/modules/resolver-core.d.ts.map +1 -0
  567. package/dist/rules/modules/resolver-core.js +338 -0
  568. package/dist/rules/modules/resolver-core.js.map +1 -0
  569. package/dist/rules/modules/resolver.d.ts +17 -0
  570. package/dist/rules/modules/resolver.d.ts.map +1 -0
  571. package/dist/rules/modules/resolver.js +49 -0
  572. package/dist/rules/modules/resolver.js.map +1 -0
  573. package/dist/rules/modules/stdlib/atomic.rules +52 -0
  574. package/dist/rules/modules/stdlib/atomic.test.json +152 -0
  575. package/dist/rules/modules/stdlib/auth.rules +7 -0
  576. package/dist/rules/modules/stdlib/auth.test.json +53 -0
  577. package/dist/rules/modules/stdlib/content.rules +50 -0
  578. package/dist/rules/modules/stdlib/content.test.json +238 -0
  579. package/dist/rules/modules/stdlib/counters.rules +41 -0
  580. package/dist/rules/modules/stdlib/counters.test.json +254 -0
  581. package/dist/rules/modules/stdlib/geometry.rules +43 -0
  582. package/dist/rules/modules/stdlib/geometry.test.json +200 -0
  583. package/dist/rules/modules/stdlib/joining.rules +49 -0
  584. package/dist/rules/modules/stdlib/joining.test.json +287 -0
  585. package/dist/rules/modules/stdlib/lifecycle.rules +51 -0
  586. package/dist/rules/modules/stdlib/lifecycle.test.json +288 -0
  587. package/dist/rules/modules/stdlib/lobby.rules +44 -0
  588. package/dist/rules/modules/stdlib/lobby.test.json +32 -0
  589. package/dist/rules/modules/stdlib/membership.rules +40 -0
  590. package/dist/rules/modules/stdlib/membership.test.json +107 -0
  591. package/dist/rules/modules/stdlib/spaces.rules +46 -0
  592. package/dist/rules/modules/stdlib/spaces.test.json +392 -0
  593. package/dist/rules/modules/stdlib/state.rules +28 -0
  594. package/dist/rules/modules/stdlib/state.test.json +55 -0
  595. package/dist/rules/modules/stdlib/timing.rules +20 -0
  596. package/dist/rules/modules/stdlib/timing.test.json +106 -0
  597. package/dist/rules/modules/stdlib/transitions.rules +34 -0
  598. package/dist/rules/modules/stdlib/transitions.test.json +86 -0
  599. package/dist/rules/modules/stdlib/turns.rules +27 -0
  600. package/dist/rules/modules/stdlib/turns.test.json +64 -0
  601. package/dist/rules/modules/stdlib/validation.rules +31 -0
  602. package/dist/rules/modules/stdlib/validation.test.json +184 -0
  603. package/dist/rules/modules/stdlib-content.d.ts +11 -0
  604. package/dist/rules/modules/stdlib-content.d.ts.map +1 -0
  605. package/dist/rules/modules/stdlib-content.js +590 -0
  606. package/dist/rules/modules/stdlib-content.js.map +1 -0
  607. package/dist/rules/rtdb/compiled-rules.d.ts +11 -0
  608. package/dist/rules/rtdb/compiled-rules.d.ts.map +1 -0
  609. package/dist/rules/rtdb/compiled-rules.js +95 -0
  610. package/dist/rules/rtdb/compiled-rules.js.map +1 -0
  611. package/dist/rules/rtdb/constraints/atoms.d.ts +29 -0
  612. package/dist/rules/rtdb/constraints/atoms.d.ts.map +1 -0
  613. package/dist/rules/rtdb/constraints/atoms.js +43 -0
  614. package/dist/rules/rtdb/constraints/atoms.js.map +1 -0
  615. package/dist/rules/rtdb/constraints/compose.d.ts +16 -0
  616. package/dist/rules/rtdb/constraints/compose.d.ts.map +1 -0
  617. package/dist/rules/rtdb/constraints/compose.js +15 -0
  618. package/dist/rules/rtdb/constraints/compose.js.map +1 -0
  619. package/dist/rules/rtdb/constraints/data.d.ts +30 -0
  620. package/dist/rules/rtdb/constraints/data.d.ts.map +1 -0
  621. package/dist/rules/rtdb/constraints/data.js +46 -0
  622. package/dist/rules/rtdb/constraints/data.js.map +1 -0
  623. package/dist/rules/rtdb/constraints/document.d.ts +57 -0
  624. package/dist/rules/rtdb/constraints/document.d.ts.map +1 -0
  625. package/dist/rules/rtdb/constraints/document.js +85 -0
  626. package/dist/rules/rtdb/constraints/document.js.map +1 -0
  627. package/dist/rules/rtdb/constraints/game.d.ts +30 -0
  628. package/dist/rules/rtdb/constraints/game.d.ts.map +1 -0
  629. package/dist/rules/rtdb/constraints/game.js +49 -0
  630. package/dist/rules/rtdb/constraints/game.js.map +1 -0
  631. package/dist/rules/rtdb/constraints/index.d.ts +12 -0
  632. package/dist/rules/rtdb/constraints/index.d.ts.map +1 -0
  633. package/dist/rules/rtdb/constraints/index.js +9 -0
  634. package/dist/rules/rtdb/constraints/index.js.map +1 -0
  635. package/dist/rules/rtdb/constraints/policies.d.ts +16 -0
  636. package/dist/rules/rtdb/constraints/policies.d.ts.map +1 -0
  637. package/dist/rules/rtdb/constraints/policies.js +17 -0
  638. package/dist/rules/rtdb/constraints/policies.js.map +1 -0
  639. package/dist/rules/rtdb/constraints/ruleset.d.ts +5 -0
  640. package/dist/rules/rtdb/constraints/ruleset.d.ts.map +1 -0
  641. package/dist/rules/rtdb/constraints/ruleset.js +132 -0
  642. package/dist/rules/rtdb/constraints/ruleset.js.map +1 -0
  643. package/dist/rules/rtdb/constraints/schema.d.ts +17 -0
  644. package/dist/rules/rtdb/constraints/schema.d.ts.map +1 -0
  645. package/dist/rules/rtdb/constraints/schema.js +74 -0
  646. package/dist/rules/rtdb/constraints/schema.js.map +1 -0
  647. package/dist/rules/rtdb/constraints/types.d.ts +22 -0
  648. package/dist/rules/rtdb/constraints/types.d.ts.map +1 -0
  649. package/dist/rules/rtdb/constraints/types.js +2 -0
  650. package/dist/rules/rtdb/constraints/types.js.map +1 -0
  651. package/dist/rules/rtdb/constraints/write-rules-file.d.ts +24 -0
  652. package/dist/rules/rtdb/constraints/write-rules-file.d.ts.map +1 -0
  653. package/dist/rules/rtdb/constraints/write-rules-file.js +30 -0
  654. package/dist/rules/rtdb/constraints/write-rules-file.js.map +1 -0
  655. package/dist/rules/rtdb/expression-engine.d.ts +8 -0
  656. package/dist/rules/rtdb/expression-engine.d.ts.map +1 -0
  657. package/dist/rules/rtdb/expression-engine.js +20 -0
  658. package/dist/rules/rtdb/expression-engine.js.map +1 -0
  659. package/dist/rules/rtdb/grammar/RtdbExpr.ohm +98 -0
  660. package/dist/rules/rtdb/grammar/RtdbExpr.ohm.generated.d.ts +2 -0
  661. package/dist/rules/rtdb/grammar/RtdbExpr.ohm.generated.d.ts.map +1 -0
  662. package/dist/rules/rtdb/grammar/RtdbExpr.ohm.generated.js +103 -0
  663. package/dist/rules/rtdb/grammar/RtdbExpr.ohm.generated.js.map +1 -0
  664. package/dist/rules/rtdb/grammar/RtdbExprParser.d.ts +3 -0
  665. package/dist/rules/rtdb/grammar/RtdbExprParser.d.ts.map +1 -0
  666. package/dist/rules/rtdb/grammar/RtdbExprParser.js +56 -0
  667. package/dist/rules/rtdb/grammar/RtdbExprParser.js.map +1 -0
  668. package/dist/rules/rtdb/grammar/linter.d.ts +3 -0
  669. package/dist/rules/rtdb/grammar/linter.d.ts.map +1 -0
  670. package/dist/rules/rtdb/grammar/linter.js +73 -0
  671. package/dist/rules/rtdb/grammar/linter.js.map +1 -0
  672. package/dist/rules/rtdb/grammar/simulator.d.ts +30 -0
  673. package/dist/rules/rtdb/grammar/simulator.d.ts.map +1 -0
  674. package/dist/rules/rtdb/grammar/simulator.js +282 -0
  675. package/dist/rules/rtdb/grammar/simulator.js.map +1 -0
  676. package/dist/rules/rtdb/grammar/validator.d.ts +3 -0
  677. package/dist/rules/rtdb/grammar/validator.d.ts.map +1 -0
  678. package/dist/rules/rtdb/grammar/validator.js +91 -0
  679. package/dist/rules/rtdb/grammar/validator.js.map +1 -0
  680. package/dist/rules/rtdb/simulation/handler.d.ts +6 -0
  681. package/dist/rules/rtdb/simulation/handler.d.ts.map +1 -0
  682. package/dist/rules/rtdb/simulation/handler.js +325 -0
  683. package/dist/rules/rtdb/simulation/handler.js.map +1 -0
  684. package/dist/rules/rtdb/simulation/spec.d.ts +102 -0
  685. package/dist/rules/rtdb/simulation/spec.d.ts.map +1 -0
  686. package/dist/rules/rtdb/simulation/spec.js +40 -0
  687. package/dist/rules/rtdb/simulation/spec.js.map +1 -0
  688. package/dist/rules/rtdb/types.d.ts +166 -0
  689. package/dist/rules/rtdb/types.d.ts.map +1 -0
  690. package/dist/rules/rtdb/types.js +21 -0
  691. package/dist/rules/rtdb/types.js.map +1 -0
  692. package/dist/rules/simulator/evaluator.d.ts +206 -0
  693. package/dist/rules/simulator/evaluator.d.ts.map +1 -0
  694. package/dist/rules/simulator/evaluator.js +1251 -0
  695. package/dist/rules/simulator/evaluator.js.map +1 -0
  696. package/dist/rules/simulator/expression/eval-errors.d.ts +86 -0
  697. package/dist/rules/simulator/expression/eval-errors.d.ts.map +1 -0
  698. package/dist/rules/simulator/expression/eval-errors.js +68 -0
  699. package/dist/rules/simulator/expression/eval-errors.js.map +1 -0
  700. package/dist/rules/simulator/expression/evaluator.d.ts +43 -0
  701. package/dist/rules/simulator/expression/evaluator.d.ts.map +1 -0
  702. package/dist/rules/simulator/expression/evaluator.js +298 -0
  703. package/dist/rules/simulator/expression/evaluator.js.map +1 -0
  704. package/dist/rules/simulator/expression/lexer.d.ts +36 -0
  705. package/dist/rules/simulator/expression/lexer.d.ts.map +1 -0
  706. package/dist/rules/simulator/expression/lexer.js +318 -0
  707. package/dist/rules/simulator/expression/lexer.js.map +1 -0
  708. package/dist/rules/simulator/expression/parser.d.ts +39 -0
  709. package/dist/rules/simulator/expression/parser.d.ts.map +1 -0
  710. package/dist/rules/simulator/expression/parser.js +329 -0
  711. package/dist/rules/simulator/expression/parser.js.map +1 -0
  712. package/dist/rules/simulator/expression/types.d.ts +137 -0
  713. package/dist/rules/simulator/expression/types.d.ts.map +1 -0
  714. package/dist/rules/simulator/expression/types.js +90 -0
  715. package/dist/rules/simulator/expression/types.js.map +1 -0
  716. package/dist/rules/simulator/expression/walk-data.d.ts +52 -0
  717. package/dist/rules/simulator/expression/walk-data.d.ts.map +1 -0
  718. package/dist/rules/simulator/expression/walk-data.js +167 -0
  719. package/dist/rules/simulator/expression/walk-data.js.map +1 -0
  720. package/dist/rules/simulator/firestore-set.d.ts +25 -0
  721. package/dist/rules/simulator/firestore-set.d.ts.map +1 -0
  722. package/dist/rules/simulator/firestore-set.js +89 -0
  723. package/dist/rules/simulator/firestore-set.js.map +1 -0
  724. package/dist/rules/simulator/handler.d.ts +47 -0
  725. package/dist/rules/simulator/handler.d.ts.map +1 -0
  726. package/dist/rules/simulator/handler.js +644 -0
  727. package/dist/rules/simulator/handler.js.map +1 -0
  728. package/dist/rules/simulator/mapdiff.d.ts +29 -0
  729. package/dist/rules/simulator/mapdiff.d.ts.map +1 -0
  730. package/dist/rules/simulator/mapdiff.js +72 -0
  731. package/dist/rules/simulator/mapdiff.js.map +1 -0
  732. package/dist/rules/simulator/project-after-state.d.ts +33 -0
  733. package/dist/rules/simulator/project-after-state.d.ts.map +1 -0
  734. package/dist/rules/simulator/project-after-state.js +88 -0
  735. package/dist/rules/simulator/project-after-state.js.map +1 -0
  736. package/dist/rules/simulator/query-proof.d.ts +80 -0
  737. package/dist/rules/simulator/query-proof.d.ts.map +1 -0
  738. package/dist/rules/simulator/query-proof.js +142 -0
  739. package/dist/rules/simulator/query-proof.js.map +1 -0
  740. package/dist/rules/simulator/value-equality.d.ts +8 -0
  741. package/dist/rules/simulator/value-equality.d.ts.map +1 -0
  742. package/dist/rules/simulator/value-equality.js +40 -0
  743. package/dist/rules/simulator/value-equality.js.map +1 -0
  744. package/dist/rules/simulator/wrappers/base.d.ts +129 -0
  745. package/dist/rules/simulator/wrappers/base.d.ts.map +1 -0
  746. package/dist/rules/simulator/wrappers/base.js +90 -0
  747. package/dist/rules/simulator/wrappers/base.js.map +1 -0
  748. package/dist/rules/simulator/wrappers/bytes.d.ts +45 -0
  749. package/dist/rules/simulator/wrappers/bytes.d.ts.map +1 -0
  750. package/dist/rules/simulator/wrappers/bytes.js +130 -0
  751. package/dist/rules/simulator/wrappers/bytes.js.map +1 -0
  752. package/dist/rules/simulator/wrappers/duration.d.ts +76 -0
  753. package/dist/rules/simulator/wrappers/duration.d.ts.map +1 -0
  754. package/dist/rules/simulator/wrappers/duration.js +176 -0
  755. package/dist/rules/simulator/wrappers/duration.js.map +1 -0
  756. package/dist/rules/simulator/wrappers/float.d.ts +52 -0
  757. package/dist/rules/simulator/wrappers/float.d.ts.map +1 -0
  758. package/dist/rules/simulator/wrappers/float.js +88 -0
  759. package/dist/rules/simulator/wrappers/float.js.map +1 -0
  760. package/dist/rules/simulator/wrappers/latlng.d.ts +40 -0
  761. package/dist/rules/simulator/wrappers/latlng.d.ts.map +1 -0
  762. package/dist/rules/simulator/wrappers/latlng.js +100 -0
  763. package/dist/rules/simulator/wrappers/latlng.js.map +1 -0
  764. package/dist/rules/simulator/wrappers/path.d.ts +75 -0
  765. package/dist/rules/simulator/wrappers/path.d.ts.map +1 -0
  766. package/dist/rules/simulator/wrappers/path.js +158 -0
  767. package/dist/rules/simulator/wrappers/path.js.map +1 -0
  768. package/dist/rules/simulator/wrappers/reference.d.ts +82 -0
  769. package/dist/rules/simulator/wrappers/reference.d.ts.map +1 -0
  770. package/dist/rules/simulator/wrappers/reference.js +145 -0
  771. package/dist/rules/simulator/wrappers/reference.js.map +1 -0
  772. package/dist/rules/simulator/wrappers/timestamp.d.ts +86 -0
  773. package/dist/rules/simulator/wrappers/timestamp.d.ts.map +1 -0
  774. package/dist/rules/simulator/wrappers/timestamp.js +207 -0
  775. package/dist/rules/simulator/wrappers/timestamp.js.map +1 -0
  776. package/dist/rules/simulator/wrappers/vector.d.ts +43 -0
  777. package/dist/rules/simulator/wrappers/vector.d.ts.map +1 -0
  778. package/dist/rules/simulator/wrappers/vector.js +80 -0
  779. package/dist/rules/simulator/wrappers/vector.js.map +1 -0
  780. package/dist/rules/simulator-tools-impl.d.ts +64 -0
  781. package/dist/rules/simulator-tools-impl.d.ts.map +1 -0
  782. package/dist/rules/simulator-tools-impl.js +462 -0
  783. package/dist/rules/simulator-tools-impl.js.map +1 -0
  784. package/dist/rules/simulator.d.ts +20 -0
  785. package/dist/rules/simulator.d.ts.map +1 -0
  786. package/dist/rules/simulator.js +24 -0
  787. package/dist/rules/simulator.js.map +1 -0
  788. package/dist/rules/stdlib-modules.d.ts +73 -0
  789. package/dist/rules/stdlib-modules.d.ts.map +1 -0
  790. package/dist/rules/stdlib-modules.js +837 -0
  791. package/dist/rules/stdlib-modules.js.map +1 -0
  792. package/dist/rules/stdlib-tools.d.ts +19 -0
  793. package/dist/rules/stdlib-tools.d.ts.map +1 -0
  794. package/dist/rules/stdlib-tools.js +164 -0
  795. package/dist/rules/stdlib-tools.js.map +1 -0
  796. package/dist/rules/test/handler.d.ts +21 -0
  797. package/dist/rules/test/handler.d.ts.map +1 -0
  798. package/dist/rules/test/handler.js +214 -0
  799. package/dist/rules/test/handler.js.map +1 -0
  800. package/dist/rules/test/spec.d.ts +677 -0
  801. package/dist/rules/test/spec.d.ts.map +1 -0
  802. package/dist/rules/test/spec.js +327 -0
  803. package/dist/rules/test/spec.js.map +1 -0
  804. package/dist/rules/tools.d.ts +41 -0
  805. package/dist/rules/tools.d.ts.map +1 -0
  806. package/dist/rules/tools.js +120 -0
  807. package/dist/rules/tools.js.map +1 -0
  808. package/dist/rules/write/handler.d.ts +6 -0
  809. package/dist/rules/write/handler.d.ts.map +1 -0
  810. package/dist/rules/write/handler.js +126 -0
  811. package/dist/rules/write/handler.js.map +1 -0
  812. package/dist/rules/write/spec.d.ts +28 -0
  813. package/dist/rules/write/spec.d.ts.map +1 -0
  814. package/dist/rules/write/spec.js +2 -0
  815. package/dist/rules/write/spec.js.map +1 -0
  816. package/dist/sandbox/admin-compat.d.ts +20 -0
  817. package/dist/sandbox/admin-compat.d.ts.map +1 -0
  818. package/dist/sandbox/admin-compat.js +19 -0
  819. package/dist/sandbox/admin-compat.js.map +1 -0
  820. package/dist/sandbox/admin-firestore/error-translation.d.ts +90 -0
  821. package/dist/sandbox/admin-firestore/error-translation.d.ts.map +1 -0
  822. package/dist/sandbox/admin-firestore/error-translation.js +214 -0
  823. package/dist/sandbox/admin-firestore/error-translation.js.map +1 -0
  824. package/dist/sandbox/admin-firestore/get-admin-firestore.d.ts +44 -0
  825. package/dist/sandbox/admin-firestore/get-admin-firestore.d.ts.map +1 -0
  826. package/dist/sandbox/admin-firestore/get-admin-firestore.js +62 -0
  827. package/dist/sandbox/admin-firestore/get-admin-firestore.js.map +1 -0
  828. package/dist/sandbox/admin-firestore/get-firestore.d.ts +34 -0
  829. package/dist/sandbox/admin-firestore/get-firestore.d.ts.map +1 -0
  830. package/dist/sandbox/admin-firestore/get-firestore.js +71 -0
  831. package/dist/sandbox/admin-firestore/get-firestore.js.map +1 -0
  832. package/dist/sandbox/admin-firestore/index.d.ts +36 -0
  833. package/dist/sandbox/admin-firestore/index.d.ts.map +1 -0
  834. package/dist/sandbox/admin-firestore/index.js +33 -0
  835. package/dist/sandbox/admin-firestore/index.js.map +1 -0
  836. package/dist/sandbox/admin-firestore/listeners.d.ts +46 -0
  837. package/dist/sandbox/admin-firestore/listeners.d.ts.map +1 -0
  838. package/dist/sandbox/admin-firestore/listeners.js +290 -0
  839. package/dist/sandbox/admin-firestore/listeners.js.map +1 -0
  840. package/dist/sandbox/admin-firestore/local-handle.d.ts +23 -0
  841. package/dist/sandbox/admin-firestore/local-handle.d.ts.map +1 -0
  842. package/dist/sandbox/admin-firestore/local-handle.js +74 -0
  843. package/dist/sandbox/admin-firestore/local-handle.js.map +1 -0
  844. package/dist/sandbox/admin-firestore/remote/batch.d.ts +6 -0
  845. package/dist/sandbox/admin-firestore/remote/batch.d.ts.map +1 -0
  846. package/dist/sandbox/admin-firestore/remote/batch.js +38 -0
  847. package/dist/sandbox/admin-firestore/remote/batch.js.map +1 -0
  848. package/dist/sandbox/admin-firestore/remote/channel.d.ts +22 -0
  849. package/dist/sandbox/admin-firestore/remote/channel.d.ts.map +1 -0
  850. package/dist/sandbox/admin-firestore/remote/channel.js +27 -0
  851. package/dist/sandbox/admin-firestore/remote/channel.js.map +1 -0
  852. package/dist/sandbox/admin-firestore/remote/doc-ref.d.ts +10 -0
  853. package/dist/sandbox/admin-firestore/remote/doc-ref.d.ts.map +1 -0
  854. package/dist/sandbox/admin-firestore/remote/doc-ref.js +88 -0
  855. package/dist/sandbox/admin-firestore/remote/doc-ref.js.map +1 -0
  856. package/dist/sandbox/admin-firestore/remote/errors.d.ts +17 -0
  857. package/dist/sandbox/admin-firestore/remote/errors.d.ts.map +1 -0
  858. package/dist/sandbox/admin-firestore/remote/errors.js +32 -0
  859. package/dist/sandbox/admin-firestore/remote/errors.js.map +1 -0
  860. package/dist/sandbox/admin-firestore/remote/listeners.d.ts +43 -0
  861. package/dist/sandbox/admin-firestore/remote/listeners.d.ts.map +1 -0
  862. package/dist/sandbox/admin-firestore/remote/listeners.js +89 -0
  863. package/dist/sandbox/admin-firestore/remote/listeners.js.map +1 -0
  864. package/dist/sandbox/admin-firestore/remote/query.d.ts +47 -0
  865. package/dist/sandbox/admin-firestore/remote/query.d.ts.map +1 -0
  866. package/dist/sandbox/admin-firestore/remote/query.js +186 -0
  867. package/dist/sandbox/admin-firestore/remote/query.js.map +1 -0
  868. package/dist/sandbox/admin-firestore/remote/remote-firestore.d.ts +55 -0
  869. package/dist/sandbox/admin-firestore/remote/remote-firestore.d.ts.map +1 -0
  870. package/dist/sandbox/admin-firestore/remote/remote-firestore.js +111 -0
  871. package/dist/sandbox/admin-firestore/remote/remote-firestore.js.map +1 -0
  872. package/dist/sandbox/admin-firestore/remote/snapshots.d.ts +10 -0
  873. package/dist/sandbox/admin-firestore/remote/snapshots.d.ts.map +1 -0
  874. package/dist/sandbox/admin-firestore/remote/snapshots.js +37 -0
  875. package/dist/sandbox/admin-firestore/remote/snapshots.js.map +1 -0
  876. package/dist/sandbox/admin-firestore/remote/transaction.d.ts +19 -0
  877. package/dist/sandbox/admin-firestore/remote/transaction.d.ts.map +1 -0
  878. package/dist/sandbox/admin-firestore/remote/transaction.js +105 -0
  879. package/dist/sandbox/admin-firestore/remote/transaction.js.map +1 -0
  880. package/dist/sandbox/admin-firestore/remote/value-codec.d.ts +52 -0
  881. package/dist/sandbox/admin-firestore/remote/value-codec.d.ts.map +1 -0
  882. package/dist/sandbox/admin-firestore/remote/value-codec.js +120 -0
  883. package/dist/sandbox/admin-firestore/remote/value-codec.js.map +1 -0
  884. package/dist/sandbox/admin-firestore/remote/wire-types.d.ts +111 -0
  885. package/dist/sandbox/admin-firestore/remote/wire-types.d.ts.map +1 -0
  886. package/dist/sandbox/admin-firestore/remote/wire-types.js +8 -0
  887. package/dist/sandbox/admin-firestore/remote/wire-types.js.map +1 -0
  888. package/dist/sandbox/admin-firestore/types.d.ts +59 -0
  889. package/dist/sandbox/admin-firestore/types.d.ts.map +1 -0
  890. package/dist/sandbox/admin-firestore/types.js +6 -0
  891. package/dist/sandbox/admin-firestore/types.js.map +1 -0
  892. package/dist/sandbox/branches/index.d.ts +141 -0
  893. package/dist/sandbox/branches/index.d.ts.map +1 -0
  894. package/dist/sandbox/branches/index.js +327 -0
  895. package/dist/sandbox/branches/index.js.map +1 -0
  896. package/dist/sandbox/firestore/admin-compat/batch.d.ts +34 -0
  897. package/dist/sandbox/firestore/admin-compat/batch.d.ts.map +1 -0
  898. package/dist/sandbox/firestore/admin-compat/batch.js +73 -0
  899. package/dist/sandbox/firestore/admin-compat/batch.js.map +1 -0
  900. package/dist/sandbox/firestore/admin-compat/doc-ref.d.ts +38 -0
  901. package/dist/sandbox/firestore/admin-compat/doc-ref.d.ts.map +1 -0
  902. package/dist/sandbox/firestore/admin-compat/doc-ref.js +154 -0
  903. package/dist/sandbox/firestore/admin-compat/doc-ref.js.map +1 -0
  904. package/dist/sandbox/firestore/admin-compat/firestore.d.ts +47 -0
  905. package/dist/sandbox/firestore/admin-compat/firestore.d.ts.map +1 -0
  906. package/dist/sandbox/firestore/admin-compat/firestore.js +117 -0
  907. package/dist/sandbox/firestore/admin-compat/firestore.js.map +1 -0
  908. package/dist/sandbox/firestore/admin-compat/index.d.ts +49 -0
  909. package/dist/sandbox/firestore/admin-compat/index.d.ts.map +1 -0
  910. package/dist/sandbox/firestore/admin-compat/index.js +27 -0
  911. package/dist/sandbox/firestore/admin-compat/index.js.map +1 -0
  912. package/dist/sandbox/firestore/admin-compat/paths.d.ts +37 -0
  913. package/dist/sandbox/firestore/admin-compat/paths.d.ts.map +1 -0
  914. package/dist/sandbox/firestore/admin-compat/paths.js +49 -0
  915. package/dist/sandbox/firestore/admin-compat/paths.js.map +1 -0
  916. package/dist/sandbox/firestore/admin-compat/query.d.ts +261 -0
  917. package/dist/sandbox/firestore/admin-compat/query.d.ts.map +1 -0
  918. package/dist/sandbox/firestore/admin-compat/query.js +758 -0
  919. package/dist/sandbox/firestore/admin-compat/query.js.map +1 -0
  920. package/dist/sandbox/firestore/admin-compat/read-translation.d.ts +8 -0
  921. package/dist/sandbox/firestore/admin-compat/read-translation.d.ts.map +1 -0
  922. package/dist/sandbox/firestore/admin-compat/read-translation.js +59 -0
  923. package/dist/sandbox/firestore/admin-compat/read-translation.js.map +1 -0
  924. package/dist/sandbox/firestore/admin-compat/snapshots.d.ts +39 -0
  925. package/dist/sandbox/firestore/admin-compat/snapshots.d.ts.map +1 -0
  926. package/dist/sandbox/firestore/admin-compat/snapshots.js +50 -0
  927. package/dist/sandbox/firestore/admin-compat/snapshots.js.map +1 -0
  928. package/dist/sandbox/firestore/admin-compat/transaction.d.ts +35 -0
  929. package/dist/sandbox/firestore/admin-compat/transaction.d.ts.map +1 -0
  930. package/dist/sandbox/firestore/admin-compat/transaction.js +88 -0
  931. package/dist/sandbox/firestore/admin-compat/transaction.js.map +1 -0
  932. package/dist/sandbox/firestore/admin-compat/types.d.ts +297 -0
  933. package/dist/sandbox/firestore/admin-compat/types.d.ts.map +1 -0
  934. package/dist/sandbox/firestore/admin-compat/types.js +127 -0
  935. package/dist/sandbox/firestore/admin-compat/types.js.map +1 -0
  936. package/dist/sandbox/firestore/admin-compat/value-order.d.ts +49 -0
  937. package/dist/sandbox/firestore/admin-compat/value-order.d.ts.map +1 -0
  938. package/dist/sandbox/firestore/admin-compat/value-order.js +172 -0
  939. package/dist/sandbox/firestore/admin-compat/value-order.js.map +1 -0
  940. package/dist/sandbox/firestore/auto-id.d.ts +26 -0
  941. package/dist/sandbox/firestore/auto-id.d.ts.map +1 -0
  942. package/dist/sandbox/firestore/auto-id.js +36 -0
  943. package/dist/sandbox/firestore/auto-id.js.map +1 -0
  944. package/dist/sandbox/firestore/converters/bytes-geopoint.d.ts +48 -0
  945. package/dist/sandbox/firestore/converters/bytes-geopoint.d.ts.map +1 -0
  946. package/dist/sandbox/firestore/converters/bytes-geopoint.js +85 -0
  947. package/dist/sandbox/firestore/converters/bytes-geopoint.js.map +1 -0
  948. package/dist/sandbox/firestore/converters/fieldvalue.d.ts +69 -0
  949. package/dist/sandbox/firestore/converters/fieldvalue.d.ts.map +1 -0
  950. package/dist/sandbox/firestore/converters/fieldvalue.js +166 -0
  951. package/dist/sandbox/firestore/converters/fieldvalue.js.map +1 -0
  952. package/dist/sandbox/firestore/converters/reference.d.ts +31 -0
  953. package/dist/sandbox/firestore/converters/reference.d.ts.map +1 -0
  954. package/dist/sandbox/firestore/converters/reference.js +51 -0
  955. package/dist/sandbox/firestore/converters/reference.js.map +1 -0
  956. package/dist/sandbox/firestore/converters/timestamp.d.ts +32 -0
  957. package/dist/sandbox/firestore/converters/timestamp.d.ts.map +1 -0
  958. package/dist/sandbox/firestore/converters/timestamp.js +63 -0
  959. package/dist/sandbox/firestore/converters/timestamp.js.map +1 -0
  960. package/dist/sandbox/firestore/converters/user-timestamp.d.ts +46 -0
  961. package/dist/sandbox/firestore/converters/user-timestamp.d.ts.map +1 -0
  962. package/dist/sandbox/firestore/converters/user-timestamp.js +65 -0
  963. package/dist/sandbox/firestore/converters/user-timestamp.js.map +1 -0
  964. package/dist/sandbox/firestore/converters/vector.d.ts +24 -0
  965. package/dist/sandbox/firestore/converters/vector.d.ts.map +1 -0
  966. package/dist/sandbox/firestore/converters/vector.js +53 -0
  967. package/dist/sandbox/firestore/converters/vector.js.map +1 -0
  968. package/dist/sandbox/firestore/errors.d.ts +82 -0
  969. package/dist/sandbox/firestore/errors.d.ts.map +1 -0
  970. package/dist/sandbox/firestore/errors.js +54 -0
  971. package/dist/sandbox/firestore/errors.js.map +1 -0
  972. package/dist/sandbox/firestore/event-log.d.ts +99 -0
  973. package/dist/sandbox/firestore/event-log.d.ts.map +1 -0
  974. package/dist/sandbox/firestore/event-log.js +67 -0
  975. package/dist/sandbox/firestore/event-log.js.map +1 -0
  976. package/dist/sandbox/firestore/field-merge.d.ts +64 -0
  977. package/dist/sandbox/firestore/field-merge.d.ts.map +1 -0
  978. package/dist/sandbox/firestore/field-merge.js +221 -0
  979. package/dist/sandbox/firestore/field-merge.js.map +1 -0
  980. package/dist/sandbox/firestore/list-query-proof.d.ts +77 -0
  981. package/dist/sandbox/firestore/list-query-proof.d.ts.map +1 -0
  982. package/dist/sandbox/firestore/list-query-proof.js +170 -0
  983. package/dist/sandbox/firestore/list-query-proof.js.map +1 -0
  984. package/dist/sandbox/firestore/local-environment.d.ts +825 -0
  985. package/dist/sandbox/firestore/local-environment.d.ts.map +1 -0
  986. package/dist/sandbox/firestore/local-environment.js +3129 -0
  987. package/dist/sandbox/firestore/local-environment.js.map +1 -0
  988. package/dist/sandbox/firestore/local-state.d.ts +196 -0
  989. package/dist/sandbox/firestore/local-state.d.ts.map +1 -0
  990. package/dist/sandbox/firestore/local-state.js +413 -0
  991. package/dist/sandbox/firestore/local-state.js.map +1 -0
  992. package/dist/sandbox/firestore/overlay-backing.d.ts +44 -0
  993. package/dist/sandbox/firestore/overlay-backing.d.ts.map +1 -0
  994. package/dist/sandbox/firestore/overlay-backing.js +82 -0
  995. package/dist/sandbox/firestore/overlay-backing.js.map +1 -0
  996. package/dist/sandbox/firestore/sentinel-capture.d.ts +30 -0
  997. package/dist/sandbox/firestore/sentinel-capture.d.ts.map +1 -0
  998. package/dist/sandbox/firestore/sentinel-capture.js +61 -0
  999. package/dist/sandbox/firestore/sentinel-capture.js.map +1 -0
  1000. package/dist/sandbox/firestore/snapshot-listeners.d.ts +290 -0
  1001. package/dist/sandbox/firestore/snapshot-listeners.d.ts.map +1 -0
  1002. package/dist/sandbox/firestore/snapshot-listeners.js +194 -0
  1003. package/dist/sandbox/firestore/snapshot-listeners.js.map +1 -0
  1004. package/dist/sandbox/firestore/topk.d.ts +12 -0
  1005. package/dist/sandbox/firestore/topk.d.ts.map +1 -0
  1006. package/dist/sandbox/firestore/topk.js +42 -0
  1007. package/dist/sandbox/firestore/topk.js.map +1 -0
  1008. package/dist/sandbox/firestore/transaction-merge.d.ts +55 -0
  1009. package/dist/sandbox/firestore/transaction-merge.d.ts.map +1 -0
  1010. package/dist/sandbox/firestore/transaction-merge.js +107 -0
  1011. package/dist/sandbox/firestore/transaction-merge.js.map +1 -0
  1012. package/dist/sandbox/firestore/transaction-types.d.ts +155 -0
  1013. package/dist/sandbox/firestore/transaction-types.d.ts.map +1 -0
  1014. package/dist/sandbox/firestore/transaction-types.js +10 -0
  1015. package/dist/sandbox/firestore/transaction-types.js.map +1 -0
  1016. package/dist/sandbox/firestore/transaction.d.ts +79 -0
  1017. package/dist/sandbox/firestore/transaction.d.ts.map +1 -0
  1018. package/dist/sandbox/firestore/transaction.js +95 -0
  1019. package/dist/sandbox/firestore/transaction.js.map +1 -0
  1020. package/dist/sandbox/firestore/value-equality.d.ts +2 -0
  1021. package/dist/sandbox/firestore/value-equality.d.ts.map +1 -0
  1022. package/dist/sandbox/firestore/value-equality.js +35 -0
  1023. package/dist/sandbox/firestore/value-equality.js.map +1 -0
  1024. package/dist/sandbox/firestore/value-resolver.d.ts +172 -0
  1025. package/dist/sandbox/firestore/value-resolver.d.ts.map +1 -0
  1026. package/dist/sandbox/firestore/value-resolver.js +221 -0
  1027. package/dist/sandbox/firestore/value-resolver.js.map +1 -0
  1028. package/dist/sandbox/firestore/wire-encoder.d.ts +14 -0
  1029. package/dist/sandbox/firestore/wire-encoder.d.ts.map +1 -0
  1030. package/dist/sandbox/firestore/wire-encoder.js +130 -0
  1031. package/dist/sandbox/firestore/wire-encoder.js.map +1 -0
  1032. package/dist/sandbox/index.d.ts +53 -0
  1033. package/dist/sandbox/index.d.ts.map +1 -0
  1034. package/dist/sandbox/index.js +65 -0
  1035. package/dist/sandbox/index.js.map +1 -0
  1036. package/dist/sandbox/internal/client-app.d.ts +29 -0
  1037. package/dist/sandbox/internal/client-app.d.ts.map +1 -0
  1038. package/dist/sandbox/internal/client-app.js +18 -0
  1039. package/dist/sandbox/internal/client-app.js.map +1 -0
  1040. package/dist/sandbox/internal/firebase-error.d.ts +14 -0
  1041. package/dist/sandbox/internal/firebase-error.d.ts.map +1 -0
  1042. package/dist/sandbox/internal/firebase-error.js +22 -0
  1043. package/dist/sandbox/internal/firebase-error.js.map +1 -0
  1044. package/dist/sandbox/internal/index.d.ts +39 -0
  1045. package/dist/sandbox/internal/index.d.ts.map +1 -0
  1046. package/dist/sandbox/internal/index.js +75 -0
  1047. package/dist/sandbox/internal/index.js.map +1 -0
  1048. package/dist/sandbox/internal/local-brand.d.ts +3 -0
  1049. package/dist/sandbox/internal/local-brand.d.ts.map +1 -0
  1050. package/dist/sandbox/internal/local-brand.js +3 -0
  1051. package/dist/sandbox/internal/local-brand.js.map +1 -0
  1052. package/dist/sandbox/internal/provenance.d.ts +16 -0
  1053. package/dist/sandbox/internal/provenance.d.ts.map +1 -0
  1054. package/dist/sandbox/internal/provenance.js +139 -0
  1055. package/dist/sandbox/internal/provenance.js.map +1 -0
  1056. package/dist/sandbox/internal/sandbox-impl.d.ts +328 -0
  1057. package/dist/sandbox/internal/sandbox-impl.d.ts.map +1 -0
  1058. package/dist/sandbox/internal/sandbox-impl.js +695 -0
  1059. package/dist/sandbox/internal/sandbox-impl.js.map +1 -0
  1060. package/dist/sandbox/operation-record.d.ts +48 -0
  1061. package/dist/sandbox/operation-record.d.ts.map +1 -0
  1062. package/dist/sandbox/operation-record.js +143 -0
  1063. package/dist/sandbox/operation-record.js.map +1 -0
  1064. package/dist/sandbox/persistence/backends.d.ts +37 -0
  1065. package/dist/sandbox/persistence/backends.d.ts.map +1 -0
  1066. package/dist/sandbox/persistence/backends.js +202 -0
  1067. package/dist/sandbox/persistence/backends.js.map +1 -0
  1068. package/dist/sandbox/persistence/chunk-format.d.ts +58 -0
  1069. package/dist/sandbox/persistence/chunk-format.d.ts.map +1 -0
  1070. package/dist/sandbox/persistence/chunk-format.js +163 -0
  1071. package/dist/sandbox/persistence/chunk-format.js.map +1 -0
  1072. package/dist/sandbox/persistence/controller.d.ts +39 -0
  1073. package/dist/sandbox/persistence/controller.d.ts.map +1 -0
  1074. package/dist/sandbox/persistence/controller.js +505 -0
  1075. package/dist/sandbox/persistence/controller.js.map +1 -0
  1076. package/dist/sandbox/persistence/index.d.ts +13 -0
  1077. package/dist/sandbox/persistence/index.d.ts.map +1 -0
  1078. package/dist/sandbox/persistence/index.js +5 -0
  1079. package/dist/sandbox/persistence/index.js.map +1 -0
  1080. package/dist/sandbox/persistence/serialize.d.ts +53 -0
  1081. package/dist/sandbox/persistence/serialize.d.ts.map +1 -0
  1082. package/dist/sandbox/persistence/serialize.js +98 -0
  1083. package/dist/sandbox/persistence/serialize.js.map +1 -0
  1084. package/dist/sandbox/persistence/types.d.ts +118 -0
  1085. package/dist/sandbox/persistence/types.d.ts.map +1 -0
  1086. package/dist/sandbox/persistence/types.js +15 -0
  1087. package/dist/sandbox/persistence/types.js.map +1 -0
  1088. package/dist/sandbox/remote.d.ts +118 -0
  1089. package/dist/sandbox/remote.d.ts.map +1 -0
  1090. package/dist/sandbox/remote.js +60 -0
  1091. package/dist/sandbox/remote.js.map +1 -0
  1092. package/dist/sandbox/replay/index.d.ts +106 -0
  1093. package/dist/sandbox/replay/index.d.ts.map +1 -0
  1094. package/dist/sandbox/replay/index.js +246 -0
  1095. package/dist/sandbox/replay/index.js.map +1 -0
  1096. package/dist/sandbox/sandbox-context.d.ts +48 -0
  1097. package/dist/sandbox/sandbox-context.d.ts.map +1 -0
  1098. package/dist/sandbox/sandbox-context.js +97 -0
  1099. package/dist/sandbox/sandbox-context.js.map +1 -0
  1100. package/dist/sandbox/tab-sync/index.d.ts +120 -0
  1101. package/dist/sandbox/tab-sync/index.d.ts.map +1 -0
  1102. package/dist/sandbox/tab-sync/index.js +273 -0
  1103. package/dist/sandbox/tab-sync/index.js.map +1 -0
  1104. package/dist/sandbox/types/auth-state.d.ts +23 -0
  1105. package/dist/sandbox/types/auth-state.d.ts.map +1 -0
  1106. package/dist/sandbox/types/auth-state.js +8 -0
  1107. package/dist/sandbox/types/auth-state.js.map +1 -0
  1108. package/dist/sandbox/types/context.d.ts +33 -0
  1109. package/dist/sandbox/types/context.d.ts.map +1 -0
  1110. package/dist/sandbox/types/context.js +5 -0
  1111. package/dist/sandbox/types/context.js.map +1 -0
  1112. package/dist/sandbox/types/errors.d.ts +109 -0
  1113. package/dist/sandbox/types/errors.d.ts.map +1 -0
  1114. package/dist/sandbox/types/errors.js +41 -0
  1115. package/dist/sandbox/types/errors.js.map +1 -0
  1116. package/dist/sandbox/types/events.d.ts +577 -0
  1117. package/dist/sandbox/types/events.d.ts.map +1 -0
  1118. package/dist/sandbox/types/events.js +7 -0
  1119. package/dist/sandbox/types/events.js.map +1 -0
  1120. package/dist/sandbox/types/index.d.ts +24 -0
  1121. package/dist/sandbox/types/index.d.ts.map +1 -0
  1122. package/dist/sandbox/types/index.js +17 -0
  1123. package/dist/sandbox/types/index.js.map +1 -0
  1124. package/dist/sandbox/types/operation.d.ts +60 -0
  1125. package/dist/sandbox/types/operation.d.ts.map +1 -0
  1126. package/dist/sandbox/types/operation.js +3 -0
  1127. package/dist/sandbox/types/operation.js.map +1 -0
  1128. package/dist/sandbox/types/persistence.d.ts +130 -0
  1129. package/dist/sandbox/types/persistence.d.ts.map +1 -0
  1130. package/dist/sandbox/types/persistence.js +7 -0
  1131. package/dist/sandbox/types/persistence.js.map +1 -0
  1132. package/dist/sandbox/types/service.d.ts +357 -0
  1133. package/dist/sandbox/types/service.d.ts.map +1 -0
  1134. package/dist/sandbox/types/service.js +6 -0
  1135. package/dist/sandbox/types/service.js.map +1 -0
  1136. package/dist/storage/admin/api.d.ts +206 -0
  1137. package/dist/storage/admin/api.d.ts.map +1 -0
  1138. package/dist/storage/admin/api.js +349 -0
  1139. package/dist/storage/admin/api.js.map +1 -0
  1140. package/dist/storage/admin/handler.d.ts +28 -0
  1141. package/dist/storage/admin/handler.d.ts.map +1 -0
  1142. package/dist/storage/admin/handler.js +82 -0
  1143. package/dist/storage/admin/handler.js.map +1 -0
  1144. package/dist/storage/admin/spec.d.ts +64 -0
  1145. package/dist/storage/admin/spec.d.ts.map +1 -0
  1146. package/dist/storage/admin/spec.js +8 -0
  1147. package/dist/storage/admin/spec.js.map +1 -0
  1148. package/dist/storage/admin/tools.d.ts +22 -0
  1149. package/dist/storage/admin/tools.d.ts.map +1 -0
  1150. package/dist/storage/admin/tools.js +90 -0
  1151. package/dist/storage/admin/tools.js.map +1 -0
  1152. package/dist/storage/download.d.ts +41 -0
  1153. package/dist/storage/download.d.ts.map +1 -0
  1154. package/dist/storage/download.js +137 -0
  1155. package/dist/storage/download.js.map +1 -0
  1156. package/dist/storage/enforce.d.ts +5 -0
  1157. package/dist/storage/enforce.d.ts.map +1 -0
  1158. package/dist/storage/enforce.js +147 -0
  1159. package/dist/storage/enforce.js.map +1 -0
  1160. package/dist/storage/errors.d.ts +44 -0
  1161. package/dist/storage/errors.d.ts.map +1 -0
  1162. package/dist/storage/errors.js +64 -0
  1163. package/dist/storage/errors.js.map +1 -0
  1164. package/dist/storage/index.d.ts +45 -0
  1165. package/dist/storage/index.d.ts.map +1 -0
  1166. package/dist/storage/index.js +39 -0
  1167. package/dist/storage/index.js.map +1 -0
  1168. package/dist/storage/instances.d.ts +9 -0
  1169. package/dist/storage/instances.d.ts.map +1 -0
  1170. package/dist/storage/instances.js +24 -0
  1171. package/dist/storage/instances.js.map +1 -0
  1172. package/dist/storage/internal.d.ts +18 -0
  1173. package/dist/storage/internal.d.ts.map +1 -0
  1174. package/dist/storage/internal.js +18 -0
  1175. package/dist/storage/internal.js.map +1 -0
  1176. package/dist/storage/list.d.ts +42 -0
  1177. package/dist/storage/list.d.ts.map +1 -0
  1178. package/dist/storage/list.js +83 -0
  1179. package/dist/storage/list.js.map +1 -0
  1180. package/dist/storage/metadata.d.ts +92 -0
  1181. package/dist/storage/metadata.d.ts.map +1 -0
  1182. package/dist/storage/metadata.js +164 -0
  1183. package/dist/storage/metadata.js.map +1 -0
  1184. package/dist/storage/persistence.d.ts +134 -0
  1185. package/dist/storage/persistence.d.ts.map +1 -0
  1186. package/dist/storage/persistence.js +132 -0
  1187. package/dist/storage/persistence.js.map +1 -0
  1188. package/dist/storage/reference.d.ts +57 -0
  1189. package/dist/storage/reference.d.ts.map +1 -0
  1190. package/dist/storage/reference.js +105 -0
  1191. package/dist/storage/reference.js.map +1 -0
  1192. package/dist/storage/rules.d.ts +339 -0
  1193. package/dist/storage/rules.d.ts.map +1 -0
  1194. package/dist/storage/rules.js +1334 -0
  1195. package/dist/storage/rules.js.map +1 -0
  1196. package/dist/storage/service.d.ts +122 -0
  1197. package/dist/storage/service.d.ts.map +1 -0
  1198. package/dist/storage/service.js +247 -0
  1199. package/dist/storage/service.js.map +1 -0
  1200. package/dist/storage/upload.d.ts +50 -0
  1201. package/dist/storage/upload.d.ts.map +1 -0
  1202. package/dist/storage/upload.js +246 -0
  1203. package/dist/storage/upload.js.map +1 -0
  1204. package/package.json +156 -3
@@ -0,0 +1,1334 @@
1
+ /**
2
+ * Storage rules — standalone subset.
3
+ *
4
+ * Why a separate evaluator (not the Firestore one):
5
+ *
6
+ * Firestore's grammar header is `service cloud.firestore` and its
7
+ * bindings (`request.method` enum of get/list/create/update/delete,
8
+ * `resource.data`, etc.) are deeply Firestore-shaped. Storage uses
9
+ * `service firebase.storage` with different bindings
10
+ * (`request.resource.size`, `request.resource.contentType`,
11
+ * `resource.metadata`). The user's call (recorded in the v1 scope
12
+ * plan): keep them independent so neither battles the other for
13
+ * grammar generality.
14
+ *
15
+ * Subset implemented in Slice 8 (Section 5 of the v1 scope):
16
+ *
17
+ * - `service firebase.storage { match … }` header
18
+ * - Nested `match` blocks with path segments:
19
+ * literal (`sessions`), parameter (`{sessionId}`), and
20
+ * multi-segment wildcard (`{allPaths=**}`)
21
+ * - `allow <verb>[, <verb>]* : if <expr>;` where verb is one of
22
+ * the coarse umbrellas (`read`, `write`) or the granular verbs
23
+ * (`get`, `list`, `create`, `update`, `delete`). `read` grants
24
+ * get + list; `write` grants create + update + delete; a granular
25
+ * grant covers only its own verb.
26
+ * - Expressions:
27
+ * literals: number, string, boolean, null
28
+ * identifiers: `request`, `resource`, plus path parameters
29
+ * member access (`a.b`), index access (`a['b']`)
30
+ * unary: `!`
31
+ * binary: `&& || == != < > <= >= + - * /`
32
+ * parens
33
+ * user-defined function calls (`isOwner(uid)`)
34
+ * `request.time` compared against the timestamp constructors
35
+ * `timestamp.date(y, m, d)` (UTC midnight) and
36
+ * `timestamp.value(epochMillis)`. The caller injects the time
37
+ * (3rd arg to `evaluateStorageRules`), defaulting to now.
38
+ * `duration.value(n, unit)` — a duration in millis, so the freshness
39
+ * idiom `request.time < resource.timeCreated + duration.value(1, 'h')`
40
+ * evaluates.
41
+ * `string.matches(re)` — whole-string RE2-style regex match
42
+ * (see `evalMatches` for the RE2-vs-JS divergence handling)
43
+ * custom-metadata access in both dotted (`resource.metadata.owner`)
44
+ * and bracket (`resource.metadata['owner']`) form — the metadata
45
+ * map is a plain string→string object, so both resolve identically
46
+ * and a missing key is `undefined` (falsy → deny).
47
+ * - `function name(params) { let …; return expr; }` declarations at
48
+ * service scope or inside a `match` block. Lexically scoped (visible
49
+ * within the declaring block and nested blocks; inner shadows
50
+ * outer), may call other functions, support `let` bindings, and are
51
+ * depth-capped. Any function-eval failure denies with a reason.
52
+ *
53
+ * - The object-identity / time fields of `resource`: `name` (the FULL object
54
+ * path, GCS convention — not the client SDK's last-segment `name`),
55
+ * `bucket`, `timeCreated`, `updated`, `generation`, `metageneration`. They
56
+ * are sourced from the persisted object record (see `resourceFromStored`),
57
+ * which already carries every one of them. There is no `resource.timeUpdated`
58
+ * in the language; the update-time field is `updated`.
59
+ *
60
+ * ERROR SEMANTICS (live-probed against the production Rules Test API — see
61
+ * `RuleError`): reading a property that is ABSENT, or dereferencing a null,
62
+ * yields an error VALUE that absorbs to DENY and SURVIVES NEGATION. Modeling
63
+ * it as a plain `undefined` would false-allow `resource.name != 'x'` on an
64
+ * object with no `name`; production denies it.
65
+ *
66
+ * Still out of scope: the content-hash fields (`md5Hash`, `crc32c`, `etag`) and
67
+ * the remaining content-* fields. Unknown builtins deny with a reason rather
68
+ * than false-allow. Hooks for adding more live at the obvious extension seams in
69
+ * the parser + evaluator.
70
+ */
71
+ /**
72
+ * Expand a coarse umbrella verb into its granular sub-verbs; a granular
73
+ * verb expands to itself. This is the single definition of the
74
+ * read→{get,list} / write→{create,update,delete} semantics, used by both
75
+ * the request side and the grant side of matching.
76
+ */
77
+ function expandVerb(verb) {
78
+ switch (verb) {
79
+ case 'read': return ['get', 'list'];
80
+ case 'write': return ['create', 'update', 'delete'];
81
+ default: return [verb];
82
+ }
83
+ }
84
+ const KEYWORDS = new Set([
85
+ 'service', 'match', 'allow', 'if', 'true', 'false', 'null',
86
+ 'read', 'write', 'get', 'list', 'create', 'update', 'delete',
87
+ 'function', 'let', 'return',
88
+ ]);
89
+ /** Verb tokens accepted in an `allow` clause. */
90
+ const GRANT_VERBS = new Set([
91
+ 'read', 'write', 'get', 'list', 'create', 'update', 'delete',
92
+ ]);
93
+ const MULTI_CHAR_OPS = ['==', '!=', '<=', '>=', '&&', '||'];
94
+ function tokenize(source) {
95
+ const tokens = [];
96
+ let i = 0;
97
+ while (i < source.length) {
98
+ const ch = source[i];
99
+ if (ch === ' ' || ch === '\t' || ch === '\n' || ch === '\r') {
100
+ i++;
101
+ continue;
102
+ }
103
+ // Line comments
104
+ if (ch === '/' && source[i + 1] === '/') {
105
+ while (i < source.length && source[i] !== '\n')
106
+ i++;
107
+ continue;
108
+ }
109
+ // String literals — single or double quoted, no escapes for the
110
+ // v1 scope (rules examples are short and use plain ASCII strings).
111
+ if (ch === "'" || ch === '"') {
112
+ const quote = ch;
113
+ const start = i;
114
+ i++;
115
+ let value = '';
116
+ while (i < source.length && source[i] !== quote) {
117
+ value += source[i];
118
+ i++;
119
+ }
120
+ if (i >= source.length) {
121
+ throw new SyntaxError(`Unterminated string literal starting at offset ${start}.`);
122
+ }
123
+ i++; // skip closing quote
124
+ tokens.push({ kind: 'string', value, pos: start });
125
+ continue;
126
+ }
127
+ // Numbers — integer only; the v1 scope's only number usage is size
128
+ // literals like `10 * 1024 * 1024`. Floats can extend later.
129
+ if (ch >= '0' && ch <= '9') {
130
+ const start = i;
131
+ let n = '';
132
+ while (i < source.length && source[i] >= '0' && source[i] <= '9') {
133
+ n += source[i];
134
+ i++;
135
+ }
136
+ tokens.push({ kind: 'number', value: Number(n), pos: start });
137
+ continue;
138
+ }
139
+ // Identifiers / keywords
140
+ if (isIdentStart(ch)) {
141
+ const start = i;
142
+ let name = '';
143
+ while (i < source.length && isIdentPart(source[i])) {
144
+ name += source[i];
145
+ i++;
146
+ }
147
+ tokens.push({ kind: 'ident', value: name, pos: start });
148
+ continue;
149
+ }
150
+ // Multi-char operators
151
+ const two = source.slice(i, i + 2);
152
+ if (MULTI_CHAR_OPS.includes(two)) {
153
+ tokens.push({ kind: 'punct', value: two, pos: i });
154
+ i += 2;
155
+ continue;
156
+ }
157
+ // Single-char punctuation. `$` is here for `$(expr)` interpolation
158
+ // segments inside a Firestore path literal (`firestore.get(/…/$(x))`).
159
+ if ('{}()[].,;:=*+-/<>!|&$'.includes(ch)) {
160
+ tokens.push({ kind: 'punct', value: ch, pos: i });
161
+ i++;
162
+ continue;
163
+ }
164
+ throw new SyntaxError(`Unexpected character "${ch}" at offset ${i}.`);
165
+ }
166
+ tokens.push({ kind: 'eof', pos: source.length });
167
+ return tokens;
168
+ }
169
+ function isIdentStart(ch) {
170
+ return (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || ch === '_';
171
+ }
172
+ function isIdentPart(ch) {
173
+ return isIdentStart(ch) || (ch >= '0' && ch <= '9');
174
+ }
175
+ // ═══════════════════════════════════════════════════════════════
176
+ // Parser
177
+ // ═══════════════════════════════════════════════════════════════
178
+ class Parser {
179
+ tokens;
180
+ pos = 0;
181
+ constructor(tokens) {
182
+ this.tokens = tokens;
183
+ }
184
+ parseService() {
185
+ // Optional leading `rules_version = '<n>';`. Production REQUIRES it for
186
+ // v2 features (functions, `let`, `matches()`); a real storage.rules file
187
+ // that uses them declares it. Accept and ignore the declaration — the
188
+ // evaluator implements v2 semantics regardless of the stated version.
189
+ if (this.atIdent('rules_version')) {
190
+ this.pos++; // rules_version
191
+ this.expectPunct('=');
192
+ this.expect('string'); // the version literal, e.g. '2'
193
+ this.expectPunct(';');
194
+ }
195
+ this.expectIdent('service');
196
+ this.expectIdent('firebase');
197
+ this.expectPunct('.');
198
+ this.expectIdent('storage');
199
+ this.expectPunct('{');
200
+ const root = { segments: [], children: [], allows: [], functions: [] };
201
+ while (!this.atPunct('}')) {
202
+ if (this.atIdent('function')) {
203
+ root.functions.push(this.parseFunction());
204
+ }
205
+ else {
206
+ this.parseMatchInto(root);
207
+ }
208
+ }
209
+ this.expectPunct('}');
210
+ return root;
211
+ }
212
+ /** Parse `function name(p1, p2) { let x = e; … return e; }`. */
213
+ parseFunction() {
214
+ this.expectIdent('function');
215
+ const name = this.expectIdentValue();
216
+ this.expectPunct('(');
217
+ const params = [];
218
+ if (!this.atPunct(')')) {
219
+ params.push(this.expectIdentValue());
220
+ while (this.atPunct(',')) {
221
+ this.expectPunct(',');
222
+ params.push(this.expectIdentValue());
223
+ }
224
+ }
225
+ this.expectPunct(')');
226
+ this.expectPunct('{');
227
+ const lets = [];
228
+ while (this.atIdent('let')) {
229
+ this.expectIdent('let');
230
+ const bindName = this.expectIdentValue();
231
+ this.expectPunct('=');
232
+ const value = this.parseExpression();
233
+ this.expectPunct(';');
234
+ lets.push({ name: bindName, value });
235
+ }
236
+ this.expectIdent('return');
237
+ const body = this.parseExpression();
238
+ this.expectPunct(';');
239
+ this.expectPunct('}');
240
+ return { name, params, lets, body };
241
+ }
242
+ /** Parse a `match /path/segments { ... }` block as a child of
243
+ * `parent`. Empty path (just `match { ... }`) is illegal. */
244
+ parseMatchInto(parent) {
245
+ this.expectIdent('match');
246
+ const segments = this.parsePath();
247
+ this.expectPunct('{');
248
+ const block = { segments, children: [], allows: [], functions: [] };
249
+ while (!this.atPunct('}')) {
250
+ if (this.atIdent('match')) {
251
+ this.parseMatchInto(block);
252
+ }
253
+ else if (this.atIdent('allow')) {
254
+ block.allows.push(this.parseAllow());
255
+ }
256
+ else if (this.atIdent('function')) {
257
+ block.functions.push(this.parseFunction());
258
+ }
259
+ else {
260
+ const t = this.peek();
261
+ throw new SyntaxError(`Expected 'match', 'allow', or 'function' inside match block at offset ${t.pos}, got "${describeToken(t)}".`);
262
+ }
263
+ }
264
+ this.expectPunct('}');
265
+ parent.children.push(block);
266
+ }
267
+ /** Parse a path like `/b/{bucket}/o/{allPaths=**}` into segments. */
268
+ parsePath() {
269
+ const segments = [];
270
+ while (this.atPunct('/')) {
271
+ this.expectPunct('/');
272
+ const t = this.peek();
273
+ if (t.kind === 'punct' && t.value === '{') {
274
+ this.expectPunct('{');
275
+ const name = this.expectIdentValue();
276
+ // `{name=**}` wildcard form
277
+ if (this.atPunct('=')) {
278
+ this.expectPunct('=');
279
+ this.expectPunct('*');
280
+ this.expectPunct('*');
281
+ this.expectPunct('}');
282
+ segments.push({ kind: 'wildcard', name });
283
+ }
284
+ else {
285
+ this.expectPunct('}');
286
+ segments.push({ kind: 'param', name });
287
+ }
288
+ }
289
+ else if (t.kind === 'ident') {
290
+ // Literal segment — `match /sessions/{id}` etc.
291
+ segments.push({ kind: 'literal', value: t.value });
292
+ this.pos++;
293
+ }
294
+ else {
295
+ throw new SyntaxError(`Expected path segment after '/' at offset ${t.pos}.`);
296
+ }
297
+ }
298
+ if (segments.length === 0) {
299
+ throw new SyntaxError(`Empty match path at offset ${this.peek().pos}.`);
300
+ }
301
+ return segments;
302
+ }
303
+ /** Parse `allow <verb>[, <verb>]*: if <expr>;` */
304
+ parseAllow() {
305
+ this.expectIdent('allow');
306
+ const verbs = [];
307
+ verbs.push(this.parseVerb());
308
+ while (this.atPunct(',')) {
309
+ this.expectPunct(',');
310
+ verbs.push(this.parseVerb());
311
+ }
312
+ this.expectPunct(':');
313
+ let condition = null;
314
+ if (this.atIdent('if')) {
315
+ this.expectIdent('if');
316
+ condition = this.parseExpression();
317
+ }
318
+ this.expectPunct(';');
319
+ return { verbs, condition };
320
+ }
321
+ parseVerb() {
322
+ const t = this.expect('ident');
323
+ if (GRANT_VERBS.has(t.value)) {
324
+ return t.value;
325
+ }
326
+ throw new SyntaxError(`Unsupported verb "${t.value}" at offset ${t.pos}. Storage rules support read, write, get, list, create, update, and delete.`);
327
+ }
328
+ // Expression precedence (loose → tight):
329
+ // OR (||) → AND (&&) → EQ (==/!=) → REL (</>/<=/>=) →
330
+ // ADD (+/-) → MUL (*//) → UNARY (!) → PRIMARY
331
+ parseExpression() { return this.parseOr(); }
332
+ parseOr() {
333
+ let left = this.parseAnd();
334
+ while (this.atPunct('||')) {
335
+ this.expectPunct('||');
336
+ left = { kind: 'binary', op: '||', left, right: this.parseAnd() };
337
+ }
338
+ return left;
339
+ }
340
+ parseAnd() {
341
+ let left = this.parseEq();
342
+ while (this.atPunct('&&')) {
343
+ this.expectPunct('&&');
344
+ left = { kind: 'binary', op: '&&', left, right: this.parseEq() };
345
+ }
346
+ return left;
347
+ }
348
+ parseEq() {
349
+ let left = this.parseRel();
350
+ while (this.atPunct('==') || this.atPunct('!=')) {
351
+ const op = this.expect('punct').value;
352
+ left = { kind: 'binary', op, left, right: this.parseRel() };
353
+ }
354
+ return left;
355
+ }
356
+ parseRel() {
357
+ let left = this.parseAdd();
358
+ while (this.atPunct('<') || this.atPunct('>') || this.atPunct('<=') || this.atPunct('>=')) {
359
+ const op = this.expect('punct').value;
360
+ left = { kind: 'binary', op, left, right: this.parseAdd() };
361
+ }
362
+ return left;
363
+ }
364
+ parseAdd() {
365
+ let left = this.parseMul();
366
+ while (this.atPunct('+') || this.atPunct('-')) {
367
+ const op = this.expect('punct').value;
368
+ left = { kind: 'binary', op, left, right: this.parseMul() };
369
+ }
370
+ return left;
371
+ }
372
+ parseMul() {
373
+ let left = this.parseUnary();
374
+ while (this.atPunct('*') || this.atPunct('/')) {
375
+ const op = this.expect('punct').value;
376
+ left = { kind: 'binary', op, left, right: this.parseUnary() };
377
+ }
378
+ return left;
379
+ }
380
+ parseUnary() {
381
+ if (this.atPunct('!')) {
382
+ this.expectPunct('!');
383
+ return { kind: 'unary', op: '!', arg: this.parseUnary() };
384
+ }
385
+ return this.parsePostfix();
386
+ }
387
+ /** `.name` and `[expr]` chain after a primary. */
388
+ parsePostfix() {
389
+ let target = this.parsePrimary();
390
+ for (;;) {
391
+ if (this.atPunct('.')) {
392
+ this.expectPunct('.');
393
+ const name = this.expectIdentValue();
394
+ target = { kind: 'member', target, name };
395
+ }
396
+ else if (this.atPunct('[')) {
397
+ this.expectPunct('[');
398
+ const index = this.parseExpression();
399
+ this.expectPunct(']');
400
+ target = { kind: 'index', target, index };
401
+ }
402
+ else if (this.atPunct('(')) {
403
+ // Call. Two shapes are accepted:
404
+ // - bare ident `f(...)` → user-defined function call
405
+ // - member `x.m(...)` → method / namespace call
406
+ // (`string.matches(re)`, `timestamp.date(...)`, …)
407
+ // Anything else (e.g. `x['k'](...)`) is not callable.
408
+ this.expectPunct('(');
409
+ const args = [];
410
+ if (!this.atPunct(')')) {
411
+ args.push(this.parseExpression());
412
+ while (this.atPunct(',')) {
413
+ this.expectPunct(',');
414
+ args.push(this.parseExpression());
415
+ }
416
+ }
417
+ this.expectPunct(')');
418
+ if (target.kind === 'ident') {
419
+ target = { kind: 'call', name: target.name, args };
420
+ }
421
+ else if (target.kind === 'member') {
422
+ target = { kind: 'methodcall', target: target.target, method: target.name, args };
423
+ }
424
+ else {
425
+ throw new SyntaxError(`Call expression at offset ${this.peek().pos} must target a function name or a member.`);
426
+ }
427
+ }
428
+ else {
429
+ return target;
430
+ }
431
+ }
432
+ }
433
+ parsePrimary() {
434
+ const t = this.peek();
435
+ // A leading `/` in primary position can only be a Firestore path
436
+ // literal (division needs a left operand, which primary position lacks).
437
+ // Only `firestore.get()/exists()` accept one; anywhere else it parses
438
+ // fine but denies at eval (see `evalExpr` 'path').
439
+ if (t.kind === 'punct' && t.value === '/') {
440
+ return this.parsePathArg();
441
+ }
442
+ if (t.kind === 'punct' && t.value === '(') {
443
+ this.expectPunct('(');
444
+ const e = this.parseExpression();
445
+ this.expectPunct(')');
446
+ return e;
447
+ }
448
+ if (t.kind === 'number') {
449
+ this.pos++;
450
+ return { kind: 'literal', value: t.value };
451
+ }
452
+ if (t.kind === 'string') {
453
+ this.pos++;
454
+ return { kind: 'literal', value: t.value };
455
+ }
456
+ if (t.kind === 'ident') {
457
+ this.pos++;
458
+ if (t.value === 'true')
459
+ return { kind: 'literal', value: true };
460
+ if (t.value === 'false')
461
+ return { kind: 'literal', value: false };
462
+ if (t.value === 'null')
463
+ return { kind: 'literal', value: null };
464
+ return { kind: 'ident', name: t.value };
465
+ }
466
+ throw new SyntaxError(`Unexpected token "${describeToken(t)}" at offset ${t.pos}.`);
467
+ }
468
+ /**
469
+ * Parse a Firestore path literal — the `firestore.get()/exists()`
470
+ * argument. Grammar (each segment preceded by `/`):
471
+ *
472
+ * - `$(expr)` — an interpolation resolved at eval time
473
+ * - `(name)` — the parenthesized database sentinel, e.g. `(default)`
474
+ * - `ident`/number — a fixed path segment (`databases`, `documents`, …)
475
+ *
476
+ * The full path is assembled and prefix-validated at eval (see
477
+ * `buildFirestoreDocPath`); the parser only captures structure.
478
+ */
479
+ parsePathArg() {
480
+ const segments = [];
481
+ while (this.atPunct('/')) {
482
+ this.expectPunct('/');
483
+ if (this.atPunct('$')) {
484
+ this.expectPunct('$');
485
+ this.expectPunct('(');
486
+ const expr = this.parseExpression();
487
+ this.expectPunct(')');
488
+ segments.push({ kind: 'interp', expr });
489
+ }
490
+ else if (this.atPunct('(')) {
491
+ // Database sentinel like `(default)`; kept verbatim (parens included)
492
+ // so the eval-time prefix check sees the exact production form.
493
+ this.expectPunct('(');
494
+ const name = this.expectIdentValue();
495
+ this.expectPunct(')');
496
+ segments.push({ kind: 'literal', value: `(${name})` });
497
+ }
498
+ else {
499
+ const t = this.peek();
500
+ if (t.kind === 'ident') {
501
+ this.pos++;
502
+ segments.push({ kind: 'literal', value: t.value });
503
+ }
504
+ else if (t.kind === 'number') {
505
+ this.pos++;
506
+ segments.push({ kind: 'literal', value: String(t.value) });
507
+ }
508
+ else {
509
+ throw new SyntaxError(`Expected a path segment after '/' at offset ${t.pos}, got "${describeToken(t)}".`);
510
+ }
511
+ }
512
+ }
513
+ if (segments.length === 0) {
514
+ throw new SyntaxError(`Empty Firestore path literal at offset ${this.peek().pos}.`);
515
+ }
516
+ return { kind: 'path', segments };
517
+ }
518
+ // ─── Token helpers ─────────────────────────────────────────
519
+ peek() { return this.tokens[this.pos]; }
520
+ atPunct(value) {
521
+ const t = this.tokens[this.pos];
522
+ return t.kind === 'punct' && t.value === value;
523
+ }
524
+ atIdent(value) {
525
+ const t = this.tokens[this.pos];
526
+ return t.kind === 'ident' && t.value === value;
527
+ }
528
+ expect(kind) {
529
+ const t = this.tokens[this.pos];
530
+ if (t.kind !== kind) {
531
+ throw new SyntaxError(`Expected ${kind} at offset ${t.pos}, got "${describeToken(t)}".`);
532
+ }
533
+ this.pos++;
534
+ return t;
535
+ }
536
+ expectIdent(value) {
537
+ const t = this.expect('ident');
538
+ if (t.value !== value) {
539
+ throw new SyntaxError(`Expected keyword "${value}" at offset ${t.pos}, got "${t.value}".`);
540
+ }
541
+ }
542
+ expectIdentValue() {
543
+ const t = this.expect('ident');
544
+ return t.value;
545
+ }
546
+ expectPunct(value) {
547
+ const t = this.expect('punct');
548
+ if (t.value !== value) {
549
+ throw new SyntaxError(`Expected "${value}" at offset ${t.pos}, got "${t.value}".`);
550
+ }
551
+ }
552
+ }
553
+ function describeToken(t) {
554
+ if (t.kind === 'eof')
555
+ return '<eof>';
556
+ if (t.kind === 'string')
557
+ return JSON.stringify(t.value);
558
+ return String(t.value);
559
+ }
560
+ // ═══════════════════════════════════════════════════════════════
561
+ // Public entry points
562
+ // ═══════════════════════════════════════════════════════════════
563
+ /**
564
+ * Parse a Storage rules source into an opaque handle. Throws
565
+ * `SyntaxError` on malformed input. Used by Slice 8's
566
+ * `getStorage(ctx, { rules })` to validate upfront.
567
+ */
568
+ export function parseStorageRules(source) {
569
+ const tokens = tokenize(source);
570
+ const parser = new Parser(tokens);
571
+ const root = parser.parseService();
572
+ resolveFunctions(root, new Map());
573
+ return { _root: root };
574
+ }
575
+ /**
576
+ * Resolve each block's visible-function map (lexical scoping): a block
577
+ * sees its ancestors' functions plus its own, with an inner declaration
578
+ * shadowing an outer one of the same name. Each function's body is bound
579
+ * to its declaring block's map so a call evaluates in declaration-site
580
+ * scope regardless of where it is called from.
581
+ */
582
+ function resolveFunctions(block, parent) {
583
+ const map = new Map(parent);
584
+ for (const fn of block.functions)
585
+ map.set(fn.name, fn);
586
+ block.visibleFuncs = map;
587
+ for (const fn of block.functions)
588
+ fn.declScope = map;
589
+ for (const child of block.children)
590
+ resolveFunctions(child, map);
591
+ }
592
+ /**
593
+ * Adapt a persisted metadata record into the `resource.*` binding the
594
+ * rules language sees.
595
+ *
596
+ * The persistence layer stores client custom metadata under
597
+ * `customMetadata` (`StoredMetadata.customMetadata`), but the rules
598
+ * language exposes it as `resource.metadata.<key>`. Without this
599
+ * mapping every `resource.metadata.X` reference reads `undefined` and
600
+ * metadata-based authorization fails open (#764). This is the single
601
+ * seam that keeps the two shapes reconciled — every gated read/delete
602
+ * call site feeds `resource` through here.
603
+ */
604
+ export function resourceFromStored(stored) {
605
+ if (!stored)
606
+ return null;
607
+ return {
608
+ size: stored.size,
609
+ contentType: stored.contentType,
610
+ metadata: stored.customMetadata,
611
+ // GCS object-name semantics — see the StorageResource docblock. Neither of
612
+ // the persisted record's two path fields is this value as-is:
613
+ // - `name` is the LAST SEGMENT (`pic.png`), the client SDK's FullMetadata
614
+ // semantics — too short.
615
+ // - `fullPath` is the FULL RESOURCE NAME including the
616
+ // `b/<bucket>/o/` prefix (`b/pyric-default/o/uploads/pic.png`), because
617
+ // that is the path the rules match tree walks — too long.
618
+ // The rules binding is the object path WITHIN the bucket
619
+ // (`uploads/pic.png`), which is `fullPath` with that prefix stripped.
620
+ name: objectNameFromFullPath(stored.fullPath, stored.bucket),
621
+ bucket: stored.bucket,
622
+ timeCreated: stored.timeCreated,
623
+ updated: stored.updated,
624
+ // Persisted as strings (FullMetadata shape); production types both `int`.
625
+ generation: numberOrUndefined(stored.generation),
626
+ metageneration: numberOrUndefined(stored.metageneration),
627
+ };
628
+ }
629
+ /**
630
+ * Reduce a persisted `fullPath` to the rules language's `resource.name` — the
631
+ * object path WITHIN the bucket.
632
+ *
633
+ * The persisted path is the full resource name (`b/<bucket>/o/<object>`), the
634
+ * form the rules match tree walks. Production's `resource.name` is only the
635
+ * `<object>` part, so the `b/<bucket>/o/` prefix comes off. The bucket-specific
636
+ * prefix is tried first; a generic `b/<any>/o/` is the fallback so a record
637
+ * whose `bucket` field is missing still reduces correctly. A path carrying no
638
+ * such prefix is already an object path and passes through untouched.
639
+ */
640
+ function objectNameFromFullPath(fullPath, bucket) {
641
+ if (fullPath === undefined)
642
+ return undefined;
643
+ const path = fullPath.startsWith('/') ? fullPath.slice(1) : fullPath;
644
+ if (bucket !== undefined) {
645
+ const prefix = `b/${bucket}/o/`;
646
+ if (path.startsWith(prefix))
647
+ return path.slice(prefix.length);
648
+ }
649
+ const generic = /^b\/[^/]+\/o\//.exec(path);
650
+ if (generic)
651
+ return path.slice(generic[0].length);
652
+ return path;
653
+ }
654
+ /** Parse a persisted numeric-string field, dropping anything unparseable so it
655
+ * reads as ABSENT (→ deny) rather than as a bogus number. */
656
+ function numberOrUndefined(v) {
657
+ if (v === undefined)
658
+ return undefined;
659
+ const n = Number(v);
660
+ return Number.isFinite(n) ? n : undefined;
661
+ }
662
+ /**
663
+ * Build the `request.resource` binding for a write. The custom
664
+ * metadata the client is about to set becomes `request.resource.metadata`
665
+ * so `allow write: if request.resource.metadata.owner == request.auth.uid`
666
+ * evaluates against the real incoming value rather than `undefined`.
667
+ */
668
+ export function requestResourceFor(args) {
669
+ return {
670
+ size: args.size,
671
+ contentType: args.contentType,
672
+ metadata: args.customMetadata,
673
+ };
674
+ }
675
+ /**
676
+ * Evaluate the rules against a request + resource binding. Returns
677
+ * `{ allowed, reasons }`. `allowed` is true iff any `allow` clause
678
+ * at any matching match block evaluates to a truthy condition.
679
+ *
680
+ * Path-matching strategy: the request's path is segmented and
681
+ * walked against the AST's match tree. Wildcards (`{p=**}`) match
682
+ * zero or more remaining segments; named params bind one segment.
683
+ *
684
+ * Multi-clause failure mode: when no clause matches, `reasons`
685
+ * contains a short trace ("no match found for path X" or "rule at
686
+ * match /sessions/{id} denied: condition false"). Helpful for the
687
+ * playground's error surface.
688
+ */
689
+ export function evaluateStorageRules(rules, input, now = new Date(), firestoreLookup) {
690
+ // `request.time` is the request's evaluation moment, modeled internally
691
+ // as epoch milliseconds so it compares numerically against the
692
+ // `timestamp.date(...)` / `timestamp.value(...)` constructors. The caller
693
+ // injects it (deterministic in tests); it defaults to now.
694
+ const nowMillis = now.getTime();
695
+ const pathSegments = splitPath(input.request.path);
696
+ const reasons = [];
697
+ // The operation's verb, reduced to its granular set. A coarse
698
+ // request method expands to its sub-verbs so umbrella semantics are
699
+ // symmetric; a precise granular verb expands to itself.
700
+ const requestVerbs = new Set(expandVerb(input.request.method));
701
+ /**
702
+ * Walk a match block. `remaining` is the still-unmatched part of
703
+ * the request path; `params` are the bindings accumulated so far.
704
+ * Recurses into matching children. Whenever a block fully
705
+ * consumes the path, its `allow` rules run.
706
+ */
707
+ function visit(block, remaining, params) {
708
+ // Match this block's segments against the start of `remaining`.
709
+ const match = matchSegments(block.segments, remaining, params);
710
+ if (!match)
711
+ return false;
712
+ const newParams = match.params;
713
+ const left = match.left;
714
+ // If this block fully consumes the path, evaluate its allow
715
+ // rules. (Or if a wildcard absorbed the remainder.)
716
+ if (left.length === 0) {
717
+ for (const rule of block.allows) {
718
+ // A grant applies when the operation's verb falls within the
719
+ // grant's verbs after coarse→granular expansion. `allow read`
720
+ // covers get + list; `allow get` covers only get.
721
+ const grantVerbs = new Set(rule.verbs.flatMap(expandVerb));
722
+ const applies = [...requestVerbs].some((v) => grantVerbs.has(v));
723
+ if (!applies)
724
+ continue;
725
+ let result;
726
+ try {
727
+ const value = rule.condition
728
+ ? evalExpr(rule.condition, {
729
+ input,
730
+ now: nowMillis,
731
+ params: newParams,
732
+ locals: {},
733
+ funcs: block.visibleFuncs ?? new Map(),
734
+ depth: 0,
735
+ firestoreLookup,
736
+ })
737
+ : true;
738
+ // An error value reaching the allow boundary DENIES, carrying
739
+ // production's own message (e.g. "Property name is undefined on
740
+ // object.") into the reason trace.
741
+ if (isErr(value)) {
742
+ reasons.push(`match ${formatPath(block.segments)} ${input.request.method}: ${value.message}`);
743
+ continue;
744
+ }
745
+ result = truthy(value);
746
+ }
747
+ catch (err) {
748
+ // Any function-evaluation failure (undefined function, wrong
749
+ // arity, depth exceeded, error inside a body) denies this rule
750
+ // with a reason that names the function — never a false allow.
751
+ if (err instanceof RuleEvalError) {
752
+ reasons.push(`match ${formatPath(block.segments)} ${input.request.method}: ${err.message}`);
753
+ continue;
754
+ }
755
+ throw err;
756
+ }
757
+ if (result)
758
+ return true;
759
+ reasons.push(`match ${formatPath(block.segments)} ${input.request.method}: condition false`);
760
+ }
761
+ }
762
+ // Recurse into children with the leftover path.
763
+ for (const child of block.children) {
764
+ if (visit(child, left, newParams))
765
+ return true;
766
+ }
767
+ return false;
768
+ }
769
+ const allowed = visit(rules._root, pathSegments, {});
770
+ if (!allowed && reasons.length === 0) {
771
+ reasons.push(`no rule matches ${input.request.method} /${pathSegments.join('/')}`);
772
+ }
773
+ return { allowed, reasons };
774
+ }
775
+ // ═══════════════════════════════════════════════════════════════
776
+ // Evaluation helpers
777
+ // ═══════════════════════════════════════════════════════════════
778
+ function splitPath(path) {
779
+ return path.split('/').filter((s) => s.length > 0);
780
+ }
781
+ function formatPath(segments) {
782
+ return ('/' +
783
+ segments
784
+ .map((s) => {
785
+ if (s.kind === 'literal')
786
+ return s.value;
787
+ if (s.kind === 'param')
788
+ return `{${s.name}}`;
789
+ return `{${s.name}=**}`;
790
+ })
791
+ .join('/'));
792
+ }
793
+ /**
794
+ * Match `segments` against the head of `remaining`. Returns the
795
+ * leftover path (if any) and the accumulated params, or `null` on
796
+ * failure. A wildcard segment must be the LAST entry in the block's
797
+ * segments — it consumes everything that remains.
798
+ */
799
+ function matchSegments(segments, remaining, params) {
800
+ let i = 0;
801
+ const next = { ...params };
802
+ for (let s = 0; s < segments.length; s++) {
803
+ const seg = segments[s];
804
+ if (seg.kind === 'wildcard') {
805
+ next[seg.name] = remaining.slice(i);
806
+ return { left: [], params: next };
807
+ }
808
+ if (i >= remaining.length)
809
+ return null;
810
+ if (seg.kind === 'literal') {
811
+ if (remaining[i] !== seg.value)
812
+ return null;
813
+ i++;
814
+ }
815
+ else {
816
+ // param
817
+ next[seg.name] = remaining[i];
818
+ i++;
819
+ }
820
+ }
821
+ return { left: remaining.slice(i), params: next };
822
+ }
823
+ /**
824
+ * A production ERROR VALUE — what the rules engine yields when an expression
825
+ * reads a property that is not present on an object, or dereferences a null.
826
+ *
827
+ * Live-probed against the production Rules Test API (`projects:test`), which
828
+ * reports these verbatim in `debugMessages`, e.g.
829
+ *
830
+ * "Error: storage.rules line [4], column [40]. Property name is undefined on object."
831
+ * "Error: storage.rules line [4], column [61]. Unsupported operation error.
832
+ * Received: int < timestamp. …"
833
+ *
834
+ * The semantics production showed, and that this type reproduces:
835
+ *
836
+ * - an error ABSORBS TO DENY at the allow boundary;
837
+ * - it SURVIVES NEGATION — `resource.name != 'x'` and `!(resource.name == 'x')`
838
+ * both DENY when `name` is absent. This is why an error must be a VALUE
839
+ * that propagates rather than a plain `undefined`: `undefined != 'x'` is
840
+ * `true` in JavaScript, which would FALSE-ALLOW exactly the extension-guard
841
+ * rules users write;
842
+ * - `<error> || true` is ALLOW (a true disjunct rescues it), while
843
+ * `<error> && …` denies.
844
+ *
845
+ * Unlike {@link RuleEvalError} (thrown, for malformed function calls), this is a
846
+ * returned value: it flows through operators the way production's does.
847
+ */
848
+ class RuleError {
849
+ message;
850
+ constructor(message) {
851
+ this.message = message;
852
+ }
853
+ }
854
+ function isErr(v) {
855
+ return v instanceof RuleError;
856
+ }
857
+ /** Property read against `obj`, with production's absent-property semantics:
858
+ * a key that is missing — or present but holding `undefined` — is an ERROR,
859
+ * never a silent `undefined`. */
860
+ function readProperty(obj, name) {
861
+ const v = obj[name];
862
+ if (v === undefined)
863
+ return new RuleError(`Property ${name} is undefined on object.`);
864
+ return v;
865
+ }
866
+ function truthy(v) {
867
+ // An error value is never truthy: it denies. (Without this, a `RuleError`
868
+ // object would be truthy and every absent-property read would FALSE-ALLOW.)
869
+ if (isErr(v))
870
+ return false;
871
+ return v !== false && v !== null && v !== undefined && !(typeof v === 'number' && Number.isNaN(v));
872
+ }
873
+ /**
874
+ * Raised when a user-defined function cannot be evaluated (undefined,
875
+ * wrong arity, call depth exceeded, or an error surfacing from within a
876
+ * body). Caught at the condition boundary and converted into a
877
+ * deny-with-reason so a function failure NEVER produces a false allow,
878
+ * matching production Storage, where evaluation errors deny.
879
+ */
880
+ class RuleEvalError extends Error {
881
+ }
882
+ /**
883
+ * Production Storage caps function call depth (documented limit 20) and
884
+ * effectively disallows recursion. We enforce a hard cap that errors
885
+ * (→ deny) rather than looping forever.
886
+ */
887
+ const MAX_CALL_DEPTH = 20;
888
+ /**
889
+ * Walk an `Expr` against the bindings + path params. The error
890
+ * model is intentionally Lax: an undefined member access returns
891
+ * `undefined` rather than throwing (mirrors what Firestore rules
892
+ * do — a missing `resource.size` against a freshly-created object
893
+ * is normal). `undefined` is falsy under `truthy`.
894
+ *
895
+ * The one place errors ARE raised is user-defined function calls
896
+ * (`RuleEvalError`): a failure there must deny, not fall through to a
897
+ * potentially-truthy value.
898
+ */
899
+ function evalExpr(expr, ctx) {
900
+ switch (expr.kind) {
901
+ case 'literal':
902
+ return expr.value;
903
+ case 'ident': {
904
+ // Local (param / let) bindings win over globals and path params.
905
+ if (expr.name in ctx.locals)
906
+ return ctx.locals[expr.name];
907
+ if (expr.name === 'request')
908
+ return buildRequestObject(ctx.input, ctx.now);
909
+ // `resource` stays a real `null` on a create (no object yet) so the
910
+ // documented `resource == null` idiom evaluates, rather than erroring.
911
+ if (expr.name === 'resource')
912
+ return buildResourceObject(ctx.input.resource);
913
+ if (expr.name in ctx.params)
914
+ return ctx.params[expr.name];
915
+ return undefined;
916
+ }
917
+ case 'member': {
918
+ const t = evalExpr(expr.target, ctx);
919
+ if (isErr(t))
920
+ return t;
921
+ // Production: dereferencing a null (e.g. `resource.name` on a create) is
922
+ // a "Null value error" — it denies, and denies through a negation too.
923
+ if (t === null || t === undefined)
924
+ return new RuleError(`Null value error.`);
925
+ return readProperty(t, expr.name);
926
+ }
927
+ case 'index': {
928
+ const t = evalExpr(expr.target, ctx);
929
+ if (isErr(t))
930
+ return t;
931
+ if (t === null || t === undefined)
932
+ return new RuleError(`Null value error.`);
933
+ const idx = evalExpr(expr.index, ctx);
934
+ if (isErr(idx))
935
+ return idx;
936
+ return readProperty(t, String(idx));
937
+ }
938
+ case 'call':
939
+ return evalCall(expr, ctx);
940
+ case 'methodcall':
941
+ return evalMethodCall(expr, ctx);
942
+ case 'path':
943
+ // A path literal is only meaningful as a `firestore.get()/exists()`
944
+ // argument (handled directly there). Reaching it anywhere else means
945
+ // the rule used it out of position — deny rather than coerce.
946
+ throw new RuleEvalError('a Firestore path literal is only valid as an argument to firestore.get()/exists()');
947
+ case 'unary': {
948
+ // An error survives negation (production: `!(resource.name == 'x')` with
949
+ // `name` absent DENIES). Propagate rather than flipping it to `true`.
950
+ const a = evalExpr(expr.arg, ctx);
951
+ if (isErr(a))
952
+ return a;
953
+ return !truthy(a);
954
+ }
955
+ case 'binary': {
956
+ // Short-circuit && / || so half-undefined chains don't trip
957
+ // (e.g. `request.auth != null && request.auth.uid == 'a'`).
958
+ if (expr.op === '&&') {
959
+ const l = evalExpr(expr.left, ctx);
960
+ if (isErr(l))
961
+ return l;
962
+ return truthy(l) ? evalExpr(expr.right, ctx) : l;
963
+ }
964
+ if (expr.op === '||') {
965
+ const l = evalExpr(expr.left, ctx);
966
+ if (isErr(l)) {
967
+ // Production: `<error> || true` ALLOWS — a true disjunct rescues the
968
+ // error; `<error> || false` stays an error.
969
+ const r = evalExpr(expr.right, ctx);
970
+ return truthy(r) ? r : l;
971
+ }
972
+ return truthy(l) ? l : evalExpr(expr.right, ctx);
973
+ }
974
+ const l = evalExpr(expr.left, ctx);
975
+ if (isErr(l))
976
+ return l;
977
+ const r = evalExpr(expr.right, ctx);
978
+ if (isErr(r))
979
+ return r;
980
+ switch (expr.op) {
981
+ // Firebase rules treat `null` and `undefined` as
982
+ // equivalent (helpful for `request.resource == null` on
983
+ // deletes, which don't carry a resource payload). Mirror
984
+ // that semantic; everything else is strict equality.
985
+ case '==': return l === r || (l == null && r == null);
986
+ case '!=': return !(l === r || (l == null && r == null));
987
+ case '<': return cmp(l, r) < 0;
988
+ case '>': return cmp(l, r) > 0;
989
+ case '<=': return cmp(l, r) <= 0;
990
+ case '>=': return cmp(l, r) >= 0;
991
+ case '+': return numOp(l, r, (a, b) => a + b);
992
+ case '-': return numOp(l, r, (a, b) => a - b);
993
+ case '*': return numOp(l, r, (a, b) => a * b);
994
+ case '/': return numOp(l, r, (a, b) => a / b);
995
+ }
996
+ }
997
+ }
998
+ }
999
+ /**
1000
+ * Evaluate a user-defined function call. Arguments are evaluated in the
1001
+ * CALLER's context, then bound to the function's parameters; the body
1002
+ * (with any `let` bindings) is evaluated in the function's own lexical
1003
+ * scope with fresh locals — caller path wildcards are not visible except
1004
+ * through the arguments passed. Every failure mode throws `RuleEvalError`
1005
+ * so the caller denies with a function-naming reason.
1006
+ */
1007
+ function evalCall(expr, ctx) {
1008
+ const fn = ctx.funcs.get(expr.name);
1009
+ if (!fn) {
1010
+ throw new RuleEvalError(`undefined function ${expr.name}()`);
1011
+ }
1012
+ if (fn.params.length !== expr.args.length) {
1013
+ throw new RuleEvalError(`function ${expr.name}() expects ${fn.params.length} argument(s), got ${expr.args.length}`);
1014
+ }
1015
+ const depth = ctx.depth + 1;
1016
+ if (depth > MAX_CALL_DEPTH) {
1017
+ throw new RuleEvalError(`function ${expr.name}() exceeded max call depth ${MAX_CALL_DEPTH}`);
1018
+ }
1019
+ // Arguments: caller context.
1020
+ const argVals = expr.args.map((a) => evalExpr(a, ctx));
1021
+ const locals = {};
1022
+ fn.params.forEach((p, i) => {
1023
+ locals[p] = argVals[i];
1024
+ });
1025
+ const bodyCtx = {
1026
+ input: ctx.input,
1027
+ now: ctx.now,
1028
+ params: {}, // no dynamic-scope leakage of caller wildcards
1029
+ locals,
1030
+ funcs: fn.declScope ?? new Map(),
1031
+ depth,
1032
+ firestoreLookup: ctx.firestoreLookup,
1033
+ };
1034
+ // `let` bindings evaluated in order; each is visible to the next and
1035
+ // to the return expression (they share the `locals` object).
1036
+ for (const b of fn.lets) {
1037
+ locals[b.name] = evalExpr(b.value, bodyCtx);
1038
+ }
1039
+ return evalExpr(fn.body, bodyCtx);
1040
+ }
1041
+ function cmp(a, b) {
1042
+ if (typeof a === 'number' && typeof b === 'number')
1043
+ return a - b;
1044
+ if (typeof a === 'string' && typeof b === 'string')
1045
+ return a < b ? -1 : a > b ? 1 : 0;
1046
+ return Number.NaN; // mismatched types → NaN → all comparisons return false
1047
+ }
1048
+ function numOp(a, b, fn) {
1049
+ if (typeof a !== 'number' || typeof b !== 'number')
1050
+ return undefined;
1051
+ return fn(a, b);
1052
+ }
1053
+ /**
1054
+ * Build the `resource.*` binding from the existing-object record, converting
1055
+ * the ISO-8601 time fields to epoch millis so they compare numerically against
1056
+ * `request.time` (which {@link buildRequestObject} models the same way) and
1057
+ * against each other (`resource.timeCreated == resource.updated`).
1058
+ *
1059
+ * `null` in → `null` out: on a create there is no object, and `resource` must
1060
+ * stay a real null so `resource == null` evaluates rather than erroring.
1061
+ *
1062
+ * A field the record does not carry is left `undefined`, which
1063
+ * {@link readProperty} reports as production's absent-property ERROR.
1064
+ */
1065
+ function buildResourceObject(resource) {
1066
+ if (resource === null)
1067
+ return null;
1068
+ return {
1069
+ size: resource.size,
1070
+ contentType: resource.contentType,
1071
+ metadata: resource.metadata,
1072
+ name: resource.name,
1073
+ bucket: resource.bucket,
1074
+ generation: resource.generation,
1075
+ metageneration: resource.metageneration,
1076
+ timeCreated: isoToMillis(resource.timeCreated),
1077
+ updated: isoToMillis(resource.updated),
1078
+ };
1079
+ }
1080
+ /** ISO-8601 → epoch millis. An unparseable or absent value stays `undefined`
1081
+ * (→ absent-property error → deny) rather than becoming `NaN`. */
1082
+ function isoToMillis(iso) {
1083
+ if (iso === undefined)
1084
+ return undefined;
1085
+ const ms = Date.parse(iso);
1086
+ return Number.isNaN(ms) ? undefined : ms;
1087
+ }
1088
+ function buildRequestObject(input, now) {
1089
+ return {
1090
+ auth: input.request.auth,
1091
+ // Present-but-null on reads (rather than absent) so the documented
1092
+ // `request.resource == null` idiom evaluates. A read THROUGH it
1093
+ // (`request.resource.size` on a get) still hits the null-dereference error.
1094
+ resource: input.request.resource ?? null,
1095
+ method: input.request.method,
1096
+ path: input.request.path,
1097
+ // `request.time` as epoch millis — see the timestamp constructors in
1098
+ // `evalMethodCall`, which produce the same representation so comparisons
1099
+ // like `request.time < timestamp.date(2030, 1, 1)` are plain numerics.
1100
+ time: now,
1101
+ };
1102
+ }
1103
+ // ═══════════════════════════════════════════════════════════════
1104
+ // Builtin method / namespace calls
1105
+ // ═══════════════════════════════════════════════════════════════
1106
+ /**
1107
+ * Evaluate a `<target>.<method>(args)` call. Two builtin families are
1108
+ * supported; everything else denies (throws `RuleEvalError`), so unknown
1109
+ * builtins — including deliberately-out-of-scope `firestore.get`/`exists` —
1110
+ * deny with a reason rather than ever a false allow.
1111
+ *
1112
+ * - `string.matches(re)` — RE2-style whole-string regex match.
1113
+ * - `timestamp.date(y, m, d)` / `timestamp.value(epochMillis)` —
1114
+ * timestamp constructors, returned as epoch millis to compare against
1115
+ * `request.time`.
1116
+ */
1117
+ function evalMethodCall(expr, ctx) {
1118
+ // Timestamp namespace: `timestamp.date(...)` / `timestamp.value(...)`.
1119
+ // Detected structurally on the bare `timestamp` identifier (not a bound
1120
+ // local/param/global) so a user value named `timestamp` can't hijack it.
1121
+ if (expr.target.kind === 'ident' &&
1122
+ expr.target.name === 'timestamp' &&
1123
+ !(expr.target.name in ctx.locals) &&
1124
+ !(expr.target.name in ctx.params)) {
1125
+ return evalTimestampBuiltin(expr, ctx);
1126
+ }
1127
+ // Duration namespace: `duration.value(n, unit)`. Detected on the bare
1128
+ // `duration` identifier so a user value named `duration` can't hijack it.
1129
+ if (expr.target.kind === 'ident' &&
1130
+ expr.target.name === 'duration' &&
1131
+ !(expr.target.name in ctx.locals) &&
1132
+ !(expr.target.name in ctx.params)) {
1133
+ return evalDurationBuiltin(expr, ctx);
1134
+ }
1135
+ // Firestore namespace: `firestore.get(path)` / `firestore.exists(path)`.
1136
+ // Detected on the bare `firestore` identifier (not a bound local/param) so
1137
+ // a user value named `firestore` can't hijack it.
1138
+ if (expr.target.kind === 'ident' &&
1139
+ expr.target.name === 'firestore' &&
1140
+ !(expr.target.name in ctx.locals) &&
1141
+ !(expr.target.name in ctx.params)) {
1142
+ return evalFirestoreBuiltin(expr, ctx);
1143
+ }
1144
+ if (expr.method === 'matches') {
1145
+ return evalMatches(expr, ctx);
1146
+ }
1147
+ throw new RuleEvalError(`unsupported method .${expr.method}()`);
1148
+ }
1149
+ /**
1150
+ * Evaluate `firestore.get(path)` / `firestore.exists(path)`.
1151
+ *
1152
+ * Requires an injected {@link FirestoreLookup} (the enforcement layer
1153
+ * supplies one from the sandbox's Firestore data). With NO capability —
1154
+ * pure/test usage without a sandbox — this denies with an "unsupported"
1155
+ * reason rather than ever a false allow, preserving the pre-lookup posture.
1156
+ *
1157
+ * Semantics (production-honest, deny-on-error):
1158
+ * - `firestore.get(path)` → a resource `{ data: <fields> }`. Member access
1159
+ * `.data.<field>` then reads the doc's fields. On a NONEXISTENT doc,
1160
+ * production `get()` is itself an error, so this denies with a reason.
1161
+ * - `firestore.exists(path)` → boolean.
1162
+ * - Malformed path (missing `/databases/<db>/documents/` prefix, odd
1163
+ * segment count), a non-string interpolation, wrong arg count, or a
1164
+ * non-path argument → deny with a reason.
1165
+ */
1166
+ function evalFirestoreBuiltin(expr, ctx) {
1167
+ if (expr.method !== 'get' && expr.method !== 'exists') {
1168
+ throw new RuleEvalError(`unsupported method firestore.${expr.method}()`);
1169
+ }
1170
+ if (!ctx.firestoreLookup) {
1171
+ // No sandbox-backed capability injected — keep the deny-with-reason
1172
+ // "unsupported" behavior; never a false allow.
1173
+ throw new RuleEvalError(`firestore.${expr.method}() is unsupported here — no Firestore lookup capability is configured`);
1174
+ }
1175
+ if (expr.args.length !== 1) {
1176
+ throw new RuleEvalError(`firestore.${expr.method}() expects a single path argument`);
1177
+ }
1178
+ const arg = expr.args[0];
1179
+ if (arg.kind !== 'path') {
1180
+ throw new RuleEvalError(`firestore.${expr.method}() requires a /databases/.../documents/... path literal`);
1181
+ }
1182
+ const docPath = buildFirestoreDocPath(arg, ctx);
1183
+ if (expr.method === 'exists') {
1184
+ return ctx.firestoreLookup.exists(docPath);
1185
+ }
1186
+ const fields = ctx.firestoreLookup.get(docPath);
1187
+ if (fields === null) {
1188
+ // Production: `get()` on a missing document errors, and errors deny.
1189
+ throw new RuleEvalError(`firestore.get() targeted a nonexistent document: ${docPath}`);
1190
+ }
1191
+ return { data: fields };
1192
+ }
1193
+ /**
1194
+ * Assemble a {@link PathArgSegment} list into the document path the
1195
+ * {@link FirestoreLookup} expects, then validate + strip the required
1196
+ * `/databases/<db>/documents/` prefix. Interpolations must resolve to a
1197
+ * string or number; anything else (e.g. `request.auth.uid` when auth is
1198
+ * null → undefined) throws → deny.
1199
+ */
1200
+ function buildFirestoreDocPath(pathExpr, ctx) {
1201
+ const parts = pathExpr.segments.map((seg) => {
1202
+ if (seg.kind === 'literal')
1203
+ return seg.value;
1204
+ const v = evalExpr(seg.expr, ctx);
1205
+ if (typeof v === 'string')
1206
+ return v;
1207
+ if (typeof v === 'number')
1208
+ return String(v);
1209
+ throw new RuleEvalError(`Firestore path interpolation resolved to ${describeType(v)} (expected a string)`);
1210
+ });
1211
+ // Required production shape: databases / <db> / documents / <doc path…>.
1212
+ if (parts.length < 4 || parts[0] !== 'databases' || parts[2] !== 'documents') {
1213
+ throw new RuleEvalError(`malformed Firestore path — expected /databases/<db>/documents/... , got /${parts.join('/')}`);
1214
+ }
1215
+ const docSegments = parts.slice(3);
1216
+ // A document path is collection/doc pairs — an even, non-zero segment count.
1217
+ if (docSegments.length === 0 || docSegments.length % 2 !== 0) {
1218
+ throw new RuleEvalError(`Firestore path does not point at a document (needs an even segment count): ${docSegments.join('/')}`);
1219
+ }
1220
+ return docSegments.join('/');
1221
+ }
1222
+ /**
1223
+ * Milliseconds in each unit `duration.value(n, unit)` accepts.
1224
+ * Production's units, per the rules language: weeks, days, hours, minutes,
1225
+ * seconds, milliseconds, nanoseconds.
1226
+ */
1227
+ const DURATION_UNIT_MILLIS = {
1228
+ w: 7 * 24 * 60 * 60 * 1000,
1229
+ d: 24 * 60 * 60 * 1000,
1230
+ h: 60 * 60 * 1000,
1231
+ m: 60 * 1000,
1232
+ s: 1000,
1233
+ ms: 1,
1234
+ ns: 1e-6,
1235
+ };
1236
+ /**
1237
+ * `duration.value(magnitude, unit)` — a duration, returned as milliseconds so
1238
+ * it adds to / subtracts from the millis-modeled timestamps
1239
+ * (`request.time`, `resource.timeCreated`). This is what makes the freshness
1240
+ * idiom production accepts work here too:
1241
+ *
1242
+ * request.time < resource.timeCreated + duration.value(1, 'h')
1243
+ */
1244
+ function evalDurationBuiltin(expr, ctx) {
1245
+ if (expr.method !== 'value') {
1246
+ throw new RuleEvalError(`unsupported duration.${expr.method}()`);
1247
+ }
1248
+ const args = expr.args.map((a) => evalExpr(a, ctx));
1249
+ if (args.length !== 2 || typeof args[0] !== 'number' || typeof args[1] !== 'string') {
1250
+ throw new RuleEvalError(`duration.value() expects (magnitude: number, unit: string)`);
1251
+ }
1252
+ const [magnitude, unit] = args;
1253
+ const millis = DURATION_UNIT_MILLIS[unit];
1254
+ if (millis === undefined) {
1255
+ throw new RuleEvalError(`duration.value() got unknown unit "${unit}" — expected one of ${Object.keys(DURATION_UNIT_MILLIS).join(', ')}`);
1256
+ }
1257
+ return magnitude * millis;
1258
+ }
1259
+ /** `timestamp.date(year, month, day)` (UTC midnight) and
1260
+ * `timestamp.value(epochMillis)`, both returning epoch milliseconds. */
1261
+ function evalTimestampBuiltin(expr, ctx) {
1262
+ const args = expr.args.map((a) => evalExpr(a, ctx));
1263
+ if (expr.method === 'value') {
1264
+ if (args.length !== 1 || typeof args[0] !== 'number') {
1265
+ throw new RuleEvalError(`timestamp.value() expects (epochMillis: number)`);
1266
+ }
1267
+ return args[0];
1268
+ }
1269
+ if (expr.method === 'date') {
1270
+ if (args.length !== 3 || !args.every((a) => typeof a === 'number')) {
1271
+ throw new RuleEvalError(`timestamp.date() expects (year, month, day) numbers`);
1272
+ }
1273
+ const [y, m, d] = args;
1274
+ // Production `timestamp.date(y, m, d)` is UTC midnight; month is 1-based.
1275
+ return Date.UTC(y, m - 1, d);
1276
+ }
1277
+ throw new RuleEvalError(`unsupported timestamp.${expr.method}()`);
1278
+ }
1279
+ /**
1280
+ * `string.matches(re)` — regex match anchored to the WHOLE string, mirroring
1281
+ * production Storage (which anchors implicitly, so `'abc'.matches('a')` is
1282
+ * FALSE).
1283
+ *
1284
+ * RE2-vs-JS divergence (honest note): production runs RE2, we compile the
1285
+ * pattern with JavaScript's `RegExp`. JS RegExp is a superset of RE2 —
1286
+ * backreferences (`\1`) and lookaround (`(?=`, `(?!`, `(?<=`, `(?<!`) work in
1287
+ * JS but are UNSUPPORTED in RE2 and would fail in production. To avoid ever
1288
+ * false-allowing on a pattern production would reject, those constructs are
1289
+ * detected up front and denied. Invalid patterns (that even JS won't compile)
1290
+ * also deny. A non-string target (e.g. a missing metadata key → undefined)
1291
+ * denies too — production would error, and an error denies.
1292
+ */
1293
+ function evalMatches(expr, ctx) {
1294
+ const subject = evalExpr(expr.target, ctx);
1295
+ // `resource.name.matches(…)` on an object whose `name` is absent: the target
1296
+ // is already production's absent-property error. Propagate it (→ deny)
1297
+ // rather than recasting it as a matches()-specific failure.
1298
+ if (isErr(subject))
1299
+ return subject;
1300
+ if (typeof subject !== 'string') {
1301
+ throw new RuleEvalError(`matches() requires a string target, got ${describeType(subject)}`);
1302
+ }
1303
+ if (expr.args.length !== 1) {
1304
+ throw new RuleEvalError(`matches() expects a single pattern argument`);
1305
+ }
1306
+ const pattern = evalExpr(expr.args[0], ctx);
1307
+ if (typeof pattern !== 'string') {
1308
+ throw new RuleEvalError(`matches() pattern must be a string`);
1309
+ }
1310
+ // Detect RE2-unsupported constructs JS would happily (mis)compile.
1311
+ const backref = /\\[1-9]/.test(pattern);
1312
+ const lookaround = /\(\?<?[=!]/.test(pattern);
1313
+ if (backref || lookaround) {
1314
+ throw new RuleEvalError(`matches() pattern uses an RE2-unsupported construct (${backref ? 'backreference' : 'lookaround'}) that production would reject`);
1315
+ }
1316
+ let re;
1317
+ try {
1318
+ // Anchor to the whole string. `(?:...)` keeps the caller's alternations
1319
+ // from binding past the anchors.
1320
+ re = new RegExp(`^(?:${pattern})$`);
1321
+ }
1322
+ catch (err) {
1323
+ throw new RuleEvalError(`matches() invalid regex pattern: ${err.message}`);
1324
+ }
1325
+ return re.test(subject);
1326
+ }
1327
+ function describeType(v) {
1328
+ if (v === null)
1329
+ return 'null';
1330
+ if (v === undefined)
1331
+ return 'undefined';
1332
+ return typeof v;
1333
+ }
1334
+ //# sourceMappingURL=rules.js.map