effect 3.14.12 → 3.14.13

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.
@@ -1,4 +1,4 @@
1
- let moduleVersion = "3.14.12";
1
+ let moduleVersion = "3.14.13";
2
2
  export const getCurrentVersion = () => moduleVersion;
3
3
  export const setCurrentVersion = version => {
4
4
  moduleVersion = version;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "effect",
3
- "version": "3.14.12",
3
+ "version": "3.14.13",
4
4
  "description": "The missing standard library for TypeScript, for writing production-grade software.",
5
5
  "license": "MIT",
6
6
  "repository": {
package/src/JSONSchema.ts CHANGED
@@ -2,8 +2,10 @@
2
2
  * @since 3.10.0
3
3
  */
4
4
 
5
+ import * as Arr from "./Array.js"
5
6
  import * as errors_ from "./internal/schema/errors.js"
6
7
  import * as Option from "./Option.js"
8
+ import * as ParseResult from "./ParseResult.js"
7
9
  import * as Predicate from "./Predicate.js"
8
10
  import * as Record from "./Record.js"
9
11
  import type * as Schema from "./Schema.js"
@@ -355,13 +357,23 @@ const constEmpty: JsonSchema7 = {
355
357
 
356
358
  const $schema = "http://json-schema.org/draft-07/schema#"
357
359
 
358
- const getJsonSchemaAnnotations = (annotated: AST.Annotated): JsonSchemaAnnotations =>
359
- Record.getSomes({
360
+ const getJsonSchemaAnnotations = (ast: AST.AST, annotated?: AST.Annotated): JsonSchemaAnnotations => {
361
+ annotated ??= ast
362
+ const out: JsonSchemaAnnotations = Record.getSomes({
360
363
  description: AST.getDescriptionAnnotation(annotated),
361
364
  title: AST.getTitleAnnotation(annotated),
362
- examples: AST.getExamplesAnnotation(annotated),
363
365
  default: AST.getDefaultAnnotation(annotated)
364
366
  })
367
+ const oexamples = AST.getExamplesAnnotation(annotated)
368
+ if (Option.isSome(oexamples) && oexamples.value.length > 0) {
369
+ const getOption = ParseResult.getOption(ast, false)
370
+ const examples = Arr.filterMap(oexamples.value, (e) => getOption(e))
371
+ if (examples.length > 0) {
372
+ out.examples = examples
373
+ }
374
+ }
375
+ return out
376
+ }
365
377
 
366
378
  const removeDefaultJsonSchemaAnnotations = (
367
379
  jsonSchemaAnnotations: JsonSchemaAnnotations,
@@ -627,11 +639,11 @@ const go = (
627
639
  case "TupleType": {
628
640
  const elements = ast.elements.map((e, i) => ({
629
641
  ...go(e.type, $defs, true, path.concat(i), options),
630
- ...getJsonSchemaAnnotations(e)
642
+ ...getJsonSchemaAnnotations(e.type, e)
631
643
  }))
632
644
  const rest = ast.rest.map((annotatedAST) => ({
633
645
  ...go(annotatedAST.type, $defs, true, path, options),
634
- ...getJsonSchemaAnnotations(annotatedAST)
646
+ ...getJsonSchemaAnnotations(annotatedAST.type, annotatedAST)
635
647
  }))
636
648
  const output: JsonSchema7Array = { type: "array" }
637
649
  // ---------------------------------------------
@@ -720,9 +732,10 @@ const go = (
720
732
  const name = ps.name
721
733
  if (Predicate.isString(name)) {
722
734
  const pruned = pruneUndefined(ps.type)
735
+ const type = pruned ?? ps.type
723
736
  output.properties[name] = {
724
- ...go(pruned ?? ps.type, $defs, true, path.concat(ps.name), options),
725
- ...getJsonSchemaAnnotations(ps)
737
+ ...go(type, $defs, true, path.concat(ps.name), options),
738
+ ...getJsonSchemaAnnotations(type, ps)
726
739
  }
727
740
  // ---------------------------------------------
728
741
  // handle optional property signatures
@@ -481,7 +481,8 @@ const getSync = (ast: AST.AST, isDecoding: boolean, options?: AST.ParseOptions)
481
481
  Either.getOrThrowWith(parser(input, overrideOptions), parseError)
482
482
  }
483
483
 
484
- const getOption = (ast: AST.AST, isDecoding: boolean, options?: AST.ParseOptions) => {
484
+ /** @internal */
485
+ export const getOption = (ast: AST.AST, isDecoding: boolean, options?: AST.ParseOptions) => {
485
486
  const parser = getEither(ast, isDecoding, options)
486
487
  return (input: unknown, overrideOptions?: AST.ParseOptions): Option.Option<any> =>
487
488
  Option.getRight(parser(input, overrideOptions))
package/src/Schema.ts CHANGED
@@ -1837,12 +1837,7 @@ const mergeSignatureAnnotations = (
1837
1837
  }
1838
1838
  case "PropertySignatureTransformation": {
1839
1839
  return new PropertySignatureTransformation(
1840
- new FromPropertySignature(
1841
- ast.from.type,
1842
- ast.from.isOptional,
1843
- ast.from.isReadonly,
1844
- ast.from.annotations
1845
- ),
1840
+ ast.from,
1846
1841
  new ToPropertySignature(ast.to.type, ast.to.isOptional, ast.to.isReadonly, {
1847
1842
  ...ast.to.annotations,
1848
1843
  ...annotations
@@ -9759,6 +9754,8 @@ const CauseInterruptEncoded = Struct({
9759
9754
  fiberId: FiberIdEncoded
9760
9755
  })
9761
9756
 
9757
+ let causeEncodedId = 0
9758
+
9762
9759
  const causeEncoded = <E extends Schema.All, D extends Schema.All>(
9763
9760
  error: E,
9764
9761
  defect: D
@@ -9789,7 +9786,10 @@ const causeEncoded = <E extends Schema.All, D extends Schema.All>(
9789
9786
  left: suspended,
9790
9787
  right: suspended
9791
9788
  })
9792
- ).annotations({ title: `CauseEncoded<${format(error)}>` })
9789
+ ).annotations({
9790
+ title: `CauseEncoded<${format(error)}>`,
9791
+ [AST.JSONIdentifierAnnotationId]: `CauseEncoded${causeEncodedId++}`
9792
+ })
9793
9793
  return out
9794
9794
  }
9795
9795
 
@@ -1,4 +1,4 @@
1
- let moduleVersion = "3.14.12"
1
+ let moduleVersion = "3.14.13"
2
2
 
3
3
  export const getCurrentVersion = () => moduleVersion
4
4