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 2.0.0 to 2.0.1

1

lib/index.js

@@ -6,2 +6,1 @@ "use strict";

Object.defineProperty(exports, "Zodios", { enumerable: true, get: function () { return zodios_1.Zodios; } });
//# sourceMappingURL=index.js.map

@@ -18,2 +18,1 @@ "use strict";

exports.omit = omit;
//# sourceMappingURL=utils.js.map

38

lib/utils.types.d.ts

@@ -48,11 +48,26 @@ import { z } from "zod";

/**
* remove empty object union from a type
* check if two types are equal
*/
declare type IfEquals<T, U, Y = unknown, N = never> = (<G>() => G extends T ? 1 : 2) extends <G>() => G extends U ? 1 : 2 ? Y : N;
/**
* get never if empty type
* @param T - type
* @example
* ```ts
* type A = { a: number } | {};
* type B = NotEmpty<A>; // { a: number }
* type A = {};
* type B = NotEmpty<A>; // B = never
*/
export declare type NotEmpty<T> = {} extends Required<OptionalProps<T>> ? {} extends RequiredProps<T> ? never : T : T;
export declare type NeverIfEmpty<T> = IfEquals<T, {}, never, T>;
declare type RequiredChildProps<T> = {
[K in keyof T]: IfEquals<T[K], OptionalProps<T[K]>, never, K>;
}[keyof T];
declare type OptionalChildProps<T> = {
[K in keyof T]: IfEquals<T[K], OptionalProps<T[K]>, K, never>;
}[keyof T];
/**
* set properties to optional if their child properties are optional
* @param T - object type
*/
export declare type SetPropsOptionalIfChildrenAreOptional<T> = MergeSimplify<Pick<Partial<T>, OptionalChildProps<T>>, Pick<T, RequiredChildProps<T>>>;
/**
* transform an array type into a readonly array type

@@ -91,16 +106,3 @@ * @param T - array type

export declare type SplitTemplateType<T, C extends string = "/"> = T extends `${infer F}${C}${infer R}` ? [F, ...SplitTemplateType<R, C>] : [T];
/**
* Trim away a type string from each element of an array of template type string
* @param T - type string
* @param C - type string
*/
export declare type TrimLeftArray<T, C extends string> = T extends readonly [
infer F,
...infer R
] ? F extends `${C}${infer U}` ? [U, ...TrimLeftArray<R, C>] : [F, ...TrimLeftArray<R, C>] : [];
/**
* Extract params prefixed with ':' from a type string URL
* @param T - type string URL
*/
export declare type Params<T extends string> = TrimLeftArray<FilterArray<SplitTemplateType<T>, `:${string}`>, ":">;
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<{

@@ -107,0 +109,0 @@ [Key in F]: string | number;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=utils.types.js.map

@@ -175,2 +175,1 @@ "use strict";

exports.Zodios = Zodios;
//# sourceMappingURL=zodios.js.map
import { AxiosRequestConfig } from "axios";
import type { FilterArray, MapSchemaParameters, MergeUnion, PickDefined, NotEmpty, UndefinedToOptional, Params, ParamsToObject } from "./utils.types";
import type { FilterArray, MapSchemaParameters, MergeUnion, PickDefined, NeverIfEmpty, UndefinedToOptional, GetParamsKeys, ParamsToObject, SetPropsOptionalIfChildrenAreOptional } from "./utils.types";
import { z } from "zod";

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

}>[number]["schema"]>;
export declare type QueryParams<Api, M extends Method, Path> = NotEmpty<UndefinedToOptional<MergeUnion<MapSchemaParameters<FilterArray<EndpointApiDescription<Api, M, Path>[number]["parameters"], {
export declare type QueryParams<Api, M extends Method, Path> = NeverIfEmpty<UndefinedToOptional<MergeUnion<MapSchemaParameters<FilterArray<EndpointApiDescription<Api, M, Path>[number]["parameters"], {
type: "Query";
}>>>>>;
export declare type PathParams<Path extends string> = NotEmpty<ParamsToObject<Params<Path>>>;
export declare type HeaderParams<Api, M extends Method, Path> = NotEmpty<UndefinedToOptional<MergeUnion<MapSchemaParameters<FilterArray<EndpointApiDescription<Api, M, Path>[number]["parameters"], {
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"], {
type: "Header";

@@ -30,7 +30,7 @@ }>>>>>;

} & Omit<AxiosRequestConfig, "params" | "headers" | "baseURL" | "data" | "method">;
export declare type ZodiosRequestOptions<Api, M extends Method, Path extends string> = PickDefined<{
export declare type ZodiosRequestOptions<Api, M extends Method, Path extends string> = SetPropsOptionalIfChildrenAreOptional<PickDefined<{
params: PathParams<Path>;
queries: QueryParams<Api, M, Path>;
headers: HeaderParams<Api, M, Path>;
}> & Omit<AxiosRequestConfig, "params" | "headers" | "baseURL" | "data" | "method">;
}>> & Omit<AxiosRequestConfig, "params" | "headers" | "baseURL" | "data" | "method">;
export declare type AxiosRetryRequestConfig = AxiosRequestConfig & {

@@ -37,0 +37,0 @@ retried?: boolean;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=zodios.types.js.map
{
"name": "zodios",
"description": "Typescript API client with autocompletion and zod validations",
"version": "2.0.0",
"version": "2.0.1",
"main": "lib/index.js",

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

"example": "ts-node examples/jsonplaceholder.ts",
"build": "tsc -p tsconfig.json",
"build": "tsc -p tsconfig.build.json",
"test": "jest --coverage"

@@ -26,0 +26,0 @@ },

@@ -9,3 +9,3 @@ <h1 align="center">Zodios</h1>

<p align="center">
Zodios is a typescript api client with auto-completion features backed by <a src="https://axios-http.com" >axios</a>, <a src="https://github.com/colinhacks/zod">zod</a> and <a src="https://www.typescriptlang.org/">typescript</a>
Zodios is a typescript api client with auto-completion features backed by <a src="https://axios-http.com" >axios</a> and <a src="https://github.com/colinhacks/zod">zod</a>
</p>

@@ -71,3 +71,3 @@

);
// typed auto-complete url auto-complete params
// typed auto-complete url auto-complete params
// ▼ ▼ ▼

@@ -74,0 +74,0 @@ const user = await apiClient.get("/users/:id", { params: { id: 7 } });

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