Code Monkey home page Code Monkey logo

Comments (4)

glime-ai avatar glime-ai commented on August 26, 2024 1

Based on the context provided, it seems you are looking to enhance the Elsa Workflow activities to support lists and dictionaries of inputs. Your proposed enhancement involves modifying classes such as InputDescriptor and ActivityDescriber to accommodate these complex input types. You have also mentioned that you have a working solution and are ready to create a pull request.

Given that you are not using the designer and are not proposing designer changes at this time, the enhancement would primarily benefit users who are developing workflows programmatically. The use cases you've described, such as sending messages to a list of users with varying input types (Literal, Variable, JavaScript) and running scripts with unique sets of named arguments, are clear examples of the flexibility this enhancement would provide.

The impact of this enhancement would allow for more sophisticated input mapping in activities, which could be beneficial for workflows that require dynamic input configurations. Although this does not currently involve changes to the designer, it could potentially lead to future enhancements that make these capabilities available in the designer interface.

Your additional context with the example activity WriteMultiLine demonstrates how a list of inputs could be used in practice.

If you have already been using this solution for a few weeks and it is stable, creating a pull request would be the next step. It would be important to ensure that your changes are well-documented and include tests to verify the new functionality. Additionally, it would be beneficial to consider how these changes might be integrated with the designer in the future, even if that is not part of the current proposal.

Before proceeding, it would be advisable to discuss this enhancement with the Elsa Workflow maintainers to ensure that it aligns with the project's roadmap and to gather any feedback they might have.

This comment was generated by Glime.

from elsa-core.

rboylesDev avatar rboylesDev commented on August 26, 2024

I don't understand why this doesn't meet what you are wanting?

public Input<List<string>> Recipients { get; set; } = default;

It's just a list of strings anyways and is effectively the same thing you're proposing just without extra steps on the consumer.

from elsa-core.

bobhauser avatar bobhauser commented on August 26, 2024

Hey @rboylesDev, thanks for your comment. For sure what you suggest would work if a simple list of names is available. But if the list were to come from a variety of sources, then I believe it would be easier to specify the inputs separately. I added a sample workflow showing both of the new input constructs that I am suggesting at the bottom of this message.

The RunScript activity has an input called arguments which consists of two string arguments (one Literal, one JavaScript) as well as a boolean argument.

The SendMessage activity has an input called to which consists of three string elements (one Literal, one JavaScript, and one Variable).

Does this help demonstrate why a simple Input<List<string>> would not be sufficient?

Sample Workflow Definition

{
	"type": "Elsa.Flowchart",
	"version": 1,
	"id": "flowchart",
	"nodeId": "120f407f-bff7-4b3a-a8b6-c57ee625dc42:flowchart",
	"metadata": {},
	"customProperties": {
		"source": "WorkflowMapper.cs:61"
	},
	"activities": [
		{
			"id": "Event_1hehqwh",
			"nodeId": "120f407f-bff7-4b3a-a8b6-c57ee625dc42:flowchart:Event_1hehqwh",
			"name": "",
			"type": "Elsa.Start",
			"version": 1,
			"customProperties": {
				"source": "WorkflowMapper.cs:121"
			},
			"metadata": {}
		},
		{
			"id": "Event_01xeq36",
			"nodeId": "120f407f-bff7-4b3a-a8b6-c57ee625dc42:flowchart:Event_01xeq36",
			"name": "",
			"type": "Elsa.End",
			"version": 1,
			"customProperties": {
				"source": "WorkflowMapper.cs:126"
			},
			"metadata": {}
		},
		{
			"scriptDependency": {
				"type": "Script",
				"name": "LookupCompanyContactEmail",
				"scope": "Private",
				"onlyAllowPublic": false
			},
			"arguments": {
				"CompanyName": {
					"typeName": "String",
					"expression": {
						"type": "Literal",
						"value": "Apex Inc"
					}
				},
				"ContactName": {
					"typeName": "String",
					"expression": {
						"type": "JavaScript",
						"value": "getInput(\"ContactName\");"
					}
				},
				"SomeBooleanArg": {
					"typeName": "Boolean",
					"expression": {
						"type": "Literal",
						"value": "true"
					}
				}
			},
			"result": {
				"typeName": "Object",
				"memoryReference": {
					"id": "9d8307aafd7641f88a0ce53a5e58fedb"
				}
			},
			"id": "Activity_10k4yr3",
			"nodeId": "120f407f-bff7-4b3a-a8b6-c57ee625dc42:flowchart:Activity_10k4yr3",
			"name": "RunScript",
			"type": "Sample.RunScript",
			"version": 1,
			"customProperties": {},
			"metadata": {}
		},
		{
			"subject": {
				"typeName": "String",
				"expression": {
					"type": "Literal",
					"value": "This is a test message"
				}
			},
			"body": {
				"typeName": "String",
				"expression": {
					"type": "JavaScript",
					"value": "getInput(\"MessageBody\");"
				}
			},
			"to": [
				{
					"typeName": "String",
					"expression": {
						"type": "Literal",
						"value": "admin"
					}
				},
				{
					"typeName": "String",
					"expression": {
						"type": "JavaScript",
						"value": "getInput(\"MessageRecipient\");"
					}
				},
				{
					"typeName": "String",
					"expression": {
						"type": "Variable",
						"value": {
							"id": "9d8307aafd7641f88a0ce53a5e58fedb",
							"name": "AnotherRecipient",
							"typeName": "String",
							"value": "ralph",
							"storageDriverTypeName": "Elsa.Workflows.Services.WorkflowStorageDriver, Elsa.Workflows.Core"
						}
					}
				}
			],
			"cc": [],
			"bcc": [],
			"id": "Activity_1ndpz3j",
			"nodeId": "120f407f-bff7-4b3a-a8b6-c57ee625dc42:flowchart:Activity_1ndpz3j",
			"name": "SendMessage",
			"type": "Sample.SendMessage",
			"version": 1,
			"customProperties": {},
			"metadata": {}
		}
	],
	"connections": [
		{
			"source": {
				"activity": "Event_1hehqwh"
			},
			"target": {
				"activity": "Activity_10k4yr3"
			}
		},
		{
			"source": {
				"activity": "Activity_10k4yr3"
			},
			"target": {
				"activity": "Activity_1ndpz3j"
			}
		},
		{
			"source": {
				"activity": "Activity_1ndpz3j"
			},
			"target": {
				"activity": "Event_01xeq36"
			}
		}
	]
}

from elsa-core.

rboylesDev avatar rboylesDev commented on August 26, 2024

@bobhauser, ah I see. We have a few of these cases and the way we've handled (worked around?) it is to have a javascript activity, or Set Variable activity with value input using Javascript, that combines all the inputs into a single list before passing to our activity. While it's not natively taking in multiple inputs, it does work now without additional Elsa changes.

from elsa-core.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.