OpenHumanTask.Sdk 0.1.7

dotnet add package OpenHumanTask.Sdk --version 0.1.7
NuGet\Install-Package OpenHumanTask.Sdk -Version 0.1.7
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="OpenHumanTask.Sdk" Version="0.1.7" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add OpenHumanTask.Sdk --version 0.1.7
#r "nuget: OpenHumanTask.Sdk, 0.1.7"
#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.
// Install OpenHumanTask.Sdk as a Cake Addin
#addin nuget:?package=OpenHumanTask.Sdk&version=0.1.7

// Install OpenHumanTask.Sdk as a Cake Tool
#tool nuget:?package=OpenHumanTask.Sdk&version=0.1.7

Open Human Task Specification<br>NET Software Development Kit

contributions welcome License <img src="http://img.shields.io/badge/slack-@openhumantask-red?style=social&logo=slack">

Provides .NET API/SPI and Model Validation for the Open Human Task Specification.

With this SDK, you can:

  • Read and write human task JSON and YAML definitions
  • Programmatically build human task definitions
  • Validate human task definitions (both schema and DSL integrity validation)

Status

Latest Releases Conformance to spec version
0.1.x v0.1

Getting Started

dotnet nuget add package OpenHumanTask.Sdk
services.AddOpenHumanTask();

How to use

Building human task definitions programatically

You can build human task definitions programatically using the SDK's fluent builder API exposed by the HumanTaskDefinitionBuilder.

 var definition = new HumanTaskDefinitionBuilder()
  .WithName("fake-task")
  .WithNamespace("oht.sdk.unit-tests")
  .WithVersion("1.0.0-unitTest")
  .UseSpecVersion("0.1.0")
  .UseExpressionLanguage("jq")
  .UseAutomaticCompletionBehavior("reviewed", complete =>
      complete
          .When("${ $CONTEXT.form.data }")
          .SetOutput(new { fakeProperty = "fake-data" }))
  .Assign(assign => 
      assign
          .ToPotentialOwners(all => 
              all
                  .Users()
                  .WithClaim("role", "clerk"))
          .ToBusinessAdministrators(single =>
              single.User("fake-user@email.com"))
          .ToGroup("fake-group", all =>
              all
                  .Users()
                  .InRole(GenericHumanRole.PotentialOwner))
          .ToNotificationRecipients(all =>
              all
                  .Users()
                  .InGroup("fake-group")))
  .AddOutcome("fake-outcome", outcome =>
      outcome
          .When("${ $CONTEXT.form.data.reviewed }")
          .Outputs("en", "fake-en-value")
          .Outputs("fr", "fake-fr-value"))
  .UseForm(form => 
      form
          .WithData("${ $CONTEXT.inputData }")
          .DisplayUsing(view => 
              view
                  .OfType("jsonform")
                  .WithTemplate("fake-jsonform-template")))
  .UseStartDeadline(deadline =>
      deadline
          .ElapsesAfter(TimeSpan.FromMinutes(30))
          .Escalates(then =>
              then.Reassign()))
  .UseCompletionDeadline(deadline =>
      deadline
          .ElapsesAt(new(2023, 4, 4, 12, 30, 00, TimeSpan.Zero))
          .Escalates(then =>
              then.StartSubtask("fake-subtask-1", subtask =>
                  subtask
                      .WithDefinition("fake-namespace.fake-other-task:1.0.0-unitTest")
                      .WithInput("${ $CONTEXT.form.inputData }"))))
  .AddSubtask("fake-subtask-2", subtask =>
      subtask.WithDefinition("fake-namespace.fake-other-task:1.5.1-unitTest"))
  .AnnotateWith("fake-annotation-key", "fake-annotation-value")
  .Build();

YAML output:

id: oht.sdk.unit-tests.fake-task:1.0.0-unitTest
name: fake-task
namespace: oht.sdk.unit-tests
version: 1.0.0-unitTest
specVersion: 0.1.0
routingMode: none
expressionLanguage: jq
peopleAssignments:
  potentialOwners:
  - users:
      withClaims:
      - type: role
        value: clerk
  businessAdministrators:
  - user: fake-user@email.com
  notificationRecipients:
  - users:
      inGroup: fake-group
  groups:
  - name: fake-group
    members:
    - users:
        inGenericRole: potentialOwner
form:
  data:
    state: ${ $CONTEXT.inputData }
subtasks:
- name: fake-subtask-2
  task:
    name: fake-other-task:1
    namespace: fake-namespace
subtaskExecutionMode: sequential
deadlines:
- type: start
  elapsesAfter: PT30M
  escalations:
  - action:
      reassignment: {}
- type: completion
  elapsesAt: 2023-04-04T12:30:00.0000000+00:00
  escalations:
  - action:
      subtask:
        name: fake-subtask-1
        task:
          name: fake-other-task:1
          namespace: fake-namespace
        input: ${ $CONTEXT.form.inputData }
completionBehaviors:
- name: reviewed
  type: automatic
  condition: ${ $CONTEXT.form.data }
outcomes:
- name: fake-outcome
  condition: ${ $CONTEXT.form.data.reviewed }
  value:
    fr: fake-fr-value
annotations:
  fake-annotation-key: fake-annotation-value
Reading human task definitions
...
var reader = HumanTaskDefinitionReader.Create();
using(Stream stream = File.OpenRead("human-task.json"))
{
  var definition = reader.Read(stream);
}
...
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
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
0.1.7 406 10/12/2022
0.1.6 369 10/12/2022
0.1.5 380 10/12/2022
0.1.4 377 10/11/2022
0.1.3 375 10/9/2022
0.1.2 372 10/8/2022
0.1.1 382 10/8/2022
0.1.0 367 10/7/2022