DCH.IntakeAgentCore 4.0.3

dotnet add package DCH.IntakeAgentCore --version 4.0.3
                    
NuGet\Install-Package DCH.IntakeAgentCore -Version 4.0.3
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DCH.IntakeAgentCore" Version="4.0.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DCH.IntakeAgentCore" Version="4.0.3" />
                    
Directory.Packages.props
<PackageReference Include="DCH.IntakeAgentCore" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DCH.IntakeAgentCore --version 4.0.3
                    
#r "nuget: DCH.IntakeAgentCore, 4.0.3"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package DCH.IntakeAgentCore@4.0.3
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DCH.IntakeAgentCore&version=4.0.3
                    
Install as a Cake Addin
#tool nuget:?package=DCH.IntakeAgentCore&version=4.0.3
                    
Install as a Cake Tool

Intake Agent Core

This package provides the core functionality for Intake Agents, offering the following key features:

  • Implementation of the contract required by Data Context Hub
  • Built-in admin functionality using a Blazor UI with Radzen components
  • Keycloak integration for Single Sign-On (SSO) across a Data Context Hub instance

Environment Variables

Configuration is managed primarily through environment variables:

Variable Description Default
BASE_PATH The path where the intake agent will be hosted /
DCH_BASE_URL The base URL of the DCH instance (e.g., https://dch.example.com/) -
DCH_KEYCLOAK_REALM The Keycloak realm used by the DCH instance -
DCH_KEYCLOAK_URL The Keycloak URL (e.g., https://dch.example.com/auth/) -
OTEL_EXPORTER_OTLP_ENDPOINT OTLP endpoint (required when OpenTelemetry is activated) -
POSTGRES_HOST PostgreSQL host address -
POSTGRES_PORT PostgreSQL port number -
POSTGRES_USER PostgreSQL username -
POSTGRES_PASSWORD PostgreSQL password -
POSTGRES_DATABASE Database name used by this Intake Agent -

Usage

In your Program.cs add the following:

var configurator = new IntakeAgentCoreConfigurator(builder.Services, builder.Configuration)
{
    AgentName = "Your Intake Agent", 
    ServiceName = "your-intake-agent",
    Version = "0.1.0",
    KeycloakClientId = "your-intake-agent"
};
configurator.AddPostgreSqlPersistence();
configurator.AddOpenTelemetry(builder);
configurator.ConfigureAdminUi(adminUiOptions =>
{
    // If you want to add your own Blazor pages, reference your assembly and configure the left side menu here.
    // Supported icons can be found here: https://fonts.google.com/icons?icon.set=Material+Symbols
    adminUiOptions.AddAssembly(typeof(Program).Assembly);
    adminUiOptions.AddConfidentialMenuItem("upload", "Upload", "./upload");
});

builder.Services.AddIntakeAgentCore(configurator);

Implementation

The core functionality is provided by the IDataProvider interface, which must be implemented by the Intake Agent.

Product Compatible and additional computed target framework versions.
.NET 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.0.3 111 11/9/2026
4.0.1 99 11/2/2026
2.1.1 247 1/27/2026
2.1.0 135 1/21/2026
2.0.0 148 1/19/2026
1.2.0 572 12/10/2025
1.1.0 698 12/2/2025
1.0.0 259 11/24/2025

# Changelog (Release Notes)

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) (SemVer).

## [Unreleased]

## [4.0.1]

### Fixed
- `GbsApiClient` percent-encodes the caller-supplied values it puts into URLs. A target entity
 identifier containing a `/` used to leave the `{idOrSlug}` route unmatched and come back 404, and
 an `&` in a relationship name silently truncated the search. Affects `GetTargetEntity`,
 `UpdateTargetEntity`, `DeleteTargetEntity`, `GetRelationship` and `GetQueueJobDetails`.

 Note for callers behind an ingress: nginx normalises `%2F` back to `/` before the request reaches
 GBS, so encoding alone does not make a slash-bearing *path* segment work there. Address entities
 by slug or id rather than by title, which is what the agents already do.

## [4.0.0]

Requires GBS 3.2 or newer. The shims that let agents talk to GBS 3.1 as well are gone: 3.2 is the
release that started returning `slug`/`type` and accepting the data source configuration slug, so an
agent on this version works against 3.2 and 4.x but no longer against 3.1.

### Added
- `IJobLifecycleListener` — agents can be told when a job of theirs ends and drop state they scoped
 to it. Opt-in: register with `configurator.AddJobLifecycleListener<T>()`, and agents that need
 nothing register nothing. Both members default to doing nothing, so a listener overrides only what
 it needs and a later event can be added without breaking the listeners already written. Two events:
 - `ImportJobFinishedEvent` — one of this agent's data jobs reached a terminal state (completed,
   failed or cancelled)
 - `IntakeJobFinishedEvent` — GBS reported that a whole intake job is over. Only GBS knows this,
   because it runs an intake job's import jobs one after another; an agent with no running job for
   an intake job cannot conclude the intake job has ended. GBS versions that predate this call never
   send it, so anything cleaned up here needs an independent fallback such as a TTL
- `POST api/v1/core/data-jobs/intake-jobs/{intakeJobId}/complete` — the endpoint GBS calls to raise
 `IntakeJobFinishedEvent`. `outcome` is carried as a string (`"Completed"`, `"Failed"`, `"Cancelled"`),
 and the optional `finishedAt` defaults to the time the call arrives
- `Humanize.Milliseconds(long?)` — formats a duration as `ms`/`s`/`min` (returns `N/A` for `null`)
- Data Preview page (`/core/data-preview`): per-entity column multi-select dropdown, and a **Force refresh** button per entity that bypasses `SourceEntity.DataPreview` and fetches live data via `IDataProvider.GetData`

### Removed
- `DataSourceConfiguration.Alias`, `TargetEntityDto.Alias`, `RelationshipDto.Alias` and
 `RelationshipDto.FromEntity` / `ToEntity` — use `Slug`, `Type` and `FromEntitySlug` / `ToEntitySlug`
- `StartDataJobRequest.DataSourceConfigurationNameOrAlias` and the `ResolvedConfigNameOrSlug`
 fallback it fed; `DataSourceConfigurationNameOrSlug` is now required and read directly
- `DataSourceConfigurationDataPreviewResponse.DataSourceConfigurationAlias`
- The GBS 3.1 retry in `DataImportConfigurationManager` that resent a rejected data source
 configuration under its other name, and the name-vs-slug normalisation before verification.
 `DataImportConfigurationManager` no longer takes an `IDataProvider`
- `RequiredMigrations.ConvertAliasToSlug`, and with it the whole entry from the registry. Agents
 should delete their `ConvertAliasToSlugMigration` and any
 `SkipRequiredMigrations(RequiredMigrations.ConvertAliasToSlug)` call. **Make sure the migration has
 already run in every environment** — its record lives in the `AppliedMigration` table
- `SlugUtil.ConvertFromAlias` and `SlugUtil.ConvertFromAliases` — they existed only for the migration
 that is gone. `ToSlug` is what builds a slug from a name

### Changed
- `TargetEntityDto.Slug`, `RelationshipDto.Type` and `RelationshipDto.FromEntitySlug` / `ToEntitySlug`
 are `required` again, now that no GBS version omits them
- `DataMigrationRunner` takes the required-migration registry as a dependency instead of reading the
 static list, so the validation stays testable while the registry is empty
- Data Jobs page and `JobInfoDto` show what a job is actually doing — intake job id, source
 configuration, and the source entities being imported with their property counts and manual-trigger
 flags — instead of a column bound to a property that no longer existed. `JobInfoDto` gained
 `IntakeJobId`, `DataSourceConfigurationNameOrSlug` and `DataToImport` as `required` members, so
 anything constructing one has to supply them
- `DataJob.TriggeredBy` and `DataImportConfigurationRequest.DataSourceConfiguration` are `init`-only;
 assign them in the object initialiser rather than afterwards
- A job now reaches a terminal state exactly once, so `ImportJobFinishedEvent` is raised once per
 job however the job ended. Cancelling a job that has already finished — failed included, not just
 completed — throws instead of overwriting the outcome, and a cancel waits (up to 10 s) for the
 processing loop to unwind before listeners are told, so they are not releasing state the job is
 still writing

### Upgrading from 3.1.x
1. Delete your `ConvertAliasToSlugMigration` and its `AddMigration` registration, and any
  `SkipRequiredMigrations(RequiredMigrations.ConvertAliasToSlug)` call
2. Delete the `Alias` property from your `DataSourceConfigurationInfo`
3. Set `Type` / `FromEntitySlug` / `ToEntitySlug` on `RelationshipDto` and `Slug` on
  `TargetEntityDto` — they are required now
4. Optionally implement `IJobLifecycleListener` to clean up per-job state

## [3.1.1]

### Added
- `ErrorDetails` models RFC 7807 problem details: `Type`, `Instance`, `TraceId`, per-field `Errors`, `AdditionalProperties` (extension members) and `RawBody`, plus a `Summary` (also `ToString()`) that flattens everything onto one line for logs and single-string error messages
- `ErrorDetails.FromResponseAsync(HttpResponseMessage)` / `ErrorDetails.FromResponseBody(body, statusCode, reasonPhrase)` — parse an error body (problem details, or plain text such as a gateway's HTML page) without throwing; usable by any client that talks to a DCH service

### Changed
- `ErrorDetails.Title` / `Message` are no longer `required` and default to an empty string, so the parser can build one from any response
- `GbsApiClient.SendDataBatch` / `ReportJobFailure` no longer use `EnsureSuccessStatusCode()`: a failed POST now throws an `IntakeAgentCoreException` carrying the status code and the problem detail from GBS instead of the bare `Response status code does not indicate success`

### Fixed
- `GbsApiClient` no longer discards what GBS said when a request fails. Error bodies were deserialized straight into `ErrorDetails`, which only knew `title`/`message`, so a problem-details response (GBS's actual format) left `ErrorDetails.Message` empty and the validation `errors` were lost — callers such as `TargetEntityManager`, `RelationshipManager` and `DataImportConfigurationManager` reported a blank `StatusMessage`. Error responses are now parsed with `ErrorDetails.FromResponseBody`, `Message` falls back through `detail` → flattened `errors` → `title` → the status line, and `ErrorDetails` is populated even for an empty body

## [2.2.0]

### Added
- Data migration framework: `IDataMigration` interface, `RequiredMigrations` registry, `DataMigrationRunner` hosted service
- `SlugUtil` with `ToSlug()`, `ConvertFromAlias()`, and `ConvertFromAliases()` methods
- `SkipRequiredMigrations()` and `AddMigration<T>()` on `IntakeAgentCoreConfigurator`

### Changed
- `DataSourceConfiguration.Alias` renamed to `Slug`; format tightened to `[a-z0-9-]`
- `IDataProvider` parameter `nameOrAlias` renamed to `nameOrSlug`
- `DataFetchParameters.DsConfigNameOrAlias` renamed to `DsConfigNameOrSlug`
- `StartDataJobRequest.DataSourceConfigurationNameOrAlias` renamed to `DataSourceConfigurationNameOrSlug` (old JSON name still accepted as fallback)
- `DataSourceConfigurationsController` route parameter `alias` renamed to `slug`
- `AliasUtil` removed; use `SlugUtil` instead

## [2.1.1]

### Changed
- ToAlias in AliasUtil now uses Hyphens ("-") instead of Underscores ("_")

## [2.1.0]

### Added
- GetQueueJobDetails added to the GBS API contract

## [2.0.0]

### Changed
- Updated to dotnet10

## [1.2.0]

### Added
- Logic to suggest a unique Alias value

## [1.1.0]

### Added
- UpdateTargetEntity added to the GBS API contract

## [1.0.0]

### Added
- Full implementation of the GBS API contract enabling agent registration and data submission
- PostgreSQL database integration for secure storage of agent-specific data
- Policy-based authentication system protecting all API endpoints
- Intuitive Admin UI with support for custom pages and single sign-on via Keycloak integration
- Comprehensive development utilities to streamline agent creation and deployment