@resultsafe/core-fp-result 0.1.10 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +355 -305
- package/cjs/constructors/Err.js.map +1 -1
- package/cjs/constructors/Ok.js.map +1 -1
- package/cjs/guards/isErr.js.map +1 -1
- package/cjs/guards/isErrAnd.js.map +1 -1
- package/cjs/guards/isOk.js.map +1 -1
- package/cjs/guards/isOkAnd.js.map +1 -1
- package/cjs/methods/andThen.js.map +1 -1
- package/cjs/methods/err.js.map +1 -1
- package/cjs/methods/expect.js.map +1 -1
- package/cjs/methods/expectErr.js.map +1 -1
- package/cjs/methods/flatten.js.map +1 -1
- package/cjs/methods/inspect.js.map +1 -1
- package/cjs/methods/inspectErr.js.map +1 -1
- package/cjs/methods/map.js.map +1 -1
- package/cjs/methods/mapErr.js.map +1 -1
- package/cjs/methods/match.js.map +1 -1
- package/cjs/methods/ok.js.map +1 -1
- package/cjs/methods/orElse.js.map +1 -1
- package/cjs/methods/tap.js.map +1 -1
- package/cjs/methods/tapErr.js.map +1 -1
- package/cjs/methods/transpose.js.map +1 -1
- package/cjs/methods/unwrap.js.map +1 -1
- package/cjs/methods/unwrapErr.js.map +1 -1
- package/cjs/methods/unwrapOr.js.map +1 -1
- package/cjs/methods/unwrapOrElse.js.map +1 -1
- package/cjs/refiners/isTypedVariant.js.map +1 -1
- package/cjs/refiners/isTypedVariantOf.js.map +1 -1
- package/cjs/refiners/matchVariant.js.map +1 -1
- package/cjs/refiners/matchVariantStrict.js.map +1 -1
- package/cjs/refiners/refineAsyncResult.js.map +1 -1
- package/cjs/refiners/refineAsyncResultU.js.map +1 -1
- package/cjs/refiners/refineResult.js.map +1 -1
- package/cjs/refiners/refineResultU.js.map +1 -1
- package/cjs/refiners/refineVariantMap.js.map +1 -1
- package/cjs/refiners/utils/getPayloadKeys.js.map +1 -1
- package/docs/assets/logo.svg +0 -0
- package/esm/constructors/Err.js.map +1 -1
- package/esm/constructors/Ok.js.map +1 -1
- package/esm/guards/isErr.js.map +1 -1
- package/esm/guards/isErrAnd.js.map +1 -1
- package/esm/guards/isOk.js.map +1 -1
- package/esm/guards/isOkAnd.js.map +1 -1
- package/esm/methods/andThen.js.map +1 -1
- package/esm/methods/err.js.map +1 -1
- package/esm/methods/expect.js.map +1 -1
- package/esm/methods/expectErr.js.map +1 -1
- package/esm/methods/flatten.js.map +1 -1
- package/esm/methods/inspect.js.map +1 -1
- package/esm/methods/inspectErr.js.map +1 -1
- package/esm/methods/map.js.map +1 -1
- package/esm/methods/mapErr.js.map +1 -1
- package/esm/methods/match.js.map +1 -1
- package/esm/methods/ok.js.map +1 -1
- package/esm/methods/orElse.js.map +1 -1
- package/esm/methods/tap.js.map +1 -1
- package/esm/methods/tapErr.js.map +1 -1
- package/esm/methods/transpose.js.map +1 -1
- package/esm/methods/unwrap.js.map +1 -1
- package/esm/methods/unwrapErr.js.map +1 -1
- package/esm/methods/unwrapOr.js.map +1 -1
- package/esm/methods/unwrapOrElse.js.map +1 -1
- package/esm/refiners/isTypedVariant.js.map +1 -1
- package/esm/refiners/isTypedVariantOf.js.map +1 -1
- package/esm/refiners/matchVariant.js.map +1 -1
- package/esm/refiners/matchVariantStrict.js.map +1 -1
- package/esm/refiners/refineAsyncResult.js.map +1 -1
- package/esm/refiners/refineAsyncResultU.js.map +1 -1
- package/esm/refiners/refineResult.js.map +1 -1
- package/esm/refiners/refineResultU.js.map +1 -1
- package/esm/refiners/refineVariantMap.js.map +1 -1
- package/esm/refiners/utils/getPayloadKeys.js.map +1 -1
- package/package.json +1 -1
- package/types/constructors/Err.d.ts +4 -4
- package/types/constructors/Err.d.ts.map +1 -1
- package/types/constructors/Ok.d.ts +4 -4
- package/types/constructors/Ok.d.ts.map +1 -1
- package/types/guards/isErr.d.ts +5 -5
- package/types/guards/isErr.d.ts.map +1 -1
- package/types/guards/isErrAnd.d.ts +6 -6
- package/types/guards/isErrAnd.d.ts.map +1 -1
- package/types/guards/isOk.d.ts +5 -5
- package/types/guards/isOk.d.ts.map +1 -1
- package/types/guards/isOkAnd.d.ts +6 -6
- package/types/guards/isOkAnd.d.ts.map +1 -1
- package/types/index.d.ts +1 -0
- package/types/index.d.ts.map +1 -1
- package/types/methods/andThen.d.ts +7 -7
- package/types/methods/andThen.d.ts.map +1 -1
- package/types/methods/err.d.ts +7 -8
- package/types/methods/err.d.ts.map +1 -1
- package/types/methods/expect.d.ts +9 -9
- package/types/methods/expect.d.ts.map +1 -1
- package/types/methods/expectErr.d.ts +9 -9
- package/types/methods/expectErr.d.ts.map +1 -1
- package/types/methods/flatten.d.ts +3 -3
- package/types/methods/flatten.d.ts.map +1 -1
- package/types/methods/inspect.d.ts +8 -8
- package/types/methods/inspect.d.ts.map +1 -1
- package/types/methods/inspectErr.d.ts +8 -8
- package/types/methods/inspectErr.d.ts.map +1 -1
- package/types/methods/map.d.ts +9 -9
- package/types/methods/map.d.ts.map +1 -1
- package/types/methods/mapErr.d.ts +8 -8
- package/types/methods/mapErr.d.ts.map +1 -1
- package/types/methods/match.d.ts +8 -8
- package/types/methods/match.d.ts.map +1 -1
- package/types/methods/ok.d.ts +7 -8
- package/types/methods/ok.d.ts.map +1 -1
- package/types/methods/orElse.d.ts +9 -9
- package/types/methods/orElse.d.ts.map +1 -1
- package/types/methods/tap.d.ts +7 -7
- package/types/methods/tap.d.ts.map +1 -1
- package/types/methods/tapErr.d.ts +7 -7
- package/types/methods/tapErr.d.ts.map +1 -1
- package/types/methods/transpose.d.ts +5 -6
- package/types/methods/transpose.d.ts.map +1 -1
- package/types/methods/unwrap.d.ts +8 -8
- package/types/methods/unwrap.d.ts.map +1 -1
- package/types/methods/unwrapErr.d.ts +8 -8
- package/types/methods/unwrapErr.d.ts.map +1 -1
- package/types/methods/unwrapOr.d.ts +8 -8
- package/types/methods/unwrapOr.d.ts.map +1 -1
- package/types/methods/unwrapOrElse.d.ts +8 -8
- package/types/methods/unwrapOrElse.d.ts.map +1 -1
- package/types/refiners/isTypedVariant.d.ts +3 -3
- package/types/refiners/isTypedVariantOf.d.ts +3 -3
- package/types/refiners/matchVariant.d.ts +5 -5
- package/types/refiners/matchVariantStrict.d.ts +6 -6
- package/types/refiners/refineAsyncResult.d.ts +17 -15
- package/types/refiners/refineAsyncResult.d.ts.map +1 -1
- package/types/refiners/refineAsyncResultU.d.ts +13 -11
- package/types/refiners/refineAsyncResultU.d.ts.map +1 -1
- package/types/refiners/refineResult.d.ts +18 -16
- package/types/refiners/refineResult.d.ts.map +1 -1
- package/types/refiners/refineResultU.d.ts +13 -11
- package/types/refiners/refineResultU.d.ts.map +1 -1
- package/types/refiners/refineVariantMap.d.ts +8 -8
- package/types/refiners/refineVariantMap.d.ts.map +1 -1
- package/types/refiners/types/Handler.d.ts +9 -1
- package/types/refiners/types/Handler.d.ts.map +1 -1
- package/types/refiners/types/MatchBuilder.d.ts +20 -1
- package/types/refiners/types/MatchBuilder.d.ts.map +1 -1
- package/types/refiners/types/Matcher.d.ts +23 -1
- package/types/refiners/types/Matcher.d.ts.map +1 -1
- package/types/refiners/types/SyncRefinedResult.d.ts +26 -2
- package/types/refiners/types/SyncRefinedResult.d.ts.map +1 -1
- package/types/refiners/types/SyncRefinedResultUnion.d.ts +25 -2
- package/types/refiners/types/SyncRefinedResultUnion.d.ts.map +1 -1
- package/types/refiners/types/SyncValidatorMap.d.ts +26 -2
- package/types/refiners/types/SyncValidatorMap.d.ts.map +1 -1
- package/types/refiners/types/UniversalAsyncRefinedResult.d.ts +28 -2
- package/types/refiners/types/UniversalAsyncRefinedResult.d.ts.map +1 -1
- package/types/refiners/types/UniversalRefinedResult.d.ts +28 -2
- package/types/refiners/types/UniversalRefinedResult.d.ts.map +1 -1
- package/types/refiners/types/VariantOf.d.ts +20 -1
- package/types/refiners/types/VariantOf.d.ts.map +1 -1
- package/types/refiners/utils/getPayloadKeys.d.ts +6 -5
- package/types/refiners/utils/getPayloadKeys.d.ts.map +1 -1
- package/types/types/core/index.d.ts +3 -0
- package/types/types/core/index.d.ts.map +1 -0
- package/types/types/index.d.ts +1 -2
- package/types/types/index.d.ts.map +1 -1
- package/umd/resultsafe-monorepo-core-fp-result.umd.js.map +1 -1
- package/types/shared-types.d.ts +0 -22
- package/types/shared-types.d.ts.map +0 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Creates a runtime type guard for a variant with additional payload keys.
|
|
3
3
|
*
|
|
4
4
|
* @typeParam K - The discriminant literal type.
|
|
5
5
|
* @typeParam T - The required payload record shape.
|
|
6
|
-
* @param variant -
|
|
6
|
+
* @param variant - The discriminant value to match.
|
|
7
7
|
* @returns A predicate that checks variant and payload key presence.
|
|
8
8
|
* @since 0.1.0
|
|
9
|
-
* @see {@link isTypedVariant} -
|
|
9
|
+
* @see {@link isTypedVariant} - Checks only the discriminant.
|
|
10
10
|
* @example
|
|
11
11
|
* ```ts
|
|
12
12
|
* import { isTypedVariantOf } from '@resultsafe/core-fp-result';
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { Matcher, VariantOf } from './types/index.js';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Creates a chained matcher for a discriminated union value.
|
|
4
4
|
*
|
|
5
|
-
* @typeParam T -
|
|
6
|
-
* @param value -
|
|
7
|
-
* @returns
|
|
5
|
+
* @typeParam T - The discriminated union type.
|
|
6
|
+
* @param value - The union value to match.
|
|
7
|
+
* @returns A fluent matcher with `with` and `otherwise` branches.
|
|
8
8
|
* @since 0.1.0
|
|
9
|
-
* @see {@link matchVariantStrict} -
|
|
9
|
+
* @see {@link matchVariantStrict} - Requires exhaustive matching at runtime.
|
|
10
10
|
* @example
|
|
11
11
|
* ```ts
|
|
12
12
|
* import { matchVariant } from '@resultsafe/core-fp-result';
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { MatchBuilder, VariantOf } from './types/index.js';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Creates a strict matcher that throws an exception for unhandled variants.
|
|
4
4
|
*
|
|
5
|
-
* @typeParam T -
|
|
6
|
-
* @param value -
|
|
7
|
-
* @returns
|
|
8
|
-
* @throws Error -
|
|
5
|
+
* @typeParam T - The discriminated union type.
|
|
6
|
+
* @param value - The union value to match.
|
|
7
|
+
* @returns A strict match builder requiring explicit handlers.
|
|
8
|
+
* @throws Error - Throws an exception if no registered handler matches `value.type`.
|
|
9
9
|
* @since 0.1.0
|
|
10
|
-
* @see {@link matchVariant} -
|
|
10
|
+
* @see {@link matchVariant} - Uses a fallback branch instead of throwing.
|
|
11
11
|
* @example
|
|
12
12
|
* ```ts
|
|
13
13
|
* import { matchVariantStrict } from '@resultsafe/core-fp-result';
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import type { AsyncValidatorFn
|
|
1
|
+
import type { AsyncValidatorFn } from '../types/refiners/AsyncValidatorFn.js';
|
|
2
|
+
import type { PayloadKeys } from '../types/refiners/PayloadKeys.js';
|
|
3
|
+
import type { VariantConfig } from '../types/refiners/VariantConfig.js';
|
|
2
4
|
import type { UniversalAsyncRefinedResult } from './types/index.js';
|
|
3
5
|
/**
|
|
4
|
-
*
|
|
6
|
+
* Creates an async variant refiner with async payload validators.
|
|
5
7
|
*
|
|
6
|
-
* @typeParam TMap -
|
|
7
|
-
* @param variantMap -
|
|
8
|
+
* @typeParam TMap - The variant configuration map type.
|
|
9
|
+
* @param variantMap - The map describing valid variants and payload fields.
|
|
8
10
|
* @returns A curried async refiner factory bound to `variantMap`.
|
|
9
11
|
* @since 0.1.0
|
|
10
|
-
* @see {@link refineAsyncResultU} -
|
|
12
|
+
* @see {@link refineAsyncResultU} - Direct (non-curried) helper variant.
|
|
11
13
|
* @example
|
|
12
14
|
* ```ts
|
|
13
15
|
* import { refineAsyncResult } from '@resultsafe/core-fp-result';
|
|
@@ -23,19 +25,19 @@ import type { UniversalAsyncRefinedResult } from './types/index.js';
|
|
|
23
25
|
*/
|
|
24
26
|
export declare const refineAsyncResult: <TMap extends Record<string, VariantConfig>>(variantMap: TMap) => <K extends keyof TMap & string>(variant: K) => <TValidators extends Partial<Record<PayloadKeys<TMap[K]>, AsyncValidatorFn>>>(validators: TValidators) => (value: unknown) => Promise<UniversalAsyncRefinedResult<K, TMap, TValidators> | null>;
|
|
25
27
|
/**
|
|
26
|
-
*
|
|
28
|
+
* Refines a value asynchronously in non-curried call style.
|
|
27
29
|
*
|
|
28
|
-
* @typeParam TMap -
|
|
29
|
-
* @typeParam K -
|
|
30
|
-
* @typeParam TValidators -
|
|
31
|
-
* @param value -
|
|
32
|
-
* @param variant -
|
|
33
|
-
* @param variantMap -
|
|
34
|
-
* @param validators -
|
|
35
|
-
* @returns
|
|
30
|
+
* @typeParam TMap - The variant configuration map type.
|
|
31
|
+
* @typeParam K - The target variant key.
|
|
32
|
+
* @typeParam TValidators - The async validator map for payload fields.
|
|
33
|
+
* @param value - The value to validate and refine.
|
|
34
|
+
* @param variant - The target variant key.
|
|
35
|
+
* @param variantMap - The variant configuration map.
|
|
36
|
+
* @param validators - The async payload validators.
|
|
37
|
+
* @returns A promise resolving to the refined value or `null`.
|
|
36
38
|
* @remarks
|
|
37
39
|
* This export is kept for compatibility. Prefer {@link refineAsyncResultU}
|
|
38
|
-
* from `refineAsyncResultU.ts`
|
|
40
|
+
* from `refineAsyncResultU.ts` as the canonical non-curried entry point.
|
|
39
41
|
* @since 0.1.0
|
|
40
42
|
* @example
|
|
41
43
|
* ```ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refineAsyncResult.d.ts","sourceRoot":"","sources":["../../../src/refiners/refineAsyncResult.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"refineAsyncResult.d.ts","sourceRoot":"","sources":["../../../src/refiners/refineAsyncResult.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AAC9E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAC;AAWpE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,iBAAiB,GAC3B,IAAI,SAAS,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,EAAE,YAAY,IAAI,MAC5D,CAAC,SAAS,MAAM,IAAI,GAAG,MAAM,EAAE,SAAS,CAAC,MACzC,WAAW,SAAS,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,gBAAgB,CAAC,CAAC,EAC1E,YAAY,WAAW,MAGvB,OAAO,OAAO,KACb,OAAO,CAAC,2BAA2B,CAAC,CAAC,EAAE,IAAI,EAAE,WAAW,CAAC,GAAG,IAAI,CAqBlE,CAAC;AAEJ;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,kBAAkB,GAC7B,IAAI,SAAS,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,EAC1C,CAAC,SAAS,MAAM,IAAI,GAAG,MAAM,EAC7B,WAAW,SAAS,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,gBAAgB,CAAC,CAAC,EAE3E,OAAO,OAAO,EACd,SAAS,CAAC,EACV,YAAY,IAAI,EAChB,YAAY,WAAW,KACtB,OAAO,CAAC,2BAA2B,CAAC,CAAC,EAAE,IAAI,EAAE,WAAW,CAAC,GAAG,IAAI,CACR,CAAC"}
|
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
import type { AsyncValidatorFn
|
|
1
|
+
import type { AsyncValidatorFn } from '../types/refiners/AsyncValidatorFn.js';
|
|
2
|
+
import type { PayloadKeys } from '../types/refiners/PayloadKeys.js';
|
|
3
|
+
import type { VariantConfig } from '../types/refiners/VariantConfig.js';
|
|
2
4
|
import type { UniversalAsyncRefinedResult } from './types/index.js';
|
|
3
5
|
/**
|
|
4
|
-
*
|
|
6
|
+
* Refines a value asynchronously in non-curried call style.
|
|
5
7
|
*
|
|
6
|
-
* @typeParam TMap -
|
|
7
|
-
* @typeParam K -
|
|
8
|
-
* @typeParam TValidators -
|
|
9
|
-
* @param value -
|
|
10
|
-
* @param variant -
|
|
11
|
-
* @param variantMap -
|
|
12
|
-
* @param validators -
|
|
13
|
-
* @returns
|
|
8
|
+
* @typeParam TMap - The variant configuration map type.
|
|
9
|
+
* @typeParam K - The target variant key.
|
|
10
|
+
* @typeParam TValidators - The async validator map for payload fields.
|
|
11
|
+
* @param value - The value to validate and refine.
|
|
12
|
+
* @param variant - The target variant key.
|
|
13
|
+
* @param variantMap - The variant configuration map.
|
|
14
|
+
* @param validators - The async payload validators.
|
|
15
|
+
* @returns A promise resolving to the refined value or `null`.
|
|
14
16
|
* @since 0.1.0
|
|
15
|
-
* @see {@link refineAsyncResult} - Curry
|
|
17
|
+
* @see {@link refineAsyncResult} - Curry-style async refiner constructor.
|
|
16
18
|
* @example
|
|
17
19
|
* ```ts
|
|
18
20
|
* import { refineAsyncResultU } from '@resultsafe/core-fp-result';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refineAsyncResultU.d.ts","sourceRoot":"","sources":["../../../src/refiners/refineAsyncResultU.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"refineAsyncResultU.d.ts","sourceRoot":"","sources":["../../../src/refiners/refineAsyncResultU.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AAC9E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAC;AAWpE;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,kBAAkB,GAC7B,IAAI,SAAS,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,EAC1C,CAAC,SAAS,MAAM,IAAI,GAAG,MAAM,EAC7B,WAAW,SAAS,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,gBAAgB,CAAC,CAAC,EAE3E,OAAO,OAAO,EACd,SAAS,CAAC,EACV,YAAY,IAAI,EAChB,YAAY,WAAW,KACtB,OAAO,CAAC,2BAA2B,CAAC,CAAC,EAAE,IAAI,EAAE,WAAW,CAAC,GAAG,IAAI,CA4BlE,CAAC"}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import type { PayloadKeys
|
|
1
|
+
import type { PayloadKeys } from '../types/refiners/PayloadKeys.js';
|
|
2
|
+
import type { ValidatorFn } from '../types/refiners/ValidatorFn.js';
|
|
3
|
+
import type { VariantConfig } from '../types/refiners/VariantConfig.js';
|
|
2
4
|
import type { UniversalRefinedResult } from './types/index.js';
|
|
3
5
|
/**
|
|
4
|
-
*
|
|
6
|
+
* Creates a sync variant refiner with payload validators.
|
|
5
7
|
*
|
|
6
|
-
* @typeParam TMap -
|
|
7
|
-
* @param variantMap -
|
|
8
|
+
* @typeParam TMap - The variant configuration map type.
|
|
9
|
+
* @param variantMap - The map describing valid variants and payload fields.
|
|
8
10
|
* @returns A curried refiner factory bound to `variantMap`.
|
|
9
11
|
* @since 0.1.0
|
|
10
|
-
* @see {@link refineResultU} -
|
|
12
|
+
* @see {@link refineResultU} - Direct (non-curried) helper variant.
|
|
11
13
|
* @example
|
|
12
14
|
* ```ts
|
|
13
15
|
* import { refineResult } from '@resultsafe/core-fp-result';
|
|
@@ -23,19 +25,19 @@ import type { UniversalRefinedResult } from './types/index.js';
|
|
|
23
25
|
*/
|
|
24
26
|
export declare const refineResult: <TMap extends Record<string, VariantConfig>>(variantMap: TMap) => <K extends keyof TMap & string>(variant: K) => <TValidators extends Partial<Record<PayloadKeys<TMap[K]>, ValidatorFn>>>(validators: TValidators) => (value: unknown) => UniversalRefinedResult<K, TMap, TValidators> | null;
|
|
25
27
|
/**
|
|
26
|
-
*
|
|
28
|
+
* Refines a value by variant map in non-curried call style.
|
|
27
29
|
*
|
|
28
|
-
* @typeParam TMap -
|
|
29
|
-
* @typeParam K -
|
|
30
|
-
* @typeParam TValidators -
|
|
31
|
-
* @param value -
|
|
32
|
-
* @param variant -
|
|
33
|
-
* @param variantMap -
|
|
34
|
-
* @param validators -
|
|
35
|
-
* @returns
|
|
30
|
+
* @typeParam TMap - The variant configuration map type.
|
|
31
|
+
* @typeParam K - The target variant key.
|
|
32
|
+
* @typeParam TValidators - The validator map for payload fields.
|
|
33
|
+
* @param value - The value to validate and refine.
|
|
34
|
+
* @param variant - The target variant key.
|
|
35
|
+
* @param variantMap - The variant configuration map.
|
|
36
|
+
* @param validators - The payload validators for the target variant.
|
|
37
|
+
* @returns The refined value or `null`.
|
|
36
38
|
* @remarks
|
|
37
|
-
*
|
|
38
|
-
* `refineResultU.ts`
|
|
39
|
+
* This export is kept for compatibility. Prefer {@link refineResultU} from
|
|
40
|
+
* `refineResultU.ts` as the canonical non-curried entry point.
|
|
39
41
|
* @since 0.1.0
|
|
40
42
|
* @example
|
|
41
43
|
* ```ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refineResult.d.ts","sourceRoot":"","sources":["../../../src/refiners/refineResult.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"refineResult.d.ts","sourceRoot":"","sources":["../../../src/refiners/refineResult.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAG/D;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,YAAY,GACtB,IAAI,SAAS,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,EAAE,YAAY,IAAI,MAC5D,CAAC,SAAS,MAAM,IAAI,GAAG,MAAM,EAAE,SAAS,CAAC,MACzC,WAAW,SAAS,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,EACrE,YAAY,WAAW,MAExB,OAAO,OAAO,KAAG,sBAAsB,CAAC,CAAC,EAAE,IAAI,EAAE,WAAW,CAAC,GAAG,IAoBhE,CAAC;AAEJ;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,aAAa,GACxB,IAAI,SAAS,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,EAC1C,CAAC,SAAS,MAAM,IAAI,GAAG,MAAM,EAC7B,WAAW,SAAS,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,EAEtE,OAAO,OAAO,EACd,SAAS,CAAC,EACV,YAAY,IAAI,EAChB,YAAY,WAAW,KACtB,sBAAsB,CAAC,CAAC,EAAE,IAAI,EAAE,WAAW,CAAC,GAAG,IACI,CAAC"}
|
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
import type { PayloadKeys
|
|
1
|
+
import type { PayloadKeys } from '../types/refiners/PayloadKeys.js';
|
|
2
|
+
import type { ValidatorFn } from '../types/refiners/ValidatorFn.js';
|
|
3
|
+
import type { VariantConfig } from '../types/refiners/VariantConfig.js';
|
|
2
4
|
import type { SyncRefinedResult } from './types/index.js';
|
|
3
5
|
/**
|
|
4
|
-
*
|
|
6
|
+
* Refines a value by variant map in non-curried call style.
|
|
5
7
|
*
|
|
6
|
-
* @typeParam TMap -
|
|
7
|
-
* @typeParam K -
|
|
8
|
-
* @typeParam TValidators -
|
|
9
|
-
* @param value -
|
|
10
|
-
* @param variant -
|
|
11
|
-
* @param variantMap -
|
|
12
|
-
* @param validators -
|
|
13
|
-
* @returns
|
|
8
|
+
* @typeParam TMap - The variant configuration map type.
|
|
9
|
+
* @typeParam K - The target variant key.
|
|
10
|
+
* @typeParam TValidators - The validator map for payload fields.
|
|
11
|
+
* @param value - The value to validate and refine.
|
|
12
|
+
* @param variant - The target variant key.
|
|
13
|
+
* @param variantMap - The variant configuration map.
|
|
14
|
+
* @param validators - The payload validators for the target variant.
|
|
15
|
+
* @returns The refined value or `null`.
|
|
14
16
|
* @since 0.1.0
|
|
15
|
-
* @see {@link refineResult} - Curry
|
|
17
|
+
* @see {@link refineResult} - Curry-style refiner constructor.
|
|
16
18
|
* @example
|
|
17
19
|
* ```ts
|
|
18
20
|
* import { refineResultU } from '@resultsafe/core-fp-result';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refineResultU.d.ts","sourceRoot":"","sources":["../../../src/refiners/refineResultU.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"refineResultU.d.ts","sourceRoot":"","sources":["../../../src/refiners/refineResultU.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AAExE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAE1D;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,aAAa,GACxB,IAAI,SAAS,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,EAC1C,CAAC,SAAS,MAAM,IAAI,GAAG,MAAM,EAC7B,WAAW,SAAS,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,EAEtE,OAAO,OAAO,EACd,SAAS,CAAC,EACV,YAAY,IAAI,EAChB,YAAY,WAAW,KACtB,iBAAiB,CAAC,CAAC,EAAE,IAAI,EAAE,WAAW,CAAC,GAAG,IACS,CAAC"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import type { VariantConfig } from '../
|
|
1
|
+
import type { VariantConfig } from '../types/refiners/VariantConfig.js';
|
|
2
2
|
import type { SyncRefinedResultUnion } from './types/SyncRefinedResultUnion.js';
|
|
3
3
|
import type { SyncValidatorMap } from './types/SyncValidatorMap.js';
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Refines a discriminated union value by a full variant map.
|
|
6
6
|
*
|
|
7
|
-
* @typeParam TMap -
|
|
8
|
-
* @typeParam TValidators -
|
|
9
|
-
* @param value -
|
|
10
|
-
* @param variantMap -
|
|
11
|
-
* @param validators -
|
|
12
|
-
* @returns
|
|
7
|
+
* @typeParam TMap - The variant configuration map type.
|
|
8
|
+
* @typeParam TValidators - The validator map type by variant.
|
|
9
|
+
* @param value - The value to validate and refine.
|
|
10
|
+
* @param variantMap - The full variant configuration map.
|
|
11
|
+
* @param validators - The validators grouped by variant key.
|
|
12
|
+
* @returns The refined union member or `null`.
|
|
13
13
|
* @since 0.1.0
|
|
14
14
|
* @see {@link refineResult} - Refines one concrete variant key.
|
|
15
15
|
* @example
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refineVariantMap.d.ts","sourceRoot":"","sources":["../../../src/refiners/refineVariantMap.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"refineVariantMap.d.ts","sourceRoot":"","sources":["../../../src/refiners/refineVariantMap.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAChF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAEpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,SAAS,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,EAC1C,WAAW,SAAS,gBAAgB,CAAC,IAAI,CAAC,EAE1C,KAAK,EAAE,OAAO,EACd,UAAU,EAAE,IAAI,EAChB,UAAU,EAAE,WAAW,GACtB,sBAAsB,CAAC,IAAI,EAAE,WAAW,CAAC,GAAG,IAAI,CAoClD"}
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import type { VariantOf } from './VariantOf.js';
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Describes a handler entry for variant matching in internal matcher mechanisms.
|
|
4
|
+
*
|
|
5
|
+
* @typeParam K - The variant key type.
|
|
6
|
+
* @typeParam T - The variant union type.
|
|
7
|
+
* @typeParam R - The return type of the handler function.
|
|
8
|
+
*
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
3
11
|
export type Handler<K extends string, T extends VariantOf<K>, R> = {
|
|
4
12
|
readonly variant: K;
|
|
5
13
|
readonly fn: (value: Extract<T, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Handler.d.ts","sourceRoot":"","sources":["../../../../src/refiners/types/Handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD
|
|
1
|
+
{"version":3,"file":"Handler.d.ts","sourceRoot":"","sources":["../../../../src/refiners/types/Handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD;;;;;;;;GAQG;AACH,MAAM,MAAM,OAAO,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI;IACjE,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;IACpB,QAAQ,CAAC,EAAE,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,EAAE;QAAE,IAAI,EAAE,CAAC,CAAA;KAAE,CAAC,KAAK,CAAC,CAAC;CACpD,CAAC"}
|
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
import type { VariantOf } from './VariantOf.js';
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Describes the shape of a strict builder for variant matching.
|
|
4
|
+
*
|
|
5
|
+
* @typeParam T - The variant union type.
|
|
6
|
+
* @typeParam R - The return type of the match operation.
|
|
7
|
+
* @typeParam Handled - The union of already handled variant types.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* import { MatchBuilder } from '@resultsafe/core-fp-result';
|
|
12
|
+
*
|
|
13
|
+
* const builder: MatchBuilder<MyVariant, string> = {
|
|
14
|
+
* with: (variant, fn) => builder,
|
|
15
|
+
* run: () => 'result'
|
|
16
|
+
* };
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @since 0.1.8
|
|
20
|
+
* @public
|
|
21
|
+
*/
|
|
3
22
|
export type MatchBuilder<T extends VariantOf, R, Handled extends T['type'] = never> = {
|
|
4
23
|
readonly with: <K extends Exclude<T['type'], Handled>>(variant: K, fn: (value: Extract<T, {
|
|
5
24
|
type: K;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MatchBuilder.d.ts","sourceRoot":"","sources":["../../../../src/refiners/types/MatchBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD
|
|
1
|
+
{"version":3,"file":"MatchBuilder.d.ts","sourceRoot":"","sources":["../../../../src/refiners/types/MatchBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,MAAM,YAAY,CACtB,CAAC,SAAS,SAAS,EACnB,CAAC,EACD,OAAO,SAAS,CAAC,CAAC,MAAM,CAAC,GAAG,KAAK,IAC/B;IACF,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,SAAS,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,EACnD,OAAO,EAAE,CAAC,EACV,EAAE,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,EAAE;QAAE,IAAI,EAAE,CAAC,CAAA;KAAE,CAAC,KAAK,CAAC,KACtC,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,GAAG,CAAC,CAAC,CAAC;IACrC,QAAQ,CAAC,GAAG,EAAE,OAAO,SAAS,CAAC,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,GAAG,KAAK,CAAC;CAC3D,CAAC"}
|
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
import type { VariantOf } from './VariantOf.js';
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Describes the shape of a non-strict builder for variant matching.
|
|
4
|
+
*
|
|
5
|
+
* @typeParam T - The variant union type.
|
|
6
|
+
* @typeParam R - The return type of the match operation.
|
|
7
|
+
*
|
|
8
|
+
* @remarks
|
|
9
|
+
* Unlike {@link MatchBuilder}, this builder allows matching any variant
|
|
10
|
+
* and provides an `otherwise` fallback handler for unmatched cases.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { Matcher } from '@resultsafe/core-fp-result';
|
|
15
|
+
*
|
|
16
|
+
* const matcher: Matcher<MyVariant, string> = {
|
|
17
|
+
* with: (variant, fn) => matcher,
|
|
18
|
+
* otherwise: (fn) => ({ run: () => 'default' })
|
|
19
|
+
* };
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @since 0.1.8
|
|
23
|
+
* @public
|
|
24
|
+
*/
|
|
3
25
|
export type Matcher<T extends VariantOf, R> = {
|
|
4
26
|
readonly with: <K extends T['type']>(variant: K, fn: (value: Extract<T, {
|
|
5
27
|
type: K;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Matcher.d.ts","sourceRoot":"","sources":["../../../../src/refiners/types/Matcher.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD
|
|
1
|
+
{"version":3,"file":"Matcher.d.ts","sourceRoot":"","sources":["../../../../src/refiners/types/Matcher.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,MAAM,OAAO,CAAC,CAAC,SAAS,SAAS,EAAE,CAAC,IAAI;IAC5C,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,EACjC,OAAO,EAAE,CAAC,EACV,EAAE,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,EAAE;QAAE,IAAI,EAAE,CAAC,CAAA;KAAE,CAAC,KAAK,CAAC,KACtC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACnB,QAAQ,CAAC,SAAS,EAAE,CAAC,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,KAAK;QAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;KAAE,CAAC;CACxE,CAAC"}
|
|
@@ -1,5 +1,29 @@
|
|
|
1
|
-
import type { PayloadKeys
|
|
2
|
-
|
|
1
|
+
import type { PayloadKeys } from '../../types/refiners/PayloadKeys.js';
|
|
2
|
+
import type { ValidatorFn } from '../../types/refiners/ValidatorFn.js';
|
|
3
|
+
import type { VariantConfig } from '../../types/refiners/VariantConfig.js';
|
|
4
|
+
/**
|
|
5
|
+
* Describes a synchronously refined specific variant value.
|
|
6
|
+
*
|
|
7
|
+
* @typeParam K - The variant key type.
|
|
8
|
+
* @typeParam TMap - The variant configuration map.
|
|
9
|
+
* @typeParam _TValidators - The validator map for the variant.
|
|
10
|
+
*
|
|
11
|
+
* @remarks
|
|
12
|
+
* This type represents a refined variant with its payload fields
|
|
13
|
+
* validated synchronously. The `type` field discriminates the variant,
|
|
14
|
+
* and the remaining fields are the validated payload.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* import { SyncRefinedResult, VariantConfig } from '@resultsafe/core-fp-result';
|
|
19
|
+
*
|
|
20
|
+
* type MyVariant = SyncRefinedResult<'user', { user: { payload: 'name' } }, {}>;
|
|
21
|
+
* // { type: 'user'; name: unknown }
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @since 0.1.8
|
|
25
|
+
* @public
|
|
26
|
+
*/
|
|
3
27
|
export type SyncRefinedResult<K extends keyof TMap & string, TMap extends Record<string, VariantConfig>, _TValidators extends Partial<Record<PayloadKeys<TMap[K]>, ValidatorFn>>> = {
|
|
4
28
|
type: K;
|
|
5
29
|
} & Record<PayloadKeys<TMap[K]>, unknown>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SyncRefinedResult.d.ts","sourceRoot":"","sources":["../../../../src/refiners/types/SyncRefinedResult.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"SyncRefinedResult.d.ts","sourceRoot":"","sources":["../../../../src/refiners/types/SyncRefinedResult.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AAE3E;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,MAAM,iBAAiB,CAC3B,CAAC,SAAS,MAAM,IAAI,GAAG,MAAM,EAC7B,IAAI,SAAS,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,EAC1C,YAAY,SAAS,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,IACrE;IACF,IAAI,EAAE,CAAC,CAAC;CACT,GAAG,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC"}
|
|
@@ -1,7 +1,30 @@
|
|
|
1
|
-
import type { VariantConfig } from '../../
|
|
1
|
+
import type { VariantConfig } from '../../types/refiners/VariantConfig.js';
|
|
2
2
|
import type { SyncRefinedResult } from './SyncRefinedResult.js';
|
|
3
3
|
import type { SyncValidatorMap } from './SyncValidatorMap.js';
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* Describes a union of synchronously refined variants.
|
|
6
|
+
*
|
|
7
|
+
* @typeParam TMap - The variant configuration map.
|
|
8
|
+
* @typeParam TValidators - The validator map for all variants.
|
|
9
|
+
*
|
|
10
|
+
* @remarks
|
|
11
|
+
* This type represents the union of all refined variants in the map.
|
|
12
|
+
* Each variant is refined using {@link SyncRefinedResult}.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* import { SyncRefinedResultUnion, VariantConfig } from '@resultsafe/core-fp-result';
|
|
17
|
+
*
|
|
18
|
+
* type Variants = SyncRefinedResultUnion<
|
|
19
|
+
* { user: { payload: 'name' }; error: { payload: 'code' } },
|
|
20
|
+
* {}
|
|
21
|
+
* >;
|
|
22
|
+
* // { type: 'user'; name: unknown } | { type: 'error'; code: unknown }
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @since 0.1.8
|
|
26
|
+
* @public
|
|
27
|
+
*/
|
|
5
28
|
export type SyncRefinedResultUnion<TMap extends Record<string, VariantConfig>, TValidators extends SyncValidatorMap<TMap>> = {
|
|
6
29
|
[K in keyof TMap & string]: SyncRefinedResult<K, TMap, NonNullable<TValidators[K]>>;
|
|
7
30
|
}[keyof TMap & string];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SyncRefinedResultUnion.d.ts","sourceRoot":"","sources":["../../../../src/refiners/types/SyncRefinedResultUnion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"SyncRefinedResultUnion.d.ts","sourceRoot":"","sources":["../../../../src/refiners/types/SyncRefinedResultUnion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AAC3E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE9D;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,MAAM,sBAAsB,CAChC,IAAI,SAAS,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,EAC1C,WAAW,SAAS,gBAAgB,CAAC,IAAI,CAAC,IACxC;KACD,CAAC,IAAI,MAAM,IAAI,GAAG,MAAM,GAAG,iBAAiB,CAC3C,CAAC,EACD,IAAI,EACJ,WAAW,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAC5B;CACF,CAAC,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC"}
|
|
@@ -1,5 +1,29 @@
|
|
|
1
|
-
import type { PayloadKeys
|
|
2
|
-
|
|
1
|
+
import type { PayloadKeys } from '../../types/refiners/PayloadKeys.js';
|
|
2
|
+
import type { ValidatorFn } from '../../types/refiners/ValidatorFn.js';
|
|
3
|
+
import type { VariantConfig } from '../../types/refiners/VariantConfig.js';
|
|
4
|
+
/**
|
|
5
|
+
* Describes validator sets grouped by variant key.
|
|
6
|
+
*
|
|
7
|
+
* @typeParam TMap - The variant configuration map.
|
|
8
|
+
*
|
|
9
|
+
* @remarks
|
|
10
|
+
* This type maps each variant to its optional validators for payload fields.
|
|
11
|
+
* Validators are used to refine and check variant data at runtime.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { SyncValidatorMap, VariantConfig } from '@resultsafe/core-fp-result';
|
|
16
|
+
*
|
|
17
|
+
* type Validators = SyncValidatorMap<{
|
|
18
|
+
* user: { payload: 'name' | 'age' };
|
|
19
|
+
* error: { payload: 'code' };
|
|
20
|
+
* }>;
|
|
21
|
+
* // { user?: { name?: ValidatorFn; age?: ValidatorFn }; error?: { code?: ValidatorFn } }
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @since 0.1.8
|
|
25
|
+
* @public
|
|
26
|
+
*/
|
|
3
27
|
export type SyncValidatorMap<TMap extends Record<string, VariantConfig>> = {
|
|
4
28
|
[K in keyof TMap]?: Partial<Record<PayloadKeys<TMap[K]>, ValidatorFn>>;
|
|
5
29
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SyncValidatorMap.d.ts","sourceRoot":"","sources":["../../../../src/refiners/types/SyncValidatorMap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"SyncValidatorMap.d.ts","sourceRoot":"","sources":["../../../../src/refiners/types/SyncValidatorMap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AAE3E;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,MAAM,gBAAgB,CAAC,IAAI,SAAS,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,IAAI;KACxE,CAAC,IAAI,MAAM,IAAI,CAAC,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC;CACvE,CAAC"}
|
|
@@ -1,5 +1,31 @@
|
|
|
1
|
-
import type { VariantConfig } from '../../
|
|
2
|
-
/**
|
|
1
|
+
import type { VariantConfig } from '../../types/refiners/VariantConfig.js';
|
|
2
|
+
/**
|
|
3
|
+
* Describes a generalized asynchronously refined variant value.
|
|
4
|
+
*
|
|
5
|
+
* @typeParam K - The variant key type.
|
|
6
|
+
* @typeParam TMap - The variant configuration map.
|
|
7
|
+
* @typeParam _TValidators - The validator map for the variant.
|
|
8
|
+
*
|
|
9
|
+
* @remarks
|
|
10
|
+
* This type represents a variant refined through async validation.
|
|
11
|
+
* The `type` field discriminates the variant, and additional fields
|
|
12
|
+
* are validated asynchronously.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* import { UniversalAsyncRefinedResult, VariantConfig } from '@resultsafe/core-fp-result';
|
|
17
|
+
*
|
|
18
|
+
* type AsyncVariant = UniversalAsyncRefinedResult<
|
|
19
|
+
* 'user',
|
|
20
|
+
* { user: { payload: 'name' } },
|
|
21
|
+
* {}
|
|
22
|
+
* >;
|
|
23
|
+
* // { type: 'user'; [key: string]: unknown }
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @since 0.1.8
|
|
27
|
+
* @public
|
|
28
|
+
*/
|
|
3
29
|
export type UniversalAsyncRefinedResult<K extends keyof TMap & string, TMap extends Record<string, VariantConfig>, _TValidators extends Record<string, unknown>> = {
|
|
4
30
|
type: K;
|
|
5
31
|
} & Record<string, unknown>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UniversalAsyncRefinedResult.d.ts","sourceRoot":"","sources":["../../../../src/refiners/types/UniversalAsyncRefinedResult.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"UniversalAsyncRefinedResult.d.ts","sourceRoot":"","sources":["../../../../src/refiners/types/UniversalAsyncRefinedResult.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AAE3E;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,MAAM,2BAA2B,CACrC,CAAC,SAAS,MAAM,IAAI,GAAG,MAAM,EAC7B,IAAI,SAAS,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,EAC1C,YAAY,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAC1C;IACF,IAAI,EAAE,CAAC,CAAC;CACT,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC"}
|
|
@@ -1,5 +1,31 @@
|
|
|
1
|
-
import type { VariantConfig } from '../../
|
|
2
|
-
/**
|
|
1
|
+
import type { VariantConfig } from '../../types/refiners/VariantConfig.js';
|
|
2
|
+
/**
|
|
3
|
+
* Describes a generalized synchronously refined variant value.
|
|
4
|
+
*
|
|
5
|
+
* @typeParam K - The variant key type.
|
|
6
|
+
* @typeParam TMap - The variant configuration map.
|
|
7
|
+
* @typeParam _TValidators - The validator map for the variant.
|
|
8
|
+
*
|
|
9
|
+
* @remarks
|
|
10
|
+
* This type represents a variant refined through sync validation.
|
|
11
|
+
* The `type` field discriminates the variant, and additional fields
|
|
12
|
+
* are validated synchronously.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* import { UniversalRefinedResult, VariantConfig } from '@resultsafe/core-fp-result';
|
|
17
|
+
*
|
|
18
|
+
* type SyncVariant = UniversalRefinedResult<
|
|
19
|
+
* 'user',
|
|
20
|
+
* { user: { payload: 'name' } },
|
|
21
|
+
* {}
|
|
22
|
+
* >;
|
|
23
|
+
* // { type: 'user'; [key: string]: unknown }
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @since 0.1.8
|
|
27
|
+
* @public
|
|
28
|
+
*/
|
|
3
29
|
export type UniversalRefinedResult<K extends keyof TMap & string, TMap extends Record<string, VariantConfig>, _TValidators extends Record<string, unknown>> = {
|
|
4
30
|
type: K;
|
|
5
31
|
} & Record<string, unknown>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UniversalRefinedResult.d.ts","sourceRoot":"","sources":["../../../../src/refiners/types/UniversalRefinedResult.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"UniversalRefinedResult.d.ts","sourceRoot":"","sources":["../../../../src/refiners/types/UniversalRefinedResult.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AAE3E;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,MAAM,sBAAsB,CAChC,CAAC,SAAS,MAAM,IAAI,GAAG,MAAM,EAC7B,IAAI,SAAS,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,EAC1C,YAAY,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAC1C;IACF,IAAI,EAAE,CAAC,CAAC;CACT,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC"}
|