public async Task <WorkflowDefinition?> PublishAsync(string workflowDefinitionId, CancellationToken cancellationToken = default) { var definition = await _workflowDefinitionStore.FindByDefinitionIdAsync( workflowDefinitionId, VersionOptions.Latest, cancellationToken); if (definition == null) { return(null); } return(await PublishAsync(definition, cancellationToken)); }
public async Task <IActionResult> Handle(string workflowDefinitionId, string?context = default, VersionOptions?version = default, CancellationToken cancellationToken = default) { version ??= VersionOptions.Latest; var workflowDefinition = await _workflowDefinitionStore.FindByDefinitionIdAsync(workflowDefinitionId, version.Value, cancellationToken); var typeDefinitions = await _typeScriptDefinitionService.GenerateTypeScriptDefinitionsAsync(workflowDefinition, context, cancellationToken); var fileName = $"elsa.{workflowDefinitionId}.d.ts"; var data = Encoding.UTF8.GetBytes(typeDefinitions); return(File(data, "application/x-typescript", fileName)); }
public async Task <ActionResult <WorkflowDefinition> > Handle(string workflowDefinitionId, ApiVersion apiVersion, CancellationToken cancellationToken) { var workflowDefinition = await _workflowDefinitionStore.FindByDefinitionIdAsync(workflowDefinitionId, VersionOptions.Published, cancellationToken); if (workflowDefinition == null) { return(NotFound()); } workflowDefinition = await _workflowPublisher.RetractAsync(workflowDefinition, cancellationToken); return(AcceptedAtAction("Handle", "GetByVersionId", new { versionId = workflowDefinition.Id, apiVersion = apiVersion.ToString() }, workflowDefinition)); }
public async Task <IActionResult> Handle(string workflowDefinitionId, VersionOptions versionOptions, CancellationToken cancellationToken) { var workflowDefinition = await _workflowDefinitionStore.FindByDefinitionIdAsync(workflowDefinitionId, versionOptions, cancellationToken); if (workflowDefinition == null) { return(NotFound()); } var json = _contentSerializer.Serialize(workflowDefinition); var bytes = Encoding.UTF8.GetBytes(json); var workflowName = workflowDefinition.Name is null or "" ? workflowDefinition.DefinitionId : workflowDefinition.Name.Trim(); var fileName = $"workflow-definition-{workflowName.Underscore().Dasherize().ToLowerInvariant()}.json"; return(File(bytes, "application/json", fileName)); }