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
<PackageReference Include="EtlAnalytics.RulesEngine.Javascript" Version="1.0.0" />
<PackageVersion Include="EtlAnalytics.RulesEngine.Javascript" Version="1.0.0" />
<PackageReference Include="EtlAnalytics.RulesEngine.Javascript" />
paket add EtlAnalytics.RulesEngine.Javascript --version 1.0.0
#r "nuget: EtlAnalytics.RulesEngine.Javascript, 1.0.0"
#:package EtlAnalytics.RulesEngine.Javascript@1.0.0
#addin nuget:?package=EtlAnalytics.RulesEngine.Javascript&version=1.0.0
#tool nuget:?package=EtlAnalytics.RulesEngine.Javascript&version=1.0.0
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:ScriptTimeoutSecondsconfiguration (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 | 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. 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. |
-
net10.0
- EtlAnalytics.RulesEngine (>= 2.0.1)
- Jint (>= 3.1.2)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.0)
-
net8.0
- EtlAnalytics.RulesEngine (>= 2.0.1)
- Jint (>= 3.1.2)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.0)
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 |