Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add workflow tooling to the cli #158

Merged
merged 7 commits into from Feb 7, 2022
Merged

Add workflow tooling to the cli #158

merged 7 commits into from Feb 7, 2022

Conversation

OR13
Copy link
Sponsor Member

@OR13 OR13 commented Feb 6, 2022

We often need to generate synthetic data associated with home human process or workflow.

This PR adds some tooling to the CLI to dynamically generate VCs and VPs associated with a scenario that must be build and tested ahead of time.

There is an actor oriented api for regenerating synthetic data:

 def.addTask({
    id: 'Task_0',
    name: 'Order Received in China',
    task: async ({ output, services, variables }: WorkflowEnvironment) => {
      // services.console.log('product ordered from China.');
      output.actors = output.actors || {};
      output.presentations = output.presentation || [];
      const manufacturer = await services.fake.actor.generate({
        type: 'Organization',
        seed: variables.manufacturer.seed, // controls identity
      });
      output.actors.manufacturer = manufacturer;
      const vc1 = await manufacturer.credential.generate({
        type: 'CertifiedPurchaseOrder',
        subject: {
          manufacturer: variables.manufacturer,
          product: variables.product,
        },
      });
      const vp1 = await manufacturer.present({
        workflow: variables.workflow,
        credentials: [vc1],
      });
      output.presentations.push(vp1);
      return {};
    },
    edges: [
      {
        source: 'StartEvent_0',
        name: 'Import Started',
      },
    ],
  });

Once the scenario is built it has a visual representation based on BPMN:

Screen Shot 2022-02-06 at 12 51 04 PM

After its been build it can be executed to generate a json trace of the "workflow instance" which will contain the VC and VPs associated with the flow:

npm run transmute -- \
data create \
--type "WorkflowInstance" \
--input "https://w3id.org/traceability/#e-commerce" \
--variables '{"workflow":{"definition":["123"],"instance":["000"]}}' \
--output "./data/workflows/workflow.instance-0.json"

After this step, the json can be imported into a graph data base or analytics tool for rendering.

So far we only have Neo4j support, but will add others in the future.

npm run transmute -- \
neo workflow import \
--clean \
--uri "neo4j://localhost" \
--user "neo4j" \
--password "test" \
--input "./data/workflows/workflow.instance-0.json"

After the data has been imported it can be rendered:

workflow-instance

@nissimsan
Copy link
Member

Looks awesome!

@OR13 OR13 merged commit b898945 into main Feb 7, 2022
@acarnagey acarnagey deleted the feat/cli-updates branch December 2, 2022 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants