ramosedb 0.0.0-stage → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/NOTICE +17 -0
- package/README.md +57 -2
- package/dist/Auth.d.ts +55 -0
- package/dist/Auth.d.ts.map +1 -0
- package/dist/Auth.js +50 -0
- package/dist/Auth.js.map +1 -0
- package/dist/Database.d.ts +40 -0
- package/dist/Database.d.ts.map +1 -0
- package/dist/Database.js +62 -0
- package/dist/Database.js.map +1 -0
- package/dist/Providers.d.ts +8 -0
- package/dist/Providers.d.ts.map +1 -0
- package/dist/Providers.js +9 -0
- package/dist/Providers.js.map +1 -0
- package/dist/RamoseEnv.d.ts +37 -0
- package/dist/RamoseEnv.d.ts.map +1 -0
- package/dist/RamoseEnv.js +2 -0
- package/dist/RamoseEnv.js.map +1 -0
- package/dist/Server.d.ts +100 -0
- package/dist/Server.d.ts.map +1 -0
- package/dist/Server.js +263 -0
- package/dist/Server.js.map +1 -0
- package/dist/ServerRuntime.d.ts +10 -0
- package/dist/ServerRuntime.d.ts.map +1 -0
- package/dist/ServerRuntime.js +11 -0
- package/dist/ServerRuntime.js.map +1 -0
- package/dist/better-auth/client.d.ts +19 -0
- package/dist/better-auth/client.d.ts.map +1 -0
- package/dist/better-auth/client.js +110 -0
- package/dist/better-auth/client.js.map +1 -0
- package/dist/better-auth/index.d.ts +140 -0
- package/dist/better-auth/index.d.ts.map +1 -0
- package/dist/better-auth/index.js +168 -0
- package/dist/better-auth/index.js.map +1 -0
- package/dist/client/activation.d.ts +2 -0
- package/dist/client/activation.d.ts.map +1 -0
- package/dist/client/activation.js +33 -0
- package/dist/client/activation.js.map +1 -0
- package/dist/client/catalog.d.ts +15 -0
- package/dist/client/catalog.d.ts.map +1 -0
- package/dist/client/catalog.js +48 -0
- package/dist/client/catalog.js.map +1 -0
- package/dist/client/changesets.d.ts +85 -0
- package/dist/client/changesets.d.ts.map +1 -0
- package/dist/client/changesets.js +160 -0
- package/dist/client/changesets.js.map +1 -0
- package/dist/client/client.d.ts +45 -0
- package/dist/client/client.d.ts.map +1 -0
- package/dist/client/client.js +425 -0
- package/dist/client/client.js.map +1 -0
- package/dist/client/database.d.ts +163 -0
- package/dist/client/database.d.ts.map +1 -0
- package/dist/client/database.js +795 -0
- package/dist/client/database.js.map +1 -0
- package/dist/client/entity.d.ts +63 -0
- package/dist/client/entity.d.ts.map +1 -0
- package/dist/client/entity.js +141 -0
- package/dist/client/entity.js.map +1 -0
- package/dist/client/errors.d.ts +67 -0
- package/dist/client/errors.d.ts.map +1 -0
- package/dist/client/errors.js +39 -0
- package/dist/client/errors.js.map +1 -0
- package/dist/client/index.d.ts +13 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +6 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/mutation-schema.d.ts +92 -0
- package/dist/client/mutation-schema.d.ts.map +1 -0
- package/dist/client/mutation-schema.js +2 -0
- package/dist/client/mutation-schema.js.map +1 -0
- package/dist/client/mutation.d.ts +25 -0
- package/dist/client/mutation.d.ts.map +1 -0
- package/dist/client/mutation.js +75 -0
- package/dist/client/mutation.js.map +1 -0
- package/dist/client/operations.d.ts +39 -0
- package/dist/client/operations.d.ts.map +1 -0
- package/dist/client/operations.js +183 -0
- package/dist/client/operations.js.map +1 -0
- package/dist/client/query.d.ts +53 -0
- package/dist/client/query.d.ts.map +1 -0
- package/dist/client/query.js +85 -0
- package/dist/client/query.js.map +1 -0
- package/dist/client/receipt.d.ts +53 -0
- package/dist/client/receipt.d.ts.map +1 -0
- package/dist/client/receipt.js +79 -0
- package/dist/client/receipt.js.map +1 -0
- package/dist/client/submission.d.ts +44 -0
- package/dist/client/submission.d.ts.map +1 -0
- package/dist/client/submission.js +165 -0
- package/dist/client/submission.js.map +1 -0
- package/dist/client/subscription.d.ts +18 -0
- package/dist/client/subscription.d.ts.map +1 -0
- package/dist/client/subscription.js +75 -0
- package/dist/client/subscription.js.map +1 -0
- package/dist/client/sync.d.ts +32 -0
- package/dist/client/sync.d.ts.map +1 -0
- package/dist/client/sync.js +34 -0
- package/dist/client/sync.js.map +1 -0
- package/dist/client/view.d.ts +37 -0
- package/dist/client/view.d.ts.map +1 -0
- package/dist/client/view.js +112 -0
- package/dist/client/view.js.map +1 -0
- package/dist/db/Binding.d.ts +79 -0
- package/dist/db/Binding.d.ts.map +1 -0
- package/dist/db/Binding.js +138 -0
- package/dist/db/Binding.js.map +1 -0
- package/dist/db/Composer.d.ts +7 -0
- package/dist/db/Composer.d.ts.map +1 -0
- package/dist/db/Composer.js +6 -0
- package/dist/db/Composer.js.map +1 -0
- package/dist/db/DatabaseName.d.ts +7 -0
- package/dist/db/DatabaseName.d.ts.map +1 -0
- package/dist/db/DatabaseName.js +9 -0
- package/dist/db/DatabaseName.js.map +1 -0
- package/dist/db/Eid.d.ts +19 -0
- package/dist/db/Eid.d.ts.map +1 -0
- package/dist/db/Eid.js +2 -0
- package/dist/db/Eid.js.map +1 -0
- package/dist/db/Entity.d.ts +133 -0
- package/dist/db/Entity.d.ts.map +1 -0
- package/dist/db/Entity.js +104 -0
- package/dist/db/Entity.js.map +1 -0
- package/dist/db/Errors.d.ts +138 -0
- package/dist/db/Errors.d.ts.map +1 -0
- package/dist/db/Errors.js +171 -0
- package/dist/db/Errors.js.map +1 -0
- package/dist/db/Field.d.ts +170 -0
- package/dist/db/Field.d.ts.map +1 -0
- package/dist/db/Field.js +187 -0
- package/dist/db/Field.js.map +1 -0
- package/dist/db/IdentName.d.ts +94 -0
- package/dist/db/IdentName.d.ts.map +1 -0
- package/dist/db/IdentName.js +34 -0
- package/dist/db/IdentName.js.map +1 -0
- package/dist/db/Operation.d.ts +441 -0
- package/dist/db/Operation.d.ts.map +1 -0
- package/dist/db/Operation.js +237 -0
- package/dist/db/Operation.js.map +1 -0
- package/dist/db/Projection.d.ts +97 -0
- package/dist/db/Projection.d.ts.map +1 -0
- package/dist/db/Projection.js +183 -0
- package/dist/db/Projection.js.map +1 -0
- package/dist/db/Pull.d.ts +361 -0
- package/dist/db/Pull.d.ts.map +1 -0
- package/dist/db/Pull.js +547 -0
- package/dist/db/Pull.js.map +1 -0
- package/dist/db/Schema.d.ts +37 -0
- package/dist/db/Schema.d.ts.map +1 -0
- package/dist/db/Schema.js +94 -0
- package/dist/db/Schema.js.map +1 -0
- package/dist/db/Trait.d.ts +129 -0
- package/dist/db/Trait.d.ts.map +1 -0
- package/dist/db/Trait.js +65 -0
- package/dist/db/Trait.js.map +1 -0
- package/dist/db/Tx.d.ts +128 -0
- package/dist/db/Tx.d.ts.map +1 -0
- package/dist/db/Tx.js +248 -0
- package/dist/db/Tx.js.map +1 -0
- package/dist/db/allocations.d.ts +44 -0
- package/dist/db/allocations.d.ts.map +1 -0
- package/dist/db/allocations.js +70 -0
- package/dist/db/allocations.js.map +1 -0
- package/dist/db/attrRef.d.ts +5 -0
- package/dist/db/attrRef.d.ts.map +1 -0
- package/dist/db/attrRef.js +6 -0
- package/dist/db/attrRef.js.map +1 -0
- package/dist/db/compose.d.ts +26 -0
- package/dist/db/compose.d.ts.map +1 -0
- package/dist/db/compose.js +105 -0
- package/dist/db/compose.js.map +1 -0
- package/dist/db/composition.d.ts +4 -0
- package/dist/db/composition.d.ts.map +1 -0
- package/dist/db/composition.js +24 -0
- package/dist/db/composition.js.map +1 -0
- package/dist/db/creation.d.ts +102 -0
- package/dist/db/creation.d.ts.map +1 -0
- package/dist/db/creation.js +448 -0
- package/dist/db/creation.js.map +1 -0
- package/dist/db/deployedSchema.d.ts +12 -0
- package/dist/db/deployedSchema.d.ts.map +1 -0
- package/dist/db/deployedSchema.js +80 -0
- package/dist/db/deployedSchema.js.map +1 -0
- package/dist/db/documentation.d.ts +4 -0
- package/dist/db/documentation.d.ts.map +1 -0
- package/dist/db/documentation.js +4 -0
- package/dist/db/documentation.js.map +1 -0
- package/dist/db/ensure.d.ts +16 -0
- package/dist/db/ensure.d.ts.map +1 -0
- package/dist/db/ensure.js +48 -0
- package/dist/db/ensure.js.map +1 -0
- package/dist/db/entityArg.d.ts +15 -0
- package/dist/db/entityArg.d.ts.map +1 -0
- package/dist/db/entityArg.js +71 -0
- package/dist/db/entityArg.js.map +1 -0
- package/dist/db/equal.d.ts +4 -0
- package/dist/db/equal.d.ts.map +1 -0
- package/dist/db/equal.js +2 -0
- package/dist/db/equal.js.map +1 -0
- package/dist/db/idents.d.ts +90 -0
- package/dist/db/idents.d.ts.map +1 -0
- package/dist/db/idents.js +2 -0
- package/dist/db/idents.js.map +1 -0
- package/dist/db/index.d.ts +27 -0
- package/dist/db/index.d.ts.map +1 -0
- package/dist/db/index.js +20 -0
- package/dist/db/index.js.map +1 -0
- package/dist/db/internal.d.ts +27 -0
- package/dist/db/internal.d.ts.map +1 -0
- package/dist/db/internal.js +27 -0
- package/dist/db/internal.js.map +1 -0
- package/dist/db/query/cursor.d.ts +13 -0
- package/dist/db/query/cursor.d.ts.map +1 -0
- package/dist/db/query/cursor.js +150 -0
- package/dist/db/query/cursor.js.map +1 -0
- package/dist/db/query/elemFilter.d.ts +7 -0
- package/dist/db/query/elemFilter.d.ts.map +1 -0
- package/dist/db/query/elemFilter.js +280 -0
- package/dist/db/query/elemFilter.js.map +1 -0
- package/dist/db/query/fluent.d.ts +92 -0
- package/dist/db/query/fluent.d.ts.map +1 -0
- package/dist/db/query/fluent.js +125 -0
- package/dist/db/query/fluent.js.map +1 -0
- package/dist/db/query/focus.d.ts +42 -0
- package/dist/db/query/focus.d.ts.map +1 -0
- package/dist/db/query/focus.js +2 -0
- package/dist/db/query/focus.js.map +1 -0
- package/dist/db/query/index.d.ts +7 -0
- package/dist/db/query/index.d.ts.map +1 -0
- package/dist/db/query/index.js +6 -0
- package/dist/db/query/index.js.map +1 -0
- package/dist/db/query/kernel.d.ts +215 -0
- package/dist/db/query/kernel.d.ts.map +1 -0
- package/dist/db/query/kernel.js +284 -0
- package/dist/db/query/kernel.js.map +1 -0
- package/dist/db/query/lib.d.ts +168 -0
- package/dist/db/query/lib.d.ts.map +1 -0
- package/dist/db/query/lib.js +175 -0
- package/dist/db/query/lib.js.map +1 -0
- package/dist/db/query/query.d.ts +209 -0
- package/dist/db/query/query.d.ts.map +1 -0
- package/dist/db/query/query.js +1536 -0
- package/dist/db/query/query.js.map +1 -0
- package/dist/db/query/stdlib/failures.d.ts +91 -0
- package/dist/db/query/stdlib/failures.d.ts.map +1 -0
- package/dist/db/query/stdlib/failures.js +57 -0
- package/dist/db/query/stdlib/failures.js.map +1 -0
- package/dist/db/query/stdlib/implementations.d.ts +5 -0
- package/dist/db/query/stdlib/implementations.d.ts.map +1 -0
- package/dist/db/query/stdlib/implementations.js +208 -0
- package/dist/db/query/stdlib/implementations.js.map +1 -0
- package/dist/db/query/stdlib/index.d.ts +6 -0
- package/dist/db/query/stdlib/index.d.ts.map +1 -0
- package/dist/db/query/stdlib/index.js +6 -0
- package/dist/db/query/stdlib/index.js.map +1 -0
- package/dist/db/query/stdlib/manifest.d.ts +3 -0
- package/dist/db/query/stdlib/manifest.d.ts.map +1 -0
- package/dist/db/query/stdlib/manifest.js +1067 -0
- package/dist/db/query/stdlib/manifest.js.map +1 -0
- package/dist/db/query/stdlib/registry.d.ts +22 -0
- package/dist/db/query/stdlib/registry.d.ts.map +1 -0
- package/dist/db/query/stdlib/registry.js +144 -0
- package/dist/db/query/stdlib/registry.js.map +1 -0
- package/dist/db/query/stdlib/types.d.ts +50 -0
- package/dist/db/query/stdlib/types.d.ts.map +1 -0
- package/dist/db/query/stdlib/types.js +17 -0
- package/dist/db/query/stdlib/types.js.map +1 -0
- package/dist/db/query/stdlib/values.d.ts +17 -0
- package/dist/db/query/stdlib/values.d.ts.map +1 -0
- package/dist/db/query/stdlib/values.js +200 -0
- package/dist/db/query/stdlib/values.js.map +1 -0
- package/dist/db/query/surface.d.ts +15 -0
- package/dist/db/query/surface.d.ts.map +1 -0
- package/dist/db/query/surface.js +14 -0
- package/dist/db/query/surface.js.map +1 -0
- package/dist/db/reachability.d.ts +40 -0
- package/dist/db/reachability.d.ts.map +1 -0
- package/dist/db/reachability.js +118 -0
- package/dist/db/reachability.js.map +1 -0
- package/dist/db/refs.d.ts +46 -0
- package/dist/db/refs.d.ts.map +1 -0
- package/dist/db/refs.js +69 -0
- package/dist/db/refs.js.map +1 -0
- package/dist/db/shapes.d.ts +227 -0
- package/dist/db/shapes.d.ts.map +1 -0
- package/dist/db/shapes.js +246 -0
- package/dist/db/shapes.js.map +1 -0
- package/dist/db/valueTypes.d.ts +92 -0
- package/dist/db/valueTypes.d.ts.map +1 -0
- package/dist/db/valueTypes.js +105 -0
- package/dist/db/valueTypes.js.map +1 -0
- package/dist/errorHttp.d.ts +27 -0
- package/dist/errorHttp.d.ts.map +1 -0
- package/dist/errorHttp.js +95 -0
- package/dist/errorHttp.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/authorization/authoring/compile.d.ts +132 -0
- package/dist/internal/authorization/authoring/compile.d.ts.map +1 -0
- package/dist/internal/authorization/authoring/compile.js +634 -0
- package/dist/internal/authorization/authoring/compile.js.map +1 -0
- package/dist/internal/authorization/authoring/expr.d.ts +25 -0
- package/dist/internal/authorization/authoring/expr.d.ts.map +1 -0
- package/dist/internal/authorization/authoring/expr.js +56 -0
- package/dist/internal/authorization/authoring/expr.js.map +1 -0
- package/dist/internal/authorization/authoring/index.d.ts +10 -0
- package/dist/internal/authorization/authoring/index.d.ts.map +1 -0
- package/dist/internal/authorization/authoring/index.js +8 -0
- package/dist/internal/authorization/authoring/index.js.map +1 -0
- package/dist/internal/authorization/authoring/invoke.d.ts +8 -0
- package/dist/internal/authorization/authoring/invoke.d.ts.map +1 -0
- package/dist/internal/authorization/authoring/invoke.js +7 -0
- package/dist/internal/authorization/authoring/invoke.js.map +1 -0
- package/dist/internal/authorization/authoring/operations.d.ts +81 -0
- package/dist/internal/authorization/authoring/operations.d.ts.map +1 -0
- package/dist/internal/authorization/authoring/operations.js +591 -0
- package/dist/internal/authorization/authoring/operations.js.map +1 -0
- package/dist/internal/authorization/authoring/path.d.ts +20 -0
- package/dist/internal/authorization/authoring/path.d.ts.map +1 -0
- package/dist/internal/authorization/authoring/path.js +109 -0
- package/dist/internal/authorization/authoring/path.js.map +1 -0
- package/dist/internal/authorization/authoring/policy.d.ts +120 -0
- package/dist/internal/authorization/authoring/policy.d.ts.map +1 -0
- package/dist/internal/authorization/authoring/policy.js +218 -0
- package/dist/internal/authorization/authoring/policy.js.map +1 -0
- package/dist/internal/authorization/authoring/read.d.ts +13 -0
- package/dist/internal/authorization/authoring/read.d.ts.map +1 -0
- package/dist/internal/authorization/authoring/read.js +27 -0
- package/dist/internal/authorization/authoring/read.js.map +1 -0
- package/dist/internal/authorization/authoring/types.d.ts +127 -0
- package/dist/internal/authorization/authoring/types.d.ts.map +1 -0
- package/dist/internal/authorization/authoring/types.js +43 -0
- package/dist/internal/authorization/authoring/types.js.map +1 -0
- package/dist/internal/authorization/bind.d.ts +687 -0
- package/dist/internal/authorization/bind.d.ts.map +1 -0
- package/dist/internal/authorization/bind.js +485 -0
- package/dist/internal/authorization/bind.js.map +1 -0
- package/dist/internal/authorization/bounds.d.ts +13 -0
- package/dist/internal/authorization/bounds.d.ts.map +1 -0
- package/dist/internal/authorization/bounds.js +9 -0
- package/dist/internal/authorization/bounds.js.map +1 -0
- package/dist/internal/authorization/canonical-json.d.ts +6 -0
- package/dist/internal/authorization/canonical-json.d.ts.map +1 -0
- package/dist/internal/authorization/canonical-json.js +65 -0
- package/dist/internal/authorization/canonical-json.js.map +1 -0
- package/dist/internal/authorization/catalog-unit.d.ts +1033 -0
- package/dist/internal/authorization/catalog-unit.d.ts.map +1 -0
- package/dist/internal/authorization/catalog-unit.js +303 -0
- package/dist/internal/authorization/catalog-unit.js.map +1 -0
- package/dist/internal/authorization/catalog.d.ts +472 -0
- package/dist/internal/authorization/catalog.d.ts.map +1 -0
- package/dist/internal/authorization/catalog.js +134 -0
- package/dist/internal/authorization/catalog.js.map +1 -0
- package/dist/internal/authorization/changesets.d.ts +54 -0
- package/dist/internal/authorization/changesets.d.ts.map +1 -0
- package/dist/internal/authorization/changesets.js +156 -0
- package/dist/internal/authorization/changesets.js.map +1 -0
- package/dist/internal/authorization/composition.d.ts +10 -0
- package/dist/internal/authorization/composition.d.ts.map +1 -0
- package/dist/internal/authorization/composition.js +28 -0
- package/dist/internal/authorization/composition.js.map +1 -0
- package/dist/internal/authorization/database-bindings.d.ts +48 -0
- package/dist/internal/authorization/database-bindings.d.ts.map +1 -0
- package/dist/internal/authorization/database-bindings.js +101 -0
- package/dist/internal/authorization/database-bindings.js.map +1 -0
- package/dist/internal/authorization/database-target.d.ts +75 -0
- package/dist/internal/authorization/database-target.d.ts.map +1 -0
- package/dist/internal/authorization/database-target.js +65 -0
- package/dist/internal/authorization/database-target.js.map +1 -0
- package/dist/internal/authorization/decode.d.ts +1704 -0
- package/dist/internal/authorization/decode.d.ts.map +1 -0
- package/dist/internal/authorization/decode.js +294 -0
- package/dist/internal/authorization/decode.js.map +1 -0
- package/dist/internal/authorization/definitions.d.ts +66 -0
- package/dist/internal/authorization/definitions.d.ts.map +1 -0
- package/dist/internal/authorization/definitions.js +335 -0
- package/dist/internal/authorization/definitions.js.map +1 -0
- package/dist/internal/authorization/deployed.d.ts +43 -0
- package/dist/internal/authorization/deployed.d.ts.map +1 -0
- package/dist/internal/authorization/deployed.js +184 -0
- package/dist/internal/authorization/deployed.js.map +1 -0
- package/dist/internal/authorization/entity-targets.d.ts +68 -0
- package/dist/internal/authorization/entity-targets.d.ts.map +1 -0
- package/dist/internal/authorization/entity-targets.js +244 -0
- package/dist/internal/authorization/entity-targets.js.map +1 -0
- package/dist/internal/authorization/expr.d.ts +259 -0
- package/dist/internal/authorization/expr.d.ts.map +1 -0
- package/dist/internal/authorization/expr.js +55 -0
- package/dist/internal/authorization/expr.js.map +1 -0
- package/dist/internal/authorization/failures.d.ts +78 -0
- package/dist/internal/authorization/failures.d.ts.map +1 -0
- package/dist/internal/authorization/failures.js +22 -0
- package/dist/internal/authorization/failures.js.map +1 -0
- package/dist/internal/authorization/identities.d.ts +207 -0
- package/dist/internal/authorization/identities.d.ts.map +1 -0
- package/dist/internal/authorization/identities.js +71 -0
- package/dist/internal/authorization/identities.js.map +1 -0
- package/dist/internal/authorization/index.d.ts +33 -0
- package/dist/internal/authorization/index.d.ts.map +1 -0
- package/dist/internal/authorization/index.js +33 -0
- package/dist/internal/authorization/index.js.map +1 -0
- package/dist/internal/authorization/install/normalize.d.ts +196 -0
- package/dist/internal/authorization/install/normalize.d.ts.map +1 -0
- package/dist/internal/authorization/install/normalize.js +168 -0
- package/dist/internal/authorization/install/normalize.js.map +1 -0
- package/dist/internal/authorization/install/plan.d.ts +8 -0
- package/dist/internal/authorization/install/plan.d.ts.map +1 -0
- package/dist/internal/authorization/install/plan.js +177 -0
- package/dist/internal/authorization/install/plan.js.map +1 -0
- package/dist/internal/authorization/install.d.ts +404 -0
- package/dist/internal/authorization/install.d.ts.map +1 -0
- package/dist/internal/authorization/install.js +103 -0
- package/dist/internal/authorization/install.js.map +1 -0
- package/dist/internal/authorization/invocation-codec.d.ts +10 -0
- package/dist/internal/authorization/invocation-codec.d.ts.map +1 -0
- package/dist/internal/authorization/invocation-codec.js +36 -0
- package/dist/internal/authorization/invocation-codec.js.map +1 -0
- package/dist/internal/authorization/invocation-receipts.d.ts +192 -0
- package/dist/internal/authorization/invocation-receipts.d.ts.map +1 -0
- package/dist/internal/authorization/invocation-receipts.js +546 -0
- package/dist/internal/authorization/invocation-receipts.js.map +1 -0
- package/dist/internal/authorization/ir.d.ts +1465 -0
- package/dist/internal/authorization/ir.d.ts.map +1 -0
- package/dist/internal/authorization/ir.js +131 -0
- package/dist/internal/authorization/ir.js.map +1 -0
- package/dist/internal/authorization/json.d.ts +8 -0
- package/dist/internal/authorization/json.d.ts.map +1 -0
- package/dist/internal/authorization/json.js +13 -0
- package/dist/internal/authorization/json.js.map +1 -0
- package/dist/internal/authorization/live.d.ts +38 -0
- package/dist/internal/authorization/live.d.ts.map +1 -0
- package/dist/internal/authorization/live.js +227 -0
- package/dist/internal/authorization/live.js.map +1 -0
- package/dist/internal/authorization/operation-grant.d.ts +16 -0
- package/dist/internal/authorization/operation-grant.d.ts.map +1 -0
- package/dist/internal/authorization/operation-grant.js +79 -0
- package/dist/internal/authorization/operation-grant.js.map +1 -0
- package/dist/internal/authorization/operation-version.d.ts +28 -0
- package/dist/internal/authorization/operation-version.d.ts.map +1 -0
- package/dist/internal/authorization/operation-version.js +206 -0
- package/dist/internal/authorization/operation-version.js.map +1 -0
- package/dist/internal/authorization/operations-runtime.d.ts +78 -0
- package/dist/internal/authorization/operations-runtime.d.ts.map +1 -0
- package/dist/internal/authorization/operations-runtime.js +1130 -0
- package/dist/internal/authorization/operations-runtime.js.map +1 -0
- package/dist/internal/authorization/principal.d.ts +95 -0
- package/dist/internal/authorization/principal.d.ts.map +1 -0
- package/dist/internal/authorization/principal.js +53 -0
- package/dist/internal/authorization/principal.js.map +1 -0
- package/dist/internal/authorization/query-view.d.ts +7 -0
- package/dist/internal/authorization/query-view.d.ts.map +1 -0
- package/dist/internal/authorization/query-view.js +17 -0
- package/dist/internal/authorization/query-view.js.map +1 -0
- package/dist/internal/authorization/read-compatibility.d.ts +185 -0
- package/dist/internal/authorization/read-compatibility.d.ts.map +1 -0
- package/dist/internal/authorization/read-compatibility.js +176 -0
- package/dist/internal/authorization/read-compatibility.js.map +1 -0
- package/dist/internal/authorization/read-filter.d.ts +48 -0
- package/dist/internal/authorization/read-filter.d.ts.map +1 -0
- package/dist/internal/authorization/read-filter.js +496 -0
- package/dist/internal/authorization/read-filter.js.map +1 -0
- package/dist/internal/authorization/read-tables.d.ts +9 -0
- package/dist/internal/authorization/read-tables.d.ts.map +1 -0
- package/dist/internal/authorization/read-tables.js +120 -0
- package/dist/internal/authorization/read-tables.js.map +1 -0
- package/dist/internal/authorization/reads.d.ts +36 -0
- package/dist/internal/authorization/reads.d.ts.map +1 -0
- package/dist/internal/authorization/reads.js +35 -0
- package/dist/internal/authorization/reads.js.map +1 -0
- package/dist/internal/authorization/request.d.ts +64 -0
- package/dist/internal/authorization/request.d.ts.map +1 -0
- package/dist/internal/authorization/request.js +210 -0
- package/dist/internal/authorization/request.js.map +1 -0
- package/dist/internal/authorization/truth.d.ts +51 -0
- package/dist/internal/authorization/truth.d.ts.map +1 -0
- package/dist/internal/authorization/truth.js +23 -0
- package/dist/internal/authorization/truth.js.map +1 -0
- package/dist/internal/authorization/validate.d.ts +3 -0
- package/dist/internal/authorization/validate.d.ts.map +1 -0
- package/dist/internal/authorization/validate.js +3 -0
- package/dist/internal/authorization/validate.js.map +1 -0
- package/dist/internal/authorization/validation/catalog.d.ts +32 -0
- package/dist/internal/authorization/validation/catalog.d.ts.map +1 -0
- package/dist/internal/authorization/validation/catalog.js +417 -0
- package/dist/internal/authorization/validation/catalog.js.map +1 -0
- package/dist/internal/authorization/validation/common.d.ts +20 -0
- package/dist/internal/authorization/validation/common.d.ts.map +1 -0
- package/dist/internal/authorization/validation/common.js +36 -0
- package/dist/internal/authorization/validation/common.js.map +1 -0
- package/dist/internal/authorization/validation/decisions.d.ts +7 -0
- package/dist/internal/authorization/validation/decisions.d.ts.map +1 -0
- package/dist/internal/authorization/validation/decisions.js +107 -0
- package/dist/internal/authorization/validation/decisions.js.map +1 -0
- package/dist/internal/authorization/validation/descriptors.d.ts +8 -0
- package/dist/internal/authorization/validation/descriptors.d.ts.map +1 -0
- package/dist/internal/authorization/validation/descriptors.js +24 -0
- package/dist/internal/authorization/validation/descriptors.js.map +1 -0
- package/dist/internal/authorization/validation/expression.d.ts +11 -0
- package/dist/internal/authorization/validation/expression.d.ts.map +1 -0
- package/dist/internal/authorization/validation/expression.js +114 -0
- package/dist/internal/authorization/validation/expression.js.map +1 -0
- package/dist/internal/authorization/validation/traversal.d.ts +19 -0
- package/dist/internal/authorization/validation/traversal.d.ts.map +1 -0
- package/dist/internal/authorization/validation/traversal.js +141 -0
- package/dist/internal/authorization/validation/traversal.js.map +1 -0
- package/dist/internal/authorization/validation/types.d.ts +55 -0
- package/dist/internal/authorization/validation/types.d.ts.map +1 -0
- package/dist/internal/authorization/validation/types.js +184 -0
- package/dist/internal/authorization/validation/types.js.map +1 -0
- package/dist/internal/authorization/validation/validate.d.ts +421 -0
- package/dist/internal/authorization/validation/validate.d.ts.map +1 -0
- package/dist/internal/authorization/validation/validate.js +95 -0
- package/dist/internal/authorization/validation/validate.js.map +1 -0
- package/dist/internal/authorization/version.d.ts +11 -0
- package/dist/internal/authorization/version.d.ts.map +1 -0
- package/dist/internal/authorization/version.js +10 -0
- package/dist/internal/authorization/version.js.map +1 -0
- package/dist/internal/changesets/protocol.d.ts +185 -0
- package/dist/internal/changesets/protocol.d.ts.map +1 -0
- package/dist/internal/changesets/protocol.js +39 -0
- package/dist/internal/changesets/protocol.js.map +1 -0
- package/dist/internal/changesets/service.d.ts +69 -0
- package/dist/internal/changesets/service.d.ts.map +1 -0
- package/dist/internal/changesets/service.js +298 -0
- package/dist/internal/changesets/service.js.map +1 -0
- package/dist/internal/core/bytes.d.ts +41 -0
- package/dist/internal/core/bytes.d.ts.map +1 -0
- package/dist/internal/core/bytes.js +215 -0
- package/dist/internal/core/bytes.js.map +1 -0
- package/dist/internal/core/composition.d.ts +20 -0
- package/dist/internal/core/composition.d.ts.map +1 -0
- package/dist/internal/core/composition.js +52 -0
- package/dist/internal/core/composition.js.map +1 -0
- package/dist/internal/core/conn.d.ts +64 -0
- package/dist/internal/core/conn.d.ts.map +1 -0
- package/dist/internal/core/conn.js +240 -0
- package/dist/internal/core/conn.js.map +1 -0
- package/dist/internal/core/datom.d.ts +73 -0
- package/dist/internal/core/datom.d.ts.map +1 -0
- package/dist/internal/core/datom.js +477 -0
- package/dist/internal/core/datom.js.map +1 -0
- package/dist/internal/core/db.d.ts +65 -0
- package/dist/internal/core/db.d.ts.map +1 -0
- package/dist/internal/core/db.js +261 -0
- package/dist/internal/core/db.js.map +1 -0
- package/dist/internal/core/index.d.ts +21 -0
- package/dist/internal/core/index.d.ts.map +1 -0
- package/dist/internal/core/index.js +21 -0
- package/dist/internal/core/index.js.map +1 -0
- package/dist/internal/core/json.d.ts +5 -0
- package/dist/internal/core/json.d.ts.map +1 -0
- package/dist/internal/core/json.js +56 -0
- package/dist/internal/core/json.js.map +1 -0
- package/dist/internal/core/log.d.ts +68 -0
- package/dist/internal/core/log.d.ts.map +1 -0
- package/dist/internal/core/log.js +76 -0
- package/dist/internal/core/log.js.map +1 -0
- package/dist/internal/core/novelty.d.ts +38 -0
- package/dist/internal/core/novelty.d.ts.map +1 -0
- package/dist/internal/core/novelty.js +300 -0
- package/dist/internal/core/novelty.js.map +1 -0
- package/dist/internal/core/query/ast.d.ts +174 -0
- package/dist/internal/core/query/ast.d.ts.map +1 -0
- package/dist/internal/core/query/ast.js +37 -0
- package/dist/internal/core/query/ast.js.map +1 -0
- package/dist/internal/core/query/builtins.d.ts +19 -0
- package/dist/internal/core/query/builtins.d.ts.map +1 -0
- package/dist/internal/core/query/builtins.js +242 -0
- package/dist/internal/core/query/builtins.js.map +1 -0
- package/dist/internal/core/query/edn.d.ts +19 -0
- package/dist/internal/core/query/edn.d.ts.map +1 -0
- package/dist/internal/core/query/edn.js +248 -0
- package/dist/internal/core/query/edn.js.map +1 -0
- package/dist/internal/core/query/engine.d.ts +56 -0
- package/dist/internal/core/query/engine.d.ts.map +1 -0
- package/dist/internal/core/query/engine.js +0 -0
- package/dist/internal/core/query/engine.js.map +1 -0
- package/dist/internal/core/query/parse.d.ts +8 -0
- package/dist/internal/core/query/parse.d.ts.map +1 -0
- package/dist/internal/core/query/parse.js +606 -0
- package/dist/internal/core/query/parse.js.map +1 -0
- package/dist/internal/core/query/pull.d.ts +7 -0
- package/dist/internal/core/query/pull.d.ts.map +1 -0
- package/dist/internal/core/query/pull.js +304 -0
- package/dist/internal/core/query/pull.js.map +1 -0
- package/dist/internal/core/query/value.d.ts +10 -0
- package/dist/internal/core/query/value.d.ts.map +1 -0
- package/dist/internal/core/query/value.js +21 -0
- package/dist/internal/core/query/value.js.map +1 -0
- package/dist/internal/core/revision.d.ts +19 -0
- package/dist/internal/core/revision.d.ts.map +1 -0
- package/dist/internal/core/revision.js +13 -0
- package/dist/internal/core/revision.js.map +1 -0
- package/dist/internal/core/schema.d.ts +63 -0
- package/dist/internal/core/schema.d.ts.map +1 -0
- package/dist/internal/core/schema.js +228 -0
- package/dist/internal/core/schema.js.map +1 -0
- package/dist/internal/core/segment.d.ts +16 -0
- package/dist/internal/core/segment.d.ts.map +1 -0
- package/dist/internal/core/segment.js +149 -0
- package/dist/internal/core/segment.js.map +1 -0
- package/dist/internal/core/store.d.ts +35 -0
- package/dist/internal/core/store.d.ts.map +1 -0
- package/dist/internal/core/store.js +88 -0
- package/dist/internal/core/store.js.map +1 -0
- package/dist/internal/core/telemetry.d.ts +53 -0
- package/dist/internal/core/telemetry.d.ts.map +1 -0
- package/dist/internal/core/telemetry.js +103 -0
- package/dist/internal/core/telemetry.js.map +1 -0
- package/dist/internal/core/tree.d.ts +60 -0
- package/dist/internal/core/tree.d.ts.map +1 -0
- package/dist/internal/core/tree.js +625 -0
- package/dist/internal/core/tree.js.map +1 -0
- package/dist/internal/core/tx-provenance.d.ts +7 -0
- package/dist/internal/core/tx-provenance.d.ts.map +1 -0
- package/dist/internal/core/tx-provenance.js +16 -0
- package/dist/internal/core/tx-provenance.js.map +1 -0
- package/dist/internal/core/tx.d.ts +51 -0
- package/dist/internal/core/tx.d.ts.map +1 -0
- package/dist/internal/core/tx.js +1029 -0
- package/dist/internal/core/tx.js.map +1 -0
- package/dist/internal/replica/basis.d.ts +15 -0
- package/dist/internal/replica/basis.d.ts.map +1 -0
- package/dist/internal/replica/basis.js +32 -0
- package/dist/internal/replica/basis.js.map +1 -0
- package/dist/internal/replica/errors.d.ts +32 -0
- package/dist/internal/replica/errors.d.ts.map +1 -0
- package/dist/internal/replica/errors.js +30 -0
- package/dist/internal/replica/errors.js.map +1 -0
- package/dist/internal/replica/index.d.ts +4 -0
- package/dist/internal/replica/index.d.ts.map +1 -0
- package/dist/internal/replica/index.js +4 -0
- package/dist/internal/replica/index.js.map +1 -0
- package/dist/internal/replica/replica-do-testing.d.ts +11 -0
- package/dist/internal/replica/replica-do-testing.d.ts.map +1 -0
- package/dist/internal/replica/replica-do-testing.js +340 -0
- package/dist/internal/replica/replica-do-testing.js.map +1 -0
- package/dist/internal/replica/replica-do.d.ts +87 -0
- package/dist/internal/replica/replica-do.d.ts.map +1 -0
- package/dist/internal/replica/replica-do.js +735 -0
- package/dist/internal/replica/replica-do.js.map +1 -0
- package/dist/internal/replica/revision-retention.d.ts +29 -0
- package/dist/internal/replica/revision-retention.d.ts.map +1 -0
- package/dist/internal/replica/revision-retention.js +39 -0
- package/dist/internal/replica/revision-retention.js.map +1 -0
- package/dist/internal/replication/activation-fence.d.ts +40 -0
- package/dist/internal/replication/activation-fence.d.ts.map +1 -0
- package/dist/internal/replication/activation-fence.js +85 -0
- package/dist/internal/replication/activation-fence.js.map +1 -0
- package/dist/internal/replication/digest.d.ts +2 -0
- package/dist/internal/replication/digest.d.ts.map +1 -0
- package/dist/internal/replication/digest.js +12 -0
- package/dist/internal/replication/digest.js.map +1 -0
- package/dist/internal/replication/entity-id.d.ts +23 -0
- package/dist/internal/replication/entity-id.d.ts.map +1 -0
- package/dist/internal/replication/entity-id.js +161 -0
- package/dist/internal/replication/entity-id.js.map +1 -0
- package/dist/internal/replication/idb.d.ts +9 -0
- package/dist/internal/replication/idb.d.ts.map +1 -0
- package/dist/internal/replication/idb.js +46 -0
- package/dist/internal/replication/idb.js.map +1 -0
- package/dist/internal/replication/identity-root.d.ts +11 -0
- package/dist/internal/replication/identity-root.d.ts.map +1 -0
- package/dist/internal/replication/identity-root.js +48 -0
- package/dist/internal/replication/identity-root.js.map +1 -0
- package/dist/internal/replication/identity.d.ts +40 -0
- package/dist/internal/replication/identity.d.ts.map +1 -0
- package/dist/internal/replication/identity.js +95 -0
- package/dist/internal/replication/identity.js.map +1 -0
- package/dist/internal/replication/index.d.ts +13 -0
- package/dist/internal/replication/index.d.ts.map +1 -0
- package/dist/internal/replication/index.js +13 -0
- package/dist/internal/replication/index.js.map +1 -0
- package/dist/internal/replication/indexeddb.d.ts +171 -0
- package/dist/internal/replication/indexeddb.d.ts.map +1 -0
- package/dist/internal/replication/indexeddb.js +1809 -0
- package/dist/internal/replication/indexeddb.js.map +1 -0
- package/dist/internal/replication/leadership.d.ts +36 -0
- package/dist/internal/replication/leadership.d.ts.map +1 -0
- package/dist/internal/replication/leadership.js +108 -0
- package/dist/internal/replication/leadership.js.map +1 -0
- package/dist/internal/replication/logical.d.ts +40 -0
- package/dist/internal/replication/logical.d.ts.map +1 -0
- package/dist/internal/replication/logical.js +375 -0
- package/dist/internal/replication/logical.js.map +1 -0
- package/dist/internal/replication/notices.d.ts +32 -0
- package/dist/internal/replication/notices.d.ts.map +1 -0
- package/dist/internal/replication/notices.js +92 -0
- package/dist/internal/replication/notices.js.map +1 -0
- package/dist/internal/replication/outbox-storage.d.ts +98 -0
- package/dist/internal/replication/outbox-storage.d.ts.map +1 -0
- package/dist/internal/replication/outbox-storage.js +826 -0
- package/dist/internal/replication/outbox-storage.js.map +1 -0
- package/dist/internal/replication/outbox.d.ts +200 -0
- package/dist/internal/replication/outbox.d.ts.map +1 -0
- package/dist/internal/replication/outbox.js +744 -0
- package/dist/internal/replication/outbox.js.map +1 -0
- package/dist/internal/replication/overlay-layers.d.ts +14 -0
- package/dist/internal/replication/overlay-layers.d.ts.map +1 -0
- package/dist/internal/replication/overlay-layers.js +2 -0
- package/dist/internal/replication/overlay-layers.js.map +1 -0
- package/dist/internal/replication/overlay-records.d.ts +61 -0
- package/dist/internal/replication/overlay-records.d.ts.map +1 -0
- package/dist/internal/replication/overlay-records.js +328 -0
- package/dist/internal/replication/overlay-records.js.map +1 -0
- package/dist/internal/replication/overlay.d.ts +20 -0
- package/dist/internal/replication/overlay.d.ts.map +1 -0
- package/dist/internal/replication/overlay.js +159 -0
- package/dist/internal/replication/overlay.js.map +1 -0
- package/dist/internal/replication/projection-binding.d.ts +39 -0
- package/dist/internal/replication/projection-binding.d.ts.map +1 -0
- package/dist/internal/replication/projection-binding.js +76 -0
- package/dist/internal/replication/projection-binding.js.map +1 -0
- package/dist/internal/replication/protocol.d.ts +633 -0
- package/dist/internal/replication/protocol.d.ts.map +1 -0
- package/dist/internal/replication/protocol.js +263 -0
- package/dist/internal/replication/protocol.js.map +1 -0
- package/dist/internal/replication/reconciliation.d.ts +64 -0
- package/dist/internal/replication/reconciliation.d.ts.map +1 -0
- package/dist/internal/replication/reconciliation.js +184 -0
- package/dist/internal/replication/reconciliation.js.map +1 -0
- package/dist/internal/replication/replica-gc.d.ts +42 -0
- package/dist/internal/replication/replica-gc.d.ts.map +1 -0
- package/dist/internal/replication/replica-gc.js +91 -0
- package/dist/internal/replication/replica-gc.js.map +1 -0
- package/dist/internal/replication/replica-integrity.d.ts +107 -0
- package/dist/internal/replication/replica-integrity.d.ts.map +1 -0
- package/dist/internal/replication/replica-integrity.js +418 -0
- package/dist/internal/replication/replica-integrity.js.map +1 -0
- package/dist/internal/replication/replica-lifecycle.d.ts +72 -0
- package/dist/internal/replication/replica-lifecycle.d.ts.map +1 -0
- package/dist/internal/replication/replica-lifecycle.js +126 -0
- package/dist/internal/replication/replica-lifecycle.js.map +1 -0
- package/dist/internal/replication/replica-schema.d.ts +27 -0
- package/dist/internal/replication/replica-schema.d.ts.map +1 -0
- package/dist/internal/replication/replica-schema.js +130 -0
- package/dist/internal/replication/replica-schema.js.map +1 -0
- package/dist/internal/replication/route-slot.d.ts +9 -0
- package/dist/internal/replication/route-slot.d.ts.map +1 -0
- package/dist/internal/replication/route-slot.js +8 -0
- package/dist/internal/replication/route-slot.js.map +1 -0
- package/dist/internal/replication/server-identity.d.ts +54 -0
- package/dist/internal/replication/server-identity.d.ts.map +1 -0
- package/dist/internal/replication/server-identity.js +68 -0
- package/dist/internal/replication/server-identity.js.map +1 -0
- package/dist/internal/replication/session.d.ts +91 -0
- package/dist/internal/replication/session.d.ts.map +1 -0
- package/dist/internal/replication/session.js +673 -0
- package/dist/internal/replication/session.js.map +1 -0
- package/dist/internal/replication/state.d.ts +34 -0
- package/dist/internal/replication/state.d.ts.map +1 -0
- package/dist/internal/replication/state.js +344 -0
- package/dist/internal/replication/state.js.map +1 -0
- package/dist/internal/replication/submission.d.ts +115 -0
- package/dist/internal/replication/submission.d.ts.map +1 -0
- package/dist/internal/replication/submission.js +266 -0
- package/dist/internal/replication/submission.js.map +1 -0
- package/dist/internal/replication/transport.d.ts +34 -0
- package/dist/internal/replication/transport.d.ts.map +1 -0
- package/dist/internal/replication/transport.js +215 -0
- package/dist/internal/replication/transport.js.map +1 -0
- package/dist/internal/runtime-boundaries.d.ts +8 -0
- package/dist/internal/runtime-boundaries.d.ts.map +1 -0
- package/dist/internal/runtime-boundaries.js +7 -0
- package/dist/internal/runtime-boundaries.js.map +1 -0
- package/dist/internal/storage/index.d.ts +111 -0
- package/dist/internal/storage/index.d.ts.map +1 -0
- package/dist/internal/storage/index.js +288 -0
- package/dist/internal/storage/index.js.map +1 -0
- package/dist/internal/storage/memory.d.ts +31 -0
- package/dist/internal/storage/memory.d.ts.map +1 -0
- package/dist/internal/storage/memory.js +46 -0
- package/dist/internal/storage/memory.js.map +1 -0
- package/dist/internal/storage/revisions.d.ts +24 -0
- package/dist/internal/storage/revisions.d.ts.map +1 -0
- package/dist/internal/storage/revisions.js +74 -0
- package/dist/internal/storage/revisions.js.map +1 -0
- package/dist/internal/test-hooks.d.ts +47 -0
- package/dist/internal/test-hooks.d.ts.map +1 -0
- package/dist/internal/test-hooks.js +256 -0
- package/dist/internal/test-hooks.js.map +1 -0
- package/dist/internal/transactor/env.d.ts +3 -0
- package/dist/internal/transactor/env.d.ts.map +1 -0
- package/dist/internal/transactor/env.js +5 -0
- package/dist/internal/transactor/env.js.map +1 -0
- package/dist/internal/transactor/errors.d.ts +47 -0
- package/dist/internal/transactor/errors.d.ts.map +1 -0
- package/dist/internal/transactor/errors.js +66 -0
- package/dist/internal/transactor/errors.js.map +1 -0
- package/dist/internal/transactor/host.d.ts +37 -0
- package/dist/internal/transactor/host.d.ts.map +1 -0
- package/dist/internal/transactor/host.js +11 -0
- package/dist/internal/transactor/host.js.map +1 -0
- package/dist/internal/transactor/index.d.ts +8 -0
- package/dist/internal/transactor/index.d.ts.map +1 -0
- package/dist/internal/transactor/index.js +8 -0
- package/dist/internal/transactor/index.js.map +1 -0
- package/dist/internal/transactor/indexer.d.ts +53 -0
- package/dist/internal/transactor/indexer.d.ts.map +1 -0
- package/dist/internal/transactor/indexer.js +125 -0
- package/dist/internal/transactor/indexer.js.map +1 -0
- package/dist/internal/transactor/internal.d.ts +8 -0
- package/dist/internal/transactor/internal.d.ts.map +1 -0
- package/dist/internal/transactor/internal.js +28 -0
- package/dist/internal/transactor/internal.js.map +1 -0
- package/dist/internal/transactor/observability.d.ts +44 -0
- package/dist/internal/transactor/observability.d.ts.map +1 -0
- package/dist/internal/transactor/observability.js +39 -0
- package/dist/internal/transactor/observability.js.map +1 -0
- package/dist/internal/transactor/transactor-do.d.ts +35 -0
- package/dist/internal/transactor/transactor-do.d.ts.map +1 -0
- package/dist/internal/transactor/transactor-do.js +198 -0
- package/dist/internal/transactor/transactor-do.js.map +1 -0
- package/dist/internal/transactor/transactor.d.ts +209 -0
- package/dist/internal/transactor/transactor.d.ts.map +1 -0
- package/dist/internal/transactor/transactor.js +1166 -0
- package/dist/internal/transactor/transactor.js.map +1 -0
- package/dist/mcp/contract.d.ts +49 -0
- package/dist/mcp/contract.d.ts.map +1 -0
- package/dist/mcp/contract.js +199 -0
- package/dist/mcp/contract.js.map +1 -0
- package/dist/mcp/kernel.d.ts +56 -0
- package/dist/mcp/kernel.d.ts.map +1 -0
- package/dist/mcp/kernel.js +344 -0
- package/dist/mcp/kernel.js.map +1 -0
- package/dist/mcp/server.d.ts +8 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +182 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/peer.d.ts +175 -0
- package/dist/peer.d.ts.map +1 -0
- package/dist/peer.js +200 -0
- package/dist/peer.js.map +1 -0
- package/dist/react/hooks.d.ts +157 -0
- package/dist/react/hooks.d.ts.map +1 -0
- package/dist/react/hooks.js +130 -0
- package/dist/react/hooks.js.map +1 -0
- package/dist/react/index.d.ts +4 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +2 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/query-state.d.ts +60 -0
- package/dist/react/query-state.d.ts.map +1 -0
- package/dist/react/query-state.js +48 -0
- package/dist/react/query-state.js.map +1 -0
- package/dist/react/receipt-state.d.ts +27 -0
- package/dist/react/receipt-state.d.ts.map +1 -0
- package/dist/react/receipt-state.js +2 -0
- package/dist/react/receipt-state.js.map +1 -0
- package/dist/react/store.d.ts +30 -0
- package/dist/react/store.d.ts.map +1 -0
- package/dist/react/store.js +118 -0
- package/dist/react/store.js.map +1 -0
- package/dist/react/suspense.d.ts +6 -0
- package/dist/react/suspense.d.ts.map +1 -0
- package/dist/react/suspense.js +111 -0
- package/dist/react/suspense.js.map +1 -0
- package/dist/worker/admit.d.ts +9 -0
- package/dist/worker/admit.d.ts.map +1 -0
- package/dist/worker/admit.js +43 -0
- package/dist/worker/admit.js.map +1 -0
- package/dist/worker/analytics.d.ts +39 -0
- package/dist/worker/analytics.d.ts.map +1 -0
- package/dist/worker/analytics.js +54 -0
- package/dist/worker/analytics.js.map +1 -0
- package/dist/worker/auth.d.ts +26 -0
- package/dist/worker/auth.d.ts.map +1 -0
- package/dist/worker/auth.js +2 -0
- package/dist/worker/auth.js.map +1 -0
- package/dist/worker/authorized-live.d.ts +15 -0
- package/dist/worker/authorized-live.d.ts.map +1 -0
- package/dist/worker/authorized-live.js +30 -0
- package/dist/worker/authorized-live.js.map +1 -0
- package/dist/worker/authorized-operation.d.ts +30 -0
- package/dist/worker/authorized-operation.d.ts.map +1 -0
- package/dist/worker/authorized-operation.js +304 -0
- package/dist/worker/authorized-operation.js.map +1 -0
- package/dist/worker/authorized-read.d.ts +32 -0
- package/dist/worker/authorized-read.d.ts.map +1 -0
- package/dist/worker/authorized-read.js +194 -0
- package/dist/worker/authorized-read.js.map +1 -0
- package/dist/worker/authorized-replication.d.ts +21 -0
- package/dist/worker/authorized-replication.d.ts.map +1 -0
- package/dist/worker/authorized-replication.js +593 -0
- package/dist/worker/authorized-replication.js.map +1 -0
- package/dist/worker/changesets.d.ts +9 -0
- package/dist/worker/changesets.d.ts.map +1 -0
- package/dist/worker/changesets.js +105 -0
- package/dist/worker/changesets.js.map +1 -0
- package/dist/worker/demo.d.ts +2 -0
- package/dist/worker/demo.d.ts.map +1 -0
- package/dist/worker/demo.js +85 -0
- package/dist/worker/demo.js.map +1 -0
- package/dist/worker/errors.d.ts +53 -0
- package/dist/worker/errors.d.ts.map +1 -0
- package/dist/worker/errors.js +107 -0
- package/dist/worker/errors.js.map +1 -0
- package/dist/worker/handle.d.ts +21 -0
- package/dist/worker/handle.d.ts.map +1 -0
- package/dist/worker/handle.js +386 -0
- package/dist/worker/handle.js.map +1 -0
- package/dist/worker/index.d.ts +27 -0
- package/dist/worker/index.d.ts.map +1 -0
- package/dist/worker/index.js +24 -0
- package/dist/worker/index.js.map +1 -0
- package/dist/worker/jwt.d.ts +23 -0
- package/dist/worker/jwt.d.ts.map +1 -0
- package/dist/worker/jwt.js +288 -0
- package/dist/worker/jwt.js.map +1 -0
- package/dist/worker/mcp.d.ts +17 -0
- package/dist/worker/mcp.d.ts.map +1 -0
- package/dist/worker/mcp.js +151 -0
- package/dist/worker/mcp.js.map +1 -0
- package/dist/worker/operation-catalogs.d.ts +38 -0
- package/dist/worker/operation-catalogs.d.ts.map +1 -0
- package/dist/worker/operation-catalogs.js +114 -0
- package/dist/worker/operation-catalogs.js.map +1 -0
- package/dist/worker/peer.d.ts +70 -0
- package/dist/worker/peer.d.ts.map +1 -0
- package/dist/worker/peer.js +330 -0
- package/dist/worker/peer.js.map +1 -0
- package/dist/worker/public-observation.d.ts +15 -0
- package/dist/worker/public-observation.d.ts.map +1 -0
- package/dist/worker/public-observation.js +111 -0
- package/dist/worker/public-observation.js.map +1 -0
- package/dist/worker/server-identity.d.ts +2 -0
- package/dist/worker/server-identity.d.ts.map +1 -0
- package/dist/worker/server-identity.js +2 -0
- package/dist/worker/server-identity.js.map +1 -0
- package/dist/worker/session-sync.d.ts +27 -0
- package/dist/worker/session-sync.d.ts.map +1 -0
- package/dist/worker/session-sync.js +4 -0
- package/dist/worker/session-sync.js.map +1 -0
- package/dist/worker/session.d.ts +144 -0
- package/dist/worker/session.d.ts.map +1 -0
- package/dist/worker/session.js +408 -0
- package/dist/worker/session.js.map +1 -0
- package/dist/worker/storage-test-admin.d.ts +3 -0
- package/dist/worker/storage-test-admin.d.ts.map +1 -0
- package/dist/worker/storage-test-admin.js +277 -0
- package/dist/worker/storage-test-admin.js.map +1 -0
- package/dist/worker/test-admin.d.ts +11 -0
- package/dist/worker/test-admin.d.ts.map +1 -0
- package/dist/worker/test-admin.js +432 -0
- package/dist/worker/test-admin.js.map +1 -0
- package/dist/worker/testing.d.ts +14 -0
- package/dist/worker/testing.d.ts.map +1 -0
- package/dist/worker/testing.js +71 -0
- package/dist/worker/testing.js.map +1 -0
- package/dist/workerEntry.d.ts +2 -0
- package/dist/workerEntry.d.ts.map +1 -0
- package/dist/workerEntry.js +10 -0
- package/dist/workerEntry.js.map +1 -0
- package/dist/writes.d.ts +8 -0
- package/dist/writes.d.ts.map +1 -0
- package/dist/writes.js +11 -0
- package/dist/writes.js.map +1 -0
- package/package.json +104 -4
|
@@ -0,0 +1,1029 @@
|
|
|
1
|
+
import { Index, ValueTag, valueKey, } from "./datom.js";
|
|
2
|
+
import { Db } from "./db.js";
|
|
3
|
+
import { ENGINE_TYPE_ASSERTION, } from "./tx-provenance.js";
|
|
4
|
+
import { DB_CARDINALITY, DB_IDENT, DB_TX_INSTANT, DB_UNIQUE, DB_VALUE_TYPE, RAMOSE_TYPE_IDENT, VALUE_TYPE_IDENTS, isTxEid, txEid, } from "./schema.js";
|
|
5
|
+
export class TxError extends Error {
|
|
6
|
+
code;
|
|
7
|
+
constructor(msg, code = "tx/invalid") {
|
|
8
|
+
super(msg);
|
|
9
|
+
this.code = code;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export const GENERATED_TEMPID_PREFIX = "__ramose.tmp/";
|
|
13
|
+
const TX_TEMPID = new Set([":db/tx", "datomic.tx", "db.tx"]);
|
|
14
|
+
export function flattenTxData(txData) {
|
|
15
|
+
const ops = [];
|
|
16
|
+
let tmpCounter = 0;
|
|
17
|
+
const freshTempid = () => `${GENERATED_TEMPID_PREFIX}${++tmpCounter}`;
|
|
18
|
+
const expandMap = (m) => {
|
|
19
|
+
const engineTypeAssertion = m[ENGINE_TYPE_ASSERTION] === true;
|
|
20
|
+
let e = m[":db/id"];
|
|
21
|
+
if (e === undefined || e === null)
|
|
22
|
+
e = freshTempid();
|
|
23
|
+
for (const [k, val] of Object.entries(m)) {
|
|
24
|
+
if (k === ":db/id")
|
|
25
|
+
continue;
|
|
26
|
+
if (typeof k !== "string" || k[0] !== ":")
|
|
27
|
+
throw new TxError(`bad attribute key ${k}`);
|
|
28
|
+
const slash = k.lastIndexOf("/");
|
|
29
|
+
const name = slash >= 0 ? k.slice(slash + 1) : k.slice(1);
|
|
30
|
+
if (name.startsWith("_")) {
|
|
31
|
+
const attr = slash >= 0 ? k.slice(0, slash + 1) + name.slice(1) : ":" + name.slice(1);
|
|
32
|
+
const vals = Array.isArray(val) ? val : [val];
|
|
33
|
+
for (const x of vals) {
|
|
34
|
+
const other = isPlainObject(x) ? expandMap(x) : x;
|
|
35
|
+
ops.push({ kind: "add", e: other, a: attr, v: e, hasV: true });
|
|
36
|
+
}
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
const vals = Array.isArray(val) && !isLookupRef(val) ? val : [val];
|
|
40
|
+
for (const x of vals) {
|
|
41
|
+
const v = isPlainObject(x) ? expandMap(x) : x;
|
|
42
|
+
ops.push({
|
|
43
|
+
kind: "add",
|
|
44
|
+
e,
|
|
45
|
+
a: k,
|
|
46
|
+
v,
|
|
47
|
+
hasV: true,
|
|
48
|
+
...(engineTypeAssertion && k === RAMOSE_TYPE_IDENT
|
|
49
|
+
? { engineTypeAssertion: true }
|
|
50
|
+
: {}),
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return e;
|
|
55
|
+
};
|
|
56
|
+
for (const item of txData) {
|
|
57
|
+
if (Array.isArray(item)) {
|
|
58
|
+
const [op, e, a, v] = item;
|
|
59
|
+
switch (op) {
|
|
60
|
+
case ":db/add":
|
|
61
|
+
if (item.length !== 4)
|
|
62
|
+
throw new TxError(":db/add needs [op e a v]");
|
|
63
|
+
ops.push({ kind: "add", e: e, a: a, v: isPlainObject(v) ? expandMap(v) : v, hasV: true });
|
|
64
|
+
break;
|
|
65
|
+
case ":db/update":
|
|
66
|
+
if (item.length === 2) {
|
|
67
|
+
ops.push({ kind: "update", e: e, hasV: false });
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
if (item.length !== 4)
|
|
71
|
+
throw new TxError(":db/update needs [op e a v]");
|
|
72
|
+
{
|
|
73
|
+
const vals = Array.isArray(v) && !isLookupRef(v) ? v : [v];
|
|
74
|
+
for (const x of vals) {
|
|
75
|
+
ops.push({
|
|
76
|
+
kind: "update",
|
|
77
|
+
e: e,
|
|
78
|
+
a: a,
|
|
79
|
+
v: isPlainObject(x) ? expandMap(x) : x,
|
|
80
|
+
hasV: true,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
break;
|
|
85
|
+
case ":db/retract":
|
|
86
|
+
if (item.length !== 3 && item.length !== 4)
|
|
87
|
+
throw new TxError(":db/retract needs [op e a v?]");
|
|
88
|
+
ops.push({ kind: "retract", e: e, a: a, v, hasV: item.length === 4 });
|
|
89
|
+
break;
|
|
90
|
+
case ":db/retractEntity":
|
|
91
|
+
case ":db.fn/retractEntity":
|
|
92
|
+
ops.push({ kind: "retractEntity", e: e });
|
|
93
|
+
break;
|
|
94
|
+
case ":db/cas":
|
|
95
|
+
if (item.length !== 5)
|
|
96
|
+
throw new TxError(":db/cas needs [op e a expected replacement]");
|
|
97
|
+
{
|
|
98
|
+
const expected = item[3];
|
|
99
|
+
const replacement = item[4];
|
|
100
|
+
ops.push({
|
|
101
|
+
kind: "cas",
|
|
102
|
+
e: e,
|
|
103
|
+
a: a,
|
|
104
|
+
v: isPlainObject(replacement) ? expandMap(replacement) : replacement,
|
|
105
|
+
expected,
|
|
106
|
+
hasV: true,
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
break;
|
|
110
|
+
default:
|
|
111
|
+
throw new TxError(`unknown tx op ${String(op)}`);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
else if (isPlainObject(item)) {
|
|
115
|
+
expandMap(item);
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
throw new TxError(`bad tx item ${String(item)}`);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return ops;
|
|
122
|
+
}
|
|
123
|
+
function isPlainObject(x) {
|
|
124
|
+
return (typeof x === "object" &&
|
|
125
|
+
x !== null &&
|
|
126
|
+
!Array.isArray(x) &&
|
|
127
|
+
!(x instanceof Date) &&
|
|
128
|
+
!(x instanceof Uint8Array) &&
|
|
129
|
+
!("vt" in x && "v" in x && Object.keys(x).length === 2));
|
|
130
|
+
}
|
|
131
|
+
function isLookupRef(x) {
|
|
132
|
+
return Array.isArray(x) && x.length === 2 && typeof x[0] === "string" && x[0][0] === ":";
|
|
133
|
+
}
|
|
134
|
+
function isTempid(x) {
|
|
135
|
+
return typeof x === "string" && x[0] !== ":";
|
|
136
|
+
}
|
|
137
|
+
export async function processTx(db, txData, t, nextEid, txInstant, options) {
|
|
138
|
+
const { ops: _ops, newEntities: _ne, ...res } = await expandTx(db, txData, t, nextEid, txInstant, options);
|
|
139
|
+
return res;
|
|
140
|
+
}
|
|
141
|
+
export async function expandTx(db, txData, t, nextEid, txInstant, options = {}) {
|
|
142
|
+
const ops = flattenTxData(txData);
|
|
143
|
+
const txe = txEid(t);
|
|
144
|
+
const tempids = new Map();
|
|
145
|
+
const claims = new Map();
|
|
146
|
+
const uniqueSeen = new Map();
|
|
147
|
+
const out = [];
|
|
148
|
+
const expanded = [];
|
|
149
|
+
const newEntities = new Set([txe]);
|
|
150
|
+
const closureCap = options.closureCap ?? Number.POSITIVE_INFINITY;
|
|
151
|
+
let closureCount = 0;
|
|
152
|
+
let inRetractEntity = false;
|
|
153
|
+
let retractEntityRoot;
|
|
154
|
+
const record = (kind, e, attr, d, implicit = false, engineTypeAssertion = false) => {
|
|
155
|
+
expanded.push({
|
|
156
|
+
kind,
|
|
157
|
+
e,
|
|
158
|
+
a: attr.id,
|
|
159
|
+
attr,
|
|
160
|
+
datom: d,
|
|
161
|
+
implicit,
|
|
162
|
+
fromRetractEntity: inRetractEntity,
|
|
163
|
+
retractEntityRoot: inRetractEntity && e === retractEntityRoot,
|
|
164
|
+
engineTypeAssertion,
|
|
165
|
+
});
|
|
166
|
+
if (inRetractEntity && ++closureCount > closureCap) {
|
|
167
|
+
throw new TxError(`:db/retractEntity closure exceeds ${closureCap} datoms`, "tx/closure-cap");
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
const attrOf = (a) => {
|
|
171
|
+
if (a === undefined)
|
|
172
|
+
throw new TxError("missing attribute");
|
|
173
|
+
const at = db.attr(a);
|
|
174
|
+
if (!at)
|
|
175
|
+
throw new TxError(`unknown attribute ${String(a)}`, "tx/unknown-attribute");
|
|
176
|
+
return at;
|
|
177
|
+
};
|
|
178
|
+
const newIdents = new Map();
|
|
179
|
+
for (const op of ops) {
|
|
180
|
+
if (op.kind === "add" && op.a === ":db/ident" && typeof op.v === "string")
|
|
181
|
+
newIdents.set(op.v, op.e);
|
|
182
|
+
}
|
|
183
|
+
const lookupEntid = async (form) => {
|
|
184
|
+
try {
|
|
185
|
+
return await db.entid(form);
|
|
186
|
+
}
|
|
187
|
+
catch (err) {
|
|
188
|
+
if (err instanceof TxError)
|
|
189
|
+
throw err;
|
|
190
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
191
|
+
const code = /unknown attribute|is not unique|bad entity reference/i.test(msg)
|
|
192
|
+
? "tx/lookup-ref"
|
|
193
|
+
: "tx/invalid";
|
|
194
|
+
throw new TxError(msg.includes("lookup") ? msg : `lookup ref ${JSON.stringify(form)}: ${msg}`, code);
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
const resolveEntity = async (form, allocate) => {
|
|
198
|
+
if (typeof form === "number") {
|
|
199
|
+
if (!Number.isSafeInteger(form) || form < 0)
|
|
200
|
+
throw new TxError(`bad entity id ${form}`);
|
|
201
|
+
return form;
|
|
202
|
+
}
|
|
203
|
+
if (typeof form === "string") {
|
|
204
|
+
if (TX_TEMPID.has(form))
|
|
205
|
+
return txe;
|
|
206
|
+
if (form[0] === ":") {
|
|
207
|
+
const id = db.schema.entid(form);
|
|
208
|
+
if (id !== undefined)
|
|
209
|
+
return id;
|
|
210
|
+
const created = newIdents.get(form);
|
|
211
|
+
if (created !== undefined && created !== form)
|
|
212
|
+
return resolveEntity(created, true);
|
|
213
|
+
throw new TxError(`unknown ident ${form}`, "tx/unknown-ident");
|
|
214
|
+
}
|
|
215
|
+
const canonical = aliasOf(form);
|
|
216
|
+
const known = tempids.get(canonical);
|
|
217
|
+
if (known !== undefined) {
|
|
218
|
+
if (canonical !== form)
|
|
219
|
+
tempids.set(form, known);
|
|
220
|
+
return known;
|
|
221
|
+
}
|
|
222
|
+
if (!allocate)
|
|
223
|
+
return undefined;
|
|
224
|
+
const id = nextEid++;
|
|
225
|
+
newEntities.add(id);
|
|
226
|
+
tempids.set(canonical, id);
|
|
227
|
+
if (canonical !== form)
|
|
228
|
+
tempids.set(form, id);
|
|
229
|
+
return id;
|
|
230
|
+
}
|
|
231
|
+
if (isLookupRef(form)) {
|
|
232
|
+
const id = await lookupEntid(form);
|
|
233
|
+
if (id !== undefined)
|
|
234
|
+
return id;
|
|
235
|
+
const sameTx = resolveLookupInTx(form);
|
|
236
|
+
if (sameTx !== undefined)
|
|
237
|
+
return sameTx;
|
|
238
|
+
throw new TxError(`lookup ref ${JSON.stringify(form)} does not resolve`, "tx/lookup-ref");
|
|
239
|
+
}
|
|
240
|
+
if (form !== null && typeof form === "object" && "vt" in form && form.vt === ValueTag.Ref) {
|
|
241
|
+
return form.v;
|
|
242
|
+
}
|
|
243
|
+
throw new TxError(`bad entity form ${JSON.stringify(form)}`);
|
|
244
|
+
};
|
|
245
|
+
const resolveEntityPreflight = async (form) => {
|
|
246
|
+
if (isLookupRef(form))
|
|
247
|
+
return lookupEntid(form);
|
|
248
|
+
return resolveEntity(form, false);
|
|
249
|
+
};
|
|
250
|
+
const aliases = new Map();
|
|
251
|
+
const aliasOf = (tid) => {
|
|
252
|
+
let cur = tid;
|
|
253
|
+
for (;;) {
|
|
254
|
+
const next = aliases.get(cur);
|
|
255
|
+
if (next === undefined || next === cur)
|
|
256
|
+
return cur;
|
|
257
|
+
cur = next;
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
const resolveLookupInTx = (form) => {
|
|
261
|
+
let attr;
|
|
262
|
+
try {
|
|
263
|
+
attr = attrOf(form[0]);
|
|
264
|
+
}
|
|
265
|
+
catch {
|
|
266
|
+
return undefined;
|
|
267
|
+
}
|
|
268
|
+
if (!attr.unique)
|
|
269
|
+
return undefined;
|
|
270
|
+
let tv;
|
|
271
|
+
try {
|
|
272
|
+
tv =
|
|
273
|
+
attr.valueType === ValueTag.Ref && typeof form[1] === "string" && form[1][0] === ":"
|
|
274
|
+
? { vt: ValueTag.Ref, v: db.schema.entid(form[1]) }
|
|
275
|
+
: db.coerce(attr, form[1]);
|
|
276
|
+
}
|
|
277
|
+
catch {
|
|
278
|
+
return undefined;
|
|
279
|
+
}
|
|
280
|
+
if (tv.v === undefined)
|
|
281
|
+
return undefined;
|
|
282
|
+
const uk = attr.id + "|" + valueKey(tv.vt, tv.v);
|
|
283
|
+
const seen = uniqueSeen.get(uk);
|
|
284
|
+
if (seen !== undefined)
|
|
285
|
+
return seen;
|
|
286
|
+
const claimant = claims.get(uk);
|
|
287
|
+
if (claimant === undefined)
|
|
288
|
+
return undefined;
|
|
289
|
+
return tempids.get(aliasOf(claimant));
|
|
290
|
+
};
|
|
291
|
+
for (const op of ops) {
|
|
292
|
+
if (op.kind !== "add" || !isTempid(op.e) || TX_TEMPID.has(op.e))
|
|
293
|
+
continue;
|
|
294
|
+
const attr = attrOf(op.a);
|
|
295
|
+
if (attr.unique !== "identity")
|
|
296
|
+
continue;
|
|
297
|
+
if (attr.valueType === ValueTag.Ref && (isTempid(op.v) || isLookupRef(op.v) || isPlainObject(op.v)))
|
|
298
|
+
continue;
|
|
299
|
+
let tv;
|
|
300
|
+
try {
|
|
301
|
+
tv = attr.valueType === ValueTag.Ref && typeof op.v === "string" && op.v[0] === ":"
|
|
302
|
+
? { vt: ValueTag.Ref, v: db.schema.entid(op.v) }
|
|
303
|
+
: db.coerce(attr, op.v);
|
|
304
|
+
}
|
|
305
|
+
catch {
|
|
306
|
+
continue;
|
|
307
|
+
}
|
|
308
|
+
if (tv.v === undefined)
|
|
309
|
+
continue;
|
|
310
|
+
const claimKey = attr.id + "|" + valueKey(tv.vt, tv.v);
|
|
311
|
+
const existing = await db.first(Index.AVET, { a: attr.id, vt: tv.vt, v: tv.v });
|
|
312
|
+
const canonical = aliasOf(op.e);
|
|
313
|
+
if (existing) {
|
|
314
|
+
const prev = tempids.get(canonical);
|
|
315
|
+
if (prev !== undefined && prev !== existing.e) {
|
|
316
|
+
throw new TxError(`tempid ${op.e} resolves to two entities (${prev}, ${existing.e})`, "tx/unique-conflict");
|
|
317
|
+
}
|
|
318
|
+
tempids.set(canonical, existing.e);
|
|
319
|
+
}
|
|
320
|
+
const claimant = claims.get(claimKey);
|
|
321
|
+
if (claimant === undefined)
|
|
322
|
+
claims.set(claimKey, canonical);
|
|
323
|
+
else if (aliasOf(claimant) !== canonical) {
|
|
324
|
+
const target = aliasOf(claimant);
|
|
325
|
+
const a = tempids.get(canonical), b = tempids.get(target);
|
|
326
|
+
if (a !== undefined && b !== undefined && a !== b) {
|
|
327
|
+
throw new TxError(`tempids ${op.e} and ${claimant} resolve to different entities`, "tx/unique-conflict");
|
|
328
|
+
}
|
|
329
|
+
aliases.set(canonical, target);
|
|
330
|
+
if (a !== undefined && b === undefined)
|
|
331
|
+
tempids.set(target, a);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
const cur = new Map();
|
|
335
|
+
const current = async (e, a) => {
|
|
336
|
+
const k = e + ":" + a;
|
|
337
|
+
let m = cur.get(k);
|
|
338
|
+
if (m)
|
|
339
|
+
return m;
|
|
340
|
+
m = new Map();
|
|
341
|
+
for (const d of await db.datomsArray(Index.EAVT, { e, a }))
|
|
342
|
+
m.set(valueKey(d.vt, d.v), d);
|
|
343
|
+
cur.set(k, m);
|
|
344
|
+
return m;
|
|
345
|
+
};
|
|
346
|
+
const casFacts = new Set();
|
|
347
|
+
const casFactKey = (e, a, vt, v) => e + ":" + a + ":" + valueKey(vt, v);
|
|
348
|
+
const rejectIfCasFact = (e, a, vt, v) => {
|
|
349
|
+
if (casFacts.has(casFactKey(e, a, vt, v))) {
|
|
350
|
+
throw new TxError("cannot retract a :db/cas assertion in the same transaction");
|
|
351
|
+
}
|
|
352
|
+
};
|
|
353
|
+
const emitAdd = async (e, attr, tv, engineTypeAssertion = false) => {
|
|
354
|
+
const vals = await current(e, attr.id);
|
|
355
|
+
const vk = valueKey(tv.vt, tv.v);
|
|
356
|
+
if (vals.has(vk)) {
|
|
357
|
+
if (attr.ident === RAMOSE_TYPE_IDENT) {
|
|
358
|
+
record("add", e, attr, { e, a: attr.id, vt: tv.vt, v: tv.v, t, op: true }, false, engineTypeAssertion);
|
|
359
|
+
}
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
if (attr.unique) {
|
|
363
|
+
const uk = attr.id + "|" + vk;
|
|
364
|
+
const seen = uniqueSeen.get(uk);
|
|
365
|
+
if (seen !== undefined && seen !== e) {
|
|
366
|
+
throw new TxError(`unique conflict: ${attr.ident} ${String(tv.v)} already asserted for ${seen}`, "tx/unique-conflict");
|
|
367
|
+
}
|
|
368
|
+
const other = await db.first(Index.AVET, { a: attr.id, vt: tv.vt, v: tv.v });
|
|
369
|
+
if (other && other.e !== e) {
|
|
370
|
+
const ov = await current(other.e, attr.id);
|
|
371
|
+
if (ov.has(vk)) {
|
|
372
|
+
throw new TxError(`unique conflict: ${attr.ident} ${String(tv.v)} already belongs to entity ${other.e}`, "tx/unique-conflict");
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
uniqueSeen.set(uk, e);
|
|
376
|
+
}
|
|
377
|
+
if (attr.cardinality === "one" && vals.size > 0) {
|
|
378
|
+
for (const [ok, od] of vals) {
|
|
379
|
+
rejectIfCasFact(e, attr.id, od.vt, od.v);
|
|
380
|
+
const r = { e, a: attr.id, vt: od.vt, v: od.v, t, op: false };
|
|
381
|
+
out.push(r);
|
|
382
|
+
record("retract", e, attr, r, true);
|
|
383
|
+
vals.delete(ok);
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
const d = { e, a: attr.id, vt: tv.vt, v: tv.v, t, op: true };
|
|
387
|
+
out.push(d);
|
|
388
|
+
record("add", e, attr, d, false, engineTypeAssertion);
|
|
389
|
+
vals.set(vk, d);
|
|
390
|
+
};
|
|
391
|
+
const emitRetract = async (e, attr, tv) => {
|
|
392
|
+
const vals = await current(e, attr.id);
|
|
393
|
+
if (tv === undefined) {
|
|
394
|
+
for (const [k, d] of vals) {
|
|
395
|
+
rejectIfCasFact(e, attr.id, d.vt, d.v);
|
|
396
|
+
const r = { e, a: attr.id, vt: d.vt, v: d.v, t, op: false };
|
|
397
|
+
out.push(r);
|
|
398
|
+
record("retract", e, attr, r);
|
|
399
|
+
vals.delete(k);
|
|
400
|
+
}
|
|
401
|
+
return;
|
|
402
|
+
}
|
|
403
|
+
const vk = valueKey(tv.vt, tv.v);
|
|
404
|
+
const d = vals.get(vk);
|
|
405
|
+
if (!d)
|
|
406
|
+
return;
|
|
407
|
+
rejectIfCasFact(e, attr.id, tv.vt, tv.v);
|
|
408
|
+
const r = { e, a: attr.id, vt: d.vt, v: d.v, t, op: false };
|
|
409
|
+
out.push(r);
|
|
410
|
+
record("retract", e, attr, r);
|
|
411
|
+
vals.delete(vk);
|
|
412
|
+
};
|
|
413
|
+
const casReplacementEids = new Set();
|
|
414
|
+
const casReplacementTempids = new Set();
|
|
415
|
+
const isCasReplacementEid = (e) => {
|
|
416
|
+
if (casReplacementEids.has(e))
|
|
417
|
+
return true;
|
|
418
|
+
for (const tid of casReplacementTempids) {
|
|
419
|
+
if (tempids.get(aliasOf(tid)) === e)
|
|
420
|
+
return true;
|
|
421
|
+
}
|
|
422
|
+
return false;
|
|
423
|
+
};
|
|
424
|
+
const retracted = new Set();
|
|
425
|
+
const retractEntity = async (e) => {
|
|
426
|
+
if (retracted.has(e))
|
|
427
|
+
return;
|
|
428
|
+
if (isCasReplacementEid(e)) {
|
|
429
|
+
throw new TxError("cannot :db/retractEntity a :db/cas replacement in the same transaction");
|
|
430
|
+
}
|
|
431
|
+
retracted.add(e);
|
|
432
|
+
const own = await db.datomsArray(Index.EAVT, { e });
|
|
433
|
+
for (const d of own) {
|
|
434
|
+
const attr = db.attr(d.a);
|
|
435
|
+
await emitRetract(e, attr ?? { id: d.a }, { vt: d.vt, v: d.v });
|
|
436
|
+
if (attr?.isComponent && d.vt === ValueTag.Ref)
|
|
437
|
+
await retractEntity(d.v);
|
|
438
|
+
}
|
|
439
|
+
const incoming = await db.datomsArray(Index.VAET, { vt: ValueTag.Ref, v: e });
|
|
440
|
+
for (const d of incoming) {
|
|
441
|
+
const attr = db.attr(d.a);
|
|
442
|
+
if (attr)
|
|
443
|
+
await emitRetract(d.e, attr, { vt: d.vt, v: d.v });
|
|
444
|
+
}
|
|
445
|
+
for (const [k, m] of cur) {
|
|
446
|
+
const [ee, aa] = k.split(":").map(Number);
|
|
447
|
+
const attr = db.attr(aa);
|
|
448
|
+
if (attr && attr.valueType === ValueTag.Ref) {
|
|
449
|
+
for (const [, d] of [...m]) {
|
|
450
|
+
if (d.v === e && d.t === t) {
|
|
451
|
+
await emitRetract(ee, attr, { vt: d.vt, v: d.v });
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
};
|
|
457
|
+
const subjectTempids = new Set();
|
|
458
|
+
for (const op of ops) {
|
|
459
|
+
if (op.kind !== "add" && op.kind !== "update")
|
|
460
|
+
continue;
|
|
461
|
+
if (isTempid(op.e) && !TX_TEMPID.has(op.e)) {
|
|
462
|
+
subjectTempids.add(aliasOf(op.e));
|
|
463
|
+
subjectTempids.add(op.e);
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
const valueFor = async (attr, v, bindRef = false) => {
|
|
467
|
+
if (v === undefined || v === null)
|
|
468
|
+
throw new TxError(`nil value for ${attr.ident}`);
|
|
469
|
+
if (attr.valueType === ValueTag.Ref) {
|
|
470
|
+
if (typeof v === "number") {
|
|
471
|
+
if (!Number.isSafeInteger(v) || v < 0)
|
|
472
|
+
throw new TxError(`bad entity id ${v}`);
|
|
473
|
+
if (bindRef && !(await entityPresent(v))) {
|
|
474
|
+
throw new TxError(`entity ${v} does not exist`, "tx/missing-entity");
|
|
475
|
+
}
|
|
476
|
+
return { vt: ValueTag.Ref, v };
|
|
477
|
+
}
|
|
478
|
+
const allocate = bindRef && isTempid(v) && subjectTempids.has(aliasOf(v));
|
|
479
|
+
const id = await resolveEntity(v, allocate);
|
|
480
|
+
if (id === undefined) {
|
|
481
|
+
throw new TxError(`cannot resolve ref value ${JSON.stringify(v)} for ${attr.ident}`, "tx/missing-entity");
|
|
482
|
+
}
|
|
483
|
+
if (bindRef && !(await entityPresent(id))) {
|
|
484
|
+
throw new TxError(`entity ${id} does not exist`, "tx/missing-entity");
|
|
485
|
+
}
|
|
486
|
+
return { vt: ValueTag.Ref, v: id };
|
|
487
|
+
}
|
|
488
|
+
try {
|
|
489
|
+
return db.coerce(attr, v);
|
|
490
|
+
}
|
|
491
|
+
catch (err) {
|
|
492
|
+
throw new TxError(`${attr.ident}: ${err.message}`, "tx/type-mismatch");
|
|
493
|
+
}
|
|
494
|
+
};
|
|
495
|
+
const validateSchemaValue = (attr, tv) => {
|
|
496
|
+
if (attr.id === DB_VALUE_TYPE && !(String(tv.v) in VALUE_TYPE_IDENTS)) {
|
|
497
|
+
throw new TxError(`invalid :db/valueType ${String(tv.v)}`, "tx/schema");
|
|
498
|
+
}
|
|
499
|
+
if (attr.id === DB_CARDINALITY && tv.v !== ":db.cardinality/one" && tv.v !== ":db.cardinality/many") {
|
|
500
|
+
throw new TxError(`invalid :db/cardinality ${String(tv.v)}`, "tx/schema");
|
|
501
|
+
}
|
|
502
|
+
if (attr.id === DB_UNIQUE && tv.v !== ":db.unique/identity" && tv.v !== ":db.unique/value") {
|
|
503
|
+
throw new TxError(`invalid :db/unique ${String(tv.v)}`, "tx/schema");
|
|
504
|
+
}
|
|
505
|
+
if (attr.id === DB_IDENT && (typeof tv.v !== "string" || tv.v[0] !== ":")) {
|
|
506
|
+
throw new TxError(`:db/ident must be a keyword-like string starting with ':'`, "tx/schema");
|
|
507
|
+
}
|
|
508
|
+
if (attr.ident === RAMOSE_TYPE_IDENT && (typeof tv.v !== "string" || tv.v[0] !== ":")) {
|
|
509
|
+
throw new TxError(`${attr.ident} must be a keyword-like string starting with ':'`, "tx/schema");
|
|
510
|
+
}
|
|
511
|
+
};
|
|
512
|
+
const nsOfIdent = (ident) => {
|
|
513
|
+
const slash = ident.indexOf("/", 1);
|
|
514
|
+
return slash > 0 ? ident.slice(1, slash) : "";
|
|
515
|
+
};
|
|
516
|
+
const nsOfComposer = (ident) => {
|
|
517
|
+
const ns = nsOfIdent(ident);
|
|
518
|
+
if (ns.length > 0)
|
|
519
|
+
return ns;
|
|
520
|
+
return ident.startsWith(":") ? ident.slice(1) : ident;
|
|
521
|
+
};
|
|
522
|
+
const composition = options.composition;
|
|
523
|
+
const isEntityIdent = (ident) => composition !== undefined && composition.isEntityIdent(ident);
|
|
524
|
+
const isTraitIdent = (ident) => composition !== undefined && composition.isTraitIdent(ident);
|
|
525
|
+
const transitiveTraits = (ident) => composition?.transitiveTraits(ident) ?? [];
|
|
526
|
+
const isCanonicalTypeIdent = (value) => typeof value === "string" &&
|
|
527
|
+
value.startsWith(":") &&
|
|
528
|
+
value.length > 1 &&
|
|
529
|
+
!value.slice(1).includes("/");
|
|
530
|
+
const isSystemIdent = (ident) => ident.startsWith(":db/") || ident.startsWith(":ramose/");
|
|
531
|
+
const isMembershipIdent = (ident) => ident === RAMOSE_TYPE_IDENT;
|
|
532
|
+
const appNamespacesOf = (idents) => {
|
|
533
|
+
const nss = new Set();
|
|
534
|
+
for (const ident of idents) {
|
|
535
|
+
if (isSystemIdent(ident))
|
|
536
|
+
continue;
|
|
537
|
+
const ns = nsOfIdent(ident);
|
|
538
|
+
if (ns.length === 0)
|
|
539
|
+
continue;
|
|
540
|
+
if (isTraitIdent(`:${ns}`))
|
|
541
|
+
continue;
|
|
542
|
+
nss.add(ns);
|
|
543
|
+
}
|
|
544
|
+
return nss;
|
|
545
|
+
};
|
|
546
|
+
const presentIdents = async (e) => {
|
|
547
|
+
const idents = [];
|
|
548
|
+
const seen = new Set();
|
|
549
|
+
const add = (ident) => {
|
|
550
|
+
if (ident === undefined || seen.has(ident))
|
|
551
|
+
return;
|
|
552
|
+
seen.add(ident);
|
|
553
|
+
idents.push(ident);
|
|
554
|
+
};
|
|
555
|
+
for (const [k, m] of cur) {
|
|
556
|
+
if (!k.startsWith(e + ":") || m.size === 0)
|
|
557
|
+
continue;
|
|
558
|
+
const a = Number(k.slice(String(e).length + 1));
|
|
559
|
+
add(db.attr(a)?.ident);
|
|
560
|
+
}
|
|
561
|
+
if ((await db.exists(e)) && !retracted.has(e)) {
|
|
562
|
+
const row = await db.entity(e);
|
|
563
|
+
if (row !== undefined) {
|
|
564
|
+
for (const key of Object.keys(row)) {
|
|
565
|
+
if (key !== ":db/id")
|
|
566
|
+
add(key);
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
return idents;
|
|
571
|
+
};
|
|
572
|
+
const entityPresent = async (e) => {
|
|
573
|
+
if (retracted.has(e))
|
|
574
|
+
return false;
|
|
575
|
+
if (newEntities.has(e))
|
|
576
|
+
return true;
|
|
577
|
+
for (const [k, m] of cur) {
|
|
578
|
+
if (k.startsWith(e + ":") && m.size > 0)
|
|
579
|
+
return true;
|
|
580
|
+
}
|
|
581
|
+
return db.exists(e);
|
|
582
|
+
};
|
|
583
|
+
const dbAppNamespaces = async (e) => {
|
|
584
|
+
if (!(await db.exists(e)) || retracted.has(e))
|
|
585
|
+
return new Set();
|
|
586
|
+
const row = await db.entity(e);
|
|
587
|
+
if (row === undefined)
|
|
588
|
+
return new Set();
|
|
589
|
+
return appNamespacesOf(Object.keys(row).filter((k) => k !== ":db/id"));
|
|
590
|
+
};
|
|
591
|
+
const typeAttr = () => db.attr(RAMOSE_TYPE_IDENT);
|
|
592
|
+
const readType = async (e) => {
|
|
593
|
+
const attr = typeAttr();
|
|
594
|
+
if (attr === undefined)
|
|
595
|
+
return undefined;
|
|
596
|
+
const vals = await current(e, attr.id);
|
|
597
|
+
if (vals.size === 0)
|
|
598
|
+
return undefined;
|
|
599
|
+
const first = vals.values().next().value;
|
|
600
|
+
return typeof first?.v === "string" ? first.v : undefined;
|
|
601
|
+
};
|
|
602
|
+
const assertWriteTarget = async (e, attr, preTx) => {
|
|
603
|
+
if (!(await entityPresent(e))) {
|
|
604
|
+
throw new TxError(`entity ${e} does not exist`, "tx/missing-entity");
|
|
605
|
+
}
|
|
606
|
+
const ns = nsOfIdent(attr.ident);
|
|
607
|
+
if (ns.length === 0 || isSystemIdent(attr.ident))
|
|
608
|
+
return;
|
|
609
|
+
const existing = preTx
|
|
610
|
+
? await dbAppNamespaces(e)
|
|
611
|
+
: appNamespacesOf(await presentIdents(e));
|
|
612
|
+
if (existing.size === 0)
|
|
613
|
+
return;
|
|
614
|
+
if (existing.has(ns))
|
|
615
|
+
return;
|
|
616
|
+
const allowed = new Set(existing);
|
|
617
|
+
for (const entityNs of existing) {
|
|
618
|
+
for (const trait of transitiveTraits(`:${entityNs}`)) {
|
|
619
|
+
allowed.add(nsOfComposer(trait));
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
const typeIdent = await readType(e);
|
|
623
|
+
if (typeIdent !== undefined) {
|
|
624
|
+
allowed.add(nsOfComposer(typeIdent));
|
|
625
|
+
for (const trait of transitiveTraits(typeIdent)) {
|
|
626
|
+
allowed.add(nsOfComposer(trait));
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
if (!allowed.has(ns)) {
|
|
630
|
+
throw new TxError(`entity ${e} is not a ${ns}`, "tx/wrong-entity");
|
|
631
|
+
}
|
|
632
|
+
};
|
|
633
|
+
const resolveCasSubject = async (form) => {
|
|
634
|
+
if (typeof form === "string" && (TX_TEMPID.has(form) || isTempid(form))) {
|
|
635
|
+
throw new TxError(":db/cas subject must be an existing eid or lookup ref");
|
|
636
|
+
}
|
|
637
|
+
if (isLookupRef(form)) {
|
|
638
|
+
const id = await lookupEntid(form);
|
|
639
|
+
if (id === undefined) {
|
|
640
|
+
throw new TxError(`lookup ref ${JSON.stringify(form)} does not resolve`, "tx/lookup-ref");
|
|
641
|
+
}
|
|
642
|
+
return id;
|
|
643
|
+
}
|
|
644
|
+
const e = await resolveEntity(form, false);
|
|
645
|
+
if (e === undefined) {
|
|
646
|
+
throw new TxError(":db/cas subject must be an existing eid or lookup ref");
|
|
647
|
+
}
|
|
648
|
+
if (!(await db.exists(e))) {
|
|
649
|
+
throw new TxError(`entity ${e} does not exist`, "tx/missing-entity");
|
|
650
|
+
}
|
|
651
|
+
return e;
|
|
652
|
+
};
|
|
653
|
+
const rememberCasReplacement = async (v) => {
|
|
654
|
+
if (v === undefined || v === null)
|
|
655
|
+
return;
|
|
656
|
+
if (isTempid(v) && !TX_TEMPID.has(v)) {
|
|
657
|
+
casReplacementTempids.add(v);
|
|
658
|
+
casReplacementTempids.add(aliasOf(v));
|
|
659
|
+
const known = tempids.get(aliasOf(v));
|
|
660
|
+
if (known !== undefined)
|
|
661
|
+
casReplacementEids.add(known);
|
|
662
|
+
return;
|
|
663
|
+
}
|
|
664
|
+
if (typeof v === "number") {
|
|
665
|
+
if (!Number.isSafeInteger(v) || v < 0)
|
|
666
|
+
throw new TxError(`bad entity id ${v}`);
|
|
667
|
+
casReplacementEids.add(v);
|
|
668
|
+
return;
|
|
669
|
+
}
|
|
670
|
+
if (typeof v === "string" && v[0] === ":") {
|
|
671
|
+
const id = db.schema.entid(v);
|
|
672
|
+
if (id !== undefined)
|
|
673
|
+
casReplacementEids.add(id);
|
|
674
|
+
return;
|
|
675
|
+
}
|
|
676
|
+
if (isLookupRef(v)) {
|
|
677
|
+
const id = await lookupEntid(v);
|
|
678
|
+
if (id !== undefined)
|
|
679
|
+
casReplacementEids.add(id);
|
|
680
|
+
return;
|
|
681
|
+
}
|
|
682
|
+
if (v !== null && typeof v === "object" && "vt" in v && v.vt === ValueTag.Ref) {
|
|
683
|
+
casReplacementEids.add(v.v);
|
|
684
|
+
}
|
|
685
|
+
};
|
|
686
|
+
const casPairs = new Set();
|
|
687
|
+
const casSubjects = new Set();
|
|
688
|
+
const pairKey = (e, a) => e + ":" + a;
|
|
689
|
+
const rejectIfCasPair = (kind, e, attr) => {
|
|
690
|
+
if (casPairs.has(pairKey(e, attr.id))) {
|
|
691
|
+
throw new TxError(`cannot ${kind} the same (${e}, ${attr.ident}) as a :db/cas in the same transaction`);
|
|
692
|
+
}
|
|
693
|
+
};
|
|
694
|
+
for (const op of ops) {
|
|
695
|
+
if (op.kind !== "cas")
|
|
696
|
+
continue;
|
|
697
|
+
const attr = attrOf(op.a);
|
|
698
|
+
const e = await resolveCasSubject(op.e);
|
|
699
|
+
const k = pairKey(e, attr.id);
|
|
700
|
+
if (casPairs.has(k)) {
|
|
701
|
+
throw new TxError(`:db/cas may mutate (${e}, ${attr.ident}) at most once in a transaction`);
|
|
702
|
+
}
|
|
703
|
+
casPairs.add(k);
|
|
704
|
+
casSubjects.add(e);
|
|
705
|
+
if (attr.valueType === ValueTag.Ref)
|
|
706
|
+
await rememberCasReplacement(op.v);
|
|
707
|
+
}
|
|
708
|
+
if (casPairs.size > 0) {
|
|
709
|
+
for (const op of ops) {
|
|
710
|
+
if (op.kind === "cas")
|
|
711
|
+
continue;
|
|
712
|
+
if (op.kind === "retractEntity") {
|
|
713
|
+
if (isTempid(op.e) && !TX_TEMPID.has(op.e) && casReplacementTempids.has(aliasOf(op.e))) {
|
|
714
|
+
throw new TxError("cannot :db/retractEntity a :db/cas replacement in the same transaction");
|
|
715
|
+
}
|
|
716
|
+
const e = await resolveEntityPreflight(op.e);
|
|
717
|
+
if (e !== undefined && casSubjects.has(e)) {
|
|
718
|
+
throw new TxError("cannot :db/retractEntity a :db/cas subject in the same transaction");
|
|
719
|
+
}
|
|
720
|
+
if (e !== undefined && casReplacementEids.has(e)) {
|
|
721
|
+
throw new TxError("cannot :db/retractEntity a :db/cas replacement in the same transaction");
|
|
722
|
+
}
|
|
723
|
+
continue;
|
|
724
|
+
}
|
|
725
|
+
if (op.a === undefined)
|
|
726
|
+
continue;
|
|
727
|
+
const attr = attrOf(op.a);
|
|
728
|
+
const e = await resolveEntityPreflight(op.e);
|
|
729
|
+
if (e === undefined)
|
|
730
|
+
continue;
|
|
731
|
+
rejectIfCasPair(op.kind, e, attr);
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
for (const op of ops) {
|
|
735
|
+
if (op.kind === "retractEntity") {
|
|
736
|
+
const e = await resolveEntity(op.e, false);
|
|
737
|
+
if (e === undefined)
|
|
738
|
+
continue;
|
|
739
|
+
inRetractEntity = true;
|
|
740
|
+
retractEntityRoot = e;
|
|
741
|
+
try {
|
|
742
|
+
await retractEntity(e);
|
|
743
|
+
}
|
|
744
|
+
finally {
|
|
745
|
+
inRetractEntity = false;
|
|
746
|
+
retractEntityRoot = undefined;
|
|
747
|
+
}
|
|
748
|
+
continue;
|
|
749
|
+
}
|
|
750
|
+
if (op.kind === "update") {
|
|
751
|
+
let e;
|
|
752
|
+
try {
|
|
753
|
+
e = await resolveEntity(op.e, false);
|
|
754
|
+
}
|
|
755
|
+
catch (err) {
|
|
756
|
+
if (err instanceof TxError && err.code === "tx/lookup-ref") {
|
|
757
|
+
throw new TxError(err.message, "tx/missing-entity");
|
|
758
|
+
}
|
|
759
|
+
throw err;
|
|
760
|
+
}
|
|
761
|
+
if (e === undefined) {
|
|
762
|
+
throw new TxError(`entity ${JSON.stringify(op.e)} does not exist`, "tx/missing-entity");
|
|
763
|
+
}
|
|
764
|
+
if (typeof op.e === "number" && !(await entityPresent(e))) {
|
|
765
|
+
throw new TxError(`entity ${e} does not exist`, "tx/missing-entity");
|
|
766
|
+
}
|
|
767
|
+
if (op.a === undefined || op.hasV === false) {
|
|
768
|
+
if (!(await entityPresent(e))) {
|
|
769
|
+
throw new TxError(`entity ${e} does not exist`, "tx/missing-entity");
|
|
770
|
+
}
|
|
771
|
+
continue;
|
|
772
|
+
}
|
|
773
|
+
const attr = attrOf(op.a);
|
|
774
|
+
rejectIfCasPair(op.kind, e, attr);
|
|
775
|
+
await assertWriteTarget(e, attr, false);
|
|
776
|
+
const tv = await valueFor(attr, op.v, true);
|
|
777
|
+
validateSchemaValue(attr, tv);
|
|
778
|
+
await emitAdd(e, attr, tv);
|
|
779
|
+
continue;
|
|
780
|
+
}
|
|
781
|
+
if (op.kind === "cas") {
|
|
782
|
+
if (op.expected === undefined) {
|
|
783
|
+
throw new TxError(":db/cas expected must be a value or null (undefined is not the absent encoding)");
|
|
784
|
+
}
|
|
785
|
+
const attr = attrOf(op.a);
|
|
786
|
+
const e = await resolveCasSubject(op.e);
|
|
787
|
+
if (attr.cardinality !== "one") {
|
|
788
|
+
throw new TxError(`:db/cas is cardinality-one only (${attr.ident})`);
|
|
789
|
+
}
|
|
790
|
+
await assertWriteTarget(e, attr, true);
|
|
791
|
+
const replacementTv = await valueFor(attr, op.v, true);
|
|
792
|
+
validateSchemaValue(attr, replacementTv);
|
|
793
|
+
const before = new Map();
|
|
794
|
+
for (const d of await db.datomsArray(Index.EAVT, { e, a: attr.id })) {
|
|
795
|
+
before.set(valueKey(d.vt, d.v), d);
|
|
796
|
+
}
|
|
797
|
+
let expectedLabel = "absent";
|
|
798
|
+
let match = false;
|
|
799
|
+
if (op.expected === null) {
|
|
800
|
+
match = before.size === 0;
|
|
801
|
+
}
|
|
802
|
+
else {
|
|
803
|
+
const expectedTv = await valueFor(attr, op.expected, false);
|
|
804
|
+
expectedLabel = String(expectedTv.v);
|
|
805
|
+
match = before.size === 1 && before.has(valueKey(expectedTv.vt, expectedTv.v));
|
|
806
|
+
}
|
|
807
|
+
if (!match) {
|
|
808
|
+
const found = before.size === 0
|
|
809
|
+
? "absent"
|
|
810
|
+
: before.size > 1
|
|
811
|
+
? "multiple values"
|
|
812
|
+
: String(before.values().next().value.v);
|
|
813
|
+
throw new TxError(`CAS conflict on ${attr.ident}: expected ${expectedLabel}, found ${found}`, "tx/cas-conflict");
|
|
814
|
+
}
|
|
815
|
+
await emitAdd(e, attr, replacementTv);
|
|
816
|
+
casFacts.add(casFactKey(e, attr.id, replacementTv.vt, replacementTv.v));
|
|
817
|
+
if (attr.valueType === ValueTag.Ref) {
|
|
818
|
+
casReplacementEids.add(replacementTv.v);
|
|
819
|
+
}
|
|
820
|
+
continue;
|
|
821
|
+
}
|
|
822
|
+
const attr = attrOf(op.a);
|
|
823
|
+
const e = await resolveEntity(op.e, op.kind === "add");
|
|
824
|
+
if (e === undefined)
|
|
825
|
+
continue;
|
|
826
|
+
rejectIfCasPair(op.kind, e, attr);
|
|
827
|
+
if (op.kind === "add") {
|
|
828
|
+
await assertWriteTarget(e, attr, true);
|
|
829
|
+
const tv = await valueFor(attr, op.v, true);
|
|
830
|
+
validateSchemaValue(attr, tv);
|
|
831
|
+
await emitAdd(e, attr, tv, op.engineTypeAssertion === true);
|
|
832
|
+
}
|
|
833
|
+
else {
|
|
834
|
+
const tv = op.hasV ? await valueFor(attr, op.v) : undefined;
|
|
835
|
+
await emitRetract(e, attr, tv);
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
const requiredOfNs = (ns) => db.schema.attributes().filter((a) => a.ident.startsWith(`:${ns}/`) &&
|
|
839
|
+
a.cardinality === "one" &&
|
|
840
|
+
!a.optional);
|
|
841
|
+
const requiredOfType = (typeIdent) => {
|
|
842
|
+
const nss = [
|
|
843
|
+
nsOfComposer(typeIdent),
|
|
844
|
+
...transitiveTraits(typeIdent).map(nsOfComposer),
|
|
845
|
+
];
|
|
846
|
+
const out = [];
|
|
847
|
+
const seen = new Set();
|
|
848
|
+
for (const ns of nss) {
|
|
849
|
+
if (ns.length === 0)
|
|
850
|
+
continue;
|
|
851
|
+
for (const attr of requiredOfNs(ns)) {
|
|
852
|
+
if (seen.has(attr.ident))
|
|
853
|
+
continue;
|
|
854
|
+
seen.add(attr.ident);
|
|
855
|
+
out.push(attr);
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
return out;
|
|
859
|
+
};
|
|
860
|
+
const missingRequired = async (e, nss) => {
|
|
861
|
+
const missing = [];
|
|
862
|
+
for (const ns of nss) {
|
|
863
|
+
for (const attr of requiredOfNs(ns)) {
|
|
864
|
+
const vals = await current(e, attr.id);
|
|
865
|
+
if (vals.size === 0)
|
|
866
|
+
missing.push(attr.ident);
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
return missing;
|
|
870
|
+
};
|
|
871
|
+
const missingRequiredAttrs = async (e, attrs) => {
|
|
872
|
+
const missing = [];
|
|
873
|
+
for (const attr of attrs) {
|
|
874
|
+
const vals = await current(e, attr.id);
|
|
875
|
+
if (vals.size === 0)
|
|
876
|
+
missing.push(attr.ident);
|
|
877
|
+
}
|
|
878
|
+
return missing;
|
|
879
|
+
};
|
|
880
|
+
const inferType = async (e) => {
|
|
881
|
+
const nss = appNamespacesOf(await presentIdents(e));
|
|
882
|
+
const entityNss = composition === undefined
|
|
883
|
+
? [...nss]
|
|
884
|
+
: [...nss].filter((ns) => isEntityIdent(`:${ns}`));
|
|
885
|
+
if (entityNss.length > 1) {
|
|
886
|
+
throw new TxError(`cannot create an entity in multiple composed types: ${[...entityNss]
|
|
887
|
+
.sort()
|
|
888
|
+
.map((n) => `:${n}`)
|
|
889
|
+
.join(", ")}`, "tx/wrong-entity");
|
|
890
|
+
}
|
|
891
|
+
const asserted = await readType(e);
|
|
892
|
+
if (asserted !== undefined) {
|
|
893
|
+
if (composition !== undefined && !isEntityIdent(asserted)) {
|
|
894
|
+
throw new TxError(`unknown entity type ${asserted}`, "tx/wrong-entity");
|
|
895
|
+
}
|
|
896
|
+
return asserted;
|
|
897
|
+
}
|
|
898
|
+
if (entityNss.length === 1)
|
|
899
|
+
return `:${entityNss[0]}`;
|
|
900
|
+
return undefined;
|
|
901
|
+
};
|
|
902
|
+
const touched = new Set();
|
|
903
|
+
for (const op of expanded) {
|
|
904
|
+
if (op.kind !== "add" || isTxEid(op.e))
|
|
905
|
+
continue;
|
|
906
|
+
touched.add(op.e);
|
|
907
|
+
}
|
|
908
|
+
for (const op of expanded) {
|
|
909
|
+
if (!isMembershipIdent(op.attr.ident))
|
|
910
|
+
continue;
|
|
911
|
+
if (op.fromRetractEntity)
|
|
912
|
+
continue;
|
|
913
|
+
const typeBefore = op.kind === "add" && op.attr.ident === RAMOSE_TYPE_IDENT
|
|
914
|
+
? await (async () => {
|
|
915
|
+
const row = await db.entity(op.e);
|
|
916
|
+
const value = row?.[RAMOSE_TYPE_IDENT];
|
|
917
|
+
return typeof value === "string" ? value : undefined;
|
|
918
|
+
})()
|
|
919
|
+
: undefined;
|
|
920
|
+
if (op.kind === "add" &&
|
|
921
|
+
op.attr.ident === RAMOSE_TYPE_IDENT &&
|
|
922
|
+
op.engineTypeAssertion &&
|
|
923
|
+
isCanonicalTypeIdent(op.datom.v) &&
|
|
924
|
+
(newEntities.has(op.e) || typeBefore === op.datom.v) &&
|
|
925
|
+
(composition === undefined || isEntityIdent(op.datom.v))) {
|
|
926
|
+
continue;
|
|
927
|
+
}
|
|
928
|
+
throw new TxError(op.kind === "retract"
|
|
929
|
+
? `cannot retract system fact ${op.attr.ident}`
|
|
930
|
+
: `cannot write system fact ${op.attr.ident}`, "tx/system");
|
|
931
|
+
}
|
|
932
|
+
for (const e of touched) {
|
|
933
|
+
if (retracted.has(e) || isTxEid(e))
|
|
934
|
+
continue;
|
|
935
|
+
const typeBefore = await (async () => {
|
|
936
|
+
if (!(await db.exists(e)) || retracted.has(e))
|
|
937
|
+
return undefined;
|
|
938
|
+
const attr = typeAttr();
|
|
939
|
+
if (attr === undefined)
|
|
940
|
+
return undefined;
|
|
941
|
+
const row = await db.entity(e);
|
|
942
|
+
const v = row?.[RAMOSE_TYPE_IDENT];
|
|
943
|
+
return typeof v === "string" ? v : undefined;
|
|
944
|
+
})();
|
|
945
|
+
const type = await inferType(e);
|
|
946
|
+
const traitNss = new Set();
|
|
947
|
+
for (const ident of await presentIdents(e)) {
|
|
948
|
+
if (isSystemIdent(ident))
|
|
949
|
+
continue;
|
|
950
|
+
const ns = nsOfIdent(ident);
|
|
951
|
+
if (ns.length > 0 && isTraitIdent(`:${ns}`))
|
|
952
|
+
traitNss.add(ns);
|
|
953
|
+
}
|
|
954
|
+
if (type === undefined && typeBefore === undefined) {
|
|
955
|
+
if (traitNss.size > 0) {
|
|
956
|
+
throw new TxError(`cannot create an entity from trait attributes alone: ${[...traitNss]
|
|
957
|
+
.sort()
|
|
958
|
+
.map((n) => `:${n}`)
|
|
959
|
+
.join(", ")}`, "tx/wrong-entity");
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
else if (type !== undefined) {
|
|
963
|
+
const allowed = new Set(transitiveTraits(type).map(nsOfComposer));
|
|
964
|
+
for (const ns of [...traitNss].sort()) {
|
|
965
|
+
if (!allowed.has(ns)) {
|
|
966
|
+
throw new TxError(`entity ${e} is not a ${ns}`, "tx/wrong-entity");
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
if (typeBefore !== undefined) {
|
|
971
|
+
const typeAfter = await readType(e);
|
|
972
|
+
if (typeAfter !== undefined && typeAfter !== typeBefore) {
|
|
973
|
+
throw new TxError(`cannot change system fact ${RAMOSE_TYPE_IDENT}`, "tx/system");
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
else if (type !== undefined && (composition === undefined || isEntityIdent(type))) {
|
|
977
|
+
const ta = typeAttr();
|
|
978
|
+
if (ta !== undefined) {
|
|
979
|
+
await emitAdd(e, ta, { vt: ValueTag.Str, v: type });
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
const before = await dbAppNamespaces(e);
|
|
983
|
+
const after = appNamespacesOf(await presentIdents(e));
|
|
984
|
+
const born = new Set();
|
|
985
|
+
for (const ns of after) {
|
|
986
|
+
if (!before.has(ns))
|
|
987
|
+
born.add(ns);
|
|
988
|
+
}
|
|
989
|
+
const typeIsNew = type !== undefined && typeBefore === undefined;
|
|
990
|
+
if (typeIsNew && (composition === undefined || isEntityIdent(type))) {
|
|
991
|
+
const missing = await missingRequiredAttrs(e, requiredOfType(type));
|
|
992
|
+
if (missing.length > 0) {
|
|
993
|
+
throw new TxError(`entity ${nsOfComposer(type)} is missing required fields: ${missing.join(", ")}`, "tx/required");
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
if (born.size === 0)
|
|
997
|
+
continue;
|
|
998
|
+
const missing = await missingRequired(e, born);
|
|
999
|
+
if (missing.length > 0) {
|
|
1000
|
+
const entity = [...born][0] ?? "entity";
|
|
1001
|
+
throw new TxError(`entity ${entity} is missing required fields: ${missing.join(", ")}`, "tx/required");
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
1004
|
+
for (const op of expanded) {
|
|
1005
|
+
if (op.kind !== "retract" || op.implicit)
|
|
1006
|
+
continue;
|
|
1007
|
+
if (op.attr.cardinality !== "one" || op.attr.optional)
|
|
1008
|
+
continue;
|
|
1009
|
+
if (op.attr.ident.startsWith(":db/"))
|
|
1010
|
+
continue;
|
|
1011
|
+
if (retracted.has(op.e) || isTxEid(op.e))
|
|
1012
|
+
continue;
|
|
1013
|
+
const vals = await current(op.e, op.attr.id);
|
|
1014
|
+
if (vals.size > 0)
|
|
1015
|
+
continue;
|
|
1016
|
+
const nss = appNamespacesOf(await presentIdents(op.e));
|
|
1017
|
+
if (nss.size === 0)
|
|
1018
|
+
continue;
|
|
1019
|
+
throw new TxError(op.fromRetractEntity
|
|
1020
|
+
? `entity ${op.e} still references the deleted entity via required ${op.attr.ident} — delete or re-point it first`
|
|
1021
|
+
: `cannot clear required field ${op.attr.ident}`, "tx/required");
|
|
1022
|
+
}
|
|
1023
|
+
out.unshift({ e: txe, a: DB_TX_INSTANT, vt: ValueTag.Inst, v: txInstant, t, op: true });
|
|
1024
|
+
const tempidsOut = {};
|
|
1025
|
+
for (const [k, v] of tempids)
|
|
1026
|
+
tempidsOut[k] = v;
|
|
1027
|
+
return { t, txEid: txe, datoms: out, tempids: tempidsOut, nextEid, newEntities, ops: expanded };
|
|
1028
|
+
}
|
|
1029
|
+
//# sourceMappingURL=tx.js.map
|