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
@@ -15,7 +15,6 @@ import * as Config from "../../Config.js";
15
15
  import * as Duration from "../../Duration.js";
16
16
  import * as Effect from "../../Effect.js";
17
17
  import { flow } from "../../Function.js";
18
- import { renderPrettyError } from "../../internal/effect.js";
19
18
  import * as Layer from "../../Layer.js";
20
19
  import * as Option from "../../Option.js";
21
20
  import * as Tracer from "../../Tracer.js";
@@ -204,7 +203,9 @@ const makeOtlpSpan = self => {
204
203
  }
205
204
  });
206
205
  } else {
207
- const errors = Cause.prettyErrors(status.exit.cause);
206
+ const errors = Cause.prettyErrors(status.exit.cause, {
207
+ includeCauseInStack: true
208
+ });
208
209
  otelStatus = {
209
210
  code: StatusCode.Error
210
211
  };
@@ -228,7 +229,7 @@ const makeOtlpSpan = self => {
228
229
  }, {
229
230
  "key": "exception.stacktrace",
230
231
  "value": {
231
- "stringValue": renderPrettyError(error) ?? "No stack trace available"
232
+ "stringValue": error.stack ?? "No stack trace available"
232
233
  }
233
234
  }]
234
235
  });
@@ -1 +1 @@
1
- {"version":3,"file":"OtlpTracer.js","names":["Cause","Config","Duration","Effect","flow","renderPrettyError","Layer","Option","Tracer","OtlpEnv","Exporter","entriesToAttributes","OtlpResource","OtlpSerialization","make","fnUntraced","options","otelResource","fromConfig","resource","serialization","scope","name","serviceNameUnsafe","exporter","label","url","headers","exportInterval","seconds","maxBatchSize","body","spans","data","resourceSpans","scopeSpans","traces","shutdownTimeout","exportFn","span","sampled","push","makeOtlpSpan","makeSpan","status","_tag","startTime","attributes","Map","export","context","primitive","fiber","currentSpan","undefined","layer","effect","layerFromConfig","gen","disabled","endpoint","exporters","all","boolean","pipe","withDefault","includes","empty","baseTimeout","tracesTimeout","exportTimeout","scheduleDelay","option","int","map","millis","firstSomeOf","_","toString","getOrUndefined","orDie","unwrap","SpanProto","end","endTime","exit","attribute","key","value","set","event","events","addLinks","links","self","Object","assign","create","isSome","parent","traceId","generateId","spanId","len","chars","result","i","Math","floor","random","length","entries","timeUnixNano","String","droppedAttributesCount","otelStatus","constOtelStatusSuccess","hasInterruptsOnly","cause","code","StatusCode","Ok","message","stringValue","boolValue","errors","prettyErrors","Error","error","parentSpanId","match","onNone","onSome","kind","SpanKind","startTimeUnixNano","endTimeUnixNano","droppedEventsCount","link","droppedLinksCount","Unset","unspecified","internal","server","client","producer","consumer"],"sources":["../../../src/unstable/observability/OtlpTracer.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;;;;;AAYA,OAAO,KAAKA,KAAK,MAAM,gBAAgB;AACvC,OAAO,KAAKC,MAAM,MAAM,iBAAiB;AAEzC,OAAO,KAAKC,QAAQ,MAAM,mBAAmB;AAC7C,OAAO,KAAKC,MAAM,MAAM,iBAAiB;AAEzC,SAASC,IAAI,QAAQ,mBAAmB;AACxC,SAASC,iBAAiB,QAAQ,0BAA0B;AAC5D,OAAO,KAAKC,KAAK,MAAM,gBAAgB;AACvC,OAAO,KAAKC,MAAM,MAAM,iBAAiB;AAEzC,OAAO,KAAKC,MAAM,MAAM,iBAAiB;AAIzC,OAAO,KAAKC,OAAO,MAAM,uBAAuB;AAChD,OAAO,KAAKC,QAAQ,MAAM,mBAAmB;AAE7C,SAASC,mBAAmB,QAAQ,mBAAmB;AACvD,OAAO,KAAKC,YAAY,MAAM,mBAAmB;AACjD,SAASC,iBAAiB,QAAQ,wBAAwB;AAE1D;;;;;;;;;;;AAWA,OAAO,MAAMC,IAAI,gBAkBbX,M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,EAAEwE,IAAI,CAACxE,IAAI;IACf+G,IAAI,EAAEC,QAAQ,CAACxC,IAAI,CAACuC,IAAI,CAAC;IACzBE,iBAAiB,EAAEtB,MAAM,CAACrE,MAAM,CAACE,SAAS,CAAC;IAC3C0F,eAAe,EAAEvB,MAAM,CAACrE,MAAM,CAACwC,OAAO,CAAC;IACvCrC,UAAU;IACVmE,sBAAsB,EAAE,CAAC;IACzBvB,MAAM;IACN8C,kBAAkB,EAAE,CAAC;IACrB7F,MAAM,EAAEuE,UAAU;IAClBtB,KAAK,EAAEC,IAAI,CAACD,KAAK,CAACnB,GAAG,CAAEgE,IAAI,KAAM;MAC/BtC,OAAO,EAAEsC,IAAI,CAACnG,IAAI,CAAC6D,OAAO;MAC1BE,MAAM,EAAEoC,IAAI,CAACnG,IAAI,CAAC+D,MAAM;MACxBvD,UAAU,EAAEpC,mBAAmB,CAACoF,MAAM,CAACgB,OAAO,CAAC2B,IAAI,CAAC3F,UAAU,CAAC,CAAC;MAChEmE,sBAAsB,EAAE;KACzB,CAAC,CAAC;IACHyB,iBAAiB,EAAE;GACpB;AACH,CAAC;AA4ED,MAAMnB,UAAU,GAAG;EACjBoB,KAAK,EAAE,CAAC;EACRnB,EAAE,EAAE,CAAC;EACLM,KAAK,EAAE;CACC;AAIV,MAAMO,QAAQ,GAAG;EACfO,WAAW,EAAE,CAAC;EACdC,QAAQ,EAAE,CAAC;EACXC,MAAM,EAAE,CAAC;EACTC,MAAM,EAAE,CAAC;EACTC,QAAQ,EAAE,CAAC;EACXC,QAAQ,EAAE;CACF;AAEV,MAAM9B,sBAAsB,GAAW;EACrCG,IAAI,EAAEC,UAAU,CAACC;CAClB","ignoreList":[]}
1
+ {"version":3,"file":"OtlpTracer.js","names":["Cause","Config","Duration","Effect","flow","Layer","Option","Tracer","OtlpEnv","Exporter","entriesToAttributes","OtlpResource","OtlpSerialization","make","fnUntraced","options","otelResource","fromConfig","resource","serialization","scope","name","serviceNameUnsafe","exporter","label","url","headers","exportInterval","seconds","maxBatchSize","body","spans","data","resourceSpans","scopeSpans","traces","shutdownTimeout","exportFn","span","sampled","push","makeOtlpSpan","makeSpan","status","_tag","startTime","attributes","Map","export","context","primitive","fiber","currentSpan","undefined","layer","effect","layerFromConfig","gen","disabled","endpoint","exporters","all","boolean","pipe","withDefault","includes","empty","baseTimeout","tracesTimeout","exportTimeout","scheduleDelay","option","int","map","millis","firstSomeOf","_","toString","getOrUndefined","orDie","unwrap","SpanProto","end","endTime","exit","attribute","key","value","set","event","events","addLinks","links","self","Object","assign","create","isSome","parent","traceId","generateId","spanId","len","chars","result","i","Math","floor","random","length","entries","timeUnixNano","String","droppedAttributesCount","otelStatus","constOtelStatusSuccess","hasInterruptsOnly","cause","code","StatusCode","Ok","message","stringValue","boolValue","errors","prettyErrors","includeCauseInStack","Error","error","stack","parentSpanId","match","onNone","onSome","kind","SpanKind","startTimeUnixNano","endTimeUnixNano","droppedEventsCount","link","droppedLinksCount","Unset","unspecified","internal","server","client","producer","consumer"],"sources":["../../../src/unstable/observability/OtlpTracer.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;;;;;AAYA,OAAO,KAAKA,KAAK,MAAM,gBAAgB;AACvC,OAAO,KAAKC,MAAM,MAAM,iBAAiB;AAEzC,OAAO,KAAKC,QAAQ,MAAM,mBAAmB;AAC7C,OAAO,KAAKC,MAAM,MAAM,iBAAiB;AAEzC,SAASC,IAAI,QAAQ,mBAAmB;AACxC,OAAO,KAAKC,KAAK,MAAM,gBAAgB;AACvC,OAAO,KAAKC,MAAM,MAAM,iBAAiB;AAEzC,OAAO,KAAKC,MAAM,MAAM,iBAAiB;AAIzC,OAAO,KAAKC,OAAO,MAAM,uBAAuB;AAChD,OAAO,KAAKC,QAAQ,MAAM,mBAAmB;AAE7C,SAASC,mBAAmB,QAAQ,mBAAmB;AACvD,OAAO,KAAKC,YAAY,MAAM,mBAAmB;AACjD,SAASC,iBAAiB,QAAQ,wBAAwB;AAE1D;;;;;;;;;;;AAWA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AAGnC,MAAM,IAAKA,MAAM,CAACG;KAC5B,CAAC;IACFhF,IAAI,EAAEwE,IAAI,CAACxE,IAAI;IACfiH,IAAI,EAAEC,QAAQ,CAAC1C,IAAI,CAACyC,IAAI,CAAC;IACzBE,iBAAiB,EAAExB,MAAM,CAACrE,MAAM,CAACE,SAAS,CAAC;IAC3C4F,eAAe,EAAEzB,MAAM,CAACrE,MAAM,CAACwC,OAAO,CAAC;IACvCrC,UAAU;IACVmE,sBAAsB,EAAE,CAAC;IACzBvB,MAAM;IACNgD,kBAAkB,EAAE,CAAC;IACrB/F,MAAM,EAAEuE,UAAU;IAClBtB,KAAK,EAAEC,IAAI,CAACD,KAAK,CAACnB,GAAG,CAAEkE,IAAI,KAAM;MAC/BxC,OAAO,EAAEwC,IAAI,CAACrG,IAAI,CAAC6D,OAAO;MAC1BE,MAAM,EAAEsC,IAAI,CAACrG,IAAI,CAAC+D,MAAM;MACxBvD,UAAU,EAAEpC,mBAAmB,CAACoF,MAAM,CAACgB,OAAO,CAAC6B,IAAI,CAAC7F,UAAU,CAAC,CAAC;MAChEmE,sBAAsB,EAAE;KACzB,CAAC,CAAC;IACH2B,iBAAiB,EAAE;GACpB;AACH,CAAC;AA4ED,MAAMrB,UAAU,GAAG;EACjBsB,KAAK,EAAE,CAAC;EACRrB,EAAE,EAAE,CAAC;EACLO,KAAK,EAAE;CACC;AAIV,MAAMQ,QAAQ,GAAG;EACfO,WAAW,EAAE,CAAC;EACdC,QAAQ,EAAE,CAAC;EACXC,MAAM,EAAE,CAAC;EACTC,MAAM,EAAE,CAAC;EACTC,QAAQ,EAAE,CAAC;EACXC,QAAQ,EAAE;CACF;AAEV,MAAMhC,sBAAsB,GAAW;EACrCG,IAAI,EAAEC,UAAU,CAACC;CAClB","ignoreList":[]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "effect",
3
3
  "type": "module",
4
- "version": "4.0.0-beta.91",
4
+ "version": "4.0.0-beta.93",
5
5
  "license": "MIT",
6
6
  "description": "The missing standard library for TypeScript, for writing production-grade software.",
7
7
  "homepage": "https://effect.website",
package/src/Cause.ts CHANGED
@@ -1234,7 +1234,9 @@ export const filterInterruptors: <E>(self: Cause<E>) => Result.Result<Set<number
1234
1234
  * @category rendering
1235
1235
  * @since 3.2.0
1236
1236
  */
1237
- export const prettyErrors: <E>(self: Cause<E>) => Array<Error> = effect.causePrettyErrors
1237
+ export const prettyErrors: <E>(self: Cause<E>, options?: {
1238
+ readonly includeCauseInStack?: boolean | undefined
1239
+ }) => Array<Error> = effect.causePrettyErrors
1238
1240
 
1239
1241
  /**
1240
1242
  * Formats a `Cause` as a human-readable string for logging or debugging.
package/src/Schema.ts CHANGED
@@ -122,6 +122,12 @@ export interface MakeOptions {
122
122
  * Whether to disable validation for the schema.
123
123
  */
124
124
  readonly disableChecks?: boolean | undefined
125
+
126
+ /** @internal */
127
+ readonly "~payload"?: {
128
+ readonly token: unknown
129
+ readonly value: unknown
130
+ }
125
131
  }
126
132
 
127
133
  /**
@@ -10975,7 +10981,10 @@ export interface fromJsonString<S extends Constraint> extends decodeTo<S, String
10975
10981
  * @since 4.0.0
10976
10982
  */
10977
10983
  export function fromJsonString<S extends Constraint>(schema: S): fromJsonString<S> {
10984
+ const identifier = SchemaAST.resolveIdentifier(schema.ast)
10978
10985
  return String.annotate({
10986
+ // Give the transport wrapper its own name so the decoded payload keeps its identifier.
10987
+ identifier: identifier === undefined ? undefined : `${identifier}JsonString`,
10979
10988
  expected: "a string that will be decoded as JSON",
10980
10989
  contentMediaType: "application/json",
10981
10990
  contentSchema: SchemaAST.toEncoded(schema.ast)
@@ -12467,6 +12476,8 @@ type InheritStaticMembers<C, Static> = C & Pick<Static, Exclude<keyof Static, ke
12467
12476
 
12468
12477
  const immerable: unique symbol = globalThis.Symbol.for("immer-draftable") as any
12469
12478
 
12479
+ const payloadToken = {}
12480
+
12470
12481
  function makeClass<
12471
12482
  Self,
12472
12483
  S extends Struct<Struct.Fields>,
@@ -12483,9 +12494,12 @@ function makeClass<
12483
12494
 
12484
12495
  const out = class extends Inherited {
12485
12496
  constructor(...[input, options]: ReadonlyArray<any>) {
12486
- input = input ?? {}
12487
- const validated = struct.make(input, options)
12488
- super({ ...input, ...validated }, { ...options, disableChecks: true })
12497
+ const internalOptions = options as MakeOptions | undefined
12498
+ const payload = internalOptions?.["~payload"]
12499
+ const value = payload?.token === payloadToken
12500
+ ? payload.value
12501
+ : struct.make(input ?? {}, options)
12502
+ super(value, { ...options, disableChecks: true, "~payload": { token: payloadToken, value } })
12489
12503
  }
12490
12504
 
12491
12505
  static readonly [TypeId] = TypeId
@@ -87,7 +87,7 @@ export const StructuralProto = {
87
87
  const thatKeys = Object.keys(that)
88
88
  if (selfKeys.length !== thatKeys.length) return false
89
89
  for (let i = 0; i < selfKeys.length; i++) {
90
- if (selfKeys[i] !== thatKeys[i] && !Equal.equals(this[selfKeys[i]], that[selfKeys[i]])) {
90
+ if (selfKeys[i] !== thatKeys[i] || !Equal.equals(this[selfKeys[i]], that[selfKeys[i]])) {
91
91
  return false
92
92
  }
93
93
  }
@@ -310,7 +310,9 @@ export const causeSquash = <E>(self: Cause.Cause<E>): unknown => {
310
310
  }
311
311
 
312
312
  /** @internal */
313
- export const causePrettyErrors = <E>(self: Cause.Cause<E>): Array<Error> => {
313
+ export const causePrettyErrors = <E>(self: Cause.Cause<E>, options?: {
314
+ readonly includeCauseInStack?: boolean | undefined
315
+ }): Array<Error> => {
314
316
  const errors: Array<Error> = []
315
317
  const interrupts: Array<Cause.Interrupt> = []
316
318
  if (self.reasons.length === 0) return errors
@@ -326,7 +328,8 @@ export const causePrettyErrors = <E>(self: Cause.Cause<E>): Array<Error> => {
326
328
  errors.push(
327
329
  causePrettyError(
328
330
  failure._tag === "Die" ? failure.defect : failure.error as any,
329
- failure.annotations
331
+ failure.annotations,
332
+ options
330
333
  )
331
334
  )
332
335
  }
@@ -337,7 +340,7 @@ export const causePrettyErrors = <E>(self: Cause.Cause<E>): Array<Error> => {
337
340
  const error = new globalThis.Error("All fibers interrupted without error", { cause })
338
341
  error.name = "InterruptError"
339
342
  error.stack = `${error.name}: ${error.message}`
340
- errors.push(causePrettyError(error, interrupts[0].annotations))
343
+ errors.push(causePrettyError(error, interrupts[0].annotations, options))
341
344
  }
342
345
 
343
346
  setStackTraceLimit(prevStackLimit)
@@ -347,7 +350,10 @@ export const causePrettyErrors = <E>(self: Cause.Cause<E>): Array<Error> => {
347
350
  /** @internal */
348
351
  export const causePrettyError = (
349
352
  original: Record<string, unknown> | Error,
350
- annotations?: ReadonlyMap<string, unknown>
353
+ annotations?: ReadonlyMap<string, unknown>,
354
+ options?: {
355
+ readonly includeCauseInStack?: boolean | undefined
356
+ }
351
357
  ): Error => {
352
358
  const kind = typeof original
353
359
  let error: Error
@@ -364,6 +370,9 @@ export const causePrettyError = (
364
370
  const stack = `${error.name}: ${error.message}`
365
371
  error.stack = annotations ? addStackAnnotations(stack, annotations) : stack
366
372
  }
373
+ if (options?.includeCauseInStack) {
374
+ error.stack = renderPrettyError(error)!
375
+ }
367
376
  for (const key of Object.keys(original)) {
368
377
  if (!(key in error)) {
369
378
  ;(error as any)[key] = (original as any)[key]
@@ -461,8 +470,7 @@ const currentStackTrace = (frame: StackFrame): string => {
461
470
  export const causePretty = <E>(cause: Cause.Cause<E>): string =>
462
471
  causePrettyErrors<E>(cause).map(renderPrettyError).join("\n")
463
472
 
464
- /** @internal */
465
- export const renderPrettyError = (e: Error): string | undefined =>
473
+ const renderPrettyError = (e: Error): string | undefined =>
466
474
  e.cause ? `${e.stack} {\n${renderErrorCause(e.cause as Error, " ")}\n}` : e.stack
467
475
 
468
476
  const renderErrorCause = (cause: Error, prefix: string) => {
@@ -335,8 +335,8 @@ export const jsonSchema = <S extends Schema.Constraint>(
335
335
  * @category constructors
336
336
  * @since 4.0.0
337
337
  */
338
- export const urlParams = (urlParams: UrlParams.UrlParams, contentType?: string): Uint8Array =>
339
- text(UrlParams.toString(urlParams), contentType ?? "application/x-www-form-urlencoded")
338
+ export const urlParams = (urlParams: UrlParams.Input, contentType?: string): Uint8Array =>
339
+ text(UrlParams.toString(UrlParams.fromInput(urlParams)), contentType ?? "application/x-www-form-urlencoded")
340
340
 
341
341
  /**
342
342
  * HTTP body variant backed by Web `FormData`.
@@ -40,7 +40,7 @@ import * as HttpClientResponse from "./HttpClientResponse.ts"
40
40
  import * as HttpIncomingMessage from "./HttpIncomingMessage.ts"
41
41
  import * as HttpMethod from "./HttpMethod.ts"
42
42
  import * as TraceContext from "./HttpTraceContext.ts"
43
- import * as UrlParams from "./UrlParams.ts"
43
+ import * as Url from "./Url.ts"
44
44
 
45
45
  const TypeId = "~effect/http/HttpClient"
46
46
 
@@ -790,7 +790,7 @@ export const make = (
790
790
  Effect.withFiber((fiber) => {
791
791
  const scopedController = scopedRequests.get(request)
792
792
  const controller = scopedController ?? new AbortController()
793
- const urlResult = UrlParams.makeUrl(request.url, request.urlParams, Option.getOrUndefined(request.hash))
793
+ const urlResult = Url.make(request.url, request.urlParams, Option.getOrUndefined(request.hash))
794
794
  if (Result.isFailure(urlResult)) {
795
795
  return Effect.fail(
796
796
  new Error.HttpClientError({
@@ -28,6 +28,7 @@ import * as Stream from "../../Stream.ts"
28
28
  import * as Headers from "./Headers.ts"
29
29
  import * as HttpBody from "./HttpBody.ts"
30
30
  import { hasBody, type HttpMethod } from "./HttpMethod.ts"
31
+ import * as Url from "./Url.ts"
31
32
  import * as UrlParams from "./UrlParams.ts"
32
33
 
33
34
  const TypeId = "~effect/http/HttpClientRequest"
@@ -116,7 +117,7 @@ const Proto = {
116
117
  export function makeWith(
117
118
  method: HttpMethod,
118
119
  url: string,
119
- urlParams: UrlParams.UrlParams,
120
+ urlParams: UrlParams.Input,
120
121
  hash: Option.Option<string>,
121
122
  headers: Headers.Headers,
122
123
  body: HttpBody.HttpBody
@@ -1180,7 +1181,7 @@ export const bodyFile: {
1180
1181
  * @since 4.0.0
1181
1182
  */
1182
1183
  export function toUrl(self: HttpClientRequest): Option.Option<URL> {
1183
- const r = UrlParams.makeUrl(self.url, self.urlParams, Option.getOrUndefined(self.hash))
1184
+ const r = Url.make(self.url, self.urlParams, Option.getOrUndefined(self.hash))
1184
1185
  if (Result.isSuccess(r)) {
1185
1186
  return Option.some(r.success)
1186
1187
  }
@@ -1230,8 +1231,8 @@ const parseContentLength = (contentLength: string | null): number | undefined =>
1230
1231
  export const toWebResult = (self: HttpClientRequest, options?: {
1231
1232
  readonly signal?: AbortSignal | undefined
1232
1233
  readonly context?: Context.Context<never> | undefined
1233
- }): Result.Result<Request, UrlParams.UrlParamsError> => {
1234
- const url = UrlParams.makeUrl(self.url, self.urlParams, Option.getOrUndefined(self.hash))
1234
+ }): Result.Result<Request, Url.UrlError> => {
1235
+ const url = Url.make(self.url, self.urlParams, Option.getOrUndefined(self.hash))
1235
1236
  if (Result.isFailure(url)) {
1236
1237
  return Result.fail(url.failure)
1237
1238
  }
@@ -1271,7 +1272,7 @@ export const toWebResult = (self: HttpClientRequest, options?: {
1271
1272
  }
1272
1273
  return Result.try({
1273
1274
  try: () => new Request(url.success, requestInit),
1274
- catch: (cause) => new UrlParams.UrlParamsError({ cause })
1275
+ catch: (cause) => new Url.UrlError({ cause })
1275
1276
  })
1276
1277
  }
1277
1278
 
@@ -1279,14 +1280,14 @@ const isReadableStream = (u: unknown): u is ReadableStream<Uint8Array> =>
1279
1280
  typeof ReadableStream !== "undefined" && u instanceof ReadableStream
1280
1281
 
1281
1282
  /**
1282
- * Converts an `HttpClientRequest` to a Web `Request`, failing with `UrlParamsError` when the request URL is invalid.
1283
+ * Converts an `HttpClientRequest` to a Web `Request`, failing with `UrlError` when the request URL is invalid.
1283
1284
  *
1284
1285
  * @category converting
1285
1286
  * @since 4.0.0
1286
1287
  */
1287
1288
  export const toWeb = (self: HttpClientRequest, options?: {
1288
1289
  readonly signal?: AbortSignal | undefined
1289
- }): Effect.Effect<Request, UrlParams.UrlParamsError> =>
1290
+ }): Effect.Effect<Request, Url.UrlError> =>
1290
1291
  Effect.contextWith((context) =>
1291
1292
  Effect.fromResult(toWebResult(self, {
1292
1293
  context: context,
@@ -9,11 +9,66 @@
9
9
  * @since 4.0.0
10
10
  */
11
11
  import * as Cause from "../../Cause.ts"
12
+ import * as Data from "../../Data.ts"
12
13
  import { dual } from "../../Function.ts"
13
14
  import * as Redacted from "../../Redacted.ts"
14
15
  import * as Result from "../../Result.ts"
15
16
  import * as UrlParams from "./UrlParams.ts"
16
17
 
18
+ /**
19
+ * Error returned when constructing a `URL` fails.
20
+ *
21
+ * @category errors
22
+ * @since 4.0.0
23
+ */
24
+ export class UrlError extends Data.TaggedError("UrlError")<{
25
+ readonly cause: unknown
26
+ }> {}
27
+
28
+ /**
29
+ * Creates a `URL` safely by appending `UrlParams` and an optional hash to a URL string.
30
+ *
31
+ * **Details**
32
+ *
33
+ * Returns a `Result` that fails with `UrlError` if the URL cannot be constructed.
34
+ *
35
+ * @category constructors
36
+ * @since 4.0.0
37
+ */
38
+ export const make = (
39
+ url: string,
40
+ params: UrlParams.UrlParams,
41
+ hash: string | undefined
42
+ ): Result.Result<URL, UrlError> =>
43
+ Result.try({
44
+ try: () => {
45
+ const urlInstance = new URL(url, baseUrl())
46
+ for (let i = 0; i < params.params.length; i++) {
47
+ const [key, value] = params.params[i]
48
+ if (value !== undefined) {
49
+ urlInstance.searchParams.append(key, value)
50
+ }
51
+ }
52
+ if (hash !== undefined) {
53
+ urlInstance.hash = hash
54
+ }
55
+ return urlInstance
56
+ },
57
+ catch: (cause) => new UrlError({ cause })
58
+ })
59
+
60
+ const baseUrl = (): string | undefined => {
61
+ if (
62
+ "location" in globalThis &&
63
+ globalThis.location !== undefined &&
64
+ globalThis.location.origin !== undefined &&
65
+ globalThis.location.pathname !== undefined
66
+ ) {
67
+ return location.origin + location.pathname
68
+ }
69
+ return undefined
70
+ }
71
+
17
72
  /**
18
73
  * Parses a URL string safely into a `URL` object, returning a `Result` type for
19
74
  * error handling.
@@ -502,7 +557,7 @@ export const setUrlParams: {
502
557
  * @category setters
503
558
  * @since 4.0.0
504
559
  */
505
- (urlParams: UrlParams.UrlParams): (url: URL) => URL
560
+ (urlParams: UrlParams.Input): (url: URL) => URL
506
561
  /**
507
562
  * Updates the query parameters of a URL.
508
563
  *
@@ -532,10 +587,10 @@ export const setUrlParams: {
532
587
  * @category setters
533
588
  * @since 4.0.0
534
589
  */
535
- (url: URL, urlParams: UrlParams.UrlParams): URL
536
- } = dual(2, (url: URL, searchParams: UrlParams.UrlParams) =>
590
+ (url: URL, urlParams: UrlParams.Input): URL
591
+ } = dual(2, (url: URL, urlParams: UrlParams.Input) =>
537
592
  mutate(url, (url) => {
538
- url.search = UrlParams.toString(searchParams)
593
+ url.search = UrlParams.toString(UrlParams.fromInput(urlParams))
539
594
  }))
540
595
 
541
596
  /**
@@ -619,7 +674,7 @@ export const modifyUrlParams: {
619
674
  * @category modifiers
620
675
  * @since 4.0.0
621
676
  */
622
- (f: (urlParams: UrlParams.UrlParams) => UrlParams.UrlParams): (url: URL) => URL
677
+ (f: (urlParams: UrlParams.UrlParams) => UrlParams.Input): (url: URL) => URL
623
678
  /**
624
679
  * Reads the query parameters of a URL, modifies them, and updates the URL.
625
680
  *
@@ -646,8 +701,8 @@ export const modifyUrlParams: {
646
701
  * @category modifiers
647
702
  * @since 4.0.0
648
703
  */
649
- (url: URL, f: (urlParams: UrlParams.UrlParams) => UrlParams.UrlParams): URL
650
- } = dual(2, (url: URL, f: (urlParams: UrlParams.UrlParams) => UrlParams.UrlParams) =>
704
+ (url: URL, f: (urlParams: UrlParams.UrlParams) => UrlParams.Input): URL
705
+ } = dual(2, (url: URL, f: (urlParams: UrlParams.UrlParams) => UrlParams.Input) =>
651
706
  mutate(url, (url) => {
652
707
  const params = f(UrlParams.fromInput(url.searchParams))
653
708
  url.search = UrlParams.toString(params)
@@ -9,7 +9,6 @@
9
9
  * @since 4.0.0
10
10
  */
11
11
  import * as Arr from "../../Array.ts"
12
- import * as Data from "../../Data.ts"
13
12
  import * as Effect from "../../Effect.ts"
14
13
  import * as Equal from "../../Equal.ts"
15
14
  import * as Equ from "../../Equivalence.ts"
@@ -21,7 +20,6 @@ import * as Option from "../../Option.ts"
21
20
  import type { Pipeable } from "../../Pipeable.ts"
22
21
  import { hasProperty } from "../../Predicate.ts"
23
22
  import type { ReadonlyRecord } from "../../Record.ts"
24
- import * as Result from "../../Result.ts"
25
23
  import * as Schema from "../../Schema.ts"
26
24
  import * as SchemaIssue from "../../SchemaIssue.ts"
27
25
  import * as SchemaTransformation from "../../SchemaTransformation.ts"
@@ -65,6 +63,7 @@ export const isUrlParams = (u: unknown): u is UrlParams => hasProperty(u, TypeId
65
63
  * @since 4.0.0
66
64
  */
67
65
  export type Input =
66
+ | UrlParams
68
67
  | CoercibleRecordInput
69
68
  | Iterable<readonly [string, Coercible]>
70
69
  | URLSearchParams
@@ -157,6 +156,9 @@ export const make = (params: ReadonlyArray<readonly [string, string]>): UrlParam
157
156
  * @since 4.0.0
158
157
  */
159
158
  export const fromInput = (input: Input): UrlParams => {
159
+ if (isUrlParams(input)) {
160
+ return input
161
+ }
160
162
  const parsed = fromInputNested(input)
161
163
  const out: Array<[string, string]> = []
162
164
  for (let i = 0; i < parsed.length; i++) {
@@ -634,68 +636,13 @@ export const remove: {
634
636
  (self: UrlParams, key: string): UrlParams
635
637
  } = dual(2, (self: UrlParams, key: string): UrlParams => transform(self, Arr.filter(([k]) => k !== key)))
636
638
 
637
- /**
638
- * Error returned when constructing a `URL` from `UrlParams` fails.
639
- *
640
- * @category errors
641
- * @since 4.0.0
642
- */
643
- export class UrlParamsError extends Data.TaggedError("UrlParamsError")<{
644
- cause: unknown
645
- }> {}
646
-
647
- /**
648
- * Creates a `URL` safely by appending `UrlParams` and an optional hash to a URL string.
649
- *
650
- * **Details**
651
- *
652
- * Returns a `Result` that fails with `UrlParamsError` if the URL cannot be
653
- * constructed.
654
- *
655
- * @category converting
656
- * @since 4.0.0
657
- */
658
- export const makeUrl = (
659
- url: string,
660
- params: UrlParams,
661
- hash: string | undefined
662
- ): Result.Result<URL, UrlParamsError> => {
663
- try {
664
- const urlInstance = new URL(url, baseUrl())
665
- for (let i = 0; i < params.params.length; i++) {
666
- const [key, value] = params.params[i]
667
- if (value !== undefined) {
668
- urlInstance.searchParams.append(key, value)
669
- }
670
- }
671
- if (hash !== undefined) {
672
- urlInstance.hash = hash
673
- }
674
- return Result.succeed(urlInstance)
675
- } catch (e) {
676
- return Result.fail(new UrlParamsError({ cause: e }))
677
- }
678
- }
679
-
680
639
  /**
681
640
  * Serializes `UrlParams` to a URL query string without a leading question mark.
682
641
  *
683
642
  * @category converting
684
643
  * @since 4.0.0
685
644
  */
686
- export const toString = (self: UrlParams): string => new URLSearchParams(self.params as any).toString()
687
-
688
- const baseUrl = (): string | undefined => {
689
- if (
690
- "location" in globalThis &&
691
- globalThis.location !== undefined &&
692
- globalThis.location.origin !== undefined &&
693
- globalThis.location.pathname !== undefined
694
- ) {
695
- return location.origin + location.pathname
696
- }
697
- return undefined
698
- }
645
+ export const toString = (input: Input): string => new URLSearchParams(fromInput(input).params as any).toString()
699
646
 
700
647
  /**
701
648
  * Builds a `Record` containing all the key-value pairs in the given `UrlParams`
@@ -21,6 +21,7 @@ import * as Layer from "../../Layer.ts"
21
21
  import * as Option from "../../Option.ts"
22
22
  import type { Path } from "../../Path.ts"
23
23
  import { type Pipeable, pipeArguments } from "../../Pipeable.ts"
24
+ import { hasProperty } from "../../Predicate.ts"
24
25
  import * as Redacted from "../../Redacted.ts"
25
26
  import * as Result from "../../Result.ts"
26
27
  import * as Schema from "../../Schema.ts"
@@ -603,13 +604,20 @@ function decodePayload(
603
604
  )
604
605
  }
605
606
  case "Json":
606
- const json = Effect.orDie(Effect.flatMap(httpRequest.text, (text) => {
607
+ return Effect.flatMap(Effect.orDie(httpRequest.text), (text) => {
607
608
  if (text === "") {
608
- return existing.nullOnEmpty ? Effect.succeed(null) : Effect.undefined
609
+ return decode(existing.nullOnEmpty ? null : undefined)
609
610
  }
610
- return Effect.succeed(JSON.parse(text))
611
- }))
612
- return Effect.flatMap(json, decode)
611
+ try {
612
+ return decode(JSON.parse(text))
613
+ } catch (cause) {
614
+ return Effect.fail(
615
+ new Schema.SchemaError(
616
+ new SchemaIssue.InvalidValue(Option.some(text), { message: `Invalid JSON: ${cause}` })
617
+ )
618
+ )
619
+ }
620
+ })
613
621
  case "Text":
614
622
  return Effect.flatMap(Effect.orDie(httpRequest.text), decode)
615
623
  case "FormUrlEncoded": {
@@ -766,6 +774,7 @@ const makeSecurityMiddleware = (
766
774
  readonly group: HttpApiGroup.AnyWithProps
767
775
  readonly endpoint: HttpApiEndpoint.AnyWithProps
768
776
  }) {
777
+ handler = Effect.mapError(handler, (error) => new HandlerError(error))
769
778
  let lastResult: Result.Result<any, any> | undefined
770
779
  for (let i = 0; i < entries.length; i++) {
771
780
  const { decode, middleware } = entries[i]
@@ -776,6 +785,9 @@ const makeSecurityMiddleware = (
776
785
  group: options.group
777
786
  })))
778
787
  if (Result.isFailure(result)) {
788
+ if (isHandlerError(result.failure)) {
789
+ return yield* Effect.fail(result.failure.error)
790
+ }
779
791
  lastResult = result
780
792
  continue
781
793
  }
@@ -788,6 +800,16 @@ const makeSecurityMiddleware = (
788
800
  return middleware
789
801
  }
790
802
 
803
+ const HandlerErrorTypeId = "~effect/httpapi/HttpApiBuilder/HandlerError" as const
804
+ class HandlerError {
805
+ readonly [HandlerErrorTypeId] = HandlerErrorTypeId
806
+ readonly error: unknown
807
+ constructor(error: unknown) {
808
+ this.error = error
809
+ }
810
+ }
811
+ const isHandlerError = (value: unknown): value is HandlerError => hasProperty(value, HandlerErrorTypeId)
812
+
791
813
  const $HttpServerResponse = Schema.declare(Response.isHttpServerResponse)
792
814
 
793
815
  type StreamEncoder = (response: unknown, context: Context.Context<never>) =>
@@ -807,7 +829,9 @@ function makeStreamEncoder(endpoint: HttpApiEndpoint.AnyWithProps): StreamEncode
807
829
  if (HttpApiSchema.isStreamUint8Array(streamSchema)) {
808
830
  return (response, context) => {
809
831
  if (!Stream.isStream(response)) {
810
- return hasBuffered ? undefined : expectedStreamResponse(response)
832
+ return hasBuffered ? undefined : new Schema.SchemaError(
833
+ new SchemaIssue.InvalidValue(Option.some(response), { message: "Expected a streaming response" })
834
+ )
811
835
  }
812
836
 
813
837
  return Effect.succeed(Response.stream(
@@ -824,7 +848,9 @@ function makeStreamEncoder(endpoint: HttpApiEndpoint.AnyWithProps): StreamEncode
824
848
 
825
849
  return (response, context) => {
826
850
  if (!Stream.isStream(response)) {
827
- return hasBuffered ? undefined : expectedStreamResponse(response)
851
+ return hasBuffered ? undefined : new Schema.SchemaError(
852
+ new SchemaIssue.InvalidValue(Option.some(response), { message: "Expected a streaming response" })
853
+ )
828
854
  }
829
855
 
830
856
  return Effect.succeed(Response.stream(
@@ -852,16 +878,6 @@ function hasBufferedSuccess(endpoint: HttpApiEndpoint.AnyWithProps): boolean {
852
878
  return endpoint.success.size === 0
853
879
  }
854
880
 
855
- function expectedStreamResponse(response: unknown) {
856
- return Effect.fail(
857
- makeSchemaError(
858
- new SchemaIssue.InvalidValue(Option.some(response), {
859
- message: "Expected a streaming response"
860
- })
861
- )
862
- )
863
- }
864
-
865
881
  interface SseStreamEncoder {
866
882
  readonly sseMode: HttpApiSchema.StreamSseMode
867
883
  readonly encodeEvents: (
@@ -922,10 +938,6 @@ function renderSseEvent(event: Sse.EventEncoded) {
922
938
  })
923
939
  }
924
940
 
925
- function makeSchemaError(issue: SchemaIssue.Issue): Schema.SchemaError {
926
- return new Schema.SchemaError(issue)
927
- }
928
-
929
941
  const toResponseSuccessSchema = toResponseSchema(HttpApiSchema.getStatusSuccess)
930
942
  const toResponseErrorSchema = toResponseSchema(HttpApiSchema.getStatusError)
931
943