-
Notifications
You must be signed in to change notification settings - Fork 10
feat(workflow-executor): implement WorkflowPort adapter using forestadmin-client #1498
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
Merged
matthv
merged 1 commit into
feat/prd-214-setup-workflow-executor-package
from
feature/prd-233-implementer-workflowport-calls-vers-le-serveur-forest-admin
Mar 18, 2026
+162
−1
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
packages/workflow-executor/src/adapters/forest-server-workflow-port.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| import type { McpConfiguration, WorkflowPort } from '../ports/workflow-port'; | ||
| import type { PendingStepExecution } from '../types/execution'; | ||
| import type { CollectionRef } from '../types/record'; | ||
| import type { StepHistory } from '../types/step-history'; | ||
| import type { HttpOptions } from '@forestadmin/forestadmin-client'; | ||
|
|
||
| import { ServerUtils } from '@forestadmin/forestadmin-client'; | ||
|
|
||
| // TODO: finalize route paths with the team — these are placeholders | ||
| const ROUTES = { | ||
| pendingStepExecutions: '/liana/v1/workflow-step-executions/pending', | ||
| updateStepExecution: (runId: string) => `/liana/v1/workflow-step-executions/${runId}/complete`, | ||
| collectionRef: (collectionName: string) => `/liana/v1/collections/${collectionName}`, | ||
| mcpServerConfigs: '/liana/mcp-server-configs-with-details', | ||
| }; | ||
|
|
||
| export default class ForestServerWorkflowPort implements WorkflowPort { | ||
| private readonly options: HttpOptions; | ||
|
|
||
| constructor(params: { envSecret: string; forestServerUrl: string }) { | ||
| this.options = { envSecret: params.envSecret, forestServerUrl: params.forestServerUrl }; | ||
| } | ||
|
|
||
| async getPendingStepExecutions(): Promise<PendingStepExecution[]> { | ||
| return ServerUtils.query<PendingStepExecution[]>( | ||
| this.options, | ||
| 'get', | ||
| ROUTES.pendingStepExecutions, | ||
| ); | ||
| } | ||
|
|
||
| async updateStepExecution(runId: string, stepHistory: StepHistory): Promise<void> { | ||
| await ServerUtils.query( | ||
| this.options, | ||
| 'post', | ||
| ROUTES.updateStepExecution(runId), | ||
| {}, | ||
| stepHistory, | ||
| ); | ||
| } | ||
|
|
||
| async getCollectionRef(collectionName: string): Promise<CollectionRef> { | ||
| return ServerUtils.query<CollectionRef>( | ||
| this.options, | ||
| 'get', | ||
| ROUTES.collectionRef(collectionName), | ||
| ); | ||
| } | ||
|
|
||
| async getMcpServerConfigs(): Promise<McpConfiguration[]> { | ||
| return ServerUtils.query<McpConfiguration[]>(this.options, 'get', ROUTES.mcpServerConfigs); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
105 changes: 105 additions & 0 deletions
105
packages/workflow-executor/test/adapters/forest-server-workflow-port.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| import type { PendingStepExecution } from '../../src/types/execution'; | ||
| import type { CollectionRef } from '../../src/types/record'; | ||
| import type { StepHistory } from '../../src/types/step-history'; | ||
|
|
||
| import { ServerUtils } from '@forestadmin/forestadmin-client'; | ||
|
|
||
| import ForestServerWorkflowPort from '../../src/adapters/forest-server-workflow-port'; | ||
|
|
||
| jest.mock('@forestadmin/forestadmin-client', () => ({ | ||
| ServerUtils: { query: jest.fn() }, | ||
| })); | ||
|
|
||
| const mockQuery = ServerUtils.query as jest.Mock; | ||
|
|
||
| const options = { envSecret: 'env-secret-123', forestServerUrl: 'https://api.forestadmin.com' }; | ||
|
|
||
| describe('ForestServerWorkflowPort', () => { | ||
| let port: ForestServerWorkflowPort; | ||
|
|
||
| beforeEach(() => { | ||
| jest.clearAllMocks(); | ||
| port = new ForestServerWorkflowPort(options); | ||
| }); | ||
|
|
||
| describe('getPendingStepExecutions', () => { | ||
| it('should call the pending step executions route', async () => { | ||
| const pending: PendingStepExecution[] = []; | ||
| mockQuery.mockResolvedValue(pending); | ||
|
|
||
| const result = await port.getPendingStepExecutions(); | ||
|
|
||
| expect(mockQuery).toHaveBeenCalledWith( | ||
| options, | ||
| 'get', | ||
| '/liana/v1/workflow-step-executions/pending', | ||
| ); | ||
| expect(result).toBe(pending); | ||
| }); | ||
| }); | ||
|
|
||
| describe('updateStepExecution', () => { | ||
| it('should post step history to the complete route', async () => { | ||
| mockQuery.mockResolvedValue(undefined); | ||
| const stepHistory: StepHistory = { | ||
| type: 'condition', | ||
| stepId: 'step-1', | ||
| stepIndex: 0, | ||
| status: 'success', | ||
| selectedOption: 'optionA', | ||
| }; | ||
|
|
||
| await port.updateStepExecution('run-42', stepHistory); | ||
|
|
||
| expect(mockQuery).toHaveBeenCalledWith( | ||
| options, | ||
| 'post', | ||
| '/liana/v1/workflow-step-executions/run-42/complete', | ||
| {}, | ||
| stepHistory, | ||
| ); | ||
| }); | ||
| }); | ||
|
|
||
| describe('getCollectionRef', () => { | ||
| it('should fetch the collection ref by name', async () => { | ||
| const collectionRef: CollectionRef = { | ||
| collectionName: 'users', | ||
| collectionDisplayName: 'Users', | ||
| primaryKeyFields: ['id'], | ||
| fields: [], | ||
| actions: [], | ||
| }; | ||
| mockQuery.mockResolvedValue(collectionRef); | ||
|
|
||
| const result = await port.getCollectionRef('users'); | ||
|
|
||
| expect(mockQuery).toHaveBeenCalledWith(options, 'get', '/liana/v1/collections/users'); | ||
| expect(result).toEqual(collectionRef); | ||
| }); | ||
| }); | ||
|
|
||
| describe('getMcpServerConfigs', () => { | ||
| it('should fetch mcp server configs', async () => { | ||
| const configs = [{ name: 'mcp-1' }]; | ||
| mockQuery.mockResolvedValue(configs); | ||
|
|
||
| const result = await port.getMcpServerConfigs(); | ||
|
|
||
| expect(mockQuery).toHaveBeenCalledWith( | ||
| options, | ||
| 'get', | ||
| '/liana/mcp-server-configs-with-details', | ||
| ); | ||
| expect(result).toEqual(configs); | ||
| }); | ||
| }); | ||
|
|
||
| describe('error propagation', () => { | ||
| it('should propagate errors from ServerUtils.query', async () => { | ||
| mockQuery.mockRejectedValue(new Error('Network error')); | ||
|
|
||
| await expect(port.getPendingStepExecutions()).rejects.toThrow('Network error'); | ||
| }); | ||
| }); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<3