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.
- package/LICENSE +216 -0
- package/README.md +179 -2
- package/README.md.orig +54 -0
- package/dist/ai/backend.d.ts +35 -0
- package/dist/ai/backend.d.ts.map +1 -0
- package/dist/ai/backend.js +42 -0
- package/dist/ai/backend.js.map +1 -0
- package/dist/ai/broker/broker.d.ts +65 -0
- package/dist/ai/broker/broker.d.ts.map +1 -0
- package/dist/ai/broker/broker.js +184 -0
- package/dist/ai/broker/broker.js.map +1 -0
- package/dist/ai/broker/index.d.ts +12 -0
- package/dist/ai/broker/index.d.ts.map +1 -0
- package/dist/ai/broker/index.js +11 -0
- package/dist/ai/broker/index.js.map +1 -0
- package/dist/ai/broker/openai-engine.d.ts +175 -0
- package/dist/ai/broker/openai-engine.d.ts.map +1 -0
- package/dist/ai/broker/openai-engine.js +502 -0
- package/dist/ai/broker/openai-engine.js.map +1 -0
- package/dist/ai/broker/scripted-engine.d.ts +44 -0
- package/dist/ai/broker/scripted-engine.d.ts.map +1 -0
- package/dist/ai/broker/scripted-engine.js +218 -0
- package/dist/ai/broker/scripted-engine.js.map +1 -0
- package/dist/ai/broker/synthesizer.d.ts +100 -0
- package/dist/ai/broker/synthesizer.d.ts.map +1 -0
- package/dist/ai/broker/synthesizer.js +278 -0
- package/dist/ai/broker/synthesizer.js.map +1 -0
- package/dist/ai/broker/types.d.ts +210 -0
- package/dist/ai/broker/types.d.ts.map +1 -0
- package/dist/ai/broker/types.js +20 -0
- package/dist/ai/broker/types.js.map +1 -0
- package/dist/ai/enums.d.ts +174 -0
- package/dist/ai/enums.d.ts.map +1 -0
- package/dist/ai/enums.js +155 -0
- package/dist/ai/enums.js.map +1 -0
- package/dist/ai/errors.d.ts +66 -0
- package/dist/ai/errors.d.ts.map +1 -0
- package/dist/ai/errors.js +100 -0
- package/dist/ai/errors.js.map +1 -0
- package/dist/ai/index.d.ts +31 -0
- package/dist/ai/index.d.ts.map +1 -0
- package/dist/ai/index.js +27 -0
- package/dist/ai/index.js.map +1 -0
- package/dist/ai/instances.d.ts +15 -0
- package/dist/ai/instances.d.ts.map +1 -0
- package/dist/ai/instances.js +69 -0
- package/dist/ai/instances.js.map +1 -0
- package/dist/ai/internal.d.ts +13 -0
- package/dist/ai/internal.d.ts.map +1 -0
- package/dist/ai/internal.js +45 -0
- package/dist/ai/internal.js.map +1 -0
- package/dist/ai/models.d.ts +116 -0
- package/dist/ai/models.d.ts.map +1 -0
- package/dist/ai/models.js +213 -0
- package/dist/ai/models.js.map +1 -0
- package/dist/ai/request-helpers.d.ts +59 -0
- package/dist/ai/request-helpers.d.ts.map +1 -0
- package/dist/ai/request-helpers.js +157 -0
- package/dist/ai/request-helpers.js.map +1 -0
- package/dist/ai/response-helpers.d.ts +41 -0
- package/dist/ai/response-helpers.d.ts.map +1 -0
- package/dist/ai/response-helpers.js +204 -0
- package/dist/ai/response-helpers.js.map +1 -0
- package/dist/ai/sandbox-plane.d.ts +41 -0
- package/dist/ai/sandbox-plane.d.ts.map +1 -0
- package/dist/ai/sandbox-plane.js +159 -0
- package/dist/ai/sandbox-plane.js.map +1 -0
- package/dist/ai/schema.d.ts +105 -0
- package/dist/ai/schema.d.ts.map +1 -0
- package/dist/ai/schema.js +174 -0
- package/dist/ai/schema.js.map +1 -0
- package/dist/ai/scripting.d.ts +53 -0
- package/dist/ai/scripting.d.ts.map +1 -0
- package/dist/ai/scripting.js +73 -0
- package/dist/ai/scripting.js.map +1 -0
- package/dist/ai/target.d.ts +20 -0
- package/dist/ai/target.d.ts.map +1 -0
- package/dist/ai/target.js +29 -0
- package/dist/ai/target.js.map +1 -0
- package/dist/ai/types.d.ts +400 -0
- package/dist/ai/types.d.ts.map +1 -0
- package/dist/ai/types.js +10 -0
- package/dist/ai/types.js.map +1 -0
- package/dist/app/diagnostics.d.ts +29 -0
- package/dist/app/diagnostics.d.ts.map +1 -0
- package/dist/app/diagnostics.js +88 -0
- package/dist/app/diagnostics.js.map +1 -0
- package/dist/app/index.d.ts +7 -0
- package/dist/app/index.d.ts.map +1 -0
- package/dist/app/index.js +5 -0
- package/dist/app/index.js.map +1 -0
- package/dist/app/internal.d.ts +11 -0
- package/dist/app/internal.d.ts.map +1 -0
- package/dist/app/internal.js +18 -0
- package/dist/app/internal.js.map +1 -0
- package/dist/app/options.d.ts +3 -0
- package/dist/app/options.d.ts.map +1 -0
- package/dist/app/options.js +19 -0
- package/dist/app/options.js.map +1 -0
- package/dist/app/register.d.ts +4 -0
- package/dist/app/register.d.ts.map +1 -0
- package/dist/app/register.js +35 -0
- package/dist/app/register.js.map +1 -0
- package/dist/app/registry.d.ts +12 -0
- package/dist/app/registry.d.ts.map +1 -0
- package/dist/app/registry.js +147 -0
- package/dist/app/registry.js.map +1 -0
- package/dist/app/runtime.d.ts +18 -0
- package/dist/app/runtime.d.ts.map +1 -0
- package/dist/app/runtime.js +119 -0
- package/dist/app/runtime.js.map +1 -0
- package/dist/app/types.d.ts +21 -0
- package/dist/app/types.d.ts.map +1 -0
- package/dist/app/types.js +2 -0
- package/dist/app/types.js.map +1 -0
- package/dist/auth/action-code-url.d.ts +70 -0
- package/dist/auth/action-code-url.d.ts.map +1 -0
- package/dist/auth/action-code-url.js +124 -0
- package/dist/auth/action-code-url.js.map +1 -0
- package/dist/auth/action-codes.d.ts +201 -0
- package/dist/auth/action-codes.d.ts.map +1 -0
- package/dist/auth/action-codes.js +355 -0
- package/dist/auth/action-codes.js.map +1 -0
- package/dist/auth/auth-errors.d.ts +21 -0
- package/dist/auth/auth-errors.d.ts.map +1 -0
- package/dist/auth/auth-errors.js +23 -0
- package/dist/auth/auth-errors.js.map +1 -0
- package/dist/auth/config-tokens.d.ts +90 -0
- package/dist/auth/config-tokens.d.ts.map +1 -0
- package/dist/auth/config-tokens.js +86 -0
- package/dist/auth/config-tokens.js.map +1 -0
- package/dist/auth/credentials.d.ts +140 -0
- package/dist/auth/credentials.d.ts.map +1 -0
- package/dist/auth/credentials.js +194 -0
- package/dist/auth/credentials.js.map +1 -0
- package/dist/auth/email-link.d.ts +91 -0
- package/dist/auth/email-link.d.ts.map +1 -0
- package/dist/auth/email-link.js +172 -0
- package/dist/auth/email-link.js.map +1 -0
- package/dist/auth/enums.d.ts +210 -0
- package/dist/auth/enums.d.ts.map +1 -0
- package/dist/auth/enums.js +206 -0
- package/dist/auth/enums.js.map +1 -0
- package/dist/auth/index.d.ts +3 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +3 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/instances.d.ts +14 -0
- package/dist/auth/instances.d.ts.map +1 -0
- package/dist/auth/instances.js +95 -0
- package/dist/auth/instances.js.map +1 -0
- package/dist/auth/linking.d.ts +93 -0
- package/dist/auth/linking.d.ts.map +1 -0
- package/dist/auth/linking.js +189 -0
- package/dist/auth/linking.js.map +1 -0
- package/dist/auth/modular.d.ts +22 -0
- package/dist/auth/modular.d.ts.map +1 -0
- package/dist/auth/modular.js +18 -0
- package/dist/auth/modular.js.map +1 -0
- package/dist/auth/password-policy.d.ts +60 -0
- package/dist/auth/password-policy.d.ts.map +1 -0
- package/dist/auth/password-policy.js +68 -0
- package/dist/auth/password-policy.js.map +1 -0
- package/dist/auth/providers.d.ts +153 -0
- package/dist/auth/providers.d.ts.map +1 -0
- package/dist/auth/providers.js +207 -0
- package/dist/auth/providers.js.map +1 -0
- package/dist/auth/reauth.d.ts +73 -0
- package/dist/auth/reauth.d.ts.map +1 -0
- package/dist/auth/reauth.js +148 -0
- package/dist/auth/reauth.js.map +1 -0
- package/dist/auth/sandbox/driver.d.ts +51 -0
- package/dist/auth/sandbox/driver.d.ts.map +1 -0
- package/dist/auth/sandbox/driver.js +88 -0
- package/dist/auth/sandbox/driver.js.map +1 -0
- package/dist/auth/sandbox/persistence.d.ts +7 -0
- package/dist/auth/sandbox/persistence.d.ts.map +1 -0
- package/dist/auth/sandbox/persistence.js +121 -0
- package/dist/auth/sandbox/persistence.js.map +1 -0
- package/dist/auth/sandbox/project-store.d.ts +15 -0
- package/dist/auth/sandbox/project-store.d.ts.map +1 -0
- package/dist/auth/sandbox/project-store.js +17 -0
- package/dist/auth/sandbox/project-store.js.map +1 -0
- package/dist/auth/sandbox-auth-flow.d.ts +173 -0
- package/dist/auth/sandbox-auth-flow.d.ts.map +1 -0
- package/dist/auth/sandbox-auth-flow.js +165 -0
- package/dist/auth/sandbox-auth-flow.js.map +1 -0
- package/dist/auth/sandbox-backend-types.d.ts +197 -0
- package/dist/auth/sandbox-backend-types.d.ts.map +1 -0
- package/dist/auth/sandbox-backend-types.js +18 -0
- package/dist/auth/sandbox-backend-types.js.map +1 -0
- package/dist/auth/sandbox-backend.d.ts +811 -0
- package/dist/auth/sandbox-backend.d.ts.map +1 -0
- package/dist/auth/sandbox-backend.js +2007 -0
- package/dist/auth/sandbox-backend.js.map +1 -0
- package/dist/auth/sandbox-credential-validators.d.ts +30 -0
- package/dist/auth/sandbox-credential-validators.d.ts.map +1 -0
- package/dist/auth/sandbox-credential-validators.js +47 -0
- package/dist/auth/sandbox-credential-validators.js.map +1 -0
- package/dist/auth/sandbox-token.d.ts +24 -0
- package/dist/auth/sandbox-token.d.ts.map +1 -0
- package/dist/auth/sandbox-token.js +32 -0
- package/dist/auth/sandbox-token.js.map +1 -0
- package/dist/auth/sign-in.d.ts +14 -0
- package/dist/auth/sign-in.d.ts.map +1 -0
- package/dist/auth/sign-in.js +140 -0
- package/dist/auth/sign-in.js.map +1 -0
- package/dist/auth/target.d.ts +29 -0
- package/dist/auth/target.d.ts.map +1 -0
- package/dist/auth/target.js +23 -0
- package/dist/auth/target.js.map +1 -0
- package/dist/auth/tokens.d.ts +54 -0
- package/dist/auth/tokens.d.ts.map +1 -0
- package/dist/auth/tokens.js +142 -0
- package/dist/auth/tokens.js.map +1 -0
- package/dist/auth/types.d.ts +283 -0
- package/dist/auth/types.d.ts.map +1 -0
- package/dist/auth/types.js +24 -0
- package/dist/auth/types.js.map +1 -0
- package/dist/auth/user-lifecycle.d.ts +17 -0
- package/dist/auth/user-lifecycle.d.ts.map +1 -0
- package/dist/auth/user-lifecycle.js +60 -0
- package/dist/auth/user-lifecycle.js.map +1 -0
- package/dist/database/index.d.ts +9 -0
- package/dist/database/index.d.ts.map +1 -0
- package/dist/database/index.js +9 -0
- package/dist/database/index.js.map +1 -0
- package/dist/database/listener-registry.d.ts +16 -0
- package/dist/database/listener-registry.d.ts.map +1 -0
- package/dist/database/listener-registry.js +68 -0
- package/dist/database/listener-registry.js.map +1 -0
- package/dist/database/modular.d.ts +632 -0
- package/dist/database/modular.d.ts.map +1 -0
- package/dist/database/modular.js +1071 -0
- package/dist/database/modular.js.map +1 -0
- package/dist/database/replay.d.ts +32 -0
- package/dist/database/replay.d.ts.map +1 -0
- package/dist/database/replay.js +124 -0
- package/dist/database/replay.js.map +1 -0
- package/dist/database/sandbox/backend-for.d.ts +10 -0
- package/dist/database/sandbox/backend-for.d.ts.map +1 -0
- package/dist/database/sandbox/backend-for.js +19 -0
- package/dist/database/sandbox/backend-for.js.map +1 -0
- package/dist/database/sandbox/backend.d.ts +407 -0
- package/dist/database/sandbox/backend.d.ts.map +1 -0
- package/dist/database/sandbox/backend.js +1495 -0
- package/dist/database/sandbox/backend.js.map +1 -0
- package/dist/database/sandbox/data-tree.d.ts +123 -0
- package/dist/database/sandbox/data-tree.d.ts.map +1 -0
- package/dist/database/sandbox/data-tree.js +310 -0
- package/dist/database/sandbox/data-tree.js.map +1 -0
- package/dist/database/sandbox/normalize.d.ts +77 -0
- package/dist/database/sandbox/normalize.d.ts.map +1 -0
- package/dist/database/sandbox/normalize.js +165 -0
- package/dist/database/sandbox/normalize.js.map +1 -0
- package/dist/database/sandbox/push-id.d.ts +32 -0
- package/dist/database/sandbox/push-id.d.ts.map +1 -0
- package/dist/database/sandbox/push-id.js +82 -0
- package/dist/database/sandbox/push-id.js.map +1 -0
- package/dist/database/sandbox/query.d.ts +175 -0
- package/dist/database/sandbox/query.d.ts.map +1 -0
- package/dist/database/sandbox/query.js +269 -0
- package/dist/database/sandbox/query.js.map +1 -0
- package/dist/database/sandbox/rules-eval.d.ts +87 -0
- package/dist/database/sandbox/rules-eval.d.ts.map +1 -0
- package/dist/database/sandbox/rules-eval.js +131 -0
- package/dist/database/sandbox/rules-eval.js.map +1 -0
- package/dist/database/sandbox/sentinels.d.ts +71 -0
- package/dist/database/sandbox/sentinels.d.ts.map +1 -0
- package/dist/database/sandbox/sentinels.js +92 -0
- package/dist/database/sandbox/sentinels.js.map +1 -0
- package/dist/database/sandbox-controls.d.ts +15 -0
- package/dist/database/sandbox-controls.d.ts.map +1 -0
- package/dist/database/sandbox-controls.js +18 -0
- package/dist/database/sandbox-controls.js.map +1 -0
- package/dist/firestore/aggregates.d.ts +50 -0
- package/dist/firestore/aggregates.d.ts.map +1 -0
- package/dist/firestore/aggregates.js +40 -0
- package/dist/firestore/aggregates.js.map +1 -0
- package/dist/firestore/equality.d.ts +5 -0
- package/dist/firestore/equality.d.ts.map +1 -0
- package/dist/firestore/equality.js +20 -0
- package/dist/firestore/equality.js.map +1 -0
- package/dist/firestore/field-values.d.ts +61 -0
- package/dist/firestore/field-values.d.ts.map +1 -0
- package/dist/firestore/field-values.js +167 -0
- package/dist/firestore/field-values.js.map +1 -0
- package/dist/firestore/index.d.ts +54 -0
- package/dist/firestore/index.d.ts.map +1 -0
- package/dist/firestore/index.js +54 -0
- package/dist/firestore/index.js.map +1 -0
- package/dist/firestore/instances.d.ts +123 -0
- package/dist/firestore/instances.d.ts.map +1 -0
- package/dist/firestore/instances.js +177 -0
- package/dist/firestore/instances.js.map +1 -0
- package/dist/firestore/internal/index.d.ts +2 -0
- package/dist/firestore/internal/index.d.ts.map +1 -0
- package/dist/firestore/internal/index.js +2 -0
- package/dist/firestore/internal/index.js.map +1 -0
- package/dist/firestore/internal/listener-routing.d.ts +4 -0
- package/dist/firestore/internal/listener-routing.d.ts.map +1 -0
- package/dist/firestore/internal/listener-routing.js +4 -0
- package/dist/firestore/internal/listener-routing.js.map +1 -0
- package/dist/firestore/listeners.d.ts +12 -0
- package/dist/firestore/listeners.d.ts.map +1 -0
- package/dist/firestore/listeners.js +200 -0
- package/dist/firestore/listeners.js.map +1 -0
- package/dist/firestore/persistence.d.ts +227 -0
- package/dist/firestore/persistence.d.ts.map +1 -0
- package/dist/firestore/persistence.js +245 -0
- package/dist/firestore/persistence.js.map +1 -0
- package/dist/firestore/query-constraints.d.ts +72 -0
- package/dist/firestore/query-constraints.d.ts.map +1 -0
- package/dist/firestore/query-constraints.js +168 -0
- package/dist/firestore/query-constraints.js.map +1 -0
- package/dist/firestore/reads.d.ts +12 -0
- package/dist/firestore/reads.d.ts.map +1 -0
- package/dist/firestore/reads.js +32 -0
- package/dist/firestore/reads.js.map +1 -0
- package/dist/firestore/refs.d.ts +27 -0
- package/dist/firestore/refs.d.ts.map +1 -0
- package/dist/firestore/refs.js +74 -0
- package/dist/firestore/refs.js.map +1 -0
- package/dist/firestore/sandbox-controls.d.ts +60 -0
- package/dist/firestore/sandbox-controls.d.ts.map +1 -0
- package/dist/firestore/sandbox-controls.js +77 -0
- package/dist/firestore/sandbox-controls.js.map +1 -0
- package/dist/firestore/snapshots.d.ts +71 -0
- package/dist/firestore/snapshots.d.ts.map +1 -0
- package/dist/firestore/snapshots.js +160 -0
- package/dist/firestore/snapshots.js.map +1 -0
- package/dist/firestore/state.d.ts +168 -0
- package/dist/firestore/state.d.ts.map +1 -0
- package/dist/firestore/state.js +260 -0
- package/dist/firestore/state.js.map +1 -0
- package/dist/firestore/tools.d.ts +71 -0
- package/dist/firestore/tools.d.ts.map +1 -0
- package/dist/firestore/tools.js +320 -0
- package/dist/firestore/tools.js.map +1 -0
- package/dist/firestore/transactions.d.ts +4 -0
- package/dist/firestore/transactions.d.ts.map +1 -0
- package/dist/firestore/transactions.js +14 -0
- package/dist/firestore/transactions.js.map +1 -0
- package/dist/firestore/types.d.ts +82 -0
- package/dist/firestore/types.d.ts.map +1 -0
- package/dist/firestore/types.js +15 -0
- package/dist/firestore/types.js.map +1 -0
- package/dist/firestore/writes.d.ts +43 -0
- package/dist/firestore/writes.d.ts.map +1 -0
- package/dist/firestore/writes.js +40 -0
- package/dist/firestore/writes.js.map +1 -0
- package/dist/firestore-values/index.d.ts +63 -0
- package/dist/firestore-values/index.d.ts.map +1 -0
- package/dist/firestore-values/index.js +148 -0
- package/dist/firestore-values/index.js.map +1 -0
- package/dist/messaging/broker/broker.d.ts +171 -0
- package/dist/messaging/broker/broker.d.ts.map +1 -0
- package/dist/messaging/broker/broker.js +400 -0
- package/dist/messaging/broker/broker.js.map +1 -0
- package/dist/messaging/broker/envelopes.d.ts +96 -0
- package/dist/messaging/broker/envelopes.d.ts.map +1 -0
- package/dist/messaging/broker/envelopes.js +132 -0
- package/dist/messaging/broker/envelopes.js.map +1 -0
- package/dist/messaging/broker/index.d.ts +27 -0
- package/dist/messaging/broker/index.d.ts.map +1 -0
- package/dist/messaging/broker/index.js +21 -0
- package/dist/messaging/broker/index.js.map +1 -0
- package/dist/messaging/broker/tokens.d.ts +22 -0
- package/dist/messaging/broker/tokens.d.ts.map +1 -0
- package/dist/messaging/broker/tokens.js +37 -0
- package/dist/messaging/broker/tokens.js.map +1 -0
- package/dist/messaging/broker/types.d.ts +117 -0
- package/dist/messaging/broker/types.d.ts.map +1 -0
- package/dist/messaging/broker/types.js +12 -0
- package/dist/messaging/broker/types.js.map +1 -0
- package/dist/messaging/broker/validate.d.ts +58 -0
- package/dist/messaging/broker/validate.d.ts.map +1 -0
- package/dist/messaging/broker/validate.js +196 -0
- package/dist/messaging/broker/validate.js.map +1 -0
- package/dist/messaging/client.d.ts +108 -0
- package/dist/messaging/client.d.ts.map +1 -0
- package/dist/messaging/client.js +65 -0
- package/dist/messaging/client.js.map +1 -0
- package/dist/messaging/index.d.ts +3 -0
- package/dist/messaging/index.d.ts.map +1 -0
- package/dist/messaging/index.js +3 -0
- package/dist/messaging/index.js.map +1 -0
- package/dist/messaging/instance.d.ts +72 -0
- package/dist/messaging/instance.d.ts.map +1 -0
- package/dist/messaging/instance.js +93 -0
- package/dist/messaging/instance.js.map +1 -0
- package/dist/messaging/internal.d.ts +12 -0
- package/dist/messaging/internal.d.ts.map +1 -0
- package/dist/messaging/internal.js +12 -0
- package/dist/messaging/internal.js.map +1 -0
- package/dist/messaging/sw.d.ts +49 -0
- package/dist/messaging/sw.d.ts.map +1 -0
- package/dist/messaging/sw.js +49 -0
- package/dist/messaging/sw.js.map +1 -0
- package/dist/project-scope.d.ts +5 -0
- package/dist/project-scope.d.ts.map +1 -0
- package/dist/project-scope.js +2 -0
- package/dist/project-scope.js.map +1 -0
- package/dist/rules/api/assert.d.ts +39 -0
- package/dist/rules/api/assert.d.ts.map +1 -0
- package/dist/rules/api/assert.js +93 -0
- package/dist/rules/api/assert.js.map +1 -0
- package/dist/rules/api/case-types.d.ts +141 -0
- package/dist/rules/api/case-types.d.ts.map +1 -0
- package/dist/rules/api/case-types.js +13 -0
- package/dist/rules/api/case-types.js.map +1 -0
- package/dist/rules/api/errors.d.ts +38 -0
- package/dist/rules/api/errors.d.ts.map +1 -0
- package/dist/rules/api/errors.js +47 -0
- package/dist/rules/api/errors.js.map +1 -0
- package/dist/rules/api/firestore.d.ts +34 -0
- package/dist/rules/api/firestore.d.ts.map +1 -0
- package/dist/rules/api/firestore.js +137 -0
- package/dist/rules/api/firestore.js.map +1 -0
- package/dist/rules/api/issue.d.ts +50 -0
- package/dist/rules/api/issue.d.ts.map +1 -0
- package/dist/rules/api/issue.js +66 -0
- package/dist/rules/api/issue.js.map +1 -0
- package/dist/rules/api/lint.d.ts +16 -0
- package/dist/rules/api/lint.d.ts.map +1 -0
- package/dist/rules/api/lint.js +60 -0
- package/dist/rules/api/lint.js.map +1 -0
- package/dist/rules/api/rtdb.d.ts +33 -0
- package/dist/rules/api/rtdb.d.ts.map +1 -0
- package/dist/rules/api/rtdb.js +166 -0
- package/dist/rules/api/rtdb.js.map +1 -0
- package/dist/rules/api/values.d.ts +51 -0
- package/dist/rules/api/values.d.ts.map +1 -0
- package/dist/rules/api/values.js +66 -0
- package/dist/rules/api/values.js.map +1 -0
- package/dist/rules/generators/assembler.d.ts +19 -0
- package/dist/rules/generators/assembler.d.ts.map +1 -0
- package/dist/rules/generators/assembler.js +292 -0
- package/dist/rules/generators/assembler.js.map +1 -0
- package/dist/rules/generators/expressions.d.ts +52 -0
- package/dist/rules/generators/expressions.d.ts.map +1 -0
- package/dist/rules/generators/expressions.js +117 -0
- package/dist/rules/generators/expressions.js.map +1 -0
- package/dist/rules/generators/grid.d.ts +22 -0
- package/dist/rules/generators/grid.d.ts.map +1 -0
- package/dist/rules/generators/grid.js +52 -0
- package/dist/rules/generators/grid.js.map +1 -0
- package/dist/rules/grammar/FirestoreAST.d.ts +129 -0
- package/dist/rules/grammar/FirestoreAST.d.ts.map +1 -0
- package/dist/rules/grammar/FirestoreAST.js +3 -0
- package/dist/rules/grammar/FirestoreAST.js.map +1 -0
- package/dist/rules/grammar/FirestoreAssembler.d.ts +5 -0
- package/dist/rules/grammar/FirestoreAssembler.d.ts.map +1 -0
- package/dist/rules/grammar/FirestoreAssembler.js +158 -0
- package/dist/rules/grammar/FirestoreAssembler.js.map +1 -0
- package/dist/rules/grammar/FirestoreParser.d.ts +46 -0
- package/dist/rules/grammar/FirestoreParser.d.ts.map +1 -0
- package/dist/rules/grammar/FirestoreParser.js +409 -0
- package/dist/rules/grammar/FirestoreParser.js.map +1 -0
- package/dist/rules/grammar/FirestoreRules.ohm +229 -0
- package/dist/rules/grammar/FirestoreRules.ohm.generated.d.ts +2 -0
- package/dist/rules/grammar/FirestoreRules.ohm.generated.d.ts.map +1 -0
- package/dist/rules/grammar/FirestoreRules.ohm.generated.js +234 -0
- package/dist/rules/grammar/FirestoreRules.ohm.generated.js.map +1 -0
- package/dist/rules/grammar/FirestoreValidator.d.ts +10 -0
- package/dist/rules/grammar/FirestoreValidator.d.ts.map +1 -0
- package/dist/rules/grammar/FirestoreValidator.js +482 -0
- package/dist/rules/grammar/FirestoreValidator.js.map +1 -0
- package/dist/rules/index.d.ts +41 -0
- package/dist/rules/index.d.ts.map +1 -0
- package/dist/rules/index.js +40 -0
- package/dist/rules/index.js.map +1 -0
- package/dist/rules/indexes/extract/annotation-collect.d.ts +42 -0
- package/dist/rules/indexes/extract/annotation-collect.d.ts.map +1 -0
- package/dist/rules/indexes/extract/annotation-collect.js +69 -0
- package/dist/rules/indexes/extract/annotation-collect.js.map +1 -0
- package/dist/rules/indexes/extract/annotations.d.ts +50 -0
- package/dist/rules/indexes/extract/annotations.d.ts.map +1 -0
- package/dist/rules/indexes/extract/annotations.js +144 -0
- package/dist/rules/indexes/extract/annotations.js.map +1 -0
- package/dist/rules/indexes/extract/ast.d.ts +54 -0
- package/dist/rules/indexes/extract/ast.d.ts.map +1 -0
- package/dist/rules/indexes/extract/ast.js +119 -0
- package/dist/rules/indexes/extract/ast.js.map +1 -0
- package/dist/rules/indexes/extract/classify.d.ts +41 -0
- package/dist/rules/indexes/extract/classify.d.ts.map +1 -0
- package/dist/rules/indexes/extract/classify.js +138 -0
- package/dist/rules/indexes/extract/classify.js.map +1 -0
- package/dist/rules/indexes/extract/composite.d.ts +38 -0
- package/dist/rules/indexes/extract/composite.d.ts.map +1 -0
- package/dist/rules/indexes/extract/composite.js +85 -0
- package/dist/rules/indexes/extract/composite.js.map +1 -0
- package/dist/rules/indexes/extract/dataflow.d.ts +45 -0
- package/dist/rules/indexes/extract/dataflow.d.ts.map +1 -0
- package/dist/rules/indexes/extract/dataflow.js +200 -0
- package/dist/rules/indexes/extract/dataflow.js.map +1 -0
- package/dist/rules/indexes/extract/enumerate.d.ts +41 -0
- package/dist/rules/indexes/extract/enumerate.d.ts.map +1 -0
- package/dist/rules/indexes/extract/enumerate.js +163 -0
- package/dist/rules/indexes/extract/enumerate.js.map +1 -0
- package/dist/rules/indexes/extract/extractor.d.ts +3 -0
- package/dist/rules/indexes/extract/extractor.d.ts.map +1 -0
- package/dist/rules/indexes/extract/extractor.js +274 -0
- package/dist/rules/indexes/extract/extractor.js.map +1 -0
- package/dist/rules/indexes/extract/types.d.ts +211 -0
- package/dist/rules/indexes/extract/types.d.ts.map +1 -0
- package/dist/rules/indexes/extract/types.js +14 -0
- package/dist/rules/indexes/extract/types.js.map +1 -0
- package/dist/rules/indexes/extractHandler.d.ts +16 -0
- package/dist/rules/indexes/extractHandler.d.ts.map +1 -0
- package/dist/rules/indexes/extractHandler.js +100 -0
- package/dist/rules/indexes/extractHandler.js.map +1 -0
- package/dist/rules/indexes/extractTool.d.ts +15 -0
- package/dist/rules/indexes/extractTool.d.ts.map +1 -0
- package/dist/rules/indexes/extractTool.js +55 -0
- package/dist/rules/indexes/extractTool.js.map +1 -0
- package/dist/rules/indexes/types.d.ts +71 -0
- package/dist/rules/indexes/types.d.ts.map +1 -0
- package/dist/rules/indexes/types.js +15 -0
- package/dist/rules/indexes/types.js.map +1 -0
- package/dist/rules/inspect/handler.d.ts +6 -0
- package/dist/rules/inspect/handler.d.ts.map +1 -0
- package/dist/rules/inspect/handler.js +144 -0
- package/dist/rules/inspect/handler.js.map +1 -0
- package/dist/rules/inspect/spec.d.ts +37 -0
- package/dist/rules/inspect/spec.d.ts.map +1 -0
- package/dist/rules/inspect/spec.js +2 -0
- package/dist/rules/inspect/spec.js.map +1 -0
- package/dist/rules/inspect/tools.d.ts +21 -0
- package/dist/rules/inspect/tools.d.ts.map +1 -0
- package/dist/rules/inspect/tools.js +21 -0
- package/dist/rules/inspect/tools.js.map +1 -0
- package/dist/rules/internal/extract.d.ts +28 -0
- package/dist/rules/internal/extract.d.ts.map +1 -0
- package/dist/rules/internal/extract.js +25 -0
- package/dist/rules/internal/extract.js.map +1 -0
- package/dist/rules/internal/index.d.ts +82 -0
- package/dist/rules/internal/index.d.ts.map +1 -0
- package/dist/rules/internal/index.js +103 -0
- package/dist/rules/internal/index.js.map +1 -0
- package/dist/rules/internal/node.d.ts +18 -0
- package/dist/rules/internal/node.d.ts.map +1 -0
- package/dist/rules/internal/node.js +27 -0
- package/dist/rules/internal/node.js.map +1 -0
- package/dist/rules/internal/rtdb.d.ts +20 -0
- package/dist/rules/internal/rtdb.d.ts.map +1 -0
- package/dist/rules/internal/rtdb.js +15 -0
- package/dist/rules/internal/rtdb.js.map +1 -0
- package/dist/rules/linter/ast-utils.d.ts +97 -0
- package/dist/rules/linter/ast-utils.d.ts.map +1 -0
- package/dist/rules/linter/ast-utils.js +491 -0
- package/dist/rules/linter/ast-utils.js.map +1 -0
- package/dist/rules/linter/hallucinations.d.ts +34 -0
- package/dist/rules/linter/hallucinations.d.ts.map +1 -0
- package/dist/rules/linter/hallucinations.js +334 -0
- package/dist/rules/linter/hallucinations.js.map +1 -0
- package/dist/rules/linter/linter.d.ts +84 -0
- package/dist/rules/linter/linter.d.ts.map +1 -0
- package/dist/rules/linter/linter.js +783 -0
- package/dist/rules/linter/linter.js.map +1 -0
- package/dist/rules/modules/resolver-browser.d.ts +41 -0
- package/dist/rules/modules/resolver-browser.d.ts.map +1 -0
- package/dist/rules/modules/resolver-browser.js +63 -0
- package/dist/rules/modules/resolver-browser.js.map +1 -0
- package/dist/rules/modules/resolver-core.d.ts +51 -0
- package/dist/rules/modules/resolver-core.d.ts.map +1 -0
- package/dist/rules/modules/resolver-core.js +338 -0
- package/dist/rules/modules/resolver-core.js.map +1 -0
- package/dist/rules/modules/resolver.d.ts +17 -0
- package/dist/rules/modules/resolver.d.ts.map +1 -0
- package/dist/rules/modules/resolver.js +49 -0
- package/dist/rules/modules/resolver.js.map +1 -0
- package/dist/rules/modules/stdlib/atomic.rules +52 -0
- package/dist/rules/modules/stdlib/atomic.test.json +152 -0
- package/dist/rules/modules/stdlib/auth.rules +7 -0
- package/dist/rules/modules/stdlib/auth.test.json +53 -0
- package/dist/rules/modules/stdlib/content.rules +50 -0
- package/dist/rules/modules/stdlib/content.test.json +238 -0
- package/dist/rules/modules/stdlib/counters.rules +41 -0
- package/dist/rules/modules/stdlib/counters.test.json +254 -0
- package/dist/rules/modules/stdlib/geometry.rules +43 -0
- package/dist/rules/modules/stdlib/geometry.test.json +200 -0
- package/dist/rules/modules/stdlib/joining.rules +49 -0
- package/dist/rules/modules/stdlib/joining.test.json +287 -0
- package/dist/rules/modules/stdlib/lifecycle.rules +51 -0
- package/dist/rules/modules/stdlib/lifecycle.test.json +288 -0
- package/dist/rules/modules/stdlib/lobby.rules +44 -0
- package/dist/rules/modules/stdlib/lobby.test.json +32 -0
- package/dist/rules/modules/stdlib/membership.rules +40 -0
- package/dist/rules/modules/stdlib/membership.test.json +107 -0
- package/dist/rules/modules/stdlib/spaces.rules +46 -0
- package/dist/rules/modules/stdlib/spaces.test.json +392 -0
- package/dist/rules/modules/stdlib/state.rules +28 -0
- package/dist/rules/modules/stdlib/state.test.json +55 -0
- package/dist/rules/modules/stdlib/timing.rules +20 -0
- package/dist/rules/modules/stdlib/timing.test.json +106 -0
- package/dist/rules/modules/stdlib/transitions.rules +34 -0
- package/dist/rules/modules/stdlib/transitions.test.json +86 -0
- package/dist/rules/modules/stdlib/turns.rules +27 -0
- package/dist/rules/modules/stdlib/turns.test.json +64 -0
- package/dist/rules/modules/stdlib/validation.rules +31 -0
- package/dist/rules/modules/stdlib/validation.test.json +184 -0
- package/dist/rules/modules/stdlib-content.d.ts +11 -0
- package/dist/rules/modules/stdlib-content.d.ts.map +1 -0
- package/dist/rules/modules/stdlib-content.js +590 -0
- package/dist/rules/modules/stdlib-content.js.map +1 -0
- package/dist/rules/rtdb/compiled-rules.d.ts +11 -0
- package/dist/rules/rtdb/compiled-rules.d.ts.map +1 -0
- package/dist/rules/rtdb/compiled-rules.js +95 -0
- package/dist/rules/rtdb/compiled-rules.js.map +1 -0
- package/dist/rules/rtdb/constraints/atoms.d.ts +29 -0
- package/dist/rules/rtdb/constraints/atoms.d.ts.map +1 -0
- package/dist/rules/rtdb/constraints/atoms.js +43 -0
- package/dist/rules/rtdb/constraints/atoms.js.map +1 -0
- package/dist/rules/rtdb/constraints/compose.d.ts +16 -0
- package/dist/rules/rtdb/constraints/compose.d.ts.map +1 -0
- package/dist/rules/rtdb/constraints/compose.js +15 -0
- package/dist/rules/rtdb/constraints/compose.js.map +1 -0
- package/dist/rules/rtdb/constraints/data.d.ts +30 -0
- package/dist/rules/rtdb/constraints/data.d.ts.map +1 -0
- package/dist/rules/rtdb/constraints/data.js +46 -0
- package/dist/rules/rtdb/constraints/data.js.map +1 -0
- package/dist/rules/rtdb/constraints/document.d.ts +57 -0
- package/dist/rules/rtdb/constraints/document.d.ts.map +1 -0
- package/dist/rules/rtdb/constraints/document.js +85 -0
- package/dist/rules/rtdb/constraints/document.js.map +1 -0
- package/dist/rules/rtdb/constraints/game.d.ts +30 -0
- package/dist/rules/rtdb/constraints/game.d.ts.map +1 -0
- package/dist/rules/rtdb/constraints/game.js +49 -0
- package/dist/rules/rtdb/constraints/game.js.map +1 -0
- package/dist/rules/rtdb/constraints/index.d.ts +12 -0
- package/dist/rules/rtdb/constraints/index.d.ts.map +1 -0
- package/dist/rules/rtdb/constraints/index.js +9 -0
- package/dist/rules/rtdb/constraints/index.js.map +1 -0
- package/dist/rules/rtdb/constraints/policies.d.ts +16 -0
- package/dist/rules/rtdb/constraints/policies.d.ts.map +1 -0
- package/dist/rules/rtdb/constraints/policies.js +17 -0
- package/dist/rules/rtdb/constraints/policies.js.map +1 -0
- package/dist/rules/rtdb/constraints/ruleset.d.ts +5 -0
- package/dist/rules/rtdb/constraints/ruleset.d.ts.map +1 -0
- package/dist/rules/rtdb/constraints/ruleset.js +132 -0
- package/dist/rules/rtdb/constraints/ruleset.js.map +1 -0
- package/dist/rules/rtdb/constraints/schema.d.ts +17 -0
- package/dist/rules/rtdb/constraints/schema.d.ts.map +1 -0
- package/dist/rules/rtdb/constraints/schema.js +74 -0
- package/dist/rules/rtdb/constraints/schema.js.map +1 -0
- package/dist/rules/rtdb/constraints/types.d.ts +22 -0
- package/dist/rules/rtdb/constraints/types.d.ts.map +1 -0
- package/dist/rules/rtdb/constraints/types.js +2 -0
- package/dist/rules/rtdb/constraints/types.js.map +1 -0
- package/dist/rules/rtdb/constraints/write-rules-file.d.ts +24 -0
- package/dist/rules/rtdb/constraints/write-rules-file.d.ts.map +1 -0
- package/dist/rules/rtdb/constraints/write-rules-file.js +30 -0
- package/dist/rules/rtdb/constraints/write-rules-file.js.map +1 -0
- package/dist/rules/rtdb/expression-engine.d.ts +8 -0
- package/dist/rules/rtdb/expression-engine.d.ts.map +1 -0
- package/dist/rules/rtdb/expression-engine.js +20 -0
- package/dist/rules/rtdb/expression-engine.js.map +1 -0
- package/dist/rules/rtdb/grammar/RtdbExpr.ohm +98 -0
- package/dist/rules/rtdb/grammar/RtdbExpr.ohm.generated.d.ts +2 -0
- package/dist/rules/rtdb/grammar/RtdbExpr.ohm.generated.d.ts.map +1 -0
- package/dist/rules/rtdb/grammar/RtdbExpr.ohm.generated.js +103 -0
- package/dist/rules/rtdb/grammar/RtdbExpr.ohm.generated.js.map +1 -0
- package/dist/rules/rtdb/grammar/RtdbExprParser.d.ts +3 -0
- package/dist/rules/rtdb/grammar/RtdbExprParser.d.ts.map +1 -0
- package/dist/rules/rtdb/grammar/RtdbExprParser.js +56 -0
- package/dist/rules/rtdb/grammar/RtdbExprParser.js.map +1 -0
- package/dist/rules/rtdb/grammar/linter.d.ts +3 -0
- package/dist/rules/rtdb/grammar/linter.d.ts.map +1 -0
- package/dist/rules/rtdb/grammar/linter.js +73 -0
- package/dist/rules/rtdb/grammar/linter.js.map +1 -0
- package/dist/rules/rtdb/grammar/simulator.d.ts +30 -0
- package/dist/rules/rtdb/grammar/simulator.d.ts.map +1 -0
- package/dist/rules/rtdb/grammar/simulator.js +282 -0
- package/dist/rules/rtdb/grammar/simulator.js.map +1 -0
- package/dist/rules/rtdb/grammar/validator.d.ts +3 -0
- package/dist/rules/rtdb/grammar/validator.d.ts.map +1 -0
- package/dist/rules/rtdb/grammar/validator.js +91 -0
- package/dist/rules/rtdb/grammar/validator.js.map +1 -0
- package/dist/rules/rtdb/simulation/handler.d.ts +6 -0
- package/dist/rules/rtdb/simulation/handler.d.ts.map +1 -0
- package/dist/rules/rtdb/simulation/handler.js +325 -0
- package/dist/rules/rtdb/simulation/handler.js.map +1 -0
- package/dist/rules/rtdb/simulation/spec.d.ts +102 -0
- package/dist/rules/rtdb/simulation/spec.d.ts.map +1 -0
- package/dist/rules/rtdb/simulation/spec.js +40 -0
- package/dist/rules/rtdb/simulation/spec.js.map +1 -0
- package/dist/rules/rtdb/types.d.ts +166 -0
- package/dist/rules/rtdb/types.d.ts.map +1 -0
- package/dist/rules/rtdb/types.js +21 -0
- package/dist/rules/rtdb/types.js.map +1 -0
- package/dist/rules/simulator/evaluator.d.ts +206 -0
- package/dist/rules/simulator/evaluator.d.ts.map +1 -0
- package/dist/rules/simulator/evaluator.js +1251 -0
- package/dist/rules/simulator/evaluator.js.map +1 -0
- package/dist/rules/simulator/expression/eval-errors.d.ts +86 -0
- package/dist/rules/simulator/expression/eval-errors.d.ts.map +1 -0
- package/dist/rules/simulator/expression/eval-errors.js +68 -0
- package/dist/rules/simulator/expression/eval-errors.js.map +1 -0
- package/dist/rules/simulator/expression/evaluator.d.ts +43 -0
- package/dist/rules/simulator/expression/evaluator.d.ts.map +1 -0
- package/dist/rules/simulator/expression/evaluator.js +298 -0
- package/dist/rules/simulator/expression/evaluator.js.map +1 -0
- package/dist/rules/simulator/expression/lexer.d.ts +36 -0
- package/dist/rules/simulator/expression/lexer.d.ts.map +1 -0
- package/dist/rules/simulator/expression/lexer.js +318 -0
- package/dist/rules/simulator/expression/lexer.js.map +1 -0
- package/dist/rules/simulator/expression/parser.d.ts +39 -0
- package/dist/rules/simulator/expression/parser.d.ts.map +1 -0
- package/dist/rules/simulator/expression/parser.js +329 -0
- package/dist/rules/simulator/expression/parser.js.map +1 -0
- package/dist/rules/simulator/expression/types.d.ts +137 -0
- package/dist/rules/simulator/expression/types.d.ts.map +1 -0
- package/dist/rules/simulator/expression/types.js +90 -0
- package/dist/rules/simulator/expression/types.js.map +1 -0
- package/dist/rules/simulator/expression/walk-data.d.ts +52 -0
- package/dist/rules/simulator/expression/walk-data.d.ts.map +1 -0
- package/dist/rules/simulator/expression/walk-data.js +167 -0
- package/dist/rules/simulator/expression/walk-data.js.map +1 -0
- package/dist/rules/simulator/firestore-set.d.ts +25 -0
- package/dist/rules/simulator/firestore-set.d.ts.map +1 -0
- package/dist/rules/simulator/firestore-set.js +89 -0
- package/dist/rules/simulator/firestore-set.js.map +1 -0
- package/dist/rules/simulator/handler.d.ts +47 -0
- package/dist/rules/simulator/handler.d.ts.map +1 -0
- package/dist/rules/simulator/handler.js +644 -0
- package/dist/rules/simulator/handler.js.map +1 -0
- package/dist/rules/simulator/mapdiff.d.ts +29 -0
- package/dist/rules/simulator/mapdiff.d.ts.map +1 -0
- package/dist/rules/simulator/mapdiff.js +72 -0
- package/dist/rules/simulator/mapdiff.js.map +1 -0
- package/dist/rules/simulator/project-after-state.d.ts +33 -0
- package/dist/rules/simulator/project-after-state.d.ts.map +1 -0
- package/dist/rules/simulator/project-after-state.js +88 -0
- package/dist/rules/simulator/project-after-state.js.map +1 -0
- package/dist/rules/simulator/query-proof.d.ts +80 -0
- package/dist/rules/simulator/query-proof.d.ts.map +1 -0
- package/dist/rules/simulator/query-proof.js +142 -0
- package/dist/rules/simulator/query-proof.js.map +1 -0
- package/dist/rules/simulator/value-equality.d.ts +8 -0
- package/dist/rules/simulator/value-equality.d.ts.map +1 -0
- package/dist/rules/simulator/value-equality.js +40 -0
- package/dist/rules/simulator/value-equality.js.map +1 -0
- package/dist/rules/simulator/wrappers/base.d.ts +129 -0
- package/dist/rules/simulator/wrappers/base.d.ts.map +1 -0
- package/dist/rules/simulator/wrappers/base.js +90 -0
- package/dist/rules/simulator/wrappers/base.js.map +1 -0
- package/dist/rules/simulator/wrappers/bytes.d.ts +45 -0
- package/dist/rules/simulator/wrappers/bytes.d.ts.map +1 -0
- package/dist/rules/simulator/wrappers/bytes.js +130 -0
- package/dist/rules/simulator/wrappers/bytes.js.map +1 -0
- package/dist/rules/simulator/wrappers/duration.d.ts +76 -0
- package/dist/rules/simulator/wrappers/duration.d.ts.map +1 -0
- package/dist/rules/simulator/wrappers/duration.js +176 -0
- package/dist/rules/simulator/wrappers/duration.js.map +1 -0
- package/dist/rules/simulator/wrappers/float.d.ts +52 -0
- package/dist/rules/simulator/wrappers/float.d.ts.map +1 -0
- package/dist/rules/simulator/wrappers/float.js +88 -0
- package/dist/rules/simulator/wrappers/float.js.map +1 -0
- package/dist/rules/simulator/wrappers/latlng.d.ts +40 -0
- package/dist/rules/simulator/wrappers/latlng.d.ts.map +1 -0
- package/dist/rules/simulator/wrappers/latlng.js +100 -0
- package/dist/rules/simulator/wrappers/latlng.js.map +1 -0
- package/dist/rules/simulator/wrappers/path.d.ts +75 -0
- package/dist/rules/simulator/wrappers/path.d.ts.map +1 -0
- package/dist/rules/simulator/wrappers/path.js +158 -0
- package/dist/rules/simulator/wrappers/path.js.map +1 -0
- package/dist/rules/simulator/wrappers/reference.d.ts +82 -0
- package/dist/rules/simulator/wrappers/reference.d.ts.map +1 -0
- package/dist/rules/simulator/wrappers/reference.js +145 -0
- package/dist/rules/simulator/wrappers/reference.js.map +1 -0
- package/dist/rules/simulator/wrappers/timestamp.d.ts +86 -0
- package/dist/rules/simulator/wrappers/timestamp.d.ts.map +1 -0
- package/dist/rules/simulator/wrappers/timestamp.js +207 -0
- package/dist/rules/simulator/wrappers/timestamp.js.map +1 -0
- package/dist/rules/simulator/wrappers/vector.d.ts +43 -0
- package/dist/rules/simulator/wrappers/vector.d.ts.map +1 -0
- package/dist/rules/simulator/wrappers/vector.js +80 -0
- package/dist/rules/simulator/wrappers/vector.js.map +1 -0
- package/dist/rules/simulator-tools-impl.d.ts +64 -0
- package/dist/rules/simulator-tools-impl.d.ts.map +1 -0
- package/dist/rules/simulator-tools-impl.js +462 -0
- package/dist/rules/simulator-tools-impl.js.map +1 -0
- package/dist/rules/simulator.d.ts +20 -0
- package/dist/rules/simulator.d.ts.map +1 -0
- package/dist/rules/simulator.js +24 -0
- package/dist/rules/simulator.js.map +1 -0
- package/dist/rules/stdlib-modules.d.ts +73 -0
- package/dist/rules/stdlib-modules.d.ts.map +1 -0
- package/dist/rules/stdlib-modules.js +837 -0
- package/dist/rules/stdlib-modules.js.map +1 -0
- package/dist/rules/stdlib-tools.d.ts +19 -0
- package/dist/rules/stdlib-tools.d.ts.map +1 -0
- package/dist/rules/stdlib-tools.js +164 -0
- package/dist/rules/stdlib-tools.js.map +1 -0
- package/dist/rules/test/handler.d.ts +21 -0
- package/dist/rules/test/handler.d.ts.map +1 -0
- package/dist/rules/test/handler.js +214 -0
- package/dist/rules/test/handler.js.map +1 -0
- package/dist/rules/test/spec.d.ts +677 -0
- package/dist/rules/test/spec.d.ts.map +1 -0
- package/dist/rules/test/spec.js +327 -0
- package/dist/rules/test/spec.js.map +1 -0
- package/dist/rules/tools.d.ts +41 -0
- package/dist/rules/tools.d.ts.map +1 -0
- package/dist/rules/tools.js +120 -0
- package/dist/rules/tools.js.map +1 -0
- package/dist/rules/write/handler.d.ts +6 -0
- package/dist/rules/write/handler.d.ts.map +1 -0
- package/dist/rules/write/handler.js +126 -0
- package/dist/rules/write/handler.js.map +1 -0
- package/dist/rules/write/spec.d.ts +28 -0
- package/dist/rules/write/spec.d.ts.map +1 -0
- package/dist/rules/write/spec.js +2 -0
- package/dist/rules/write/spec.js.map +1 -0
- package/dist/sandbox/admin-compat.d.ts +20 -0
- package/dist/sandbox/admin-compat.d.ts.map +1 -0
- package/dist/sandbox/admin-compat.js +19 -0
- package/dist/sandbox/admin-compat.js.map +1 -0
- package/dist/sandbox/admin-firestore/error-translation.d.ts +90 -0
- package/dist/sandbox/admin-firestore/error-translation.d.ts.map +1 -0
- package/dist/sandbox/admin-firestore/error-translation.js +214 -0
- package/dist/sandbox/admin-firestore/error-translation.js.map +1 -0
- package/dist/sandbox/admin-firestore/get-admin-firestore.d.ts +44 -0
- package/dist/sandbox/admin-firestore/get-admin-firestore.d.ts.map +1 -0
- package/dist/sandbox/admin-firestore/get-admin-firestore.js +62 -0
- package/dist/sandbox/admin-firestore/get-admin-firestore.js.map +1 -0
- package/dist/sandbox/admin-firestore/get-firestore.d.ts +34 -0
- package/dist/sandbox/admin-firestore/get-firestore.d.ts.map +1 -0
- package/dist/sandbox/admin-firestore/get-firestore.js +71 -0
- package/dist/sandbox/admin-firestore/get-firestore.js.map +1 -0
- package/dist/sandbox/admin-firestore/index.d.ts +36 -0
- package/dist/sandbox/admin-firestore/index.d.ts.map +1 -0
- package/dist/sandbox/admin-firestore/index.js +33 -0
- package/dist/sandbox/admin-firestore/index.js.map +1 -0
- package/dist/sandbox/admin-firestore/listeners.d.ts +46 -0
- package/dist/sandbox/admin-firestore/listeners.d.ts.map +1 -0
- package/dist/sandbox/admin-firestore/listeners.js +290 -0
- package/dist/sandbox/admin-firestore/listeners.js.map +1 -0
- package/dist/sandbox/admin-firestore/local-handle.d.ts +23 -0
- package/dist/sandbox/admin-firestore/local-handle.d.ts.map +1 -0
- package/dist/sandbox/admin-firestore/local-handle.js +74 -0
- package/dist/sandbox/admin-firestore/local-handle.js.map +1 -0
- package/dist/sandbox/admin-firestore/remote/batch.d.ts +6 -0
- package/dist/sandbox/admin-firestore/remote/batch.d.ts.map +1 -0
- package/dist/sandbox/admin-firestore/remote/batch.js +38 -0
- package/dist/sandbox/admin-firestore/remote/batch.js.map +1 -0
- package/dist/sandbox/admin-firestore/remote/channel.d.ts +22 -0
- package/dist/sandbox/admin-firestore/remote/channel.d.ts.map +1 -0
- package/dist/sandbox/admin-firestore/remote/channel.js +27 -0
- package/dist/sandbox/admin-firestore/remote/channel.js.map +1 -0
- package/dist/sandbox/admin-firestore/remote/doc-ref.d.ts +10 -0
- package/dist/sandbox/admin-firestore/remote/doc-ref.d.ts.map +1 -0
- package/dist/sandbox/admin-firestore/remote/doc-ref.js +88 -0
- package/dist/sandbox/admin-firestore/remote/doc-ref.js.map +1 -0
- package/dist/sandbox/admin-firestore/remote/errors.d.ts +17 -0
- package/dist/sandbox/admin-firestore/remote/errors.d.ts.map +1 -0
- package/dist/sandbox/admin-firestore/remote/errors.js +32 -0
- package/dist/sandbox/admin-firestore/remote/errors.js.map +1 -0
- package/dist/sandbox/admin-firestore/remote/listeners.d.ts +43 -0
- package/dist/sandbox/admin-firestore/remote/listeners.d.ts.map +1 -0
- package/dist/sandbox/admin-firestore/remote/listeners.js +89 -0
- package/dist/sandbox/admin-firestore/remote/listeners.js.map +1 -0
- package/dist/sandbox/admin-firestore/remote/query.d.ts +47 -0
- package/dist/sandbox/admin-firestore/remote/query.d.ts.map +1 -0
- package/dist/sandbox/admin-firestore/remote/query.js +186 -0
- package/dist/sandbox/admin-firestore/remote/query.js.map +1 -0
- package/dist/sandbox/admin-firestore/remote/remote-firestore.d.ts +55 -0
- package/dist/sandbox/admin-firestore/remote/remote-firestore.d.ts.map +1 -0
- package/dist/sandbox/admin-firestore/remote/remote-firestore.js +111 -0
- package/dist/sandbox/admin-firestore/remote/remote-firestore.js.map +1 -0
- package/dist/sandbox/admin-firestore/remote/snapshots.d.ts +10 -0
- package/dist/sandbox/admin-firestore/remote/snapshots.d.ts.map +1 -0
- package/dist/sandbox/admin-firestore/remote/snapshots.js +37 -0
- package/dist/sandbox/admin-firestore/remote/snapshots.js.map +1 -0
- package/dist/sandbox/admin-firestore/remote/transaction.d.ts +19 -0
- package/dist/sandbox/admin-firestore/remote/transaction.d.ts.map +1 -0
- package/dist/sandbox/admin-firestore/remote/transaction.js +105 -0
- package/dist/sandbox/admin-firestore/remote/transaction.js.map +1 -0
- package/dist/sandbox/admin-firestore/remote/value-codec.d.ts +52 -0
- package/dist/sandbox/admin-firestore/remote/value-codec.d.ts.map +1 -0
- package/dist/sandbox/admin-firestore/remote/value-codec.js +120 -0
- package/dist/sandbox/admin-firestore/remote/value-codec.js.map +1 -0
- package/dist/sandbox/admin-firestore/remote/wire-types.d.ts +111 -0
- package/dist/sandbox/admin-firestore/remote/wire-types.d.ts.map +1 -0
- package/dist/sandbox/admin-firestore/remote/wire-types.js +8 -0
- package/dist/sandbox/admin-firestore/remote/wire-types.js.map +1 -0
- package/dist/sandbox/admin-firestore/types.d.ts +59 -0
- package/dist/sandbox/admin-firestore/types.d.ts.map +1 -0
- package/dist/sandbox/admin-firestore/types.js +6 -0
- package/dist/sandbox/admin-firestore/types.js.map +1 -0
- package/dist/sandbox/branches/index.d.ts +141 -0
- package/dist/sandbox/branches/index.d.ts.map +1 -0
- package/dist/sandbox/branches/index.js +327 -0
- package/dist/sandbox/branches/index.js.map +1 -0
- package/dist/sandbox/firestore/admin-compat/batch.d.ts +34 -0
- package/dist/sandbox/firestore/admin-compat/batch.d.ts.map +1 -0
- package/dist/sandbox/firestore/admin-compat/batch.js +73 -0
- package/dist/sandbox/firestore/admin-compat/batch.js.map +1 -0
- package/dist/sandbox/firestore/admin-compat/doc-ref.d.ts +38 -0
- package/dist/sandbox/firestore/admin-compat/doc-ref.d.ts.map +1 -0
- package/dist/sandbox/firestore/admin-compat/doc-ref.js +154 -0
- package/dist/sandbox/firestore/admin-compat/doc-ref.js.map +1 -0
- package/dist/sandbox/firestore/admin-compat/firestore.d.ts +47 -0
- package/dist/sandbox/firestore/admin-compat/firestore.d.ts.map +1 -0
- package/dist/sandbox/firestore/admin-compat/firestore.js +117 -0
- package/dist/sandbox/firestore/admin-compat/firestore.js.map +1 -0
- package/dist/sandbox/firestore/admin-compat/index.d.ts +49 -0
- package/dist/sandbox/firestore/admin-compat/index.d.ts.map +1 -0
- package/dist/sandbox/firestore/admin-compat/index.js +27 -0
- package/dist/sandbox/firestore/admin-compat/index.js.map +1 -0
- package/dist/sandbox/firestore/admin-compat/paths.d.ts +37 -0
- package/dist/sandbox/firestore/admin-compat/paths.d.ts.map +1 -0
- package/dist/sandbox/firestore/admin-compat/paths.js +49 -0
- package/dist/sandbox/firestore/admin-compat/paths.js.map +1 -0
- package/dist/sandbox/firestore/admin-compat/query.d.ts +261 -0
- package/dist/sandbox/firestore/admin-compat/query.d.ts.map +1 -0
- package/dist/sandbox/firestore/admin-compat/query.js +758 -0
- package/dist/sandbox/firestore/admin-compat/query.js.map +1 -0
- package/dist/sandbox/firestore/admin-compat/read-translation.d.ts +8 -0
- package/dist/sandbox/firestore/admin-compat/read-translation.d.ts.map +1 -0
- package/dist/sandbox/firestore/admin-compat/read-translation.js +59 -0
- package/dist/sandbox/firestore/admin-compat/read-translation.js.map +1 -0
- package/dist/sandbox/firestore/admin-compat/snapshots.d.ts +39 -0
- package/dist/sandbox/firestore/admin-compat/snapshots.d.ts.map +1 -0
- package/dist/sandbox/firestore/admin-compat/snapshots.js +50 -0
- package/dist/sandbox/firestore/admin-compat/snapshots.js.map +1 -0
- package/dist/sandbox/firestore/admin-compat/transaction.d.ts +35 -0
- package/dist/sandbox/firestore/admin-compat/transaction.d.ts.map +1 -0
- package/dist/sandbox/firestore/admin-compat/transaction.js +88 -0
- package/dist/sandbox/firestore/admin-compat/transaction.js.map +1 -0
- package/dist/sandbox/firestore/admin-compat/types.d.ts +297 -0
- package/dist/sandbox/firestore/admin-compat/types.d.ts.map +1 -0
- package/dist/sandbox/firestore/admin-compat/types.js +127 -0
- package/dist/sandbox/firestore/admin-compat/types.js.map +1 -0
- package/dist/sandbox/firestore/admin-compat/value-order.d.ts +49 -0
- package/dist/sandbox/firestore/admin-compat/value-order.d.ts.map +1 -0
- package/dist/sandbox/firestore/admin-compat/value-order.js +172 -0
- package/dist/sandbox/firestore/admin-compat/value-order.js.map +1 -0
- package/dist/sandbox/firestore/auto-id.d.ts +26 -0
- package/dist/sandbox/firestore/auto-id.d.ts.map +1 -0
- package/dist/sandbox/firestore/auto-id.js +36 -0
- package/dist/sandbox/firestore/auto-id.js.map +1 -0
- package/dist/sandbox/firestore/converters/bytes-geopoint.d.ts +48 -0
- package/dist/sandbox/firestore/converters/bytes-geopoint.d.ts.map +1 -0
- package/dist/sandbox/firestore/converters/bytes-geopoint.js +85 -0
- package/dist/sandbox/firestore/converters/bytes-geopoint.js.map +1 -0
- package/dist/sandbox/firestore/converters/fieldvalue.d.ts +69 -0
- package/dist/sandbox/firestore/converters/fieldvalue.d.ts.map +1 -0
- package/dist/sandbox/firestore/converters/fieldvalue.js +166 -0
- package/dist/sandbox/firestore/converters/fieldvalue.js.map +1 -0
- package/dist/sandbox/firestore/converters/reference.d.ts +31 -0
- package/dist/sandbox/firestore/converters/reference.d.ts.map +1 -0
- package/dist/sandbox/firestore/converters/reference.js +51 -0
- package/dist/sandbox/firestore/converters/reference.js.map +1 -0
- package/dist/sandbox/firestore/converters/timestamp.d.ts +32 -0
- package/dist/sandbox/firestore/converters/timestamp.d.ts.map +1 -0
- package/dist/sandbox/firestore/converters/timestamp.js +63 -0
- package/dist/sandbox/firestore/converters/timestamp.js.map +1 -0
- package/dist/sandbox/firestore/converters/user-timestamp.d.ts +46 -0
- package/dist/sandbox/firestore/converters/user-timestamp.d.ts.map +1 -0
- package/dist/sandbox/firestore/converters/user-timestamp.js +65 -0
- package/dist/sandbox/firestore/converters/user-timestamp.js.map +1 -0
- package/dist/sandbox/firestore/converters/vector.d.ts +24 -0
- package/dist/sandbox/firestore/converters/vector.d.ts.map +1 -0
- package/dist/sandbox/firestore/converters/vector.js +53 -0
- package/dist/sandbox/firestore/converters/vector.js.map +1 -0
- package/dist/sandbox/firestore/errors.d.ts +82 -0
- package/dist/sandbox/firestore/errors.d.ts.map +1 -0
- package/dist/sandbox/firestore/errors.js +54 -0
- package/dist/sandbox/firestore/errors.js.map +1 -0
- package/dist/sandbox/firestore/event-log.d.ts +99 -0
- package/dist/sandbox/firestore/event-log.d.ts.map +1 -0
- package/dist/sandbox/firestore/event-log.js +67 -0
- package/dist/sandbox/firestore/event-log.js.map +1 -0
- package/dist/sandbox/firestore/field-merge.d.ts +64 -0
- package/dist/sandbox/firestore/field-merge.d.ts.map +1 -0
- package/dist/sandbox/firestore/field-merge.js +221 -0
- package/dist/sandbox/firestore/field-merge.js.map +1 -0
- package/dist/sandbox/firestore/list-query-proof.d.ts +77 -0
- package/dist/sandbox/firestore/list-query-proof.d.ts.map +1 -0
- package/dist/sandbox/firestore/list-query-proof.js +170 -0
- package/dist/sandbox/firestore/list-query-proof.js.map +1 -0
- package/dist/sandbox/firestore/local-environment.d.ts +825 -0
- package/dist/sandbox/firestore/local-environment.d.ts.map +1 -0
- package/dist/sandbox/firestore/local-environment.js +3129 -0
- package/dist/sandbox/firestore/local-environment.js.map +1 -0
- package/dist/sandbox/firestore/local-state.d.ts +196 -0
- package/dist/sandbox/firestore/local-state.d.ts.map +1 -0
- package/dist/sandbox/firestore/local-state.js +413 -0
- package/dist/sandbox/firestore/local-state.js.map +1 -0
- package/dist/sandbox/firestore/overlay-backing.d.ts +44 -0
- package/dist/sandbox/firestore/overlay-backing.d.ts.map +1 -0
- package/dist/sandbox/firestore/overlay-backing.js +82 -0
- package/dist/sandbox/firestore/overlay-backing.js.map +1 -0
- package/dist/sandbox/firestore/sentinel-capture.d.ts +30 -0
- package/dist/sandbox/firestore/sentinel-capture.d.ts.map +1 -0
- package/dist/sandbox/firestore/sentinel-capture.js +61 -0
- package/dist/sandbox/firestore/sentinel-capture.js.map +1 -0
- package/dist/sandbox/firestore/snapshot-listeners.d.ts +290 -0
- package/dist/sandbox/firestore/snapshot-listeners.d.ts.map +1 -0
- package/dist/sandbox/firestore/snapshot-listeners.js +194 -0
- package/dist/sandbox/firestore/snapshot-listeners.js.map +1 -0
- package/dist/sandbox/firestore/topk.d.ts +12 -0
- package/dist/sandbox/firestore/topk.d.ts.map +1 -0
- package/dist/sandbox/firestore/topk.js +42 -0
- package/dist/sandbox/firestore/topk.js.map +1 -0
- package/dist/sandbox/firestore/transaction-merge.d.ts +55 -0
- package/dist/sandbox/firestore/transaction-merge.d.ts.map +1 -0
- package/dist/sandbox/firestore/transaction-merge.js +107 -0
- package/dist/sandbox/firestore/transaction-merge.js.map +1 -0
- package/dist/sandbox/firestore/transaction-types.d.ts +155 -0
- package/dist/sandbox/firestore/transaction-types.d.ts.map +1 -0
- package/dist/sandbox/firestore/transaction-types.js +10 -0
- package/dist/sandbox/firestore/transaction-types.js.map +1 -0
- package/dist/sandbox/firestore/transaction.d.ts +79 -0
- package/dist/sandbox/firestore/transaction.d.ts.map +1 -0
- package/dist/sandbox/firestore/transaction.js +95 -0
- package/dist/sandbox/firestore/transaction.js.map +1 -0
- package/dist/sandbox/firestore/value-equality.d.ts +2 -0
- package/dist/sandbox/firestore/value-equality.d.ts.map +1 -0
- package/dist/sandbox/firestore/value-equality.js +35 -0
- package/dist/sandbox/firestore/value-equality.js.map +1 -0
- package/dist/sandbox/firestore/value-resolver.d.ts +172 -0
- package/dist/sandbox/firestore/value-resolver.d.ts.map +1 -0
- package/dist/sandbox/firestore/value-resolver.js +221 -0
- package/dist/sandbox/firestore/value-resolver.js.map +1 -0
- package/dist/sandbox/firestore/wire-encoder.d.ts +14 -0
- package/dist/sandbox/firestore/wire-encoder.d.ts.map +1 -0
- package/dist/sandbox/firestore/wire-encoder.js +130 -0
- package/dist/sandbox/firestore/wire-encoder.js.map +1 -0
- package/dist/sandbox/index.d.ts +53 -0
- package/dist/sandbox/index.d.ts.map +1 -0
- package/dist/sandbox/index.js +65 -0
- package/dist/sandbox/index.js.map +1 -0
- package/dist/sandbox/internal/client-app.d.ts +29 -0
- package/dist/sandbox/internal/client-app.d.ts.map +1 -0
- package/dist/sandbox/internal/client-app.js +18 -0
- package/dist/sandbox/internal/client-app.js.map +1 -0
- package/dist/sandbox/internal/firebase-error.d.ts +14 -0
- package/dist/sandbox/internal/firebase-error.d.ts.map +1 -0
- package/dist/sandbox/internal/firebase-error.js +22 -0
- package/dist/sandbox/internal/firebase-error.js.map +1 -0
- package/dist/sandbox/internal/index.d.ts +39 -0
- package/dist/sandbox/internal/index.d.ts.map +1 -0
- package/dist/sandbox/internal/index.js +75 -0
- package/dist/sandbox/internal/index.js.map +1 -0
- package/dist/sandbox/internal/local-brand.d.ts +3 -0
- package/dist/sandbox/internal/local-brand.d.ts.map +1 -0
- package/dist/sandbox/internal/local-brand.js +3 -0
- package/dist/sandbox/internal/local-brand.js.map +1 -0
- package/dist/sandbox/internal/provenance.d.ts +16 -0
- package/dist/sandbox/internal/provenance.d.ts.map +1 -0
- package/dist/sandbox/internal/provenance.js +139 -0
- package/dist/sandbox/internal/provenance.js.map +1 -0
- package/dist/sandbox/internal/sandbox-impl.d.ts +328 -0
- package/dist/sandbox/internal/sandbox-impl.d.ts.map +1 -0
- package/dist/sandbox/internal/sandbox-impl.js +695 -0
- package/dist/sandbox/internal/sandbox-impl.js.map +1 -0
- package/dist/sandbox/operation-record.d.ts +48 -0
- package/dist/sandbox/operation-record.d.ts.map +1 -0
- package/dist/sandbox/operation-record.js +143 -0
- package/dist/sandbox/operation-record.js.map +1 -0
- package/dist/sandbox/persistence/backends.d.ts +37 -0
- package/dist/sandbox/persistence/backends.d.ts.map +1 -0
- package/dist/sandbox/persistence/backends.js +202 -0
- package/dist/sandbox/persistence/backends.js.map +1 -0
- package/dist/sandbox/persistence/chunk-format.d.ts +58 -0
- package/dist/sandbox/persistence/chunk-format.d.ts.map +1 -0
- package/dist/sandbox/persistence/chunk-format.js +163 -0
- package/dist/sandbox/persistence/chunk-format.js.map +1 -0
- package/dist/sandbox/persistence/controller.d.ts +39 -0
- package/dist/sandbox/persistence/controller.d.ts.map +1 -0
- package/dist/sandbox/persistence/controller.js +505 -0
- package/dist/sandbox/persistence/controller.js.map +1 -0
- package/dist/sandbox/persistence/index.d.ts +13 -0
- package/dist/sandbox/persistence/index.d.ts.map +1 -0
- package/dist/sandbox/persistence/index.js +5 -0
- package/dist/sandbox/persistence/index.js.map +1 -0
- package/dist/sandbox/persistence/serialize.d.ts +53 -0
- package/dist/sandbox/persistence/serialize.d.ts.map +1 -0
- package/dist/sandbox/persistence/serialize.js +98 -0
- package/dist/sandbox/persistence/serialize.js.map +1 -0
- package/dist/sandbox/persistence/types.d.ts +118 -0
- package/dist/sandbox/persistence/types.d.ts.map +1 -0
- package/dist/sandbox/persistence/types.js +15 -0
- package/dist/sandbox/persistence/types.js.map +1 -0
- package/dist/sandbox/remote.d.ts +118 -0
- package/dist/sandbox/remote.d.ts.map +1 -0
- package/dist/sandbox/remote.js +60 -0
- package/dist/sandbox/remote.js.map +1 -0
- package/dist/sandbox/replay/index.d.ts +106 -0
- package/dist/sandbox/replay/index.d.ts.map +1 -0
- package/dist/sandbox/replay/index.js +246 -0
- package/dist/sandbox/replay/index.js.map +1 -0
- package/dist/sandbox/sandbox-context.d.ts +48 -0
- package/dist/sandbox/sandbox-context.d.ts.map +1 -0
- package/dist/sandbox/sandbox-context.js +97 -0
- package/dist/sandbox/sandbox-context.js.map +1 -0
- package/dist/sandbox/tab-sync/index.d.ts +120 -0
- package/dist/sandbox/tab-sync/index.d.ts.map +1 -0
- package/dist/sandbox/tab-sync/index.js +273 -0
- package/dist/sandbox/tab-sync/index.js.map +1 -0
- package/dist/sandbox/types/auth-state.d.ts +23 -0
- package/dist/sandbox/types/auth-state.d.ts.map +1 -0
- package/dist/sandbox/types/auth-state.js +8 -0
- package/dist/sandbox/types/auth-state.js.map +1 -0
- package/dist/sandbox/types/context.d.ts +33 -0
- package/dist/sandbox/types/context.d.ts.map +1 -0
- package/dist/sandbox/types/context.js +5 -0
- package/dist/sandbox/types/context.js.map +1 -0
- package/dist/sandbox/types/errors.d.ts +109 -0
- package/dist/sandbox/types/errors.d.ts.map +1 -0
- package/dist/sandbox/types/errors.js +41 -0
- package/dist/sandbox/types/errors.js.map +1 -0
- package/dist/sandbox/types/events.d.ts +577 -0
- package/dist/sandbox/types/events.d.ts.map +1 -0
- package/dist/sandbox/types/events.js +7 -0
- package/dist/sandbox/types/events.js.map +1 -0
- package/dist/sandbox/types/index.d.ts +24 -0
- package/dist/sandbox/types/index.d.ts.map +1 -0
- package/dist/sandbox/types/index.js +17 -0
- package/dist/sandbox/types/index.js.map +1 -0
- package/dist/sandbox/types/operation.d.ts +60 -0
- package/dist/sandbox/types/operation.d.ts.map +1 -0
- package/dist/sandbox/types/operation.js +3 -0
- package/dist/sandbox/types/operation.js.map +1 -0
- package/dist/sandbox/types/persistence.d.ts +130 -0
- package/dist/sandbox/types/persistence.d.ts.map +1 -0
- package/dist/sandbox/types/persistence.js +7 -0
- package/dist/sandbox/types/persistence.js.map +1 -0
- package/dist/sandbox/types/service.d.ts +357 -0
- package/dist/sandbox/types/service.d.ts.map +1 -0
- package/dist/sandbox/types/service.js +6 -0
- package/dist/sandbox/types/service.js.map +1 -0
- package/dist/storage/admin/api.d.ts +206 -0
- package/dist/storage/admin/api.d.ts.map +1 -0
- package/dist/storage/admin/api.js +349 -0
- package/dist/storage/admin/api.js.map +1 -0
- package/dist/storage/admin/handler.d.ts +28 -0
- package/dist/storage/admin/handler.d.ts.map +1 -0
- package/dist/storage/admin/handler.js +82 -0
- package/dist/storage/admin/handler.js.map +1 -0
- package/dist/storage/admin/spec.d.ts +64 -0
- package/dist/storage/admin/spec.d.ts.map +1 -0
- package/dist/storage/admin/spec.js +8 -0
- package/dist/storage/admin/spec.js.map +1 -0
- package/dist/storage/admin/tools.d.ts +22 -0
- package/dist/storage/admin/tools.d.ts.map +1 -0
- package/dist/storage/admin/tools.js +90 -0
- package/dist/storage/admin/tools.js.map +1 -0
- package/dist/storage/download.d.ts +41 -0
- package/dist/storage/download.d.ts.map +1 -0
- package/dist/storage/download.js +137 -0
- package/dist/storage/download.js.map +1 -0
- package/dist/storage/enforce.d.ts +5 -0
- package/dist/storage/enforce.d.ts.map +1 -0
- package/dist/storage/enforce.js +147 -0
- package/dist/storage/enforce.js.map +1 -0
- package/dist/storage/errors.d.ts +44 -0
- package/dist/storage/errors.d.ts.map +1 -0
- package/dist/storage/errors.js +64 -0
- package/dist/storage/errors.js.map +1 -0
- package/dist/storage/index.d.ts +45 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/index.js +39 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/storage/instances.d.ts +9 -0
- package/dist/storage/instances.d.ts.map +1 -0
- package/dist/storage/instances.js +24 -0
- package/dist/storage/instances.js.map +1 -0
- package/dist/storage/internal.d.ts +18 -0
- package/dist/storage/internal.d.ts.map +1 -0
- package/dist/storage/internal.js +18 -0
- package/dist/storage/internal.js.map +1 -0
- package/dist/storage/list.d.ts +42 -0
- package/dist/storage/list.d.ts.map +1 -0
- package/dist/storage/list.js +83 -0
- package/dist/storage/list.js.map +1 -0
- package/dist/storage/metadata.d.ts +92 -0
- package/dist/storage/metadata.d.ts.map +1 -0
- package/dist/storage/metadata.js +164 -0
- package/dist/storage/metadata.js.map +1 -0
- package/dist/storage/persistence.d.ts +134 -0
- package/dist/storage/persistence.d.ts.map +1 -0
- package/dist/storage/persistence.js +132 -0
- package/dist/storage/persistence.js.map +1 -0
- package/dist/storage/reference.d.ts +57 -0
- package/dist/storage/reference.d.ts.map +1 -0
- package/dist/storage/reference.js +105 -0
- package/dist/storage/reference.js.map +1 -0
- package/dist/storage/rules.d.ts +339 -0
- package/dist/storage/rules.d.ts.map +1 -0
- package/dist/storage/rules.js +1334 -0
- package/dist/storage/rules.js.map +1 -0
- package/dist/storage/service.d.ts +122 -0
- package/dist/storage/service.d.ts.map +1 -0
- package/dist/storage/service.js +247 -0
- package/dist/storage/service.js.map +1 -0
- package/dist/storage/upload.d.ts +50 -0
- package/dist/storage/upload.d.ts.map +1 -0
- package/dist/storage/upload.js +246 -0
- package/dist/storage/upload.js.map +1 -0
- 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
|