File tree Expand file tree Collapse file tree 6 files changed +20
-15
lines changed
pkgs/typed-api-spec/src/core Expand file tree Collapse file tree 6 files changed +20
-15
lines changed Original file line number Diff line number Diff line change 11import { withValidation } from "@notainc/typed-api-spec/fetch" ;
22import { z } from "zod" ;
33import { 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" ;
55
66const GITHUB_API_ORIGIN = "https://api.github.com" ;
77
@@ -12,15 +12,15 @@ const spec = {
1212 responses : { 200 : { body : z . object ( { names : z . string ( ) . array ( ) } ) } } ,
1313 } ,
1414 } ,
15- } satisfies SSApiEndpoints ;
15+ } satisfies ApiEndpointsSchema ;
1616const spec2 = {
1717 "/repos/:owner/:repo/topics" : {
1818 get : {
1919 // Invalid response schema
2020 responses : { 200 : { body : z . object ( { noexist : z . string ( ) } ) } } ,
2121 } ,
2222 } ,
23- } satisfies SSApiEndpoints ;
23+ } satisfies ApiEndpointsSchema ;
2424
2525const main = async ( ) => {
2626 {
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" ;
25import * as v from "valibot" ;
36
47const JsonHeader = v . object ( {
@@ -41,5 +44,5 @@ export const pathMap = {
4144 } ,
4245 } ,
4346 } ,
44- } satisfies SSApiEndpoints ;
47+ } satisfies ApiEndpointsSchema ;
4548export 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" ;
25import { z } from "zod" ;
36
47const JsonHeader = z . union ( [
@@ -42,5 +45,5 @@ export const pathMap = {
4245 } ,
4346 } ,
4447 } ,
45- } satisfies SSApiEndpoints ;
48+ } satisfies ApiEndpointsSchema ;
4649export type PathMap = ToApiEndpoints < typeof pathMap > ;
Original file line number Diff line number Diff line change @@ -7,3 +7,4 @@ export * from "./validator/validate";
77export * from "./validator/request" ;
88export * from "./validator/response" ;
99export * from "./openapi" ;
10+ export * from "./schema" ;
Original file line number Diff line number Diff line change @@ -17,11 +17,9 @@ import {
1717 ToOpenApiResponse ,
1818} from "./spec" ;
1919import { StandardSchemaV1 } from "@standard-schema/spec" ;
20- import { ApiResponseSchema } from "../schema" ;
20+ import { AnyStandardSchemaV1 , ApiResponseSchema } from "../schema" ;
2121import { toJsonSchemaApiEndpoints } from "../jsonschema" ;
2222
23- // eslint-disable-next-line @typescript-eslint/no-explicit-any
24- type AnyStandardSchemaV1 = StandardSchemaV1 < any > ;
2523export type SSOpenApiEndpoints = {
2624 [ Path in string ] : SSOpenApiEndpoint ;
2725} ;
Original file line number Diff line number Diff line change @@ -11,7 +11,11 @@ import {
1111 MethodInvalidError ,
1212 newMethodInvalidError ,
1313} from "../spec" ;
14- import { ApiResponsesSchema , ApiSpecSchema } from "../schema" ;
14+ import {
15+ AnyStandardSchemaV1 ,
16+ ApiResponsesSchema ,
17+ ApiSpecSchema ,
18+ } from "../schema" ;
1519import { ApiEndpointsSchema } from "../schema" ;
1620import {
1721 AnySpecValidator ,
@@ -29,10 +33,6 @@ import {
2933import { StatusCode } from "../hono-types" ;
3034export type SSResult < Data > = SS . Result < Data > | Promise < SS . Result < Data > > ;
3135
32- // eslint-disable-next-line @typescript-eslint/no-explicit-any
33- export type AnyStandardSchemaV1 = SS < any > ;
34-
35- // export type Validator<Data> = () => SSResult<Data>;
3636export type Validator < V extends AnyStandardSchemaV1 | undefined > =
3737 V extends AnyStandardSchemaV1
3838 ? ( ) => SSResult < NonNullable < SS . InferOutput < V > > >
You can’t perform that action at this time.
0 commit comments