diff --git a/.github/workflows/aur-publish.yml b/.github/workflows/aur-publish.yml new file mode 100644 index 00000000..2d11aed4 --- /dev/null +++ b/.github/workflows/aur-publish.yml @@ -0,0 +1,88 @@ +name: Update AUR Package + +on: + push: + tags: + - 'v*' + paths: + - 'pubspec.yaml' + +jobs: + aur-publish: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Get version from pubspec + id: get_version + run: | + VERSION=$(grep 'version:' pubspec.yaml | awk '{print $2}' | cut -d'+' -f1) + echo "version=$VERSION" >> $GITHUB_OUTPUT + + - name: Get checksums + id: get_checksums + run: | + # Download the x86_64 .deb + wget https://github.com/foss42/apidash/releases/download/v${{ steps.get_version.outputs.version }}/apidash-linux-amd64.deb + + # Download the arm64 .deb + wget https://github.com/foss42/apidash/releases/download/v${{ steps.get_version.outputs.version }}/apidash-linux-arm64.deb + + # Download the LICENSE + wget https://raw.githubusercontent.com/foss42/apidash/main/LICENSE + + # Generate SHA512 checksums + DEB_X86_64_CHECKSUM=$(sha512sum apidash-linux-amd64.deb | awk '{print $1}') + DEB_ARM64_CHECKSUM=$(sha512sum apidash-linux-arm64.deb | awk '{print $1}') + LICENSE_CHECKSUM=$(sha512sum LICENSE | awk '{print $1}') + + echo "deb_x86_64_checksum=$DEB_X86_64_CHECKSUM" >> $GITHUB_OUTPUT + echo "deb_arm64_checksum=$DEB_ARM64_CHECKSUM" >> $GITHUB_OUTPUT + echo "license_checksum=$LICENSE_CHECKSUM" >> $GITHUB_OUTPUT + + - name: Publish AUR package + uses: KSXGitHub/github-actions-deploy-aur@v2.7.0 + with: + pkgname: apidash-bin + pkgbuild: | + # Maintainer: Angelo Geulin + + pkgname=apidash-bin + pkgver=${{ steps.get_version.outputs.version }} + pkgrel=1 + pkgdesc="Beautiful open-source cross-platform API Client" + arch=('x86_64' 'aarch64') + url="https://apidash.dev" + license=('Apache-2.0') + depends=() + options=('!emptydirs' '!strip') + source=("LICENSE::https://raw.githubusercontent.com/foss42/apidash/main/LICENSE") + source_x86_64=("apidash-linux-amd64.deb::https://github.com/foss42/apidash/releases/download/v${{ steps.get_version.outputs.version }}/apidash-linux-amd64.deb") + source_aarch64=("apidash-linux-arm64.deb::https://github.com/foss42/apidash/releases/download/v${{ steps.get_version.outputs.version }}/apidash-linux-arm64.deb") + sha512sums=('${{ steps.get_checksums.outputs.license_checksum }}') + sha512sums_x86_64=('${{ steps.get_checksums.outputs.deb_x86_64_checksum }}') + sha512sums_aarch64=('${{ steps.get_checksums.outputs.deb_arm64_checksum }}') + + package() { + if [ "$CARCH" = "x86_64" ]; then + _debfile="$srcdir/apidash-linux-amd64.deb" + elif [ "$CARCH" = "aarch64" ]; then + _debfile="$srcdir/apidash-linux-arm64.deb" + fi + ar -x "${_debfile}" data.tar.zst + bsdtar -xf data.tar.zst -C "$pkgdir/" + + # Fix permissions of directories + find "$pkgdir/" -type d -exec chmod 755 {} \; + + # Create a symlink inside /usr/bin + mkdir -p "${pkgdir}/usr/bin" + ln -s /usr/share/apidash/apidash "$pkgdir/usr/bin/apidash" + + install -Dm644 "$srcdir/LICENSE" "$pkgdir/usr/share/licenses/$pkgname/LICENSE" + } + commit_username: ${{ secrets.AUR_USERNAME }} + commit_email: ${{ secrets.AUR_EMAIL }} + ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }} + commit_message: "Update to version ${{ steps.get_version.outputs.version }}" \ No newline at end of file diff --git a/.gitignore b/.gitignore index 787eab48..73c02ac9 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,8 @@ .svn/ .swiftpm/ migrate_working_dir/ +.fvm +.fvmrc # IntelliJ related *.iml diff --git a/README.md b/README.md index c75ada48..b4e69fe1 100644 --- a/README.md +++ b/README.md @@ -89,7 +89,7 @@ API Dash can be downloaded from the links below: | --- | --- | | Postman | ✅ | | cURL | ✅ | -| Insomnia | https://github.com/foss42/apidash/issues/125 | +| Insomnia | ✅ | | OpenAPI | https://github.com/foss42/apidash/issues/121 | | hurl | https://github.com/foss42/apidash/issues/123 | | HAR | https://github.com/foss42/apidash/issues/122 | diff --git a/doc/dev_guide/packaging.md b/doc/dev_guide/packaging.md index f43a0a63..59fc1fcf 100644 --- a/doc/dev_guide/packaging.md +++ b/doc/dev_guide/packaging.md @@ -23,7 +23,58 @@ ## Arch Linux (PKGBUILD) -TODO Instructions +Steps to update and release the Arch Linux package + +1. Install required packages: + +```bash +sudo pacman -S base-devel +``` + +2. Clone the ApiDash AUR repository: + +```bash +git clone https://aur.archlinux.org/apidash-bin.git +cd apidash-bin +``` + +3. Get the recent `.deb` release from the [releases page](https://github.com/foss42/apidash/releases/) + +4. Generate new checksums: + +```bash +sha512sum apidash-linux-amd64.deb LICENSE +``` + +5. Update the `PKGBUILD` file: + + - Change `pkgver` to the new version + - Reset `pkgrel` to 1 + - Update `sha512sums` with the new checksums + +6. Build the package + +```bash +# Clean build files (if they exist from previous builds) +# rm -rf pkg/ src/ + +# Build and install the package +makepkg -si +``` + +7. Update .SRCINFO: + +```bash +makepkg --printsrcinfo > .SRCINFO +``` + +8. Commit and push the changes: + +```bash +git add PKGBUILD .SRCINFO +git commit -m "Update to v[NEW_VERSION]" +git push +``` ## FlatHub (Flatpak) diff --git a/doc/proposals/2025/fosshack/dark_knight_history.md b/doc/proposals/2025/fosshack/dark_knight_history.md new file mode 100644 index 00000000..3e69e02c --- /dev/null +++ b/doc/proposals/2025/fosshack/dark_knight_history.md @@ -0,0 +1,94 @@ +# History Service Implementation for Auto-Clearing API Requests + +Initial proposals: +- https://github.com/foss42/apidash/pull/577 +- https://github.com/foss42/apidash/pull/578 + +Issue - https://github.com/foss42/apidash/issues/551 +PR - https://github.com/foss42/apidash/pull/604 https://github.com/foss42/apidash/pull/616 +Project Link - https://fossunited.org/hack/fosshack25/p/i0aod39ham + +## Team Dart Knight + ++ User - `Vishwa Karthik` ++ Mail - `vishwa.prarthana@gmail.com` + +## Do Checkout ++ [Issues with Isolate & Compute Methodology](https://github.com/foss42/apidash/pull/604#issuecomment-2676863276) + + +## Overview + +This document outlines the implementation of the autoClearHistory feature in APIDASH to efficiently manage stored API request history while maintaining a smooth user experience across all supported platforms. + +## Features +### Auto-Clear History on App Launch + ++ When the app is launched, it automatically clears 50 old API records to prevent excessive local storage usage. + ++ This helps in keeping the app responsive and prevents unnecessary memory consumption. + ++ Triggered using autoClearHistory() from HistoryServiceImpl. + +### Dynamic Auto-Clear Trigger (State Management-Based) + ++ Uses Riverpod StateNotifier to monitor the API request list dynamically. + ++ If the length exceeds 50, the history clearance is automatically triggered, just to avoid heavy duty on app launch. + ++ Reason to use State management here is to resist unnecessary local database call because user may keep switching apps/window during development cycle. + +### Platform-Specific Cleanup Handling + ++ For Android & iOS: Uses AppLifecycleState.paused via WidgetsBindingObserver to trigger autoClearHistory() when the app goes to the background. + ++ For Windows, macOS, Linux:Uses window_manager to detect app minimize events and trigger cleanup accordingly. + ++ Ensures proper handling since AppLifecycleState does not work on desktops. + +### Batch Deletion Strategy + ++ Deleting 50 records at a time minimizes performance issues. + ++ Ensures smooth UX by avoiding excessive database transactions. + ++ Users can continue adding new requests seamlessly without experiencing lag. + +## [Issues with Clearing via Isolates](https://github.com/foss42/apidash/pull/604) + +## My Findings... + +Local Database Hive do not support concurrent connections or transactions due to Native OS locking the hive files on the user desired directory, (hive.lock) files. + ++ Linux Based Arch Distributions and Apple System follow strict file lock system and wouldn't allow opening or accessing boxes from multiple isolates. + +## Reasoning ++ `Hive.init` and `hive.initFlutter` are both method-channel and main UI thread operations which needs many data accessibility which are only available in main thread isolate. + +## Cheap Work Around Solution +1. Close Hive in the main thread +2. Start an isolate +3. Initialize Hive in that isolate +4. Offload tasks to new isolate & Close Hive +5. Re-Open Hive Box in the main thread + +## Problems ++ Although the database transactions are fast, there are high chances the database behavior becomes highly unpredictable. ++ The cleaning service job trigger logic had to changed, since calling it main function may become stupidity. + +## Technical Issues ++ With issues stated, frequent switches between threads will make too many open/close hive boxes to hinder performance of the app. ++ App may stop working abruptly ++ IOS Production app may not allow these operations to do so, and may kill the app. ++ The Hive documentation clearly states that it is not designed for multi-threaded use. ++ Simultaneous reads/writes across isolates may lead to inconsistencies. + +## What about... [PR 604](https://github.com/foss42/apidash/pull/604) ++ The reason why it could have worked for Android, is due to its lenient OS behavior although its Linux-based distribution. ++ Even though Android doesn't throw an error, it's still not safe to open Hive in multiple isolates. + +## Note ++ There is another database called 'Isar' which probably supports multi-threaded concurrent transactions which could have been possible to resolve this functionality. + +## Conclusion ++ The issue opened is very real but the way it has to be tackled is just to clear them in main isolate using optimization techniques like batch request, clearing history in frequent intervals and few more everything in Main Thread ONLY. diff --git a/doc/proposals/2025/fosshack/hackelements.md b/doc/proposals/2025/fosshack/hackelements.md new file mode 100644 index 00000000..0fe8e398 --- /dev/null +++ b/doc/proposals/2025/fosshack/hackelements.md @@ -0,0 +1,5 @@ +# Documentation chnages for Android + +Issue - https://github.com/foss42/apidash/issues/584 +PR - https://github.com/foss42/apidash/pull/589 +Link - https://fossunited.org/hack/fosshack25/p/alqifpr39s diff --git a/doc/proposals/2025/fosshack/mavericks_chatbot.md b/doc/proposals/2025/fosshack/mavericks_chatbot.md new file mode 100644 index 00000000..6192d4bf --- /dev/null +++ b/doc/proposals/2025/fosshack/mavericks_chatbot.md @@ -0,0 +1,86 @@ +# Add ChatBot for API Assistance + +Issue - https://github.com/foss42/apidash/issues/605 +PR - https://github.com/foss42/apidash/pull/608 +Link - https://fossunited.org/hack/fosshack25/p/7e6upj6f19 + +### What we planned to do: + +We aim to implement a **ChatBot feature** in API Dash with the following capabilities: + +1. **Explain API**: + - **Description**: Analyze API responses and provide explanations in natural language. + - **Features**: Generate clear descriptions of the API, including: + - Purpose of the API. + - Key parameters and their roles. + - Response structure and fields. + - Useful for **documentation** and **understanding API behavior**. +2. **Debug Requests Based on Status Codes & Error Messages**: + - **Description**: Provide **structured debugging suggestions** for failed API requests. + - **Features**: + - Analyze status codes (e.g., 4xx, 5xx) and error messages. + - Offer step-by-step guidance to resolve issues. +3. **Generate Test Cases**: + - **Description**: Automatically generate **test cases** for API endpoints. + - **Features**: Includes + - Valid input scenarios. + - Edge cases (e.g., invalid inputs, boundary values). + - Expected responses and status codes. + - Ensure test cases are **ready to use** in testing frameworks +4. **Generate Sample Codes**: + - **Description**: Generate **ready-to-run code snippets** for various programming languages (e.g., Dart, Python, JavaScript, React, Flutter). + - **Features:** Includes + - API integration code. + - Error handling. + - UI components for frontend frameworks (e.g: React). + - Ensure the code is **directly usable** with minimal modifications. + +## What we built + +### **1. Ollama Model Integration** + +- **Dependency**: We integrated the AI chatbot with API Dash using the `ollama_dart: ^0.2.2` package. +- **System Requirements**: To use the Ollama model, the system must have the Ollama application installed locally with a compatible model. +- **Implementation**: + - The interaction with the Ollama model is handled in `lib/services/ollama_services.dart`. + - We tested multiple models, including `deepseek:r1:1.5b`, `ollama3.2:3b`, and `llama3.2:1b`. + - Among these, `ollama3.2:3b` delivered the most accurate responses. + - **Recommendation**: Use `ollama3.2:3b` or higher models for better accuracy. + - **Customization**: Developers can switch models by modifying the “`model:''`” parameter in `/apidash/lib/services/ollama_service.dart`. + +### **2. Dynamic UI: ChatBot Widget** + +- **Design**: + - A mini widget (`?`) is placed at the bottom right of the response panel. + - When clicked, it expands into an AI chatbot interface. +- **Features**: + - **Explain API**: Provides explanations for API functionalities. + - **Debug API**: Assists in debugging API-related issues. + - **Test Cases**: Generates test cases for APIs. + - **Generate Code**: Helps in generating code snippets for API integration. + - **General Questions**: Users can ask general questions about ApiDash. +- **Markdown Support**: + - We used the `“package:flutter_markdown/flutter_markdown.dart”`package to format and display responses in a clean, readable manner. + + +### Setup Guide + +- Install the updated dependency`ollama_dart: ^0.2.2` +- To use the Ollama model, the system must have the Ollama application installed locally with a compatible model. +- The interaction with the Ollama model is handled in `lib/services/ollama_services.dart`. +- **Recommendation**: Use `ollama3.2:3b` or higher models for better accuracy. +- Developers need to switch models by modifying the “`model:''`” parameter in `/apidash/lib/services/ollama_service.dart` to their local Ollama model to interact. +- There you go now run `flutter run` to use AI Chatbot in ApiDash. + + +## Issues +1. **Enhance Response Formatting**: Improve the AI to ensure consistent markdown formatting in responses, eliminating plain text outputs. +2. **Optimize Structured Outputs**: Fine-tune the AI to generate more organized and structured responses for better usability and clarity. + + +## Future Enhancements: +1. Enable users to integrate their local Ollama models seamlessly through the ChatBot interface for enhanced customization. +2. Enable one-click downloading and copying of test codes, ensuring a seamless workflow for developers. +3. Implementing a feature to generate test codes dynamically based on API endpoints and user inputs. +4. A feature to Integrate with complete system architecture +5. Suggesting the best practices from selected type of requests. diff --git a/doc/proposals/2025/fosshack/nihal_arch_packaging.md b/doc/proposals/2025/fosshack/nihal_arch_packaging.md new file mode 100644 index 00000000..653b30d9 --- /dev/null +++ b/doc/proposals/2025/fosshack/nihal_arch_packaging.md @@ -0,0 +1,23 @@ +# Add Arch Linux packaging instructions and CI Pipeline + +Issue - https://github.com/foss42/apidash/issues/545 +PR - https://github.com/foss42/apidash/pull/594 +Link - https://fossunited.org/hack/fosshack25/p/e5n4kirnno + +A GitHub action is triggered on new version tags when `pubspec.yaml` changes + +It: + - Extracts version from pubspec.yaml + - Downloads and generates checksums for the .deb package and LICENSE + - Updates the PKGBUILD with new version and checksums + - Publishes to AUR using the KSXGitHub/github-actions-deploy-aur action + +The following secrets need to be added to the GitHub repository: + +- `AUR_USERNAME`: Maintainer's AUR username +- `AUR_EMAIL`: Maintainer's AUR email address +- `AUR_SSH_PRIVATE_KEY`: Maintiner's SSH private key with AUR access + +Adding workflow for `.deb` turned out to be complex than I had thought. +I have added the support for arm64 and this will assume `.deb` files are available at release time. +If they’re not, it will fail, prompting manual intervention or a separate release process. diff --git a/lib/consts.dart b/lib/consts.dart index 5937636e..595aa69e 100644 --- a/lib/consts.dart +++ b/lib/consts.dart @@ -96,8 +96,6 @@ enum SidebarMenuOption { final String label; } -enum EnvironmentVariableType { variable, secret } - final kEnvVarRegEx = RegExp(r'{{([^{}]*)}}'); enum CodegenLanguage { @@ -141,7 +139,8 @@ enum CodegenLanguage { enum ImportFormat { curl("cURL"), - postman("Postman Collection v2.1"); + postman("Postman Collection v2.1"), + insomnia("Insomnia v4"); const ImportFormat(this.label); final String label; @@ -432,6 +431,7 @@ const kLabelSelect = "Select"; const kLabelContinue = "Continue"; const kLabelCancel = "Cancel"; const kLabelOk = "Ok"; +const kLabelImport = "Import"; const kUntitled = "untitled"; // Request Pane const kLabelRequest = "Request"; diff --git a/lib/importer/importer.dart b/lib/importer/importer.dart index 96d33091..4d93d9be 100644 --- a/lib/importer/importer.dart +++ b/lib/importer/importer.dart @@ -12,6 +12,7 @@ class Importer { ?.map((t) => (null, t)) .toList(), ImportFormat.postman => PostmanIO().getHttpRequestModelList(content), + ImportFormat.insomnia => InsomniaIO().getHttpRequestModelList(content), }; } } diff --git a/lib/models/models.dart b/lib/models/models.dart index d8ea6ac0..5d17479a 100644 --- a/lib/models/models.dart +++ b/lib/models/models.dart @@ -1,4 +1,3 @@ -export 'environment_model.dart'; export 'history_meta_model.dart'; export 'history_request_model.dart'; export 'request_model.dart'; diff --git a/lib/providers/environment_providers.dart b/lib/providers/environment_providers.dart index 0f29cb2d..13c504b2 100644 --- a/lib/providers/environment_providers.dart +++ b/lib/providers/environment_providers.dart @@ -1,7 +1,7 @@ import 'package:apidash/consts.dart'; -import 'package:apidash/models/environment_model.dart'; import 'package:apidash/providers/providers.dart'; import 'package:apidash/utils/file_utils.dart'; +import 'package:apidash_core/apidash_core.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import '../services/services.dart' show hiveHandler, HiveHandler; diff --git a/lib/screens/common_widgets/env_trigger_options.dart b/lib/screens/common_widgets/env_trigger_options.dart index 702209b8..045db973 100644 --- a/lib/screens/common_widgets/env_trigger_options.dart +++ b/lib/screens/common_widgets/env_trigger_options.dart @@ -1,8 +1,8 @@ import 'package:apidash/consts.dart'; +import 'package:apidash_core/apidash_core.dart'; import 'package:apidash_design_system/apidash_design_system.dart'; import 'package:flutter/material.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; -import 'package:apidash/models/models.dart'; import 'package:apidash/providers/providers.dart'; import 'package:apidash/utils/utils.dart'; diff --git a/lib/screens/common_widgets/envvar_indicator.dart b/lib/screens/common_widgets/envvar_indicator.dart index bc56fc19..c57b2e87 100644 --- a/lib/screens/common_widgets/envvar_indicator.dart +++ b/lib/screens/common_widgets/envvar_indicator.dart @@ -1,6 +1,6 @@ +import 'package:apidash_core/apidash_core.dart'; import 'package:apidash_design_system/apidash_design_system.dart'; import 'package:flutter/material.dart'; -import 'package:apidash/models/models.dart'; import 'package:apidash/consts.dart'; class EnvVarIndicator extends StatelessWidget { diff --git a/lib/screens/common_widgets/envvar_popover.dart b/lib/screens/common_widgets/envvar_popover.dart index 3d7b93da..7a5e67c0 100644 --- a/lib/screens/common_widgets/envvar_popover.dart +++ b/lib/screens/common_widgets/envvar_popover.dart @@ -1,6 +1,6 @@ +import 'package:apidash_core/apidash_core.dart'; import 'package:apidash_design_system/apidash_design_system.dart'; import 'package:flutter/material.dart'; -import 'package:apidash/models/models.dart'; import 'common_widgets.dart'; class EnvVarPopover extends StatelessWidget { diff --git a/lib/screens/envvar/editor_pane/secrets_pane.dart b/lib/screens/envvar/editor_pane/secrets_pane.dart index 0e67f0f7..014d0426 100644 --- a/lib/screens/envvar/editor_pane/secrets_pane.dart +++ b/lib/screens/envvar/editor_pane/secrets_pane.dart @@ -1,10 +1,10 @@ import 'dart:math'; +import 'package:apidash_core/apidash_core.dart'; import 'package:apidash_design_system/apidash_design_system.dart'; import 'package:flutter/material.dart'; import 'package:data_table_2/data_table_2.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:apidash/consts.dart'; -import 'package:apidash/models/models.dart'; import 'package:apidash/providers/providers.dart'; import 'package:apidash/utils/utils.dart'; import 'package:apidash/widgets/widgets.dart'; diff --git a/lib/screens/envvar/editor_pane/variables_pane.dart b/lib/screens/envvar/editor_pane/variables_pane.dart index 31039770..af3a1e39 100644 --- a/lib/screens/envvar/editor_pane/variables_pane.dart +++ b/lib/screens/envvar/editor_pane/variables_pane.dart @@ -1,10 +1,10 @@ import 'dart:math'; +import 'package:apidash_core/apidash_core.dart'; import 'package:apidash_design_system/apidash_design_system.dart'; import 'package:flutter/material.dart'; import 'package:data_table_2/data_table_2.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:apidash/consts.dart'; -import 'package:apidash/models/models.dart'; import 'package:apidash/providers/providers.dart'; import 'package:apidash/utils/utils.dart'; import 'package:apidash/widgets/widgets.dart'; diff --git a/lib/screens/envvar/environments_pane.dart b/lib/screens/envvar/environments_pane.dart index 18bd2053..2c74742e 100644 --- a/lib/screens/envvar/environments_pane.dart +++ b/lib/screens/envvar/environments_pane.dart @@ -1,8 +1,8 @@ +import 'package:apidash_core/apidash_core.dart'; import 'package:apidash_design_system/apidash_design_system.dart'; import 'package:flutter/material.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; -import 'package:apidash/models/environment_model.dart'; import 'package:apidash/providers/providers.dart'; import 'package:apidash/widgets/widgets.dart'; import 'package:apidash/consts.dart'; diff --git a/lib/utils/envvar_utils.dart b/lib/utils/envvar_utils.dart index 620b8f4a..230cf535 100644 --- a/lib/utils/envvar_utils.dart +++ b/lib/utils/envvar_utils.dart @@ -1,6 +1,5 @@ import 'package:apidash_core/apidash_core.dart'; import 'package:apidash/consts.dart'; -import 'package:apidash/models/models.dart'; String getEnvironmentTitle(String? name) { if (name == null || name.trim() == "") { @@ -86,6 +85,11 @@ HttpRequestModel substituteHttpRequestModel( value: substituteVariables(param.value, envMap, activeEnvironmentId), ); }).toList(), + body: substituteVariables( + httpRequestModel.body, + envMap, + activeEnvironmentId, + ), ); return newRequestModel; } diff --git a/lib/widgets/dialog_import.dart b/lib/widgets/dialog_import.dart index 7bb2b82e..bfc50eda 100644 --- a/lib/widgets/dialog_import.dart +++ b/lib/widgets/dialog_import.dart @@ -1,8 +1,9 @@ -import 'package:apidash/consts.dart'; +import 'package:apidash_design_system/apidash_design_system.dart'; import 'package:flutter/material.dart'; import 'package:file_selector/file_selector.dart'; import 'drag_and_drop_area.dart'; import 'dropdown_import_format.dart'; +import '../consts.dart'; showImportDialog({ required BuildContext context, @@ -17,14 +18,15 @@ showImportDialog({ return StatefulBuilder( builder: (context, StateSetter setState) { return AlertDialog( - contentPadding: const EdgeInsets.all(12), + contentPadding: kP12, content: Column( mainAxisSize: MainAxisSize.min, children: [ Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - const Text("Import "), + const Text(kLabelImport), + kHSpacer8, DropdownButtonImportFormat( importFormat: fmt, onChanged: (format) { @@ -38,6 +40,7 @@ showImportDialog({ ), ], ), + kVSpacer6, DragAndDropArea( onFileDropped: onFileDropped, ), diff --git a/lib/widgets/menu_sidebar_top.dart b/lib/widgets/menu_sidebar_top.dart index 0f1ced58..4bf95ace 100644 --- a/lib/widgets/menu_sidebar_top.dart +++ b/lib/widgets/menu_sidebar_top.dart @@ -10,13 +10,14 @@ class SidebarTopMenu extends StatelessWidget { this.splashRadius = 14, this.tooltip, this.shape, + this.menuPadding, }); final Widget? child; final Offset offset; final double splashRadius; final String? tooltip; final ShapeBorder? shape; - + final EdgeInsets? menuPadding; final Function(SidebarMenuOption)? onSelected; @override @@ -30,6 +31,7 @@ class SidebarTopMenu extends StatelessWidget { offset: offset, onSelected: onSelected, shape: shape, + menuPadding: menuPadding, itemBuilder: (BuildContext context) => SidebarMenuOption.values .map>( (e) => PopupMenuItem( diff --git a/lib/widgets/popup_menu_env.dart b/lib/widgets/popup_menu_env.dart index 1ee1022d..601c7fad 100644 --- a/lib/widgets/popup_menu_env.dart +++ b/lib/widgets/popup_menu_env.dart @@ -1,7 +1,6 @@ import 'package:apidash_core/apidash_core.dart'; import 'package:apidash_design_system/apidash_design_system.dart'; import 'package:flutter/material.dart'; -import 'package:apidash/models/models.dart'; import 'package:apidash/utils/utils.dart'; import '../consts.dart'; diff --git a/packages/apidash_core/lib/consts.dart b/packages/apidash_core/lib/consts.dart index c3ac388c..1d7044c7 100644 --- a/packages/apidash_core/lib/consts.dart +++ b/packages/apidash_core/lib/consts.dart @@ -9,6 +9,8 @@ enum APIType { final String abbr; } +enum EnvironmentVariableType { variable, secret } + enum HTTPVerb { get("GET"), head("HEAD"), diff --git a/packages/apidash_core/lib/import_export/import_export.dart b/packages/apidash_core/lib/import_export/import_export.dart index c61e96a9..33762e50 100644 --- a/packages/apidash_core/lib/import_export/import_export.dart +++ b/packages/apidash_core/lib/import_export/import_export.dart @@ -1,2 +1,3 @@ export 'curl_io.dart'; export 'postman_io.dart'; +export 'insomnia_io.dart'; diff --git a/packages/apidash_core/lib/import_export/insomnia_io.dart b/packages/apidash_core/lib/import_export/insomnia_io.dart new file mode 100644 index 00000000..d9608500 --- /dev/null +++ b/packages/apidash_core/lib/import_export/insomnia_io.dart @@ -0,0 +1,117 @@ +import 'package:flutter/material.dart'; +import 'package:insomnia_collection/insomnia_collection.dart'; +import 'package:seed/seed.dart'; +import '../consts.dart'; +import '../models/models.dart'; +import '../utils/utils.dart'; + +class InsomniaIO { + List<(String?, HttpRequestModel)>? getHttpRequestModelList(String content) { + content = content.trim(); + try { + final ic = insomniaCollectionFromJsonStr(content); + final requests = getRequestsFromInsomniaCollection(ic); + + return requests + .map((req) => (req.$1, insomniaResourceToHttpRequestModel(req.$2))) + .toList(); + } catch (e) { + debugPrint("$e"); + return null; + } + } + + HttpRequestModel insomniaResourceToHttpRequestModel(Resource resource) { + HTTPVerb method; + try { + method = HTTPVerb.values.byName((resource.method ?? "").toLowerCase()); + } catch (e) { + method = kDefaultHttpMethod; + } + String url = stripUrlParams(resource.url ?? ""); + List headers = []; + List isHeaderEnabledList = []; + + List params = []; + List isParamEnabledList = []; + + for (var header in resource.headers ??
[]) { + var name = header.name ?? ""; + var value = header.value ?? ""; + var activeHeader = header.disabled ?? false; + headers.add(NameValueModel(name: name, value: value)); + isHeaderEnabledList.add(!activeHeader); + } + + for (var query in resource.parameters ?? []) { + var name = query.name ?? ""; + var value = query.value; + var activeQuery = query.disabled ?? false; + params.add(NameValueModel(name: name, value: value)); + isParamEnabledList.add(!activeQuery); + } + + ContentType bodyContentType = + getContentTypeFromContentTypeStr(resource.body?.mimeType) ?? + kDefaultContentType; + + String? body; + List? formData; + if (resource.body != null && resource.body?.mimeType != null) { + if (bodyContentType == ContentType.formdata) { + formData = []; + for (var fd in resource.body?.params ?? []) { + var name = fd.name ?? ""; + FormDataType formDataType; + try { + formDataType = FormDataType.values.byName(fd.type ?? ""); + } catch (e) { + formDataType = FormDataType.text; + } + var value = switch (formDataType) { + FormDataType.text => fd.value ?? "", + FormDataType.file => fd.src ?? "" + }; + formData.add(FormDataModel( + name: name, + value: value, + type: formDataType, + )); + } + } else { + body = resource.body?.text; + } + } + + return HttpRequestModel( + method: method, + url: url, + headers: headers, + params: params, + isHeaderEnabledList: isHeaderEnabledList, + isParamEnabledList: isParamEnabledList, + body: body, + bodyContentType: bodyContentType, + formData: formData, + ); + } + + EnvironmentModel insomniaResourceToEnvironmentModel(Resource resource) { + List variables = []; + for (var envvar in resource.kvPairData!) { + variables.add(EnvironmentVariableModel( + key: envvar.name ?? "", + value: envvar.value ?? "", + enabled: envvar.enabled ?? true, + type: envvar.type == "secret" + ? EnvironmentVariableType.secret + : EnvironmentVariableType.variable, + )); + } + return EnvironmentModel( + id: resource.id!, + name: resource.name ?? "", + values: variables, + ); + } +} diff --git a/lib/models/environment_model.dart b/packages/apidash_core/lib/models/environment_model.dart similarity index 96% rename from lib/models/environment_model.dart rename to packages/apidash_core/lib/models/environment_model.dart index 7f37fb6f..9242d4d5 100644 --- a/lib/models/environment_model.dart +++ b/packages/apidash_core/lib/models/environment_model.dart @@ -1,5 +1,5 @@ -import 'package:apidash/consts.dart'; -import 'package:apidash_core/apidash_core.dart'; +import 'package:freezed_annotation/freezed_annotation.dart'; +import '../consts.dart'; part 'environment_model.freezed.dart'; diff --git a/lib/models/environment_model.freezed.dart b/packages/apidash_core/lib/models/environment_model.freezed.dart similarity index 100% rename from lib/models/environment_model.freezed.dart rename to packages/apidash_core/lib/models/environment_model.freezed.dart diff --git a/lib/models/environment_model.g.dart b/packages/apidash_core/lib/models/environment_model.g.dart similarity index 100% rename from lib/models/environment_model.g.dart rename to packages/apidash_core/lib/models/environment_model.g.dart diff --git a/packages/apidash_core/lib/models/models.dart b/packages/apidash_core/lib/models/models.dart index a33c6fdd..c50ec988 100644 --- a/packages/apidash_core/lib/models/models.dart +++ b/packages/apidash_core/lib/models/models.dart @@ -1,2 +1,3 @@ +export 'environment_model.dart'; export 'http_request_model.dart'; export 'http_response_model.dart'; diff --git a/packages/apidash_core/lib/utils/content_type_utils.dart b/packages/apidash_core/lib/utils/content_type_utils.dart index 13fb7226..ace8d715 100644 --- a/packages/apidash_core/lib/utils/content_type_utils.dart +++ b/packages/apidash_core/lib/utils/content_type_utils.dart @@ -7,15 +7,7 @@ ContentType? getContentTypeFromHeadersMap( ) { if (kvMap != null && kvMap.hasKeyContentType()) { var val = getMediaTypeFromHeaders(kvMap); - if (val != null) { - if (val.subtype.contains(kSubTypeJson)) { - return ContentType.json; - } else if (val.type == kTypeMultipart && - val.subtype == kSubTypeFormData) { - return ContentType.formdata; - } - return ContentType.text; - } + return getContentTypeFromMediaType(val); } return null; } @@ -37,3 +29,26 @@ MediaType? getMediaTypeFromContentType(String? contentType) { } return null; } + +ContentType? getContentTypeFromMediaType(MediaType? mediaType) { + if (mediaType != null) { + if (mediaType.subtype.contains(kSubTypeJson)) { + return ContentType.json; + } else if (mediaType.type == kTypeMultipart && + mediaType.subtype == kSubTypeFormData) { + return ContentType.formdata; + } + return ContentType.text; + } + return null; +} + +ContentType? getContentTypeFromContentTypeStr( + String? contentType, +) { + if (contentType != null) { + var val = getMediaTypeFromContentType(contentType); + return getContentTypeFromMediaType(val); + } + return null; +} diff --git a/packages/apidash_core/pubspec.yaml b/packages/apidash_core/pubspec.yaml index f9c31cfd..d29330e4 100644 --- a/packages/apidash_core/pubspec.yaml +++ b/packages/apidash_core/pubspec.yaml @@ -19,6 +19,8 @@ dependencies: http_parser: ^4.0.2 postman: path: ../postman + insomnia_collection: + path: ../insomnia_collection seed: ^0.0.3 xml: ^6.3.0 diff --git a/packages/apidash_core/pubspec_overrides.yaml b/packages/apidash_core/pubspec_overrides.yaml index 7c2883d9..7cac389e 100644 --- a/packages/apidash_core/pubspec_overrides.yaml +++ b/packages/apidash_core/pubspec_overrides.yaml @@ -1,7 +1,9 @@ -# melos_managed_dependency_overrides: curl_parser,postman,seed +# melos_managed_dependency_overrides: curl_parser,postman,seed,insomnia_collection dependency_overrides: curl_parser: path: ../curl_parser + insomnia_collection: + path: ../insomnia_collection postman: path: ../postman seed: diff --git a/packages/apidash_design_system/lib/tokens/measurements.dart b/packages/apidash_design_system/lib/tokens/measurements.dart index 638e5413..f760f8f9 100644 --- a/packages/apidash_design_system/lib/tokens/measurements.dart +++ b/packages/apidash_design_system/lib/tokens/measurements.dart @@ -26,13 +26,14 @@ const kP4 = EdgeInsets.all(4); const kP5 = EdgeInsets.all(5); const kP6 = EdgeInsets.all(6); const kP8 = EdgeInsets.all(8); +const kP10 = EdgeInsets.all(10); +const kP12 = EdgeInsets.all(12); const kPs8 = EdgeInsets.only(left: 8); const kPs2 = EdgeInsets.only(left: 2); const kPe4 = EdgeInsets.only(right: 4); const kPe8 = EdgeInsets.only(right: 8); const kPh20v5 = EdgeInsets.symmetric(horizontal: 20, vertical: 5); const kPh20v10 = EdgeInsets.symmetric(horizontal: 20, vertical: 10); -const kP10 = EdgeInsets.all(10); const kPv2 = EdgeInsets.symmetric(vertical: 2); const kPv6 = EdgeInsets.symmetric(vertical: 6); const kPv8 = EdgeInsets.symmetric(vertical: 8); @@ -92,6 +93,7 @@ const kHSpacer20 = SizedBox(width: 20); const kHSpacer40 = SizedBox(width: 40); const kVSpacer3 = SizedBox(height: 3); const kVSpacer5 = SizedBox(height: 5); +const kVSpacer6 = SizedBox(height: 6); const kVSpacer8 = SizedBox(height: 8); const kVSpacer10 = SizedBox(height: 10); const kVSpacer16 = SizedBox(height: 16); diff --git a/packages/insomnia_collection/.gitignore b/packages/insomnia_collection/.gitignore new file mode 100644 index 00000000..fca0f548 --- /dev/null +++ b/packages/insomnia_collection/.gitignore @@ -0,0 +1,30 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. +/pubspec.lock +**/doc/api/ +.dart_tool/ +build/ +coverage/ diff --git a/packages/insomnia_collection/CHANGELOG.md b/packages/insomnia_collection/CHANGELOG.md new file mode 100644 index 00000000..a0ba62dd --- /dev/null +++ b/packages/insomnia_collection/CHANGELOG.md @@ -0,0 +1,3 @@ +## 0.0.1 + +- Implement fromJson object and fromJson String for Insomnia v4 json format diff --git a/packages/insomnia_collection/LICENSE b/packages/insomnia_collection/LICENSE new file mode 100644 index 00000000..498fbbb0 --- /dev/null +++ b/packages/insomnia_collection/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2023 Ashita Prasad, Ankit Mahato + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/packages/insomnia_collection/README.md b/packages/insomnia_collection/README.md new file mode 100644 index 00000000..3063e46f --- /dev/null +++ b/packages/insomnia_collection/README.md @@ -0,0 +1,396 @@ +# insomnia + +Seamlessly convert Insomnia Collection Format v4 to Dart. + +Helps you bring your APIs stored in Insomnia to Dart and work with them. + +Currently, this package is being used by [API Dash](https://github.com/foss42/apidash), a beautiful open-source cross-platform (macOS, Windows, Linux, Android & iOS) API Client built using Flutter which can help you easily create & customize your API requests, visually inspect responses and generate API integration code. A lightweight alternative to postman & insomnia. + +## Usage + +### Example 1: Insomnia collection JSON string to Insomnia model + +```dart +import 'package:insomnia_collection/insomnia_collection.dart'; + +void main() { + // Example 1: Insomnia collection JSON string to Insomnia model + var collectionJsonStr = r''' +{ + "_type": "export", + "__export_format": 4, + "__export_date": "2025-01-05T13:05:11.752Z", + "__export_source": "insomnia.desktop.app:v10.3.0", + "resources": [ + { + "_id":"req_15f4d64ca3084a92a0680e29a958c9da", + "parentId":"fld_a2e9704c49034e36a05cdb3a233f6ebd", + "modified":1736112258432, + "created":1736111908438, + "url":"https://food-service-backend.onrender.com/api/users/", + "name":"get-with-params", + "description":"", + "method":"GET", + "body":{}, + "parameters": [ + {"id":"pair_bf0ae4f4280e440a8a591b64fd4ec4f4","name":"user_id","value":"34","description":"","disabled":false} + ], + "headers":[{"name":"User-Agent","value":"insomnia/10.3.0"}], + "authentication":{}, + "metaSortKey":-1736111908438, + "isPrivate":false, + "pathParameters":[], + "settingStoreCookies":true, + "settingSendCookies":true, + "settingDisableRenderRequestBody":false, + "settingEncodeUrl":true, + "settingRebuildPath":true, + "settingFollowRedirects": "global", + "_type":"request" + }, + { + "_id":"fld_a2e9704c49034e36a05cdb3a233f6ebd", + "parentId":"wrk_fde7dcc4f5064b74b0fd749cbf8f684a", + "modified":1736082089076, + "created":1736082089076, + "name":"APIDash-APItests", + "description":"These are test endpoints for API Dash", + "environment":{},"environmentPropertyOrder":null, + "metaSortKey":-1736082080559, + "preRequestScript":"", + "afterResponseScript":"", + "authentication":{}, + "_type":"request_group" + }, + {"_id":"wrk_fde7dcc4f5064b74b0fd749cbf8f684a", + "parentId":null, + "modified":1736082089075, + "created":1736082089075, + "name":"APIDash-APItests","description":"", + "scope":"collection","_type":"workspace"}, + { + "_id":"req_db3c393084f14369bb409afe857e390c", + "parentId":"fld_a2e9704c49034e36a05cdb3a233f6ebd", + "modified":1736082089077, + "created":1736082089077, + "url":"https://api.apidash.dev/country/codes", + "name":"test-get", + "description":"", + "method":"GET", + "body":{}, + "parameters":[], + "headers":[], + "authentication":{}, + "preRequestScript":"", + "metaSortKey":-1736082080558, + "isPrivate":false, + "afterResponseScript":"", + "settingStoreCookies":true, + "settingSendCookies":true, + "settingDisableRenderRequestBody":false, + "settingEncodeUrl":true, + "settingRebuildPath":true, + "settingFollowRedirects":"global", + "_type":"request"}, + {"_id":"req_ba718bbacd094e95a30ef3f07baa4e42", + "parentId":"fld_a2e9704c49034e36a05cdb3a233f6ebd", + "modified":1736082089078,"created":1736082089078, + "url":"https://api.apidash.dev/case/lower", + "name":"test-post", + "description":"", + "method":"POST", + "body":{"mimeType":"application/json","text":"{\n \"text\": \"Grass is green\"\n}"}, + "parameters":[], + "headers":[{"name":"Content-Type","value":"application/json"}], + "authentication":{}, + "preRequestScript":"", + "metaSortKey":-1736082080557, + "isPrivate":false, + "afterResponseScript":"", + "settingStoreCookies":true, + "settingSendCookies":true, + "settingDisableRenderRequestBody":false, + "settingEncodeUrl":true, + "settingRebuildPath":true, + "settingFollowRedirects":"global", + "_type":"request"}, + {"_id":"req_24cff90fc3c74e71a567f61d3f8e8cc1", + "parentId":"fld_a2e9704c49034e36a05cdb3a233f6ebd", + "modified":1736082089078, + "created":1736082089078, + "url":"https://reqres.in/api/users/2", + "name":"test-put", + "description":"", + "method":"PUT", + "body":{"mimeType":"application/json", + "text":"{\n \"name\": \"morpheus\",\n \"job\": \"zion resident\"\n}"}, + "parameters":[], + "headers":[{"name":"Content-Type","value":"application/json"}], + "authentication":{}, + "preRequestScript":"", + "metaSortKey":-1736082080556, + "isPrivate":false, + "afterResponseScript":"", + "settingStoreCookies":true, + "settingSendCookies":true, + "settingDisableRenderRequestBody":false, + "settingEncodeUrl":true, + "settingRebuildPath":true, + "settingFollowRedirects":"global", + "_type":"request"}, + { + "_id":"env_9d818b2866dffc9831640d91a516ea3986e16bda", + "parentId":"wrk_fde7dcc4f5064b74b0fd749cbf8f684a", + "modified":1736082095630,"created":1736082095630, + "name":"Base Environment", + "data":{},"dataPropertyOrder":null, + "color":null, + "isPrivate":false, + "metaSortKey":1736082095630, + "environmentType":"kv", + "_type":"environment" + }, + { + "_id":"jar_9d818b2866dffc9831640d91a516ea3986e16bda", + "parentId":"wrk_fde7dcc4f5064b74b0fd749cbf8f684a", + "modified":1736082095688, + "created":1736082095688, + "name":"Default Jar", + "cookies":[], + "_type":"cookie_jar" + } + ] +} +'''; + + + + var collection; + try { + collection = insomniaCollectionFromJsonStr(collectionJsonStr); + + + + print(collection.exportSource); + // insomnia.desktop.app:v10.3.0 + print(collection.resources?[3].name); + // test-get + print(collection.resources?[3].method); + // GET + print(collection.resources?[3].url); + // https://api.apidash.dev/country/codes + } catch (e) { + print(e.toString() + 'error from collection'); + } +} +``` + +### Example 2: Insomnia collection from JSON + +```dart +import 'package:insomnia_collection/insomnia_collection.dart'; + +void main() { + // Example 2: Insomnia collection from JSON + var collectionJson = { + "_type": "export", + "__export_format": 4, + "__export_date": "2025-01-05T13:05:11.752Z", + "__export_source": "insomnia.desktop.app:v10.3.0", + "resources": [ + { + "_id": "req_15f4d64ca3084a92a0680e29a958c9da", + "parentId": "fld_a2e9704c49034e36a05cdb3a233f6ebd", + "modified": 1736112258432, + "created": 1736111908438, + "url": "https://food-service-backend.onrender.com/api/users/", + "name": "get-with-params", + "description": "", + "method": "GET", + "body": {}, + "parameters": [ + { + "id": "pair_bf0ae4f4280e440a8a591b64fd4ec4f4", + "name": "user_id", + "value": "34", + "description": "", + "disabled": false + } + ], + "headers": [ + {"name": "User-Agent", "value": "insomnia/10.3.0"} + ], + "authentication": {}, + "metaSortKey": -1736111908438, + "isPrivate": false, + "pathParameters": [], + "settingStoreCookies": true, + "settingSendCookies": true, + "settingDisableRenderRequestBody": false, + "settingEncodeUrl": true, + "settingRebuildPath": true, + "settingFollowRedirects": "global", + "_type": "request" + }, + { + "_id": "fld_a2e9704c49034e36a05cdb3a233f6ebd", + "parentId": "wrk_fde7dcc4f5064b74b0fd749cbf8f684a", + "modified": 1736082089076, + "created": 1736082089076, + "name": "APIDash-APItests", + "description": "These are test endpoints for API Dash", + "environment": {}, + "environmentPropertyOrder": null, + "metaSortKey": -1736082080559, + "preRequestScript": "", + "afterResponseScript": "", + "authentication": {}, + "_type": "request_group" + }, + { + "_id": "wrk_fde7dcc4f5064b74b0fd749cbf8f684a", + "parentId": null, + "modified": 1736082089075, + "created": 1736082089075, + "name": "APIDash-APItests", + "description": "", + "scope": "collection", + "_type": "workspace" + }, + { + "_id": "req_db3c393084f14369bb409afe857e390c", + "parentId": "fld_a2e9704c49034e36a05cdb3a233f6ebd", + "modified": 1736082089077, + "created": 1736082089077, + "url": "https://api.apidash.dev/country/codes", + "name": "test-get", + "description": "", + "method": "GET", + "body": {}, + "parameters": [], + "headers": [], + "authentication": {}, + "preRequestScript": "", + "metaSortKey": -1736082080558, + "isPrivate": false, + "afterResponseScript": "", + "settingStoreCookies": true, + "settingSendCookies": true, + "settingDisableRenderRequestBody": false, + "settingEncodeUrl": true, + "settingRebuildPath": true, + "settingFollowRedirects": "global", + "_type": "request" + }, + { + "_id": "req_ba718bbacd094e95a30ef3f07baa4e42", + "parentId": "fld_a2e9704c49034e36a05cdb3a233f6ebd", + "modified": 1736082089078, + "created": 1736082089078, + "url": "https://api.apidash.dev/case/lower", + "name": "test-post", + "description": "", + "method": "POST", + "body": { + "mimeType": "application/json", + "text": "{\n \"text\": \"Grass is green\"\n}" + }, + "parameters": [], + "headers": [ + {"name": "Content-Type", "value": "application/json"} + ], + "authentication": {}, + "preRequestScript": "", + "metaSortKey": -1736082080557, + "isPrivate": false, + "afterResponseScript": "", + "settingStoreCookies": true, + "settingSendCookies": true, + "settingDisableRenderRequestBody": false, + "settingEncodeUrl": true, + "settingRebuildPath": true, + "settingFollowRedirects": "global", + "_type": "request" + }, + { + "_id": "req_24cff90fc3c74e71a567f61d3f8e8cc1", + "parentId": "fld_a2e9704c49034e36a05cdb3a233f6ebd", + "modified": 1736082089078, + "created": 1736082089078, + "url": "https://reqres.in/api/users/2", + "name": "test-put", + "description": "", + "method": "PUT", + "body": { + "mimeType": "application/json", + "text": + "{\n \"name\": \"morpheus\",\n \"job\": \"zion resident\"\n}" + }, + "parameters": [], + "headers": [ + {"name": "Content-Type", "value": "application/json"} + ], + "authentication": {}, + "preRequestScript": "", + "metaSortKey": -1736082080556, + "isPrivate": false, + "afterResponseScript": "", + "settingStoreCookies": true, + "settingSendCookies": true, + "settingDisableRenderRequestBody": false, + "settingEncodeUrl": true, + "settingRebuildPath": true, + "settingFollowRedirects": "global", + "_type": "request" + }, + { + "_id": "env_9d818b2866dffc9831640d91a516ea3986e16bda", + "parentId": "wrk_fde7dcc4f5064b74b0fd749cbf8f684a", + "modified": 1736082095630, + "created": 1736082095630, + "name": "Base Environment", + "data": {}, + "dataPropertyOrder": null, + "color": null, + "isPrivate": false, + "metaSortKey": 1736082095630, + "environmentType": "kv", + "_type": "environment" + }, + { + "_id": "jar_9d818b2866dffc9831640d91a516ea3986e16bda", + "parentId": "wrk_fde7dcc4f5064b74b0fd749cbf8f684a", + "modified": 1736082095688, + "created": 1736082095688, + "name": "Default Jar", + "cookies": [], + "_type": "cookie_jar" + } + ] + }; + + var collection2; + try { + collection2 = InsomniaCollection.fromJson(collectionJson); + print(collection2.exportSource); + // insomnia.desktop.app:v10.3.0 + print(collection2.resources?[3].name); + // test-get + print(collection2.resources?[3].method); + // GET + print(collection2.resources?[3].url); + // https://api.apidash.dev/country/codes + } catch (e) { + print(e.toString() + 'error from collection2'); + } +} +``` + +## Maintainer + +- Ashita Prasad ([GitHub](https://github.com/ashitaprasad), [LinkedIn](https://www.linkedin.com/in/ashitaprasad/), [X](https://x.com/ashitaprasad)) +- Papa Kofi (contributor) ([GitHub](https://github.com/StormGear)) + +## License + +This project is licensed under the [Apache License 2.0](https://github.com/foss42/apidash/blob/main/packages/insomnia_collection/LICENSE). diff --git a/packages/insomnia_collection/analysis_options.yaml b/packages/insomnia_collection/analysis_options.yaml new file mode 100644 index 00000000..1dea9522 --- /dev/null +++ b/packages/insomnia_collection/analysis_options.yaml @@ -0,0 +1,6 @@ +analyzer: + exclude: + - "**/*.g.dart" + - "**/*.freezed.dart" + errors: + invalid_annotation_target: ignore diff --git a/packages/insomnia_collection/example/insomnia_example.dart b/packages/insomnia_collection/example/insomnia_example.dart new file mode 100644 index 00000000..36830b5c --- /dev/null +++ b/packages/insomnia_collection/example/insomnia_example.dart @@ -0,0 +1,360 @@ +import 'package:insomnia_collection/insomnia_collection.dart'; + +void main() { + // Example 1: Insomnia collection JSON string to Insomnia model + var collectionJsonStr = r''' +{ + "_type": "export", + "__export_format": 4, + "__export_date": "2025-01-05T13:05:11.752Z", + "__export_source": "insomnia.desktop.app:v10.3.0", + "resources": [ + { + "_id":"req_15f4d64ca3084a92a0680e29a958c9da", + "parentId":"fld_a2e9704c49034e36a05cdb3a233f6ebd", + "modified":1736112258432, + "created":1736111908438, + "url":"https://food-service-backend.onrender.com/api/users/", + "name":"get-with-params", + "description":"", + "method":"GET", + "body":{}, + "parameters": [ + {"id":"pair_bf0ae4f4280e440a8a591b64fd4ec4f4","name":"user_id","value":"34","description":"","disabled":false} + ], + "headers":[{"name":"User-Agent","value":"insomnia/10.3.0"}], + "authentication":{}, + "metaSortKey":-1736111908438, + "isPrivate":false, + "pathParameters":[], + "settingStoreCookies":true, + "settingSendCookies":true, + "settingDisableRenderRequestBody":false, + "settingEncodeUrl":true, + "settingRebuildPath":true, + "settingFollowRedirects": "global", + "_type":"request" + }, + { + "_id":"fld_a2e9704c49034e36a05cdb3a233f6ebd", + "parentId":"wrk_fde7dcc4f5064b74b0fd749cbf8f684a", + "modified":1736082089076, + "created":1736082089076, + "name":"APIDash-APItests", + "description":"These are test endpoints for API Dash", + "environment":{},"environmentPropertyOrder":null, + "metaSortKey":-1736082080559, + "preRequestScript":"", + "afterResponseScript":"", + "authentication":{}, + "_type":"request_group" + }, +{"_id":"wrk_fde7dcc4f5064b74b0fd749cbf8f684a", +"parentId":null, +"modified":1736082089075, +"created":1736082089075, +"name":"APIDash-APItests","description":"", +"scope":"collection","_type":"workspace"}, +{ +"_id":"req_db3c393084f14369bb409afe857e390c", +"parentId":"fld_a2e9704c49034e36a05cdb3a233f6ebd", +"modified":1736082089077, +"created":1736082089077, +"url":"https://api.apidash.dev/country/codes", +"name":"test-get", +"description":"", +"method":"GET", +"body":{}, +"parameters":[], +"headers":[], +"authentication":{}, +"preRequestScript":"", +"metaSortKey":-1736082080558, +"isPrivate":false, +"afterResponseScript":"", +"settingStoreCookies":true, +"settingSendCookies":true, +"settingDisableRenderRequestBody":false, +"settingEncodeUrl":true, +"settingRebuildPath":true, +"settingFollowRedirects":"global", +"_type":"request"}, +{"_id":"req_ba718bbacd094e95a30ef3f07baa4e42", +"parentId":"fld_a2e9704c49034e36a05cdb3a233f6ebd", +"modified":1736082089078,"created":1736082089078, +"url":"https://api.apidash.dev/case/lower", +"name":"test-post", +"description":"", +"method":"POST", +"body":{"mimeType":"application/json","text":"{\n \"text\": \"Grass is green\"\n}"}, +"parameters":[], +"headers":[{"name":"Content-Type","value":"application/json"}], +"authentication":{}, +"preRequestScript":"", +"metaSortKey":-1736082080557, +"isPrivate":false, +"afterResponseScript":"", +"settingStoreCookies":true, +"settingSendCookies":true, +"settingDisableRenderRequestBody":false, +"settingEncodeUrl":true, +"settingRebuildPath":true, +"settingFollowRedirects":"global", +"_type":"request"}, +{"_id":"req_24cff90fc3c74e71a567f61d3f8e8cc1", +"parentId":"fld_a2e9704c49034e36a05cdb3a233f6ebd", +"modified":1736082089078, +"created":1736082089078, +"url":"https://reqres.in/api/users/2", +"name":"test-put", +"description":"", +"method":"PUT", +"body":{"mimeType":"application/json", +"text":"{\n \"name\": \"morpheus\",\n \"job\": \"zion resident\"\n}"}, +"parameters":[], +"headers":[{"name":"Content-Type","value":"application/json"}], +"authentication":{}, +"preRequestScript":"", +"metaSortKey":-1736082080556, +"isPrivate":false, +"afterResponseScript":"", +"settingStoreCookies":true, +"settingSendCookies":true, +"settingDisableRenderRequestBody":false, +"settingEncodeUrl":true, +"settingRebuildPath":true, +"settingFollowRedirects":"global", +"_type":"request"}, +{"_id":"env_9d818b2866dffc9831640d91a516ea3986e16bda", +"parentId":"wrk_fde7dcc4f5064b74b0fd749cbf8f684a", +"modified":1736082095630,"created":1736082095630, +"name":"Base Environment", +"data":{},"dataPropertyOrder":null, +"color":null, +"isPrivate":false, +"metaSortKey":1736082095630, +"environmentType":"kv", +"_type":"environment" +}, +{ +"_id":"jar_9d818b2866dffc9831640d91a516ea3986e16bda", +"parentId":"wrk_fde7dcc4f5064b74b0fd749cbf8f684a", +"modified":1736082095688, +"created":1736082095688, +"name":"Default Jar", +"cookies":[], +"_type":"cookie_jar" +} +] +} +'''; + + var collection; + try { + collection = insomniaCollectionFromJsonStr(collectionJsonStr); + + print(collection.exportSource); + // insomnia.desktop.app:v10.3.0 + print(collection.resources?[3].name); + // test-get + print(collection.resources?[3].method); + // GET + print(collection.resources?[3].url); + // https://api.apidash.dev/country/codes + } catch (e) { + print(e.toString() + 'error from collection'); + } + + // Example 2: Insomnia collection from JSON + var collectionJson = { + "_type": "export", + "__export_format": 4, + "__export_date": "2025-01-05T13:05:11.752Z", + "__export_source": "insomnia.desktop.app:v10.3.0", + "resources": [ + { + "_id": "req_15f4d64ca3084a92a0680e29a958c9da", + "parentId": "fld_a2e9704c49034e36a05cdb3a233f6ebd", + "modified": 1736112258432, + "created": 1736111908438, + "url": "https://food-service-backend.onrender.com/api/users/", + "name": "get-with-params", + "description": "", + "method": "GET", + "body": {}, + "parameters": [ + { + "id": "pair_bf0ae4f4280e440a8a591b64fd4ec4f4", + "name": "user_id", + "value": "34", + "description": "", + "disabled": false + } + ], + "headers": [ + {"name": "User-Agent", "value": "insomnia/10.3.0"} + ], + "authentication": {}, + "metaSortKey": -1736111908438, + "isPrivate": false, + "pathParameters": [], + "settingStoreCookies": true, + "settingSendCookies": true, + "settingDisableRenderRequestBody": false, + "settingEncodeUrl": true, + "settingRebuildPath": true, + "settingFollowRedirects": "global", + "_type": "request" + }, + { + "_id": "fld_a2e9704c49034e36a05cdb3a233f6ebd", + "parentId": "wrk_fde7dcc4f5064b74b0fd749cbf8f684a", + "modified": 1736082089076, + "created": 1736082089076, + "name": "APIDash-APItests", + "description": "These are test endpoints for API Dash", + "environment": {}, + "environmentPropertyOrder": null, + "metaSortKey": -1736082080559, + "preRequestScript": "", + "afterResponseScript": "", + "authentication": {}, + "_type": "request_group" + }, + { + "_id": "wrk_fde7dcc4f5064b74b0fd749cbf8f684a", + "parentId": null, + "modified": 1736082089075, + "created": 1736082089075, + "name": "APIDash-APItests", + "description": "", + "scope": "collection", + "_type": "workspace" + }, + { + "_id": "req_db3c393084f14369bb409afe857e390c", + "parentId": "fld_a2e9704c49034e36a05cdb3a233f6ebd", + "modified": 1736082089077, + "created": 1736082089077, + "url": "https://api.apidash.dev/country/codes", + "name": "test-get", + "description": "", + "method": "GET", + "body": {}, + "parameters": [], + "headers": [], + "authentication": {}, + "preRequestScript": "", + "metaSortKey": -1736082080558, + "isPrivate": false, + "afterResponseScript": "", + "settingStoreCookies": true, + "settingSendCookies": true, + "settingDisableRenderRequestBody": false, + "settingEncodeUrl": true, + "settingRebuildPath": true, + "settingFollowRedirects": "global", + "_type": "request" + }, + { + "_id": "req_ba718bbacd094e95a30ef3f07baa4e42", + "parentId": "fld_a2e9704c49034e36a05cdb3a233f6ebd", + "modified": 1736082089078, + "created": 1736082089078, + "url": "https://api.apidash.dev/case/lower", + "name": "test-post", + "description": "", + "method": "POST", + "body": { + "mimeType": "application/json", + "text": "{\n \"text\": \"Grass is green\"\n}" + }, + "parameters": [], + "headers": [ + {"name": "Content-Type", "value": "application/json"} + ], + "authentication": {}, + "preRequestScript": "", + "metaSortKey": -1736082080557, + "isPrivate": false, + "afterResponseScript": "", + "settingStoreCookies": true, + "settingSendCookies": true, + "settingDisableRenderRequestBody": false, + "settingEncodeUrl": true, + "settingRebuildPath": true, + "settingFollowRedirects": "global", + "_type": "request" + }, + { + "_id": "req_24cff90fc3c74e71a567f61d3f8e8cc1", + "parentId": "fld_a2e9704c49034e36a05cdb3a233f6ebd", + "modified": 1736082089078, + "created": 1736082089078, + "url": "https://reqres.in/api/users/2", + "name": "test-put", + "description": "", + "method": "PUT", + "body": { + "mimeType": "application/json", + "text": + "{\n \"name\": \"morpheus\",\n \"job\": \"zion resident\"\n}" + }, + "parameters": [], + "headers": [ + {"name": "Content-Type", "value": "application/json"} + ], + "authentication": {}, + "preRequestScript": "", + "metaSortKey": -1736082080556, + "isPrivate": false, + "afterResponseScript": "", + "settingStoreCookies": true, + "settingSendCookies": true, + "settingDisableRenderRequestBody": false, + "settingEncodeUrl": true, + "settingRebuildPath": true, + "settingFollowRedirects": "global", + "_type": "request" + }, + { + "_id": "env_9d818b2866dffc9831640d91a516ea3986e16bda", + "parentId": "wrk_fde7dcc4f5064b74b0fd749cbf8f684a", + "modified": 1736082095630, + "created": 1736082095630, + "name": "Base Environment", + "data": {}, + "dataPropertyOrder": null, + "color": null, + "isPrivate": false, + "metaSortKey": 1736082095630, + "environmentType": "kv", + "_type": "environment" + }, + { + "_id": "jar_9d818b2866dffc9831640d91a516ea3986e16bda", + "parentId": "wrk_fde7dcc4f5064b74b0fd749cbf8f684a", + "modified": 1736082095688, + "created": 1736082095688, + "name": "Default Jar", + "cookies": [], + "_type": "cookie_jar" + } + ] + }; + + var collection2; + try { + collection2 = InsomniaCollection.fromJson(collectionJson); + print(collection2.exportSource); + // insomnia.desktop.app:v10.3.0 + print(collection2.resources?[3].name); + // test-get + print(collection2.resources?[3].method); + // GET + print(collection2.resources?[3].url); + // https://api.apidash.dev/country/codes + } catch (e) { + print(e.toString() + 'error from collection2'); + } +} diff --git a/packages/insomnia_collection/lib/insomnia_collection.dart b/packages/insomnia_collection/lib/insomnia_collection.dart new file mode 100644 index 00000000..66c1cef9 --- /dev/null +++ b/packages/insomnia_collection/lib/insomnia_collection.dart @@ -0,0 +1,4 @@ +library insomnia_collection; + +export 'models/models.dart'; +export 'utils/insomnia_utils.dart'; diff --git a/packages/insomnia_collection/lib/models/insomnia_collection.dart b/packages/insomnia_collection/lib/models/insomnia_collection.dart new file mode 100644 index 00000000..c5d2b1d7 --- /dev/null +++ b/packages/insomnia_collection/lib/models/insomnia_collection.dart @@ -0,0 +1,192 @@ +import 'dart:convert'; +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'insomnia_collection.freezed.dart'; +part 'insomnia_collection.g.dart'; + +InsomniaCollection insomniaCollectionFromJsonStr(String str) => + InsomniaCollection.fromJson(json.decode(str)); + +String insomniaCollectionToJsonStr(InsomniaCollection data) => + JsonEncoder.withIndent(' ').convert(data); + +@freezed +class InsomniaCollection with _$InsomniaCollection { + @JsonSerializable( + explicitToJson: true, + anyMap: true, + includeIfNull: false, + ) + const factory InsomniaCollection({ + @JsonKey(name: '_type') String? type, + @JsonKey(name: '__export_format') num? exportFormat, + @JsonKey(name: '__export_date') String? exportDate, + @JsonKey(name: '__export_source') String? exportSource, + List? resources, + }) = _InsomniaCollection; + + factory InsomniaCollection.fromJson(Map json) => + _$InsomniaCollectionFromJson(json); +} + +@freezed +class Resource with _$Resource { + @JsonSerializable( + explicitToJson: true, + anyMap: true, + includeIfNull: false, + ) + const factory Resource({ + @JsonKey(name: '_id') String? id, + String? parentId, + num? modified, + num? created, + String? url, + String? name, + String? description, + String? method, + Body? body, + String? preRequestScript, + List? parameters, + List
? headers, + dynamic authentication, + num? metaSortKey, + bool? isPrivate, + List? pathParameters, + String? afterResponseScript, + bool? settingStoreCookies, + bool? settingSendCookies, + bool? settingDisableRenderRequestBody, + bool? settingEncodeUrl, + bool? settingRebuildPath, + String? settingFollowRedirects, + dynamic environment, + dynamic environmentPropertyOrder, + String? scope, + dynamic data, + dynamic dataPropertyOrder, + dynamic color, + List? cookies, + String? fileName, + String? contents, + String? contentType, + String? environmentType, + List? kvPairData, + @JsonKey(name: '_type') String? type, + }) = _Resource; + + factory Resource.fromJson(Map json) => + _$ResourceFromJson(json); +} + +@freezed +class Body with _$Body { + @JsonSerializable( + explicitToJson: true, + anyMap: true, + includeIfNull: false, + ) + const factory Body({ + String? mimeType, + String? text, + List? params, + }) = _Body; + + factory Body.fromJson(Map json) => _$BodyFromJson(json); +} + +@freezed +class Formdatum with _$Formdatum { + @JsonSerializable( + explicitToJson: true, + anyMap: true, + includeIfNull: false, + ) + const factory Formdatum({ + String? name, + String? value, + String? type, + @JsonKey(name: 'fileName') String? src, + }) = _Formdatum; + + factory Formdatum.fromJson(Map json) => + _$FormdatumFromJson(json); +} + +@freezed +class Parameter with _$Parameter { + @JsonSerializable( + explicitToJson: true, + anyMap: true, + includeIfNull: false, + ) + const factory Parameter({ + String? id, + String? name, + String? value, + String? description, + bool? disabled, + }) = _Parameter; + + factory Parameter.fromJson(Map json) => + _$ParameterFromJson(json); +} + +@freezed +class Header with _$Header { + @JsonSerializable( + explicitToJson: true, + anyMap: true, + includeIfNull: false, + ) + const factory Header({ + String? name, + String? value, + bool? disabled, + }) = _Header; + + factory Header.fromJson(Map json) => _$HeaderFromJson(json); +} + +@freezed +class Cookie with _$Cookie { + @JsonSerializable( + explicitToJson: true, + anyMap: true, + includeIfNull: false, + ) + const factory Cookie({ + String? key, + String? value, + String? domain, + String? path, + bool? secure, + bool? httpOnly, + bool? hostOnly, + DateTime? creation, + DateTime? lastAccessed, + String? sameSite, + String? id, + }) = _Cookie; + + factory Cookie.fromJson(Map json) => _$CookieFromJson(json); +} + +@freezed +class KVPairDatum with _$KVPairDatum { + @JsonSerializable( + explicitToJson: true, + anyMap: true, + includeIfNull: false, + ) + const factory KVPairDatum({ + String? id, + String? name, + String? value, + String? type, + bool? enabled, + }) = _KVPairDatum; + + factory KVPairDatum.fromJson(Map json) => + _$KVPairDatumFromJson(json); +} diff --git a/packages/insomnia_collection/lib/models/insomnia_collection.freezed.dart b/packages/insomnia_collection/lib/models/insomnia_collection.freezed.dart new file mode 100644 index 00000000..ffa05a31 --- /dev/null +++ b/packages/insomnia_collection/lib/models/insomnia_collection.freezed.dart @@ -0,0 +1,2660 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'insomnia_collection.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); + +InsomniaCollection _$InsomniaCollectionFromJson(Map json) { + return _InsomniaCollection.fromJson(json); +} + +/// @nodoc +mixin _$InsomniaCollection { + @JsonKey(name: '_type') + String? get type => throw _privateConstructorUsedError; + @JsonKey(name: '__export_format') + num? get exportFormat => throw _privateConstructorUsedError; + @JsonKey(name: '__export_date') + String? get exportDate => throw _privateConstructorUsedError; + @JsonKey(name: '__export_source') + String? get exportSource => throw _privateConstructorUsedError; + List? get resources => throw _privateConstructorUsedError; + + /// Serializes this InsomniaCollection to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of InsomniaCollection + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $InsomniaCollectionCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $InsomniaCollectionCopyWith<$Res> { + factory $InsomniaCollectionCopyWith( + InsomniaCollection value, $Res Function(InsomniaCollection) then) = + _$InsomniaCollectionCopyWithImpl<$Res, InsomniaCollection>; + @useResult + $Res call( + {@JsonKey(name: '_type') String? type, + @JsonKey(name: '__export_format') num? exportFormat, + @JsonKey(name: '__export_date') String? exportDate, + @JsonKey(name: '__export_source') String? exportSource, + List? resources}); +} + +/// @nodoc +class _$InsomniaCollectionCopyWithImpl<$Res, $Val extends InsomniaCollection> + implements $InsomniaCollectionCopyWith<$Res> { + _$InsomniaCollectionCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of InsomniaCollection + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? type = freezed, + Object? exportFormat = freezed, + Object? exportDate = freezed, + Object? exportSource = freezed, + Object? resources = freezed, + }) { + return _then(_value.copyWith( + type: freezed == type + ? _value.type + : type // ignore: cast_nullable_to_non_nullable + as String?, + exportFormat: freezed == exportFormat + ? _value.exportFormat + : exportFormat // ignore: cast_nullable_to_non_nullable + as num?, + exportDate: freezed == exportDate + ? _value.exportDate + : exportDate // ignore: cast_nullable_to_non_nullable + as String?, + exportSource: freezed == exportSource + ? _value.exportSource + : exportSource // ignore: cast_nullable_to_non_nullable + as String?, + resources: freezed == resources + ? _value.resources + : resources // ignore: cast_nullable_to_non_nullable + as List?, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$InsomniaCollectionImplCopyWith<$Res> + implements $InsomniaCollectionCopyWith<$Res> { + factory _$$InsomniaCollectionImplCopyWith(_$InsomniaCollectionImpl value, + $Res Function(_$InsomniaCollectionImpl) then) = + __$$InsomniaCollectionImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {@JsonKey(name: '_type') String? type, + @JsonKey(name: '__export_format') num? exportFormat, + @JsonKey(name: '__export_date') String? exportDate, + @JsonKey(name: '__export_source') String? exportSource, + List? resources}); +} + +/// @nodoc +class __$$InsomniaCollectionImplCopyWithImpl<$Res> + extends _$InsomniaCollectionCopyWithImpl<$Res, _$InsomniaCollectionImpl> + implements _$$InsomniaCollectionImplCopyWith<$Res> { + __$$InsomniaCollectionImplCopyWithImpl(_$InsomniaCollectionImpl _value, + $Res Function(_$InsomniaCollectionImpl) _then) + : super(_value, _then); + + /// Create a copy of InsomniaCollection + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? type = freezed, + Object? exportFormat = freezed, + Object? exportDate = freezed, + Object? exportSource = freezed, + Object? resources = freezed, + }) { + return _then(_$InsomniaCollectionImpl( + type: freezed == type + ? _value.type + : type // ignore: cast_nullable_to_non_nullable + as String?, + exportFormat: freezed == exportFormat + ? _value.exportFormat + : exportFormat // ignore: cast_nullable_to_non_nullable + as num?, + exportDate: freezed == exportDate + ? _value.exportDate + : exportDate // ignore: cast_nullable_to_non_nullable + as String?, + exportSource: freezed == exportSource + ? _value.exportSource + : exportSource // ignore: cast_nullable_to_non_nullable + as String?, + resources: freezed == resources + ? _value._resources + : resources // ignore: cast_nullable_to_non_nullable + as List?, + )); + } +} + +/// @nodoc + +@JsonSerializable(explicitToJson: true, anyMap: true, includeIfNull: false) +class _$InsomniaCollectionImpl implements _InsomniaCollection { + const _$InsomniaCollectionImpl( + {@JsonKey(name: '_type') this.type, + @JsonKey(name: '__export_format') this.exportFormat, + @JsonKey(name: '__export_date') this.exportDate, + @JsonKey(name: '__export_source') this.exportSource, + final List? resources}) + : _resources = resources; + + factory _$InsomniaCollectionImpl.fromJson(Map json) => + _$$InsomniaCollectionImplFromJson(json); + + @override + @JsonKey(name: '_type') + final String? type; + @override + @JsonKey(name: '__export_format') + final num? exportFormat; + @override + @JsonKey(name: '__export_date') + final String? exportDate; + @override + @JsonKey(name: '__export_source') + final String? exportSource; + final List? _resources; + @override + List? get resources { + final value = _resources; + if (value == null) return null; + if (_resources is EqualUnmodifiableListView) return _resources; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(value); + } + + @override + String toString() { + return 'InsomniaCollection(type: $type, exportFormat: $exportFormat, exportDate: $exportDate, exportSource: $exportSource, resources: $resources)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$InsomniaCollectionImpl && + (identical(other.type, type) || other.type == type) && + (identical(other.exportFormat, exportFormat) || + other.exportFormat == exportFormat) && + (identical(other.exportDate, exportDate) || + other.exportDate == exportDate) && + (identical(other.exportSource, exportSource) || + other.exportSource == exportSource) && + const DeepCollectionEquality() + .equals(other._resources, _resources)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash(runtimeType, type, exportFormat, exportDate, + exportSource, const DeepCollectionEquality().hash(_resources)); + + /// Create a copy of InsomniaCollection + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$InsomniaCollectionImplCopyWith<_$InsomniaCollectionImpl> get copyWith => + __$$InsomniaCollectionImplCopyWithImpl<_$InsomniaCollectionImpl>( + this, _$identity); + + @override + Map toJson() { + return _$$InsomniaCollectionImplToJson( + this, + ); + } +} + +abstract class _InsomniaCollection implements InsomniaCollection { + const factory _InsomniaCollection( + {@JsonKey(name: '_type') final String? type, + @JsonKey(name: '__export_format') final num? exportFormat, + @JsonKey(name: '__export_date') final String? exportDate, + @JsonKey(name: '__export_source') final String? exportSource, + final List? resources}) = _$InsomniaCollectionImpl; + + factory _InsomniaCollection.fromJson(Map json) = + _$InsomniaCollectionImpl.fromJson; + + @override + @JsonKey(name: '_type') + String? get type; + @override + @JsonKey(name: '__export_format') + num? get exportFormat; + @override + @JsonKey(name: '__export_date') + String? get exportDate; + @override + @JsonKey(name: '__export_source') + String? get exportSource; + @override + List? get resources; + + /// Create a copy of InsomniaCollection + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$InsomniaCollectionImplCopyWith<_$InsomniaCollectionImpl> get copyWith => + throw _privateConstructorUsedError; +} + +Resource _$ResourceFromJson(Map json) { + return _Resource.fromJson(json); +} + +/// @nodoc +mixin _$Resource { + @JsonKey(name: '_id') + String? get id => throw _privateConstructorUsedError; + String? get parentId => throw _privateConstructorUsedError; + num? get modified => throw _privateConstructorUsedError; + num? get created => throw _privateConstructorUsedError; + String? get url => throw _privateConstructorUsedError; + String? get name => throw _privateConstructorUsedError; + String? get description => throw _privateConstructorUsedError; + String? get method => throw _privateConstructorUsedError; + Body? get body => throw _privateConstructorUsedError; + String? get preRequestScript => throw _privateConstructorUsedError; + List? get parameters => throw _privateConstructorUsedError; + List
? get headers => throw _privateConstructorUsedError; + dynamic get authentication => throw _privateConstructorUsedError; + num? get metaSortKey => throw _privateConstructorUsedError; + bool? get isPrivate => throw _privateConstructorUsedError; + List? get pathParameters => throw _privateConstructorUsedError; + String? get afterResponseScript => throw _privateConstructorUsedError; + bool? get settingStoreCookies => throw _privateConstructorUsedError; + bool? get settingSendCookies => throw _privateConstructorUsedError; + bool? get settingDisableRenderRequestBody => + throw _privateConstructorUsedError; + bool? get settingEncodeUrl => throw _privateConstructorUsedError; + bool? get settingRebuildPath => throw _privateConstructorUsedError; + String? get settingFollowRedirects => throw _privateConstructorUsedError; + dynamic get environment => throw _privateConstructorUsedError; + dynamic get environmentPropertyOrder => throw _privateConstructorUsedError; + String? get scope => throw _privateConstructorUsedError; + dynamic get data => throw _privateConstructorUsedError; + dynamic get dataPropertyOrder => throw _privateConstructorUsedError; + dynamic get color => throw _privateConstructorUsedError; + List? get cookies => throw _privateConstructorUsedError; + String? get fileName => throw _privateConstructorUsedError; + String? get contents => throw _privateConstructorUsedError; + String? get contentType => throw _privateConstructorUsedError; + String? get environmentType => throw _privateConstructorUsedError; + List? get kvPairData => throw _privateConstructorUsedError; + @JsonKey(name: '_type') + String? get type => throw _privateConstructorUsedError; + + /// Serializes this Resource to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of Resource + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $ResourceCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $ResourceCopyWith<$Res> { + factory $ResourceCopyWith(Resource value, $Res Function(Resource) then) = + _$ResourceCopyWithImpl<$Res, Resource>; + @useResult + $Res call( + {@JsonKey(name: '_id') String? id, + String? parentId, + num? modified, + num? created, + String? url, + String? name, + String? description, + String? method, + Body? body, + String? preRequestScript, + List? parameters, + List
? headers, + dynamic authentication, + num? metaSortKey, + bool? isPrivate, + List? pathParameters, + String? afterResponseScript, + bool? settingStoreCookies, + bool? settingSendCookies, + bool? settingDisableRenderRequestBody, + bool? settingEncodeUrl, + bool? settingRebuildPath, + String? settingFollowRedirects, + dynamic environment, + dynamic environmentPropertyOrder, + String? scope, + dynamic data, + dynamic dataPropertyOrder, + dynamic color, + List? cookies, + String? fileName, + String? contents, + String? contentType, + String? environmentType, + List? kvPairData, + @JsonKey(name: '_type') String? type}); + + $BodyCopyWith<$Res>? get body; +} + +/// @nodoc +class _$ResourceCopyWithImpl<$Res, $Val extends Resource> + implements $ResourceCopyWith<$Res> { + _$ResourceCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of Resource + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = freezed, + Object? parentId = freezed, + Object? modified = freezed, + Object? created = freezed, + Object? url = freezed, + Object? name = freezed, + Object? description = freezed, + Object? method = freezed, + Object? body = freezed, + Object? preRequestScript = freezed, + Object? parameters = freezed, + Object? headers = freezed, + Object? authentication = freezed, + Object? metaSortKey = freezed, + Object? isPrivate = freezed, + Object? pathParameters = freezed, + Object? afterResponseScript = freezed, + Object? settingStoreCookies = freezed, + Object? settingSendCookies = freezed, + Object? settingDisableRenderRequestBody = freezed, + Object? settingEncodeUrl = freezed, + Object? settingRebuildPath = freezed, + Object? settingFollowRedirects = freezed, + Object? environment = freezed, + Object? environmentPropertyOrder = freezed, + Object? scope = freezed, + Object? data = freezed, + Object? dataPropertyOrder = freezed, + Object? color = freezed, + Object? cookies = freezed, + Object? fileName = freezed, + Object? contents = freezed, + Object? contentType = freezed, + Object? environmentType = freezed, + Object? kvPairData = freezed, + Object? type = freezed, + }) { + return _then(_value.copyWith( + id: freezed == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as String?, + parentId: freezed == parentId + ? _value.parentId + : parentId // ignore: cast_nullable_to_non_nullable + as String?, + modified: freezed == modified + ? _value.modified + : modified // ignore: cast_nullable_to_non_nullable + as num?, + created: freezed == created + ? _value.created + : created // ignore: cast_nullable_to_non_nullable + as num?, + url: freezed == url + ? _value.url + : url // ignore: cast_nullable_to_non_nullable + as String?, + name: freezed == name + ? _value.name + : name // ignore: cast_nullable_to_non_nullable + as String?, + description: freezed == description + ? _value.description + : description // ignore: cast_nullable_to_non_nullable + as String?, + method: freezed == method + ? _value.method + : method // ignore: cast_nullable_to_non_nullable + as String?, + body: freezed == body + ? _value.body + : body // ignore: cast_nullable_to_non_nullable + as Body?, + preRequestScript: freezed == preRequestScript + ? _value.preRequestScript + : preRequestScript // ignore: cast_nullable_to_non_nullable + as String?, + parameters: freezed == parameters + ? _value.parameters + : parameters // ignore: cast_nullable_to_non_nullable + as List?, + headers: freezed == headers + ? _value.headers + : headers // ignore: cast_nullable_to_non_nullable + as List
?, + authentication: freezed == authentication + ? _value.authentication + : authentication // ignore: cast_nullable_to_non_nullable + as dynamic, + metaSortKey: freezed == metaSortKey + ? _value.metaSortKey + : metaSortKey // ignore: cast_nullable_to_non_nullable + as num?, + isPrivate: freezed == isPrivate + ? _value.isPrivate + : isPrivate // ignore: cast_nullable_to_non_nullable + as bool?, + pathParameters: freezed == pathParameters + ? _value.pathParameters + : pathParameters // ignore: cast_nullable_to_non_nullable + as List?, + afterResponseScript: freezed == afterResponseScript + ? _value.afterResponseScript + : afterResponseScript // ignore: cast_nullable_to_non_nullable + as String?, + settingStoreCookies: freezed == settingStoreCookies + ? _value.settingStoreCookies + : settingStoreCookies // ignore: cast_nullable_to_non_nullable + as bool?, + settingSendCookies: freezed == settingSendCookies + ? _value.settingSendCookies + : settingSendCookies // ignore: cast_nullable_to_non_nullable + as bool?, + settingDisableRenderRequestBody: freezed == + settingDisableRenderRequestBody + ? _value.settingDisableRenderRequestBody + : settingDisableRenderRequestBody // ignore: cast_nullable_to_non_nullable + as bool?, + settingEncodeUrl: freezed == settingEncodeUrl + ? _value.settingEncodeUrl + : settingEncodeUrl // ignore: cast_nullable_to_non_nullable + as bool?, + settingRebuildPath: freezed == settingRebuildPath + ? _value.settingRebuildPath + : settingRebuildPath // ignore: cast_nullable_to_non_nullable + as bool?, + settingFollowRedirects: freezed == settingFollowRedirects + ? _value.settingFollowRedirects + : settingFollowRedirects // ignore: cast_nullable_to_non_nullable + as String?, + environment: freezed == environment + ? _value.environment + : environment // ignore: cast_nullable_to_non_nullable + as dynamic, + environmentPropertyOrder: freezed == environmentPropertyOrder + ? _value.environmentPropertyOrder + : environmentPropertyOrder // ignore: cast_nullable_to_non_nullable + as dynamic, + scope: freezed == scope + ? _value.scope + : scope // ignore: cast_nullable_to_non_nullable + as String?, + data: freezed == data + ? _value.data + : data // ignore: cast_nullable_to_non_nullable + as dynamic, + dataPropertyOrder: freezed == dataPropertyOrder + ? _value.dataPropertyOrder + : dataPropertyOrder // ignore: cast_nullable_to_non_nullable + as dynamic, + color: freezed == color + ? _value.color + : color // ignore: cast_nullable_to_non_nullable + as dynamic, + cookies: freezed == cookies + ? _value.cookies + : cookies // ignore: cast_nullable_to_non_nullable + as List?, + fileName: freezed == fileName + ? _value.fileName + : fileName // ignore: cast_nullable_to_non_nullable + as String?, + contents: freezed == contents + ? _value.contents + : contents // ignore: cast_nullable_to_non_nullable + as String?, + contentType: freezed == contentType + ? _value.contentType + : contentType // ignore: cast_nullable_to_non_nullable + as String?, + environmentType: freezed == environmentType + ? _value.environmentType + : environmentType // ignore: cast_nullable_to_non_nullable + as String?, + kvPairData: freezed == kvPairData + ? _value.kvPairData + : kvPairData // ignore: cast_nullable_to_non_nullable + as List?, + type: freezed == type + ? _value.type + : type // ignore: cast_nullable_to_non_nullable + as String?, + ) as $Val); + } + + /// Create a copy of Resource + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $BodyCopyWith<$Res>? get body { + if (_value.body == null) { + return null; + } + + return $BodyCopyWith<$Res>(_value.body!, (value) { + return _then(_value.copyWith(body: value) as $Val); + }); + } +} + +/// @nodoc +abstract class _$$ResourceImplCopyWith<$Res> + implements $ResourceCopyWith<$Res> { + factory _$$ResourceImplCopyWith( + _$ResourceImpl value, $Res Function(_$ResourceImpl) then) = + __$$ResourceImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {@JsonKey(name: '_id') String? id, + String? parentId, + num? modified, + num? created, + String? url, + String? name, + String? description, + String? method, + Body? body, + String? preRequestScript, + List? parameters, + List
? headers, + dynamic authentication, + num? metaSortKey, + bool? isPrivate, + List? pathParameters, + String? afterResponseScript, + bool? settingStoreCookies, + bool? settingSendCookies, + bool? settingDisableRenderRequestBody, + bool? settingEncodeUrl, + bool? settingRebuildPath, + String? settingFollowRedirects, + dynamic environment, + dynamic environmentPropertyOrder, + String? scope, + dynamic data, + dynamic dataPropertyOrder, + dynamic color, + List? cookies, + String? fileName, + String? contents, + String? contentType, + String? environmentType, + List? kvPairData, + @JsonKey(name: '_type') String? type}); + + @override + $BodyCopyWith<$Res>? get body; +} + +/// @nodoc +class __$$ResourceImplCopyWithImpl<$Res> + extends _$ResourceCopyWithImpl<$Res, _$ResourceImpl> + implements _$$ResourceImplCopyWith<$Res> { + __$$ResourceImplCopyWithImpl( + _$ResourceImpl _value, $Res Function(_$ResourceImpl) _then) + : super(_value, _then); + + /// Create a copy of Resource + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = freezed, + Object? parentId = freezed, + Object? modified = freezed, + Object? created = freezed, + Object? url = freezed, + Object? name = freezed, + Object? description = freezed, + Object? method = freezed, + Object? body = freezed, + Object? preRequestScript = freezed, + Object? parameters = freezed, + Object? headers = freezed, + Object? authentication = freezed, + Object? metaSortKey = freezed, + Object? isPrivate = freezed, + Object? pathParameters = freezed, + Object? afterResponseScript = freezed, + Object? settingStoreCookies = freezed, + Object? settingSendCookies = freezed, + Object? settingDisableRenderRequestBody = freezed, + Object? settingEncodeUrl = freezed, + Object? settingRebuildPath = freezed, + Object? settingFollowRedirects = freezed, + Object? environment = freezed, + Object? environmentPropertyOrder = freezed, + Object? scope = freezed, + Object? data = freezed, + Object? dataPropertyOrder = freezed, + Object? color = freezed, + Object? cookies = freezed, + Object? fileName = freezed, + Object? contents = freezed, + Object? contentType = freezed, + Object? environmentType = freezed, + Object? kvPairData = freezed, + Object? type = freezed, + }) { + return _then(_$ResourceImpl( + id: freezed == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as String?, + parentId: freezed == parentId + ? _value.parentId + : parentId // ignore: cast_nullable_to_non_nullable + as String?, + modified: freezed == modified + ? _value.modified + : modified // ignore: cast_nullable_to_non_nullable + as num?, + created: freezed == created + ? _value.created + : created // ignore: cast_nullable_to_non_nullable + as num?, + url: freezed == url + ? _value.url + : url // ignore: cast_nullable_to_non_nullable + as String?, + name: freezed == name + ? _value.name + : name // ignore: cast_nullable_to_non_nullable + as String?, + description: freezed == description + ? _value.description + : description // ignore: cast_nullable_to_non_nullable + as String?, + method: freezed == method + ? _value.method + : method // ignore: cast_nullable_to_non_nullable + as String?, + body: freezed == body + ? _value.body + : body // ignore: cast_nullable_to_non_nullable + as Body?, + preRequestScript: freezed == preRequestScript + ? _value.preRequestScript + : preRequestScript // ignore: cast_nullable_to_non_nullable + as String?, + parameters: freezed == parameters + ? _value._parameters + : parameters // ignore: cast_nullable_to_non_nullable + as List?, + headers: freezed == headers + ? _value._headers + : headers // ignore: cast_nullable_to_non_nullable + as List
?, + authentication: freezed == authentication + ? _value.authentication + : authentication // ignore: cast_nullable_to_non_nullable + as dynamic, + metaSortKey: freezed == metaSortKey + ? _value.metaSortKey + : metaSortKey // ignore: cast_nullable_to_non_nullable + as num?, + isPrivate: freezed == isPrivate + ? _value.isPrivate + : isPrivate // ignore: cast_nullable_to_non_nullable + as bool?, + pathParameters: freezed == pathParameters + ? _value._pathParameters + : pathParameters // ignore: cast_nullable_to_non_nullable + as List?, + afterResponseScript: freezed == afterResponseScript + ? _value.afterResponseScript + : afterResponseScript // ignore: cast_nullable_to_non_nullable + as String?, + settingStoreCookies: freezed == settingStoreCookies + ? _value.settingStoreCookies + : settingStoreCookies // ignore: cast_nullable_to_non_nullable + as bool?, + settingSendCookies: freezed == settingSendCookies + ? _value.settingSendCookies + : settingSendCookies // ignore: cast_nullable_to_non_nullable + as bool?, + settingDisableRenderRequestBody: freezed == + settingDisableRenderRequestBody + ? _value.settingDisableRenderRequestBody + : settingDisableRenderRequestBody // ignore: cast_nullable_to_non_nullable + as bool?, + settingEncodeUrl: freezed == settingEncodeUrl + ? _value.settingEncodeUrl + : settingEncodeUrl // ignore: cast_nullable_to_non_nullable + as bool?, + settingRebuildPath: freezed == settingRebuildPath + ? _value.settingRebuildPath + : settingRebuildPath // ignore: cast_nullable_to_non_nullable + as bool?, + settingFollowRedirects: freezed == settingFollowRedirects + ? _value.settingFollowRedirects + : settingFollowRedirects // ignore: cast_nullable_to_non_nullable + as String?, + environment: freezed == environment + ? _value.environment + : environment // ignore: cast_nullable_to_non_nullable + as dynamic, + environmentPropertyOrder: freezed == environmentPropertyOrder + ? _value.environmentPropertyOrder + : environmentPropertyOrder // ignore: cast_nullable_to_non_nullable + as dynamic, + scope: freezed == scope + ? _value.scope + : scope // ignore: cast_nullable_to_non_nullable + as String?, + data: freezed == data + ? _value.data + : data // ignore: cast_nullable_to_non_nullable + as dynamic, + dataPropertyOrder: freezed == dataPropertyOrder + ? _value.dataPropertyOrder + : dataPropertyOrder // ignore: cast_nullable_to_non_nullable + as dynamic, + color: freezed == color + ? _value.color + : color // ignore: cast_nullable_to_non_nullable + as dynamic, + cookies: freezed == cookies + ? _value._cookies + : cookies // ignore: cast_nullable_to_non_nullable + as List?, + fileName: freezed == fileName + ? _value.fileName + : fileName // ignore: cast_nullable_to_non_nullable + as String?, + contents: freezed == contents + ? _value.contents + : contents // ignore: cast_nullable_to_non_nullable + as String?, + contentType: freezed == contentType + ? _value.contentType + : contentType // ignore: cast_nullable_to_non_nullable + as String?, + environmentType: freezed == environmentType + ? _value.environmentType + : environmentType // ignore: cast_nullable_to_non_nullable + as String?, + kvPairData: freezed == kvPairData + ? _value._kvPairData + : kvPairData // ignore: cast_nullable_to_non_nullable + as List?, + type: freezed == type + ? _value.type + : type // ignore: cast_nullable_to_non_nullable + as String?, + )); + } +} + +/// @nodoc + +@JsonSerializable(explicitToJson: true, anyMap: true, includeIfNull: false) +class _$ResourceImpl implements _Resource { + const _$ResourceImpl( + {@JsonKey(name: '_id') this.id, + this.parentId, + this.modified, + this.created, + this.url, + this.name, + this.description, + this.method, + this.body, + this.preRequestScript, + final List? parameters, + final List
? headers, + this.authentication, + this.metaSortKey, + this.isPrivate, + final List? pathParameters, + this.afterResponseScript, + this.settingStoreCookies, + this.settingSendCookies, + this.settingDisableRenderRequestBody, + this.settingEncodeUrl, + this.settingRebuildPath, + this.settingFollowRedirects, + this.environment, + this.environmentPropertyOrder, + this.scope, + this.data, + this.dataPropertyOrder, + this.color, + final List? cookies, + this.fileName, + this.contents, + this.contentType, + this.environmentType, + final List? kvPairData, + @JsonKey(name: '_type') this.type}) + : _parameters = parameters, + _headers = headers, + _pathParameters = pathParameters, + _cookies = cookies, + _kvPairData = kvPairData; + + factory _$ResourceImpl.fromJson(Map json) => + _$$ResourceImplFromJson(json); + + @override + @JsonKey(name: '_id') + final String? id; + @override + final String? parentId; + @override + final num? modified; + @override + final num? created; + @override + final String? url; + @override + final String? name; + @override + final String? description; + @override + final String? method; + @override + final Body? body; + @override + final String? preRequestScript; + final List? _parameters; + @override + List? get parameters { + final value = _parameters; + if (value == null) return null; + if (_parameters is EqualUnmodifiableListView) return _parameters; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(value); + } + + final List
? _headers; + @override + List
? get headers { + final value = _headers; + if (value == null) return null; + if (_headers is EqualUnmodifiableListView) return _headers; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(value); + } + + @override + final dynamic authentication; + @override + final num? metaSortKey; + @override + final bool? isPrivate; + final List? _pathParameters; + @override + List? get pathParameters { + final value = _pathParameters; + if (value == null) return null; + if (_pathParameters is EqualUnmodifiableListView) return _pathParameters; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(value); + } + + @override + final String? afterResponseScript; + @override + final bool? settingStoreCookies; + @override + final bool? settingSendCookies; + @override + final bool? settingDisableRenderRequestBody; + @override + final bool? settingEncodeUrl; + @override + final bool? settingRebuildPath; + @override + final String? settingFollowRedirects; + @override + final dynamic environment; + @override + final dynamic environmentPropertyOrder; + @override + final String? scope; + @override + final dynamic data; + @override + final dynamic dataPropertyOrder; + @override + final dynamic color; + final List? _cookies; + @override + List? get cookies { + final value = _cookies; + if (value == null) return null; + if (_cookies is EqualUnmodifiableListView) return _cookies; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(value); + } + + @override + final String? fileName; + @override + final String? contents; + @override + final String? contentType; + @override + final String? environmentType; + final List? _kvPairData; + @override + List? get kvPairData { + final value = _kvPairData; + if (value == null) return null; + if (_kvPairData is EqualUnmodifiableListView) return _kvPairData; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(value); + } + + @override + @JsonKey(name: '_type') + final String? type; + + @override + String toString() { + return 'Resource(id: $id, parentId: $parentId, modified: $modified, created: $created, url: $url, name: $name, description: $description, method: $method, body: $body, preRequestScript: $preRequestScript, parameters: $parameters, headers: $headers, authentication: $authentication, metaSortKey: $metaSortKey, isPrivate: $isPrivate, pathParameters: $pathParameters, afterResponseScript: $afterResponseScript, settingStoreCookies: $settingStoreCookies, settingSendCookies: $settingSendCookies, settingDisableRenderRequestBody: $settingDisableRenderRequestBody, settingEncodeUrl: $settingEncodeUrl, settingRebuildPath: $settingRebuildPath, settingFollowRedirects: $settingFollowRedirects, environment: $environment, environmentPropertyOrder: $environmentPropertyOrder, scope: $scope, data: $data, dataPropertyOrder: $dataPropertyOrder, color: $color, cookies: $cookies, fileName: $fileName, contents: $contents, contentType: $contentType, environmentType: $environmentType, kvPairData: $kvPairData, type: $type)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$ResourceImpl && + (identical(other.id, id) || other.id == id) && + (identical(other.parentId, parentId) || + other.parentId == parentId) && + (identical(other.modified, modified) || + other.modified == modified) && + (identical(other.created, created) || other.created == created) && + (identical(other.url, url) || other.url == url) && + (identical(other.name, name) || other.name == name) && + (identical(other.description, description) || + other.description == description) && + (identical(other.method, method) || other.method == method) && + (identical(other.body, body) || other.body == body) && + (identical(other.preRequestScript, preRequestScript) || + other.preRequestScript == preRequestScript) && + const DeepCollectionEquality() + .equals(other._parameters, _parameters) && + const DeepCollectionEquality().equals(other._headers, _headers) && + const DeepCollectionEquality() + .equals(other.authentication, authentication) && + (identical(other.metaSortKey, metaSortKey) || + other.metaSortKey == metaSortKey) && + (identical(other.isPrivate, isPrivate) || + other.isPrivate == isPrivate) && + const DeepCollectionEquality() + .equals(other._pathParameters, _pathParameters) && + (identical(other.afterResponseScript, afterResponseScript) || + other.afterResponseScript == afterResponseScript) && + (identical(other.settingStoreCookies, settingStoreCookies) || + other.settingStoreCookies == settingStoreCookies) && + (identical(other.settingSendCookies, settingSendCookies) || + other.settingSendCookies == settingSendCookies) && + (identical(other.settingDisableRenderRequestBody, + settingDisableRenderRequestBody) || + other.settingDisableRenderRequestBody == + settingDisableRenderRequestBody) && + (identical(other.settingEncodeUrl, settingEncodeUrl) || + other.settingEncodeUrl == settingEncodeUrl) && + (identical(other.settingRebuildPath, settingRebuildPath) || + other.settingRebuildPath == settingRebuildPath) && + (identical(other.settingFollowRedirects, settingFollowRedirects) || + other.settingFollowRedirects == settingFollowRedirects) && + const DeepCollectionEquality() + .equals(other.environment, environment) && + const DeepCollectionEquality().equals( + other.environmentPropertyOrder, environmentPropertyOrder) && + (identical(other.scope, scope) || other.scope == scope) && + const DeepCollectionEquality().equals(other.data, data) && + const DeepCollectionEquality() + .equals(other.dataPropertyOrder, dataPropertyOrder) && + const DeepCollectionEquality().equals(other.color, color) && + const DeepCollectionEquality().equals(other._cookies, _cookies) && + (identical(other.fileName, fileName) || + other.fileName == fileName) && + (identical(other.contents, contents) || + other.contents == contents) && + (identical(other.contentType, contentType) || + other.contentType == contentType) && + (identical(other.environmentType, environmentType) || + other.environmentType == environmentType) && + const DeepCollectionEquality() + .equals(other._kvPairData, _kvPairData) && + (identical(other.type, type) || other.type == type)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hashAll([ + runtimeType, + id, + parentId, + modified, + created, + url, + name, + description, + method, + body, + preRequestScript, + const DeepCollectionEquality().hash(_parameters), + const DeepCollectionEquality().hash(_headers), + const DeepCollectionEquality().hash(authentication), + metaSortKey, + isPrivate, + const DeepCollectionEquality().hash(_pathParameters), + afterResponseScript, + settingStoreCookies, + settingSendCookies, + settingDisableRenderRequestBody, + settingEncodeUrl, + settingRebuildPath, + settingFollowRedirects, + const DeepCollectionEquality().hash(environment), + const DeepCollectionEquality().hash(environmentPropertyOrder), + scope, + const DeepCollectionEquality().hash(data), + const DeepCollectionEquality().hash(dataPropertyOrder), + const DeepCollectionEquality().hash(color), + const DeepCollectionEquality().hash(_cookies), + fileName, + contents, + contentType, + environmentType, + const DeepCollectionEquality().hash(_kvPairData), + type + ]); + + /// Create a copy of Resource + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$ResourceImplCopyWith<_$ResourceImpl> get copyWith => + __$$ResourceImplCopyWithImpl<_$ResourceImpl>(this, _$identity); + + @override + Map toJson() { + return _$$ResourceImplToJson( + this, + ); + } +} + +abstract class _Resource implements Resource { + const factory _Resource( + {@JsonKey(name: '_id') final String? id, + final String? parentId, + final num? modified, + final num? created, + final String? url, + final String? name, + final String? description, + final String? method, + final Body? body, + final String? preRequestScript, + final List? parameters, + final List
? headers, + final dynamic authentication, + final num? metaSortKey, + final bool? isPrivate, + final List? pathParameters, + final String? afterResponseScript, + final bool? settingStoreCookies, + final bool? settingSendCookies, + final bool? settingDisableRenderRequestBody, + final bool? settingEncodeUrl, + final bool? settingRebuildPath, + final String? settingFollowRedirects, + final dynamic environment, + final dynamic environmentPropertyOrder, + final String? scope, + final dynamic data, + final dynamic dataPropertyOrder, + final dynamic color, + final List? cookies, + final String? fileName, + final String? contents, + final String? contentType, + final String? environmentType, + final List? kvPairData, + @JsonKey(name: '_type') final String? type}) = _$ResourceImpl; + + factory _Resource.fromJson(Map json) = + _$ResourceImpl.fromJson; + + @override + @JsonKey(name: '_id') + String? get id; + @override + String? get parentId; + @override + num? get modified; + @override + num? get created; + @override + String? get url; + @override + String? get name; + @override + String? get description; + @override + String? get method; + @override + Body? get body; + @override + String? get preRequestScript; + @override + List? get parameters; + @override + List
? get headers; + @override + dynamic get authentication; + @override + num? get metaSortKey; + @override + bool? get isPrivate; + @override + List? get pathParameters; + @override + String? get afterResponseScript; + @override + bool? get settingStoreCookies; + @override + bool? get settingSendCookies; + @override + bool? get settingDisableRenderRequestBody; + @override + bool? get settingEncodeUrl; + @override + bool? get settingRebuildPath; + @override + String? get settingFollowRedirects; + @override + dynamic get environment; + @override + dynamic get environmentPropertyOrder; + @override + String? get scope; + @override + dynamic get data; + @override + dynamic get dataPropertyOrder; + @override + dynamic get color; + @override + List? get cookies; + @override + String? get fileName; + @override + String? get contents; + @override + String? get contentType; + @override + String? get environmentType; + @override + List? get kvPairData; + @override + @JsonKey(name: '_type') + String? get type; + + /// Create a copy of Resource + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$ResourceImplCopyWith<_$ResourceImpl> get copyWith => + throw _privateConstructorUsedError; +} + +Body _$BodyFromJson(Map json) { + return _Body.fromJson(json); +} + +/// @nodoc +mixin _$Body { + String? get mimeType => throw _privateConstructorUsedError; + String? get text => throw _privateConstructorUsedError; + List? get params => throw _privateConstructorUsedError; + + /// Serializes this Body to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of Body + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $BodyCopyWith get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $BodyCopyWith<$Res> { + factory $BodyCopyWith(Body value, $Res Function(Body) then) = + _$BodyCopyWithImpl<$Res, Body>; + @useResult + $Res call({String? mimeType, String? text, List? params}); +} + +/// @nodoc +class _$BodyCopyWithImpl<$Res, $Val extends Body> + implements $BodyCopyWith<$Res> { + _$BodyCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of Body + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? mimeType = freezed, + Object? text = freezed, + Object? params = freezed, + }) { + return _then(_value.copyWith( + mimeType: freezed == mimeType + ? _value.mimeType + : mimeType // ignore: cast_nullable_to_non_nullable + as String?, + text: freezed == text + ? _value.text + : text // ignore: cast_nullable_to_non_nullable + as String?, + params: freezed == params + ? _value.params + : params // ignore: cast_nullable_to_non_nullable + as List?, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$BodyImplCopyWith<$Res> implements $BodyCopyWith<$Res> { + factory _$$BodyImplCopyWith( + _$BodyImpl value, $Res Function(_$BodyImpl) then) = + __$$BodyImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({String? mimeType, String? text, List? params}); +} + +/// @nodoc +class __$$BodyImplCopyWithImpl<$Res> + extends _$BodyCopyWithImpl<$Res, _$BodyImpl> + implements _$$BodyImplCopyWith<$Res> { + __$$BodyImplCopyWithImpl(_$BodyImpl _value, $Res Function(_$BodyImpl) _then) + : super(_value, _then); + + /// Create a copy of Body + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? mimeType = freezed, + Object? text = freezed, + Object? params = freezed, + }) { + return _then(_$BodyImpl( + mimeType: freezed == mimeType + ? _value.mimeType + : mimeType // ignore: cast_nullable_to_non_nullable + as String?, + text: freezed == text + ? _value.text + : text // ignore: cast_nullable_to_non_nullable + as String?, + params: freezed == params + ? _value._params + : params // ignore: cast_nullable_to_non_nullable + as List?, + )); + } +} + +/// @nodoc + +@JsonSerializable(explicitToJson: true, anyMap: true, includeIfNull: false) +class _$BodyImpl implements _Body { + const _$BodyImpl({this.mimeType, this.text, final List? params}) + : _params = params; + + factory _$BodyImpl.fromJson(Map json) => + _$$BodyImplFromJson(json); + + @override + final String? mimeType; + @override + final String? text; + final List? _params; + @override + List? get params { + final value = _params; + if (value == null) return null; + if (_params is EqualUnmodifiableListView) return _params; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(value); + } + + @override + String toString() { + return 'Body(mimeType: $mimeType, text: $text, params: $params)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$BodyImpl && + (identical(other.mimeType, mimeType) || + other.mimeType == mimeType) && + (identical(other.text, text) || other.text == text) && + const DeepCollectionEquality().equals(other._params, _params)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash(runtimeType, mimeType, text, + const DeepCollectionEquality().hash(_params)); + + /// Create a copy of Body + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$BodyImplCopyWith<_$BodyImpl> get copyWith => + __$$BodyImplCopyWithImpl<_$BodyImpl>(this, _$identity); + + @override + Map toJson() { + return _$$BodyImplToJson( + this, + ); + } +} + +abstract class _Body implements Body { + const factory _Body( + {final String? mimeType, + final String? text, + final List? params}) = _$BodyImpl; + + factory _Body.fromJson(Map json) = _$BodyImpl.fromJson; + + @override + String? get mimeType; + @override + String? get text; + @override + List? get params; + + /// Create a copy of Body + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$BodyImplCopyWith<_$BodyImpl> get copyWith => + throw _privateConstructorUsedError; +} + +Formdatum _$FormdatumFromJson(Map json) { + return _Formdatum.fromJson(json); +} + +/// @nodoc +mixin _$Formdatum { + String? get name => throw _privateConstructorUsedError; + String? get value => throw _privateConstructorUsedError; + String? get type => throw _privateConstructorUsedError; + @JsonKey(name: 'fileName') + String? get src => throw _privateConstructorUsedError; + + /// Serializes this Formdatum to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of Formdatum + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $FormdatumCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $FormdatumCopyWith<$Res> { + factory $FormdatumCopyWith(Formdatum value, $Res Function(Formdatum) then) = + _$FormdatumCopyWithImpl<$Res, Formdatum>; + @useResult + $Res call( + {String? name, + String? value, + String? type, + @JsonKey(name: 'fileName') String? src}); +} + +/// @nodoc +class _$FormdatumCopyWithImpl<$Res, $Val extends Formdatum> + implements $FormdatumCopyWith<$Res> { + _$FormdatumCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of Formdatum + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? name = freezed, + Object? value = freezed, + Object? type = freezed, + Object? src = freezed, + }) { + return _then(_value.copyWith( + name: freezed == name + ? _value.name + : name // ignore: cast_nullable_to_non_nullable + as String?, + value: freezed == value + ? _value.value + : value // ignore: cast_nullable_to_non_nullable + as String?, + type: freezed == type + ? _value.type + : type // ignore: cast_nullable_to_non_nullable + as String?, + src: freezed == src + ? _value.src + : src // ignore: cast_nullable_to_non_nullable + as String?, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$FormdatumImplCopyWith<$Res> + implements $FormdatumCopyWith<$Res> { + factory _$$FormdatumImplCopyWith( + _$FormdatumImpl value, $Res Function(_$FormdatumImpl) then) = + __$$FormdatumImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {String? name, + String? value, + String? type, + @JsonKey(name: 'fileName') String? src}); +} + +/// @nodoc +class __$$FormdatumImplCopyWithImpl<$Res> + extends _$FormdatumCopyWithImpl<$Res, _$FormdatumImpl> + implements _$$FormdatumImplCopyWith<$Res> { + __$$FormdatumImplCopyWithImpl( + _$FormdatumImpl _value, $Res Function(_$FormdatumImpl) _then) + : super(_value, _then); + + /// Create a copy of Formdatum + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? name = freezed, + Object? value = freezed, + Object? type = freezed, + Object? src = freezed, + }) { + return _then(_$FormdatumImpl( + name: freezed == name + ? _value.name + : name // ignore: cast_nullable_to_non_nullable + as String?, + value: freezed == value + ? _value.value + : value // ignore: cast_nullable_to_non_nullable + as String?, + type: freezed == type + ? _value.type + : type // ignore: cast_nullable_to_non_nullable + as String?, + src: freezed == src + ? _value.src + : src // ignore: cast_nullable_to_non_nullable + as String?, + )); + } +} + +/// @nodoc + +@JsonSerializable(explicitToJson: true, anyMap: true, includeIfNull: false) +class _$FormdatumImpl implements _Formdatum { + const _$FormdatumImpl( + {this.name, this.value, this.type, @JsonKey(name: 'fileName') this.src}); + + factory _$FormdatumImpl.fromJson(Map json) => + _$$FormdatumImplFromJson(json); + + @override + final String? name; + @override + final String? value; + @override + final String? type; + @override + @JsonKey(name: 'fileName') + final String? src; + + @override + String toString() { + return 'Formdatum(name: $name, value: $value, type: $type, src: $src)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$FormdatumImpl && + (identical(other.name, name) || other.name == name) && + (identical(other.value, value) || other.value == value) && + (identical(other.type, type) || other.type == type) && + (identical(other.src, src) || other.src == src)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash(runtimeType, name, value, type, src); + + /// Create a copy of Formdatum + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$FormdatumImplCopyWith<_$FormdatumImpl> get copyWith => + __$$FormdatumImplCopyWithImpl<_$FormdatumImpl>(this, _$identity); + + @override + Map toJson() { + return _$$FormdatumImplToJson( + this, + ); + } +} + +abstract class _Formdatum implements Formdatum { + const factory _Formdatum( + {final String? name, + final String? value, + final String? type, + @JsonKey(name: 'fileName') final String? src}) = _$FormdatumImpl; + + factory _Formdatum.fromJson(Map json) = + _$FormdatumImpl.fromJson; + + @override + String? get name; + @override + String? get value; + @override + String? get type; + @override + @JsonKey(name: 'fileName') + String? get src; + + /// Create a copy of Formdatum + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$FormdatumImplCopyWith<_$FormdatumImpl> get copyWith => + throw _privateConstructorUsedError; +} + +Parameter _$ParameterFromJson(Map json) { + return _Parameter.fromJson(json); +} + +/// @nodoc +mixin _$Parameter { + String? get id => throw _privateConstructorUsedError; + String? get name => throw _privateConstructorUsedError; + String? get value => throw _privateConstructorUsedError; + String? get description => throw _privateConstructorUsedError; + bool? get disabled => throw _privateConstructorUsedError; + + /// Serializes this Parameter to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of Parameter + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $ParameterCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $ParameterCopyWith<$Res> { + factory $ParameterCopyWith(Parameter value, $Res Function(Parameter) then) = + _$ParameterCopyWithImpl<$Res, Parameter>; + @useResult + $Res call( + {String? id, + String? name, + String? value, + String? description, + bool? disabled}); +} + +/// @nodoc +class _$ParameterCopyWithImpl<$Res, $Val extends Parameter> + implements $ParameterCopyWith<$Res> { + _$ParameterCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of Parameter + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = freezed, + Object? name = freezed, + Object? value = freezed, + Object? description = freezed, + Object? disabled = freezed, + }) { + return _then(_value.copyWith( + id: freezed == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as String?, + name: freezed == name + ? _value.name + : name // ignore: cast_nullable_to_non_nullable + as String?, + value: freezed == value + ? _value.value + : value // ignore: cast_nullable_to_non_nullable + as String?, + description: freezed == description + ? _value.description + : description // ignore: cast_nullable_to_non_nullable + as String?, + disabled: freezed == disabled + ? _value.disabled + : disabled // ignore: cast_nullable_to_non_nullable + as bool?, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$ParameterImplCopyWith<$Res> + implements $ParameterCopyWith<$Res> { + factory _$$ParameterImplCopyWith( + _$ParameterImpl value, $Res Function(_$ParameterImpl) then) = + __$$ParameterImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {String? id, + String? name, + String? value, + String? description, + bool? disabled}); +} + +/// @nodoc +class __$$ParameterImplCopyWithImpl<$Res> + extends _$ParameterCopyWithImpl<$Res, _$ParameterImpl> + implements _$$ParameterImplCopyWith<$Res> { + __$$ParameterImplCopyWithImpl( + _$ParameterImpl _value, $Res Function(_$ParameterImpl) _then) + : super(_value, _then); + + /// Create a copy of Parameter + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = freezed, + Object? name = freezed, + Object? value = freezed, + Object? description = freezed, + Object? disabled = freezed, + }) { + return _then(_$ParameterImpl( + id: freezed == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as String?, + name: freezed == name + ? _value.name + : name // ignore: cast_nullable_to_non_nullable + as String?, + value: freezed == value + ? _value.value + : value // ignore: cast_nullable_to_non_nullable + as String?, + description: freezed == description + ? _value.description + : description // ignore: cast_nullable_to_non_nullable + as String?, + disabled: freezed == disabled + ? _value.disabled + : disabled // ignore: cast_nullable_to_non_nullable + as bool?, + )); + } +} + +/// @nodoc + +@JsonSerializable(explicitToJson: true, anyMap: true, includeIfNull: false) +class _$ParameterImpl implements _Parameter { + const _$ParameterImpl( + {this.id, this.name, this.value, this.description, this.disabled}); + + factory _$ParameterImpl.fromJson(Map json) => + _$$ParameterImplFromJson(json); + + @override + final String? id; + @override + final String? name; + @override + final String? value; + @override + final String? description; + @override + final bool? disabled; + + @override + String toString() { + return 'Parameter(id: $id, name: $name, value: $value, description: $description, disabled: $disabled)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$ParameterImpl && + (identical(other.id, id) || other.id == id) && + (identical(other.name, name) || other.name == name) && + (identical(other.value, value) || other.value == value) && + (identical(other.description, description) || + other.description == description) && + (identical(other.disabled, disabled) || + other.disabled == disabled)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => + Object.hash(runtimeType, id, name, value, description, disabled); + + /// Create a copy of Parameter + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$ParameterImplCopyWith<_$ParameterImpl> get copyWith => + __$$ParameterImplCopyWithImpl<_$ParameterImpl>(this, _$identity); + + @override + Map toJson() { + return _$$ParameterImplToJson( + this, + ); + } +} + +abstract class _Parameter implements Parameter { + const factory _Parameter( + {final String? id, + final String? name, + final String? value, + final String? description, + final bool? disabled}) = _$ParameterImpl; + + factory _Parameter.fromJson(Map json) = + _$ParameterImpl.fromJson; + + @override + String? get id; + @override + String? get name; + @override + String? get value; + @override + String? get description; + @override + bool? get disabled; + + /// Create a copy of Parameter + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$ParameterImplCopyWith<_$ParameterImpl> get copyWith => + throw _privateConstructorUsedError; +} + +Header _$HeaderFromJson(Map json) { + return _Header.fromJson(json); +} + +/// @nodoc +mixin _$Header { + String? get name => throw _privateConstructorUsedError; + String? get value => throw _privateConstructorUsedError; + bool? get disabled => throw _privateConstructorUsedError; + + /// Serializes this Header to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of Header + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $HeaderCopyWith
get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $HeaderCopyWith<$Res> { + factory $HeaderCopyWith(Header value, $Res Function(Header) then) = + _$HeaderCopyWithImpl<$Res, Header>; + @useResult + $Res call({String? name, String? value, bool? disabled}); +} + +/// @nodoc +class _$HeaderCopyWithImpl<$Res, $Val extends Header> + implements $HeaderCopyWith<$Res> { + _$HeaderCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of Header + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? name = freezed, + Object? value = freezed, + Object? disabled = freezed, + }) { + return _then(_value.copyWith( + name: freezed == name + ? _value.name + : name // ignore: cast_nullable_to_non_nullable + as String?, + value: freezed == value + ? _value.value + : value // ignore: cast_nullable_to_non_nullable + as String?, + disabled: freezed == disabled + ? _value.disabled + : disabled // ignore: cast_nullable_to_non_nullable + as bool?, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$HeaderImplCopyWith<$Res> implements $HeaderCopyWith<$Res> { + factory _$$HeaderImplCopyWith( + _$HeaderImpl value, $Res Function(_$HeaderImpl) then) = + __$$HeaderImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({String? name, String? value, bool? disabled}); +} + +/// @nodoc +class __$$HeaderImplCopyWithImpl<$Res> + extends _$HeaderCopyWithImpl<$Res, _$HeaderImpl> + implements _$$HeaderImplCopyWith<$Res> { + __$$HeaderImplCopyWithImpl( + _$HeaderImpl _value, $Res Function(_$HeaderImpl) _then) + : super(_value, _then); + + /// Create a copy of Header + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? name = freezed, + Object? value = freezed, + Object? disabled = freezed, + }) { + return _then(_$HeaderImpl( + name: freezed == name + ? _value.name + : name // ignore: cast_nullable_to_non_nullable + as String?, + value: freezed == value + ? _value.value + : value // ignore: cast_nullable_to_non_nullable + as String?, + disabled: freezed == disabled + ? _value.disabled + : disabled // ignore: cast_nullable_to_non_nullable + as bool?, + )); + } +} + +/// @nodoc + +@JsonSerializable(explicitToJson: true, anyMap: true, includeIfNull: false) +class _$HeaderImpl implements _Header { + const _$HeaderImpl({this.name, this.value, this.disabled}); + + factory _$HeaderImpl.fromJson(Map json) => + _$$HeaderImplFromJson(json); + + @override + final String? name; + @override + final String? value; + @override + final bool? disabled; + + @override + String toString() { + return 'Header(name: $name, value: $value, disabled: $disabled)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$HeaderImpl && + (identical(other.name, name) || other.name == name) && + (identical(other.value, value) || other.value == value) && + (identical(other.disabled, disabled) || + other.disabled == disabled)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash(runtimeType, name, value, disabled); + + /// Create a copy of Header + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$HeaderImplCopyWith<_$HeaderImpl> get copyWith => + __$$HeaderImplCopyWithImpl<_$HeaderImpl>(this, _$identity); + + @override + Map toJson() { + return _$$HeaderImplToJson( + this, + ); + } +} + +abstract class _Header implements Header { + const factory _Header( + {final String? name, + final String? value, + final bool? disabled}) = _$HeaderImpl; + + factory _Header.fromJson(Map json) = _$HeaderImpl.fromJson; + + @override + String? get name; + @override + String? get value; + @override + bool? get disabled; + + /// Create a copy of Header + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$HeaderImplCopyWith<_$HeaderImpl> get copyWith => + throw _privateConstructorUsedError; +} + +Cookie _$CookieFromJson(Map json) { + return _Cookie.fromJson(json); +} + +/// @nodoc +mixin _$Cookie { + String? get key => throw _privateConstructorUsedError; + String? get value => throw _privateConstructorUsedError; + String? get domain => throw _privateConstructorUsedError; + String? get path => throw _privateConstructorUsedError; + bool? get secure => throw _privateConstructorUsedError; + bool? get httpOnly => throw _privateConstructorUsedError; + bool? get hostOnly => throw _privateConstructorUsedError; + DateTime? get creation => throw _privateConstructorUsedError; + DateTime? get lastAccessed => throw _privateConstructorUsedError; + String? get sameSite => throw _privateConstructorUsedError; + String? get id => throw _privateConstructorUsedError; + + /// Serializes this Cookie to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of Cookie + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $CookieCopyWith get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $CookieCopyWith<$Res> { + factory $CookieCopyWith(Cookie value, $Res Function(Cookie) then) = + _$CookieCopyWithImpl<$Res, Cookie>; + @useResult + $Res call( + {String? key, + String? value, + String? domain, + String? path, + bool? secure, + bool? httpOnly, + bool? hostOnly, + DateTime? creation, + DateTime? lastAccessed, + String? sameSite, + String? id}); +} + +/// @nodoc +class _$CookieCopyWithImpl<$Res, $Val extends Cookie> + implements $CookieCopyWith<$Res> { + _$CookieCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of Cookie + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? key = freezed, + Object? value = freezed, + Object? domain = freezed, + Object? path = freezed, + Object? secure = freezed, + Object? httpOnly = freezed, + Object? hostOnly = freezed, + Object? creation = freezed, + Object? lastAccessed = freezed, + Object? sameSite = freezed, + Object? id = freezed, + }) { + return _then(_value.copyWith( + key: freezed == key + ? _value.key + : key // ignore: cast_nullable_to_non_nullable + as String?, + value: freezed == value + ? _value.value + : value // ignore: cast_nullable_to_non_nullable + as String?, + domain: freezed == domain + ? _value.domain + : domain // ignore: cast_nullable_to_non_nullable + as String?, + path: freezed == path + ? _value.path + : path // ignore: cast_nullable_to_non_nullable + as String?, + secure: freezed == secure + ? _value.secure + : secure // ignore: cast_nullable_to_non_nullable + as bool?, + httpOnly: freezed == httpOnly + ? _value.httpOnly + : httpOnly // ignore: cast_nullable_to_non_nullable + as bool?, + hostOnly: freezed == hostOnly + ? _value.hostOnly + : hostOnly // ignore: cast_nullable_to_non_nullable + as bool?, + creation: freezed == creation + ? _value.creation + : creation // ignore: cast_nullable_to_non_nullable + as DateTime?, + lastAccessed: freezed == lastAccessed + ? _value.lastAccessed + : lastAccessed // ignore: cast_nullable_to_non_nullable + as DateTime?, + sameSite: freezed == sameSite + ? _value.sameSite + : sameSite // ignore: cast_nullable_to_non_nullable + as String?, + id: freezed == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as String?, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$CookieImplCopyWith<$Res> implements $CookieCopyWith<$Res> { + factory _$$CookieImplCopyWith( + _$CookieImpl value, $Res Function(_$CookieImpl) then) = + __$$CookieImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {String? key, + String? value, + String? domain, + String? path, + bool? secure, + bool? httpOnly, + bool? hostOnly, + DateTime? creation, + DateTime? lastAccessed, + String? sameSite, + String? id}); +} + +/// @nodoc +class __$$CookieImplCopyWithImpl<$Res> + extends _$CookieCopyWithImpl<$Res, _$CookieImpl> + implements _$$CookieImplCopyWith<$Res> { + __$$CookieImplCopyWithImpl( + _$CookieImpl _value, $Res Function(_$CookieImpl) _then) + : super(_value, _then); + + /// Create a copy of Cookie + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? key = freezed, + Object? value = freezed, + Object? domain = freezed, + Object? path = freezed, + Object? secure = freezed, + Object? httpOnly = freezed, + Object? hostOnly = freezed, + Object? creation = freezed, + Object? lastAccessed = freezed, + Object? sameSite = freezed, + Object? id = freezed, + }) { + return _then(_$CookieImpl( + key: freezed == key + ? _value.key + : key // ignore: cast_nullable_to_non_nullable + as String?, + value: freezed == value + ? _value.value + : value // ignore: cast_nullable_to_non_nullable + as String?, + domain: freezed == domain + ? _value.domain + : domain // ignore: cast_nullable_to_non_nullable + as String?, + path: freezed == path + ? _value.path + : path // ignore: cast_nullable_to_non_nullable + as String?, + secure: freezed == secure + ? _value.secure + : secure // ignore: cast_nullable_to_non_nullable + as bool?, + httpOnly: freezed == httpOnly + ? _value.httpOnly + : httpOnly // ignore: cast_nullable_to_non_nullable + as bool?, + hostOnly: freezed == hostOnly + ? _value.hostOnly + : hostOnly // ignore: cast_nullable_to_non_nullable + as bool?, + creation: freezed == creation + ? _value.creation + : creation // ignore: cast_nullable_to_non_nullable + as DateTime?, + lastAccessed: freezed == lastAccessed + ? _value.lastAccessed + : lastAccessed // ignore: cast_nullable_to_non_nullable + as DateTime?, + sameSite: freezed == sameSite + ? _value.sameSite + : sameSite // ignore: cast_nullable_to_non_nullable + as String?, + id: freezed == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as String?, + )); + } +} + +/// @nodoc + +@JsonSerializable(explicitToJson: true, anyMap: true, includeIfNull: false) +class _$CookieImpl implements _Cookie { + const _$CookieImpl( + {this.key, + this.value, + this.domain, + this.path, + this.secure, + this.httpOnly, + this.hostOnly, + this.creation, + this.lastAccessed, + this.sameSite, + this.id}); + + factory _$CookieImpl.fromJson(Map json) => + _$$CookieImplFromJson(json); + + @override + final String? key; + @override + final String? value; + @override + final String? domain; + @override + final String? path; + @override + final bool? secure; + @override + final bool? httpOnly; + @override + final bool? hostOnly; + @override + final DateTime? creation; + @override + final DateTime? lastAccessed; + @override + final String? sameSite; + @override + final String? id; + + @override + String toString() { + return 'Cookie(key: $key, value: $value, domain: $domain, path: $path, secure: $secure, httpOnly: $httpOnly, hostOnly: $hostOnly, creation: $creation, lastAccessed: $lastAccessed, sameSite: $sameSite, id: $id)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$CookieImpl && + (identical(other.key, key) || other.key == key) && + (identical(other.value, value) || other.value == value) && + (identical(other.domain, domain) || other.domain == domain) && + (identical(other.path, path) || other.path == path) && + (identical(other.secure, secure) || other.secure == secure) && + (identical(other.httpOnly, httpOnly) || + other.httpOnly == httpOnly) && + (identical(other.hostOnly, hostOnly) || + other.hostOnly == hostOnly) && + (identical(other.creation, creation) || + other.creation == creation) && + (identical(other.lastAccessed, lastAccessed) || + other.lastAccessed == lastAccessed) && + (identical(other.sameSite, sameSite) || + other.sameSite == sameSite) && + (identical(other.id, id) || other.id == id)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash(runtimeType, key, value, domain, path, secure, + httpOnly, hostOnly, creation, lastAccessed, sameSite, id); + + /// Create a copy of Cookie + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$CookieImplCopyWith<_$CookieImpl> get copyWith => + __$$CookieImplCopyWithImpl<_$CookieImpl>(this, _$identity); + + @override + Map toJson() { + return _$$CookieImplToJson( + this, + ); + } +} + +abstract class _Cookie implements Cookie { + const factory _Cookie( + {final String? key, + final String? value, + final String? domain, + final String? path, + final bool? secure, + final bool? httpOnly, + final bool? hostOnly, + final DateTime? creation, + final DateTime? lastAccessed, + final String? sameSite, + final String? id}) = _$CookieImpl; + + factory _Cookie.fromJson(Map json) = _$CookieImpl.fromJson; + + @override + String? get key; + @override + String? get value; + @override + String? get domain; + @override + String? get path; + @override + bool? get secure; + @override + bool? get httpOnly; + @override + bool? get hostOnly; + @override + DateTime? get creation; + @override + DateTime? get lastAccessed; + @override + String? get sameSite; + @override + String? get id; + + /// Create a copy of Cookie + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$CookieImplCopyWith<_$CookieImpl> get copyWith => + throw _privateConstructorUsedError; +} + +KVPairDatum _$KVPairDatumFromJson(Map json) { + return _KVPairDatum.fromJson(json); +} + +/// @nodoc +mixin _$KVPairDatum { + String? get id => throw _privateConstructorUsedError; + String? get name => throw _privateConstructorUsedError; + String? get value => throw _privateConstructorUsedError; + String? get type => throw _privateConstructorUsedError; + bool? get enabled => throw _privateConstructorUsedError; + + /// Serializes this KVPairDatum to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of KVPairDatum + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $KVPairDatumCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $KVPairDatumCopyWith<$Res> { + factory $KVPairDatumCopyWith( + KVPairDatum value, $Res Function(KVPairDatum) then) = + _$KVPairDatumCopyWithImpl<$Res, KVPairDatum>; + @useResult + $Res call( + {String? id, String? name, String? value, String? type, bool? enabled}); +} + +/// @nodoc +class _$KVPairDatumCopyWithImpl<$Res, $Val extends KVPairDatum> + implements $KVPairDatumCopyWith<$Res> { + _$KVPairDatumCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of KVPairDatum + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = freezed, + Object? name = freezed, + Object? value = freezed, + Object? type = freezed, + Object? enabled = freezed, + }) { + return _then(_value.copyWith( + id: freezed == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as String?, + name: freezed == name + ? _value.name + : name // ignore: cast_nullable_to_non_nullable + as String?, + value: freezed == value + ? _value.value + : value // ignore: cast_nullable_to_non_nullable + as String?, + type: freezed == type + ? _value.type + : type // ignore: cast_nullable_to_non_nullable + as String?, + enabled: freezed == enabled + ? _value.enabled + : enabled // ignore: cast_nullable_to_non_nullable + as bool?, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$KVPairDatumImplCopyWith<$Res> + implements $KVPairDatumCopyWith<$Res> { + factory _$$KVPairDatumImplCopyWith( + _$KVPairDatumImpl value, $Res Function(_$KVPairDatumImpl) then) = + __$$KVPairDatumImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {String? id, String? name, String? value, String? type, bool? enabled}); +} + +/// @nodoc +class __$$KVPairDatumImplCopyWithImpl<$Res> + extends _$KVPairDatumCopyWithImpl<$Res, _$KVPairDatumImpl> + implements _$$KVPairDatumImplCopyWith<$Res> { + __$$KVPairDatumImplCopyWithImpl( + _$KVPairDatumImpl _value, $Res Function(_$KVPairDatumImpl) _then) + : super(_value, _then); + + /// Create a copy of KVPairDatum + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = freezed, + Object? name = freezed, + Object? value = freezed, + Object? type = freezed, + Object? enabled = freezed, + }) { + return _then(_$KVPairDatumImpl( + id: freezed == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as String?, + name: freezed == name + ? _value.name + : name // ignore: cast_nullable_to_non_nullable + as String?, + value: freezed == value + ? _value.value + : value // ignore: cast_nullable_to_non_nullable + as String?, + type: freezed == type + ? _value.type + : type // ignore: cast_nullable_to_non_nullable + as String?, + enabled: freezed == enabled + ? _value.enabled + : enabled // ignore: cast_nullable_to_non_nullable + as bool?, + )); + } +} + +/// @nodoc + +@JsonSerializable(explicitToJson: true, anyMap: true, includeIfNull: false) +class _$KVPairDatumImpl implements _KVPairDatum { + const _$KVPairDatumImpl( + {this.id, this.name, this.value, this.type, this.enabled}); + + factory _$KVPairDatumImpl.fromJson(Map json) => + _$$KVPairDatumImplFromJson(json); + + @override + final String? id; + @override + final String? name; + @override + final String? value; + @override + final String? type; + @override + final bool? enabled; + + @override + String toString() { + return 'KVPairDatum(id: $id, name: $name, value: $value, type: $type, enabled: $enabled)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$KVPairDatumImpl && + (identical(other.id, id) || other.id == id) && + (identical(other.name, name) || other.name == name) && + (identical(other.value, value) || other.value == value) && + (identical(other.type, type) || other.type == type) && + (identical(other.enabled, enabled) || other.enabled == enabled)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash(runtimeType, id, name, value, type, enabled); + + /// Create a copy of KVPairDatum + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$KVPairDatumImplCopyWith<_$KVPairDatumImpl> get copyWith => + __$$KVPairDatumImplCopyWithImpl<_$KVPairDatumImpl>(this, _$identity); + + @override + Map toJson() { + return _$$KVPairDatumImplToJson( + this, + ); + } +} + +abstract class _KVPairDatum implements KVPairDatum { + const factory _KVPairDatum( + {final String? id, + final String? name, + final String? value, + final String? type, + final bool? enabled}) = _$KVPairDatumImpl; + + factory _KVPairDatum.fromJson(Map json) = + _$KVPairDatumImpl.fromJson; + + @override + String? get id; + @override + String? get name; + @override + String? get value; + @override + String? get type; + @override + bool? get enabled; + + /// Create a copy of KVPairDatum + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$KVPairDatumImplCopyWith<_$KVPairDatumImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/packages/insomnia_collection/lib/models/insomnia_collection.g.dart b/packages/insomnia_collection/lib/models/insomnia_collection.g.dart new file mode 100644 index 00000000..431aa70d --- /dev/null +++ b/packages/insomnia_collection/lib/models/insomnia_collection.g.dart @@ -0,0 +1,249 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'insomnia_collection.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$InsomniaCollectionImpl _$$InsomniaCollectionImplFromJson(Map json) => + _$InsomniaCollectionImpl( + type: json['_type'] as String?, + exportFormat: json['__export_format'] as num?, + exportDate: json['__export_date'] as String?, + exportSource: json['__export_source'] as String?, + resources: (json['resources'] as List?) + ?.map((e) => Resource.fromJson(Map.from(e as Map))) + .toList(), + ); + +Map _$$InsomniaCollectionImplToJson( + _$InsomniaCollectionImpl instance) => + { + if (instance.type case final value?) '_type': value, + if (instance.exportFormat case final value?) '__export_format': value, + if (instance.exportDate case final value?) '__export_date': value, + if (instance.exportSource case final value?) '__export_source': value, + if (instance.resources?.map((e) => e.toJson()).toList() case final value?) + 'resources': value, + }; + +_$ResourceImpl _$$ResourceImplFromJson(Map json) => _$ResourceImpl( + id: json['_id'] as String?, + parentId: json['parentId'] as String?, + modified: json['modified'] as num?, + created: json['created'] as num?, + url: json['url'] as String?, + name: json['name'] as String?, + description: json['description'] as String?, + method: json['method'] as String?, + body: json['body'] == null + ? null + : Body.fromJson(Map.from(json['body'] as Map)), + preRequestScript: json['preRequestScript'] as String?, + parameters: (json['parameters'] as List?) + ?.map((e) => Parameter.fromJson(Map.from(e as Map))) + .toList(), + headers: (json['headers'] as List?) + ?.map((e) => Header.fromJson(Map.from(e as Map))) + .toList(), + authentication: json['authentication'], + metaSortKey: json['metaSortKey'] as num?, + isPrivate: json['isPrivate'] as bool?, + pathParameters: json['pathParameters'] as List?, + afterResponseScript: json['afterResponseScript'] as String?, + settingStoreCookies: json['settingStoreCookies'] as bool?, + settingSendCookies: json['settingSendCookies'] as bool?, + settingDisableRenderRequestBody: + json['settingDisableRenderRequestBody'] as bool?, + settingEncodeUrl: json['settingEncodeUrl'] as bool?, + settingRebuildPath: json['settingRebuildPath'] as bool?, + settingFollowRedirects: json['settingFollowRedirects'] as String?, + environment: json['environment'], + environmentPropertyOrder: json['environmentPropertyOrder'], + scope: json['scope'] as String?, + data: json['data'], + dataPropertyOrder: json['dataPropertyOrder'], + color: json['color'], + cookies: (json['cookies'] as List?) + ?.map((e) => Cookie.fromJson(Map.from(e as Map))) + .toList(), + fileName: json['fileName'] as String?, + contents: json['contents'] as String?, + contentType: json['contentType'] as String?, + environmentType: json['environmentType'] as String?, + kvPairData: (json['kvPairData'] as List?) + ?.map( + (e) => KVPairDatum.fromJson(Map.from(e as Map))) + .toList(), + type: json['_type'] as String?, + ); + +Map _$$ResourceImplToJson(_$ResourceImpl instance) => + { + if (instance.id case final value?) '_id': value, + if (instance.parentId case final value?) 'parentId': value, + if (instance.modified case final value?) 'modified': value, + if (instance.created case final value?) 'created': value, + if (instance.url case final value?) 'url': value, + if (instance.name case final value?) 'name': value, + if (instance.description case final value?) 'description': value, + if (instance.method case final value?) 'method': value, + if (instance.body?.toJson() case final value?) 'body': value, + if (instance.preRequestScript case final value?) + 'preRequestScript': value, + if (instance.parameters?.map((e) => e.toJson()).toList() + case final value?) + 'parameters': value, + if (instance.headers?.map((e) => e.toJson()).toList() case final value?) + 'headers': value, + if (instance.authentication case final value?) 'authentication': value, + if (instance.metaSortKey case final value?) 'metaSortKey': value, + if (instance.isPrivate case final value?) 'isPrivate': value, + if (instance.pathParameters case final value?) 'pathParameters': value, + if (instance.afterResponseScript case final value?) + 'afterResponseScript': value, + if (instance.settingStoreCookies case final value?) + 'settingStoreCookies': value, + if (instance.settingSendCookies case final value?) + 'settingSendCookies': value, + if (instance.settingDisableRenderRequestBody case final value?) + 'settingDisableRenderRequestBody': value, + if (instance.settingEncodeUrl case final value?) + 'settingEncodeUrl': value, + if (instance.settingRebuildPath case final value?) + 'settingRebuildPath': value, + if (instance.settingFollowRedirects case final value?) + 'settingFollowRedirects': value, + if (instance.environment case final value?) 'environment': value, + if (instance.environmentPropertyOrder case final value?) + 'environmentPropertyOrder': value, + if (instance.scope case final value?) 'scope': value, + if (instance.data case final value?) 'data': value, + if (instance.dataPropertyOrder case final value?) + 'dataPropertyOrder': value, + if (instance.color case final value?) 'color': value, + if (instance.cookies?.map((e) => e.toJson()).toList() case final value?) + 'cookies': value, + if (instance.fileName case final value?) 'fileName': value, + if (instance.contents case final value?) 'contents': value, + if (instance.contentType case final value?) 'contentType': value, + if (instance.environmentType case final value?) 'environmentType': value, + if (instance.kvPairData?.map((e) => e.toJson()).toList() + case final value?) + 'kvPairData': value, + if (instance.type case final value?) '_type': value, + }; + +_$BodyImpl _$$BodyImplFromJson(Map json) => _$BodyImpl( + mimeType: json['mimeType'] as String?, + text: json['text'] as String?, + params: (json['params'] as List?) + ?.map((e) => Formdatum.fromJson(Map.from(e as Map))) + .toList(), + ); + +Map _$$BodyImplToJson(_$BodyImpl instance) => + { + if (instance.mimeType case final value?) 'mimeType': value, + if (instance.text case final value?) 'text': value, + if (instance.params?.map((e) => e.toJson()).toList() case final value?) + 'params': value, + }; + +_$FormdatumImpl _$$FormdatumImplFromJson(Map json) => _$FormdatumImpl( + name: json['name'] as String?, + value: json['value'] as String?, + type: json['type'] as String?, + src: json['fileName'] as String?, + ); + +Map _$$FormdatumImplToJson(_$FormdatumImpl instance) => + { + if (instance.name case final value?) 'name': value, + if (instance.value case final value?) 'value': value, + if (instance.type case final value?) 'type': value, + if (instance.src case final value?) 'fileName': value, + }; + +_$ParameterImpl _$$ParameterImplFromJson(Map json) => _$ParameterImpl( + id: json['id'] as String?, + name: json['name'] as String?, + value: json['value'] as String?, + description: json['description'] as String?, + disabled: json['disabled'] as bool?, + ); + +Map _$$ParameterImplToJson(_$ParameterImpl instance) => + { + if (instance.id case final value?) 'id': value, + if (instance.name case final value?) 'name': value, + if (instance.value case final value?) 'value': value, + if (instance.description case final value?) 'description': value, + if (instance.disabled case final value?) 'disabled': value, + }; + +_$HeaderImpl _$$HeaderImplFromJson(Map json) => _$HeaderImpl( + name: json['name'] as String?, + value: json['value'] as String?, + disabled: json['disabled'] as bool?, + ); + +Map _$$HeaderImplToJson(_$HeaderImpl instance) => + { + if (instance.name case final value?) 'name': value, + if (instance.value case final value?) 'value': value, + if (instance.disabled case final value?) 'disabled': value, + }; + +_$CookieImpl _$$CookieImplFromJson(Map json) => _$CookieImpl( + key: json['key'] as String?, + value: json['value'] as String?, + domain: json['domain'] as String?, + path: json['path'] as String?, + secure: json['secure'] as bool?, + httpOnly: json['httpOnly'] as bool?, + hostOnly: json['hostOnly'] as bool?, + creation: json['creation'] == null + ? null + : DateTime.parse(json['creation'] as String), + lastAccessed: json['lastAccessed'] == null + ? null + : DateTime.parse(json['lastAccessed'] as String), + sameSite: json['sameSite'] as String?, + id: json['id'] as String?, + ); + +Map _$$CookieImplToJson(_$CookieImpl instance) => + { + if (instance.key case final value?) 'key': value, + if (instance.value case final value?) 'value': value, + if (instance.domain case final value?) 'domain': value, + if (instance.path case final value?) 'path': value, + if (instance.secure case final value?) 'secure': value, + if (instance.httpOnly case final value?) 'httpOnly': value, + if (instance.hostOnly case final value?) 'hostOnly': value, + if (instance.creation?.toIso8601String() case final value?) + 'creation': value, + if (instance.lastAccessed?.toIso8601String() case final value?) + 'lastAccessed': value, + if (instance.sameSite case final value?) 'sameSite': value, + if (instance.id case final value?) 'id': value, + }; + +_$KVPairDatumImpl _$$KVPairDatumImplFromJson(Map json) => _$KVPairDatumImpl( + id: json['id'] as String?, + name: json['name'] as String?, + value: json['value'] as String?, + type: json['type'] as String?, + enabled: json['enabled'] as bool?, + ); + +Map _$$KVPairDatumImplToJson(_$KVPairDatumImpl instance) => + { + if (instance.id case final value?) 'id': value, + if (instance.name case final value?) 'name': value, + if (instance.value case final value?) 'value': value, + if (instance.type case final value?) 'type': value, + if (instance.enabled case final value?) 'enabled': value, + }; diff --git a/packages/insomnia_collection/lib/models/insomnia_item.dart b/packages/insomnia_collection/lib/models/insomnia_item.dart new file mode 100644 index 00000000..c906baf9 --- /dev/null +++ b/packages/insomnia_collection/lib/models/insomnia_item.dart @@ -0,0 +1,102 @@ +import 'insomnia_collection.dart'; + +enum ResourceType { + workspace, + environment, + request_group, + cookie_jar, + request, + websocket_payload, + api_spec +} + +class InsomniaItem { + const InsomniaItem({ + this.id, + this.type, + this.resource, + this.children, + }); + + final String? id; + final ResourceType? type; + final Resource? resource; + final List? children; + + factory InsomniaItem.fromInsomniaCollection( + InsomniaCollection? collection, + ) { + if (collection?.resources == null) { + return InsomniaItem(); + } + final resources = collection!.resources!; + final resourceMap = {for (var v in resources) v.id!: v}; + Map> childrenMap = {}; + for (var item in resources) { + if (item.parentId != null && item.id != null) { + if (childrenMap.containsKey(item.parentId)) { + childrenMap[item.parentId]!.add(item.id!); + } else { + childrenMap[item.parentId!] = [item.id!]; + } + } + } + var wksp; + for (var item in resources) { + if (item.type == ResourceType.workspace.name) { + wksp = InsomniaItem( + id: item.id, + type: ResourceType.workspace, + resource: item, + children: getInsomniaItemChildren( + childrenMap[item.id], + childrenMap, + resourceMap, + ), + ); + break; + } + } + return wksp; + } +} + +List? getInsomniaItemChildren( + List? ids, + Map> childrenMap, + Map resourceMap, +) { + if (ids == null) { + return null; + } + List children = []; + for (var itemId in ids) { + var resource = resourceMap[itemId]; + ResourceType? type; + try { + type = ResourceType.values.byName(resource?.type ?? ''); + } catch (e) { + type = null; + } + if (childrenMap.containsKey(itemId)) { + children.add(InsomniaItem( + id: itemId, + type: type, + resource: resource, + children: getInsomniaItemChildren( + childrenMap[itemId], + childrenMap, + resourceMap, + ), + )); + } else { + children.add(InsomniaItem( + id: itemId, + type: type, + resource: resource, + children: null, + )); + } + } + return children; +} diff --git a/packages/insomnia_collection/lib/models/models.dart b/packages/insomnia_collection/lib/models/models.dart new file mode 100644 index 00000000..12e1aa42 --- /dev/null +++ b/packages/insomnia_collection/lib/models/models.dart @@ -0,0 +1,2 @@ +export 'insomnia_collection.dart'; +export 'insomnia_item.dart'; diff --git a/packages/insomnia_collection/lib/utils/insomnia_utils.dart b/packages/insomnia_collection/lib/utils/insomnia_utils.dart new file mode 100644 index 00000000..9d4aa7eb --- /dev/null +++ b/packages/insomnia_collection/lib/utils/insomnia_utils.dart @@ -0,0 +1,25 @@ +import '../models/models.dart'; + +List<(String?, Resource)> getRequestsFromInsomniaCollection( + InsomniaCollection? ic) => + getItemByTypeFromInsomniaCollection(ic, ResourceType.request.name); + +List<(String?, Resource)> getEnvironmentsFromInsomniaCollection( + InsomniaCollection? ic) => + getItemByTypeFromInsomniaCollection(ic, ResourceType.environment.name); + +List<(String?, Resource)> getItemByTypeFromInsomniaCollection( + InsomniaCollection? ic, + String type, +) { + if (ic?.resources == null || ic!.resources!.length == 0) { + return []; + } + List<(String?, Resource)> requests = []; + for (var item in ic.resources!) { + if (item.type != null && item.type == type) { + requests.add((item.name, item)); + } + } + return requests; +} diff --git a/packages/insomnia_collection/pubspec.yaml b/packages/insomnia_collection/pubspec.yaml new file mode 100644 index 00000000..66f89b28 --- /dev/null +++ b/packages/insomnia_collection/pubspec.yaml @@ -0,0 +1,25 @@ +name: insomnia_collection +description: Seamlessly convert Insomnia Collection Format v4 to Dart. +version: 0.0.1 +homepage: https://github.com/foss42/apidash + +topics: + - insomnia + - api + - rest + - http + - network + +environment: + sdk: ">=3.0.0 <4.0.0" + +dependencies: + freezed_annotation: ^2.4.4 + json_annotation: ^4.9.0 + +dev_dependencies: + build_runner: ^2.4.12 + freezed: ^2.5.7 + json_serializable: ^6.7.1 + lints: ^4.0.0 + test: ^1.24.0 diff --git a/packages/insomnia_collection/test/collection_examples/collection_apidash.dart b/packages/insomnia_collection/test/collection_examples/collection_apidash.dart new file mode 100644 index 00000000..7c836e30 --- /dev/null +++ b/packages/insomnia_collection/test/collection_examples/collection_apidash.dart @@ -0,0 +1,353 @@ +var collectionApiDashJsonStr = r'''{ + "_type": "export", + "__export_format": 4, + "__export_date": "2025-01-05T13:05:11.752Z", + "__export_source": "insomnia.desktop.app:v10.3.0", + "resources": [ + { + "_id": "req_15f4d64ca3084a92a0680e29a958c9da", + "parentId": "fld_a2e9704c49034e36a05cdb3a233f6ebd", + "modified": 1736112258432, + "created": 1736111908438, + "url": "https://food-service-backend.onrender.com/api/users/", + "name": "get-with-params", + "description": "", + "method": "GET", + "body": {}, + "parameters": [ + { + "id": "pair_bf0ae4f4280e440a8a591b64fd4ec4f4", + "name": "user_id", + "value": "34", + "description": "", + "disabled": false + } + ], + "headers": [ + { + "name": "User-Agent", + "value": "insomnia/10.3.0" + } + ], + "authentication": {}, + "metaSortKey": -1736111908438, + "isPrivate": false, + "pathParameters": [], + "settingStoreCookies": true, + "settingSendCookies": true, + "settingDisableRenderRequestBody": false, + "settingEncodeUrl": true, + "settingRebuildPath": true, + "settingFollowRedirects": "global", + "_type": "request" + }, + { + "_id": "fld_a2e9704c49034e36a05cdb3a233f6ebd", + "parentId": "wrk_fde7dcc4f5064b74b0fd749cbf8f684a", + "modified": 1736082089076, + "created": 1736082089076, + "name": "APIDash-APItests", + "description": "These are test endpoints for API Dash", + "authentication": {}, + "metaSortKey": -1736082080559, + "isPrivate": false, + "afterResponseScript": "", + "environment": {}, + "_type": "request_group" + }, + { + "_id": "wrk_fde7dcc4f5064b74b0fd749cbf8f684a", + "modified": 1736082089075, + "created": 1736082089075, + "name": "APIDash-APItests", + "description": "", + "scope": "collection", + "_type": "workspace" + }, + { + "_id": "req_db3c393084f14369bb409afe857e390c", + "parentId": "fld_a2e9704c49034e36a05cdb3a233f6ebd", + "modified": 1736082089077, + "created": 1736082089077, + "url": "https://api.apidash.dev/country/codes", + "name": "test-get", + "description": "", + "method": "GET", + "body": {}, + "preRequestScript": "", + "parameters": [], + "headers": [], + "authentication": {}, + "metaSortKey": -1736082080558, + "isPrivate": false, + "afterResponseScript": "", + "settingStoreCookies": true, + "settingSendCookies": true, + "settingDisableRenderRequestBody": false, + "settingEncodeUrl": true, + "settingRebuildPath": true, + "settingFollowRedirects": "global", + "_type": "request" + }, + { + "_id": "req_ba718bbacd094e95a30ef3f07baa4e42", + "parentId": "fld_a2e9704c49034e36a05cdb3a233f6ebd", + "modified": 1736082089078, + "created": 1736082089078, + "url": "https://api.apidash.dev/case/lower", + "name": "test-post", + "description": "", + "method": "POST", + "body": { + "mimeType": "application/json", + "text": "{\n \"text\": \"Grass is green\"\n}" + }, + "preRequestScript": "", + "parameters": [], + "headers": [ + { + "name": "Content-Type", + "value": "application/json" + } + ], + "authentication": {}, + "metaSortKey": -1736082080557, + "isPrivate": false, + "afterResponseScript": "", + "settingStoreCookies": true, + "settingSendCookies": true, + "settingDisableRenderRequestBody": false, + "settingEncodeUrl": true, + "settingRebuildPath": true, + "settingFollowRedirects": "global", + "_type": "request" + }, + { + "_id": "req_24cff90fc3c74e71a567f61d3f8e8cc1", + "parentId": "fld_a2e9704c49034e36a05cdb3a233f6ebd", + "modified": 1736082089078, + "created": 1736082089078, + "url": "https://reqres.in/api/users/2", + "name": "test-put", + "description": "", + "method": "PUT", + "body": { + "mimeType": "application/json", + "text": "{\n \"name\": \"morpheus\",\n \"job\": \"zion resident\"\n}" + }, + "preRequestScript": "", + "parameters": [], + "headers": [ + { + "name": "Content-Type", + "value": "application/json" + } + ], + "authentication": {}, + "metaSortKey": -1736082080556, + "isPrivate": false, + "afterResponseScript": "", + "settingStoreCookies": true, + "settingSendCookies": true, + "settingDisableRenderRequestBody": false, + "settingEncodeUrl": true, + "settingRebuildPath": true, + "settingFollowRedirects": "global", + "_type": "request" + }, + { + "_id": "env_9d818b2866dffc9831640d91a516ea3986e16bda", + "parentId": "wrk_fde7dcc4f5064b74b0fd749cbf8f684a", + "modified": 1736082095630, + "created": 1736082095630, + "name": "Base Environment", + "metaSortKey": 1736082095630, + "isPrivate": false, + "data": {}, + "environmentType": "kv", + "_type": "environment" + }, + { + "_id": "jar_9d818b2866dffc9831640d91a516ea3986e16bda", + "parentId": "wrk_fde7dcc4f5064b74b0fd749cbf8f684a", + "modified": 1736082095688, + "created": 1736082095688, + "name": "Default Jar", + "cookies": [], + "_type": "cookie_jar" + } + ] +}'''; + +var collectionApiDashJson = { + "_type": "export", + "__export_format": 4, + "__export_date": "2025-01-05T13:05:11.752Z", + "__export_source": "insomnia.desktop.app:v10.3.0", + "resources": [ + { + "_id": "req_15f4d64ca3084a92a0680e29a958c9da", + "parentId": "fld_a2e9704c49034e36a05cdb3a233f6ebd", + "modified": 1736112258432, + "created": 1736111908438, + "url": "https://food-service-backend.onrender.com/api/users/", + "name": "get-with-params", + "description": "", + "method": "GET", + "body": {}, + "parameters": [ + { + "id": "pair_bf0ae4f4280e440a8a591b64fd4ec4f4", + "name": "user_id", + "value": "34", + "description": "", + "disabled": false + } + ], + "headers": [ + {"name": "User-Agent", "value": "insomnia/10.3.0"} + ], + "authentication": {}, + "metaSortKey": -1736111908438, + "isPrivate": false, + "pathParameters": [], + "settingStoreCookies": true, + "settingSendCookies": true, + "settingDisableRenderRequestBody": false, + "settingEncodeUrl": true, + "settingRebuildPath": true, + "settingFollowRedirects": "global", + "_type": "request" + }, + { + "_id": "fld_a2e9704c49034e36a05cdb3a233f6ebd", + "parentId": "wrk_fde7dcc4f5064b74b0fd749cbf8f684a", + "modified": 1736082089076, + "created": 1736082089076, + "name": "APIDash-APItests", + "description": "These are test endpoints for API Dash", + "authentication": {}, + "metaSortKey": -1736082080559, + "isPrivate": false, + "afterResponseScript": "", + "environment": {}, + "_type": "request_group" + }, + { + "_id": "wrk_fde7dcc4f5064b74b0fd749cbf8f684a", + "modified": 1736082089075, + "created": 1736082089075, + "name": "APIDash-APItests", + "description": "", + "scope": "collection", + "_type": "workspace" + }, + { + "_id": "req_db3c393084f14369bb409afe857e390c", + "parentId": "fld_a2e9704c49034e36a05cdb3a233f6ebd", + "modified": 1736082089077, + "created": 1736082089077, + "url": "https://api.apidash.dev/country/codes", + "name": "test-get", + "description": "", + "method": "GET", + "body": {}, + "preRequestScript": "", + "parameters": [], + "headers": [], + "authentication": {}, + "metaSortKey": -1736082080558, + "isPrivate": false, + "afterResponseScript": "", + "settingStoreCookies": true, + "settingSendCookies": true, + "settingDisableRenderRequestBody": false, + "settingEncodeUrl": true, + "settingRebuildPath": true, + "settingFollowRedirects": "global", + "_type": "request" + }, + { + "_id": "req_ba718bbacd094e95a30ef3f07baa4e42", + "parentId": "fld_a2e9704c49034e36a05cdb3a233f6ebd", + "modified": 1736082089078, + "created": 1736082089078, + "url": "https://api.apidash.dev/case/lower", + "name": "test-post", + "description": "", + "method": "POST", + "body": { + "mimeType": "application/json", + "text": "{\n \"text\": \"Grass is green\"\n}" + }, + "preRequestScript": "", + "parameters": [], + "headers": [ + {"name": "Content-Type", "value": "application/json"} + ], + "authentication": {}, + "metaSortKey": -1736082080557, + "isPrivate": false, + "afterResponseScript": "", + "settingStoreCookies": true, + "settingSendCookies": true, + "settingDisableRenderRequestBody": false, + "settingEncodeUrl": true, + "settingRebuildPath": true, + "settingFollowRedirects": "global", + "_type": "request" + }, + { + "_id": "req_24cff90fc3c74e71a567f61d3f8e8cc1", + "parentId": "fld_a2e9704c49034e36a05cdb3a233f6ebd", + "modified": 1736082089078, + "created": 1736082089078, + "url": "https://reqres.in/api/users/2", + "name": "test-put", + "description": "", + "method": "PUT", + "body": { + "mimeType": "application/json", + "text": + "{\n \"name\": \"morpheus\",\n \"job\": \"zion resident\"\n}" + }, + "preRequestScript": "", + "parameters": [], + "headers": [ + {"name": "Content-Type", "value": "application/json"} + ], + "authentication": {}, + "metaSortKey": -1736082080556, + "isPrivate": false, + "afterResponseScript": "", + "settingStoreCookies": true, + "settingSendCookies": true, + "settingDisableRenderRequestBody": false, + "settingEncodeUrl": true, + "settingRebuildPath": true, + "settingFollowRedirects": "global", + "_type": "request" + }, + { + "_id": "env_9d818b2866dffc9831640d91a516ea3986e16bda", + "parentId": "wrk_fde7dcc4f5064b74b0fd749cbf8f684a", + "modified": 1736082095630, + "created": 1736082095630, + "name": "Base Environment", + "metaSortKey": 1736082095630, + "isPrivate": false, + "data": {}, + "environmentType": "kv", + "_type": "environment" + }, + { + "_id": "jar_9d818b2866dffc9831640d91a516ea3986e16bda", + "parentId": "wrk_fde7dcc4f5064b74b0fd749cbf8f684a", + "modified": 1736082095688, + "created": 1736082095688, + "name": "Default Jar", + "cookies": [], + "_type": "cookie_jar" + } + ] +}; diff --git a/packages/insomnia_collection/test/insomnia_test.dart b/packages/insomnia_collection/test/insomnia_test.dart new file mode 100644 index 00000000..41bf8e14 --- /dev/null +++ b/packages/insomnia_collection/test/insomnia_test.dart @@ -0,0 +1,29 @@ +import 'package:insomnia_collection/insomnia_collection.dart'; +import 'collection_examples/collection_apidash.dart'; +import 'models/collection_apidash_model.dart'; +import 'package:test/test.dart'; + +void main() { + group('Insomnia tests', () { + test('Insomnia collection from Json String', () { + expect( + insomniaCollectionFromJsonStr(collectionApiDashJsonStr), + collectionApiDashModel, + ); + }); + + test('Insomnia collection from Json', () { + expect( + InsomniaCollection.fromJson(collectionApiDashJson), + collectionApiDashModel, + ); + }); + + test('Insomnia collection to Json String', () { + expect( + insomniaCollectionToJsonStr(collectionApiDashModel), + collectionApiDashJsonStr, + ); + }); + }); +} diff --git a/packages/insomnia_collection/test/models/collection_apidash_model.dart b/packages/insomnia_collection/test/models/collection_apidash_model.dart new file mode 100644 index 00000000..6b931b07 --- /dev/null +++ b/packages/insomnia_collection/test/models/collection_apidash_model.dart @@ -0,0 +1,186 @@ +import 'package:insomnia_collection/models/models.dart'; + +var collectionApiDashModel = InsomniaCollection( + type: "export", + exportFormat: 4, + exportDate: "2025-01-05T13:05:11.752Z", + exportSource: "insomnia.desktop.app:v10.3.0", + resources: [ + Resource( + id: "req_15f4d64ca3084a92a0680e29a958c9da", + parentId: "fld_a2e9704c49034e36a05cdb3a233f6ebd", + modified: 1736112258432, + created: 1736111908438, + url: "https://food-service-backend.onrender.com/api/users/", + name: "get-with-params", + description: "", + method: "GET", + body: Body(), + parameters: [ + Parameter( + id: "pair_bf0ae4f4280e440a8a591b64fd4ec4f4", + name: "user_id", + value: "34", + description: "", + disabled: false, + ) + ], + headers: [ + Header( + name: "User-Agent", + value: "insomnia/10.3.0", + ) + ], + authentication: {}, + metaSortKey: -1736111908438, + isPrivate: false, + pathParameters: [], + afterResponseScript: null, + settingSendCookies: true, + settingStoreCookies: true, + settingDisableRenderRequestBody: false, + settingEncodeUrl: true, + settingRebuildPath: true, + settingFollowRedirects: "global", + type: "request", + ), + Resource( + id: "fld_a2e9704c49034e36a05cdb3a233f6ebd", + parentId: "wrk_fde7dcc4f5064b74b0fd749cbf8f684a", + modified: 1736082089076, + created: 1736082089076, + name: "APIDash-APItests", + description: "These are test endpoints for API Dash", + environment: {}, + environmentPropertyOrder: null, + metaSortKey: -1736082080559, + isPrivate: false, + afterResponseScript: "", + authentication: {}, + type: "request_group", + ), + Resource( + id: "wrk_fde7dcc4f5064b74b0fd749cbf8f684a", + parentId: null, + modified: 1736082089075, + created: 1736082089075, + name: "APIDash-APItests", + description: "", + scope: "collection", + type: "workspace", + ), + Resource( + id: "req_db3c393084f14369bb409afe857e390c", + parentId: "fld_a2e9704c49034e36a05cdb3a233f6ebd", + modified: 1736082089077, + created: 1736082089077, + url: "https://api.apidash.dev/country/codes", + name: "test-get", + description: "", + method: "GET", + body: Body(), + parameters: [], + headers: [], + preRequestScript: "", + authentication: {}, + metaSortKey: -1736082080558, + isPrivate: false, + afterResponseScript: "", + settingSendCookies: true, + settingStoreCookies: true, + settingDisableRenderRequestBody: false, + settingEncodeUrl: true, + settingRebuildPath: true, + settingFollowRedirects: "global", + type: "request", + ), + Resource( + id: "req_ba718bbacd094e95a30ef3f07baa4e42", + parentId: "fld_a2e9704c49034e36a05cdb3a233f6ebd", + modified: 1736082089078, + created: 1736082089078, + url: "https://api.apidash.dev/case/lower", + name: "test-post", + description: "", + method: "POST", + body: Body( + mimeType: "application/json", + text: "{\n \"text\": \"Grass is green\"\n}", + ), + parameters: [], + headers: [ + Header( + name: "Content-Type", + value: "application/json", + ) + ], + preRequestScript: "", + authentication: {}, + metaSortKey: -1736082080557, + isPrivate: false, + afterResponseScript: "", + settingSendCookies: true, + settingStoreCookies: true, + settingDisableRenderRequestBody: false, + settingEncodeUrl: true, + settingRebuildPath: true, + settingFollowRedirects: "global", + type: "request", + ), + Resource( + id: "req_24cff90fc3c74e71a567f61d3f8e8cc1", + parentId: "fld_a2e9704c49034e36a05cdb3a233f6ebd", + modified: 1736082089078, + created: 1736082089078, + url: "https://reqres.in/api/users/2", + name: "test-put", + description: "", + method: "PUT", + body: Body( + mimeType: "application/json", + text: + "{\n \"name\": \"morpheus\",\n \"job\": \"zion resident\"\n}"), + parameters: [], + headers: [ + Header( + name: "Content-Type", + value: "application/json", + ) + ], + preRequestScript: "", + authentication: {}, + metaSortKey: -1736082080556, + isPrivate: false, + afterResponseScript: "", + settingSendCookies: true, + settingStoreCookies: true, + settingDisableRenderRequestBody: false, + settingEncodeUrl: true, + settingRebuildPath: true, + settingFollowRedirects: "global", + type: "request", + ), + Resource( + id: "env_9d818b2866dffc9831640d91a516ea3986e16bda", + parentId: "wrk_fde7dcc4f5064b74b0fd749cbf8f684a", + modified: 1736082095630, + created: 1736082095630, + name: "Base Environment", + data: {}, + dataPropertyOrder: null, + color: null, + isPrivate: false, + metaSortKey: 1736082095630, + environmentType: "kv", + type: "environment", + ), + Resource( + id: "jar_9d818b2866dffc9831640d91a516ea3986e16bda", + parentId: "wrk_fde7dcc4f5064b74b0fd749cbf8f684a", + modified: 1736082095688, + created: 1736082095688, + name: "Default Jar", + cookies: [], + type: "cookie_jar", + ), + ]); diff --git a/pubspec.lock b/pubspec.lock index 392861f6..f23349b0 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -779,7 +779,14 @@ packages: sha256: "13d3349ace88f12f4a0d175eb5c12dcdd39d35c4c109a8a13dfeb6d0bd9e31c3" url: "https://pub.dev" source: hosted - version: "4.5.3" + version: "4.3.0" + insomnia_collection: + dependency: transitive + description: + path: "packages/insomnia_collection" + relative: true + source: path + version: "0.0.1" integration_test: dependency: "direct dev" description: flutter diff --git a/test/models/environment_models.dart b/test/models/environment_models.dart index 66d61eb3..e23f659b 100644 --- a/test/models/environment_models.dart +++ b/test/models/environment_models.dart @@ -1,9 +1,5 @@ import 'package:apidash/consts.dart'; -import 'package:apidash/models/models.dart' - show - EnvironmentModel, - EnvironmentVariableModel, - EnvironmentVariableSuggestion; +import 'package:apidash_core/apidash_core.dart'; /// Global environment model const globalEnvironment = EnvironmentModel( diff --git a/test/models/environment_models_test.dart b/test/models/environment_models_test.dart index 8664b164..f4ab1e31 100644 --- a/test/models/environment_models_test.dart +++ b/test/models/environment_models_test.dart @@ -1,6 +1,5 @@ +import 'package:apidash_core/apidash_core.dart'; import 'package:test/test.dart'; -import 'package:apidash/models/models.dart'; -import 'package:apidash/consts.dart'; import 'environment_models.dart'; diff --git a/test/screens/common_widgets/env_trigger_options_test.dart b/test/screens/common_widgets/env_trigger_options_test.dart index 0bbe5bf4..8856e6b8 100644 --- a/test/screens/common_widgets/env_trigger_options_test.dart +++ b/test/screens/common_widgets/env_trigger_options_test.dart @@ -1,7 +1,7 @@ +import 'package:apidash_core/apidash_core.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; -import 'package:apidash/models/models.dart'; import 'package:apidash/providers/providers.dart'; import 'package:apidash/consts.dart'; import 'package:apidash/screens/common_widgets/env_trigger_options.dart'; diff --git a/test/screens/common_widgets/envvar_indicator_test.dart b/test/screens/common_widgets/envvar_indicator_test.dart index 9dc9bdc6..effddb8b 100644 --- a/test/screens/common_widgets/envvar_indicator_test.dart +++ b/test/screens/common_widgets/envvar_indicator_test.dart @@ -1,7 +1,7 @@ +import 'package:apidash_core/apidash_core.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:apidash/consts.dart'; -import 'package:apidash/models/models.dart'; import 'package:apidash/screens/common_widgets/envvar_indicator.dart'; void main() { diff --git a/test/screens/common_widgets/envvar_popover_test.dart b/test/screens/common_widgets/envvar_popover_test.dart index d1eb268f..5a47257d 100644 --- a/test/screens/common_widgets/envvar_popover_test.dart +++ b/test/screens/common_widgets/envvar_popover_test.dart @@ -1,6 +1,6 @@ +import 'package:apidash_core/apidash_core.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:apidash/models/models.dart'; import 'package:apidash/screens/common_widgets/envvar_indicator.dart'; import 'package:apidash/screens/common_widgets/envvar_popover.dart'; diff --git a/test/utils/envvar_utils_test.dart b/test/utils/envvar_utils_test.dart index a6c9ee03..6e2dfa55 100644 --- a/test/utils/envvar_utils_test.dart +++ b/test/utils/envvar_utils_test.dart @@ -1,4 +1,3 @@ -import 'package:apidash/models/models.dart'; import 'package:apidash/utils/envvar_utils.dart'; import 'package:apidash/consts.dart'; import 'package:apidash_core/apidash_core.dart'; @@ -211,10 +210,12 @@ void main() { NameValueModel(name: "num", value: "{{num}}"), ], ); + Map> envMap = { kGlobalEnvironmentId: globalVars, "activeEnvId": activeEnvVars, }; + String? activeEnvironmentId = "activeEnvId"; const expected = HttpRequestModel( url: "api.apidash.dev/humanize/social", @@ -227,7 +228,10 @@ void main() { ); expect( substituteHttpRequestModel( - httpRequestModel, envMap, activeEnvironmentId), + httpRequestModel, + envMap, + activeEnvironmentId, + ), expected); }); @@ -260,6 +264,40 @@ void main() { httpRequestModel, envMap, activeEnvironmentId), expected); }); + + test( + "Testing substituteHttpRequestModel with environment variables in body", + () { + const httpRequestModel = HttpRequestModel( + url: "{{url}}/humanize/social", + headers: [ + NameValueModel(name: "Authorization", value: "Bearer {{token}}"), + ], + params: [ + NameValueModel(name: "num", value: "{{num}}"), + ], + body: "The API key is {{token}} and the number is {{num}}", + ); + Map> envMap = { + kGlobalEnvironmentId: globalVars, + "activeEnvId": activeEnvVars, + }; + String? activeEnvironmentId = "activeEnvId"; + const expected = HttpRequestModel( + url: "api.apidash.dev/humanize/social", + headers: [ + NameValueModel(name: "Authorization", value: "Bearer token"), + ], + params: [ + NameValueModel(name: "num", value: "8940000"), + ], + body: "The API key is token and the number is 8940000", + ); + expect( + substituteHttpRequestModel( + httpRequestModel, envMap, activeEnvironmentId), + expected); + }); }); group("Testing getEnvironmentTriggerSuggestions function", () { diff --git a/test/widgets/popup_menu_env_test.dart b/test/widgets/popup_menu_env_test.dart index 4c11df39..66672d3c 100644 --- a/test/widgets/popup_menu_env_test.dart +++ b/test/widgets/popup_menu_env_test.dart @@ -1,7 +1,7 @@ import 'package:apidash/consts.dart'; +import 'package:apidash_core/apidash_core.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:apidash/models/models.dart'; import 'package:apidash/widgets/popup_menu_env.dart'; void main() {