A TypeScript client library and type definitions for interacting with the iGRP Process Management API. This monorepo provides a simple and type-safe way to manage processes, tasks, and areas in the iGRP platform.
- Node.js 20.x.x or higher
- TypeScript 5.2.2 or higher
npm install @igrp/platform-process-management-client-ts
npm install @igrp/platform-process-management-types
This project is built with:
- Node.js 20.x.x
- Vite 6.3.5
- TypeScript (Vanilla TS template)
- Vitest for testing
igrp-process-manager-frontend-monorepo/ ├── packages/ │ └── @igrp/ │ ├── client/ # Client implementations for API calls │ │ ├── src/ │ │ │ ├── client/ # Client classes (ProcessClient, TaskClient, AreaClient) │ │ │ ├── utils/ # Utility functions │ │ │ └── index.ts # Main exports │ │ └── package.json │ └── types/ # Type definitions │ ├── src/ │ │ ├── area.ts # Area-related types │ │ ├── process.ts # Process-related types │ │ ├── task.ts # Task-related types │ │ ├── user.ts # User-related types │ │ ├── response.ts # API response types │ │ └── index.ts # Type exports │ └── package.json ├── apps/ │ └── demo-app/ # Demo application └── package.json # Monorepo configuration
import { ProcessManagementClient } from '@igrp/platform-process-management-client-ts';
import type { Process, Task, Area } from '@igrp/platform-process-management-types';
// Create a client instance
const client = ProcessManagementClient.create({
baseUrl: 'https://your-api-endpoint.com',
timeout: 30000, // optional, defaults to 30000 (30 seconds)
headers: { // optional
'Authorization': 'Bearer your-token-here'
}
});
// Use the client to interact with the API
async function getProcesses() {
try {
const response = await client.processes.getProcesses();
console.log('Processes:', response.data);
} catch (error) {
console.error('Error fetching processes:', error);
}
}
// Get all processes
const processes = await client.processes.getProcesses();
// Get a specific process
const process = await client.processes.getProcessById('process123');
// Get process instances
const instances = await client.processes.getProcessInstances({
processKey: 'my-process',
status: 'ACTIVE'
});
// Start a new process instance
const newInstance = await client.processes.startProcessInstance('process-key', {
variables: [
{ name: 'variable1', value: 'value1' },
{ name: 'variable2', value: 'value2' }
]
});
// Terminate a process instance
await client.processes.terminateProcessInstance('instance123');
// Suspend/Resume process instances
await client.processes.suspendProcessInstance('instance123');
await client.processes.resumeProcessInstance('instance123');
// Get all tasks
const tasks = await client.tasks.getTasks({
status: 'ACTIVE',
user: 'john.doe'
});
// Get tasks assigned to current user
const myTasks = await client.tasks.getMyTasks();
// Get a specific task
const task = await client.tasks.getTaskById('task123');
// Complete a task
await client.tasks.completeTask('task123', [
{ name: 'result', value: 'approved' }
]);
// Claim a task
await client.tasks.claimTask('task123', {
user: 'john.doe',
note: 'Taking ownership of this task'
});
// Assign a task to another user
await client.tasks.assignTask('task123', {
user: 'jane.smith',
note: 'Assigning to specialist'
});
// Unclaim/Release a task
await client.tasks.unclaimTask('task123', {
user: 'john.doe',
note: 'Releasing task back to pool'
});
// Get all areas
const areas = await client.areas.getAreas({
status: 'ACTIVE',
parentId: 'parent123'
});
// Get a specific area
const area = await client.areas.getAreaById('area123');
// Create a new area
const newArea = await client.areas.createArea({
name: 'New Department',
description: 'A new organizational area',
parentId: 'parent123'
});
// Update an area
await client.areas.updateArea('area123', {
description: 'Updated description'
});
// Get processes associated with an area
const areaProcesses = await client.areas.getAreaProcesses('area123', {
status: 'ACTIVE'
});
// Associate a process with an area
await client.areas.associateProcessToArea('area123', 'process456');
// Remove process from area
await client.areas.removeProcessFromArea('area123', 'process456');
The main client that provides access to all API resources.
const client = ProcessManagementClient.create({
baseUrl: 'https://your-api-endpoint.com',
timeout: 30000,
headers: { 'Authorization': 'Bearer token' }
});
Methods for managing processes and process instances:
getProcesses(filters?)
: Get all processes with optional filtersgetProcessById(id)
: Get a specific process by IDgetProcessInstances(filters?)
: Get process instances with filtersgetProcessInstanceById(id)
: Get a specific process instancestartProcessInstance(processKey, data)
: Start a new process instanceterminateProcessInstance(id)
: Terminate a process instancesuspendProcessInstance(id)
: Suspend a process instanceresumeProcessInstance(id)
: Resume a process instance
Methods for managing tasks:
getTasks(filters?)
: Get all tasks with optional filtersgetMyTasks(filters?)
: Get tasks assigned to current usergetTaskById(id)
: Get a specific task by IDcompleteTask(id, variables?)
: Complete a task with optional variablesclaimTask(id, params)
: Claim a taskunclaimTask(id, params)
: Release/unclaim a taskassignTask(id, params)
: Assign a task to a userunassignTask(id, params)
: Unassign a taskgetAvailableTasks(filters?)
: Get unassigned tasksgetTasksByProcessInstance(processInstanceId, params?)
: Get tasks by process instancegetTasksByUser(userId, params?)
: Get tasks by user
Methods for managing areas:
getAreas(filters?)
: Get all areas with optional filtersgetAreaById(id)
: Get a specific area by IDcreateArea(area)
: Create a new areaupdateArea(id, area)
: Update an existing areadeleteArea(id)
: Delete an areagetAreaProcesses(id, filters?)
: Get processes associated with an areaassociateProcessToArea(areaId, processId)
: Associate a process with an arearemoveProcessFromArea(areaId, processId)
: Remove a process from an area
The @igrp/platform-process-management-types
package provides comprehensive TypeScript definitions:
Process
: Process definition and metadataProcessInstance
: Running process instanceTask
: Task definition and stateArea
: Organizational area structureUser
: User information
ApiResponse<T>
: Standard API response wrapperPaginatedResponse<T>
: Paginated response for list endpointsPostResponse
: Response for POST operationsApiError
: Error response structure
The client provides a standardized error handling mechanism:
import { ApiClientError } from '@igrp/platform-process-management-client-ts';
try {
const processes = await client.processes.getProcesses();
} catch (error) {
if (error instanceof ApiClientError) {
console.error(`API Error (${error.status}): ${error.message}`);
console.error('Details:', error.details);
} else {
console.error('Unexpected error:', error);
}
}
# Build all packages
pnpm build
# Build specific packages
pnpm build:types
pnpm build:client
# Release all packages
pnpm release
# Deploy specific packages
pnpm deploy:types
pnpm deploy:client
Unit tests are written using Vitest, and test coverage includes all major client functionalities.
To run the test suite:
pnpm test
To run tests in watch mode:
pnpm test:watch
To check test coverage:
pnpm test:coverage
Each client test follows a consistent mock-based structure to isolate API logic:
import { describe, it, expect, vi, beforeEach } from 'vitest';
// Mock BaseApiClient and inject into ProcessClient, TaskClient, AreaClient
Mocks are created for:
get
post
put
delete
This ensures no real HTTP calls are made during test execution.
Before submitting changes, ensure code and tests pass linting and type checks:
pnpm lint
pnpm typecheck
Contributions to the iGRP Process Management client are welcome! Please follow these steps:
- Fork the repository
- Create a new branch for your feature or bug fix
- Make your changes
- Write tests for your changes
- Run the tests to ensure they pass
- Submit a pull/merge request
MIT License - see the LICENSE file for details.
- @igrp/platform-process-management-client-ts: Main client library (v0.1.0-beta.4)
- @igrp/platform-process-management-types: TypeScript type definitions (v0.0.1-beta.5)
Both packages are published to the NOSI registry at https://sonatype.nosi.cv/repository/igrp/