elsa-workflows / elsa-core

A .NET workflows library
https://v3.elsaworkflows.io/
MIT License
6.4k stars 1.19k forks source link

Extend TypeScript Definitions #1671

Open noxe opened 3 years ago

noxe commented 3 years ago

Hi,

i have a custom (generic) activity - where the user can select an object type - and based on this we create a new business object.

It is simple like this:

    [ActivityInput(Hint = "Objekttyp", OptionsProvider = typeof(ObjectTypeProvider), UIHint = ActivityInputUIHints.Dropdown)]
    public string ObjectType { get; set; }

    [ActivityOutput(DefaultWorkflowStorageProvider = TransientWorkflowStorageProvider.ProviderName)]
    public object Result { get; set; }

Now i want to provide Intellisense for the Result property. Currently it renders as object type "any" - since it is an object.

Would it be possible to extend the RenderJavaScriptTypeDefinitions class with some event or something like this - i think the main part will be the RenderActivityProperty - when i have a reference here to the activity instance - i could change the output for the Result property from Result(): any; to Result(): MyCustomType; ?

noxe commented 3 years ago

I made a test and did a copy of the RenderJavaScriptTypeDefinitions class. i could render my custom activity and simple change the output property type based on the input property in the RenderActivityTypeDeclarationAsync method - this just works fine and intellisense works perfect.

So - i think the easiest way would be to have an way to skip some activities - and render them by an custom INotificationHandler handler. i think this is also somehow related to https://github.com/elsa-workflows/elsa-core/issues/1670 - since currently ConfigureJavaScriptEngine and RenderJavaScriptTypeDefinitions render the named activities. looking at the output of the RenderJavaScriptTypeDefinitions - the declaration of the named activities is duplicated - once for the ConfigureJavaScriptEngine - and the same for the ConfigureJavaScriptEngine.

I think the ConfigureJavaScriptEngine should render only Http Activities - and the RenderJavaScriptTypeDefinitions should NOT render the Http Activities.

At the end i would need an similar behaviour - i want to exclude my custom acitivities - and render them myself ?