effect-app 4.0.0-beta.254 → 4.0.0-beta.256

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.
@@ -11,16 +11,22 @@
11
11
  import { extendM } from "effect-app/utils"
12
12
  import * as Effect from "effect/Effect"
13
13
  import * as S from "effect/Schema"
14
+ import type * as SchemaAST from "effect/SchemaAST"
14
15
  import type { Simplify } from "effect/Types"
15
- import { fromBrand, nominal } from "./brand.js"
16
+ import { type BrandedSchema, fromBrand, nominal } from "./brand.js"
16
17
  import { withDefaultMake } from "./ext.js"
17
18
  import { type B } from "./schema.js"
18
19
 
19
20
  export interface PositiveIntBrand
20
21
  extends Simplify<B.Brand<"PositiveInt"> & NonNegativeIntBrand & PositiveNumberBrand>
21
22
  {}
23
+ export type PositiveInt = number & PositiveIntBrand
22
24
  /** Positive integer. `.withConstructorDefault` => `1` (construction-only). */
23
- export const PositiveInt = extendM(
25
+ export interface PositiveIntSchema extends BrandedSchema<S.Int, PositiveInt> {
26
+ (i: number, options?: SchemaAST.ParseOptions): PositiveInt
27
+ readonly withConstructorDefault: S.withConstructorDefault<BrandedSchema<S.Int, PositiveInt>>
28
+ }
29
+ export const PositiveInt: PositiveIntSchema = extendM(
24
30
  S.Int.pipe(
25
31
  S.check(S.isGreaterThan(0)),
26
32
  fromBrand<PositiveInt>(nominal<PositiveInt>(), { identifier: "PositiveInt", jsonSchema: {} }),
@@ -35,11 +41,15 @@ export const PositiveInt = extendM(
35
41
  withConstructorDefault: s.pipe(S.withConstructorDefault(Effect.sync(() => s(1))))
36
42
  })
37
43
  )
38
- export type PositiveInt = number & PositiveIntBrand
39
44
 
40
45
  export interface NonNegativeIntBrand extends Simplify<B.Brand<"NonNegativeInt"> & IntBrand & NonNegativeNumberBrand> {}
46
+ export type NonNegativeInt = number & NonNegativeIntBrand
41
47
  /** Non-negative integer. `.withConstructorDefault` => `0` (construction-only). */
42
- export const NonNegativeInt = extendM(
48
+ export interface NonNegativeIntSchema extends BrandedSchema<S.Int, NonNegativeInt> {
49
+ (i: number, options?: SchemaAST.ParseOptions): NonNegativeInt
50
+ readonly withConstructorDefault: S.withConstructorDefault<BrandedSchema<S.Int, NonNegativeInt>>
51
+ }
52
+ export const NonNegativeInt: NonNegativeIntSchema = extendM(
43
53
  S.Int.pipe(
44
54
  S.check(S.isGreaterThanOrEqualTo(0)),
45
55
  fromBrand<NonNegativeInt>(nominal<NonNegativeInt>(), {
@@ -57,11 +67,15 @@ export const NonNegativeInt = extendM(
57
67
  withConstructorDefault: s.pipe(S.withConstructorDefault(Effect.sync(() => s(0))))
58
68
  })
59
69
  )
60
- export type NonNegativeInt = number & NonNegativeIntBrand
61
70
 
62
71
  export interface IntBrand extends Simplify<B.Brand<"Int">> {}
72
+ export type Int = number & IntBrand
63
73
  /** Integer. `.withConstructorDefault` => `0` (construction-only). */
64
- export const Int = extendM(
74
+ export interface IntSchema extends BrandedSchema<S.Int, Int> {
75
+ (i: number, options?: SchemaAST.ParseOptions): Int
76
+ readonly withConstructorDefault: S.withConstructorDefault<BrandedSchema<S.Int, Int>>
77
+ }
78
+ export const Int: IntSchema = extendM(
65
79
  S.Int.pipe(fromBrand<Int>(nominal<Int>(), { identifier: "Int", jsonSchema: {} }), withDefaultMake),
66
80
  (s) => ({
67
81
  /**
@@ -72,11 +86,15 @@ export const Int = extendM(
72
86
  withConstructorDefault: s.pipe(S.withConstructorDefault(Effect.sync(() => s(0))))
73
87
  })
74
88
  )
75
- export type Int = number & IntBrand
76
89
 
77
90
  export interface PositiveNumberBrand extends Simplify<B.Brand<"PositiveNumber"> & NonNegativeNumberBrand> {}
91
+ export type PositiveNumber = number & PositiveNumberBrand
78
92
  /** Positive finite number. `.withConstructorDefault` => `1` (construction-only). */
79
- export const PositiveNumber = extendM(
93
+ export interface PositiveNumberSchema extends BrandedSchema<S.Finite, PositiveNumber> {
94
+ (i: number, options?: SchemaAST.ParseOptions): PositiveNumber
95
+ readonly withConstructorDefault: S.withConstructorDefault<BrandedSchema<S.Finite, PositiveNumber>>
96
+ }
97
+ export const PositiveNumber: PositiveNumberSchema = extendM(
80
98
  S.Finite.pipe(
81
99
  S.check(S.isGreaterThan(0)),
82
100
  fromBrand<PositiveNumber>(nominal<PositiveNumber>(), {
@@ -94,11 +112,15 @@ export const PositiveNumber = extendM(
94
112
  withConstructorDefault: s.pipe(S.withConstructorDefault(Effect.sync(() => s(1))))
95
113
  })
96
114
  )
97
- export type PositiveNumber = number & PositiveNumberBrand
98
115
 
99
116
  export interface NonNegativeNumberBrand extends Simplify<B.Brand<"NonNegativeNumber">> {}
117
+ export type NonNegativeNumber = number & NonNegativeNumberBrand
100
118
  /** Non-negative finite number. `.withConstructorDefault` => `0` (construction-only). */
101
- export const NonNegativeNumber = extendM(
119
+ export interface NonNegativeNumberSchema extends BrandedSchema<S.Finite, NonNegativeNumber> {
120
+ (i: number, options?: SchemaAST.ParseOptions): NonNegativeNumber
121
+ readonly withConstructorDefault: S.withConstructorDefault<BrandedSchema<S.Finite, NonNegativeNumber>>
122
+ }
123
+ export const NonNegativeNumber: NonNegativeNumberSchema = extendM(
102
124
  S
103
125
  .Finite
104
126
  .pipe(
@@ -118,7 +140,6 @@ export const NonNegativeNumber = extendM(
118
140
  withConstructorDefault: s.pipe(S.withConstructorDefault(Effect.sync(() => s(0))))
119
141
  })
120
142
  )
121
- export type NonNegativeNumber = number & NonNegativeNumberBrand
122
143
 
123
144
  /** @deprecated Not an actual decimal */
124
145
  export const NonNegativeDecimal = NonNegativeNumber
@@ -1,12 +1,16 @@
1
1
  import type * as B from "effect/Brand"
2
2
  import * as S from "effect/Schema"
3
+ import type * as SchemaAST from "effect/SchemaAST"
3
4
  import type { Simplify } from "effect/Types"
4
- import { fromBrand, nominal } from "./brand.js"
5
+ import { type BrandedSchema, fromBrand, nominal } from "./brand.js"
5
6
  import { withDefaultMake } from "./ext.js"
6
7
 
7
8
  export type NonEmptyStringBrand = B.Brand<"NonEmptyString">
8
9
  export type NonEmptyString = string & NonEmptyStringBrand
9
- export const NonEmptyString = S
10
+ export interface NonEmptyStringSchema extends BrandedSchema<S.NonEmptyString, NonEmptyString> {
11
+ (i: string, options?: SchemaAST.ParseOptions): NonEmptyString
12
+ }
13
+ export const NonEmptyString: NonEmptyStringSchema = S
10
14
  .NonEmptyString
11
15
  .pipe(
12
16
  fromBrand<NonEmptyString>(nominal<NonEmptyString>(), {
@@ -18,7 +22,10 @@ export const NonEmptyString = S
18
22
 
19
23
  export interface NonEmptyString64kBrand extends Simplify<B.Brand<"NonEmptyString64k"> & NonEmptyStringBrand> {}
20
24
  export type NonEmptyString64k = string & NonEmptyString64kBrand
21
- export const NonEmptyString64k = S
25
+ export interface NonEmptyString64kSchema extends BrandedSchema<S.NonEmptyString, NonEmptyString64k> {
26
+ (i: string, options?: SchemaAST.ParseOptions): NonEmptyString64k
27
+ }
28
+ export const NonEmptyString64k: NonEmptyString64kSchema = S
22
29
  .NonEmptyString
23
30
  .pipe(
24
31
  S.check(S.isMaxLength(64 * 1024)),
@@ -31,7 +38,10 @@ export const NonEmptyString64k = S
31
38
 
32
39
  export interface NonEmptyString2kBrand extends Simplify<B.Brand<"NonEmptyString2k"> & NonEmptyString64kBrand> {}
33
40
  export type NonEmptyString2k = string & NonEmptyString2kBrand
34
- export const NonEmptyString2k = S
41
+ export interface NonEmptyString2kSchema extends BrandedSchema<S.NonEmptyString, NonEmptyString2k> {
42
+ (i: string, options?: SchemaAST.ParseOptions): NonEmptyString2k
43
+ }
44
+ export const NonEmptyString2k: NonEmptyString2kSchema = S
35
45
  .NonEmptyString
36
46
  .pipe(
37
47
  S.check(S.isMaxLength(2 * 1024)),
@@ -44,7 +54,10 @@ export const NonEmptyString2k = S
44
54
 
45
55
  export interface NonEmptyString255Brand extends Simplify<B.Brand<"NonEmptyString255"> & NonEmptyString2kBrand> {}
46
56
  export type NonEmptyString255 = string & NonEmptyString255Brand
47
- export const NonEmptyString255 = S
57
+ export interface NonEmptyString255Schema extends BrandedSchema<S.NonEmptyString, NonEmptyString255> {
58
+ (i: string, options?: SchemaAST.ParseOptions): NonEmptyString255
59
+ }
60
+ export const NonEmptyString255: NonEmptyString255Schema = S
48
61
  .NonEmptyString
49
62
  .pipe(
50
63
  S.check(S.isMaxLength(255)),