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/dist/node.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { Router } from "./router-rGV6mTr8.cjs";
1
+ import { Router } from "./router-DxkLDx_d.cjs";
2
2
  import { IncomingMessage, ServerResponse } from "node:http";
3
3
 
4
4
  //#region src/adapters/node/request.d.ts
package/dist/node.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Router } from "./router-NaFkuy-s.js";
1
+ import { Router } from "./router-DgnLO11b.js";
2
2
  import { IncomingMessage, ServerResponse } from "node:http";
3
3
 
4
4
  //#region src/adapters/node/request.d.ts
@@ -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> = IsEmptyObject<InferParamPath<Path> & InferParamWildCard<Path>> extends true ? {
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: string;
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
- declare const createEndpoint: {
1148
- <Path extends string, Options extends EndpointOptions, R>(path: Path, options: Options, handler: (context: EndpointContext<Path, Options>) => Promise<R>): StrictEndpoint<Path, Options, R>;
1149
- create<E extends {
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): <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 & {
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-NaFkuy-s.d.ts.map
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> = IsEmptyObject<InferParamPath<Path> & InferParamWildCard<Path>> extends true ? {
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: string;
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
- declare const createEndpoint: {
1148
- <Path extends string, Options extends EndpointOptions, R>(path: Path, options: Options, handler: (context: EndpointContext<Path, Options>) => Promise<R>): StrictEndpoint<Path, Options, R>;
1149
- create<E extends {
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): <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 & {
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-rGV6mTr8.d.cts.map
1313
+ //# sourceMappingURL=router-DxkLDx_d.d.cts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "better-call",
3
- "version": "1.0.29",
3
+ "version": "1.1.0-beta.2",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",