New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

zodios

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zodios - npm Package Compare versions

Comparing version 3.1.2 to 3.1.3

2

lib/index.d.ts

@@ -1,3 +0,3 @@

export { Zodios, ApiOf } from "./zodios";
export { Zodios, ApiOf, UrlOf, ZodiosPlugin } from "./zodios";
export type { ZodiosEndpointDescription, ZodiosEnpointDescriptions, ZodiosOptions, ZodiosRequestOptions, Method, Paths, Body, AxiosRetryRequestConfig, } from "./zodios.types";
export { asApi } from "./api";

@@ -30,7 +30,14 @@ import { z } from "zod";

/**
* merge two types into a single type
* Simplify a type by merging intersections if possible
* @param T - type to simplify
*/
export declare type Simplify<T> = T extends unknown ? {
[K in keyof T]: T[K];
} : T;
/**
* Merge two types into a single type
* @param T - first type
* @param U - second type
*/
declare type MergeSimplify<T, U> = MergeUnion<T | U>;
export declare type Merge<T, U> = Simplify<T & U>;
/**

@@ -40,3 +47,3 @@ * transform possible undefined properties from a type into optional properties

*/
export declare type UndefinedToOptional<T> = MergeSimplify<RequiredProps<T>, Partial<OptionalProps<T>>>;
export declare type UndefinedToOptional<T> = Merge<RequiredProps<T>, Partial<OptionalProps<T>>>;
/**

@@ -72,3 +79,3 @@ * remove all the never properties from a type object

*/
export declare type SetPropsOptionalIfChildrenAreOptional<T> = MergeSimplify<Pick<Partial<T>, OptionalChildProps<T>>, Pick<T, RequiredChildProps<T>>>;
export declare type SetPropsOptionalIfChildrenAreOptional<T> = Merge<Pick<Partial<T>, OptionalChildProps<T>>, Pick<T, RequiredChildProps<T>>>;
/**

@@ -99,5 +106,5 @@ * transform an array type into a readonly array type

schema: z.ZodType<infer Z>;
}> ? Name extends string ? {
}> ? Name extends string ? Merge<{
[Key in Name]: Z;
} | MapSchemaParameters<R> : never : never : never;
}, MapSchemaParameters<R>> : never : never : {};
/**

@@ -109,6 +116,14 @@ * split template type string with '/' separator into a tuple of strings

export declare type SplitTemplateType<T, C extends string = "/"> = T extends `${infer F}${C}${infer R}` ? [F, ...SplitTemplateType<R, C>] : [T];
export declare type GetParamsKeys<T> = T extends `${infer F}:${infer R}/${infer S}` ? [R, ...GetParamsKeys<S>] : T extends `${infer G}:${infer U}` ? [U] : [];
export declare type ParamsToObject<T> = T extends [infer F, ...infer R] ? F extends string ? MergeSimplify<{
/**
* get all parameters from an API path
* @param Path - API path
*/
export declare type GetParamsKeys<Path> = Path extends `${infer F}:${infer R}/${infer S}` ? [R, ...GetParamsKeys<S>] : Path extends `${infer G}:${infer U}` ? [U] : [];
/**
* Transform a list of parameters string into a a api type declaration
* @param T - list of parameters string
*/
export declare type ParamsToObject<T> = T extends [infer F, ...infer R] ? F extends string ? Merge<{
[Key in F]: string | number;
}, ParamsToObject<R>> : ParamsToObject<R> : {};
export {};

@@ -47,3 +47,3 @@ import { AxiosInstance } from "axios";

*/
use(plugin: (zodios: Zodios<URL, Api>) => void): void;
use(plugin: ZodiosPlugin<URL, Api>): void;
private findEndpoint;

@@ -110,1 +110,7 @@ private validateResponse;

export declare type UrlOf<Z extends Zodios<any, any>> = Z extends Zodios<infer Url, any> ? Url : never;
/**
* Zodios Plugin type
* @Param URL - the url of the api
* @Param Api - the api description type
*/
export declare type ZodiosPlugin<URL extends string, Api extends ZodiosEnpointDescriptions> = (zodios: Zodios<URL, Api>) => void;
import { AxiosInstance, AxiosRequestConfig } from "axios";
import type { FilterArray, MapSchemaParameters, MergeUnion, PickDefined, NeverIfEmpty, UndefinedToOptional, GetParamsKeys, ParamsToObject, SetPropsOptionalIfChildrenAreOptional, ReadonlyDeep } from "./utils.types";
import type { FilterArray, MapSchemaParameters, PickDefined, NeverIfEmpty, UndefinedToOptional, GetParamsKeys, ParamsToObject, SetPropsOptionalIfChildrenAreOptional, ReadonlyDeep } from "./utils.types";
import { z } from "zod";

@@ -17,9 +17,9 @@ export declare type Method = "get" | "post" | "put" | "delete" | "patch" | "head" | "options";

}>[number]["schema"]>;
export declare type QueryParams<Api, M extends Method, Path> = NeverIfEmpty<UndefinedToOptional<MergeUnion<MapSchemaParameters<FilterArray<EndpointApiDescription<Api, M, Path>[number]["parameters"], {
export declare type QueryParams<Api, M extends Method, Path> = NeverIfEmpty<UndefinedToOptional<MapSchemaParameters<FilterArray<EndpointApiDescription<Api, M, Path>[number]["parameters"], {
type: "Query";
}>>>>>;
}>>>>;
export declare type PathParams<Path extends string> = NeverIfEmpty<ParamsToObject<GetParamsKeys<Path>>>;
export declare type HeaderParams<Api, M extends Method, Path> = NeverIfEmpty<UndefinedToOptional<MergeUnion<MapSchemaParameters<FilterArray<EndpointApiDescription<Api, M, Path>[number]["parameters"], {
export declare type HeaderParams<Api, M extends Method, Path> = NeverIfEmpty<UndefinedToOptional<MapSchemaParameters<FilterArray<EndpointApiDescription<Api, M, Path>[number]["parameters"], {
type: "Header";
}>>>>>;
}>>>>;
export declare type AnyZodiosRequestOptions = {

@@ -26,0 +26,0 @@ params?: Record<string, unknown>;

{
"name": "zodios",
"description": "Typescript API client with autocompletion and zod validations",
"version": "3.1.2",
"version": "3.1.3",
"main": "lib/index.js",

@@ -30,2 +30,3 @@ "typings": "lib/index.d.ts",

"example": "ts-node examples/jsonplaceholder.ts",
"example:dev.to": "ts-node examples/dev.to/example.ts",
"build": "tsc -p tsconfig.build.json",

@@ -32,0 +33,0 @@ "test": "jest --coverage"

@@ -47,2 +47,4 @@ <h1 align="center">Zodios</h1>

For an almost complete example on how to use zodios and how to split your APIs declarations, take a look at [dev.to](examples/dev.to/) example.
## Declare your API with zodios

@@ -49,0 +51,0 @@

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