better-call 1.0.25-beta.2 → 1.0.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -1
- package/dist/client.d.cts +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/index.cjs +65 -39
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +65 -40
- package/dist/index.js.map +1 -1
- package/dist/node.d.cts +1 -1
- package/dist/node.d.ts +1 -1
- package/dist/{router-BFJOSfmb.d.cts → router-DRUBbubk.d.ts} +91 -15
- package/dist/{router-D0KeMgM6.d.ts → router-DeSuoHCx.d.cts} +91 -15
- package/package.json +2 -3
package/dist/node.d.cts
CHANGED
package/dist/node.d.ts
CHANGED
|
@@ -89,6 +89,9 @@ declare class InternalAPIError extends Error {
|
|
|
89
89
|
cause?: unknown;
|
|
90
90
|
} & Record<string, any>) | undefined, headers?: HeadersInit, statusCode?: number);
|
|
91
91
|
}
|
|
92
|
+
declare class BetterCallError extends Error {
|
|
93
|
+
constructor(message: string);
|
|
94
|
+
}
|
|
92
95
|
type APIError = InstanceType<typeof InternalAPIError>;
|
|
93
96
|
declare const APIError: new (status?: "OK" | "CREATED" | "ACCEPTED" | "NO_CONTENT" | "MULTIPLE_CHOICES" | "MOVED_PERMANENTLY" | "FOUND" | "SEE_OTHER" | "NOT_MODIFIED" | "TEMPORARY_REDIRECT" | "BAD_REQUEST" | "UNAUTHORIZED" | "PAYMENT_REQUIRED" | "FORBIDDEN" | "NOT_FOUND" | "METHOD_NOT_ALLOWED" | "NOT_ACCEPTABLE" | "PROXY_AUTHENTICATION_REQUIRED" | "REQUEST_TIMEOUT" | "CONFLICT" | "GONE" | "LENGTH_REQUIRED" | "PRECONDITION_FAILED" | "PAYLOAD_TOO_LARGE" | "URI_TOO_LONG" | "UNSUPPORTED_MEDIA_TYPE" | "RANGE_NOT_SATISFIABLE" | "EXPECTATION_FAILED" | "I'M_A_TEAPOT" | "MISDIRECTED_REQUEST" | "UNPROCESSABLE_ENTITY" | "LOCKED" | "FAILED_DEPENDENCY" | "TOO_EARLY" | "UPGRADE_REQUIRED" | "PRECONDITION_REQUIRED" | "TOO_MANY_REQUESTS" | "REQUEST_HEADER_FIELDS_TOO_LARGE" | "UNAVAILABLE_FOR_LEGAL_REASONS" | "INTERNAL_SERVER_ERROR" | "NOT_IMPLEMENTED" | "BAD_GATEWAY" | "SERVICE_UNAVAILABLE" | "GATEWAY_TIMEOUT" | "HTTP_VERSION_NOT_SUPPORTED" | "VARIANT_ALSO_NEGOTIATES" | "INSUFFICIENT_STORAGE" | "LOOP_DETECTED" | "NOT_EXTENDED" | "NETWORK_AUTHENTICATION_REQUIRED" | Status | undefined, body?: ({
|
|
94
97
|
message?: string;
|
|
@@ -317,8 +320,8 @@ type InferMiddlewareQuery<Options extends MiddlewareOptions> = Options["query"]
|
|
|
317
320
|
type InputContext<Path extends string, Options extends EndpointOptions> = InferBodyInput<Options> & InferInputMethod<Options> & InferQueryInput<Options> & InferParamInput<Path> & InferRequestInput<Options> & InferHeadersInput<Options> & {
|
|
318
321
|
asResponse?: boolean;
|
|
319
322
|
returnHeaders?: boolean;
|
|
323
|
+
returnStatus?: boolean;
|
|
320
324
|
use?: Middleware[];
|
|
321
|
-
path?: string;
|
|
322
325
|
};
|
|
323
326
|
declare const createInternalContext: (context: InputContext<any, any>, {
|
|
324
327
|
options,
|
|
@@ -377,6 +380,7 @@ declare const createInternalContext: (context: InputContext<any, any>, {
|
|
|
377
380
|
} & {
|
|
378
381
|
errorStack: string | undefined;
|
|
379
382
|
};
|
|
383
|
+
setStatus: (status: Status) => void;
|
|
380
384
|
json: (json: Record<string, any>, routerResponse?: {
|
|
381
385
|
status?: number;
|
|
382
386
|
headers?: Record<string, string>;
|
|
@@ -384,8 +388,10 @@ declare const createInternalContext: (context: InputContext<any, any>, {
|
|
|
384
388
|
body?: Record<string, any>;
|
|
385
389
|
} | Response) => Record<string, any>;
|
|
386
390
|
responseHeaders: Headers;
|
|
391
|
+
responseStatus: Status | undefined;
|
|
387
392
|
asResponse?: boolean;
|
|
388
393
|
returnHeaders?: boolean;
|
|
394
|
+
returnStatus?: boolean;
|
|
389
395
|
use?: Middleware[];
|
|
390
396
|
} | {
|
|
391
397
|
body: any;
|
|
@@ -438,6 +444,7 @@ declare const createInternalContext: (context: InputContext<any, any>, {
|
|
|
438
444
|
} & {
|
|
439
445
|
errorStack: string | undefined;
|
|
440
446
|
};
|
|
447
|
+
setStatus: (status: Status) => void;
|
|
441
448
|
json: (json: Record<string, any>, routerResponse?: {
|
|
442
449
|
status?: number;
|
|
443
450
|
headers?: Record<string, string>;
|
|
@@ -445,8 +452,10 @@ declare const createInternalContext: (context: InputContext<any, any>, {
|
|
|
445
452
|
body?: Record<string, any>;
|
|
446
453
|
} | Response) => Record<string, any>;
|
|
447
454
|
responseHeaders: Headers;
|
|
455
|
+
responseStatus: Status | undefined;
|
|
448
456
|
asResponse?: boolean;
|
|
449
457
|
returnHeaders?: boolean;
|
|
458
|
+
returnStatus?: boolean;
|
|
450
459
|
use?: Middleware[];
|
|
451
460
|
} | {
|
|
452
461
|
body: any;
|
|
@@ -499,6 +508,7 @@ declare const createInternalContext: (context: InputContext<any, any>, {
|
|
|
499
508
|
} & {
|
|
500
509
|
errorStack: string | undefined;
|
|
501
510
|
};
|
|
511
|
+
setStatus: (status: Status) => void;
|
|
502
512
|
json: (json: Record<string, any>, routerResponse?: {
|
|
503
513
|
status?: number;
|
|
504
514
|
headers?: Record<string, string>;
|
|
@@ -506,8 +516,10 @@ declare const createInternalContext: (context: InputContext<any, any>, {
|
|
|
506
516
|
body?: Record<string, any>;
|
|
507
517
|
} | Response) => Record<string, any>;
|
|
508
518
|
responseHeaders: Headers;
|
|
519
|
+
responseStatus: Status | undefined;
|
|
509
520
|
asResponse?: boolean;
|
|
510
521
|
returnHeaders?: boolean;
|
|
522
|
+
returnStatus?: boolean;
|
|
511
523
|
use?: Middleware[];
|
|
512
524
|
} | {
|
|
513
525
|
body: any;
|
|
@@ -560,6 +572,7 @@ declare const createInternalContext: (context: InputContext<any, any>, {
|
|
|
560
572
|
} & {
|
|
561
573
|
errorStack: string | undefined;
|
|
562
574
|
};
|
|
575
|
+
setStatus: (status: Status) => void;
|
|
563
576
|
json: (json: Record<string, any>, routerResponse?: {
|
|
564
577
|
status?: number;
|
|
565
578
|
headers?: Record<string, string>;
|
|
@@ -567,8 +580,10 @@ declare const createInternalContext: (context: InputContext<any, any>, {
|
|
|
567
580
|
body?: Record<string, any>;
|
|
568
581
|
} | Response) => Record<string, any>;
|
|
569
582
|
responseHeaders: Headers;
|
|
583
|
+
responseStatus: Status | undefined;
|
|
570
584
|
asResponse?: boolean;
|
|
571
585
|
returnHeaders?: boolean;
|
|
586
|
+
returnStatus?: boolean;
|
|
572
587
|
use?: Middleware[];
|
|
573
588
|
}>;
|
|
574
589
|
//#endregion
|
|
@@ -799,15 +814,7 @@ declare const getHTML: (apiReference: Record<string, any>, config?: {
|
|
|
799
814
|
}) => string;
|
|
800
815
|
//#endregion
|
|
801
816
|
//#region src/endpoint.d.ts
|
|
802
|
-
interface
|
|
803
|
-
/**
|
|
804
|
-
* Request Method
|
|
805
|
-
*/
|
|
806
|
-
method: Method | Method[];
|
|
807
|
-
/**
|
|
808
|
-
* Body Schema
|
|
809
|
-
*/
|
|
810
|
-
body?: StandardSchemaV1;
|
|
817
|
+
interface EndpointBaseOptions {
|
|
811
818
|
/**
|
|
812
819
|
* Query Schema
|
|
813
820
|
*/
|
|
@@ -940,6 +947,44 @@ interface EndpointOptions {
|
|
|
940
947
|
*/
|
|
941
948
|
onAPIError?: (e: APIError) => void | Promise<void>;
|
|
942
949
|
}
|
|
950
|
+
type EndpointBodyMethodOptions = {
|
|
951
|
+
/**
|
|
952
|
+
* Request Method
|
|
953
|
+
*/
|
|
954
|
+
method: "POST" | "PUT" | "DELETE" | "PATCH" | ("POST" | "PUT" | "DELETE" | "PATCH")[];
|
|
955
|
+
/**
|
|
956
|
+
* Body Schema
|
|
957
|
+
*/
|
|
958
|
+
body?: StandardSchemaV1;
|
|
959
|
+
} | {
|
|
960
|
+
/**
|
|
961
|
+
* Request Method
|
|
962
|
+
*/
|
|
963
|
+
method: "GET" | "HEAD" | ("GET" | "HEAD")[];
|
|
964
|
+
/**
|
|
965
|
+
* Body Schema
|
|
966
|
+
*/
|
|
967
|
+
body?: never;
|
|
968
|
+
} | {
|
|
969
|
+
/**
|
|
970
|
+
* Request Method
|
|
971
|
+
*/
|
|
972
|
+
method: "*";
|
|
973
|
+
/**
|
|
974
|
+
* Body Schema
|
|
975
|
+
*/
|
|
976
|
+
body?: StandardSchemaV1;
|
|
977
|
+
} | {
|
|
978
|
+
/**
|
|
979
|
+
* Request Method
|
|
980
|
+
*/
|
|
981
|
+
method: ("POST" | "PUT" | "DELETE" | "PATCH" | "GET" | "HEAD")[];
|
|
982
|
+
/**
|
|
983
|
+
* Body Schema
|
|
984
|
+
*/
|
|
985
|
+
body?: StandardSchemaV1;
|
|
986
|
+
};
|
|
987
|
+
type EndpointOptions = EndpointBaseOptions & EndpointBodyMethodOptions;
|
|
943
988
|
type EndpointContext<Path extends string, Options extends EndpointOptions, Context = {}> = {
|
|
944
989
|
/**
|
|
945
990
|
* Method
|
|
@@ -996,6 +1041,10 @@ type EndpointContext<Path extends string, Options extends EndpointOptions, Conte
|
|
|
996
1041
|
* If it's called outside of a request it will just be ignored.
|
|
997
1042
|
*/
|
|
998
1043
|
setHeader: (key: string, value: string) => void;
|
|
1044
|
+
/**
|
|
1045
|
+
* Set the response status code
|
|
1046
|
+
*/
|
|
1047
|
+
setStatus: (status: Status) => void;
|
|
999
1048
|
/**
|
|
1000
1049
|
* Get header
|
|
1001
1050
|
*
|
|
@@ -1091,16 +1140,43 @@ type StrictEndpoint<Path extends string, Options extends EndpointOptions, R = an
|
|
|
1091
1140
|
asResponse: true;
|
|
1092
1141
|
}): Promise<Response>;
|
|
1093
1142
|
(context: InputContext<Path, Options> & {
|
|
1094
|
-
|
|
1095
|
-
|
|
1143
|
+
returnHeaders: true;
|
|
1144
|
+
returnStatus: true;
|
|
1145
|
+
}): Promise<{
|
|
1146
|
+
headers: Headers;
|
|
1147
|
+
status: number;
|
|
1148
|
+
response: Awaited<R>;
|
|
1149
|
+
}>;
|
|
1150
|
+
(context: InputContext<Path, Options> & {
|
|
1151
|
+
returnHeaders: true;
|
|
1152
|
+
returnStatus: false;
|
|
1153
|
+
}): Promise<{
|
|
1154
|
+
headers: Headers;
|
|
1155
|
+
response: Awaited<R>;
|
|
1156
|
+
}>;
|
|
1157
|
+
(context: InputContext<Path, Options> & {
|
|
1158
|
+
returnHeaders: false;
|
|
1159
|
+
returnStatus: true;
|
|
1160
|
+
}): Promise<{
|
|
1161
|
+
status: number;
|
|
1162
|
+
response: Awaited<R>;
|
|
1163
|
+
}>;
|
|
1164
|
+
(context: InputContext<Path, Options> & {
|
|
1165
|
+
returnHeaders: false;
|
|
1166
|
+
returnStatus: false;
|
|
1096
1167
|
}): Promise<R>;
|
|
1097
1168
|
(context: InputContext<Path, Options> & {
|
|
1098
|
-
asResponse?: false;
|
|
1099
1169
|
returnHeaders: true;
|
|
1100
1170
|
}): Promise<{
|
|
1101
1171
|
headers: Headers;
|
|
1102
1172
|
response: Awaited<R>;
|
|
1103
1173
|
}>;
|
|
1174
|
+
(context: InputContext<Path, Options> & {
|
|
1175
|
+
returnStatus: true;
|
|
1176
|
+
}): Promise<{
|
|
1177
|
+
status: number;
|
|
1178
|
+
response: Awaited<R>;
|
|
1179
|
+
}>;
|
|
1104
1180
|
(context?: InputContext<Path, Options>): Promise<R>;
|
|
1105
1181
|
options: Options;
|
|
1106
1182
|
path: Path;
|
|
@@ -1182,5 +1258,5 @@ declare const createRouter: <E extends Record<string, Endpoint>, Config extends
|
|
|
1182
1258
|
};
|
|
1183
1259
|
type Router = ReturnType<typeof createRouter>;
|
|
1184
1260
|
//#endregion
|
|
1185
|
-
export { APIError, CookieOptions, CookiePrefixOptions, Endpoint, EndpointContext, EndpointOptions, HTTPMethod, HasRequiredKeys, InferBody, InferBodyInput, InferHeaders, InferHeadersInput, InferInputMethod, InferMethod, InferMiddlewareBody, InferMiddlewareQuery, InferParam, InferParamInput, InferParamPath, InferParamWildCard, InferQuery, InferQueryInput, InferRequest, InferRequestInput, InferUse, InputContext, IsEmptyObject, MergeObject, Method, Middleware, MiddlewareContext, MiddlewareInputContext, MiddlewareOptions, MiddlewareResponse, OpenAPIParameter, OpenAPISchemaType, Path$1 as Path, Prettify, RequiredKeysOf, Router, RouterConfig, StandardSchemaV1, Status, StrictEndpoint, UnionToIntersection, _statusCode, createEndpoint, createInternalContext, createMiddleware, createRouter, generator, getCookieKey, getHTML, hideInternalStackFrames, makeErrorForHideStackFrame, parseCookies, serializeCookie, serializeSignedCookie };
|
|
1186
|
-
//# sourceMappingURL=router-
|
|
1261
|
+
export { APIError, BetterCallError, CookieOptions, CookiePrefixOptions, Endpoint, EndpointBaseOptions, EndpointBodyMethodOptions, EndpointContext, EndpointOptions, HTTPMethod, HasRequiredKeys, InferBody, InferBodyInput, InferHeaders, InferHeadersInput, InferInputMethod, InferMethod, InferMiddlewareBody, InferMiddlewareQuery, InferParam, InferParamInput, InferParamPath, InferParamWildCard, InferQuery, InferQueryInput, InferRequest, InferRequestInput, InferUse, InputContext, IsEmptyObject, MergeObject, Method, Middleware, MiddlewareContext, MiddlewareInputContext, MiddlewareOptions, MiddlewareResponse, OpenAPIParameter, OpenAPISchemaType, Path$1 as Path, Prettify, RequiredKeysOf, Router, RouterConfig, StandardSchemaV1, Status, StrictEndpoint, UnionToIntersection, _statusCode, createEndpoint, createInternalContext, createMiddleware, createRouter, generator, getCookieKey, getHTML, hideInternalStackFrames, makeErrorForHideStackFrame, parseCookies, serializeCookie, serializeSignedCookie };
|
|
1262
|
+
//# sourceMappingURL=router-DRUBbubk.d.ts.map
|
|
@@ -89,6 +89,9 @@ declare class InternalAPIError extends Error {
|
|
|
89
89
|
cause?: unknown;
|
|
90
90
|
} & Record<string, any>) | undefined, headers?: HeadersInit, statusCode?: number);
|
|
91
91
|
}
|
|
92
|
+
declare class BetterCallError extends Error {
|
|
93
|
+
constructor(message: string);
|
|
94
|
+
}
|
|
92
95
|
type APIError = InstanceType<typeof InternalAPIError>;
|
|
93
96
|
declare const APIError: new (status?: "OK" | "CREATED" | "ACCEPTED" | "NO_CONTENT" | "MULTIPLE_CHOICES" | "MOVED_PERMANENTLY" | "FOUND" | "SEE_OTHER" | "NOT_MODIFIED" | "TEMPORARY_REDIRECT" | "BAD_REQUEST" | "UNAUTHORIZED" | "PAYMENT_REQUIRED" | "FORBIDDEN" | "NOT_FOUND" | "METHOD_NOT_ALLOWED" | "NOT_ACCEPTABLE" | "PROXY_AUTHENTICATION_REQUIRED" | "REQUEST_TIMEOUT" | "CONFLICT" | "GONE" | "LENGTH_REQUIRED" | "PRECONDITION_FAILED" | "PAYLOAD_TOO_LARGE" | "URI_TOO_LONG" | "UNSUPPORTED_MEDIA_TYPE" | "RANGE_NOT_SATISFIABLE" | "EXPECTATION_FAILED" | "I'M_A_TEAPOT" | "MISDIRECTED_REQUEST" | "UNPROCESSABLE_ENTITY" | "LOCKED" | "FAILED_DEPENDENCY" | "TOO_EARLY" | "UPGRADE_REQUIRED" | "PRECONDITION_REQUIRED" | "TOO_MANY_REQUESTS" | "REQUEST_HEADER_FIELDS_TOO_LARGE" | "UNAVAILABLE_FOR_LEGAL_REASONS" | "INTERNAL_SERVER_ERROR" | "NOT_IMPLEMENTED" | "BAD_GATEWAY" | "SERVICE_UNAVAILABLE" | "GATEWAY_TIMEOUT" | "HTTP_VERSION_NOT_SUPPORTED" | "VARIANT_ALSO_NEGOTIATES" | "INSUFFICIENT_STORAGE" | "LOOP_DETECTED" | "NOT_EXTENDED" | "NETWORK_AUTHENTICATION_REQUIRED" | Status | undefined, body?: ({
|
|
94
97
|
message?: string;
|
|
@@ -317,8 +320,8 @@ type InferMiddlewareQuery<Options extends MiddlewareOptions> = Options["query"]
|
|
|
317
320
|
type InputContext<Path extends string, Options extends EndpointOptions> = InferBodyInput<Options> & InferInputMethod<Options> & InferQueryInput<Options> & InferParamInput<Path> & InferRequestInput<Options> & InferHeadersInput<Options> & {
|
|
318
321
|
asResponse?: boolean;
|
|
319
322
|
returnHeaders?: boolean;
|
|
323
|
+
returnStatus?: boolean;
|
|
320
324
|
use?: Middleware[];
|
|
321
|
-
path?: string;
|
|
322
325
|
};
|
|
323
326
|
declare const createInternalContext: (context: InputContext<any, any>, {
|
|
324
327
|
options,
|
|
@@ -377,6 +380,7 @@ declare const createInternalContext: (context: InputContext<any, any>, {
|
|
|
377
380
|
} & {
|
|
378
381
|
errorStack: string | undefined;
|
|
379
382
|
};
|
|
383
|
+
setStatus: (status: Status) => void;
|
|
380
384
|
json: (json: Record<string, any>, routerResponse?: {
|
|
381
385
|
status?: number;
|
|
382
386
|
headers?: Record<string, string>;
|
|
@@ -384,8 +388,10 @@ declare const createInternalContext: (context: InputContext<any, any>, {
|
|
|
384
388
|
body?: Record<string, any>;
|
|
385
389
|
} | Response) => Record<string, any>;
|
|
386
390
|
responseHeaders: Headers;
|
|
391
|
+
responseStatus: Status | undefined;
|
|
387
392
|
asResponse?: boolean;
|
|
388
393
|
returnHeaders?: boolean;
|
|
394
|
+
returnStatus?: boolean;
|
|
389
395
|
use?: Middleware[];
|
|
390
396
|
} | {
|
|
391
397
|
body: any;
|
|
@@ -438,6 +444,7 @@ declare const createInternalContext: (context: InputContext<any, any>, {
|
|
|
438
444
|
} & {
|
|
439
445
|
errorStack: string | undefined;
|
|
440
446
|
};
|
|
447
|
+
setStatus: (status: Status) => void;
|
|
441
448
|
json: (json: Record<string, any>, routerResponse?: {
|
|
442
449
|
status?: number;
|
|
443
450
|
headers?: Record<string, string>;
|
|
@@ -445,8 +452,10 @@ declare const createInternalContext: (context: InputContext<any, any>, {
|
|
|
445
452
|
body?: Record<string, any>;
|
|
446
453
|
} | Response) => Record<string, any>;
|
|
447
454
|
responseHeaders: Headers;
|
|
455
|
+
responseStatus: Status | undefined;
|
|
448
456
|
asResponse?: boolean;
|
|
449
457
|
returnHeaders?: boolean;
|
|
458
|
+
returnStatus?: boolean;
|
|
450
459
|
use?: Middleware[];
|
|
451
460
|
} | {
|
|
452
461
|
body: any;
|
|
@@ -499,6 +508,7 @@ declare const createInternalContext: (context: InputContext<any, any>, {
|
|
|
499
508
|
} & {
|
|
500
509
|
errorStack: string | undefined;
|
|
501
510
|
};
|
|
511
|
+
setStatus: (status: Status) => void;
|
|
502
512
|
json: (json: Record<string, any>, routerResponse?: {
|
|
503
513
|
status?: number;
|
|
504
514
|
headers?: Record<string, string>;
|
|
@@ -506,8 +516,10 @@ declare const createInternalContext: (context: InputContext<any, any>, {
|
|
|
506
516
|
body?: Record<string, any>;
|
|
507
517
|
} | Response) => Record<string, any>;
|
|
508
518
|
responseHeaders: Headers;
|
|
519
|
+
responseStatus: Status | undefined;
|
|
509
520
|
asResponse?: boolean;
|
|
510
521
|
returnHeaders?: boolean;
|
|
522
|
+
returnStatus?: boolean;
|
|
511
523
|
use?: Middleware[];
|
|
512
524
|
} | {
|
|
513
525
|
body: any;
|
|
@@ -560,6 +572,7 @@ declare const createInternalContext: (context: InputContext<any, any>, {
|
|
|
560
572
|
} & {
|
|
561
573
|
errorStack: string | undefined;
|
|
562
574
|
};
|
|
575
|
+
setStatus: (status: Status) => void;
|
|
563
576
|
json: (json: Record<string, any>, routerResponse?: {
|
|
564
577
|
status?: number;
|
|
565
578
|
headers?: Record<string, string>;
|
|
@@ -567,8 +580,10 @@ declare const createInternalContext: (context: InputContext<any, any>, {
|
|
|
567
580
|
body?: Record<string, any>;
|
|
568
581
|
} | Response) => Record<string, any>;
|
|
569
582
|
responseHeaders: Headers;
|
|
583
|
+
responseStatus: Status | undefined;
|
|
570
584
|
asResponse?: boolean;
|
|
571
585
|
returnHeaders?: boolean;
|
|
586
|
+
returnStatus?: boolean;
|
|
572
587
|
use?: Middleware[];
|
|
573
588
|
}>;
|
|
574
589
|
//#endregion
|
|
@@ -799,15 +814,7 @@ declare const getHTML: (apiReference: Record<string, any>, config?: {
|
|
|
799
814
|
}) => string;
|
|
800
815
|
//#endregion
|
|
801
816
|
//#region src/endpoint.d.ts
|
|
802
|
-
interface
|
|
803
|
-
/**
|
|
804
|
-
* Request Method
|
|
805
|
-
*/
|
|
806
|
-
method: Method | Method[];
|
|
807
|
-
/**
|
|
808
|
-
* Body Schema
|
|
809
|
-
*/
|
|
810
|
-
body?: StandardSchemaV1;
|
|
817
|
+
interface EndpointBaseOptions {
|
|
811
818
|
/**
|
|
812
819
|
* Query Schema
|
|
813
820
|
*/
|
|
@@ -940,6 +947,44 @@ interface EndpointOptions {
|
|
|
940
947
|
*/
|
|
941
948
|
onAPIError?: (e: APIError) => void | Promise<void>;
|
|
942
949
|
}
|
|
950
|
+
type EndpointBodyMethodOptions = {
|
|
951
|
+
/**
|
|
952
|
+
* Request Method
|
|
953
|
+
*/
|
|
954
|
+
method: "POST" | "PUT" | "DELETE" | "PATCH" | ("POST" | "PUT" | "DELETE" | "PATCH")[];
|
|
955
|
+
/**
|
|
956
|
+
* Body Schema
|
|
957
|
+
*/
|
|
958
|
+
body?: StandardSchemaV1;
|
|
959
|
+
} | {
|
|
960
|
+
/**
|
|
961
|
+
* Request Method
|
|
962
|
+
*/
|
|
963
|
+
method: "GET" | "HEAD" | ("GET" | "HEAD")[];
|
|
964
|
+
/**
|
|
965
|
+
* Body Schema
|
|
966
|
+
*/
|
|
967
|
+
body?: never;
|
|
968
|
+
} | {
|
|
969
|
+
/**
|
|
970
|
+
* Request Method
|
|
971
|
+
*/
|
|
972
|
+
method: "*";
|
|
973
|
+
/**
|
|
974
|
+
* Body Schema
|
|
975
|
+
*/
|
|
976
|
+
body?: StandardSchemaV1;
|
|
977
|
+
} | {
|
|
978
|
+
/**
|
|
979
|
+
* Request Method
|
|
980
|
+
*/
|
|
981
|
+
method: ("POST" | "PUT" | "DELETE" | "PATCH" | "GET" | "HEAD")[];
|
|
982
|
+
/**
|
|
983
|
+
* Body Schema
|
|
984
|
+
*/
|
|
985
|
+
body?: StandardSchemaV1;
|
|
986
|
+
};
|
|
987
|
+
type EndpointOptions = EndpointBaseOptions & EndpointBodyMethodOptions;
|
|
943
988
|
type EndpointContext<Path extends string, Options extends EndpointOptions, Context = {}> = {
|
|
944
989
|
/**
|
|
945
990
|
* Method
|
|
@@ -996,6 +1041,10 @@ type EndpointContext<Path extends string, Options extends EndpointOptions, Conte
|
|
|
996
1041
|
* If it's called outside of a request it will just be ignored.
|
|
997
1042
|
*/
|
|
998
1043
|
setHeader: (key: string, value: string) => void;
|
|
1044
|
+
/**
|
|
1045
|
+
* Set the response status code
|
|
1046
|
+
*/
|
|
1047
|
+
setStatus: (status: Status) => void;
|
|
999
1048
|
/**
|
|
1000
1049
|
* Get header
|
|
1001
1050
|
*
|
|
@@ -1091,16 +1140,43 @@ type StrictEndpoint<Path extends string, Options extends EndpointOptions, R = an
|
|
|
1091
1140
|
asResponse: true;
|
|
1092
1141
|
}): Promise<Response>;
|
|
1093
1142
|
(context: InputContext<Path, Options> & {
|
|
1094
|
-
|
|
1095
|
-
|
|
1143
|
+
returnHeaders: true;
|
|
1144
|
+
returnStatus: true;
|
|
1145
|
+
}): Promise<{
|
|
1146
|
+
headers: Headers;
|
|
1147
|
+
status: number;
|
|
1148
|
+
response: Awaited<R>;
|
|
1149
|
+
}>;
|
|
1150
|
+
(context: InputContext<Path, Options> & {
|
|
1151
|
+
returnHeaders: true;
|
|
1152
|
+
returnStatus: false;
|
|
1153
|
+
}): Promise<{
|
|
1154
|
+
headers: Headers;
|
|
1155
|
+
response: Awaited<R>;
|
|
1156
|
+
}>;
|
|
1157
|
+
(context: InputContext<Path, Options> & {
|
|
1158
|
+
returnHeaders: false;
|
|
1159
|
+
returnStatus: true;
|
|
1160
|
+
}): Promise<{
|
|
1161
|
+
status: number;
|
|
1162
|
+
response: Awaited<R>;
|
|
1163
|
+
}>;
|
|
1164
|
+
(context: InputContext<Path, Options> & {
|
|
1165
|
+
returnHeaders: false;
|
|
1166
|
+
returnStatus: false;
|
|
1096
1167
|
}): Promise<R>;
|
|
1097
1168
|
(context: InputContext<Path, Options> & {
|
|
1098
|
-
asResponse?: false;
|
|
1099
1169
|
returnHeaders: true;
|
|
1100
1170
|
}): Promise<{
|
|
1101
1171
|
headers: Headers;
|
|
1102
1172
|
response: Awaited<R>;
|
|
1103
1173
|
}>;
|
|
1174
|
+
(context: InputContext<Path, Options> & {
|
|
1175
|
+
returnStatus: true;
|
|
1176
|
+
}): Promise<{
|
|
1177
|
+
status: number;
|
|
1178
|
+
response: Awaited<R>;
|
|
1179
|
+
}>;
|
|
1104
1180
|
(context?: InputContext<Path, Options>): Promise<R>;
|
|
1105
1181
|
options: Options;
|
|
1106
1182
|
path: Path;
|
|
@@ -1182,5 +1258,5 @@ declare const createRouter: <E extends Record<string, Endpoint>, Config extends
|
|
|
1182
1258
|
};
|
|
1183
1259
|
type Router = ReturnType<typeof createRouter>;
|
|
1184
1260
|
//#endregion
|
|
1185
|
-
export { APIError, CookieOptions, CookiePrefixOptions, Endpoint, EndpointContext, EndpointOptions, HTTPMethod, HasRequiredKeys, InferBody, InferBodyInput, InferHeaders, InferHeadersInput, InferInputMethod, InferMethod, InferMiddlewareBody, InferMiddlewareQuery, InferParam, InferParamInput, InferParamPath, InferParamWildCard, InferQuery, InferQueryInput, InferRequest, InferRequestInput, InferUse, InputContext, IsEmptyObject, MergeObject, Method, Middleware, MiddlewareContext, MiddlewareInputContext, MiddlewareOptions, MiddlewareResponse, OpenAPIParameter, OpenAPISchemaType, Path$1 as Path, Prettify, RequiredKeysOf, Router, RouterConfig, StandardSchemaV1, Status, StrictEndpoint, UnionToIntersection, _statusCode, createEndpoint, createInternalContext, createMiddleware, createRouter, generator, getCookieKey, getHTML, hideInternalStackFrames, makeErrorForHideStackFrame, parseCookies, serializeCookie, serializeSignedCookie };
|
|
1186
|
-
//# sourceMappingURL=router-
|
|
1261
|
+
export { APIError, BetterCallError, CookieOptions, CookiePrefixOptions, Endpoint, EndpointBaseOptions, EndpointBodyMethodOptions, EndpointContext, EndpointOptions, HTTPMethod, HasRequiredKeys, InferBody, InferBodyInput, InferHeaders, InferHeadersInput, InferInputMethod, InferMethod, InferMiddlewareBody, InferMiddlewareQuery, InferParam, InferParamInput, InferParamPath, InferParamWildCard, InferQuery, InferQueryInput, InferRequest, InferRequestInput, InferUse, InputContext, IsEmptyObject, MergeObject, Method, Middleware, MiddlewareContext, MiddlewareInputContext, MiddlewareOptions, MiddlewareResponse, OpenAPIParameter, OpenAPISchemaType, Path$1 as Path, Prettify, RequiredKeysOf, Router, RouterConfig, StandardSchemaV1, Status, StrictEndpoint, UnionToIntersection, _statusCode, createEndpoint, createInternalContext, createMiddleware, createRouter, generator, getCookieKey, getHTML, hideInternalStackFrames, makeErrorForHideStackFrame, parseCookies, serializeCookie, serializeSignedCookie };
|
|
1262
|
+
//# sourceMappingURL=router-DeSuoHCx.d.cts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "better-call",
|
|
3
|
-
"version": "1.0.25
|
|
3
|
+
"version": "1.0.25",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -33,8 +33,7 @@
|
|
|
33
33
|
"@better-auth/utils": "^0.3.0",
|
|
34
34
|
"@better-fetch/fetch": "^1.1.4",
|
|
35
35
|
"rou3": "^0.5.1",
|
|
36
|
-
"set-cookie-parser": "^2.7.1"
|
|
37
|
-
"uncrypto": "^0.1.3"
|
|
36
|
+
"set-cookie-parser": "^2.7.1"
|
|
38
37
|
},
|
|
39
38
|
"exports": {
|
|
40
39
|
".": {
|