Adds a value to the context only if it doesn't already exist.
If the token already has a value, this operation is a no-op. Useful for initializing context values that should only be set once.
Token representing the context key
The value to add
This context instance for method chaining
Puts a value into the context, creating or overwriting any existing value.
This is the primary way to set or update a context value. It always succeeds regardless of whether the key existed before.
Token representing the context key
The value to store
This context instance for method chaining
Puts a numeric value in the context and decrements it.
If the key doesn't exist, initializes it with the specified initialValue, then decrements it. If it exists, decrements the current value. Respects the optional min floor.
Token representing a numeric value in the context
Optionalsettings: PutDecrementSettingsConfiguration for initialization and decrement behavior
This context instance for method chaining
Puts a numeric value in the context and increments it.
If the key doesn't exist, initializes it with the specified initialValue, then increments it. If it exists, increments the current value. Respects the optional max cap.
Token representing a numeric value in the context
Optionalsettings: PutIncrementSettingsConfiguration for initialization and increment behavior
This context instance for method chaining
Puts an array into the context and pushes values to it.
If the key doesn't exist, creates a new array with the provided values. If it exists, appends the provided values to the existing array. Enables accumulating arrays in the context.
Token representing an array in the context
The values to push to the array
This context instance for method chaining
Removes a value from the context.
After removal, the token will be missing from the context. Subsequent get() calls will return null.
Token representing the context key to remove
This context instance for method chaining
Updates an existing context value only if it already exists.
If the token doesn't have a value, this operation is a no-op. Useful for safely updating values that should already be present.
Token representing the context key
The new value
This context instance for method chaining
Updates an existing numeric value in the context by decrementing it.
Only decrements if the value already exists. Respects the optional min floor.
Token representing a numeric value in the context
Optionalsettings: DecrementSettingsConfiguration for decrement behavior
This context instance for method chaining
Updates an existing numeric value in the context by incrementing it.
Only increments if the value already exists. Respects the optional max cap.
Token representing a numeric value in the context
Optionalsettings: IncrementSettingsConfiguration for increment behavior
This context instance for method chaining
Updates an existing array in the context by pushing values to it.
Only appends to the array if it already exists. If the value doesn't exist, this operation is a no-op.
Token representing an array in the context
The values to push to the array
This context instance for method chaining
Conditionally applies one or more operations to the context.
If the condition evaluates to true, executes all provided invokable functions with this context. The condition can be a direct boolean or a lazy-evaluated function. Useful for conditional context modifications.
This context instance for method chaining
IMPORT_PATH:
"@daiso-tech/core/execution-context/contracts"Read-write contract for managing execution context values.
This contract extends IReadableContext and adds methods for storing, updating, and removing values from the execution context. All methods return IContext to enable method chaining. It supports various operations: basic put/update/remove, numeric increment/decrement, array push, and conditional operations.