better-call 1.0.13 → 1.0.14

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, U as HasRequiredKeys, t as InferBody, I as InferBodyInput, F as InferHeaders, G as InferHeadersInput, x as InferInputMethod, w as InferMethod, K as InferMiddlewareBody, L as InferMiddlewareQuery, y as InferParam, z as InferParamInput, Z as InferParamPath, $ as InferParamWildCard, v as InferQuery, u as InferQueryInput, B as InferRequest, D as InferRequestInput, J as InferUse, N as InputContext, W as IsEmptyObject, Y 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, V as Prettify, T as RequiredKeysOf, j as Router, R as RouterConfig, a0 as StandardSchemaV1, S as Status, X as UnionToIntersection, _ as _statusCode, c as createEndpoint, Q 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-BEp4ze3Q.cjs';
1
+ export { A as APIError, k as CookieOptions, C as CookiePrefixOptions, b as Endpoint, a as EndpointContext, E as EndpointOptions, H as HTTPMethod, U as HasRequiredKeys, t as InferBody, I as InferBodyInput, F as InferHeaders, G as InferHeadersInput, x as InferInputMethod, w as InferMethod, K as InferMiddlewareBody, L as InferMiddlewareQuery, y as InferParam, z as InferParamInput, Z as InferParamPath, $ as InferParamWildCard, v as InferQuery, u as InferQueryInput, B as InferRequest, D as InferRequestInput, J as InferUse, N as InputContext, W as IsEmptyObject, Y 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, V as Prettify, T as RequiredKeysOf, j as Router, R as RouterConfig, a0 as StandardSchemaV1, S as Status, X as UnionToIntersection, _ as _statusCode, c as createEndpoint, Q 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-BcwNrqXF.cjs';
2
2
 
3
3
  type JSONResponse = {
4
4
  body: Record<string, any>;
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, U as HasRequiredKeys, t as InferBody, I as InferBodyInput, F as InferHeaders, G as InferHeadersInput, x as InferInputMethod, w as InferMethod, K as InferMiddlewareBody, L as InferMiddlewareQuery, y as InferParam, z as InferParamInput, Z as InferParamPath, $ as InferParamWildCard, v as InferQuery, u as InferQueryInput, B as InferRequest, D as InferRequestInput, J as InferUse, N as InputContext, W as IsEmptyObject, Y 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, V as Prettify, T as RequiredKeysOf, j as Router, R as RouterConfig, a0 as StandardSchemaV1, S as Status, X as UnionToIntersection, _ as _statusCode, c as createEndpoint, Q 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-BEp4ze3Q.js';
1
+ export { A as APIError, k as CookieOptions, C as CookiePrefixOptions, b as Endpoint, a as EndpointContext, E as EndpointOptions, H as HTTPMethod, U as HasRequiredKeys, t as InferBody, I as InferBodyInput, F as InferHeaders, G as InferHeadersInput, x as InferInputMethod, w as InferMethod, K as InferMiddlewareBody, L as InferMiddlewareQuery, y as InferParam, z as InferParamInput, Z as InferParamPath, $ as InferParamWildCard, v as InferQuery, u as InferQueryInput, B as InferRequest, D as InferRequestInput, J as InferUse, N as InputContext, W as IsEmptyObject, Y 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, V as Prettify, T as RequiredKeysOf, j as Router, R as RouterConfig, a0 as StandardSchemaV1, S as Status, X as UnionToIntersection, _ as _statusCode, c as createEndpoint, Q 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-BcwNrqXF.js';
2
2
 
3
3
  type JSONResponse = {
4
4
  body: Record<string, any>;
package/dist/index.js CHANGED
@@ -1,10 +1,71 @@
1
1
  var __defProp = Object.defineProperty;
2
+ var __typeError = (msg) => {
3
+ throw TypeError(msg);
4
+ };
2
5
  var __export = (target, all) => {
3
6
  for (var name in all)
4
7
  __defProp(target, name, { get: all[name], enumerable: true });
5
8
  };
9
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
10
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
11
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
12
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
6
13
 
7
14
  // src/error.ts
15
+ function isErrorStackTraceLimitWritable() {
16
+ const desc = Object.getOwnPropertyDescriptor(Error, "stackTraceLimit");
17
+ if (desc === void 0) {
18
+ return Object.isExtensible(Error);
19
+ }
20
+ return Object.prototype.hasOwnProperty.call(desc, "writable") ? desc.writable : desc.set !== void 0;
21
+ }
22
+ var ErrorWithStack = class extends Error {
23
+ constructor() {
24
+ super();
25
+ this.name = "ErrorWithStack";
26
+ }
27
+ };
28
+ function hideInternalStackFrames(stack) {
29
+ const lines = stack.split("\n at ");
30
+ if (lines.length <= 1) {
31
+ return stack;
32
+ }
33
+ lines.splice(1, 1);
34
+ return lines.join("\n at ");
35
+ }
36
+ function makeErrorForHideStackFrame(Base, clazz) {
37
+ var _errorWithStack;
38
+ class HideStackFramesError extends Base {
39
+ // This is a workaround for wpt tests that expect that the error
40
+ // constructor has a `name` property of the base class.
41
+ get ["constructor"]() {
42
+ var __super = (...args) => {
43
+ super(...args);
44
+ __privateAdd(this, _errorWithStack);
45
+ return this;
46
+ };
47
+ return clazz;
48
+ }
49
+ constructor(...args2) {
50
+ if (isErrorStackTraceLimitWritable()) {
51
+ const limit = Error.stackTraceLimit;
52
+ Error.stackTraceLimit = 0;
53
+ __super(...args2);
54
+ Error.stackTraceLimit = limit;
55
+ } else {
56
+ __super(...args2);
57
+ }
58
+ __privateSet(this, _errorWithStack, new ErrorWithStack());
59
+ __privateGet(this, _errorWithStack).stack = hideInternalStackFrames(__privateGet(this, _errorWithStack).stack ?? "");
60
+ }
61
+ // use `getter` here to avoid the stack trace being captured by loggers
62
+ get errorWithStack() {
63
+ return __privateGet(this, _errorWithStack);
64
+ }
65
+ }
66
+ _errorWithStack = new WeakMap();
67
+ return HideStackFramesError;
68
+ }
8
69
  var _statusCode = {
9
70
  OK: 200,
10
71
  CREATED: 201,
@@ -57,9 +118,14 @@ var _statusCode = {
57
118
  NOT_EXTENDED: 510,
58
119
  NETWORK_AUTHENTICATION_REQUIRED: 511
59
120
  };
60
- var APIError = class extends Error {
121
+ var InternalAPIError = class extends Error {
61
122
  constructor(status = "INTERNAL_SERVER_ERROR", body = void 0, headers = {}, statusCode = typeof status === "number" ? status : _statusCode[status]) {
62
- super(body?.message);
123
+ super(
124
+ body?.message,
125
+ body?.cause ? {
126
+ cause: body.cause
127
+ } : void 0
128
+ );
63
129
  this.status = status;
64
130
  this.body = body;
65
131
  this.headers = headers;
@@ -72,9 +138,9 @@ var APIError = class extends Error {
72
138
  code: body?.message?.toUpperCase().replace(/ /g, "_").replace(/[^A-Z0-9_]/g, ""),
73
139
  ...body
74
140
  } : void 0;
75
- this.stack = "";
76
141
  }
77
142
  };
143
+ var APIError = makeErrorForHideStackFrame(InternalAPIError, Error);
78
144
 
79
145
  // src/utils.ts
80
146
  async function getBody(request) {