Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 22 additions & 17 deletions openapi/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -482,17 +482,19 @@ paths:
requestBody:
required: true
content:
application/xml:
multipart/form-data:
schema:
type: string
format: xml
example: |
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions>
<bpmn:process id="loan-application" name="Loan Application Process" isExecutable="true">
...
</bpmn:process>
</bpmn:definitions>
type: object
required:
- resource
properties:
resource:
type: string
format: binary
description: BPMN process definition file (.bpmn format only, max 4MB)
encoding:
resource:
contentType: application/octet-stream
responses:
201:
description: Process definition deployed
Expand Down Expand Up @@ -561,14 +563,9 @@ paths:
in: query
schema:
type: string
enum: [name, bpmnProcessId, bpmnResourceName, version, key]
enum: [name, bpmnProcessId, bpmnProcessName, version, key]
description: Sort field
- name: sortOrder
in: query
schema:
type: string
enum: [asc, desc]
description: Sort direction
- $ref: "#/components/parameters/sortOrder"
- name: bpmnProcessId
in: query
schema:
Expand Down Expand Up @@ -2861,3 +2858,11 @@ components:
unresolved:
type: integer
description: Number of unresolved incidents
parameters:
sortOrder:
name: sortOrder
in: query
schema:
type: string
enum: [asc, desc]
description: "Sort direction"
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"scripts": {
"prebuild": "orval",
"predev": "pnpm prebuild",
"dev": "vite --mode mocks",
"dev": "vite",
"dev:mocks": "pnpm dev --mode mocks",
"dev:live": "pnpm dev --mode live",
"build": "tsc -b && vite build",
Expand Down
21 changes: 17 additions & 4 deletions src/base/api/processDefinitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ import type {
ProcessDefinitionDetail,
ProcessDefinitionSimple,
ProcessDefinitionsPage,
CreateProcessDefinitionBody
} from '@base/openapi';

import { createProcessDefinition as createProcessDefinitionApi } from '@base/openapi';

export type { ProcessDefinitionDetail, ProcessDefinitionSimple, ProcessDefinitionsPage };

// Statistics types
Expand Down Expand Up @@ -82,8 +85,18 @@ export const getProcessDefinition = async (
* Deploy a process definition
*/
export const createProcessDefinition = async (xml: string): Promise<ProcessDefinitionDetail> => {
const response = await AXIOS_INSTANCE.post<ProcessDefinitionDetail>('/process-definitions', xml, {
headers: { 'Content-Type': 'application/xml' },
});
return response.data;
// Convert XML string to Blob
const blob = new Blob([xml], { type: 'application/xml' });

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The Blob is created with type: 'application/xml', but the OpenAPI specification for this endpoint (openapi/api.yaml line 497) specifies contentType: application/octet-stream for the resource part. While BPMN files are XML-based, it's best to align with the API contract to prevent potential issues.

Suggested change
const blob = new Blob([xml], { type: 'application/xml' });
const blob = new Blob([xml], { type: 'application/octet-stream' });


// Create request body for the generated client
const requestBody: CreateProcessDefinitionBody = {
resource: blob
};

// Call the generated client
const response = await createProcessDefinitionApi(requestBody);
const processDefinitionKey = response.processDefinitionKey;

const detailResponse = await getProcessDefinition(processDefinitionKey);
return detailResponse;
};
Comment on lines 87 to 102

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

This implementation makes two separate API calls: one to create the process definition and another to fetch its details. This is inefficient. To improve performance, consider modifying the backend POST /process-definitions endpoint to return the complete ProcessDefinitionDetail object upon successful creation. This would eliminate the need for the second getProcessDefinition call.

4 changes: 2 additions & 2 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ export default defineConfig({
server: {
port: 3000,
proxy: {
'/api': {
'/v1': {
target: 'http://localhost:8080',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, '/v1'),
// rewrite: (path) => path.replace(/^\/api/, '/v1'),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This commented-out rewrite function is no longer needed with the new proxy configuration. It should be removed to improve code clarity and maintainability.

},
},
},
Expand Down