2019-11-25 09:15:11 +00:00
/ * *
* Handles the Api pane ui state . It looks into the routing based on actions too
* * /
2021-05-17 07:21:48 +00:00
import get from "lodash/get" ;
import omit from "lodash/omit" ;
import cloneDeep from "lodash/cloneDeep" ;
2022-10-17 15:16:38 +00:00
import { all , call , put , select , take , takeEvery } from "redux-saga/effects" ;
2020-12-14 16:22:45 +00:00
import * as Sentry from "@sentry/react" ;
2019-11-25 09:15:11 +00:00
import {
ReduxAction ,
2020-06-18 14:16:49 +00:00
ReduxActionErrorTypes ,
2019-11-25 09:15:11 +00:00
ReduxActionTypes ,
ReduxActionWithMeta ,
ReduxFormActionTypes ,
2022-04-12 10:50:01 +00:00
} from "@appsmith/constants/ReduxActionConstants" ;
2022-06-21 13:57:34 +00:00
import { GetFormData , getFormData } from "selectors/formSelectors" ;
2022-09-02 17:15:08 +00:00
import {
API_EDITOR_FORM_NAME ,
QUERY_EDITOR_FORM_NAME ,
} from "@appsmith/constants/forms" ;
2020-04-20 08:26:19 +00:00
import {
2021-03-01 14:57:15 +00:00
CONTENT_TYPE_HEADER_KEY ,
EMPTY_KEY_VALUE_PAIRS ,
feat: Support body in GET API requests (#7127)
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* adds apiContentType to actionConfiguration.formData object
* Handling apiContentType property in Rest API formData
* change apiContentType when user types content-type value and switches http method
* makes api editor as similar as possible to postman, project postman.
* Correcting the import in ApiEditorConstants
* Resolved all merge conflicts
* replay DSL functtionality
* removes unneccessary files from worker
* Fixes type declarations, naming e.t.c.
* fix server side merge conflicts
* fix client side merge conflicts
* fix failing cypress tests
Co-authored-by: Irongade <adeoluayangade@yahoo.com>
Co-authored-by: Ayangade Adeoluwa <37867493+Irongade@users.noreply.github.com>
2022-02-15 11:13:48 +00:00
HTTP_METHOD ,
2022-04-12 11:13:11 +00:00
HTTP_METHODS_DEFAULT_FORMAT_TYPES ,
2022-10-17 15:16:38 +00:00
POST_BODY_FORMAT_OPTIONS ,
POST_BODY_FORMAT_OPTIONS_ARRAY ,
2022-09-09 15:59:47 +00:00
} from "constants/ApiEditorConstants/CommonApiConstants" ;
2022-10-17 15:16:38 +00:00
import { DEFAULT_CREATE_API_CONFIG } from "constants/ApiEditorConstants/ApiEditorConstants" ;
import { DEFAULT_CREATE_GRAPHQL_CONFIG } from "constants/ApiEditorConstants/GraphQLEditorConstants" ;
2019-11-25 09:15:11 +00:00
import history from "utils/history" ;
2022-03-25 10:43:26 +00:00
import { INTEGRATION_EDITOR_MODES , INTEGRATION_TABS } from "constants/routes" ;
2022-10-17 15:16:38 +00:00
import { autofill , change , initialize } from "redux-form" ;
2020-06-04 13:49:22 +00:00
import { Property } from "api/ActionAPI" ;
2022-08-04 05:40:44 +00:00
import { createNewApiName } from "utils/AppsmithUtils" ;
import { getQueryParams } from "utils/URLUtils" ;
2020-04-20 08:26:19 +00:00
import { getPluginIdOfPackageName } from "sagas/selectors" ;
2022-11-30 05:59:45 +00:00
import {
getAction ,
getActions ,
getDatasourceActionRouteInfo ,
getPlugin ,
} from "selectors/entitiesSelector" ;
2022-06-21 13:57:34 +00:00
import {
ActionData ,
ActionDataState ,
} from "reducers/entityReducers/actionsReducer" ;
2021-08-27 09:25:28 +00:00
import {
createActionRequest ,
setActionProperty ,
} from "actions/pluginActionActions" ;
2022-10-17 15:16:38 +00:00
import {
Action ,
ApiAction ,
PluginPackageName ,
PluginType ,
} from "entities/Action" ;
2022-06-15 15:37:41 +00:00
import { getCurrentWorkspaceId } from "@appsmith/selectors/workspaceSelectors" ;
2020-08-18 08:48:06 +00:00
import log from "loglevel" ;
2020-09-24 04:47:37 +00:00
import PerformanceTracker , {
PerformanceTransactionName ,
} from "utils/PerformanceTracker" ;
2020-10-06 15:10:21 +00:00
import { EventLocation } from "utils/AnalyticsUtil" ;
chore: import common variables from design system (#17600)
* Delete CommonComponentProps, Classes, import them from design-system
* Delete Icon.test.tsx
* Remove color utils, add import from design-system
* Remove Variant, add import from design-system
* Remove unused toast parameters from common
* use design-system version 28-alpha-7
* Move ThemeProp from ads/common to widgets/constants
* fix import
* Delete index.ts
* feat: migrated form group from ads folder to design system repository (#17400)
* feat: migrated form group from ads folder to design system repo
* fix: formGroup label color fix
* DS version updated
* Updated Label Config
* chore: Flapdoodle version upgrade to 3.5.0 (#17609)
* chore: code split tenant API CE (#17596)
## Description
We shouldn't expose tenant config on CE , so on CE, we should only return the necessary user permissions hard coded on the saga.
## Type of change
- New feature (non-breaking change which adds functionality)
## How Has This Been Tested?
- Manual
## Checklist:
- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [x] New and existing unit tests pass locally with my changes
* chore: BaseAppsmithRepo code split (#17614)
* chore: Updating the tenant API to return the complete object instead of just the configuration (#17615)
* Fix sandbox iframe default setting (#17618)
* feat: upgrade hooks | audit logs (#17525)
* feat: Text Widget Reskinning (#17298)
* feat: Use truncate button color from theme
* fix: Update Truncate Button Color validation regex
* feat: Maintain Focus and Context Phase 1 (#16317)
* fix: update regex and test case for organisation website (#17612)
* chore: Add properties to analytics event (#17621)
* feat: enabled setTimeout/clearTimeout APIs (#17445)
* Update top contributors
* fix: ms sql default port updated to 1433 (#17342)
* fix: removed global style from design system dropdown component (#17392)
* bug: removed global style from design system dropdown component
* changed design system package version
* fix: Dropdown background fix - design system
* design-system - dropdown background color fix
* DS version updated
* chore: Fixing broken client build (#17634)
## Description
EE client build is broken due to not following proper code splitting strategy; one file in particularly didn't get split earlier and changes to that file broke the client build on EE.
This PR fixes the issues.
* Fix/16994 refactor common datatype handling (#17429)
* fix:Add array datatype to execute request
* feat: Consume and store type of array elements in Param class (#16994)
* Append param instead of clientDataType in varargs (#16994)
* Refactor common data type handling w.r.t newer structure (#16994)
This commit takes care of the following items:
- It minimizes the number of usage to the older stringToKnownDataTypeConverter method
- Modifies the existing test cases to conform to the newer structure
- Marks stringToKnownDataTypeConverter method as deprecated to discourage further use
* Remove comma delimited numbers from valid test cases (#16994)
* Fix extracting clientDataType from varargs in MySQL (#16994)
* Pass param as a dedicated parameter in json smart replacement (#16994)
* Remove varargs from json smart replacement method (#16994)
* Move BsonType to mongoplugin module (#16994)
* Introduce NullArrayType and refactor BsonType test cases (#16994)
* Add new test cases on numeric string with leading zero (#16994)
* Refactor test case name (#16994)
* Add comment on the ordering of Json and Bson types (#16994)
* Add comment on the ordering of Json and Bson types (#16994)
* Add NullArrayType in Postgres and introduce postgres-specific types (#16994)
* Add data type test cases for Postgres and change as per review comments (#16994)
Co-authored-by: ChandanBalajiBP <chandan@appsmith.com>
* feat: Update invite modal submit when we have tabs in modal (#17608)
## Description
> Update invite modal submit when we have tabs in modal.
Fixes [#16741](https://github.com/appsmithorg/appsmith/issues/16741)
## Type of change
- New feature (non-breaking change which adds functionality)
## How Has This Been Tested?
> Tested it locally.
## Checklist:
- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [x] New and existing unit tests pass locally with my changes
* feat: AST based entity refactor (#17434)
* task: AST based entity refactor
* implemented refactor logic
* jest cases with string manipulation using AST logic
* comments and indentation
* added evalVersion to request
* chore: Added feature flag for datasource environments (#17657)
chore: Added Feature flag for datasource environments
* chore: Corrected analytics event for instance setting events (#17622)
* Update top contributors
* Fix typo in cloud-hosting check and NPE from Segment (#17692)
Signed-off-by: Shrikant Sharat Kandula <shrikant@appsmith.com>
* fix: remove file references on click of cancel button (#17664)
* fix: table does not show data issue fixed (#17459)
* chore: Add recommended indexes (#17704)
Signed-off-by: Shrikant Sharat Kandula <shrikant@appsmith.com>
* chore: Added workspace details to user invite analytic event (#17644)
## Description
This PR adds the workspace details to user invite analytics event
## Type of change
- New feature (non-breaking change which adds functionality)
## How Has This Been Tested?
- Manually on local
## Checklist:
- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [x] New and existing unit tests pass locally with my changes
* chore: Correct the toast font on windows (#17671)
* fix: JS option missing for Label Font Style in Input widget (#17631)
* fix: replace time based action to event based (#17586)
* fix: replace time based action to event based
- The delete datasource button was getting reset to it's original state after a static time of 2200ms
- Replaced this to reset on completion of deletion instead
* fix: removed unused functions
* fix: updated the condition to show confirm delete icon
* Updated Label Config
* test: Add cypress tests for template phase 2 (#17036)
Co-authored-by: Parthvi Goswami <parthvigoswami@Parthvis-MacBook-Pro.local>
* Change Segment CDN to our proxy (#17714)
* chore: Fixing prettier formatting for AnalyticsUtil.tsx
* chore: Adding base repository function to add user permissions to generic domain object (#17733)
## Description
Adding base function to set the user permissions for a user in any domain object.
As part of this, we also add default permission group to the `SeedMongoData`. Without this fix, the JUnit tests go into an infinite loop. Also fixing the `ExampleWorkspaceClonerTest` file.
## Type of change
- Bug fix (non-breaking change which fixes an issue)
## How Has This Been Tested?
- JUnit
## Checklist:
- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
* Update top contributors
Signed-off-by: Shrikant Sharat Kandula <shrikant@appsmith.com>
Co-authored-by: Nikhil Nandagopal <nikhil.nandagopal@gmail.com>
Co-authored-by: Nidhi <nidhi@appsmith.com>
Co-authored-by: Sangeeth Sivan <74818788+berzerkeer@users.noreply.github.com>
Co-authored-by: Trisha Anand <trisha@appsmith.com>
Co-authored-by: Arpit Mohan <mohanarpit@users.noreply.github.com>
Co-authored-by: Shrikant Sharat Kandula <shrikant@appsmith.com>
Co-authored-by: f0c1s <anubhav@appsmith.com>
Co-authored-by: Dhruvik Neharia <dhruvik@appsmith.com>
Co-authored-by: Hetu Nandu <hetu@appsmith.com>
Co-authored-by: Nilesh Sarupriya <nilesh@appsmith.com>
Co-authored-by: Anagh Hegde <anagh@appsmith.com>
Co-authored-by: arunvjn <32433245+arunvjn@users.noreply.github.com>
Co-authored-by: Appsmith Bot <74705725+appsmith-bot@users.noreply.github.com>
Co-authored-by: Vaibhav Tanwar <40293928+vaibh1297@users.noreply.github.com>
Co-authored-by: subratadeypappu <subrata@appsmith.com>
Co-authored-by: ChandanBalajiBP <chandan@appsmith.com>
Co-authored-by: Ankita Kinger <ankita@appsmith.com>
Co-authored-by: ChandanBalajiBP <104058110+ChandanBalajiBP@users.noreply.github.com>
Co-authored-by: Vishnu Gp <vishnu@appsmith.com>
Co-authored-by: Keyur Paralkar <keyur@appsmith.com>
Co-authored-by: sneha122 <sneha@appsmith.com>
Co-authored-by: Tanvi Bhakta <tanvibhakta@gmail.com>
Co-authored-by: sanjus-robotic-studio <58104863+sanjus-robotic-studio@users.noreply.github.com>
Co-authored-by: Ayush Pahwa <ayush@appsmith.com>
Co-authored-by: Parthvi <80334441+Parthvi12@users.noreply.github.com>
Co-authored-by: Parthvi Goswami <parthvigoswami@Parthvis-MacBook-Pro.local>
Co-authored-by: Arpit Mohan <arpit@appsmith.com>
Signed-off-by: Shrikant Sharat Kandula <shrikant@appsmith.com>
Co-authored-by: albinAppsmith <87797149+albinAppsmith@users.noreply.github.com>
Co-authored-by: Nikhil Nandagopal <nikhil.nandagopal@gmail.com>
Co-authored-by: Nidhi <nidhi@appsmith.com>
Co-authored-by: Sangeeth Sivan <74818788+berzerkeer@users.noreply.github.com>
Co-authored-by: Trisha Anand <trisha@appsmith.com>
Co-authored-by: Arpit Mohan <mohanarpit@users.noreply.github.com>
Co-authored-by: Shrikant Sharat Kandula <shrikant@appsmith.com>
Co-authored-by: f0c1s <anubhav@appsmith.com>
Co-authored-by: Dhruvik Neharia <dhruvik@appsmith.com>
Co-authored-by: Hetu Nandu <hetu@appsmith.com>
Co-authored-by: Nilesh Sarupriya <nilesh@appsmith.com>
Co-authored-by: Anagh Hegde <anagh@appsmith.com>
Co-authored-by: arunvjn <32433245+arunvjn@users.noreply.github.com>
Co-authored-by: Appsmith Bot <74705725+appsmith-bot@users.noreply.github.com>
Co-authored-by: Vaibhav Tanwar <40293928+vaibh1297@users.noreply.github.com>
Co-authored-by: subratadeypappu <subrata@appsmith.com>
Co-authored-by: ChandanBalajiBP <chandan@appsmith.com>
Co-authored-by: Ankita Kinger <ankita@appsmith.com>
Co-authored-by: ChandanBalajiBP <104058110+ChandanBalajiBP@users.noreply.github.com>
Co-authored-by: Vishnu Gp <vishnu@appsmith.com>
Co-authored-by: Keyur Paralkar <keyur@appsmith.com>
Co-authored-by: sneha122 <sneha@appsmith.com>
Co-authored-by: sanjus-robotic-studio <58104863+sanjus-robotic-studio@users.noreply.github.com>
Co-authored-by: Ayush Pahwa <ayush@appsmith.com>
Co-authored-by: Parthvi <80334441+Parthvi12@users.noreply.github.com>
Co-authored-by: Parthvi Goswami <parthvigoswami@Parthvis-MacBook-Pro.local>
Co-authored-by: Arpit Mohan <arpit@appsmith.com>
2022-10-31 01:24:47 +00:00
import { Toaster , Variant } from "design-system" ;
2022-02-11 18:08:46 +00:00
import {
createMessage ,
ERROR_ACTION_RENAME_FAIL ,
} from "@appsmith/constants/messages" ;
2021-06-03 04:58:18 +00:00
import {
2022-09-21 09:40:36 +00:00
getContentTypeHeaderValue ,
2021-06-03 04:58:18 +00:00
getIndextoUpdate ,
parseUrlForQueryParams ,
queryParamsRegEx ,
} from "utils/ApiPaneUtils" ;
2021-12-07 09:45:18 +00:00
import { updateReplayEntity } from "actions/pageActions" ;
import { ENTITY_TYPE } from "entities/AppsmithConsole" ;
2022-03-25 10:43:26 +00:00
import { Plugin } from "api/PluginApi" ;
2022-02-22 11:02:43 +00:00
import { getDisplayFormat } from "selectors/apiPaneSelectors" ;
2022-03-25 10:43:26 +00:00
import {
apiEditorIdURL ,
datasourcesEditorIdURL ,
integrationEditorURL ,
} from "RouteBuilder" ;
2022-07-11 04:06:29 +00:00
import { getCurrentPageId } from "selectors/editorSelectors" ;
2022-11-30 05:59:45 +00:00
import {
CreateDatasourceSuccessAction ,
removeTempDatasource ,
} from "actions/datasourceActions" ;
2019-11-25 09:15:11 +00:00
2019-12-23 12:12:58 +00:00
function * syncApiParamsSaga (
actionPayload : ReduxActionWithMeta < string , { field : string } > ,
2020-07-14 06:53:33 +00:00
actionId : string ,
2019-12-23 12:12:58 +00:00
) {
const field = actionPayload . meta . field ;
2021-05-06 13:15:05 +00:00
//Payload here contains the path and query params of a typical url like https://{domain}/{path}?{query_params}
2021-06-03 04:58:18 +00:00
const value = actionPayload . payload ;
2021-05-06 13:15:05 +00:00
// Regular expression to find the query params group
2020-09-24 04:47:37 +00:00
PerformanceTracker . startTracking ( PerformanceTransactionName . SYNC_PARAMS_SAGA ) ;
2019-12-23 12:12:58 +00:00
if ( field === "actionConfiguration.path" ) {
2021-06-03 04:58:18 +00:00
const params = parseUrlForQueryParams ( value ) ;
yield put (
autofill (
API_EDITOR_FORM_NAME ,
"actionConfiguration.queryParameters" ,
params ,
) ,
) ;
yield put (
setActionProperty ( {
actionId : actionId ,
propertyName : "actionConfiguration.queryParameters" ,
value : params ,
} ) ,
) ;
2019-12-23 12:12:58 +00:00
} else if ( field . includes ( "actionConfiguration.queryParameters" ) ) {
const { values } = yield select ( getFormData , API_EDITOR_FORM_NAME ) ;
2019-12-30 13:05:37 +00:00
const path = values . actionConfiguration . path || "" ;
2021-05-06 13:15:05 +00:00
const matchGroups = path . match ( queryParamsRegEx ) || [ ] ;
const currentPath = matchGroups [ 1 ] || "" ;
2019-12-23 12:12:58 +00:00
const paramsString = values . actionConfiguration . queryParameters
. filter ( ( p : Property ) = > p . key )
. map (
( p : Property , i : number ) = > ` ${ i === 0 ? "?" : "&" } ${ p . key } = ${ p . value } ` ,
)
. join ( "" ) ;
yield put (
autofill (
API_EDITOR_FORM_NAME ,
"actionConfiguration.path" ,
` ${ currentPath } ${ paramsString } ` ,
) ,
) ;
}
2020-09-24 04:47:37 +00:00
PerformanceTracker . stopTracking ( ) ;
2019-12-23 12:12:58 +00:00
}
2021-07-07 03:46:16 +00:00
function * redirectToNewIntegrations (
2021-07-29 08:13:10 +00:00
action : ReduxAction < {
pageId : string ;
params? : Record < string , string > ;
} > ,
2021-07-07 03:46:16 +00:00
) {
history . push (
2022-03-25 10:43:26 +00:00
integrationEditorURL ( {
pageId : action.payload.pageId ,
selectedTab : INTEGRATION_TABS.ACTIVE ,
params : {
. . . action . payload . params ,
mode : INTEGRATION_EDITOR_MODES.AUTO ,
} ,
} ) ,
2021-07-07 03:46:16 +00:00
) ;
}
2021-03-01 14:57:15 +00:00
function * handleUpdateBodyContentType (
feat: Support body in GET API requests (#7127)
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* adds apiContentType to actionConfiguration.formData object
* Handling apiContentType property in Rest API formData
* change apiContentType when user types content-type value and switches http method
* makes api editor as similar as possible to postman, project postman.
* Correcting the import in ApiEditorConstants
* Resolved all merge conflicts
* replay DSL functtionality
* removes unneccessary files from worker
* Fixes type declarations, naming e.t.c.
* fix server side merge conflicts
* fix client side merge conflicts
* fix failing cypress tests
Co-authored-by: Irongade <adeoluayangade@yahoo.com>
Co-authored-by: Ayangade Adeoluwa <37867493+Irongade@users.noreply.github.com>
2022-02-15 11:13:48 +00:00
action : ReduxAction < { title : string ; apiId : string } > ,
2021-03-01 14:57:15 +00:00
) {
2021-05-13 08:35:39 +00:00
const { apiId , title } = action . payload ;
2021-03-01 14:57:15 +00:00
const { values } = yield select ( getFormData , API_EDITOR_FORM_NAME ) ;
2022-02-22 11:02:43 +00:00
// this is the previous value gotten before the new content type has been set
feat: Support body in GET API requests (#7127)
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* adds apiContentType to actionConfiguration.formData object
* Handling apiContentType property in Rest API formData
* change apiContentType when user types content-type value and switches http method
* makes api editor as similar as possible to postman, project postman.
* Correcting the import in ApiEditorConstants
* Resolved all merge conflicts
* replay DSL functtionality
* removes unneccessary files from worker
* Fixes type declarations, naming e.t.c.
* fix server side merge conflicts
* fix client side merge conflicts
* fix failing cypress tests
Co-authored-by: Irongade <adeoluayangade@yahoo.com>
Co-authored-by: Ayangade Adeoluwa <37867493+Irongade@users.noreply.github.com>
2022-02-15 11:13:48 +00:00
const previousContentType =
2022-02-16 03:17:13 +00:00
values . actionConfiguration ? . formData ? . apiContentType ;
feat: Support body in GET API requests (#7127)
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* adds apiContentType to actionConfiguration.formData object
* Handling apiContentType property in Rest API formData
* change apiContentType when user types content-type value and switches http method
* makes api editor as similar as possible to postman, project postman.
* Correcting the import in ApiEditorConstants
* Resolved all merge conflicts
* replay DSL functtionality
* removes unneccessary files from worker
* Fixes type declarations, naming e.t.c.
* fix server side merge conflicts
* fix client side merge conflicts
* fix failing cypress tests
Co-authored-by: Irongade <adeoluayangade@yahoo.com>
Co-authored-by: Ayangade Adeoluwa <37867493+Irongade@users.noreply.github.com>
2022-02-15 11:13:48 +00:00
const displayFormatValue = POST_BODY_FORMAT_OPTIONS_ARRAY . find (
( el ) = > el === title ,
2021-03-01 14:57:15 +00:00
) ;
feat: Support body in GET API requests (#7127)
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* adds apiContentType to actionConfiguration.formData object
* Handling apiContentType property in Rest API formData
* change apiContentType when user types content-type value and switches http method
* makes api editor as similar as possible to postman, project postman.
* Correcting the import in ApiEditorConstants
* Resolved all merge conflicts
* replay DSL functtionality
* removes unneccessary files from worker
* Fixes type declarations, naming e.t.c.
* fix server side merge conflicts
* fix client side merge conflicts
* fix failing cypress tests
Co-authored-by: Irongade <adeoluayangade@yahoo.com>
Co-authored-by: Ayangade Adeoluwa <37867493+Irongade@users.noreply.github.com>
2022-02-15 11:13:48 +00:00
if ( ! displayFormatValue ) {
2021-03-01 14:57:15 +00:00
log . error ( "Display format not supported" , title ) ;
return ;
}
feat: Support body in GET API requests (#7127)
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* adds apiContentType to actionConfiguration.formData object
* Handling apiContentType property in Rest API formData
* change apiContentType when user types content-type value and switches http method
* makes api editor as similar as possible to postman, project postman.
* Correcting the import in ApiEditorConstants
* Resolved all merge conflicts
* replay DSL functtionality
* removes unneccessary files from worker
* Fixes type declarations, naming e.t.c.
* fix server side merge conflicts
* fix client side merge conflicts
* fix failing cypress tests
Co-authored-by: Irongade <adeoluayangade@yahoo.com>
Co-authored-by: Ayangade Adeoluwa <37867493+Irongade@users.noreply.github.com>
2022-02-15 11:13:48 +00:00
2022-02-22 11:02:43 +00:00
// this is the update for the new apicontentType
// Quick Context: APiContentype is the field that represents the content type the user wants while in RAW mode.
// users should be able to set the content type to whatever they want.
feat: Support body in GET API requests (#7127)
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* adds apiContentType to actionConfiguration.formData object
* Handling apiContentType property in Rest API formData
* change apiContentType when user types content-type value and switches http method
* makes api editor as similar as possible to postman, project postman.
* Correcting the import in ApiEditorConstants
* Resolved all merge conflicts
* replay DSL functtionality
* removes unneccessary files from worker
* Fixes type declarations, naming e.t.c.
* fix server side merge conflicts
* fix client side merge conflicts
* fix failing cypress tests
Co-authored-by: Irongade <adeoluayangade@yahoo.com>
Co-authored-by: Ayangade Adeoluwa <37867493+Irongade@users.noreply.github.com>
2022-02-15 11:13:48 +00:00
let formData = { . . . values . actionConfiguration . formData } ;
if ( formData === undefined ) formData = { } ;
2022-02-22 11:02:43 +00:00
formData [ "apiContentType" ] =
2022-04-12 11:13:11 +00:00
title === POST_BODY_FORMAT_OPTIONS . NONE ? previousContentType : title ;
feat: Support body in GET API requests (#7127)
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* adds apiContentType to actionConfiguration.formData object
* Handling apiContentType property in Rest API formData
* change apiContentType when user types content-type value and switches http method
* makes api editor as similar as possible to postman, project postman.
* Correcting the import in ApiEditorConstants
* Resolved all merge conflicts
* replay DSL functtionality
* removes unneccessary files from worker
* Fixes type declarations, naming e.t.c.
* fix server side merge conflicts
* fix client side merge conflicts
* fix failing cypress tests
Co-authored-by: Irongade <adeoluayangade@yahoo.com>
Co-authored-by: Ayangade Adeoluwa <37867493+Irongade@users.noreply.github.com>
2022-02-15 11:13:48 +00:00
yield put (
change ( API_EDITOR_FORM_NAME , "actionConfiguration.formData" , formData ) ,
) ;
2022-02-22 11:02:43 +00:00
// Quick Context: The extra formadata action is responsible for updating the current multi switch mode you see on api editor body tab
// whenever a user selects a new content type through the tab e.g application/json, this action is dispatched to update that value, which is then read in the PostDataBody file
// to show the appropriate content type section.
yield put ( {
type : ReduxActionTypes . SET_EXTRA_FORMDATA ,
payload : {
id : apiId ,
values : {
displayFormat : {
label : title ,
value : title ,
2021-03-01 14:57:15 +00:00
} ,
} ,
2022-02-22 11:02:43 +00:00
} ,
} ) ;
2021-03-01 14:57:15 +00:00
const headers = cloneDeep ( values . actionConfiguration . headers ) ;
const contentTypeHeaderIndex = headers . findIndex (
( element : { key : string ; value : string } ) = >
element &&
element . key &&
element . key . trim ( ) . toLowerCase ( ) === CONTENT_TYPE_HEADER_KEY ,
) ;
2021-03-23 09:44:44 +00:00
const indexToUpdate = getIndextoUpdate ( headers , contentTypeHeaderIndex ) ;
2021-03-01 14:57:15 +00:00
2022-06-18 06:26:45 +00:00
// If the user has selected "None" as the body type & there was a content-type
feat: Support body in GET API requests (#7127)
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* adds apiContentType to actionConfiguration.formData object
* Handling apiContentType property in Rest API formData
* change apiContentType when user types content-type value and switches http method
* makes api editor as similar as possible to postman, project postman.
* Correcting the import in ApiEditorConstants
* Resolved all merge conflicts
* replay DSL functtionality
* removes unneccessary files from worker
* Fixes type declarations, naming e.t.c.
* fix server side merge conflicts
* fix client side merge conflicts
* fix failing cypress tests
Co-authored-by: Irongade <adeoluayangade@yahoo.com>
Co-authored-by: Ayangade Adeoluwa <37867493+Irongade@users.noreply.github.com>
2022-02-15 11:13:48 +00:00
// header present in the API configuration, keep the previous content type header
2022-06-18 06:26:45 +00:00
// this is done to ensure user input isn't cleared off if they switch to none mode.
2022-02-22 11:02:43 +00:00
// however if the user types in a new value, we use the updated value (formValueChangeSaga - line 426).
feat: Support body in GET API requests (#7127)
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* adds apiContentType to actionConfiguration.formData object
* Handling apiContentType property in Rest API formData
* change apiContentType when user types content-type value and switches http method
* makes api editor as similar as possible to postman, project postman.
* Correcting the import in ApiEditorConstants
* Resolved all merge conflicts
* replay DSL functtionality
* removes unneccessary files from worker
* Fixes type declarations, naming e.t.c.
* fix server side merge conflicts
* fix client side merge conflicts
* fix failing cypress tests
Co-authored-by: Irongade <adeoluayangade@yahoo.com>
Co-authored-by: Ayangade Adeoluwa <37867493+Irongade@users.noreply.github.com>
2022-02-15 11:13:48 +00:00
if (
2022-04-12 11:13:11 +00:00
displayFormatValue === POST_BODY_FORMAT_OPTIONS . NONE &&
feat: Support body in GET API requests (#7127)
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* adds apiContentType to actionConfiguration.formData object
* Handling apiContentType property in Rest API formData
* change apiContentType when user types content-type value and switches http method
* makes api editor as similar as possible to postman, project postman.
* Correcting the import in ApiEditorConstants
* Resolved all merge conflicts
* replay DSL functtionality
* removes unneccessary files from worker
* Fixes type declarations, naming e.t.c.
* fix server side merge conflicts
* fix client side merge conflicts
* fix failing cypress tests
Co-authored-by: Irongade <adeoluayangade@yahoo.com>
Co-authored-by: Ayangade Adeoluwa <37867493+Irongade@users.noreply.github.com>
2022-02-15 11:13:48 +00:00
indexToUpdate !== - 1
) {
2022-06-18 06:26:45 +00:00
//Checking if any type was seleccted before
if ( contentTypeHeaderIndex !== - 1 ) {
headers [ indexToUpdate ] = {
key : previousContentType ? CONTENT_TYPE_HEADER_KEY : "" ,
value : previousContentType ? previousContentType : "" ,
} ;
}
feat: Support body in GET API requests (#7127)
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* adds apiContentType to actionConfiguration.formData object
* Handling apiContentType property in Rest API formData
* change apiContentType when user types content-type value and switches http method
* makes api editor as similar as possible to postman, project postman.
* Correcting the import in ApiEditorConstants
* Resolved all merge conflicts
* replay DSL functtionality
* removes unneccessary files from worker
* Fixes type declarations, naming e.t.c.
* fix server side merge conflicts
* fix client side merge conflicts
* fix failing cypress tests
Co-authored-by: Irongade <adeoluayangade@yahoo.com>
Co-authored-by: Ayangade Adeoluwa <37867493+Irongade@users.noreply.github.com>
2022-02-15 11:13:48 +00:00
} else {
headers [ indexToUpdate ] = {
key : CONTENT_TYPE_HEADER_KEY ,
value : displayFormatValue ,
} ;
}
2021-03-01 14:57:15 +00:00
2022-02-22 11:02:43 +00:00
// update the new header values.
2021-03-01 14:57:15 +00:00
yield put (
change ( API_EDITOR_FORM_NAME , "actionConfiguration.headers" , headers ) ,
) ;
feat: Support body in GET API requests (#7127)
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* adds apiContentType to actionConfiguration.formData object
* Handling apiContentType property in Rest API formData
* change apiContentType when user types content-type value and switches http method
* makes api editor as similar as possible to postman, project postman.
* Correcting the import in ApiEditorConstants
* Resolved all merge conflicts
* replay DSL functtionality
* removes unneccessary files from worker
* Fixes type declarations, naming e.t.c.
* fix server side merge conflicts
* fix client side merge conflicts
* fix failing cypress tests
Co-authored-by: Irongade <adeoluayangade@yahoo.com>
Co-authored-by: Ayangade Adeoluwa <37867493+Irongade@users.noreply.github.com>
2022-02-15 11:13:48 +00:00
const bodyFormData = cloneDeep ( values . actionConfiguration . bodyFormData ) ;
2021-08-25 10:48:17 +00:00
if (
feat: Support body in GET API requests (#7127)
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* adds apiContentType to actionConfiguration.formData object
* Handling apiContentType property in Rest API formData
* change apiContentType when user types content-type value and switches http method
* makes api editor as similar as possible to postman, project postman.
* Correcting the import in ApiEditorConstants
* Resolved all merge conflicts
* replay DSL functtionality
* removes unneccessary files from worker
* Fixes type declarations, naming e.t.c.
* fix server side merge conflicts
* fix client side merge conflicts
* fix failing cypress tests
Co-authored-by: Irongade <adeoluayangade@yahoo.com>
Co-authored-by: Ayangade Adeoluwa <37867493+Irongade@users.noreply.github.com>
2022-02-15 11:13:48 +00:00
displayFormatValue === POST_BODY_FORMAT_OPTIONS . FORM_URLENCODED ||
displayFormatValue === POST_BODY_FORMAT_OPTIONS . MULTIPART_FORM_DATA
2021-08-25 10:48:17 +00:00
) {
2021-03-01 14:57:15 +00:00
if ( ! bodyFormData || bodyFormData . length === 0 ) {
yield put (
change (
API_EDITOR_FORM_NAME ,
"actionConfiguration.bodyFormData" ,
EMPTY_KEY_VALUE_PAIRS . slice ( ) ,
) ,
) ;
}
}
}
2022-04-12 11:13:11 +00:00
function * updateExtraFormDataSaga() {
2022-06-21 13:57:34 +00:00
const formData : GetFormData = yield select ( getFormData , API_EDITOR_FORM_NAME ) ;
2020-05-07 07:56:37 +00:00
const { values } = formData ;
2022-02-22 11:02:43 +00:00
// when initializing, check if theres a display format present, if not use Json display format as default.
2022-06-21 13:57:34 +00:00
const extraFormData : GetFormData = yield select ( getDisplayFormat , values . id ) ;
2022-02-22 11:02:43 +00:00
2022-04-12 11:13:11 +00:00
const headers : Array < { key : string ; value : string } > =
get ( values , "actionConfiguration.headers" ) || [ ] ;
2022-09-21 09:40:36 +00:00
const contentTypeValue : string = getContentTypeHeaderValue ( headers ) ;
2022-04-12 11:13:11 +00:00
let rawApiContentType ;
2022-02-22 11:02:43 +00:00
if ( ! extraFormData ) {
2022-04-12 11:13:11 +00:00
/ *
* Checking if the content - type header exists , if yes then set the body format type one of the three json , multipart or url encoded whichever matches else set raw as default
* /
if (
[
POST_BODY_FORMAT_OPTIONS . JSON ,
POST_BODY_FORMAT_OPTIONS . FORM_URLENCODED ,
POST_BODY_FORMAT_OPTIONS . MULTIPART_FORM_DATA ,
] . includes ( contentTypeValue )
) {
rawApiContentType = contentTypeValue ;
2022-06-01 10:29:58 +00:00
} else if (
contentTypeValue === "" ||
contentTypeValue === POST_BODY_FORMAT_OPTIONS . NONE
) {
rawApiContentType = POST_BODY_FORMAT_OPTIONS . NONE ;
2022-04-12 11:13:11 +00:00
} else {
rawApiContentType = POST_BODY_FORMAT_OPTIONS . RAW ;
}
} else {
if (
[
POST_BODY_FORMAT_OPTIONS . JSON ,
POST_BODY_FORMAT_OPTIONS . FORM_URLENCODED ,
POST_BODY_FORMAT_OPTIONS . MULTIPART_FORM_DATA ,
] . includes ( contentTypeValue )
) {
rawApiContentType = contentTypeValue ;
2022-06-01 10:29:58 +00:00
} else if (
contentTypeValue === "" ||
contentTypeValue === POST_BODY_FORMAT_OPTIONS . NONE
) {
rawApiContentType = POST_BODY_FORMAT_OPTIONS . NONE ;
2022-04-12 11:13:11 +00:00
} else {
rawApiContentType = POST_BODY_FORMAT_OPTIONS . RAW ;
}
2020-05-07 07:56:37 +00:00
}
2022-04-12 11:13:11 +00:00
yield call ( setHeaderFormat , values . id , rawApiContentType ) ;
2020-05-07 07:56:37 +00:00
}
2021-05-04 13:08:20 +00:00
function * changeApiSaga (
2021-12-07 09:45:18 +00:00
actionPayload : ReduxAction < { id : string ; isSaas : boolean ; action? : Action } > ,
2021-05-04 13:08:20 +00:00
) {
2020-09-24 04:47:37 +00:00
PerformanceTracker . startTracking ( PerformanceTransactionName . CHANGE_API_SAGA ) ;
2021-05-04 13:08:20 +00:00
const { id , isSaas } = actionPayload . payload ;
2021-12-07 09:45:18 +00:00
let { action } = actionPayload . payload ;
if ( ! action ) action = yield select ( getAction , id ) ;
2020-05-07 07:09:07 +00:00
if ( ! action ) return ;
2021-05-04 13:08:20 +00:00
if ( isSaas ) {
2022-04-07 16:18:49 +00:00
yield put ( initialize ( QUERY_EDITOR_FORM_NAME , action ) ) ;
2021-05-04 13:08:20 +00:00
} else {
yield put ( initialize ( API_EDITOR_FORM_NAME , action ) ) ;
2020-05-07 07:56:37 +00:00
2022-04-12 11:13:11 +00:00
yield call ( updateExtraFormDataSaga ) ;
2020-05-07 07:56:37 +00:00
2021-05-04 13:08:20 +00:00
if (
action . actionConfiguration &&
action . actionConfiguration . queryParameters ? . length
) {
// Sync the api params my mocking a change action
yield call (
syncApiParamsSaga ,
{
type : ReduxFormActionTypes . ARRAY_REMOVE ,
payload : action.actionConfiguration.queryParameters ,
meta : {
field : "actionConfiguration.queryParameters" ,
} ,
2020-07-14 06:53:33 +00:00
} ,
2021-05-04 13:08:20 +00:00
id ,
) ;
}
2019-12-30 13:05:37 +00:00
}
2021-05-04 13:08:20 +00:00
2021-12-07 09:45:18 +00:00
//Retrieve form data with synced query params to start tracking change history.
const { values : actionPostProcess } = yield select (
getFormData ,
API_EDITOR_FORM_NAME ,
) ;
2020-09-24 04:47:37 +00:00
PerformanceTracker . stopTracking ( ) ;
2021-12-07 09:45:18 +00:00
yield put ( updateReplayEntity ( id , actionPostProcess , ENTITY_TYPE . ACTION ) ) ;
2019-11-25 09:15:11 +00:00
}
feat: Support body in GET API requests (#7127)
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* adds apiContentType to actionConfiguration.formData object
* Handling apiContentType property in Rest API formData
* change apiContentType when user types content-type value and switches http method
* makes api editor as similar as possible to postman, project postman.
* Correcting the import in ApiEditorConstants
* Resolved all merge conflicts
* replay DSL functtionality
* removes unneccessary files from worker
* Fixes type declarations, naming e.t.c.
* fix server side merge conflicts
* fix client side merge conflicts
* fix failing cypress tests
Co-authored-by: Irongade <adeoluayangade@yahoo.com>
Co-authored-by: Ayangade Adeoluwa <37867493+Irongade@users.noreply.github.com>
2022-02-15 11:13:48 +00:00
function * setHeaderFormat ( apiId : string , apiContentType? : string ) {
// use the current apiContentType to set appropriate Headers for action
2021-04-26 05:41:32 +00:00
let displayFormat ;
2022-02-22 11:02:43 +00:00
feat: Support body in GET API requests (#7127)
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* adds apiContentType to actionConfiguration.formData object
* Handling apiContentType property in Rest API formData
* change apiContentType when user types content-type value and switches http method
* makes api editor as similar as possible to postman, project postman.
* Correcting the import in ApiEditorConstants
* Resolved all merge conflicts
* replay DSL functtionality
* removes unneccessary files from worker
* Fixes type declarations, naming e.t.c.
* fix server side merge conflicts
* fix client side merge conflicts
* fix failing cypress tests
Co-authored-by: Irongade <adeoluayangade@yahoo.com>
Co-authored-by: Ayangade Adeoluwa <37867493+Irongade@users.noreply.github.com>
2022-02-15 11:13:48 +00:00
if ( apiContentType ) {
if ( apiContentType === POST_BODY_FORMAT_OPTIONS . NONE ) {
displayFormat = {
label : POST_BODY_FORMAT_OPTIONS.NONE ,
value : POST_BODY_FORMAT_OPTIONS.NONE ,
} ;
} else if (
apiContentType !== POST_BODY_FORMAT_OPTIONS . NONE &&
Object . values ( POST_BODY_FORMAT_OPTIONS ) . includes ( apiContentType )
2021-04-26 05:41:32 +00:00
) {
displayFormat = {
feat: Support body in GET API requests (#7127)
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* adds apiContentType to actionConfiguration.formData object
* Handling apiContentType property in Rest API formData
* change apiContentType when user types content-type value and switches http method
* makes api editor as similar as possible to postman, project postman.
* Correcting the import in ApiEditorConstants
* Resolved all merge conflicts
* replay DSL functtionality
* removes unneccessary files from worker
* Fixes type declarations, naming e.t.c.
* fix server side merge conflicts
* fix client side merge conflicts
* fix failing cypress tests
Co-authored-by: Irongade <adeoluayangade@yahoo.com>
Co-authored-by: Ayangade Adeoluwa <37867493+Irongade@users.noreply.github.com>
2022-02-15 11:13:48 +00:00
label : apiContentType ,
value : apiContentType ,
2021-04-26 05:41:32 +00:00
} ;
} else {
feat: Support body in GET API requests (#7127)
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* adds apiContentType to actionConfiguration.formData object
* Handling apiContentType property in Rest API formData
* change apiContentType when user types content-type value and switches http method
* makes api editor as similar as possible to postman, project postman.
* Correcting the import in ApiEditorConstants
* Resolved all merge conflicts
* replay DSL functtionality
* removes unneccessary files from worker
* Fixes type declarations, naming e.t.c.
* fix server side merge conflicts
* fix client side merge conflicts
* fix failing cypress tests
Co-authored-by: Irongade <adeoluayangade@yahoo.com>
Co-authored-by: Ayangade Adeoluwa <37867493+Irongade@users.noreply.github.com>
2022-02-15 11:13:48 +00:00
displayFormat = {
label : POST_BODY_FORMAT_OPTIONS.RAW ,
value : POST_BODY_FORMAT_OPTIONS.RAW ,
} ;
2021-04-26 05:41:32 +00:00
}
}
yield put ( {
type : ReduxActionTypes . SET_EXTRA_FORMDATA ,
payload : {
id : apiId ,
values : {
displayFormat ,
} ,
} ,
} ) ;
}
2021-12-07 09:45:18 +00:00
export function * updateFormFields (
2020-04-14 12:34:14 +00:00
actionPayload : ReduxActionWithMeta < string , { field : string } > ,
) {
const field = actionPayload . meta . field ;
const value = actionPayload . payload ;
feat: Support body in GET API requests (#7127)
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* adds apiContentType to actionConfiguration.formData object
* Handling apiContentType property in Rest API formData
* change apiContentType when user types content-type value and switches http method
* makes api editor as similar as possible to postman, project postman.
* Correcting the import in ApiEditorConstants
* Resolved all merge conflicts
* replay DSL functtionality
* removes unneccessary files from worker
* Fixes type declarations, naming e.t.c.
* fix server side merge conflicts
* fix client side merge conflicts
* fix failing cypress tests
Co-authored-by: Irongade <adeoluayangade@yahoo.com>
Co-authored-by: Ayangade Adeoluwa <37867493+Irongade@users.noreply.github.com>
2022-02-15 11:13:48 +00:00
log . debug ( "updateFormFields: " + JSON . stringify ( value ) ) ;
2020-07-03 08:58:58 +00:00
const { values } = yield select ( getFormData , API_EDITOR_FORM_NAME ) ;
2020-04-14 12:34:14 +00:00
2022-02-22 11:02:43 +00:00
// get current content type of the action
2022-03-03 15:32:59 +00:00
let apiContentType =
values ? . actionConfiguration ? . formData ? . apiContentType ||
POST_BODY_FORMAT_OPTIONS . JSON ;
2022-04-12 11:13:11 +00:00
let extraFormDataToBeChanged = false ;
2020-04-14 12:34:14 +00:00
if ( field === "actionConfiguration.httpMethod" ) {
2021-03-16 14:27:21 +00:00
const { actionConfiguration } = values ;
feat: Support body in GET API requests (#7127)
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* adds apiContentType to actionConfiguration.formData object
* Handling apiContentType property in Rest API formData
* change apiContentType when user types content-type value and switches http method
* makes api editor as similar as possible to postman, project postman.
* Correcting the import in ApiEditorConstants
* Resolved all merge conflicts
* replay DSL functtionality
* removes unneccessary files from worker
* Fixes type declarations, naming e.t.c.
* fix server side merge conflicts
* fix client side merge conflicts
* fix failing cypress tests
Co-authored-by: Irongade <adeoluayangade@yahoo.com>
Co-authored-by: Ayangade Adeoluwa <37867493+Irongade@users.noreply.github.com>
2022-02-15 11:13:48 +00:00
if ( ! actionConfiguration . headers ) return ;
2021-03-16 14:27:21 +00:00
const actionConfigurationHeaders = cloneDeep ( actionConfiguration . headers ) ;
feat: Support body in GET API requests (#7127)
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* adds apiContentType to actionConfiguration.formData object
* Handling apiContentType property in Rest API formData
* change apiContentType when user types content-type value and switches http method
* makes api editor as similar as possible to postman, project postman.
* Correcting the import in ApiEditorConstants
* Resolved all merge conflicts
* replay DSL functtionality
* removes unneccessary files from worker
* Fixes type declarations, naming e.t.c.
* fix server side merge conflicts
* fix client side merge conflicts
* fix failing cypress tests
Co-authored-by: Irongade <adeoluayangade@yahoo.com>
Co-authored-by: Ayangade Adeoluwa <37867493+Irongade@users.noreply.github.com>
2022-02-15 11:13:48 +00:00
const contentTypeHeaderIndex = actionConfigurationHeaders . findIndex (
( header : { key : string ; value : string } ) = >
header ? . key ? . trim ( ) . toLowerCase ( ) === CONTENT_TYPE_HEADER_KEY ,
) ;
2022-06-01 10:29:58 +00:00
const indexToUpdate = getIndextoUpdate (
actionConfigurationHeaders ,
contentTypeHeaderIndex ,
) ;
2022-06-18 06:26:45 +00:00
//When user switches to GET method, content type remains same (empty or any type)
//This condition handles other HTTP methods
feat: Support body in GET API requests (#7127)
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* adds apiContentType to actionConfiguration.formData object
* Handling apiContentType property in Rest API formData
* change apiContentType when user types content-type value and switches http method
* makes api editor as similar as possible to postman, project postman.
* Correcting the import in ApiEditorConstants
* Resolved all merge conflicts
* replay DSL functtionality
* removes unneccessary files from worker
* Fixes type declarations, naming e.t.c.
* fix server side merge conflicts
* fix client side merge conflicts
* fix failing cypress tests
Co-authored-by: Irongade <adeoluayangade@yahoo.com>
Co-authored-by: Ayangade Adeoluwa <37867493+Irongade@users.noreply.github.com>
2022-02-15 11:13:48 +00:00
if ( value !== HTTP_METHOD . GET ) {
// if user switches to other methods that is not GET and apiContentType is undefined set default apiContentType to JSON.
2022-04-12 11:13:11 +00:00
if ( apiContentType === POST_BODY_FORMAT_OPTIONS . NONE ) {
apiContentType =
HTTP_METHODS_DEFAULT_FORMAT_TYPES [ value as HTTP_METHOD ] ;
extraFormDataToBeChanged = true ;
}
feat: Support body in GET API requests (#7127)
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* adds apiContentType to actionConfiguration.formData object
* Handling apiContentType property in Rest API formData
* change apiContentType when user types content-type value and switches http method
* makes api editor as similar as possible to postman, project postman.
* Correcting the import in ApiEditorConstants
* Resolved all merge conflicts
* replay DSL functtionality
* removes unneccessary files from worker
* Fixes type declarations, naming e.t.c.
* fix server side merge conflicts
* fix client side merge conflicts
* fix failing cypress tests
Co-authored-by: Irongade <adeoluayangade@yahoo.com>
Co-authored-by: Ayangade Adeoluwa <37867493+Irongade@users.noreply.github.com>
2022-02-15 11:13:48 +00:00
actionConfigurationHeaders [ indexToUpdate ] = {
key : CONTENT_TYPE_HEADER_KEY ,
value : apiContentType ,
} ;
2020-04-14 12:34:14 +00:00
}
2022-02-22 11:02:43 +00:00
feat: Support body in GET API requests (#7127)
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* adds apiContentType to actionConfiguration.formData object
* Handling apiContentType property in Rest API formData
* change apiContentType when user types content-type value and switches http method
* makes api editor as similar as possible to postman, project postman.
* Correcting the import in ApiEditorConstants
* Resolved all merge conflicts
* replay DSL functtionality
* removes unneccessary files from worker
* Fixes type declarations, naming e.t.c.
* fix server side merge conflicts
* fix client side merge conflicts
* fix failing cypress tests
Co-authored-by: Irongade <adeoluayangade@yahoo.com>
Co-authored-by: Ayangade Adeoluwa <37867493+Irongade@users.noreply.github.com>
2022-02-15 11:13:48 +00:00
yield put (
change (
API_EDITOR_FORM_NAME ,
"actionConfiguration.headers" ,
actionConfigurationHeaders ,
) ,
) ;
2022-04-12 11:13:11 +00:00
if ( extraFormDataToBeChanged ) yield call ( updateExtraFormDataSaga ) ;
2020-04-14 12:34:14 +00:00
}
}
2020-07-03 08:58:58 +00:00
function * formValueChangeSaga (
actionPayload : ReduxActionWithMeta < string , { field : string ; form : string } > ,
2020-06-04 13:49:22 +00:00
) {
2021-05-13 08:35:39 +00:00
const { field , form } = actionPayload . meta ;
2020-07-03 08:58:58 +00:00
if ( form !== API_EDITOR_FORM_NAME ) return ;
2020-07-06 13:35:31 +00:00
if ( field === "dynamicBindingPathList" || field === "name" ) return ;
2020-06-04 13:49:22 +00:00
const { values } = yield select ( getFormData , API_EDITOR_FORM_NAME ) ;
if ( ! values . id ) return ;
feat: Support body in GET API requests (#7127)
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* adds apiContentType to actionConfiguration.formData object
* Handling apiContentType property in Rest API formData
* change apiContentType when user types content-type value and switches http method
* makes api editor as similar as possible to postman, project postman.
* Correcting the import in ApiEditorConstants
* Resolved all merge conflicts
* replay DSL functtionality
* removes unneccessary files from worker
* Fixes type declarations, naming e.t.c.
* fix server side merge conflicts
* fix client side merge conflicts
* fix failing cypress tests
Co-authored-by: Irongade <adeoluayangade@yahoo.com>
Co-authored-by: Ayangade Adeoluwa <37867493+Irongade@users.noreply.github.com>
2022-02-15 11:13:48 +00:00
const contentTypeHeaderIndex = values . actionConfiguration . headers . findIndex (
( header : { key : string ; value : string } ) = >
header ? . key ? . trim ( ) . toLowerCase ( ) === CONTENT_TYPE_HEADER_KEY ,
) ;
2020-07-03 08:58:58 +00:00
if (
actionPayload . type === ReduxFormActionTypes . ARRAY_REMOVE ||
actionPayload . type === ReduxFormActionTypes . ARRAY_PUSH
) {
Feature/entity browse (#220)
# New Feature: Entity Explorer
- Entities are actions (apis and queries), datasources, pages, and widgets
- With this new feature, all entities in the application will be available
to view in the new entity explorer sidebar
- All existing application features from the api sidebar, query sidebar, datasource sidebar and pages sidebar
now are avialable on the entity explorer sidebar
- Users are now able to quickly switch to any entity in the application from the entity explorer sidebar.
- Users can also search all entities in the application from the new sidebar. Use cmd + f or ctrl + f to focus on the search input
- Users can rename entities from the new sidebar
- Users can also perform contextual actions on these entities like set a page as home page, copy/move actions, delete entity, etc from the context menu available alongside the entities in the sidebar
- Users can view the properties of the entities in the sidebar, as well as copy bindings to use in the application.
2020-08-10 08:52:45 +00:00
const value = get ( values , field ) ;
2020-07-14 06:53:33 +00:00
yield put (
setActionProperty ( {
actionId : values.id ,
propertyName : field ,
value ,
} ) ,
) ;
2020-07-03 08:58:58 +00:00
} else {
2020-06-12 08:35:52 +00:00
yield put (
2020-07-03 08:58:58 +00:00
setActionProperty ( {
actionId : values.id ,
propertyName : field ,
value : actionPayload.payload ,
} ) ,
2020-06-12 08:35:52 +00:00
) ;
feat: Support body in GET API requests (#7127)
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* adds apiContentType to actionConfiguration.formData object
* Handling apiContentType property in Rest API formData
* change apiContentType when user types content-type value and switches http method
* makes api editor as similar as possible to postman, project postman.
* Correcting the import in ApiEditorConstants
* Resolved all merge conflicts
* replay DSL functtionality
* removes unneccessary files from worker
* Fixes type declarations, naming e.t.c.
* fix server side merge conflicts
* fix client side merge conflicts
* fix failing cypress tests
Co-authored-by: Irongade <adeoluayangade@yahoo.com>
Co-authored-by: Ayangade Adeoluwa <37867493+Irongade@users.noreply.github.com>
2022-02-15 11:13:48 +00:00
// when user types a content type value, update actionConfiguration.formData.apiContent type as well.
2022-02-22 11:02:43 +00:00
// we don't do this initally because we want to specifically catch user editing the content-type value
feat: Support body in GET API requests (#7127)
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* adds apiContentType to actionConfiguration.formData object
* Handling apiContentType property in Rest API formData
* change apiContentType when user types content-type value and switches http method
* makes api editor as similar as possible to postman, project postman.
* Correcting the import in ApiEditorConstants
* Resolved all merge conflicts
* replay DSL functtionality
* removes unneccessary files from worker
* Fixes type declarations, naming e.t.c.
* fix server side merge conflicts
* fix client side merge conflicts
* fix failing cypress tests
Co-authored-by: Irongade <adeoluayangade@yahoo.com>
Co-authored-by: Ayangade Adeoluwa <37867493+Irongade@users.noreply.github.com>
2022-02-15 11:13:48 +00:00
if (
field === ` actionConfiguration.headers[ ${ contentTypeHeaderIndex } ].value `
) {
2022-02-22 11:02:43 +00:00
yield put (
change (
API_EDITOR_FORM_NAME ,
"actionConfiguration.formData.apiContentType" ,
actionPayload . payload ,
) ,
) ;
const apiId = get ( values , "id" ) ;
// when the user specifically sets a new content type value, we check if the input value is a supported post body type and switch to it
// if it does not we set the default to Raw mode.
yield call ( setHeaderFormat , apiId , actionPayload . payload ) ;
feat: Support body in GET API requests (#7127)
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* WIP
* Refactoring HTTP Method & Content Type to be objects instead of arrays
TODO:
1. Set the default content-type for Get request to "None". Currently, it's raw
2. For None content-type, don't send the body field in the API request
* Almost working implementation for the None type
Currently, the body still gets sent in non-GET requests even if the None tab is selected.
* Adding object.freeze to prevent any modifications to HTTP_METHOD_ENUM
* WIP: Using enum & const for ts autocomplete
* working implementation for NONE type, apiContentType prop added to API actions
* adds apiContentType to actionConfiguration.formData object
* Handling apiContentType property in Rest API formData
* change apiContentType when user types content-type value and switches http method
* makes api editor as similar as possible to postman, project postman.
* Correcting the import in ApiEditorConstants
* Resolved all merge conflicts
* replay DSL functtionality
* removes unneccessary files from worker
* Fixes type declarations, naming e.t.c.
* fix server side merge conflicts
* fix client side merge conflicts
* fix failing cypress tests
Co-authored-by: Irongade <adeoluayangade@yahoo.com>
Co-authored-by: Ayangade Adeoluwa <37867493+Irongade@users.noreply.github.com>
2022-02-15 11:13:48 +00:00
}
2020-06-12 08:35:52 +00:00
}
2019-12-23 12:12:58 +00:00
yield all ( [
2020-07-14 06:53:33 +00:00
call ( syncApiParamsSaga , actionPayload , values . id ) ,
2020-04-14 12:34:14 +00:00
call ( updateFormFields , actionPayload ) ,
2019-12-23 12:12:58 +00:00
] ) ;
2021-12-07 09:45:18 +00:00
// We need to refetch form values here since syncApuParams saga and updateFormFields directly update reform form values.
const { values : formValuesPostProcess } = yield select (
getFormData ,
API_EDITOR_FORM_NAME ,
) ;
yield put (
updateReplayEntity (
formValuesPostProcess . id ,
formValuesPostProcess ,
ENTITY_TYPE . ACTION ,
) ,
) ;
2019-11-25 09:15:11 +00:00
}
2019-12-23 12:12:58 +00:00
2021-01-12 04:17:28 +00:00
function * handleActionCreatedSaga ( actionPayload : ReduxAction < Action > ) {
2020-05-05 07:50:30 +00:00
const { id , pluginType } = actionPayload . payload ;
2022-06-21 13:57:34 +00:00
const action : Action | undefined = yield select ( getAction , id ) ;
const data = action ? { . . . action } : { } ;
2022-07-11 04:06:29 +00:00
const pageId : string = yield select ( getCurrentPageId ) ;
2020-05-05 07:50:30 +00:00
2021-04-22 03:30:09 +00:00
if ( pluginType === PluginType . API ) {
Feature/entity browse (#220)
# New Feature: Entity Explorer
- Entities are actions (apis and queries), datasources, pages, and widgets
- With this new feature, all entities in the application will be available
to view in the new entity explorer sidebar
- All existing application features from the api sidebar, query sidebar, datasource sidebar and pages sidebar
now are avialable on the entity explorer sidebar
- Users are now able to quickly switch to any entity in the application from the entity explorer sidebar.
- Users can also search all entities in the application from the new sidebar. Use cmd + f or ctrl + f to focus on the search input
- Users can rename entities from the new sidebar
- Users can also perform contextual actions on these entities like set a page as home page, copy/move actions, delete entity, etc from the context menu available alongside the entities in the sidebar
- Users can view the properties of the entities in the sidebar, as well as copy bindings to use in the application.
2020-08-10 08:52:45 +00:00
yield put ( initialize ( API_EDITOR_FORM_NAME , omit ( data , "name" ) ) ) ;
2020-07-06 05:38:39 +00:00
history . push (
2022-03-25 10:43:26 +00:00
apiEditorIdURL ( {
2022-07-11 04:06:29 +00:00
pageId ,
2022-03-25 10:43:26 +00:00
apiId : id ,
params : {
editName : "true" ,
from : "datasources" ,
} ,
2020-07-06 05:38:39 +00:00
} ) ,
) ;
2020-05-05 07:50:30 +00:00
}
2019-11-25 09:15:11 +00:00
}
2022-11-30 05:59:45 +00:00
function * handleDatasourceCreatedSaga (
actionPayload : CreateDatasourceSuccessAction ,
) {
2022-06-21 13:57:34 +00:00
const plugin : Plugin | undefined = yield select (
2022-03-25 10:43:26 +00:00
getPlugin ,
actionPayload . payload . pluginId ,
) ;
2022-07-11 04:06:29 +00:00
const pageId : string = yield select ( getCurrentPageId ) ;
2021-04-22 03:30:09 +00:00
// Only look at API plugins
2022-06-21 13:57:34 +00:00
if ( plugin && plugin . type !== PluginType . API ) return ;
2021-04-22 03:30:09 +00:00
2022-11-30 05:59:45 +00:00
const actionRouteInfo : Partial < {
apiId : string ;
datasourceId : string ;
pageId : string ;
applicationId : string ;
} > = yield select ( getDatasourceActionRouteInfo ) ;
// This will ensure that API if saved as datasource, will get attached with datasource
// once the datasource is saved
if ( ! ! actionRouteInfo . apiId ) {
yield put (
setActionProperty ( {
actionId : actionRouteInfo.apiId ,
propertyName : "datasource" ,
value : actionPayload.payload ,
} ) ,
) ;
// we need to wait for action to be updated with respective datasource,
// before redirecting back to action page, hence added take operator to
// wait for update action to be complete.
yield take ( ReduxActionTypes . UPDATE_ACTION_SUCCESS ) ;
yield put ( {
type : ReduxActionTypes . STORE_AS_DATASOURCE_COMPLETE ,
} ) ;
// temp datasource data is deleted here, because we need temp data before
// redirecting to api page, otherwise it will lead to invalid url page
yield put ( removeTempDatasource ( ) ) ;
}
const { redirect } = actionPayload ;
// redirect back to api page
if ( actionRouteInfo && redirect ) {
history . push (
apiEditorIdURL ( {
pageId : actionRouteInfo?.pageId ? ? "" ,
apiId : actionRouteInfo.apiId ? ? "" ,
} ) ,
) ;
} else {
history . push (
datasourcesEditorIdURL ( {
pageId ,
datasourceId : actionPayload.payload.id ,
params : {
from : "datasources" ,
. . . getQueryParams ( ) ,
pluginId : plugin?.id ,
} ,
} ) ,
) ;
}
2021-04-22 03:30:09 +00:00
}
2022-09-09 15:59:47 +00:00
/ * *
* Creates an API with datasource as DEFAULT_REST_DATASOURCE ( No user created datasource )
* @param action
* /
2020-04-20 08:26:19 +00:00
function * handleCreateNewApiActionSaga (
2022-09-09 15:59:47 +00:00
action : ReduxAction < {
pageId : string ;
from : EventLocation ;
apiType? : string ;
} > ,
2020-04-20 08:26:19 +00:00
) {
2022-06-15 15:37:41 +00:00
const workspaceId : string = yield select ( getCurrentWorkspaceId ) ;
2022-10-17 15:16:38 +00:00
const { pageId , apiType = PluginPackageName . REST_API } = action . payload ;
2022-09-09 15:59:47 +00:00
const pluginId : string = yield select ( getPluginIdOfPackageName , apiType ) ;
// Default Config is Rest Api Plugin Config
let defaultConfig = DEFAULT_CREATE_API_CONFIG ;
2022-10-17 15:16:38 +00:00
if ( apiType === PluginPackageName . GRAPHQL ) {
2022-09-09 15:59:47 +00:00
defaultConfig = DEFAULT_CREATE_GRAPHQL_CONFIG ;
}
2020-04-20 08:26:19 +00:00
if ( pageId && pluginId ) {
2022-06-21 13:57:34 +00:00
const actions : ActionDataState = yield select ( getActions ) ;
2020-04-20 08:26:19 +00:00
const pageActions = actions . filter (
( a : ActionData ) = > a . config . pageId === pageId ,
) ;
const newActionName = createNewApiName ( pageActions , pageId ) ;
2021-02-16 15:01:35 +00:00
// Note: Do NOT send pluginId on top level here.
// It breaks embedded rest datasource flow.
2020-04-20 08:26:19 +00:00
yield put (
createActionRequest ( {
2022-09-09 15:59:47 +00:00
actionConfiguration : defaultConfig.config ,
2020-04-20 08:26:19 +00:00
name : newActionName ,
datasource : {
2022-09-09 15:59:47 +00:00
name : defaultConfig.datasource.name ,
2020-04-20 08:26:19 +00:00
pluginId ,
2022-06-15 15:37:41 +00:00
workspaceId ,
2020-04-20 08:26:19 +00:00
} ,
2020-10-06 15:10:21 +00:00
eventData : {
2022-09-09 15:59:47 +00:00
actionType : defaultConfig.eventData.actionType ,
2020-10-06 15:10:21 +00:00
from : action . payload . from ,
} ,
2020-04-20 08:26:19 +00:00
pageId ,
2021-01-12 04:17:28 +00:00
} as ApiAction ) , // We don't have recursive partial in typescript for now.
2020-04-20 08:26:19 +00:00
) ;
}
}
2020-08-19 09:21:32 +00:00
function * handleApiNameChangeSaga (
action : ReduxAction < { id : string ; name : string } > ,
) {
2020-06-18 14:16:49 +00:00
yield put ( change ( API_EDITOR_FORM_NAME , "name" , action . payload . name ) ) ;
}
2020-08-19 09:21:32 +00:00
function * handleApiNameChangeSuccessSaga (
action : ReduxAction < { actionId : string } > ,
) {
const { actionId } = action . payload ;
2022-06-21 13:57:34 +00:00
const actionObj : Action | undefined = yield select ( getAction , actionId ) ;
2020-08-19 09:21:32 +00:00
yield take ( ReduxActionTypes . FETCH_ACTIONS_FOR_PAGE_SUCCESS ) ;
2020-12-14 16:22:45 +00:00
if ( ! actionObj ) {
// Error case, log to sentry
Toaster . show ( {
2021-04-20 06:56:30 +00:00
text : createMessage ( ERROR_ACTION_RENAME_FAIL , "" ) ,
2020-12-14 16:22:45 +00:00
variant : Variant.danger ,
} ) ;
2021-03-13 14:24:45 +00:00
Sentry . captureException (
2021-04-20 06:56:30 +00:00
new Error ( createMessage ( ERROR_ACTION_RENAME_FAIL , "" ) ) ,
2021-03-13 14:24:45 +00:00
{
extra : {
actionId : actionId ,
} ,
2020-12-14 16:22:45 +00:00
} ,
2021-03-13 14:24:45 +00:00
) ;
2020-12-14 16:22:45 +00:00
return ;
}
2021-04-22 03:30:09 +00:00
if ( actionObj . pluginType === PluginType . API ) {
const params = getQueryParams ( ) ;
if ( params . editName ) {
params . editName = "false" ;
}
2022-03-25 10:43:26 +00:00
history . push (
apiEditorIdURL ( {
2022-07-11 04:06:29 +00:00
pageId : actionObj.pageId ,
2022-03-25 10:43:26 +00:00
apiId : actionId ,
params ,
} ) ,
) ;
2021-04-22 03:30:09 +00:00
}
2020-08-19 09:21:32 +00:00
}
2020-06-18 14:16:49 +00:00
function * handleApiNameChangeFailureSaga (
action : ReduxAction < { oldName : string } > ,
) {
yield put ( change ( API_EDITOR_FORM_NAME , "name" , action . payload . oldName ) ) ;
}
2019-11-25 09:15:11 +00:00
export default function * root() {
yield all ( [
takeEvery ( ReduxActionTypes . API_PANE_CHANGE_API , changeApiSaga ) ,
takeEvery ( ReduxActionTypes . CREATE_ACTION_SUCCESS , handleActionCreatedSaga ) ,
2021-04-22 03:30:09 +00:00
takeEvery (
ReduxActionTypes . CREATE_DATASOURCE_SUCCESS ,
handleDatasourceCreatedSaga ,
) ,
Feature/entity browse (#220)
# New Feature: Entity Explorer
- Entities are actions (apis and queries), datasources, pages, and widgets
- With this new feature, all entities in the application will be available
to view in the new entity explorer sidebar
- All existing application features from the api sidebar, query sidebar, datasource sidebar and pages sidebar
now are avialable on the entity explorer sidebar
- Users are now able to quickly switch to any entity in the application from the entity explorer sidebar.
- Users can also search all entities in the application from the new sidebar. Use cmd + f or ctrl + f to focus on the search input
- Users can rename entities from the new sidebar
- Users can also perform contextual actions on these entities like set a page as home page, copy/move actions, delete entity, etc from the context menu available alongside the entities in the sidebar
- Users can view the properties of the entities in the sidebar, as well as copy bindings to use in the application.
2020-08-10 08:52:45 +00:00
takeEvery ( ReduxActionTypes . SAVE_ACTION_NAME_INIT , handleApiNameChangeSaga ) ,
2020-08-19 09:21:32 +00:00
takeEvery (
ReduxActionTypes . SAVE_ACTION_NAME_SUCCESS ,
handleApiNameChangeSuccessSaga ,
) ,
2020-06-18 14:16:49 +00:00
takeEvery (
2020-08-18 08:48:06 +00:00
ReduxActionErrorTypes . SAVE_ACTION_NAME_ERROR ,
2020-06-18 14:16:49 +00:00
handleApiNameChangeFailureSaga ,
) ,
2020-04-20 08:26:19 +00:00
takeEvery (
ReduxActionTypes . CREATE_NEW_API_ACTION ,
handleCreateNewApiActionSaga ,
) ,
2021-03-01 14:57:15 +00:00
takeEvery (
ReduxActionTypes . UPDATE_API_ACTION_BODY_CONTENT_TYPE ,
handleUpdateBodyContentType ,
) ,
2021-07-07 03:46:16 +00:00
takeEvery (
ReduxActionTypes . REDIRECT_TO_NEW_INTEGRATIONS ,
redirectToNewIntegrations ,
) ,
2019-12-23 12:12:58 +00:00
// Intercepting the redux-form change actionType
takeEvery ( ReduxFormActionTypes . VALUE_CHANGE , formValueChangeSaga ) ,
takeEvery ( ReduxFormActionTypes . ARRAY_REMOVE , formValueChangeSaga ) ,
2020-04-14 12:34:14 +00:00
takeEvery ( ReduxFormActionTypes . ARRAY_PUSH , formValueChangeSaga ) ,
2019-11-25 09:15:11 +00:00
] ) ;
}