functype 1.2.0 → 1.2.2
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/cli/exports.js +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/do/index.d.ts +1 -1
- package/dist/do/index.js +1 -1
- package/dist/either/index.d.ts +1 -1
- package/dist/either/index.js +1 -1
- package/dist/{full-interfaces-CLF4LjBB.js → full-interfaces-DMopL9Xt.js} +1 -1
- package/dist/{index-DAKubqXO.d.ts → index-D6Zlkrnf.d.ts} +94 -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-CONOwKkM.js → src-D3v1n1vv.js} +1 -1
- package/dist/try/index.d.ts +1 -1
- package/dist/try/index.js +1 -1
- package/package.json +2 -2
package/dist/cli/exports.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,i as t,n,r,t as i}from"../full-interfaces-
|
|
1
|
+
import{a as e,i as t,n,r,t as i}from"../full-interfaces-DMopL9Xt.js";export{n as CATEGORIES,i as FULL_INTERFACES,r as INTERFACES,t as TYPES,e as VERSION};
|
package/dist/cli/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{Mt as e,St as t,Z as n}from"../src-
|
|
2
|
+
import{Mt as e,St as t,Z as n}from"../src-D3v1n1vv.js";import{a as r,i,n as a,r as o,t as s}from"../full-interfaces-DMopL9Xt.js";const c=()=>{let n=t([`functype ${r} - Scala-inspired FP for TypeScript`,``]);return t(Object.entries(a)).foldLeft(n)((n,[r,a])=>{let o=n.add(r.toUpperCase());return t(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(t([`Use: npx functype <Type> for details`,`Use: npx functype interfaces for interface reference`])).toArray().join(`
|
|
3
3
|
`)},l=(n,r)=>{let i=r.interfaces.length>0?` [${r.interfaces.join(`, `)}]`:``,a=t([`create`,`transform`,`extract`,`check`,`other`]),o=t([`${n}<T>${i}`,``,r.description,``]);return a.foldLeft(o)((n,i)=>e(r.methods[i]).filter(e=>e.length>0).fold(()=>n,e=>{let r=n.add(i.toUpperCase());return t(e).foldLeft(r)((e,t)=>e.add(` ${t}`)).add(``)})).toArray().join(`
|
|
4
4
|
`).trimEnd()},u=()=>{let e=t([`INTERFACES`,``]);return t(Object.entries(o)).foldLeft(e)((e,[n,r])=>{let i=r.extends?` extends ${r.extends}`:``,a=e.add(`${n}<A>${i}`).add(` ${r.description}`);return t(r.methods).foldLeft(a)((e,t)=>e.add(` ${t}`)).add(``)}).toArray().join(`
|
|
5
5
|
`).trimEnd()},d=e=>JSON.stringify(e,null,2),f=()=>({version:r,categories:a,types:i}),p=n=>e(i[n]).map(e=>({name:n,data:e})).or(t(Object.entries(i)).find(([e])=>e.toLowerCase()===n.toLowerCase()).map(([e,t])=>({name:e,data:t}))).orUndefined(),m=()=>Object.keys(i),h=()=>o,g=e=>{let n=t(e.slice(2));return{flags:{json:n.contains(`--json`),full:n.contains(`--full`),help:n.exists(e=>e===`--help`||e===`-h`)},args:n.filter(e=>!e.startsWith(`--`)&&e!==`-h`)}},_=n=>e(s[n]).or(t(Object.entries(s)).find(([e])=>e.toLowerCase()===n.toLowerCase()).map(([,e])=>e)),v=()=>{let e=t([`FULL INTERFACE DEFINITIONS`,`=`.repeat(60),``]);return t(Object.entries(s)).foldLeft(e)((e,[n,r])=>e.concat(t([`// ${n}`,r,``,`-`.repeat(60),``]))).toArray().join(`
|
package/dist/do/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Er as Doable, Tr as DoResult, a as EmptyListError, c as LeftError, d as isDoCapable, f as unwrap, i as DoGenerator, l as LeftErrorType, n as Do, o as FailureError, r as DoAsync, s as FailureErrorType, t as $, u as NoneError } from "../index-
|
|
1
|
+
import { Er as Doable, Tr as DoResult, a as EmptyListError, c as LeftError, d as isDoCapable, f as unwrap, i as DoGenerator, l as LeftErrorType, n as Do, o as FailureError, r as DoAsync, s as FailureErrorType, t as $, u as NoneError } from "../index-D6Zlkrnf.js";
|
|
2
2
|
export { $, Do, DoAsync, DoGenerator, type DoResult, type Doable, EmptyListError, FailureError, FailureErrorType, LeftError, LeftErrorType, NoneError, isDoCapable, unwrap };
|
package/dist/do/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A as e,F as t,I as n,L as r,M as i,N as a,P as o,R as s,j as c}from"../src-
|
|
1
|
+
import{A as e,F as t,I as n,L as r,M as i,N as a,P as o,R as s,j as c}from"../src-D3v1n1vv.js";export{e as $,c as Do,i as DoAsync,a as EmptyListError,o as FailureError,t as LeftError,n as NoneError,r as isDoCapable,s as unwrap};
|
package/dist/either/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { C as isRight, S as isLeft, T as tryCatchAsync, _ as Right, b as TypeCheckLeft, g as LeftOf, h as Left, m as EitherBase, p as Either, v as RightOf, w as tryCatch, x as TypeCheckRight, y as TestEither } from "../index-
|
|
1
|
+
import { C as isRight, S as isLeft, T as tryCatchAsync, _ as Right, b as TypeCheckLeft, g as LeftOf, h as Left, m as EitherBase, p as Either, v as RightOf, w as tryCatch, x as TypeCheckRight, y as TestEither } from "../index-D6Zlkrnf.js";
|
|
2
2
|
export { Either, EitherBase, Left, LeftOf, Right, RightOf, TestEither, TypeCheckLeft, TypeCheckRight, isLeft, isRight, tryCatch, tryCatchAsync };
|
package/dist/either/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_t as e,bt as t,gt as n,ht as r,mt as i,pt as a,vt as o,xt as s,yt as c}from"../src-
|
|
1
|
+
import{_t as e,bt as t,gt as n,ht as r,mt as i,pt as a,vt as o,xt as s,yt as c}from"../src-D3v1n1vv.js";export{a as Either,i as Left,r as Right,n as TypeCheckLeft,e as TypeCheckRight,o as isLeft,c as isRight,t as tryCatch,s as tryCatchAsync};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var e=`1.2.0`;const t={Option:[`Applicative`,`AsyncMonad`,`Doable`,`Extractable`,`Foldable`,`Functor`,`Matchable`,`Monad`,`Promisable`,`Reshapeable`,`Serializable`,`Traversable`],Either:[`Applicative`,`AsyncMonad`,`Doable`,`Extractable`,`Foldable`,`Functor`,`Monad`,`Promisable`,`Reshapeable`,`Serializable`],Try:[`Applicative`,`AsyncMonad`,`Doable`,`Extractable`,`Foldable`,`Functor`,`Monad`,`Promisable`,`Reshapeable`,`Serializable`],List:[`Collection`,`Doable`,`Iterable`,`Reshapeable`],Set:[`Collection`,`Iterable`],Map:[`Collection`,`Foldable`,`Iterable`,`KVTraversable`,`Serializable`],Obj:[`Doable`,`Promisable`,`Reshapeable`],Lazy:[`Applicative`,`AsyncMonad`,`Extractable`,`Foldable`,`Functor`,`Monad`,`Serializable`,`Traversable`],LazyList:[`Foldable`,`Serializable`],Tuple:[`Foldable`,`Serializable`],Task:[`Applicative`,`AsyncMonad`,`Doable`,`Extractable`,`Foldable`,`Functor`,`Monad`,`Promisable`,`Serializable`,`Traversable`]},n=e,r=(e,...n)=>Array.from(new Set([...t[e],...n])).sort(),i={Option:{description:`Safe nullable handling - Some<T> or None`,interfaces:r(`Option`),methods:{create:[`Option(v)`,`Option.none()`,`Some(v)`,`None()`],transform:[`.map(f)`,`.flatMap(f)`,`.filter(p)`,`.ap(ff)`],extract:[`.fold(n, s)`,`.foldAsync(n, s)`,`.orElse(d)`,`.orThrow()`,`.expect(() => never)`,`.orNull()`,`.match({Some, None})`],check:[`.isSome`,`.isNone`,`.isDefined`,`.isEmpty`],other:[`Option.sequence(arr)`,`Option.traverse(arr, f)`]}},Either:{description:`Error handling with Left (error) or Right (success)`,interfaces:r(`Either`,`Traversable`),methods:{create:[`Right(v)`,`Left(e)`,`Either.right(v)`,`Either.left(e)`,`Either.void()`],transform:[`.map(f)`,`.flatMap(f)`,`.mapLeft(f)`,`.swap()`],extract:[`.fold(l, r)`,`.foldAsync(l, r)`,`.orElse(d)`,`.orThrow()`,`.expect((l) => never)`,`.match({Left, Right})`],check:[`.isRight`,`.isLeft`],other:[`Either.sequence(arr)`,`Either.traverse(arr, f)`,`Either.fromNullable(v, e)`]}},Try:{description:`Wrap operations that may throw - Success<T> or Failure`,interfaces:r(`Try`,`Matchable`,`Traversable`),methods:{create:[`Try(() => expr)`,`Try.success(v)`,`Try.failure(e)`,`Try.fromPromise(p)`],transform:[`.map(f)`,`.flatMap(f)`,`.recover(f)`,`.recoverWith(f)`],extract:[`.fold(f, s)`,`.foldAsync(f, s)`,`.orElse(d)`,`.orThrow()`,`.expect((e) => never)`,`.toOption()`,`.toEither()`],check:[`.isSuccess`,`.isFailure`],other:[`Try.sequence(arr)`,`Try.traverse(arr, f)`]}},List:{description:`Immutable array with functional operations`,interfaces:r(`List`,`Functor`,`Monad`,`Foldable`,`Serializable`,`Traversable`),methods:{create:[`List([...])`,`List.of(...)`,`List.empty()`],transform:[`.map(f)`,`.flatMap(f)`,`.filter(p)`,`.take(n)`,`.takeWhile(p)`,`.takeRight(n)`,`.drop(n)`,`.dropWhile(p)`,`.concat(list)`,`.reverse()`,`.distinct()`,`.sorted()`,`.sortBy(f)`,`.zip(list)`,`.zipWithIndex()`,`.prepend(v)`,`.slice(s, e)`],extract:[`.fold(z, f)`,`.reduce(f)`,`.head`,`.headOption`,`.tail`,`.last`,`.lastOption`,`.init`,`.indexOf(v)`,`.toArray()`],check:[`.isEmpty`,`.nonEmpty`,`.size`,`.contains(v)`],other:[`.groupBy(f)`,`.partition(p)`,`.span(p)`]}},Set:{description:`Immutable set of unique values`,interfaces:r(`Set`,`Functor`,`Foldable`,`Serializable`,`Traversable`),methods:{create:[`Set([...])`,`Set.of(...)`,`Set.empty()`],transform:[`.map(f)`,`.filter(p)`,`.union(s)`,`.intersection(s)`,`.difference(s)`,`.add(v)`],extract:[`.fold(z, f)`,`.toArray()`],check:[`.has(v)`,`.isEmpty`,`.size`]}},Obj:{description:`Immutable object wrapper with fluent operations`,interfaces:r(`Obj`,`KVTraversable`,`Foldable`,`Matchable`,`Extractable`,`Serializable`),methods:{create:[`Obj({...})`,`Obj.of({...})`,`Obj.empty()`],transform:[`.set(k, v)`,`.assign(partial)`,`.merge(obj)`,`.when(cond, partial)`,`.omit(...keys)`,`.pick(...keys)`,`.map(f)`,`.flatMap(f)`],extract:[`.get(k)`,`.value()`,`.keys()`,`.values()`,`.entries()`,`.fold(n, s)`,`.match({Obj})`],check:[`.has(k)`,`.isEmpty`,`.size`]}},Map:{description:`Immutable key-value store`,interfaces:r(`Map`),methods:{create:[`Map([[k, v], ...])`,`Map.of([k, v], ...)`,`Map.empty()`],transform:[`.set(k, v)`,`.delete(k)`,`.map(f)`,`.filter(p)`,`.add(k, v)`],extract:[`.get(k)`,`.keys()`,`.values()`,`.entries()`,`.fold(z, f)`],check:[`.has(k)`,`.isEmpty`,`.size`]}},Lazy:{description:"Deferred computation with memoization. Note: `serialize()` and `toValue()` FORCE the thunk (visible side effect) since a closure cannot be JSON-serialized — there is no representable 'unevaluated post-serialize' state. Thunk failures are captured via SerializedError and rethrown on access after fromJSON.",interfaces:r(`Lazy`),methods:{create:[`Lazy(() => expr)`,`Lazy.fromValue(value) — wrap a non-deferred value`,`Lazy.evaluated(value) — reads as 'already-forced'; used by fromJSON`,`Lazy.fail(error) — Lazy that throws on access`],transform:[`.map(f)`,`.flatMap(f)`],extract:[`.fold(n, s)`,`.orElse(d)`,`.orThrow()`,`.get()`,`.toJSON()`,`Lazy.fromJSON(json)`],check:[`.isEvaluated`]}},LazyList:{description:`Lazy sequences for large/infinite data`,interfaces:r(`LazyList`,`Functor`,`Monad`,`Iterable`),methods:{create:[`LazyList.from(iter)`,`LazyList.range(start, end)`,`LazyList.infinite(f)`,`LazyList.fromJSON(json)`],transform:[`.map(f)`,`.filter(p)`,`.take(n)`,`.takeRight(n)`,`.drop(n)`,`.takeWhile(p)`,`.dropWhile(p)`,`.concat(ll)`,`.reverse()`,`.distinct()`,`.zip(ll)`,`.zipWithIndex()`],extract:[`.head`,`.headOption`,`.tail`,`.last`,`.lastOption`,`.init`,`.toArray()`,`.toJSON()`],check:[`.isEmpty`]}},Task:{description:`Async operations with cancellation and progress tracking. Returns TaskOutcome<T> (Ok/Err) which implements Functor, AsyncMonad, Foldable, Extractable, Serializable`,interfaces:r(`Task`),methods:{create:[`Task(params).Async(fn, errFn)`,`Task(params).Sync(fn, errFn)`,`Task.ok(value)`,`Task.err(error)`,`Task.fromEither(either)`,`Task.fromTry(try)`,`Task.fromPromise(fn)`,`Task.fromNodeCallback(fn)`,`Task.fromJSON(json) — reconstruct from serialize() output`],transform:[`.map(f)`,`.flatMap(f)`,`.mapError(f)`,`.recover(v)`,`.recoverWith(f)`],extract:[`.fold(onErr, onOk)`,`.match({Ok, Err})`,`.orElse(v)`,`.orThrow()`,`.toEither()`,`.toOption()`,`.toJSON()`],other:[`Task.cancellable(fn)`,`Task.withProgress(fn, onProgress)`,`Task.race(tasks, timeout?)`,`Task.getErrorChain(error)`,`Task.formatErrorChain(error)`]}},IO:{description:`Lazy effect type with typed errors and dependency injection`,interfaces:[`Functor`,`Monad`,`Foldable`,`Matchable`],methods:{create:[`IO(() => v)`,`IO.succeed(v)`,`IO.fail(e)`,`IO.sync(f)`,`IO.async(f)`,`IO.tryPromise({try, catch})`,`IO.fromEither(e)`,`IO.fromOption(o)`,`IO.fromTry(t)`],transform:[`.map(f)`,`.flatMap(f)`,`.tap(f)`,`.mapError(f)`,`.recover(v)`,`.recoverWith(f)`],extract:[`.run()`,`.runOrThrow()`,`.runSync()`,`.runSyncOrThrow()`,`.runExit()`,`.runOption()`,`.runTry()`,`.fold(onErr, onOk)`,`.match({failure, success})`],check:[],other:[`.catchTag(tag, f)`,`.catchAll(f)`,`.retry(n)`,`.retryWithDelay(n, ms)`,`.timeout(ms)`,`.delay(ms)`,`.zip(io)`,`.pipe(f)`,`IO.all([...])`,`IO.race([...])`,`IO.bracket(acquire, use, release)`,`IO.gen(function*() {...})`,`IO.Do.bind().map()`,`IO.service(Tag)`,`.provideService(Tag, impl)`,`.provideLayer(layer)`]}},Cond:{description:`Conditional expression builder - replace if-else chains`,interfaces:[],methods:{create:[`Cond<T>()`],other:[`.case(pred, result)`,`.otherwise(result)`,`.eval()`]}},Match:{description:`Pattern matching - replace switch statements`,interfaces:[],methods:{create:[`Match(value)`],other:[`.case(pattern, result)`,`.when(pred, result)`,`.default(result)`,`.done()`]}},Brand:{description:`Nominal typing without runtime overhead`,interfaces:[],methods:{create:[`Brand<K, T>(value)`],extract:[`.unwrap()`,`.toString()`]}},ValidatedBrand:{description:`Branded types with runtime validation`,interfaces:[],methods:{create:[`ValidatedBrand(validator)`,`.of(v)`,`.from(v)`,`.unsafeOf(v)`],check:[`.is(v)`],other:[`.refine(validator)`]}},Tuple:{description:`Fixed-size typed array`,interfaces:r(`Tuple`,`Typeable`,`Valuable`,`Iterable`),methods:{create:[`Tuple([a, b, ...])`,`Tuple.of(a, b, ...)`,`Tuple.fromJSON(json)`],extract:[`.first`,`.second`,`.toArray()`,`.toJSON()`],transform:[`.map(f)`]}},Stack:{description:`Immutable LIFO stack`,interfaces:[`Foldable`,`Collection`,`Serializable`,`Traversable`],methods:{create:[`Stack()`,`Stack.of(...)`],transform:[`.push(v)`,`.pop()`],extract:[`.peek()`,`.toArray()`],check:[`.isEmpty`,`.size`]}},Http:{description:"HTTP fetch wrapper returning IO<never, HttpError, HttpResponse<T>>. Pass `decode: Decoder<T>` (Either-returning) for typed responses; the deprecated `validate: (data) => T` field is still accepted for throw-pattern back-compat. Request bodies auto-flatten functype ADTs to primitives; `flatten: false` preserves tagged emission for functype-to-functype services. Http.client accepts `beforeRequest` (effectful IO transformer for auth refresh, request IDs, etc.). Composes via .tap/.map/.flatMap/.catchTag/.retry/.timeout.",interfaces:[],methods:{create:[`Http.get(url, { decode }?)`,`Http.post(url, { body, decode }?)`,`Http.put(url, { body, decode }?)`,`Http.patch(url, { body, decode }?)`,`Http.delete(url, { decode }?)`,`Http.request({ url, decode })`,`Http.client({ baseUrl, defaultHeaders, fetch, beforeRequest })`],transform:[`.tap(f)`,`.map(f)`,`.flatMap(f)`,`.mapError(f)`,`.retry(n)`,`.retryWithDelay(n, ms)`,`.timeout(ms)`],extract:[`.run()`,`.runOrThrow()`,`.runOption()`,`.runTry()`,`.runExit()`],check:[],other:[`.catchTag(tag, handler)`,`.catchAll(handler)`,`.recover(fallback)`,`decode: Decoder<T> (Either-returning, structural failures preserved)`,`validate: (data) => T (deprecated, throws — for back-compat / Zod .parse)`,`flatten: boolean (default true; false preserves tagged emission)`,`beforeRequest: (req) => IO<never, HttpError, HttpRequestView>`]}},HttpError:{description:`Three-variant ADT for HTTP failures: NetworkError | HttpStatusError | DecodeError (also exported as ResponseDecodeError alias)`,interfaces:[],methods:{create:[`HttpError.networkError(url, method, cause)`,`HttpError.httpStatusError(url, method, status, statusText, body)`,`HttpError.decodeError(url, method, body, cause)`],check:[`HttpError.isNetworkError(e)`,`HttpError.isHttpStatusError(e)`,`HttpError.isDecodeError(e)`],other:[`HttpError.match(error, { NetworkError, HttpStatusError, DecodeError })`]}},Decoder:{description:"Either-returning decoder contract: `Decoder<A> = (raw: unknown) => Either<DecoderError, A>`. Bundled combinators for primitives + functype ADTs (Option/Either/List/Map, null-bias). `Decoder.tagged.*` round-trips the `{_tag, value}` shape for functype-to-functype services.",interfaces:[],methods:{create:[`Decoder.string / .number / .boolean / .unknown / .nullable(inner)`,`Decoder.option(inner)`,`Decoder.either.envelope({ok, err})`,`Decoder.either.discriminated({tag, leftTag, rightTag}, l, r)`,`Decoder.list(inner) / .array(inner) / .map(inner)`,`Decoder.object({k: Decoder<V>, ...}) — accumulates field failures into Composite`,`Decoder.tagged.option/either/try/list/map/obj(inner?) — round-trips {_tag, value}`],other:[`Pluggable by construction: any (raw) => Either<DecoderError, T> IS a Decoder<T>`,`Composes across sources: Decoder.object({a: Decoder.fromZod(s), b: Decoder.option(myAjv)})`]}},DecoderError:{description:"Recursive ADT for decoder failures: Leaf | Composite. Children mirror the input tree so multi-field failures preserve structural paths. Distinct from `HttpError.DecodeError` — this is the inner structural cause that the HTTP wrapper carries.",interfaces:[],methods:{create:[`DecoderError.leaf(path, message, cause?)`,`DecoderError.composite(path, children: List<DecoderError>)`],check:[`DecoderError.isLeaf(e)`,`DecoderError.isComposite(e)`],other:[`DecoderError.match(e, { Leaf, Composite })`,`DecoderError.prepend(segment, e) — used by combinators to attribute child failures`,`DecoderError.flatten(e): List<{path, message}> — collect leaves`,`DecoderError.format(e): string — render tree as multi-line`]}},Serialization:{description:"Universal `@functype`-marked JSON serialization. `deserialize` walks parsed JSON and reconstructs any functype value found — no type argument needed. Plain JSON passes through. Strict on unknown markers (defends against Effect/fp-ts `_tag` collision).",interfaces:[],methods:{create:[],transform:[`Serialization.serialize(value: unknown): string`,`Serialization.deserialize(json: string): Try<unknown>`],check:[`Serialization.isFunctypeValue(v): v is Serializable<unknown>`],other:[`Plain JSON passthrough: non-functype data walks through unchanged`,`Strict policy: unknown @functype marker → Try.Failure`,`Dispatch table covers all 12 Serializable types (Option, Either, Try, List, Set, Map, Obj, Stack, Tuple, LazyList, Lazy, Task)`,`No DBOS / SuperJSON facade — consumers wire host serializer in ~8 lines`]}},SerializedError:{description:"Canonical Error projection used by Try.Failure, Task.Err, Lazy-with-thrown-thunk. Round-trips name + message + stack + cause chain. `e.name === 'TypeError'` survives; `instanceof TypeError` does NOT.",interfaces:[],methods:{create:[`serializeError(err: unknown): SerializedError`,`deserializeError(s: SerializedError | string): Error`],other:[`Shape: { name: string; message: string; stack?: string; cause?: SerializedError | string }`,`Non-Error throwables (strings, plain objects) projected under name: 'NonErrorThrowable'`,`Cause chain is recursive — arbitrary nesting depth survives`]}}},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`,`.expect(handler: (e?) => never): 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`,`Obj`],Collection:[`List`,`Set`,`Map`,`LazyList`,`Tuple`,`Stack`],Effect:[`IO`,`Task`,`Http`,`HttpError`,`Decoder`,`DecoderError`],Utility:[`Lazy`,`Cond`,`Match`,`Brand`,`ValidatedBrand`],Serialization:[`Serialization`,`SerializedError`]},s={Option:`export interface Option<out T extends Type>
|
|
1
|
+
var e=`1.2.2`;const t={Option:[`Applicative`,`AsyncMonad`,`Doable`,`Extractable`,`Foldable`,`Functor`,`Matchable`,`Monad`,`Promisable`,`Reshapeable`,`Serializable`,`Traversable`],Either:[`Applicative`,`AsyncMonad`,`Doable`,`Extractable`,`Foldable`,`Functor`,`Monad`,`Promisable`,`Reshapeable`,`Serializable`],Try:[`Applicative`,`AsyncMonad`,`Doable`,`Extractable`,`Foldable`,`Functor`,`Monad`,`Promisable`,`Reshapeable`,`Serializable`],List:[`Collection`,`Doable`,`Iterable`,`Reshapeable`],Set:[`Collection`,`Iterable`],Map:[`Collection`,`Foldable`,`Iterable`,`KVTraversable`,`Serializable`],Obj:[`Doable`,`Promisable`,`Reshapeable`],Lazy:[`Applicative`,`AsyncMonad`,`Extractable`,`Foldable`,`Functor`,`Monad`,`Serializable`,`Traversable`],LazyList:[`Foldable`,`Serializable`],Tuple:[`Foldable`,`Serializable`],Task:[`Applicative`,`AsyncMonad`,`Doable`,`Extractable`,`Foldable`,`Functor`,`Monad`,`Promisable`,`Serializable`,`Traversable`]},n=e,r=(e,...n)=>Array.from(new Set([...t[e],...n])).sort(),i={Option:{description:`Safe nullable handling - Some<T> or None`,interfaces:r(`Option`),methods:{create:[`Option(v)`,`Option.none()`,`Some(v)`,`None()`],transform:[`.map(f)`,`.flatMap(f)`,`.filter(p)`,`.ap(ff)`],extract:[`.fold(n, s)`,`.foldAsync(n, s)`,`.orElse(d)`,`.orThrow()`,`.expect(() => never)`,`.orNull()`,`.match({Some, None})`],check:[`.isSome`,`.isNone`,`.isDefined`,`.isEmpty`],other:[`Option.sequence(arr)`,`Option.traverse(arr, f)`]}},Either:{description:`Error handling with Left (error) or Right (success)`,interfaces:r(`Either`,`Traversable`),methods:{create:[`Right(v)`,`Left(e)`,`Either.right(v)`,`Either.left(e)`,`Either.void()`],transform:[`.map(f)`,`.flatMap(f)`,`.mapLeft(f)`,`.swap()`],extract:[`.fold(l, r)`,`.foldAsync(l, r)`,`.orElse(d)`,`.orThrow()`,`.expect((l) => never)`,`.match({Left, Right})`],check:[`.isRight`,`.isLeft`],other:[`Either.sequence(arr)`,`Either.traverse(arr, f)`,`Either.fromNullable(v, e)`]}},Try:{description:`Wrap operations that may throw - Success<T> or Failure`,interfaces:r(`Try`,`Matchable`,`Traversable`),methods:{create:[`Try(() => expr)`,`Try.success(v)`,`Try.failure(e)`,`Try.fromPromise(p)`],transform:[`.map(f)`,`.flatMap(f)`,`.recover(f)`,`.recoverWith(f)`],extract:[`.fold(f, s)`,`.foldAsync(f, s)`,`.orElse(d)`,`.orThrow()`,`.expect((e) => never)`,`.toOption()`,`.toEither()`],check:[`.isSuccess`,`.isFailure`],other:[`Try.sequence(arr)`,`Try.traverse(arr, f)`]}},List:{description:`Immutable array with functional operations`,interfaces:r(`List`,`Functor`,`Monad`,`Foldable`,`Serializable`,`Traversable`),methods:{create:[`List([...])`,`List.of(...)`,`List.empty()`],transform:[`.map(f)`,`.flatMap(f)`,`.filter(p)`,`.take(n)`,`.takeWhile(p)`,`.takeRight(n)`,`.drop(n)`,`.dropWhile(p)`,`.concat(list)`,`.reverse()`,`.distinct()`,`.sorted()`,`.sortBy(f)`,`.zip(list)`,`.zipWithIndex()`,`.prepend(v)`,`.slice(s, e)`],extract:[`.fold(z, f)`,`.reduce(f)`,`.head`,`.headOption`,`.tail`,`.last`,`.lastOption`,`.init`,`.indexOf(v)`,`.toArray()`],check:[`.isEmpty`,`.nonEmpty`,`.size`,`.contains(v)`],other:[`.groupBy(f)`,`.partition(p)`,`.span(p)`]}},Set:{description:`Immutable set of unique values`,interfaces:r(`Set`,`Functor`,`Foldable`,`Serializable`,`Traversable`),methods:{create:[`Set([...])`,`Set.of(...)`,`Set.empty()`],transform:[`.map(f)`,`.filter(p)`,`.union(s)`,`.intersection(s)`,`.difference(s)`,`.add(v)`],extract:[`.fold(z, f)`,`.toArray()`],check:[`.has(v)`,`.isEmpty`,`.size`]}},Obj:{description:`Immutable object wrapper with fluent operations`,interfaces:r(`Obj`,`KVTraversable`,`Foldable`,`Matchable`,`Extractable`,`Serializable`),methods:{create:[`Obj({...})`,`Obj.of({...})`,`Obj.empty()`],transform:[`.set(k, v)`,`.assign(partial)`,`.merge(obj)`,`.when(cond, partial)`,`.omit(...keys)`,`.pick(...keys)`,`.map(f)`,`.flatMap(f)`],extract:[`.get(k)`,`.value()`,`.keys()`,`.values()`,`.entries()`,`.fold(n, s)`,`.match({Obj})`],check:[`.has(k)`,`.isEmpty`,`.size`]}},Map:{description:`Immutable key-value store`,interfaces:r(`Map`),methods:{create:[`Map([[k, v], ...])`,`Map.of([k, v], ...)`,`Map.empty()`],transform:[`.set(k, v)`,`.delete(k)`,`.map(f)`,`.filter(p)`,`.add(k, v)`],extract:[`.get(k)`,`.keys()`,`.values()`,`.entries()`,`.fold(z, f)`],check:[`.has(k)`,`.isEmpty`,`.size`]}},Lazy:{description:"Deferred computation with memoization. Note: `serialize()` and `toValue()` FORCE the thunk (visible side effect) since a closure cannot be JSON-serialized — there is no representable 'unevaluated post-serialize' state. Thunk failures are captured via SerializedError and rethrown on access after fromJSON.",interfaces:r(`Lazy`),methods:{create:[`Lazy(() => expr)`,`Lazy.fromValue(value) — wrap a non-deferred value`,`Lazy.evaluated(value) — reads as 'already-forced'; used by fromJSON`,`Lazy.fail(error) — Lazy that throws on access`],transform:[`.map(f)`,`.flatMap(f)`],extract:[`.fold(n, s)`,`.orElse(d)`,`.orThrow()`,`.get()`,`.toJSON()`,`Lazy.fromJSON(json)`],check:[`.isEvaluated`]}},LazyList:{description:`Lazy sequences for large/infinite data`,interfaces:r(`LazyList`,`Functor`,`Monad`,`Iterable`),methods:{create:[`LazyList.from(iter)`,`LazyList.range(start, end)`,`LazyList.infinite(f)`,`LazyList.fromJSON(json)`],transform:[`.map(f)`,`.filter(p)`,`.take(n)`,`.takeRight(n)`,`.drop(n)`,`.takeWhile(p)`,`.dropWhile(p)`,`.concat(ll)`,`.reverse()`,`.distinct()`,`.zip(ll)`,`.zipWithIndex()`],extract:[`.head`,`.headOption`,`.tail`,`.last`,`.lastOption`,`.init`,`.toArray()`,`.toJSON()`],check:[`.isEmpty`]}},Task:{description:`Async operations with cancellation and progress tracking. Returns TaskOutcome<T> (Ok/Err) which implements Functor, AsyncMonad, Foldable, Extractable, Serializable`,interfaces:r(`Task`),methods:{create:[`Task(params).Async(fn, errFn)`,`Task(params).Sync(fn, errFn)`,`Task.ok(value)`,`Task.err(error)`,`Task.fromEither(either)`,`Task.fromTry(try)`,`Task.fromPromise(fn)`,`Task.fromNodeCallback(fn)`,`Task.fromJSON(json) — reconstruct from serialize() output`],transform:[`.map(f)`,`.flatMap(f)`,`.mapError(f)`,`.recover(v)`,`.recoverWith(f)`],extract:[`.fold(onErr, onOk)`,`.match({Ok, Err})`,`.orElse(v)`,`.orThrow()`,`.toEither()`,`.toOption()`,`.toJSON()`],other:[`Task.cancellable(fn)`,`Task.withProgress(fn, onProgress)`,`Task.race(tasks, timeout?)`,`Task.getErrorChain(error)`,`Task.formatErrorChain(error)`]}},IO:{description:`Lazy effect type with typed errors and dependency injection`,interfaces:[`Functor`,`Monad`,`Foldable`,`Matchable`],methods:{create:[`IO(() => v)`,`IO.succeed(v)`,`IO.fail(e)`,`IO.sync(f)`,`IO.async(f)`,`IO.tryPromise({try, catch})`,`IO.fromEither(e)`,`IO.fromOption(o)`,`IO.fromTry(t)`],transform:[`.map(f)`,`.flatMap(f)`,`.tap(f)`,`.mapError(f)`,`.recover(v)`,`.recoverWith(f)`],extract:[`.run()`,`.runOrThrow()`,`.runSync()`,`.runSyncOrThrow()`,`.runExit()`,`.runOption()`,`.runTry()`,`.fold(onErr, onOk)`,`.match({failure, success})`],check:[],other:[`.catchTag(tag, f)`,`.catchAll(f)`,`.retry(n)`,`.retryWithDelay(n, ms)`,`.timeout(ms)`,`.delay(ms)`,`.zip(io)`,`.pipe(f)`,`IO.all([...])`,`IO.race([...])`,`IO.bracket(acquire, use, release)`,`IO.gen(function*() {...})`,`IO.Do.bind().map()`,`IO.service(Tag)`,`.provideService(Tag, impl)`,`.provideLayer(layer)`]}},Cond:{description:`Conditional expression builder - replace if-else chains`,interfaces:[],methods:{create:[`Cond<T>()`],other:[`.case(pred, result)`,`.otherwise(result)`,`.eval()`]}},Match:{description:`Pattern matching - replace switch statements`,interfaces:[],methods:{create:[`Match(value)`],other:[`.case(pattern, result)`,`.when(pred, result)`,`.default(result)`,`.done()`]}},Brand:{description:`Nominal typing without runtime overhead`,interfaces:[],methods:{create:[`Brand<K, T>(value)`],extract:[`.unwrap()`,`.toString()`]}},ValidatedBrand:{description:`Branded types with runtime validation`,interfaces:[],methods:{create:[`ValidatedBrand(validator)`,`.of(v)`,`.from(v)`,`.unsafeOf(v)`],check:[`.is(v)`],other:[`.refine(validator)`]}},Tuple:{description:`Fixed-size typed array`,interfaces:r(`Tuple`,`Typeable`,`Valuable`,`Iterable`),methods:{create:[`Tuple([a, b, ...])`,`Tuple.of(a, b, ...)`,`Tuple.fromJSON(json)`],extract:[`.first`,`.second`,`.toArray()`,`.toJSON()`],transform:[`.map(f)`]}},Stack:{description:`Immutable LIFO stack`,interfaces:[`Foldable`,`Collection`,`Serializable`,`Traversable`],methods:{create:[`Stack()`,`Stack.of(...)`],transform:[`.push(v)`,`.pop()`],extract:[`.peek()`,`.toArray()`],check:[`.isEmpty`,`.size`]}},Http:{description:"HTTP fetch wrapper returning IO<never, HttpError, HttpResponse<T>>. Pass `decode: Decoder<T>` (Either-returning) for typed responses; the deprecated `validate: (data) => T` field is still accepted for throw-pattern back-compat. Request bodies auto-flatten functype ADTs to primitives; `flatten: false` preserves tagged emission for functype-to-functype services. Http.client accepts `beforeRequest` (effectful IO transformer for auth refresh, request IDs, etc.). Composes via .tap/.map/.flatMap/.catchTag/.retry/.timeout.",interfaces:[],methods:{create:[`Http.get(url, { decode }?)`,`Http.post(url, { body, decode }?)`,`Http.put(url, { body, decode }?)`,`Http.patch(url, { body, decode }?)`,`Http.delete(url, { decode }?)`,`Http.request({ url, decode })`,`Http.client({ baseUrl, defaultHeaders, fetch, beforeRequest })`],transform:[`.tap(f)`,`.map(f)`,`.flatMap(f)`,`.mapError(f)`,`.retry(n)`,`.retryWithDelay(n, ms)`,`.timeout(ms)`],extract:[`.run()`,`.runOrThrow()`,`.runOption()`,`.runTry()`,`.runExit()`],check:[],other:[`.catchTag(tag, handler)`,`.catchAll(handler)`,`.recover(fallback)`,`decode: Decoder<T> (Either-returning, structural failures preserved)`,`validate: (data) => T (deprecated, throws — for back-compat / Zod .parse)`,`flatten: boolean (default true; false preserves tagged emission)`,`beforeRequest: (req) => IO<never, HttpError, HttpRequestView>`]}},HttpError:{description:`Three-variant ADT for HTTP failures: NetworkError | HttpStatusError | DecodeError (also exported as ResponseDecodeError alias)`,interfaces:[],methods:{create:[`HttpError.networkError(url, method, cause)`,`HttpError.httpStatusError(url, method, status, statusText, body)`,`HttpError.decodeError(url, method, body, cause)`],check:[`HttpError.isNetworkError(e)`,`HttpError.isHttpStatusError(e)`,`HttpError.isDecodeError(e)`],other:[`HttpError.match(error, { NetworkError, HttpStatusError, DecodeError })`]}},Decoder:{description:"Either-returning decoder contract: `Decoder<A> = (raw: unknown) => Either<DecoderError, A>`. Bundled combinators for primitives + functype ADTs (Option/Either/List/Map, null-bias). `Decoder.tagged.*` round-trips the `{_tag, value}` shape for functype-to-functype services.",interfaces:[],methods:{create:[`Decoder.string / .number / .boolean / .unknown / .nullable(inner)`,`Decoder.option(inner)`,`Decoder.either.envelope({ok, err})`,`Decoder.either.discriminated({tag, leftTag, rightTag}, l, r)`,`Decoder.list(inner) / .array(inner) / .map(inner)`,`Decoder.object({k: Decoder<V>, ...}) — accumulates field failures into Composite`,`Decoder.tagged.option/either/try/list/map/obj(inner?) — round-trips {_tag, value}`],other:[`Pluggable by construction: any (raw) => Either<DecoderError, T> IS a Decoder<T>`,`Composes across sources: Decoder.object({a: Decoder.fromZod(s), b: Decoder.option(myAjv)})`]}},DecoderError:{description:"Recursive ADT for decoder failures: Leaf | Composite. Children mirror the input tree so multi-field failures preserve structural paths. Distinct from `HttpError.DecodeError` — this is the inner structural cause that the HTTP wrapper carries.",interfaces:[],methods:{create:[`DecoderError.leaf(path, message, cause?)`,`DecoderError.composite(path, children: List<DecoderError>)`],check:[`DecoderError.isLeaf(e)`,`DecoderError.isComposite(e)`],other:[`DecoderError.match(e, { Leaf, Composite })`,`DecoderError.prepend(segment, e) — used by combinators to attribute child failures`,`DecoderError.flatten(e): List<{path, message}> — collect leaves`,`DecoderError.format(e): string — render tree as multi-line`]}},Serialization:{description:"Universal `@functype`-marked JSON serialization. `deserialize` walks parsed JSON and reconstructs any functype value found — no type argument needed. Lenient: plain JSON passes through. Strict on unknown markers (defends against Effect/fp-ts `_tag` collision). 1.2.1 adds `toEnvelope`/`fromEnvelope` for nesting inside structured serializers (SuperJSON, DBOS), and `deserializeStrict` for boundaries that require functype on the wire.",interfaces:[],methods:{create:[],transform:[`Serialization.serialize(value: unknown): string — lenient JSON codec`,`Serialization.deserialize(json: string): Try<unknown> — lenient; pass-through for unmarked JSON`,`Serialization.deserializeStrict(json: string): Try<unknown> — Failure if no @functype marker at top level`,`Serialization.toEnvelope(value: unknown): JSONValue — parsed JSON shape (1.2.2 tightened from unknown)`,`Serialization.fromEnvelope(envelope: unknown): Try<unknown> — inverse of toEnvelope; input stays permissive (Postel's law)`,`Serialization.JSONValue — exported recursive type for the envelope shape`],check:[`Serialization.isFunctypeValue(v): v is Serializable<unknown>`],other:[`Plain JSON passthrough: non-functype data walks through unchanged (use deserializeStrict to reject)`,`Strict policy on unknown markers: unknown @functype marker → Try.Failure`,`Dispatch table covers all 12 Serializable types (Option, Either, Try, List, Set, Map, Obj, Stack, Tuple, LazyList, Lazy, Task)`,`Algebraic square: serialize ≡ JSON.stringify ∘ toEnvelope; deserialize ≡ fromEnvelope ∘ JSON.parse`,`No DBOS / SuperJSON facade — consumers wire host serializer in ~8 lines via toEnvelope/fromEnvelope`]}},SerializedError:{description:"Canonical Error projection used by Try.Failure, Task.Err, Lazy-with-thrown-thunk. Round-trips name + message + stack + cause chain. `e.name === 'TypeError'` survives; `instanceof TypeError` does NOT.",interfaces:[],methods:{create:[`serializeError(err: unknown): SerializedError`,`deserializeError(s: SerializedError | string): Error`],other:[`Shape: { name: string; message: string; stack?: string; cause?: SerializedError | string }`,`Non-Error throwables (strings, plain objects) projected under name: 'NonErrorThrowable'`,`Cause chain is recursive — arbitrary nesting depth survives`]}}},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`,`.expect(handler: (e?) => never): 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`,`Obj`],Collection:[`List`,`Set`,`Map`,`LazyList`,`Tuple`,`Stack`],Effect:[`IO`,`Task`,`Http`,`HttpError`,`Decoder`,`DecoderError`],Utility:[`Lazy`,`Cond`,`Match`,`Brand`,`ValidatedBrand`],Serialization:[`Serialization`,`SerializedError`]},s={Option:`export interface Option<out T extends Type>
|
|
2
2
|
extends Functype<T, "Some" | "None">, Promisable<T>, Doable<T>, Reshapeable<T> {
|
|
3
3
|
/** The contained value (undefined for None) */
|
|
4
4
|
readonly value: T | undefined
|
|
@@ -4697,13 +4697,34 @@ declare const Ref: (<A extends Type>(initial: A) => Ref<A>) & {
|
|
|
4697
4697
|
of: <A extends Type>(initial: A) => Ref<A>;
|
|
4698
4698
|
};
|
|
4699
4699
|
declare namespace Serialization_d_exports {
|
|
4700
|
-
export { deserialize, isFunctypeValue, serialize };
|
|
4700
|
+
export { JSONValue, deserialize, deserializeStrict, fromEnvelope, isFunctypeValue, serialize, toEnvelope };
|
|
4701
4701
|
}
|
|
4702
4702
|
/**
|
|
4703
|
-
*
|
|
4704
|
-
*
|
|
4705
|
-
*
|
|
4706
|
-
*
|
|
4703
|
+
* The canonical JSON value type — anything `JSON.parse` can return and
|
|
4704
|
+
* anything `JSON.stringify` can accept as input. Used by `toEnvelope` /
|
|
4705
|
+
* `fromEnvelope` to express the contract precisely: the envelope is a
|
|
4706
|
+
* structured JSON shape, not opaque `unknown`. Lets consumers wiring this
|
|
4707
|
+
* API into another structured serializer (SuperJSON, DBOS custom
|
|
4708
|
+
* transformers) slot it in without a cast at the boundary.
|
|
4709
|
+
*
|
|
4710
|
+
* Added in 1.2.2 — `toEnvelope`/`fromEnvelope` previously typed input/output
|
|
4711
|
+
* as `unknown`, which forced a cast at the consumer side.
|
|
4712
|
+
*/
|
|
4713
|
+
type JSONValue = string | number | boolean | null | JSONValue[] | {
|
|
4714
|
+
[key: string]: JSONValue;
|
|
4715
|
+
};
|
|
4716
|
+
/**
|
|
4717
|
+
* Reconstruct any value from a JSON string. Lenient codec: walks the parsed
|
|
4718
|
+
* structure and rebuilds any value carrying an `@functype` marker via the
|
|
4719
|
+
* dispatch table; plain JSON without the marker walks through unchanged.
|
|
4720
|
+
* Returns `Try` so malformed JSON or unknown markers are expressible values
|
|
4721
|
+
* rather than thrown — matches the functype convention for expected-failure
|
|
4722
|
+
* paths.
|
|
4723
|
+
*
|
|
4724
|
+
* **Pass-through policy:** valid JSON without an `@functype` marker is
|
|
4725
|
+
* returned verbatim as `Success(value)`; only marker-carrying values are
|
|
4726
|
+
* reconstructed. Only malformed JSON (or an unknown marker) yields `Failure`.
|
|
4727
|
+
* For a strict variant that rejects unmarked input, see `deserializeStrict`.
|
|
4707
4728
|
*
|
|
4708
4729
|
* @example
|
|
4709
4730
|
* const result = Serialization.deserialize('{"@functype":"Either","_tag":"Right","value":5}')
|
|
@@ -4711,20 +4732,84 @@ declare namespace Serialization_d_exports {
|
|
|
4711
4732
|
*
|
|
4712
4733
|
* // Plain (non-functype) values pass through:
|
|
4713
4734
|
* Serialization.deserialize('{"name":"alice","age":30}') // → Success({name, age})
|
|
4735
|
+
*
|
|
4736
|
+
* // Embedding in another structured serializer (SuperJSON, DBOS)? See
|
|
4737
|
+
* // `fromEnvelope` — taking a string here forces the consumer through a
|
|
4738
|
+
* // JSON.stringify shim and SuperJSON re-walks strings character-by-character.
|
|
4714
4739
|
*/
|
|
4715
4740
|
declare const deserialize: (json: string) => Try<unknown>;
|
|
4716
4741
|
/**
|
|
4717
|
-
*
|
|
4718
|
-
*
|
|
4719
|
-
*
|
|
4742
|
+
* Strict variant of `deserialize`: returns `Failure` when the parsed JSON
|
|
4743
|
+
* doesn't carry an `@functype` marker at the top level. Use this at API,
|
|
4744
|
+
* queue, or RPC boundaries where the wire format MUST be a functype value
|
|
4745
|
+
* and pass-through silence would be a bug.
|
|
4746
|
+
*
|
|
4747
|
+
* Implementation note: only the top-level value is checked for the marker.
|
|
4748
|
+
* Nested values inside it follow the same lenient pass-through rules as
|
|
4749
|
+
* `deserialize` — a `Right` containing a plain object still reconstructs
|
|
4750
|
+
* fine, you just can't START with a plain object.
|
|
4751
|
+
*
|
|
4752
|
+
* @example
|
|
4753
|
+
* Serialization.deserializeStrict('{"@functype":"Option","_tag":"Some","value":1}') // → Success(Some(1))
|
|
4754
|
+
* Serialization.deserializeStrict('{"_tag":"Some","value":1}') // → Failure
|
|
4755
|
+
* Serialization.deserializeStrict('42') // → Failure
|
|
4756
|
+
*/
|
|
4757
|
+
declare const deserializeStrict: (json: string) => Try<unknown>;
|
|
4758
|
+
/**
|
|
4759
|
+
* Serialize any value to a JSON string. Lenient codec: thin convenience over
|
|
4760
|
+
* `JSON.stringify` — functype instances self-stringify via their instance
|
|
4761
|
+
* `toJSON()` method (which emits the `@functype`-marked envelope), and
|
|
4762
|
+
* non-functype values pass through as plain JSON. Nested functype values
|
|
4720
4763
|
* embedded in plain objects/arrays serialize correctly via the standard
|
|
4721
4764
|
* JSON.stringify protocol with no walker needed.
|
|
4722
4765
|
*
|
|
4723
4766
|
* `undefined` is converted to `null` (matching the convention DBOS and
|
|
4724
|
-
* SuperJSON use; `JSON.stringify(undefined)` returns the string `undefined`
|
|
4767
|
+
* SuperJSON use; `JSON.stringify(undefined)` returns the string `"undefined"`
|
|
4725
4768
|
* which is not valid JSON).
|
|
4726
4769
|
*/
|
|
4727
4770
|
declare const serialize: (value: unknown) => string;
|
|
4771
|
+
/**
|
|
4772
|
+
* Serialize a value to a parsed JSON envelope (object/array/primitive) rather
|
|
4773
|
+
* than a string. Use this when nesting functype values inside another
|
|
4774
|
+
* **structured** serializer (SuperJSON / DBOS custom transformers / similar)
|
|
4775
|
+
* whose custom-transformer hook expects JSON values, not strings — passing a
|
|
4776
|
+
* string to such a hook causes the host to re-walk it character-by-character,
|
|
4777
|
+
* destroying the round-trip.
|
|
4778
|
+
*
|
|
4779
|
+
* Equivalent to `JSON.parse(serialize(value))` but exposed as a named entry
|
|
4780
|
+
* point so consumers don't carry the parse/stringify shim.
|
|
4781
|
+
*
|
|
4782
|
+
* Returns `JSONValue` (tightened from `unknown` in 1.2.2) so consumers can
|
|
4783
|
+
* drop the result straight into a host serializer's `serialize` hook without
|
|
4784
|
+
* a boundary cast.
|
|
4785
|
+
*
|
|
4786
|
+
* @example
|
|
4787
|
+
* // Inside a DBOS custom serialization recipe — zero casts:
|
|
4788
|
+
* DBOS.registerSerialization({
|
|
4789
|
+
* name: "functype",
|
|
4790
|
+
* isApplicable: Serialization.isFunctypeValue,
|
|
4791
|
+
* serialize: Serialization.toEnvelope,
|
|
4792
|
+
* deserialize: (o) => Serialization.fromEnvelope(o).orThrow(),
|
|
4793
|
+
* })
|
|
4794
|
+
*/
|
|
4795
|
+
declare const toEnvelope: (value: unknown) => JSONValue;
|
|
4796
|
+
/**
|
|
4797
|
+
* Inverse of `toEnvelope`: reconstruct any value from a parsed JSON envelope
|
|
4798
|
+
* (object/array/primitive). Equivalent to `deserialize(JSON.stringify(envelope))`
|
|
4799
|
+
* but skips the stringify/parse roundtrip — the same `revive` walker is
|
|
4800
|
+
* applied directly. Returns `Try` for the same reasons as `deserialize`.
|
|
4801
|
+
*
|
|
4802
|
+
* Pass-through policy matches `deserialize`: a parsed value without an
|
|
4803
|
+
* `@functype` marker is returned verbatim as `Success(value)`.
|
|
4804
|
+
*
|
|
4805
|
+
* Input is `unknown` (intentionally permissive — Postel's law). Host
|
|
4806
|
+
* serializers typically hand the deserialize callback a JSON-shaped value
|
|
4807
|
+
* that they parsed themselves, but their callback typing varies (some are
|
|
4808
|
+
* `JSONValue`, some are `unknown`, some are `any`). Accepting `unknown`
|
|
4809
|
+
* here means the function slots into any host shape without forcing a
|
|
4810
|
+
* cast at the consumer site.
|
|
4811
|
+
*/
|
|
4812
|
+
declare const fromEnvelope: (envelope: unknown) => Try<unknown>;
|
|
4728
4813
|
/**
|
|
4729
4814
|
* Runtime guard: is this a live functype Serializable? Checks for the
|
|
4730
4815
|
* `serialize()` method plus the `_tag` field that every Serializable instance
|
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-bfnGXuum.js";
|
|
2
|
-
import { $ as HKT, $n as reduceWiden, $t as TaskErrorInfo, A as Collection, An as Cond, At as LayerError, B as Serialization_d_exports, Bn as NonEmptyString, Bt as FieldValidation, C as isRight, Cn as isTaggedThrowable, Cr as Extractable, Ct as IO, D as Functype, Dn as Base, Dr as ParseError, Dt as TimeoutError, E as FunctypeSum, En as ThrowableType, Er as Doable, Et as Task, F as Some, Fn as BoundedNumber, Ft as Context, G as ESMap, Gn as UUID, Gt as ErrorCode, H as Obj, Hn as PatternString, Ht as Validation, I as Stack, In as BoundedString, It as ContextServices, J as KVTraversable, Jn as ValidatedBrandCompanion, Jt as TypedError, K as ESMapType, Kn as UrlString, Kt as ErrorMessage, L as Valuable, Ln as EmailAddress, Lt as HasService, M as None, Mn as InstanceType, Mt as LayerOutput, N as Option, Nn as isCompanion, Nt as Exit, O as FunctypeBase, On as Match, Ot as UIO, P as OptionConstructor, Pn as Companion, Pt as ExitTag, Q as EitherKind, Qn as reduceRightWiden, Qt as ErrorWithTaskInfo, R as ValuableParams, Rn as ISO8601Date, Rt as Tag, S as isLeft, Sn as createCancellationTokenSource, Sr as LazyList, St as TestContext, T as tryCatchAsync, Tn as Throwable, Tr as DoResult, Tt as RIO, U as Matchable, Un as PositiveInteger, Ut as ValidationRule, V as Ref, Vn as NonNegativeNumber, Vt as FormValidation, W as MatchableUtils, Wn as PositiveNumber, Wt as Validator, X as Lazy, Xn as TypeNames, Xt as ErrorChainElement, Y as Traversable, Yn as Try, Yt as TypedErrorContext, Z as Identity, Zn as Widen, Zt as ErrorFormatterOptions, _ as Right, _n as TaskMetadata, _r as fromYAML, _t as HttpStatusError, a as EmptyListError, an as DecoderError, ar as CollectionOps, at as FoldableUtils, b as TypeCheckLeft, bn as TaskResult, br as deserializeError, bt as TestClock, c as LeftError, cn as Async, cr as FunctypeEnvelope, ct as HttpClientConfig, d as isDoCapable, dn as Err, dr as createSerializationCompanion, dt as HttpRequestView, en as createErrorSerializer, er as Promisable, et as Kind, f as unwrap, fn as Ok, fr as createSerializer, ft as HttpResponse, g as LeftOf, gn as TaskFailure, gr as fromJSON, gt as HttpMethod, h as Left, hn as Task$1, hr as fromBinary, ht as HttpError, i as DoGenerator, in as Decoder, ir as Monad, it as UniversalContainer, j as List, jn as CompanionMethods, jt as LayerInput, k as FunctypeCollection, kn as UntypedMatch, kt as Layer, l as LeftErrorType, ln as CancellationToken, lr as SerializationResult, lt as HttpMethodOptions, m as EitherBase, mn as TaggedThrowable, mr as envelope, mt as DecodeError, n as Do, nn as formatStackTrace, nr as AsyncMonad, nt as OptionKind, o as FailureError, on as DecoderErrorComposite, or as ContainerOps, ot as Http, p as Either, pn as Sync, pr as createTaggedSerializer, pt as ParseMode, q as Map, qn as ValidatedBrand, qt as ErrorStatus, r as DoAsync, rn as safeStringify, rr as Functor, rt as TryKind, s as FailureErrorType, sn as DecoderErrorLeaf, sr as FUNCTYPE_MARKER, st as HttpClient, t as $, tn as formatError, tr as Applicative, tt as ListKind, u as NoneError, un as CancellationTokenSource, ur as createCustomSerializer, ut as HttpRequestOptions, v as RightOf, vn as TaskOutcome, vr as taggedEnvelope, vt as NetworkError, w as tryCatch, wn as NAME, wr as isExtractable, wt as InterruptedError, x as TypeCheckRight, xn as TaskSuccess, xr as serializeError, xt as TestClockTag, y as TestEither, yn as TaskParams, yr as SerializedError, yt as ResponseDecodeError, z as Set, zn as IntegerNumber, zt as TagService } from "./index-
|
|
2
|
+
import { $ as HKT, $n as reduceWiden, $t as TaskErrorInfo, A as Collection, An as Cond, At as LayerError, B as Serialization_d_exports, Bn as NonEmptyString, Bt as FieldValidation, C as isRight, Cn as isTaggedThrowable, Cr as Extractable, Ct as IO, D as Functype, Dn as Base, Dr as ParseError, Dt as TimeoutError, E as FunctypeSum, En as ThrowableType, Er as Doable, Et as Task, F as Some, Fn as BoundedNumber, Ft as Context, G as ESMap, Gn as UUID, Gt as ErrorCode, H as Obj, Hn as PatternString, Ht as Validation, I as Stack, In as BoundedString, It as ContextServices, J as KVTraversable, Jn as ValidatedBrandCompanion, Jt as TypedError, K as ESMapType, Kn as UrlString, Kt as ErrorMessage, L as Valuable, Ln as EmailAddress, Lt as HasService, M as None, Mn as InstanceType, Mt as LayerOutput, N as Option, Nn as isCompanion, Nt as Exit, O as FunctypeBase, On as Match, Ot as UIO, P as OptionConstructor, Pn as Companion, Pt as ExitTag, Q as EitherKind, Qn as reduceRightWiden, Qt as ErrorWithTaskInfo, R as ValuableParams, Rn as ISO8601Date, Rt as Tag, S as isLeft, Sn as createCancellationTokenSource, Sr as LazyList, St as TestContext, T as tryCatchAsync, Tn as Throwable, Tr as DoResult, Tt as RIO, U as Matchable, Un as PositiveInteger, Ut as ValidationRule, V as Ref, Vn as NonNegativeNumber, Vt as FormValidation, W as MatchableUtils, Wn as PositiveNumber, Wt as Validator, X as Lazy, Xn as TypeNames, Xt as ErrorChainElement, Y as Traversable, Yn as Try, Yt as TypedErrorContext, Z as Identity, Zn as Widen, Zt as ErrorFormatterOptions, _ as Right, _n as TaskMetadata, _r as fromYAML, _t as HttpStatusError, a as EmptyListError, an as DecoderError, ar as CollectionOps, at as FoldableUtils, b as TypeCheckLeft, bn as TaskResult, br as deserializeError, bt as TestClock, c as LeftError, cn as Async, cr as FunctypeEnvelope, ct as HttpClientConfig, d as isDoCapable, dn as Err, dr as createSerializationCompanion, dt as HttpRequestView, en as createErrorSerializer, er as Promisable, et as Kind, f as unwrap, fn as Ok, fr as createSerializer, ft as HttpResponse, g as LeftOf, gn as TaskFailure, gr as fromJSON, gt as HttpMethod, h as Left, hn as Task$1, hr as fromBinary, ht as HttpError, i as DoGenerator, in as Decoder, ir as Monad, it as UniversalContainer, j as List, jn as CompanionMethods, jt as LayerInput, k as FunctypeCollection, kn as UntypedMatch, kt as Layer, l as LeftErrorType, ln as CancellationToken, lr as SerializationResult, lt as HttpMethodOptions, m as EitherBase, mn as TaggedThrowable, mr as envelope, mt as DecodeError, n as Do, nn as formatStackTrace, nr as AsyncMonad, nt as OptionKind, o as FailureError, on as DecoderErrorComposite, or as ContainerOps, ot as Http, p as Either, pn as Sync, pr as createTaggedSerializer, pt as ParseMode, q as Map, qn as ValidatedBrand, qt as ErrorStatus, r as DoAsync, rn as safeStringify, rr as Functor, rt as TryKind, s as FailureErrorType, sn as DecoderErrorLeaf, sr as FUNCTYPE_MARKER, st as HttpClient, t as $, tn as formatError, tr as Applicative, tt as ListKind, u as NoneError, un as CancellationTokenSource, ur as createCustomSerializer, ut as HttpRequestOptions, v as RightOf, vn as TaskOutcome, vr as taggedEnvelope, vt as NetworkError, w as tryCatch, wn as NAME, wr as isExtractable, wt as InterruptedError, x as TypeCheckRight, xn as TaskSuccess, xr as serializeError, xt as TestClockTag, y as TestEither, yn as TaskParams, yr as SerializedError, yt as ResponseDecodeError, z as Set, zn as IntegerNumber, zt as TagService } from "./index-D6Zlkrnf.js";
|
|
3
3
|
import { a as isTypeable, c as SerializationMethods, d as Type, i as TypeableParams, l as Pipe, n as ExtractTag, o as Serializable, r as Typeable, s as SerializableEnvelope, t as Tuple, u as Foldable } from "./Tuple-8yRldBty.js";
|
|
4
4
|
export { $, type Applicative, Async, type AsyncMonad, Base, BoundedNumber, BoundedString, Brand, BrandedBoolean, type BrandedBoolean as BrandedBooleanType, BrandedNumber, type BrandedNumber as BrandedNumberType, BrandedString, type BrandedString as BrandedStringType, CancellationToken, CancellationTokenSource, Collection, type CollectionOps, Companion, CompanionMethods, Cond, type ContainerOps, Context, type Context as ContextType, type ContextServices, type DecodeError, Decoder, DecoderError, type DecoderErrorComposite, type DecoderErrorLeaf, Do, DoAsync, DoGenerator, type DoResult, type Doable, ESMap, ESMapType, Either, EitherBase, EitherKind, EmailAddress, EmptyListError, Err, ErrorChainElement, ErrorCode, ErrorFormatterOptions, ErrorMessage, ErrorStatus, ErrorWithTaskInfo, Exit, type Exit as ExitType, type ExitTag, type ExtractBrand, ExtractTag, type Extractable, FUNCTYPE_MARKER, FailureError, FailureErrorType, FieldValidation, Foldable, FoldableUtils, FormValidation, type Functor, Functype, FunctypeBase, FunctypeCollection, FunctypeEnvelope, FunctypeSum, HKT, type HasService, Http, HttpClient, type HttpClientConfig, type HttpError, HttpError as HttpErrors, type HttpMethod, type HttpMethodOptions, type HttpRequestOptions, type HttpRequestView, type HttpResponse, type HttpStatusError, IO, type IO as IOType, type Task as IOTask, ISO8601Date, Identity, InstanceType, IntegerNumber, InterruptedError, KVTraversable, Kind, Layer, type Layer as LayerType, type LayerError, type LayerInput, type LayerOutput, Lazy, type Lazy as LazyType, LazyList, Left, LeftError, LeftErrorType, LeftOf, List, ListKind, Map, Match, type Matchable, MatchableUtils, type Monad, NAME, type NetworkError, NonEmptyString, NonNegativeNumber, None, NoneError, Obj, Ok, Option, OptionConstructor, OptionKind, ParseError, type ParseMode, PatternString, Pipe, PositiveInteger, PositiveNumber, type Promisable, type RIO, Ref, type Ref as RefType, type ResponseDecodeError, Right, RightOf, Serializable, SerializableEnvelope, Serialization_d_exports as Serialization, SerializationMethods, SerializationResult, SerializedError, Set, Some, Stack, Sync, Tag, type Tag as TagType, type TagService, TaggedThrowable, Task$1 as Task, TaskErrorInfo, TaskFailure, TaskMetadata, TaskOutcome, TaskParams, TaskResult, TaskSuccess, TestClock, type TestClock as TestClockType, TestClockTag, TestContext, type TestContext as TestContextType, TestEither, Throwable, ThrowableType, TimeoutError, Traversable, Try, TryKind, Tuple, Type, TypeCheckLeft, TypeCheckRight, TypeNames, Typeable, TypeableParams, TypedError, TypedErrorContext, type UIO, UUID, UniversalContainer, UntypedMatch, type Unwrap, UrlString, ValidatedBrand, type ValidatedBrand as ValidatedBrandType, type ValidatedBrandCompanion, Validation, ValidationRule, Validator, Valuable, ValuableParams, type Widen, createBrander, createCancellationTokenSource, createCustomSerializer, createErrorSerializer, createSerializationCompanion, createSerializer, createTaggedSerializer, deserializeError, envelope, formatError, formatStackTrace, fromBinary, fromJSON, fromYAML, hasBrand, isCompanion, isDoCapable, isExtractable, isLeft, isRight, isTaggedThrowable, isTypeable, reduceRightWiden, reduceWiden, safeStringify, serializeError, taggedEnvelope, tryCatch, tryCatchAsync, unwrap, unwrapBrand };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Brand as e,BrandedBoolean as t,BrandedNumber as n,BrandedString as r,createBrander as i,hasBrand as a,unwrap as o}from"./branded/index.js";import{$ as s,A as c,At as l,B as u,C as d,Ct as f,D as p,Dt as m,E as h,Et as g,F as _,Ft as v,G as y,H as b,I as x,It as S,J as C,K as w,L as T,Lt as E,M as D,Mt as O,N as k,Nt as A,O as j,Ot as M,P as N,Pt as P,Q as F,R as I,S as L,St as R,T as z,Tt as B,U as V,V as H,W as U,X as W,Y as G,Z as K,_ as q,_t as J,a as Y,at as X,b as Z,bt as Q,c as $,ct as ee,d as te,dt as ne,et as re,f as ie,ft as ae,g as oe,gt as se,h as ce,ht as le,i as ue,it as de,j as fe,jt as pe,k as me,kt as he,l as ge,lt as _e,m as ve,mt as ye,n as be,nt as xe,o as Se,ot as Ce,p as we,pt as Te,q as Ee,r as De,rt as Oe,s as ke,st as Ae,t as je,tt as Me,u as Ne,ut as Pe,v as Fe,vt as Ie,w as Le,wt as Re,x as ze,xt as Be,y as Ve,yt as He,z as Ue}from"./src-
|
|
1
|
+
import{Brand as e,BrandedBoolean as t,BrandedNumber as n,BrandedString as r,createBrander as i,hasBrand as a,unwrap as o}from"./branded/index.js";import{$ as s,A as c,At as l,B as u,C as d,Ct as f,D as p,Dt as m,E as h,Et as g,F as _,Ft as v,G as y,H as b,I as x,It as S,J as C,K as w,L as T,Lt as E,M as D,Mt as O,N as k,Nt as A,O as j,Ot as M,P as N,Pt as P,Q as F,R as I,S as L,St as R,T as z,Tt as B,U as V,V as H,W as U,X as W,Y as G,Z as K,_ as q,_t as J,a as Y,at as X,b as Z,bt as Q,c as $,ct as ee,d as te,dt as ne,et as re,f as ie,ft as ae,g as oe,gt as se,h as ce,ht as le,i as ue,it as de,j as fe,jt as pe,k as me,kt as he,l as ge,lt as _e,m as ve,mt as ye,n as be,nt as xe,o as Se,ot as Ce,p as we,pt as Te,q as Ee,r as De,rt as Oe,s as ke,st as Ae,t as je,tt as Me,u as Ne,ut as Pe,v as Fe,vt as Ie,w as Le,wt as Re,x as ze,xt as Be,y as Ve,yt as He,z as Ue}from"./src-D3v1n1vv.js";import{a as We,c as Ge,d as Ke,i as qe,l as Je,n as Ye,o as Xe,p as Ze,r as Qe,s as $e,t as et,u as tt}from"./Tuple-knEoDiKZ.js";export{c as $,W as Base,re as BoundedNumber,Me as BoundedString,e as Brand,t as BrandedBoolean,n as BrandedNumber,r as BrandedString,Ze as Companion,F as Cond,L as Context,Ue as Decoder,u as DecoderError,fe as Do,D as DoAsync,b as ESMap,Te as Either,xe as EmailAddress,k as EmptyListError,V as Err,ze as Exit,Ye as FUNCTYPE_MARKER,N as FailureError,ge as FoldableUtils,$ as HKT,Ne as Http,ie as HttpClient,te as HttpErrors,Fe as IO,Oe as ISO8601Date,ke as Identity,de as IntegerNumber,Ve as InterruptedError,q as Layer,Se as Lazy,g as LazyList,ye as Left,_ as LeftError,R as List,H as Map,K as Match,Y as MatchableUtils,C as NAME,X as NonEmptyString,Ce as NonNegativeNumber,pe as None,x as NoneError,ue as Obj,U as Ok,O as Option,A as OptionConstructor,E as ParseError,Ae as PatternString,ee as PositiveInteger,_e as PositiveNumber,m as Ref,le as Right,be as Serialization,M as Set,P as Some,De as Stack,oe as Tag,y as Task,we as TestClock,ve as TestClockTag,ce as TestContext,G as Throwable,Z as TimeoutError,B as Try,et as Tuple,se as TypeCheckLeft,J as TypeCheckRight,f as Typeable,z as TypedError,Pe as UUID,ne as UrlString,ae as ValidatedBrand,Le as Validation,je as Valuable,i as createBrander,w as createCancellationTokenSource,Qe as createCustomSerializer,h as createErrorSerializer,qe as createSerializationCompanion,We as createSerializer,Xe as createTaggedSerializer,v as deserializeError,$e as envelope,p as formatError,j as formatStackTrace,Ge as fromBinary,Je as fromJSON,tt as fromYAML,a as hasBrand,s as isCompanion,T as isDoCapable,d as isExtractable,Ie as isLeft,He as isRight,Ee as isTaggedThrowable,Re as isTypeable,he as reduceRightWiden,l as reduceWiden,me as safeStringify,S as serializeError,Ke as taggedEnvelope,Q as tryCatch,Be as tryCatchAsync,I as unwrap,o as unwrapBrand};
|
package/dist/list/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { j as List } from "../index-
|
|
1
|
+
import { j as List } from "../index-D6Zlkrnf.js";
|
|
2
2
|
export { List };
|
package/dist/list/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{St as e}from"../src-
|
|
1
|
+
import{St as e}from"../src-D3v1n1vv.js";export{e as List};
|
package/dist/map/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { q as Map } from "../index-
|
|
1
|
+
import { q as Map } from "../index-D6Zlkrnf.js";
|
|
2
2
|
export { Map };
|
package/dist/map/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{V as e}from"../src-
|
|
1
|
+
import{V as e}from"../src-D3v1n1vv.js";export{e as Map};
|
package/dist/option/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { F as Some, M as None, N as Option, P as OptionConstructor } from "../index-
|
|
1
|
+
import { F as Some, M as None, N as Option, P as OptionConstructor } from "../index-D6Zlkrnf.js";
|
|
2
2
|
export { None, Option, OptionConstructor, Some };
|
package/dist/option/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Mt as e,Nt as t,Pt as n,jt as r}from"../src-
|
|
1
|
+
import{Mt as e,Nt as t,Pt as n,jt as r}from"../src-D3v1n1vv.js";export{r as None,e as Option,t as OptionConstructor,n as Some};
|
package/dist/set/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { z as Set } from "../index-
|
|
1
|
+
import { z as Set } from "../index-D6Zlkrnf.js";
|
|
2
2
|
export { Set };
|
package/dist/set/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Ot as e}from"../src-
|
|
1
|
+
import{Ot as e}from"../src-D3v1n1vv.js";export{e as Set};
|
|
@@ -14,4 +14,4 @@ import{t as e}from"./chunk-DK3Fl9T5.js";import{Brand as t}from"./branded/index.j
|
|
|
14
14
|
`)}function Xt(e,t){let n={...qt,...t},r=e instanceof Error?e:Qe.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=Yt(e.stack).split(`
|
|
15
15
|
`).slice(1),i=n.maxStackFrames??qt.maxStackFrames??3,a=t.slice(0,i).map(e=>`${r} ${n.colors?`\x1B[90m`:``}${e}${n.colors?`\x1B[0m`:``}`).join(`
|
|
16
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${Jt(e)}`:`\n\nContext:\n${Jt(e)}`;a+=t}}return a}function Zt(){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?Yt(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?Yt(e.stack):void 0})))}catch{}return Object.getOwnPropertyNames(t).forEach(e=>{n[e]||(n[e]=t[e])}),n}}const P=(e,t,n,r)=>i(Qe.apply(t,n,{name:e,description:t}),{code:e,message:t,status:Qt(e),context:n,timestamp:new Date().toISOString(),traceId:r?.traceId}),Qt=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],F=Object.assign(P,{validation:(e,t,n)=>P(`VALIDATION_FAILED`,`Validation failed: ${e} ${n}`,{field:e,value:t,rule:n}),network:(e,t,n)=>P(`NETWORK_ERROR`,`Network error: ${t} ${e}${n?` (${n})`:``}`,{url:e,method:t,statusCode:n}),auth:(e,t)=>P(`AUTH_REQUIRED`,`Authentication required: ${e}${t?` (role: ${t})`:``}`,{resource:e,requiredRole:t}),notFound:(e,t)=>P(`NOT_FOUND`,`Not found: ${e} with id ${t}`,{resource:e,id:t}),permission:(e,t,n)=>P(`PERMISSION_DENIED`,`Permission denied: cannot ${e} ${t}`,{action:e,resource:t,userId:n}),rateLimit:(e,t,n)=>P(`RATE_LIMITED`,`Rate limit exceeded: ${e} requests per ${t}`,{limit:e,window:t,retryAfter:n}),internal:e=>P(`INTERNAL_ERROR`,`Internal server error: ${e}`,{errorId:e,timestamp:new Date().toISOString()}),badRequest:(e,t)=>P(`BAD_REQUEST`,`Bad request: ${e}`,{reason:e,expected:t}),conflict:(e,t)=>P(`CONFLICT`,`Conflict: ${e} already exists with value ${t}`,{resource:e,conflictingValue:t}),timeout:(e,t)=>P(`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}),I={rule:e=>t=>{if(e===`email`)return typeof t!=`string`||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)?E(F.validation(`value`,t,`must be a valid email`)):T(t);if(e===`url`)try{return new URL(String(t)),T(t)}catch{return E(F.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)?E(F.validation(`value`,t,`must be a valid UUID`)):T(t);if(e===`required`)return t==null||t===``?E(F.validation(`value`,t,`is required`)):T(t);if(e===`numeric`)return typeof t!=`number`&&!/^\d+$/.test(String(t))?E(F.validation(`value`,t,`must be numeric`)):T(t);if(e===`alpha`)return typeof t!=`string`||!/^[a-zA-Z]+$/.test(t)?E(F.validation(`value`,t,`must contain only letters`)):T(t);if(e===`alphanumeric`)return typeof t!=`string`||!/^[a-zA-Z0-9]+$/.test(t)?E(F.validation(`value`,t,`must be alphanumeric`)):T(t);if(e.startsWith(`min:`)){let n=Number(e.split(`:`)[1]),r=Number(t);return isNaN(r)||r<n?E(F.validation(`value`,t,`must be at least ${n}`)):T(t)}if(e.startsWith(`max:`)){let n=Number(e.split(`:`)[1]),r=Number(t);return isNaN(r)||r>n?E(F.validation(`value`,t,`must be at most ${n}`)):T(t)}if(e.startsWith(`minLength:`)){let n=Number(e.split(`:`)[1]);return String(t).length<n?E(F.validation(`value`,t,`must be at least ${n} characters`)):T(t)}if(e.startsWith(`maxLength:`)){let n=Number(e.split(`:`)[1]);return String(t).length>n?E(F.validation(`value`,t,`must be at most ${n} characters`)):T(t)}if(e.startsWith(`pattern:`)){let n=e.substring(8);return new RegExp(n).test(String(t))?T(t):E(F.validation(`value`,t,`must match pattern ${n}`))}if(e.startsWith(`in:`)){let n=e.substring(3).split(`,`);return n.includes(String(t))?T(t):E(F.validation(`value`,t,`must be one of: ${n.join(`, `)}`))}if(e.startsWith(`notIn:`)){let n=e.substring(6).split(`,`);return n.includes(String(t))?E(F.validation(`value`,t,`must not be one of: ${n.join(`, `)}`)):T(t)}if(e===`date`){let e=new Date(String(t));return isNaN(e.getTime())?E(F.validation(`value`,t,`must be a valid date`)):T(t)}if(e===`future`){let e=new Date(String(t));return isNaN(e.getTime())||e<=new Date?E(F.validation(`value`,t,`must be a future date`)):T(t)}if(e===`past`){let e=new Date(String(t));return isNaN(e.getTime())||e>=new Date?E(F.validation(`value`,t,`must be a past date`)):T(t)}return T(t)},combine:(...e)=>t=>{for(let n of e){let e=n(t);if(e.isLeft())return e}return T(t)},custom:(e,t)=>n=>e(n)?T(n):E(F.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=F.validation(i,e,t.context.rule);n.push(r)}else r[i]=o.orThrow()}return n.length>0?E(w(n)):T(r)}},$t={...I,validators:{email:I.rule(`email`),url:I.rule(`url`),uuid:I.rule(`uuid`),required:I.rule(`required`),numeric:I.rule(`numeric`),positiveNumber:I.combine(I.rule(`numeric`),I.rule(`min:0`)),nonEmptyString:I.combine(I.rule(`required`),I.custom(e=>typeof e==`string`&&e.trim().length>0,`must not be empty`))}},en=i(I.rule,$t);function tn(e){return typeof e==`object`&&!!e&&`orThrow`in e&&typeof e.orThrow==`function`}function nn(e){return tn(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 rn=e=>({_tag:`Context`,services:e,get(t){let n=e.get(t.id);return n===void 0?m():f(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),rn(r)},merge(t){let n=new Map(e);for(let[e,r]of t.services)n.set(e,r);return rn(n)},get size(){return e.size},toString(){return`Context(${Array.from(e.keys()).join(`, `)})`}}),L={empty:()=>rn(new Map),make:(e,t)=>{let n=new Map;return n.set(e.id,t),rn(n)},isContext:e=>typeof e==`object`&&!!e&&e._tag===`Context`},R=e=>({[Symbol.toStringTag]:`Exit`,_tag:`Success`,isSuccess(){return!0},isFailure(){return!1},isInterrupted(){return!1},map(t){return R(t(e))},mapError(t){return R(e)},mapBoth(t,n){return R(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 f(e)},toEither(){return T(e)},toValue(){return{_tag:`Success`,value:e}},toString(){return`Exit.Success(${r(e)})`},toJSON(){return{_tag:`Success`,value:e}}}),an=e=>({[Symbol.toStringTag]:`Exit`,_tag:`Failure`,isSuccess(){return!1},isFailure(){return!0},isInterrupted(){return!1},map(t){return an(e)},mapError(t){return an(t(e))},mapBoth(t,n){return an(t(e))},flatMap(t){return an(e)},fold(t,n,r){return t(e)},match(t){return t.Failure(e)},orThrow(){throw e},orElse(e){return e},toOption(){return m()},toEither(){return E(e)},toValue(){return{_tag:`Failure`,error:e}},toString(){return`Exit.Failure(${r(e)})`},toJSON(){return{_tag:`Failure`,error:e}}}),on=e=>({[Symbol.toStringTag]:`Exit`,_tag:`Interrupted`,isSuccess(){return!1},isFailure(){return!1},isInterrupted(){return!0},map(t){return on(e)},mapError(t){return on(e)},mapBoth(t,n){return on(e)},flatMap(t){return on(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 m()},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}}}),z=s(e=>R(e),{succeed:e=>R(e),fail:e=>an(e),interrupt:e=>on(e),interrupted:()=>on(`interrupted`),isSuccess:e=>e.isSuccess(),isFailure:e=>e.isFailure(),isInterrupted:e=>e.isInterrupted(),fromEither:e=>e.isRight()?R(e.value):an(e.value),fromOption:(e,t)=>e.isSome()?R(e.value):an(t()),zip:(e,t)=>e.isInterrupted()?e:t.isInterrupted()?t:e.isFailure()?e:t.isFailure()?t:R([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 R(t)}}),B=e=>e;var sn=class extends Error{constructor(e,t){super(t??`Effect timed out after ${e}ms`),this.duration=e,this._tag=`TimeoutError`,this.name=`TimeoutError`}},cn=class extends Error{constructor(e){super(e??`Effect was interrupted`),this._tag=`InterruptedError`,this.name=`InterruptedError`}};const ln=Symbol.for(`functype/IO/effect`),V=e=>e[ln],H=e=>{let t={[Symbol.toStringTag]:`IO`,[ln]:e,map(e){return H(B({_tag:`Map`,effect:t,f:e}))},flatMap(e){return H(B({_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 H(B({_tag:`MapError`,effect:t,f:e}))},tapError(e){return t.mapError(t=>(e(t),t))},recover(e){return H(B({_tag:`Recover`,effect:t,fallback:e}))},recoverWith(e){return H(B({_tag:`RecoverWith`,effect:t,f:e}))},fold(e,n){return H(B({_tag:`Fold`,effect:t,onFailure:e,onSuccess:n}))},match(e){return t.fold(e.failure,e.success)},catchTag(e,n){return H(B({_tag:`RecoverWith`,effect:t,f:t=>typeof t==`object`&&t&&`_tag`in t&&t._tag===e?B(n(t)):B(G.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(()=>G.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 H(B({_tag:`ProvideContext`,effect:t,context:e}))},provideService(e,n){return H(B({_tag:`ProvideContext`,effect:t,context:L.make(e,n)}))},provideLayer(e){return B(B(G.async(async()=>{let t=L.empty();return await e.build(B(t))})).flatMap(e=>H(B({_tag:`ProvideContext`,effect:t,context:e}))))},async run(){let e=await W(V(this));return e.isSuccess()?T(e.orThrow()):E(e.isFailure()?e.toValue().error:new cn)},async runOrThrow(){let e=await W(V(this));if(e.isSuccess())return e.orThrow();throw e.isFailure()?e.toValue().error:new cn},runSync(){try{return T(U(V(this)))}catch(e){return E(e)}},runSyncOrThrow(){return U(V(this))},async runExit(){return W(V(this))},async runOption(){let e=await W(V(this));return e.isSuccess()?f(e.orThrow()):m()},async runTry(){let e=await W(V(this));if(e.isSuccess())return B(S(()=>e.orThrow()));let t=e.isFailure()?e.toValue().error:Error(`Effect was interrupted`);return B(S(()=>{throw t}))},pipe(e){return e(t)},delay(e){return B(G.async(()=>new Promise(t=>setTimeout(t,e))).flatMap(()=>t))},timeout(e){return H(B({_tag:`Timeout`,effect:t,duration:e}))},timeoutTo(e,n){return B(t.timeout(e).recover(B(n)))},toString(){return`IO(${r(e._tag)})`},toJSON(){return{_tag:`IO`,effect:e._tag}},*[Symbol.iterator](){return yield t}};return t},U=(e,t=L.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=U(V(e.effect),t);return e.f(n)}case`FlatMap`:{let n=U(V(e.effect),t);return U(V(e.f(n)),t)}case`MapError`:try{return U(V(e.effect),t)}catch(t){throw e.f(t)}case`Recover`:try{return U(V(e.effect),t)}catch{return e.fallback}case`RecoverWith`:try{return B(U(V(e.effect),t))}catch(n){return U(V(e.f(n)),t)}case`Fold`:try{let n=U(V(e.effect),t);return e.onSuccess(n)}catch(t){return e.onFailure(t)}case`Service`:{let n=t.get(e.tag);if(n.isNone())throw Error(`Service not found: ${e.tag.id}`);return n.orThrow()}case`ProvideContext`:{let n=t.merge(e.context);return U(V(e.effect),n)}case`Interrupt`:throw new cn;case`Bracket`:{let n=U(V(e.acquire),t);try{return U(V(e.use(n)),t)}finally{U(V(e.release(n)),t)}}case`BracketExit`:{let n=U(V(e.acquire),t),r;try{let i=U(V(e.use(n)),t);return r=B(z.succeed(i)),i}catch(e){throw r=B(z.fail(e)),e}finally{U(V(e.release(n,r)),t)}}case`Race`:throw Error(`Cannot run race effect synchronously`);case`Timeout`:throw Error(`Cannot run timeout effect synchronously`)}},W=async(e,t=L.empty())=>{try{switch(e._tag){case`Succeed`:return B(z.succeed(e.value));case`Fail`:return B(z.fail(e.error));case`Die`:throw e.defect;case`Sync`:return B(z.succeed(e.thunk()));case`Async`:{let t=await e.thunk();return B(z.succeed(t))}case`Auto`:{let t=e.thunk();return t instanceof Promise?B(z.succeed(await t)):B(z.succeed(t))}case`Map`:{let n=await W(V(e.effect),t);return n.isSuccess()?B(z.succeed(e.f(n.orThrow()))):B(n)}case`FlatMap`:{let n=await W(V(e.effect),t);return n.isSuccess()?W(V(e.f(n.orThrow())),t):B(n)}case`MapError`:{let n=await W(V(e.effect),t);return n.isSuccess()?B(n):n.isFailure()?B(z.fail(e.f(n.toValue().error))):B(n)}case`Recover`:{let n=await W(V(e.effect),t);return n.isSuccess()?n:z.succeed(e.fallback)}case`RecoverWith`:{let n=await W(V(e.effect),t);return n.isSuccess()?B(n):n.isFailure()?W(V(e.f(n.toValue().error)),t):B(n)}case`Fold`:{let n=await W(V(e.effect),t);return n.isSuccess()?z.succeed(e.onSuccess(n.orThrow())):n.isFailure()?z.succeed(e.onFailure(n.toValue().error)):n}case`Service`:{let n=t.get(e.tag);return n.isNone()?z.fail(Error(`Service not found: ${e.tag.id}`)):z.succeed(n.orThrow())}case`ProvideContext`:{let n=t.merge(e.context);return W(V(e.effect),n)}case`Interrupt`:return z.interrupted();case`Bracket`:{let n=await W(V(e.acquire),t);if(!n.isSuccess())return n;let r=n.orThrow();try{return await W(V(e.use(r)),t)}finally{await W(V(e.release(r)),t)}}case`BracketExit`:{let n=await W(V(e.acquire),t);if(!n.isSuccess())return n;let r=n.orThrow(),i=await W(V(e.use(r)),t);return await W(V(e.release(r,i)),t),i}case`Race`:return e.effects.length===0?z.fail(Error(`No effects to race`)):await Promise.race(e.effects.map(e=>W(V(e),t)));case`Timeout`:{let n=new Promise(t=>setTimeout(()=>t(z.fail(new sn(e.duration))),e.duration)),r=W(V(e.effect),t);return Promise.race([r,n])}}}catch(e){return z.fail(e)}},G={sync:e=>H({_tag:`Sync`,thunk:e}),succeed:e=>H({_tag:`Succeed`,value:e}),fail:e=>H({_tag:`Fail`,error:e}),die:e=>H({_tag:`Die`,defect:e}),async:e=>H(B({_tag:`Async`,thunk:e})),tryPromise:e=>H({_tag:`Async`,thunk:e.try}).mapError(e.catch),tryCatch:(e,t)=>G.sync(()=>{try{return e()}catch(e){throw t(e)}}),liftSync:e=>(...t)=>G.sync(()=>e(...t)),liftPromise:e=>(...t)=>G.async(()=>e(...t)),fromEither:e=>B(e.isRight()?G.succeed(e.value):G.fail(e.value)),fromOption:e=>B(e.isSome()?G.succeed(e.value):G.fail(void 0)),fromOptionOrFail:(e,t)=>B(e.isSome()?G.succeed(e.value):G.fail(t())),fromTry:e=>B(e.isSuccess()?G.succeed(e.orThrow()):G.fail(e.error)),fromResult:e=>B(e.error?G.fail(e.error):G.succeed(h(e.data))),tryAsync:(e,t,n)=>n?.aborted?B(G.fail(t(n.reason??new DOMException(`Aborted`,`AbortError`)))):G.async(()=>e(n)).mapError(t),asyncResult:(e,t,n)=>{let r=n?.dataKey??`data`,i=n?.errorKey??`error`;return G.tryAsync(t=>e(t),t,n?.signal).flatMap(e=>G.fromResult({data:e[r],error:e[i]}))},service:e=>H({_tag:`Service`,tag:e}),serviceWith:(e,t)=>G.service(e).map(t),serviceWithIO:(e,t)=>G.service(e).flatMap(t),withServices:(e,t)=>{let n=Object.entries(e);if(n.length===0)return B(H({_tag:`Auto`,thunk:()=>t({})}));let r=B(G.succeed({}));return B(n.reduce((e,[t,n])=>B(e.flatMap(e=>G.service(n).map(n=>({...e,[t]:n})))),r).flatMap(e=>H({_tag:`Auto`,thunk:()=>t(e)})))},all:e=>{if(e.length===0)return B(G.succeed([]));let t=B(G.succeed([]));return B(e.reduce((e,t)=>e.flatMap(e=>t.map(t=>[...e,t])),t))},firstSuccessOf:e=>e.length===0?B(G.fail(Error(`No effects provided`))):e.reduce((e,t)=>e.recoverWith(()=>t)),sleep:e=>B(G.async(()=>new Promise(t=>setTimeout(t,e)))),never:()=>B(G.async(()=>new Promise(()=>{}))),get unit(){return B(H({_tag:`Succeed`,value:void 0}))},fromNullable:e=>B(e==null?G.fail(void 0):G.succeed(e)),interrupt:()=>H({_tag:`Interrupt`}),bracket:(e,t,n)=>H({_tag:`Bracket`,acquire:e,use:t,release:n}),acquireRelease:(e,t,n)=>G.bracket(e,t,n),bracketExit:(e,t,n)=>H({_tag:`BracketExit`,acquire:e,use:t,release:n}),race:e=>H({_tag:`Race`,effects:e}),any:e=>e.length===0?B(G.fail(Error(`No effects provided`))):e.reduce((e,t)=>e.recoverWith(()=>t)),forEach:(e,t)=>{if(e.length===0)return B(G.succeed([]));let n=B(G.succeed([]));return B(e.reduce((e,n)=>e.flatMap(e=>t(n).map(t=>[...e,t])),n))},forEachPar:(e,t)=>G.forEach(e,t),timeout:(e,t)=>H(B({_tag:`Timeout`,effect:e,duration:t})),gen:e=>B(G.sync(()=>{let t=e(),n=e=>{let r=t.next(e);return r.done?B(G.succeed(r.value)):B(r.value.flatMap(e=>n(e)))};return n(void 0)}).flatMap(e=>e)),get Do(){return un(G.succeed({}))}},un=e=>({effect:e,bind(t,n){return un(e.flatMap(e=>n(e).map(n=>({...e,[t]:n}))))},let(t,n){return un(e.map(e=>({...e,[t]:n(e)})))},map(t){return e.map(t)},flatMap(t){return e.flatMap(t)},tap(t){return un(e.tap(t))},tapEffect(t){return un(e.tapEffect(t))},done(){return e}}),K=s(e=>H(B({_tag:`Auto`,thunk:e})),G),q=(e,t)=>({_tag:`Layer`,build:e,provideToAndMerge(t){return q(async n=>{let r=await e(n),i=n.merge(r),a=await t.build(i);return r.merge(a)})},merge(t){return q(async n=>{let[r,i]=await Promise.all([e(n),t.build(n)]);return r.merge(i)})},map(t){return q(async n=>t(await e(n)))},toString(){return`Layer(${t??`anonymous`})`}}),dn={succeed:(e,t)=>q(()=>Promise.resolve(L.make(e,t)),e.id),effect:(e,t)=>q(async()=>{let n=await t();return L.make(e,n)},e.id),sync:(e,t)=>q(()=>Promise.resolve(L.make(e,t())),e.id),fromService:(e,t,n)=>q(r=>{let i=r.unsafeGet(t);return Promise.resolve(L.make(e,n(i)))},e.id),fromServiceEffect:(e,t,n)=>q(async r=>{let i=await n(r.unsafeGet(t));return L.make(e,i)},e.id),fromContext:e=>q(()=>Promise.resolve(e)),empty:()=>q(()=>Promise.resolve(L.empty()),`empty`),mergeAll:(...e)=>q(async t=>(await Promise.all(e.map(e=>e.build(t)))).reduce((e,t)=>e.merge(t),L.empty()))},fn=e=>({id:e,_tag:`Tag`,toString(){return`Tag(${e})`}}),pn=()=>{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})})}}},mn=fn(`TestClock`),hn={make:pn,tag:mn,test:async e=>e(pn()),get:K.service(mn),advance:e=>K.serviceWithIO(mn,t=>K.async(()=>t.advance(e))),setTime:e=>K.serviceWithIO(mn,t=>K.async(()=>t.setTime(e))),runAll:K.serviceWithIO(mn,e=>K.async(()=>e.runAll())),context:()=>{let e=pn();return{clock:e,context:L.make(mn,e)}}},gn={make:()=>{let e=pn(),t=L.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=pn();return gn.make().withService(mn,e)}},_n=fn(`HttpClient`),vn={},yn=s({},{networkError:(e,t,n)=>({_tag:`NetworkError`,url:e,method:t,cause:n}),httpStatusError:(e,t,n,r,i)=>({_tag:`HttpStatusError`,url:e,method:t,status:n,statusText:r,body:i}),decodeError:(e,t,n,r)=>({_tag:`DecodeError`,url:e,method:t,body:n,cause:r}),isNetworkError:e=>e._tag===`NetworkError`,isHttpStatusError:e=>e._tag===`HttpStatusError`,isDecodeError:e=>e._tag===`DecodeError`,match:(e,t)=>{switch(e._tag){case`NetworkError`:return t.NetworkError(e);case`HttpStatusError`:return t.HttpStatusError(e);case`DecodeError`:return t.DecodeError(e)}}}),bn=(e,t)=>!e||t.startsWith(`http://`)||t.startsWith(`https://`)?t:`${e.endsWith(`/`)?e.slice(0,-1):e}${t.startsWith(`/`)?t:`/${t}`}`,xn=(e,t)=>e[Symbol.toStringTag]===t,J=(e,t)=>{if(typeof e!=`object`||!e||e instanceof Date||e instanceof RegExp||typeof Buffer<`u`&&e instanceof Buffer)return e;if(xn(e,`Option`)){let n=e;return t===`tagged`?n._tag===`None`?{_tag:`None`,value:null}:{_tag:`Some`,value:J(n.value,t)}:n._tag===`None`?null:J(n.value,t)}if(xn(e,`Either`)){let n=e;if(t===`tagged`)return{_tag:n._tag,value:J(n.value,t)};if(n._tag===`Left`)throw Error(`Cannot serialize a Left in a request body — Either's failure path should not cross the wire as data. Resolve the Left before sending, or omit the field. (Left value: ${JSON.stringify(n.value)})`);return J(n.value,t)}if(xn(e,`Try`)){let n=e;if(t===`tagged`){if(n._tag===`Failure`){let e=n.error??Error(`unknown`);return{_tag:`Failure`,error:e.message,stack:e.stack}}return{_tag:`Success`,value:J(n.value,t)}}if(n._tag===`Failure`)throw n.error??Error(`Cannot serialize a Try Failure in a request body`);return J(n.value,t)}if(xn(e,`List`)){let n=e.toArray().map(e=>J(e,t));return t===`tagged`?{_tag:`List`,value:n}:n}if(xn(e,`FunctypeMap`)){let n=e.toValue().value;if(t===`tagged`)return{_tag:`Map`,value:n.map(([e,n])=>[e,J(n,t)])};let r={};for(let[e,i]of n){if(typeof e!=`string`)throw Error(`Cannot serialize Map with non-string keys to JSON (key: ${String(e)})`);r[e]=J(i,t)}return r}if(Array.isArray(e))return e.map(e=>J(e,t));let n={};for(let r of Object.keys(e))n[r]=J(e[r],t);return n},Sn=(e,t)=>{if(e==null)return{serialized:void 0,contentType:void 0};if(typeof e==`string`)return{serialized:e,contentType:void 0};if(typeof e==`object`||Array.isArray(e)){let n=J(e,t?`primitive`:`tagged`);return{serialized:JSON.stringify(n),contentType:`application/json`}}return{serialized:String(e),contentType:void 0}},Cn=e=>{let t=e.get(`content-type`)??``;return t.includes(`application/json`)?`json`:t.startsWith(`text/`)?`text`:`raw`},wn=async(e,t,n,r,i,a)=>{let o=t??Cn(e.headers),s,c={};switch(o){case`json`:{let t=await e.text();c.value=t;try{s=JSON.parse(t)}catch(e){throw yn.decodeError(n,r,t,e)}break}case`text`:s=await e.text(),c.value=s;break;case`blob`:s=await e.blob();break;case`arrayBuffer`:s=await e.arrayBuffer();break;case`raw`:s=e;break}let l;if(i){let e=i(s);if(e.isLeft()){let t=c.value??(typeof s==`string`?s:JSON.stringify(s));throw yn.decodeError(n,r,t,e.value)}l=e.value}else if(a)try{l=a(s)}catch(e){let t=c.value??(typeof s==`string`?s:JSON.stringify(s));throw yn.decodeError(n,r,t,e)}else l=s;return{data:l,status:e.status,statusText:e.statusText,headers:e.headers}},Tn=(e,t)=>{let n={url:bn(e.baseUrl,t.url),method:t.method,headers:{...e.defaultHeaders,...t.headers},body:t.body,signal:t.signal,parseAs:t.parseAs,flatten:t.flatten};return(e.beforeRequest?e.beforeRequest(n):K.succeed(n)).flatMap(n=>{let r=n.flatten??!0,i=(()=>{try{return{ok:!0,value:Sn(n.body,r)}}catch(e){return{ok:!1,cause:e}}})();if(!i.ok)return K.fail(yn.networkError(n.url,n.method,i.cause));let{serialized:a,contentType:o}=i.value,s={...n.headers,...o?{"Content-Type":o}:{}};return K.tryAsync(r=>(e.fetch??globalThis.fetch)(n.url,{method:n.method,headers:s,body:a,signal:n.signal??r}).then(async e=>{if(!e.ok){let t=await e.text().catch(()=>``);throw yn.httpStatusError(n.url,n.method,e.status,e.statusText,t)}return wn(e,n.parseAs,n.url,n.method,t.decode,t.validate)}),e=>typeof e==`object`&&e&&`_tag`in e?e:yn.networkError(n.url,n.method,e))})},En=e=>Tn(vn,e),Dn=s({},{request:En,get:(e,t)=>En({...t,url:e,method:`GET`}),post:(e,t)=>En({...t,url:e,method:`POST`}),put:(e,t)=>En({...t,url:e,method:`PUT`}),patch:(e,t)=>En({...t,url:e,method:`PATCH`}),delete:(e,t)=>En({...t,url:e,method:`DELETE`}),head:(e,t)=>En({...t,url:e,method:`HEAD`,parseAs:`raw`}),options:(e,t)=>En({...t,url:e,method:`OPTIONS`,parseAs:`raw`}),client:e=>({request:t=>Tn(e,t),get:(t,n)=>Tn(e,{...n,url:t,method:`GET`}),post:(t,n)=>Tn(e,{...n,url:t,method:`POST`}),put:(t,n)=>Tn(e,{...n,url:t,method:`PUT`}),patch:(t,n)=>Tn(e,{...n,url:t,method:`PATCH`}),delete:(t,n)=>Tn(e,{...n,url:t,method:`DELETE`}),head:(t,n)=>Tn(e,{...n,url:t,method:`HEAD`,parseAs:`raw`}),options:(t,n)=>Tn(e,{...n,url:t,method:`OPTIONS`,parseAs:`raw`})})}),On={toOption:e=>e.fold(()=>m(),e=>f(e)),toList:e=>e.fold(()=>w([]),e=>w([e])),toEither:(e,t)=>e.fold(()=>E(t),e=>T(e)),isEmpty:e=>e.fold(()=>!0,()=>!1),size:e=>e.fold(()=>0,()=>1)},kn=e=>typeof e==`object`&&!!e&&(e._tag===`Some`||e._tag===`None`),Y=e=>typeof e==`object`&&!!e&&e._tag===`List`,An=e=>typeof e==`object`&&!!e&&(e._tag===`Left`||e._tag===`Right`),jn=e=>typeof e==`object`&&!!e&&(e._tag===`Success`||e._tag===`Failure`),X=()=>{let e=(e,t)=>{if(kn(e)||Y(e)||An(e)||jn(e))return e.map(e=>t(e));throw Error(`Unsupported functor type: ${JSON.stringify(e)}`)},t=e=>{if(kn(e))return e.orThrow();if(Y(e)){let t=e.toArray();if(t.length>0&&Y(t[0])){let e=[];for(let n of t)Y(n)&&e.push(...n.toArray());return w(e)}return e.flatten()}if(An(e))return e.isRight()?e.fold(()=>null,e=>e):e;if(jn(e))return e.isSuccess()?e.orThrow():e;throw Error(`Unsupported functor type for flatten: ${JSON.stringify(e)}`)},n=(e,t)=>{if(kn(e)||Y(e)||An(e)||jn(e))return e.flatMap(e=>t(e));throw Error(`Unsupported functor type for flatMap: ${JSON.stringify(e)}`)},r=(e,t)=>{if(kn(e)&&kn(t)||Y(e)&&Y(t)||An(e)&&An(t)||jn(e)&&jn(t))return e.flatMap(e=>t.map(t=>e(t)));throw Error(`Unsupported functor type for ap: ${JSON.stringify(e)}`)},i=e=>{if(kn(e)){let t=e;if(t.isEmpty)return w([h.none()]);let n=t.orThrow();if(Y(n))return n.map(e=>h(e));throw Error(`Unsupported inner container type for sequence`)}if(Y(e)){let t=e.toArray();if(t.length===0)return h.none();let n=t[0];if(kn(n)){for(let e of t)if(e.isEmpty)return h.none();return h(w(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`}},Mn=X();X.map=(e,t)=>Mn.map(e,t),X.flatten=e=>Mn.flatten(e),X.flatMap=(e,t)=>Mn.flatMap(e,t),X.ap=(e,t)=>Mn.ap(e,t),X.sequence=e=>Mn.sequence(e),X.traverse=(e,t)=>Mn.traverse(e,t),X.isOption=kn,X.isList=Y,X.isEither=An,X.isTry=jn;const Nn=e=>({id:e,isSame:t=>t.id===e}),Pn=s(Nn,{of:e=>Nn(e),pure:e=>Nn(e)}),Fn=e=>{let t=!1,i,a,s=!1,c=()=>{if(!t)try{i=e(),t=!0}catch(e){throw a=e,s=!0,t=!0,e}if(s)throw a;return i};return{[Symbol.toStringTag]:`Lazy`,_tag:`Lazy`,get isEvaluated(){return t},orElse:e=>{try{return c()}catch{return e}},orNull:()=>{try{return c()}catch{return null}},orThrow:e=>{try{return c()}catch(t){throw e??t}},or:e=>Z(()=>{try{return c()}catch{return e.orThrow()}}),orUndefined:()=>{try{return c()}catch{return}},map:e=>Z(()=>e(c())),ap:e=>Z(()=>e.orThrow()(c())),mapAsync:async e=>{let t=await e(c());return Z(()=>t)},flatMap:e=>Z(()=>e(c()).orThrow()),flatMapAsync:async e=>{let t=await e(c());return Z(()=>t.orThrow())},filter:e=>Z(()=>{let t=c();return e(t)?f(t):m}),recover:e=>Z(()=>{try{return c()}catch(t){return e(t)}}),recoverWith:e=>Z(()=>{try{return c()}catch(t){return e(t).orThrow()}}),toOption:()=>{try{return f(c())}catch{return m}},toEither:()=>{try{return T(c())}catch(e){return E(e)}},toEitherWith:e=>{try{return T(c())}catch(t){return E(e(t))}},toTry:()=>S(()=>c()),tap:e=>Z(()=>{let t=c();return e(t),t}),tapError:e=>Z(()=>{try{return c()}catch(t){throw e(t),t}}),fold:e=>e(c()),foldWith:(e,t)=>{try{return t(c())}catch(t){return e(t)}},foldLeft:e=>t=>t(e,c()),foldRight:e=>t=>t(c(),e),match:e=>e.Lazy(c()),toString:()=>t&&!s?`Lazy(${r(i)})`:t&&s?`Lazy(<error: ${a instanceof Error?a.message:String(a)}>)`:`Lazy(<not evaluated>)`,toValue:()=>{try{return{_tag:`Lazy`,value:c()}}catch(e){return{_tag:`Lazy`,error:e instanceof Error?e:Error(String(e))}}},get size(){try{return c(),1}catch{return 0}},get isEmpty(){try{return c(),!1}catch{return!0}},contains:e=>{try{return c()===e}catch{return!1}},reduce:e=>c(),reduceRight:e=>c(),count:e=>{try{return+!!e(c())}catch{return 0}},find:e=>{try{let t=c();return e(t)?f(t):m}catch{return m}},exists:e=>{try{return e(c())}catch{return!1}},forEach:e=>{try{e(c())}catch{}},pipe:e=>e(c()),toJSON:()=>{try{return{"@functype":`Lazy`,_tag:`Lazy`,value:c()}}catch(e){return{"@functype":`Lazy`,_tag:`Lazy`,error:u(e)}}},serialize:()=>{try{return n(`Lazy`,c())}catch(e){return o(`Lazy`,`Lazy`,{error:u(e)})}},typeable:`Lazy`}},In={of:e=>Fn(e),fromValue:e=>Fn(()=>e),fromOption:(e,t)=>Fn(()=>e._tag===`Some`?e.value:t()),fromTry:e=>Fn(()=>e.orThrow()),fromEither:e=>Fn(()=>e.fold(e=>{throw e},e=>e)),fromPromise:e=>Fn(()=>{throw Error(`Promise not yet resolved. Use await on the promise before creating Lazy.`)}),fail:e=>Fn(()=>{throw e}),evaluated:e=>Fn(()=>e),fromJSON:e=>{let t=JSON.parse(e);if(t[`@functype`]!==void 0&&t[`@functype`]!==`Lazy`)throw Error(`Lazy.fromJSON: expected @functype="Lazy", got ${JSON.stringify(t[`@functype`])}`);if(t.error!==void 0){let e=typeof t.error==`object`?d(t.error):Error(t.error);return In.fail(e)}return In.evaluated(t.value)}},Z=s(Fn,In),Ln={default:e=>t=>e(t),when:(e,t)=>n=>e(n)?t(n):void 0},Q=e=>({[Symbol.toStringTag]:`Obj`,_tag:`Obj`,data:e,get:t=>h(e[t]),set:(t,n)=>Q({...e,[t]:n}),assign:t=>Q({...e,...t}),merge:t=>Q({...e,...t}),when:(t,n)=>(typeof t==`function`?t():t)?Q({...e,...n}):Q(e),omit:(...t)=>{let n={...e};for(let e of t)delete n[e];return Q(n)},pick:(...t)=>{let n={};for(let r of t)r in e&&(n[r]=e[r]);return Q(n)},keys:()=>w(Object.keys(e)),values:()=>w(Object.values(e)),entries:()=>w(Object.entries(e).map(([e,t])=>c([e,t]))),has:t=>t in e,value:()=>e,get isEmpty(){return Object.keys(e).length===0},get size(){return Object.keys(e).length},map:t=>Q(t(e)),flatMap:t=>t(e),flatMapAsync:async t=>await t(e),ap:t=>{let n=t.data;return Q(n(e))},fold:(t,n)=>Object.keys(e).length===0?t():n(e),match:t=>t.Obj(e),foldLeft:t=>n=>n(t,e),foldRight:t=>n=>n(e,t),count:t=>+!!t(e),find:t=>t(e)?h(e):h(void 0),exists:t=>t(e),forEach:t=>t(e),reduce:t=>e,reduceRight:t=>e,contains:t=>JSON.stringify(e)===JSON.stringify(t),orElse:t=>e,orThrow:t=>e,or:t=>Q(e),orNull:()=>e,orUndefined:()=>e,toOption:()=>h(e),toEither:t=>T(e),toList:()=>w([e]),toTry:()=>S(()=>e),toPromise:()=>Promise.resolve(e),toString:()=>`Obj(${r(e)})`,toValue:()=>({_tag:`Obj`,value:e}),toJSON:()=>({"@functype":`Obj`,_tag:`Obj`,value:e}),pipe:t=>t(e),serialize:()=>n(`Obj`,e),doUnwrap(){return{ok:!0,value:e}}}),Rn=e=>Q(e),zn={of:e=>Q(e),empty:()=>Q({}),fromJSON:e=>{let t=JSON.parse(e);if(t[`@functype`]!==void 0&&t[`@functype`]!==`Obj`)throw Error(`Obj.fromJSON: expected @functype="Obj", got ${JSON.stringify(t[`@functype`])}`);return Q(t.value)},fromBinary:e=>{let t=Buffer.from(e,`base64`).toString();return zn.fromJSON(t)}},Bn=s(Rn,zn),$=(e=[])=>{let t=[...e],r=()=>t.length,i=()=>t.length===0,a=e=>t.includes(e),o=e=>{if(t.length===0)throw Error(`Cannot reduce an empty stack`);return re(t,e)},s=e=>{if(t.length===0)throw Error(`Cannot reduce an empty stack`);return ie(t,e)},c=e=>$([...t,e]),l=()=>{if(i())return[$([]),h(null)];let e=[...t],n=e.pop();return[$(e),h(n)]},ee=()=>i()?h(null):h(t[t.length-1]),u=e=>$(t.map(e)),d=e=>i()?$([]):t.reduce((t,n)=>e(n).toArray().reduce((e,t)=>e.push(t),t),$([])),f=e=>{let n=[];return t.forEach(t=>{e.toArray().forEach(e=>{n.push(e(t))})}),$(n)},p=async e=>i()?$([]):(await Promise.all(t.map(async t=>await e(t)))).reduce((e,t)=>t.toArray().reduce((e,t)=>e.push(t),e),$([])),m=()=>w(t),te=()=>[...t],ne=()=>`Stack(${t.join(`, `)})`,g=(e,n)=>t.reduce(n,e),_=e=>n=>t.reduce(n,e),ae=e=>n=>t.reduceRight((e,t)=>n(t,e),e),oe=e=>i()?e.Empty():e.NonEmpty([...t]);return{[Symbol.toStringTag]:`Stack`,_tag:`Stack`,get size(){return r()},get isEmpty(){return i()},contains:a,reduce:o,reduceRight:s,push:c,pop:l,peek:ee,map:u,flatMap:d,ap:f,flatMapAsync:p,toList:m,toArray:te,toString:ne,fold:g,foldLeft:_,foldRight:ae,match:oe,toValue:()=>({_tag:`Stack`,value:t}),toJSON:()=>({"@functype":`Stack`,_tag:`Stack`,value:[...t]}),pipe:e=>e([...t]),serialize:()=>n(`Stack`,t)}},Vn=(e=[])=>$(e),Hn={empty:()=>$([]),of:e=>$([e]),fromJSON:e=>{let t=JSON.parse(e);if(t[`@functype`]!==void 0&&t[`@functype`]!==`Stack`)throw Error(`Stack.fromJSON: expected @functype="Stack", got ${JSON.stringify(t[`@functype`])}`);return Un(t.value)},fromYAML:e=>{let t=e.split(`
|
|
17
|
-
`)[1]?.split(`: `)[1];return Un(t?JSON.parse(t):[])},fromBinary:e=>{let t=Buffer.from(e,`base64`).toString();return Hn.fromJSON(t)}},Un=s(Vn,Hn);var Wn=e({deserialize:()=>Xn,isFunctypeValue:()=>
|
|
17
|
+
`)[1]?.split(`: `)[1];return Un(t?JSON.parse(t):[])},fromBinary:e=>{let t=Buffer.from(e,`base64`).toString();return Hn.fromJSON(t)}},Un=s(Vn,Hn);var Wn=e({deserialize:()=>Xn,deserializeStrict:()=>Zn,fromEnvelope:()=>er,isFunctypeValue:()=>tr,serialize:()=>Qn,toEnvelope:()=>$n});let Gn;const Kn=()=>(Gn===void 0&&(Gn={Option:e=>e._tag===`Some`?f(e.value):m(),Either:e=>e._tag===`Right`?T(e.value):E(e.value),Try:e=>{if(e._tag===`Success`)return S.success(e.value);let t=e.error!==void 0&&typeof e.error==`object`?d(e.error):Error(typeof e.error==`string`?e.error:``);return S.failure(t)},List:e=>w(e.value),Set:e=>ce(e.value),Map:e=>ct(e.value),Obj:e=>Bn(e.value),Stack:e=>Un(e.value),Tuple:e=>c(e.value),LazyList:e=>fe(e.value),Lazy:e=>{if(e.error!==void 0){let t=typeof e.error==`object`?d(e.error):Error(e.error);return Z.fail(t)}return Z.evaluated(e.value)},Task:e=>{if(e._tag===`Ok`)return j.ok(e.value);let t=e.error!==void 0&&typeof e.error==`object`?d(e.error):Error(typeof e.error==`string`?e.error:`Unknown Task error`);return j.err(t)}}),Gn),qn=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Jn=e=>qn(e)&&typeof e[`@functype`]==`string`,Yn=e=>{if(Array.isArray(e))return e.map(Yn);if(Jn(e)){let t=e[a],n=Kn()[t];if(n===void 0)throw Error(`Serialization.deserialize: unknown @functype marker ${JSON.stringify(t)}`);let r={};for(let t of Object.keys(e))r[t]=Yn(e[t]);return n(r)}if(qn(e)){let t={};for(let n of Object.keys(e))t[n]=Yn(e[n]);return t}return e},Xn=e=>S(()=>Yn(JSON.parse(e))),Zn=e=>S(()=>{let t=JSON.parse(e);if(!Jn(t))throw Error(`Serialization.deserializeStrict: input is not a functype envelope (no @functype marker at the top level)`);return Yn(t)}),Qn=e=>JSON.stringify(e??null),$n=e=>JSON.parse(JSON.stringify(e??null)),er=e=>S(()=>Yn(e)),tr=e=>typeof e==`object`&&!!e&&typeof e.serialize==`function`&&typeof e._tag==`string`;function nr(e){let t=he({_tag:e._tag,impl:e.impl});return{...t,toValue:()=>({_tag:t._tag,value:e.value})}}export{Ue as $,Ht as A,re as At,N as B,nn as C,he as Ct,Xt as D,v as Dt,Zt as E,fe as Et,Wt as F,d as Ft,j as G,it as H,Ut as I,u as It,Ze as J,tt as K,Bt as L,l as Lt,zt as M,h as Mt,Gt as N,te as Nt,Yt as O,ce as Ot,Kt as P,f as Pt,Ke as Q,Vt as R,L as S,w as St,F as T,S as Tt,k as U,ct as V,A as W,Xe as X,Qe as Y,Ye as Z,dn as _,Te as _t,Ln as a,Fe as at,sn as b,we as bt,X as c,Pe as ct,yn as d,Le as dt,Be as et,_n as f,D as ft,fn as g,Ee as gt,gn as h,T as ht,Bn as i,Ne as it,Lt as j,m as jt,Jt as k,ie as kt,On as l,je as lt,mn as m,E as mt,Wn as n,Ie as nt,Z as o,Me as ot,hn as p,Ae as pt,$e as q,Un as r,ze as rt,Pn as s,He as st,nr as t,Ve as tt,Dn as u,Re as ut,K as v,Ce as vt,en as w,ge as wt,z as x,De as xt,cn as y,Se as yt,Pt as z};
|
package/dist/try/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Xn as TypeNames, Yn as Try } from "../index-
|
|
1
|
+
import { Xn as TypeNames, Yn as Try } from "../index-D6Zlkrnf.js";
|
|
2
2
|
export { Try, TypeNames };
|
package/dist/try/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Tt as e}from"../src-
|
|
1
|
+
import{Tt as e}from"../src-D3v1n1vv.js";export{e as Try};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "functype",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A functional programming library for TypeScript, using immutable data structures and type classes",
|
|
6
6
|
"keywords": [
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"tsdown": "^0.22.1",
|
|
42
42
|
"tsx": "^4.22.4",
|
|
43
43
|
"typedoc": "^0.28.19",
|
|
44
|
-
"eslint-config-functype": "^2.102.
|
|
44
|
+
"eslint-config-functype": "^2.102.2"
|
|
45
45
|
},
|
|
46
46
|
"types": "./dist/index.d.ts",
|
|
47
47
|
"module": "./dist/index.js",
|