Skip to content

Commit bd604d6

Browse files
committed
Remove zod and valibot unused types
1 parent cae5248 commit bd604d6

File tree

6 files changed

+18
-331
lines changed

6 files changed

+18
-331
lines changed

pkgs/typed-api-spec/src/express/valibot.ts

+15-17
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
import {
2-
ToApiEndpoints,
3-
ValibotApiEndpoints,
4-
ValibotApiSpec,
5-
ValibotValidators,
6-
} from "../valibot";
71
import { Method } from "../core";
82
import {
93
RouterT,
@@ -12,32 +6,36 @@ import {
126
validatorMiddleware,
137
} from "./index";
148
import { Router } from "express";
15-
import { newSSValidator } from "../ss";
9+
import {
10+
newSSValidator,
11+
SSApiEndpoints,
12+
SSApiSpec,
13+
SSValidators,
14+
ToApiEndpoints,
15+
} from "../ss";
1616

1717
/**
18-
* Convert ValibotApiSpec to Express Request Handler type.
18+
* Convert SSApiSpec to Express Request Handler type.
1919
*/
2020
export type ToHandler<
21-
ZodE extends ValibotApiEndpoints,
21+
ZodE extends SSApiEndpoints,
2222
Path extends keyof ZodE & string,
2323
M extends Method,
2424
> = ToPureHandler<ToApiEndpoints<ZodE>[Path][M], ToValidators<ZodE[Path][M]>>;
2525

26-
export type ToValidators<Spec extends ValibotApiSpec | undefined> =
27-
Spec extends ValibotApiSpec
28-
? ValibotValidators<Spec, string>
29-
: Record<string, never>;
26+
export type ToValidators<Spec extends SSApiSpec | undefined> =
27+
Spec extends SSApiSpec ? SSValidators<Spec, string> : Record<string, never>;
3028

3129
/**
32-
* Convert ValibotApiEndpoints to Express Request Handler type map.
30+
* Convert SSApiEndpoints to Express Request Handler type map.
3331
*/
3432
export type ToHandlers<
35-
ZodE extends ValibotApiEndpoints,
33+
ZodE extends SSApiEndpoints,
3634
E extends ToApiEndpoints<ZodE> = ToApiEndpoints<ZodE>,
3735
V extends ToValidatorsMap<ZodE> = ToValidatorsMap<ZodE>,
3836
> = ToPureHandlers<E, V>;
3937

40-
export type ToValidatorsMap<ZodE extends ValibotApiEndpoints> = {
38+
export type ToValidatorsMap<ZodE extends SSApiEndpoints> = {
4139
[Path in keyof ZodE & string]: {
4240
[M in Method]: ToValidators<ZodE[Path][M]>;
4341
};
@@ -61,7 +59,7 @@ export type ToValidatorsMap<ZodE extends ValibotApiEndpoints> = {
6159
* })
6260
* ```
6361
*/
64-
export const typed = <const Endpoints extends ValibotApiEndpoints>(
62+
export const typed = <const Endpoints extends SSApiEndpoints>(
6563
pathMap: Endpoints,
6664
router: Router,
6765
): RouterT<ToApiEndpoints<Endpoints>, ToValidatorsMap<Endpoints>> => {
-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
export * from "./spec";
21
export * from "./util";
3-
export * from "./validator";
42
export * from "./openapi";

pkgs/typed-api-spec/src/valibot/openapi.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ import {
1111
JsonSchemaOpenApiEndpoints,
1212
ToOpenApiResponse,
1313
} from "../core/openapi/spec";
14-
import { ValibotAnyApiResponse, ValibotApiEndpoints } from "./spec";
1514
import { toJsonSchemaApiEndpoints as toEndpoints } from "../core/jsonschema";
1615
import { toJsonSchema } from "@valibot/to-json-schema";
16+
import { SSAnyApiResponse, SSApiEndpoints } from "../ss";
1717

1818
export const toOpenApiDoc = <E extends ValibotOpenApiEndpoints>(
1919
doc: Omit<OpenAPIV3_1.Document, "paths">,
@@ -27,8 +27,7 @@ export type ValibotOpenApiEndpoints = {
2727
[Path in string]: ValibotOpenApiEndpoint;
2828
};
2929
export type ValibotOpenApiEndpoint = DefineOpenApiEndpoint<ValibotOpenApiSpec>;
30-
export type ValibotAnyOpenApiResponse =
31-
ToOpenApiResponse<ValibotAnyApiResponse>;
30+
export type ValibotAnyOpenApiResponse = ToOpenApiResponse<SSAnyApiResponse>;
3231
export type ValibotAnyOpenApiResponses =
3332
DefineOpenApiResponses<ValibotAnyOpenApiResponse>;
3433

@@ -42,6 +41,6 @@ export type ValibotOpenApiSpec<
4241
Responses extends ValibotAnyOpenApiResponses = ValibotAnyOpenApiResponses,
4342
> = BaseOpenApiSpec<Params, Query, Body, RequestHeaders, Responses>;
4443

45-
export const toJsonSchemaApiEndpoints = <E extends ValibotApiEndpoints>(
44+
export const toJsonSchemaApiEndpoints = <E extends SSApiEndpoints>(
4645
endpoints: E,
4746
): JsonSchemaApiEndpoints => toEndpoints(toJsonSchema, endpoints);

pkgs/typed-api-spec/src/valibot/spec.ts

-49
This file was deleted.

pkgs/typed-api-spec/src/valibot/validator.ts

-112
This file was deleted.

0 commit comments

Comments
 (0)