From b0612b86329af9ee5da2291d2a3e48dbd3b0441c Mon Sep 17 00:00:00 2001 From: Gregory Schier Date: Sun, 5 Nov 2023 14:35:25 -0800 Subject: [PATCH] Basic import of request body and bearer auth --- .../insomnia-importer/Insomnia_bigger.json | 570 ++++++++---------- .../insomnia-importer/importers/request.js | 22 +- src-tauri/src/main.rs | 3 +- src-web/components/RequestPane.tsx | 13 +- src-web/lib/models.ts | 3 - src-web/lib/sendEphemeralRequest.ts | 7 +- 6 files changed, 294 insertions(+), 324 deletions(-) diff --git a/src-tauri/plugins/insomnia-importer/Insomnia_bigger.json b/src-tauri/plugins/insomnia-importer/Insomnia_bigger.json index fb0168e4..511f51f5 100644 --- a/src-tauri/plugins/insomnia-importer/Insomnia_bigger.json +++ b/src-tauri/plugins/insomnia-importer/Insomnia_bigger.json @@ -1,32 +1,28 @@ { "_type": "export", "__export_format": 4, - "__export_date": "2023-11-05T20:51:37.696Z", + "__export_date": "2023-11-05T22:20:12.831Z", "__export_source": "insomnia.desktop.app:v8.3.0", "resources": [ { - "_id": "req_a91c380534a6459ea27c4d30418ab16f", + "_id": "req_cb5fb72d0afd4e479b70a824cedc325a", "parentId": "wrk_cd2351f82a134dec87cb74c0bc9e3e7c", - "modified": 1699117176571, - "created": 1652981694993, - "url": "{{ _.GRAPHQL_ENDPOINT }}", - "name": "Resource Access", + "modified": 1699222790515, + "created": 1699222790515, + "url": "", + "name": "New Request", "description": "", - "method": "POST", - "body": { - "mimeType": "application/graphql", - "text": "{\"query\":\"{\\n\\tresourceAccess {\\n\\t\\tproject {\\n\\t\\t\\tdisallowed\\n\\t\\t}\\n\\t\\tplugin {\\n\\t\\t\\tdisallowed\\n\\t\\t}\\n\\t}\\n}\\n\",\"variables\":{}}" - }, + "method": "GET", + "body": {}, "parameters": [], "headers": [ { - "name": "Content-Type", - "value": "application/json", - "id": "pair_a547d82bc2684b7595ab676d2668bbac" + "name": "User-Agent", + "value": "insomnia/8.3.0" } ], "authentication": {}, - "metaSortKey": -1699117141751, + "metaSortKey": -1699222790515, "isPrivate": false, "settingStoreCookies": true, "settingSendCookies": true, @@ -47,17 +43,17 @@ "_type": "workspace" }, { - "_id": "req_8ec4d463e2a1454e8e537a8a6f629979", - "parentId": "wrk_cd2351f82a134dec87cb74c0bc9e3e7c", - "modified": 1699117178347, - "created": 1652826927278, + "_id": "req_5741a3ea53e7403f956c44543cb98793", + "parentId": "fld_6030301042004f1d937834031923f864", + "modified": 1699222716936, + "created": 1653506166429, "url": "{{ _.GRAPHQL_ENDPOINT }}", - "name": "Create Team", + "name": "Delete Service Domain", "description": "", "method": "POST", "body": { "mimeType": "application/graphql", - "text": "{\"query\":\"mutation {\\n\\tagreeFairUse() {\\n\\t\\tname\\n\\t}\\n}\\n\",\"variables\":{}}" + "text": "{\"query\":\"mutation ($serviceDomainId: ID!) {\\n\\tserviceDomainDelete(\\n\\t\\tprojectId: \\\"b7a46032-fe7f-48f2-8a0c-5d7e30b1a6dc\\\"\\n\\t\\tenvironmentId: \\\"5b53202d-f0dd-4aef-ae67-b7dffc9f2664\\\"\\n\\t\\tid: $serviceDomainId\\n\\t)\\n}\\n\",\"variables\":{\"serviceDomainId\":\"{% response 'body', 'req_9765c255e6924e84b9945eb350b22525', 'b64::JC4uaWQ=::46b', 'never', 60 %}\"}}" }, "parameters": [], "headers": [ @@ -68,7 +64,51 @@ } ], "authentication": {}, - "metaSortKey": -1699117141701, + "metaSortKey": -1699222709368, + "isPrivate": false, + "settingStoreCookies": true, + "settingSendCookies": true, + "settingDisableRenderRequestBody": false, + "settingEncodeUrl": true, + "settingRebuildPath": true, + "settingFollowRedirects": "global", + "_type": "request" + }, + { + "_id": "fld_6030301042004f1d937834031923f864", + "parentId": "wrk_cd2351f82a134dec87cb74c0bc9e3e7c", + "modified": 1699042236916, + "created": 1651610199647, + "name": "GraphQL", + "description": "", + "environment": {}, + "environmentPropertyOrder": null, + "metaSortKey": -1652937563623.9062, + "_type": "request_group" + }, + { + "_id": "req_a91c380534a6459ea27c4d30418ab16f", + "parentId": "fld_6030301042004f1d937834031923f864", + "modified": 1699222726156, + "created": 1652981694993, + "url": "{{ _.GRAPHQL_ENDPOINT }}", + "name": "Resource Access", + "description": "", + "method": "POST", + "body": { + "mimeType": "application/graphql", + "text": "{\"query\":\"{\\n\\tresourceAccess {\\n\\t\\tproject {\\n\\t\\t\\tdisallowed\\n\\t\\t}\\n\\t\\tplugin {\\n\\t\\t\\tdisallowed\\n\\t\\t}\\n\\t}\\n}\\n\",\"variables\":{}}" + }, + "parameters": [], + "headers": [ + { + "name": "Content-Type", + "value": "application/json", + "id": "pair_a547d82bc2684b7595ab676d2668bbac" + } + ], + "authentication": {}, + "metaSortKey": -1699222709361.75, "isPrivate": false, "settingStoreCookies": true, "settingSendCookies": true, @@ -80,8 +120,8 @@ }, { "_id": "req_d1a181e68234451a99c8677c86c0fb2f", - "parentId": "fld_fa4d4d23e5334207899d8ebc2b1b3518", - "modified": 1699117183071, + "parentId": "fld_6030301042004f1d937834031923f864", + "modified": 1699222723983, "created": 1653505877087, "url": "", "name": "Get Service Domains", @@ -100,7 +140,7 @@ } ], "authentication": {}, - "metaSortKey": -1699117183007, + "metaSortKey": -1699222709355.5, "isPrivate": false, "settingStoreCookies": true, "settingSendCookies": true, @@ -111,21 +151,41 @@ "_type": "request" }, { - "_id": "fld_fa4d4d23e5334207899d8ebc2b1b3518", - "parentId": "wrk_cd2351f82a134dec87cb74c0bc9e3e7c", - "modified": 1699117141651, - "created": 1699117141651, - "name": "My Foldertsra", + "_id": "req_8ec4d463e2a1454e8e537a8a6f629979", + "parentId": "fld_6030301042004f1d937834031923f864", + "modified": 1699222725074, + "created": 1652826927278, + "url": "{{ _.GRAPHQL_ENDPOINT }}", + "name": "Create Team", "description": "", - "environment": {}, - "environmentPropertyOrder": null, - "metaSortKey": -1699117141651, - "_type": "request_group" + "method": "POST", + "body": { + "mimeType": "application/graphql", + "text": "{\"query\":\"mutation {\\n\\tagreeFairUse() {\\n\\t\\tname\\n\\t}\\n}\\n\",\"variables\":{}}" + }, + "parameters": [], + "headers": [ + { + "name": "Content-Type", + "value": "application/json", + "id": "pair_a547d82bc2684b7595ab676d2668bbac" + } + ], + "authentication": {}, + "metaSortKey": -1699222709349.25, + "isPrivate": false, + "settingStoreCookies": true, + "settingSendCookies": true, + "settingDisableRenderRequestBody": false, + "settingEncodeUrl": true, + "settingRebuildPath": true, + "settingFollowRedirects": "global", + "_type": "request" }, { "_id": "req_df86bf5272724c5696c45e4e36e0b87c", - "parentId": "wrk_cd2351f82a134dec87cb74c0bc9e3e7c", - "modified": 1680413502517, + "parentId": "fld_6030301042004f1d937834031923f864", + "modified": 1699222722899, "created": 1679927297821, "url": "https://spacex-production.up.railway.app", "name": "New Request", @@ -146,7 +206,7 @@ "type": "bearer", "token": "4c1736b6-d63f-4e07-860e-3da77c83dcde" }, - "metaSortKey": -1679927297821, + "metaSortKey": -1699222709343, "isPrivate": false, "settingStoreCookies": true, "settingSendCookies": true, @@ -158,8 +218,8 @@ }, { "_id": "req_4321f12845724866ae665653dc9013a1", - "parentId": "wrk_cd2351f82a134dec87cb74c0bc9e3e7c", - "modified": 1698941918874, + "parentId": "fld_6030301042004f1d937834031923f864", + "modified": 1699222722182, "created": 1651611238329, "url": "{{ _.GRAPHQL_ENDPOINT }}", "name": "My Request", @@ -189,7 +249,7 @@ } ], "authentication": {}, - "metaSortKey": -1653380018282.875, + "metaSortKey": -1699222709318, "isPrivate": false, "settingStoreCookies": true, "settingSendCookies": true, @@ -201,8 +261,8 @@ }, { "_id": "req_63cd07c5ecb34c1b8c9d350be8c22c73", - "parentId": "wrk_cd2351f82a134dec87cb74c0bc9e3e7c", - "modified": 1698941919965, + "parentId": "fld_6030301042004f1d937834031923f864", + "modified": 1699222715513, "created": 1652983047395, "url": "{{ _.GRAPHQL_ENDPOINT }}", "name": "Project Resource Access", @@ -221,7 +281,7 @@ } ], "authentication": {}, - "metaSortKey": -1652495108964.9375, + "metaSortKey": -1699222709268, "isPrivate": false, "settingStoreCookies": true, "settingSendCookies": true, @@ -232,33 +292,40 @@ "_type": "request" }, { - "_id": "req_d4e228c310684efa918141df95047ca5", - "parentId": "fld_981294d5fef54ea8afd1f8ace781e826", - "modified": 1699021088931, - "created": 1680201417381, - "url": "35.230.57.124:6747", - "name": "New Request", + "_id": "req_2ca47b965a3a456fa82d91799b1bb672", + "parentId": "fld_6030301042004f1d937834031923f864", + "modified": 1699222718108, + "created": 1653522891907, + "url": "{{ _.GRAPHQL_ENDPOINT }}", + "name": "Get Deployments", "description": "", - "method": "GET", - "body": {}, - "parameters": [ + "method": "POST", + "body": { + "mimeType": "application/graphql", + "text": "{\"query\":\"query {\\n\\tdeployments(where: {projectId: \\\"b7a46032-fe7f-48f2-8a0c-5d7e30b1a6dc\\\"}) {\\n\\t\\tnodes {\\n\\t\\t\\tid\\n\\t\\t\\tstaticUrl\\n\\t\\t}\\n\\t}\\n}\\n\",\"variables\":{}}" + }, + "parameters": [], + "headers": [ { - "id": "pair_0a6249504fd04fe29a8457beaf115459", + "name": "Content-Type", + "value": "application/json", + "id": "pair_a547d82bc2684b7595ab676d2668bbac" + }, + { + "id": "pair_619347adbf6c47c98965adc8a616bedf", + "name": "", + "value": "", + "description": "" + }, + { + "id": "pair_0806f4c53d97487da52deac558b9a714", "name": "", "value": "", "description": "" } ], - "headers": [ - { - "id": "pair_811f4f1073404a82b43b4998b6558277", - "name": "Host`", - "value": "sports-app-pr-2420.up.railway.app", - "description": "" - } - ], "authentication": {}, - "metaSortKey": -1699021088896, + "metaSortKey": -1699222709218, "isPrivate": false, "settingStoreCookies": true, "settingSendCookies": true, @@ -269,33 +336,54 @@ "_type": "request" }, { - "_id": "fld_981294d5fef54ea8afd1f8ace781e826", - "parentId": "fld_036eba97da3a442c9e816031c563b7fa", - "modified": 1699042248107, - "created": 1699021081046, - "name": "My Folder", + "_id": "req_342c6ea8a6e44ee79146f658bbccbc37", + "parentId": "fld_6030301042004f1d937834031923f864", + "modified": 1699222720479, + "created": 1664387180476, + "url": "https://backboard.railway-develop.app/graphql/v2", + "name": "Variables", "description": "", - "environment": {}, - "environmentPropertyOrder": null, - "metaSortKey": -1699042248028, - "_type": "request_group" - }, - { - "_id": "fld_036eba97da3a442c9e816031c563b7fa", - "parentId": "wrk_cd2351f82a134dec87cb74c0bc9e3e7c", - "modified": 1699053144611, - "created": 1699021054008, - "name": "My Folder", - "description": "", - "environment": {}, - "environmentPropertyOrder": null, - "metaSortKey": -1652273881635.4531, - "_type": "request_group" + "method": "POST", + "body": { + "mimeType": "application/graphql", + "text": "{\"query\":\"query VariablesForDeploy {\\n\\tvariablesForServiceDeployment(\\n\\t\\tenvironmentId: \\\"e12b44cd-2f44-4213-918a-c6b2b2da1119\\\"\\n\\t\\tserviceId: \\\"1fb71daf-a16f-4908-bc9a-edf5eb17ff55\\\"\\n\\t\\tprojectId: \\\"0f65ff5f-66c8-4768-9efe-151c5fb0c67e\\\"\\n\\t)\\n}\\n\",\"operationName\":\"VariablesForDeploy\"}" + }, + "parameters": [ + { + "name": "q", + "value": "project", + "disabled": false, + "id": "pair_22881d63794c4a30bde5ebde1acfd6e7" + } + ], + "headers": [ + { + "name": "Cookie", + "value": "__stripe_mid=9edfc0bb-44b7-4578-9891-79fc8186bd8d21bd04; rw.session=rw_Fe26.2**59c48bdf92c61ccc01305240c75c68bec817014d417a8491d8b00452308052f8*xndzMd6R6DfmF7gVMgqB6A*f1kHhYV1qfls1RNnf25ZaTJIVziG448bozcrI014mb7heWWbtYxuj-HaUieCd2krFmhW6YEtlBq1_tn38BTzjQ*1666553259403*51eef82f4bb9607e184b4b577c5ca1c73bb2a23eb1c724f1435230ab2f4553a4*DHOs3UtBSPZFv3tmx-hIfP93MFHNH37z945vZHCuFFc; rw.session.sig=qDAXZPk6-xyOrqIyCxucXO208B0", + "id": "pair_a0828f267f4f490a8f3571b8fda99c77" + }, + { + "id": "pair_149b1a50185c4f3b8ae8f9c83477b0d9", + "name": "Content-Type", + "value": "application/json", + "description": "" + } + ], + "authentication": {}, + "metaSortKey": -1699222709193, + "isPrivate": false, + "settingStoreCookies": true, + "settingSendCookies": true, + "settingDisableRenderRequestBody": false, + "settingEncodeUrl": true, + "settingRebuildPath": true, + "settingFollowRedirects": "global", + "_type": "request" }, { "_id": "req_9765c255e6924e84b9945eb350b22525", - "parentId": "wrk_cd2351f82a134dec87cb74c0bc9e3e7c", - "modified": 1698941921008, + "parentId": "fld_6030301042004f1d937834031923f864", + "modified": 1699222709203, "created": 1653501388183, "url": "{{ _.GRAPHQL_ENDPOINT }}", "name": "Create Service Domain", @@ -410,174 +498,7 @@ } ], "authentication": {}, - "metaSortKey": -1652052654305.9688, - "isPrivate": false, - "settingStoreCookies": true, - "settingSendCookies": true, - "settingDisableRenderRequestBody": false, - "settingEncodeUrl": true, - "settingRebuildPath": true, - "settingFollowRedirects": "global", - "_type": "request" - }, - { - "_id": "req_5741a3ea53e7403f956c44543cb98793", - "parentId": "wrk_cd2351f82a134dec87cb74c0bc9e3e7c", - "modified": 1698941922124, - "created": 1653506166429, - "url": "{{ _.GRAPHQL_ENDPOINT }}", - "name": "Delete Service Domain", - "description": "", - "method": "POST", - "body": { - "mimeType": "application/graphql", - "text": "{\"query\":\"mutation ($serviceDomainId: ID!) {\\n\\tserviceDomainDelete(\\n\\t\\tprojectId: \\\"b7a46032-fe7f-48f2-8a0c-5d7e30b1a6dc\\\"\\n\\t\\tenvironmentId: \\\"5b53202d-f0dd-4aef-ae67-b7dffc9f2664\\\"\\n\\t\\tid: $serviceDomainId\\n\\t)\\n}\\n\",\"variables\":{\"serviceDomainId\":\"{% response 'body', 'req_9765c255e6924e84b9945eb350b22525', 'b64::JC4uaWQ=::46b', 'never', 60 %}\"}}" - }, - "parameters": [], - "headers": [ - { - "name": "Content-Type", - "value": "application/json", - "id": "pair_a547d82bc2684b7595ab676d2668bbac" - } - ], - "authentication": {}, - "metaSortKey": -1651831426976.4844, - "isPrivate": false, - "settingStoreCookies": true, - "settingSendCookies": true, - "settingDisableRenderRequestBody": false, - "settingEncodeUrl": true, - "settingRebuildPath": true, - "settingFollowRedirects": "global", - "_type": "request" - }, - { - "_id": "req_2ca47b965a3a456fa82d91799b1bb672", - "parentId": "wrk_cd2351f82a134dec87cb74c0bc9e3e7c", - "modified": 1698941923984, - "created": 1653522891907, - "url": "{{ _.GRAPHQL_ENDPOINT }}", - "name": "Get Deployments", - "description": "", - "method": "POST", - "body": { - "mimeType": "application/graphql", - "text": "{\"query\":\"query {\\n\\tdeployments(where: {projectId: \\\"b7a46032-fe7f-48f2-8a0c-5d7e30b1a6dc\\\"}) {\\n\\t\\tnodes {\\n\\t\\t\\tid\\n\\t\\t\\tstaticUrl\\n\\t\\t}\\n\\t}\\n}\\n\",\"variables\":{}}" - }, - "parameters": [], - "headers": [ - { - "name": "Content-Type", - "value": "application/json", - "id": "pair_a547d82bc2684b7595ab676d2668bbac" - }, - { - "id": "pair_619347adbf6c47c98965adc8a616bedf", - "name": "", - "value": "", - "description": "" - }, - { - "id": "pair_0806f4c53d97487da52deac558b9a714", - "name": "", - "value": "", - "description": "" - } - ], - "authentication": {}, - "metaSortKey": -1651720813311.7422, - "isPrivate": false, - "settingStoreCookies": true, - "settingSendCookies": true, - "settingDisableRenderRequestBody": false, - "settingEncodeUrl": true, - "settingRebuildPath": true, - "settingFollowRedirects": "global", - "_type": "request" - }, - { - "_id": "req_342c6ea8a6e44ee79146f658bbccbc37", - "parentId": "wrk_cd2351f82a134dec87cb74c0bc9e3e7c", - "modified": 1698941925316, - "created": 1664387180476, - "url": "https://backboard.railway-develop.app/graphql/v2", - "name": "Variables", - "description": "", - "method": "POST", - "body": { - "mimeType": "application/graphql", - "text": "{\"query\":\"query VariablesForDeploy {\\n\\tvariablesForServiceDeployment(\\n\\t\\tenvironmentId: \\\"e12b44cd-2f44-4213-918a-c6b2b2da1119\\\"\\n\\t\\tserviceId: \\\"1fb71daf-a16f-4908-bc9a-edf5eb17ff55\\\"\\n\\t\\tprojectId: \\\"0f65ff5f-66c8-4768-9efe-151c5fb0c67e\\\"\\n\\t)\\n}\\n\",\"operationName\":\"VariablesForDeploy\"}" - }, - "parameters": [ - { - "name": "q", - "value": "project", - "disabled": false, - "id": "pair_22881d63794c4a30bde5ebde1acfd6e7" - } - ], - "headers": [ - { - "name": "Cookie", - "value": "__stripe_mid=9edfc0bb-44b7-4578-9891-79fc8186bd8d21bd04; rw.session=rw_Fe26.2**59c48bdf92c61ccc01305240c75c68bec817014d417a8491d8b00452308052f8*xndzMd6R6DfmF7gVMgqB6A*f1kHhYV1qfls1RNnf25ZaTJIVziG448bozcrI014mb7heWWbtYxuj-HaUieCd2krFmhW6YEtlBq1_tn38BTzjQ*1666553259403*51eef82f4bb9607e184b4b577c5ca1c73bb2a23eb1c724f1435230ab2f4553a4*DHOs3UtBSPZFv3tmx-hIfP93MFHNH37z945vZHCuFFc; rw.session.sig=qDAXZPk6-xyOrqIyCxucXO208B0", - "id": "pair_a0828f267f4f490a8f3571b8fda99c77" - }, - { - "id": "pair_149b1a50185c4f3b8ae8f9c83477b0d9", - "name": "Content-Type", - "value": "application/json", - "description": "" - } - ], - "authentication": {}, - "metaSortKey": -1651665506479.371, - "isPrivate": false, - "settingStoreCookies": true, - "settingSendCookies": true, - "settingDisableRenderRequestBody": false, - "settingEncodeUrl": true, - "settingRebuildPath": true, - "settingFollowRedirects": "global", - "_type": "request" - }, - { - "_id": "req_b78c4a006dda4a8bacd2d5e6860cc418", - "parentId": "wrk_cd2351f82a134dec87cb74c0bc9e3e7c", - "modified": 1698941930038, - "created": 1661542784701, - "url": "en", - "name": "New Request", - "description": "", - "method": "GET", - "body": {}, - "parameters": [], - "headers": [], - "authentication": {}, - "metaSortKey": -1651610151969.5, - "isPrivate": false, - "settingStoreCookies": true, - "settingSendCookies": true, - "settingDisableRenderRequestBody": false, - "settingEncodeUrl": true, - "settingRebuildPath": true, - "settingFollowRedirects": "global", - "_type": "request" - }, - { - "_id": "req_c88f176ac17c441ca702b644898e2d20", - "parentId": "wrk_cd2351f82a134dec87cb74c0bc9e3e7c", - "modified": 1698941931162, - "created": 1655414519907, - "url": "newworld-server-status-production.up.railway.app", - "name": "Test", - "description": "", - "method": "GET", - "body": {}, - "parameters": [], - "headers": [], - "authentication": {}, - "metaSortKey": -1651610128130.75, + "metaSortKey": -1699222709168, "isPrivate": false, "settingStoreCookies": true, "settingSendCookies": true, @@ -589,8 +510,8 @@ }, { "_id": "req_aceafe72950f4818bcb74eab4b79d3f5", - "parentId": "wrk_cd2351f82a134dec87cb74c0bc9e3e7c", - "modified": 1698941932133, + "parentId": "fld_ee67581f87c542aabb3fe375104264b9", + "modified": 1699222669071, "created": 1647458250539, "url": "https://health.up.railway.app", "name": "Production Health", @@ -600,7 +521,7 @@ "parameters": [], "headers": [], "authentication": {}, - "metaSortKey": -1651610116211.375, + "metaSortKey": -1699222664648, "isPrivate": false, "settingStoreCookies": true, "settingSendCookies": true, @@ -611,9 +532,21 @@ "_type": "request" }, { - "_id": "req_6c99ccd2c0b64897be2c148506315105", + "_id": "fld_ee67581f87c542aabb3fe375104264b9", "parentId": "wrk_cd2351f82a134dec87cb74c0bc9e3e7c", - "modified": 1698941933294, + "modified": 1699222650974, + "created": 1699222644488, + "name": "Service Proxy", + "description": "", + "environment": {}, + "environmentPropertyOrder": null, + "metaSortKey": -1651610122171.0625, + "_type": "request_group" + }, + { + "_id": "req_6c99ccd2c0b64897be2c148506315105", + "parentId": "fld_ee67581f87c542aabb3fe375104264b9", + "modified": 1699222673201, "created": 1647463574333, "url": "https://35.227.136.140", "name": "Production Go Server (SP 0)", @@ -631,7 +564,7 @@ } ], "authentication": {}, - "metaSortKey": -1651610110251.6875, + "metaSortKey": -1699222664623, "isPrivate": false, "settingStoreCookies": true, "settingSendCookies": true, @@ -643,8 +576,8 @@ }, { "_id": "req_5ef4cd8d591d4f97b55360ec38f9bcf7", - "parentId": "wrk_cd2351f82a134dec87cb74c0bc9e3e7c", - "modified": 1698941935909, + "parentId": "fld_ee67581f87c542aabb3fe375104264b9", + "modified": 1699222683904, "created": 1647463586661, "url": "https://34.82.254.200", "name": "Production Go Server (SP 1)", @@ -662,7 +595,7 @@ } ], "authentication": {}, - "metaSortKey": -1651610107271.8438, + "metaSortKey": -1699222664616.75, "isPrivate": false, "settingStoreCookies": true, "settingSendCookies": true, @@ -674,8 +607,8 @@ }, { "_id": "req_5d976ede609e4c76b8e8d33d7c3c90c5", - "parentId": "wrk_cd2351f82a134dec87cb74c0bc9e3e7c", - "modified": 1698941936827, + "parentId": "fld_ee67581f87c542aabb3fe375104264b9", + "modified": 1699222685468, "created": 1648507862472, "url": "https://34.127.19.80", "name": "Production Go Server (SP 2)", @@ -693,7 +626,7 @@ } ], "authentication": {}, - "metaSortKey": -1651610105781.9219, + "metaSortKey": -1699222664613.625, "isPrivate": false, "settingStoreCookies": true, "settingSendCookies": true, @@ -705,8 +638,8 @@ }, { "_id": "req_4070af182e2c4414b5e9cecf04b39c21", - "parentId": "wrk_cd2351f82a134dec87cb74c0bc9e3e7c", - "modified": 1698941937902, + "parentId": "fld_ee67581f87c542aabb3fe375104264b9", + "modified": 1699222686873, "created": 1648509308934, "url": "https://35.227.136.140", "name": "Production Health (SP 0)", @@ -724,7 +657,7 @@ } ], "authentication": {}, - "metaSortKey": -1651610105036.961, + "metaSortKey": -1699222664612.0625, "isPrivate": false, "settingStoreCookies": true, "settingSendCookies": true, @@ -736,8 +669,8 @@ }, { "_id": "req_d090114065924f849d5d70983c1a9445", - "parentId": "wrk_cd2351f82a134dec87cb74c0bc9e3e7c", - "modified": 1698941938930, + "parentId": "fld_ee67581f87c542aabb3fe375104264b9", + "modified": 1699222688149, "created": 1648509727183, "url": "https://34.82.254.200", "name": "Production Health (SP 1)", @@ -755,7 +688,7 @@ } ], "authentication": {}, - "metaSortKey": -1651610104664.4805, + "metaSortKey": -1699222664611.2812, "isPrivate": false, "settingStoreCookies": true, "settingSendCookies": true, @@ -767,8 +700,8 @@ }, { "_id": "req_3b4f8d4cf5c0403cbacc20cfa0d0909e", - "parentId": "wrk_cd2351f82a134dec87cb74c0bc9e3e7c", - "modified": 1698941940665, + "parentId": "fld_ee67581f87c542aabb3fe375104264b9", + "modified": 1699222689198, "created": 1648507992005, "url": "https://34.127.19.80", "name": "Production Health (SP 2)", @@ -786,7 +719,7 @@ } ], "authentication": {}, - "metaSortKey": -1651610104478.2402, + "metaSortKey": -1699222664610.8906, "isPrivate": false, "settingStoreCookies": true, "settingSendCookies": true, @@ -798,8 +731,8 @@ }, { "_id": "req_0abf3b152fef4e2b809b3eca7fa8c5ed", - "parentId": "wrk_cd2351f82a134dec87cb74c0bc9e3e7c", - "modified": 1698941941575, + "parentId": "fld_ee67581f87c542aabb3fe375104264b9", + "modified": 1699222690412, "created": 1661495542931, "url": "https://35.230.52.169", "name": "Production Health (SP 3)", @@ -817,7 +750,7 @@ } ], "authentication": {}, - "metaSortKey": -1651610104385.12, + "metaSortKey": -1699222664610.6953, "isPrivate": false, "settingStoreCookies": true, "settingSendCookies": true, @@ -829,8 +762,8 @@ }, { "_id": "req_86bc2a68db064d3394d61d5012685d88", - "parentId": "wrk_cd2351f82a134dec87cb74c0bc9e3e7c", - "modified": 1698941942602, + "parentId": "fld_ee67581f87c542aabb3fe375104264b9", + "modified": 1699222691411, "created": 1661536011852, "url": "https://34.83.190.231", "name": "Production Health (SP 4)", @@ -848,7 +781,7 @@ } ], "authentication": {}, - "metaSortKey": -1651610104338.56, + "metaSortKey": -1699222664610.5977, "isPrivate": false, "settingStoreCookies": true, "settingSendCookies": true, @@ -860,8 +793,8 @@ }, { "_id": "req_2a1a47392f71465abedf1605878bd8b7", - "parentId": "wrk_cd2351f82a134dec87cb74c0bc9e3e7c", - "modified": 1698941946272, + "parentId": "fld_ee67581f87c542aabb3fe375104264b9", + "modified": 1699222692671, "created": 1661536017974, "url": "https://35.203.130.181", "name": "Production Health (SP 5)", @@ -879,30 +812,7 @@ } ], "authentication": {}, - "metaSortKey": -1651610104315.28, - "isPrivate": false, - "settingStoreCookies": true, - "settingSendCookies": true, - "settingDisableRenderRequestBody": false, - "settingEncodeUrl": true, - "settingRebuildPath": true, - "settingFollowRedirects": "global", - "_type": "request" - }, - { - "_id": "req_b78b921a543442f6ad26cffd79134a71", - "parentId": "wrk_cd2351f82a134dec87cb74c0bc9e3e7c", - "modified": 1698941947284, - "created": 1650998377419, - "url": "https://fastapi-test-production-cfb9.up.railway.app/", - "name": "Fallback 503", - "description": "", - "method": "GET", - "body": {}, - "parameters": [], - "headers": [], - "authentication": {}, - "metaSortKey": -1651610104303.6401, + "metaSortKey": -1699222664610.5488, "isPrivate": false, "settingStoreCookies": true, "settingSendCookies": true, @@ -914,8 +824,8 @@ }, { "_id": "req_ce1409130bbd470b82ee234986055732", - "parentId": "wrk_cd2351f82a134dec87cb74c0bc9e3e7c", - "modified": 1698941948315, + "parentId": "fld_ee67581f87c542aabb3fe375104264b9", + "modified": 1699222682620, "created": 1650998482383, "url": "https://b44574691bf9.up.railway.app/", "name": "Fallback 404", @@ -925,7 +835,30 @@ "parameters": [], "headers": [], "authentication": {}, - "metaSortKey": -1651610104297.82, + "metaSortKey": -1699222664610.5, + "isPrivate": false, + "settingStoreCookies": true, + "settingSendCookies": true, + "settingDisableRenderRequestBody": false, + "settingEncodeUrl": true, + "settingRebuildPath": true, + "settingFollowRedirects": "global", + "_type": "request" + }, + { + "_id": "req_b78b921a543442f6ad26cffd79134a71", + "parentId": "fld_ee67581f87c542aabb3fe375104264b9", + "modified": 1699222695088, + "created": 1650998377419, + "url": "https://fastapi-test-production-cfb9.up.railway.app/", + "name": "Fallback 503", + "description": "", + "method": "GET", + "body": {}, + "parameters": [], + "headers": [], + "authentication": {}, + "metaSortKey": -1699222664510.5, "isPrivate": false, "settingStoreCookies": true, "settingSendCookies": true, @@ -1128,6 +1061,25 @@ "isPrivate": false, "metaSortKey": 1651610110792, "_type": "environment" + }, + { + "_id": "env_6f68e0b0ace7422886f3d5de98bf3c2a", + "parentId": "env_396b20e683679d3405b86836c3479da41cef2434", + "modified": 1699222778492, + "created": 1699222764262, + "name": "Hello Env", + "data": { + "number": 1 + }, + "dataPropertyOrder": { + "&": [ + "number" + ] + }, + "color": null, + "isPrivate": false, + "metaSortKey": 1699222764262, + "_type": "environment" } ] } diff --git a/src-tauri/plugins/insomnia-importer/importers/request.js b/src-tauri/plugins/insomnia-importer/importers/request.js index c8c4a666..e9b1a001 100644 --- a/src-tauri/plugins/insomnia-importer/importers/request.js +++ b/src-tauri/plugins/insomnia-importer/importers/request.js @@ -6,6 +6,20 @@ */ export function importRequest(r, workspaceId, sortPriority = 0) { console.log('IMPORTING REQUEST', r._id, r.name, JSON.stringify(r, null, 2)); + let bodyType = null; + let body = null; + if (r.body?.mimeType === 'application/graphql') { + bodyType = 'graphql'; + body = r.body.text; + } + let authenticationType = null; + let authentication = {}; + if (r.authentication.type === 'bearer') { + authenticationType = 'bearer'; + authentication = { + token: r.authentication.token, + }; + } return { id: r._id, createdAt: new Date(r.created ?? Date.now()).toISOString().replace('Z', ''), @@ -16,10 +30,10 @@ export function importRequest(r, workspaceId, sortPriority = 0) { sortPriority, name: r.name, url: r.url, - body: null, // TODO: Import body - bodyType: null, - authentication: {}, // TODO: Import authentication - authenticationType: null, + body, + bodyType, + authentication, + authenticationType, method: r.method, headers: (r.headers ?? []).map(({ name, value, disabled }) => ({ enabled: !disabled, diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index bbc37ce1..9844c5b8 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -68,7 +68,7 @@ async fn migrate_db( #[tauri::command] async fn send_ephemeral_request( - request: models::HttpRequest, + mut request: models::HttpRequest, environment_id: Option<&str>, app_handle: AppHandle, db_instance: State<'_, Mutex>>, @@ -76,6 +76,7 @@ async fn send_ephemeral_request( let pool = &*db_instance.lock().await; let response = models::HttpResponse::default(); let environment_id2 = environment_id.unwrap_or("n/a").to_string(); + request.id = "".to_string(); return actually_send_ephemeral_request( request, &response, diff --git a/src-web/components/RequestPane.tsx b/src-web/components/RequestPane.tsx index 024bc59e..0edf4c38 100644 --- a/src-web/components/RequestPane.tsx +++ b/src-web/components/RequestPane.tsx @@ -4,9 +4,10 @@ import classNames from 'classnames'; import type { CSSProperties } from 'react'; import { memo, useCallback, useMemo, useState } from 'react'; import { createGlobalState } from 'react-use'; +import { useActiveEnvironmentId } from '../hooks/useActiveEnvironmentId'; import { useActiveRequest } from '../hooks/useActiveRequest'; -import { useRequestUpdateKey } from '../hooks/useRequestUpdateKey'; import { useListenToTauriEvent } from '../hooks/useListenToTauriEvent'; +import { useRequestUpdateKey } from '../hooks/useRequestUpdateKey'; import { useUpdateRequest } from '../hooks/useUpdateRequest'; import { tryFormatJson } from '../lib/formatters'; import type { HttpHeader, HttpRequest } from '../lib/models'; @@ -30,7 +31,6 @@ import { GraphQLEditor } from './GraphQLEditor'; import { HeaderEditor } from './HeaderEditor'; import { ParametersEditor } from './ParameterEditor'; import { UrlBar } from './UrlBar'; -import { useActiveEnvironmentId } from '../hooks/useActiveEnvironmentId'; interface Props { style?: CSSProperties; @@ -88,7 +88,7 @@ export const RequestPane = memo(function RequestPane({ style, fullHeight, classN // Force update header editor so any changed headers are reflected setTimeout(() => setForceUpdateHeaderEditorKey((u) => u + 1), 100); - await updateRequest.mutate(patch); + updateRequest.mutate(patch); }, }, }, @@ -125,7 +125,7 @@ export const RequestPane = memo(function RequestPane({ style, fullHeight, classN token: authentication.token ?? '', }; } - await updateRequest.mutate({ authenticationType, authentication }); + updateRequest.mutate({ authenticationType, authentication }); }, }, }, @@ -146,7 +146,10 @@ export const RequestPane = memo(function RequestPane({ style, fullHeight, classN 'send_request', async ({ windowLabel }) => { if (windowLabel !== appWindow.label) return; - await invoke('send_request', { requestId: activeRequestId, environmentId: activeEnvironmentId }); + await invoke('send_request', { + requestId: activeRequestId, + environmentId: activeEnvironmentId, + }); }, [activeRequestId, activeEnvironmentId], ); diff --git a/src-web/lib/models.ts b/src-web/lib/models.ts index 8d2a191c..501ea489 100644 --- a/src-web/lib/models.ts +++ b/src-web/lib/models.ts @@ -1,4 +1,3 @@ - export const BODY_TYPE_NONE = null; export const BODY_TYPE_GRAPHQL = 'graphql'; export const BODY_TYPE_JSON = 'application/json'; @@ -61,8 +60,6 @@ export interface HttpRequest extends BaseModel { bodyType: string | null; authentication: Record; authenticationType: string | null; - auth: Record; - authType: string | null; method: string; headers: HttpHeader[]; } diff --git a/src-web/lib/sendEphemeralRequest.ts b/src-web/lib/sendEphemeralRequest.ts index ec5ce115..daa4a909 100644 --- a/src-web/lib/sendEphemeralRequest.ts +++ b/src-web/lib/sendEphemeralRequest.ts @@ -1,8 +1,11 @@ import { invoke } from '@tauri-apps/api'; import type { HttpRequest, HttpResponse } from './models'; -export async function sendEphemeralRequest(request: HttpRequest, environmentId: string | null): Promise { +export async function sendEphemeralRequest( + request: HttpRequest, + environmentId: string | null, +): Promise { // Remove some things that we don't want to associate - const newRequest = { ...request, id: '', requestId: '', workspaceId: '' }; + const newRequest = { ...request }; return invoke('send_ephemeral_request', { request: newRequest, environmentId }); }