EtlAnalytics.RulesEngine.Javascript 1.0.0

dotnet add package EtlAnalytics.RulesEngine.Javascript --version 1.0.0
                    
NuGet\Install-Package EtlAnalytics.RulesEngine.Javascript -Version 1.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="EtlAnalytics.RulesEngine.Javascript" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="EtlAnalytics.RulesEngine.Javascript" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="EtlAnalytics.RulesEngine.Javascript" />
                    
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 EtlAnalytics.RulesEngine.Javascript --version 1.0.0
                    
#r "nuget: EtlAnalytics.RulesEngine.Javascript, 1.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 EtlAnalytics.RulesEngine.Javascript@1.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=EtlAnalytics.RulesEngine.Javascript&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=EtlAnalytics.RulesEngine.Javascript&version=1.0.0
                    
Install as a Cake Tool

EtlAnalytics.RulesEngine.Javascript

This package provides Javascript execution support for the EtlAnalytics.RulesEngine. It allows you to write business rules using standard Javascript logic, executed via the high-performance Jint engine.

Installation

Install via NuGet:

dotnet add package EtlAnalytics.RulesEngine.Javascript

Setup

To enable Javascript rules, register the executor in your Dependency Injection container during application startup:

using EtlAnalytics.RulesEngine.Javascript;

// ...

builder.Services.AddJavascriptRules();

Usage

Once registered, you can create rules with the RuleType set to "Javascript".

Writing a Javascript Rule

In your Javascript rules, the execution context is available via the context global object. You can also use the log() function to append messages to the execution log.

// Properties from your C# Context class are mapped to the 'context' object
if (context.OrderTotal > 500) {
    log("Applying bulk discount via Javascript");
    return context.OrderTotal * 0.15; // 15% discount
}

return 0;

Accessing Bundle History

Just like in C# rules, you can access results from previous steps in a bundle:

// Access the result of the immediately preceding rule
var prev = context.PreviousResult;

// Access a specific step by its sequence order
var step1 = context.StepResults[1];

if (prev === "HighValueOrder") {
    return 50.0;
}

Features

  • Sandboxed Execution: Rules are executed in a memory-limited sandbox.
  • Timeout Support: Javascript rules respect the RulesEngine:ScriptTimeoutSeconds configuration (defaults to 10 seconds).
  • C# Interop: Seamlessly access your C# context properties and methods (methods must be permitted by Jint's interop settings if customized).
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.  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.  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
1.0.0 114 7/25/2026