diff --git a/plugins/importer-insomnia/src/v5.ts b/plugins/importer-insomnia/src/v5.ts index f85b9010..523d5abe 100644 --- a/plugins/importer-insomnia/src/v5.ts +++ b/plugins/importer-insomnia/src/v5.ts @@ -75,7 +75,7 @@ function importHttpRequest( let bodyType: string | null = null; let body = {}; - if (r.body.mimeType === 'application/octet-stream') { + if (r.body?.mimeType === 'application/octet-stream') { bodyType = 'binary'; body = { filePath: r.body.fileName ?? '' }; } else if (r.body?.mimeType === 'application/x-www-form-urlencoded') { @@ -256,7 +256,7 @@ function importEnvironment(e: any, workspaceId: string, isParent?: boolean): Par base: isParent ?? e.parentId === workspaceId, model: 'environment', name: e.name, - variables: Object.entries(e.data).map(([name, value]) => ({ + variables: Object.entries(e.data ?? {}).map(([name, value]) => ({ enabled: true, name, value: `${value}`, diff --git a/plugins/importer-insomnia/tests/fixtures/basic.output.json b/plugins/importer-insomnia/tests/fixtures/basic.output.json index f640dc7c..235a227d 100644 --- a/plugins/importer-insomnia/tests/fixtures/basic.output.json +++ b/plugins/importer-insomnia/tests/fixtures/basic.output.json @@ -113,6 +113,7 @@ "workspaceId": "GENERATE_ID::wrk_d4d92f7c0ee947b89159243506687019" } ], + "websocketRequests": [], "workspaces": [ { "createdAt": "2025-01-13T15:15:43.765", diff --git a/plugins/importer-insomnia/tests/fixtures/version-5-minimal.input.yaml b/plugins/importer-insomnia/tests/fixtures/version-5-minimal.input.yaml new file mode 100644 index 00000000..ff7a005b --- /dev/null +++ b/plugins/importer-insomnia/tests/fixtures/version-5-minimal.input.yaml @@ -0,0 +1,72 @@ +type: collection.insomnia.rest/5.0 +name: Debugging +meta: + id: wrk_9717dd1c9e0c4b2e9ed6d2abcf3bd45c + created: 1747197924902 + modified: 1747197924902 +collection: + - name: My Folder + meta: + id: fld_296933ea4ea84783a775d199997e9be7 + created: 1747414092298 + modified: 1747414142427 + sortKey: -1747414092298 + children: + - url: https://httpbin.org/post + name: New Request + meta: + id: req_9a80320365ac4509ade406359dbc6a71 + created: 1747197928502 + modified: 1747414129313 + isPrivate: false + sortKey: -1747414129276 + method: GET + headers: + - name: User-Agent + value: insomnia/11.1.0 + id: pair_6ae87d1620a9494f8e5b29cd9f92d087 + settings: + renderRequestBody: true + encodeUrl: true + followRedirects: global + cookies: + send: true + store: true + rebuildPath: true + headers: + - id: pair_f2b330e3914f4c11b209318aef94325c + name: foo + value: bar + disabled: false + - name: New Request + meta: + id: req_e3f8cdbd58784a539dd4c1e127d73451 + created: 1747414160497 + modified: 1747414160497 + isPrivate: false + sortKey: -1747414160498 + method: GET + headers: + - name: User-Agent + value: insomnia/11.1.0 + settings: + renderRequestBody: true + encodeUrl: true + followRedirects: global + cookies: + send: true + store: true + rebuildPath: true +cookieJar: + name: Default Jar + meta: + id: jar_e46dc73e8ccda30ca132153e8f11183bd08119ce + created: 1747197924904 + modified: 1747197924904 +environments: + name: Base Environment + meta: + id: env_e46dc73e8ccda30ca132153e8f11183bd08119ce + created: 1747197924903 + modified: 1747197924903 + isPrivate: false diff --git a/plugins/importer-insomnia/tests/fixtures/version-5-minimal.output.json b/plugins/importer-insomnia/tests/fixtures/version-5-minimal.output.json new file mode 100644 index 00000000..b581956c --- /dev/null +++ b/plugins/importer-insomnia/tests/fixtures/version-5-minimal.output.json @@ -0,0 +1,87 @@ +{ + "resources": { + "environments": [ + { + "base": true, + "createdAt": "2025-05-14T04:45:24.903", + "id": "GENERATE_ID::env_e46dc73e8ccda30ca132153e8f11183bd08119ce", + "model": "environment", + "name": "Base Environment", + "public": true, + "updatedAt": "2025-05-14T04:45:24.903", + "variables": [], + "workspaceId": "GENERATE_ID::wrk_9717dd1c9e0c4b2e9ed6d2abcf3bd45c" + } + ], + "folders": [ + { + "createdAt": "2025-05-16T16:48:12.298", + "folderId": null, + "id": "GENERATE_ID::fld_296933ea4ea84783a775d199997e9be7", + "model": "folder", + "name": "My Folder", + "sortPriority": -1747414092298, + "updatedAt": "2025-05-16T16:49:02.427", + "workspaceId": "GENERATE_ID::wrk_9717dd1c9e0c4b2e9ed6d2abcf3bd45c" + } + ], + "grpcRequests": [], + "httpRequests": [ + { + "authentication": {}, + "authenticationType": null, + "body": {}, + "bodyType": null, + "createdAt": "2025-05-14T04:45:28.502", + "folderId": "GENERATE_ID::fld_296933ea4ea84783a775d199997e9be7", + "headers": [ + { + "enabled": true, + "name": "User-Agent", + "value": "insomnia/11.1.0" + } + ], + "id": "GENERATE_ID::req_9a80320365ac4509ade406359dbc6a71", + "method": "GET", + "model": "http_request", + "name": "New Request", + "sortPriority": -1747414129276, + "updatedAt": "2025-05-16T16:48:49.313", + "url": "https://httpbin.org/post", + "workspaceId": "GENERATE_ID::wrk_9717dd1c9e0c4b2e9ed6d2abcf3bd45c" + }, + { + "authentication": {}, + "authenticationType": null, + "body": {}, + "bodyType": null, + "createdAt": "2025-05-16T16:49:20.497", + "folderId": null, + "headers": [ + { + "enabled": true, + "name": "User-Agent", + "value": "insomnia/11.1.0" + } + ], + "id": "GENERATE_ID::req_e3f8cdbd58784a539dd4c1e127d73451", + "method": "GET", + "model": "http_request", + "name": "New Request", + "sortPriority": -1747414160498, + "updatedAt": "2025-05-16T16:49:20.497", + "workspaceId": "GENERATE_ID::wrk_9717dd1c9e0c4b2e9ed6d2abcf3bd45c" + } + ], + "websocketRequests": [], + "workspaces": [ + { + "createdAt": "2025-05-14T04:45:24.902", + "id": "GENERATE_ID::wrk_9717dd1c9e0c4b2e9ed6d2abcf3bd45c", + "model": "workspace", + "name": "Debugging", + "updatedAt": "2025-05-14T04:45:24.902" + } + ] + } +}