Skip to main content

Installation

npm install iii-browser-sdk

Initialization

registerWorker

Creates and returns a connected SDK instance. The WebSocket connection is established automatically — there is no separate connect() call. Signature
registerWorker(address: string, options: InitOptions) => ISdk

Parameters

NameTypeRequiredDescription
addressstringYesWebSocket URL of the III engine (e.g. ws://localhost:49135).
optionsInitOptionsYesOptional InitOptions for worker name, timeouts, and reconnection.

Example

import { registerWorker } from 'iii-browser-sdk'

const worker = registerWorker('ws://localhost:49135')

Methods

registerTrigger

Registers a new trigger. A trigger is a way to invoke a function when a certain event occurs. Signature
registerTrigger(trigger: RegisterTriggerInput) => Trigger

Parameters

NameTypeRequiredDescription
triggerRegisterTriggerInputYesThe trigger to register

Example

const trigger = worker.registerTrigger({
  type: 'cron',
  function_id: 'my-service::process-batch',
  config: { expression: '0 */5 * * * * *' },
})

// Later, remove the trigger
trigger.unregister()

registerFunction

Registers a new function with a local handler or an HTTP invocation config. Signature
registerFunction(functionId: string, handler: RemoteFunctionHandler, options: RegisterFunctionOptions) => FunctionRef

Parameters

NameTypeRequiredDescription
functionIdstringYesUnique function identifier
handlerRemoteFunctionHandlerYesAsync handler for local execution, or an HTTP invocation config for external functions (Lambda, Cloudflare Workers, etc.)
optionsRegisterFunctionOptionsYesOptional function registration options (description, request/response formats, metadata)

Example

// Local handler
const ref = worker.registerFunction(
  'greet',
  async (data: { name: string }) => ({ message: `Hello, ${data.name}!` }),
  { description: 'Returns a greeting' },
)

// Later, remove the function
ref.unregister()

trigger

Invokes a function using a request object. Signature
trigger(request: TriggerRequest<TInput>) => Promise<TOutput>

Parameters

NameTypeRequiredDescription
requestTriggerRequest<TInput>YesThe trigger request containing function_id, payload, and optional action/timeout

Example

// Synchronous invocation
const result = await worker.trigger<{ name: string }, { message: string }>({
  function_id: 'greet',
  payload: { name: 'World' },
  timeoutMs: 5000,
})
console.log(result.message) // "Hello, World!"

// Fire-and-forget
await worker.trigger({
  function_id: 'send-email',
  payload: { to: 'user@example.com' },
  action: TriggerAction.Void(),
})

// Enqueue for async processing
const receipt = await worker.trigger({
  function_id: 'process-order',
  payload: { orderId: '123' },
  action: TriggerAction.Enqueue({ queue: 'orders' }),
})

registerTriggerType

Registers a new trigger type. A trigger type is a way to invoke a function when a certain event occurs. Signature
registerTriggerType(triggerType: RegisterTriggerTypeInput, handler: TriggerHandler<TConfig>) => TriggerTypeRef<TConfig>

Parameters

NameTypeRequiredDescription
triggerTypeRegisterTriggerTypeInputYesThe trigger type to register
handlerTriggerHandler<TConfig>YesThe handler for the trigger type

Example

type CronConfig = { expression: string }

worker.registerTriggerType<CronConfig>(
  { id: 'cron', description: 'Fires on a cron schedule' },
  {
    async registerTrigger({ id, function_id, config }) {
      startCronJob(id, config.expression, () =>
        worker.trigger({ function_id, payload: {} }),
      )
    },
    async unregisterTrigger({ id }) {
      stopCronJob(id)
    },
  },
)

unregisterTriggerType

Unregisters a trigger type. Signature
unregisterTriggerType(triggerType: RegisterTriggerTypeInput) => void

Parameters

NameTypeRequiredDescription
triggerTypeRegisterTriggerTypeInputYesThe trigger type to unregister

Example

worker.unregisterTriggerType({ id: 'cron', description: 'Fires on a cron schedule' })

addConnectionStateListener

Subscribe to connection-state transitions. The handler is fired immediately with the current state, then on every transition. Multiple listeners are supported. Returns an unsubscribe function. Signature
addConnectionStateListener(handler: (state: IIIConnectionState) => void) => () => void

Parameters

NameTypeRequiredDescription
handler(state: IIIConnectionState) => voidYes-

Example

const unsub = worker.addConnectionStateListener((state) => {
  console.log('connection state:', state)
})

// Later, stop receiving updates
unsub()

shutdown

Gracefully shutdown the iii, cleaning up all resources. Signature
shutdown() => Promise<void>

Example

await worker.shutdown()

Subpath Exports

The iii-browser-sdk package provides additional entry points:
Import pathContents
iii-browser-sdkApiRequest, ApiResponse, AuthInput, AuthResult, Channel, ChannelReader, ChannelWriter, EngineFunctions, EngineTriggers, EnqueueResult, etc.
iii-browser-sdk/stateDeleteResult, IState, StateDeleteInput, StateDeleteResult, StateEventData, StateEventType, StateGetInput, StateListInput, StateSetInput, StateSetResult, etc.
iii-browser-sdk/streamDeleteResult, IStream, MergePath, StreamAuthInput, StreamAuthResult, StreamChangeEvent, StreamContext, StreamDeleteInput, StreamGetInput, StreamJoinLeaveEvent, etc.

Types

iii-browser-sdk

ApiRequest · ApiResponse · AuthInput · AuthResult · Channel · ChannelReader · ChannelWriter · EnqueueResult · FunctionRef · IIIConnectionState · InitOptions · MessageType · MiddlewareFunctionInput · OnFunctionRegistrationInput · OnFunctionRegistrationResult · OnTriggerRegistrationInput · OnTriggerRegistrationResult · OnTriggerTypeRegistrationInput · OnTriggerTypeRegistrationResult · RegisterFunctionInput · RegisterFunctionMessage · RegisterFunctionOptions · RegisterTriggerInput · RegisterTriggerMessage · RegisterTriggerTypeInput · RegisterTriggerTypeMessage · RemoteFunctionHandler · StreamChannelRef · Trigger · TriggerConfig · TriggerHandler · TriggerRequest · TriggerTypeRef

ApiRequest

Incoming HTTP request received by a function registered with an HTTP trigger.
NameTypeRequiredDescription
bodyTBodyYes-
headersRecord<string, string | string[]>Yes-
methodstringYes-
path_paramsRecord<string, string>Yes-
query_paramsRecord<string, string | string[]>Yes-

ApiResponse

Structured API response returned from HTTP function handlers.
NameTypeRequiredDescription
bodyTBodyNoResponse body.
headersRecord<string, string>NoResponse headers.
status_codeTStatusYesHTTP status code.

AuthInput

Input passed to the RBAC auth function during WebSocket upgrade. Contains the HTTP headers, query parameters, and client IP from the connecting worker’s upgrade request.
NameTypeRequiredDescription
headersRecord<string, string>YesHTTP headers from the WebSocket upgrade request.
ip_addressstringYesIP address of the connecting client.
query_paramsRecord<string, string[]>YesQuery parameters from the upgrade URL. Each key maps to an array of values to support repeated keys.

AuthResult

Return value from the RBAC auth function. Controls which functions the authenticated worker can invoke and what context is forwarded to the middleware.
NameTypeRequiredDescription
allow_function_registrationbooleanNoWhether the worker may register new functions. Defaults to true if omitted.
allow_trigger_type_registrationbooleanNoWhether the worker may register new trigger types. Defaults to false if omitted.
allowed_functionsstring[]NoAdditional function IDs to allow beyond the expose_functions config. Defaults to [] if omitted.
allowed_trigger_typesstring[]NoTrigger type IDs the worker may register triggers for. When omitted, all types are allowed.
contextRecord<string, unknown>NoArbitrary context forwarded to the middleware function on every invocation. Defaults to {} if omitted.
forbidden_functionsstring[]NoFunction IDs to deny even if they match expose_functions. Takes precedence over allowed. Defaults to [] if omitted.
function_registration_prefixstringNoOptional prefix applied to all function IDs registered by this worker.

Channel

A streaming channel pair for worker-to-worker data transfer. Created via the createChannel helper from iii-browser-sdk/helpers.
NameTypeRequiredDescription
readerChannelReaderYesReader end of the channel.
readerRefStreamChannelRefYesSerializable reference to the reader (can be sent to other workers).
writerChannelWriterYesWriter end of the channel.
writerRefStreamChannelRefYesSerializable reference to the writer (can be sent to other workers).

ChannelReader

Read end of a streaming channel. Uses native browser WebSocket.

ChannelWriter

Write end of a streaming channel. Uses native browser WebSocket.

EnqueueResult

Result returned when a function is invoked with TriggerAction.Enqueue.
NameTypeRequiredDescription
messageReceiptIdstringYesUnique receipt ID for the enqueued message.

FunctionRef

Handle returned by ISdk.registerFunction. Contains the function’s id and an unregister() method.
NameTypeRequiredDescription
idstringYesThe unique function identifier.
unregister() => voidYesRemoves this function from the engine.

IIIConnectionState

Connection state for the III WebSocket
type IIIConnectionState = "disconnected" | "connecting" | "connected" | "reconnecting" | "failed"

InitOptions

Configuration options passed to registerWorker.
NameTypeRequiredDescription
headersRecord<string, string>NoCustom headers are not supported by browser WebSocket. Use query parameters or cookies for auth.
invocationTimeoutMsnumberNoDefault timeout for trigger() in milliseconds. Defaults to 30000.
reconnectionConfigPartial<IIIReconnectionConfig>NoWebSocket reconnection behavior.

MessageType

NameTypeRequiredDescription
InvocationResult"invocationresult"Yes-
InvokeFunction"invokefunction"Yes-
RegisterFunction"registerfunction"Yes-
RegisterTrigger"registertrigger"Yes-
RegisterTriggerType"registertriggertype"Yes-
TriggerRegistrationResult"triggerregistrationresult"Yes-
UnregisterFunction"unregisterfunction"Yes-
UnregisterTrigger"unregistertrigger"Yes-
UnregisterTriggerType"unregistertriggertype"Yes-
WorkerRegistered"workerregistered"Yes-

MiddlewareFunctionInput

Input passed to the RBAC middleware function on every function invocation through the RBAC port. The middleware can inspect, modify, or reject the call before it reaches the target function.
NameTypeRequiredDescription
actionTriggerActionNoRouting action, if any.
contextRecord<string, unknown>YesAuth context returned by the auth function for this session.
function_idstringYesID of the function being invoked.
payloadRecord<string, unknown>YesPayload sent by the caller.

OnFunctionRegistrationInput

Input passed to the on_function_registration_function_id hook when a worker attempts to register a function through the RBAC port. Return an OnFunctionRegistrationResult with the (possibly mapped) fields, or throw to deny the registration.
NameTypeRequiredDescription
contextRecord<string, unknown>YesAuth context from AuthResult.context for this session.
descriptionstringNoHuman-readable description of the function.
function_idstringYesID of the function being registered.
metadataRecord<string, unknown>NoArbitrary metadata attached to the function.

OnFunctionRegistrationResult

Result returned from the on_function_registration_function_id hook. All fields are optional — omitted fields keep the original value from the registration request.
NameTypeRequiredDescription
descriptionstringNoMapped description.
function_idstringNoMapped function ID.
metadataRecord<string, unknown>NoMapped metadata.

OnTriggerRegistrationInput

Input passed to the on_trigger_registration_function_id hook when a worker attempts to register a trigger through the RBAC port. Return an OnTriggerRegistrationResult with the (possibly mapped) fields, or throw to deny the registration.
NameTypeRequiredDescription
configunknownYesTrigger-specific configuration.
contextRecord<string, unknown>YesAuth context from AuthResult.context for this session.
function_idstringYesID of the function this trigger is bound to.
trigger_idstringYesID of the trigger being registered.
trigger_typestringYesTrigger type identifier.

OnTriggerRegistrationResult

Result returned from the on_trigger_registration_function_id hook. All fields are optional — omitted fields keep the original value from the registration request.
NameTypeRequiredDescription
configunknownNoMapped trigger configuration.
function_idstringNoMapped function ID.
trigger_idstringNoMapped trigger ID.
trigger_typestringNoMapped trigger type.

OnTriggerTypeRegistrationInput

Input passed to the on_trigger_type_registration_function_id hook when a worker attempts to register a new trigger type through the RBAC port. Return an OnTriggerTypeRegistrationResult with the (possibly mapped) fields, or throw to deny the registration.
NameTypeRequiredDescription
contextRecord<string, unknown>YesAuth context from AuthResult.context for this session.
descriptionstringYesHuman-readable description of the trigger type.
trigger_type_idstringYesID of the trigger type being registered.

OnTriggerTypeRegistrationResult

Result returned from the on_trigger_type_registration_function_id hook. All fields are optional — omitted fields keep the original value from the registration request.
NameTypeRequiredDescription
descriptionstringNoMapped description.
trigger_type_idstringNoMapped trigger type ID.

RegisterFunctionInput

type RegisterFunctionInput = Omit<RegisterFunctionMessage, "message_type">

RegisterFunctionMessage

NameTypeRequiredDescription
descriptionstringNoThe description of the function
idstringYesThe path of the function (use :: for namespacing, e.g. external::my_lambda)
message_typeMessageType.RegisterFunctionYes-
metadataRecord<string, unknown>No-
request_formatRegisterFunctionFormatNoThe request format of the function
response_formatRegisterFunctionFormatNoThe response format of the function

RegisterFunctionOptions

type RegisterFunctionOptions = Omit<RegisterFunctionMessage, "message_type" | "id">

RegisterTriggerInput

type RegisterTriggerInput = Omit<RegisterTriggerMessage, "message_type" | "id">

RegisterTriggerMessage

NameTypeRequiredDescription
configunknownYes-
function_idstringYes-
idstringYes-
message_typeMessageType.RegisterTriggerYes-
typestringYes-

RegisterTriggerTypeInput

type RegisterTriggerTypeInput = Omit<RegisterTriggerTypeMessage, "message_type">

RegisterTriggerTypeMessage

NameTypeRequiredDescription
descriptionstringYes-
idstringYes-
message_typeMessageType.RegisterTriggerTypeYes-

RemoteFunctionHandler

Async function handler for a registered function. Receives the invocation payload and returns the result.
type RemoteFunctionHandler = (data: TInput) => Promise<TOutput>

StreamChannelRef

Serializable reference to one end of a streaming channel. Can be included in invocation payloads to pass channel endpoints between workers.
NameTypeRequiredDescription
access_keystringYesAccess key for authentication.
channel_idstringYesUnique channel identifier.
direction"read" | "write"YesWhether this ref is for reading or writing.

Trigger

Handle returned by ISdk.registerTrigger. Use unregister() to remove the trigger from the engine.
NameTypeRequiredDescription
unregistervoidYesRemoves this trigger from the engine.

TriggerConfig

Configuration passed to a trigger handler when a trigger instance is registered or unregistered.
NameTypeRequiredDescription
configTConfigYesTrigger-specific configuration.
function_idstringYesFunction to invoke when the trigger fires.
idstringYesTrigger instance ID.

TriggerHandler

Handler interface for custom trigger types. Passed to ISdk.registerTriggerType.
NameTypeRequiredDescription
registerTriggerPromise<void>YesCalled when a trigger instance is registered.
unregisterTriggerPromise<void>YesCalled when a trigger instance is unregistered.

TriggerRequest

Request object passed to ISdk.trigger.
NameTypeRequiredDescription
actionTriggerActionNoRouting action. Omit for synchronous request/response.
function_idstringYesID of the function to invoke.
payloadTInputYesPayload to pass to the function.
timeoutMsnumberNoOverride the default invocation timeout in milliseconds.

TriggerTypeRef

Typed handle returned by ISdk.registerTriggerType. Provides convenience methods to register triggers and functions scoped to this trigger type, so callers don’t need to repeat the type field.
NameTypeRequiredDescription
idstringYesThe trigger type identifier.
registerFunctionFunctionRefYesRegister a function and immediately bind it to this trigger type.
registerTriggerTriggerYesRegister a trigger bound to this trigger type.
unregistervoidYesUnregister this trigger type from the engine.

iii-browser-sdk/state

DeleteResult · IState · StateDeleteInput · StateDeleteResult · StateEventData · StateEventType · StateGetInput · StateListInput · StateSetInput · StateSetResult · StateUpdateInput · StateUpdateResult

DeleteResult

Result of a state delete operation.
NameTypeRequiredDescription
old_valueanyNoPrevious value (if it existed).

IState

Interface for state management operations. Available via the iii-sdk/state subpath export.
NameTypeRequiredDescription
deletePromise<DeleteResult>YesDelete a state value.
getPromise<TData | null>YesRetrieve a value by scope and key.
listPromise<TData[]>YesList all values in a scope.
setPromise<StateSetResult<TData> | null>YesSet (create or overwrite) a state value.
updatePromise<StateUpdateResult<TData> | null>YesApply atomic update operations to a state value.

StateDeleteInput

Input for deleting a state value.
NameTypeRequiredDescription
keystringYesKey within the scope.
scopestringYesState scope (namespace).

StateDeleteResult

Result of a state delete operation.
NameTypeRequiredDescription
old_valueanyNoPrevious value (if it existed).

StateEventData

Payload for state change events.
NameTypeRequiredDescription
event_typeStateEventTypeYesType of state change.
keystringYesKey within the scope.
new_valueTDataNoNew value (for create/update events).
old_valueTDataNoPrevious value (for update/delete events).
scopestringYesState scope (namespace).
type"state"Yes-

StateEventType

Types of state change events.
NameTypeRequiredDescription
Created"state:created"Yes-
Deleted"state:deleted"Yes-
Updated"state:updated"Yes-

StateGetInput

Input for retrieving a state value.
NameTypeRequiredDescription
keystringYesKey within the scope.
scopestringYesState scope (namespace).

StateListInput

Input for listing all values in a state scope.
NameTypeRequiredDescription
scopestringYesState scope (namespace).

StateSetInput

Input for setting a state value.
NameTypeRequiredDescription
keystringYesKey within the scope.
scopestringYesState scope (namespace).
valueanyYesValue to store.

StateSetResult

Result of a state set operation.
NameTypeRequiredDescription
new_valueTDataYesNew value that was stored.
old_valueTDataNoPrevious value (if it existed).

StateUpdateInput

Input for atomically updating a state value.
NameTypeRequiredDescription
keystringYesKey within the scope.
opsUpdateOp[]YesOrdered list of update operations to apply atomically.
scopestringYesState scope (namespace).

StateUpdateResult

Result of a state update operation.
NameTypeRequiredDescription
errorsUpdateOpError[]NoPer-op errors. Currently emitted only by the merge op when
input violates validation bounds. Field omitted when empty.
new_valueTDataYesNew value after the update.
old_valueTDataNoPrevious value (if it existed).

iii-browser-sdk/stream

IStream · MergePath · StreamAuthInput · StreamAuthResult · StreamChangeEvent · StreamContext · StreamDeleteInput · StreamGetInput · StreamJoinLeaveEvent · StreamJoinLeaveTriggerConfig · StreamJoinResult · StreamListGroupsInput · StreamListInput · StreamSetInput · StreamSetResult · StreamTriggerConfig · StreamUpdateInput · StreamUpdateResult · UpdateAppend · UpdateDecrement · UpdateIncrement · UpdateMerge · UpdateOp · UpdateOpError · UpdateRemove · UpdateSet

IStream

Interface for custom stream implementations. Passed to ISdk.createStream to override the engine’s built-in stream storage.
NameTypeRequiredDescription
deletePromise<DeleteResult>YesDelete a stream item.
getPromise<TData | null>YesRetrieve a single item by group and item ID.
listPromise<TData[]>YesList all items in a group.
listGroupsPromise<string[]>YesList all group IDs in a stream.
setPromise<StreamSetResult<TData> | null>YesSet (create or overwrite) a stream item.
updatePromise<StreamUpdateResult<TData> | null>YesApply atomic update operations to a stream item.

MergePath

Path target for a UpdateMerge op. Accepts:
  • a single string (legacy / first-level field)
  • an array of literal segments (nested path; each element is one literal key, dots are NOT interpreted as separators)
Omit path, pass "", or pass [] to target the root value.
type MergePath = string | string[]

StreamAuthInput

Input for stream authentication.
NameTypeRequiredDescription
addrstringYesClient address.
headersRecord<string, string>YesRequest headers.
pathstringYesRequest path.
query_paramsRecord<string, string[]>YesQuery parameters.

StreamAuthResult

Result of stream authentication.
NameTypeRequiredDescription
contextanyNoArbitrary context passed to stream handlers after authentication.

StreamChangeEvent

Handler input for stream triggers, fired when an item changes via stream::set, stream::update, or stream::delete.
NameTypeRequiredDescription
event{ data: any; type: "create" | "update" | "delete" }YesThe event detail object containing type and data fields.
groupIdstringYesThe group where the change occurred.
idstringNoThe item ID that changed.
streamNamestringYesThe stream where the change occurred.
timestampnumberYesUnix timestamp of the event.
type"stream"YesThe event type.

StreamContext

Context type extracted from StreamAuthResult.
type StreamContext = StreamAuthResult["context"]

StreamDeleteInput

Input for deleting a stream item.
NameTypeRequiredDescription
group_idstringYesGroup identifier.
item_idstringYesItem identifier.
stream_namestringYesName of the stream.

StreamGetInput

Input for retrieving a single stream item.
NameTypeRequiredDescription
group_idstringYesGroup identifier.
item_idstringYesItem identifier.
stream_namestringYesName of the stream.

StreamJoinLeaveEvent

Event payload for stream join/leave events.
NameTypeRequiredDescription
contextanyNoAuth context from StreamAuthResult.
group_idstringYesGroup identifier.
idstringNoItem identifier (if applicable).
stream_namestringYesName of the stream.
subscription_idstringYesUnique subscription identifier.

StreamJoinLeaveTriggerConfig

Trigger config for stream:join and stream:leave triggers.
NameTypeRequiredDescription
condition_function_idstringNoFunction ID for conditional execution. If it returns false, the handler is skipped.

StreamJoinResult

Result of a stream join request.
NameTypeRequiredDescription
unauthorizedbooleanYesWhether the join was unauthorized.

StreamListGroupsInput

Input for listing all groups in a stream.
NameTypeRequiredDescription
stream_namestringYesName of the stream.

StreamListInput

Input for listing all items in a stream group.
NameTypeRequiredDescription
group_idstringYesGroup identifier.
stream_namestringYesName of the stream.

StreamSetInput

Input for setting a stream item.
NameTypeRequiredDescription
dataanyYesData to store.
group_idstringYesGroup identifier.
item_idstringYesItem identifier.
stream_namestringYesName of the stream.

StreamSetResult

Result of a stream set operation.
NameTypeRequiredDescription
new_valueTDataYesNew value that was stored.
old_valueTDataNoPrevious value (if it existed).

StreamTriggerConfig

Trigger config for stream triggers. Filters which item changes fire the handler.
NameTypeRequiredDescription
condition_function_idstringNoFunction ID for conditional execution. If it returns false, the handler is skipped.
group_idstringNoIf set, only changes within this group fire the handler.
item_idstringNoIf set, only changes to this specific item fire the handler.
stream_namestringYesStream name to watch. Only changes on this stream fire the handler.

StreamUpdateInput

Input for atomically updating a stream item.
NameTypeRequiredDescription
group_idstringYesGroup identifier.
item_idstringYesItem identifier.
opsUpdateOp[]YesOrdered list of update operations to apply atomically.
stream_namestringYesName of the stream.

StreamUpdateResult

Result of a stream update operation.
NameTypeRequiredDescription
errorsUpdateOpError[]NoPer-op errors. Emitted by merge and append for validation
rejections (path/value bounds, proto-pollution segments) and by
append for the append.type_mismatch and
append.target_not_object surfaces. Field omitted when empty.
new_valueTDataYesNew value after the update.
old_valueTDataNoPrevious value (if it existed).

UpdateAppend

Append an element to an array, concatenate a string, or push a new value at a nested path. The target is the root (when path is omitted, empty, or []), a single first-level key (when path is a non-empty string), or an arbitrary nested location (when path is an array of literal segments). See MergePath. Engine semantics: missing/null intermediates along a nested path are auto-created; missing leaves on a nested path always become arrays (no string-concat tier); existing object/scalar leaves return append.type_mismatch. Each path segment is a literal key, ["a.b"] targets a single key named "a.b", not a → b.
NameTypeRequiredDescription
pathMergePathNoOptional path to the append target. Accepts a single first-level
key (legacy string) or an array of literal segments for nested
append. See MergePath (the same shape is reused).
type"append"Yes-
valueanyYesValue to append. String targets only accept string values.

UpdateDecrement

Decrement a numeric field by a given amount.
NameTypeRequiredDescription
bynumberYesAmount to decrement by.
pathstringYesFirst-level field path.
type"decrement"Yes-

UpdateIncrement

Increment a numeric field by a given amount.
NameTypeRequiredDescription
bynumberYesAmount to increment by.
pathstringYesFirst-level field path.
type"increment"Yes-

UpdateMerge

Shallow-merge an object into the target. The target is the root (when path is omitted/empty) or an arbitrary nested location specified by an array of literal segments. See MergePath. Validation: invalid paths/values (depth > 32, segment > 256 bytes, value depth > 16, > 1024 top-level keys, or any __proto__/constructor/prototype segment or top-level key) are rejected with a structured error in the response’s errors array.
NameTypeRequiredDescription
pathMergePathNoOptional path to the merge target. See MergePath.
type"merge"Yes-
valueanyYesObject to merge. Must be a JSON object.

UpdateOp

Union of all atomic update operations supported by streams.
type UpdateOp = UpdateSet | UpdateIncrement | UpdateDecrement | UpdateAppend | UpdateRemove | UpdateMerge

UpdateOpError

Per-op error returned by state::update / stream::update.
NameTypeRequiredDescription
codestringYesStable error code, e.g. "merge.path.too_deep".
doc_urlstringNoOptional documentation URL.
messagestringYesHuman-readable description with concrete numbers when applicable.
op_indexnumberYesIndex of the offending op within the original ops array.

UpdateRemove

Remove a field at the given path.
NameTypeRequiredDescription
pathstringYesFirst-level field path.
type"remove"Yes-

UpdateSet

Set a field at the given path to a value.
NameTypeRequiredDescription
pathstringYesFirst-level field path. Use an empty string to target the root value.
type"set"Yes-
valueanyYesValue to set.