import * as domainFunctions from "https://deno.land/x/domain_functions@v3.0.0/mod.ts";
Classes
A custom error class for environment errors. | |
A custom error class for input errors. | |
A custom error class for creating ErrorResult. |
Functions
f all | Creates a single domain function out of multiple domain functions. It will pass the same input and environment to each provided function. The functions will run in parallel. If all constituent functions are successful, The data field will be a tuple containing each function's output. |
Use it to add conditional logic to your domain functions' compositions.
It receives a domain function and a predicate function that should return the next domain function to be executed based on the previous domain function's output, like | |
Receives a Record of domain functions, runs them all in parallel and preserves the shape of this record for the data property in successful results. | |
Receives a Record of domain functions, runs them all in sequence like | |
Extracts the error messages for a property from the given ErrorResult. | |
Creates a composite domain function that will return the result of the first successful constituent domain function. It is important to notice that all constituent domain functions will be executed in parallel, so be mindful of the side effects. | |
A functions that helps incremental migration from the legacy | |
It can be used to call a domain function from another domain function. It will return the output of the given domain function if it was successfull, otherwise it will throw a | |
Creates a domain function. After giving the input and environment schemas, you can pass a handler function that takes type safe input and environment. That function is gonna catch any errors and always return a Result. | |
f map | It takes a domain function and a predicate to apply a transformation over the result.data of that function. It only runs if the function was successfull. When the given domain function fails, its error is returned wihout changes. |
Creates a single domain function that will apply a transformation over the ErrorResult of a failed DomainFunction. When the given domain function succeeds, its result is returned without changes. | |
f mdf | Creates a domain function. After giving the input and environment schemas, you can pass a handler function that takes type safe input and environment. That function is gonna catch any errors and always return a Result. |
NOTE : Try to use collect instead wherever possible since it is much safer. | |
f pipe | Creates a single domain function out of a chain of multiple domain functions. It will pass the same environment to all given functions, and it will pass the output of a function as the next function's input in left-to-right order. The resulting data will be the output of the rightmost function. |
A functions that turns the result of its callback into a Result object. | |
Creates a SchemaError (used in inputErrors and environmentErrors) from the given message and path. | |
Works like | |
A functions that helps incremental migration from the legacy | |
Turns the given 'unknown' error into an ErrorWithMessage. | |
Whenever you need to intercept inputs and a domain function result without changing them you can use this function. The most common use case is to log failures to the console or to an external service. |
Type Aliases
It is similar to Partial but it requires at least one property to be defined. | |
A domain function. It carries the output type which can be further unpacked with UnpackData and other type helpers. | |
The properties of the ErrorResult which carry information about what made the domain function fail. | |
A failed domain function result. | |
Items in the errors array returned by failed domain functions. | |
T Last | Returns the last item of a tuple type. |
A parsing error when validating the input or environment schemas.
This will be transformed into a | |
The result of input or environment validation.
See the type | |
The object used to validate either input or environment when creating domain functions. | |
The content of the Promise a domain function returns. | |
Items in the inputErrors and environmentErrors array returned by failed domain functions. | |
A successful domain function result. | |
Converts a tuple type to a union type. | |
Unpacks a list of DomainFunctions into a tuple of their data types. | |
Unpacks the data type of a successful domain function. | |
Unpacks the result of a domain function. | |
Unpacks the data type of a successful domain function. |