functype 0.30.0 → 0.41.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Brand-BPeggBaO.d.ts +1 -2
- package/dist/Brand-Cfr5zy8F.js +1 -2
- package/dist/Tuple-C4maYbiO.d.ts +1 -2
- package/dist/Tuple-CgX4p79w.js +1 -2
- package/dist/cli/index.js +2 -3
- 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/fpromise/index.d.ts +1 -1
- package/dist/fpromise/index.js +1 -1
- package/dist/{index-BiUAv9kR.d.ts → index-B6Civ4kr.d.ts} +132 -9
- 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-BeaSFZFq.js → src-DpfaJv6K.js} +2 -3
- package/dist/try/index.d.ts +1 -1
- package/dist/try/index.js +1 -1
- package/package.json +37 -40
- package/README.processed.md +0 -862
- package/dist/Brand-Cfr5zy8F.js.map +0 -1
- package/dist/Tuple-CgX4p79w.js.map +0 -1
- package/dist/cli/index.js.map +0 -1
- package/dist/src-BeaSFZFq.js.map +0 -1
- package/readme/BRAND_MIGRATION_GUIDE.md +0 -230
- package/readme/BUNDLE_OPTIMIZATION.md +0 -74
- package/readme/FPromise-Assessment.md +0 -43
- package/readme/HKT.md +0 -110
- package/readme/ROADMAP.md +0 -113
- package/readme/TASK-TODO.md +0 -33
- package/readme/TUPLE-EXAMPLES.md +0 -76
- package/readme/TaskMigration.md +0 -129
- package/readme/ai-guide.md +0 -406
- package/readme/examples.md +0 -2093
- package/readme/functype-changes-required.md +0 -189
- package/readme/quick-reference.md +0 -514
- package/readme/task-error-handling.md +0 -283
- package/readme/tasks.md +0 -203
- package/readme/type-index.md +0 -238
package/dist/Brand-BPeggBaO.d.ts
CHANGED
|
@@ -51,5 +51,4 @@ declare const BrandedString: <K extends string>(brand: K) => (value: string) =>
|
|
|
51
51
|
declare const BrandedNumber: <K extends string>(brand: K) => (value: number) => BrandedNumber<K>;
|
|
52
52
|
declare const BrandedBoolean: <K extends string>(brand: K) => (value: boolean) => BrandedBoolean<K>;
|
|
53
53
|
//#endregion
|
|
54
|
-
export { ExtractBrand as a, hasBrand as c, BrandedString as i, unwrapBrand as l, BrandedBoolean as n, Unwrap as o, BrandedNumber as r, createBrander as s, Brand as t };
|
|
55
|
-
//# sourceMappingURL=Brand-BPeggBaO.d.ts.map
|
|
54
|
+
export { ExtractBrand as a, hasBrand as c, BrandedString as i, unwrapBrand as l, BrandedBoolean as n, Unwrap as o, BrandedNumber as r, createBrander as s, Brand as t };
|
package/dist/Brand-Cfr5zy8F.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
function e(e,t){return t}function t(e){return e??e}function n(e,t){return e!=null}function r(t){return n=>e(t,n)}const i=t=>n=>e(t,n),a=t=>n=>e(t,n),o=t=>n=>e(t,n);export{r as a,i,o as n,n as o,a as r,t as s,e as t};
|
|
2
|
-
//# sourceMappingURL=Brand-Cfr5zy8F.js.map
|
|
1
|
+
function e(e,t){return t}function t(e){return e??e}function n(e,t){return e!=null}function r(t){return n=>e(t,n)}const i=t=>n=>e(t,n),a=t=>n=>e(t,n),o=t=>n=>e(t,n);export{r as a,i,o as n,n as o,a as r,t as s,e as t};
|
package/dist/Tuple-C4maYbiO.d.ts
CHANGED
|
@@ -174,5 +174,4 @@ declare const Tuple: (<T extends Type[]>(values: T) => Tuple<T>) & {
|
|
|
174
174
|
from: <T extends Type[]>(values: T) => Tuple<T>;
|
|
175
175
|
};
|
|
176
176
|
//#endregion
|
|
177
|
-
export { isTypeable as a, Pipe as c, TypeableParams as i, Foldable as l, ExtractTag as n, Serializable as o, Typeable as r, SerializationMethods as s, Tuple as t, Type as u };
|
|
178
|
-
//# sourceMappingURL=Tuple-C4maYbiO.d.ts.map
|
|
177
|
+
export { isTypeable as a, Pipe as c, TypeableParams as i, Foldable as l, ExtractTag as n, Serializable as o, Typeable as r, SerializationMethods as s, Tuple as t, Type as u };
|
package/dist/Tuple-CgX4p79w.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
import e from"safe-stable-stringify";function t(e,t){return Object.assign(e,t)}const n=t=>{let n={_tag:`Tuple`,map:e=>r(e(t)),flatMap:e=>e(t),get:e=>t[e],toArray:()=>t,length:t.length,[Symbol.iterator](){let e=0;return{next:()=>e<t.length?{value:t[e++],done:!1}:{value:void 0,done:!0}}},fold:(e,n)=>t.length===0?e():n(t[0]),foldLeft:e=>n=>t.reduce(n,e),foldRight:e=>n=>t.reduceRight((e,t)=>n(t,e),e),pipe:e=>e(n),serialize:()=>({toJSON:()=>JSON.stringify({_tag:`Tuple`,value:t}),toYAML:()=>`_tag: Tuple\nvalue: ${e(t)}`,toBinary:()=>Buffer.from(JSON.stringify({_tag:`Tuple`,value:t})).toString(`base64`)}),toValue:()=>({_tag:`Tuple`,value:t}),toString:()=>`Tuple(${t.map(e=>String(e)).join(`, `)})`};return n},r=t(e=>n(e),{of:(...e)=>n(e),pair:(e,t)=>n([e,t]),triple:(e,t,r)=>n([e,t,r]),empty:()=>n([]),from:e=>n(e)});export{t as n,r as t};
|
|
2
|
-
//# sourceMappingURL=Tuple-CgX4p79w.js.map
|
|
1
|
+
import e from"safe-stable-stringify";function t(e,t){return Object.assign(e,t)}const n=t=>{let n={_tag:`Tuple`,map:e=>r(e(t)),flatMap:e=>e(t),get:e=>t[e],toArray:()=>t,length:t.length,[Symbol.iterator](){let e=0;return{next:()=>e<t.length?{value:t[e++],done:!1}:{value:void 0,done:!0}}},fold:(e,n)=>t.length===0?e():n(t[0]),foldLeft:e=>n=>t.reduce(n,e),foldRight:e=>n=>t.reduceRight((e,t)=>n(t,e),e),pipe:e=>e(n),serialize:()=>({toJSON:()=>JSON.stringify({_tag:`Tuple`,value:t}),toYAML:()=>`_tag: Tuple\nvalue: ${e(t)}`,toBinary:()=>Buffer.from(JSON.stringify({_tag:`Tuple`,value:t})).toString(`base64`)}),toValue:()=>({_tag:`Tuple`,value:t}),toString:()=>`Tuple(${t.map(e=>String(e)).join(`, `)})`};return n},r=t(e=>n(e),{of:(...e)=>n(e),pair:(e,t)=>n([e,t]),triple:(e,t,r)=>n([e,t,r]),empty:()=>n([]),from:e=>n(e)});export{t as n,r as t};
|
package/dist/cli/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import"../Brand-Cfr5zy8F.js";import"../Tuple-CgX4p79w.js";import{Et as e,q as t,vt as n}from"../src-
|
|
2
|
+
import"../Brand-Cfr5zy8F.js";import"../Tuple-CgX4p79w.js";import{Et as e,q as t,vt as n}from"../src-DpfaJv6K.js";const r=`0.41.0`,i={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)`,`.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)`],transform:[`.map(f)`,`.flatMap(f)`,`.mapLeft(f)`,`.swap()`],extract:[`.fold(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)`,`Success(v)`,`Failure(e)`],transform:[`.map(f)`,`.flatMap(f)`,`.recover(f)`,`.recoverWith(f)`],extract:[`.fold(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)`,`.drop(n)`],extract:[`.fold(z, f)`,`.reduce(f)`,`.head`,`.tail`,`.toArray()`],check:[`.isEmpty`,`.nonEmpty`,`.size`,`.contains(v)`]}},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)`],extract:[`.fold(z, f)`,`.toArray()`],check:[`.has(v)`,`.isEmpty`,`.size`]}},Map:{description:`Immutable key-value store`,interfaces:[`SafeTraversable`,`Collection`,`Serializable`],methods:{create:[`Map([...])`,`Map.of(...)`,`Map.empty()`],transform:[`.set(k, v)`,`.delete(k)`,`.map(f)`,`.filter(p)`],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)`,`.drop(n)`,`.concat(ll)`],extract:[`.head`,`.tail`,`.toArray()`],check:[`.isEmpty`]}},Task:{description:`Async operations with cancellation and progress`,interfaces:[],methods:{create:[`Task.of(v)`,`Task.from(promise)`,`Task.sync(f)`,`Task.async(f)`],transform:[`.map(f)`,`.flatMap(f)`,`.mapError(f)`],extract:[`.run()`,`.cancel()`],other:[`.onProgress(cb)`,`.onCancel(cb)`]}},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)`]}},FPromise:{description:`Enhanced Promise with functional methods`,interfaces:[`PromiseLike`],methods:{create:[`FPromise.of(v)`,`FPromise.from(promise)`],transform:[`.map(f)`,`.flatMap(f)`,`.mapError(f)`,`.recover(f)`],extract:[`.toPromise()`,`.cancel()`]}},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`]}}},a={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`]}},o={Core:[`Option`,`Either`,`Try`],Collection:[`List`,`Set`,`Map`,`LazyList`,`Tuple`,`Stack`],Effect:[`IO`,`Task`,`FPromise`],Utility:[`Lazy`,`Cond`,`Match`,`Brand`,`ValidatedBrand`]},s=()=>{let t=n([`functype ${r} - Scala-inspired FP for TypeScript`,``]);return n(Object.entries(o)).foldLeft(t)((t,[r,a])=>{let o=t.add(r.toUpperCase());return n(a).foldLeft(o)((t,n)=>e(i[n]).fold(()=>t,e=>{let r=e.interfaces.length>0?` [${e.interfaces.join(`, `)}]`:``;return t.add(` ${n}${r}`).add(` ${e.description}`)})).add(``)}).concat(n([`Use: npx functype <Type> for details`,`Use: npx functype interfaces for interface reference`])).toArray().join(`
|
|
3
3
|
`)},c=(t,r)=>{let i=r.interfaces.length>0?` [${r.interfaces.join(`, `)}]`:``,a=n([`create`,`transform`,`extract`,`check`,`other`]),o=n([`${t}<T>${i}`,``,r.description,``]);return a.foldLeft(o)((t,i)=>e(r.methods[i]).filter(e=>e.length>0).fold(()=>t,e=>{let r=t.add(i.toUpperCase());return n(e).foldLeft(r)((e,t)=>e.add(` ${t}`)).add(``)})).toArray().join(`
|
|
4
4
|
`).trimEnd()},l=()=>{let e=n([`INTERFACES`,``]);return n(Object.entries(a)).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()},u=e=>JSON.stringify(e,null,2),d=()=>({version:r,categories:o,types:i}),f=t=>e(i[t]).map(e=>({name:t,data:e})).or(n(Object.entries(i)).find(([e])=>e.toLowerCase()===t.toLowerCase()).map(([e,t])=>({name:e,data:t}))).orUndefined(),p=()=>Object.keys(i),m=()=>a,h={Option:`export interface Option<T extends Type> extends Functype<T, "Some" | "None">, Promisable<T>, Doable<T>, Reshapeable<T> {
|
|
@@ -656,5 +656,4 @@ EXAMPLES
|
|
|
656
656
|
npx functype Option --json # Option as JSON
|
|
657
657
|
npx functype Option --full # Full TypeScript interface
|
|
658
658
|
npx functype --full # All full interfaces (large output!)
|
|
659
|
-
`)},b=e=>{console.error(`Unknown type: ${e}`),console.error(``),console.error(`Available types: ${p().join(`, `)}`),console.error(``),console.error(`Use: npx functype interfaces - for interface reference`),process.exit(1)},x=e=>console.log(e),S=(t,n)=>e(f(t)).fold(()=>b(t),e=>{n.full?_(e.name).fold(()=>x(n.json?u({[e.name]:e.data}):c(e.name,e.data)),t=>x(n.json?u({[e.name]:{...e.data,fullInterface:t}}):t)):x(n.json?u({[e.name]:e.data}):c(e.name,e.data))});(()=>{let{flags:e,args:n}=g(process.argv);t(!0).when(()=>e.help,()=>y()).when(()=>n.isEmpty,()=>e.full?x(e.json?u(h):v()):x(e.json?u(d()):s())).when(()=>n.headOption.contains(`interfaces`),()=>x(e.json?u(m()):l())).default(()=>n.headOption.fold(()=>x(e.json?u(d()):s()),t=>S(t,e)))})();
|
|
660
|
-
//# sourceMappingURL=index.js.map
|
|
659
|
+
`)},b=e=>{console.error(`Unknown type: ${e}`),console.error(``),console.error(`Available types: ${p().join(`, `)}`),console.error(``),console.error(`Use: npx functype interfaces - for interface reference`),process.exit(1)},x=e=>console.log(e),S=(t,n)=>e(f(t)).fold(()=>b(t),e=>{n.full?_(e.name).fold(()=>x(n.json?u({[e.name]:e.data}):c(e.name,e.data)),t=>x(n.json?u({[e.name]:{...e.data,fullInterface:t}}):t)):x(n.json?u({[e.name]:e.data}):c(e.name,e.data))});(()=>{let{flags:e,args:n}=g(process.argv);t(!0).when(()=>e.help,()=>y()).when(()=>n.isEmpty,()=>e.full?x(e.json?u(h):v()):x(e.json?u(d()):s())).when(()=>n.headOption.contains(`interfaces`),()=>x(e.json?u(m()):l())).default(()=>n.headOption.fold(()=>x(e.json?u(d()):s()),t=>S(t,e)))})();
|
package/dist/do/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import "../Brand-BPeggBaO.js";
|
|
2
|
-
import { Jn as Doable, a as EmptyListError, c as LeftError, d as isDoCapable, f as unwrap, i as DoGenerator, l as LeftErrorType, n as Do, o as FailureError, qn as DoResult, r as DoAsync, s as FailureErrorType, t as $, u as NoneError } from "../index-
|
|
2
|
+
import { Jn as Doable, a as EmptyListError, c as LeftError, d as isDoCapable, f as unwrap, i as DoGenerator, l as LeftErrorType, n as Do, o as FailureError, qn as DoResult, r as DoAsync, s as FailureErrorType, t as $, u as NoneError } from "../index-B6Civ4kr.js";
|
|
3
3
|
import "../Tuple-C4maYbiO.js";
|
|
4
4
|
export { $, Do, DoAsync, DoGenerator, DoResult, Doable, EmptyListError, FailureError, FailureErrorType, LeftError, LeftErrorType, NoneError, isDoCapable, unwrap };
|
package/dist/do/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../Brand-Cfr5zy8F.js";import"../Tuple-CgX4p79w.js";import{A as e,F as t,I as n,M as r,N as i,O as a,P as o,j as s,k as c}from"../src-
|
|
1
|
+
import"../Brand-Cfr5zy8F.js";import"../Tuple-CgX4p79w.js";import{A as e,F as t,I as n,M as r,N as i,O as a,P as o,j as s,k as c}from"../src-DpfaJv6K.js";export{a as $,c as Do,e as DoAsync,s as EmptyListError,r as FailureError,i as LeftError,o as NoneError,t as isDoCapable,n as unwrap};
|
package/dist/either/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import "../Brand-BPeggBaO.js";
|
|
2
|
-
import { S as tryCatchAsync, _ as TypeCheckLeft, b as isRight, g as TestEither, h as Right, m as Left, p as Either, v as TypeCheckRight, x as tryCatch, y as isLeft } from "../index-
|
|
2
|
+
import { S as tryCatchAsync, _ as TypeCheckLeft, b as isRight, g as TestEither, h as Right, m as Left, p as Either, v as TypeCheckRight, x as tryCatch, y as isLeft } from "../index-B6Civ4kr.js";
|
|
3
3
|
import "../Tuple-C4maYbiO.js";
|
|
4
4
|
export { Either, Left, Right, TestEither, TypeCheckLeft, TypeCheckRight, isLeft, isRight, tryCatch, tryCatchAsync };
|
package/dist/either/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../Brand-Cfr5zy8F.js";import"../Tuple-CgX4p79w.js";import{_t as e,dt as t,ft as n,gt as r,ht as i,lt as a,mt as o,pt as s,ut as c}from"../src-
|
|
1
|
+
import"../Brand-Cfr5zy8F.js";import"../Tuple-CgX4p79w.js";import{_t as e,dt as t,ft as n,gt as r,ht as i,lt as a,mt as o,pt as s,ut as c}from"../src-DpfaJv6K.js";export{a as Either,c as Left,t as Right,n as TypeCheckLeft,s as TypeCheckRight,o as isLeft,i as isRight,r as tryCatch,e as tryCatchAsync};
|
package/dist/fpromise/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import "../Brand-BPeggBaO.js";
|
|
2
|
-
import { cn as ErrorContext, ln as FPromise, un as FPromiseCompanion } from "../index-
|
|
2
|
+
import { cn as ErrorContext, ln as FPromise, un as FPromiseCompanion } from "../index-B6Civ4kr.js";
|
|
3
3
|
import "../Tuple-C4maYbiO.js";
|
|
4
4
|
export { ErrorContext, FPromise, FPromiseCompanion };
|
package/dist/fpromise/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../Brand-Cfr5zy8F.js";import"../Tuple-CgX4p79w.js";import{H as e,U as t}from"../src-
|
|
1
|
+
import"../Brand-Cfr5zy8F.js";import"../Tuple-CgX4p79w.js";import{H as e,U as t}from"../src-DpfaJv6K.js";export{e as FPromise,t as FPromiseCompanion};
|
|
@@ -2850,6 +2850,21 @@ interface IO<R$1 extends Type, E extends Type, A extends Type> {
|
|
|
2850
2850
|
* @returns New IO with transformed error
|
|
2851
2851
|
*/
|
|
2852
2852
|
mapError<E2 extends Type>(f: (e: E) => E2): IO<R$1, E2, A>;
|
|
2853
|
+
/**
|
|
2854
|
+
* Executes a side effect on the error without changing it.
|
|
2855
|
+
* Useful for logging errors while preserving the error chain.
|
|
2856
|
+
*
|
|
2857
|
+
* @param f - Side effect function to run on error
|
|
2858
|
+
* @returns Same IO with the side effect attached
|
|
2859
|
+
*
|
|
2860
|
+
* @example
|
|
2861
|
+
* ```typescript
|
|
2862
|
+
* const io = IO.asyncResult(() => query(), toError)
|
|
2863
|
+
* .tapError(err => console.error('Query failed:', err))
|
|
2864
|
+
* .map(data => transform(data))
|
|
2865
|
+
* ```
|
|
2866
|
+
*/
|
|
2867
|
+
tapError(f: (e: E) => void): IO<R$1, E, A>;
|
|
2853
2868
|
/**
|
|
2854
2869
|
* Recovers from any error with a fallback value.
|
|
2855
2870
|
* @param fallback - Value to use on error
|
|
@@ -2935,20 +2950,31 @@ interface IO<R$1 extends Type, E extends Type, A extends Type> {
|
|
|
2935
2950
|
* @param layer - The layer that provides services
|
|
2936
2951
|
*/
|
|
2937
2952
|
provideLayer<RIn extends Type, E2 extends Type, ROut extends R$1>(layer: Layer<RIn, E2, ROut>): IO<RIn | Exclude<R$1, ROut>, E | E2, A>;
|
|
2953
|
+
/**
|
|
2954
|
+
* Runs the effect and returns an Either. Never throws.
|
|
2955
|
+
* This is the safe default - all errors become Left.
|
|
2956
|
+
* Requires R = never.
|
|
2957
|
+
*/
|
|
2958
|
+
run(this: IO<never, E, A>): Promise<Either<E, A>>;
|
|
2938
2959
|
/**
|
|
2939
2960
|
* Runs the effect and returns a Promise of the value.
|
|
2940
|
-
* Throws on error
|
|
2961
|
+
* Throws on any error (typed E, defect, or interrupt).
|
|
2962
|
+
* Requires R = never.
|
|
2941
2963
|
*/
|
|
2942
|
-
|
|
2964
|
+
runOrThrow(this: IO<never, E, A>): Promise<A>;
|
|
2943
2965
|
/**
|
|
2944
|
-
* Runs a sync effect and returns
|
|
2945
|
-
*
|
|
2966
|
+
* Runs a sync effect and returns an Either. Never throws.
|
|
2967
|
+
* This is the safe default - all errors become Left.
|
|
2968
|
+
* Throws only if the effect is async (cannot be made safe synchronously).
|
|
2969
|
+
* Requires R = never.
|
|
2946
2970
|
*/
|
|
2947
|
-
runSync(this: IO<never, E, A>): A
|
|
2971
|
+
runSync(this: IO<never, E, A>): Either<E, A>;
|
|
2948
2972
|
/**
|
|
2949
|
-
* Runs
|
|
2973
|
+
* Runs a sync effect and returns the value.
|
|
2974
|
+
* Throws on any error or if the effect is async.
|
|
2975
|
+
* Requires R = never.
|
|
2950
2976
|
*/
|
|
2951
|
-
|
|
2977
|
+
runSyncOrThrow(this: IO<never, E, A>): A;
|
|
2952
2978
|
/**
|
|
2953
2979
|
* Runs the effect and returns an Exit.
|
|
2954
2980
|
*/
|
|
@@ -3130,6 +3156,104 @@ declare const IO: (<A extends Type>(f: () => A | Promise<A>) => IO<never, unknow
|
|
|
3130
3156
|
* Creates an IO from a Try.
|
|
3131
3157
|
*/
|
|
3132
3158
|
fromTry: <A extends Type>(t: ReturnType<typeof Try<A>>) => IO<never, Error, A>;
|
|
3159
|
+
/**
|
|
3160
|
+
* Creates an IO from a result object with data/error pattern.
|
|
3161
|
+
* If error is present (truthy), fails with the error.
|
|
3162
|
+
* Otherwise succeeds with Option-wrapped data (None if data is null/undefined).
|
|
3163
|
+
*
|
|
3164
|
+
* This handles the common `{ data, error }` response pattern used by
|
|
3165
|
+
* Supabase, many REST APIs, and similar libraries.
|
|
3166
|
+
*
|
|
3167
|
+
* @example
|
|
3168
|
+
* ```typescript
|
|
3169
|
+
* const response = { data: user, error: null }
|
|
3170
|
+
* const io = IO.fromResult(response) // IO<never, null, Option<User>> -> Some(user)
|
|
3171
|
+
*
|
|
3172
|
+
* const emptyResponse = { data: null, error: null }
|
|
3173
|
+
* const emptyIo = IO.fromResult(emptyResponse) // IO<never, null, Option<User>> -> None
|
|
3174
|
+
*
|
|
3175
|
+
* const errorResponse = { data: null, error: new Error("Not found") }
|
|
3176
|
+
* const failedIo = IO.fromResult(errorResponse) // IO<never, Error, Option<null>> -> fails
|
|
3177
|
+
* ```
|
|
3178
|
+
*/
|
|
3179
|
+
fromResult: <D extends Type, E extends Type>(result: {
|
|
3180
|
+
data: D | null;
|
|
3181
|
+
error: E | null;
|
|
3182
|
+
}) => IO<never, E, Option<D>>;
|
|
3183
|
+
/**
|
|
3184
|
+
* Creates an IO from an async thunk with typed error handling.
|
|
3185
|
+
* Catches any thrown errors and maps them using the provided function.
|
|
3186
|
+
* Supports cancellation via AbortSignal.
|
|
3187
|
+
*
|
|
3188
|
+
* This is a simpler alternative to `tryPromise` that takes a direct
|
|
3189
|
+
* error mapper function instead of an options object.
|
|
3190
|
+
*
|
|
3191
|
+
* @param f - Async function to execute (receives optional AbortSignal)
|
|
3192
|
+
* @param onError - Function to map caught errors to typed error E
|
|
3193
|
+
* @param signal - Optional AbortSignal for cancellation support
|
|
3194
|
+
*
|
|
3195
|
+
* @example
|
|
3196
|
+
* ```typescript
|
|
3197
|
+
* const io = IO.tryAsync(
|
|
3198
|
+
* () => fetch('/api/users').then(r => r.json()),
|
|
3199
|
+
* (e) => new ApiError(e)
|
|
3200
|
+
* )
|
|
3201
|
+
*
|
|
3202
|
+
* // With cancellation:
|
|
3203
|
+
* const controller = new AbortController()
|
|
3204
|
+
* const io = IO.tryAsync(
|
|
3205
|
+
* (signal) => fetch('/api/users', { signal }).then(r => r.json()),
|
|
3206
|
+
* (e) => new ApiError(e),
|
|
3207
|
+
* controller.signal
|
|
3208
|
+
* )
|
|
3209
|
+
* controller.abort() // Cancels the request
|
|
3210
|
+
* ```
|
|
3211
|
+
*/
|
|
3212
|
+
tryAsync: <A extends Type, E extends Type>(f: (signal?: AbortSignal) => Promise<A>, onError: (error: unknown) => E, signal?: AbortSignal) => IO<never, E, A>;
|
|
3213
|
+
/**
|
|
3214
|
+
* Creates an IO from an async function that returns { data, error }.
|
|
3215
|
+
* Handles both:
|
|
3216
|
+
* - Thrown errors (mapped via onThrow)
|
|
3217
|
+
* - Returned errors in the result object
|
|
3218
|
+
* Supports cancellation via AbortSignal.
|
|
3219
|
+
*
|
|
3220
|
+
* This is the most ergonomic way to wrap Supabase and similar API calls.
|
|
3221
|
+
*
|
|
3222
|
+
* @param f - Async function returning { data, error } object (receives optional AbortSignal)
|
|
3223
|
+
* @param onThrow - Function to map thrown errors to typed error E
|
|
3224
|
+
* @param config - Optional configuration for custom field names and cancellation
|
|
3225
|
+
*
|
|
3226
|
+
* @example
|
|
3227
|
+
* ```typescript
|
|
3228
|
+
* // Supabase query in one line:
|
|
3229
|
+
* const getUser = (id: string): IO<never, Error, Option<User>> =>
|
|
3230
|
+
* IO.asyncResult(
|
|
3231
|
+
* () => supabase.from('users').select('*').eq('id', id).single(),
|
|
3232
|
+
* toError
|
|
3233
|
+
* )
|
|
3234
|
+
*
|
|
3235
|
+
* // With custom field names:
|
|
3236
|
+
* const result = IO.asyncResult(
|
|
3237
|
+
* () => customApi.fetch(),
|
|
3238
|
+
* toError,
|
|
3239
|
+
* { dataKey: 'result', errorKey: 'err' }
|
|
3240
|
+
* )
|
|
3241
|
+
*
|
|
3242
|
+
* // With cancellation:
|
|
3243
|
+
* const controller = new AbortController()
|
|
3244
|
+
* const getUser = IO.asyncResult(
|
|
3245
|
+
* (signal) => supabase.from('users').abortSignal(signal).select('*').single(),
|
|
3246
|
+
* toError,
|
|
3247
|
+
* { signal: controller.signal }
|
|
3248
|
+
* )
|
|
3249
|
+
* controller.abort() // Cancels the request
|
|
3250
|
+
* ```
|
|
3251
|
+
*/
|
|
3252
|
+
asyncResult: <D extends Type, E extends Type>(f: (signal?: AbortSignal) => Promise<Record<string, unknown>>, onThrow: (error: unknown) => E, config?: {
|
|
3253
|
+
dataKey?: string;
|
|
3254
|
+
errorKey?: string;
|
|
3255
|
+
signal?: AbortSignal;
|
|
3256
|
+
}) => IO<never, E, Option<D>>;
|
|
3133
3257
|
/**
|
|
3134
3258
|
* Creates an IO that requires a service identified by the tag.
|
|
3135
3259
|
* The service must be provided before the effect can be run.
|
|
@@ -4814,5 +4938,4 @@ interface FailureErrorType extends Error {
|
|
|
4814
4938
|
}
|
|
4815
4939
|
declare const FailureError: (cause: Error, message?: string) => FailureErrorType;
|
|
4816
4940
|
//#endregion
|
|
4817
|
-
export { TestClockTag as $, Task$1 as $t, OptionConstructor as A, PositiveNumber as An, ValidationRule as At, fromBinary as B, Functor as Bn, ErrorWithTaskInfo as Bt, Functype as C, EmailAddress as Cn, OptionKind as Ct, List as D, NonNegativeNumber as Dn, FieldValidation as Dt, Collection as E, NonEmptyString as En, FoldableUtils as Et, Set as F, Try as Fn, TypedError as Ft, MatchableUtils as G, Extractable as Gn, safeStringify as Gt, fromYAML as H, CollectionOps as Hn, createErrorSerializer as Ht, SerializationResult as I, TypeNames as In, TypedErrorContext as It, Map$1 as J, Doable as Jn, CancellationTokenSource as Jt, ESMap as K, isExtractable as Kn, Async as Kt, createCustomSerializer as L, Promisable as Ln, ParseError as Lt, Stack as M, UrlString as Mn, ErrorCode as Mt, Valuable as N, ValidatedBrand as Nn, ErrorMessage as Nt, None as O, PatternString as On, FormValidation as Ot, ValuableParams as P, ValidatedBrandCompanion as Pn, ErrorStatus as Pt, TestClock as Q, TaggedThrowable as Qt, createSerializationCompanion as R, Applicative as Rn, ErrorChainElement as Rt, tryCatchAsync as S, BoundedString as Sn, ListKind as St, FunctypeCollection as T, IntegerNumber as Tn, UniversalContainer as Tt, Ref as U, ContainerOps as Un, formatError as Ut, fromJSON as V, Monad as Vn, TaskErrorInfo as Vt, Matchable as W, LazyList as Wn, formatStackTrace as Wt, Traversable as X, Ok as Xt, SafeTraversable as Y, Err as Yt, Lazy as Z, Sync as Zt, TypeCheckLeft as _, CompanionMethods as _n, TagService as _t, EmptyListError as a, TaskSuccess as an, TimeoutError as at, isRight as b, Companion as bn, HKT as bt, LeftError as c, ErrorContext as cn, LayerError as ct, isDoCapable as d, NAME as dn, Exit as dt, TaskFailure as en, TestContext as et, unwrap as f, Throwable as fn, ExitTag as ft, TestEither as g, Cond as gn, Tag as gt, Right as h, Match as hn, HasService as ht, DoGenerator as i, TaskResult as in, Task as it, Some as j, UUID as jn, Validator as jt, Option as k, PositiveInteger as kn, Validation as kt, LeftErrorType as l, FPromise as ln, LayerInput as lt, Left as m, Base as mn, ContextServices as mt, Do as n, TaskOutcome as nn, InterruptedError as nt, FailureError as o, createCancellationTokenSource as on, UIO as ot, Either as p, ThrowableType as pn, Context as pt, ESMapType as q, DoResult as qn, CancellationToken as qt, DoAsync as r, TaskParams as rn, RIO as rt, FailureErrorType as s, isTaggedThrowable as sn, Layer as st, $ as t, TaskMetadata as tn, IO as tt, NoneError as u, FPromiseCompanion as un, LayerOutput as ut, TypeCheckRight as v, InstanceType as vn, Identity as vt, FunctypeBase as w, ISO8601Date as wn, TryKind as wt, tryCatch as x, BoundedNumber as xn, Kind as xt, isLeft as y, isCompanion as yn, EitherKind as yt, createSerializer as z, AsyncMonad as zn, ErrorFormatterOptions as zt };
|
|
4818
|
-
//# sourceMappingURL=index-BiUAv9kR.d.ts.map
|
|
4941
|
+
export { TestClockTag as $, Task$1 as $t, OptionConstructor as A, PositiveNumber as An, ValidationRule as At, fromBinary as B, Functor as Bn, ErrorWithTaskInfo as Bt, Functype as C, EmailAddress as Cn, OptionKind as Ct, List as D, NonNegativeNumber as Dn, FieldValidation as Dt, Collection as E, NonEmptyString as En, FoldableUtils as Et, Set as F, Try as Fn, TypedError as Ft, MatchableUtils as G, Extractable as Gn, safeStringify as Gt, fromYAML as H, CollectionOps as Hn, createErrorSerializer as Ht, SerializationResult as I, TypeNames as In, TypedErrorContext as It, Map$1 as J, Doable as Jn, CancellationTokenSource as Jt, ESMap as K, isExtractable as Kn, Async as Kt, createCustomSerializer as L, Promisable as Ln, ParseError as Lt, Stack as M, UrlString as Mn, ErrorCode as Mt, Valuable as N, ValidatedBrand as Nn, ErrorMessage as Nt, None as O, PatternString as On, FormValidation as Ot, ValuableParams as P, ValidatedBrandCompanion as Pn, ErrorStatus as Pt, TestClock as Q, TaggedThrowable as Qt, createSerializationCompanion as R, Applicative as Rn, ErrorChainElement as Rt, tryCatchAsync as S, BoundedString as Sn, ListKind as St, FunctypeCollection as T, IntegerNumber as Tn, UniversalContainer as Tt, Ref as U, ContainerOps as Un, formatError as Ut, fromJSON as V, Monad as Vn, TaskErrorInfo as Vt, Matchable as W, LazyList as Wn, formatStackTrace as Wt, Traversable as X, Ok as Xt, SafeTraversable as Y, Err as Yt, Lazy as Z, Sync as Zt, TypeCheckLeft as _, CompanionMethods as _n, TagService as _t, EmptyListError as a, TaskSuccess as an, TimeoutError as at, isRight as b, Companion as bn, HKT as bt, LeftError as c, ErrorContext as cn, LayerError as ct, isDoCapable as d, NAME as dn, Exit as dt, TaskFailure as en, TestContext as et, unwrap as f, Throwable as fn, ExitTag as ft, TestEither as g, Cond as gn, Tag as gt, Right as h, Match as hn, HasService as ht, DoGenerator as i, TaskResult as in, Task as it, Some as j, UUID as jn, Validator as jt, Option as k, PositiveInteger as kn, Validation as kt, LeftErrorType as l, FPromise as ln, LayerInput as lt, Left as m, Base as mn, ContextServices as mt, Do as n, TaskOutcome as nn, InterruptedError as nt, FailureError as o, createCancellationTokenSource as on, UIO as ot, Either as p, ThrowableType as pn, Context as pt, ESMapType as q, DoResult as qn, CancellationToken as qt, DoAsync as r, TaskParams as rn, RIO as rt, FailureErrorType as s, isTaggedThrowable as sn, Layer as st, $ as t, TaskMetadata as tn, IO as tt, NoneError as u, FPromiseCompanion as un, LayerOutput as ut, TypeCheckRight as v, InstanceType as vn, Identity as vt, FunctypeBase as w, ISO8601Date as wn, TryKind as wt, tryCatch as x, BoundedNumber as xn, Kind as xt, isLeft as y, isCompanion as yn, EitherKind as yt, createSerializer as z, AsyncMonad as zn, ErrorFormatterOptions as zt };
|
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-BPeggBaO.js";
|
|
2
|
-
import { $ as TestClockTag, $t as Task$1, A as OptionConstructor, An as PositiveNumber, At as ValidationRule, B as fromBinary, Bn as Functor, Bt as ErrorWithTaskInfo, C as Functype, Cn as EmailAddress, Ct as OptionKind, D as List, Dn as NonNegativeNumber, Dt as FieldValidation, E as Collection, En as NonEmptyString, Et as FoldableUtils, F as Set, Fn as Try, Ft as TypedError, G as MatchableUtils, Gn as Extractable, Gt as safeStringify, H as fromYAML, Hn as CollectionOps, Ht as createErrorSerializer, I as SerializationResult, In as TypeNames, It as TypedErrorContext, J as Map, Jn as Doable, Jt as CancellationTokenSource, K as ESMap, Kn as isExtractable, Kt as Async, L as createCustomSerializer, Ln as Promisable, Lt as ParseError, M as Stack, Mn as UrlString, Mt as ErrorCode, N as Valuable, Nn as ValidatedBrand, Nt as ErrorMessage, O as None, On as PatternString, Ot as FormValidation, P as ValuableParams, Pn as ValidatedBrandCompanion, Pt as ErrorStatus, Q as TestClock, Qt as TaggedThrowable, R as createSerializationCompanion, Rn as Applicative, Rt as ErrorChainElement, S as tryCatchAsync, Sn as BoundedString, St as ListKind, T as FunctypeCollection, Tn as IntegerNumber, Tt as UniversalContainer, U as Ref, Un as ContainerOps, Ut as formatError, V as fromJSON, Vn as Monad, Vt as TaskErrorInfo, W as Matchable, Wn as LazyList, Wt as formatStackTrace, X as Traversable, Xt as Ok, Y as SafeTraversable, Yt as Err, Z as Lazy, Zt as Sync, _ as TypeCheckLeft, _n as CompanionMethods, _t as TagService, a as EmptyListError, an as TaskSuccess, at as TimeoutError, b as isRight, bn as Companion, bt as HKT, c as LeftError, cn as ErrorContext, ct as LayerError, d as isDoCapable, dn as NAME, dt as Exit, en as TaskFailure, et as TestContext, f as unwrap, fn as Throwable, ft as ExitTag, g as TestEither, gn as Cond, gt as Tag, h as Right, hn as Match, ht as HasService, i as DoGenerator, in as TaskResult, it as Task, j as Some, jn as UUID, jt as Validator, k as Option, kn as PositiveInteger, kt as Validation, l as LeftErrorType, ln as FPromise, lt as LayerInput, m as Left, mn as Base, mt as ContextServices, n as Do, nn as TaskOutcome, nt as InterruptedError, o as FailureError, on as createCancellationTokenSource, ot as UIO, p as Either, pn as ThrowableType, pt as Context, q as ESMapType, qn as DoResult, qt as CancellationToken, r as DoAsync, rn as TaskParams, rt as RIO, s as FailureErrorType, sn as isTaggedThrowable, st as Layer, t as $, tn as TaskMetadata, tt as IO, u as NoneError, un as FPromiseCompanion, ut as LayerOutput, v as TypeCheckRight, vn as InstanceType, vt as Identity, w as FunctypeBase, wn as ISO8601Date, wt as TryKind, x as tryCatch, xn as BoundedNumber, xt as Kind, y as isLeft, yn as isCompanion, yt as EitherKind, z as createSerializer, zn as AsyncMonad, zt as ErrorFormatterOptions } from "./index-
|
|
2
|
+
import { $ as TestClockTag, $t as Task$1, A as OptionConstructor, An as PositiveNumber, At as ValidationRule, B as fromBinary, Bn as Functor, Bt as ErrorWithTaskInfo, C as Functype, Cn as EmailAddress, Ct as OptionKind, D as List, Dn as NonNegativeNumber, Dt as FieldValidation, E as Collection, En as NonEmptyString, Et as FoldableUtils, F as Set, Fn as Try, Ft as TypedError, G as MatchableUtils, Gn as Extractable, Gt as safeStringify, H as fromYAML, Hn as CollectionOps, Ht as createErrorSerializer, I as SerializationResult, In as TypeNames, It as TypedErrorContext, J as Map, Jn as Doable, Jt as CancellationTokenSource, K as ESMap, Kn as isExtractable, Kt as Async, L as createCustomSerializer, Ln as Promisable, Lt as ParseError, M as Stack, Mn as UrlString, Mt as ErrorCode, N as Valuable, Nn as ValidatedBrand, Nt as ErrorMessage, O as None, On as PatternString, Ot as FormValidation, P as ValuableParams, Pn as ValidatedBrandCompanion, Pt as ErrorStatus, Q as TestClock, Qt as TaggedThrowable, R as createSerializationCompanion, Rn as Applicative, Rt as ErrorChainElement, S as tryCatchAsync, Sn as BoundedString, St as ListKind, T as FunctypeCollection, Tn as IntegerNumber, Tt as UniversalContainer, U as Ref, Un as ContainerOps, Ut as formatError, V as fromJSON, Vn as Monad, Vt as TaskErrorInfo, W as Matchable, Wn as LazyList, Wt as formatStackTrace, X as Traversable, Xt as Ok, Y as SafeTraversable, Yt as Err, Z as Lazy, Zt as Sync, _ as TypeCheckLeft, _n as CompanionMethods, _t as TagService, a as EmptyListError, an as TaskSuccess, at as TimeoutError, b as isRight, bn as Companion, bt as HKT, c as LeftError, cn as ErrorContext, ct as LayerError, d as isDoCapable, dn as NAME, dt as Exit, en as TaskFailure, et as TestContext, f as unwrap, fn as Throwable, ft as ExitTag, g as TestEither, gn as Cond, gt as Tag, h as Right, hn as Match, ht as HasService, i as DoGenerator, in as TaskResult, it as Task, j as Some, jn as UUID, jt as Validator, k as Option, kn as PositiveInteger, kt as Validation, l as LeftErrorType, ln as FPromise, lt as LayerInput, m as Left, mn as Base, mt as ContextServices, n as Do, nn as TaskOutcome, nt as InterruptedError, o as FailureError, on as createCancellationTokenSource, ot as UIO, p as Either, pn as ThrowableType, pt as Context, q as ESMapType, qn as DoResult, qt as CancellationToken, r as DoAsync, rn as TaskParams, rt as RIO, s as FailureErrorType, sn as isTaggedThrowable, st as Layer, t as $, tn as TaskMetadata, tt as IO, u as NoneError, un as FPromiseCompanion, ut as LayerOutput, v as TypeCheckRight, vn as InstanceType, vt as Identity, w as FunctypeBase, wn as ISO8601Date, wt as TryKind, x as tryCatch, xn as BoundedNumber, xt as Kind, y as isLeft, yn as isCompanion, yt as EitherKind, z as createSerializer, zn as AsyncMonad, zt as ErrorFormatterOptions } from "./index-B6Civ4kr.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-C4maYbiO.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, Do, DoAsync, DoGenerator, DoResult, Doable, ESMap, ESMapType, Either, EitherKind, EmailAddress, EmptyListError, Err, ErrorChainElement, ErrorCode, ErrorContext, ErrorFormatterOptions, ErrorMessage, ErrorStatus, ErrorWithTaskInfo, Exit, Exit as ExitType, ExitTag, ExtractBrand, ExtractTag, Extractable, FPromise, FPromiseCompanion, FailureError, FailureErrorType, FieldValidation, Foldable, FoldableUtils, FormValidation, Functor, Functype, FunctypeBase, FunctypeCollection, HKT, HasService, IO, IO as IOType, Task as IOTask, ISO8601Date, Identity, InstanceType, IntegerNumber, InterruptedError, Kind, Layer, Layer as LayerType, LayerError, LayerInput, LayerOutput, Lazy, Lazy as LazyType, LazyList, Left, LeftError, LeftErrorType, List, ListKind, Map, Match, Matchable, MatchableUtils, Monad, NAME, NonEmptyString, NonNegativeNumber, None, NoneError, Ok, Option, OptionConstructor, OptionKind, ParseError, PatternString, Pipe, PositiveInteger, PositiveNumber, Promisable, RIO, Ref, Ref as RefType, Right, SafeTraversable, 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, Unwrap, UrlString, ValidatedBrand, ValidatedBrand as ValidatedBrandType, ValidatedBrandCompanion, Validation, ValidationRule, Validator, Valuable, ValuableParams, createBrander, createCancellationTokenSource, createCustomSerializer, createErrorSerializer, createSerializationCompanion, createSerializer, formatError, formatStackTrace, fromBinary, fromJSON, fromYAML, hasBrand, isCompanion, isDoCapable, isExtractable, isLeft, isRight, isTaggedThrowable, isTypeable, safeStringify, tryCatch, tryCatchAsync, unwrap, unwrapBrand };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,i as t,n,o as r,r as i,s as a,t as o}from"./Brand-Cfr5zy8F.js";import{n as s,t as c}from"./Tuple-CgX4p79w.js";import{$ as l,A as u,At as d,B as f,C as p,Ct as m,D as h,Dt as g,E as _,Et as v,F as y,G as b,H as x,I as S,J as C,K as w,L as T,M as E,Mt as D,N as O,Nt as k,O as A,Ot as j,P as M,Pt as N,Q as P,R as F,S as I,St as L,T as R,Tt as z,U as B,V,W as H,X as U,Y as W,Z as G,_ as K,_t as q,a as J,at as Y,b as X,bt as Z,c as Q,ct as $,d as ee,dt as te,et as ne,f as re,ft as ie,g as ae,gt as oe,h as se,ht as ce,i as le,it as ue,j as de,jt as fe,k as pe,kt as me,l as he,lt as ge,m as _e,mt as ve,n as ye,nt as be,o as xe,ot as Se,p as Ce,pt as we,q as Te,r as Ee,rt as De,s as Oe,st as ke,t as Ae,tt as je,u as Me,ut as Ne,v as Pe,vt as Fe,w as Ie,wt as Le,x as Re,xt as ze,y as Be,yt as Ve,z as He}from"./src-
|
|
1
|
+
import{a as e,i as t,n,o as r,r as i,s as a,t as o}from"./Brand-Cfr5zy8F.js";import{n as s,t as c}from"./Tuple-CgX4p79w.js";import{$ as l,A as u,At as d,B as f,C as p,Ct as m,D as h,Dt as g,E as _,Et as v,F as y,G as b,H as x,I as S,J as C,K as w,L as T,M as E,Mt as D,N as O,Nt as k,O as A,Ot as j,P as M,Pt as N,Q as P,R as F,S as I,St as L,T as R,Tt as z,U as B,V,W as H,X as U,Y as W,Z as G,_ as K,_t as q,a as J,at as Y,b as X,bt as Z,c as Q,ct as $,d as ee,dt as te,et as ne,f as re,ft as ie,g as ae,gt as oe,h as se,ht as ce,i as le,it as ue,j as de,jt as fe,k as pe,kt as me,l as he,lt as ge,m as _e,mt as ve,n as ye,nt as be,o as xe,ot as Se,p as Ce,pt as we,q as Te,r as Ee,rt as De,s as Oe,st as ke,t as Ae,tt as je,u as Me,ut as Ne,v as Pe,vt as Fe,w as Ie,wt as Le,x as Re,xt as ze,y as Be,yt as Ve,z as He}from"./src-DpfaJv6K.js";export{A as $,w as Base,U as BoundedNumber,G as BoundedString,o as Brand,n as BrandedBoolean,i as BrandedNumber,t as BrandedString,s as Companion,C as Cond,ae as Context,pe as Do,u as DoAsync,J as ESMap,ge as Either,P as EmailAddress,de as EmptyListError,T as Err,se as Exit,x as FPromise,B as FPromiseCompanion,E as FailureError,Be as FoldableUtils,Pe as HKT,re as IO,l as ISO8601Date,K as Identity,ne as IntegerNumber,Ce as InterruptedError,ee as Layer,xe as Lazy,L as LazyList,Ne as Left,O as LeftError,Fe as List,le as Map,Te as Match,Ee as MatchableUtils,H as NAME,je as NonEmptyString,be as NonNegativeNumber,z as None,M as NoneError,F as Ok,v as Option,g as OptionConstructor,p as ParseError,De as PatternString,ue as PositiveInteger,Y as PositiveNumber,m as Ref,te as Right,Le as Set,j as Some,ye as Stack,Me as Tag,He as Task,Oe as TestClock,Q as TestClockTag,he as TestContext,b as Throwable,_e as TimeoutError,ze as Try,c as Tuple,ie as TypeCheckLeft,we as TypeCheckRight,Ve as Typeable,I as TypedError,Se as UUID,ke as UrlString,$ as ValidatedBrand,Re as Validation,Ae as Valuable,e as createBrander,f as createCancellationTokenSource,me as createCustomSerializer,Ie as createErrorSerializer,d as createSerializationCompanion,fe as createSerializer,R as formatError,_ as formatStackTrace,D as fromBinary,k as fromJSON,N as fromYAML,r as hasBrand,W as isCompanion,y as isDoCapable,X as isExtractable,ve as isLeft,ce as isRight,V as isTaggedThrowable,Z as isTypeable,h as safeStringify,oe as tryCatch,q as tryCatchAsync,S as unwrap,a as unwrapBrand};
|
package/dist/list/index.d.ts
CHANGED
package/dist/list/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../Brand-Cfr5zy8F.js";import"../Tuple-CgX4p79w.js";import{vt as e}from"../src-
|
|
1
|
+
import"../Brand-Cfr5zy8F.js";import"../Tuple-CgX4p79w.js";import{vt as e}from"../src-DpfaJv6K.js";export{e as List};
|
package/dist/map/index.d.ts
CHANGED
package/dist/map/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../Brand-Cfr5zy8F.js";import"../Tuple-CgX4p79w.js";import{i as e}from"../src-
|
|
1
|
+
import"../Brand-Cfr5zy8F.js";import"../Tuple-CgX4p79w.js";import{i as e}from"../src-DpfaJv6K.js";export{e as Map};
|
package/dist/option/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import "../Brand-BPeggBaO.js";
|
|
2
|
-
import { A as OptionConstructor, O as None, j as Some, k as Option } from "../index-
|
|
2
|
+
import { A as OptionConstructor, O as None, j as Some, k as Option } from "../index-B6Civ4kr.js";
|
|
3
3
|
import "../Tuple-C4maYbiO.js";
|
|
4
4
|
export { None, Option, OptionConstructor, Some };
|
package/dist/option/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../Brand-Cfr5zy8F.js";import"../Tuple-CgX4p79w.js";import{Dt as e,Et as t,Ot as n,Tt as r}from"../src-
|
|
1
|
+
import"../Brand-Cfr5zy8F.js";import"../Tuple-CgX4p79w.js";import{Dt as e,Et as t,Ot as n,Tt as r}from"../src-DpfaJv6K.js";export{r as None,t as Option,e as OptionConstructor,n as Some};
|
package/dist/set/index.d.ts
CHANGED
package/dist/set/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../Brand-Cfr5zy8F.js";import"../Tuple-CgX4p79w.js";import{wt as e}from"../src-
|
|
1
|
+
import"../Brand-Cfr5zy8F.js";import"../Tuple-CgX4p79w.js";import{wt as e}from"../src-DpfaJv6K.js";export{e as Set};
|
|
@@ -13,8 +13,7 @@ import{t as e}from"./Brand-Cfr5zy8F.js";import{n as t,t as n}from"./Tuple-CgX4p7
|
|
|
13
13
|
`);return[t[0],...t.slice(1).map(e=>e.trim())].join(`
|
|
14
14
|
`)}function mt(e,t){let n={...dt,...t},r=e instanceof Error?e:Ge.apply(e),i=j?.getErrorChain?j.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=pt(e.stack).split(`
|
|
15
15
|
`).slice(1),i=n.maxStackFrames??dt.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${ft(e)}`:`\n\nContext:\n${ft(e)}`;a+=t}}return a}function ht(){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?pt(t.stack):void 0};if(t.taskInfo&&(n.taskInfo=t.taskInfo),t.data&&(n.data=t.data),typeof j?.getErrorChain==`function`)try{let e=j.getErrorChain(t);e.length>1&&(n.errorChain=j.formatErrorChain(t,{includeTasks:!0}),n.structuredErrorChain=e.map(e=>({message:e.message,name:e.name,taskInfo:e.taskInfo,stack:e.stack?pt(e.stack):void 0})))}catch{}return Object.getOwnPropertyNames(t).forEach(e=>{n[e]||(n[e]=t[e])}),n}}const gt=e=>{let t=Error(e);return t.name=`ParseError`,t},M=(e,t,n,r)=>{let i=Ge.apply(t,n,{name:e,description:t});return Object.assign(i,{code:e,message:t,status:_t(e),context:n,timestamp:new Date().toISOString(),traceId:r?.traceId})},_t=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],N=Object.assign(M,{validation:(e,t,n)=>M(`VALIDATION_FAILED`,`Validation failed: ${e} ${n}`,{field:e,value:t,rule:n}),network:(e,t,n)=>M(`NETWORK_ERROR`,`Network error: ${t} ${e}${n?` (${n})`:``}`,{url:e,method:t,statusCode:n}),auth:(e,t)=>M(`AUTH_REQUIRED`,`Authentication required: ${e}${t?` (role: ${t})`:``}`,{resource:e,requiredRole:t}),notFound:(e,t)=>M(`NOT_FOUND`,`Not found: ${e} with id ${t}`,{resource:e,id:t}),permission:(e,t,n)=>M(`PERMISSION_DENIED`,`Permission denied: cannot ${e} ${t}`,{action:e,resource:t,userId:n}),rateLimit:(e,t,n)=>M(`RATE_LIMITED`,`Rate limit exceeded: ${e} requests per ${t}`,{limit:e,window:t,retryAfter:n}),internal:e=>M(`INTERNAL_ERROR`,`Internal server error: ${e}`,{errorId:e,timestamp:new Date().toISOString()}),badRequest:(e,t)=>M(`BAD_REQUEST`,`Bad request: ${e}`,{reason:e,expected:t}),conflict:(e,t)=>M(`CONFLICT`,`Conflict: ${e} already exists with value ${t}`,{resource:e,conflictingValue:t}),timeout:(e,t)=>M(`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}),P={rule:e=>t=>{if(e===`email`)return typeof t!=`string`||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)?w(N.validation(`value`,t,`must be a valid email`)):C(t);if(e===`url`)try{return new URL(String(t)),C(t)}catch{return w(N.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)?w(N.validation(`value`,t,`must be a valid UUID`)):C(t);if(e===`required`)return t==null||t===``?w(N.validation(`value`,t,`is required`)):C(t);if(e===`numeric`)return typeof t!=`number`&&!/^\d+$/.test(String(t))?w(N.validation(`value`,t,`must be numeric`)):C(t);if(e===`alpha`)return typeof t!=`string`||!/^[a-zA-Z]+$/.test(t)?w(N.validation(`value`,t,`must contain only letters`)):C(t);if(e===`alphanumeric`)return typeof t!=`string`||!/^[a-zA-Z0-9]+$/.test(t)?w(N.validation(`value`,t,`must be alphanumeric`)):C(t);if(e.startsWith(`min:`)){let n=Number(e.split(`:`)[1]),r=Number(t);return isNaN(r)||r<n?w(N.validation(`value`,t,`must be at least ${n}`)):C(t)}if(e.startsWith(`max:`)){let n=Number(e.split(`:`)[1]),r=Number(t);return isNaN(r)||r>n?w(N.validation(`value`,t,`must be at most ${n}`)):C(t)}if(e.startsWith(`minLength:`)){let n=Number(e.split(`:`)[1]);return String(t).length<n?w(N.validation(`value`,t,`must be at least ${n} characters`)):C(t)}if(e.startsWith(`maxLength:`)){let n=Number(e.split(`:`)[1]);return String(t).length>n?w(N.validation(`value`,t,`must be at most ${n} characters`)):C(t)}if(e.startsWith(`pattern:`)){let n=e.substring(8);return new RegExp(n).test(String(t))?C(t):w(N.validation(`value`,t,`must match pattern ${n}`))}if(e.startsWith(`in:`)){let n=e.substring(3).split(`,`);return n.includes(String(t))?C(t):w(N.validation(`value`,t,`must be one of: ${n.join(`, `)}`))}if(e.startsWith(`notIn:`)){let n=e.substring(6).split(`,`);return n.includes(String(t))?w(N.validation(`value`,t,`must not be one of: ${n.join(`, `)}`)):C(t)}if(e===`date`){let e=new Date(String(t));return isNaN(e.getTime())?w(N.validation(`value`,t,`must be a valid date`)):C(t)}if(e===`future`){let e=new Date(String(t));return isNaN(e.getTime())||e<=new Date?w(N.validation(`value`,t,`must be a future date`)):C(t)}if(e===`past`){let e=new Date(String(t));return isNaN(e.getTime())||e>=new Date?w(N.validation(`value`,t,`must be a past date`)):C(t)}return C(t)},combine:(...e)=>t=>{for(let n of e){let e=n(t);if(e.isLeft())return e}return C(t)},custom:(e,t)=>n=>e(n)?C(n):w(N.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=N.validation(i,e,t.context.rule);n.push(r)}else r[i]=o.orThrow()}return n.length>0?w(S(n)):C(r)}},vt={...P,validators:{email:P.rule(`email`),url:P.rule(`url`),uuid:P.rule(`uuid`),required:P.rule(`required`),numeric:P.rule(`numeric`),positiveNumber:P.combine(P.rule(`numeric`),P.rule(`min:0`)),nonEmptyString:P.combine(P.rule(`required`),P.custom(e=>typeof e==`string`&&e.trim().length>0,`must not be empty`))}},yt=Object.assign(P.rule,vt);function bt(e){return typeof e==`object`&&!!e&&`orThrow`in e&&typeof e.orThrow==`function`}function xt(e){return bt(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 St={toOption:e=>e.fold(()=>f(),e=>u(e)),toList:e=>e.fold(()=>S([]),e=>S([e])),toEither:(e,t)=>e.fold(()=>w(t),e=>C(e)),isEmpty:e=>e.fold(()=>!0,()=>!1),size:e=>e.fold(()=>0,()=>1)},F=e=>typeof e==`object`&&!!e&&(e._tag===`Some`||e._tag===`None`),I=e=>typeof e==`object`&&!!e&&e._tag===`List`,Ct=e=>typeof e==`object`&&!!e&&(e._tag===`Left`||e._tag===`Right`),wt=e=>typeof e==`object`&&!!e&&(e._tag===`Success`||e._tag===`Failure`),L=()=>{let e=(e,t)=>{if(F(e)||I(e)||Ct(e)||wt(e))return e.map(e=>t(e));throw Error(`Unsupported functor type: ${JSON.stringify(e)}`)},t=e=>{if(F(e))return e.orThrow();if(I(e)){let t=e.toArray();if(t.length>0&&I(t[0])){let e=[];for(let n of t)I(n)&&e.push(...n.toArray());return S(e)}return e.flatten()}if(Ct(e))return e.isRight()?e.fold(()=>null,e=>e):e;if(wt(e))return e.isSuccess()?e.orThrow():e;throw Error(`Unsupported functor type for flatten: ${JSON.stringify(e)}`)},n=(e,t)=>{if(F(e)||I(e)||Ct(e)||wt(e))return e.flatMap(e=>t(e));throw Error(`Unsupported functor type for flatMap: ${JSON.stringify(e)}`)},r=(e,t)=>{if(F(e)&&F(t)||I(e)&&I(t)||Ct(e)&&Ct(t)||wt(e)&&wt(t))return e.flatMap(e=>t.map(t=>e(t)));throw Error(`Unsupported functor type for ap: ${JSON.stringify(e)}`)},i=e=>{if(F(e)){let t=e;if(t.isEmpty)return S([p.none()]);let n=t.orThrow();if(I(n))return n.map(e=>p(e));throw Error(`Unsupported inner container type for sequence`)}if(I(e)){let t=e.toArray();if(t.length===0)return p.none();let n=t[0];if(F(n)){for(let e of t)if(e.isEmpty)return p.none();return p(S(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`}},Tt=L();L.map=(e,t)=>Tt.map(e,t),L.flatten=e=>Tt.flatten(e),L.flatMap=(e,t)=>Tt.flatMap(e,t),L.ap=(e,t)=>Tt.ap(e,t),L.sequence=e=>Tt.sequence(e),L.traverse=(e,t)=>Tt.traverse(e,t),L.isOption=F,L.isList=I,L.isEither=Ct,L.isTry=wt;const Et=e=>({id:e,isSame:t=>t.id===e}),Dt=t(Et,{of:e=>Et(e),pure:e=>Et(e)}),Ot=e=>({_tag:`Context`,services:e,get(t){let n=e.get(t.id);return n===void 0?f():u(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),Ot(r)},merge(t){let n=new Map(e);for(let[e,r]of t.services)n.set(e,r);return Ot(n)},get size(){return e.size},toString(){return`Context(${Array.from(e.keys()).join(`, `)})`}}),R={empty:()=>Ot(new Map),make:(e,t)=>{let n=new Map;return n.set(e.id,t),Ot(n)},isContext:e=>typeof e==`object`&&!!e&&e._tag===`Context`},z=e=>({_tag:`Success`,isSuccess(){return!0},isFailure(){return!1},isInterrupted(){return!1},map(t){return z(t(e))},mapError(t){return z(e)},mapBoth(t,n){return z(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 u(e)},toEither(){return C(e)},toValue(){return{_tag:`Success`,value:e}},toString(){return`Exit.Success(${r(e)})`},toJSON(){return{_tag:`Success`,value:e}}}),B=e=>({_tag:`Failure`,isSuccess(){return!1},isFailure(){return!0},isInterrupted(){return!1},map(t){return B(e)},mapError(t){return B(t(e))},mapBoth(t,n){return B(t(e))},flatMap(t){return B(e)},fold(t,n,r){return t(e)},match(t){return t.Failure(e)},orThrow(){throw e},orElse(e){return e},toOption(){return f()},toEither(){return w(e)},toValue(){return{_tag:`Failure`,error:e}},toString(){return`Exit.Failure(${r(e)})`},toJSON(){return{_tag:`Failure`,error:e}}}),kt=e=>({_tag:`Interrupted`,isSuccess(){return!1},isFailure(){return!1},isInterrupted(){return!0},map(t){return kt(e)},mapError(t){return kt(e)},mapBoth(t,n){return kt(e)},flatMap(t){return kt(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 f()},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}}}),V=t(e=>z(e),{succeed:e=>z(e),fail:e=>B(e),interrupt:e=>kt(e),interrupted:()=>kt(`interrupted`),isSuccess:e=>e.isSuccess(),isFailure:e=>e.isFailure(),isInterrupted:e=>e.isInterrupted(),fromEither:e=>e.isRight()?z(e.value):B(e.value),fromOption:(e,t)=>e.isSome()?z(e.value):B(t()),zip:(e,t)=>e.isInterrupted()?e:t.isInterrupted()?t:e.isFailure()?e:t.isFailure()?t:z([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 z(t)}}),H=e=>e;var At=class extends Error{constructor(e,t){super(t??`Effect timed out after ${e}ms`),this.duration=e,this._tag=`TimeoutError`,this.name=`TimeoutError`}},jt=class extends Error{constructor(e){super(e??`Effect was interrupted`),this._tag=`InterruptedError`,this.name=`InterruptedError`}};const U=e=>{let t={_effect:e,map(e){return U(H({_tag:`Map`,effect:t,f:e}))},flatMap(e){return U(H({_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 U(H({_tag:`MapError`,effect:t,f:e}))},recover(e){return U(H({_tag:`Recover`,effect:t,fallback:e}))},recoverWith(e){return U(H({_tag:`RecoverWith`,effect:t,f:e}))},fold(e,n){return U(H({_tag:`Fold`,effect:t,onFailure:e,onSuccess:n}))},match(e){return t.fold(e.failure,e.success)},catchTag(e,n){return U(H({_tag:`RecoverWith`,effect:t,f:t=>typeof t==`object`&&t&&`_tag`in t&&t._tag===e?H(n(t)):H(K.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(()=>K.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 U(H({_tag:`ProvideContext`,effect:t,context:e}))},provideService(e,n){return U(H({_tag:`ProvideContext`,effect:t,context:R.make(e,n)}))},provideLayer(e){return H(H(K.async(async()=>{let t=R.empty();return await e.build(H(t))})).flatMap(e=>U(H({_tag:`ProvideContext`,effect:t,context:e}))))},async run(){let e=await G(this._effect);if(e.isSuccess())return e.orThrow();throw e.isFailure()?e.toValue().error:Error(`Effect was interrupted`)},runSync(){return W(this._effect)},async runEither(){let e=await G(this._effect);if(e.isSuccess())return C(e.orThrow());if(e.isFailure())return w(e.toValue().error);throw Error(`Effect was interrupted`)},async runExit(){return G(this._effect)},async runOption(){let e=await G(this._effect);return e.isSuccess()?u(e.orThrow()):f()},async runTry(){let e=await G(this._effect);if(e.isSuccess())return H(b(()=>e.orThrow()));let t=e.isFailure()?e.toValue().error:Error(`Effect was interrupted`);return H(b(()=>{throw t}))},pipe(e){return e(t)},delay(e){return H(K.async(()=>new Promise(t=>setTimeout(t,e))).flatMap(()=>t))},timeout(e){return U(H({_tag:`Timeout`,effect:t,duration:e}))},timeoutTo(e,n){return H(t.timeout(e).recover(H(n)))},toString(){return`IO(${r(e._tag)})`},toJSON(){return{_tag:`IO`,effect:e._tag}},*[Symbol.iterator](){return yield t}};return t},W=(e,t=R.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=W(e.effect._effect,t);return e.f(n)}case`FlatMap`:{let n=W(e.effect._effect,t);return W(e.f(n)._effect,t)}case`MapError`:try{return W(e.effect._effect,t)}catch(t){throw e.f(t)}case`Recover`:try{return W(e.effect._effect,t)}catch{return e.fallback}case`RecoverWith`:try{return W(e.effect._effect,t)}catch(n){return W(e.f(n)._effect,t)}case`Fold`:try{let n=W(e.effect._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 W(e.effect._effect,n)}case`Interrupt`:throw new jt;case`Bracket`:{let n=W(e.acquire._effect,t);try{return W(e.use(n)._effect,t)}finally{W(e.release(n)._effect,t)}}case`Race`:throw Error(`Cannot run race effect synchronously`);case`Timeout`:throw Error(`Cannot run timeout effect synchronously`)}},G=async(e,t=R.empty())=>{try{switch(e._tag){case`Succeed`:return H(V.succeed(e.value));case`Fail`:return H(V.fail(e.error));case`Die`:throw e.defect;case`Sync`:return H(V.succeed(e.thunk()));case`Async`:{let t=await e.thunk();return H(V.succeed(t))}case`Auto`:{let t=e.thunk();return t instanceof Promise?H(V.succeed(await t)):H(V.succeed(t))}case`Map`:{let n=await G(e.effect._effect,t);return n.isSuccess()?H(V.succeed(e.f(n.orThrow()))):H(n)}case`FlatMap`:{let n=await G(e.effect._effect,t);return n.isSuccess()?G(e.f(n.orThrow())._effect,t):H(n)}case`MapError`:{let n=await G(e.effect._effect,t);return n.isSuccess()?H(n):n.isFailure()?H(V.fail(e.f(n.toValue().error))):H(n)}case`Recover`:{let n=await G(e.effect._effect,t);return n.isSuccess()?n:V.succeed(e.fallback)}case`RecoverWith`:{let n=await G(e.effect._effect,t);return n.isSuccess()?n:n.isFailure()?G(e.f(n.toValue().error)._effect,t):n}case`Fold`:{let n=await G(e.effect._effect,t);return n.isSuccess()?V.succeed(e.onSuccess(n.orThrow())):n.isFailure()?V.succeed(e.onFailure(n.toValue().error)):n}case`Service`:{let n=t.get(e.tag);return n.isNone()?V.fail(Error(`Service not found: ${e.tag.id}`)):V.succeed(n.orThrow())}case`ProvideContext`:{let n=t.merge(e.context);return G(e.effect._effect,n)}case`Interrupt`:return V.interrupted();case`Bracket`:{let n=await G(e.acquire._effect,t);if(!n.isSuccess())return n;let r=n.orThrow();try{return await G(e.use(r)._effect,t)}finally{await G(e.release(r)._effect,t)}}case`Race`:return e.effects.length===0?V.fail(Error(`No effects to race`)):await Promise.race(e.effects.map(e=>G(e._effect,t)));case`Timeout`:{let n=new Promise(t=>setTimeout(()=>t(V.fail(new At(e.duration))),e.duration)),r=G(e.effect._effect,t);return Promise.race([r,n])}}}catch(e){return V.fail(e)}},K={sync:e=>U({_tag:`Sync`,thunk:e}),succeed:e=>U({_tag:`Succeed`,value:e}),fail:e=>U({_tag:`Fail`,error:e}),die:e=>U({_tag:`Die`,defect:e}),async:e=>U(H({_tag:`Async`,thunk:e})),tryPromise:e=>U({_tag:`Async`,thunk:e.try}).mapError(e.catch),tryCatch:(e,t)=>K.sync(()=>{try{return e()}catch(e){throw t(e)}}),liftSync:e=>(...t)=>K.sync(()=>e(...t)),liftPromise:e=>(...t)=>K.async(()=>e(...t)),fromEither:e=>H(e.isRight()?K.succeed(e.value):K.fail(e.value)),fromOption:e=>H(e.isSome()?K.succeed(e.value):K.fail(void 0)),fromOptionOrFail:(e,t)=>H(e.isSome()?K.succeed(e.value):K.fail(t())),fromTry:e=>H(e.isSuccess()?K.succeed(e.orThrow()):K.fail(e.error)),service:e=>U({_tag:`Service`,tag:e}),serviceWith:(e,t)=>K.service(e).map(t),serviceWithIO:(e,t)=>K.service(e).flatMap(t),withServices:(e,t)=>{let n=Object.entries(e);if(n.length===0)return H(U({_tag:`Auto`,thunk:()=>t({})}));let r=H(K.succeed({}));return H(n.reduce((e,[t,n])=>H(e.flatMap(e=>K.service(n).map(n=>({...e,[t]:n})))),r).flatMap(e=>U({_tag:`Auto`,thunk:()=>t(e)})))},all:e=>{if(e.length===0)return H(K.succeed([]));let t=H(K.succeed([]));return H(e.reduce((e,t)=>e.flatMap(e=>t.map(t=>[...e,t])),t))},firstSuccessOf:e=>e.length===0?H(K.fail(Error(`No effects provided`))):e.reduce((e,t)=>e.recoverWith(()=>t)),sleep:e=>H(K.async(()=>new Promise(t=>setTimeout(t,e)))),never:()=>H(K.async(()=>new Promise(()=>{}))),get unit(){return H(U({_tag:`Succeed`,value:void 0}))},fromNullable:e=>H(e==null?K.fail(void 0):K.succeed(e)),interrupt:()=>U({_tag:`Interrupt`}),bracket:(e,t,n)=>U({_tag:`Bracket`,acquire:e,use:t,release:n}),acquireRelease:(e,t,n)=>K.bracket(e,t,n),race:e=>U({_tag:`Race`,effects:e}),any:e=>e.length===0?H(K.fail(Error(`No effects provided`))):e.reduce((e,t)=>e.recoverWith(()=>t)),forEach:(e,t)=>{if(e.length===0)return H(K.succeed([]));let n=H(K.succeed([]));return H(e.reduce((e,n)=>e.flatMap(e=>t(n).map(t=>[...e,t])),n))},forEachPar:(e,t)=>K.forEach(e,t),timeout:(e,t)=>U(H({_tag:`Timeout`,effect:e,duration:t})),gen:e=>H(K.sync(()=>{let t=e(),n=e=>{let r=t.next(e);return r.done?H(K.succeed(r.value)):H(r.value.flatMap(e=>n(e)))};return n(void 0)}).flatMap(e=>e)),get Do(){return Mt(K.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}}),q=t(e=>U(H({_tag:`Auto`,thunk:e})),K),J=(e,t)=>({_tag:`Layer`,build:e,provideToAndMerge(t){return J(async n=>{let r=await e(n),i=n.merge(r),a=await t.build(i);return r.merge(a)})},merge(t){return J(async n=>{let[r,i]=await Promise.all([e(n),t.build(n)]);return r.merge(i)})},map(t){return J(async n=>t(await e(n)))},toString(){return`Layer(${t??`anonymous`})`}}),Nt={succeed:(e,t)=>J(()=>Promise.resolve(R.make(e,t)),e.id),effect:(e,t)=>J(async()=>{let n=await t();return R.make(e,n)},e.id),sync:(e,t)=>J(()=>Promise.resolve(R.make(e,t())),e.id),fromService:(e,t,n)=>J(r=>{let i=r.unsafeGet(t);return Promise.resolve(R.make(e,n(i)))},e.id),fromServiceEffect:(e,t,n)=>J(async r=>{let i=await n(r.unsafeGet(t));return R.make(e,i)},e.id),fromContext:e=>J(()=>Promise.resolve(e)),empty:()=>J(()=>Promise.resolve(R.empty()),`empty`),mergeAll:(...e)=>J(async t=>(await Promise.all(e.map(e=>e.build(t)))).reduce((e,t)=>e.merge(t),R.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})})}}},Y=Pt(`TestClock`),It={make:Ft,tag:Y,test:async e=>e(Ft()),get:q.service(Y),advance:e=>q.serviceWithIO(Y,t=>q.async(()=>t.advance(e))),setTime:e=>q.serviceWithIO(Y,t=>q.async(()=>t.setTime(e))),runAll:q.serviceWithIO(Y,e=>q.async(()=>e.runAll())),context:()=>{let e=Ft();return{clock:e,context:R.make(Y,e)}}},Lt={make:()=>{let e=Ft(),t=R.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).run()}};return n},withClock:()=>{let e=Ft();return Lt.make().withService(Y,e)}},X=e=>{let t=!1,n,i,a=!1,o=()=>{if(!t)try{n=e(),t=!0}catch(e){throw i=e,a=!0,t=!0,e}if(a)throw i;return n};return{_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=>Z(()=>{try{return o()}catch{return e.orThrow()}}),orUndefined:()=>{try{return o()}catch{return}},map:e=>Z(()=>e(o())),ap:e=>Z(()=>e.orThrow()(o())),mapAsync:async e=>{let t=await e(o());return Z(()=>t)},flatMap:e=>Z(()=>e(o()).orThrow()),flatMapAsync:async e=>{let t=await e(o());return Z(()=>t.orThrow())},filter:e=>Z(()=>{let t=o();return e(t)?u(t):f}),recover:e=>Z(()=>{try{return o()}catch(t){return e(t)}}),recoverWith:e=>Z(()=>{try{return o()}catch(t){return e(t).orThrow()}}),toOption:()=>{try{return u(o())}catch{return f}},toEither:()=>{try{return C(o())}catch(e){return w(e)}},toEitherWith:e=>{try{return C(o())}catch(t){return w(e(t))}},toTry:()=>b(()=>o()),tap:e=>Z(()=>{let t=o();return e(t),t}),tapError:e=>Z(()=>{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(${r(n)})`:t&&a?`Lazy(<error: ${i instanceof Error?i.message:String(i)}>)`:`Lazy(<not evaluated>)`,toValue:()=>t&&!a?{_tag:`Lazy`,evaluated:!0,value:n}:{_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())?1:0}catch{return 0}},find:e=>{try{let t=o();return e(t)?u(t):f}catch{return f}},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:n}:{_tag:`Lazy`,evaluated:!1}),toYAML:()=>t&&!a?`_tag: Lazy\nevaluated: true\nvalue: ${r(n)}`:`_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${ft(e)}`:`\n\nContext:\n${ft(e)}`;a+=t}}return a}function ht(){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?pt(t.stack):void 0};if(t.taskInfo&&(n.taskInfo=t.taskInfo),t.data&&(n.data=t.data),typeof j?.getErrorChain==`function`)try{let e=j.getErrorChain(t);e.length>1&&(n.errorChain=j.formatErrorChain(t,{includeTasks:!0}),n.structuredErrorChain=e.map(e=>({message:e.message,name:e.name,taskInfo:e.taskInfo,stack:e.stack?pt(e.stack):void 0})))}catch{}return Object.getOwnPropertyNames(t).forEach(e=>{n[e]||(n[e]=t[e])}),n}}const gt=e=>{let t=Error(e);return t.name=`ParseError`,t},M=(e,t,n,r)=>{let i=Ge.apply(t,n,{name:e,description:t});return Object.assign(i,{code:e,message:t,status:_t(e),context:n,timestamp:new Date().toISOString(),traceId:r?.traceId})},_t=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],N=Object.assign(M,{validation:(e,t,n)=>M(`VALIDATION_FAILED`,`Validation failed: ${e} ${n}`,{field:e,value:t,rule:n}),network:(e,t,n)=>M(`NETWORK_ERROR`,`Network error: ${t} ${e}${n?` (${n})`:``}`,{url:e,method:t,statusCode:n}),auth:(e,t)=>M(`AUTH_REQUIRED`,`Authentication required: ${e}${t?` (role: ${t})`:``}`,{resource:e,requiredRole:t}),notFound:(e,t)=>M(`NOT_FOUND`,`Not found: ${e} with id ${t}`,{resource:e,id:t}),permission:(e,t,n)=>M(`PERMISSION_DENIED`,`Permission denied: cannot ${e} ${t}`,{action:e,resource:t,userId:n}),rateLimit:(e,t,n)=>M(`RATE_LIMITED`,`Rate limit exceeded: ${e} requests per ${t}`,{limit:e,window:t,retryAfter:n}),internal:e=>M(`INTERNAL_ERROR`,`Internal server error: ${e}`,{errorId:e,timestamp:new Date().toISOString()}),badRequest:(e,t)=>M(`BAD_REQUEST`,`Bad request: ${e}`,{reason:e,expected:t}),conflict:(e,t)=>M(`CONFLICT`,`Conflict: ${e} already exists with value ${t}`,{resource:e,conflictingValue:t}),timeout:(e,t)=>M(`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}),P={rule:e=>t=>{if(e===`email`)return typeof t!=`string`||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)?w(N.validation(`value`,t,`must be a valid email`)):C(t);if(e===`url`)try{return new URL(String(t)),C(t)}catch{return w(N.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)?w(N.validation(`value`,t,`must be a valid UUID`)):C(t);if(e===`required`)return t==null||t===``?w(N.validation(`value`,t,`is required`)):C(t);if(e===`numeric`)return typeof t!=`number`&&!/^\d+$/.test(String(t))?w(N.validation(`value`,t,`must be numeric`)):C(t);if(e===`alpha`)return typeof t!=`string`||!/^[a-zA-Z]+$/.test(t)?w(N.validation(`value`,t,`must contain only letters`)):C(t);if(e===`alphanumeric`)return typeof t!=`string`||!/^[a-zA-Z0-9]+$/.test(t)?w(N.validation(`value`,t,`must be alphanumeric`)):C(t);if(e.startsWith(`min:`)){let n=Number(e.split(`:`)[1]),r=Number(t);return isNaN(r)||r<n?w(N.validation(`value`,t,`must be at least ${n}`)):C(t)}if(e.startsWith(`max:`)){let n=Number(e.split(`:`)[1]),r=Number(t);return isNaN(r)||r>n?w(N.validation(`value`,t,`must be at most ${n}`)):C(t)}if(e.startsWith(`minLength:`)){let n=Number(e.split(`:`)[1]);return String(t).length<n?w(N.validation(`value`,t,`must be at least ${n} characters`)):C(t)}if(e.startsWith(`maxLength:`)){let n=Number(e.split(`:`)[1]);return String(t).length>n?w(N.validation(`value`,t,`must be at most ${n} characters`)):C(t)}if(e.startsWith(`pattern:`)){let n=e.substring(8);return new RegExp(n).test(String(t))?C(t):w(N.validation(`value`,t,`must match pattern ${n}`))}if(e.startsWith(`in:`)){let n=e.substring(3).split(`,`);return n.includes(String(t))?C(t):w(N.validation(`value`,t,`must be one of: ${n.join(`, `)}`))}if(e.startsWith(`notIn:`)){let n=e.substring(6).split(`,`);return n.includes(String(t))?w(N.validation(`value`,t,`must not be one of: ${n.join(`, `)}`)):C(t)}if(e===`date`){let e=new Date(String(t));return isNaN(e.getTime())?w(N.validation(`value`,t,`must be a valid date`)):C(t)}if(e===`future`){let e=new Date(String(t));return isNaN(e.getTime())||e<=new Date?w(N.validation(`value`,t,`must be a future date`)):C(t)}if(e===`past`){let e=new Date(String(t));return isNaN(e.getTime())||e>=new Date?w(N.validation(`value`,t,`must be a past date`)):C(t)}return C(t)},combine:(...e)=>t=>{for(let n of e){let e=n(t);if(e.isLeft())return e}return C(t)},custom:(e,t)=>n=>e(n)?C(n):w(N.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=N.validation(i,e,t.context.rule);n.push(r)}else r[i]=o.orThrow()}return n.length>0?w(S(n)):C(r)}},vt={...P,validators:{email:P.rule(`email`),url:P.rule(`url`),uuid:P.rule(`uuid`),required:P.rule(`required`),numeric:P.rule(`numeric`),positiveNumber:P.combine(P.rule(`numeric`),P.rule(`min:0`)),nonEmptyString:P.combine(P.rule(`required`),P.custom(e=>typeof e==`string`&&e.trim().length>0,`must not be empty`))}},yt=Object.assign(P.rule,vt);function bt(e){return typeof e==`object`&&!!e&&`orThrow`in e&&typeof e.orThrow==`function`}function xt(e){return bt(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 St={toOption:e=>e.fold(()=>f(),e=>u(e)),toList:e=>e.fold(()=>S([]),e=>S([e])),toEither:(e,t)=>e.fold(()=>w(t),e=>C(e)),isEmpty:e=>e.fold(()=>!0,()=>!1),size:e=>e.fold(()=>0,()=>1)},F=e=>typeof e==`object`&&!!e&&(e._tag===`Some`||e._tag===`None`),I=e=>typeof e==`object`&&!!e&&e._tag===`List`,Ct=e=>typeof e==`object`&&!!e&&(e._tag===`Left`||e._tag===`Right`),wt=e=>typeof e==`object`&&!!e&&(e._tag===`Success`||e._tag===`Failure`),L=()=>{let e=(e,t)=>{if(F(e)||I(e)||Ct(e)||wt(e))return e.map(e=>t(e));throw Error(`Unsupported functor type: ${JSON.stringify(e)}`)},t=e=>{if(F(e))return e.orThrow();if(I(e)){let t=e.toArray();if(t.length>0&&I(t[0])){let e=[];for(let n of t)I(n)&&e.push(...n.toArray());return S(e)}return e.flatten()}if(Ct(e))return e.isRight()?e.fold(()=>null,e=>e):e;if(wt(e))return e.isSuccess()?e.orThrow():e;throw Error(`Unsupported functor type for flatten: ${JSON.stringify(e)}`)},n=(e,t)=>{if(F(e)||I(e)||Ct(e)||wt(e))return e.flatMap(e=>t(e));throw Error(`Unsupported functor type for flatMap: ${JSON.stringify(e)}`)},r=(e,t)=>{if(F(e)&&F(t)||I(e)&&I(t)||Ct(e)&&Ct(t)||wt(e)&&wt(t))return e.flatMap(e=>t.map(t=>e(t)));throw Error(`Unsupported functor type for ap: ${JSON.stringify(e)}`)},i=e=>{if(F(e)){let t=e;if(t.isEmpty)return S([p.none()]);let n=t.orThrow();if(I(n))return n.map(e=>p(e));throw Error(`Unsupported inner container type for sequence`)}if(I(e)){let t=e.toArray();if(t.length===0)return p.none();let n=t[0];if(F(n)){for(let e of t)if(e.isEmpty)return p.none();return p(S(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`}},Tt=L();L.map=(e,t)=>Tt.map(e,t),L.flatten=e=>Tt.flatten(e),L.flatMap=(e,t)=>Tt.flatMap(e,t),L.ap=(e,t)=>Tt.ap(e,t),L.sequence=e=>Tt.sequence(e),L.traverse=(e,t)=>Tt.traverse(e,t),L.isOption=F,L.isList=I,L.isEither=Ct,L.isTry=wt;const Et=e=>({id:e,isSame:t=>t.id===e}),Dt=t(Et,{of:e=>Et(e),pure:e=>Et(e)}),Ot=e=>({_tag:`Context`,services:e,get(t){let n=e.get(t.id);return n===void 0?f():u(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),Ot(r)},merge(t){let n=new Map(e);for(let[e,r]of t.services)n.set(e,r);return Ot(n)},get size(){return e.size},toString(){return`Context(${Array.from(e.keys()).join(`, `)})`}}),R={empty:()=>Ot(new Map),make:(e,t)=>{let n=new Map;return n.set(e.id,t),Ot(n)},isContext:e=>typeof e==`object`&&!!e&&e._tag===`Context`},z=e=>({_tag:`Success`,isSuccess(){return!0},isFailure(){return!1},isInterrupted(){return!1},map(t){return z(t(e))},mapError(t){return z(e)},mapBoth(t,n){return z(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 u(e)},toEither(){return C(e)},toValue(){return{_tag:`Success`,value:e}},toString(){return`Exit.Success(${r(e)})`},toJSON(){return{_tag:`Success`,value:e}}}),B=e=>({_tag:`Failure`,isSuccess(){return!1},isFailure(){return!0},isInterrupted(){return!1},map(t){return B(e)},mapError(t){return B(t(e))},mapBoth(t,n){return B(t(e))},flatMap(t){return B(e)},fold(t,n,r){return t(e)},match(t){return t.Failure(e)},orThrow(){throw e},orElse(e){return e},toOption(){return f()},toEither(){return w(e)},toValue(){return{_tag:`Failure`,error:e}},toString(){return`Exit.Failure(${r(e)})`},toJSON(){return{_tag:`Failure`,error:e}}}),kt=e=>({_tag:`Interrupted`,isSuccess(){return!1},isFailure(){return!1},isInterrupted(){return!0},map(t){return kt(e)},mapError(t){return kt(e)},mapBoth(t,n){return kt(e)},flatMap(t){return kt(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 f()},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}}}),V=t(e=>z(e),{succeed:e=>z(e),fail:e=>B(e),interrupt:e=>kt(e),interrupted:()=>kt(`interrupted`),isSuccess:e=>e.isSuccess(),isFailure:e=>e.isFailure(),isInterrupted:e=>e.isInterrupted(),fromEither:e=>e.isRight()?z(e.value):B(e.value),fromOption:(e,t)=>e.isSome()?z(e.value):B(t()),zip:(e,t)=>e.isInterrupted()?e:t.isInterrupted()?t:e.isFailure()?e:t.isFailure()?t:z([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 z(t)}}),H=e=>e;var At=class extends Error{constructor(e,t){super(t??`Effect timed out after ${e}ms`),this.duration=e,this._tag=`TimeoutError`,this.name=`TimeoutError`}},jt=class extends Error{constructor(e){super(e??`Effect was interrupted`),this._tag=`InterruptedError`,this.name=`InterruptedError`}};const U=e=>{let t={_effect:e,map(e){return U(H({_tag:`Map`,effect:t,f:e}))},flatMap(e){return U(H({_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 U(H({_tag:`MapError`,effect:t,f:e}))},tapError(e){return t.mapError(t=>(e(t),t))},recover(e){return U(H({_tag:`Recover`,effect:t,fallback:e}))},recoverWith(e){return U(H({_tag:`RecoverWith`,effect:t,f:e}))},fold(e,n){return U(H({_tag:`Fold`,effect:t,onFailure:e,onSuccess:n}))},match(e){return t.fold(e.failure,e.success)},catchTag(e,n){return U(H({_tag:`RecoverWith`,effect:t,f:t=>typeof t==`object`&&t&&`_tag`in t&&t._tag===e?H(n(t)):H(K.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(()=>K.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 U(H({_tag:`ProvideContext`,effect:t,context:e}))},provideService(e,n){return U(H({_tag:`ProvideContext`,effect:t,context:R.make(e,n)}))},provideLayer(e){return H(H(K.async(async()=>{let t=R.empty();return await e.build(H(t))})).flatMap(e=>U(H({_tag:`ProvideContext`,effect:t,context:e}))))},async run(){let e=await G(this._effect);return e.isSuccess()?C(e.orThrow()):w(e.isFailure()?e.toValue().error:new jt)},async runOrThrow(){let e=await G(this._effect);if(e.isSuccess())return e.orThrow();throw e.isFailure()?e.toValue().error:new jt},runSync(){try{return C(W(this._effect))}catch(e){return w(e)}},runSyncOrThrow(){return W(this._effect)},async runExit(){return G(this._effect)},async runOption(){let e=await G(this._effect);return e.isSuccess()?u(e.orThrow()):f()},async runTry(){let e=await G(this._effect);if(e.isSuccess())return H(b(()=>e.orThrow()));let t=e.isFailure()?e.toValue().error:Error(`Effect was interrupted`);return H(b(()=>{throw t}))},pipe(e){return e(t)},delay(e){return H(K.async(()=>new Promise(t=>setTimeout(t,e))).flatMap(()=>t))},timeout(e){return U(H({_tag:`Timeout`,effect:t,duration:e}))},timeoutTo(e,n){return H(t.timeout(e).recover(H(n)))},toString(){return`IO(${r(e._tag)})`},toJSON(){return{_tag:`IO`,effect:e._tag}},*[Symbol.iterator](){return yield t}};return t},W=(e,t=R.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=W(e.effect._effect,t);return e.f(n)}case`FlatMap`:{let n=W(e.effect._effect,t);return W(e.f(n)._effect,t)}case`MapError`:try{return W(e.effect._effect,t)}catch(t){throw e.f(t)}case`Recover`:try{return W(e.effect._effect,t)}catch{return e.fallback}case`RecoverWith`:try{return W(e.effect._effect,t)}catch(n){return W(e.f(n)._effect,t)}case`Fold`:try{let n=W(e.effect._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 W(e.effect._effect,n)}case`Interrupt`:throw new jt;case`Bracket`:{let n=W(e.acquire._effect,t);try{return W(e.use(n)._effect,t)}finally{W(e.release(n)._effect,t)}}case`Race`:throw Error(`Cannot run race effect synchronously`);case`Timeout`:throw Error(`Cannot run timeout effect synchronously`)}},G=async(e,t=R.empty())=>{try{switch(e._tag){case`Succeed`:return H(V.succeed(e.value));case`Fail`:return H(V.fail(e.error));case`Die`:throw e.defect;case`Sync`:return H(V.succeed(e.thunk()));case`Async`:{let t=await e.thunk();return H(V.succeed(t))}case`Auto`:{let t=e.thunk();return t instanceof Promise?H(V.succeed(await t)):H(V.succeed(t))}case`Map`:{let n=await G(e.effect._effect,t);return n.isSuccess()?H(V.succeed(e.f(n.orThrow()))):H(n)}case`FlatMap`:{let n=await G(e.effect._effect,t);return n.isSuccess()?G(e.f(n.orThrow())._effect,t):H(n)}case`MapError`:{let n=await G(e.effect._effect,t);return n.isSuccess()?H(n):n.isFailure()?H(V.fail(e.f(n.toValue().error))):H(n)}case`Recover`:{let n=await G(e.effect._effect,t);return n.isSuccess()?n:V.succeed(e.fallback)}case`RecoverWith`:{let n=await G(e.effect._effect,t);return n.isSuccess()?n:n.isFailure()?G(e.f(n.toValue().error)._effect,t):n}case`Fold`:{let n=await G(e.effect._effect,t);return n.isSuccess()?V.succeed(e.onSuccess(n.orThrow())):n.isFailure()?V.succeed(e.onFailure(n.toValue().error)):n}case`Service`:{let n=t.get(e.tag);return n.isNone()?V.fail(Error(`Service not found: ${e.tag.id}`)):V.succeed(n.orThrow())}case`ProvideContext`:{let n=t.merge(e.context);return G(e.effect._effect,n)}case`Interrupt`:return V.interrupted();case`Bracket`:{let n=await G(e.acquire._effect,t);if(!n.isSuccess())return n;let r=n.orThrow();try{return await G(e.use(r)._effect,t)}finally{await G(e.release(r)._effect,t)}}case`Race`:return e.effects.length===0?V.fail(Error(`No effects to race`)):await Promise.race(e.effects.map(e=>G(e._effect,t)));case`Timeout`:{let n=new Promise(t=>setTimeout(()=>t(V.fail(new At(e.duration))),e.duration)),r=G(e.effect._effect,t);return Promise.race([r,n])}}}catch(e){return V.fail(e)}},K={sync:e=>U({_tag:`Sync`,thunk:e}),succeed:e=>U({_tag:`Succeed`,value:e}),fail:e=>U({_tag:`Fail`,error:e}),die:e=>U({_tag:`Die`,defect:e}),async:e=>U(H({_tag:`Async`,thunk:e})),tryPromise:e=>U({_tag:`Async`,thunk:e.try}).mapError(e.catch),tryCatch:(e,t)=>K.sync(()=>{try{return e()}catch(e){throw t(e)}}),liftSync:e=>(...t)=>K.sync(()=>e(...t)),liftPromise:e=>(...t)=>K.async(()=>e(...t)),fromEither:e=>H(e.isRight()?K.succeed(e.value):K.fail(e.value)),fromOption:e=>H(e.isSome()?K.succeed(e.value):K.fail(void 0)),fromOptionOrFail:(e,t)=>H(e.isSome()?K.succeed(e.value):K.fail(t())),fromTry:e=>H(e.isSuccess()?K.succeed(e.orThrow()):K.fail(e.error)),fromResult:e=>H(e.error?K.fail(e.error):K.succeed(p(e.data))),tryAsync:(e,t,n)=>n?.aborted?H(K.fail(t(n.reason??new DOMException(`Aborted`,`AbortError`)))):K.async(()=>e(n)).mapError(t),asyncResult:(e,t,n)=>{let r=n?.dataKey??`data`,i=n?.errorKey??`error`;return K.tryAsync(t=>e(t),t,n?.signal).flatMap(e=>K.fromResult({data:e[r],error:e[i]}))},service:e=>U({_tag:`Service`,tag:e}),serviceWith:(e,t)=>K.service(e).map(t),serviceWithIO:(e,t)=>K.service(e).flatMap(t),withServices:(e,t)=>{let n=Object.entries(e);if(n.length===0)return H(U({_tag:`Auto`,thunk:()=>t({})}));let r=H(K.succeed({}));return H(n.reduce((e,[t,n])=>H(e.flatMap(e=>K.service(n).map(n=>({...e,[t]:n})))),r).flatMap(e=>U({_tag:`Auto`,thunk:()=>t(e)})))},all:e=>{if(e.length===0)return H(K.succeed([]));let t=H(K.succeed([]));return H(e.reduce((e,t)=>e.flatMap(e=>t.map(t=>[...e,t])),t))},firstSuccessOf:e=>e.length===0?H(K.fail(Error(`No effects provided`))):e.reduce((e,t)=>e.recoverWith(()=>t)),sleep:e=>H(K.async(()=>new Promise(t=>setTimeout(t,e)))),never:()=>H(K.async(()=>new Promise(()=>{}))),get unit(){return H(U({_tag:`Succeed`,value:void 0}))},fromNullable:e=>H(e==null?K.fail(void 0):K.succeed(e)),interrupt:()=>U({_tag:`Interrupt`}),bracket:(e,t,n)=>U({_tag:`Bracket`,acquire:e,use:t,release:n}),acquireRelease:(e,t,n)=>K.bracket(e,t,n),race:e=>U({_tag:`Race`,effects:e}),any:e=>e.length===0?H(K.fail(Error(`No effects provided`))):e.reduce((e,t)=>e.recoverWith(()=>t)),forEach:(e,t)=>{if(e.length===0)return H(K.succeed([]));let n=H(K.succeed([]));return H(e.reduce((e,n)=>e.flatMap(e=>t(n).map(t=>[...e,t])),n))},forEachPar:(e,t)=>K.forEach(e,t),timeout:(e,t)=>U(H({_tag:`Timeout`,effect:e,duration:t})),gen:e=>H(K.sync(()=>{let t=e(),n=e=>{let r=t.next(e);return r.done?H(K.succeed(r.value)):H(r.value.flatMap(e=>n(e)))};return n(void 0)}).flatMap(e=>e)),get Do(){return Mt(K.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}}),q=t(e=>U(H({_tag:`Auto`,thunk:e})),K),J=(e,t)=>({_tag:`Layer`,build:e,provideToAndMerge(t){return J(async n=>{let r=await e(n),i=n.merge(r),a=await t.build(i);return r.merge(a)})},merge(t){return J(async n=>{let[r,i]=await Promise.all([e(n),t.build(n)]);return r.merge(i)})},map(t){return J(async n=>t(await e(n)))},toString(){return`Layer(${t??`anonymous`})`}}),Nt={succeed:(e,t)=>J(()=>Promise.resolve(R.make(e,t)),e.id),effect:(e,t)=>J(async()=>{let n=await t();return R.make(e,n)},e.id),sync:(e,t)=>J(()=>Promise.resolve(R.make(e,t())),e.id),fromService:(e,t,n)=>J(r=>{let i=r.unsafeGet(t);return Promise.resolve(R.make(e,n(i)))},e.id),fromServiceEffect:(e,t,n)=>J(async r=>{let i=await n(r.unsafeGet(t));return R.make(e,i)},e.id),fromContext:e=>J(()=>Promise.resolve(e)),empty:()=>J(()=>Promise.resolve(R.empty()),`empty`),mergeAll:(...e)=>J(async t=>(await Promise.all(e.map(e=>e.build(t)))).reduce((e,t)=>e.merge(t),R.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})})}}},Y=Pt(`TestClock`),It={make:Ft,tag:Y,test:async e=>e(Ft()),get:q.service(Y),advance:e=>q.serviceWithIO(Y,t=>q.async(()=>t.advance(e))),setTime:e=>q.serviceWithIO(Y,t=>q.async(()=>t.setTime(e))),runAll:q.serviceWithIO(Y,e=>q.async(()=>e.runAll())),context:()=>{let e=Ft();return{clock:e,context:R.make(Y,e)}}},Lt={make:()=>{let e=Ft(),t=R.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(Y,e)}},X=e=>{let t=!1,n,i,a=!1,o=()=>{if(!t)try{n=e(),t=!0}catch(e){throw i=e,a=!0,t=!0,e}if(a)throw i;return n};return{_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=>Z(()=>{try{return o()}catch{return e.orThrow()}}),orUndefined:()=>{try{return o()}catch{return}},map:e=>Z(()=>e(o())),ap:e=>Z(()=>e.orThrow()(o())),mapAsync:async e=>{let t=await e(o());return Z(()=>t)},flatMap:e=>Z(()=>e(o()).orThrow()),flatMapAsync:async e=>{let t=await e(o());return Z(()=>t.orThrow())},filter:e=>Z(()=>{let t=o();return e(t)?u(t):f}),recover:e=>Z(()=>{try{return o()}catch(t){return e(t)}}),recoverWith:e=>Z(()=>{try{return o()}catch(t){return e(t).orThrow()}}),toOption:()=>{try{return u(o())}catch{return f}},toEither:()=>{try{return C(o())}catch(e){return w(e)}},toEitherWith:e=>{try{return C(o())}catch(t){return w(e(t))}},toTry:()=>b(()=>o()),tap:e=>Z(()=>{let t=o();return e(t),t}),tapError:e=>Z(()=>{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(${r(n)})`:t&&a?`Lazy(<error: ${i instanceof Error?i.message:String(i)}>)`:`Lazy(<not evaluated>)`,toValue:()=>t&&!a?{_tag:`Lazy`,evaluated:!0,value:n}:{_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())?1:0}catch{return 0}},find:e=>{try{let t=o();return e(t)?u(t):f}catch{return f}},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:n}:{_tag:`Lazy`,evaluated:!1}),toYAML:()=>t&&!a?`_tag: Lazy\nevaluated: true\nvalue: ${r(n)}`:`_tag: Lazy
|
|
17
17
|
evaluated: false`,toBinary:()=>Buffer.from(JSON.stringify(t&&!a?{_tag:`Lazy`,evaluated:!0,value:n}:{_tag:`Lazy`,evaluated:!1})).toString(`base64`)}),typeable:`Lazy`}},Z=t(X,{of:e=>X(e),fromValue:e=>X(()=>e),fromOption:(e,t)=>X(()=>e._tag===`Some`?e.value:t()),fromTry:e=>X(()=>e.orThrow()),fromEither:e=>X(()=>e.fold(e=>{throw e},e=>e)),fromPromise:e=>X(()=>{throw Error(`Promise not yet resolved. Use await on the promise before creating Lazy.`)}),fail:e=>X(()=>{throw e})}),Rt=Map,Q=e=>{let t={values:new Rt(e)},r=()=>Array.from(t.values.entries()).map(([e,t])=>n([e,t])),a=e=>Q(new Rt(t.values).set(e.toArray()[0],e.toArray()[1]).entries()),o=e=>{let n=new Rt(t.values);return n.delete(e)?Q(n.entries()):Q(t.values.entries())},s=e=>{let n=e.toArray();return t.values.get(n[0])===n[1]},c=()=>t.values.size,l=e=>Q(Array.from(t.values.entries()).map(([t,n])=>[t,e(n)])),u=e=>Q(Q(t.values.entries()).toList().flatMap(e).toArray()),d=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 Q(n)},f=async e=>{let n=new Rt;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 Q(n.entries())},ee=e=>S(r()).reduce(e),te=e=>S(r()).reduceRight(e),m=e=>t=>S(r()).foldLeft(e)(t),h=e=>t=>S(r()).foldRight(e)(t),ne=e=>p(t.values.get(e)),re=(e,n)=>p(t.values.get(e)).orElse(n),ae=()=>t.values.size===0,g=(e,n)=>p(t.values.get(e)).or(n),oe=(e,t)=>{if(ae())return e();let n=r();if(n.length===0)return e();let i=n[0];return i===void 0?e():t(i)},se=()=>S(r()),_=()=>ie(r()),ce=()=>`Map(${r().toString()})`,v=e=>ae()?e.Empty():e.NonEmpty(r());return{_tag:`Map`,[Symbol.iterator]:()=>t.values.entries(),add:a,remove:o,contains:s,get size(){return c()},map:l,ap:d,flatMap:u,flatMapAsync:f,reduce:ee,reduceRight:te,foldLeft:m,foldRight:h,fold:oe,match:v,get:ne,getOrElse:re,get isEmpty(){return ae()},orElse:g,toList:se,toSet:_,toString:ce,toValue:()=>({_tag:`Map`,value:Array.from(t.values.entries())}),pipe:e=>e(Array.from(t.values.entries())),serialize:()=>i(`Map`,Array.from(t.values.entries()))}},zt=e=>Q(e),Bt={fromJSON:e=>Vt(JSON.parse(e).value),fromYAML:e=>{let t=e.split(`
|
|
18
18
|
`)[1]?.split(`: `)[1];return Vt(t?JSON.parse(t):[])},fromBinary:e=>{let t=Buffer.from(e,`base64`).toString();return Bt.fromJSON(t)}},Vt=t(zt,Bt),Ht={default:e=>t=>e(t),when:(e,t)=>n=>e(n)?t(n):void 0},$=(e=[])=>{let t=[...e],n=()=>t.length,r=()=>t.length===0;return{_tag:`Stack`,get size(){return n()},get isEmpty(){return r()},contains:e=>t.includes(e),reduce:e=>{if(t.length===0)throw Error(`Cannot reduce an empty stack`);return t.reduce(e)},reduceRight:e=>{if(t.length===0)throw Error(`Cannot reduce an empty stack`);return t.reduceRight(e)},push:e=>$([...t,e]),pop:()=>{if(r())return[$([]),p(null)];let e=[...t],n=e.pop();return[$(e),p(n)]},peek:()=>r()?p(null):p(t[t.length-1]),map:e=>$(t.map(e)),flatMap:e=>r()?$([]):t.reduce((t,n)=>e(n).toArray().reduce((e,t)=>e.push(t),t),$([])),ap:e=>{let n=[];return t.forEach(t=>{e.toArray().forEach(e=>{n.push(e(t))})}),$(n)},flatMapAsync:async e=>r()?$([]):(await Promise.all(t.map(async t=>await e(t)))).reduce((e,t)=>t.toArray().reduce((e,t)=>e.push(t),e),$([])),toList:()=>S(t),toArray:()=>[...t],toString:()=>`Stack(${t.join(`, `)})`,fold:(e,n)=>{if(r())return e();let i=t[t.length-1];return i===void 0?e():n(i)},foldLeft:e=>n=>t.reduce(n,e),foldRight:e=>n=>t.reduceRight((e,t)=>n(t,e),e),match:e=>r()?e.Empty():e.NonEmpty([...t]),toValue:()=>({_tag:`Stack`,value:t}),pipe:e=>e([...t]),serialize:()=>({toJSON:()=>JSON.stringify({_tag:`Stack`,value:t}),toYAML:()=>`_tag: Stack\nvalue: ${JSON.stringify(t)}`,toBinary:()=>Buffer.from(JSON.stringify({_tag:`Stack`,value:t})).toString(`base64`)})}},Ut=(e=[])=>$(e),Wt={empty:()=>$([]),of:e=>$([e]),fromJSON:e=>Gt(JSON.parse(e).value),fromYAML:e=>{let t=e.split(`
|
|
19
|
-
`)[1]?.split(`: `)[1];return Gt(t?JSON.parse(t):[])},fromBinary:e=>{let t=Buffer.from(e,`base64`).toString();return Wt.fromJSON(t)}},Gt=t(Ut,Wt);function Kt(e){let t=de({_tag:e._tag,impl:e.impl});return{...t,toValue:()=>({_tag:t._tag,value:e.value})}}export{Pe as $,rt as A,l as At,Xe as B,gt as C,g as Ct,ft as D,ee as Dt,pt as E,p as Et,it as F,Ge as G,qe as H,at as I,Ve as J,Ue as K,k as L,ut as M,c as Mt,ct as N,o as Nt,ot as O,u as Ot,st as P,s as Pt,je as Q,A as R,N as S,ce as St,mt as T,f as Tt,Ke as U,Je as V,We as W,Fe as X,Re as Y,Ie as Z,Dt as _,Se as _t,Rt as a,Ee as at,xt as b,fe as bt,Y as c,T as ct,Nt as d,C as dt,Oe as et,q as f,xe as ft,R as g,ye as gt,V as h,_e as ht,Vt as i,ke as it,lt as j,i as jt,tt as k,a as kt,Lt as l,Te as lt,At as m,ve as mt,Gt as n,De as nt,Z as o,Ne as ot,jt as p,be as pt,He as q,Ht as r,Le as rt,It as s,Me as st,Kt as t,Ae as tt,Pt as u,w as ut,L as v,S as vt,ht as w,ie as wt,yt as x,b as xt,St as y,de as yt,j as z};
|
|
20
|
-
//# sourceMappingURL=src-BeaSFZFq.js.map
|
|
19
|
+
`)[1]?.split(`: `)[1];return Gt(t?JSON.parse(t):[])},fromBinary:e=>{let t=Buffer.from(e,`base64`).toString();return Wt.fromJSON(t)}},Gt=t(Ut,Wt);function Kt(e){let t=de({_tag:e._tag,impl:e.impl});return{...t,toValue:()=>({_tag:t._tag,value:e.value})}}export{Pe as $,rt as A,l as At,Xe as B,gt as C,g as Ct,ft as D,ee as Dt,pt as E,p as Et,it as F,Ge as G,qe as H,at as I,Ve as J,Ue as K,k as L,ut as M,c as Mt,ct as N,o as Nt,ot as O,u as Ot,st as P,s as Pt,je as Q,A as R,N as S,ce as St,mt as T,f as Tt,Ke as U,Je as V,We as W,Fe as X,Re as Y,Ie as Z,Dt as _,Se as _t,Rt as a,Ee as at,xt as b,fe as bt,Y as c,T as ct,Nt as d,C as dt,Oe as et,q as f,xe as ft,R as g,ye as gt,V as h,_e as ht,Vt as i,ke as it,lt as j,i as jt,tt as k,a as kt,Lt as l,Te as lt,At as m,ve as mt,Gt as n,De as nt,Z as o,Ne as ot,jt as p,be as pt,He as q,Ht as r,Le as rt,It as s,Me as st,Kt as t,Ae as tt,Pt as u,w as ut,L as v,S as vt,ht as w,ie as wt,yt as x,b as xt,St as y,de as yt,j as z};
|
package/dist/try/index.d.ts
CHANGED
package/dist/try/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../Brand-Cfr5zy8F.js";import"../Tuple-CgX4p79w.js";import{xt as e}from"../src-
|
|
1
|
+
import"../Brand-Cfr5zy8F.js";import"../Tuple-CgX4p79w.js";import{xt as e}from"../src-DpfaJv6K.js";export{e as Try};
|