Skip to content

Commit

Permalink
Merge pull request #73 from batzionb/bugfix1
Browse files Browse the repository at this point in the history
fix(orchestrator): execute should allow no inputs
  • Loading branch information
batzionb authored Nov 28, 2024
2 parents 8e9e292 + 9f61eb0 commit b68c744
Show file tree
Hide file tree
Showing 12 changed files with 18 additions and 18 deletions.
6 changes: 6 additions & 0 deletions workspaces/orchestrator/.changeset/chilly-donkeys-design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@red-hat-developer-hub/backstage-plugin-orchestrator-backend': patch
'@red-hat-developer-hub/backstage-plugin-orchestrator-common': patch
---

execute API should allow no inputs
3 changes: 3 additions & 0 deletions workspaces/orchestrator/app-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ backend:
connection: ':memory:'
cache:
store: memory
# useful for debugging APIs via curl in dev env without requiring a auth:
# auth:
# dangerouslyDisableDefaultAuthPolicy: true
# workingDirectory: /tmp # Use this to configure a working directory for the scaffolder, defaults to the OS temp-dir

integrations: {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ export class OrchestratorService {
public async executeWorkflow(args: {
definitionId: string;
serviceUrl: string;
inputData: ProcessInstanceVariables;
inputData?: ProcessInstanceVariables;
businessKey?: string;
cacheHandler?: CacheHandler;
}): Promise<WorkflowExecutionResponse | undefined> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export class SonataFlowService {
public async executeWorkflow(args: {
definitionId: string;
serviceUrl: string;
inputData: ProcessInstanceVariables;
inputData?: ProcessInstanceVariables;
businessKey?: string;
}): Promise<WorkflowExecutionResponse | undefined> {
const urlToFetch = args.businessKey
Expand All @@ -100,7 +100,7 @@ export class SonataFlowService {

const response = await fetch(urlToFetch, {
method: 'POST',
body: JSON.stringify(args.inputData),
body: JSON.stringify(args.inputData || {}),
headers: { 'content-type': 'application/json' },
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,6 @@ export class V2 {
workflowId: string,
businessKey: string | undefined,
): Promise<ExecuteWorkflowResponseDTO> {
if (Object.keys(executeWorkflowRequestDTO?.inputData).length === 0) {
throw new Error(
`ExecuteWorkflowRequestDTO.inputData is required for executing workflow with id ${workflowId}`,
);
}

const definition = await this.orchestratorService.fetchWorkflowInfo({
definitionId: workflowId,
cacheHandler: 'throw',
Expand All @@ -182,7 +176,7 @@ export class V2 {
const executionResponse = await this.orchestratorService.executeWorkflow({
definitionId: workflowId,
inputData:
executeWorkflowRequestDTO?.inputData as ProcessInstanceVariables,
executeWorkflowRequestDTO.inputData as ProcessInstanceVariables,
serviceUrl: definition.serviceUrl,
businessKey,
cacheHandler: 'throw',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ export interface ExecuteWorkflowRequestDTO {
// Warning: (tsdoc-malformed-inline-tag) Expecting a TSDoc tag starting with "{@"
// Warning: (tsdoc-undefined-tag) The TSDoc tag "@type" is not defined in this configuration
// Warning: (tsdoc-undefined-tag) The TSDoc tag "@memberof" is not defined in this configuration
'inputData': object;
'inputData'?: object;
}

// Warning: (tsdoc-undefined-tag) The TSDoc tag "@export" is not defined in this configuration
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
f4fd9f652a05159a3d506540493e275885d54dcd
fc8d7c1e837b67d3de9b235126aeb829972a98ce

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export interface ExecuteWorkflowRequestDTO {
* @type {object}
* @memberof ExecuteWorkflowRequestDTO
*/
'inputData': object;
'inputData'?: object;
}
/**
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,6 @@
"description" : "The ErrorResponse object represents a common structure for handling errors in API responses. It includes essential information about the error, such as the error message and additional optional details."
};
defs["ExecuteWorkflowRequestDTO"] = {
"required" : [ "inputData" ],
"properties" : {
"inputData" : {
"type" : "object",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

| Name | Type | Description | Notes |
|------------ | ------------- | ------------- | -------------|
| **inputData** | [**Object**](.md) | | [default to null] |
| **inputData** | [**Object**](.md) | | [optional] [default to null] |

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

Original file line number Diff line number Diff line change
Expand Up @@ -585,8 +585,6 @@ components:
inputData:
type: object
additionalProperties: true
required:
- inputData
ExecuteWorkflowResponseDTO:
type: object
properties:
Expand Down

0 comments on commit b68c744

Please sign in to comment.