effect 3.10.7 → 3.10.8

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.
@@ -3936,11 +3936,85 @@ export interface Class<Self, Fields extends Struct.Fields, I, R, C, Inherited, P
3936
3936
  readonly [K in keyof Fields]: Fields[K];
3937
3937
  };
3938
3938
  readonly identifier: string;
3939
+ /**
3940
+ * @example
3941
+ * import { Schema } from "effect"
3942
+ *
3943
+ * class MyClass extends Schema.Class<MyClass>("MyClass")({
3944
+ * myField: Schema.String
3945
+ * }) {
3946
+ * myMethod() {
3947
+ * return this.myField + "my"
3948
+ * }
3949
+ * }
3950
+ *
3951
+ * class NextClass extends MyClass.extend<NextClass>("NextClass")({
3952
+ * nextField: Schema.Number
3953
+ * }) {
3954
+ * nextMethod() {
3955
+ * return this.myMethod() + this.myField + this.nextField
3956
+ * }
3957
+ * }
3958
+ */
3939
3959
  extend<Extended = never>(identifier: string): <newFields extends Struct.Fields>(fields: newFields | HasFields<newFields>, annotations?: Annotations.Schema<Extended>) => [Extended] extends [never] ? MissingSelfGeneric<"Base.extend"> : Class<Extended, Fields & newFields, I & Struct.Encoded<newFields>, R | Struct.Context<newFields>, C & Struct.Constructor<newFields>, Self, Proto>;
3960
+ /**
3961
+ * @example
3962
+ * import { Effect, Schema } from "effect"
3963
+ *
3964
+ * class MyClass extends Schema.Class<MyClass>("MyClass")({
3965
+ * myField: Schema.String
3966
+ * }) {
3967
+ * myMethod() {
3968
+ * return this.myField + "my"
3969
+ * }
3970
+ * }
3971
+ *
3972
+ * class NextClass extends MyClass.transformOrFail<NextClass>("NextClass")({
3973
+ * nextField: Schema.Number
3974
+ * }, {
3975
+ * decode: (i) =>
3976
+ * Effect.succeed({
3977
+ * myField: i.myField,
3978
+ * nextField: i.myField.length
3979
+ * }),
3980
+ * encode: (a) => Effect.succeed({ myField: a.myField })
3981
+ * }) {
3982
+ * nextMethod() {
3983
+ * return this.myMethod() + this.myField + this.nextField
3984
+ * }
3985
+ * }
3986
+ */
3940
3987
  transformOrFail<Transformed = never>(identifier: string): <newFields extends Struct.Fields, R2, R3>(fields: newFields, options: {
3941
3988
  readonly decode: (input: Simplify<Struct.Type<Fields>>, options: ParseOptions, ast: AST.Transformation) => Effect.Effect<Simplify<Struct.Type<Fields & newFields>>, ParseResult.ParseIssue, R2>;
3942
3989
  readonly encode: (input: Simplify<Struct.Type<Fields & newFields>>, options: ParseOptions, ast: AST.Transformation) => Effect.Effect<Struct.Type<Fields>, ParseResult.ParseIssue, R3>;
3943
3990
  }, annotations?: Annotations.Schema<Transformed>) => [Transformed] extends [never] ? MissingSelfGeneric<"Base.transformOrFail"> : Class<Transformed, Fields & newFields, I, R | Struct.Context<newFields> | R2 | R3, C & Struct.Constructor<newFields>, Self, Proto>;
3991
+ /**
3992
+ * @example
3993
+ * import { Effect, Schema } from "effect"
3994
+ *
3995
+ * class MyClass extends Schema.Class<MyClass>("MyClass")({
3996
+ * myField: Schema.String
3997
+ * }) {
3998
+ * myMethod() {
3999
+ * return this.myField + "my"
4000
+ * }
4001
+ * }
4002
+ *
4003
+ * class NextClass extends MyClass.transformOrFailFrom<NextClass>("NextClass")({
4004
+ * nextField: Schema.Number
4005
+ * }, {
4006
+ * decode: (i) =>
4007
+ * Effect.succeed({
4008
+ * myField: i.myField,
4009
+ * nextField: i.myField.length
4010
+ * }),
4011
+ * encode: (a) => Effect.succeed({ myField: a.myField })
4012
+ * }) {
4013
+ * nextMethod() {
4014
+ * return this.myMethod() + this.myField + this.nextField
4015
+ * }
4016
+ * }
4017
+ */
3944
4018
  transformOrFailFrom<Transformed = never>(identifier: string): <newFields extends Struct.Fields, R2, R3>(fields: newFields, options: {
3945
4019
  readonly decode: (input: Simplify<I>, options: ParseOptions, ast: AST.Transformation) => Effect.Effect<Simplify<I & Struct.Encoded<newFields>>, ParseResult.ParseIssue, R2>;
3946
4020
  readonly encode: (input: Simplify<I & Struct.Encoded<newFields>>, options: ParseOptions, ast: AST.Transformation) => Effect.Effect<I, ParseResult.ParseIssue, R3>;
@@ -3950,6 +4024,17 @@ type HasFields<Fields extends Struct.Fields> = Struct<Fields> | {
3950
4024
  readonly [RefineSchemaId]: HasFields<Fields>;
3951
4025
  };
3952
4026
  /**
4027
+ * @example
4028
+ * import { Schema } from "effect"
4029
+ *
4030
+ * class MyClass extends Schema.Class<MyClass>("MyClass")({
4031
+ * someField: Schema.String
4032
+ * }) {
4033
+ * someMethod() {
4034
+ * return this.someField + "bar"
4035
+ * }
4036
+ * }
4037
+ *
3953
4038
  * @category classes
3954
4039
  * @since 3.10.0
3955
4040
  */
@@ -3962,6 +4047,13 @@ export interface TaggedClass<Self, Tag extends string, Fields extends Struct.Fie
3962
4047
  readonly _tag: Tag;
3963
4048
  }
3964
4049
  /**
4050
+ * @example
4051
+ * import { Schema } from "effect"
4052
+ *
4053
+ * class MyClass extends Schema.TaggedClass<MyClass>("MyClass")("MyClass", {
4054
+ * a: Schema.String
4055
+ * }) {}
4056
+ *
3965
4057
  * @category classes
3966
4058
  * @since 3.10.0
3967
4059
  */
@@ -3976,6 +4068,21 @@ export interface TaggedErrorClass<Self, Tag extends string, Fields extends Struc
3976
4068
  readonly _tag: Tag;
3977
4069
  }
3978
4070
  /**
4071
+ * @example
4072
+ * import { Schema } from "effect"
4073
+ *
4074
+ * class MyError extends Schema.TaggedError<MyError>("MyError")(
4075
+ * "MyError",
4076
+ * {
4077
+ * module: Schema.String,
4078
+ * method: Schema.String,
4079
+ * description: Schema.String
4080
+ * }
4081
+ * ) {
4082
+ * get message(): string {
4083
+ * return `${this.module}.${this.method}: ${this.description}`
4084
+ * }
4085
+ * }
3979
4086
  * @category classes
3980
4087
  * @since 3.10.0
3981
4088
  */
@@ -4542,6 +4649,15 @@ export interface TaggedRequestClass<Self, Tag extends string, Payload extends St
4542
4649
  readonly failure: Failure;
4543
4650
  }
4544
4651
  /**
4652
+ * @example
4653
+ * import { Schema } from "effect"
4654
+ *
4655
+ * class MyRequest extends Schema.TaggedRequest<MyRequest>("MyRequest")("MyRequest", {
4656
+ * failure: Schema.String,
4657
+ * success: Schema.Number,
4658
+ * payload: { id: Schema.String }
4659
+ * }) {}
4660
+ *
4545
4661
  * @category classes
4546
4662
  * @since 3.10.0
4547
4663
  */