Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: Implement request transformation between HAR and Firecamp formats #115

Closed
2 tasks
Nishchit14 opened this issue Oct 16, 2023 · 12 comments · Fixed by #126
Closed
2 tasks

feature: Implement request transformation between HAR and Firecamp formats #115

Nishchit14 opened this issue Oct 16, 2023 · 12 comments · Fixed by #126
Labels
features hacktoberfest Issue that are part of Hacktoberfest

Comments

@Nishchit14
Copy link
Contributor

Description:

Firecamp currently does not have the ability to transform HTTP request/response data between the HAR (HTTP Archive) format and Firecamp's internal request format.

This feature request is to implement bidirectional conversion:

  • HAR to Firecamp request: Parse a HAR request object and convert it to a Firecamp request object
  • Firecamp request to HAR: Take a Firecamp request object and convert it to a HAR request object

This will allow:

  • Importing HAR files from other tools (like browser developer tools) into Firecamp for editing/replay
  • Exporting requests edited in Firecamp out to HAR format for use in other tools
  • Prepare a code snippet for the request

The implementation should include:

  • Mapping of all relevant fields between the two formats
  • Helper functions for HAR -> Firecamp and Firecamp -> HAR conversions
  • Unit tests validating bidirectional conversion

This feature will enable better interoperability with external tools for importing and exporting HTTP request data.

Resources

  1. Firecamp Request Type: https://github.com/firecamp-dev/firecamp/blob/main/packages/firecamp-types/src/requests/rest/request.ts#L17C25-L17C25
  2. https://www.npmjs.com/package/@types/har-format
@Nishchit14 Nishchit14 added hacktoberfest Issue that are part of Hacktoberfest features labels Oct 16, 2023
@RISHIKESHk07
Copy link

Hey @Nishchit14 would like to contribute , though I have not much knowledge about the above issue.

@Nishchit14
Copy link
Contributor Author

Nishchit14 commented Oct 18, 2023

The business logic of this feature is around HAR and Firecamp API Request transformation. Firecamp Rest Request and HAR both have JSON format. We need to create two transformer functions

Converts formats

  1. HAR Request to Firecamp Rest Request
  2. Firecamp Rest Request to HAR Request

Getting started steps would be

  1. create a new package under the packages/*, folder name firecamp-har and package name in package.json with @firecamp/firecamp-har, you can copy the existing package to start with typescript boilerplate
  2. start building transformer business logic
  3. write jest tests
  4. submit PR.

for any kind of help feel free to ask on Discord's contribution channel.

Reference

HAR
JSON: https://gist.github.com/igrigorik/3495174
https://github.com/javieraviles/Har2Postman/blob/master/test/0.1.0/input.json
TS: https://www.npmjs.com/package/@types/har-format

Firecamp
JOSN:

{
"url": {
"raw": "{{host}}/get?foo1=bar1&foo2=bar2",
"queryParams": [
{
"id": "RRMgDmGWwOa9ZwpijZiWj",
"key": "foo1",
"value": "bar1",
"type": "text"
},
{
"id": "FhvTGiXwTPf6V2PKcgdkq",
"key": "foo2",
"value": "bar2",
"type": "text"
}
],
"pathParams": []
},
"method": "GET",
"headers": [],
"body": {
"type": "none",
"value": ""
},
"auth": {
"type": "none",
"value": ""
},
"preScripts": [
{
"id": "uFY46hx7i07o1XTNDMf3g",
"type": "prerequest",
"value": [
""
],
"language": "text/javascript"
}
],
"postScripts": [
{
"id": "6sNaqQkVd6ILXJnXz7Zdr",
"type": "test",
"value": [
"fc.test(\"response is ok\", function () {",
" fc.response.to.have.status(200);",
"});",
"",
"fc.test(\"response body has json with request queries\", function () {",
" fc.response.to.have.jsonBody('args.foo1', 'bar1')",
" .and.have.jsonBody('args.foo2', 'bar2');",
"});",
""
],
"language": "text/javascript"
}
],
"__meta": {
"name": "GET Request",
"description": "",
"type": "rest",
"version": "2.0.0"
},
"__ref": {
"id": "i6F9xE_XY-1adwy7LpKE1"
}
},

TS: https://github.com/firecamp-dev/firecamp/blob/main/packages/firecamp-types/src/requests/rest/request.ts#L17C25-L17C25

@note: only transform request to request, do not consider whole collection transformation as of now.

cc: @RISHIKESHk07

@Nishchit14 Nishchit14 pinned this issue Oct 18, 2023
@jatingodnani
Copy link

jatingodnani commented Oct 18, 2023

@Nishchit14 are you asking to implement a toll to convert a har to fire format and vice verse?

@Nishchit14
Copy link
Contributor Author

@jatingodnani yes, format conversion from HAR to Firecamp and Firecamp to HAR.

@jatingodnani
Copy link

@Nishchit14 where to implement this

@Nishchit14
Copy link
Contributor Author

@jatingodnani please read this #115 (comment), specific this section Getting started steps would be

@jatingodnani
Copy link

Screenshot 2023-10-19 121918
@Nishchit14 can you pls tell me is this correct?or i am missing something

@jatingodnani
Copy link

@Nishchit14 check this above

@Nishchit14
Copy link
Contributor Author

Nishchit14 commented Oct 19, 2023

@jatingodnani Refer this #120 (comment)

I appreciate your efforts to understand this issue. I need some time to prepare a minimum package so you can start. also the HAR <=> Firecamp comparison looks good at first sight but I prefer to have json in PR so I can review it properly.

@jatingodnani
Copy link

@Nishchit14 can you pls checkk and review is it correct conversion

@Nishchit14
Copy link
Contributor Author

@jatingodnani yes, it looks correct.

@jatingodnani
Copy link

@Nishchit14 i am ready to take this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
features hacktoberfest Issue that are part of Hacktoberfest
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants