Jinaga.Tool
1.1.4
dotnet tool install --global Jinaga.Tool --version 1.1.4
dotnet new tool-manifest # if you are setting up this repo dotnet tool install --local Jinaga.Tool --version 1.1.4
#tool dotnet:?package=Jinaga.Tool&version=1.1.4
nuke :add-package Jinaga.Tool --version 1.1.4
Jinaga command line tool
Manage Jinaga replicators. Deploy authorization, distribution, and purge rules.
Installation
Install the global tool via dotnet
.
dotnet tool install -g Jinaga.Tool
Usage
Run the tool during continuous deployment to deploy authorization, distribution, and purge rules.
dotnet jinaga deploy authorization <assembly> <endpoint> <secret>
dotnet jinaga deploy distribution <assembly> <endpoint> <secret>
dotnet jinaga deploy purge <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, distribution, and purge 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<Site>.Match((site, facts) =>
from content in facts.OfType<Content>()
where content.site == site &&
facts.Any<Publish>(publish => publish.content == content)
select content
))
.WithEveryone()
// The creator can see all posts
.Share(Given<Site>.Match((site, facts) =>
from content in facts.OfType<Content>()
where content.site == site
select content
))
.With(site => site.creator)
;
Use the PurgeConditions
class to build and describe your rules.
For example:
public static string Purge() => PurgeConditions.Describe(Purge);
private static PurgeConditions Purge(PurgeConditions r) => r
// Purge posts that have been deleted
.Purge<Post>().WhenExists<PostDelete>(delete => delete.post)
;
Run the tool to deploy the rules to the replicator. The replicator will then enforce the rules.
You can also print the rules to the console for verification.
dotnet jinaga print authorization <assembly>
dotnet jinaga print distribution <assembly>
dotnet jinaga print policy <assembly>
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
sudo dotnet tool uninstall --global Jinaga.Tool
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. |
This package has no dependencies.