-
Notifications
You must be signed in to change notification settings - Fork 95
feat(consumption): Add Invoke Nested Agent operation for Consumption Logic Apps #8660
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
Open
Bhavd13
wants to merge
9
commits into
Azure:main
Choose a base branch
from
Bhavd13:NestedAgent
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
033cdc5
Adding Invoke Nested Agent operation
Bhavd13 028e30a
Merge branch 'Azure:main' into NestedAgent
Bhavd13 b1186c9
Reset package files to main
Bhavd13 3c39100
Adding Unit Tests
Bhavd13 5487000
Making task message mandatory
Bhavd13 2aa09bc
Merge branch 'Azure:main' into NestedAgent
Bhavd13 c7fa578
Merge branch 'Azure:main' into NestedAgent
Bhavd13 6ba8dd4
Filtering for nested agent operation
Bhavd13 6d29e08
Merge branch 'main' into NestedAgent
Bhavd13 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
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
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
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
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
203 changes: 203 additions & 0 deletions
203
libs/logic-apps-shared/src/designer-client-services/lib/base/__test__/search.spec.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,203 @@ | ||
| import { describe, test, expect, beforeEach, vi } from 'vitest'; | ||
| import type { IHttpClient } from '../../httpClient'; | ||
|
|
||
| // Create a concrete implementation for testing | ||
| class TestSearchService { | ||
| constructor(private options: any) {} | ||
|
|
||
| private async getWorkflows(filter: string): Promise<any[]> { | ||
| const { httpClient, apiHubServiceDetails } = this.options; | ||
| const uri = `/subscriptions/${apiHubServiceDetails.subscriptionId}/providers/Microsoft.Logic/workflows`; | ||
| const queryParameters = { | ||
| 'api-version': apiHubServiceDetails.apiVersion, | ||
| $filter: filter, | ||
| }; | ||
| const response = await httpClient.get({ uri, queryParameters }); | ||
| return response?.value ?? []; | ||
| } | ||
|
|
||
| public async getAgentWorkflows(): Promise<any[]> { | ||
| const requestWorkflows = await this.getWorkflows( | ||
| "contains(Trigger, 'Request') and (properties/integrationServiceEnvironmentResourceId eq null)" | ||
| ); | ||
| return requestWorkflows.filter((workflow: any) => { | ||
| const triggers = workflow.properties?.definition?.triggers ?? {}; | ||
| return Object.values(triggers).some((trigger: any) => trigger.kind?.toLowerCase() === 'agent'); | ||
| }); | ||
| } | ||
| } | ||
|
|
||
| describe('BaseSearchService', () => { | ||
| let mockHttpClient: IHttpClient; | ||
| let searchService: TestSearchService; | ||
| let mockOptions: any; | ||
|
|
||
| beforeEach(() => { | ||
| mockHttpClient = { | ||
| get: vi.fn(), | ||
| post: vi.fn(), | ||
| put: vi.fn(), | ||
| delete: vi.fn(), | ||
| patch: vi.fn(), | ||
| dispose: vi.fn(), | ||
| }; | ||
|
|
||
| mockOptions = { | ||
| httpClient: mockHttpClient, | ||
| apiHubServiceDetails: { | ||
| subscriptionId: 'test-subscription', | ||
| location: 'westus', | ||
| apiVersion: '2016-06-01', | ||
| }, | ||
| }; | ||
|
|
||
| searchService = new TestSearchService(mockOptions); | ||
| }); | ||
|
|
||
| describe('getAgentWorkflows', () => { | ||
| test('should return only workflows with Agent triggers', async () => { | ||
| const mockWorkflows = { | ||
| value: [ | ||
| { | ||
| id: '/workflows/agent-workflow', | ||
| name: 'agent-workflow', | ||
| properties: { | ||
| definition: { | ||
| triggers: { | ||
| manual: { | ||
| type: 'Request', | ||
| kind: 'Agent', | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| { | ||
| id: '/workflows/regular-workflow', | ||
| name: 'regular-workflow', | ||
| properties: { | ||
| definition: { | ||
| triggers: { | ||
| manual: { | ||
| type: 'Request', | ||
| kind: 'Http', | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| ], | ||
| }; | ||
|
|
||
| vi.mocked(mockHttpClient.get).mockResolvedValue(mockWorkflows); | ||
|
|
||
| const result = await searchService.getAgentWorkflows(); | ||
|
|
||
| expect(result).toHaveLength(1); | ||
| expect(result[0].name).toBe('agent-workflow'); | ||
| }); | ||
|
|
||
| test('should handle case-insensitive Agent kind matching', async () => { | ||
| const mockWorkflows = { | ||
| value: [ | ||
| { | ||
| id: '/workflows/agent-uppercase', | ||
| name: 'agent-uppercase', | ||
| properties: { | ||
| definition: { | ||
| triggers: { | ||
| manual: { type: 'Request', kind: 'AGENT' }, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| { | ||
| id: '/workflows/agent-mixedcase', | ||
| name: 'agent-mixedcase', | ||
| properties: { | ||
| definition: { | ||
| triggers: { | ||
| manual: { type: 'Request', kind: 'AgEnT' }, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| ], | ||
| }; | ||
|
|
||
| vi.mocked(mockHttpClient.get).mockResolvedValue(mockWorkflows); | ||
|
|
||
| const result = await searchService.getAgentWorkflows(); | ||
|
|
||
| expect(result).toHaveLength(2); | ||
| }); | ||
|
|
||
| test('should return empty array when no Agent workflows exist', async () => { | ||
| const mockWorkflows = { | ||
| value: [ | ||
| { | ||
| id: '/workflows/regular', | ||
| name: 'regular', | ||
| properties: { | ||
| definition: { | ||
| triggers: { | ||
| manual: { type: 'Request', kind: 'Http' }, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| ], | ||
| }; | ||
|
|
||
| vi.mocked(mockHttpClient.get).mockResolvedValue(mockWorkflows); | ||
|
|
||
| const result = await searchService.getAgentWorkflows(); | ||
|
|
||
| expect(result).toHaveLength(0); | ||
| }); | ||
|
|
||
| test('should handle workflows with no triggers defined', async () => { | ||
| const mockWorkflows = { | ||
| value: [ | ||
| { | ||
| id: '/workflows/no-triggers', | ||
| name: 'no-triggers', | ||
| properties: { | ||
| definition: {}, | ||
| }, | ||
| }, | ||
| ], | ||
| }; | ||
|
|
||
| vi.mocked(mockHttpClient.get).mockResolvedValue(mockWorkflows); | ||
|
|
||
| const result = await searchService.getAgentWorkflows(); | ||
|
|
||
| expect(result).toHaveLength(0); | ||
| }); | ||
|
|
||
| test('should handle workflows with undefined kind', async () => { | ||
| const mockWorkflows = { | ||
| value: [ | ||
| { | ||
| id: '/workflows/no-kind', | ||
| name: 'no-kind', | ||
| properties: { | ||
| definition: { | ||
| triggers: { | ||
| manual: { type: 'Request' }, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| ], | ||
| }; | ||
|
|
||
| vi.mocked(mockHttpClient.get).mockResolvedValue(mockWorkflows); | ||
|
|
||
| const result = await searchService.getAgentWorkflows(); | ||
|
|
||
| expect(result).toHaveLength(0); | ||
| }); | ||
| }); | ||
| }); |
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.