Jinaga.Tool 0.9.1

dotnet tool install --global Jinaga.Tool --version 0.9.1
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest # if you are setting up this repo
dotnet tool install --local Jinaga.Tool --version 0.9.1
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=Jinaga.Tool&version=0.9.1
nuke :add-package Jinaga.Tool --version 0.9.1

Jinaga command line tool

Manage Jinaga replicators. Deploy authorization and distribution rules.

Installation

Install the global tool via dotnet.

dotnet tool install -g Jinaga.Tool

Usage

Run the tool during continuous deployment to deploy authorization and distribution rules.

dotnet jinaga deploy authorization <assembly> <endpoint> <secret>
dotnet jinaga deploy distribution <assembly> <endpoint> <secret>

You can find the endpoint and secret in the Jinaga replicator portal.

This tool is to be used with a Jinaga application. Install the Jinaga NuGet package and create a model. For example:

[FactType("Blog.Site")]
public record Site(User creator, string identifier) { }

[FactType("Blog.GuestBlogger")]
public record GuestBlogger(Site site, User guest) { }

[FactType("Blog.Content")]
public record Content(Site site, string path) { }

Create a public static class called JinagaConfig. This will typically be the class that creates the JinagaClient. For example:

public static class JinagaConfig
{
  public static JinagaClient j = JinagaClient.Create(opt =>
  {
    var settings = new Settings();
    settings.Verify();
    opt.HttpEndpoint = new Uri(settings.ReplicatorUrl);
  });
}

Add your authorization and distribution rules to this class. Use the AuthorizationRules class to build and describe your rules. For example:

  public static string Authorization() => AuthorizationRules.Describe(Authorization);

  private static AuthorizationRules Authorization(AuthorizationRules r) => r
    // Anyone can create a user
    .Any<User>()
    // A site can only be created by its creator
    .Type<Site>(site => site.creator)
    // A guest blogger can only be created by the site's creator
    .Type<GuestBlogger>(guestBlogger => guestBlogger.site.creator)
    // A content item can be created by the site's creator
    .Type<Content>(content => content.site.creator)
    // A content item can also be created by a guest blogger
    .Type<Content>((content, facts) =>
      from guestBlogger in facts.OfType<GuestBlogger>()
      where guestBlogger.site == content.site
      from user in facts.OfType<User>()
      where user == guestBlogger.guest
      select user
    )
    ;

Use the DistributionRules class to build and describe your rules. For example:

  public static string Distribution() => DistributionRules.Describe(Distribution);

  private static DistributionRules Distribution(DistributionRules r) => r
    // Everyone can see published posts
    .Share(Given<Model.Site>.Match((site, facts) =>
      from content in facts.OfType<Model.Content>()
      where content.site == site &&
        facts.Any<Model.Publish>(publish => publish.content == content)
      select content
    ))
    .WithEveryone()
    // The creator can see all posts
    .Share(Given<Model.Site>.Match((site, facts) =>
      from content in facts.OfType<Model.Content>()
      where content.site == site
      select content
    ))
    .With(site => site.creator)
    ;

Run the tool to deploy the rules to the replicator. The replicator will then enforce the rules.

Build and Test

dotnet build .\Jinaga.Tool -c Release
dotnet pack .\Jinaga.Tool -c Release
dotnet tool install --global --add-source .\Jinaga.Tool\bin\Release Jinaga.Tool
dotnet build ./Jinaga.Tool -c Release
dotnet pack ./Jinaga.Tool -c Release
sudo dotnet tool install --global --add-source ./Jinaga.Tool/bin/Release Jinaga.Tool

After testing, uninstall the tool

dotnet tool uninstall --global Jinaga.Tool

``bash sudo dotnet tool uninstall --global Jinaga.Tool

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

This package has no dependencies.

Version Downloads Last updated
0.9.1 127 2/10/2024
0.9.0 112 2/9/2024
0.6.1 250 9/16/2023
0.6.0 222 9/12/2023