File tree 6 files changed +20
-15
lines changed
pkgs/typed-api-spec/src/core
6 files changed +20
-15
lines changed Original file line number Diff line number Diff line change 1
1
import { withValidation } from "@notainc/typed-api-spec/fetch" ;
2
2
import { z } from "zod" ;
3
3
import { SpecValidatorError } from "@notainc/typed-api-spec/fetch" ;
4
- import { SSApiEndpoints } from "@notainc/typed-api-spec/core" ;
4
+ import { ApiEndpointsSchema } from "@notainc/typed-api-spec/core" ;
5
5
6
6
const GITHUB_API_ORIGIN = "https://api.github.com" ;
7
7
@@ -12,15 +12,15 @@ const spec = {
12
12
responses : { 200 : { body : z . object ( { names : z . string ( ) . array ( ) } ) } } ,
13
13
} ,
14
14
} ,
15
- } satisfies SSApiEndpoints ;
15
+ } satisfies ApiEndpointsSchema ;
16
16
const spec2 = {
17
17
"/repos/:owner/:repo/topics" : {
18
18
get : {
19
19
// Invalid response schema
20
20
responses : { 200 : { body : z . object ( { noexist : z . string ( ) } ) } } ,
21
21
} ,
22
22
} ,
23
- } satisfies SSApiEndpoints ;
23
+ } satisfies ApiEndpointsSchema ;
24
24
25
25
const main = async ( ) => {
26
26
{
Original file line number Diff line number Diff line change 1
- import { SSApiEndpoints , ToApiEndpoints } from "@notainc/typed-api-spec/core" ;
1
+ import {
2
+ ApiEndpointsSchema ,
3
+ ToApiEndpoints ,
4
+ } from "@notainc/typed-api-spec/core" ;
2
5
import * as v from "valibot" ;
3
6
4
7
const JsonHeader = v . object ( {
@@ -41,5 +44,5 @@ export const pathMap = {
41
44
} ,
42
45
} ,
43
46
} ,
44
- } satisfies SSApiEndpoints ;
47
+ } satisfies ApiEndpointsSchema ;
45
48
export type PathMap = ToApiEndpoints < typeof pathMap > ;
Original file line number Diff line number Diff line change 1
- import { SSApiEndpoints , ToApiEndpoints } from "@notainc/typed-api-spec/core" ;
1
+ import {
2
+ ApiEndpointsSchema ,
3
+ ToApiEndpoints ,
4
+ } from "@notainc/typed-api-spec/core" ;
2
5
import { z } from "zod" ;
3
6
4
7
const JsonHeader = z . union ( [
@@ -42,5 +45,5 @@ export const pathMap = {
42
45
} ,
43
46
} ,
44
47
} ,
45
- } satisfies SSApiEndpoints ;
48
+ } satisfies ApiEndpointsSchema ;
46
49
export type PathMap = ToApiEndpoints < typeof pathMap > ;
Original file line number Diff line number Diff line change @@ -7,3 +7,4 @@ export * from "./validator/validate";
7
7
export * from "./validator/request" ;
8
8
export * from "./validator/response" ;
9
9
export * from "./openapi" ;
10
+ export * from "./schema" ;
Original file line number Diff line number Diff line change @@ -17,11 +17,9 @@ import {
17
17
ToOpenApiResponse ,
18
18
} from "./spec" ;
19
19
import { StandardSchemaV1 } from "@standard-schema/spec" ;
20
- import { ApiResponseSchema } from "../schema" ;
20
+ import { AnyStandardSchemaV1 , ApiResponseSchema } from "../schema" ;
21
21
import { toJsonSchemaApiEndpoints } from "../jsonschema" ;
22
22
23
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
24
- type AnyStandardSchemaV1 = StandardSchemaV1 < any > ;
25
23
export type SSOpenApiEndpoints = {
26
24
[ Path in string ] : SSOpenApiEndpoint ;
27
25
} ;
Original file line number Diff line number Diff line change @@ -11,7 +11,11 @@ import {
11
11
MethodInvalidError ,
12
12
newMethodInvalidError ,
13
13
} from "../spec" ;
14
- import { ApiResponsesSchema , ApiSpecSchema } from "../schema" ;
14
+ import {
15
+ AnyStandardSchemaV1 ,
16
+ ApiResponsesSchema ,
17
+ ApiSpecSchema ,
18
+ } from "../schema" ;
15
19
import { ApiEndpointsSchema } from "../schema" ;
16
20
import {
17
21
AnySpecValidator ,
@@ -29,10 +33,6 @@ import {
29
33
import { StatusCode } from "../hono-types" ;
30
34
export type SSResult < Data > = SS . Result < Data > | Promise < SS . Result < Data > > ;
31
35
32
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
33
- export type AnyStandardSchemaV1 = SS < any > ;
34
-
35
- // export type Validator<Data> = () => SSResult<Data>;
36
36
export type Validator < V extends AnyStandardSchemaV1 | undefined > =
37
37
V extends AnyStandardSchemaV1
38
38
? ( ) => SSResult < NonNullable < SS . InferOutput < V > > >
You can’t perform that action at this time.
0 commit comments