better-call 1.0.29 → 1.1.0-beta.1
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 +54 -0
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +12 -4
- package/dist/client.d.ts +12 -4
- package/dist/client.js.map +1 -1
- package/dist/index.cjs +8 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +8 -5
- package/dist/index.js.map +1 -1
- package/dist/node.d.cts +1 -1
- package/dist/node.d.ts +1 -1
- package/dist/{router-rGV6mTr8.d.cts → router-DguGh6Qa.d.cts} +24 -9
- package/dist/{router-NaFkuy-s.d.ts → router-EvGJRGFD.d.ts} +24 -9
- package/package.json +1 -1
package/dist/node.d.cts
CHANGED
package/dist/node.d.ts
CHANGED
|
@@ -296,8 +296,10 @@ type InferInputMethod<Options extends EndpointOptions, Method = (Options["method
|
|
|
296
296
|
} : {
|
|
297
297
|
method: Method;
|
|
298
298
|
};
|
|
299
|
-
type InferParam<Path extends string> = IsEmptyObject<InferParamPath<Path> & InferParamWildCard<Path>> extends true ? Record<string, any> | undefined : Prettify<InferParamPath<Path> & InferParamWildCard<Path>>;
|
|
300
|
-
type InferParamInput<Path extends string> =
|
|
299
|
+
type InferParam<Path extends string> = [Path] extends [never] ? Record<string, any> | undefined : IsEmptyObject<InferParamPath<Path> & InferParamWildCard<Path>> extends true ? Record<string, any> | undefined : Prettify<InferParamPath<Path> & InferParamWildCard<Path>>;
|
|
300
|
+
type InferParamInput<Path extends string> = [Path] extends [never] ? {
|
|
301
|
+
params?: Record<string, any>;
|
|
302
|
+
} : IsEmptyObject<InferParamPath<Path> & InferParamWildCard<Path>> extends true ? {
|
|
301
303
|
params?: Record<string, any>;
|
|
302
304
|
} : {
|
|
303
305
|
params: Prettify<InferParamPath<Path> & InferParamWildCard<Path>>;
|
|
@@ -329,7 +331,7 @@ declare const createInternalContext: (context: InputContext<any, any>, {
|
|
|
329
331
|
path
|
|
330
332
|
}: {
|
|
331
333
|
options: EndpointOptions;
|
|
332
|
-
path
|
|
334
|
+
path?: string;
|
|
333
335
|
}) => Promise<{
|
|
334
336
|
body: any;
|
|
335
337
|
query: any;
|
|
@@ -929,8 +931,19 @@ interface EndpointBaseOptions {
|
|
|
929
931
|
};
|
|
930
932
|
/**
|
|
931
933
|
* If enabled, endpoint won't be exposed over a router
|
|
934
|
+
* @deprecated Use path-less endpoints instead
|
|
932
935
|
*/
|
|
933
936
|
SERVER_ONLY?: boolean;
|
|
937
|
+
/**
|
|
938
|
+
* Defines the places where the endpoint will be available
|
|
939
|
+
*
|
|
940
|
+
* Possible options:
|
|
941
|
+
* - `rpc` - the endpoint is exposed to the router, can be invoked directly and is available to the client
|
|
942
|
+
* - `server` - the endpoint is exposed to the router, can be invoked directly, but is not available to the client
|
|
943
|
+
* - `http` - the endpoint is only exposed to the router
|
|
944
|
+
* @default "rpc"
|
|
945
|
+
*/
|
|
946
|
+
scope?: "rpc" | "server" | "http";
|
|
934
947
|
/**
|
|
935
948
|
* List of allowed media types (MIME types) for the endpoint
|
|
936
949
|
*
|
|
@@ -1144,14 +1157,16 @@ type EndpointContext<Path extends string, Options extends EndpointOptions, Conte
|
|
|
1144
1157
|
code?: string;
|
|
1145
1158
|
} & Record<string, any>, headers?: HeadersInit) => APIError;
|
|
1146
1159
|
};
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1160
|
+
type EndpointHandler<Path extends string, Options extends EndpointOptions, R> = (context: EndpointContext<Path, Options>) => Promise<R>;
|
|
1161
|
+
declare function createEndpoint<Path extends string, Options extends EndpointOptions, R>(path: Path, options: Options, handler: EndpointHandler<Path, Options, R>): StrictEndpoint<Path, Options, R>;
|
|
1162
|
+
declare function createEndpoint<Options extends EndpointOptions, R>(options: Options, handler: EndpointHandler<never, Options, R>): StrictEndpoint<never, Options, R>;
|
|
1163
|
+
declare namespace createEndpoint {
|
|
1164
|
+
var create: <E extends {
|
|
1150
1165
|
use?: Middleware[];
|
|
1151
|
-
}>(opts?: E)
|
|
1166
|
+
}>(opts?: E) => <Path extends string, Opts extends EndpointOptions, R extends Promise<any>>(path: Path, options: Opts, handler: (ctx: EndpointContext<Path, Opts, InferUse<E["use"]>>) => R) => StrictEndpoint<Path, Opts & {
|
|
1152
1167
|
use: any[];
|
|
1153
1168
|
}, any>;
|
|
1154
|
-
}
|
|
1169
|
+
}
|
|
1155
1170
|
type StrictEndpoint<Path extends string, Options extends EndpointOptions, R = any> = {
|
|
1156
1171
|
(context: InputContext<Path, Options> & {
|
|
1157
1172
|
asResponse: true;
|
|
@@ -1290,4 +1305,4 @@ declare const createRouter: <E extends Record<string, Endpoint>, Config extends
|
|
|
1290
1305
|
type Router = ReturnType<typeof createRouter>;
|
|
1291
1306
|
//#endregion
|
|
1292
1307
|
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, createEndpoint, createInternalContext, createMiddleware, createRouter, generator, getCookieKey, getHTML, hideInternalStackFrames, makeErrorForHideStackFrame, parseCookies, serializeCookie, serializeSignedCookie, statusCodes };
|
|
1293
|
-
//# sourceMappingURL=router-
|
|
1308
|
+
//# sourceMappingURL=router-DguGh6Qa.d.cts.map
|
|
@@ -296,8 +296,10 @@ type InferInputMethod<Options extends EndpointOptions, Method = (Options["method
|
|
|
296
296
|
} : {
|
|
297
297
|
method: Method;
|
|
298
298
|
};
|
|
299
|
-
type InferParam<Path extends string> = IsEmptyObject<InferParamPath<Path> & InferParamWildCard<Path>> extends true ? Record<string, any> | undefined : Prettify<InferParamPath<Path> & InferParamWildCard<Path>>;
|
|
300
|
-
type InferParamInput<Path extends string> =
|
|
299
|
+
type InferParam<Path extends string> = [Path] extends [never] ? Record<string, any> | undefined : IsEmptyObject<InferParamPath<Path> & InferParamWildCard<Path>> extends true ? Record<string, any> | undefined : Prettify<InferParamPath<Path> & InferParamWildCard<Path>>;
|
|
300
|
+
type InferParamInput<Path extends string> = [Path] extends [never] ? {
|
|
301
|
+
params?: Record<string, any>;
|
|
302
|
+
} : IsEmptyObject<InferParamPath<Path> & InferParamWildCard<Path>> extends true ? {
|
|
301
303
|
params?: Record<string, any>;
|
|
302
304
|
} : {
|
|
303
305
|
params: Prettify<InferParamPath<Path> & InferParamWildCard<Path>>;
|
|
@@ -329,7 +331,7 @@ declare const createInternalContext: (context: InputContext<any, any>, {
|
|
|
329
331
|
path
|
|
330
332
|
}: {
|
|
331
333
|
options: EndpointOptions;
|
|
332
|
-
path
|
|
334
|
+
path?: string;
|
|
333
335
|
}) => Promise<{
|
|
334
336
|
body: any;
|
|
335
337
|
query: any;
|
|
@@ -929,8 +931,19 @@ interface EndpointBaseOptions {
|
|
|
929
931
|
};
|
|
930
932
|
/**
|
|
931
933
|
* If enabled, endpoint won't be exposed over a router
|
|
934
|
+
* @deprecated Use path-less endpoints instead
|
|
932
935
|
*/
|
|
933
936
|
SERVER_ONLY?: boolean;
|
|
937
|
+
/**
|
|
938
|
+
* Defines the places where the endpoint will be available
|
|
939
|
+
*
|
|
940
|
+
* Possible options:
|
|
941
|
+
* - `rpc` - the endpoint is exposed to the router, can be invoked directly and is available to the client
|
|
942
|
+
* - `server` - the endpoint is exposed to the router, can be invoked directly, but is not available to the client
|
|
943
|
+
* - `http` - the endpoint is only exposed to the router
|
|
944
|
+
* @default "rpc"
|
|
945
|
+
*/
|
|
946
|
+
scope?: "rpc" | "server" | "http";
|
|
934
947
|
/**
|
|
935
948
|
* List of allowed media types (MIME types) for the endpoint
|
|
936
949
|
*
|
|
@@ -1144,14 +1157,16 @@ type EndpointContext<Path extends string, Options extends EndpointOptions, Conte
|
|
|
1144
1157
|
code?: string;
|
|
1145
1158
|
} & Record<string, any>, headers?: HeadersInit) => APIError;
|
|
1146
1159
|
};
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1160
|
+
type EndpointHandler<Path extends string, Options extends EndpointOptions, R> = (context: EndpointContext<Path, Options>) => Promise<R>;
|
|
1161
|
+
declare function createEndpoint<Path extends string, Options extends EndpointOptions, R>(path: Path, options: Options, handler: EndpointHandler<Path, Options, R>): StrictEndpoint<Path, Options, R>;
|
|
1162
|
+
declare function createEndpoint<Options extends EndpointOptions, R>(options: Options, handler: EndpointHandler<never, Options, R>): StrictEndpoint<never, Options, R>;
|
|
1163
|
+
declare namespace createEndpoint {
|
|
1164
|
+
var create: <E extends {
|
|
1150
1165
|
use?: Middleware[];
|
|
1151
|
-
}>(opts?: E)
|
|
1166
|
+
}>(opts?: E) => <Path extends string, Opts extends EndpointOptions, R extends Promise<any>>(path: Path, options: Opts, handler: (ctx: EndpointContext<Path, Opts, InferUse<E["use"]>>) => R) => StrictEndpoint<Path, Opts & {
|
|
1152
1167
|
use: any[];
|
|
1153
1168
|
}, any>;
|
|
1154
|
-
}
|
|
1169
|
+
}
|
|
1155
1170
|
type StrictEndpoint<Path extends string, Options extends EndpointOptions, R = any> = {
|
|
1156
1171
|
(context: InputContext<Path, Options> & {
|
|
1157
1172
|
asResponse: true;
|
|
@@ -1290,4 +1305,4 @@ declare const createRouter: <E extends Record<string, Endpoint>, Config extends
|
|
|
1290
1305
|
type Router = ReturnType<typeof createRouter>;
|
|
1291
1306
|
//#endregion
|
|
1292
1307
|
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, createEndpoint, createInternalContext, createMiddleware, createRouter, generator, getCookieKey, getHTML, hideInternalStackFrames, makeErrorForHideStackFrame, parseCookies, serializeCookie, serializeSignedCookie, statusCodes };
|
|
1293
|
-
//# sourceMappingURL=router-
|
|
1308
|
+
//# sourceMappingURL=router-EvGJRGFD.d.ts.map
|