@laserdata/laser-sdk 0.0.1-rc.21 → 0.0.1-rc.22
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/README.md +1 -1
- package/dist/agent/agdx.d.ts +55 -0
- package/dist/agent/agdx.d.ts.map +1 -0
- package/dist/agent/agdx.js +447 -0
- package/dist/agent/agdx.js.map +1 -0
- package/dist/agent/assembler.d.ts +29 -0
- package/dist/agent/assembler.d.ts.map +1 -0
- package/dist/agent/assembler.js +69 -0
- package/dist/agent/assembler.js.map +1 -0
- package/dist/agent/builder.d.ts +114 -0
- package/dist/agent/builder.d.ts.map +1 -0
- package/dist/agent/builder.js +334 -0
- package/dist/agent/builder.js.map +1 -0
- package/dist/agent/context.d.ts +68 -0
- package/dist/agent/context.d.ts.map +1 -0
- package/dist/agent/context.js +212 -0
- package/dist/agent/context.js.map +1 -0
- package/dist/agent/contract.d.ts +70 -0
- package/dist/agent/contract.d.ts.map +1 -0
- package/dist/agent/contract.js +275 -0
- package/dist/agent/contract.js.map +1 -0
- package/dist/agent/registry.d.ts +76 -0
- package/dist/agent/registry.d.ts.map +1 -0
- package/dist/agent/registry.js +286 -0
- package/dist/agent/registry.js.map +1 -0
- package/dist/agent/reliable-consumer.d.ts +126 -0
- package/dist/agent/reliable-consumer.d.ts.map +1 -0
- package/dist/agent/reliable-consumer.js +551 -0
- package/dist/agent/reliable-consumer.js.map +1 -0
- package/dist/agent/replies.d.ts +28 -0
- package/dist/agent/replies.d.ts.map +1 -0
- package/dist/agent/replies.js +175 -0
- package/dist/agent/replies.js.map +1 -0
- package/dist/agent/router.d.ts +72 -0
- package/dist/agent/router.d.ts.map +1 -0
- package/dist/agent/router.js +172 -0
- package/dist/agent/router.js.map +1 -0
- package/dist/agent/scope.d.ts +16 -0
- package/dist/agent/scope.d.ts.map +1 -0
- package/dist/agent/scope.js +34 -0
- package/dist/agent/scope.js.map +1 -0
- package/dist/agent/workflow.d.ts +85 -0
- package/dist/agent/workflow.d.ts.map +1 -0
- package/dist/agent/workflow.js +416 -0
- package/dist/agent/workflow.js.map +1 -0
- package/dist/blob.d.ts +12 -0
- package/dist/blob.d.ts.map +1 -0
- package/dist/blob.js +34 -0
- package/dist/blob.js.map +1 -0
- package/dist/bridges/a2a.d.ts +89 -0
- package/dist/bridges/a2a.d.ts.map +1 -0
- package/dist/bridges/a2a.js +244 -0
- package/dist/bridges/a2a.js.map +1 -0
- package/dist/bridges/agui.d.ts +66 -0
- package/dist/bridges/agui.d.ts.map +1 -0
- package/dist/bridges/agui.js +335 -0
- package/dist/bridges/agui.js.map +1 -0
- package/dist/bridges/edge-auth.d.ts +16 -0
- package/dist/bridges/edge-auth.d.ts.map +1 -0
- package/dist/bridges/edge-auth.js +19 -0
- package/dist/bridges/edge-auth.js.map +1 -0
- package/dist/bridges/hops.d.ts +9 -0
- package/dist/bridges/hops.d.ts.map +1 -0
- package/dist/bridges/hops.js +16 -0
- package/dist/bridges/hops.js.map +1 -0
- package/dist/bridges/mcp.d.ts +79 -0
- package/dist/bridges/mcp.d.ts.map +1 -0
- package/dist/bridges/mcp.js +248 -0
- package/dist/bridges/mcp.js.map +1 -0
- package/dist/client/bytes.d.ts +3 -0
- package/dist/client/bytes.d.ts.map +1 -0
- package/dist/client/bytes.js +9 -0
- package/dist/client/bytes.js.map +1 -0
- package/dist/client/capabilities.d.ts +36 -0
- package/dist/client/capabilities.d.ts.map +1 -0
- package/dist/client/capabilities.js +91 -0
- package/dist/client/capabilities.js.map +1 -0
- package/dist/client/errors.d.ts +178 -0
- package/dist/client/errors.d.ts.map +1 -0
- package/dist/client/errors.js +192 -0
- package/dist/client/errors.js.map +1 -0
- package/dist/client/internals.d.ts +5 -0
- package/dist/client/internals.d.ts.map +1 -0
- package/dist/client/internals.js +5 -0
- package/dist/client/internals.js.map +1 -0
- package/dist/client/laser.d.ts +238 -0
- package/dist/client/laser.d.ts.map +1 -0
- package/dist/client/laser.js +831 -0
- package/dist/client/laser.js.map +1 -0
- package/dist/client/laserdata-ca.d.ts +2 -0
- package/dist/client/laserdata-ca.d.ts.map +1 -0
- package/dist/client/laserdata-ca.js +35 -0
- package/dist/client/laserdata-ca.js.map +1 -0
- package/dist/client/managed.d.ts +6 -0
- package/dist/client/managed.d.ts.map +1 -0
- package/dist/client/managed.js +19 -0
- package/dist/client/managed.js.map +1 -0
- package/dist/context-scope.d.ts +40 -0
- package/dist/context-scope.d.ts.map +1 -0
- package/dist/context-scope.js +73 -0
- package/dist/context-scope.js.map +1 -0
- package/dist/context.d.ts +64 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +149 -0
- package/dist/context.js.map +1 -0
- package/dist/conversation-state.d.ts +24 -0
- package/dist/conversation-state.d.ts.map +1 -0
- package/dist/conversation-state.js +29 -0
- package/dist/conversation-state.js.map +1 -0
- package/dist/crash-context.d.ts +11 -0
- package/dist/crash-context.d.ts.map +1 -0
- package/dist/crash-context.js +62 -0
- package/dist/crash-context.js.map +1 -0
- package/dist/full.d.ts +3 -0
- package/dist/full.d.ts.map +1 -0
- package/dist/full.js +3 -0
- package/dist/full.js.map +1 -0
- package/dist/govern.d.ts +133 -0
- package/dist/govern.d.ts.map +1 -0
- package/dist/govern.js +347 -0
- package/dist/govern.js.map +1 -0
- package/dist/iggy/apache-iggy.d.ts +173 -0
- package/dist/iggy/apache-iggy.d.ts.map +1 -0
- package/dist/iggy/apache-iggy.js +634 -0
- package/dist/iggy/apache-iggy.js.map +1 -0
- package/dist/index.d.ts +121 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +64 -0
- package/dist/index.js.map +1 -0
- package/dist/intent.d.ts +75 -0
- package/dist/intent.d.ts.map +1 -0
- package/dist/intent.js +195 -0
- package/dist/intent.js.map +1 -0
- package/dist/managed/batch.d.ts +5 -0
- package/dist/managed/batch.d.ts.map +1 -0
- package/dist/managed/batch.js +32 -0
- package/dist/managed/batch.js.map +1 -0
- package/dist/managed/forks.d.ts +72 -0
- package/dist/managed/forks.d.ts.map +1 -0
- package/dist/managed/forks.js +188 -0
- package/dist/managed/forks.js.map +1 -0
- package/dist/managed/graph.d.ts +58 -0
- package/dist/managed/graph.d.ts.map +1 -0
- package/dist/managed/graph.js +176 -0
- package/dist/managed/graph.js.map +1 -0
- package/dist/managed/kv.d.ts +144 -0
- package/dist/managed/kv.d.ts.map +1 -0
- package/dist/managed/kv.js +502 -0
- package/dist/managed/kv.js.map +1 -0
- package/dist/managed/projections.d.ts +61 -0
- package/dist/managed/projections.d.ts.map +1 -0
- package/dist/managed/projections.js +191 -0
- package/dist/managed/projections.js.map +1 -0
- package/dist/managed/query.d.ts +72 -0
- package/dist/managed/query.d.ts.map +1 -0
- package/dist/managed/query.js +287 -0
- package/dist/managed/query.js.map +1 -0
- package/dist/managed/rbac.d.ts +16 -0
- package/dist/managed/rbac.d.ts.map +1 -0
- package/dist/managed/rbac.js +82 -0
- package/dist/managed/rbac.js.map +1 -0
- package/dist/managed/runs.d.ts +40 -0
- package/dist/managed/runs.d.ts.map +1 -0
- package/dist/managed/runs.js +112 -0
- package/dist/managed/runs.js.map +1 -0
- package/dist/managed/watch.d.ts +21 -0
- package/dist/managed/watch.d.ts.map +1 -0
- package/dist/managed/watch.js +73 -0
- package/dist/managed/watch.js.map +1 -0
- package/dist/memory/handle.d.ts +77 -0
- package/dist/memory/handle.d.ts.map +1 -0
- package/dist/memory/handle.js +234 -0
- package/dist/memory/handle.js.map +1 -0
- package/dist/memory/log-memory.d.ts +38 -0
- package/dist/memory/log-memory.d.ts.map +1 -0
- package/dist/memory/log-memory.js +309 -0
- package/dist/memory/log-memory.js.map +1 -0
- package/dist/memory/topic.d.ts +22 -0
- package/dist/memory/topic.d.ts.map +1 -0
- package/dist/memory/topic.js +56 -0
- package/dist/memory/topic.js.map +1 -0
- package/dist/memory/types.d.ts +108 -0
- package/dist/memory/types.d.ts.map +1 -0
- package/dist/memory/types.js +127 -0
- package/dist/memory/types.js.map +1 -0
- package/dist/memory/vector-memory.d.ts +20 -0
- package/dist/memory/vector-memory.d.ts.map +1 -0
- package/dist/memory/vector-memory.js +193 -0
- package/dist/memory/vector-memory.js.map +1 -0
- package/dist/memory.d.ts +7 -0
- package/dist/memory.d.ts.map +1 -0
- package/dist/memory.js +6 -0
- package/dist/memory.js.map +1 -0
- package/dist/observe.d.ts +10 -0
- package/dist/observe.d.ts.map +1 -0
- package/dist/observe.js +5 -0
- package/dist/observe.js.map +1 -0
- package/dist/opentelemetry.d.ts +22 -0
- package/dist/opentelemetry.d.ts.map +1 -0
- package/dist/opentelemetry.js +38 -0
- package/dist/opentelemetry.js.map +1 -0
- package/dist/provenance/agent-topic.d.ts +14 -0
- package/dist/provenance/agent-topic.d.ts.map +1 -0
- package/dist/provenance/agent-topic.js +13 -0
- package/dist/provenance/agent-topic.js.map +1 -0
- package/dist/provenance/provenance.d.ts +24 -0
- package/dist/provenance/provenance.d.ts.map +1 -0
- package/dist/provenance/provenance.js +186 -0
- package/dist/provenance/provenance.js.map +1 -0
- package/dist/provenance/session-policy.d.ts +4 -0
- package/dist/provenance/session-policy.d.ts.map +1 -0
- package/dist/provenance/session-policy.js +5 -0
- package/dist/provenance/session-policy.js.map +1 -0
- package/dist/runtime/async-once.d.ts +6 -0
- package/dist/runtime/async-once.d.ts.map +1 -0
- package/dist/runtime/async-once.js +19 -0
- package/dist/runtime/async-once.js.map +1 -0
- package/dist/runtime/clock.d.ts +14 -0
- package/dist/runtime/clock.d.ts.map +1 -0
- package/dist/runtime/clock.js +21 -0
- package/dist/runtime/clock.js.map +1 -0
- package/dist/runtime/mutex.d.ts +5 -0
- package/dist/runtime/mutex.d.ts.map +1 -0
- package/dist/runtime/mutex.js +23 -0
- package/dist/runtime/mutex.js.map +1 -0
- package/dist/runtime/ulid.d.ts +7 -0
- package/dist/runtime/ulid.d.ts.map +1 -0
- package/dist/runtime/ulid.js +17 -0
- package/dist/runtime/ulid.js.map +1 -0
- package/dist/schema-codecs.d.ts +16 -0
- package/dist/schema-codecs.d.ts.map +1 -0
- package/dist/schema-codecs.js +174 -0
- package/dist/schema-codecs.js.map +1 -0
- package/dist/signing.d.ts +63 -0
- package/dist/signing.d.ts.map +1 -0
- package/dist/signing.js +288 -0
- package/dist/signing.js.map +1 -0
- package/dist/snapshot.d.ts +24 -0
- package/dist/snapshot.d.ts.map +1 -0
- package/dist/snapshot.js +80 -0
- package/dist/snapshot.js.map +1 -0
- package/dist/state-store.d.ts +20 -0
- package/dist/state-store.d.ts.map +1 -0
- package/dist/state-store.js +70 -0
- package/dist/state-store.js.map +1 -0
- package/dist/stream/codecs.d.ts +9 -0
- package/dist/stream/codecs.d.ts.map +1 -0
- package/dist/stream/codecs.js +83 -0
- package/dist/stream/codecs.js.map +1 -0
- package/dist/stream/consumer.d.ts +50 -0
- package/dist/stream/consumer.d.ts.map +1 -0
- package/dist/stream/consumer.js +145 -0
- package/dist/stream/consumer.js.map +1 -0
- package/dist/stream/cursor.d.ts +26 -0
- package/dist/stream/cursor.d.ts.map +1 -0
- package/dist/stream/cursor.js +83 -0
- package/dist/stream/cursor.js.map +1 -0
- package/dist/stream/header-value.d.ts +18 -0
- package/dist/stream/header-value.d.ts.map +1 -0
- package/dist/stream/header-value.js +70 -0
- package/dist/stream/header-value.js.map +1 -0
- package/dist/stream/polling-strategy.d.ts +14 -0
- package/dist/stream/polling-strategy.d.ts.map +1 -0
- package/dist/stream/polling-strategy.js +2 -0
- package/dist/stream/polling-strategy.js.map +1 -0
- package/dist/stream/producer.d.ts +44 -0
- package/dist/stream/producer.d.ts.map +1 -0
- package/dist/stream/producer.js +125 -0
- package/dist/stream/producer.js.map +1 -0
- package/dist/stream/publish.d.ts +83 -0
- package/dist/stream/publish.d.ts.map +1 -0
- package/dist/stream/publish.js +287 -0
- package/dist/stream/publish.js.map +1 -0
- package/dist/stream/record.d.ts +29 -0
- package/dist/stream/record.d.ts.map +1 -0
- package/dist/stream/record.js +152 -0
- package/dist/stream/record.js.map +1 -0
- package/dist/stream/routing.d.ts +10 -0
- package/dist/stream/routing.d.ts.map +1 -0
- package/dist/stream/routing.js +2 -0
- package/dist/stream/routing.js.map +1 -0
- package/dist/stream/stream.d.ts +14 -0
- package/dist/stream/stream.d.ts.map +1 -0
- package/dist/stream/stream.js +26 -0
- package/dist/stream/stream.js.map +1 -0
- package/dist/stream/topic.d.ts +52 -0
- package/dist/stream/topic.d.ts.map +1 -0
- package/dist/stream/topic.js +181 -0
- package/dist/stream/topic.js.map +1 -0
- package/dist/stream/typed-topic.d.ts +59 -0
- package/dist/stream/typed-topic.d.ts.map +1 -0
- package/dist/stream/typed-topic.js +119 -0
- package/dist/stream/typed-topic.js.map +1 -0
- package/dist/swarm.d.ts +16 -0
- package/dist/swarm.d.ts.map +1 -0
- package/dist/swarm.js +40 -0
- package/dist/swarm.js.map +1 -0
- package/dist/testing.d.ts +16 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +19 -0
- package/dist/testing.js.map +1 -0
- package/dist/types/ids.d.ts +48 -0
- package/dist/types/ids.d.ts.map +1 -0
- package/dist/types/ids.js +161 -0
- package/dist/types/ids.js.map +1 -0
- package/dist/wire/agent-record.d.ts +24 -0
- package/dist/wire/agent-record.d.ts.map +1 -0
- package/dist/wire/agent-record.js +99 -0
- package/dist/wire/agent-record.js.map +1 -0
- package/dist/wire/agent-workflow.d.ts +118 -0
- package/dist/wire/agent-workflow.d.ts.map +1 -0
- package/dist/wire/agent-workflow.js +290 -0
- package/dist/wire/agent-workflow.js.map +1 -0
- package/dist/wire/agent.d.ts +255 -0
- package/dist/wire/agent.d.ts.map +1 -0
- package/dist/wire/agent.js +792 -0
- package/dist/wire/agent.js.map +1 -0
- package/dist/wire/authz.d.ts +186 -0
- package/dist/wire/authz.d.ts.map +1 -0
- package/dist/wire/authz.js +545 -0
- package/dist/wire/authz.js.map +1 -0
- package/dist/wire/batch.d.ts +17 -0
- package/dist/wire/batch.d.ts.map +1 -0
- package/dist/wire/batch.js +41 -0
- package/dist/wire/batch.js.map +1 -0
- package/dist/wire/browse.d.ts +96 -0
- package/dist/wire/browse.d.ts.map +1 -0
- package/dist/wire/browse.js +201 -0
- package/dist/wire/browse.js.map +1 -0
- package/dist/wire/cbor.d.ts +35 -0
- package/dist/wire/cbor.d.ts.map +1 -0
- package/dist/wire/cbor.js +231 -0
- package/dist/wire/cbor.js.map +1 -0
- package/dist/wire/change.d.ts +12 -0
- package/dist/wire/change.d.ts.map +1 -0
- package/dist/wire/change.js +22 -0
- package/dist/wire/change.js.map +1 -0
- package/dist/wire/clients.d.ts +27 -0
- package/dist/wire/clients.d.ts.map +1 -0
- package/dist/wire/clients.js +64 -0
- package/dist/wire/clients.js.map +1 -0
- package/dist/wire/codes.d.ts +67 -0
- package/dist/wire/codes.d.ts.map +1 -0
- package/dist/wire/codes.js +67 -0
- package/dist/wire/codes.js.map +1 -0
- package/dist/wire/commands.d.ts +68 -0
- package/dist/wire/commands.d.ts.map +1 -0
- package/dist/wire/commands.js +140 -0
- package/dist/wire/commands.js.map +1 -0
- package/dist/wire/content.d.ts +17 -0
- package/dist/wire/content.d.ts.map +1 -0
- package/dist/wire/content.js +47 -0
- package/dist/wire/content.js.map +1 -0
- package/dist/wire/control.d.ts +170 -0
- package/dist/wire/control.d.ts.map +1 -0
- package/dist/wire/control.js +453 -0
- package/dist/wire/control.js.map +1 -0
- package/dist/wire/fork.d.ts +112 -0
- package/dist/wire/fork.d.ts.map +1 -0
- package/dist/wire/fork.js +280 -0
- package/dist/wire/fork.js.map +1 -0
- package/dist/wire/forward.d.ts +23 -0
- package/dist/wire/forward.d.ts.map +1 -0
- package/dist/wire/forward.js +72 -0
- package/dist/wire/forward.js.map +1 -0
- package/dist/wire/graph.d.ts +181 -0
- package/dist/wire/graph.d.ts.map +1 -0
- package/dist/wire/graph.js +554 -0
- package/dist/wire/graph.js.map +1 -0
- package/dist/wire/hashing.d.ts +2 -0
- package/dist/wire/hashing.d.ts.map +1 -0
- package/dist/wire/hashing.js +21 -0
- package/dist/wire/hashing.js.map +1 -0
- package/dist/wire/headers.d.ts +32 -0
- package/dist/wire/headers.d.ts.map +1 -0
- package/dist/wire/headers.js +32 -0
- package/dist/wire/headers.js.map +1 -0
- package/dist/wire/hello.d.ts +50 -0
- package/dist/wire/hello.d.ts.map +1 -0
- package/dist/wire/hello.js +122 -0
- package/dist/wire/hello.js.map +1 -0
- package/dist/wire/http.d.ts +95 -0
- package/dist/wire/http.d.ts.map +1 -0
- package/dist/wire/http.js +282 -0
- package/dist/wire/http.js.map +1 -0
- package/dist/wire/ids.d.ts +50 -0
- package/dist/wire/ids.d.ts.map +1 -0
- package/dist/wire/ids.js +198 -0
- package/dist/wire/ids.js.map +1 -0
- package/dist/wire/index.d.ts +32 -0
- package/dist/wire/index.d.ts.map +1 -0
- package/dist/wire/index.js +32 -0
- package/dist/wire/index.js.map +1 -0
- package/dist/wire/kv.d.ts +260 -0
- package/dist/wire/kv.d.ts.map +1 -0
- package/dist/wire/kv.js +650 -0
- package/dist/wire/kv.js.map +1 -0
- package/dist/wire/limits.d.ts +36 -0
- package/dist/wire/limits.d.ts.map +1 -0
- package/dist/wire/limits.js +36 -0
- package/dist/wire/limits.js.map +1 -0
- package/dist/wire/memory.d.ts +17 -0
- package/dist/wire/memory.d.ts.map +1 -0
- package/dist/wire/memory.js +65 -0
- package/dist/wire/memory.js.map +1 -0
- package/dist/wire/mutation.d.ts +10 -0
- package/dist/wire/mutation.d.ts.map +1 -0
- package/dist/wire/mutation.js +18 -0
- package/dist/wire/mutation.js.map +1 -0
- package/dist/wire/query.d.ts +210 -0
- package/dist/wire/query.d.ts.map +1 -0
- package/dist/wire/query.js +594 -0
- package/dist/wire/query.js.map +1 -0
- package/dist/wire/result.d.ts +25 -0
- package/dist/wire/result.d.ts.map +1 -0
- package/dist/wire/result.js +52 -0
- package/dist/wire/result.js.map +1 -0
- package/dist/wire/snapshot.d.ts +11 -0
- package/dist/wire/snapshot.d.ts.map +1 -0
- package/dist/wire/snapshot.js +50 -0
- package/dist/wire/snapshot.js.map +1 -0
- package/dist/wire/topics.d.ts +5 -0
- package/dist/wire/topics.d.ts.map +1 -0
- package/dist/wire/topics.js +5 -0
- package/dist/wire/topics.js.map +1 -0
- package/dist/wire/topology.d.ts +24 -0
- package/dist/wire/topology.d.ts.map +1 -0
- package/dist/wire/topology.js +56 -0
- package/dist/wire/topology.js.map +1 -0
- package/dist/wire/value.d.ts +21 -0
- package/dist/wire/value.d.ts.map +1 -0
- package/dist/wire/value.js +40 -0
- package/dist/wire/value.js.map +1 -0
- package/package.json +2 -1
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import type { Capabilities } from "../client/capabilities.js";
|
|
2
|
+
import { type ManagedTransport } from "../client/managed.js";
|
|
3
|
+
import type { Codec } from "../stream/codecs.js";
|
|
4
|
+
import { type KvEntry, type KvMetadata, type KvNamespaceInfo, type KvPage } from "../wire/kv.js";
|
|
5
|
+
/** A granted advisory lease with its fencing token and effective TTL. */
|
|
6
|
+
export interface Lease {
|
|
7
|
+
readonly token: bigint;
|
|
8
|
+
readonly grantedTtlMicros: bigint;
|
|
9
|
+
}
|
|
10
|
+
export type KvBackend = ManagedTransport;
|
|
11
|
+
/** A namespace-scoped managed key-value view. */
|
|
12
|
+
export declare class Kv {
|
|
13
|
+
private readonly backend;
|
|
14
|
+
private readonly getCapabilities;
|
|
15
|
+
readonly namespace: string;
|
|
16
|
+
constructor(backend: KvBackend, getCapabilities: () => Promise<Capabilities>, namespace: string);
|
|
17
|
+
static namespaces(backend: KvBackend, getCapabilities: () => Promise<Capabilities>): Promise<readonly KvNamespaceInfo[]>;
|
|
18
|
+
get(key: Uint8Array): Promise<Uint8Array | undefined>;
|
|
19
|
+
getEntry(key: Uint8Array): Promise<KvEntry | undefined>;
|
|
20
|
+
/** Decodes a value with the supplied codec, or returns undefined. */
|
|
21
|
+
getAs<T>(key: Uint8Array, codec: Codec<T>): Promise<T | undefined>;
|
|
22
|
+
getTyped<T>(key: Uint8Array, decodeValue: (value: unknown) => T): Promise<T | undefined>;
|
|
23
|
+
/** Starts a value write or compare-and-swap request. */
|
|
24
|
+
set(key: Uint8Array): KvSetRequest;
|
|
25
|
+
/** Starts a compare-and-swap protected by a lease fencing token. */
|
|
26
|
+
casFenced(key: Uint8Array, fenceKey: Uint8Array, fenceToken: bigint): KvCasFencedRequest;
|
|
27
|
+
delete(key: Uint8Array): Promise<boolean>;
|
|
28
|
+
exists(key: Uint8Array): Promise<KvMetadata | undefined>;
|
|
29
|
+
/** Changes an entry expiry without rewriting its value. */
|
|
30
|
+
expire(key: Uint8Array, expiresAtMicros?: bigint): Promise<bigint>;
|
|
31
|
+
/** Applies a codec-specific merge patch and returns the new version. */
|
|
32
|
+
patch(key: Uint8Array, patch: Uint8Array): Promise<bigint>;
|
|
33
|
+
lease(key: Uint8Array, leaseTtlMicros: bigint): Promise<Lease>;
|
|
34
|
+
release(key: Uint8Array, token: bigint): Promise<boolean>;
|
|
35
|
+
/** Starts an atomic value copy that preserves remaining expiry. */
|
|
36
|
+
copyTo(key: Uint8Array, toKey: Uint8Array): KvCopyRequest;
|
|
37
|
+
moveTo(key: Uint8Array, toKey: Uint8Array): KvCopyRequest;
|
|
38
|
+
/** Reads several keys in one round trip while preserving key order. */
|
|
39
|
+
getMany(keys: readonly Uint8Array[]): Promise<readonly (Uint8Array | undefined)[]>;
|
|
40
|
+
/** Starts a filtered bulk delete. */
|
|
41
|
+
deleteMany(): KvDeleteManyRequest;
|
|
42
|
+
scan(): KvScanRequest;
|
|
43
|
+
}
|
|
44
|
+
/** Builds a value write or compare-and-swap. */
|
|
45
|
+
export declare class KvSetRequest {
|
|
46
|
+
private readonly backend;
|
|
47
|
+
private readonly getCapabilities;
|
|
48
|
+
private readonly namespace;
|
|
49
|
+
private readonly key;
|
|
50
|
+
private value;
|
|
51
|
+
private expiresAtMicros;
|
|
52
|
+
private expect;
|
|
53
|
+
constructor(backend: KvBackend, getCapabilities: () => Promise<Capabilities>, namespace: string, key: Uint8Array);
|
|
54
|
+
bytes(payload: Uint8Array): this;
|
|
55
|
+
encodeWith<T>(codec: Codec<T>, value: T): this;
|
|
56
|
+
json(value: unknown): this;
|
|
57
|
+
expiresAt(epochMicros: bigint): this;
|
|
58
|
+
/** Expires the entry after `ttlMicros`. Pass `nowMicros` for deterministic tests. */
|
|
59
|
+
ttl(ttlMicros: bigint, nowMicros?: bigint): this;
|
|
60
|
+
expectVersion(version: bigint): this;
|
|
61
|
+
expectAbsent(): this;
|
|
62
|
+
send(): Promise<void>;
|
|
63
|
+
/** Commits the configured compare-and-swap and returns its new version. */
|
|
64
|
+
commit(): Promise<bigint>;
|
|
65
|
+
}
|
|
66
|
+
/** Builds a compare-and-swap protected by a lease fencing token. */
|
|
67
|
+
export declare class KvCasFencedRequest {
|
|
68
|
+
private readonly backend;
|
|
69
|
+
private readonly getCapabilities;
|
|
70
|
+
private readonly namespace;
|
|
71
|
+
private readonly key;
|
|
72
|
+
private readonly fenceKey;
|
|
73
|
+
private readonly fenceToken;
|
|
74
|
+
private value;
|
|
75
|
+
private expiresAtMicros;
|
|
76
|
+
private expect;
|
|
77
|
+
constructor(backend: KvBackend, getCapabilities: () => Promise<Capabilities>, namespace: string, key: Uint8Array, fenceKey: Uint8Array, fenceToken: bigint);
|
|
78
|
+
bytes(payload: Uint8Array): this;
|
|
79
|
+
encodeWith<T>(codec: Codec<T>, value: T): this;
|
|
80
|
+
json(value: unknown): this;
|
|
81
|
+
expiresAt(epochMicros: bigint): this;
|
|
82
|
+
/** Expires the entry after `ttlMicros`. Pass `nowMicros` for deterministic tests. */
|
|
83
|
+
ttl(ttlMicros: bigint, nowMicros?: bigint): this;
|
|
84
|
+
expectVersion(version: bigint): this;
|
|
85
|
+
expectAbsent(): this;
|
|
86
|
+
/** Commits the fenced compare-and-swap and returns its new version. */
|
|
87
|
+
commit(): Promise<bigint>;
|
|
88
|
+
}
|
|
89
|
+
/** Builds a paged namespace scan. */
|
|
90
|
+
export declare class KvScanRequest {
|
|
91
|
+
private readonly backend;
|
|
92
|
+
private readonly getCapabilities;
|
|
93
|
+
private readonly namespace;
|
|
94
|
+
private boundPrefix;
|
|
95
|
+
private boundStart;
|
|
96
|
+
private boundEnd;
|
|
97
|
+
private boundKeyContains;
|
|
98
|
+
private boundConversation;
|
|
99
|
+
private pageLimit;
|
|
100
|
+
private pageCursor;
|
|
101
|
+
constructor(backend: KvBackend, getCapabilities: () => Promise<Capabilities>, namespace: string);
|
|
102
|
+
/** Restricts a memory namespace scan to one conversation. */
|
|
103
|
+
conversation(conversationId: string): this;
|
|
104
|
+
prefix(prefix: Uint8Array): this;
|
|
105
|
+
range(start: Uint8Array, end: Uint8Array): this;
|
|
106
|
+
keyContains(substring: string): this;
|
|
107
|
+
limit(n: number): this;
|
|
108
|
+
cursor(cursor: Uint8Array): this;
|
|
109
|
+
fetch(): Promise<KvPage>;
|
|
110
|
+
/** Collects every matching entry across pages. */
|
|
111
|
+
entries(): Promise<readonly KvEntry[]>;
|
|
112
|
+
private request;
|
|
113
|
+
}
|
|
114
|
+
/** Builds a filtered bulk delete. */
|
|
115
|
+
export declare class KvDeleteManyRequest {
|
|
116
|
+
private readonly backend;
|
|
117
|
+
private readonly getCapabilities;
|
|
118
|
+
private readonly namespace;
|
|
119
|
+
private boundPrefix;
|
|
120
|
+
private boundStart;
|
|
121
|
+
private boundEnd;
|
|
122
|
+
private boundKeyContains;
|
|
123
|
+
private boundConversation;
|
|
124
|
+
constructor(backend: KvBackend, getCapabilities: () => Promise<Capabilities>, namespace: string);
|
|
125
|
+
conversation(conversationId: string): this;
|
|
126
|
+
prefix(prefix: Uint8Array): this;
|
|
127
|
+
range(start: Uint8Array, end: Uint8Array): this;
|
|
128
|
+
keyContains(substring: string): this;
|
|
129
|
+
send(): Promise<number>;
|
|
130
|
+
}
|
|
131
|
+
/** Builds an atomic value copy or move. */
|
|
132
|
+
export declare class KvCopyRequest {
|
|
133
|
+
private readonly backend;
|
|
134
|
+
private readonly getCapabilities;
|
|
135
|
+
private readonly namespace;
|
|
136
|
+
private readonly key;
|
|
137
|
+
private readonly toKey;
|
|
138
|
+
private readonly deleteSource;
|
|
139
|
+
private toNamespaceOverride;
|
|
140
|
+
constructor(backend: KvBackend, getCapabilities: () => Promise<Capabilities>, namespace: string, key: Uint8Array, toKey: Uint8Array, deleteSource: boolean);
|
|
141
|
+
intoNamespace(namespace: string): this;
|
|
142
|
+
send(): Promise<bigint>;
|
|
143
|
+
}
|
|
144
|
+
//# sourceMappingURL=kv.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kv.d.ts","sourceRoot":"","sources":["../../src/managed/kv.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAO7D,OAAO,EAAkB,KAAK,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAE5E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAqBhD,OAAO,EAEL,KAAK,OAAO,EACZ,KAAK,UAAU,EACf,KAAK,eAAe,EAEpB,KAAK,MAAM,EAGZ,MAAM,eAAe,CAAA;AAGtB,yEAAyE;AACzE,MAAM,WAAW,KAAK;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAA;CAClC;AAED,MAAM,MAAM,SAAS,GAAG,gBAAgB,CAAA;AAoDxC,iDAAiD;AACjD,qBAAa,EAAE;IAEX,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,eAAe;IAChC,QAAQ,CAAC,SAAS,EAAE,MAAM;IAH5B,YACmB,OAAO,EAAE,SAAS,EAClB,eAAe,EAAE,MAAM,OAAO,CAAC,YAAY,CAAC,EACpD,SAAS,EAAE,MAAM,EACxB;IAEJ,OAAa,UAAU,CACrB,OAAO,EAAE,SAAS,EAClB,eAAe,EAAE,MAAM,OAAO,CAAC,YAAY,CAAC,GAC3C,OAAO,CAAC,SAAS,eAAe,EAAE,C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AAO,CAAC,QAAQ,CAAwB;IACxC,OAAO,CAAC,gBAAgB,CAAoB;IAC5C,OAAO,CAAC,iBAAiB,CAAoB;IAE7C,YACmB,OAAO,EAAE,SAAS,EAClB,eAAe,EAAE,MAAM,OAAO,CAAC,YAAY,CAAC,EAC5C,SAAS,EAAE,MAAM,EAChC;IAEJ,YAAY,CAAC,cAAc,EAAE,MAAM,GAAG,IAAI,CAGzC;IAED,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI,CAG/B;IAED,KAAK,CAAC,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,UAAU,GAAG,IAAI,CAI9C;IAED,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAGnC;IAEK,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,CAkB5B;CACF;AAED,2CAA2C;AAC3C,qBAAa,aAAa;IAItB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,eAAe;IAChC,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,YAAY;IAR/B,OAAO,CAAC,mBAAmB,CAAoB;IAE/C,YACmB,OAAO,EAAE,SAAS,EAClB,eAAe,EAAE,MAAM,OAAO,CAAC,YAAY,CAAC,EAC5C,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,UAAU,EACf,KAAK,EAAE,UAAU,EACjB,YAAY,EAAE,OAAO,EACpC;IAEJ,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAGrC;IAEK,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,CAY5B;CACF"}
|
|
@@ -0,0 +1,502 @@
|
|
|
1
|
+
import { InvalidError, KvExecutionError, ProtocolError, UnsupportedError } from "../client/errors.js";
|
|
2
|
+
import { executeManaged } from "../client/managed.js";
|
|
3
|
+
import { executeBatch } from "./batch.js";
|
|
4
|
+
import { jsonCodec } from "../stream/codecs.js";
|
|
5
|
+
import { KvCasCommand, KvCasFencedCommand, KvCopyCommand, KvDeleteCommand, KvDeleteManyCommand, KvExistsCommand, KvExpireCommand, KvGetCommand, KvLeaseCommand, KvMoveCommand, KvNamespacesCommand, KvPatchCommand, KvReleaseCommand, KvScanCommand, KvSetCommand } from "../wire/commands.js";
|
|
6
|
+
import { validateNamespace } from "../wire/kv.js";
|
|
7
|
+
import { DEFAULT_SCAN_LIMIT, MAX_KEY_BYTES, MAX_VALUE_BYTES } from "../wire/limits.js";
|
|
8
|
+
async function executeKv(backend, capabilities, namespace, command, request) {
|
|
9
|
+
if (namespace !== undefined)
|
|
10
|
+
validateNamespace(namespace);
|
|
11
|
+
const reply = await executeManaged(backend, capabilities, command, request);
|
|
12
|
+
if (reply.kind === "ok")
|
|
13
|
+
return reply.outcome;
|
|
14
|
+
if (reply.kind === "err") {
|
|
15
|
+
if (reply.error.kind === "unsupported")
|
|
16
|
+
throw new UnsupportedError(reply.error.message);
|
|
17
|
+
throw new KvExecutionError(`kv command failed: ${reply.error.kind}`, reply.error);
|
|
18
|
+
}
|
|
19
|
+
throw new ProtocolError(`kv: unrecognized reply variant \`${reply.tag}\``, {
|
|
20
|
+
commandCode: command.code
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
function unexpected(op, outcome) {
|
|
24
|
+
return new ProtocolError(`kv ${op}: unexpected reply outcome \`${outcome.kind}\``);
|
|
25
|
+
}
|
|
26
|
+
function validatedKey(key) {
|
|
27
|
+
if (key.byteLength === 0)
|
|
28
|
+
throw new InvalidError("key must not be empty");
|
|
29
|
+
if (key.byteLength > MAX_KEY_BYTES) {
|
|
30
|
+
throw new InvalidError(`key is ${String(key.byteLength)}B, exceeds cap ${String(MAX_KEY_BYTES)}B`);
|
|
31
|
+
}
|
|
32
|
+
return key;
|
|
33
|
+
}
|
|
34
|
+
function validatedValue(value) {
|
|
35
|
+
if (value.byteLength > MAX_VALUE_BYTES) {
|
|
36
|
+
throw new InvalidError(`value is ${String(value.byteLength)}B, exceeds cap ${String(MAX_VALUE_BYTES)}B`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
async function fetchNamespaces(backend, capabilities) {
|
|
40
|
+
const outcome = await executeKv(backend, capabilities, undefined, KvNamespacesCommand, undefined);
|
|
41
|
+
if (outcome.kind === "namespaces")
|
|
42
|
+
return outcome.namespaces;
|
|
43
|
+
throw unexpected("namespaces", outcome);
|
|
44
|
+
}
|
|
45
|
+
/** A namespace-scoped managed key-value view. */
|
|
46
|
+
export class Kv {
|
|
47
|
+
backend;
|
|
48
|
+
getCapabilities;
|
|
49
|
+
namespace;
|
|
50
|
+
constructor(backend, getCapabilities, namespace) {
|
|
51
|
+
this.backend = backend;
|
|
52
|
+
this.getCapabilities = getCapabilities;
|
|
53
|
+
this.namespace = namespace;
|
|
54
|
+
}
|
|
55
|
+
static async namespaces(backend, getCapabilities) {
|
|
56
|
+
const capabilities = await getCapabilities();
|
|
57
|
+
return fetchNamespaces(backend, capabilities);
|
|
58
|
+
}
|
|
59
|
+
async get(key) {
|
|
60
|
+
const entry = await this.getEntry(key);
|
|
61
|
+
return entry?.value;
|
|
62
|
+
}
|
|
63
|
+
async getEntry(key) {
|
|
64
|
+
const capabilities = await this.getCapabilities();
|
|
65
|
+
const outcome = await executeKv(this.backend, capabilities, this.namespace, KvGetCommand, {
|
|
66
|
+
namespace: this.namespace,
|
|
67
|
+
key: validatedKey(key)
|
|
68
|
+
});
|
|
69
|
+
if (outcome.kind === "value")
|
|
70
|
+
return outcome.entry;
|
|
71
|
+
throw unexpected("get", outcome);
|
|
72
|
+
}
|
|
73
|
+
/** Decodes a value with the supplied codec, or returns undefined. */
|
|
74
|
+
async getAs(key, codec) {
|
|
75
|
+
const value = await this.get(key);
|
|
76
|
+
return value === undefined ? undefined : codec.decode(value);
|
|
77
|
+
}
|
|
78
|
+
async getTyped(key, decodeValue) {
|
|
79
|
+
return this.getAs(key, jsonCodec(decodeValue));
|
|
80
|
+
}
|
|
81
|
+
/** Starts a value write or compare-and-swap request. */
|
|
82
|
+
set(key) {
|
|
83
|
+
return new KvSetRequest(this.backend, this.getCapabilities, this.namespace, validatedKey(key));
|
|
84
|
+
}
|
|
85
|
+
/** Starts a compare-and-swap protected by a lease fencing token. */
|
|
86
|
+
casFenced(key, fenceKey, fenceToken) {
|
|
87
|
+
return new KvCasFencedRequest(this.backend, this.getCapabilities, this.namespace, validatedKey(key), validatedKey(fenceKey), fenceToken);
|
|
88
|
+
}
|
|
89
|
+
async delete(key) {
|
|
90
|
+
const capabilities = await this.getCapabilities();
|
|
91
|
+
const outcome = await executeKv(this.backend, capabilities, this.namespace, KvDeleteCommand, {
|
|
92
|
+
namespace: this.namespace,
|
|
93
|
+
key: validatedKey(key)
|
|
94
|
+
});
|
|
95
|
+
if (outcome.kind === "deleted")
|
|
96
|
+
return outcome.removed;
|
|
97
|
+
throw unexpected("delete", outcome);
|
|
98
|
+
}
|
|
99
|
+
async exists(key) {
|
|
100
|
+
const capabilities = await this.getCapabilities();
|
|
101
|
+
const outcome = await executeKv(this.backend, capabilities, this.namespace, KvExistsCommand, {
|
|
102
|
+
namespace: this.namespace,
|
|
103
|
+
key: validatedKey(key)
|
|
104
|
+
});
|
|
105
|
+
if (outcome.kind === "metadata")
|
|
106
|
+
return outcome.metadata;
|
|
107
|
+
throw unexpected("exists", outcome);
|
|
108
|
+
}
|
|
109
|
+
/** Changes an entry expiry without rewriting its value. */
|
|
110
|
+
async expire(key, expiresAtMicros) {
|
|
111
|
+
const capabilities = await this.getCapabilities();
|
|
112
|
+
const outcome = await executeKv(this.backend, capabilities, this.namespace, KvExpireCommand, {
|
|
113
|
+
namespace: this.namespace,
|
|
114
|
+
key: validatedKey(key),
|
|
115
|
+
...(expiresAtMicros !== undefined ? { expiresAtMicros } : {})
|
|
116
|
+
});
|
|
117
|
+
if (outcome.kind === "versioned")
|
|
118
|
+
return outcome.version;
|
|
119
|
+
throw unexpected("expire", outcome);
|
|
120
|
+
}
|
|
121
|
+
/** Applies a codec-specific merge patch and returns the new version. */
|
|
122
|
+
async patch(key, patch) {
|
|
123
|
+
const capabilities = await this.getCapabilities();
|
|
124
|
+
const outcome = await executeKv(this.backend, capabilities, this.namespace, KvPatchCommand, {
|
|
125
|
+
namespace: this.namespace,
|
|
126
|
+
key: validatedKey(key),
|
|
127
|
+
patch
|
|
128
|
+
});
|
|
129
|
+
if (outcome.kind === "versioned")
|
|
130
|
+
return outcome.version;
|
|
131
|
+
throw unexpected("patch", outcome);
|
|
132
|
+
}
|
|
133
|
+
async lease(key, leaseTtlMicros) {
|
|
134
|
+
const capabilities = await this.getCapabilities();
|
|
135
|
+
const outcome = await executeKv(this.backend, capabilities, this.namespace, KvLeaseCommand, {
|
|
136
|
+
namespace: this.namespace,
|
|
137
|
+
key: validatedKey(key),
|
|
138
|
+
leaseTtlMicros
|
|
139
|
+
});
|
|
140
|
+
if (outcome.kind === "leased") {
|
|
141
|
+
return { token: outcome.leaseToken, grantedTtlMicros: outcome.grantedTtlMicros };
|
|
142
|
+
}
|
|
143
|
+
throw unexpected("lease", outcome);
|
|
144
|
+
}
|
|
145
|
+
async release(key, token) {
|
|
146
|
+
const capabilities = await this.getCapabilities();
|
|
147
|
+
const outcome = await executeKv(this.backend, capabilities, this.namespace, KvReleaseCommand, {
|
|
148
|
+
namespace: this.namespace,
|
|
149
|
+
key: validatedKey(key),
|
|
150
|
+
leaseToken: token
|
|
151
|
+
});
|
|
152
|
+
if (outcome.kind === "released")
|
|
153
|
+
return outcome.wasHeld;
|
|
154
|
+
throw unexpected("release", outcome);
|
|
155
|
+
}
|
|
156
|
+
/** Starts an atomic value copy that preserves remaining expiry. */
|
|
157
|
+
copyTo(key, toKey) {
|
|
158
|
+
return new KvCopyRequest(this.backend, this.getCapabilities, this.namespace, validatedKey(key), validatedKey(toKey), false);
|
|
159
|
+
}
|
|
160
|
+
moveTo(key, toKey) {
|
|
161
|
+
return new KvCopyRequest(this.backend, this.getCapabilities, this.namespace, validatedKey(key), validatedKey(toKey), true);
|
|
162
|
+
}
|
|
163
|
+
/** Reads several keys in one round trip while preserving key order. */
|
|
164
|
+
async getMany(keys) {
|
|
165
|
+
const capabilities = await this.getCapabilities();
|
|
166
|
+
const ops = keys.map((key) => ({
|
|
167
|
+
code: KvGetCommand.code,
|
|
168
|
+
payload: KvGetCommand.encode({ namespace: this.namespace, key: validatedKey(key) })
|
|
169
|
+
}));
|
|
170
|
+
const results = await executeBatch(this.backend, capabilities, ops);
|
|
171
|
+
return results.map((slot) => {
|
|
172
|
+
const reply = KvGetCommand.decode(slot);
|
|
173
|
+
if (reply.kind === "ok" && reply.outcome.kind === "value")
|
|
174
|
+
return reply.outcome.entry?.value;
|
|
175
|
+
if (reply.kind === "ok")
|
|
176
|
+
throw unexpected("get", reply.outcome);
|
|
177
|
+
if (reply.kind === "err") {
|
|
178
|
+
if (reply.error.kind === "unsupported")
|
|
179
|
+
throw new UnsupportedError(reply.error.message);
|
|
180
|
+
throw new KvExecutionError(`kv command failed: ${reply.error.kind}`, reply.error);
|
|
181
|
+
}
|
|
182
|
+
throw new ProtocolError(`kv: unrecognized reply variant in a batch slot \`${reply.tag}\``);
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
/** Starts a filtered bulk delete. */
|
|
186
|
+
deleteMany() {
|
|
187
|
+
return new KvDeleteManyRequest(this.backend, this.getCapabilities, this.namespace);
|
|
188
|
+
}
|
|
189
|
+
scan() {
|
|
190
|
+
return new KvScanRequest(this.backend, this.getCapabilities, this.namespace);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
/** Builds a value write or compare-and-swap. */
|
|
194
|
+
export class KvSetRequest {
|
|
195
|
+
backend;
|
|
196
|
+
getCapabilities;
|
|
197
|
+
namespace;
|
|
198
|
+
key;
|
|
199
|
+
value = new Uint8Array();
|
|
200
|
+
expiresAtMicros;
|
|
201
|
+
expect;
|
|
202
|
+
constructor(backend, getCapabilities, namespace, key) {
|
|
203
|
+
this.backend = backend;
|
|
204
|
+
this.getCapabilities = getCapabilities;
|
|
205
|
+
this.namespace = namespace;
|
|
206
|
+
this.key = key;
|
|
207
|
+
}
|
|
208
|
+
bytes(payload) {
|
|
209
|
+
this.value = payload;
|
|
210
|
+
return this;
|
|
211
|
+
}
|
|
212
|
+
encodeWith(codec, value) {
|
|
213
|
+
this.value = codec.encode(value);
|
|
214
|
+
return this;
|
|
215
|
+
}
|
|
216
|
+
json(value) {
|
|
217
|
+
return this.encodeWith(jsonCodec((decoded) => decoded), value);
|
|
218
|
+
}
|
|
219
|
+
expiresAt(epochMicros) {
|
|
220
|
+
this.expiresAtMicros = epochMicros;
|
|
221
|
+
return this;
|
|
222
|
+
}
|
|
223
|
+
/** Expires the entry after `ttlMicros`. Pass `nowMicros` for deterministic tests. */
|
|
224
|
+
ttl(ttlMicros, nowMicros = BigInt(Date.now()) * 1000n) {
|
|
225
|
+
return this.expiresAt(nowMicros + ttlMicros);
|
|
226
|
+
}
|
|
227
|
+
expectVersion(version) {
|
|
228
|
+
this.expect = { kind: "match", version };
|
|
229
|
+
return this;
|
|
230
|
+
}
|
|
231
|
+
expectAbsent() {
|
|
232
|
+
this.expect = { kind: "absent" };
|
|
233
|
+
return this;
|
|
234
|
+
}
|
|
235
|
+
async send() {
|
|
236
|
+
validatedValue(this.value);
|
|
237
|
+
const capabilities = await this.getCapabilities();
|
|
238
|
+
const outcome = await executeKv(this.backend, capabilities, this.namespace, KvSetCommand, {
|
|
239
|
+
namespace: this.namespace,
|
|
240
|
+
key: this.key,
|
|
241
|
+
value: this.value,
|
|
242
|
+
...(this.expiresAtMicros !== undefined ? { expiresAtMicros: this.expiresAtMicros } : {})
|
|
243
|
+
});
|
|
244
|
+
if (outcome.kind === "written")
|
|
245
|
+
return;
|
|
246
|
+
throw unexpected("set", outcome);
|
|
247
|
+
}
|
|
248
|
+
/** Commits the configured compare-and-swap and returns its new version. */
|
|
249
|
+
async commit() {
|
|
250
|
+
if (this.expect === undefined) {
|
|
251
|
+
throw new InvalidError("commit() needs a precondition: call expectVersion(..) or expectAbsent()");
|
|
252
|
+
}
|
|
253
|
+
const capabilities = await this.getCapabilities();
|
|
254
|
+
if (!capabilities.kv.cas) {
|
|
255
|
+
throw new UnsupportedError("compare-and-swap is not advertised by this deployment");
|
|
256
|
+
}
|
|
257
|
+
validatedValue(this.value);
|
|
258
|
+
const outcome = await executeKv(this.backend, capabilities, this.namespace, KvCasCommand, {
|
|
259
|
+
namespace: this.namespace,
|
|
260
|
+
key: this.key,
|
|
261
|
+
value: this.value,
|
|
262
|
+
expect: this.expect,
|
|
263
|
+
...(this.expiresAtMicros !== undefined ? { expiresAtMicros: this.expiresAtMicros } : {})
|
|
264
|
+
});
|
|
265
|
+
if (outcome.kind === "committed")
|
|
266
|
+
return outcome.version;
|
|
267
|
+
throw unexpected("cas", outcome);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
/** Builds a compare-and-swap protected by a lease fencing token. */
|
|
271
|
+
export class KvCasFencedRequest {
|
|
272
|
+
backend;
|
|
273
|
+
getCapabilities;
|
|
274
|
+
namespace;
|
|
275
|
+
key;
|
|
276
|
+
fenceKey;
|
|
277
|
+
fenceToken;
|
|
278
|
+
value = new Uint8Array();
|
|
279
|
+
expiresAtMicros;
|
|
280
|
+
expect;
|
|
281
|
+
constructor(backend, getCapabilities, namespace, key, fenceKey, fenceToken) {
|
|
282
|
+
this.backend = backend;
|
|
283
|
+
this.getCapabilities = getCapabilities;
|
|
284
|
+
this.namespace = namespace;
|
|
285
|
+
this.key = key;
|
|
286
|
+
this.fenceKey = fenceKey;
|
|
287
|
+
this.fenceToken = fenceToken;
|
|
288
|
+
}
|
|
289
|
+
bytes(payload) {
|
|
290
|
+
this.value = payload;
|
|
291
|
+
return this;
|
|
292
|
+
}
|
|
293
|
+
encodeWith(codec, value) {
|
|
294
|
+
this.value = codec.encode(value);
|
|
295
|
+
return this;
|
|
296
|
+
}
|
|
297
|
+
json(value) {
|
|
298
|
+
return this.encodeWith(jsonCodec((decoded) => decoded), value);
|
|
299
|
+
}
|
|
300
|
+
expiresAt(epochMicros) {
|
|
301
|
+
this.expiresAtMicros = epochMicros;
|
|
302
|
+
return this;
|
|
303
|
+
}
|
|
304
|
+
/** Expires the entry after `ttlMicros`. Pass `nowMicros` for deterministic tests. */
|
|
305
|
+
ttl(ttlMicros, nowMicros = BigInt(Date.now()) * 1000n) {
|
|
306
|
+
return this.expiresAt(nowMicros + ttlMicros);
|
|
307
|
+
}
|
|
308
|
+
expectVersion(version) {
|
|
309
|
+
this.expect = { kind: "match", version };
|
|
310
|
+
return this;
|
|
311
|
+
}
|
|
312
|
+
expectAbsent() {
|
|
313
|
+
this.expect = { kind: "absent" };
|
|
314
|
+
return this;
|
|
315
|
+
}
|
|
316
|
+
/** Commits the fenced compare-and-swap and returns its new version. */
|
|
317
|
+
async commit() {
|
|
318
|
+
if (this.expect === undefined) {
|
|
319
|
+
throw new InvalidError("commit() needs a precondition: call expectVersion(..) or expectAbsent()");
|
|
320
|
+
}
|
|
321
|
+
const capabilities = await this.getCapabilities();
|
|
322
|
+
if (!capabilities.kv.casFenced) {
|
|
323
|
+
throw new UnsupportedError("fenced compare-and-swap is not advertised by this deployment");
|
|
324
|
+
}
|
|
325
|
+
validatedValue(this.value);
|
|
326
|
+
const outcome = await executeKv(this.backend, capabilities, this.namespace, KvCasFencedCommand, {
|
|
327
|
+
namespace: this.namespace,
|
|
328
|
+
key: this.key,
|
|
329
|
+
value: this.value,
|
|
330
|
+
expect: this.expect,
|
|
331
|
+
fenceKey: this.fenceKey,
|
|
332
|
+
fenceToken: this.fenceToken,
|
|
333
|
+
...(this.expiresAtMicros !== undefined ? { expiresAtMicros: this.expiresAtMicros } : {})
|
|
334
|
+
});
|
|
335
|
+
if (outcome.kind === "committed")
|
|
336
|
+
return outcome.version;
|
|
337
|
+
throw unexpected("cas_fenced", outcome);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
/** Builds a paged namespace scan. */
|
|
341
|
+
export class KvScanRequest {
|
|
342
|
+
backend;
|
|
343
|
+
getCapabilities;
|
|
344
|
+
namespace;
|
|
345
|
+
boundPrefix;
|
|
346
|
+
boundStart;
|
|
347
|
+
boundEnd;
|
|
348
|
+
boundKeyContains;
|
|
349
|
+
boundConversation;
|
|
350
|
+
pageLimit = DEFAULT_SCAN_LIMIT;
|
|
351
|
+
pageCursor;
|
|
352
|
+
constructor(backend, getCapabilities, namespace) {
|
|
353
|
+
this.backend = backend;
|
|
354
|
+
this.getCapabilities = getCapabilities;
|
|
355
|
+
this.namespace = namespace;
|
|
356
|
+
}
|
|
357
|
+
/** Restricts a memory namespace scan to one conversation. */
|
|
358
|
+
conversation(conversationId) {
|
|
359
|
+
this.boundConversation = conversationId;
|
|
360
|
+
return this;
|
|
361
|
+
}
|
|
362
|
+
prefix(prefix) {
|
|
363
|
+
this.boundPrefix = prefix;
|
|
364
|
+
return this;
|
|
365
|
+
}
|
|
366
|
+
range(start, end) {
|
|
367
|
+
this.boundStart = start;
|
|
368
|
+
this.boundEnd = end;
|
|
369
|
+
return this;
|
|
370
|
+
}
|
|
371
|
+
keyContains(substring) {
|
|
372
|
+
this.boundKeyContains = substring;
|
|
373
|
+
return this;
|
|
374
|
+
}
|
|
375
|
+
limit(n) {
|
|
376
|
+
this.pageLimit = n;
|
|
377
|
+
return this;
|
|
378
|
+
}
|
|
379
|
+
cursor(cursor) {
|
|
380
|
+
this.pageCursor = cursor;
|
|
381
|
+
return this;
|
|
382
|
+
}
|
|
383
|
+
async fetch() {
|
|
384
|
+
const capabilities = await this.getCapabilities();
|
|
385
|
+
const outcome = await executeKv(this.backend, capabilities, this.namespace, KvScanCommand, this.request());
|
|
386
|
+
if (outcome.kind === "page")
|
|
387
|
+
return outcome.page;
|
|
388
|
+
throw unexpected("scan", outcome);
|
|
389
|
+
}
|
|
390
|
+
/** Collects every matching entry across pages. */
|
|
391
|
+
async entries() {
|
|
392
|
+
const capabilities = await this.getCapabilities();
|
|
393
|
+
const out = [];
|
|
394
|
+
let request = this.request();
|
|
395
|
+
for (;;) {
|
|
396
|
+
const outcome = await executeKv(this.backend, capabilities, this.namespace, KvScanCommand, request);
|
|
397
|
+
if (outcome.kind !== "page")
|
|
398
|
+
throw unexpected("scan", outcome);
|
|
399
|
+
out.push(...outcome.page.entries);
|
|
400
|
+
if (outcome.page.cursor === undefined)
|
|
401
|
+
return out;
|
|
402
|
+
request = { ...request, cursor: outcome.page.cursor };
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
request() {
|
|
406
|
+
return {
|
|
407
|
+
namespace: this.namespace,
|
|
408
|
+
...(this.boundPrefix !== undefined ? { prefix: this.boundPrefix } : {}),
|
|
409
|
+
...(this.boundStart !== undefined ? { start: this.boundStart } : {}),
|
|
410
|
+
...(this.boundEnd !== undefined ? { end: this.boundEnd } : {}),
|
|
411
|
+
...(this.boundKeyContains !== undefined ? { keyContains: this.boundKeyContains } : {}),
|
|
412
|
+
...(this.boundConversation !== undefined ? { conversation: this.boundConversation } : {}),
|
|
413
|
+
limit: this.pageLimit,
|
|
414
|
+
...(this.pageCursor !== undefined ? { cursor: this.pageCursor } : {})
|
|
415
|
+
};
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
/** Builds a filtered bulk delete. */
|
|
419
|
+
export class KvDeleteManyRequest {
|
|
420
|
+
backend;
|
|
421
|
+
getCapabilities;
|
|
422
|
+
namespace;
|
|
423
|
+
boundPrefix;
|
|
424
|
+
boundStart;
|
|
425
|
+
boundEnd;
|
|
426
|
+
boundKeyContains;
|
|
427
|
+
boundConversation;
|
|
428
|
+
constructor(backend, getCapabilities, namespace) {
|
|
429
|
+
this.backend = backend;
|
|
430
|
+
this.getCapabilities = getCapabilities;
|
|
431
|
+
this.namespace = namespace;
|
|
432
|
+
}
|
|
433
|
+
conversation(conversationId) {
|
|
434
|
+
this.boundConversation = conversationId;
|
|
435
|
+
return this;
|
|
436
|
+
}
|
|
437
|
+
prefix(prefix) {
|
|
438
|
+
this.boundPrefix = prefix;
|
|
439
|
+
return this;
|
|
440
|
+
}
|
|
441
|
+
range(start, end) {
|
|
442
|
+
this.boundStart = start;
|
|
443
|
+
this.boundEnd = end;
|
|
444
|
+
return this;
|
|
445
|
+
}
|
|
446
|
+
keyContains(substring) {
|
|
447
|
+
this.boundKeyContains = substring;
|
|
448
|
+
return this;
|
|
449
|
+
}
|
|
450
|
+
async send() {
|
|
451
|
+
const capabilities = await this.getCapabilities();
|
|
452
|
+
const outcome = await executeKv(this.backend, capabilities, this.namespace, KvDeleteManyCommand, {
|
|
453
|
+
namespace: this.namespace,
|
|
454
|
+
...(this.boundPrefix !== undefined ? { prefix: this.boundPrefix } : {}),
|
|
455
|
+
...(this.boundStart !== undefined ? { start: this.boundStart } : {}),
|
|
456
|
+
...(this.boundEnd !== undefined ? { end: this.boundEnd } : {}),
|
|
457
|
+
...(this.boundKeyContains !== undefined ? { keyContains: this.boundKeyContains } : {}),
|
|
458
|
+
...(this.boundConversation !== undefined ? { conversation: this.boundConversation } : {})
|
|
459
|
+
});
|
|
460
|
+
if (outcome.kind === "deletedMany")
|
|
461
|
+
return outcome.count;
|
|
462
|
+
throw unexpected("delete_many", outcome);
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
/** Builds an atomic value copy or move. */
|
|
466
|
+
export class KvCopyRequest {
|
|
467
|
+
backend;
|
|
468
|
+
getCapabilities;
|
|
469
|
+
namespace;
|
|
470
|
+
key;
|
|
471
|
+
toKey;
|
|
472
|
+
deleteSource;
|
|
473
|
+
toNamespaceOverride;
|
|
474
|
+
constructor(backend, getCapabilities, namespace, key, toKey, deleteSource) {
|
|
475
|
+
this.backend = backend;
|
|
476
|
+
this.getCapabilities = getCapabilities;
|
|
477
|
+
this.namespace = namespace;
|
|
478
|
+
this.key = key;
|
|
479
|
+
this.toKey = toKey;
|
|
480
|
+
this.deleteSource = deleteSource;
|
|
481
|
+
}
|
|
482
|
+
intoNamespace(namespace) {
|
|
483
|
+
this.toNamespaceOverride = namespace;
|
|
484
|
+
return this;
|
|
485
|
+
}
|
|
486
|
+
async send() {
|
|
487
|
+
if (this.toNamespaceOverride !== undefined)
|
|
488
|
+
validateNamespace(this.toNamespaceOverride);
|
|
489
|
+
const capabilities = await this.getCapabilities();
|
|
490
|
+
const command = this.deleteSource ? KvMoveCommand : KvCopyCommand;
|
|
491
|
+
const outcome = await executeKv(this.backend, capabilities, this.namespace, command, {
|
|
492
|
+
namespace: this.namespace,
|
|
493
|
+
key: this.key,
|
|
494
|
+
toKey: this.toKey,
|
|
495
|
+
...(this.toNamespaceOverride !== undefined ? { toNamespace: this.toNamespaceOverride } : {})
|
|
496
|
+
});
|
|
497
|
+
if (outcome.kind === "committed")
|
|
498
|
+
return outcome.version;
|
|
499
|
+
throw unexpected(this.deleteSource ? "move" : "copy", outcome);
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
//# sourceMappingURL=kv.js.map
|