functype 0.14.0 → 0.14.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.
@@ -9,6 +9,10 @@ import { T as Type, P as Pipe, a as Typeable, S as Serializable, F as Foldable }
9
9
  * All monads that support Do-notation should implement this protocol
10
10
  */
11
11
  declare const DO_PROTOCOL: unique symbol;
12
+ /**
13
+ * Type for the DO_PROTOCOL symbol
14
+ */
15
+ type DO_PROTOCOL_TYPE = typeof DO_PROTOCOL;
12
16
  /**
13
17
  * Result type for Do-notation unwrapping
14
18
  * Indicates whether unwrapping succeeded and provides the value or error
@@ -29,7 +33,7 @@ type DoResult<T> = {
29
33
  * Implementing this interface allows a type to be yielded in Do-comprehensions
30
34
  */
31
35
  interface DoProtocol<T> {
32
- [DO_PROTOCOL](): DoResult<T>;
36
+ [DO_PROTOCOL]: () => DoResult<T>;
33
37
  }
34
38
 
35
39
  /**
@@ -903,4 +907,4 @@ declare const Either: {
903
907
  fromBinary: <L extends Type, R extends Type>(binary: string) => Either<L, R>;
904
908
  };
905
909
 
906
- export { type Applicative as A, type Collection as C, DO_PROTOCOL as D, Either as E, type FunctypeBase as F, List as L, type Matchable as M, None as N, Option as O, type Promisable as P, Right as R, Some as S, Try as T, type DoResult as a, type Extractable as b, type Traversable as c, type DoProtocol as d, type TestEither as e, Left as f, isLeft as g, TypeCheckRight as h, isRight as i, TypeCheckLeft as j, tryCatchAsync as k, isExtractable as l, type Functype as m, type FunctypeCollection as n, MatchableUtils as o, OptionConstructor as p, Set as q, type TypeNames as r, type CollectionOps as s, tryCatch as t, type ContainerOps as u, type AsyncMonad as v, type Functor as w, type Monad as x, type Reshapeable as y };
910
+ export { type Applicative as A, type Collection as C, DO_PROTOCOL as D, Either as E, type FunctypeBase as F, List as L, type Matchable as M, None as N, Option as O, type Promisable as P, Right as R, Some as S, Try as T, type DoResult as a, type Extractable as b, type Traversable as c, type DO_PROTOCOL_TYPE as d, type DoProtocol as e, type TestEither as f, Left as g, isLeft as h, isRight as i, TypeCheckRight as j, TypeCheckLeft as k, tryCatchAsync as l, isExtractable as m, type Functype as n, type FunctypeCollection as o, MatchableUtils as p, OptionConstructor as q, Set as r, type TypeNames as s, tryCatch as t, type CollectionOps as u, type ContainerOps as v, type AsyncMonad as w, type Functor as x, type Monad as y, type Reshapeable as z };
@@ -17,7 +17,7 @@ ${o.stack.split(`
17
17
  `)}`),l.get()}).join(n)},fromPromise:(t,e)=>(...r)=>J(e??{name:"PromiseTask",description:"Task from Promise"}).Async(()=>t(...r),o=>o),toPromise:t=>new Promise((e,r)=>{t.isSuccess()?e(t.get()):r(t.error);}),race:(t,e,r)=>{let n=r?.name??"TaskRace",o=r?.description??"Race between multiple tasks";return J({name:n,description:o}).Async(async()=>{let s=Ae();t.forEach(u=>s.add(u));let i=x(void 0);if(typeof e=="number"&&e>0){let u=Se((l,d)=>{i.set(setTimeout(()=>{d(new Error(`Task race timed out after ${e}ms`));},e));});s.add(u);}try{return await new Promise((u,l)=>{s.build().forEach(d=>{d.then(y=>{if(y&&typeof y=="object"&&"_tag"in y){let A=y;A._tag==="TaskSuccess"?u(A.get()):A._tag==="TaskFailure"?l(A.error):u(y);}else u(y);},y=>l(y));});})}finally{i.get()&&clearTimeout(i.get());}},s=>s)},fromNodeCallback:(t,e)=>{let r=e?.name??"NodeCallbackTask",n=e?.description??"Task from Node.js callback function",o={name:r,description:n};return (...a)=>J(o).Async(()=>new Promise((s,i)=>{try{t(...a,(u,l)=>{u?i(u):s(l);});}catch(u){i(u);}}),s=>s)},createCancellationTokenSource:ve,cancellable:(t,e)=>{let r=ve();return {task:J(e).Async(()=>t(r.token),o=>o,()=>{},r.token),cancel:()=>r.cancel()}},withProgress:(t,e=()=>{},r)=>{let n=ve(),o=x(0),a=i=>{o.set(Math.max(0,Math.min(100,i))),e(o.get());};return {task:J(r).Async(()=>t(a,n.token),i=>i,()=>{},n.token),cancel:()=>n.cancel(),currentProgress:()=>o.get()}}},J=a(gt,je);var We={includeTasks:true,includeStackTrace:false,separator:`
18
18
  `,includeData:false,maxStackFrames:3,title:"Error",colors:false};function Ge(t){let e=new WeakSet;return JSON.stringify(t,(r,n)=>{if(typeof n=="bigint")return `${n.toString()}n`;if(typeof n=="object"&&n!==null){if(e.has(n))return "[Circular Reference]";e.add(n);}return r==="stack"&&typeof n=="string"?xe(n):n},2)}function xe(t){if(t===void 0||t==="")return "";let e=t.split(`
19
19
  `),r=e[0],n=e.slice(1).map(o=>o.trim());return [r,...n].join(`
20
- `)}function An(t,e){let r={...We,...e},n=t instanceof Error?t:Q.apply(t),o=J?.getErrorChain?J.getErrorChain(n):[n],a=r.colors?`\x1B[31m${r.title}:\x1B[0m ${n.message}`:`${r.title}: ${n.message}`,s=o.map((u,l)=>{let d=" ".repeat(l),y=l>0?"\u21B3 ":"",{taskInfo:A}=u,R=r.includeTasks&&A?.name?r.colors?`\x1B[36m[${A.name}]\x1B[0m `:`[${A.name}] `:"",E=`${d}${y}${R}${u.message}`;if(r.includeStackTrace&&u.stack){let X=xe(u.stack).split(`
20
+ `)}function Rn(t,e){let r={...We,...e},n=t instanceof Error?t:Q.apply(t),o=J?.getErrorChain?J.getErrorChain(n):[n],a=r.colors?`\x1B[31m${r.title}:\x1B[0m ${n.message}`:`${r.title}: ${n.message}`,s=o.map((u,l)=>{let d=" ".repeat(l),y=l>0?"\u21B3 ":"",{taskInfo:A}=u,R=r.includeTasks&&A?.name?r.colors?`\x1B[36m[${A.name}]\x1B[0m `:`[${A.name}] `:"",E=`${d}${y}${R}${u.message}`;if(r.includeStackTrace&&u.stack){let X=xe(u.stack).split(`
21
21
  `).slice(1),ae=r.maxStackFrames??We.maxStackFrames??3,he=X.slice(0,ae).map(Ee=>`${d} ${r.colors?"\x1B[90m":""}${Ee}${r.colors?"\x1B[0m":""}`).join(`
22
22
  `);E+=`
23
23
  ${he}`,X.length>ae&&(E+=`
@@ -29,15 +29,15 @@ ${s}`;if(r.includeData){let{data:u}=n;if(u){let l=r.colors?`
29
29
  ${Ge(u)}`:`
30
30
 
31
31
  Context:
32
- ${Ge(u)}`;i+=l;}}return i}function Ln(){return function(e){if(!e)return e;let r=e instanceof Error?e:new Error(String(e)),n={message:r.message,name:r.name||"Error",stack:r.stack?xe(r.stack):void 0};if(r.taskInfo&&(n.taskInfo=r.taskInfo),r.data&&(n.data=r.data),typeof J?.getErrorChain=="function")try{let o=J.getErrorChain(r);o.length>1&&(n.errorChain=J.formatErrorChain(r,{includeTasks:!0}),n.structuredErrorChain=o.map(a=>({message:a.message,name:a.name,taskInfo:a.taskInfo,stack:a.stack?xe(a.stack):void 0})));}catch{}return Object.getOwnPropertyNames(r).forEach(o=>{if(!n[o]){let a=r[o];n[o]=a;}}),n}}var xn=t=>{let e=new Error(t);return e.name="ParseError",e};var j=(t,e,r,n)=>{let o=Q.apply(e,r,{name:t,description:e});return Object.assign(o,{code:t,message:e,status:ht(t),context:r,timestamp:new Date().toISOString(),traceId:n?.traceId})},ht=t=>({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})[t],Et={validation:(t,e,r)=>j("VALIDATION_FAILED",`Validation failed: ${t} ${r}`,{field:t,value:e,rule:r}),network:(t,e,r)=>j("NETWORK_ERROR",`Network error: ${e} ${t}${r?` (${r})`:""}`,{url:t,method:e,statusCode:r}),auth:(t,e)=>j("AUTH_REQUIRED",`Authentication required: ${t}${e?` (role: ${e})`:""}`,{resource:t,requiredRole:e}),notFound:(t,e)=>j("NOT_FOUND",`Not found: ${t} with id ${e}`,{resource:t,id:e}),permission:(t,e,r)=>j("PERMISSION_DENIED",`Permission denied: cannot ${t} ${e}`,{action:t,resource:e,userId:r}),rateLimit:(t,e,r)=>j("RATE_LIMITED",`Rate limit exceeded: ${t} requests per ${e}`,{limit:t,window:e,retryAfter:r}),internal:t=>j("INTERNAL_ERROR",`Internal server error: ${t}`,{errorId:t,timestamp:new Date().toISOString()}),badRequest:(t,e)=>j("BAD_REQUEST",`Bad request: ${t}`,{reason:t,expected:e}),conflict:(t,e)=>j("CONFLICT",`Conflict: ${t} already exists with value ${e}`,{resource:t,conflictingValue:e}),timeout:(t,e)=>j("TIMEOUT",`Request timeout: ${e} exceeded ${t}ms`,{duration:t,operation:e}),isTypedError:t=>typeof t=="object"&&t!==null&&"code"in t&&"message"in t&&"status"in t&&"context"in t&&"_tag"in t&&t._tag==="Throwable",hasCode:(t,e)=>t.code===e},S=Object.assign(j,Et);var C={rule:t=>e=>{if(t==="email")return typeof e!="string"||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)?p(S.validation("value",e,"must be a valid email")):c(e);if(t==="url")try{return new URL(String(e)),c(e)}catch{return p(S.validation("value",e,"must be a valid URL"))}if(t==="uuid")return typeof e!="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(e)?p(S.validation("value",e,"must be a valid UUID")):c(e);if(t==="required")return e==null||e===""?p(S.validation("value",e,"is required")):c(e);if(t==="numeric")return typeof e!="number"&&!/^\d+$/.test(String(e))?p(S.validation("value",e,"must be numeric")):c(e);if(t==="alpha")return typeof e!="string"||!/^[a-zA-Z]+$/.test(e)?p(S.validation("value",e,"must contain only letters")):c(e);if(t==="alphanumeric")return typeof e!="string"||!/^[a-zA-Z0-9]+$/.test(e)?p(S.validation("value",e,"must be alphanumeric")):c(e);if(t.startsWith("min:")){let r=Number(t.split(":")[1]),n=Number(e);return isNaN(n)||n<r?p(S.validation("value",e,`must be at least ${r}`)):c(e)}if(t.startsWith("max:")){let r=Number(t.split(":")[1]),n=Number(e);return isNaN(n)||n>r?p(S.validation("value",e,`must be at most ${r}`)):c(e)}if(t.startsWith("minLength:")){let r=Number(t.split(":")[1]);return String(e).length<r?p(S.validation("value",e,`must be at least ${r} characters`)):c(e)}if(t.startsWith("maxLength:")){let r=Number(t.split(":")[1]);return String(e).length>r?p(S.validation("value",e,`must be at most ${r} characters`)):c(e)}if(t.startsWith("pattern:")){let r=t.substring(8);return new RegExp(r).test(String(e))?c(e):p(S.validation("value",e,`must match pattern ${r}`))}if(t.startsWith("in:")){let r=t.substring(3).split(",");return r.includes(String(e))?c(e):p(S.validation("value",e,`must be one of: ${r.join(", ")}`))}if(t.startsWith("notIn:")){let r=t.substring(6).split(",");return r.includes(String(e))?p(S.validation("value",e,`must not be one of: ${r.join(", ")}`)):c(e)}if(t==="date"){let r=new Date(String(e));return isNaN(r.getTime())?p(S.validation("value",e,"must be a valid date")):c(e)}if(t==="future"){let r=new Date(String(e));return isNaN(r.getTime())||r<=new Date?p(S.validation("value",e,"must be a future date")):c(e)}if(t==="past"){let r=new Date(String(e));return isNaN(r.getTime())||r>=new Date?p(S.validation("value",e,"must be a past date")):c(e)}return c(e)},combine:(...t)=>e=>{for(let r of t){let n=r(e);if(n.isLeft())return n}return c(e)},custom:(t,e)=>r=>t(r)?c(r):p(S.validation("value",r,e)),form:(t,e)=>{let r=[],n={};for(let[o,a]of Object.entries(t)){let s=e[o],i=a(s);if(i.isLeft()){let u=i.fold(d=>d,()=>{throw new Error("Should not be left")}),l=S.validation(o,s,u.context.rule);r.push(l);}else n[o]=i.get();}return r.length>0?p(m(r)):c(n)}},Rt={...C,validators:{email:C.rule("email"),url:C.rule("url"),uuid:C.rule("uuid"),required:C.rule("required"),numeric:C.rule("numeric"),positiveNumber:C.combine(C.rule("numeric"),C.rule("min:0")),nonEmptyString:C.combine(C.rule("required"),C.custom(t=>typeof t=="string"&&t.trim().length>0,"must not be empty"))}},Bn=Object.assign(C.rule,Rt);function At(t){return t!=null&&typeof t=="object"&&"getOrElse"in t&&typeof t.getOrElse=="function"&&"getOrThrow"in t&&typeof t.getOrThrow=="function"&&"get"in t&&typeof t.get=="function"&&"orElse"in t&&typeof t.orElse=="function"&&"orNull"in t&&typeof t.orNull=="function"&&"orUndefined"in t&&typeof t.orUndefined=="function"}var In={toOption:t=>t.fold(()=>w(),e=>U(e)),toList:t=>t.fold(()=>m([]),e=>m([e])),toEither:(t,e)=>t.fold(()=>p(e),r=>c(r)),isEmpty:t=>t.fold(()=>true,()=>false),size:t=>t.fold(()=>0,()=>1)};var te=t=>t!==null&&typeof t=="object"&&(t._tag==="Some"||t._tag==="None"),Y=t=>t!==null&&typeof t=="object"&&t._tag==="List",le=t=>t!==null&&typeof t=="object"&&(t._tag==="Left"||t._tag==="Right"),pe=t=>t!==null&&typeof t=="object"&&(t._tag==="Success"||t._tag==="Failure"),W=()=>{let t=(s,i)=>{if(te(s))return s.map(u=>i(u));if(Y(s))return s.map(u=>i(u));if(le(s))return s.map(u=>i(u));if(pe(s))return s.map(u=>i(u));throw new Error(`Unsupported functor type: ${JSON.stringify(s)}`)},e=s=>{if(te(s))return s.get();if(Y(s)){let i=s.toArray();if(i.length>0&&Y(i[0])){let u=[];for(let l of i)Y(l)&&u.push(...l.toArray());return m(u)}return s.flatten()}if(le(s))return s.isRight()?s.fold(()=>null,i=>i):s;if(pe(s))return s.isSuccess()?s.get():s;throw new Error(`Unsupported functor type for flatten: ${JSON.stringify(s)}`)},r=(s,i)=>{if(te(s))return s.flatMap(u=>i(u));if(Y(s))return s.flatMap(u=>i(u));if(le(s))return s.flatMap(u=>i(u));if(pe(s))return s.flatMap(u=>i(u));throw new Error(`Unsupported functor type for flatMap: ${JSON.stringify(s)}`)},n=(s,i)=>{if(te(s)&&te(i))return s.flatMap(u=>i.map(l=>u(l)));if(Y(s)&&Y(i))return s.flatMap(u=>i.map(l=>u(l)));if(le(s)&&le(i))return s.flatMap(u=>i.map(l=>u(l)));if(pe(s)&&pe(i))return s.flatMap(u=>i.map(l=>u(l)));throw new Error(`Unsupported functor type for ap: ${JSON.stringify(s)}`)},o=s=>{if(te(s)){let i=s;if(i.isEmpty)return m([f.none()]);let u=i.get();if(Y(u))return u.map(l=>f(l));throw new Error("Unsupported inner container type for sequence")}if(Y(s)){let u=s.toArray();if(u.length===0)return f.none();let l=u[0];if(te(l)){for(let y of u)if(y.isEmpty)return f.none();let d=u.map(y=>y.get());return f(m(d))}throw new Error("Unsupported inner container type for sequence")}throw new Error(`Unsupported outer container type for sequence: ${JSON.stringify(s)}`)};return {_tag:"HKT",map:t,flatten:e,flatMap:r,ap:n,sequence:o,traverse:(s,i)=>o(t(s,u=>i(u))),_type:"HKT"}},ce=W();W.map=(t,e)=>ce.map(t,e);W.flatten=t=>ce.flatten(t);W.flatMap=(t,e)=>ce.flatMap(t,e);W.ap=(t,e)=>ce.ap(t,e);W.sequence=t=>ce.sequence(t);W.traverse=(t,e)=>ce.traverse(t,e);W.isOption=te;W.isList=Y;W.isEither=le;W.isTry=pe;function Jn(t){return {id:t,isSame:r=>r.id===t}}var re=t=>{let e=false,r,n,o=false,a=()=>{if(!e)try{r=t(),e=!0;}catch(i){throw n=i,o=true,e=true,i}if(o)throw n;return r};return {_tag:"Lazy",get isEvaluated(){return e},get:a,getOrElse:i=>{try{return a()}catch{return i}},getOrNull:()=>{try{return a()}catch{return null}},orNull:()=>{try{return a()}catch{return null}},getOrThrow:i=>{try{return a()}catch(u){throw i??u}},orElse:i=>D(()=>{try{return a()}catch{return i.get()}}),orUndefined:()=>{try{return a()}catch{return}},map:i=>D(()=>i(a())),ap:i=>D(()=>i.get()(a())),mapAsync:async i=>{let u=a(),l=await i(u);return D(()=>l)},flatMap:i=>D(()=>i(a()).get()),flatMapAsync:async i=>{let u=a(),l=await i(u);return D(()=>l.get())},filter:i=>D(()=>{let u=a();return i(u)?U(u):w}),recover:i=>D(()=>{try{return a()}catch(u){return i(u)}}),recoverWith:i=>D(()=>{try{return a()}catch(u){return i(u).get()}}),toOption:()=>{try{return U(a())}catch{return w}},toEither:()=>{try{return c(a())}catch(i){return p(i)}},toEitherWith:i=>{try{return c(a())}catch(u){return p(i(u))}},toTry:()=>P(()=>a()),tap:i=>D(()=>{let u=a();return i(u),u}),tapError:i=>D(()=>{try{return a()}catch(u){throw i(u),u}}),fold:i=>i(a()),foldWith:(i,u)=>{try{return u(a())}catch(l){return i(l)}},foldLeft:i=>u=>u(i,a()),foldRight:i=>u=>u(a(),i),match:i=>i.Lazy(a()),toString:()=>e&&!o?`Lazy(${me(r)})`:e&&o?`Lazy(<error: ${n instanceof Error?n.message:String(n)}>)`:"Lazy(<not evaluated>)",toValue:()=>e&&!o?{_tag:"Lazy",evaluated:true,value:r}:{_tag:"Lazy",evaluated:false},get size(){try{return a(),1}catch{return 0}},get isEmpty(){try{return a(),!1}catch{return true}},contains:i=>{try{return a()===i}catch{return false}},reduce:i=>a(),reduceRight:i=>a(),count:i=>{try{return i(a())?1:0}catch{return 0}},find:i=>{try{let u=a();return i(u)?U(u):w}catch{return w}},exists:i=>{try{return i(a())}catch{return false}},forEach:i=>{try{i(a());}catch{}},pipe:i=>i(a()),serialize:()=>({toJSON:()=>JSON.stringify(e&&!o?{_tag:"Lazy",evaluated:true,value:r}:{_tag:"Lazy",evaluated:false}),toYAML:()=>e&&!o?`_tag: Lazy
32
+ ${Ge(u)}`;i+=l;}}return i}function An(){return function(e){if(!e)return e;let r=e instanceof Error?e:new Error(String(e)),n={message:r.message,name:r.name||"Error",stack:r.stack?xe(r.stack):void 0};if(r.taskInfo&&(n.taskInfo=r.taskInfo),r.data&&(n.data=r.data),typeof J?.getErrorChain=="function")try{let o=J.getErrorChain(r);o.length>1&&(n.errorChain=J.formatErrorChain(r,{includeTasks:!0}),n.structuredErrorChain=o.map(a=>({message:a.message,name:a.name,taskInfo:a.taskInfo,stack:a.stack?xe(a.stack):void 0})));}catch{}return Object.getOwnPropertyNames(r).forEach(o=>{if(!n[o]){let a=r[o];n[o]=a;}}),n}}var kn=t=>{let e=new Error(t);return e.name="ParseError",e};var j=(t,e,r,n)=>{let o=Q.apply(e,r,{name:t,description:e});return Object.assign(o,{code:t,message:e,status:ht(t),context:r,timestamp:new Date().toISOString(),traceId:n?.traceId})},ht=t=>({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})[t],Et={validation:(t,e,r)=>j("VALIDATION_FAILED",`Validation failed: ${t} ${r}`,{field:t,value:e,rule:r}),network:(t,e,r)=>j("NETWORK_ERROR",`Network error: ${e} ${t}${r?` (${r})`:""}`,{url:t,method:e,statusCode:r}),auth:(t,e)=>j("AUTH_REQUIRED",`Authentication required: ${t}${e?` (role: ${e})`:""}`,{resource:t,requiredRole:e}),notFound:(t,e)=>j("NOT_FOUND",`Not found: ${t} with id ${e}`,{resource:t,id:e}),permission:(t,e,r)=>j("PERMISSION_DENIED",`Permission denied: cannot ${t} ${e}`,{action:t,resource:e,userId:r}),rateLimit:(t,e,r)=>j("RATE_LIMITED",`Rate limit exceeded: ${t} requests per ${e}`,{limit:t,window:e,retryAfter:r}),internal:t=>j("INTERNAL_ERROR",`Internal server error: ${t}`,{errorId:t,timestamp:new Date().toISOString()}),badRequest:(t,e)=>j("BAD_REQUEST",`Bad request: ${t}`,{reason:t,expected:e}),conflict:(t,e)=>j("CONFLICT",`Conflict: ${t} already exists with value ${e}`,{resource:t,conflictingValue:e}),timeout:(t,e)=>j("TIMEOUT",`Request timeout: ${e} exceeded ${t}ms`,{duration:t,operation:e}),isTypedError:t=>typeof t=="object"&&t!==null&&"code"in t&&"message"in t&&"status"in t&&"context"in t&&"_tag"in t&&t._tag==="Throwable",hasCode:(t,e)=>t.code===e},S=Object.assign(j,Et);var C={rule:t=>e=>{if(t==="email")return typeof e!="string"||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)?p(S.validation("value",e,"must be a valid email")):c(e);if(t==="url")try{return new URL(String(e)),c(e)}catch{return p(S.validation("value",e,"must be a valid URL"))}if(t==="uuid")return typeof e!="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(e)?p(S.validation("value",e,"must be a valid UUID")):c(e);if(t==="required")return e==null||e===""?p(S.validation("value",e,"is required")):c(e);if(t==="numeric")return typeof e!="number"&&!/^\d+$/.test(String(e))?p(S.validation("value",e,"must be numeric")):c(e);if(t==="alpha")return typeof e!="string"||!/^[a-zA-Z]+$/.test(e)?p(S.validation("value",e,"must contain only letters")):c(e);if(t==="alphanumeric")return typeof e!="string"||!/^[a-zA-Z0-9]+$/.test(e)?p(S.validation("value",e,"must be alphanumeric")):c(e);if(t.startsWith("min:")){let r=Number(t.split(":")[1]),n=Number(e);return isNaN(n)||n<r?p(S.validation("value",e,`must be at least ${r}`)):c(e)}if(t.startsWith("max:")){let r=Number(t.split(":")[1]),n=Number(e);return isNaN(n)||n>r?p(S.validation("value",e,`must be at most ${r}`)):c(e)}if(t.startsWith("minLength:")){let r=Number(t.split(":")[1]);return String(e).length<r?p(S.validation("value",e,`must be at least ${r} characters`)):c(e)}if(t.startsWith("maxLength:")){let r=Number(t.split(":")[1]);return String(e).length>r?p(S.validation("value",e,`must be at most ${r} characters`)):c(e)}if(t.startsWith("pattern:")){let r=t.substring(8);return new RegExp(r).test(String(e))?c(e):p(S.validation("value",e,`must match pattern ${r}`))}if(t.startsWith("in:")){let r=t.substring(3).split(",");return r.includes(String(e))?c(e):p(S.validation("value",e,`must be one of: ${r.join(", ")}`))}if(t.startsWith("notIn:")){let r=t.substring(6).split(",");return r.includes(String(e))?p(S.validation("value",e,`must not be one of: ${r.join(", ")}`)):c(e)}if(t==="date"){let r=new Date(String(e));return isNaN(r.getTime())?p(S.validation("value",e,"must be a valid date")):c(e)}if(t==="future"){let r=new Date(String(e));return isNaN(r.getTime())||r<=new Date?p(S.validation("value",e,"must be a future date")):c(e)}if(t==="past"){let r=new Date(String(e));return isNaN(r.getTime())||r>=new Date?p(S.validation("value",e,"must be a past date")):c(e)}return c(e)},combine:(...t)=>e=>{for(let r of t){let n=r(e);if(n.isLeft())return n}return c(e)},custom:(t,e)=>r=>t(r)?c(r):p(S.validation("value",r,e)),form:(t,e)=>{let r=[],n={};for(let[o,a]of Object.entries(t)){let s=e[o],i=a(s);if(i.isLeft()){let u=i.fold(d=>d,()=>{throw new Error("Should not be left")}),l=S.validation(o,s,u.context.rule);r.push(l);}else n[o]=i.get();}return r.length>0?p(m(r)):c(n)}},Rt={...C,validators:{email:C.rule("email"),url:C.rule("url"),uuid:C.rule("uuid"),required:C.rule("required"),numeric:C.rule("numeric"),positiveNumber:C.combine(C.rule("numeric"),C.rule("min:0")),nonEmptyString:C.combine(C.rule("required"),C.custom(t=>typeof t=="string"&&t.trim().length>0,"must not be empty"))}},On=Object.assign(C.rule,Rt);function At(t){return t!=null&&typeof t=="object"&&"getOrElse"in t&&typeof t.getOrElse=="function"&&"getOrThrow"in t&&typeof t.getOrThrow=="function"&&"get"in t&&typeof t.get=="function"&&"orElse"in t&&typeof t.orElse=="function"&&"orNull"in t&&typeof t.orNull=="function"&&"orUndefined"in t&&typeof t.orUndefined=="function"}var Vn={toOption:t=>t.fold(()=>w(),e=>U(e)),toList:t=>t.fold(()=>m([]),e=>m([e])),toEither:(t,e)=>t.fold(()=>p(e),r=>c(r)),isEmpty:t=>t.fold(()=>true,()=>false),size:t=>t.fold(()=>0,()=>1)};var te=t=>t!==null&&typeof t=="object"&&(t._tag==="Some"||t._tag==="None"),Y=t=>t!==null&&typeof t=="object"&&t._tag==="List",le=t=>t!==null&&typeof t=="object"&&(t._tag==="Left"||t._tag==="Right"),pe=t=>t!==null&&typeof t=="object"&&(t._tag==="Success"||t._tag==="Failure"),W=()=>{let t=(s,i)=>{if(te(s))return s.map(u=>i(u));if(Y(s))return s.map(u=>i(u));if(le(s))return s.map(u=>i(u));if(pe(s))return s.map(u=>i(u));throw new Error(`Unsupported functor type: ${JSON.stringify(s)}`)},e=s=>{if(te(s))return s.get();if(Y(s)){let i=s.toArray();if(i.length>0&&Y(i[0])){let u=[];for(let l of i)Y(l)&&u.push(...l.toArray());return m(u)}return s.flatten()}if(le(s))return s.isRight()?s.fold(()=>null,i=>i):s;if(pe(s))return s.isSuccess()?s.get():s;throw new Error(`Unsupported functor type for flatten: ${JSON.stringify(s)}`)},r=(s,i)=>{if(te(s))return s.flatMap(u=>i(u));if(Y(s))return s.flatMap(u=>i(u));if(le(s))return s.flatMap(u=>i(u));if(pe(s))return s.flatMap(u=>i(u));throw new Error(`Unsupported functor type for flatMap: ${JSON.stringify(s)}`)},n=(s,i)=>{if(te(s)&&te(i))return s.flatMap(u=>i.map(l=>u(l)));if(Y(s)&&Y(i))return s.flatMap(u=>i.map(l=>u(l)));if(le(s)&&le(i))return s.flatMap(u=>i.map(l=>u(l)));if(pe(s)&&pe(i))return s.flatMap(u=>i.map(l=>u(l)));throw new Error(`Unsupported functor type for ap: ${JSON.stringify(s)}`)},o=s=>{if(te(s)){let i=s;if(i.isEmpty)return m([f.none()]);let u=i.get();if(Y(u))return u.map(l=>f(l));throw new Error("Unsupported inner container type for sequence")}if(Y(s)){let u=s.toArray();if(u.length===0)return f.none();let l=u[0];if(te(l)){for(let y of u)if(y.isEmpty)return f.none();let d=u.map(y=>y.get());return f(m(d))}throw new Error("Unsupported inner container type for sequence")}throw new Error(`Unsupported outer container type for sequence: ${JSON.stringify(s)}`)};return {_tag:"HKT",map:t,flatten:e,flatMap:r,ap:n,sequence:o,traverse:(s,i)=>o(t(s,u=>i(u))),_type:"HKT"}},ce=W();W.map=(t,e)=>ce.map(t,e);W.flatten=t=>ce.flatten(t);W.flatMap=(t,e)=>ce.flatMap(t,e);W.ap=(t,e)=>ce.ap(t,e);W.sequence=t=>ce.sequence(t);W.traverse=(t,e)=>ce.traverse(t,e);W.isOption=te;W.isList=Y;W.isEither=le;W.isTry=pe;function $n(t){return {id:t,isSame:r=>r.id===t}}var re=t=>{let e=false,r,n,o=false,a=()=>{if(!e)try{r=t(),e=!0;}catch(i){throw n=i,o=true,e=true,i}if(o)throw n;return r};return {_tag:"Lazy",get isEvaluated(){return e},get:a,getOrElse:i=>{try{return a()}catch{return i}},getOrNull:()=>{try{return a()}catch{return null}},orNull:()=>{try{return a()}catch{return null}},getOrThrow:i=>{try{return a()}catch(u){throw i??u}},orElse:i=>D(()=>{try{return a()}catch{return i.get()}}),orUndefined:()=>{try{return a()}catch{return}},map:i=>D(()=>i(a())),ap:i=>D(()=>i.get()(a())),mapAsync:async i=>{let u=a(),l=await i(u);return D(()=>l)},flatMap:i=>D(()=>i(a()).get()),flatMapAsync:async i=>{let u=a(),l=await i(u);return D(()=>l.get())},filter:i=>D(()=>{let u=a();return i(u)?U(u):w}),recover:i=>D(()=>{try{return a()}catch(u){return i(u)}}),recoverWith:i=>D(()=>{try{return a()}catch(u){return i(u).get()}}),toOption:()=>{try{return U(a())}catch{return w}},toEither:()=>{try{return c(a())}catch(i){return p(i)}},toEitherWith:i=>{try{return c(a())}catch(u){return p(i(u))}},toTry:()=>P(()=>a()),tap:i=>D(()=>{let u=a();return i(u),u}),tapError:i=>D(()=>{try{return a()}catch(u){throw i(u),u}}),fold:i=>i(a()),foldWith:(i,u)=>{try{return u(a())}catch(l){return i(l)}},foldLeft:i=>u=>u(i,a()),foldRight:i=>u=>u(a(),i),match:i=>i.Lazy(a()),toString:()=>e&&!o?`Lazy(${me(r)})`:e&&o?`Lazy(<error: ${n instanceof Error?n.message:String(n)}>)`:"Lazy(<not evaluated>)",toValue:()=>e&&!o?{_tag:"Lazy",evaluated:true,value:r}:{_tag:"Lazy",evaluated:false},get size(){try{return a(),1}catch{return 0}},get isEmpty(){try{return a(),!1}catch{return true}},contains:i=>{try{return a()===i}catch{return false}},reduce:i=>a(),reduceRight:i=>a(),count:i=>{try{return i(a())?1:0}catch{return 0}},find:i=>{try{let u=a();return i(u)?U(u):w}catch{return w}},exists:i=>{try{return i(a())}catch{return false}},forEach:i=>{try{i(a());}catch{}},pipe:i=>i(a()),serialize:()=>({toJSON:()=>JSON.stringify(e&&!o?{_tag:"Lazy",evaluated:true,value:r}:{_tag:"Lazy",evaluated:false}),toYAML:()=>e&&!o?`_tag: Lazy
33
33
  evaluated: true
34
34
  value: ${me(r)}`:`_tag: Lazy
35
35
  evaluated: false`,toBinary:()=>Buffer.from(JSON.stringify(e&&!o?{_tag:"Lazy",evaluated:true,value:r}:{_tag:"Lazy",evaluated:false})).toString("base64")}),typeable:"Lazy"}},Lt={of:t=>re(t),fromValue:t=>re(()=>t),fromOption:(t,e)=>re(()=>t._tag==="Some"?t.value:e()),fromTry:t=>re(()=>t.get()),fromEither:t=>re(()=>t.fold(e=>{throw e},e=>e)),fromPromise:t=>re(()=>{throw new Error("Promise not yet resolved. Use await on the promise before creating Lazy.")}),fail:t=>re(()=>{throw t})},D=a(re,Lt);var ge=Map;var Z=t=>{let r={values:new ge(t)},n=()=>Array.from(r.values.entries()).map(([T,h])=>b$1([T,h])),o=T=>Z(new ge(r.values).set(T.toArray()[0],T.toArray()[1]).entries()),a=T=>{let h=new ge(r.values);return h.delete(T)?Z(h.entries()):Z(r.values.entries())},s=T=>{let h=T.toArray();return r.values.get(h[0])===h[1]},i=()=>r.values.size,u=T=>Z(Array.from(r.values.entries()).map(([h,V])=>[h,T(V)])),l=T=>{let h=Z(r.values.entries()).toList();return Z(h.flatMap(T).toArray())},d=T=>{let h=[];for(let[V,se]of r.values.entries()){let fe=T.get(V);fe._tag==="Some"&&fe.value&&h.push([V,fe.value(se)]);}return Z(h)},y=async T=>{let h=new ge;for(let[V,se]of r.values.entries()){let fe=await T(se);for(let Xe of fe.toList()){let[et,tt]=Xe.toArray();h.set(et,tt);}}return Z(h.entries())},A=T=>m(n()).reduce(T),R=T=>m(n()).reduceRight(T),E=T=>h=>m(n()).foldLeft(T)(h),F=T=>h=>m(n()).foldRight(T)(h),X=T=>f(r.values.get(T)),ae=(T,h)=>f(r.values.get(T)).getOrElse(h),Te=()=>r.values.size===0,he=(T,h)=>f(r.values.get(T)).orElse(h),Ee=(T,h)=>{if(Te())return T();let V=n();if(V.length===0)return T();let se=V[0];return se===void 0?T():h(se)},_e=()=>m(n()),g=()=>ne(n()),B=()=>`Map(${n().toString()})`,_=T=>Te()?T.Empty():T.NonEmpty(n());return {_tag:"Map",[Symbol.iterator]:()=>r.values.entries(),add:o,remove:a,contains:s,get size(){return i()},map:u,ap:d,flatMap:l,flatMapAsync:y,reduce:A,reduceRight:R,foldLeft:E,foldRight:F,fold:Ee,match:_,get:X,getOrElse:ae,get isEmpty(){return Te()},orElse:he,toList:_e,toSet:g,toString:B,toValue:()=>({_tag:"Map",value:Array.from(r.values.entries())}),pipe:T=>T(Array.from(r.values.entries())),serialize:()=>({toJSON:()=>JSON.stringify({_tag:"Map",value:Array.from(r.values.entries())}),toYAML:()=>`_tag: Map
36
36
  value: ${JSON.stringify(Array.from(r.values.entries()))}`,toBinary:()=>Buffer.from(JSON.stringify({_tag:"Map",value:Array.from(r.values.entries())})).toString("base64")})}},kt=t=>Z(t),qe={fromJSON:t=>{let e=JSON.parse(t);return Be(e.value)},fromYAML:t=>{let r=t.split(`
37
37
  `)[1]?.split(": ")[1];if(!r)return Be([]);let n=JSON.parse(r);return Be(n)},fromBinary:t=>{let e=Buffer.from(t,"base64").toString();return qe.fromJSON(e)}},Be=a(kt,qe);var xt={default:t=>e=>t(e),when:(t,e)=>r=>t(r)?e(r):void 0};var K=(t=[])=>{let e="Stack",r=[...t],n=()=>r.length,o=()=>r.length===0;return {_tag:e,get size(){return n()},get isEmpty(){return o()},contains:g=>r.includes(g),reduce:g=>{if(r.length===0)throw new Error("Cannot reduce an empty stack");return r.reduce(g)},reduceRight:g=>{if(r.length===0)throw new Error("Cannot reduce an empty stack");return r.reduceRight(g)},push:g=>K([...r,g]),pop:()=>{if(o())return [K([]),f(null)];let g=[...r],B=g.pop();return [K(g),f(B)]},peek:()=>o()?f(null):f(r[r.length-1]),map:g=>K(r.map(g)),flatMap:g=>o()?K([]):r.reduce((B,_)=>g(_).toArray().reduce((h,V)=>h.push(V),B),K([])),ap:g=>{let B=[];return r.forEach(_=>{g.toArray().forEach(T=>{B.push(T(_));});}),K(B)},flatMapAsync:async g=>o()?K([]):(await Promise.all(r.map(async _=>await g(_)))).reduce((_,T)=>T.toArray().reduce((h,V)=>h.push(V),_),K([])),toList:()=>m(r),toArray:()=>[...r],toString:()=>`Stack(${r.join(", ")})`,fold:(g,B)=>{if(o())return g();let _=r[r.length-1];return _!==void 0?B(_):g()},foldLeft:g=>B=>r.reduce(B,g),foldRight:g=>B=>r.reduceRight((_,T)=>B(T,_),g),match:g=>o()?g.Empty():g.NonEmpty([...r]),toValue:()=>({_tag:"Stack",value:r}),pipe:g=>g([...r]),serialize:()=>({toJSON:()=>JSON.stringify({_tag:"Stack",value:r}),toYAML:()=>`_tag: Stack
38
38
  value: ${JSON.stringify(r)}`,toBinary:()=>Buffer.from(JSON.stringify({_tag:"Stack",value:r})).toString("base64")})}},bt=(t=[])=>K(t),Qe={empty:()=>K([]),of:t=>K([t]),fromJSON:t=>{let e=JSON.parse(t);return Pe(e.value)},fromYAML:t=>{let r=t.split(`
39
- `)[1]?.split(": ")[1];if(!r)return Pe([]);let n=JSON.parse(r);return Pe(n)},fromBinary:t=>{let e=Buffer.from(t,"base64").toString();return Qe.fromJSON(e)}},Pe=a(bt,Qe);function Eo(t){let e=Le({_tag:t._tag,impl:t.impl});return {...e,toValue:()=>({_tag:e._tag,value:t.value})}}var U=t=>({_tag:"Some",value:t,isEmpty:false,isSome(){return true},isNone(){return false},get:()=>t,getOrElse:()=>t,getOrThrow:()=>t,orElse:e=>U(t),orNull:()=>t,orUndefined:()=>t,map:e=>U(e(t)),ap:e=>e._tag==="Some"&&e.value?U(e.value(t)):G,filter(e){return e(t)?U(t):G},count:e=>e(t)?1:0,find:e=>e(t)?U(t):G,exists:e=>e(t),forEach:e=>e(t),fold:(e,r)=>r(t),match:e=>e.Some(t),flatMap:e=>e(t),flatMapAsync:async e=>await e(t),reduce:e=>e(void 0,t),reduceRight:e=>e(void 0,t),foldLeft:e=>r=>r(e,t),foldRight:e=>r=>r(t,e),toList:()=>m([t]),contains:e=>e===t,size:1,toOption:()=>U(t),toEither:e=>c(t),toTry:()=>P(()=>t),toPromise:()=>Promise.resolve(t),toString:()=>`Some(${me(t)})`,toValue:()=>({_tag:"Some",value:t}),pipe:e=>e(t),serialize:()=>({toJSON:()=>JSON.stringify({_tag:"Some",value:t}),toYAML:()=>`_tag: Some
39
+ `)[1]?.split(": ")[1];if(!r)return Pe([]);let n=JSON.parse(r);return Pe(n)},fromBinary:t=>{let e=Buffer.from(t,"base64").toString();return Qe.fromJSON(e)}},Pe=a(bt,Qe);function ho(t){let e=Le({_tag:t._tag,impl:t.impl});return {...e,toValue:()=>({_tag:e._tag,value:t.value})}}var U=t=>({_tag:"Some",value:t,isEmpty:false,isSome(){return true},isNone(){return false},get:()=>t,getOrElse:()=>t,getOrThrow:()=>t,orElse:e=>U(t),orNull:()=>t,orUndefined:()=>t,map:e=>U(e(t)),ap:e=>e._tag==="Some"&&e.value?U(e.value(t)):G,filter(e){return e(t)?U(t):G},count:e=>e(t)?1:0,find:e=>e(t)?U(t):G,exists:e=>e(t),forEach:e=>e(t),fold:(e,r)=>r(t),match:e=>e.Some(t),flatMap:e=>e(t),flatMapAsync:async e=>await e(t),reduce:e=>e(void 0,t),reduceRight:e=>e(void 0,t),foldLeft:e=>r=>r(e,t),foldRight:e=>r=>r(t,e),toList:()=>m([t]),contains:e=>e===t,size:1,toOption:()=>U(t),toEither:e=>c(t),toTry:()=>P(()=>t),toPromise:()=>Promise.resolve(t),toString:()=>`Some(${me(t)})`,toValue:()=>({_tag:"Some",value:t}),pipe:e=>e(t),serialize:()=>({toJSON:()=>JSON.stringify({_tag:"Some",value:t}),toYAML:()=>`_tag: Some
40
40
  value: ${me(t)}`,toBinary:()=>Buffer.from(JSON.stringify({_tag:"Some",value:t})).toString("base64")}),[k](){return {ok:true,value:t}}}),G={_tag:"None",value:void 0,isEmpty:true,isSome(){return false},isNone(){return true},get:()=>{throw new Error("Cannot call get() on None")},getOrElse:t=>t,getOrThrow(t){throw t},orElse:t=>t,orNull:()=>null,orUndefined:()=>{},map:t=>G,ap:t=>G,filter(t){return G},count:t=>0,find:t=>G,exists:t=>false,forEach:t=>{},flatMap:t=>G,flatMapAsync:t=>Promise.resolve(G),reduce:()=>{},reduceRight:()=>{},fold:(t,e)=>t(),match:t=>t.None(),foldLeft:t=>()=>t,foldRight:t=>()=>t,toList:()=>m([]),contains:()=>false,size:0,toOption:()=>G,toEither:t=>p(t),toTry:()=>P(()=>{throw new Error("None")}),toPromise:()=>Promise.reject(new Error("Cannot convert None to Promise")),toString:()=>"None",toValue:()=>({_tag:"None",value:void 0}),pipe:t=>t(void 0),serialize:()=>({toJSON:()=>JSON.stringify({_tag:"None",value:null}),toYAML:()=>`_tag: None
41
41
  value: null`,toBinary:()=>Buffer.from(JSON.stringify({_tag:"None",value:null})).toString("base64")}),[k](){return {ok:false,empty:true}}},w=()=>G,wt=t=>t!=null?U(t):w(),Ze={from:t=>f(t),none:()=>w(),fromJSON:t=>{let e=JSON.parse(t);return e._tag==="Some"?U(e.value):w()},fromYAML:t=>{let e=t.split(`
42
- `),r=e[0]?.split(": ")[1],n=e[1]?.split(": ")[1];if(!r||!n)return w();let o=n==="null"?null:JSON.parse(n);return r==="Some"?U(o):w()},fromBinary:t=>{let e=Buffer.from(t,"base64").toString();return Ze.fromJSON(e)}},f=a(wt,Ze);export{Oe as $,xr as A,br as B,wr as C,Ur as D,Sr as E,vr as F,Or as G,Br as H,Nr as I,Vr as J,$e as K,Yr as L,qr as M,Qr as N,Hr as O,Zr as P,Xr as Q,en as R,tn as S,rn as T,ke as U,Q as V,mt as W,Se as X,yt as Y,ye as Z,H as _,k as a,N as aa,U as b,ve as ba,w as c,J as ca,wt as d,Ge as da,f as e,xe as ea,ne as f,An as fa,x as g,Ln as ga,$t as h,xn as ha,P as i,S as ia,Le as j,Bn as ja,we as k,At as ka,m as l,In as la,c as m,W as ma,p as n,Jn as na,fr as o,D as oa,dr as p,ge as pa,mr as q,Be as qa,ut as r,xt as ra,lt as s,Pe as sa,yr as t,Eo as ta,Ie as u,I as v,pt as w,Ar as x,Lr as y,kr as z};//# sourceMappingURL=chunk-7VZBQDNM.mjs.map
43
- //# sourceMappingURL=chunk-7VZBQDNM.mjs.map
42
+ `),r=e[0]?.split(": ")[1],n=e[1]?.split(": ")[1];if(!r||!n)return w();let o=n==="null"?null:JSON.parse(n);return r==="Some"?U(o):w()},fromBinary:t=>{let e=Buffer.from(t,"base64").toString();return Ze.fromJSON(e)}},f=a(wt,Ze);export{Oe as $,xr as A,br as B,wr as C,Ur as D,Sr as E,vr as F,Or as G,Br as H,Nr as I,Vr as J,$e as K,Yr as L,qr as M,Qr as N,Hr as O,Zr as P,Xr as Q,en as R,tn as S,rn as T,ke as U,Q as V,mt as W,Se as X,yt as Y,ye as Z,H as _,k as a,N as aa,U as b,ve as ba,w as c,J as ca,wt as d,Ge as da,f as e,xe as ea,ne as f,Rn as fa,x as g,An as ga,$t as h,kn as ha,P as i,S as ia,Le as j,On as ja,we as k,At as ka,m as l,Vn as la,c as m,W as ma,p as n,$n as na,fr as o,D as oa,dr as p,ge as pa,mr as q,Be as qa,ut as r,xt as ra,lt as s,Pe as sa,yr as t,ho as ta,Ie as u,I as v,pt as w,Ar as x,Lr as y,kr as z};//# sourceMappingURL=chunk-E23BUTN4.mjs.map
43
+ //# sourceMappingURL=chunk-E23BUTN4.mjs.map