UNPKG

@sirhc77/postman-sdk-gen

Version:

Generate a fully-typed TypeScript SDK from a Postman collection, with support for Axios or Fetch, folder-based namespacing, and auto-inferred types.

34 lines (33 loc) 1.25 kB
import { SdkGenConfig } from "./config"; import { ParsedCollection, ParsedEndpoint } from "./parser"; import { RequestAuth } from "postman-collection"; interface SdkMethod { code: string; optionsType?: string; requestType?: string; responseType?: string; } interface MethodParts { funcName: string; reqTypeName: string; resTypeName: string; optionsTypeName: string; hasBody: boolean; hasOptions: boolean; hasResponse: boolean; paramMap: Map<string, string>; optionsMap: Map<string, string>; optionsType: string | undefined; } interface GeneratedCode { importCode?: string; typesCode: string; classCode: string; } export declare function generateSdk(config: SdkGenConfig): Promise<void>; export declare function extractMethodParts(endpoint: ParsedEndpoint): MethodParts; export declare function generateAuthArgs(auth: RequestAuth): string[]; export declare function generateFetchMethod(endpoint: ParsedEndpoint, collectionAuth: RequestAuth): SdkMethod; export declare function generateAxiosMethod(endpoint: ParsedEndpoint, collectionAuth: RequestAuth): SdkMethod; export declare function generateCode(parsedCollection: ParsedCollection, config: SdkGenConfig): GeneratedCode; export {};