functype 1.27.2 → 2.1.0

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 (181) hide show
  1. package/README.md +70 -88
  2. package/dist/_virtual/_rolldown/runtime.js +1 -0
  3. package/dist/branded/ValidatedBrand.d.ts +122 -0
  4. package/dist/branded/ValidatedBrand.js +1 -0
  5. package/dist/branded/index.d.ts +52 -2
  6. package/dist/cli/data.d.ts +37 -0
  7. package/dist/cli/data.js +1 -0
  8. package/dist/cli/exports.d.ts +5 -46
  9. package/dist/cli/exports.js +1 -1
  10. package/dist/cli/formatters.js +4 -0
  11. package/dist/cli/full-interfaces.d.ts +6 -0
  12. package/dist/cli/full-interfaces.js +1150 -0
  13. package/dist/cli/index.js +3 -6
  14. package/dist/cli/interfaces.generated.js +1 -0
  15. package/dist/collections/index.d.ts +13 -0
  16. package/dist/companion/Companion.d.ts +23 -0
  17. package/dist/companion/Companion.js +1 -0
  18. package/dist/companion/CompanionTypes.d.ts +30 -0
  19. package/dist/{CompanionTypes-BVqO7Kc2.js → companion/CompanionTypes.js} +1 -1
  20. package/dist/companion/index.d.ts +2 -1
  21. package/dist/companion/index.js +1 -1
  22. package/dist/conditional/Cond.d.ts +147 -0
  23. package/dist/conditional/Cond.js +1 -0
  24. package/dist/conditional/Match.d.ts +295 -0
  25. package/dist/conditional/Match.js +1 -0
  26. package/dist/conditional/index.d.ts +3 -2
  27. package/dist/conditional/index.js +1 -1
  28. package/dist/core/base/Base.d.ts +12 -0
  29. package/dist/core/base/Base.js +1 -0
  30. package/dist/core/throwable/Throwable.d.ts +38 -0
  31. package/dist/core/throwable/Throwable.js +1 -0
  32. package/dist/decoder/Decoder.d.ts +15 -0
  33. package/dist/decoder/DecoderCompanion.js +1 -0
  34. package/dist/decoder/DecoderError.d.ts +56 -0
  35. package/dist/decoder/DecoderError.js +2 -0
  36. package/dist/decoder/Encoder.d.ts +15 -0
  37. package/dist/decoder/index.d.ts +71 -2
  38. package/dist/decoder/index.js +1 -1
  39. package/dist/decoder/tagged.js +1 -0
  40. package/dist/do/index.d.ts +246 -2
  41. package/dist/do/index.js +1 -1
  42. package/dist/do/protocol.d.ts +29 -0
  43. package/dist/either/index.d.ts +290 -2
  44. package/dist/either/index.js +1 -1
  45. package/dist/error/ErrorChain.d.ts +60 -0
  46. package/dist/error/ErrorChain.js +4 -0
  47. package/dist/error/ErrorFormatter.d.ts +67 -0
  48. package/dist/error/ErrorFormatter.js +6 -0
  49. package/dist/error/ParseError.d.ts +6 -0
  50. package/dist/error/ParseError.js +1 -0
  51. package/dist/error/typed/TypedError.d.ts +146 -0
  52. package/dist/error/typed/TypedError.js +1 -0
  53. package/dist/error/typed/Validation.d.ts +76 -0
  54. package/dist/error/typed/Validation.js +1 -0
  55. package/dist/extractable/Extractable.d.ts +62 -0
  56. package/dist/extractable/Extractable.js +1 -0
  57. package/dist/fetch/Http.d.ts +32 -0
  58. package/dist/fetch/Http.js +1 -0
  59. package/dist/fetch/HttpClient.d.ts +80 -0
  60. package/dist/fetch/HttpClient.js +1 -0
  61. package/dist/fetch/HttpError.d.ts +57 -0
  62. package/dist/fetch/HttpError.js +1 -0
  63. package/dist/fetch/HttpRequest.d.ts +103 -0
  64. package/dist/fetch/index.d.ts +5 -2
  65. package/dist/fetch/index.js +1 -1
  66. package/dist/foldable/Foldable.d.ts +27 -0
  67. package/dist/foldable/index.d.ts +55 -0
  68. package/dist/foldable/index.js +1 -0
  69. package/dist/functype/Functype.d.ts +76 -0
  70. package/dist/functype/FunctypeSum.d.ts +39 -0
  71. package/dist/functype/index.d.ts +4 -2
  72. package/dist/hkt/index.d.ts +68 -0
  73. package/dist/hkt/index.js +1 -0
  74. package/dist/identity/Identity.d.ts +34 -0
  75. package/dist/identity/Identity.js +1 -0
  76. package/dist/index.d.ts +74 -8
  77. package/dist/index.js +1 -1
  78. package/dist/internal/base64.js +1 -0
  79. package/dist/internal/call-alone.js +1 -0
  80. package/dist/internal/concurrency.d.ts +11 -0
  81. package/dist/internal/concurrency.js +1 -0
  82. package/dist/internal/define.js +1 -0
  83. package/dist/internal/mutation-utils.js +1 -0
  84. package/dist/internal/signal.js +1 -0
  85. package/dist/internal/stringify.js +1 -0
  86. package/dist/invariant/index.d.ts +32 -2
  87. package/dist/io/Context.d.ts +112 -0
  88. package/dist/io/Context.js +1 -0
  89. package/dist/io/Exit.d.ts +249 -0
  90. package/dist/io/Exit.js +1 -0
  91. package/dist/io/IO.d.ts +1263 -0
  92. package/dist/io/IO.js +1 -0
  93. package/dist/io/Layer.d.ts +139 -0
  94. package/dist/io/Layer.js +1 -0
  95. package/dist/io/SpanTracer.d.ts +78 -0
  96. package/dist/io/SpanTracer.js +1 -0
  97. package/dist/io/Tag.d.ts +75 -0
  98. package/dist/io/Tag.js +1 -0
  99. package/dist/io/TestClock.d.ts +133 -0
  100. package/dist/io/TestClock.js +1 -0
  101. package/dist/io/index.d.ts +41 -2
  102. package/dist/io/index.js +1 -1
  103. package/dist/lazy/Lazy.d.ts +312 -0
  104. package/dist/lazy/Lazy.js +1 -0
  105. package/dist/lazy/index.d.ts +2 -2
  106. package/dist/lazy/index.js +1 -1
  107. package/dist/list/LazyList.d.ts +182 -0
  108. package/dist/list/LazyList.js +1 -0
  109. package/dist/list/index.d.ts +137 -2
  110. package/dist/list/index.js +1 -1
  111. package/dist/logger/index.d.ts +24 -2
  112. package/dist/map/index.d.ts +95 -2
  113. package/dist/map/index.js +1 -1
  114. package/dist/map/shim.d.ts +13 -0
  115. package/dist/map/shim.js +1 -0
  116. package/dist/matchable/Matchable.d.ts +38 -0
  117. package/dist/matchable/Matchable.js +1 -0
  118. package/dist/obj/Obj.d.ts +212 -0
  119. package/dist/obj/Obj.js +1 -0
  120. package/dist/obj/index.d.ts +2 -2
  121. package/dist/obj/index.js +1 -1
  122. package/dist/option/index.d.ts +304 -2
  123. package/dist/option/index.js +1 -1
  124. package/dist/package.json.js +1 -0
  125. package/dist/pipe/index.d.ts +14 -0
  126. package/dist/ref/Ref.d.ts +77 -0
  127. package/dist/ref/Ref.js +1 -0
  128. package/dist/reshapeable/Reshapeable.d.ts +90 -0
  129. package/dist/serializable/Serializable.d.ts +39 -0
  130. package/dist/serialization/Serialization.d.ts +147 -0
  131. package/dist/serialization/Serialization.js +1 -0
  132. package/dist/serialization/SerializationCompanion.d.ts +125 -0
  133. package/dist/serialization/SerializationCompanion.js +1 -0
  134. package/dist/serialization/error-envelope.d.ts +44 -0
  135. package/dist/serialization/error-envelope.js +1 -0
  136. package/dist/serialization/index.d.ts +4 -2
  137. package/dist/serialization/index.js +1 -1
  138. package/dist/set/index.d.ts +106 -2
  139. package/dist/set/index.js +1 -1
  140. package/dist/stack/Stack.d.ts +120 -0
  141. package/dist/stack/Stack.js +1 -0
  142. package/dist/traced/TraceEvent.d.ts +27 -0
  143. package/dist/traced/TracedOption.d.ts +46 -0
  144. package/dist/traced/TracedOption.js +1 -0
  145. package/dist/traced/Tracer.d.ts +26 -0
  146. package/dist/traversable/KVTraversable.d.ts +14 -0
  147. package/dist/traversable/Traversable.d.ts +30 -0
  148. package/dist/try/index.d.ts +238 -2
  149. package/dist/try/index.js +1 -1
  150. package/dist/tuple/index.d.ts +92 -2
  151. package/dist/tuple/index.js +1 -1
  152. package/dist/typeable/Typeable.d.ts +40 -0
  153. package/dist/typeable/Typeable.js +1 -0
  154. package/dist/typeclass/ContainerOps.d.ts +131 -0
  155. package/dist/typeclass/Functor.d.ts +41 -0
  156. package/dist/typeclass/Promisable.d.ts +33 -0
  157. package/dist/typeclass/index.d.ts +4 -1
  158. package/dist/typeclass/index.js +1 -1
  159. package/dist/typeclass/variance.d.ts +54 -0
  160. package/dist/typeclass/variance.js +1 -0
  161. package/dist/types/index.d.ts +1 -0
  162. package/dist/util/index.d.ts +1 -3
  163. package/dist/valuable/Valuable.d.ts +28 -0
  164. package/dist/valuable/Valuable.js +1 -0
  165. package/dist/wire/index.d.ts +40 -2
  166. package/package.json +8 -13
  167. package/dist/Brand-bfnGXuum.d.ts +0 -54
  168. package/dist/Companion-DiOMBHDG.js +0 -1
  169. package/dist/CompanionTypes-Cc90cQ4P.d.ts +0 -58
  170. package/dist/Invariant-DEan-SxV.d.ts +0 -35
  171. package/dist/Logger-BmprRS8v.d.ts +0 -27
  172. package/dist/Tuple-B8KM-H8Y.d.ts +0 -213
  173. package/dist/Wire-3hvw0Ogg.d.ts +0 -42
  174. package/dist/core/task/index.d.ts +0 -2
  175. package/dist/core/task/index.js +0 -1
  176. package/dist/full-interfaces-BadxJrCt.js +0 -1202
  177. package/dist/index-CLYh2qZu.d.ts +0 -6649
  178. package/dist/rolldown-runtime-DK3Fl9T5.js +0 -1
  179. package/dist/serialization-9_SyrfdG.js +0 -3
  180. package/dist/src-BQPeS6p2.js +0 -10
  181. package/dist/typeclass-C61yDVYd.js +0 -1
@@ -1,213 +0,0 @@
1
- //#region src/types/index.d.ts
2
- type Type = unknown;
3
- //#endregion
4
- //#region src/foldable/Foldable.d.ts
5
- /**
6
- * Foldable type class represents data structures that can be folded to a summary value.
7
- *
8
- * This interface provides the universal fold operations (foldLeft, foldRight) that work
9
- * consistently across all data structures. The `fold` method is intentionally excluded
10
- * because it has different semantics for sum types vs collections:
11
- * - Sum types (Option, Either, Try): `fold(onEmpty, onValue)` — pattern match
12
- * - Collections (List, Set, Map): `fold(initial, fn)` — left-reduce accumulator
13
- *
14
- * Each type category defines its own `fold` with the appropriate signature.
15
- *
16
- * @typeParam A - The type of elements in the data structure
17
- */
18
- interface Foldable<out A> {
19
- /**
20
- * Left-associative fold using the provided zero value and operation
21
- * @param z - Zero/identity value
22
- * @returns A function that takes an operation to apply
23
- */
24
- foldLeft<B>(z: B): (op: (b: B, a: A) => B) => B;
25
- /**
26
- * Right-associative fold using the provided zero value and operation
27
- * @param z - Zero/identity value
28
- * @returns A function that takes an operation to apply
29
- */
30
- foldRight<B>(z: B): (op: (a: A, b: B) => B) => B;
31
- }
32
- //#endregion
33
- //#region src/pipe/index.d.ts
34
- /**
35
- * Pipe interface for functional data structures
36
- * @typeParam T - The type of value to pipe
37
- */
38
- interface Pipe<out T extends Type> {
39
- /**
40
- * Pipes the value through the provided function
41
- * @param f - The function to apply to the value
42
- * @returns The result of applying the function to the value
43
- * @typeParam U - The return type of the function
44
- */
45
- pipe<U extends Type>(f: (value: T) => U): U;
46
- }
47
- //#endregion
48
- //#region src/serializable/Serializable.d.ts
49
- /**
50
- * Methods for different serialization formats
51
- */
52
- interface SerializationMethods<T> {
53
- toJSON(): string;
54
- toYAML(): string;
55
- toBinary(): string;
56
- }
57
- /**
58
- * Shape of the envelope object emitted by a Serializable's instance-level
59
- * `toJSON()` (the method native `JSON.stringify` picks up via protocol).
60
- * Concrete types narrow this with their specific marker/tag literals.
61
- *
62
- * The `@functype` marker is the type discriminator (defends against
63
- * `_tag`-collision with Effect/fp-ts). `_tag` is the variant discriminator
64
- * within that type — kept across the board (variant-less types repeat the
65
- * marker for back-compat with 1.1.0 readers that did `parsed._tag === "List"`).
66
- *
67
- * Payload shape is type-specific: canonical types carry `value`; failure
68
- * branches (`Try.Failure`, `Task.Err`, `Lazy` with thrown thunk) carry
69
- * `error: SerializedError` instead.
70
- */
71
- interface SerializableEnvelope {
72
- readonly "@functype": string;
73
- readonly _tag: string;
74
- readonly [key: string]: unknown;
75
- }
76
- interface Serializable<out T> {
77
- serialize(): SerializationMethods<T>;
78
- /**
79
- * Custom JSON serialization. Returns the canonical `@functype`-marked
80
- * envelope object so native `JSON.stringify` (and the rest of the JSON
81
- * `toJSON` protocol) emits a round-trip-able shape that
82
- * `Serialization.deserialize` can reconstruct.
83
- *
84
- * Added in 1.2.0. Concrete types narrow the return to their specific
85
- * marker/tag literals.
86
- */
87
- toJSON(): SerializableEnvelope;
88
- }
89
- //#endregion
90
- //#region src/typeable/Typeable.d.ts
91
- /**
92
- * Base interface for objects with a type tag
93
- * @internal
94
- */
95
- interface TypeableBase<Tag extends string> {
96
- readonly _tag: Tag;
97
- }
98
- type Typeable<Tag extends string, T = object> = T & TypeableBase<Tag>;
99
- /**
100
- * Parameters for creating a Typeable instance
101
- * @internal
102
- */
103
- type TypeableParams<Tag extends string, T> = {
104
- _tag: Tag;
105
- impl: T;
106
- };
107
- /**
108
- * Utility type to extract the Tag from a Typeable type
109
- * @typeParam T - The Typeable type to extract the tag from
110
- * @internal
111
- */
112
- type ExtractTag<T> = T extends Typeable<infer Tag, unknown> ? Tag : never;
113
- /**
114
- * Core utility for creating nominal typing in TypeScript by adding a type tag to any object.
115
- * This allows for creating distinct types that are structurally identical but considered different by TypeScript's type system.
116
- *
117
- * @param params - The parameters containing the tag and implementation
118
- * @returns A Typeable object with the specified tag
119
- * @typeParam Tag - The string literal type used as the discriminator
120
- * @typeParam T - The base type to extend with the tag
121
- */
122
- declare function Typeable<Tag extends string, T>({ _tag, impl }: TypeableParams<Tag, T>): Typeable<Tag, T>;
123
- /**
124
- * Type guard with automatic type inference using the full type
125
- * @param value - The value to check
126
- * @param tag - The tag to check for
127
- * @returns Whether the value is a Typeable with the specified tag
128
- */
129
- declare function isTypeable<T>(value: unknown, tag: string): value is T;
130
- //#endregion
131
- //#region src/tuple/Tuple.d.ts
132
- interface Tuple<out T extends Type[]> extends Foldable<T[number]>, Pipe<Tuple<T>>, Serializable<Tuple<T>>, Typeable<"Tuple"> {
133
- readonly [Symbol.toStringTag]: string;
134
- get<K extends number>(index: K): T[K];
135
- fold<B>(initial: B, fn: (acc: B, a: T[number]) => B): B;
136
- map<U extends Type[]>(f: (value: T) => U): Tuple<U>;
137
- flatMap<U extends Type[]>(f: (value: T) => Tuple<U>): Tuple<U>;
138
- toArray(): T;
139
- length: number;
140
- [Symbol.iterator](): Iterator<T[number]>;
141
- toString(): string;
142
- toValue(): {
143
- _tag: "Tuple";
144
- value: T;
145
- };
146
- }
147
- /**
148
- * Tuple provides a type-safe, fixed-length array with functional operations.
149
- *
150
- * @example
151
- * // Creating tuples
152
- * const t1 = Tuple([1, "hello", true])
153
- * const t2 = Tuple.of(1, "hello", true)
154
- * const pair = Tuple.pair("key", 42)
155
- *
156
- * @example
157
- * // Type-safe access
158
- * const triple = Tuple.triple("x", 10, true)
159
- * const first = triple.get(0) // string
160
- * const second = triple.get(1) // number
161
- * const third = triple.get(2) // boolean
162
- *
163
- * @example
164
- * // Functional operations
165
- * const doubled = Tuple([1, 2, 3])
166
- * .map(arr => arr.map(x => x * 2))
167
- * .toArray() // [2, 4, 6]
168
- */
169
- declare const Tuple: (<T extends Type[]>(values: T) => Tuple<T>) & {
170
- /**
171
- * Create a Tuple from multiple arguments
172
- * @example
173
- * const t = Tuple.of(1, "hello", true)
174
- * // TypeScript infers: Tuple<[number, string, boolean]>
175
- */
176
- of: <T extends Type[]>(...values: T) => Tuple<T>;
177
- /**
178
- * Create a Tuple of size 2 (pair)
179
- * @example
180
- * const pair = Tuple.pair("key", 42)
181
- * // TypeScript infers: Tuple<[string, number]>
182
- */
183
- pair: <A extends Type, B extends Type>(first: A, second: B) => Tuple<[A, B]>;
184
- /**
185
- * Create a Tuple of size 3 (triple)
186
- * @example
187
- * const triple = Tuple.triple("x", 10, true)
188
- * // TypeScript infers: Tuple<[string, number, boolean]>
189
- */
190
- triple: <A extends Type, B extends Type, C extends Type>(first: A, second: B, third: C) => Tuple<[A, B, C]>;
191
- /**
192
- * Create an empty Tuple
193
- * @example
194
- * const empty = Tuple.empty()
195
- * // TypeScript infers: Tuple<[]>
196
- */
197
- empty: () => Tuple<[]>;
198
- /**
199
- * Create a Tuple from an array (alias for constructor)
200
- * @example
201
- * const t = Tuple.from([1, 2, 3])
202
- */
203
- from: <T extends Type[]>(values: T) => Tuple<T>;
204
- /**
205
- * Reconstruct a Tuple from a JSON envelope emitted by `serialize().toJSON()`
206
- * or instance `toJSON()`. Verifies `@functype === "Tuple"` if the marker is
207
- * present (the marker became canonical in 1.2.0; older envelopes are
208
- * accepted by leniently treating missing-marker as opt-in legacy).
209
- */
210
- fromJSON: <T extends Type[]>(json: string) => Tuple<T>;
211
- };
212
- //#endregion
213
- export { isTypeable as a, SerializationMethods as c, Type as d, TypeableParams as i, Pipe as l, ExtractTag as n, Serializable as o, Typeable as r, SerializableEnvelope as s, Tuple as t, Foldable as u };
@@ -1,42 +0,0 @@
1
- //#region src/wire/Wire.d.ts
2
- /**
3
- * A value in its serialization-safe shape — a DB row, an HTTP body, a JSONB payload, a workflow
4
- * input. Wraps ANY boundary shape: a collection (`Wire<ReadonlyArray<Row>>`), a nullable field
5
- * (`Wire<string | null>`), or a whole row/DTO type (`Wire<Row>`), which covers every field inside it.
6
- *
7
- * `null` is the shape that survives `JSON.stringify`; `Option` and `List` are not. Inside the code that
8
- * transforms these values, convert with `Option(x)` / `List(xs)`.
9
- *
10
- * Zero runtime, zero type-level enforcement. `Wire<T>` is `T | (T & WireMark)`: the plain `T` member
11
- * keeps it assignable both ways with `T` — including `null`, `undefined` and `unknown` — so call sites
12
- * need no casts, and generic helpers like `findOne<R>(): Promise<Wire<R | null>>` compile. The branded
13
- * member exists so TypeScript keeps the alias name instead of resolving it eagerly: inferred exports
14
- * emit `Wire<Row>` in `.d.ts` files and hovers, rather than a type that names an unexported symbol
15
- * (which fails a consumer's declaration build with TS4023).
16
- *
17
- * Value lives in three places:
18
- * - `rg 'Wire<'` is the countable inventory of serialization boundaries;
19
- * - the name documents intent at the declaration site;
20
- * - `functype/prefer-list` and `functype/prefer-option` skip everything inside a `Wire<…>` type
21
- * argument (`wireTypes` option, default `["Wire"]`), so the boundary is declared once instead of
22
- * suppressed at every field.
23
- *
24
- * Consumer aliases compose: `type UserRow = Wire<{ … }>` — uses of `UserRow` pass the linter, and the
25
- * alias declaration is the one place the boundary is stated.
26
- *
27
- * Migration from 1.9: `Wire<Row>` meant `ReadonlyArray<Row>`; write `Wire<ReadonlyArray<Row>>`. The
28
- * change is compile-loud except for `Wire<object>` and `Wire<any>`, which accept an array either way.
29
- *
30
- * @category Wire
31
- */
32
- declare const WIRE: unique symbol;
33
- /**
34
- * The phantom mark that keeps `Wire<T>` a named alias through inference and declaration emit.
35
- * Exported so emitted declarations can name it; never needed in user code.
36
- */
37
- interface WireMark {
38
- readonly [WIRE]?: never;
39
- }
40
- type Wire<T> = T | (T & WireMark);
41
- //#endregion
42
- export { WireMark as n, Wire as t };
@@ -1,2 +0,0 @@
1
- import { $t as Sync, Jt as Async, Qt as Ok, Xt as CancellationTokenSource, Yt as CancellationToken, Zt as Err, an as TaskParams, cn as createCancellationTokenSource, en as TaggedThrowable, in as TaskOutcome, ln as isTaggedThrowable, nn as TaskFailure, on as TaskResult, rn as TaskMetadata, sn as TaskSuccess, tn as Task } from "../../index-CLYh2qZu.js";
2
- export { Async, CancellationToken, CancellationTokenSource, Err, Ok, Sync, TaggedThrowable, Task, TaskFailure, TaskMetadata, TaskOutcome, TaskParams, TaskResult, TaskSuccess, createCancellationTokenSource, isTaggedThrowable };
@@ -1 +0,0 @@
1
- import{J as e,K as t,X as n,Y as r,q as i}from"../../src-BQPeS6p2.js";export{t as Err,i as Ok,e as Task,r as createCancellationTokenSource,n as isTaggedThrowable};