better-call 1.0.29 → 1.1.0-beta.2
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 +16 -4
- package/dist/client.d.ts +16 -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-NaFkuy-s.d.ts → router-DgnLO11b.d.ts} +29 -9
- package/dist/{router-rGV6mTr8.d.cts → router-DxkLDx_d.d.cts} +29 -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,24 @@ 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
|
+
* If enabled, endpoint won't be exposed as an action to the client
|
|
939
|
+
* @deprecated Use path-less endpoints instead
|
|
940
|
+
*/
|
|
941
|
+
isAction?: boolean;
|
|
942
|
+
/**
|
|
943
|
+
* Defines the places where the endpoint will be available
|
|
944
|
+
*
|
|
945
|
+
* Possible options:
|
|
946
|
+
* - `rpc` - the endpoint is exposed to the router, can be invoked directly and is available to the client
|
|
947
|
+
* - `server` - the endpoint is exposed to the router, can be invoked directly, but is not available to the client
|
|
948
|
+
* - `http` - the endpoint is only exposed to the router
|
|
949
|
+
* @default "rpc"
|
|
950
|
+
*/
|
|
951
|
+
scope?: "rpc" | "server" | "http";
|
|
934
952
|
/**
|
|
935
953
|
* List of allowed media types (MIME types) for the endpoint
|
|
936
954
|
*
|
|
@@ -1144,14 +1162,16 @@ type EndpointContext<Path extends string, Options extends EndpointOptions, Conte
|
|
|
1144
1162
|
code?: string;
|
|
1145
1163
|
} & Record<string, any>, headers?: HeadersInit) => APIError;
|
|
1146
1164
|
};
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1165
|
+
type EndpointHandler<Path extends string, Options extends EndpointOptions, R> = (context: EndpointContext<Path, Options>) => Promise<R>;
|
|
1166
|
+
declare function createEndpoint<Path extends string, Options extends EndpointOptions, R>(path: Path, options: Options, handler: EndpointHandler<Path, Options, R>): StrictEndpoint<Path, Options, R>;
|
|
1167
|
+
declare function createEndpoint<Options extends EndpointOptions, R>(options: Options, handler: EndpointHandler<never, Options, R>): StrictEndpoint<never, Options, R>;
|
|
1168
|
+
declare namespace createEndpoint {
|
|
1169
|
+
var create: <E extends {
|
|
1150
1170
|
use?: Middleware[];
|
|
1151
|
-
}>(opts?: E)
|
|
1171
|
+
}>(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
1172
|
use: any[];
|
|
1153
1173
|
}, any>;
|
|
1154
|
-
}
|
|
1174
|
+
}
|
|
1155
1175
|
type StrictEndpoint<Path extends string, Options extends EndpointOptions, R = any> = {
|
|
1156
1176
|
(context: InputContext<Path, Options> & {
|
|
1157
1177
|
asResponse: true;
|
|
@@ -1290,4 +1310,4 @@ declare const createRouter: <E extends Record<string, Endpoint>, Config extends
|
|
|
1290
1310
|
type Router = ReturnType<typeof createRouter>;
|
|
1291
1311
|
//#endregion
|
|
1292
1312
|
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-
|
|
1313
|
+
//# sourceMappingURL=router-DgnLO11b.d.ts.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,24 @@ 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
|
+
* If enabled, endpoint won't be exposed as an action to the client
|
|
939
|
+
* @deprecated Use path-less endpoints instead
|
|
940
|
+
*/
|
|
941
|
+
isAction?: boolean;
|
|
942
|
+
/**
|
|
943
|
+
* Defines the places where the endpoint will be available
|
|
944
|
+
*
|
|
945
|
+
* Possible options:
|
|
946
|
+
* - `rpc` - the endpoint is exposed to the router, can be invoked directly and is available to the client
|
|
947
|
+
* - `server` - the endpoint is exposed to the router, can be invoked directly, but is not available to the client
|
|
948
|
+
* - `http` - the endpoint is only exposed to the router
|
|
949
|
+
* @default "rpc"
|
|
950
|
+
*/
|
|
951
|
+
scope?: "rpc" | "server" | "http";
|
|
934
952
|
/**
|
|
935
953
|
* List of allowed media types (MIME types) for the endpoint
|
|
936
954
|
*
|
|
@@ -1144,14 +1162,16 @@ type EndpointContext<Path extends string, Options extends EndpointOptions, Conte
|
|
|
1144
1162
|
code?: string;
|
|
1145
1163
|
} & Record<string, any>, headers?: HeadersInit) => APIError;
|
|
1146
1164
|
};
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1165
|
+
type EndpointHandler<Path extends string, Options extends EndpointOptions, R> = (context: EndpointContext<Path, Options>) => Promise<R>;
|
|
1166
|
+
declare function createEndpoint<Path extends string, Options extends EndpointOptions, R>(path: Path, options: Options, handler: EndpointHandler<Path, Options, R>): StrictEndpoint<Path, Options, R>;
|
|
1167
|
+
declare function createEndpoint<Options extends EndpointOptions, R>(options: Options, handler: EndpointHandler<never, Options, R>): StrictEndpoint<never, Options, R>;
|
|
1168
|
+
declare namespace createEndpoint {
|
|
1169
|
+
var create: <E extends {
|
|
1150
1170
|
use?: Middleware[];
|
|
1151
|
-
}>(opts?: E)
|
|
1171
|
+
}>(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
1172
|
use: any[];
|
|
1153
1173
|
}, any>;
|
|
1154
|
-
}
|
|
1174
|
+
}
|
|
1155
1175
|
type StrictEndpoint<Path extends string, Options extends EndpointOptions, R = any> = {
|
|
1156
1176
|
(context: InputContext<Path, Options> & {
|
|
1157
1177
|
asResponse: true;
|
|
@@ -1290,4 +1310,4 @@ declare const createRouter: <E extends Record<string, Endpoint>, Config extends
|
|
|
1290
1310
|
type Router = ReturnType<typeof createRouter>;
|
|
1291
1311
|
//#endregion
|
|
1292
1312
|
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-
|
|
1313
|
+
//# sourceMappingURL=router-DxkLDx_d.d.cts.map
|