npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@n1rjal/pm_ts

v0.3.2

Published

A simple tool that transforms Postman files into typescript type files

Downloads

382

Readme

POSTMAN TO TYPESCRIPT

A simple tool built on top of nodejs that scans for all the content of a postman json document and creates interface according to the examples response output, url request query params and url request query body

How to use

First of all, you'll either need to

  • export the postman collection Learn more about it here, or,
  • use remote postman collection, for which you need to have a postman API key and a remote postman collection.
    • To generate your own API key, check docs.
    • To get a remote postman collection, you can either make your workspace public and access your collection remotely, or explore public API network.
      A collection url is in the format of https://www.postman.com/<team>/workspace/<workspace>/collection/<collection-id>.

Then,

  1. Download node version >=16
  2. Git clone the repo:
git clone https://github.com/n1rjal/postman-to-typescript.git
  1. Change the config file eator.json accordingly or you can use the sample type here. The config and index.js file must be in same directory
node index.js

Use npx

npx @n1rjal/pm_ts -i cit-input.json -o types # using input file
npx @n1rjal/pm_ts -X YOUR_API_KEY -U REMOTE_POSTMAN_COLLECTION_URL -o types # using remote postman collection

Command-line Arguments

The script file is most stable for -i and -o flags. Other files may bring unwanted results. And postman form data can perform errors. pm_ts supports the following command-line arguments:

| Argument | Description | | ------------------- | ------------------------------------------------------------------------------------------------------------------- | | -i, --input | The export of postman data as json v2.0 | | -X, --api-key | This specifies your postman API key | | -U, --collection-url| This specifies the remote postman collection url | | -o, --output | The output directory for all types | | -ia, --include-any | This specifies if any must be included in typescript types or not. Default value is false | | -sc, --status-codes | This specifies if we can add type support for response of the types provided. Default value is 200[comma separated] | | -ft, --force-text | This specifies if we need to parse text content in postman request or not. Default value is false | | -te, --throw-error | This specifies if the program should throw an error |

You can use these arguments when running the script or program to provide additional options or information.

After successful execution

On local run, before your folder structure, should look like this

.
├── eater.json
├── index.js
├── readme.md
├── sample.json
└── types

After successful execution, you should see your code structure change as


.
├── eater.json
├── index.js
├── readme.md
├── sample.json
└── types
    ├── queries
    │   ├── IAllOpenRequetsQuery.ts
    │   ├── IGetAllPostsForACompetitionQuery.ts
    │   ├── IGetAllPostsQuery.ts
    │   ├── IGetAllRequestsFromOneTimeToAnotherQuery.ts
    │   ├── IGetFamousHashtagsQuery.ts
    │   ├── IGetLikesToACommentQuery.ts
    │   ├── IGetRepliesToACommentQuery.ts
    │   └── ISearchAUserQuery.ts
    ├── request
    │   ├── IAddAwardsForACompetitionRequest.ts
    │   ├── IAddNewTokenRequest.ts
    │   ├── IAddSponserRequest.ts
    │   ├── ICalculateWinnersRequest.ts
    │   ├── ICommentAPostRequest.ts
    │   ├── IDeleteNotificationRequest.ts
    │   ├── IGetNewAccessTokenUsingRefreshTokenRequest.ts
    │   ├── IRemoveAwardForACompetitionRequest.ts
    │   ├── IRemoveSponserRequest.ts
    │   ├── IReplyToACommentRequest.ts
    │   ├── IReportAPostRequest.ts
    │   ├── ISendNotificationRequest.ts
    │   ├── ISiginUserRequest.ts
    │   ├── IUpdateAwardForACompetitionRequest.ts
    │   ├── IUpdateCommentRequest.ts
    │   ├── IUpdateSponserRequest.ts
    │   └── IUpdateVideoRequest.ts
    └── response
        ├── ICreateACommentResponseBody.ts
        ├── ICreateACompetitionResponseBody.ts
        ├── IDeleteACommentResponseBody.ts
        ├── IErrorInUseCreationResponseBody.ts
        ├── IGetAllCompeditionsResponseBody.ts
        ├── IGetAllPostsResponseBody.ts
        ├── IGetNewAccessTokenUsingRefreshTokenResponseBody.ts
        ├── IGetPostByIDResponseBody.ts
        ├── IPostCreatedSuccessfullyResponseBody.ts
        ├── ISiginFailureResponseBody.ts
        ├── ISuccesfulDeletionResponseBody.ts
        ├── ISuccessfulDeletionResponseBody.ts
        ├── ISuccessfullySignedResponseBody.ts
        ├── ISuccessfullyUpdatedResponseBody.ts
        ├── ITokenUserNotFounResponseBody.ts
        ├── IUnlikeDeleyeAlikeResponseBody.ts
        ├── IUpdaateVideoResponseBody.ts
        ├── IUpdateCommentResponseBody.ts
        └── IUserCreatedSuccessfullyResponseBody.ts

4 directories, 48 files

Interface

Every interface here will have the following format

/*
Get all requests from one time to another
GET: {{host}}/report/time-stamps?startDate=05-22-2021&endDate=07-30-2021
*/
export interface IGetAllRequestsFromOneTimeToAnother {
  startDate: string;
  endDate: string;
}

Option Flag

The option flags, we have for the command are listed below

This will prompt you for some basic information about your project, such as the project name and the package manager you want to use (npm or yarn). After providing the required information, pm_ts will set up a new TypeScript project for you with the selected package manager.

Contributing

Please see CONTRIBUTING.md for contributing guide.

License

This project is licensed under the MIT License.

Use this table as a quick reference for understanding the purpose of each field in the configuration file.

Warning

Note that this project is still in beta stage and might return files with undefined in it every here and there. So feel free to create issues and contribute the project as necessary