better-call 1.0.0 → 1.0.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/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- export { A as APIError, k as CookieOptions, C as CookiePrefixOptions, b as Endpoint, a as EndpointContext, E as EndpointOptions, H as HTTPMethod, T as HasRequiredKeys, t as InferBody, I as InferBodyInput, B as InferHeaders, D as InferHeadersInput, x as InferInputMethod, w as InferMethod, G as InferMiddlewareBody, J as InferMiddlewareQuery, y as InferParam, Y as InferParamPath, Z as InferParamWildCard, v as InferQuery, u as InferQueryInput, z as InferRequest, F as InferUse, N as Input, K as InputContext, V as IsEmptyObject, X as MergeObject, r as Method, h as Middleware, e as MiddlewareContext, g as MiddlewareInputContext, M as MiddlewareOptions, d as MiddlewareResponse, n as OpenAPIParameter, O as OpenAPISchemaType, P as Path, U as Prettify, Q as RequiredKeysOf, j as Router, R as RouterConfig, $ as StandardSchemaV1, S as Status, W as UnionToIntersection, _ as _statusCode, c as createEndpoint, L as createInternalContext, f as createMiddleware, i as createRouter, o as generator, l as getCookieKey, q as getHTML, p as parseCookies, s as serializeCookie, m as serializeSignedCookie } from './router-Bpb8tT1Y.cjs';
1
+ export { A as APIError, k as CookieOptions, C as CookiePrefixOptions, b as Endpoint, a as EndpointContext, E as EndpointOptions, H as HTTPMethod, T as HasRequiredKeys, t as InferBody, I as InferBodyInput, B as InferHeaders, D as InferHeadersInput, x as InferInputMethod, w as InferMethod, G as InferMiddlewareBody, J as InferMiddlewareQuery, y as InferParam, Y as InferParamPath, Z as InferParamWildCard, v as InferQuery, u as InferQueryInput, z as InferRequest, F as InferUse, N as Input, K as InputContext, V as IsEmptyObject, X as MergeObject, r as Method, h as Middleware, e as MiddlewareContext, g as MiddlewareInputContext, M as MiddlewareOptions, d as MiddlewareResponse, n as OpenAPIParameter, O as OpenAPISchemaType, P as Path, U as Prettify, Q as RequiredKeysOf, j as Router, R as RouterConfig, $ as StandardSchemaV1, S as Status, W as UnionToIntersection, _ as _statusCode, c as createEndpoint, L as createInternalContext, f as createMiddleware, i as createRouter, o as generator, l as getCookieKey, q as getHTML, p as parseCookies, s as serializeCookie, m as serializeSignedCookie } from './router-DUkPVacX.cjs';
2
2
 
3
3
  declare function toResponse(data?: any, init?: ResponseInit): Response;
4
4
 
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { A as APIError, k as CookieOptions, C as CookiePrefixOptions, b as Endpoint, a as EndpointContext, E as EndpointOptions, H as HTTPMethod, T as HasRequiredKeys, t as InferBody, I as InferBodyInput, B as InferHeaders, D as InferHeadersInput, x as InferInputMethod, w as InferMethod, G as InferMiddlewareBody, J as InferMiddlewareQuery, y as InferParam, Y as InferParamPath, Z as InferParamWildCard, v as InferQuery, u as InferQueryInput, z as InferRequest, F as InferUse, N as Input, K as InputContext, V as IsEmptyObject, X as MergeObject, r as Method, h as Middleware, e as MiddlewareContext, g as MiddlewareInputContext, M as MiddlewareOptions, d as MiddlewareResponse, n as OpenAPIParameter, O as OpenAPISchemaType, P as Path, U as Prettify, Q as RequiredKeysOf, j as Router, R as RouterConfig, $ as StandardSchemaV1, S as Status, W as UnionToIntersection, _ as _statusCode, c as createEndpoint, L as createInternalContext, f as createMiddleware, i as createRouter, o as generator, l as getCookieKey, q as getHTML, p as parseCookies, s as serializeCookie, m as serializeSignedCookie } from './router-Bpb8tT1Y.js';
1
+ export { A as APIError, k as CookieOptions, C as CookiePrefixOptions, b as Endpoint, a as EndpointContext, E as EndpointOptions, H as HTTPMethod, T as HasRequiredKeys, t as InferBody, I as InferBodyInput, B as InferHeaders, D as InferHeadersInput, x as InferInputMethod, w as InferMethod, G as InferMiddlewareBody, J as InferMiddlewareQuery, y as InferParam, Y as InferParamPath, Z as InferParamWildCard, v as InferQuery, u as InferQueryInput, z as InferRequest, F as InferUse, N as Input, K as InputContext, V as IsEmptyObject, X as MergeObject, r as Method, h as Middleware, e as MiddlewareContext, g as MiddlewareInputContext, M as MiddlewareOptions, d as MiddlewareResponse, n as OpenAPIParameter, O as OpenAPISchemaType, P as Path, U as Prettify, Q as RequiredKeysOf, j as Router, R as RouterConfig, $ as StandardSchemaV1, S as Status, W as UnionToIntersection, _ as _statusCode, c as createEndpoint, L as createInternalContext, f as createMiddleware, i as createRouter, o as generator, l as getCookieKey, q as getHTML, p as parseCookies, s as serializeCookie, m as serializeSignedCookie } from './router-DUkPVacX.js';
2
2
 
3
3
  declare function toResponse(data?: any, init?: ResponseInit): Response;
4
4
 
package/dist/index.js CHANGED
@@ -113,10 +113,7 @@ function toResponse(data, init) {
113
113
  return toResponse(data.body, {
114
114
  status: data.statusCode,
115
115
  statusText: data.status.toString(),
116
- headers: {
117
- ...data.headers instanceof Headers ? Object.fromEntries(data.headers.entries()) : data?.headers,
118
- ...init?.headers instanceof Headers ? Object.fromEntries(init.headers.entries()) : init?.headers
119
- }
116
+ headers: init?.headers || data.headers
120
117
  });
121
118
  }
122
119
  let body = data;
@@ -4440,8 +4437,8 @@ function getTypeFromZodType(zodType) {
4440
4437
  }
4441
4438
  function getParameters(options) {
4442
4439
  const parameters = [];
4443
- if (options.metadata?.openAPI?.parameters) {
4444
- parameters.push(...options.metadata.openAPI.parameters);
4440
+ if (options.metadata?.openapi?.parameters) {
4441
+ parameters.push(...options.metadata.openapi.parameters);
4445
4442
  return parameters;
4446
4443
  }
4447
4444
  if (options.query instanceof ZodObject) {
@@ -4464,8 +4461,8 @@ function getParameters(options) {
4464
4461
  return parameters;
4465
4462
  }
4466
4463
  function getRequestBody(options) {
4467
- if (options.metadata?.openAPI?.requestBody) {
4468
- return options.metadata.openAPI.requestBody;
4464
+ if (options.metadata?.openapi?.requestBody) {
4465
+ return options.metadata.openapi.requestBody;
4469
4466
  }
4470
4467
  if (!options.body) return void 0;
4471
4468
  if (options.body instanceof ZodObject || options.body instanceof ZodOptional) {
@@ -4606,16 +4603,16 @@ async function generator(endpoints, config) {
4606
4603
  if (options.method === "GET") {
4607
4604
  paths[value.path] = {
4608
4605
  get: {
4609
- tags: ["Default", ...options.metadata?.openAPI?.tags || []],
4610
- description: options.metadata?.openAPI?.description,
4611
- operationId: options.metadata?.openAPI?.operationId,
4606
+ tags: ["Default", ...options.metadata?.openapi?.tags || []],
4607
+ description: options.metadata?.openapi?.description,
4608
+ operationId: options.metadata?.openapi?.operationId,
4612
4609
  security: [
4613
4610
  {
4614
4611
  bearerAuth: []
4615
4612
  }
4616
4613
  ],
4617
4614
  parameters: getParameters(options),
4618
- responses: getResponse(options.metadata?.openAPI?.responses)
4615
+ responses: getResponse(options.metadata?.openapi?.responses)
4619
4616
  }
4620
4617
  };
4621
4618
  }
@@ -4623,9 +4620,9 @@ async function generator(endpoints, config) {
4623
4620
  const body = getRequestBody(options);
4624
4621
  paths[value.path] = {
4625
4622
  post: {
4626
- tags: ["Default", ...options.metadata?.openAPI?.tags || []],
4627
- description: options.metadata?.openAPI?.description,
4628
- operationId: options.metadata?.openAPI?.operationId,
4623
+ tags: ["Default", ...options.metadata?.openapi?.tags || []],
4624
+ description: options.metadata?.openapi?.description,
4625
+ operationId: options.metadata?.openapi?.operationId,
4629
4626
  security: [
4630
4627
  {
4631
4628
  bearerAuth: []
@@ -4645,7 +4642,7 @@ async function generator(endpoints, config) {
4645
4642
  }
4646
4643
  }
4647
4644
  },
4648
- responses: getResponse(options.metadata?.openAPI?.responses)
4645
+ responses: getResponse(options.metadata?.openapi?.responses)
4649
4646
  }
4650
4647
  };
4651
4648
  }
@@ -4752,19 +4749,19 @@ async function getBody(request) {
4752
4749
 
4753
4750
  // src/router.ts
4754
4751
  var createRouter = (endpoints, config) => {
4755
- if (!config?.openAPI?.disabled) {
4756
- const openAPI = {
4752
+ if (!config?.openapi?.disabled) {
4753
+ const openapi = {
4757
4754
  path: "/api/reference",
4758
- ...config?.openAPI
4755
+ ...config?.openapi
4759
4756
  };
4760
- endpoints["openAPI"] = createEndpoint2(
4761
- openAPI.path,
4757
+ endpoints["openapi"] = createEndpoint2(
4758
+ openapi.path,
4762
4759
  {
4763
4760
  method: "GET"
4764
4761
  },
4765
4762
  async (c) => {
4766
4763
  const schema = await generator(endpoints);
4767
- return new Response(getHTML(schema, openAPI.scalar), {
4764
+ return new Response(getHTML(schema, openapi.scalar), {
4768
4765
  headers: {
4769
4766
  "Content-Type": "text/html"
4770
4767
  }