elsa-workflows / elsa-workflows/elsa-core
Default SupportedSyntaxes for activities
- Dominant language
- C#
- Stars
- 7.9k
- Forks
- 1.5k
- Avg merge
- 15h 22m
- Merged PRs (30d)
- 114
Description
We are using Elsa extensively, and we found limitation in some existing activities like **FileExists** that has path property that does not allow javascript syntax.
We circumvented the problem with this code
```csharp
public class ImproveExistingElsaActivitiesInjector : INotificationHandler
{
private Dictionary _propertiesToOverrideSyntax;
public ImproveExistingElsaActivitiesInjector()
{
string overrideConfigurationFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Support", "PropertiesSupportedSyntaxOverrideList.json");
if (File.Exists(overrideConfigurationFile))
{
_propertiesToOverrideSyntax = JsonConvert.DeserializeObject>(File.ReadAllText(overrideConfigurationFile))!;
}
else
{
//No file to override syntaxes, we create empty dictionary.
_propertiesToOverrideSyntax = new Dictionary();
}
}
public Task Handle(DescribingActivityType notification, CancellationToken cancellationToken)
{
if (_propertiesToOverrideSyntax.TryGetValue(notification.ActivityType.TypeName, out var propertiesToOverride))
{
foreach (var propertyToOverride in propertiesToOverride)
{
var propertyDef = notification.ActivityDescriptor.InputProperties.Single(p => p.Name == propertyToOverride);
if (propertyDef != null)
{
propertyDef.SupportedSyntaxes = new[] { SyntaxNames.JavaScript, SyntaxNames.Literal, SyntaxNames.Json, SyntaxNames.Liquid };
}
}
}
return Task.CompletedTask;
}
}
```
A simple component that intercept DescribingActivityType and uses a stupid json file where we wrote the list of activities/properties where we want to have all syntaxes.
But I have a couple of questions.
1. Is this the right way to have existing properties to support all syntaxes?
2. why we do not have a default that supports all possible syntax? In our scenario for a lots of properties it is convenient to have javascript / liquid and not only plain text.
Contributor guide
Research direction
Start by reading the DescribingActivityType handler and the FileExists path property, then inspect how SupportedSyntaxes is assigned and how SyntaxNames are defined. Compare the current defaults with the proposed JavaScript, Liquid, Literal, and JSON set; done requires a decided default behavior for existing activity properties and confirmation that the affected activities expose it consistently.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100