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" ;
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" ;
chore: upgrade to prettier v2 + enforce import types (#21013)Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
## Description
This PR upgrades Prettier to v2 + enforces TypeScript’s [`import
type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export)
syntax where applicable. It’s submitted as a separate PR so we can merge
it easily.
As a part of this PR, we reformat the codebase heavily:
- add `import type` everywhere where it’s required, and
- re-format the code to account for Prettier 2’s breaking changes:
https://prettier.io/blog/2020/03/21/2.0.0.html#breaking-changes
This PR is submitted against `release` to make sure all new code by team
members will adhere to new formatting standards, and we’ll have fewer
conflicts when merging `bundle-optimizations` into `release`. (I’ll
merge `release` back into `bundle-optimizations` once this PR is
merged.)
### Why is this needed?
This PR is needed because, for the Lodash optimization from
https://github.com/appsmithorg/appsmith/commit/7cbb12af886621256224be0c93e6a465dd710ad3,
we need to use `import type`. Otherwise, `babel-plugin-lodash` complains
that `LoDashStatic` is not a lodash function.
However, just using `import type` in the current codebase will give you
this:
<img width="962" alt="Screenshot 2023-03-08 at 17 45 59"
src="https://user-images.githubusercontent.com/2953267/223775744-407afa0c-e8b9-44a1-90f9-b879348da57f.png">
That’s because Prettier 1 can’t parse `import type` at all. To parse it,
we need to upgrade to Prettier 2.
### Why enforce `import type`?
Apart from just enabling `import type` support, this PR enforces
specifying `import type` everywhere it’s needed. (Developers will get
immediate TypeScript and ESLint errors when they forget to do so.)
I’m doing this because I believe `import type` improves DX and makes
refactorings easier.
Let’s say you had a few imports like below. Can you tell which of these
imports will increase the bundle size? (Tip: it’s not all of them!)
```ts
// app/client/src/workers/Linting/utils.ts
import { Position } from "codemirror";
import { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
It’s pretty hard, right?
What about now?
```ts
// app/client/src/workers/Linting/utils.ts
import type { Position } from "codemirror";
import type { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
Now, it’s clear that only `lodash` will be bundled.
This helps developers to see which imports are problematic, but it
_also_ helps with refactorings. Now, if you want to see where
`codemirror` is bundled, you can just grep for `import \{.*\} from
"codemirror"` – and you won’t get any type-only imports.
This also helps (some) bundlers. Upon transpiling, TypeScript erases
type-only imports completely. In some environment (not ours), this makes
the bundle smaller, as the bundler doesn’t need to bundle type-only
imports anymore.
## Type of change
- Chore (housekeeping or task changes that don't impact user perception)
## How Has This Been Tested?
This was tested to not break the build.
### Test Plan
> Add Testsmith test cases links that relate to this PR
### Issues raised during DP testing
> Link issues raised during DP testing for better visiblity and tracking
(copy link from comments dropped on this PR)
## Checklist:
### Dev activity
- [x] 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
- [x] 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
- [ ] PR is being merged under a feature flag
### QA activity:
- [ ] Test plan has been approved by relevant developers
- [ ] Test plan has been peer reviewed by QA
- [ ] Cypress test cases have been added and approved by either SDET or
manual QA
- [ ] Organized project review call with relevant stakeholders after
Round 1/2 of QA
- [ ] Added Test Plan Approved label after reveiwing all Cypress test
---------
Co-authored-by: Satish Gandham <hello@satishgandham.com>
Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2023-03-16 11:41:47 +00:00
import type {
2019-11-25 09:15:11 +00:00
ReduxAction ,
chore: upgrade to prettier v2 + enforce import types (#21013)Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
## Description
This PR upgrades Prettier to v2 + enforces TypeScript’s [`import
type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export)
syntax where applicable. It’s submitted as a separate PR so we can merge
it easily.
As a part of this PR, we reformat the codebase heavily:
- add `import type` everywhere where it’s required, and
- re-format the code to account for Prettier 2’s breaking changes:
https://prettier.io/blog/2020/03/21/2.0.0.html#breaking-changes
This PR is submitted against `release` to make sure all new code by team
members will adhere to new formatting standards, and we’ll have fewer
conflicts when merging `bundle-optimizations` into `release`. (I’ll
merge `release` back into `bundle-optimizations` once this PR is
merged.)
### Why is this needed?
This PR is needed because, for the Lodash optimization from
https://github.com/appsmithorg/appsmith/commit/7cbb12af886621256224be0c93e6a465dd710ad3,
we need to use `import type`. Otherwise, `babel-plugin-lodash` complains
that `LoDashStatic` is not a lodash function.
However, just using `import type` in the current codebase will give you
this:
<img width="962" alt="Screenshot 2023-03-08 at 17 45 59"
src="https://user-images.githubusercontent.com/2953267/223775744-407afa0c-e8b9-44a1-90f9-b879348da57f.png">
That’s because Prettier 1 can’t parse `import type` at all. To parse it,
we need to upgrade to Prettier 2.
### Why enforce `import type`?
Apart from just enabling `import type` support, this PR enforces
specifying `import type` everywhere it’s needed. (Developers will get
immediate TypeScript and ESLint errors when they forget to do so.)
I’m doing this because I believe `import type` improves DX and makes
refactorings easier.
Let’s say you had a few imports like below. Can you tell which of these
imports will increase the bundle size? (Tip: it’s not all of them!)
```ts
// app/client/src/workers/Linting/utils.ts
import { Position } from "codemirror";
import { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
It’s pretty hard, right?
What about now?
```ts
// app/client/src/workers/Linting/utils.ts
import type { Position } from "codemirror";
import type { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
Now, it’s clear that only `lodash` will be bundled.
This helps developers to see which imports are problematic, but it
_also_ helps with refactorings. Now, if you want to see where
`codemirror` is bundled, you can just grep for `import \{.*\} from
"codemirror"` – and you won’t get any type-only imports.
This also helps (some) bundlers. Upon transpiling, TypeScript erases
type-only imports completely. In some environment (not ours), this makes
the bundle smaller, as the bundler doesn’t need to bundle type-only
imports anymore.
## Type of change
- Chore (housekeeping or task changes that don't impact user perception)
## How Has This Been Tested?
This was tested to not break the build.
### Test Plan
> Add Testsmith test cases links that relate to this PR
### Issues raised during DP testing
> Link issues raised during DP testing for better visiblity and tracking
(copy link from comments dropped on this PR)
## Checklist:
### Dev activity
- [x] 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
- [x] 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
- [ ] PR is being merged under a feature flag
### QA activity:
- [ ] Test plan has been approved by relevant developers
- [ ] Test plan has been peer reviewed by QA
- [ ] Cypress test cases have been added and approved by either SDET or
manual QA
- [ ] Organized project review call with relevant stakeholders after
Round 1/2 of QA
- [ ] Added Test Plan Approved label after reveiwing all Cypress test
---------
Co-authored-by: Satish Gandham <hello@satishgandham.com>
Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2023-03-16 11:41:47 +00:00
ReduxActionWithMeta ,
} from "@appsmith/constants/ReduxActionConstants" ;
import {
2020-06-18 14:16:49 +00:00
ReduxActionErrorTypes ,
2019-11-25 09:15:11 +00:00
ReduxActionTypes ,
ReduxFormActionTypes ,
2022-04-12 10:50:01 +00:00
} from "@appsmith/constants/ReduxActionConstants" ;
chore: upgrade to prettier v2 + enforce import types (#21013)Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
## Description
This PR upgrades Prettier to v2 + enforces TypeScript’s [`import
type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export)
syntax where applicable. It’s submitted as a separate PR so we can merge
it easily.
As a part of this PR, we reformat the codebase heavily:
- add `import type` everywhere where it’s required, and
- re-format the code to account for Prettier 2’s breaking changes:
https://prettier.io/blog/2020/03/21/2.0.0.html#breaking-changes
This PR is submitted against `release` to make sure all new code by team
members will adhere to new formatting standards, and we’ll have fewer
conflicts when merging `bundle-optimizations` into `release`. (I’ll
merge `release` back into `bundle-optimizations` once this PR is
merged.)
### Why is this needed?
This PR is needed because, for the Lodash optimization from
https://github.com/appsmithorg/appsmith/commit/7cbb12af886621256224be0c93e6a465dd710ad3,
we need to use `import type`. Otherwise, `babel-plugin-lodash` complains
that `LoDashStatic` is not a lodash function.
However, just using `import type` in the current codebase will give you
this:
<img width="962" alt="Screenshot 2023-03-08 at 17 45 59"
src="https://user-images.githubusercontent.com/2953267/223775744-407afa0c-e8b9-44a1-90f9-b879348da57f.png">
That’s because Prettier 1 can’t parse `import type` at all. To parse it,
we need to upgrade to Prettier 2.
### Why enforce `import type`?
Apart from just enabling `import type` support, this PR enforces
specifying `import type` everywhere it’s needed. (Developers will get
immediate TypeScript and ESLint errors when they forget to do so.)
I’m doing this because I believe `import type` improves DX and makes
refactorings easier.
Let’s say you had a few imports like below. Can you tell which of these
imports will increase the bundle size? (Tip: it’s not all of them!)
```ts
// app/client/src/workers/Linting/utils.ts
import { Position } from "codemirror";
import { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
It’s pretty hard, right?
What about now?
```ts
// app/client/src/workers/Linting/utils.ts
import type { Position } from "codemirror";
import type { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
Now, it’s clear that only `lodash` will be bundled.
This helps developers to see which imports are problematic, but it
_also_ helps with refactorings. Now, if you want to see where
`codemirror` is bundled, you can just grep for `import \{.*\} from
"codemirror"` – and you won’t get any type-only imports.
This also helps (some) bundlers. Upon transpiling, TypeScript erases
type-only imports completely. In some environment (not ours), this makes
the bundle smaller, as the bundler doesn’t need to bundle type-only
imports anymore.
## Type of change
- Chore (housekeeping or task changes that don't impact user perception)
## How Has This Been Tested?
This was tested to not break the build.
### Test Plan
> Add Testsmith test cases links that relate to this PR
### Issues raised during DP testing
> Link issues raised during DP testing for better visiblity and tracking
(copy link from comments dropped on this PR)
## Checklist:
### Dev activity
- [x] 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
- [x] 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
- [ ] PR is being merged under a feature flag
### QA activity:
- [ ] Test plan has been approved by relevant developers
- [ ] Test plan has been peer reviewed by QA
- [ ] Cypress test cases have been added and approved by either SDET or
manual QA
- [ ] Organized project review call with relevant stakeholders after
Round 1/2 of QA
- [ ] Added Test Plan Approved label after reveiwing all Cypress test
---------
Co-authored-by: Satish Gandham <hello@satishgandham.com>
Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2023-03-16 11:41:47 +00:00
import type { GetFormData } from "selectors/formSelectors" ;
import { 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-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-12-01 06:30:50 +00:00
import { initialize , autofill , change , reset } from "redux-form" ;
chore: upgrade to prettier v2 + enforce import types (#21013)Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
## Description
This PR upgrades Prettier to v2 + enforces TypeScript’s [`import
type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export)
syntax where applicable. It’s submitted as a separate PR so we can merge
it easily.
As a part of this PR, we reformat the codebase heavily:
- add `import type` everywhere where it’s required, and
- re-format the code to account for Prettier 2’s breaking changes:
https://prettier.io/blog/2020/03/21/2.0.0.html#breaking-changes
This PR is submitted against `release` to make sure all new code by team
members will adhere to new formatting standards, and we’ll have fewer
conflicts when merging `bundle-optimizations` into `release`. (I’ll
merge `release` back into `bundle-optimizations` once this PR is
merged.)
### Why is this needed?
This PR is needed because, for the Lodash optimization from
https://github.com/appsmithorg/appsmith/commit/7cbb12af886621256224be0c93e6a465dd710ad3,
we need to use `import type`. Otherwise, `babel-plugin-lodash` complains
that `LoDashStatic` is not a lodash function.
However, just using `import type` in the current codebase will give you
this:
<img width="962" alt="Screenshot 2023-03-08 at 17 45 59"
src="https://user-images.githubusercontent.com/2953267/223775744-407afa0c-e8b9-44a1-90f9-b879348da57f.png">
That’s because Prettier 1 can’t parse `import type` at all. To parse it,
we need to upgrade to Prettier 2.
### Why enforce `import type`?
Apart from just enabling `import type` support, this PR enforces
specifying `import type` everywhere it’s needed. (Developers will get
immediate TypeScript and ESLint errors when they forget to do so.)
I’m doing this because I believe `import type` improves DX and makes
refactorings easier.
Let’s say you had a few imports like below. Can you tell which of these
imports will increase the bundle size? (Tip: it’s not all of them!)
```ts
// app/client/src/workers/Linting/utils.ts
import { Position } from "codemirror";
import { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
It’s pretty hard, right?
What about now?
```ts
// app/client/src/workers/Linting/utils.ts
import type { Position } from "codemirror";
import type { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
Now, it’s clear that only `lodash` will be bundled.
This helps developers to see which imports are problematic, but it
_also_ helps with refactorings. Now, if you want to see where
`codemirror` is bundled, you can just grep for `import \{.*\} from
"codemirror"` – and you won’t get any type-only imports.
This also helps (some) bundlers. Upon transpiling, TypeScript erases
type-only imports completely. In some environment (not ours), this makes
the bundle smaller, as the bundler doesn’t need to bundle type-only
imports anymore.
## Type of change
- Chore (housekeeping or task changes that don't impact user perception)
## How Has This Been Tested?
This was tested to not break the build.
### Test Plan
> Add Testsmith test cases links that relate to this PR
### Issues raised during DP testing
> Link issues raised during DP testing for better visiblity and tracking
(copy link from comments dropped on this PR)
## Checklist:
### Dev activity
- [x] 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
- [x] 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
- [ ] PR is being merged under a feature flag
### QA activity:
- [ ] Test plan has been approved by relevant developers
- [ ] Test plan has been peer reviewed by QA
- [ ] Cypress test cases have been added and approved by either SDET or
manual QA
- [ ] Organized project review call with relevant stakeholders after
Round 1/2 of QA
- [ ] Added Test Plan Approved label after reveiwing all Cypress test
---------
Co-authored-by: Satish Gandham <hello@satishgandham.com>
Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2023-03-16 11:41:47 +00:00
import type { 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" ;
chore: upgrade to prettier v2 + enforce import types (#21013)Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
## Description
This PR upgrades Prettier to v2 + enforces TypeScript’s [`import
type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export)
syntax where applicable. It’s submitted as a separate PR so we can merge
it easily.
As a part of this PR, we reformat the codebase heavily:
- add `import type` everywhere where it’s required, and
- re-format the code to account for Prettier 2’s breaking changes:
https://prettier.io/blog/2020/03/21/2.0.0.html#breaking-changes
This PR is submitted against `release` to make sure all new code by team
members will adhere to new formatting standards, and we’ll have fewer
conflicts when merging `bundle-optimizations` into `release`. (I’ll
merge `release` back into `bundle-optimizations` once this PR is
merged.)
### Why is this needed?
This PR is needed because, for the Lodash optimization from
https://github.com/appsmithorg/appsmith/commit/7cbb12af886621256224be0c93e6a465dd710ad3,
we need to use `import type`. Otherwise, `babel-plugin-lodash` complains
that `LoDashStatic` is not a lodash function.
However, just using `import type` in the current codebase will give you
this:
<img width="962" alt="Screenshot 2023-03-08 at 17 45 59"
src="https://user-images.githubusercontent.com/2953267/223775744-407afa0c-e8b9-44a1-90f9-b879348da57f.png">
That’s because Prettier 1 can’t parse `import type` at all. To parse it,
we need to upgrade to Prettier 2.
### Why enforce `import type`?
Apart from just enabling `import type` support, this PR enforces
specifying `import type` everywhere it’s needed. (Developers will get
immediate TypeScript and ESLint errors when they forget to do so.)
I’m doing this because I believe `import type` improves DX and makes
refactorings easier.
Let’s say you had a few imports like below. Can you tell which of these
imports will increase the bundle size? (Tip: it’s not all of them!)
```ts
// app/client/src/workers/Linting/utils.ts
import { Position } from "codemirror";
import { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
It’s pretty hard, right?
What about now?
```ts
// app/client/src/workers/Linting/utils.ts
import type { Position } from "codemirror";
import type { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
Now, it’s clear that only `lodash` will be bundled.
This helps developers to see which imports are problematic, but it
_also_ helps with refactorings. Now, if you want to see where
`codemirror` is bundled, you can just grep for `import \{.*\} from
"codemirror"` – and you won’t get any type-only imports.
This also helps (some) bundlers. Upon transpiling, TypeScript erases
type-only imports completely. In some environment (not ours), this makes
the bundle smaller, as the bundler doesn’t need to bundle type-only
imports anymore.
## Type of change
- Chore (housekeeping or task changes that don't impact user perception)
## How Has This Been Tested?
This was tested to not break the build.
### Test Plan
> Add Testsmith test cases links that relate to this PR
### Issues raised during DP testing
> Link issues raised during DP testing for better visiblity and tracking
(copy link from comments dropped on this PR)
## Checklist:
### Dev activity
- [x] 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
- [x] 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
- [ ] PR is being merged under a feature flag
### QA activity:
- [ ] Test plan has been approved by relevant developers
- [ ] Test plan has been peer reviewed by QA
- [ ] Cypress test cases have been added and approved by either SDET or
manual QA
- [ ] Organized project review call with relevant stakeholders after
Round 1/2 of QA
- [ ] Added Test Plan Approved label after reveiwing all Cypress test
---------
Co-authored-by: Satish Gandham <hello@satishgandham.com>
Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2023-03-16 11:41:47 +00:00
import type {
2022-06-21 13:57:34 +00:00
ActionData ,
ActionDataState ,
} from "reducers/entityReducers/actionsReducer" ;
2021-08-27 09:25:28 +00:00
import {
createActionRequest ,
setActionProperty ,
} from "actions/pluginActionActions" ;
chore: upgrade to prettier v2 + enforce import types (#21013)Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
## Description
This PR upgrades Prettier to v2 + enforces TypeScript’s [`import
type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export)
syntax where applicable. It’s submitted as a separate PR so we can merge
it easily.
As a part of this PR, we reformat the codebase heavily:
- add `import type` everywhere where it’s required, and
- re-format the code to account for Prettier 2’s breaking changes:
https://prettier.io/blog/2020/03/21/2.0.0.html#breaking-changes
This PR is submitted against `release` to make sure all new code by team
members will adhere to new formatting standards, and we’ll have fewer
conflicts when merging `bundle-optimizations` into `release`. (I’ll
merge `release` back into `bundle-optimizations` once this PR is
merged.)
### Why is this needed?
This PR is needed because, for the Lodash optimization from
https://github.com/appsmithorg/appsmith/commit/7cbb12af886621256224be0c93e6a465dd710ad3,
we need to use `import type`. Otherwise, `babel-plugin-lodash` complains
that `LoDashStatic` is not a lodash function.
However, just using `import type` in the current codebase will give you
this:
<img width="962" alt="Screenshot 2023-03-08 at 17 45 59"
src="https://user-images.githubusercontent.com/2953267/223775744-407afa0c-e8b9-44a1-90f9-b879348da57f.png">
That’s because Prettier 1 can’t parse `import type` at all. To parse it,
we need to upgrade to Prettier 2.
### Why enforce `import type`?
Apart from just enabling `import type` support, this PR enforces
specifying `import type` everywhere it’s needed. (Developers will get
immediate TypeScript and ESLint errors when they forget to do so.)
I’m doing this because I believe `import type` improves DX and makes
refactorings easier.
Let’s say you had a few imports like below. Can you tell which of these
imports will increase the bundle size? (Tip: it’s not all of them!)
```ts
// app/client/src/workers/Linting/utils.ts
import { Position } from "codemirror";
import { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
It’s pretty hard, right?
What about now?
```ts
// app/client/src/workers/Linting/utils.ts
import type { Position } from "codemirror";
import type { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
Now, it’s clear that only `lodash` will be bundled.
This helps developers to see which imports are problematic, but it
_also_ helps with refactorings. Now, if you want to see where
`codemirror` is bundled, you can just grep for `import \{.*\} from
"codemirror"` – and you won’t get any type-only imports.
This also helps (some) bundlers. Upon transpiling, TypeScript erases
type-only imports completely. In some environment (not ours), this makes
the bundle smaller, as the bundler doesn’t need to bundle type-only
imports anymore.
## Type of change
- Chore (housekeeping or task changes that don't impact user perception)
## How Has This Been Tested?
This was tested to not break the build.
### Test Plan
> Add Testsmith test cases links that relate to this PR
### Issues raised during DP testing
> Link issues raised during DP testing for better visiblity and tracking
(copy link from comments dropped on this PR)
## Checklist:
### Dev activity
- [x] 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
- [x] 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
- [ ] PR is being merged under a feature flag
### QA activity:
- [ ] Test plan has been approved by relevant developers
- [ ] Test plan has been peer reviewed by QA
- [ ] Cypress test cases have been added and approved by either SDET or
manual QA
- [ ] Organized project review call with relevant stakeholders after
Round 1/2 of QA
- [ ] Added Test Plan Approved label after reveiwing all Cypress test
---------
Co-authored-by: Satish Gandham <hello@satishgandham.com>
Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2023-03-16 11:41:47 +00:00
import type { Action , ApiAction } from "entities/Action" ;
import { 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" ;
2023-08-09 09:45:01 +00:00
import type { EventLocation } from "@appsmith/utils/analyticsUtilTypes" ;
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
parseUrlForQueryParams ,
queryParamsRegEx ,
} from "utils/ApiPaneUtils" ;
2021-12-07 09:45:18 +00:00
import { updateReplayEntity } from "actions/pageActions" ;
import { ENTITY_TYPE } from "entities/AppsmithConsole" ;
chore: upgrade to prettier v2 + enforce import types (#21013)Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
## Description
This PR upgrades Prettier to v2 + enforces TypeScript’s [`import
type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export)
syntax where applicable. It’s submitted as a separate PR so we can merge
it easily.
As a part of this PR, we reformat the codebase heavily:
- add `import type` everywhere where it’s required, and
- re-format the code to account for Prettier 2’s breaking changes:
https://prettier.io/blog/2020/03/21/2.0.0.html#breaking-changes
This PR is submitted against `release` to make sure all new code by team
members will adhere to new formatting standards, and we’ll have fewer
conflicts when merging `bundle-optimizations` into `release`. (I’ll
merge `release` back into `bundle-optimizations` once this PR is
merged.)
### Why is this needed?
This PR is needed because, for the Lodash optimization from
https://github.com/appsmithorg/appsmith/commit/7cbb12af886621256224be0c93e6a465dd710ad3,
we need to use `import type`. Otherwise, `babel-plugin-lodash` complains
that `LoDashStatic` is not a lodash function.
However, just using `import type` in the current codebase will give you
this:
<img width="962" alt="Screenshot 2023-03-08 at 17 45 59"
src="https://user-images.githubusercontent.com/2953267/223775744-407afa0c-e8b9-44a1-90f9-b879348da57f.png">
That’s because Prettier 1 can’t parse `import type` at all. To parse it,
we need to upgrade to Prettier 2.
### Why enforce `import type`?
Apart from just enabling `import type` support, this PR enforces
specifying `import type` everywhere it’s needed. (Developers will get
immediate TypeScript and ESLint errors when they forget to do so.)
I’m doing this because I believe `import type` improves DX and makes
refactorings easier.
Let’s say you had a few imports like below. Can you tell which of these
imports will increase the bundle size? (Tip: it’s not all of them!)
```ts
// app/client/src/workers/Linting/utils.ts
import { Position } from "codemirror";
import { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
It’s pretty hard, right?
What about now?
```ts
// app/client/src/workers/Linting/utils.ts
import type { Position } from "codemirror";
import type { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
Now, it’s clear that only `lodash` will be bundled.
This helps developers to see which imports are problematic, but it
_also_ helps with refactorings. Now, if you want to see where
`codemirror` is bundled, you can just grep for `import \{.*\} from
"codemirror"` – and you won’t get any type-only imports.
This also helps (some) bundlers. Upon transpiling, TypeScript erases
type-only imports completely. In some environment (not ours), this makes
the bundle smaller, as the bundler doesn’t need to bundle type-only
imports anymore.
## Type of change
- Chore (housekeeping or task changes that don't impact user perception)
## How Has This Been Tested?
This was tested to not break the build.
### Test Plan
> Add Testsmith test cases links that relate to this PR
### Issues raised during DP testing
> Link issues raised during DP testing for better visiblity and tracking
(copy link from comments dropped on this PR)
## Checklist:
### Dev activity
- [x] 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
- [x] 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
- [ ] PR is being merged under a feature flag
### QA activity:
- [ ] Test plan has been approved by relevant developers
- [ ] Test plan has been peer reviewed by QA
- [ ] Cypress test cases have been added and approved by either SDET or
manual QA
- [ ] Organized project review call with relevant stakeholders after
Round 1/2 of QA
- [ ] Added Test Plan Approved label after reveiwing all Cypress test
---------
Co-authored-by: Satish Gandham <hello@satishgandham.com>
Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2023-03-16 11:41:47 +00:00
import type { 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-12-01 06:30:50 +00:00
import { validateResponse } from "./ErrorSagas" ;
import { hasManageActionPermission } from "@appsmith/utils/permissionHelpers" ;
chore: upgrade to prettier v2 + enforce import types (#21013)Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
## Description
This PR upgrades Prettier to v2 + enforces TypeScript’s [`import
type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export)
syntax where applicable. It’s submitted as a separate PR so we can merge
it easily.
As a part of this PR, we reformat the codebase heavily:
- add `import type` everywhere where it’s required, and
- re-format the code to account for Prettier 2’s breaking changes:
https://prettier.io/blog/2020/03/21/2.0.0.html#breaking-changes
This PR is submitted against `release` to make sure all new code by team
members will adhere to new formatting standards, and we’ll have fewer
conflicts when merging `bundle-optimizations` into `release`. (I’ll
merge `release` back into `bundle-optimizations` once this PR is
merged.)
### Why is this needed?
This PR is needed because, for the Lodash optimization from
https://github.com/appsmithorg/appsmith/commit/7cbb12af886621256224be0c93e6a465dd710ad3,
we need to use `import type`. Otherwise, `babel-plugin-lodash` complains
that `LoDashStatic` is not a lodash function.
However, just using `import type` in the current codebase will give you
this:
<img width="962" alt="Screenshot 2023-03-08 at 17 45 59"
src="https://user-images.githubusercontent.com/2953267/223775744-407afa0c-e8b9-44a1-90f9-b879348da57f.png">
That’s because Prettier 1 can’t parse `import type` at all. To parse it,
we need to upgrade to Prettier 2.
### Why enforce `import type`?
Apart from just enabling `import type` support, this PR enforces
specifying `import type` everywhere it’s needed. (Developers will get
immediate TypeScript and ESLint errors when they forget to do so.)
I’m doing this because I believe `import type` improves DX and makes
refactorings easier.
Let’s say you had a few imports like below. Can you tell which of these
imports will increase the bundle size? (Tip: it’s not all of them!)
```ts
// app/client/src/workers/Linting/utils.ts
import { Position } from "codemirror";
import { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
It’s pretty hard, right?
What about now?
```ts
// app/client/src/workers/Linting/utils.ts
import type { Position } from "codemirror";
import type { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
Now, it’s clear that only `lodash` will be bundled.
This helps developers to see which imports are problematic, but it
_also_ helps with refactorings. Now, if you want to see where
`codemirror` is bundled, you can just grep for `import \{.*\} from
"codemirror"` – and you won’t get any type-only imports.
This also helps (some) bundlers. Upon transpiling, TypeScript erases
type-only imports completely. In some environment (not ours), this makes
the bundle smaller, as the bundler doesn’t need to bundle type-only
imports anymore.
## Type of change
- Chore (housekeeping or task changes that don't impact user perception)
## How Has This Been Tested?
This was tested to not break the build.
### Test Plan
> Add Testsmith test cases links that relate to this PR
### Issues raised during DP testing
> Link issues raised during DP testing for better visiblity and tracking
(copy link from comments dropped on this PR)
## Checklist:
### Dev activity
- [x] 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
- [x] 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
- [ ] PR is being merged under a feature flag
### QA activity:
- [ ] Test plan has been approved by relevant developers
- [ ] Test plan has been peer reviewed by QA
- [ ] Cypress test cases have been added and approved by either SDET or
manual QA
- [ ] Organized project review call with relevant stakeholders after
Round 1/2 of QA
- [ ] Added Test Plan Approved label after reveiwing all Cypress test
---------
Co-authored-by: Satish Gandham <hello@satishgandham.com>
Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2023-03-16 11:41:47 +00:00
import type { CreateDatasourceSuccessAction } from "actions/datasourceActions" ;
import { removeTempDatasource } from "actions/datasourceActions" ;
2023-02-24 12:18:48 +00:00
import { klona } from "klona/lite" ;
2023-05-19 18:37:06 +00:00
import { toast } from "design-system" ;
chore: upgrade to prettier v2 + enforce import types (#21013)Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
## Description
This PR upgrades Prettier to v2 + enforces TypeScript’s [`import
type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export)
syntax where applicable. It’s submitted as a separate PR so we can merge
it easily.
As a part of this PR, we reformat the codebase heavily:
- add `import type` everywhere where it’s required, and
- re-format the code to account for Prettier 2’s breaking changes:
https://prettier.io/blog/2020/03/21/2.0.0.html#breaking-changes
This PR is submitted against `release` to make sure all new code by team
members will adhere to new formatting standards, and we’ll have fewer
conflicts when merging `bundle-optimizations` into `release`. (I’ll
merge `release` back into `bundle-optimizations` once this PR is
merged.)
### Why is this needed?
This PR is needed because, for the Lodash optimization from
https://github.com/appsmithorg/appsmith/commit/7cbb12af886621256224be0c93e6a465dd710ad3,
we need to use `import type`. Otherwise, `babel-plugin-lodash` complains
that `LoDashStatic` is not a lodash function.
However, just using `import type` in the current codebase will give you
this:
<img width="962" alt="Screenshot 2023-03-08 at 17 45 59"
src="https://user-images.githubusercontent.com/2953267/223775744-407afa0c-e8b9-44a1-90f9-b879348da57f.png">
That’s because Prettier 1 can’t parse `import type` at all. To parse it,
we need to upgrade to Prettier 2.
### Why enforce `import type`?
Apart from just enabling `import type` support, this PR enforces
specifying `import type` everywhere it’s needed. (Developers will get
immediate TypeScript and ESLint errors when they forget to do so.)
I’m doing this because I believe `import type` improves DX and makes
refactorings easier.
Let’s say you had a few imports like below. Can you tell which of these
imports will increase the bundle size? (Tip: it’s not all of them!)
```ts
// app/client/src/workers/Linting/utils.ts
import { Position } from "codemirror";
import { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
It’s pretty hard, right?
What about now?
```ts
// app/client/src/workers/Linting/utils.ts
import type { Position } from "codemirror";
import type { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
Now, it’s clear that only `lodash` will be bundled.
This helps developers to see which imports are problematic, but it
_also_ helps with refactorings. Now, if you want to see where
`codemirror` is bundled, you can just grep for `import \{.*\} from
"codemirror"` – and you won’t get any type-only imports.
This also helps (some) bundlers. Upon transpiling, TypeScript erases
type-only imports completely. In some environment (not ours), this makes
the bundle smaller, as the bundler doesn’t need to bundle type-only
imports anymore.
## Type of change
- Chore (housekeeping or task changes that don't impact user perception)
## How Has This Been Tested?
This was tested to not break the build.
### Test Plan
> Add Testsmith test cases links that relate to this PR
### Issues raised during DP testing
> Link issues raised during DP testing for better visiblity and tracking
(copy link from comments dropped on this PR)
## Checklist:
### Dev activity
- [x] 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
- [x] 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
- [ ] PR is being merged under a feature flag
### QA activity:
- [ ] Test plan has been approved by relevant developers
- [ ] Test plan has been peer reviewed by QA
- [ ] Cypress test cases have been added and approved by either SDET or
manual QA
- [ ] Organized project review call with relevant stakeholders after
Round 1/2 of QA
- [ ] Added Test Plan Approved label after reveiwing all Cypress test
---------
Co-authored-by: Satish Gandham <hello@satishgandham.com>
Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2023-03-16 11:41:47 +00:00
import type { AutoGeneratedHeader } from "pages/Editor/APIEditor/helpers" ;
import { deriveAutoGeneratedHeaderState } from "pages/Editor/APIEditor/helpers" ;
2023-05-19 18:37:06 +00:00
import { TEMP_DATASOURCE_ID } from "constants/Datasource" ;
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 ) ;
2023-05-26 10:13:18 +00:00
// before updating the query parameters make sure the path field changes have been successfully updated first
yield take ( ReduxActionTypes . BATCH_UPDATES_SUCCESS ) ;
2021-06-03 04:58:18 +00:00
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
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
2023-02-24 12:18:48 +00:00
// we want apiContentType to always match the current body tab the user is on.
yield put (
change (
API_EDITOR_FORM_NAME ,
"actionConfiguration.formData.apiContentType" ,
displayFormatValue ,
) ,
) ;
// get headers
2023-05-24 20:26:23 +00:00
const headers = klona ( values ? . actionConfiguration ? . headers ) ;
2023-02-24 12:18:48 +00:00
// set autoGeneratedHeaders
const autoGeneratedHeaders : AutoGeneratedHeader [ ] = [ ] ;
// Set an auto generated content type header for all post body format options except none.
// also if we wish to add more auto genrated content-type the code goes inside here.
if ( displayFormatValue !== POST_BODY_FORMAT_OPTIONS . NONE ) {
2023-05-24 20:26:23 +00:00
// get content type header index
const contentTypeHeaderIndex = headers . findIndex (
( element : { key : string ; value : string } ) = >
element &&
element . key &&
element . key . trim ( ) . toLowerCase ( ) === CONTENT_TYPE_HEADER_KEY ,
) ;
2023-02-24 12:18:48 +00:00
// if theres content type
if ( contentTypeHeaderIndex !== - 1 ) {
autoGeneratedHeaders . push ( {
key : CONTENT_TYPE_HEADER_KEY ,
value : displayFormatValue ,
isInvalid : true ,
} ) ;
} else {
autoGeneratedHeaders . push ( {
key : CONTENT_TYPE_HEADER_KEY ,
value : displayFormatValue ,
isInvalid : false ,
} ) ;
// Example of setting extra auto generated header.
// autoGeneratedHeaders.push({
// key: "content-length",
// value: "0",
// isInvalid: false,
// });
}
}
// change the autoGeneratedHeader 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
yield put (
2023-02-24 12:18:48 +00:00
change (
API_EDITOR_FORM_NAME ,
"actionConfiguration.autoGeneratedHeaders" ,
autoGeneratedHeaders ,
) ,
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
// 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
2023-02-24 12:18:48 +00:00
// help to prevent cyclic dependency error in case the bodyFormData is empty.
2023-05-24 20:26:23 +00:00
const bodyFormData = klona ( values ? . actionConfiguration ? . bodyFormData ) ;
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
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
) {
2023-05-24 20:26:23 +00:00
if ( ! bodyFormData || bodyFormData ? . length === 0 ) {
2021-03-01 14:57:15 +00:00
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 ;
2023-02-24 12:18:48 +00:00
// when initializing, check if theres a display format present.
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" ) || [ ] ;
2023-02-24 12:18:48 +00:00
const autoGeneratedHeaders : AutoGeneratedHeader [ ] =
get ( values , "actionConfiguration.autoGeneratedHeaders" ) || [ ] ;
2022-09-21 09:40:36 +00:00
const contentTypeValue : string = getContentTypeHeaderValue ( headers ) ;
chore: upgrade to prettier v2 + enforce import types (#21013)Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
## Description
This PR upgrades Prettier to v2 + enforces TypeScript’s [`import
type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export)
syntax where applicable. It’s submitted as a separate PR so we can merge
it easily.
As a part of this PR, we reformat the codebase heavily:
- add `import type` everywhere where it’s required, and
- re-format the code to account for Prettier 2’s breaking changes:
https://prettier.io/blog/2020/03/21/2.0.0.html#breaking-changes
This PR is submitted against `release` to make sure all new code by team
members will adhere to new formatting standards, and we’ll have fewer
conflicts when merging `bundle-optimizations` into `release`. (I’ll
merge `release` back into `bundle-optimizations` once this PR is
merged.)
### Why is this needed?
This PR is needed because, for the Lodash optimization from
https://github.com/appsmithorg/appsmith/commit/7cbb12af886621256224be0c93e6a465dd710ad3,
we need to use `import type`. Otherwise, `babel-plugin-lodash` complains
that `LoDashStatic` is not a lodash function.
However, just using `import type` in the current codebase will give you
this:
<img width="962" alt="Screenshot 2023-03-08 at 17 45 59"
src="https://user-images.githubusercontent.com/2953267/223775744-407afa0c-e8b9-44a1-90f9-b879348da57f.png">
That’s because Prettier 1 can’t parse `import type` at all. To parse it,
we need to upgrade to Prettier 2.
### Why enforce `import type`?
Apart from just enabling `import type` support, this PR enforces
specifying `import type` everywhere it’s needed. (Developers will get
immediate TypeScript and ESLint errors when they forget to do so.)
I’m doing this because I believe `import type` improves DX and makes
refactorings easier.
Let’s say you had a few imports like below. Can you tell which of these
imports will increase the bundle size? (Tip: it’s not all of them!)
```ts
// app/client/src/workers/Linting/utils.ts
import { Position } from "codemirror";
import { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
It’s pretty hard, right?
What about now?
```ts
// app/client/src/workers/Linting/utils.ts
import type { Position } from "codemirror";
import type { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
Now, it’s clear that only `lodash` will be bundled.
This helps developers to see which imports are problematic, but it
_also_ helps with refactorings. Now, if you want to see where
`codemirror` is bundled, you can just grep for `import \{.*\} from
"codemirror"` – and you won’t get any type-only imports.
This also helps (some) bundlers. Upon transpiling, TypeScript erases
type-only imports completely. In some environment (not ours), this makes
the bundle smaller, as the bundler doesn’t need to bundle type-only
imports anymore.
## Type of change
- Chore (housekeeping or task changes that don't impact user perception)
## How Has This Been Tested?
This was tested to not break the build.
### Test Plan
> Add Testsmith test cases links that relate to this PR
### Issues raised during DP testing
> Link issues raised during DP testing for better visiblity and tracking
(copy link from comments dropped on this PR)
## Checklist:
### Dev activity
- [x] 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
- [x] 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
- [ ] PR is being merged under a feature flag
### QA activity:
- [ ] Test plan has been approved by relevant developers
- [ ] Test plan has been peer reviewed by QA
- [ ] Cypress test cases have been added and approved by either SDET or
manual QA
- [ ] Organized project review call with relevant stakeholders after
Round 1/2 of QA
- [ ] Added Test Plan Approved label after reveiwing all Cypress test
---------
Co-authored-by: Satish Gandham <hello@satishgandham.com>
Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2023-03-16 11:41:47 +00:00
const contentTypeAutoGeneratedHeaderValue : string =
getContentTypeHeaderValue ( autoGeneratedHeaders ) ;
2022-04-12 11:13:11 +00:00
2023-02-24 12:18:48 +00:00
let rawApiContentType = "" ;
2022-02-22 11:02:43 +00:00
if ( ! extraFormData ) {
2022-04-12 11:13:11 +00:00
/ *
2023-02-24 12:18:48 +00:00
* if there is no user specified content type value or autogenerated content type value , we default to raw
* if there is no user specified content type value and there is a autogenerated content type value , we default to its value
* if there is a user specified content type value and no autogenerated content type value , we default to the user content type value
* if there is a user specified content type value and a autogenerated content type value , we default to the user content type value
2022-04-12 11:13:11 +00:00
* /
2023-02-24 12:18:48 +00:00
if ( ! contentTypeValue && ! contentTypeAutoGeneratedHeaderValue ) {
2022-06-01 10:29:58 +00:00
rawApiContentType = POST_BODY_FORMAT_OPTIONS . NONE ;
2023-02-24 12:18:48 +00:00
} else if ( ! contentTypeValue && contentTypeAutoGeneratedHeaderValue ) {
rawApiContentType = contentTypeAutoGeneratedHeaderValue ;
2022-06-01 10:29:58 +00:00
} else if (
2023-02-24 12:18:48 +00:00
( contentTypeValue && ! contentTypeAutoGeneratedHeaderValue ) ||
( contentTypeValue && contentTypeAutoGeneratedHeaderValue )
2022-06-01 10:29:58 +00:00
) {
2023-02-24 12:18:48 +00:00
rawApiContentType = contentTypeValue ;
2022-04-12 11:13:11 +00:00
}
2023-02-24 12:18:48 +00:00
yield call ( setApiBodyTabHeaderFormat , values . id , rawApiContentType ) ;
}
2020-05-07 07:56:37 +00:00
}
2021-05-04 13:08:20 +00:00
function * changeApiSaga (
2023-02-24 12:18:48 +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
}
2023-02-24 12:18:48 +00:00
function * setApiBodyTabHeaderFormat ( apiId : string , apiContentType? : string ) {
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 ) {
2023-02-24 12:18:48 +00:00
if ( 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
}
2023-02-24 12:18:48 +00:00
} else {
displayFormat = {
label : POST_BODY_FORMAT_OPTIONS.NONE ,
value : POST_BODY_FORMAT_OPTIONS.NONE ,
} ;
2021-04-26 05:41:32 +00:00
}
yield put ( {
type : ReduxActionTypes . SET_EXTRA_FORMDATA ,
payload : {
id : apiId ,
values : {
displayFormat ,
} ,
} ,
} ) ;
}
2020-07-03 08:58:58 +00:00
function * formValueChangeSaga (
2023-02-24 12:18:48 +00:00
actionPayload : ReduxActionWithMeta <
string ,
{ field : string ; form : string ; index? : number }
> ,
2020-06-04 13:49:22 +00:00
) {
2022-12-01 06:30:50 +00:00
try {
const { field , form } = actionPayload . meta ;
if ( form !== API_EDITOR_FORM_NAME ) return ;
if ( field === "dynamicBindingPathList" || field === "name" ) return ;
const { values } = yield select ( getFormData , API_EDITOR_FORM_NAME ) ;
if ( ! values . id ) return ;
if ( ! hasManageActionPermission ( values . userPermissions ) ) {
yield validateResponse ( {
status : 403 ,
resourceType : values?.pluginType ,
resourceId : values.id ,
} ) ;
}
chore: upgrade to prettier v2 + enforce import types (#21013)Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
## Description
This PR upgrades Prettier to v2 + enforces TypeScript’s [`import
type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export)
syntax where applicable. It’s submitted as a separate PR so we can merge
it easily.
As a part of this PR, we reformat the codebase heavily:
- add `import type` everywhere where it’s required, and
- re-format the code to account for Prettier 2’s breaking changes:
https://prettier.io/blog/2020/03/21/2.0.0.html#breaking-changes
This PR is submitted against `release` to make sure all new code by team
members will adhere to new formatting standards, and we’ll have fewer
conflicts when merging `bundle-optimizations` into `release`. (I’ll
merge `release` back into `bundle-optimizations` once this PR is
merged.)
### Why is this needed?
This PR is needed because, for the Lodash optimization from
https://github.com/appsmithorg/appsmith/commit/7cbb12af886621256224be0c93e6a465dd710ad3,
we need to use `import type`. Otherwise, `babel-plugin-lodash` complains
that `LoDashStatic` is not a lodash function.
However, just using `import type` in the current codebase will give you
this:
<img width="962" alt="Screenshot 2023-03-08 at 17 45 59"
src="https://user-images.githubusercontent.com/2953267/223775744-407afa0c-e8b9-44a1-90f9-b879348da57f.png">
That’s because Prettier 1 can’t parse `import type` at all. To parse it,
we need to upgrade to Prettier 2.
### Why enforce `import type`?
Apart from just enabling `import type` support, this PR enforces
specifying `import type` everywhere it’s needed. (Developers will get
immediate TypeScript and ESLint errors when they forget to do so.)
I’m doing this because I believe `import type` improves DX and makes
refactorings easier.
Let’s say you had a few imports like below. Can you tell which of these
imports will increase the bundle size? (Tip: it’s not all of them!)
```ts
// app/client/src/workers/Linting/utils.ts
import { Position } from "codemirror";
import { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
It’s pretty hard, right?
What about now?
```ts
// app/client/src/workers/Linting/utils.ts
import type { Position } from "codemirror";
import type { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
Now, it’s clear that only `lodash` will be bundled.
This helps developers to see which imports are problematic, but it
_also_ helps with refactorings. Now, if you want to see where
`codemirror` is bundled, you can just grep for `import \{.*\} from
"codemirror"` – and you won’t get any type-only imports.
This also helps (some) bundlers. Upon transpiling, TypeScript erases
type-only imports completely. In some environment (not ours), this makes
the bundle smaller, as the bundler doesn’t need to bundle type-only
imports anymore.
## Type of change
- Chore (housekeeping or task changes that don't impact user perception)
## How Has This Been Tested?
This was tested to not break the build.
### Test Plan
> Add Testsmith test cases links that relate to this PR
### Issues raised during DP testing
> Link issues raised during DP testing for better visiblity and tracking
(copy link from comments dropped on this PR)
## Checklist:
### Dev activity
- [x] 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
- [x] 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
- [ ] PR is being merged under a feature flag
### QA activity:
- [ ] Test plan has been approved by relevant developers
- [ ] Test plan has been peer reviewed by QA
- [ ] Cypress test cases have been added and approved by either SDET or
manual QA
- [ ] Organized project review call with relevant stakeholders after
Round 1/2 of QA
- [ ] Added Test Plan Approved label after reveiwing all Cypress test
---------
Co-authored-by: Satish Gandham <hello@satishgandham.com>
Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2023-03-16 11:41:47 +00:00
const contentTypeHeaderIndex =
values ? . actionConfiguration ? . headers ? . findIndex (
( header : { key : string ; value : string } ) = >
header ? . key ? . trim ( ) . toLowerCase ( ) === CONTENT_TYPE_HEADER_KEY ,
) ;
2023-02-24 12:18:48 +00:00
chore: upgrade to prettier v2 + enforce import types (#21013)Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
## Description
This PR upgrades Prettier to v2 + enforces TypeScript’s [`import
type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export)
syntax where applicable. It’s submitted as a separate PR so we can merge
it easily.
As a part of this PR, we reformat the codebase heavily:
- add `import type` everywhere where it’s required, and
- re-format the code to account for Prettier 2’s breaking changes:
https://prettier.io/blog/2020/03/21/2.0.0.html#breaking-changes
This PR is submitted against `release` to make sure all new code by team
members will adhere to new formatting standards, and we’ll have fewer
conflicts when merging `bundle-optimizations` into `release`. (I’ll
merge `release` back into `bundle-optimizations` once this PR is
merged.)
### Why is this needed?
This PR is needed because, for the Lodash optimization from
https://github.com/appsmithorg/appsmith/commit/7cbb12af886621256224be0c93e6a465dd710ad3,
we need to use `import type`. Otherwise, `babel-plugin-lodash` complains
that `LoDashStatic` is not a lodash function.
However, just using `import type` in the current codebase will give you
this:
<img width="962" alt="Screenshot 2023-03-08 at 17 45 59"
src="https://user-images.githubusercontent.com/2953267/223775744-407afa0c-e8b9-44a1-90f9-b879348da57f.png">
That’s because Prettier 1 can’t parse `import type` at all. To parse it,
we need to upgrade to Prettier 2.
### Why enforce `import type`?
Apart from just enabling `import type` support, this PR enforces
specifying `import type` everywhere it’s needed. (Developers will get
immediate TypeScript and ESLint errors when they forget to do so.)
I’m doing this because I believe `import type` improves DX and makes
refactorings easier.
Let’s say you had a few imports like below. Can you tell which of these
imports will increase the bundle size? (Tip: it’s not all of them!)
```ts
// app/client/src/workers/Linting/utils.ts
import { Position } from "codemirror";
import { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
It’s pretty hard, right?
What about now?
```ts
// app/client/src/workers/Linting/utils.ts
import type { Position } from "codemirror";
import type { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
Now, it’s clear that only `lodash` will be bundled.
This helps developers to see which imports are problematic, but it
_also_ helps with refactorings. Now, if you want to see where
`codemirror` is bundled, you can just grep for `import \{.*\} from
"codemirror"` – and you won’t get any type-only imports.
This also helps (some) bundlers. Upon transpiling, TypeScript erases
type-only imports completely. In some environment (not ours), this makes
the bundle smaller, as the bundler doesn’t need to bundle type-only
imports anymore.
## Type of change
- Chore (housekeeping or task changes that don't impact user perception)
## How Has This Been Tested?
This was tested to not break the build.
### Test Plan
> Add Testsmith test cases links that relate to this PR
### Issues raised during DP testing
> Link issues raised during DP testing for better visiblity and tracking
(copy link from comments dropped on this PR)
## Checklist:
### Dev activity
- [x] 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
- [x] 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
- [ ] PR is being merged under a feature flag
### QA activity:
- [ ] Test plan has been approved by relevant developers
- [ ] Test plan has been peer reviewed by QA
- [ ] Cypress test cases have been added and approved by either SDET or
manual QA
- [ ] Organized project review call with relevant stakeholders after
Round 1/2 of QA
- [ ] Added Test Plan Approved label after reveiwing all Cypress test
---------
Co-authored-by: Satish Gandham <hello@satishgandham.com>
Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2023-03-16 11:41:47 +00:00
const autoGeneratedContentTypeHeaderIndex =
values ? . actionConfiguration ? . autoGeneratedHeaders ? . findIndex (
( header : { key : string ; value : string } ) = >
header ? . key ? . trim ( ) . toLowerCase ( ) === CONTENT_TYPE_HEADER_KEY ,
) ;
2023-02-24 12:18:48 +00:00
const autoGeneratedHeaders =
get ( values , "actionConfiguration.autoGeneratedHeaders" ) || [ ] ;
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-12-01 06:30:50 +00:00
actionPayload . type === ReduxFormActionTypes . ARRAY_REMOVE ||
actionPayload . type === ReduxFormActionTypes . ARRAY_PUSH
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-12-01 06:30:50 +00:00
const value = get ( values , field ) ;
2022-02-22 11:02:43 +00:00
yield put (
2022-12-01 06:30:50 +00:00
setActionProperty ( {
actionId : values.id ,
propertyName : field ,
value ,
} ) ,
2022-02-22 11:02:43 +00:00
) ;
2023-02-24 12:18:48 +00:00
// if the user triggers a delete operation on any headers field
if ( field === ` actionConfiguration.headers ` ) {
// we get the updated auto generated header state based on the user specified content-type.
chore: upgrade to prettier v2 + enforce import types (#21013)Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
## Description
This PR upgrades Prettier to v2 + enforces TypeScript’s [`import
type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export)
syntax where applicable. It’s submitted as a separate PR so we can merge
it easily.
As a part of this PR, we reformat the codebase heavily:
- add `import type` everywhere where it’s required, and
- re-format the code to account for Prettier 2’s breaking changes:
https://prettier.io/blog/2020/03/21/2.0.0.html#breaking-changes
This PR is submitted against `release` to make sure all new code by team
members will adhere to new formatting standards, and we’ll have fewer
conflicts when merging `bundle-optimizations` into `release`. (I’ll
merge `release` back into `bundle-optimizations` once this PR is
merged.)
### Why is this needed?
This PR is needed because, for the Lodash optimization from
https://github.com/appsmithorg/appsmith/commit/7cbb12af886621256224be0c93e6a465dd710ad3,
we need to use `import type`. Otherwise, `babel-plugin-lodash` complains
that `LoDashStatic` is not a lodash function.
However, just using `import type` in the current codebase will give you
this:
<img width="962" alt="Screenshot 2023-03-08 at 17 45 59"
src="https://user-images.githubusercontent.com/2953267/223775744-407afa0c-e8b9-44a1-90f9-b879348da57f.png">
That’s because Prettier 1 can’t parse `import type` at all. To parse it,
we need to upgrade to Prettier 2.
### Why enforce `import type`?
Apart from just enabling `import type` support, this PR enforces
specifying `import type` everywhere it’s needed. (Developers will get
immediate TypeScript and ESLint errors when they forget to do so.)
I’m doing this because I believe `import type` improves DX and makes
refactorings easier.
Let’s say you had a few imports like below. Can you tell which of these
imports will increase the bundle size? (Tip: it’s not all of them!)
```ts
// app/client/src/workers/Linting/utils.ts
import { Position } from "codemirror";
import { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
It’s pretty hard, right?
What about now?
```ts
// app/client/src/workers/Linting/utils.ts
import type { Position } from "codemirror";
import type { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
Now, it’s clear that only `lodash` will be bundled.
This helps developers to see which imports are problematic, but it
_also_ helps with refactorings. Now, if you want to see where
`codemirror` is bundled, you can just grep for `import \{.*\} from
"codemirror"` – and you won’t get any type-only imports.
This also helps (some) bundlers. Upon transpiling, TypeScript erases
type-only imports completely. In some environment (not ours), this makes
the bundle smaller, as the bundler doesn’t need to bundle type-only
imports anymore.
## Type of change
- Chore (housekeeping or task changes that don't impact user perception)
## How Has This Been Tested?
This was tested to not break the build.
### Test Plan
> Add Testsmith test cases links that relate to this PR
### Issues raised during DP testing
> Link issues raised during DP testing for better visiblity and tracking
(copy link from comments dropped on this PR)
## Checklist:
### Dev activity
- [x] 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
- [x] 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
- [ ] PR is being merged under a feature flag
### QA activity:
- [ ] Test plan has been approved by relevant developers
- [ ] Test plan has been peer reviewed by QA
- [ ] Cypress test cases have been added and approved by either SDET or
manual QA
- [ ] Organized project review call with relevant stakeholders after
Round 1/2 of QA
- [ ] Added Test Plan Approved label after reveiwing all Cypress test
---------
Co-authored-by: Satish Gandham <hello@satishgandham.com>
Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2023-03-16 11:41:47 +00:00
const newAutoGeneratedHeaderState : AutoGeneratedHeader [ ] =
deriveAutoGeneratedHeaderState (
values ? . actionConfiguration ? . headers ,
autoGeneratedHeaders ,
) ;
2023-02-24 12:18:48 +00:00
// update the autogenerated headers with the new autogenerated headers state.
yield put (
change (
API_EDITOR_FORM_NAME ,
"actionConfiguration.autoGeneratedHeaders" ,
newAutoGeneratedHeaderState ,
) ,
) ;
}
2022-12-01 06:30:50 +00:00
} else {
yield put (
setActionProperty ( {
actionId : values.id ,
propertyName : field ,
value : actionPayload.payload ,
} ) ,
) ;
2023-02-24 12:18:48 +00:00
if ( field . includes ( "actionConfiguration.headers" ) ) {
// if user is changing the header keys and if autoGenerated headers exist, derive new state based on the header value.
if (
field . includes ( ".key" ) &&
autoGeneratedHeaders &&
autoGeneratedHeaders . length > 0
) {
const newAutoGeneratedHeaderState = deriveAutoGeneratedHeaderState (
values ? . actionConfiguration ? . headers || [ ] ,
autoGeneratedHeaders ,
) ;
yield put (
change (
API_EDITOR_FORM_NAME ,
"actionConfiguration.autoGeneratedHeaders" ,
newAutoGeneratedHeaderState ,
) ,
) ;
}
}
// when the httpMethod is changed
if ( field === "actionConfiguration.httpMethod" ) {
const value = actionPayload . payload ;
// if the user is switching to any other type of httpMethod apart from GET we add an autogenerated content type.
if ( value !== HTTP_METHOD . GET ) {
// if the autoGenerated header does not have any key-values or if there's no content type in the headers
// we add a default content-type of application/json and set the body tab appropriately.
if (
autoGeneratedHeaders . length < 1 ||
autoGeneratedContentTypeHeaderIndex === - 1
) {
const newAutoGeneratedHeaders : AutoGeneratedHeader [ ] = [
. . . autoGeneratedHeaders ,
] ;
if ( contentTypeHeaderIndex !== - 1 ) {
newAutoGeneratedHeaders . push ( {
key : CONTENT_TYPE_HEADER_KEY ,
value : POST_BODY_FORMAT_OPTIONS.JSON ,
isInvalid : true ,
} ) ;
} else {
newAutoGeneratedHeaders . push ( {
key : CONTENT_TYPE_HEADER_KEY ,
value : POST_BODY_FORMAT_OPTIONS.JSON ,
isInvalid : false ,
} ) ;
}
// change the autoGeneratedHeader value.
yield put (
change (
API_EDITOR_FORM_NAME ,
"actionConfiguration.autoGeneratedHeaders" ,
newAutoGeneratedHeaders ,
) ,
) ;
// set the body tab.
yield call (
setApiBodyTabHeaderFormat ,
values . id ,
POST_BODY_FORMAT_OPTIONS . JSON ,
) ;
}
}
2022-12-01 06:30:50 +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
}
2023-02-24 12:18:48 +00:00
yield all ( [ call ( syncApiParamsSaga , actionPayload , values . id ) ] ) ;
2022-12-01 06:30:50 +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 ,
) ;
2021-12-07 09:45:18 +00:00
2022-12-01 06:30:50 +00:00
yield put (
updateReplayEntity (
formValuesPostProcess . id ,
formValuesPostProcess ,
ENTITY_TYPE . ACTION ,
) ,
) ;
} catch ( error ) {
yield put ( {
type : ReduxActionErrorTypes . SAVE_PAGE_ERROR ,
payload : {
error ,
} ,
} ) ;
yield put ( reset ( API_EDITOR_FORM_NAME ) ) ;
}
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
2023-05-19 18:37:06 +00:00
if (
! ! actionRouteInfo . apiId &&
actionPayload . payload ? . id !== TEMP_DATASOURCE_ID
) {
2022-11-30 05:59:45 +00:00
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
2023-05-19 18:37:06 +00:00
toast . show ( createMessage ( ERROR_ACTION_RENAME_FAIL , "" ) , {
kind : "error" ,
2020-12-14 16:22:45 +00:00
} ) ;
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
] ) ;
}