functype 0.60.0 → 0.60.3
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.
- package/README.md +30 -5
- package/dist/cli/exports.js +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/do/index.d.ts +1 -1
- package/dist/do/index.js +1 -1
- package/dist/either/index.d.ts +1 -1
- package/dist/either/index.js +1 -1
- package/dist/{full-interfaces-BTDCY3Q1.js → full-interfaces-BPyQ4Hyv.js} +1 -1
- package/dist/{index-BPe5pcCH.d.ts → index-BFDvVJ8v.d.ts} +5 -5
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/list/index.d.ts +1 -1
- package/dist/list/index.js +1 -1
- package/dist/map/index.d.ts +1 -1
- package/dist/map/index.js +1 -1
- package/dist/option/index.d.ts +1 -1
- package/dist/option/index.js +1 -1
- package/dist/set/index.d.ts +1 -1
- package/dist/set/index.js +1 -1
- package/dist/{src-Co3npRp-.js → src-lZq532nx.js} +1 -1
- package/dist/try/index.d.ts +1 -1
- package/dist/try/index.js +1 -1
- package/package.json +6 -5
package/README.md
CHANGED
|
@@ -769,10 +769,10 @@ For more details, see the [Error Formatting Guide](docs/error-formatting.md).
|
|
|
769
769
|
|
|
770
770
|
### Performance Optimizations
|
|
771
771
|
|
|
772
|
-
- [
|
|
772
|
+
- [x] Add memoization utilities (via `Lazy` — memoized deferred computation)
|
|
773
773
|
- [ ] Improve recursive operations for large collections
|
|
774
774
|
- [ ] Implement immutable data structures with structural sharing
|
|
775
|
-
- [
|
|
775
|
+
- [x] Add performance benchmarks (`bench/` — Do-notation, monad detection, optimization targets)
|
|
776
776
|
- [x] Optimize TreeShaking with sideEffects flag in package.json
|
|
777
777
|
- [x] Support selective module imports for smaller bundles
|
|
778
778
|
- [x] Add bundle size monitoring to CI/CD
|
|
@@ -784,14 +784,14 @@ For more details, see the [Error Formatting Guide](docs/error-formatting.md).
|
|
|
784
784
|
- Object methods for common operations
|
|
785
785
|
- Companion functions for additional utilities
|
|
786
786
|
- [x] Align Task API with other monadic structures
|
|
787
|
-
- [
|
|
787
|
+
- [x] Standardize import patterns (@ imports vs relative paths)
|
|
788
788
|
- [x] Implement consistent error handling strategy for async operations
|
|
789
789
|
|
|
790
790
|
### Testing and Documentation
|
|
791
791
|
|
|
792
792
|
- [ ] Add observable test coverage metrics
|
|
793
793
|
- [x] Implement property-based testing
|
|
794
|
-
- [
|
|
794
|
+
- [x] Expand error handling tests (`test/error/` — typed errors, pino integration, stack traces)
|
|
795
795
|
- [ ] Add interoperability tests with other libraries
|
|
796
796
|
|
|
797
797
|
### TypeScript Improvements
|
|
@@ -802,9 +802,34 @@ For more details, see the [Error Formatting Guide](docs/error-formatting.md).
|
|
|
802
802
|
- Current type parameters work well for first-order types
|
|
803
803
|
- Expand to support type constructors as parameters (F<A> => F<B>)
|
|
804
804
|
- [x] Add branded/nominal types for stronger type safety
|
|
805
|
-
- [
|
|
805
|
+
- [x] Implement more type-level utilities — partial (`Widen<A, B>` conditional-type helper in `src/typeclass/variance.ts`; more in `src/types/`, `src/typeable/`)
|
|
806
806
|
- [ ] Leverage newer TypeScript features (const type parameters, tuple manipulation)
|
|
807
807
|
|
|
808
|
+
### Completed Major Features (0.60.0 audit)
|
|
809
|
+
|
|
810
|
+
Work that shipped but wasn't captured in the planned roadmap above:
|
|
811
|
+
|
|
812
|
+
- [x] **Scala-aligned covariance for the container family** (0.57.2 → 0.60.0)
|
|
813
|
+
- ✓ `<out T>` / `<out K, out V>` across Option, Either, Try, List, Set, Map, Lazy, LazyList, Tuple, Identity, Task/TaskOutcome
|
|
814
|
+
- ✓ `FunctypeSum` hierarchy separating sum types (Either, Try) from iterables
|
|
815
|
+
- ✓ `Widen<A, B>` conditional-type helper enforcing Scala's `[B >: A]` lower-bound semantics in `reduce` / `reduceRight`
|
|
816
|
+
- ✓ Method-level widening patterns (`or`, `orElse`, `recover`, `add`, `concat`, etc.)
|
|
817
|
+
- ✓ Contributor guide at [`docs/variance-guide.md`](docs/variance-guide.md)
|
|
818
|
+
- Deferred: ZIO-style `<in R, out E, out A>` for IO
|
|
819
|
+
- [x] **Do-notation with generator comprehensions** (`src/do/`)
|
|
820
|
+
- [x] **HTTP module** — typed fetch wrapper with validator support (`src/fetch/` — Http, HttpClient, HttpError, HttpRequest)
|
|
821
|
+
- [x] **Throwable** — enhanced error wrapper preserving stack traces and context (`src/core/throwable/`)
|
|
822
|
+
- [x] **Task / TaskOutcome** — sync/async with cancellation + progress tracking (`src/core/task/`)
|
|
823
|
+
- [x] **IO effect system companions** — Context, Tag, Layer, Exit, TestClock (`src/io/`)
|
|
824
|
+
- [x] **Ref** — mutable reference for controlled mutability (`src/ref/`)
|
|
825
|
+
- [x] **Identity** — trivial covariant container (`src/identity/`)
|
|
826
|
+
- [x] **Conditional module** (`src/conditional/`)
|
|
827
|
+
- [x] **Valuable module** (`src/valuable/`)
|
|
828
|
+
- [x] **MCP server for functype documentation** (`mcp-server/`)
|
|
829
|
+
- [x] **CLI — `npx functype`** (`src/cli/`)
|
|
830
|
+
- [x] **Claude Code skills** — `functype` (user guide) and `functype-developer` (contributor guide)
|
|
831
|
+
- [x] **Serialization infrastructure** — JSON / YAML / binary (`src/serialization/`)
|
|
832
|
+
|
|
808
833
|
## Claude Code Skills
|
|
809
834
|
|
|
810
835
|
Functype provides two specialized Claude Code skills to enhance your development experience:
|
package/dist/cli/exports.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,i as t,n,r,t as i}from"../full-interfaces-
|
|
1
|
+
import{a as e,i as t,n,r,t as i}from"../full-interfaces-BPyQ4Hyv.js";export{n as CATEGORIES,i as FULL_INTERFACES,r as INTERFACES,t as TYPES,e as VERSION};
|
package/dist/cli/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{J as e,kt as t,yt as n}from"../src-
|
|
2
|
+
import{J as e,kt as t,yt as n}from"../src-lZq532nx.js";import{a as r,i,n as a,r as o,t as s}from"../full-interfaces-BPyQ4Hyv.js";const c=()=>{let e=n([`functype ${r} - Scala-inspired FP for TypeScript`,``]);return n(Object.entries(a)).foldLeft(e)((e,[r,a])=>{let o=e.add(r.toUpperCase());return n(a).foldLeft(o)((e,n)=>t(i[n]).fold(()=>e,t=>{let r=t.interfaces.length>0?` [${t.interfaces.join(`, `)}]`:``;return e.add(` ${n}${r}`).add(` ${t.description}`)})).add(``)}).concat(n([`Use: npx functype <Type> for details`,`Use: npx functype interfaces for interface reference`])).toArray().join(`
|
|
3
3
|
`)},l=(e,r)=>{let i=r.interfaces.length>0?` [${r.interfaces.join(`, `)}]`:``,a=n([`create`,`transform`,`extract`,`check`,`other`]),o=n([`${e}<T>${i}`,``,r.description,``]);return a.foldLeft(o)((e,i)=>t(r.methods[i]).filter(e=>e.length>0).fold(()=>e,t=>{let r=e.add(i.toUpperCase());return n(t).foldLeft(r)((e,t)=>e.add(` ${t}`)).add(``)})).toArray().join(`
|
|
4
4
|
`).trimEnd()},u=()=>{let e=n([`INTERFACES`,``]);return n(Object.entries(o)).foldLeft(e)((e,[t,r])=>{let i=r.extends?` extends ${r.extends}`:``,a=e.add(`${t}<A>${i}`).add(` ${r.description}`);return n(r.methods).foldLeft(a)((e,t)=>e.add(` ${t}`)).add(``)}).toArray().join(`
|
|
5
5
|
`).trimEnd()},d=e=>JSON.stringify(e,null,2),f=()=>({version:r,categories:a,types:i}),p=e=>t(i[e]).map(t=>({name:e,data:t})).or(n(Object.entries(i)).find(([t])=>t.toLowerCase()===e.toLowerCase()).map(([e,t])=>({name:e,data:t}))).orUndefined(),m=()=>Object.keys(i),h=()=>o,g=e=>{let t=n(e.slice(2));return{flags:{json:t.contains(`--json`),full:t.contains(`--full`),help:t.exists(e=>e===`--help`||e===`-h`)},args:t.filter(e=>!e.startsWith(`--`)&&e!==`-h`)}},_=e=>t(s[e]).or(n(Object.entries(s)).find(([t])=>t.toLowerCase()===e.toLowerCase()).map(([,e])=>e)),v=()=>{let e=n([`FULL INTERFACE DEFINITIONS`,`=`.repeat(60),``]);return n(Object.entries(s)).foldLeft(e)((e,[t,r])=>e.concat(n([`// ${t}`,r,``,`-`.repeat(60),``]))).toArray().join(`
|
package/dist/do/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as EmptyListError, c as LeftError, d as isDoCapable, dr as Doable, f as unwrap, i as DoGenerator, l as LeftErrorType, n as Do, o as FailureError, r as DoAsync, s as FailureErrorType, t as $, u as NoneError, ur as DoResult } from "../index-
|
|
1
|
+
import { a as EmptyListError, c as LeftError, d as isDoCapable, dr as Doable, f as unwrap, i as DoGenerator, l as LeftErrorType, n as Do, o as FailureError, r as DoAsync, s as FailureErrorType, t as $, u as NoneError, ur as DoResult } from "../index-BFDvVJ8v.js";
|
|
2
2
|
export { $, Do, DoAsync, DoGenerator, DoResult, Doable, EmptyListError, FailureError, FailureErrorType, LeftError, LeftErrorType, NoneError, isDoCapable, unwrap };
|
package/dist/do/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{F as e,I as t,L as n,M as r,N as i,P as a,R as o,j as s,z as c}from"../src-
|
|
1
|
+
import{F as e,I as t,L as n,M as r,N as i,P as a,R as o,j as s,z as c}from"../src-lZq532nx.js";export{s as $,r as Do,i as DoAsync,a as EmptyListError,e as FailureError,t as LeftError,n as NoneError,o as isDoCapable,c as unwrap};
|
package/dist/either/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { C as isRight, S as isLeft, T as tryCatchAsync, _ as Right, b as TypeCheckLeft, g as LeftOf, h as Left, m as EitherBase, p as Either, v as RightOf, w as tryCatch, x as TypeCheckRight, y as TestEither } from "../index-
|
|
1
|
+
import { C as isRight, S as isLeft, T as tryCatchAsync, _ as Right, b as TypeCheckLeft, g as LeftOf, h as Left, m as EitherBase, p as Either, v as RightOf, w as tryCatch, x as TypeCheckRight, y as TestEither } from "../index-BFDvVJ8v.js";
|
|
2
2
|
export { Either, EitherBase, Left, LeftOf, Right, RightOf, TestEither, TypeCheckLeft, TypeCheckRight, isLeft, isRight, tryCatch, tryCatchAsync };
|
package/dist/either/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_t as e,dt as t,ft as n,gt as r,ht as i,mt as a,pt as o,ut as s,vt as c}from"../src-
|
|
1
|
+
import{_t as e,dt as t,ft as n,gt as r,ht as i,mt as a,pt as o,ut as s,vt as c}from"../src-lZq532nx.js";export{s as Either,t as Left,n as Right,o as TypeCheckLeft,a as TypeCheckRight,i as isLeft,r as isRight,e as tryCatch,c as tryCatchAsync};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=`0.60.
|
|
1
|
+
const e=`0.60.3`,t={Option:{description:`Safe nullable handling - Some<T> or None`,interfaces:[`Functor`,`Monad`,`Foldable`,`Extractable`,`Matchable`,`Serializable`,`Traversable`],methods:{create:[`Option(v)`,`Option.none()`,`Some(v)`,`None()`],transform:[`.map(f)`,`.flatMap(f)`,`.filter(p)`,`.ap(ff)`],extract:[`.fold(n, s)`,`.foldAsync(n, s)`,`.orElse(d)`,`.orThrow()`,`.orNull()`,`.match({Some, None})`],check:[`.isSome`,`.isNone`,`.isDefined`,`.isEmpty`]}},Either:{description:`Error handling with Left (error) or Right (success)`,interfaces:[`Functor`,`Monad`,`Foldable`,`Traversable`,`PromiseLike`],methods:{create:[`Right(v)`,`Left(e)`,`Either.right(v)`,`Either.left(e)`,`Either.void()`],transform:[`.map(f)`,`.flatMap(f)`,`.mapLeft(f)`,`.swap()`],extract:[`.fold(l, r)`,`.foldAsync(l, r)`,`.orElse(d)`,`.orThrow()`,`.match({Left, Right})`],check:[`.isRight`,`.isLeft`]}},Try:{description:`Wrap operations that may throw - Success<T> or Failure`,interfaces:[`Functor`,`Monad`,`Foldable`,`Extractable`,`Matchable`,`Serializable`,`Traversable`],methods:{create:[`Try(() => expr)`,`Try.success(v)`,`Try.failure(e)`,`Try.fromPromise(p)`],transform:[`.map(f)`,`.flatMap(f)`,`.recover(f)`,`.recoverWith(f)`],extract:[`.fold(f, s)`,`.foldAsync(f, s)`,`.orElse(d)`,`.orThrow()`,`.toOption()`,`.toEither()`],check:[`.isSuccess`,`.isFailure`]}},List:{description:`Immutable array with functional operations`,interfaces:[`Functor`,`Monad`,`Foldable`,`Collection`,`Serializable`,`Traversable`],methods:{create:[`List([...])`,`List.of(...)`,`List.empty()`],transform:[`.map(f)`,`.flatMap(f)`,`.filter(p)`,`.take(n)`,`.takeWhile(p)`,`.takeRight(n)`,`.drop(n)`,`.dropWhile(p)`,`.concat(list)`,`.reverse()`,`.distinct()`,`.sorted()`,`.sortBy(f)`,`.zip(list)`,`.zipWithIndex()`,`.prepend(v)`,`.slice(s, e)`],extract:[`.fold(z, f)`,`.reduce(f)`,`.head`,`.headOption`,`.tail`,`.last`,`.lastOption`,`.init`,`.indexOf(v)`,`.toArray()`],check:[`.isEmpty`,`.nonEmpty`,`.size`,`.contains(v)`],other:[`.groupBy(f)`,`.partition(p)`,`.span(p)`]}},Set:{description:`Immutable set of unique values`,interfaces:[`Functor`,`Foldable`,`Collection`,`Serializable`,`Traversable`],methods:{create:[`Set([...])`,`Set.of(...)`,`Set.empty()`],transform:[`.map(f)`,`.filter(p)`,`.union(s)`,`.intersection(s)`,`.difference(s)`,`.add(v)`],extract:[`.fold(z, f)`,`.toArray()`],check:[`.has(v)`,`.isEmpty`,`.size`]}},Obj:{description:`Immutable object wrapper with fluent operations`,interfaces:[`KVTraversable`,`Foldable`,`Matchable`,`Extractable`,`Serializable`,`Reshapeable`,`Doable`],methods:{create:[`Obj({...})`,`Obj.of({...})`,`Obj.empty()`],transform:[`.set(k, v)`,`.assign(partial)`,`.merge(obj)`,`.when(cond, partial)`,`.omit(...keys)`,`.pick(...keys)`,`.map(f)`,`.flatMap(f)`],extract:[`.get(k)`,`.value()`,`.keys()`,`.values()`,`.entries()`,`.fold(n, s)`,`.match({Obj})`],check:[`.has(k)`,`.isEmpty`,`.size`]}},Map:{description:`Immutable key-value store`,interfaces:[`KVTraversable`,`Collection`,`Serializable`],methods:{create:[`Map([[k, v], ...])`,`Map.of([k, v], ...)`,`Map.empty()`],transform:[`.set(k, v)`,`.delete(k)`,`.map(f)`,`.filter(p)`,`.add(k, v)`],extract:[`.get(k)`,`.keys()`,`.values()`,`.entries()`,`.fold(z, f)`],check:[`.has(k)`,`.isEmpty`,`.size`]}},Lazy:{description:`Deferred computation with memoization`,interfaces:[`Functor`,`Monad`,`Foldable`,`Extractable`,`Serializable`,`Traversable`],methods:{create:[`Lazy(() => expr)`],transform:[`.map(f)`,`.flatMap(f)`],extract:[`.fold(n, s)`,`.orElse(d)`,`.orThrow()`,`.get()`],check:[`.isEvaluated`]}},LazyList:{description:`Lazy sequences for large/infinite data`,interfaces:[`Functor`,`Monad`,`Iterable`],methods:{create:[`LazyList.from(iter)`,`LazyList.range(start, end)`,`LazyList.infinite(f)`],transform:[`.map(f)`,`.filter(p)`,`.take(n)`,`.takeRight(n)`,`.drop(n)`,`.takeWhile(p)`,`.dropWhile(p)`,`.concat(ll)`,`.reverse()`,`.distinct()`,`.zip(ll)`,`.zipWithIndex()`],extract:[`.head`,`.headOption`,`.tail`,`.last`,`.lastOption`,`.init`,`.toArray()`],check:[`.isEmpty`]}},Task:{description:`Async operations with cancellation and progress tracking. Returns TaskOutcome<T> (Ok/Err) which implements Functor, AsyncMonad, Foldable, Extractable, Serializable`,interfaces:[],methods:{create:[`Task(params).Async(fn, errFn)`,`Task(params).Sync(fn, errFn)`,`Task.ok(value)`,`Task.err(error)`,`Task.fromEither(either)`,`Task.fromTry(try)`,`Task.fromPromise(fn)`,`Task.fromNodeCallback(fn)`],transform:[`.map(f)`,`.flatMap(f)`,`.mapError(f)`,`.recover(v)`,`.recoverWith(f)`],extract:[`.fold(onErr, onOk)`,`.match({Ok, Err})`,`.orElse(v)`,`.orThrow()`,`.toEither()`,`.toOption()`],other:[`Task.cancellable(fn)`,`Task.withProgress(fn, onProgress)`,`Task.race(tasks, timeout?)`,`Task.getErrorChain(error)`,`Task.formatErrorChain(error)`]}},IO:{description:`Lazy effect type with typed errors and dependency injection`,interfaces:[`Functor`,`Monad`,`Foldable`,`Matchable`],methods:{create:[`IO(() => v)`,`IO.succeed(v)`,`IO.fail(e)`,`IO.sync(f)`,`IO.async(f)`,`IO.tryPromise({try, catch})`,`IO.fromEither(e)`,`IO.fromOption(o)`,`IO.fromTry(t)`],transform:[`.map(f)`,`.flatMap(f)`,`.tap(f)`,`.mapError(f)`,`.recover(v)`,`.recoverWith(f)`],extract:[`.run()`,`.runOrThrow()`,`.runSync()`,`.runSyncOrThrow()`,`.runExit()`,`.runOption()`,`.runTry()`,`.fold(onErr, onOk)`,`.match({failure, success})`],check:[],other:[`.catchTag(tag, f)`,`.catchAll(f)`,`.retry(n)`,`.retryWithDelay(n, ms)`,`.timeout(ms)`,`.delay(ms)`,`.zip(io)`,`.pipe(f)`,`IO.all([...])`,`IO.race([...])`,`IO.bracket(acquire, use, release)`,`IO.gen(function*() {...})`,`IO.Do.bind().map()`,`IO.service(Tag)`,`.provideService(Tag, impl)`,`.provideLayer(layer)`]}},Cond:{description:`Conditional expression builder - replace if-else chains`,interfaces:[],methods:{create:[`Cond<T>()`],other:[`.case(pred, result)`,`.otherwise(result)`,`.eval()`]}},Match:{description:`Pattern matching - replace switch statements`,interfaces:[],methods:{create:[`Match(value)`],other:[`.case(pattern, result)`,`.when(pred, result)`,`.default(result)`,`.done()`]}},Brand:{description:`Nominal typing without runtime overhead`,interfaces:[],methods:{create:[`Brand<K, T>(value)`],extract:[`.unwrap()`,`.toString()`]}},ValidatedBrand:{description:`Branded types with runtime validation`,interfaces:[],methods:{create:[`ValidatedBrand(validator)`,`.of(v)`,`.from(v)`,`.unsafeOf(v)`],check:[`.is(v)`],other:[`.refine(validator)`]}},Tuple:{description:`Fixed-size typed array`,interfaces:[`Typeable`,`Valuable`,`Iterable`],methods:{create:[`Tuple([a, b, ...])`,`Tuple.of(a, b, ...)`],extract:[`.first`,`.second`,`.toArray()`],transform:[`.map(f)`]}},Stack:{description:`Immutable LIFO stack`,interfaces:[`Foldable`,`Collection`,`Serializable`,`Traversable`],methods:{create:[`Stack()`,`Stack.of(...)`],transform:[`.push(v)`,`.pop()`],extract:[`.peek()`,`.toArray()`],check:[`.isEmpty`,`.size`]}},Http:{description:`HTTP fetch wrapper returning IO<never, HttpError, HttpResponse<unknown>> by default. Provide a validate function to get typed responses (BYOV: bring your own validator). Works with Zod, TypeBox, Valibot, or manual validators.`,interfaces:[],methods:{create:[`Http.get(url, { validate }?)`,`Http.post(url, { body, validate }?)`,`Http.put(url, { body, validate }?)`,`Http.patch(url, { body, validate }?)`,`Http.delete(url, { validate }?)`,`Http.request({ url, validate })`,`Http.client(config)`],transform:[`.map(f)`,`.flatMap(f)`,`.retry(n)`,`.retryWithDelay(n, ms)`,`.timeout(ms)`],extract:[`.run()`,`.runOrThrow()`,`.runOption()`,`.runTry()`],check:[],other:[`.catchTag(tag, handler)`,`.catchAll(handler)`,`.mapError(f)`,`.recover(fallback)`]}},HttpError:{description:`Three-variant ADT for HTTP failures: NetworkError | HttpStatusError | DecodeError`,interfaces:[],methods:{create:[`HttpError.networkError(url, method, cause)`,`HttpError.httpStatusError(url, method, status, statusText, body)`,`HttpError.decodeError(url, method, body, cause)`],check:[`HttpError.isNetworkError(e)`,`HttpError.isHttpStatusError(e)`,`HttpError.isDecodeError(e)`],other:[`HttpError.match(error, { NetworkError, HttpStatusError, DecodeError })`]}}},n={Functor:{description:`Transform contained values`,methods:[`.map<B>(f: A => B): Functor<B>`]},Applicative:{extends:`Functor`,description:`Apply wrapped functions`,methods:[`.ap<B>(ff: Applicative<A => B>): Applicative<B>`]},Monad:{extends:`Applicative`,description:`Chain operations returning wrapped values`,methods:[`.flatMap<B>(f: A => Monad<B>): Monad<B>`]},Foldable:{description:`Extract via pattern matching`,methods:[`.fold<B>(empty: () => B, f: A => B): B`,`.foldLeft<B>(z: B, op: (B, A) => B): B`,`.foldRight<B>(z: B, op: (A, B) => B): B`]},Extractable:{description:`Get contained value with fallback`,methods:[`.orElse(d: T): T`,`.orThrow(e?: Error): T`,`.orNull(): T | null`,`.orUndefined(): T | undefined`]},Matchable:{description:`Pattern match on type variants`,methods:[`.match<R>(patterns: Record<Tag, Handler>): R`]},Traversable:{description:`Iterate and check contents`,methods:[`.size: number`,`.isEmpty: boolean`,`.contains(v: A): boolean`,`.reduce<B>(f, init): B`]},Collection:{description:`Collection operations`,methods:[`.toArray(): A[]`,`.forEach(f: A => void): void`]},Serializable:{description:`Convert to string formats`,methods:[`.serialize().toJSON(): string`,`.serialize().toYAML(): string`]}},r={Core:[`Option`,`Either`,`Try`,`Obj`],Collection:[`List`,`Set`,`Map`,`LazyList`,`Tuple`,`Stack`],Effect:[`IO`,`Task`,`Http`,`HttpError`],Utility:[`Lazy`,`Cond`,`Match`,`Brand`,`ValidatedBrand`]},i={Option:`export interface Option<out T extends Type>
|
|
2
2
|
extends Functype<T, "Some" | "None">, Promisable<T>, Doable<T>, Reshapeable<T> {
|
|
3
3
|
/** The contained value (undefined for None) */
|
|
4
4
|
readonly value: T | undefined
|
|
@@ -2449,12 +2449,12 @@ type IOEffect<R, E, A> = {
|
|
|
2449
2449
|
readonly fallback: A;
|
|
2450
2450
|
} | {
|
|
2451
2451
|
readonly _tag: "RecoverWith";
|
|
2452
|
-
readonly effect: IO<R,
|
|
2453
|
-
readonly f: (e:
|
|
2452
|
+
readonly effect: IO<R, unknown, unknown>;
|
|
2453
|
+
readonly f: (e: unknown) => IO<R, E, A>;
|
|
2454
2454
|
} | {
|
|
2455
2455
|
readonly _tag: "Fold";
|
|
2456
|
-
readonly effect: IO<R,
|
|
2457
|
-
readonly onFailure: (e:
|
|
2456
|
+
readonly effect: IO<R, unknown, unknown>;
|
|
2457
|
+
readonly onFailure: (e: unknown) => A;
|
|
2458
2458
|
readonly onSuccess: (a: unknown) => A;
|
|
2459
2459
|
} | {
|
|
2460
2460
|
readonly _tag: "Bracket";
|
|
@@ -2492,7 +2492,7 @@ type IOEffect<R, E, A> = {
|
|
|
2492
2492
|
interface IOYieldable {
|
|
2493
2493
|
readonly [Symbol.toStringTag]: string;
|
|
2494
2494
|
}
|
|
2495
|
-
interface IO<R extends Type, E extends Type, A extends Type> {
|
|
2495
|
+
interface IO<in out R extends Type, out E extends Type, out A extends Type> {
|
|
2496
2496
|
readonly [Symbol.toStringTag]: string;
|
|
2497
2497
|
/**
|
|
2498
2498
|
* Internal effect representation (symbol-keyed for opacity)
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { a as ExtractBrand, c as hasBrand, i as BrandedString, l as unwrapBrand, n as BrandedBoolean, o as Unwrap, r as BrandedNumber, s as createBrander, t as Brand } from "./Brand-BJIRbUKB.js";
|
|
2
|
-
import { $ as Map, $n as reduceWiden, $t as TypedErrorContext, A as Collection, An as Cond, At as Task, B as SerializationResult, Bn as NonEmptyString, Bt as ContextServices, C as isRight, Cn as isTaggedThrowable, Ct as HttpClientConfig, D as Functype, Dn as Base, Dt as IO, E as FunctypeSum, En as ThrowableType, Et as TestContext, F as Some, Fn as BoundedNumber, Ft as LayerInput, G as fromJSON, Gn as UUID, Gt as FormValidation, H as createSerializationCompanion, Hn as PatternString, Ht as Tag, I as Stack, In as BoundedString, It as LayerOutput, J as Obj, Jn as ValidatedBrandCompanion, Jt as Validator, K as fromYAML, Kn as UrlString, Kt as Validation, L as Valuable, Ln as EmailAddress, Lt as Exit, M as None, Mn as InstanceType, Mt as UIO, N as Option, Nn as isCompanion, Nt as Layer, O as FunctypeBase, On as Match, Ot as InterruptedError, P as OptionConstructor, Pn as Companion, Pt as LayerError, Q as ESMapType, Qn as reduceRightWiden, Qt as TypedError, R as ValuableParams, Rn as ISO8601Date, Rt as ExitTag, S as isLeft, Sn as createCancellationTokenSource, St as HttpClient, T as tryCatchAsync, Tn as Throwable, Tt as TestClockTag, U as createSerializer, Un as PositiveInteger, Ut as TagService, V as createCustomSerializer, Vn as NonNegativeNumber, Vt as HasService, W as fromBinary, Wn as PositiveNumber, Wt as FieldValidation, X as MatchableUtils, Xn as TypeNames, Xt as ErrorMessage, Y as Matchable, Yn as Try, Yt as ErrorCode, Z as ESMap, Zn as Widen, Zt as ErrorStatus, _ as Right, _n as TaskMetadata, _t as DecodeError, a as EmptyListError, an as formatError, ar as CollectionOps, at as HKT, b as TypeCheckLeft, bn as TaskResult, bt as HttpStatusError, c as LeftError, cn as Async, cr as Extractable, ct as OptionKind, d as isDoCapable, dn as Err, dr as Doable, dt as FoldableUtils, en as ErrorChainElement, er as Promisable, et as KVTraversable, f as unwrap, fn as Ok, fr as ParseError, ft as Http, g as LeftOf, gn as TaskFailure, gt as ParseMode, h as Left, hn as Task$1, ht as HttpResponse, i as DoGenerator, in as createErrorSerializer, ir as Monad, it as EitherKind, j as List, jn as CompanionMethods, jt as TimeoutError, k as FunctypeCollection, kn as UntypedMatch, kt as RIO, l as LeftErrorType, ln as CancellationToken, lr as isExtractable, lt as TryKind, m as EitherBase, mn as TaggedThrowable, mt as HttpRequestOptions, n as Do, nn as ErrorWithTaskInfo, nr as AsyncMonad, nt as Lazy, o as FailureError, on as formatStackTrace, or as ContainerOps, ot as Kind, p as Either, pn as Sync, pt as HttpMethodOptions, q as Ref, qn as ValidatedBrand, qt as ValidationRule, r as DoAsync, rn as TaskErrorInfo, rr as Functor, rt as Identity, s as FailureErrorType, sn as safeStringify, sr as LazyList, st as ListKind, t as $, tn as ErrorFormatterOptions, tr as Applicative, tt as Traversable, u as NoneError, un as CancellationTokenSource, ur as DoResult, ut as UniversalContainer, v as RightOf, vn as TaskOutcome, vt as HttpError, w as tryCatch, wn as NAME, wt as TestClock, x as TypeCheckRight, xn as TaskSuccess, xt as NetworkError, y as TestEither, yn as TaskParams, yt as HttpMethod, z as Set, zn as IntegerNumber, zt as Context } from "./index-
|
|
2
|
+
import { $ as Map, $n as reduceWiden, $t as TypedErrorContext, A as Collection, An as Cond, At as Task, B as SerializationResult, Bn as NonEmptyString, Bt as ContextServices, C as isRight, Cn as isTaggedThrowable, Ct as HttpClientConfig, D as Functype, Dn as Base, Dt as IO, E as FunctypeSum, En as ThrowableType, Et as TestContext, F as Some, Fn as BoundedNumber, Ft as LayerInput, G as fromJSON, Gn as UUID, Gt as FormValidation, H as createSerializationCompanion, Hn as PatternString, Ht as Tag, I as Stack, In as BoundedString, It as LayerOutput, J as Obj, Jn as ValidatedBrandCompanion, Jt as Validator, K as fromYAML, Kn as UrlString, Kt as Validation, L as Valuable, Ln as EmailAddress, Lt as Exit, M as None, Mn as InstanceType, Mt as UIO, N as Option, Nn as isCompanion, Nt as Layer, O as FunctypeBase, On as Match, Ot as InterruptedError, P as OptionConstructor, Pn as Companion, Pt as LayerError, Q as ESMapType, Qn as reduceRightWiden, Qt as TypedError, R as ValuableParams, Rn as ISO8601Date, Rt as ExitTag, S as isLeft, Sn as createCancellationTokenSource, St as HttpClient, T as tryCatchAsync, Tn as Throwable, Tt as TestClockTag, U as createSerializer, Un as PositiveInteger, Ut as TagService, V as createCustomSerializer, Vn as NonNegativeNumber, Vt as HasService, W as fromBinary, Wn as PositiveNumber, Wt as FieldValidation, X as MatchableUtils, Xn as TypeNames, Xt as ErrorMessage, Y as Matchable, Yn as Try, Yt as ErrorCode, Z as ESMap, Zn as Widen, Zt as ErrorStatus, _ as Right, _n as TaskMetadata, _t as DecodeError, a as EmptyListError, an as formatError, ar as CollectionOps, at as HKT, b as TypeCheckLeft, bn as TaskResult, bt as HttpStatusError, c as LeftError, cn as Async, cr as Extractable, ct as OptionKind, d as isDoCapable, dn as Err, dr as Doable, dt as FoldableUtils, en as ErrorChainElement, er as Promisable, et as KVTraversable, f as unwrap, fn as Ok, fr as ParseError, ft as Http, g as LeftOf, gn as TaskFailure, gt as ParseMode, h as Left, hn as Task$1, ht as HttpResponse, i as DoGenerator, in as createErrorSerializer, ir as Monad, it as EitherKind, j as List, jn as CompanionMethods, jt as TimeoutError, k as FunctypeCollection, kn as UntypedMatch, kt as RIO, l as LeftErrorType, ln as CancellationToken, lr as isExtractable, lt as TryKind, m as EitherBase, mn as TaggedThrowable, mt as HttpRequestOptions, n as Do, nn as ErrorWithTaskInfo, nr as AsyncMonad, nt as Lazy, o as FailureError, on as formatStackTrace, or as ContainerOps, ot as Kind, p as Either, pn as Sync, pt as HttpMethodOptions, q as Ref, qn as ValidatedBrand, qt as ValidationRule, r as DoAsync, rn as TaskErrorInfo, rr as Functor, rt as Identity, s as FailureErrorType, sn as safeStringify, sr as LazyList, st as ListKind, t as $, tn as ErrorFormatterOptions, tr as Applicative, tt as Traversable, u as NoneError, un as CancellationTokenSource, ur as DoResult, ut as UniversalContainer, v as RightOf, vn as TaskOutcome, vt as HttpError, w as tryCatch, wn as NAME, wt as TestClock, x as TypeCheckRight, xn as TaskSuccess, xt as NetworkError, y as TestEither, yn as TaskParams, yt as HttpMethod, z as Set, zn as IntegerNumber, zt as Context } from "./index-BFDvVJ8v.js";
|
|
3
3
|
import { a as isTypeable, c as Pipe, i as TypeableParams, l as Foldable, n as ExtractTag, o as Serializable, r as Typeable, s as SerializationMethods, t as Tuple, u as Type } from "./Tuple-De-FhPDq.js";
|
|
4
4
|
export { $, Applicative, Async, AsyncMonad, Base, BoundedNumber, BoundedString, Brand, BrandedBoolean, BrandedBoolean as BrandedBooleanType, BrandedNumber, BrandedNumber as BrandedNumberType, BrandedString, BrandedString as BrandedStringType, CancellationToken, CancellationTokenSource, Collection, CollectionOps, Companion, CompanionMethods, Cond, ContainerOps, Context, Context as ContextType, ContextServices, DecodeError, Do, DoAsync, DoGenerator, DoResult, Doable, ESMap, ESMapType, Either, EitherBase, EitherKind, EmailAddress, EmptyListError, Err, ErrorChainElement, ErrorCode, ErrorFormatterOptions, ErrorMessage, ErrorStatus, ErrorWithTaskInfo, Exit, Exit as ExitType, ExitTag, ExtractBrand, ExtractTag, Extractable, FailureError, FailureErrorType, FieldValidation, Foldable, FoldableUtils, FormValidation, Functor, Functype, FunctypeBase, FunctypeCollection, FunctypeSum, HKT, HasService, Http, HttpClient, HttpClientConfig, HttpError, HttpError as HttpErrors, HttpMethod, HttpMethodOptions, HttpRequestOptions, HttpResponse, HttpStatusError, IO, IO as IOType, Task as IOTask, ISO8601Date, Identity, InstanceType, IntegerNumber, InterruptedError, KVTraversable, Kind, Layer, Layer as LayerType, LayerError, LayerInput, LayerOutput, Lazy, Lazy as LazyType, LazyList, Left, LeftError, LeftErrorType, LeftOf, List, ListKind, Map, Match, Matchable, MatchableUtils, Monad, NAME, NetworkError, NonEmptyString, NonNegativeNumber, None, NoneError, Obj, Ok, Option, OptionConstructor, OptionKind, ParseError, ParseMode, PatternString, Pipe, PositiveInteger, PositiveNumber, Promisable, RIO, Ref, Ref as RefType, Right, RightOf, Serializable, SerializationMethods, SerializationResult, Set, Some, Stack, Sync, Tag, Tag as TagType, TagService, TaggedThrowable, Task$1 as Task, TaskErrorInfo, TaskFailure, TaskMetadata, TaskOutcome, TaskParams, TaskResult, TaskSuccess, TestClock, TestClock as TestClockType, TestClockTag, TestContext, TestContext as TestContextType, TestEither, Throwable, ThrowableType, TimeoutError, Traversable, Try, TryKind, Tuple, Type, TypeCheckLeft, TypeCheckRight, TypeNames, Typeable, TypeableParams, TypedError, TypedErrorContext, UIO, UUID, UniversalContainer, UntypedMatch, Unwrap, UrlString, ValidatedBrand, ValidatedBrand as ValidatedBrandType, ValidatedBrandCompanion, Validation, ValidationRule, Validator, Valuable, ValuableParams, Widen, createBrander, createCancellationTokenSource, createCustomSerializer, createErrorSerializer, createSerializationCompanion, createSerializer, formatError, formatStackTrace, fromBinary, fromJSON, fromYAML, hasBrand, isCompanion, isDoCapable, isExtractable, isLeft, isRight, isTaggedThrowable, isTypeable, reduceRightWiden, reduceWiden, safeStringify, tryCatch, tryCatchAsync, unwrap, unwrapBrand };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Brand as e,BrandedBoolean as t,BrandedNumber as n,BrandedString as r,createBrander as i,hasBrand as a,unwrap as o}from"./branded/index.js";import{$ as s,A as c,At as l,B as u,C as d,Ct as f,D as p,Dt as m,E as h,Et as g,F as _,Ft as v,G as y,H as b,I as x,It as S,J as C,K as w,L as T,Lt as E,M as D,Mt as O,N as k,Nt as A,O as j,Ot as M,P as N,Pt as P,Q as F,R as I,Rt as L,S as R,St as z,T as B,Tt as V,U as H,V as U,W,X as G,Y as K,Z as q,_ as J,_t as Y,a as X,at as Z,b as Q,bt as $,c as ee,ct as te,d as ne,dt as re,et as ie,f as ae,ft as oe,g as se,gt as ce,h as le,ht as ue,i as de,it as fe,j as pe,jt as me,k as he,kt as ge,l as _e,lt as ve,m as ye,mt as be,n as xe,nt as Se,o as Ce,ot as we,p as Te,pt as Ee,q as De,r as Oe,rt as ke,s as Ae,st as je,t as Me,tt as Ne,u as Pe,ut as Fe,v as Ie,vt as Le,w as Re,wt as ze,x as Be,xt as Ve,y as He,yt as Ue,z as We}from"./src-
|
|
1
|
+
import{Brand as e,BrandedBoolean as t,BrandedNumber as n,BrandedString as r,createBrander as i,hasBrand as a,unwrap as o}from"./branded/index.js";import{$ as s,A as c,At as l,B as u,C as d,Ct as f,D as p,Dt as m,E as h,Et as g,F as _,Ft as v,G as y,H as b,I as x,It as S,J as C,K as w,L as T,Lt as E,M as D,Mt as O,N as k,Nt as A,O as j,Ot as M,P as N,Pt as P,Q as F,R as I,Rt as L,S as R,St as z,T as B,Tt as V,U as H,V as U,W,X as G,Y as K,Z as q,_ as J,_t as Y,a as X,at as Z,b as Q,bt as $,c as ee,ct as te,d as ne,dt as re,et as ie,f as ae,ft as oe,g as se,gt as ce,h as le,ht as ue,i as de,it as fe,j as pe,jt as me,k as he,kt as ge,l as _e,lt as ve,m as ye,mt as be,n as xe,nt as Se,o as Ce,ot as we,p as Te,pt as Ee,q as De,r as Oe,rt as ke,s as Ae,st as je,t as Me,tt as Ne,u as Pe,ut as Fe,v as Ie,vt as Le,w as Re,wt as ze,x as Be,xt as Ve,y as He,yt as Ue,z as We}from"./src-lZq532nx.js";import{r as Ge,t as Ke}from"./Tuple-DY00RBep.js";export{pe as $,De as Base,q as BoundedNumber,F as BoundedString,e as Brand,t as BrandedBoolean,n as BrandedNumber,r as BrandedString,Ge as Companion,K as Cond,d as Context,D as Do,k as DoAsync,Ce as ESMap,Fe as Either,s as EmailAddress,N as EmptyListError,u as Err,R as Exit,_ as FailureError,Pe as FoldableUtils,_e as HKT,ne as Http,Te as HttpClient,ae as HttpErrors,He as IO,ie as ISO8601Date,ee as Identity,Ne as IntegerNumber,Q as InterruptedError,Ie as Layer,Ae as Lazy,f as LazyList,re as Left,x as LeftError,Ue as List,X as Map,C as Match,de as MatchableUtils,y as NAME,Se as NonEmptyString,ke as NonNegativeNumber,M as None,T as NoneError,Oe as Obj,U as Ok,ge as Option,l as OptionConstructor,L as ParseError,fe as PatternString,Z as PositiveInteger,we as PositiveNumber,ze as Ref,oe as Right,V as Set,me as Some,xe as Stack,J as Tag,b as Task,ye as TestClock,le as TestClockTag,se as TestContext,w as Throwable,Be as TimeoutError,z as Try,Ke as Tuple,Ee as TypeCheckLeft,be as TypeCheckRight,$ as Typeable,h as TypedError,je as UUID,te as UrlString,ve as ValidatedBrand,B as Validation,Me as Valuable,i as createBrander,H as createCancellationTokenSource,O as createCustomSerializer,p as createErrorSerializer,A as createSerializationCompanion,P as createSerializer,j as formatError,he as formatStackTrace,v as fromBinary,S as fromJSON,E as fromYAML,a as hasBrand,G as isCompanion,I as isDoCapable,Re as isExtractable,ue as isLeft,ce as isRight,W as isTaggedThrowable,Ve as isTypeable,g as reduceRightWiden,m as reduceWiden,c as safeStringify,Y as tryCatch,Le as tryCatchAsync,We as unwrap,o as unwrapBrand};
|
package/dist/list/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { j as List } from "../index-
|
|
1
|
+
import { j as List } from "../index-BFDvVJ8v.js";
|
|
2
2
|
export { List };
|
package/dist/list/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{yt as e}from"../src-
|
|
1
|
+
import{yt as e}from"../src-lZq532nx.js";export{e as List};
|
package/dist/map/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as Map } from "../index-
|
|
1
|
+
import { $ as Map } from "../index-BFDvVJ8v.js";
|
|
2
2
|
export { Map };
|
package/dist/map/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"../src-
|
|
1
|
+
import{a as e}from"../src-lZq532nx.js";export{e as Map};
|
package/dist/option/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { F as Some, M as None, N as Option, P as OptionConstructor } from "../index-
|
|
1
|
+
import { F as Some, M as None, N as Option, P as OptionConstructor } from "../index-BFDvVJ8v.js";
|
|
2
2
|
export { None, Option, OptionConstructor, Some };
|
package/dist/option/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{At as e,Ot as t,jt as n,kt as r}from"../src-
|
|
1
|
+
import{At as e,Ot as t,jt as n,kt as r}from"../src-lZq532nx.js";export{t as None,r as Option,e as OptionConstructor,n as Some};
|
package/dist/set/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { z as Set } from "../index-
|
|
1
|
+
import { z as Set } from "../index-BFDvVJ8v.js";
|
|
2
2
|
export { Set };
|
package/dist/set/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Tt as e}from"../src-
|
|
1
|
+
import{Tt as e}from"../src-lZq532nx.js";export{e as Set};
|
|
@@ -13,7 +13,7 @@ import{Brand as e}from"./branded/index.js";import{i as t,n,r,t as i}from"./Tuple
|
|
|
13
13
|
`);return[t[0],...t.slice(1).map(e=>e.trim())].join(`
|
|
14
14
|
`)}function yt(e,t){let n={...gt,...t},r=e instanceof Error?e:Qe.apply(e),i=A?.getErrorChain?A.getErrorChain(r):[r],a=`${n.colors?`\x1b[31m${n.title}:\x1b[0m ${r.message}`:`${n.title}: ${r.message}`}\n\n${i.map((e,t)=>{let r=` `.repeat(t),i=t>0?`↳ `:``,{taskInfo:a}=e,o=`${r}${i}${n.includeTasks&&a?.name?n.colors?`\x1b[36m[${a.name}]\x1b[0m `:`[${a.name}] `:``}${e.message}`;if(n.includeStackTrace&&e.stack){let t=vt(e.stack).split(`
|
|
15
15
|
`).slice(1),i=n.maxStackFrames??gt.maxStackFrames??3,a=t.slice(0,i).map(e=>`${r} ${n.colors?`\x1B[90m`:``}${e}${n.colors?`\x1B[0m`:``}`).join(`
|
|
16
|
-
`);o+=`\n${a}`,t.length>i&&(o+=`\n${r} ${n.colors?`\x1B[90m`:``}...${t.length-i} more stack frames${n.colors?`\x1B[0m`:``}`)}return o}).join(n.separator)}`;if(n.includeData){let{data:e}=r;if(e){let t=n.colors?`\n\n\x1b[33mContext:\x1b[0m\n${_t(e)}`:`\n\nContext:\n${_t(e)}`;a+=t}}return a}function bt(){return function(e){if(!e)return e;let t=e instanceof Error?e:Error(String(e)),n={message:t.message,name:t.name||`Error`,stack:t.stack?vt(t.stack):void 0};if(t.taskInfo&&(n.taskInfo=t.taskInfo),t.data&&(n.data=t.data),typeof A?.getErrorChain==`function`)try{let e=A.getErrorChain(t);e.length>1&&(n.errorChain=A.formatErrorChain(t,{includeTasks:!0}),n.structuredErrorChain=e.map(e=>({message:e.message,name:e.name,taskInfo:e.taskInfo,stack:e.stack?vt(e.stack):void 0})))}catch{}return Object.getOwnPropertyNames(t).forEach(e=>{n[e]||(n[e]=t[e])}),n}}const j=(e,n,r,i)=>t(Qe.apply(n,r,{name:e,description:n}),{code:e,message:n,status:xt(e),context:r,timestamp:new Date().toISOString(),traceId:i?.traceId}),xt=e=>({VALIDATION_FAILED:400,BAD_REQUEST:400,AUTH_REQUIRED:401,PERMISSION_DENIED:403,NOT_FOUND:404,TIMEOUT:408,CONFLICT:409,RATE_LIMITED:429,INTERNAL_ERROR:500,NETWORK_ERROR:503})[e],M=Object.assign(j,{validation:(e,t,n)=>j(`VALIDATION_FAILED`,`Validation failed: ${e} ${n}`,{field:e,value:t,rule:n}),network:(e,t,n)=>j(`NETWORK_ERROR`,`Network error: ${t} ${e}${n?` (${n})`:``}`,{url:e,method:t,statusCode:n}),auth:(e,t)=>j(`AUTH_REQUIRED`,`Authentication required: ${e}${t?` (role: ${t})`:``}`,{resource:e,requiredRole:t}),notFound:(e,t)=>j(`NOT_FOUND`,`Not found: ${e} with id ${t}`,{resource:e,id:t}),permission:(e,t,n)=>j(`PERMISSION_DENIED`,`Permission denied: cannot ${e} ${t}`,{action:e,resource:t,userId:n}),rateLimit:(e,t,n)=>j(`RATE_LIMITED`,`Rate limit exceeded: ${e} requests per ${t}`,{limit:e,window:t,retryAfter:n}),internal:e=>j(`INTERNAL_ERROR`,`Internal server error: ${e}`,{errorId:e,timestamp:new Date().toISOString()}),badRequest:(e,t)=>j(`BAD_REQUEST`,`Bad request: ${e}`,{reason:e,expected:t}),conflict:(e,t)=>j(`CONFLICT`,`Conflict: ${e} already exists with value ${t}`,{resource:e,conflictingValue:t}),timeout:(e,t)=>j(`TIMEOUT`,`Request timeout: ${t} exceeded ${e}ms`,{duration:e,operation:t}),isTypedError:e=>typeof e==`object`&&!!e&&`code`in e&&`message`in e&&`status`in e&&`context`in e&&`_tag`in e&&e._tag===`Throwable`,hasCode:(e,t)=>e.code===t}),N={rule:e=>t=>{if(e===`email`)return typeof t!=`string`||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)?T(M.validation(`value`,t,`must be a valid email`)):w(t);if(e===`url`)try{return new URL(String(t)),w(t)}catch{return T(M.validation(`value`,t,`must be a valid URL`))}if(e===`uuid`)return typeof t!=`string`||!/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(t)?T(M.validation(`value`,t,`must be a valid UUID`)):w(t);if(e===`required`)return t==null||t===``?T(M.validation(`value`,t,`is required`)):w(t);if(e===`numeric`)return typeof t!=`number`&&!/^\d+$/.test(String(t))?T(M.validation(`value`,t,`must be numeric`)):w(t);if(e===`alpha`)return typeof t!=`string`||!/^[a-zA-Z]+$/.test(t)?T(M.validation(`value`,t,`must contain only letters`)):w(t);if(e===`alphanumeric`)return typeof t!=`string`||!/^[a-zA-Z0-9]+$/.test(t)?T(M.validation(`value`,t,`must be alphanumeric`)):w(t);if(e.startsWith(`min:`)){let n=Number(e.split(`:`)[1]),r=Number(t);return isNaN(r)||r<n?T(M.validation(`value`,t,`must be at least ${n}`)):w(t)}if(e.startsWith(`max:`)){let n=Number(e.split(`:`)[1]),r=Number(t);return isNaN(r)||r>n?T(M.validation(`value`,t,`must be at most ${n}`)):w(t)}if(e.startsWith(`minLength:`)){let n=Number(e.split(`:`)[1]);return String(t).length<n?T(M.validation(`value`,t,`must be at least ${n} characters`)):w(t)}if(e.startsWith(`maxLength:`)){let n=Number(e.split(`:`)[1]);return String(t).length>n?T(M.validation(`value`,t,`must be at most ${n} characters`)):w(t)}if(e.startsWith(`pattern:`)){let n=e.substring(8);return new RegExp(n).test(String(t))?w(t):T(M.validation(`value`,t,`must match pattern ${n}`))}if(e.startsWith(`in:`)){let n=e.substring(3).split(`,`);return n.includes(String(t))?w(t):T(M.validation(`value`,t,`must be one of: ${n.join(`, `)}`))}if(e.startsWith(`notIn:`)){let n=e.substring(6).split(`,`);return n.includes(String(t))?T(M.validation(`value`,t,`must not be one of: ${n.join(`, `)}`)):w(t)}if(e===`date`){let e=new Date(String(t));return isNaN(e.getTime())?T(M.validation(`value`,t,`must be a valid date`)):w(t)}if(e===`future`){let e=new Date(String(t));return isNaN(e.getTime())||e<=new Date?T(M.validation(`value`,t,`must be a future date`)):w(t)}if(e===`past`){let e=new Date(String(t));return isNaN(e.getTime())||e>=new Date?T(M.validation(`value`,t,`must be a past date`)):w(t)}return w(t)},combine:(...e)=>t=>{for(let n of e){let e=n(t);if(e.isLeft())return e}return w(t)},custom:(e,t)=>n=>e(n)?w(n):T(M.validation(`value`,n,t)),form:(e,t)=>{let n=[],r={};for(let[i,a]of Object.entries(e)){let e=t[i],o=a(e);if(o.isLeft()){let t=o.fold(e=>e,()=>{throw Error(`Should not be left`)}),r=M.validation(i,e,t.context.rule);n.push(r)}else r[i]=o.orThrow()}return n.length>0?T(C(n)):w(r)}},St={...N,validators:{email:N.rule(`email`),url:N.rule(`url`),uuid:N.rule(`uuid`),required:N.rule(`required`),numeric:N.rule(`numeric`),positiveNumber:N.combine(N.rule(`numeric`),N.rule(`min:0`)),nonEmptyString:N.combine(N.rule(`required`),N.custom(e=>typeof e==`string`&&e.trim().length>0,`must not be empty`))}},Ct=t(N.rule,St);function wt(e){return typeof e==`object`&&!!e&&`orThrow`in e&&typeof e.orThrow==`function`}function Tt(e){return wt(e)&&`orElse`in e&&typeof e.orElse==`function`&&`or`in e&&typeof e.or==`function`&&`orNull`in e&&typeof e.orNull==`function`&&`orUndefined`in e&&typeof e.orUndefined==`function`}const Et=e=>({_tag:`Context`,services:e,get(t){let n=e.get(t.id);return n===void 0?p():d(n)},unsafeGet(t){let n=e.get(t.id);if(n===void 0)throw Error(`Service not found: ${t.id}`);return n},has(t){return e.has(t.id)},add(t,n){let r=new Map(e);return r.set(t.id,n),Et(r)},merge(t){let n=new Map(e);for(let[e,r]of t.services)n.set(e,r);return Et(n)},get size(){return e.size},toString(){return`Context(${Array.from(e.keys()).join(`, `)})`}}),P={empty:()=>Et(new Map),make:(e,t)=>{let n=new Map;return n.set(e.id,t),Et(n)},isContext:e=>typeof e==`object`&&!!e&&e._tag===`Context`},F=e=>({[Symbol.toStringTag]:`Exit`,_tag:`Success`,isSuccess(){return!0},isFailure(){return!1},isInterrupted(){return!1},map(t){return F(t(e))},mapError(t){return F(e)},mapBoth(t,n){return F(n(e))},flatMap(t){return t(e)},fold(t,n,r){return n(e)},match(t){return t.Success(e)},orThrow(){return e},orElse(t){return e},toOption(){return d(e)},toEither(){return w(e)},toValue(){return{_tag:`Success`,value:e}},toString(){return`Exit.Success(${n(e)})`},toJSON(){return{_tag:`Success`,value:e}}}),Dt=e=>({[Symbol.toStringTag]:`Exit`,_tag:`Failure`,isSuccess(){return!1},isFailure(){return!0},isInterrupted(){return!1},map(t){return Dt(e)},mapError(t){return Dt(t(e))},mapBoth(t,n){return Dt(t(e))},flatMap(t){return Dt(e)},fold(t,n,r){return t(e)},match(t){return t.Failure(e)},orThrow(){throw e},orElse(e){return e},toOption(){return p()},toEither(){return T(e)},toValue(){return{_tag:`Failure`,error:e}},toString(){return`Exit.Failure(${n(e)})`},toJSON(){return{_tag:`Failure`,error:e}}}),Ot=e=>({[Symbol.toStringTag]:`Exit`,_tag:`Interrupted`,isSuccess(){return!1},isFailure(){return!1},isInterrupted(){return!0},map(t){return Ot(e)},mapError(t){return Ot(e)},mapBoth(t,n){return Ot(e)},flatMap(t){return Ot(e)},fold(t,n,r){if(r)return r(e);throw Error(`Effect was interrupted: ${e}`)},match(t){return t.Interrupted(e)},orThrow(){throw Error(`Effect was interrupted: ${e}`)},orElse(e){return e},toOption(){return p()},toEither(){throw Error(`Cannot convert Interrupted Exit to Either: ${e}`)},toValue(){return{_tag:`Interrupted`,fiberId:e}},toString(){return`Exit.Interrupted(${e})`},toJSON(){return{_tag:`Interrupted`,fiberId:e}}}),I=r(e=>F(e),{succeed:e=>F(e),fail:e=>Dt(e),interrupt:e=>Ot(e),interrupted:()=>Ot(`interrupted`),isSuccess:e=>e.isSuccess(),isFailure:e=>e.isFailure(),isInterrupted:e=>e.isInterrupted(),fromEither:e=>e.isRight()?F(e.value):Dt(e.value),fromOption:(e,t)=>e.isSome()?F(e.value):Dt(t()),zip:(e,t)=>e.isInterrupted()?e:t.isInterrupted()?t:e.isFailure()?e:t.isFailure()?t:F([e.orThrow(),t.orThrow()]),all:e=>{let t=[];for(let n of e){if(n.isInterrupted()||n.isFailure())return n;t.push(n.orThrow())}return F(t)}}),L=e=>e;var kt=class extends Error{constructor(e,t){super(t??`Effect timed out after ${e}ms`),this.duration=e,this._tag=`TimeoutError`,this.name=`TimeoutError`}},At=class extends Error{constructor(e){super(e??`Effect was interrupted`),this._tag=`InterruptedError`,this.name=`InterruptedError`}};const jt=Symbol.for(`functype/IO/effect`),R=e=>e[jt],z=e=>{let t={[Symbol.toStringTag]:`IO`,[jt]:e,map(e){return z(L({_tag:`Map`,effect:t,f:e}))},flatMap(e){return z(L({_tag:`FlatMap`,effect:t,f:e}))},tap(e){return t.map(t=>(e(t),t))},tapEffect(e){return t.flatMap(t=>e(t).map(()=>t))},mapError(e){return z(L({_tag:`MapError`,effect:t,f:e}))},tapError(e){return t.mapError(t=>(e(t),t))},recover(e){return z(L({_tag:`Recover`,effect:t,fallback:e}))},recoverWith(e){return z(L({_tag:`RecoverWith`,effect:t,f:e}))},fold(e,n){return z(L({_tag:`Fold`,effect:t,onFailure:e,onSuccess:n}))},match(e){return t.fold(e.failure,e.success)},catchTag(e,n){return z(L({_tag:`RecoverWith`,effect:t,f:t=>typeof t==`object`&&t&&`_tag`in t&&t._tag===e?L(n(t)):L(H.fail(t))}))},catchAll(e){return t.recoverWith(e)},retry(e){return e<=0?t:t.recoverWith(()=>t.retry(e-1))},retryWithDelay(e,n){return e<=0?t:t.recoverWith(()=>H.sleep(n).flatMap(()=>t.retryWithDelay(e-1,n)))},zipRight(e){return t.flatMap(()=>e)},zipLeft(e){return t.flatMap(t=>e.map(()=>t))},zip(e){return t.flatMap(t=>e.map(e=>[t,e]))},flatten(){return this.flatMap(e=>e)},provideContext(e){return z(L({_tag:`ProvideContext`,effect:t,context:e}))},provideService(e,n){return z(L({_tag:`ProvideContext`,effect:t,context:P.make(e,n)}))},provideLayer(e){return L(L(H.async(async()=>{let t=P.empty();return await e.build(L(t))})).flatMap(e=>z(L({_tag:`ProvideContext`,effect:t,context:e}))))},async run(){let e=await V(R(this));return e.isSuccess()?w(e.orThrow()):T(e.isFailure()?e.toValue().error:new At)},async runOrThrow(){let e=await V(R(this));if(e.isSuccess())return e.orThrow();throw e.isFailure()?e.toValue().error:new At},runSync(){try{return w(B(R(this)))}catch(e){return T(e)}},runSyncOrThrow(){return B(R(this))},async runExit(){return V(R(this))},async runOption(){let e=await V(R(this));return e.isSuccess()?d(e.orThrow()):p()},async runTry(){let e=await V(R(this));if(e.isSuccess())return L(x(()=>e.orThrow()));let t=e.isFailure()?e.toValue().error:Error(`Effect was interrupted`);return L(x(()=>{throw t}))},pipe(e){return e(t)},delay(e){return L(H.async(()=>new Promise(t=>setTimeout(t,e))).flatMap(()=>t))},timeout(e){return z(L({_tag:`Timeout`,effect:t,duration:e}))},timeoutTo(e,n){return L(t.timeout(e).recover(L(n)))},toString(){return`IO(${n(e._tag)})`},toJSON(){return{_tag:`IO`,effect:e._tag}},*[Symbol.iterator](){return yield t}};return t},B=(e,t=P.empty())=>{switch(e._tag){case`Succeed`:return e.value;case`Fail`:throw e.error;case`Die`:throw e.defect;case`Sync`:return e.thunk();case`Async`:throw Error(`Cannot run async effect synchronously`);case`Auto`:{let t=e.thunk();if(t instanceof Promise)throw Error(`Cannot run async effect synchronously`);return t}case`Map`:{let n=B(R(e.effect),t);return e.f(n)}case`FlatMap`:{let n=B(R(e.effect),t);return B(R(e.f(n)),t)}case`MapError`:try{return B(R(e.effect),t)}catch(t){throw e.f(t)}case`Recover`:try{return B(R(e.effect),t)}catch{return e.fallback}case`RecoverWith`:try{return B(R(e.effect),t)}catch(n){return B(R(e.f(n)),t)}case`Fold`:try{let n=B(R(e.effect),t);return e.onSuccess(n)}catch(t){return e.onFailure(t)}case`Service`:{let n=t.get(e.tag);if(n.isNone())throw Error(`Service not found: ${e.tag.id}`);return n.orThrow()}case`ProvideContext`:{let n=t.merge(e.context);return B(R(e.effect),n)}case`Interrupt`:throw new At;case`Bracket`:{let n=B(R(e.acquire),t);try{return B(R(e.use(n)),t)}finally{B(R(e.release(n)),t)}}case`Race`:throw Error(`Cannot run race effect synchronously`);case`Timeout`:throw Error(`Cannot run timeout effect synchronously`)}},V=async(e,t=P.empty())=>{try{switch(e._tag){case`Succeed`:return L(I.succeed(e.value));case`Fail`:return L(I.fail(e.error));case`Die`:throw e.defect;case`Sync`:return L(I.succeed(e.thunk()));case`Async`:{let t=await e.thunk();return L(I.succeed(t))}case`Auto`:{let t=e.thunk();return t instanceof Promise?L(I.succeed(await t)):L(I.succeed(t))}case`Map`:{let n=await V(R(e.effect),t);return n.isSuccess()?L(I.succeed(e.f(n.orThrow()))):L(n)}case`FlatMap`:{let n=await V(R(e.effect),t);return n.isSuccess()?V(R(e.f(n.orThrow())),t):L(n)}case`MapError`:{let n=await V(R(e.effect),t);return n.isSuccess()?L(n):n.isFailure()?L(I.fail(e.f(n.toValue().error))):L(n)}case`Recover`:{let n=await V(R(e.effect),t);return n.isSuccess()?n:I.succeed(e.fallback)}case`RecoverWith`:{let n=await V(R(e.effect),t);return n.isSuccess()?n:n.isFailure()?V(R(e.f(n.toValue().error)),t):n}case`Fold`:{let n=await V(R(e.effect),t);return n.isSuccess()?I.succeed(e.onSuccess(n.orThrow())):n.isFailure()?I.succeed(e.onFailure(n.toValue().error)):n}case`Service`:{let n=t.get(e.tag);return n.isNone()?I.fail(Error(`Service not found: ${e.tag.id}`)):I.succeed(n.orThrow())}case`ProvideContext`:{let n=t.merge(e.context);return V(R(e.effect),n)}case`Interrupt`:return I.interrupted();case`Bracket`:{let n=await V(R(e.acquire),t);if(!n.isSuccess())return n;let r=n.orThrow();try{return await V(R(e.use(r)),t)}finally{await V(R(e.release(r)),t)}}case`Race`:return e.effects.length===0?I.fail(Error(`No effects to race`)):await Promise.race(e.effects.map(e=>V(R(e),t)));case`Timeout`:{let n=new Promise(t=>setTimeout(()=>t(I.fail(new kt(e.duration))),e.duration)),r=V(R(e.effect),t);return Promise.race([r,n])}}}catch(e){return I.fail(e)}},H={sync:e=>z({_tag:`Sync`,thunk:e}),succeed:e=>z({_tag:`Succeed`,value:e}),fail:e=>z({_tag:`Fail`,error:e}),die:e=>z({_tag:`Die`,defect:e}),async:e=>z(L({_tag:`Async`,thunk:e})),tryPromise:e=>z({_tag:`Async`,thunk:e.try}).mapError(e.catch),tryCatch:(e,t)=>H.sync(()=>{try{return e()}catch(e){throw t(e)}}),liftSync:e=>(...t)=>H.sync(()=>e(...t)),liftPromise:e=>(...t)=>H.async(()=>e(...t)),fromEither:e=>L(e.isRight()?H.succeed(e.value):H.fail(e.value)),fromOption:e=>L(e.isSome()?H.succeed(e.value):H.fail(void 0)),fromOptionOrFail:(e,t)=>L(e.isSome()?H.succeed(e.value):H.fail(t())),fromTry:e=>L(e.isSuccess()?H.succeed(e.orThrow()):H.fail(e.error)),fromResult:e=>L(e.error?H.fail(e.error):H.succeed(m(e.data))),tryAsync:(e,t,n)=>n?.aborted?L(H.fail(t(n.reason??new DOMException(`Aborted`,`AbortError`)))):H.async(()=>e(n)).mapError(t),asyncResult:(e,t,n)=>{let r=n?.dataKey??`data`,i=n?.errorKey??`error`;return H.tryAsync(t=>e(t),t,n?.signal).flatMap(e=>H.fromResult({data:e[r],error:e[i]}))},service:e=>z({_tag:`Service`,tag:e}),serviceWith:(e,t)=>H.service(e).map(t),serviceWithIO:(e,t)=>H.service(e).flatMap(t),withServices:(e,t)=>{let n=Object.entries(e);if(n.length===0)return L(z({_tag:`Auto`,thunk:()=>t({})}));let r=L(H.succeed({}));return L(n.reduce((e,[t,n])=>L(e.flatMap(e=>H.service(n).map(n=>({...e,[t]:n})))),r).flatMap(e=>z({_tag:`Auto`,thunk:()=>t(e)})))},all:e=>{if(e.length===0)return L(H.succeed([]));let t=L(H.succeed([]));return L(e.reduce((e,t)=>e.flatMap(e=>t.map(t=>[...e,t])),t))},firstSuccessOf:e=>e.length===0?L(H.fail(Error(`No effects provided`))):e.reduce((e,t)=>e.recoverWith(()=>t)),sleep:e=>L(H.async(()=>new Promise(t=>setTimeout(t,e)))),never:()=>L(H.async(()=>new Promise(()=>{}))),get unit(){return L(z({_tag:`Succeed`,value:void 0}))},fromNullable:e=>L(e==null?H.fail(void 0):H.succeed(e)),interrupt:()=>z({_tag:`Interrupt`}),bracket:(e,t,n)=>z({_tag:`Bracket`,acquire:e,use:t,release:n}),acquireRelease:(e,t,n)=>H.bracket(e,t,n),race:e=>z({_tag:`Race`,effects:e}),any:e=>e.length===0?L(H.fail(Error(`No effects provided`))):e.reduce((e,t)=>e.recoverWith(()=>t)),forEach:(e,t)=>{if(e.length===0)return L(H.succeed([]));let n=L(H.succeed([]));return L(e.reduce((e,n)=>e.flatMap(e=>t(n).map(t=>[...e,t])),n))},forEachPar:(e,t)=>H.forEach(e,t),timeout:(e,t)=>z(L({_tag:`Timeout`,effect:e,duration:t})),gen:e=>L(H.sync(()=>{let t=e(),n=e=>{let r=t.next(e);return r.done?L(H.succeed(r.value)):L(r.value.flatMap(e=>n(e)))};return n(void 0)}).flatMap(e=>e)),get Do(){return Mt(H.succeed({}))}},Mt=e=>({effect:e,bind(t,n){return Mt(e.flatMap(e=>n(e).map(n=>({...e,[t]:n}))))},let(t,n){return Mt(e.map(e=>({...e,[t]:n(e)})))},map(t){return e.map(t)},flatMap(t){return e.flatMap(t)},tap(t){return Mt(e.tap(t))},tapEffect(t){return Mt(e.tapEffect(t))},done(){return e}}),U=r(e=>z(L({_tag:`Auto`,thunk:e})),H),W=(e,t)=>({_tag:`Layer`,build:e,provideToAndMerge(t){return W(async n=>{let r=await e(n),i=n.merge(r),a=await t.build(i);return r.merge(a)})},merge(t){return W(async n=>{let[r,i]=await Promise.all([e(n),t.build(n)]);return r.merge(i)})},map(t){return W(async n=>t(await e(n)))},toString(){return`Layer(${t??`anonymous`})`}}),Nt={succeed:(e,t)=>W(()=>Promise.resolve(P.make(e,t)),e.id),effect:(e,t)=>W(async()=>{let n=await t();return P.make(e,n)},e.id),sync:(e,t)=>W(()=>Promise.resolve(P.make(e,t())),e.id),fromService:(e,t,n)=>W(r=>{let i=r.unsafeGet(t);return Promise.resolve(P.make(e,n(i)))},e.id),fromServiceEffect:(e,t,n)=>W(async r=>{let i=await n(r.unsafeGet(t));return P.make(e,i)},e.id),fromContext:e=>W(()=>Promise.resolve(e)),empty:()=>W(()=>Promise.resolve(P.empty()),`empty`),mergeAll:(...e)=>W(async t=>(await Promise.all(e.map(e=>e.build(t)))).reduce((e,t)=>e.merge(t),P.empty()))},Pt=e=>({id:e,_tag:`Tag`,toString(){return`Tag(${e})`}}),Ft=()=>{let e=0,t=[],n=async()=>{for(t.sort((e,t)=>e.time-t.time);t.length>0&&t[0]!==void 0&&t[0].time<=e;){let e=t.shift();e&&(e.resolve(),await Promise.resolve())}};return{get currentTime(){return e},async advance(t){e+=t,await n()},async setTime(t){e=t,await n()},async runAll(){if(t.length>0){let n=t[t.length-1];n&&(e=n.time)}await n()},get pendingCount(){return t.length},sleep(n){return new Promise(r=>{t.push({time:e+n,resolve:r})})}}},G=Pt(`TestClock`),It={make:Ft,tag:G,test:async e=>e(Ft()),get:U.service(G),advance:e=>U.serviceWithIO(G,t=>U.async(()=>t.advance(e))),setTime:e=>U.serviceWithIO(G,t=>U.async(()=>t.setTime(e))),runAll:U.serviceWithIO(G,e=>U.async(()=>e.runAll())),context:()=>{let e=Ft();return{clock:e,context:P.make(G,e)}}},Lt={make:()=>{let e=Ft(),t=P.empty(),n={get context(){return t},get clock(){return e},withService(e,r){return t=t.add(e,r),n},async run(e){return e.provideContext(t).runOrThrow()}};return n},withClock:()=>{let e=Ft();return Lt.make().withService(G,e)}},Rt=Pt(`HttpClient`),zt={},Bt=r({},{networkError:(e,t,n)=>({_tag:`NetworkError`,url:e,method:t,cause:n}),httpStatusError:(e,t,n,r,i)=>({_tag:`HttpStatusError`,url:e,method:t,status:n,statusText:r,body:i}),decodeError:(e,t,n,r)=>({_tag:`DecodeError`,url:e,method:t,body:n,cause:r}),isNetworkError:e=>e._tag===`NetworkError`,isHttpStatusError:e=>e._tag===`HttpStatusError`,isDecodeError:e=>e._tag===`DecodeError`,match:(e,t)=>{switch(e._tag){case`NetworkError`:return t.NetworkError(e);case`HttpStatusError`:return t.HttpStatusError(e);case`DecodeError`:return t.DecodeError(e)}}}),Vt=(e,t)=>!e||t.startsWith(`http://`)||t.startsWith(`https://`)?t:`${e.endsWith(`/`)?e.slice(0,-1):e}${t.startsWith(`/`)?t:`/${t}`}`,Ht=e=>e==null?{serialized:void 0,contentType:void 0}:typeof e==`string`?{serialized:e,contentType:void 0}:typeof e==`object`||Array.isArray(e)?{serialized:JSON.stringify(e),contentType:`application/json`}:{serialized:String(e),contentType:void 0},Ut=e=>{let t=e.get(`content-type`)??``;return t.includes(`application/json`)?`json`:t.startsWith(`text/`)?`text`:`raw`},Wt=async(e,t,n,r,i)=>{let a=t??Ut(e.headers),o,s={};switch(a){case`json`:{let t=await e.text();s.value=t;try{o=JSON.parse(t)}catch(e){throw Bt.decodeError(n,r,t,e)}break}case`text`:o=await e.text(),s.value=o;break;case`blob`:o=await e.blob();break;case`arrayBuffer`:o=await e.arrayBuffer();break;case`raw`:o=e;break}return{data:i?(()=>{try{return i(o)}catch(e){let t=s.value??(typeof o==`string`?o:JSON.stringify(o));throw Bt.decodeError(n,r,t,e)}})():o,status:e.status,statusText:e.statusText,headers:e.headers}},K=(e,t)=>{let n=Vt(e.baseUrl,t.url),{serialized:r,contentType:i}=Ht(t.body),a={...e.defaultHeaders,...t.headers,...i?{"Content-Type":i}:{}};return U.tryAsync(i=>(e.fetch??globalThis.fetch)(n,{method:t.method,headers:a,body:r,signal:t.signal??i}).then(async e=>{if(!e.ok){let r=await e.text().catch(()=>``);throw Bt.httpStatusError(n,t.method,e.status,e.statusText,r)}return Wt(e,t.parseAs,n,t.method,t.validate)}),e=>typeof e==`object`&&e&&`_tag`in e?e:Bt.networkError(n,t.method,e))},Gt=e=>K(zt,e),Kt=r({},{request:Gt,get:(e,t)=>Gt({...t,url:e,method:`GET`}),post:(e,t)=>Gt({...t,url:e,method:`POST`}),put:(e,t)=>Gt({...t,url:e,method:`PUT`}),patch:(e,t)=>Gt({...t,url:e,method:`PATCH`}),delete:(e,t)=>Gt({...t,url:e,method:`DELETE`}),head:(e,t)=>Gt({...t,url:e,method:`HEAD`,parseAs:`raw`}),options:(e,t)=>Gt({...t,url:e,method:`OPTIONS`,parseAs:`raw`}),client:e=>({request:t=>K(e,t),get:(t,n)=>K(e,{...n,url:t,method:`GET`}),post:(t,n)=>K(e,{...n,url:t,method:`POST`}),put:(t,n)=>K(e,{...n,url:t,method:`PUT`}),patch:(t,n)=>K(e,{...n,url:t,method:`PATCH`}),delete:(t,n)=>K(e,{...n,url:t,method:`DELETE`}),head:(t,n)=>K(e,{...n,url:t,method:`HEAD`,parseAs:`raw`}),options:(t,n)=>K(e,{...n,url:t,method:`OPTIONS`,parseAs:`raw`})})}),qt={toOption:e=>e.fold(()=>p(),e=>d(e)),toList:e=>e.fold(()=>C([]),e=>C([e])),toEither:(e,t)=>e.fold(()=>T(t),e=>w(e)),isEmpty:e=>e.fold(()=>!0,()=>!1),size:e=>e.fold(()=>0,()=>1)},Jt=e=>typeof e==`object`&&!!e&&(e._tag===`Some`||e._tag===`None`),q=e=>typeof e==`object`&&!!e&&e._tag===`List`,Yt=e=>typeof e==`object`&&!!e&&(e._tag===`Left`||e._tag===`Right`),Xt=e=>typeof e==`object`&&!!e&&(e._tag===`Success`||e._tag===`Failure`),J=()=>{let e=(e,t)=>{if(Jt(e)||q(e)||Yt(e)||Xt(e))return e.map(e=>t(e));throw Error(`Unsupported functor type: ${JSON.stringify(e)}`)},t=e=>{if(Jt(e))return e.orThrow();if(q(e)){let t=e.toArray();if(t.length>0&&q(t[0])){let e=[];for(let n of t)q(n)&&e.push(...n.toArray());return C(e)}return e.flatten()}if(Yt(e))return e.isRight()?e.fold(()=>null,e=>e):e;if(Xt(e))return e.isSuccess()?e.orThrow():e;throw Error(`Unsupported functor type for flatten: ${JSON.stringify(e)}`)},n=(e,t)=>{if(Jt(e)||q(e)||Yt(e)||Xt(e))return e.flatMap(e=>t(e));throw Error(`Unsupported functor type for flatMap: ${JSON.stringify(e)}`)},r=(e,t)=>{if(Jt(e)&&Jt(t)||q(e)&&q(t)||Yt(e)&&Yt(t)||Xt(e)&&Xt(t))return e.flatMap(e=>t.map(t=>e(t)));throw Error(`Unsupported functor type for ap: ${JSON.stringify(e)}`)},i=e=>{if(Jt(e)){let t=e;if(t.isEmpty)return C([m.none()]);let n=t.orThrow();if(q(n))return n.map(e=>m(e));throw Error(`Unsupported inner container type for sequence`)}if(q(e)){let t=e.toArray();if(t.length===0)return m.none();let n=t[0];if(Jt(n)){for(let e of t)if(e.isEmpty)return m.none();return m(C(t.map(e=>e.orThrow())))}throw Error(`Unsupported inner container type for sequence`)}throw Error(`Unsupported outer container type for sequence: ${JSON.stringify(e)}`)};return{_tag:`HKT`,map:e,flatten:t,flatMap:n,ap:r,sequence:i,traverse:(t,n)=>i(e(t,e=>n(e))),_type:`HKT`}},Zt=J();J.map=(e,t)=>Zt.map(e,t),J.flatten=e=>Zt.flatten(e),J.flatMap=(e,t)=>Zt.flatMap(e,t),J.ap=(e,t)=>Zt.ap(e,t),J.sequence=e=>Zt.sequence(e),J.traverse=(e,t)=>Zt.traverse(e,t),J.isOption=Jt,J.isList=q,J.isEither=Yt,J.isTry=Xt;const Qt=e=>({id:e,isSame:t=>t.id===e}),$t=r(Qt,{of:e=>Qt(e),pure:e=>Qt(e)}),Y=e=>{let t=!1,r,i,a=!1,o=()=>{if(!t)try{r=e(),t=!0}catch(e){throw i=e,a=!0,t=!0,e}if(a)throw i;return r};return{[Symbol.toStringTag]:`Lazy`,_tag:`Lazy`,get isEvaluated(){return t},orElse:e=>{try{return o()}catch{return e}},orNull:()=>{try{return o()}catch{return null}},orThrow:e=>{try{return o()}catch(t){throw e??t}},or:e=>X(()=>{try{return o()}catch{return e.orThrow()}}),orUndefined:()=>{try{return o()}catch{return}},map:e=>X(()=>e(o())),ap:e=>X(()=>e.orThrow()(o())),mapAsync:async e=>{let t=await e(o());return X(()=>t)},flatMap:e=>X(()=>e(o()).orThrow()),flatMapAsync:async e=>{let t=await e(o());return X(()=>t.orThrow())},filter:e=>X(()=>{let t=o();return e(t)?d(t):p}),recover:e=>X(()=>{try{return o()}catch(t){return e(t)}}),recoverWith:e=>X(()=>{try{return o()}catch(t){return e(t).orThrow()}}),toOption:()=>{try{return d(o())}catch{return p}},toEither:()=>{try{return w(o())}catch(e){return T(e)}},toEitherWith:e=>{try{return w(o())}catch(t){return T(e(t))}},toTry:()=>x(()=>o()),tap:e=>X(()=>{let t=o();return e(t),t}),tapError:e=>X(()=>{try{return o()}catch(t){throw e(t),t}}),fold:e=>e(o()),foldWith:(e,t)=>{try{return t(o())}catch(t){return e(t)}},foldLeft:e=>t=>t(e,o()),foldRight:e=>t=>t(o(),e),match:e=>e.Lazy(o()),toString:()=>t&&!a?`Lazy(${n(r)})`:t&&a?`Lazy(<error: ${i instanceof Error?i.message:String(i)}>)`:`Lazy(<not evaluated>)`,toValue:()=>t&&!a?{_tag:`Lazy`,evaluated:!0,value:r}:{_tag:`Lazy`,evaluated:!1},get size(){try{return o(),1}catch{return 0}},get isEmpty(){try{return o(),!1}catch{return!0}},contains:e=>{try{return o()===e}catch{return!1}},reduce:e=>o(),reduceRight:e=>o(),count:e=>{try{return+!!e(o())}catch{return 0}},find:e=>{try{let t=o();return e(t)?d(t):p}catch{return p}},exists:e=>{try{return e(o())}catch{return!1}},forEach:e=>{try{e(o())}catch{}},pipe:e=>e(o()),serialize:()=>({toJSON:()=>JSON.stringify(t&&!a?{_tag:`Lazy`,evaluated:!0,value:r}:{_tag:`Lazy`,evaluated:!1}),toYAML:()=>t&&!a?`_tag: Lazy\nevaluated: true\nvalue: ${n(r)}`:`_tag: Lazy
|
|
16
|
+
`);o+=`\n${a}`,t.length>i&&(o+=`\n${r} ${n.colors?`\x1B[90m`:``}...${t.length-i} more stack frames${n.colors?`\x1B[0m`:``}`)}return o}).join(n.separator)}`;if(n.includeData){let{data:e}=r;if(e){let t=n.colors?`\n\n\x1b[33mContext:\x1b[0m\n${_t(e)}`:`\n\nContext:\n${_t(e)}`;a+=t}}return a}function bt(){return function(e){if(!e)return e;let t=e instanceof Error?e:Error(String(e)),n={message:t.message,name:t.name||`Error`,stack:t.stack?vt(t.stack):void 0};if(t.taskInfo&&(n.taskInfo=t.taskInfo),t.data&&(n.data=t.data),typeof A?.getErrorChain==`function`)try{let e=A.getErrorChain(t);e.length>1&&(n.errorChain=A.formatErrorChain(t,{includeTasks:!0}),n.structuredErrorChain=e.map(e=>({message:e.message,name:e.name,taskInfo:e.taskInfo,stack:e.stack?vt(e.stack):void 0})))}catch{}return Object.getOwnPropertyNames(t).forEach(e=>{n[e]||(n[e]=t[e])}),n}}const j=(e,n,r,i)=>t(Qe.apply(n,r,{name:e,description:n}),{code:e,message:n,status:xt(e),context:r,timestamp:new Date().toISOString(),traceId:i?.traceId}),xt=e=>({VALIDATION_FAILED:400,BAD_REQUEST:400,AUTH_REQUIRED:401,PERMISSION_DENIED:403,NOT_FOUND:404,TIMEOUT:408,CONFLICT:409,RATE_LIMITED:429,INTERNAL_ERROR:500,NETWORK_ERROR:503})[e],M=Object.assign(j,{validation:(e,t,n)=>j(`VALIDATION_FAILED`,`Validation failed: ${e} ${n}`,{field:e,value:t,rule:n}),network:(e,t,n)=>j(`NETWORK_ERROR`,`Network error: ${t} ${e}${n?` (${n})`:``}`,{url:e,method:t,statusCode:n}),auth:(e,t)=>j(`AUTH_REQUIRED`,`Authentication required: ${e}${t?` (role: ${t})`:``}`,{resource:e,requiredRole:t}),notFound:(e,t)=>j(`NOT_FOUND`,`Not found: ${e} with id ${t}`,{resource:e,id:t}),permission:(e,t,n)=>j(`PERMISSION_DENIED`,`Permission denied: cannot ${e} ${t}`,{action:e,resource:t,userId:n}),rateLimit:(e,t,n)=>j(`RATE_LIMITED`,`Rate limit exceeded: ${e} requests per ${t}`,{limit:e,window:t,retryAfter:n}),internal:e=>j(`INTERNAL_ERROR`,`Internal server error: ${e}`,{errorId:e,timestamp:new Date().toISOString()}),badRequest:(e,t)=>j(`BAD_REQUEST`,`Bad request: ${e}`,{reason:e,expected:t}),conflict:(e,t)=>j(`CONFLICT`,`Conflict: ${e} already exists with value ${t}`,{resource:e,conflictingValue:t}),timeout:(e,t)=>j(`TIMEOUT`,`Request timeout: ${t} exceeded ${e}ms`,{duration:e,operation:t}),isTypedError:e=>typeof e==`object`&&!!e&&`code`in e&&`message`in e&&`status`in e&&`context`in e&&`_tag`in e&&e._tag===`Throwable`,hasCode:(e,t)=>e.code===t}),N={rule:e=>t=>{if(e===`email`)return typeof t!=`string`||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)?T(M.validation(`value`,t,`must be a valid email`)):w(t);if(e===`url`)try{return new URL(String(t)),w(t)}catch{return T(M.validation(`value`,t,`must be a valid URL`))}if(e===`uuid`)return typeof t!=`string`||!/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(t)?T(M.validation(`value`,t,`must be a valid UUID`)):w(t);if(e===`required`)return t==null||t===``?T(M.validation(`value`,t,`is required`)):w(t);if(e===`numeric`)return typeof t!=`number`&&!/^\d+$/.test(String(t))?T(M.validation(`value`,t,`must be numeric`)):w(t);if(e===`alpha`)return typeof t!=`string`||!/^[a-zA-Z]+$/.test(t)?T(M.validation(`value`,t,`must contain only letters`)):w(t);if(e===`alphanumeric`)return typeof t!=`string`||!/^[a-zA-Z0-9]+$/.test(t)?T(M.validation(`value`,t,`must be alphanumeric`)):w(t);if(e.startsWith(`min:`)){let n=Number(e.split(`:`)[1]),r=Number(t);return isNaN(r)||r<n?T(M.validation(`value`,t,`must be at least ${n}`)):w(t)}if(e.startsWith(`max:`)){let n=Number(e.split(`:`)[1]),r=Number(t);return isNaN(r)||r>n?T(M.validation(`value`,t,`must be at most ${n}`)):w(t)}if(e.startsWith(`minLength:`)){let n=Number(e.split(`:`)[1]);return String(t).length<n?T(M.validation(`value`,t,`must be at least ${n} characters`)):w(t)}if(e.startsWith(`maxLength:`)){let n=Number(e.split(`:`)[1]);return String(t).length>n?T(M.validation(`value`,t,`must be at most ${n} characters`)):w(t)}if(e.startsWith(`pattern:`)){let n=e.substring(8);return new RegExp(n).test(String(t))?w(t):T(M.validation(`value`,t,`must match pattern ${n}`))}if(e.startsWith(`in:`)){let n=e.substring(3).split(`,`);return n.includes(String(t))?w(t):T(M.validation(`value`,t,`must be one of: ${n.join(`, `)}`))}if(e.startsWith(`notIn:`)){let n=e.substring(6).split(`,`);return n.includes(String(t))?T(M.validation(`value`,t,`must not be one of: ${n.join(`, `)}`)):w(t)}if(e===`date`){let e=new Date(String(t));return isNaN(e.getTime())?T(M.validation(`value`,t,`must be a valid date`)):w(t)}if(e===`future`){let e=new Date(String(t));return isNaN(e.getTime())||e<=new Date?T(M.validation(`value`,t,`must be a future date`)):w(t)}if(e===`past`){let e=new Date(String(t));return isNaN(e.getTime())||e>=new Date?T(M.validation(`value`,t,`must be a past date`)):w(t)}return w(t)},combine:(...e)=>t=>{for(let n of e){let e=n(t);if(e.isLeft())return e}return w(t)},custom:(e,t)=>n=>e(n)?w(n):T(M.validation(`value`,n,t)),form:(e,t)=>{let n=[],r={};for(let[i,a]of Object.entries(e)){let e=t[i],o=a(e);if(o.isLeft()){let t=o.fold(e=>e,()=>{throw Error(`Should not be left`)}),r=M.validation(i,e,t.context.rule);n.push(r)}else r[i]=o.orThrow()}return n.length>0?T(C(n)):w(r)}},St={...N,validators:{email:N.rule(`email`),url:N.rule(`url`),uuid:N.rule(`uuid`),required:N.rule(`required`),numeric:N.rule(`numeric`),positiveNumber:N.combine(N.rule(`numeric`),N.rule(`min:0`)),nonEmptyString:N.combine(N.rule(`required`),N.custom(e=>typeof e==`string`&&e.trim().length>0,`must not be empty`))}},Ct=t(N.rule,St);function wt(e){return typeof e==`object`&&!!e&&`orThrow`in e&&typeof e.orThrow==`function`}function Tt(e){return wt(e)&&`orElse`in e&&typeof e.orElse==`function`&&`or`in e&&typeof e.or==`function`&&`orNull`in e&&typeof e.orNull==`function`&&`orUndefined`in e&&typeof e.orUndefined==`function`}const Et=e=>({_tag:`Context`,services:e,get(t){let n=e.get(t.id);return n===void 0?p():d(n)},unsafeGet(t){let n=e.get(t.id);if(n===void 0)throw Error(`Service not found: ${t.id}`);return n},has(t){return e.has(t.id)},add(t,n){let r=new Map(e);return r.set(t.id,n),Et(r)},merge(t){let n=new Map(e);for(let[e,r]of t.services)n.set(e,r);return Et(n)},get size(){return e.size},toString(){return`Context(${Array.from(e.keys()).join(`, `)})`}}),P={empty:()=>Et(new Map),make:(e,t)=>{let n=new Map;return n.set(e.id,t),Et(n)},isContext:e=>typeof e==`object`&&!!e&&e._tag===`Context`},F=e=>({[Symbol.toStringTag]:`Exit`,_tag:`Success`,isSuccess(){return!0},isFailure(){return!1},isInterrupted(){return!1},map(t){return F(t(e))},mapError(t){return F(e)},mapBoth(t,n){return F(n(e))},flatMap(t){return t(e)},fold(t,n,r){return n(e)},match(t){return t.Success(e)},orThrow(){return e},orElse(t){return e},toOption(){return d(e)},toEither(){return w(e)},toValue(){return{_tag:`Success`,value:e}},toString(){return`Exit.Success(${n(e)})`},toJSON(){return{_tag:`Success`,value:e}}}),Dt=e=>({[Symbol.toStringTag]:`Exit`,_tag:`Failure`,isSuccess(){return!1},isFailure(){return!0},isInterrupted(){return!1},map(t){return Dt(e)},mapError(t){return Dt(t(e))},mapBoth(t,n){return Dt(t(e))},flatMap(t){return Dt(e)},fold(t,n,r){return t(e)},match(t){return t.Failure(e)},orThrow(){throw e},orElse(e){return e},toOption(){return p()},toEither(){return T(e)},toValue(){return{_tag:`Failure`,error:e}},toString(){return`Exit.Failure(${n(e)})`},toJSON(){return{_tag:`Failure`,error:e}}}),Ot=e=>({[Symbol.toStringTag]:`Exit`,_tag:`Interrupted`,isSuccess(){return!1},isFailure(){return!1},isInterrupted(){return!0},map(t){return Ot(e)},mapError(t){return Ot(e)},mapBoth(t,n){return Ot(e)},flatMap(t){return Ot(e)},fold(t,n,r){if(r)return r(e);throw Error(`Effect was interrupted: ${e}`)},match(t){return t.Interrupted(e)},orThrow(){throw Error(`Effect was interrupted: ${e}`)},orElse(e){return e},toOption(){return p()},toEither(){throw Error(`Cannot convert Interrupted Exit to Either: ${e}`)},toValue(){return{_tag:`Interrupted`,fiberId:e}},toString(){return`Exit.Interrupted(${e})`},toJSON(){return{_tag:`Interrupted`,fiberId:e}}}),I=r(e=>F(e),{succeed:e=>F(e),fail:e=>Dt(e),interrupt:e=>Ot(e),interrupted:()=>Ot(`interrupted`),isSuccess:e=>e.isSuccess(),isFailure:e=>e.isFailure(),isInterrupted:e=>e.isInterrupted(),fromEither:e=>e.isRight()?F(e.value):Dt(e.value),fromOption:(e,t)=>e.isSome()?F(e.value):Dt(t()),zip:(e,t)=>e.isInterrupted()?e:t.isInterrupted()?t:e.isFailure()?e:t.isFailure()?t:F([e.orThrow(),t.orThrow()]),all:e=>{let t=[];for(let n of e){if(n.isInterrupted()||n.isFailure())return n;t.push(n.orThrow())}return F(t)}}),L=e=>e;var kt=class extends Error{constructor(e,t){super(t??`Effect timed out after ${e}ms`),this.duration=e,this._tag=`TimeoutError`,this.name=`TimeoutError`}},At=class extends Error{constructor(e){super(e??`Effect was interrupted`),this._tag=`InterruptedError`,this.name=`InterruptedError`}};const jt=Symbol.for(`functype/IO/effect`),R=e=>e[jt],z=e=>{let t={[Symbol.toStringTag]:`IO`,[jt]:e,map(e){return z(L({_tag:`Map`,effect:t,f:e}))},flatMap(e){return z(L({_tag:`FlatMap`,effect:t,f:e}))},tap(e){return t.map(t=>(e(t),t))},tapEffect(e){return t.flatMap(t=>e(t).map(()=>t))},mapError(e){return z(L({_tag:`MapError`,effect:t,f:e}))},tapError(e){return t.mapError(t=>(e(t),t))},recover(e){return z(L({_tag:`Recover`,effect:t,fallback:e}))},recoverWith(e){return z(L({_tag:`RecoverWith`,effect:t,f:e}))},fold(e,n){return z(L({_tag:`Fold`,effect:t,onFailure:e,onSuccess:n}))},match(e){return t.fold(e.failure,e.success)},catchTag(e,n){return z(L({_tag:`RecoverWith`,effect:t,f:t=>typeof t==`object`&&t&&`_tag`in t&&t._tag===e?L(n(t)):L(H.fail(t))}))},catchAll(e){return t.recoverWith(e)},retry(e){return e<=0?t:t.recoverWith(()=>t.retry(e-1))},retryWithDelay(e,n){return e<=0?t:t.recoverWith(()=>H.sleep(n).flatMap(()=>t.retryWithDelay(e-1,n)))},zipRight(e){return t.flatMap(()=>e)},zipLeft(e){return t.flatMap(t=>e.map(()=>t))},zip(e){return t.flatMap(t=>e.map(e=>[t,e]))},flatten(){return this.flatMap(e=>e)},provideContext(e){return z(L({_tag:`ProvideContext`,effect:t,context:e}))},provideService(e,n){return z(L({_tag:`ProvideContext`,effect:t,context:P.make(e,n)}))},provideLayer(e){return L(L(H.async(async()=>{let t=P.empty();return await e.build(L(t))})).flatMap(e=>z(L({_tag:`ProvideContext`,effect:t,context:e}))))},async run(){let e=await V(R(this));return e.isSuccess()?w(e.orThrow()):T(e.isFailure()?e.toValue().error:new At)},async runOrThrow(){let e=await V(R(this));if(e.isSuccess())return e.orThrow();throw e.isFailure()?e.toValue().error:new At},runSync(){try{return w(B(R(this)))}catch(e){return T(e)}},runSyncOrThrow(){return B(R(this))},async runExit(){return V(R(this))},async runOption(){let e=await V(R(this));return e.isSuccess()?d(e.orThrow()):p()},async runTry(){let e=await V(R(this));if(e.isSuccess())return L(x(()=>e.orThrow()));let t=e.isFailure()?e.toValue().error:Error(`Effect was interrupted`);return L(x(()=>{throw t}))},pipe(e){return e(t)},delay(e){return L(H.async(()=>new Promise(t=>setTimeout(t,e))).flatMap(()=>t))},timeout(e){return z(L({_tag:`Timeout`,effect:t,duration:e}))},timeoutTo(e,n){return L(t.timeout(e).recover(L(n)))},toString(){return`IO(${n(e._tag)})`},toJSON(){return{_tag:`IO`,effect:e._tag}},*[Symbol.iterator](){return yield t}};return t},B=(e,t=P.empty())=>{switch(e._tag){case`Succeed`:return e.value;case`Fail`:throw e.error;case`Die`:throw e.defect;case`Sync`:return e.thunk();case`Async`:throw Error(`Cannot run async effect synchronously`);case`Auto`:{let t=e.thunk();if(t instanceof Promise)throw Error(`Cannot run async effect synchronously`);return t}case`Map`:{let n=B(R(e.effect),t);return e.f(n)}case`FlatMap`:{let n=B(R(e.effect),t);return B(R(e.f(n)),t)}case`MapError`:try{return B(R(e.effect),t)}catch(t){throw e.f(t)}case`Recover`:try{return B(R(e.effect),t)}catch{return e.fallback}case`RecoverWith`:try{return L(B(R(e.effect),t))}catch(n){return B(R(e.f(n)),t)}case`Fold`:try{let n=B(R(e.effect),t);return e.onSuccess(n)}catch(t){return e.onFailure(t)}case`Service`:{let n=t.get(e.tag);if(n.isNone())throw Error(`Service not found: ${e.tag.id}`);return n.orThrow()}case`ProvideContext`:{let n=t.merge(e.context);return B(R(e.effect),n)}case`Interrupt`:throw new At;case`Bracket`:{let n=B(R(e.acquire),t);try{return B(R(e.use(n)),t)}finally{B(R(e.release(n)),t)}}case`Race`:throw Error(`Cannot run race effect synchronously`);case`Timeout`:throw Error(`Cannot run timeout effect synchronously`)}},V=async(e,t=P.empty())=>{try{switch(e._tag){case`Succeed`:return L(I.succeed(e.value));case`Fail`:return L(I.fail(e.error));case`Die`:throw e.defect;case`Sync`:return L(I.succeed(e.thunk()));case`Async`:{let t=await e.thunk();return L(I.succeed(t))}case`Auto`:{let t=e.thunk();return t instanceof Promise?L(I.succeed(await t)):L(I.succeed(t))}case`Map`:{let n=await V(R(e.effect),t);return n.isSuccess()?L(I.succeed(e.f(n.orThrow()))):L(n)}case`FlatMap`:{let n=await V(R(e.effect),t);return n.isSuccess()?V(R(e.f(n.orThrow())),t):L(n)}case`MapError`:{let n=await V(R(e.effect),t);return n.isSuccess()?L(n):n.isFailure()?L(I.fail(e.f(n.toValue().error))):L(n)}case`Recover`:{let n=await V(R(e.effect),t);return n.isSuccess()?n:I.succeed(e.fallback)}case`RecoverWith`:{let n=await V(R(e.effect),t);return n.isSuccess()?L(n):n.isFailure()?V(R(e.f(n.toValue().error)),t):L(n)}case`Fold`:{let n=await V(R(e.effect),t);return n.isSuccess()?I.succeed(e.onSuccess(n.orThrow())):n.isFailure()?I.succeed(e.onFailure(n.toValue().error)):n}case`Service`:{let n=t.get(e.tag);return n.isNone()?I.fail(Error(`Service not found: ${e.tag.id}`)):I.succeed(n.orThrow())}case`ProvideContext`:{let n=t.merge(e.context);return V(R(e.effect),n)}case`Interrupt`:return I.interrupted();case`Bracket`:{let n=await V(R(e.acquire),t);if(!n.isSuccess())return n;let r=n.orThrow();try{return await V(R(e.use(r)),t)}finally{await V(R(e.release(r)),t)}}case`Race`:return e.effects.length===0?I.fail(Error(`No effects to race`)):await Promise.race(e.effects.map(e=>V(R(e),t)));case`Timeout`:{let n=new Promise(t=>setTimeout(()=>t(I.fail(new kt(e.duration))),e.duration)),r=V(R(e.effect),t);return Promise.race([r,n])}}}catch(e){return I.fail(e)}},H={sync:e=>z({_tag:`Sync`,thunk:e}),succeed:e=>z({_tag:`Succeed`,value:e}),fail:e=>z({_tag:`Fail`,error:e}),die:e=>z({_tag:`Die`,defect:e}),async:e=>z(L({_tag:`Async`,thunk:e})),tryPromise:e=>z({_tag:`Async`,thunk:e.try}).mapError(e.catch),tryCatch:(e,t)=>H.sync(()=>{try{return e()}catch(e){throw t(e)}}),liftSync:e=>(...t)=>H.sync(()=>e(...t)),liftPromise:e=>(...t)=>H.async(()=>e(...t)),fromEither:e=>L(e.isRight()?H.succeed(e.value):H.fail(e.value)),fromOption:e=>L(e.isSome()?H.succeed(e.value):H.fail(void 0)),fromOptionOrFail:(e,t)=>L(e.isSome()?H.succeed(e.value):H.fail(t())),fromTry:e=>L(e.isSuccess()?H.succeed(e.orThrow()):H.fail(e.error)),fromResult:e=>L(e.error?H.fail(e.error):H.succeed(m(e.data))),tryAsync:(e,t,n)=>n?.aborted?L(H.fail(t(n.reason??new DOMException(`Aborted`,`AbortError`)))):H.async(()=>e(n)).mapError(t),asyncResult:(e,t,n)=>{let r=n?.dataKey??`data`,i=n?.errorKey??`error`;return H.tryAsync(t=>e(t),t,n?.signal).flatMap(e=>H.fromResult({data:e[r],error:e[i]}))},service:e=>z({_tag:`Service`,tag:e}),serviceWith:(e,t)=>H.service(e).map(t),serviceWithIO:(e,t)=>H.service(e).flatMap(t),withServices:(e,t)=>{let n=Object.entries(e);if(n.length===0)return L(z({_tag:`Auto`,thunk:()=>t({})}));let r=L(H.succeed({}));return L(n.reduce((e,[t,n])=>L(e.flatMap(e=>H.service(n).map(n=>({...e,[t]:n})))),r).flatMap(e=>z({_tag:`Auto`,thunk:()=>t(e)})))},all:e=>{if(e.length===0)return L(H.succeed([]));let t=L(H.succeed([]));return L(e.reduce((e,t)=>e.flatMap(e=>t.map(t=>[...e,t])),t))},firstSuccessOf:e=>e.length===0?L(H.fail(Error(`No effects provided`))):e.reduce((e,t)=>e.recoverWith(()=>t)),sleep:e=>L(H.async(()=>new Promise(t=>setTimeout(t,e)))),never:()=>L(H.async(()=>new Promise(()=>{}))),get unit(){return L(z({_tag:`Succeed`,value:void 0}))},fromNullable:e=>L(e==null?H.fail(void 0):H.succeed(e)),interrupt:()=>z({_tag:`Interrupt`}),bracket:(e,t,n)=>z({_tag:`Bracket`,acquire:e,use:t,release:n}),acquireRelease:(e,t,n)=>H.bracket(e,t,n),race:e=>z({_tag:`Race`,effects:e}),any:e=>e.length===0?L(H.fail(Error(`No effects provided`))):e.reduce((e,t)=>e.recoverWith(()=>t)),forEach:(e,t)=>{if(e.length===0)return L(H.succeed([]));let n=L(H.succeed([]));return L(e.reduce((e,n)=>e.flatMap(e=>t(n).map(t=>[...e,t])),n))},forEachPar:(e,t)=>H.forEach(e,t),timeout:(e,t)=>z(L({_tag:`Timeout`,effect:e,duration:t})),gen:e=>L(H.sync(()=>{let t=e(),n=e=>{let r=t.next(e);return r.done?L(H.succeed(r.value)):L(r.value.flatMap(e=>n(e)))};return n(void 0)}).flatMap(e=>e)),get Do(){return Mt(H.succeed({}))}},Mt=e=>({effect:e,bind(t,n){return Mt(e.flatMap(e=>n(e).map(n=>({...e,[t]:n}))))},let(t,n){return Mt(e.map(e=>({...e,[t]:n(e)})))},map(t){return e.map(t)},flatMap(t){return e.flatMap(t)},tap(t){return Mt(e.tap(t))},tapEffect(t){return Mt(e.tapEffect(t))},done(){return e}}),U=r(e=>z(L({_tag:`Auto`,thunk:e})),H),W=(e,t)=>({_tag:`Layer`,build:e,provideToAndMerge(t){return W(async n=>{let r=await e(n),i=n.merge(r),a=await t.build(i);return r.merge(a)})},merge(t){return W(async n=>{let[r,i]=await Promise.all([e(n),t.build(n)]);return r.merge(i)})},map(t){return W(async n=>t(await e(n)))},toString(){return`Layer(${t??`anonymous`})`}}),Nt={succeed:(e,t)=>W(()=>Promise.resolve(P.make(e,t)),e.id),effect:(e,t)=>W(async()=>{let n=await t();return P.make(e,n)},e.id),sync:(e,t)=>W(()=>Promise.resolve(P.make(e,t())),e.id),fromService:(e,t,n)=>W(r=>{let i=r.unsafeGet(t);return Promise.resolve(P.make(e,n(i)))},e.id),fromServiceEffect:(e,t,n)=>W(async r=>{let i=await n(r.unsafeGet(t));return P.make(e,i)},e.id),fromContext:e=>W(()=>Promise.resolve(e)),empty:()=>W(()=>Promise.resolve(P.empty()),`empty`),mergeAll:(...e)=>W(async t=>(await Promise.all(e.map(e=>e.build(t)))).reduce((e,t)=>e.merge(t),P.empty()))},Pt=e=>({id:e,_tag:`Tag`,toString(){return`Tag(${e})`}}),Ft=()=>{let e=0,t=[],n=async()=>{for(t.sort((e,t)=>e.time-t.time);t.length>0&&t[0]!==void 0&&t[0].time<=e;){let e=t.shift();e&&(e.resolve(),await Promise.resolve())}};return{get currentTime(){return e},async advance(t){e+=t,await n()},async setTime(t){e=t,await n()},async runAll(){if(t.length>0){let n=t[t.length-1];n&&(e=n.time)}await n()},get pendingCount(){return t.length},sleep(n){return new Promise(r=>{t.push({time:e+n,resolve:r})})}}},G=Pt(`TestClock`),It={make:Ft,tag:G,test:async e=>e(Ft()),get:U.service(G),advance:e=>U.serviceWithIO(G,t=>U.async(()=>t.advance(e))),setTime:e=>U.serviceWithIO(G,t=>U.async(()=>t.setTime(e))),runAll:U.serviceWithIO(G,e=>U.async(()=>e.runAll())),context:()=>{let e=Ft();return{clock:e,context:P.make(G,e)}}},Lt={make:()=>{let e=Ft(),t=P.empty(),n={get context(){return t},get clock(){return e},withService(e,r){return t=t.add(e,r),n},async run(e){return e.provideContext(t).runOrThrow()}};return n},withClock:()=>{let e=Ft();return Lt.make().withService(G,e)}},Rt=Pt(`HttpClient`),zt={},Bt=r({},{networkError:(e,t,n)=>({_tag:`NetworkError`,url:e,method:t,cause:n}),httpStatusError:(e,t,n,r,i)=>({_tag:`HttpStatusError`,url:e,method:t,status:n,statusText:r,body:i}),decodeError:(e,t,n,r)=>({_tag:`DecodeError`,url:e,method:t,body:n,cause:r}),isNetworkError:e=>e._tag===`NetworkError`,isHttpStatusError:e=>e._tag===`HttpStatusError`,isDecodeError:e=>e._tag===`DecodeError`,match:(e,t)=>{switch(e._tag){case`NetworkError`:return t.NetworkError(e);case`HttpStatusError`:return t.HttpStatusError(e);case`DecodeError`:return t.DecodeError(e)}}}),Vt=(e,t)=>!e||t.startsWith(`http://`)||t.startsWith(`https://`)?t:`${e.endsWith(`/`)?e.slice(0,-1):e}${t.startsWith(`/`)?t:`/${t}`}`,Ht=e=>e==null?{serialized:void 0,contentType:void 0}:typeof e==`string`?{serialized:e,contentType:void 0}:typeof e==`object`||Array.isArray(e)?{serialized:JSON.stringify(e),contentType:`application/json`}:{serialized:String(e),contentType:void 0},Ut=e=>{let t=e.get(`content-type`)??``;return t.includes(`application/json`)?`json`:t.startsWith(`text/`)?`text`:`raw`},Wt=async(e,t,n,r,i)=>{let a=t??Ut(e.headers),o,s={};switch(a){case`json`:{let t=await e.text();s.value=t;try{o=JSON.parse(t)}catch(e){throw Bt.decodeError(n,r,t,e)}break}case`text`:o=await e.text(),s.value=o;break;case`blob`:o=await e.blob();break;case`arrayBuffer`:o=await e.arrayBuffer();break;case`raw`:o=e;break}return{data:i?(()=>{try{return i(o)}catch(e){let t=s.value??(typeof o==`string`?o:JSON.stringify(o));throw Bt.decodeError(n,r,t,e)}})():o,status:e.status,statusText:e.statusText,headers:e.headers}},K=(e,t)=>{let n=Vt(e.baseUrl,t.url),{serialized:r,contentType:i}=Ht(t.body),a={...e.defaultHeaders,...t.headers,...i?{"Content-Type":i}:{}};return U.tryAsync(i=>(e.fetch??globalThis.fetch)(n,{method:t.method,headers:a,body:r,signal:t.signal??i}).then(async e=>{if(!e.ok){let r=await e.text().catch(()=>``);throw Bt.httpStatusError(n,t.method,e.status,e.statusText,r)}return Wt(e,t.parseAs,n,t.method,t.validate)}),e=>typeof e==`object`&&e&&`_tag`in e?e:Bt.networkError(n,t.method,e))},Gt=e=>K(zt,e),Kt=r({},{request:Gt,get:(e,t)=>Gt({...t,url:e,method:`GET`}),post:(e,t)=>Gt({...t,url:e,method:`POST`}),put:(e,t)=>Gt({...t,url:e,method:`PUT`}),patch:(e,t)=>Gt({...t,url:e,method:`PATCH`}),delete:(e,t)=>Gt({...t,url:e,method:`DELETE`}),head:(e,t)=>Gt({...t,url:e,method:`HEAD`,parseAs:`raw`}),options:(e,t)=>Gt({...t,url:e,method:`OPTIONS`,parseAs:`raw`}),client:e=>({request:t=>K(e,t),get:(t,n)=>K(e,{...n,url:t,method:`GET`}),post:(t,n)=>K(e,{...n,url:t,method:`POST`}),put:(t,n)=>K(e,{...n,url:t,method:`PUT`}),patch:(t,n)=>K(e,{...n,url:t,method:`PATCH`}),delete:(t,n)=>K(e,{...n,url:t,method:`DELETE`}),head:(t,n)=>K(e,{...n,url:t,method:`HEAD`,parseAs:`raw`}),options:(t,n)=>K(e,{...n,url:t,method:`OPTIONS`,parseAs:`raw`})})}),qt={toOption:e=>e.fold(()=>p(),e=>d(e)),toList:e=>e.fold(()=>C([]),e=>C([e])),toEither:(e,t)=>e.fold(()=>T(t),e=>w(e)),isEmpty:e=>e.fold(()=>!0,()=>!1),size:e=>e.fold(()=>0,()=>1)},Jt=e=>typeof e==`object`&&!!e&&(e._tag===`Some`||e._tag===`None`),q=e=>typeof e==`object`&&!!e&&e._tag===`List`,Yt=e=>typeof e==`object`&&!!e&&(e._tag===`Left`||e._tag===`Right`),Xt=e=>typeof e==`object`&&!!e&&(e._tag===`Success`||e._tag===`Failure`),J=()=>{let e=(e,t)=>{if(Jt(e)||q(e)||Yt(e)||Xt(e))return e.map(e=>t(e));throw Error(`Unsupported functor type: ${JSON.stringify(e)}`)},t=e=>{if(Jt(e))return e.orThrow();if(q(e)){let t=e.toArray();if(t.length>0&&q(t[0])){let e=[];for(let n of t)q(n)&&e.push(...n.toArray());return C(e)}return e.flatten()}if(Yt(e))return e.isRight()?e.fold(()=>null,e=>e):e;if(Xt(e))return e.isSuccess()?e.orThrow():e;throw Error(`Unsupported functor type for flatten: ${JSON.stringify(e)}`)},n=(e,t)=>{if(Jt(e)||q(e)||Yt(e)||Xt(e))return e.flatMap(e=>t(e));throw Error(`Unsupported functor type for flatMap: ${JSON.stringify(e)}`)},r=(e,t)=>{if(Jt(e)&&Jt(t)||q(e)&&q(t)||Yt(e)&&Yt(t)||Xt(e)&&Xt(t))return e.flatMap(e=>t.map(t=>e(t)));throw Error(`Unsupported functor type for ap: ${JSON.stringify(e)}`)},i=e=>{if(Jt(e)){let t=e;if(t.isEmpty)return C([m.none()]);let n=t.orThrow();if(q(n))return n.map(e=>m(e));throw Error(`Unsupported inner container type for sequence`)}if(q(e)){let t=e.toArray();if(t.length===0)return m.none();let n=t[0];if(Jt(n)){for(let e of t)if(e.isEmpty)return m.none();return m(C(t.map(e=>e.orThrow())))}throw Error(`Unsupported inner container type for sequence`)}throw Error(`Unsupported outer container type for sequence: ${JSON.stringify(e)}`)};return{_tag:`HKT`,map:e,flatten:t,flatMap:n,ap:r,sequence:i,traverse:(t,n)=>i(e(t,e=>n(e))),_type:`HKT`}},Zt=J();J.map=(e,t)=>Zt.map(e,t),J.flatten=e=>Zt.flatten(e),J.flatMap=(e,t)=>Zt.flatMap(e,t),J.ap=(e,t)=>Zt.ap(e,t),J.sequence=e=>Zt.sequence(e),J.traverse=(e,t)=>Zt.traverse(e,t),J.isOption=Jt,J.isList=q,J.isEither=Yt,J.isTry=Xt;const Qt=e=>({id:e,isSame:t=>t.id===e}),$t=r(Qt,{of:e=>Qt(e),pure:e=>Qt(e)}),Y=e=>{let t=!1,r,i,a=!1,o=()=>{if(!t)try{r=e(),t=!0}catch(e){throw i=e,a=!0,t=!0,e}if(a)throw i;return r};return{[Symbol.toStringTag]:`Lazy`,_tag:`Lazy`,get isEvaluated(){return t},orElse:e=>{try{return o()}catch{return e}},orNull:()=>{try{return o()}catch{return null}},orThrow:e=>{try{return o()}catch(t){throw e??t}},or:e=>X(()=>{try{return o()}catch{return e.orThrow()}}),orUndefined:()=>{try{return o()}catch{return}},map:e=>X(()=>e(o())),ap:e=>X(()=>e.orThrow()(o())),mapAsync:async e=>{let t=await e(o());return X(()=>t)},flatMap:e=>X(()=>e(o()).orThrow()),flatMapAsync:async e=>{let t=await e(o());return X(()=>t.orThrow())},filter:e=>X(()=>{let t=o();return e(t)?d(t):p}),recover:e=>X(()=>{try{return o()}catch(t){return e(t)}}),recoverWith:e=>X(()=>{try{return o()}catch(t){return e(t).orThrow()}}),toOption:()=>{try{return d(o())}catch{return p}},toEither:()=>{try{return w(o())}catch(e){return T(e)}},toEitherWith:e=>{try{return w(o())}catch(t){return T(e(t))}},toTry:()=>x(()=>o()),tap:e=>X(()=>{let t=o();return e(t),t}),tapError:e=>X(()=>{try{return o()}catch(t){throw e(t),t}}),fold:e=>e(o()),foldWith:(e,t)=>{try{return t(o())}catch(t){return e(t)}},foldLeft:e=>t=>t(e,o()),foldRight:e=>t=>t(o(),e),match:e=>e.Lazy(o()),toString:()=>t&&!a?`Lazy(${n(r)})`:t&&a?`Lazy(<error: ${i instanceof Error?i.message:String(i)}>)`:`Lazy(<not evaluated>)`,toValue:()=>t&&!a?{_tag:`Lazy`,evaluated:!0,value:r}:{_tag:`Lazy`,evaluated:!1},get size(){try{return o(),1}catch{return 0}},get isEmpty(){try{return o(),!1}catch{return!0}},contains:e=>{try{return o()===e}catch{return!1}},reduce:e=>o(),reduceRight:e=>o(),count:e=>{try{return+!!e(o())}catch{return 0}},find:e=>{try{let t=o();return e(t)?d(t):p}catch{return p}},exists:e=>{try{return e(o())}catch{return!1}},forEach:e=>{try{e(o())}catch{}},pipe:e=>e(o()),serialize:()=>({toJSON:()=>JSON.stringify(t&&!a?{_tag:`Lazy`,evaluated:!0,value:r}:{_tag:`Lazy`,evaluated:!1}),toYAML:()=>t&&!a?`_tag: Lazy\nevaluated: true\nvalue: ${n(r)}`:`_tag: Lazy
|
|
17
17
|
evaluated: false`,toBinary:()=>Buffer.from(JSON.stringify(t&&!a?{_tag:`Lazy`,evaluated:!0,value:r}:{_tag:`Lazy`,evaluated:!1})).toString(`base64`)}),typeable:`Lazy`}},X=r(Y,{of:e=>Y(e),fromValue:e=>Y(()=>e),fromOption:(e,t)=>Y(()=>e._tag===`Some`?e.value:t()),fromTry:e=>Y(()=>e.orThrow()),fromEither:e=>Y(()=>e.fold(e=>{throw e},e=>e)),fromPromise:e=>Y(()=>{throw Error(`Promise not yet resolved. Use await on the promise before creating Lazy.`)}),fail:e=>Y(()=>{throw e})}),en=Map,Z=e=>{let t={values:new en(e)},n=()=>Array.from(t.values.entries()).map(([e,t])=>i([e,t])),r=e=>Z(new en(t.values).set(e.toArray()[0],e.toArray()[1]).entries()),a=e=>{let n=new en(t.values);return n.delete(e)?Z(n.entries()):Z(t.values.entries())},s=e=>{if(!e||typeof e.toArray!=`function`)return!1;let n=e.toArray();return t.values.get(n[0])===n[1]},c=()=>t.values.size,l=e=>Z(Array.from(t.values.entries()).map(([t,n])=>[t,e(n)])),u=e=>Z(Z(t.values.entries()).toList().flatMap(e).toArray()),ee=e=>{let n=[];for(let[r,i]of t.values.entries()){let t=e.get(r);t._tag===`Some`&&t.value&&n.push([r,t.value(i)])}return Z(n)},d=async e=>{let n=new en;for(let[r,i]of t.values.entries()){let t=await e(i);for(let e of t.toList()){let[t,r]=e.toArray();n.set(t,r)}}return Z(n.entries())},f=e=>C(n()).reduce(e),p=e=>C(n()).reduceRight(e),te=e=>t=>C(n()).foldLeft(e)(t),ne=e=>t=>C(n()).foldRight(e)(t),re=e=>m(t.values.get(e)),ie=(e,n)=>m(t.values.get(e)).orElse(n),h=()=>t.values.size===0,g=(e,n)=>m(t.values.get(e)).or(n),ae=(e,t)=>C(n()).fold(e,t),oe=()=>C(n()),se=()=>ce(n()),le=()=>`Map(${n().toString()})`,_=e=>h()?e.Empty():e.NonEmpty(n());return{[Symbol.toStringTag]:`FunctypeMap`,_tag:`Map`,[Symbol.iterator]:()=>t.values.entries(),add:r,remove:a,contains:s,get size(){return c()},map:l,ap:ee,flatMap:u,flatMapAsync:d,reduce:f,reduceRight:p,foldLeft:te,foldRight:ne,fold:ae,match:_,get:re,getOrElse:ie,get isEmpty(){return h()},orElse:g,toList:oe,toSet:se,toString:le,toValue:()=>({_tag:`Map`,value:Array.from(t.values.entries())}),pipe:e=>e(Array.from(t.values.entries())),serialize:()=>o(`Map`,Array.from(t.values.entries()))}},tn=e=>Z(e),nn=Z([]),rn={empty:()=>nn,of:(...e)=>Z(e),fromJSON:e=>an(JSON.parse(e).value),fromYAML:e=>{let t=e.split(`
|
|
18
18
|
`)[1]?.split(`: `)[1];return an(t?JSON.parse(t):[])},fromBinary:e=>{let t=Buffer.from(e,`base64`).toString();return rn.fromJSON(t)}},an=r(tn,rn),on={default:e=>t=>e(t),when:(e,t)=>n=>e(n)?t(n):void 0},Q=e=>({[Symbol.toStringTag]:`Obj`,_tag:`Obj`,data:e,get:t=>m(e[t]),set:(t,n)=>Q({...e,[t]:n}),assign:t=>Q({...e,...t}),merge:t=>Q({...e,...t}),when:(t,n)=>(typeof t==`function`?t():t)?Q({...e,...n}):Q(e),omit:(...t)=>{let n={...e};for(let e of t)delete n[e];return Q(n)},pick:(...t)=>{let n={};for(let r of t)r in e&&(n[r]=e[r]);return Q(n)},keys:()=>C(Object.keys(e)),values:()=>C(Object.values(e)),entries:()=>C(Object.entries(e).map(([e,t])=>i([e,t]))),has:t=>t in e,value:()=>e,get isEmpty(){return Object.keys(e).length===0},get size(){return Object.keys(e).length},map:t=>Q(t(e)),flatMap:t=>t(e),flatMapAsync:async t=>await t(e),ap:t=>{let n=t.data;return Q(n(e))},fold:(t,n)=>Object.keys(e).length===0?t():n(e),match:t=>t.Obj(e),foldLeft:t=>n=>n(t,e),foldRight:t=>n=>n(e,t),count:t=>+!!t(e),find:t=>t(e)?m(e):m(void 0),exists:t=>t(e),forEach:t=>t(e),reduce:t=>e,reduceRight:t=>e,contains:t=>JSON.stringify(e)===JSON.stringify(t),orElse:t=>e,orThrow:t=>e,or:t=>Q(e),orNull:()=>e,orUndefined:()=>e,toOption:()=>m(e),toEither:t=>w(e),toList:()=>C([e]),toTry:()=>x(()=>e),toPromise:()=>Promise.resolve(e),toString:()=>`Obj(${n(e)})`,toValue:()=>({_tag:`Obj`,value:e}),pipe:t=>t(e),serialize:()=>o(`Obj`,e),doUnwrap(){return{ok:!0,value:e}}}),sn=e=>Q(e),cn={of:e=>Q(e),empty:()=>Q({}),fromJSON:e=>Q(JSON.parse(e).value),fromBinary:e=>{let t=Buffer.from(e,`base64`).toString();return cn.fromJSON(t)}},ln=r(sn,cn),$=(e=[])=>{let t=[...e],r=()=>t.length,i=()=>t.length===0,a=e=>t.includes(e),o=e=>{if(t.length===0)throw Error(`Cannot reduce an empty stack`);return re(t,e)},s=e=>{if(t.length===0)throw Error(`Cannot reduce an empty stack`);return ie(t,e)},c=e=>$([...t,e]),l=()=>{if(i())return[$([]),m(null)];let e=[...t],n=e.pop();return[$(e),m(n)]},u=()=>i()?m(null):m(t[t.length-1]),ee=e=>$(t.map(e)),d=e=>i()?$([]):t.reduce((t,n)=>e(n).toArray().reduce((e,t)=>e.push(t),t),$([])),f=e=>{let n=[];return t.forEach(t=>{e.toArray().forEach(e=>{n.push(e(t))})}),$(n)},p=async e=>i()?$([]):(await Promise.all(t.map(async t=>await e(t)))).reduce((e,t)=>t.toArray().reduce((e,t)=>e.push(t),e),$([])),te=()=>C(t),ne=()=>[...t],h=()=>`Stack(${t.join(`, `)})`,g=(e,n)=>t.reduce(n,e),ae=e=>n=>t.reduce(n,e),oe=e=>n=>t.reduceRight((e,t)=>n(t,e),e),se=e=>i()?e.Empty():e.NonEmpty([...t]);return{[Symbol.toStringTag]:`Stack`,_tag:`Stack`,get size(){return r()},get isEmpty(){return i()},contains:a,reduce:o,reduceRight:s,push:c,pop:l,peek:u,map:ee,flatMap:d,ap:f,flatMapAsync:p,toList:te,toArray:ne,toString:h,fold:g,foldLeft:ae,foldRight:oe,match:se,toValue:()=>({_tag:`Stack`,value:t}),pipe:e=>e([...t]),serialize:()=>({toJSON:()=>JSON.stringify({_tag:`Stack`,value:t}),toYAML:()=>`_tag: Stack\nvalue: ${n(t)}`,toBinary:()=>Buffer.from(JSON.stringify({_tag:`Stack`,value:t})).toString(`base64`)})}},un=(e=[])=>$(e),dn={empty:()=>$([]),of:e=>$([e]),fromJSON:e=>fn(JSON.parse(e).value),fromYAML:e=>{let t=e.split(`
|
|
19
19
|
`)[1]?.split(`: `)[1];return fn(t?JSON.parse(t):[])},fromBinary:e=>{let t=Buffer.from(e,`base64`).toString();return dn.fromJSON(t)}},fn=r(un,dn);function pn(e){let t=he({_tag:e._tag,impl:e.impl});return{...t,toValue:()=>({_tag:t._tag,value:e.value})}}export{Ie as $,_t as A,te as At,O as B,P as C,fe as Ct,bt as D,re as Dt,M as E,ie as Et,ht as F,u as Ft,Ze as G,A as H,pt as I,c as It,Ye as J,Qe as K,ft as L,l as Lt,ot as M,s as Mt,ct as N,ee as Nt,yt as O,p as Ot,mt as P,o as Pt,Ve as Q,lt as R,a as Rt,I as S,x as St,Ct as T,ce as Tt,tt as U,k as V,$e as W,Ue as X,Ke as Y,Be as Z,Pt as _,we as _t,an as a,Pe as at,At as b,he as bt,$t as c,Le as ct,Kt as d,T as dt,ze as et,Bt as f,w as ft,Lt as g,Se as gt,G as h,Ce as ht,on as i,He as it,dt as j,d as jt,vt as k,m as kt,J as l,E as lt,It as m,Te as mt,fn as n,Fe as nt,en as o,je as ot,Rt as p,Ee as pt,Xe as q,ln as r,Me as rt,X as s,Re as st,pn as t,Ne as tt,qt as u,Ae as ut,Nt as v,De as vt,Tt as w,_ as wt,kt as x,ge as xt,U as y,C as yt,ut as z};
|
package/dist/try/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Xn as TypeNames, Yn as Try } from "../index-
|
|
1
|
+
import { Xn as TypeNames, Yn as Try } from "../index-BFDvVJ8v.js";
|
|
2
2
|
export { Try, TypeNames };
|
package/dist/try/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{St as e}from"../src-
|
|
1
|
+
import{St as e}from"../src-lZq532nx.js";export{e as Try};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "functype",
|
|
3
|
-
"version": "0.60.
|
|
3
|
+
"version": "0.60.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A functional programming library for TypeScript, using immutable data structures and type classes",
|
|
6
6
|
"author": "jordan.burke@gmail.com",
|
|
@@ -43,17 +43,18 @@
|
|
|
43
43
|
"site:build": "cd site && pnpm build",
|
|
44
44
|
"site:preview": "cd site && pnpm preview",
|
|
45
45
|
"cli-example": "npx . Option",
|
|
46
|
-
"version:bump": "bash scripts/version-bump.sh"
|
|
46
|
+
"version:bump": "bash scripts/version-bump.sh",
|
|
47
|
+
"version": "bash scripts/version-sync-satellites.sh"
|
|
47
48
|
},
|
|
48
49
|
"devDependencies": {
|
|
49
50
|
"@eslint/compat": "^2.0.5",
|
|
50
51
|
"@types/node": "~24.10.15",
|
|
51
|
-
"eslint-config-functype": "2.
|
|
52
|
+
"eslint-config-functype": "2.3.0",
|
|
52
53
|
"eslint-plugin-functional": "^9.0.4",
|
|
53
54
|
"fast-check": "^4.7.0",
|
|
54
55
|
"globals": "^17.5.0",
|
|
55
|
-
"ts-builds": "^2.7.
|
|
56
|
-
"tsdown": "^0.21.
|
|
56
|
+
"ts-builds": "^2.7.2",
|
|
57
|
+
"tsdown": "^0.21.10",
|
|
57
58
|
"tsx": "^4.21.0",
|
|
58
59
|
"typedoc": "^0.28.19"
|
|
59
60
|
},
|