better-call 1.0.28 → 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/dist/node.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { Router } from "./router-rGV6mTr8.cjs";
1
+ import { Router } from "./router-DguGh6Qa.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-EvGJRGFD.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,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
- 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 {
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): <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 & {
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-rGV6mTr8.d.cts.map
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> = 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,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
- 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 {
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): <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 & {
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-NaFkuy-s.d.ts.map
1308
+ //# sourceMappingURL=router-EvGJRGFD.d.ts.map
package/package.json CHANGED
@@ -1,11 +1,13 @@
1
1
  {
2
2
  "name": "better-call",
3
- "version": "1.0.28",
3
+ "version": "1.1.0-beta.1",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/Bekacru/better-call"
8
8
  },
9
+ "copyright": "Copyright (C) 2025 Bereket Engida",
10
+ "license": "MIT",
9
11
  "main": "./dist/index.cjs",
10
12
  "module": "./dist/index.js",
11
13
  "types": "./dist/index.d.ts",