Git Product home page Git Product logo

dev-proxy-toolkit's Introduction

Dev Proxy Toolkit

Dev Proxy is an API simulator that helps you effortlessly test your app beyond the happy path.

The Dev Proxy Toolkit extension for Visual Studio Code makes it easy to create and update configuration files.

IMPORTANT

Dev Proxy Toolkit is designed to be used with the latest version of Dev Proxy, v0.19.1. If you are using an earlier build some features may not work as intended.

Features

The following sections describe the features that the extension contributes to Visual Studio Code when installed

Diagnostics

  • Check for missing configSection property in plugin instance for plugins that require configuration
  • Check for missing configSection when defined in plugin instance
  • Check that schema matches installed version of Dev Proxy
  • Check that reporters are placed after plugins

Code Actions

  • Update schema to match installed version of Dev Proxy

Code Lenses

  • Plugin documentation link

Notifications

  • Not installed
  • New version detection

Status Bar

  • Display installed Dev Proxy version
  • Display waring when Dev Proxy is not latest version
  • Display tick if Dev Proxy is latest version (check based on newVersionNotification config setting)
  • Display radio tower when Dev Proxy is running
  • Display error is Dev Proxy is not installed

Settings

  • devproxytoolkit.versionPreference - Determines the version to use when Dev Proxy and Dev Proxy Beta are installed side by side. Can be stable (default) or beta.

Snippets

Prefix Description
devproxy-config-file Dev Proxy config file
devproxy-config-file-schema Dev Proxy config file schema
devproxy-mocks-file Dev Proxy mocks file
devproxy-mocks-file-schema Dev Proxy mocks file schema
devproxy-mock Dev Proxy mock
devproxy-request Dev Proxy request
devproxy-response Dev Proxy response
devproxy-response-header Dev Proxy response header
devproxy-plugin-api-center-minimal-permissions ApiCenterMinimalPermissionsPlugin instance
devproxy-plugin-api-center-minimal-permissions-config ApiCenterMinimalPermissionsPlugin config section
devproxy-plugin-api-center-onboarding ApiCenterOnboardingPlugin instance
devproxy-plugin-api-center-onboarding-config ApiCenterOnboardingPlugin config section
devproxy-plugin-api-center-production-version ApiCenterProductionVersionPlugin instance
devproxy-plugin-api-center-production-version-config ApiCenterProductionVersionPlugin config section
devproxy-plugin-caching-guidance CachingGuidancePlugin instance
devproxy-plugin-caching-guidance-config CachingGuidancePlugin config section
devproxy-plugin-crud-api CrudApiPlugin instance
devproxy-plugin-crud-api-config CrudApiPlugin config section
devproxy-plugin-crud-api-file CrudApiPlugin API file
devproxy-plugin-crud-api-file-schema CrudApiPlugin API file schema
devproxy-plugin-crud-api-action CrudApiPlugin action
devproxy-plugin-dev-tools DevToolsPlugin instance
devproxy-plugin-dev-tools-config DevToolsPlugin config section
devproxy-plugin-entra-mock-response EntraMockResponsePlugin instance
devproxy-plugin-entra-mock-response-config EntraMockResponsePlugin config section
devproxy-plugin-execution-summary ExecutionSummaryPlugin instance
devproxy-plugin-execution-summary-config ExecutionSummaryPlugin config section
devproxy-plugin-generic-random-error GenericRandomErrorPlugin instance
devproxy-plugin-generic-random-error-config GenericRandomErrorPlugin config section
devproxy-plugin-generic-random-error-file GenericRandomErrorPlugin errors file
devproxy-plugin-generic-random-error-file-schema GenericRandomErrorPlugin errors file schema
devproxy-plugin-graph-beta-support-guidance GraphBetaSupportGuidancePlugin instance
devproxy-plugin-graph-client-request-id-guidance GraphClientRequestIdGuidancePlugin instance
devproxy-plugin-graph-mock-response GraphMockResponsePlugin instance
devproxy-plugin-graph-mock-response-config GraphMockResponsePlugin config section
devproxy-plugin-graph-random-error GraphRandomErrorPlugin instance
devproxy-plugin-graph-random-error-config GraphRandomErrorPlugin config section
devproxy-plugin-graph-sdk-guidance GraphSdkGuidancePlugin instance
devproxy-plugin-graph-select-guidance GraphSdkGuidancePlugin instance
devproxy-plugin-http-file-generator HttpFileGeneratorPlugin instance
devproxy-plugin-http-file-generator-config HttpFileGeneratorPlugin config section
devproxy-plugin-latency LatencyPlugin instance
devproxy-plugin-latency-config LatencyPlugin config section
devproxy-plugin-graph-minimal-permissions-guidance MinimalPermissionsGuidancePlugin instance
devproxy-plugin-graph-minimal-permissions MinimalPermissionsPlugin instance
devproxy-plugin-mock-generator MockGeneratorPlugin instance
devproxy-plugin-mock-request MockResponsePlugin instance
devproxy-plugin-mock-request-config MockResponsePlugin config section
devproxy-plugin-mock-response MockResponsePlugin instance
devproxy-plugin-mock-response-config MockResponsePlugin config section
devproxy-plugin-mock-response-schema MockResponsePlugin schema
devproxy-plugin-odata-paging-guidance ODataPagingGuidancePlugin instance
devproxy-plugin-graph-odsp-search-guidance ODSPSearchGuidancePlugin instance
devproxy-plugin-openai-mock-response OpenAIMockResponsePlugin instance
devproxy-plugin-open-api-spec-generator OpenApiSpecGeneratorPlugin instance
devproxy-plugin-rate-limiting MockResponsePlugin instance
devproxy-plugin-rate-limiting-config RateLimitingPlugin config section
devproxy-plugin-rate-limiting-file Dev Proxy rate limiting file
devproxy-plugin-rate-limiting-file-schema Dev Proxy rate limiting file schema
devproxy-plugin-retry-after RetryAfterPlugin instance
devproxy-reporter-json JsonReporter instance
devproxy-reporter-markdown MarkdownReporter instance
devproxy-reporter-plain-text PlainTextReporter instance

dev-proxy-toolkit's People

Contributors

garrytrinder avatar waldekmastykarz avatar

Stargazers

Marco M. von Hagen avatar  avatar  avatar

Watchers

 avatar

dev-proxy-toolkit's Issues

Detect config file in project

We should add a check to detect whether there is a file in the current workspace that resembles an rc file. If a file doesn't exist we can suggest to the developer to create one and help with that.

Detect if schema version matches installed version

After #38 is implemented, we should detect if the version used in the schema matches the installed version of proxy.

If the version does not match, we should suggest the correct version and provide a code action to make this a one click operation.

Expand objects and arrays in snippets

Raised from #29

Update the following snippets

  • devproxy-config-file
  • devproxy-request
  • devproxy-response
  • devproxy-plugin-crud-api-file
  • devproxy-plugin-generic-random-error-file
  • devproxy-plugin-rate-limiting-file

Improve snippets behavior

some snippets could provide even more help and handy behavior for the user.

for example the snippet devproxy-plugin-crud-api-action creates the following part of json

   {
        "action": "",
        "method": "",
        "query": "",
        "url": ""
    }

but in a way the user works doesn't stop there. the user will need to still go over each property and fill it.
I was thinking we could improve that adding tabstops/placeholders to some snippets (like this one). You may do that by adding the $1 $2 etc to your snippet definition.
https://code.visualstudio.com/docs/editor/userdefinedsnippets#_tabstops

as an example the CLI for Microsoft 365 VS Code extension uses tab stops in every snippets that have some required option that needs to be set. That way after the snippet code is added the user may use tab to move between next options. Like this

snippets.mp4

Create example versions of the file snippets

We currently ship file snippets but they just provide the basic shape. We should create snippets that are more like examples, so we can show how a completed file would look like, the developers can remove and edit to their own needs.

Detect if proxy is installed

We should check to see if proxy is installed on the local machine.

If proxy is not installed we can suggest to download the version relevant to the current OS.

Schema suggestion

We provide schemas to make it easier for developers to build out their own files, however the schema property is optional.

We should suggest that when a file looks like something related to proxy we should suggest to add the relevant schema to the file for the best experience.

Detect if proxy is running

It would be useful to show the proxy status in VS Code, this could just be a visual indicator at first with no functionality, the Status Bar would be a good place to add this indicator.

https://code.visualstudio.com/api/ux-guidelines/status-bar

We can check for the devproxy process using the following code:

import { exec } from 'child_process';
import { promisify } from 'util';

const execAsync = promisify(exec);

async function isProcessRunning(processName: string): Promise<boolean> {
  const command = process.platform === 'win32' ? 'tasklist' : 'ps aux';
  const { stdout } = await execAsync(command);
  return stdout.includes(processName);
}

async function checkProcess() {
  const isRunning = await isProcessRunning('devproxy');
  console.log(`Is 'devproxy' running? ${isRunning ? 'Yes' : 'No'}`);
}

checkProcess().catch(console.error);

File snippets

Add snippets to create the following files along with snippets for their schema.

  • Config
  • ConfigSchema
  • Errors
  • ErrorsShema
  • Mocks
  • MocksSchema
  • CRUDAPI
  • CRUDAPISchema
  • RateLimiting
  • RateLimitingSchema

some general ideas top of my head

hi ๐Ÿ‘‹
For starters awesome work ๐Ÿคฉ and I am already in love with this extension ๐Ÿ‘.
While playing around with it I have a looooot of ideas and I thought that instead of creating separate issues for each of those and making a mess in the issues list (sorry if I already did ๐Ÿ˜‰๐Ÿ™) I will create this one single issue with all of the ideas I currently have and you may decide on your own which are valuable and which totally are out of scope and make no sense at all ๐Ÿ˜….

  1. validate setup - I was wondering if the extension could have a kind of valdiate devproxy setup VS Code command. So when executed it would check in the user preferable terminal (based on VSCode settings) if devproxy (for example devproxy --help) works and is recognizable. If no the extension could present a notify that your devproxy is not properly setup with a button that when clicked would check if user is on win or mac and what shell and would run the install script for the user like (Invoke-WebRequest https://aka.ms/devproxy/setup.ps1).Content | Invoke-Expression in the console. If yes the extension could also present a notify that you are ready to go. Depending on how far this extension would go if in future it would extend VS code with some UI this command may be 'attached' to any button, like in the extension welcome experience to a button like 'validate your devproxy setup'. To provide an example I would say this could be a similar feature like the viva toolkit validates if the user has correct dependencies installed to start doing SPFx development https://github.com/pnp/vscode-viva/wiki/5.1-Validate-and-set-up-a-local-workspace

  2. samples/presets gallery - I was thinking that the extension could have a command like open samples gallery that would open a dedicated webview in the editor window presenting all the dev proxy samples/presets from the pnp repo https://github.com/pnp/proxy-samples. The user should be able to get quick details about each sample, go to github repo or download it locally to the current workspace with a single click all without leaving VS Code. nowadays it became a quite common feature, for example Teams Toolkit has it's samples gallery, or PnP PS extension or Viva Toolkit as well

  3. add a quick action to run devproxy with a mock - add a editor action to the toolbar visible when someone has a mock json file opened in the editor. The action should allow to run the devproxy command in the console with the currently opened mock.

  4. add a command to start devproxy - this is probably and overkill but I was wondering if it worth having VS Code commands that will start devprox with a specific setting. For example the extension could have a command like run devproxy and record. After running it the extension would ask the user additional questions like "provide file name for the summary report (default empty)" and after that VS Code could run the command devproxy --record --summary-file-path report.md in the user console

  5. add an icon to the status bar that would indicate if the proxy is working or not - this might be tricky as I am not sure how to do that just now ๐Ÿ˜… I would need to do a bit of research ๐Ÿ˜‰.

Ok this is just some ideas I had, I have some other ideas as well but those base on a concept that the VS Code extension would have some UI ๐Ÿค”. I hope this will be of any help

Cheers ๐Ÿ‘

BTW before I will be the person that just adds a lot of feedback and then doesn't provide any help at all ๐Ÿ˜… I am wondering if you consider to be open for contributions? I would love to help out

Some snippets generate invalid JSON

urlsToWatch for Graph plugins are missing a comma at the end of the second to last entry

image

  • GraphClientRequestIdGuidancePlugin
  • GraphMockResponsePlugin
  • GraphRandomErrorPlugin
  • GraphSdkGuidancePlugin
  • GraphSelectGuidancePlugin
  • ODSPSearchGuidancePlugin

Plugins with no config sections have dangling commas after pluginPath

image

  • ODataPagingGuidancePlugin
  • OpenApiDocGeneratorPlugin
  • RetryAfterPlugin

Schema snippets

From @waldekmastykarz

if you start from the snippet, you have it already, but if you have a file already, it's a PITA to figure out the schema URL

Let's create the following snippets for each schema URL

Prefix URL
devproxy-plugin-crudapi-schema https://raw.githubusercontent.com/microsoft/dev-proxy/main/schemas/v1.0/crudapiplugin.schema.json
devproxy-plugin-genericrandomerror-schema https://raw.githubusercontent.com/microsoft/dev-proxy/main/schemas/v1.0/genericrandomerrorplugin.schema.json
devproxy-plugin-mockresponse-schema https://raw.githubusercontent.com/microsoft/dev-proxy/main/schemas/v1.0/mockresponseplugin.schema.json
devproxy-plugin-ratelimiting-schema https://raw.githubusercontent.com/microsoft/dev-proxy/main/schemas/v1.0/ratelimitingplugin.schema.json
devproxy-config-schema https://raw.githubusercontent.com/microsoft/dev-proxy/main/schemas/v1.0/rc.schema.json

Remove `urlsToWatch` diagnostic check

Currently we show an error when the urlsToWatch array is empty, however

  • urlsToWatch is optional
  • urlsToWatch can be defined on a plugin instance

We should update the check so that an error is shown if plugins don't have urlsToWatch set and there is no global array set, or the global array is empty.

Plugin documentation code lens

It is not possible to include markdown in Diagnostics messages which would be the best place to add links to documentation when errors and warnings occur.

As a work around, we should add a code lens action above the name property in the plugin instance which opens the integrated browser in VSCode and displays the reference page for the plugin.

Detect proxy version

Once #37 is implemented, we should obtain the currently installed version.

If the version installed is not the latest, we should suggest upgrading to the latest version.

Introduce a welcome walkthrough experience

In VS Code it is possible to introduce a walkthrough for the user which shows up one time on first startup of the extension just after user installs it from the marketplace, it's also possible to start a walkthrough manually by the user if needed

https://code.visualstudio.com/api/ux-guidelines/walkthroughs

It's a perfect place to introduce additional guide and instructions for the user not only about the vs code extension itself but in this case it could have a step that instructs how to get and download toe proxy with an action button for that, and the references to the guide.

Add quick fix for missing plugin configSections

If we get an error saying that a configSection is missing for a plugin that requires it, we should provide a quick fix to add a default configSection, this will be much easier than adding a configSection using a snippet.

image

Start proxy

Now that we can detect dev proxy installations, we should provide an easy way to start dev proxy from within VS code when a config file is in the active window.

There are a couple of ways we could achieve this

  • Add a code lens to the top of the editor
  • Add a command to the status bar

Either of these approaches should open a visible terminal and start the dev proxy process using the config file. To stop the proxy, users would issue Ctrl + C as normal in the terminal window.

MinimalPrermissionsGuidancePlugin has an optional config section

We treat all plugins the same, if they have accept a configSection we make it mandatory, however the MinimalPrermissionsGuidancePlugin does not require a configSection to work, so we don't need to raise an error for this plugin if a configSection does not exist.

Beta support

From @waldekmastykarz

If you have a beta version installed, you will get a message to update to the latest version.

We should support beta versions, so that this message does not appear, however if you are using an old beta version, we should provide a message to upgrade to the latest beta version.

We should also show the full beta version in the status bar, e.g. v0.15.0-beta.5

image

Indenting is off on `devproxy-mock` snippet

From @waldekmastykarz

image

The snippet has a new line feed and extra tabs, assuming that you don't expand the mocks array before adding the snippet.

As the user behaviour is to automatically expand the array first, then add the mock via the snippet. we should ensure that arrays and objects in the snippets are automatically expanded and remove the new line and extra tabs so indenting is correct.

Update plugins with optional config sections

The following plugins have optional config sections

  • CachingGuidancePlugin
  • DevToolsPlugin
  • ExecutionSummaryPlugin
  • GraphRandomErrorPlugin
  • LatencyPlugin
  • MinimalPermissionsGuidancePlugin
  • MinimalPermissionsPlugin

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.