HyperDev.Connectors
1.0.1
dotnet add package HyperDev.Connectors --version 1.0.1
NuGet\Install-Package HyperDev.Connectors -Version 1.0.1
<PackageReference Include="HyperDev.Connectors" Version="1.0.1" />
<PackageVersion Include="HyperDev.Connectors" Version="1.0.1" />
<PackageReference Include="HyperDev.Connectors" />
paket add HyperDev.Connectors --version 1.0.1
#r "nuget: HyperDev.Connectors, 1.0.1"
#:package HyperDev.Connectors@1.0.1
#addin nuget:?package=HyperDev.Connectors&version=1.0.1
#tool nuget:?package=HyperDev.Connectors&version=1.0.1
HyperDev.Connectors
Core of the HyperDev connectors: an operation of an external system (a REST API, a SOAP service, a database) is written as a JSON definition, compiled once against an environment that holds the resources (endpoints, connections, variables, secrets) and then executed with JSON input and output.
The kinds of operation are in their own packages:
| Package | Kind |
|---|---|
HyperDev.Connectors.Rest |
REST / HTTP, import from OpenAPI (JSON or YAML) |
HyperDev.Connectors.Soap |
SOAP / WCF, import from WSDL and XSD |
HyperDev.Connectors.Sql |
SQL queries, procedures and functions (HyperDev.Data providers) |
A "type" met in a definition loads HyperDev.Connectors.<Type> by convention, so the host only references the
packages it uses.
Definitions
// read, check and write a definition
OperationDefinition definition = OperationDefinition.FromJson(json);
IReadOnlyList<DefinitionIssue> issues = definition.Validate(); // every problem, with its JSON path
IReadOnlyList<DefinitionIssue> all = OperationDefinition.ValidateJson(json); // also unknown properties and wrong values
string saved = definition.ToJson(); // read back as the same text
// the contract of the operation (JSON Schema, HyperDev.Text.Json.Schema)
JsonSchema input = definition.GetInputSchema();
JsonSchema output = definition.GetOutputSchema();
// the JSON schema of the definitions of a kind, for an editor
JsonSchema schema = OperationDefinitionSerializer.GetSchema("rest");
A definition names its resources, never their values: the same definition runs in every environment. It also
carries fixedValues (fields of the input set by the connector), excluded (optional fields never sent),
sensitive (paths masked in captures and diagnostics) and unwrap (Simplify(true): wrappers of the request and
of the response hidden from the caller).
Environment and resources
using var environment = new OperationEnvironment()
.UseResourceSource(JsonResourceSource.Parse("""
{
"rest": { "customers": { "baseAddress": "https://api.example.com", "authentication": { "type": "bearer", "token": "${env:CUSTOMERS_TOKEN}" } } },
"sql": { "main": { "provider": "Microsoft.Data.SqlClient", "connectionString": "...", "userName": "app", "password": "${env:DB_PASSWORD}" } },
"variable": { "tenant": { "value": "T01", "secret": false } }
}
"""))
.UseSecretProvider(new EnvironmentVariableSecretProvider());
- Resources are read by kind and name from the sources (
IResourceSource, the first that knows the name wins), validated by their kind (ResourceKinds.Get("rest").Validate(settings)) and built at their first use: an invalid resource blocks only the operations that use it. - Secrets are references inside any setting (
${env:NAME},Bearer ${secret:token}), resolved by theISecretProviderof their scheme; the application registers its own (a vault, a database). - Variables (
{{$var.tenant}}) are resources of kindvariable, usable in the templates of the operations and as defaults of the parameters; they are resolved when the operation is compiled. - HTTP clients are shared per configuration (TLS, proxy, credentials) and disposed with the environment.
// is every resource used by these definitions there and valid?
IReadOnlyList<ResourceStatus> readiness = environment.CheckResources(definitions);
// try a resource without running an operation (opens a connection, or sends a HEAD request)
ResourceProbe probe = await environment.ProbeResourceAsync("rest", "customers", TimeSpan.FromSeconds(10));
Execution
IOperation operation = definition.Compile(environment); // once; operations are thread-safe
JToken result = await operation.ExecuteAsync(new JObject { ["id"] = 7 });
// with the context of the call: correlation id, user and headers ({{$correlationId}}, {{$user}})
JToken traced = await operation.ExecuteAsync(input, new OperationCallContext(correlationId, user));
OperationCache keeps the compiled operations and compiles them again when the resources of the environment
change (GetResourceRevision):
var cache = new OperationCache(environment, TimeSpan.FromSeconds(30));
IOperation op = cache.Get(key, () => OperationDefinition.FromJson(json));
Timeout, concurrency limit, retries and circuit breaker are options of the definition. A failure is an
OperationException with a category (Kind), a stable Reason (OperationErrorReasons, e.g. fault.not_found,
backend.unauthorized), the code of the system (Code), IsTransient and, for the input, the path of the value
(Target).
Telemetry
Standard .NET API, no dependency: an ActivitySource and a Meter named HyperDev.Connectors
(OperationTelemetry.Name) for OpenTelemetry, measured only while someone listens. A report per call is given to
OperationCallContext.Observer (OperationCallReport: outcome, attempts, durations, sizes, rows). Input and output
values, users and secrets never go into traces and metrics.
Target frameworks: net8.0, net10.0.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- HyperDev.Text.Json.Schema (>= 1.2.0)
- Newtonsoft.Json (>= 13.0.4)
-
net8.0
- HyperDev.Text.Json.Schema (>= 1.2.0)
- Newtonsoft.Json (>= 13.0.4)
NuGet packages (4)
Showing the top 4 NuGet packages that depend on HyperDev.Connectors:
| Package | Downloads |
|---|---|
|
HyperDev.Connectors.Sql
HyperDev Fatum Framework |
|
|
HyperDev.Connectors.Editor
HyperDev Fatum Framework: server side of the connector editor (@wemake4u/connector-editor) |
|
|
HyperDev.Connectors.Rest
HyperDev Fatum Framework |
|
|
HyperDev.Connectors.Soap
HyperDev Fatum Framework |
GitHub repositories
This package is not used by any popular GitHub repositories.