-
Notifications
You must be signed in to change notification settings - Fork 383
Add flow extensions create/listing/delete support. #10349
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -616,3 +616,20 @@ | |
| */ | ||
| disabled?: boolean | ||
| } | ||
|
|
||
| /** | ||
| * Expose/modify entry in access config. | ||
| * Same structure is used for both expose and modify entries: a path plus an optional encryption flag. | ||
| */ | ||
| export interface ContextPathInterface { | ||
| path: string; | ||
| encrypted: boolean; | ||
| } | ||
|
|
||
| /** | ||
| * Access config for Flow Extension actions. | ||
| */ | ||
| export interface AccessConfigInterface { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. interface name feels too generic. Shall we rename it to something like FlowExtensionAccessConfigInterface? Also, should this be defined inside actions.v1? |
||
| expose: ContextPathInterface[]; | ||
| modify: ContextPathInterface[]; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| /** | ||
| * Copyright (c) 2026, WSO2 LLC. (https://www.wso2.com). | ||
| * | ||
| * WSO2 LLC. licenses this file to you under the Apache License, | ||
| * Version 2.0 (the "License"); you may not use this file except | ||
| * in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| import { AsgardeoSPAClient, HttpClientInstance } from "@asgardeo/auth-react"; | ||
| import { RequestConfigInterface } from "@wso2is/admin.core.v1/hooks/use-request"; | ||
| import { store } from "@wso2is/admin.core.v1/store"; | ||
| import { IdentityAppsApiException } from "@wso2is/core/exceptions"; | ||
| import { HttpErrorResponseDataInterface, HttpMethods } from "@wso2is/core/models"; | ||
| import { AxiosError, AxiosResponse } from "axios"; | ||
| import { | ||
| FlowExtensionCreateRequestInterface, | ||
| FlowExtensionResponseInterface | ||
| } from "../models/flow-extension"; | ||
|
Comment on lines
+25
to
+28
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shall we keep this in a single line for compactness? |
||
|
|
||
| const httpClient: HttpClientInstance = AsgardeoSPAClient.getInstance() | ||
| .httpRequest.bind(AsgardeoSPAClient.getInstance()); | ||
|
|
||
| /** | ||
| * Create a Flow Extension connection. | ||
| * | ||
| * @param body - Flow Extension create request body. | ||
| * @returns A promise that resolves with the created Flow Extension. | ||
| * @throws Throws an IdentityAppsApiException if the request fails. | ||
| */ | ||
| const createFlowExtension = ( | ||
| body: FlowExtensionCreateRequestInterface | ||
| ): Promise<FlowExtensionResponseInterface> => { | ||
| const requestConfig: RequestConfigInterface = { | ||
| data: body, | ||
| method: HttpMethods.POST, | ||
| url: store.getState().config.endpoints.flowExtension | ||
| }; | ||
|
|
||
| return httpClient(requestConfig) | ||
| .then((response: AxiosResponse) => { | ||
| if (response.status !== 201) { | ||
| throw new IdentityAppsApiException( | ||
| "Failed to create the flow extension.", | ||
| null, | ||
| response.status, | ||
| response.request, | ||
| response, | ||
| response.config | ||
| ); | ||
| } | ||
|
|
||
| return Promise.resolve(response.data as FlowExtensionResponseInterface); | ||
| }) | ||
| .catch((error: AxiosError<HttpErrorResponseDataInterface>) => { | ||
| throw new IdentityAppsApiException( | ||
| error.message, | ||
| error.stack, | ||
| error.response?.data?.code, | ||
| error.request, | ||
| error.response, | ||
| error.config | ||
| ); | ||
| }); | ||
| }; | ||
|
|
||
| export default createFlowExtension; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| /** | ||
| * Copyright (c) 2026, WSO2 LLC. (https://www.wso2.com). | ||
| * | ||
| * WSO2 LLC. licenses this file to you under the Apache License, | ||
| * Version 2.0 (the "License"); you may not use this file except | ||
| * in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| import { AsgardeoSPAClient, HttpClientInstance } from "@asgardeo/auth-react"; | ||
| import { RequestConfigInterface } from "@wso2is/admin.core.v1/hooks/use-request"; | ||
| import { store } from "@wso2is/admin.core.v1/store"; | ||
| import { IdentityAppsApiException } from "@wso2is/core/exceptions"; | ||
| import { HttpErrorResponseDataInterface, HttpMethods } from "@wso2is/core/models"; | ||
| import { AxiosError, AxiosResponse } from "axios"; | ||
|
|
||
| const httpClient: HttpClientInstance = AsgardeoSPAClient.getInstance() | ||
| .httpRequest.bind(AsgardeoSPAClient.getInstance()); | ||
|
|
||
| /** | ||
| * Delete a Flow Extension connection. | ||
| * | ||
| * @param id - ID of the Flow Extension to delete. | ||
| * @returns A promise resolving with the delete response. | ||
| * @throws Throws an IdentityAppsApiException if the request fails. | ||
| */ | ||
| const deleteFlowExtension = (id: string): Promise<AxiosResponse> => { | ||
| const requestConfig: RequestConfigInterface = { | ||
| method: HttpMethods.DELETE, | ||
| url: `${ store.getState().config.endpoints.flowExtension }/${ id }` | ||
| }; | ||
|
|
||
| return httpClient(requestConfig) | ||
| .then((response: AxiosResponse) => { | ||
| if (response.status !== 204) { | ||
| throw new IdentityAppsApiException( | ||
| "Failed to delete the flow extension.", | ||
| null, | ||
| response.status, | ||
| response.request, | ||
| response, | ||
| response.config | ||
| ); | ||
| } | ||
|
|
||
| return response; | ||
| }) | ||
| .catch((error: AxiosError<HttpErrorResponseDataInterface>) => { | ||
| throw new IdentityAppsApiException( | ||
| error.message, | ||
| error.stack, | ||
| error.response?.data?.code, | ||
| error.request, | ||
| error.response, | ||
| error.config | ||
| ); | ||
| }); | ||
| }; | ||
|
|
||
| export default deleteFlowExtension; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| /** | ||
| * Copyright (c) 2026, WSO2 LLC. (https://www.wso2.com). | ||
| * | ||
| * WSO2 LLC. licenses this file to you under the Apache License, | ||
| * Version 2.0 (the "License"); you may not use this file except | ||
| * in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| import useRequest, { | ||
| RequestConfigInterface, | ||
| RequestErrorInterface, | ||
| RequestResultInterface | ||
| } from "@wso2is/admin.core.v1/hooks/use-request"; | ||
| import { store } from "@wso2is/admin.core.v1/store"; | ||
| import { HttpMethods } from "@wso2is/core/models"; | ||
| import { FlowExtensionBasicResponseInterface } from "../models/flow-extension"; | ||
|
|
||
| /** | ||
| * Hook to get the list of Flow Extensions. | ||
| * | ||
| * @param shouldFetch - Whether the request should be sent. | ||
| * @returns The list of Flow Extensions as an SWR response. | ||
| */ | ||
| const useGetFlowExtension = < | ||
| Data = FlowExtensionBasicResponseInterface[], | ||
| Error = RequestErrorInterface | ||
| >( | ||
| shouldFetch: boolean = true | ||
| ): RequestResultInterface<Data, Error> => { | ||
|
Comment on lines
+37
to
+39
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shall we improve formatting here? |
||
|
|
||
| const requestConfig: RequestConfigInterface = { | ||
| headers: { | ||
| "Accept": "application/json", | ||
| "Content-Type": "application/json" | ||
| }, | ||
| method: HttpMethods.GET, | ||
| url: store.getState().config.endpoints.flowExtension | ||
| }; | ||
|
|
||
| const { data, error, isLoading, isValidating, mutate } = useRequest<Data, Error>( | ||
| shouldFetch ? requestConfig : null, | ||
| { shouldRetryOnError: false } | ||
| ); | ||
|
|
||
| return { data, error, isLoading, isValidating, mutate }; | ||
| }; | ||
|
|
||
| export default useGetFlowExtension; | ||
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.
it seems this interface is no longer used and can be removed. Please verify.