effect 4.0.0-beta.91 → 4.0.0-beta.93

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.
Files changed (45) hide show
  1. package/dist/Cause.d.ts +3 -1
  2. package/dist/Cause.d.ts.map +1 -1
  3. package/dist/Cause.js.map +1 -1
  4. package/dist/Schema.d.ts.map +1 -1
  5. package/dist/Schema.js +13 -7
  6. package/dist/Schema.js.map +1 -1
  7. package/dist/internal/core.js +1 -1
  8. package/dist/internal/effect.js +8 -6
  9. package/dist/internal/effect.js.map +1 -1
  10. package/dist/unstable/http/HttpBody.d.ts +1 -1
  11. package/dist/unstable/http/HttpBody.d.ts.map +1 -1
  12. package/dist/unstable/http/HttpBody.js +1 -1
  13. package/dist/unstable/http/HttpBody.js.map +1 -1
  14. package/dist/unstable/http/HttpClient.js +2 -2
  15. package/dist/unstable/http/HttpClient.js.map +1 -1
  16. package/dist/unstable/http/HttpClientRequest.d.ts +5 -4
  17. package/dist/unstable/http/HttpClientRequest.d.ts.map +1 -1
  18. package/dist/unstable/http/HttpClientRequest.js +5 -4
  19. package/dist/unstable/http/HttpClientRequest.js.map +1 -1
  20. package/dist/unstable/http/Url.d.ts +29 -4
  21. package/dist/unstable/http/Url.d.ts.map +1 -1
  22. package/dist/unstable/http/Url.js +44 -2
  23. package/dist/unstable/http/Url.js.map +1 -1
  24. package/dist/unstable/http/UrlParams.d.ts +2 -28
  25. package/dist/unstable/http/UrlParams.d.ts.map +1 -1
  26. package/dist/unstable/http/UrlParams.js +4 -46
  27. package/dist/unstable/http/UrlParams.js.map +1 -1
  28. package/dist/unstable/httpapi/HttpApiBuilder.d.ts.map +1 -1
  29. package/dist/unstable/httpapi/HttpApiBuilder.js +30 -15
  30. package/dist/unstable/httpapi/HttpApiBuilder.js.map +1 -1
  31. package/dist/unstable/observability/OtlpTracer.d.ts.map +1 -1
  32. package/dist/unstable/observability/OtlpTracer.js +4 -3
  33. package/dist/unstable/observability/OtlpTracer.js.map +1 -1
  34. package/package.json +1 -1
  35. package/src/Cause.ts +3 -1
  36. package/src/Schema.ts +17 -3
  37. package/src/internal/core.ts +1 -1
  38. package/src/internal/effect.ts +14 -6
  39. package/src/unstable/http/HttpBody.ts +2 -2
  40. package/src/unstable/http/HttpClient.ts +2 -2
  41. package/src/unstable/http/HttpClientRequest.ts +8 -7
  42. package/src/unstable/http/Url.ts +62 -7
  43. package/src/unstable/http/UrlParams.ts +5 -58
  44. package/src/unstable/httpapi/HttpApiBuilder.ts +33 -21
  45. package/src/unstable/observability/OtlpTracer.ts +4 -3
@@ -59,7 +59,7 @@ export const StructuralProto = {
59
59
  const thatKeys = Object.keys(that);
60
60
  if (selfKeys.length !== thatKeys.length) return false;
61
61
  for (let i = 0; i < selfKeys.length; i++) {
62
- if (selfKeys[i] !== thatKeys[i] && !Equal.equals(this[selfKeys[i]], that[selfKeys[i]])) {
62
+ if (selfKeys[i] !== thatKeys[i] || !Equal.equals(this[selfKeys[i]], that[selfKeys[i]])) {
63
63
  return false;
64
64
  }
65
65
  }
@@ -174,7 +174,7 @@ export const causeSquash = self => {
174
174
  return new globalThis.Error("Empty cause");
175
175
  };
176
176
  /** @internal */
177
- export const causePrettyErrors = self => {
177
+ export const causePrettyErrors = (self, options) => {
178
178
  const errors = [];
179
179
  const interrupts = [];
180
180
  if (self.reasons.length === 0) return errors;
@@ -185,7 +185,7 @@ export const causePrettyErrors = self => {
185
185
  interrupts.push(failure);
186
186
  continue;
187
187
  }
188
- errors.push(causePrettyError(failure._tag === "Die" ? failure.defect : failure.error, failure.annotations));
188
+ errors.push(causePrettyError(failure._tag === "Die" ? failure.defect : failure.error, failure.annotations, options));
189
189
  }
190
190
  if (errors.length === 0) {
191
191
  const cause = new Error("The fiber was interrupted by:");
@@ -196,13 +196,13 @@ export const causePrettyErrors = self => {
196
196
  });
197
197
  error.name = "InterruptError";
198
198
  error.stack = `${error.name}: ${error.message}`;
199
- errors.push(causePrettyError(error, interrupts[0].annotations));
199
+ errors.push(causePrettyError(error, interrupts[0].annotations, options));
200
200
  }
201
201
  setStackTraceLimit(prevStackLimit);
202
202
  return errors;
203
203
  };
204
204
  /** @internal */
205
- export const causePrettyError = (original, annotations) => {
205
+ export const causePrettyError = (original, annotations, options) => {
206
206
  const kind = typeof original;
207
207
  let error;
208
208
  if (original && kind === "object") {
@@ -218,6 +218,9 @@ export const causePrettyError = (original, annotations) => {
218
218
  const stack = `${error.name}: ${error.message}`;
219
219
  error.stack = annotations ? addStackAnnotations(stack, annotations) : stack;
220
220
  }
221
+ if (options?.includeCauseInStack) {
222
+ error.stack = renderPrettyError(error);
223
+ }
221
224
  for (const key of Object.keys(original)) {
222
225
  if (!(key in error)) {
223
226
  ;
@@ -297,8 +300,7 @@ const currentStackTrace = frame => {
297
300
  };
298
301
  /** @internal */
299
302
  export const causePretty = cause => causePrettyErrors(cause).map(renderPrettyError).join("\n");
300
- /** @internal */
301
- export const renderPrettyError = e => e.cause ? `${e.stack} {\n${renderErrorCause(e.cause, " ")}\n}` : e.stack;
303
+ const renderPrettyError = e => e.cause ? `${e.stack} {\n${renderErrorCause(e.cause, " ")}\n}` : e.stack;
302
304
  const renderErrorCause = (cause, prefix) => {
303
305
  const lines = cause.stack.split("\n");
304
306
  let stack = `${prefix}[cause]: ${lines[0]}`;