NewHeap.Platform.Common 26.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package NewHeap.Platform.Common --version 26.0.0
                    
NuGet\Install-Package NewHeap.Platform.Common -Version 26.0.0
                    
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="NewHeap.Platform.Common" Version="26.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="NewHeap.Platform.Common" Version="26.0.0" />
                    
Directory.Packages.props
<PackageReference Include="NewHeap.Platform.Common" />
                    
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 NewHeap.Platform.Common --version 26.0.0
                    
#r "nuget: NewHeap.Platform.Common, 26.0.0"
                    
#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 NewHeap.Platform.Common@26.0.0
                    
#: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=NewHeap.Platform.Common&version=26.0.0
                    
Install as a Cake Addin
#tool nuget:?package=NewHeap.Platform.Common&version=26.0.0
                    
Install as a Cake Tool

NewHeap Platform Common

API clients

AddNhApiClient<TApi> registers a reusable client for one logical target API. TApi is an empty marker type that lets related endpoint services share the same base address, handlers, and token cache.

Registration can be performed directly in Program.cs:

builder.Services.AddNhApiClient<CommerceManagementApi>(options =>
{
    options.BaseAddress = new Uri(
        builder.Configuration["Commerce:ManagementApiUrl"]!);
});

Or from a configuration section:

builder.Services.AddNhApiClient<CommerceManagementApi>(
    builder.Configuration.GetSection("ApiClients:CommerceManagement"));
{
  "ApiClients": {
    "CommerceManagement": {
      "BaseAddress": "https://management.example.test",
      "Timeout": "00:00:30"
    }
  }
}

An endpoint service derives from BaseNhApiService<TApi>:

public sealed class CommerceManagementApi;

public sealed class OperationsUserApiService
    : BaseNhApiService<CommerceManagementApi>
{
    public OperationsUserApiService(
        ILogger<OperationsUserApiService> logger,
        INhApiHttpClientFactory<CommerceManagementApi> httpClientFactory)
        : base(logger, httpClientFactory)
    {
    }

    public Task<TaskResult<OperationsUserViewModel>> GetAsync(
        Guid id,
        CancellationToken cancellationToken = default)
    {
        return DoGetAsync<OperationsUserViewModel>(
            $"/api/management/operations-user/{id}",
            cancellationToken);
    }
}

The base class provides helpers for GET, collection GET, POST, PUT, PATCH, and DELETE. Every helper has a default implementation and is protected virtual. JSON responses and NewHeap validation errors are returned as TaskResult.

Downloads and raw responses

Use DoGetResponseAsync when content must not be buffered as JSON. The result owns the response, request, and factory client, so it must be disposed:

public async Task<TaskResult> DownloadAsync(
    Stream destination,
    CancellationToken cancellationToken = default)
{
    using var responseResult = await DoGetResponseAsync(
        "/api/management/export",
        cancellationToken);

    if (!responseResult.Success)
    {
        return TaskResult.Failed(responseResult);
    }

    await using var source = await responseResult.Data.ReadAsStreamAsync(cancellationToken);
    await source.CopyToAsync(destination, cancellationToken);
    return TaskResult.Succeeded();
}

For other HTTP methods, the same raw pipeline is available through DoSendResponseAsync. Regular DTO methods deliberately remain TaskResult<T>.

Username and password authentication

When Authentication is present, the library automatically registers a separate authentication client, bearer handler, and thread-safe token cache:

{
  "ApiClients": {
    "CommerceManagement": {
      "BaseAddress": "https://management.example.test",
      "Authentication": {
        "Endpoint": "/api/authentication/username-password",
        "Username": "service-account",
        "Password": "configure-via-user-secrets-or-environment",
        "Realm": "",
        "RefreshBeforeExpiration": "00:03:00"
      }
    }
  }
}

Do not store passwords in a committed appsettings.json; use user secrets, environment variables, or a secret store. For other authentication methods, a custom INhApiAccessTokenProvider<TApi> can be registered through AddNhApiClient<TApi, TAccessTokenProvider>().

Actors

Platform modules ask the application about people through the interfaces in NewHeap.Platform.Common.Actors, so they work with NewHeap Identity and with an application's own identity model:

  • INhActorContextAccessor: the current actor (NhActorRef) and active division.
  • INhDivisionAccess: whether an actor may work in a division.
  • INhActorDirectory: names, e-mail addresses and cultures of actors, in one call.
  • INhUserNotificationSink: a message for a user's in-app inbox.
  • INhRetention: forget a user or division in every module that registered an INhRetentionParticipant.

NewHeap Identity implements them. An application without it registers its own with AddNewHeapActorContext, AddNewHeapDivisionAccess, AddNewHeapActorDirectory and AddNewHeapUserNotificationSink; see the consumer guide platform modules without identity.

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 (7)

Showing the top 5 NuGet packages that depend on NewHeap.Platform.Common:

Package Downloads
NewHeap.Platform.AspNet.Common

ASP.NET Core authentication, authorization, repository, query, background-job, and observability building blocks for NewHeap Platform applications.

NewHeap.Platform.AI.Common

Provider-neutral AI tool contracts, guarded invocation, and Microsoft.Extensions.AI adapters for NewHeap Platform applications.

NewHeap.Platform.Common.Test

Reusable test contexts, fixtures, assertions, and substitute helpers for applications built with NewHeap.Platform.Common.

NewHeap.Platform.Events.Cap

CAP-based transactional event publishing with SQL Server and PostgreSQL integrations for NewHeap Platform applications.

NewHeap.Platform.AI.Chat

Provider-neutral assistant conversations, turn orchestration, approvals and durable ledgers for NewHeap AI.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
30.0.0 53 11/1/2026
29.0.0 178 10/31/2026
28.0.0 117 10/30/2026
27.0.0 128 10/29/2026
26.0.0 126 10/29/2026
25.0.1 120 10/29/2026
25.0.0 124 10/29/2026
24.0.0 164 10/28/2026
23.0.1 201 10/28/2026
23.0.0 245 10/27/2026
22.0.0 269 10/26/2026
21.0.0 239 10/25/2026
20.0.0 249 10/24/2026
19.0.0 244 10/23/2026
18.0.0 245 10/22/2026
17.0.0 252 10/22/2026
16.0.0 252 10/21/2026
15.0.0 257 10/19/2026
14.0.0 235 10/17/2026
13.0.0 229 10/16/2026
Loading failed