Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@insertish/oapi

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@insertish/oapi - npm Package Compare versions

Comparing version 0.1.10 to 0.1.11

.vscode/settings.json

13

cli.js

@@ -41,6 +41,3 @@ #!/usr/bin/env bash

let template = path;
if (!process.env.STRICT) {
template = path.replace(/\{\w+\}/g, '${string}');
}
let template = path.replace(/\{\w+\}/g, '${string}');

@@ -85,5 +82,9 @@ for (const method of methods) {

const object = `{ method: '${method}', path: \`${template}\`, params: ${params}, response: ${RESPONSE} }`;
entries.push(`| ${object}`);
const parts = path.split('').find(x => x === '/').length;
entries.push(`| { method: '${method}', path: \`${template}\`, parts: ${parts}, params: ${params}, response: ${RESPONSE} }`);
if (/\{\w+\}/.test(path)) {
entries.push(`| { method: '${method}', path: '-${path}', parts: ${parts}, params: ${params}, response: ${RESPONSE} }`);
}
queryData[path] = {

@@ -90,0 +91,0 @@ ...queryData[path],

{
"name": "@insertish/oapi",
"version": "0.1.10",
"version": "0.1.11",
"description": "API Library Generator for OpenAPI",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -5,2 +5,4 @@ # OAPI Client

Thank you to [bree](https://bree.dev/) for helping me figure out all the especially difficult Typescript types.
## Goals

@@ -7,0 +9,0 @@

@@ -13,2 +13,14 @@ // This file was auto-generated by @insertish/oapi!

type Methods = APIRoutes['method'];
type PickRoutes<Method extends Methods> = APIRoutes & { method: Method };
type GetRoutes = PickRoutes<'get'>;
type PatchRoutes = PickRoutes<'patch'>;
type PutRoutes = PickRoutes<'put'>;
type DeleteRoutes = PickRoutes<'delete'>;
type PostRoutes = PickRoutes<'post'>;
type Count<Str extends string, SubStr extends string, Matches extends null[] = []> =
Str extends `${infer _}${SubStr}${infer After}` ? Count<After, SubStr, [...Matches, null]> : Matches['length'];
/**

@@ -38,11 +50,2 @@ * Get the specific path name of any given path.

type Methods = APIRoutes['method'];
type PickRoutes<Method extends Methods> = APIRoutes & { method: Method };
type GetRoutes = PickRoutes<'get'>;
type PatchRoutes = PickRoutes<'patch'>;
type PutRoutes = PickRoutes<'put'>;
type DeleteRoutes = PickRoutes<'delete'>;
type PostRoutes = PickRoutes<'post'>;
/**

@@ -129,3 +132,3 @@ * Client configuration options

*/
req<Method extends Methods, Routes extends PickRoutes<Method>, Path extends Routes['path'], Route extends Routes & { path: Path }>(method: Method, path: Path, params: Route['params'], config?: AxiosRequestConfig): Promise<Route['response']> {
req<Method extends Methods, Routes extends PickRoutes<Method>, Path extends Routes['path'], Route extends Routes & { path: Path, parts: Count<Path, '/'> }>(method: Method, path: Path, params: Route['params'], config?: AxiosRequestConfig): Promise<Route['response']> {
let query, body;

@@ -173,3 +176,3 @@ let named = getPathName(path);

*/
get<Path extends GetRoutes['path'], Route extends GetRoutes & { path: Path }>(path: Path, params: Route['params'], config?: AxiosRequestConfig): Promise<Route['response']>;
get<Path extends GetRoutes['path'], Route extends GetRoutes & { path: Path, parts: Count<Path, '/'> }>(path: Path, params: Route['params'], config?: AxiosRequestConfig): Promise<Route['response']>;

@@ -181,3 +184,3 @@ /**

*/
get<Path extends (GetRoutes & { params: undefined })['path'], Route extends GetRoutes & { path: Path }>(path: Path): Promise<Route['response']>;
get<Path extends (GetRoutes & { params: undefined })['path'], Route extends GetRoutes & { path: Path, parts: Count<Path, '/'> }>(path: Path): Promise<Route['response']>;

@@ -195,3 +198,3 @@ get(path: any, params?: any, config?: AxiosRequestConfig): Promise<any> {

*/
patch<Path extends PatchRoutes['path'], Route extends PatchRoutes & { path: Path }>(path: Path, params: Route['params'], config?: AxiosRequestConfig): Promise<Route['response']>;
patch<Path extends PatchRoutes['path'], Route extends PatchRoutes & { path: Path, parts: Count<Path, '/'> }>(path: Path, params: Route['params'], config?: AxiosRequestConfig): Promise<Route['response']>;

@@ -203,3 +206,3 @@ /**

*/
patch<Path extends (PatchRoutes & { params: undefined })['path'], Route extends PatchRoutes & { path: Path }>(path: Path): Promise<Route['response']>;
patch<Path extends (PatchRoutes & { params: undefined })['path'], Route extends PatchRoutes & { path: Path, parts: Count<Path, '/'> }>(path: Path): Promise<Route['response']>;

@@ -217,3 +220,3 @@ patch(path: any, params?: any, config?: AxiosRequestConfig): Promise<any> {

*/
put<Path extends PutRoutes['path'], Route extends PutRoutes & { path: Path }>(path: Path, params: Route['params'], config?: AxiosRequestConfig): Promise<Route['response']>;
put<Path extends PutRoutes['path'], Route extends PutRoutes & { path: Path, parts: Count<Path, '/'> }>(path: Path, params: Route['params'], config?: AxiosRequestConfig): Promise<Route['response']>;

@@ -225,3 +228,3 @@ /**

*/
put<Path extends (PutRoutes & { params: undefined })['path'], Route extends PutRoutes & { path: Path }>(path: Path): Promise<Route['response']>;
put<Path extends (PutRoutes & { params: undefined })['path'], Route extends PutRoutes & { path: Path, parts: Count<Path, '/'> }>(path: Path): Promise<Route['response']>;

@@ -239,3 +242,3 @@ put(path: any, params?: any, config?: AxiosRequestConfig): Promise<any> {

*/
delete<Path extends DeleteRoutes['path'], Route extends DeleteRoutes & { path: Path }>(path: Path, config?: AxiosRequestConfig): Promise<Route['response']>;
delete<Path extends DeleteRoutes['path'], Route extends DeleteRoutes & { path: Path, parts: Count<Path, '/'> }>(path: Path, config?: AxiosRequestConfig): Promise<Route['response']>;

@@ -247,3 +250,3 @@ /**

*/
delete<Path extends (DeleteRoutes & { params: undefined })['path'], Route extends DeleteRoutes & { path: Path }>(path: Path): Promise<Route['response']>;
delete<Path extends (DeleteRoutes & { params: undefined })['path'], Route extends DeleteRoutes & { path: Path, parts: Count<Path, '/'> }>(path: Path): Promise<Route['response']>;

@@ -261,3 +264,3 @@ delete(path: any, config?: AxiosRequestConfig): Promise<any> {

*/
post<Path extends PostRoutes['path'], Route extends PostRoutes & { path: Path }>(path: Path, params: Route['params'], config?: AxiosRequestConfig): Promise<Route['response']>;
post<Path extends PostRoutes['path'], Route extends PostRoutes & { path: Path, parts: Count<Path, '/'> }>(path: Path, params: Route['params'], config?: AxiosRequestConfig): Promise<Route['response']>;

@@ -269,3 +272,3 @@ /**

*/
post<Path extends (PostRoutes & { params: undefined })['path'], Route extends PostRoutes & { path: Path }>(path: Path): Promise<Route['response']>;
post<Path extends (PostRoutes & { params: undefined })['path'], Route extends PostRoutes & { path: Path, parts: Count<Path, '/'> }>(path: Path): Promise<Route['response']>;

@@ -272,0 +275,0 @@ post(path: any, params?: any, config?: AxiosRequestConfig): Promise<any> {

// Sample file for type-checking.
export type APIRoutes =
| { method: 'get', path: `/`, params: undefined, response: undefined }
| { method: 'patch', path: `/`, params: undefined, response: undefined }
| { method: 'put', path: `/`, params: undefined, response: undefined }
| { method: 'delete', path: `/`, params: undefined, response: undefined }
| { method: 'post', path: `/`, params: undefined, response: undefined };
| { method: 'get', parts: 2, path: '-/sus/{target}', params: undefined, response: undefined; }
| { method: 'get', parts: 2, path: `/sus/${string}`, params: undefined, response: string; }
| { method: 'get', parts: 3, path: `/sus/${string}/conflicting`, params: { some: string }, response: number; }
| { method: 'patch', parts: 1, path: `/`, params: undefined, response: undefined }
| { method: 'put', parts: 1, path: `/`, params: undefined, response: undefined }
| { method: 'delete', parts: 1, path: `/`, params: undefined, response: undefined }
| { method: 'post', parts: 1, path: `/`, params: undefined, response: undefined };
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc