@craft-ng/core 0.0.2 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/craft-ng-core.mjs +4831 -2168
- package/fesm2022/craft-ng-core.mjs.map +1 -1
- package/package.json +1 -1
- package/types/craft-ng-core.d.ts +924 -101
package/types/craft-ng-core.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import * as _angular_core from '@angular/core';
|
|
2
|
-
import { Signal, WritableSignal, ValueEqualityFn, Injector, InjectionToken, Provider,
|
|
2
|
+
import { Signal, WritableSignal, ValueEqualityFn, Injector, InjectionToken, Provider, Type, EventEmitter, ResourceRef, ResourceOptions, ResourceStatus, ResourceLoaderParams, ResourceStreamingLoader } from '@angular/core';
|
|
3
|
+
import { CompatFieldState, FieldState, ReadonlyArrayLike, MaybeFieldTree, Subfields, FieldTree, SchemaPathTree, PathKind, SchemaPath, SchemaPathRules, ValidationError } from '@angular/forms/signals';
|
|
4
|
+
import { AbstractControl } from '@angular/forms';
|
|
3
5
|
|
|
4
6
|
type ReadonlySource<T> = Signal<T | undefined> & {
|
|
5
7
|
preserveLastValue: Signal<T | undefined>;
|
|
@@ -2293,7 +2295,7 @@ type MergeObjects<F extends unknown[], Acc = {}> = F extends [
|
|
|
2293
2295
|
infer First,
|
|
2294
2296
|
...infer Rest
|
|
2295
2297
|
] ? First extends object ? MergeObjects<Rest, MergeObject<Acc, First>> : Prettify<Acc> : Prettify<Acc>;
|
|
2296
|
-
type InternalType<State, Params, Args, IsGroupedResource, IsMethod, Insertions, GroupIdentifier, SourceParams> = {
|
|
2298
|
+
type InternalType<State, Params, Args, IsGroupedResource, IsMethod, Insertions, GroupIdentifier, SourceParams, Exceptions extends ResourceExceptionConstraints> = {
|
|
2297
2299
|
state: State;
|
|
2298
2300
|
params: Params;
|
|
2299
2301
|
args: Args;
|
|
@@ -2302,6 +2304,7 @@ type InternalType<State, Params, Args, IsGroupedResource, IsMethod, Insertions,
|
|
|
2302
2304
|
isMethod?: IsMethod;
|
|
2303
2305
|
insertions?: Insertions;
|
|
2304
2306
|
sourceParams?: SourceParams;
|
|
2307
|
+
exceptions: Exceptions;
|
|
2305
2308
|
};
|
|
2306
2309
|
/**
|
|
2307
2310
|
* trick to combine multiple unions of objects into a single object
|
|
@@ -2427,8 +2430,8 @@ type ResourceByIdConfig<State, ResourceParams, GroupIdentifier extends string, F
|
|
|
2427
2430
|
declare function resourceById<State, ResourceParams, GroupIdentifier extends string, FromObjectGroupIdentifier extends string, FromObjectState, FromObjectResourceParams>(config: ResourceByIdConfig<State, ResourceParams, GroupIdentifier, FromObjectGroupIdentifier, FromObjectState, FromObjectResourceParams>): ResourceByIdRef<GroupIdentifier, State, ResourceParams>;
|
|
2428
2431
|
|
|
2429
2432
|
type QueryAndMutationRecordConstraints = {
|
|
2430
|
-
query: InternalType<unknown, unknown, unknown, unknown, boolean, unknown, unknown, unknown>;
|
|
2431
|
-
mutation: InternalType<unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown>;
|
|
2433
|
+
query: InternalType<unknown, unknown, unknown, unknown, boolean, unknown, unknown, unknown, ResourceExceptionConstraints>;
|
|
2434
|
+
mutation: InternalType<unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, ResourceExceptionConstraints>;
|
|
2432
2435
|
};
|
|
2433
2436
|
type CustomReloadOnSpecificMutationStatus<QueryAndMutationRecord extends QueryAndMutationRecordConstraints> = (data: MergeObjects<[
|
|
2434
2437
|
{
|
|
@@ -2485,6 +2488,46 @@ type FilterQueryById<QueryAndMutationRecord extends QueryAndMutationRecordConstr
|
|
|
2485
2488
|
} : {}
|
|
2486
2489
|
]>) => boolean;
|
|
2487
2490
|
|
|
2491
|
+
declare const CRAFT_EXCEPTION_SYMBOL: unique symbol;
|
|
2492
|
+
type CraftExceptionMeta<Code extends string = string, Scope extends string | undefined = string | undefined, Identifier extends string | undefined = string | undefined> = {
|
|
2493
|
+
code: Code;
|
|
2494
|
+
scope?: Scope;
|
|
2495
|
+
identifier?: Identifier;
|
|
2496
|
+
};
|
|
2497
|
+
type CraftExceptionResult<Meta extends CraftExceptionMeta, Payload = unknown> = {
|
|
2498
|
+
readonly [CRAFT_EXCEPTION_SYMBOL]: true;
|
|
2499
|
+
readonly payload: Payload;
|
|
2500
|
+
} & Meta & {
|
|
2501
|
+
[key in Meta['code']]: Payload;
|
|
2502
|
+
};
|
|
2503
|
+
type CraftException<Meta extends CraftExceptionMeta = CraftExceptionMeta, Payload = unknown> = CraftExceptionResult<Meta, Payload>;
|
|
2504
|
+
type AnyCraftException = CraftExceptionResult<CraftExceptionMeta, unknown>;
|
|
2505
|
+
declare function craftException<const Code extends string, Scope extends string | undefined = undefined, Identifier extends string | undefined = undefined, Payload = undefined>(meta: {
|
|
2506
|
+
code: Code;
|
|
2507
|
+
scope?: Scope;
|
|
2508
|
+
identifier?: Identifier;
|
|
2509
|
+
}, payload?: Payload): CraftExceptionResult<{
|
|
2510
|
+
code: Code;
|
|
2511
|
+
scope: Scope;
|
|
2512
|
+
identifier?: Identifier;
|
|
2513
|
+
}, Payload>;
|
|
2514
|
+
declare function isCraftException(value: unknown): value is AnyCraftException;
|
|
2515
|
+
type StripCraftException<T> = Exclude<T, AnyCraftException>;
|
|
2516
|
+
type ExtractCraftException<T> = Extract<T, AnyCraftException>;
|
|
2517
|
+
type InsertMetaInCraftExceptionIfExists<Exception, Scope extends string | undefined, Identifier extends string | undefined | unknown> = Exception extends CraftExceptionResult<infer CraftExceptionMeta, infer Payload> ? [unknown] extends [Identifier] ? CraftExceptionResult<{
|
|
2518
|
+
code: CraftExceptionMeta['code'];
|
|
2519
|
+
scope: Scope;
|
|
2520
|
+
}, Payload> : [Identifier] extends [string] ? CraftExceptionResult<{
|
|
2521
|
+
code: CraftExceptionMeta['code'];
|
|
2522
|
+
scope: Scope;
|
|
2523
|
+
identifier: Identifier;
|
|
2524
|
+
}, Payload> : CraftExceptionResult<{
|
|
2525
|
+
code: CraftExceptionMeta['code'];
|
|
2526
|
+
scope: Scope;
|
|
2527
|
+
}, Payload> : Exception;
|
|
2528
|
+
type ExtractCodeFromCraftResultUnion<T> = T extends CraftExceptionResult<infer E, any> ? E['code'] : never;
|
|
2529
|
+
type ExcludeByCode<T, C> = T extends CraftExceptionResult<infer E, any> ? E['code'] extends C ? never : T : never;
|
|
2530
|
+
|
|
2488
2531
|
type MutationConfig<ResourceState, Params, ParamsArgs, SourceParams, GroupIdentifier, FromObjectGroupIdentifier extends string, FromObjectState, FromObjectResourceParams> = Omit<ResourceOptions<NoInfer<ResourceState>, Params>, 'params' | 'loader'> & ({
|
|
2489
2532
|
/**
|
|
2490
2533
|
* Used to generate a method in the store, when called will trigger the resource loader/stream.
|
|
@@ -2501,10 +2544,10 @@ type MutationConfig<ResourceState, Params, ParamsArgs, SourceParams, GroupIdenti
|
|
|
2501
2544
|
* A unique identifier for the resource, derived from the params.
|
|
2502
2545
|
* It should be a string that uniquely identifies the resource based on the params.
|
|
2503
2546
|
*/
|
|
2504
|
-
identifier?: (params: NoInfer<NonNullable<Params
|
|
2547
|
+
identifier?: (params: NoInfer<NonNullable<StripCraftException<Params>>>) => GroupIdentifier;
|
|
2505
2548
|
loader: (param: ResourceLoaderParams<NonNullable<[
|
|
2506
2549
|
unknown
|
|
2507
|
-
] extends [Params] ? NoInfer<SourceParams
|
|
2550
|
+
] extends [Params] ? NoInfer<StripCraftException<SourceParams>> : NoInfer<StripCraftException<Params>>>>) => Promise<ResourceState>;
|
|
2508
2551
|
stream?: never;
|
|
2509
2552
|
} | {
|
|
2510
2553
|
/**
|
|
@@ -2519,14 +2562,14 @@ type MutationConfig<ResourceState, Params, ParamsArgs, SourceParams, GroupIdenti
|
|
|
2519
2562
|
method: ((args: ParamsArgs) => Params) | ReadonlySource<SourceParams>;
|
|
2520
2563
|
loader?: never;
|
|
2521
2564
|
fromResourceById?: never;
|
|
2522
|
-
identifier?: (params: NoInfer<NonNullable<Params
|
|
2565
|
+
identifier?: (params: NoInfer<NonNullable<StripCraftException<Params>>>) => GroupIdentifier;
|
|
2523
2566
|
/**
|
|
2524
2567
|
* Loading function which returns a `Promise` of a signal of the resource's value for a given
|
|
2525
2568
|
* request, which can change over time as new values are received from a stream.
|
|
2526
2569
|
*/
|
|
2527
2570
|
stream: ResourceStreamingLoader<ResourceState, ResourceLoaderParams<NonNullable<[
|
|
2528
2571
|
unknown
|
|
2529
|
-
] extends [Params] ? NoInfer<SourceParams
|
|
2572
|
+
] extends [Params] ? NoInfer<StripCraftException<SourceParams>> : NoInfer<StripCraftException<Params>>>>>;
|
|
2530
2573
|
} | {
|
|
2531
2574
|
/**
|
|
2532
2575
|
* Use it, when you need to bind a ResourceByIdRef to another ResourceByIdRef.
|
|
@@ -2542,14 +2585,14 @@ type MutationConfig<ResourceState, Params, ParamsArgs, SourceParams, GroupIdenti
|
|
|
2542
2585
|
params: (entity: ResourceRef<NoInfer<FromObjectState>>) => Params;
|
|
2543
2586
|
loader?: never;
|
|
2544
2587
|
method?: never;
|
|
2545
|
-
identifier?: (params: NoInfer<NonNullable<Params
|
|
2588
|
+
identifier?: (params: NoInfer<NonNullable<StripCraftException<Params>>>) => GroupIdentifier;
|
|
2546
2589
|
/**
|
|
2547
2590
|
* Loading function which returns a `Promise` of a signal of the resource's value for a given
|
|
2548
2591
|
* request, which can change over time as new values are received from a stream.
|
|
2549
2592
|
*/
|
|
2550
2593
|
stream: ResourceStreamingLoader<ResourceState, ResourceLoaderParams<NonNullable<[
|
|
2551
2594
|
unknown
|
|
2552
|
-
] extends [Params] ? NoInfer<SourceParams
|
|
2595
|
+
] extends [Params] ? NoInfer<StripCraftException<SourceParams>> : NoInfer<StripCraftException<Params>>>>>;
|
|
2553
2596
|
} | {
|
|
2554
2597
|
/**
|
|
2555
2598
|
* Use it, when you need to bind a ResourceByIdRef to another ResourceByIdRef.
|
|
@@ -2567,10 +2610,10 @@ type MutationConfig<ResourceState, Params, ParamsArgs, SourceParams, GroupIdenti
|
|
|
2567
2610
|
* A unique identifier for the resource, derived from the params.
|
|
2568
2611
|
* It should be a string that uniquely identifies the resource based on the params.
|
|
2569
2612
|
*/
|
|
2570
|
-
identifier?: (params: NoInfer<NonNullable<Params
|
|
2613
|
+
identifier?: (params: NoInfer<NonNullable<StripCraftException<Params>>>) => GroupIdentifier;
|
|
2571
2614
|
loader: (param: ResourceLoaderParams<NonNullable<[
|
|
2572
2615
|
unknown
|
|
2573
|
-
] extends [Params] ? NoInfer<SourceParams
|
|
2616
|
+
] extends [Params] ? NoInfer<StripCraftException<SourceParams>> : NoInfer<StripCraftException<Params>>>>) => Promise<ResourceState>;
|
|
2574
2617
|
stream?: never;
|
|
2575
2618
|
} | {
|
|
2576
2619
|
fromResourceById?: never;
|
|
@@ -2583,14 +2626,14 @@ type MutationConfig<ResourceState, Params, ParamsArgs, SourceParams, GroupIdenti
|
|
|
2583
2626
|
params: (entity: ResourceRef<NoInfer<FromObjectState>>) => Params;
|
|
2584
2627
|
loader?: never;
|
|
2585
2628
|
method?: never;
|
|
2586
|
-
identifier?: (params: NoInfer<NonNullable<Params
|
|
2629
|
+
identifier?: (params: NoInfer<NonNullable<StripCraftException<Params>>>) => GroupIdentifier;
|
|
2587
2630
|
/**
|
|
2588
2631
|
* Loading function which returns a `Promise` of a signal of the resource's value for a given
|
|
2589
2632
|
* request, which can change over time as new values are received from a stream.
|
|
2590
2633
|
*/
|
|
2591
2634
|
stream: ResourceStreamingLoader<ResourceState, ResourceLoaderParams<NonNullable<[
|
|
2592
2635
|
unknown
|
|
2593
|
-
] extends [Params] ? NoInfer<SourceParams
|
|
2636
|
+
] extends [Params] ? NoInfer<StripCraftException<SourceParams>> : NoInfer<StripCraftException<Params>>>>>;
|
|
2594
2637
|
} | {
|
|
2595
2638
|
/**
|
|
2596
2639
|
* Use it, when you need to bind a ResourceByIdRef to another ResourceByIdRef.
|
|
@@ -2608,13 +2651,30 @@ type MutationConfig<ResourceState, Params, ParamsArgs, SourceParams, GroupIdenti
|
|
|
2608
2651
|
* A unique identifier for the resource, derived from the params.
|
|
2609
2652
|
* It should be a string that uniquely identifies the resource based on the params.
|
|
2610
2653
|
*/
|
|
2611
|
-
identifier?: (params: NoInfer<NonNullable<Params
|
|
2654
|
+
identifier?: (params: NoInfer<NonNullable<StripCraftException<Params>>>) => GroupIdentifier;
|
|
2612
2655
|
loader: (param: ResourceLoaderParams<NonNullable<[
|
|
2613
2656
|
unknown
|
|
2614
|
-
] extends [Params] ? NoInfer<SourceParams
|
|
2657
|
+
] extends [Params] ? NoInfer<StripCraftException<SourceParams>> : NoInfer<StripCraftException<Params>>>>) => Promise<ResourceState>;
|
|
2615
2658
|
stream?: never;
|
|
2616
2659
|
});
|
|
2617
|
-
type
|
|
2660
|
+
type HasDefinedException<MutationException extends ResourceExceptionConstraints> = [MutationException['params']] extends [never] ? [MutationException['loader']] extends [never] ? false : true : true;
|
|
2661
|
+
type ResourceLikeMutationExceptions<MutationException extends ResourceExceptionConstraints, GroupIdentifier = unknown> = HasDefinedException<MutationException> extends true ? {
|
|
2662
|
+
hasException: Signal<HasDefinedException<MutationException>>;
|
|
2663
|
+
exceptions: Signal<{
|
|
2664
|
+
list: (InsertMetaInCraftExceptionIfExists<MutationException['params'], 'params', unknown> | InsertMetaInCraftExceptionIfExists<MutationException['loader'], 'loader', GroupIdentifier>)[];
|
|
2665
|
+
params?: InsertMetaInCraftExceptionIfExists<MutationException['params'], 'params', unknown>;
|
|
2666
|
+
loader?: InsertMetaInCraftExceptionIfExists<MutationException['loader'], 'loader', GroupIdentifier>;
|
|
2667
|
+
}>;
|
|
2668
|
+
} : {};
|
|
2669
|
+
type ResourceByIdLikeMutationExceptions<MutationException extends ResourceExceptionConstraints, GroupIdentifier extends string> = {
|
|
2670
|
+
hasException: Signal<boolean>;
|
|
2671
|
+
exceptions: Signal<{
|
|
2672
|
+
list: (InsertMetaInCraftExceptionIfExists<MutationException['params'], 'params', unknown> | InsertMetaInCraftExceptionIfExists<MutationException['loader'], 'loader', GroupIdentifier>)[];
|
|
2673
|
+
params?: InsertMetaInCraftExceptionIfExists<MutationException['params'], 'params', unknown>;
|
|
2674
|
+
loader: Partial<Record<GroupIdentifier, InsertMetaInCraftExceptionIfExists<MutationException['loader'], 'loader', GroupIdentifier>>>;
|
|
2675
|
+
}>;
|
|
2676
|
+
};
|
|
2677
|
+
type ResourceLikeMutationRef<Value, Params, IsMethod, ArgParams, SourceParams, Insertions, MutationException extends ResourceExceptionConstraints> = {
|
|
2618
2678
|
type: 'resourceLike';
|
|
2619
2679
|
kind: 'mutation';
|
|
2620
2680
|
} & MergeObjects$1<[
|
|
@@ -2635,11 +2695,12 @@ type ResourceLikeMutationRef<Value, Params, IsMethod, ArgParams, SourceParams, I
|
|
|
2635
2695
|
source: ReadonlySource<SourceParams>;
|
|
2636
2696
|
},
|
|
2637
2697
|
Insertions,
|
|
2698
|
+
ResourceLikeMutationExceptions<MutationException>,
|
|
2638
2699
|
{
|
|
2639
2700
|
[key in `~InternalType`]: 'Used to avoid TS type erasure';
|
|
2640
2701
|
}
|
|
2641
2702
|
]>;
|
|
2642
|
-
type ResourceByIdLikeMutationRef<Value, Params, IsMethod, ArgParams, SourceParams, Insertions, GroupIdentifier> = {
|
|
2703
|
+
type ResourceByIdLikeMutationRef<Value, Params, IsMethod, ArgParams, SourceParams, Insertions, GroupIdentifier, MutationException extends ResourceExceptionConstraints> = {
|
|
2643
2704
|
type: 'resourceByGroupLike';
|
|
2644
2705
|
kind: 'mutation';
|
|
2645
2706
|
} & {
|
|
@@ -2653,14 +2714,14 @@ type ResourceByIdLikeMutationRef<Value, Params, IsMethod, ArgParams, SourceParam
|
|
|
2653
2714
|
*
|
|
2654
2715
|
* return the associated resource or undefined if not existing
|
|
2655
2716
|
*/
|
|
2656
|
-
select: (id: GroupIdentifier) => {
|
|
2717
|
+
select: (id: GroupIdentifier) => ({
|
|
2657
2718
|
readonly value: Signal<Value | undefined>;
|
|
2658
2719
|
readonly status: Signal<ResourceStatus>;
|
|
2659
2720
|
readonly error: Signal<Error | undefined>;
|
|
2660
2721
|
readonly isLoading: Signal<boolean>;
|
|
2661
2722
|
readonly safeValue: Signal<Value | undefined>;
|
|
2662
2723
|
hasValue(): boolean;
|
|
2663
|
-
} | undefined;
|
|
2724
|
+
} & ResourceLikeMutationExceptions<MutationException, GroupIdentifier>) | undefined;
|
|
2664
2725
|
} & MergeObjects$1<[
|
|
2665
2726
|
Insertions,
|
|
2666
2727
|
IsMethod extends true ? {
|
|
@@ -2668,21 +2729,48 @@ type ResourceByIdLikeMutationRef<Value, Params, IsMethod, ArgParams, SourceParam
|
|
|
2668
2729
|
} : {
|
|
2669
2730
|
source: ReadonlySource<SourceParams>;
|
|
2670
2731
|
},
|
|
2671
|
-
ResourceByIdRef<GroupIdentifier & string, Value, Params
|
|
2732
|
+
ResourceByIdRef<GroupIdentifier & string, Value, Params>,
|
|
2733
|
+
[
|
|
2734
|
+
GroupIdentifier
|
|
2735
|
+
] extends [string] ? ResourceByIdLikeMutationExceptions<MutationException, GroupIdentifier> : {}
|
|
2672
2736
|
]>;
|
|
2673
|
-
type MutationRef<Value, Params, ArgParams, Insertions, IsMethod, SourceParams, GroupIdentifier> = [unknown] extends [GroupIdentifier] ? ResourceLikeMutationRef<Value, Params, IsMethod, ArgParams, SourceParams, Insertions> : ResourceByIdLikeMutationRef<Value, Params, IsMethod, ArgParams, SourceParams, Insertions, GroupIdentifier>;
|
|
2674
|
-
type MutationOutput<State extends object | undefined, Params, ArgParams, SourceParams, GroupIdentifier, Insertions> = MutationRef<State
|
|
2737
|
+
type MutationRef<Value, Params, ArgParams, Insertions, IsMethod, SourceParams, GroupIdentifier, MutationExceptions extends ResourceExceptionConstraints = ResourceExceptionConstraints> = [unknown] extends [GroupIdentifier] ? ResourceLikeMutationRef<Value, Params, IsMethod, ArgParams, SourceParams, Insertions, MutationExceptions> : ResourceByIdLikeMutationRef<Value, Params, IsMethod, ArgParams, SourceParams, Insertions, GroupIdentifier, MutationExceptions>;
|
|
2738
|
+
type MutationOutput<State extends object | undefined, Params, ArgParams, SourceParams, GroupIdentifier, Insertions, MutationExceptions extends ResourceExceptionConstraints> = MutationRef<StripCraftException<State>, StripCraftException<Params>, ArgParams, Insertions, [
|
|
2675
2739
|
unknown
|
|
2676
2740
|
] extends [ArgParams] ? false : true, // ! force to method to have one arg minimum, we can not compare SourceParams type, because it also infer Params
|
|
2677
|
-
SourceParams, GroupIdentifier>;
|
|
2678
|
-
declare function mutation<MutationState extends object | undefined, MutationParams, MutationArgsParams, SourceParams, GroupIdentifier, FromObjectGroupIdentifier extends string, FromObjectState, FromObjectResourceParams
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
declare function mutation<MutationState extends object | undefined, MutationParams, MutationArgsParams, SourceParams, GroupIdentifier, FromObjectGroupIdentifier extends string, FromObjectState, FromObjectResourceParams, Insertion1,
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2741
|
+
SourceParams, GroupIdentifier, MutationExceptions>;
|
|
2742
|
+
declare function mutation<MutationState extends object | undefined, MutationParams, MutationArgsParams, SourceParams, GroupIdentifier, FromObjectGroupIdentifier extends string, FromObjectState, FromObjectResourceParams, Exceptions extends ResourceExceptionConstraints = {
|
|
2743
|
+
params: ExtractCraftException<MutationParams>;
|
|
2744
|
+
loader: ExtractCraftException<MutationState>;
|
|
2745
|
+
}>(mutationConfig: MutationConfig<MutationState, MutationParams, MutationArgsParams, SourceParams, GroupIdentifier, FromObjectGroupIdentifier, FromObjectState, FromObjectResourceParams>): MutationOutput<StripCraftException<MutationState>, StripCraftException<MutationParams>, MutationArgsParams, StripCraftException<MutationParams>, GroupIdentifier, {}, Exceptions>;
|
|
2746
|
+
declare function mutation<MutationState extends object | undefined, MutationParams, MutationArgsParams, SourceParams, GroupIdentifier, FromObjectGroupIdentifier extends string, FromObjectState, FromObjectResourceParams, Insertion1, Exceptions extends ResourceExceptionConstraints = {
|
|
2747
|
+
params: ExtractCraftException<MutationParams>;
|
|
2748
|
+
loader: ExtractCraftException<MutationState>;
|
|
2749
|
+
}>(mutationConfig: MutationConfig<MutationState, MutationParams, MutationArgsParams, SourceParams, GroupIdentifier, FromObjectGroupIdentifier, FromObjectState, FromObjectResourceParams>, insertion1: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<MutationState>>, NoInfer<StripCraftException<MutationParams>>, Exceptions, Insertion1, {}>): MutationOutput<StripCraftException<MutationState>, StripCraftException<MutationParams>, MutationArgsParams, StripCraftException<MutationParams>, GroupIdentifier, Insertion1, Exceptions>;
|
|
2750
|
+
declare function mutation<MutationState extends object | undefined, MutationParams, MutationArgsParams, SourceParams, GroupIdentifier, FromObjectGroupIdentifier extends string, FromObjectState, FromObjectResourceParams, Insertion1, Insertion2, Exceptions extends ResourceExceptionConstraints = {
|
|
2751
|
+
params: ExtractCraftException<MutationParams>;
|
|
2752
|
+
loader: ExtractCraftException<MutationState>;
|
|
2753
|
+
}>(mutationConfig: MutationConfig<MutationState, MutationParams, MutationArgsParams, SourceParams, GroupIdentifier, FromObjectGroupIdentifier, FromObjectState, FromObjectResourceParams>, insertion1: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<MutationState>>, NoInfer<StripCraftException<MutationParams>>, Exceptions, Insertion1>, insertion2: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<MutationState>>, NoInfer<StripCraftException<MutationParams>>, Exceptions, Insertion2, Insertion1>): MutationOutput<StripCraftException<MutationState>, StripCraftException<MutationParams>, MutationArgsParams, StripCraftException<MutationParams>, GroupIdentifier, Insertion1 & Insertion2, Exceptions>;
|
|
2754
|
+
declare function mutation<MutationState extends object | undefined, MutationParams, MutationArgsParams, SourceParams, GroupIdentifier, FromObjectGroupIdentifier extends string, FromObjectState, FromObjectResourceParams, Insertion1, Insertion2, Insertion3, Exceptions extends ResourceExceptionConstraints = {
|
|
2755
|
+
params: ExtractCraftException<MutationParams>;
|
|
2756
|
+
loader: ExtractCraftException<MutationState>;
|
|
2757
|
+
}>(mutationConfig: MutationConfig<MutationState, MutationParams, MutationArgsParams, SourceParams, GroupIdentifier, FromObjectGroupIdentifier, FromObjectState, FromObjectResourceParams>, insertion1: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<MutationState>>, NoInfer<StripCraftException<MutationParams>>, Exceptions, Insertion1>, insertion2: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<MutationState>>, NoInfer<StripCraftException<MutationParams>>, Exceptions, Insertion2, Insertion1>, insertion3: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<MutationState>>, NoInfer<StripCraftException<MutationParams>>, Exceptions, Insertion3, Insertion1 & Insertion2>): MutationOutput<StripCraftException<MutationState>, StripCraftException<MutationParams>, MutationArgsParams, StripCraftException<MutationParams>, GroupIdentifier, Insertion1 & Insertion2 & Insertion3, Exceptions>;
|
|
2758
|
+
declare function mutation<MutationState extends object | undefined, MutationParams, MutationArgsParams, SourceParams, GroupIdentifier, FromObjectGroupIdentifier extends string, FromObjectState, FromObjectResourceParams, Insertion1, Insertion2, Insertion3, Insertion4, Exceptions extends ResourceExceptionConstraints = {
|
|
2759
|
+
params: ExtractCraftException<MutationParams>;
|
|
2760
|
+
loader: ExtractCraftException<MutationState>;
|
|
2761
|
+
}>(mutationConfig: MutationConfig<MutationState, MutationParams, MutationArgsParams, SourceParams, GroupIdentifier, FromObjectGroupIdentifier, FromObjectState, FromObjectResourceParams>, insertion1: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<MutationState>>, NoInfer<StripCraftException<MutationParams>>, Exceptions, Insertion1>, insertion2: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<MutationState>>, NoInfer<StripCraftException<MutationParams>>, Exceptions, Insertion2, Insertion1>, insertion3: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<MutationState>>, NoInfer<StripCraftException<MutationParams>>, Exceptions, Insertion3, Insertion1 & Insertion2>, insertion4: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<MutationState>>, NoInfer<StripCraftException<MutationParams>>, Exceptions, Insertion4, Insertion1 & Insertion2 & Insertion3>): MutationOutput<StripCraftException<MutationState>, StripCraftException<MutationParams>, MutationArgsParams, StripCraftException<MutationParams>, GroupIdentifier, Insertion1 & Insertion2 & Insertion3 & Insertion4, Exceptions>;
|
|
2762
|
+
declare function mutation<MutationState extends object | undefined, MutationParams, MutationArgsParams, SourceParams, GroupIdentifier, FromObjectGroupIdentifier extends string, FromObjectState, FromObjectResourceParams, Insertion1, Insertion2, Insertion3, Insertion4, Insertion5, Exceptions extends ResourceExceptionConstraints = {
|
|
2763
|
+
params: ExtractCraftException<MutationParams>;
|
|
2764
|
+
loader: ExtractCraftException<MutationState>;
|
|
2765
|
+
}>(mutationConfig: MutationConfig<MutationState, MutationParams, MutationArgsParams, SourceParams, GroupIdentifier, FromObjectGroupIdentifier, FromObjectState, FromObjectResourceParams>, insertion1: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<MutationState>>, NoInfer<StripCraftException<MutationParams>>, Exceptions, Insertion1>, insertion2: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<MutationState>>, NoInfer<StripCraftException<MutationParams>>, Exceptions, Insertion2, Insertion1>, insertion3: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<MutationState>>, NoInfer<StripCraftException<MutationParams>>, Exceptions, Insertion3, Insertion1 & Insertion2>, insertion4: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<MutationState>>, NoInfer<StripCraftException<MutationParams>>, Exceptions, Insertion4, Insertion1 & Insertion2 & Insertion3>, insertion5: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<MutationState>>, NoInfer<StripCraftException<MutationParams>>, Exceptions, Insertion5, Insertion1 & Insertion2 & Insertion3 & Insertion4>): MutationOutput<StripCraftException<MutationState>, StripCraftException<MutationParams>, MutationArgsParams, StripCraftException<MutationParams>, GroupIdentifier, Insertion1 & Insertion2 & Insertion3 & Insertion4 & Insertion5, Exceptions>;
|
|
2766
|
+
declare function mutation<MutationState extends object | undefined, MutationParams, MutationArgsParams, SourceParams, GroupIdentifier, FromObjectGroupIdentifier extends string, FromObjectState, FromObjectResourceParams, Insertion1, Insertion2, Insertion3, Insertion4, Insertion5, Insertion6, Exceptions extends ResourceExceptionConstraints = {
|
|
2767
|
+
params: ExtractCraftException<MutationParams>;
|
|
2768
|
+
loader: ExtractCraftException<MutationState>;
|
|
2769
|
+
}>(mutationConfig: MutationConfig<MutationState, MutationParams, MutationArgsParams, SourceParams, GroupIdentifier, FromObjectGroupIdentifier, FromObjectState, FromObjectResourceParams>, insertion1: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<MutationState>>, NoInfer<StripCraftException<MutationParams>>, Exceptions, Insertion1>, insertion2: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<MutationState>>, NoInfer<StripCraftException<MutationParams>>, Exceptions, Insertion2, Insertion1>, insertion3: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<MutationState>>, NoInfer<StripCraftException<MutationParams>>, Exceptions, Insertion3, Insertion1 & Insertion2>, insertion4: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<MutationState>>, NoInfer<StripCraftException<MutationParams>>, Exceptions, Insertion4, Insertion1 & Insertion2 & Insertion3>, insertion5: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<MutationState>>, NoInfer<StripCraftException<MutationParams>>, Exceptions, Insertion5, Insertion1 & Insertion2 & Insertion3 & Insertion4>, insertion6: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<MutationState>>, NoInfer<StripCraftException<MutationParams>>, Exceptions, Insertion6, Insertion1 & Insertion2 & Insertion3 & Insertion4 & Insertion5>): MutationOutput<StripCraftException<MutationState>, StripCraftException<MutationParams>, MutationArgsParams, StripCraftException<MutationParams>, GroupIdentifier, Insertion1 & Insertion2 & Insertion3 & Insertion4 & Insertion5 & Insertion6, Exceptions>;
|
|
2770
|
+
declare function mutation<MutationState extends object | undefined, MutationParams, MutationArgsParams, SourceParams, GroupIdentifier, FromObjectGroupIdentifier extends string, FromObjectState, FromObjectResourceParams, Insertion1, Insertion2, Insertion3, Insertion4, Insertion5, Insertion6, Insertion7, Exceptions extends ResourceExceptionConstraints = {
|
|
2771
|
+
params: ExtractCraftException<MutationParams>;
|
|
2772
|
+
loader: ExtractCraftException<MutationState>;
|
|
2773
|
+
}>(mutationConfig: MutationConfig<MutationState, MutationParams, MutationArgsParams, SourceParams, GroupIdentifier, FromObjectGroupIdentifier, FromObjectState, FromObjectResourceParams>, insertion1: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<MutationState>>, NoInfer<StripCraftException<MutationParams>>, Exceptions, Insertion1>, insertion2: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<MutationState>>, NoInfer<StripCraftException<MutationParams>>, Exceptions, Insertion2, Insertion1>, insertion3: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<MutationState>>, NoInfer<StripCraftException<MutationParams>>, Exceptions, Insertion3, Insertion1 & Insertion2>, insertion4: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<MutationState>>, NoInfer<StripCraftException<MutationParams>>, Exceptions, Insertion4, Insertion1 & Insertion2 & Insertion3>, insertion5: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<MutationState>>, NoInfer<StripCraftException<MutationParams>>, Exceptions, Insertion5, Insertion1 & Insertion2 & Insertion3 & Insertion4>, insertion6: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<MutationState>>, NoInfer<StripCraftException<MutationParams>>, Exceptions, Insertion6, Insertion1 & Insertion2 & Insertion3 & Insertion4 & Insertion5>, insertion7: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<MutationState>>, NoInfer<StripCraftException<MutationParams>>, Exceptions, Insertion7, Insertion1 & Insertion2 & Insertion3 & Insertion4 & Insertion5 & Insertion6>): MutationOutput<StripCraftException<MutationState>, StripCraftException<MutationParams>, MutationArgsParams, StripCraftException<MutationParams>, GroupIdentifier, Insertion1 & Insertion2 & Insertion3 & Insertion4 & Insertion5 & Insertion6 & Insertion7, Exceptions>;
|
|
2686
2774
|
|
|
2687
2775
|
interface QueryParamNavigationOptions$1 {
|
|
2688
2776
|
queryParamsHandling?: 'merge' | 'preserve' | '';
|
|
@@ -2691,20 +2779,32 @@ interface QueryParamNavigationOptions$1 {
|
|
|
2691
2779
|
skipLocationChange?: boolean;
|
|
2692
2780
|
}
|
|
2693
2781
|
type QueryParamsToState<QueryParamConfigs> = {
|
|
2694
|
-
[K in keyof QueryParamConfigs]: 'parse' extends keyof QueryParamConfigs[K] ? QueryParamConfigs[K]['parse'] extends (value: string) => infer U ? U : 'Error1: QueryParamsToState' : 'Error2: QueryParamsToState';
|
|
2782
|
+
[K in keyof QueryParamConfigs]: 'parse' extends keyof QueryParamConfigs[K] ? QueryParamConfigs[K]['parse'] extends (value: string) => infer U ? StripCraftException<U> : 'Error1: QueryParamsToState' : 'Error2: QueryParamsToState';
|
|
2783
|
+
};
|
|
2784
|
+
type QueryParamParseExceptionsByKey<QueryParamsType> = QueryParamsType extends Record<string, QueryParamConfig<unknown>> ? {
|
|
2785
|
+
[K in keyof QueryParamsType]: InsertMetaInCraftExceptionIfExists<ExtractCraftException<ReturnType<QueryParamsType[K]['parse']>>, 'parse', K & string>;
|
|
2786
|
+
} : Record<string, never>;
|
|
2787
|
+
type QueryParamParseExceptionUnion<QueryParamsType> = QueryParamParseExceptionsByKey<QueryParamsType>[keyof QueryParamParseExceptionsByKey<QueryParamsType>];
|
|
2788
|
+
type QueryParamExceptions<QueryParamsType> = {
|
|
2789
|
+
list: QueryParamParseExceptionUnion<QueryParamsType>[];
|
|
2790
|
+
parse: Partial<QueryParamParseExceptionsByKey<QueryParamsType>>;
|
|
2695
2791
|
};
|
|
2696
2792
|
type QueryParamOutput<QueryParamsType, Insertions, QueryParamsState> = Signal<QueryParamsState> & MergeObjects<[
|
|
2697
2793
|
{
|
|
2698
2794
|
[K in keyof QueryParamsState]: Signal<QueryParamsState[K]>;
|
|
2699
2795
|
},
|
|
2700
2796
|
IsEmptyObject<Insertions> extends true ? {} : FilterSource<Insertions>,
|
|
2797
|
+
{
|
|
2798
|
+
hasException: Signal<boolean>;
|
|
2799
|
+
exceptions: Signal<QueryParamExceptions<QueryParamsType>>;
|
|
2800
|
+
},
|
|
2701
2801
|
{
|
|
2702
2802
|
_config: QueryParamsType;
|
|
2703
2803
|
}
|
|
2704
2804
|
]>;
|
|
2705
2805
|
interface QueryParamConfig<T = unknown> {
|
|
2706
|
-
fallbackValue: NoInfer<T>;
|
|
2707
2806
|
parse: (value: string) => T;
|
|
2807
|
+
fallbackValue: NoInfer<T>;
|
|
2708
2808
|
serialize: (value: NoInfer<T>) => string;
|
|
2709
2809
|
}
|
|
2710
2810
|
/**
|
|
@@ -2784,6 +2884,32 @@ interface QueryParamConfig<T = unknown> {
|
|
|
2784
2884
|
*
|
|
2785
2885
|
* myQueryParams.goTo(5); // Custom method from insertion
|
|
2786
2886
|
* ```
|
|
2887
|
+
*
|
|
2888
|
+
* @example
|
|
2889
|
+
* Parse exceptions with `craftException`
|
|
2890
|
+
* ```ts
|
|
2891
|
+
* import { craftException, queryParam } from '@craft-ng/core';
|
|
2892
|
+
*
|
|
2893
|
+
* const mode = queryParam({
|
|
2894
|
+
* state: {
|
|
2895
|
+
* mode: {
|
|
2896
|
+
* fallbackValue: 'success' as const,
|
|
2897
|
+
* parse: (value: string) =>
|
|
2898
|
+
* value === 'success'
|
|
2899
|
+
* ? ('success' as const)
|
|
2900
|
+
* : craftException(
|
|
2901
|
+
* { code: 'INVALID_MODE_FROM_URL' },
|
|
2902
|
+
* { received: value },
|
|
2903
|
+
* ),
|
|
2904
|
+
* serialize: (value) => String(value),
|
|
2905
|
+
* },
|
|
2906
|
+
* },
|
|
2907
|
+
* });
|
|
2908
|
+
*
|
|
2909
|
+
* console.log(mode.mode()); // fallbackValue when parse exception occurs
|
|
2910
|
+
* console.log(mode.hasException()); // true/false
|
|
2911
|
+
* console.log(mode.exceptions().parse.mode?.INVALID_MODE_FROM_URL);
|
|
2912
|
+
* ```
|
|
2787
2913
|
*/
|
|
2788
2914
|
declare function queryParam<QueryParamsType extends Record<string, QueryParamConfig<unknown>>, QueryParamsState = Prettify<QueryParamsToState<QueryParamsType>>>(config: {
|
|
2789
2915
|
state: QueryParamsType;
|
|
@@ -2804,7 +2930,7 @@ interface QueryParamNavigationOptions {
|
|
|
2804
2930
|
replaceUrl?: boolean;
|
|
2805
2931
|
skipLocationChange?: boolean;
|
|
2806
2932
|
}
|
|
2807
|
-
type MutationResourceByIdRefHelper<QueryAndMutationRecord extends QueryAndMutationRecordConstraints> = ResourceByIdLikeMutationRef<QueryAndMutationRecord['mutation']['state'], QueryAndMutationRecord['mutation']['params'], QueryAndMutationRecord['mutation']['isMethod'], QueryAndMutationRecord['mutation']['args'], QueryAndMutationRecord['mutation']['sourceParams'], QueryAndMutationRecord['mutation']['insertions'], QueryAndMutationRecord['mutation']['groupIdentifier']>;
|
|
2933
|
+
type MutationResourceByIdRefHelper<QueryAndMutationRecord extends QueryAndMutationRecordConstraints> = ResourceByIdLikeMutationRef<QueryAndMutationRecord['mutation']['state'], QueryAndMutationRecord['mutation']['params'], QueryAndMutationRecord['mutation']['isMethod'], QueryAndMutationRecord['mutation']['args'], QueryAndMutationRecord['mutation']['sourceParams'], QueryAndMutationRecord['mutation']['insertions'], QueryAndMutationRecord['mutation']['groupIdentifier'], QueryAndMutationRecord['mutation']['exceptions']>;
|
|
2808
2934
|
type UpdateData<QueryAndMutationRecord extends QueryAndMutationRecordConstraints> = MergeObjects<[
|
|
2809
2935
|
{
|
|
2810
2936
|
queryResource: CraftResourceRef<QueryAndMutationRecord['query']['state'], QueryAndMutationRecord['query']['params']>;
|
|
@@ -2825,9 +2951,7 @@ type QueryDeclarativeEffect<QueryAndMutationRecord extends QueryAndMutationRecor
|
|
|
2825
2951
|
/**
|
|
2826
2952
|
* Run when the mutation is in loading state.
|
|
2827
2953
|
*/
|
|
2828
|
-
optimisticUpdate?: (data: UpdateData<QueryAndMutationRecord>
|
|
2829
|
-
testData: QueryAndMutationRecord['query']['groupIdentifier'];
|
|
2830
|
-
}) => QueryAndMutationRecord['query']['state'];
|
|
2954
|
+
optimisticUpdate?: (data: UpdateData<QueryAndMutationRecord>) => QueryAndMutationRecord['query']['state'];
|
|
2831
2955
|
/**
|
|
2832
2956
|
* Run when the mutation is in loaded state.
|
|
2833
2957
|
*/
|
|
@@ -2856,34 +2980,57 @@ type QueryDeclarativeEffect<QueryAndMutationRecord extends QueryAndMutationRecor
|
|
|
2856
2980
|
filter: FilterQueryById<QueryAndMutationRecord>;
|
|
2857
2981
|
} : {}
|
|
2858
2982
|
]>;
|
|
2859
|
-
type
|
|
2983
|
+
type ResourceExceptionConstraints = {
|
|
2984
|
+
params: unknown;
|
|
2985
|
+
loader: unknown;
|
|
2986
|
+
};
|
|
2987
|
+
type InsertionParams<ResourceState extends object | undefined, ResourceParams, Exceptions extends ResourceExceptionConstraints, PreviousInsertionsOutputs> = {
|
|
2988
|
+
test: ResourceState;
|
|
2860
2989
|
state: Signal<ResourceState>;
|
|
2861
2990
|
set: (newState: ResourceState) => ResourceState;
|
|
2862
2991
|
update: (updateFn: (currentState: ResourceState) => ResourceState) => ResourceState;
|
|
2992
|
+
patch: (patchFn: (currentState: ResourceState) => Partial<ResourceState>) => ResourceState;
|
|
2863
2993
|
insertions: keyof PreviousInsertionsOutputs extends string ? PreviousInsertionsOutputs : never;
|
|
2864
2994
|
resource: CraftResourceRef<ResourceState, ResourceParams>;
|
|
2865
2995
|
resourceParamsSrc: WritableSignal<ResourceParams | undefined>;
|
|
2996
|
+
hasException: Signal<boolean>;
|
|
2997
|
+
exceptions: Signal<{
|
|
2998
|
+
list: (InsertMetaInCraftExceptionIfExists<Exceptions['params'], 'params', unknown> | InsertMetaInCraftExceptionIfExists<Exceptions['loader'], 'loader', unknown>)[];
|
|
2999
|
+
params?: InsertMetaInCraftExceptionIfExists<Exceptions['params'], 'params', unknown>;
|
|
3000
|
+
loader?: InsertMetaInCraftExceptionIfExists<Exceptions['loader'], 'loader', unknown>;
|
|
3001
|
+
}>;
|
|
2866
3002
|
resourceById: never;
|
|
2867
3003
|
identifier: never;
|
|
2868
3004
|
};
|
|
2869
|
-
type InsertionByIdParams<GroupIdentifier extends string, ResourceState extends object | undefined, ResourceParams, PreviousInsertionsOutputs> = {
|
|
3005
|
+
type InsertionByIdParams<GroupIdentifier extends string, ResourceState extends object | undefined, ResourceParams, Exceptions extends ResourceExceptionConstraints, PreviousInsertionsOutputs> = {
|
|
2870
3006
|
state: Signal<ResourceState>;
|
|
2871
3007
|
set: (newState: ResourceState) => ResourceState;
|
|
2872
3008
|
update: (updateFn: (currentState: ResourceState) => ResourceState) => ResourceState;
|
|
3009
|
+
patch: (patchFn: (currentState: ResourceState) => Partial<ResourceState>) => ResourceState;
|
|
2873
3010
|
insertions: keyof PreviousInsertionsOutputs extends string ? PreviousInsertionsOutputs : never;
|
|
2874
3011
|
resourceById: ResourceByIdRef<GroupIdentifier, ResourceState, ResourceParams>;
|
|
2875
3012
|
resource: never;
|
|
2876
3013
|
resourceParamsSrc: WritableSignal<ResourceParams | undefined>;
|
|
3014
|
+
hasException: Signal<boolean>;
|
|
3015
|
+
exceptions: Signal<{
|
|
3016
|
+
list: (InsertMetaInCraftExceptionIfExists<Exceptions['params'], 'params', unknown> | InsertMetaInCraftExceptionIfExists<Exceptions['loader'], 'loader', GroupIdentifier>)[];
|
|
3017
|
+
params?: InsertMetaInCraftExceptionIfExists<Exceptions['params'], 'params', unknown>;
|
|
3018
|
+
loader: Partial<Record<GroupIdentifier, InsertMetaInCraftExceptionIfExists<Exceptions['loader'], 'loader', GroupIdentifier>>>;
|
|
3019
|
+
}>;
|
|
2877
3020
|
identifier: (params: NonNullable<ResourceParams>) => GroupIdentifier;
|
|
2878
3021
|
};
|
|
2879
3022
|
type InsertionStateFactoryContext<StateType, PreviousInsertionsOutputs> = {
|
|
2880
3023
|
state: Signal<StateType>;
|
|
2881
3024
|
set: (newState: StateType) => StateType;
|
|
2882
3025
|
update: (updateFn: (currentState: StateType) => StateType) => StateType;
|
|
3026
|
+
patch: (patchFn: (currentState: StateType) => Partial<StateType>) => StateType;
|
|
2883
3027
|
insertions: keyof PreviousInsertionsOutputs extends string ? PreviousInsertionsOutputs : never;
|
|
2884
3028
|
};
|
|
2885
3029
|
type QueryParamMethods<QueryParamsState> = {
|
|
2886
|
-
patch:
|
|
3030
|
+
patch: {
|
|
3031
|
+
(patchFn: (currentParams: QueryParamsState) => Partial<QueryParamsState>, options?: QueryParamNavigationOptions): QueryParamsState;
|
|
3032
|
+
(params: Partial<QueryParamsState>, options?: QueryParamNavigationOptions): QueryParamsState;
|
|
3033
|
+
};
|
|
2887
3034
|
reset: (options?: QueryParamNavigationOptions) => void;
|
|
2888
3035
|
set: (params: QueryParamsState, options?: QueryParamNavigationOptions) => QueryParamsState;
|
|
2889
3036
|
update: (updateFn: (currentParams: QueryParamsState) => QueryParamsState, options?: QueryParamNavigationOptions) => QueryParamsState;
|
|
@@ -2891,14 +3038,16 @@ type QueryParamMethods<QueryParamsState> = {
|
|
|
2891
3038
|
type InsertionQueryParamsFactoryContext<QueryParamsType, PreviousInsertionsOutputs, QueryParamsState = Prettify<QueryParamsToState<QueryParamsType>>> = QueryParamMethods<QueryParamsState> & {
|
|
2892
3039
|
state: Signal<QueryParamsState>;
|
|
2893
3040
|
config: QueryParamsType;
|
|
3041
|
+
hasException: Signal<boolean>;
|
|
3042
|
+
exceptions: Signal<QueryParamExceptions<QueryParamsType>>;
|
|
2894
3043
|
insertions: keyof PreviousInsertionsOutputs extends string ? PreviousInsertionsOutputs : never;
|
|
2895
3044
|
};
|
|
2896
|
-
type InsertionResourceFactoryContext<GroupIdentifier, ResourceState extends object | undefined, ResourceParams, PreviousInsertionsOutputs> = [unknown] extends [GroupIdentifier] ? InsertionParams<ResourceState, ResourceParams, PreviousInsertionsOutputs> : InsertionByIdParams<GroupIdentifier & string, ResourceState, ResourceParams, PreviousInsertionsOutputs>;
|
|
2897
|
-
type InsertionsResourcesFactory<GroupIdentifier, ResourceState extends object | undefined, ResourceParams, InsertionsOutputs, PreviousInsertionsOutputs = {}> = (context: InsertionResourceFactoryContext<GroupIdentifier, ResourceState, ResourceParams, PreviousInsertionsOutputs>) => InsertionsOutputs;
|
|
3045
|
+
type InsertionResourceFactoryContext<GroupIdentifier, ResourceState extends object | undefined, ResourceParams, Exceptions extends ResourceExceptionConstraints, PreviousInsertionsOutputs> = [unknown] extends [GroupIdentifier] ? InsertionParams<ResourceState, ResourceParams, Exceptions, PreviousInsertionsOutputs> : InsertionByIdParams<GroupIdentifier & string, ResourceState, ResourceParams, Exceptions, PreviousInsertionsOutputs>;
|
|
3046
|
+
type InsertionsResourcesFactory<GroupIdentifier, ResourceState extends object | undefined, ResourceParams, Exceptions extends ResourceExceptionConstraints, InsertionsOutputs, PreviousInsertionsOutputs = {}> = (context: InsertionResourceFactoryContext<GroupIdentifier, ResourceState, ResourceParams, Exceptions, PreviousInsertionsOutputs>) => InsertionsOutputs;
|
|
2898
3047
|
type InsertionsStateFactory<State, InsertionsOutputs, PreviousInsertionsOutputs = {}> = (context: InsertionStateFactoryContext<State, PreviousInsertionsOutputs>) => InsertionsOutputs;
|
|
2899
3048
|
type InsertionsQueryParamsFactory<QueryParamsType, InsertionsOutputs, PreviousInsertionsOutputs = {}> = (context: InsertionQueryParamsFactoryContext<QueryParamsType, PreviousInsertionsOutputs>) => InsertionsOutputs;
|
|
2900
3049
|
|
|
2901
|
-
type AsyncProcessRef<Value, ArgParams, Params, Insertions, IsMethod, SourceParams, GroupIdentifier> = MergeObjects$1<[
|
|
3050
|
+
type AsyncProcessRef<Value, ArgParams, Params, Insertions, IsMethod, SourceParams, GroupIdentifier, AsyncProcessExceptions extends AsyncProcessExceptionConstraints = AsyncProcessExceptionConstraints> = MergeObjects$1<[
|
|
2902
3051
|
[
|
|
2903
3052
|
unknown
|
|
2904
3053
|
] extends [GroupIdentifier] ? {
|
|
@@ -2908,7 +3057,7 @@ type AsyncProcessRef<Value, ArgParams, Params, Insertions, IsMethod, SourceParam
|
|
|
2908
3057
|
readonly isLoading: Signal<boolean>;
|
|
2909
3058
|
readonly safeValue: Signal<Value | undefined>;
|
|
2910
3059
|
hasValue(): boolean;
|
|
2911
|
-
} : {},
|
|
3060
|
+
} & ResourceLikeAsyncProcessExceptions<AsyncProcessExceptions> : {},
|
|
2912
3061
|
Insertions,
|
|
2913
3062
|
IsMethod extends true ? {
|
|
2914
3063
|
method: (args: ArgParams) => Params;
|
|
@@ -2926,15 +3075,15 @@ type AsyncProcessRef<Value, ArgParams, Params, Insertions, IsMethod, SourceParam
|
|
|
2926
3075
|
*
|
|
2927
3076
|
* return the associated resource or undefined if not existing
|
|
2928
3077
|
*/
|
|
2929
|
-
select: (id: GroupIdentifier) => {
|
|
3078
|
+
select: (id: GroupIdentifier) => ({
|
|
2930
3079
|
readonly value: Signal<Value | undefined>;
|
|
2931
3080
|
readonly status: Signal<ResourceStatus>;
|
|
2932
3081
|
readonly error: Signal<Error | undefined>;
|
|
2933
3082
|
readonly isLoading: Signal<boolean>;
|
|
2934
3083
|
readonly safeValue: Signal<Value | undefined>;
|
|
2935
3084
|
hasValue(): boolean;
|
|
2936
|
-
} | undefined;
|
|
2937
|
-
}
|
|
3085
|
+
} & ResourceLikeAsyncProcessExceptions<AsyncProcessExceptions, GroupIdentifier>) | undefined;
|
|
3086
|
+
} & ([GroupIdentifier] extends [string] ? ResourceByIdLikeAsyncProcessExceptions<AsyncProcessExceptions, GroupIdentifier> : {})
|
|
2938
3087
|
]>;
|
|
2939
3088
|
type AsyncProcessConfig<ResourceState, Params, ParamsArgs, SourceParams, GroupIdentifier> = Omit<ResourceOptions<NoInfer<ResourceState>, Params>, 'params' | 'loader'> & ({
|
|
2940
3089
|
/**
|
|
@@ -2947,29 +3096,49 @@ type AsyncProcessConfig<ResourceState, Params, ParamsArgs, SourceParams, GroupId
|
|
|
2947
3096
|
* A unique identifier for the resource, derived from the params.
|
|
2948
3097
|
* It should be a string that uniquely identifies the resource based on the params.
|
|
2949
3098
|
*/
|
|
2950
|
-
identifier?: (params: NoInfer<NonNullable<Params
|
|
3099
|
+
identifier?: (params: NoInfer<NonNullable<StripCraftException<Params>>>) => GroupIdentifier;
|
|
2951
3100
|
loader: (param: ResourceLoaderParams<NonNullable<[
|
|
2952
3101
|
unknown
|
|
2953
|
-
] extends [Params] ? NoInfer<SourceParams
|
|
3102
|
+
] extends [Params] ? NoInfer<StripCraftException<SourceParams>> : NoInfer<StripCraftException<Params>>>>) => Promise<ResourceState>;
|
|
2954
3103
|
stream?: never;
|
|
2955
3104
|
preservePreviousValue?: () => boolean;
|
|
2956
3105
|
} | {
|
|
2957
3106
|
method: ((args: ParamsArgs) => Params) | ReadonlySource<SourceParams>;
|
|
2958
3107
|
loader?: never;
|
|
2959
|
-
identifier?: (params: NoInfer<NonNullable<Params
|
|
3108
|
+
identifier?: (params: NoInfer<NonNullable<StripCraftException<Params>>>) => GroupIdentifier;
|
|
2960
3109
|
/**
|
|
2961
3110
|
* Loading function which returns a `Promise` of a signal of the resource's value for a given
|
|
2962
3111
|
* request, which can change over time as new values are received from a stream.
|
|
2963
3112
|
*/
|
|
2964
3113
|
stream: ResourceStreamingLoader<ResourceState, ResourceLoaderParams<NonNullable<[
|
|
2965
3114
|
unknown
|
|
2966
|
-
] extends [Params] ? NoInfer<SourceParams
|
|
3115
|
+
] extends [Params] ? NoInfer<StripCraftException<SourceParams>> : NoInfer<StripCraftException<Params>>>>>;
|
|
2967
3116
|
preservePreviousValue?: () => boolean;
|
|
2968
3117
|
});
|
|
2969
|
-
type
|
|
3118
|
+
type AsyncProcessExceptionConstraints = {
|
|
3119
|
+
params: AnyCraftException;
|
|
3120
|
+
loader: AnyCraftException;
|
|
3121
|
+
};
|
|
3122
|
+
type ResourceLikeAsyncProcessExceptions<AsyncProcessException extends AsyncProcessExceptionConstraints = AsyncProcessExceptionConstraints, GroupIdentifier = unknown> = {
|
|
3123
|
+
hasException: Signal<boolean>;
|
|
3124
|
+
exceptions: Signal<{
|
|
3125
|
+
list: (InsertMetaInCraftExceptionIfExists<AsyncProcessException['params'], 'params', GroupIdentifier> | InsertMetaInCraftExceptionIfExists<AsyncProcessException['loader'], 'loader', GroupIdentifier>)[];
|
|
3126
|
+
params?: InsertMetaInCraftExceptionIfExists<AsyncProcessException['params'], 'params', unknown>;
|
|
3127
|
+
loader?: InsertMetaInCraftExceptionIfExists<AsyncProcessException['loader'], 'loader', GroupIdentifier>;
|
|
3128
|
+
}>;
|
|
3129
|
+
};
|
|
3130
|
+
type ResourceByIdLikeAsyncProcessExceptions<AsyncProcessException extends AsyncProcessExceptionConstraints = AsyncProcessExceptionConstraints, GroupIdentifier extends string = string> = {
|
|
3131
|
+
hasException: Signal<boolean>;
|
|
3132
|
+
exceptions: Signal<{
|
|
3133
|
+
list: (InsertMetaInCraftExceptionIfExists<AsyncProcessException['params'], 'params', unknown> | InsertMetaInCraftExceptionIfExists<AsyncProcessException['loader'], 'loader', GroupIdentifier>)[];
|
|
3134
|
+
params?: InsertMetaInCraftExceptionIfExists<AsyncProcessException['params'], 'params', unknown>;
|
|
3135
|
+
loader: Partial<Record<GroupIdentifier, InsertMetaInCraftExceptionIfExists<AsyncProcessException['loader'], 'loader', GroupIdentifier>>>;
|
|
3136
|
+
}>;
|
|
3137
|
+
};
|
|
3138
|
+
type AsyncProcessOutput<State extends object | undefined, Params, ArgParams, SourceParams, GroupIdentifier, Insertions, AsyncProcessExceptions extends AsyncProcessExceptionConstraints> = AsyncProcessRef<StripCraftException<State>, ArgParams, StripCraftException<Params>, Insertions, [
|
|
2970
3139
|
unknown
|
|
2971
3140
|
] extends [ArgParams] ? false : true, // ! force to method to have one arg minimum, we can not compare SourceParams type, because it also infer Params
|
|
2972
|
-
SourceParams, GroupIdentifier>;
|
|
3141
|
+
SourceParams, GroupIdentifier, AsyncProcessExceptions>;
|
|
2973
3142
|
/**
|
|
2974
3143
|
* Creates an async method that manages asynchronous operations with automatic state tracking.
|
|
2975
3144
|
*
|
|
@@ -3076,6 +3245,36 @@ SourceParams, GroupIdentifier>;
|
|
|
3076
3245
|
* ```
|
|
3077
3246
|
*
|
|
3078
3247
|
* @example
|
|
3248
|
+
* Business exceptions with `craftException`
|
|
3249
|
+
* ```ts
|
|
3250
|
+
* import { asyncProcess, craftException } from '@craft-ng/core';
|
|
3251
|
+
*
|
|
3252
|
+
* const loadUser = asyncProcess({
|
|
3253
|
+
* method: (value: string) =>
|
|
3254
|
+
* value.length < 3
|
|
3255
|
+
* ? craftException(
|
|
3256
|
+
* { code: 'SEARCH_TERM_TOO_SHORT' },
|
|
3257
|
+
* { min: 3, received: value.length },
|
|
3258
|
+
* )
|
|
3259
|
+
* : value,
|
|
3260
|
+
* loader: async ({ params }) =>
|
|
3261
|
+
* params === 'blocked'
|
|
3262
|
+
* ? craftException(
|
|
3263
|
+
* { code: 'USER_ACCESS_FORBIDDEN' },
|
|
3264
|
+
* { id: params },
|
|
3265
|
+
* )
|
|
3266
|
+
* : { id: params, name: 'John Doe' },
|
|
3267
|
+
* });
|
|
3268
|
+
*
|
|
3269
|
+
* loadUser.method('ab');
|
|
3270
|
+
* console.log(loadUser.hasException()); // true
|
|
3271
|
+
* console.log(loadUser.exceptions().params?.SEARCH_TERM_TOO_SHORT);
|
|
3272
|
+
*
|
|
3273
|
+
* loadUser.method('blocked');
|
|
3274
|
+
* console.log(loadUser.exceptions().loader?.USER_ACCESS_FORBIDDEN);
|
|
3275
|
+
* ```
|
|
3276
|
+
*
|
|
3277
|
+
* @example
|
|
3079
3278
|
* Async method with identifier for parallel operations
|
|
3080
3279
|
* ```ts
|
|
3081
3280
|
* const delayById = asyncProcess({
|
|
@@ -3116,14 +3315,38 @@ SourceParams, GroupIdentifier>;
|
|
|
3116
3315
|
*
|
|
3117
3316
|
* ```
|
|
3118
3317
|
*/
|
|
3119
|
-
declare function asyncProcess<AsyncProcesstate extends object | undefined, AsyncProcessParams, AsyncProcessArgsParams, SourceParams, GroupIdentifier
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
declare function asyncProcess<AsyncProcesstate extends object | undefined, AsyncProcessParams, AsyncProcessArgsParams, SourceParams, GroupIdentifier, Insertion1,
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3318
|
+
declare function asyncProcess<AsyncProcesstate extends object | undefined, AsyncProcessParams, AsyncProcessArgsParams, SourceParams, GroupIdentifier, Exceptions extends AsyncProcessExceptionConstraints = {
|
|
3319
|
+
params: ExtractCraftException<AsyncProcessParams>;
|
|
3320
|
+
loader: ExtractCraftException<AsyncProcesstate>;
|
|
3321
|
+
}>(AsyncProcessConfig: AsyncProcessConfig<AsyncProcesstate, AsyncProcessParams, AsyncProcessArgsParams, SourceParams, GroupIdentifier>): AsyncProcessOutput<StripCraftException<AsyncProcesstate>, StripCraftException<AsyncProcessParams>, AsyncProcessArgsParams, StripCraftException<AsyncProcessParams>, GroupIdentifier, {}, Exceptions>;
|
|
3322
|
+
declare function asyncProcess<AsyncProcesstate extends object | undefined, AsyncProcessParams, AsyncProcessArgsParams, SourceParams, GroupIdentifier, Insertion1, Exceptions extends AsyncProcessExceptionConstraints = {
|
|
3323
|
+
params: ExtractCraftException<AsyncProcessParams>;
|
|
3324
|
+
loader: ExtractCraftException<AsyncProcesstate>;
|
|
3325
|
+
}>(AsyncProcessConfig: AsyncProcessConfig<AsyncProcesstate, AsyncProcessParams, AsyncProcessArgsParams, SourceParams, GroupIdentifier>, insertion1: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<AsyncProcesstate>>, NoInfer<StripCraftException<AsyncProcessParams>>, Exceptions, Insertion1, {}>): AsyncProcessOutput<StripCraftException<AsyncProcesstate>, StripCraftException<AsyncProcessParams>, AsyncProcessArgsParams, StripCraftException<AsyncProcessParams>, GroupIdentifier, Insertion1, Exceptions>;
|
|
3326
|
+
declare function asyncProcess<AsyncProcesstate extends object | undefined, AsyncProcessParams, AsyncProcessArgsParams, SourceParams, GroupIdentifier, Insertion1, Insertion2, Exceptions extends AsyncProcessExceptionConstraints = {
|
|
3327
|
+
params: ExtractCraftException<AsyncProcessParams>;
|
|
3328
|
+
loader: ExtractCraftException<AsyncProcesstate>;
|
|
3329
|
+
}>(AsyncProcessConfig: AsyncProcessConfig<AsyncProcesstate, AsyncProcessParams, AsyncProcessArgsParams, SourceParams, GroupIdentifier>, insertion1: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<AsyncProcesstate>>, NoInfer<StripCraftException<AsyncProcessParams>>, Exceptions, Insertion1>, insertion2: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<AsyncProcesstate>>, NoInfer<StripCraftException<AsyncProcessParams>>, Exceptions, Insertion2, Insertion1>): AsyncProcessOutput<StripCraftException<AsyncProcesstate>, StripCraftException<AsyncProcessParams>, AsyncProcessArgsParams, StripCraftException<AsyncProcessParams>, GroupIdentifier, Insertion1 & Insertion2, Exceptions>;
|
|
3330
|
+
declare function asyncProcess<AsyncProcesstate extends object | undefined, AsyncProcessParams, AsyncProcessArgsParams, SourceParams, GroupIdentifier, Insertion1, Insertion2, Insertion3, Exceptions extends AsyncProcessExceptionConstraints = {
|
|
3331
|
+
params: ExtractCraftException<AsyncProcessParams>;
|
|
3332
|
+
loader: ExtractCraftException<AsyncProcesstate>;
|
|
3333
|
+
}>(AsyncProcessConfig: AsyncProcessConfig<AsyncProcesstate, AsyncProcessParams, AsyncProcessArgsParams, SourceParams, GroupIdentifier>, insertion1: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<AsyncProcesstate>>, NoInfer<StripCraftException<AsyncProcessParams>>, Exceptions, Insertion1>, insertion2: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<AsyncProcesstate>>, NoInfer<StripCraftException<AsyncProcessParams>>, Exceptions, Insertion2, Insertion1>, insertion3: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<AsyncProcesstate>>, NoInfer<StripCraftException<AsyncProcessParams>>, Exceptions, Insertion3, Insertion1 & Insertion2>): AsyncProcessOutput<StripCraftException<AsyncProcesstate>, StripCraftException<AsyncProcessParams>, AsyncProcessArgsParams, StripCraftException<AsyncProcessParams>, GroupIdentifier, Insertion1 & Insertion2 & Insertion3, Exceptions>;
|
|
3334
|
+
declare function asyncProcess<AsyncProcesstate extends object | undefined, AsyncProcessParams, AsyncProcessArgsParams, SourceParams, GroupIdentifier, Insertion1, Insertion2, Insertion3, Insertion4, Exceptions extends AsyncProcessExceptionConstraints = {
|
|
3335
|
+
params: ExtractCraftException<AsyncProcessParams>;
|
|
3336
|
+
loader: ExtractCraftException<AsyncProcesstate>;
|
|
3337
|
+
}>(AsyncProcessConfig: AsyncProcessConfig<AsyncProcesstate, AsyncProcessParams, AsyncProcessArgsParams, SourceParams, GroupIdentifier>, insertion1: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<AsyncProcesstate>>, NoInfer<StripCraftException<AsyncProcessParams>>, Exceptions, Insertion1>, insertion2: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<AsyncProcesstate>>, NoInfer<StripCraftException<AsyncProcessParams>>, Exceptions, Insertion2, Insertion1>, insertion3: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<AsyncProcesstate>>, NoInfer<StripCraftException<AsyncProcessParams>>, Exceptions, Insertion3, Insertion1 & Insertion2>, insertion4: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<AsyncProcesstate>>, NoInfer<StripCraftException<AsyncProcessParams>>, Exceptions, Insertion4, Insertion1 & Insertion2 & Insertion3>): AsyncProcessOutput<StripCraftException<AsyncProcesstate>, StripCraftException<AsyncProcessParams>, AsyncProcessArgsParams, StripCraftException<AsyncProcessParams>, GroupIdentifier, Insertion1 & Insertion2 & Insertion3 & Insertion4, Exceptions>;
|
|
3338
|
+
declare function asyncProcess<AsyncProcesstate extends object | undefined, AsyncProcessParams, AsyncProcessArgsParams, SourceParams, GroupIdentifier, Insertion1, Insertion2, Insertion3, Insertion4, Insertion5, Exceptions extends AsyncProcessExceptionConstraints = {
|
|
3339
|
+
params: ExtractCraftException<AsyncProcessParams>;
|
|
3340
|
+
loader: ExtractCraftException<AsyncProcesstate>;
|
|
3341
|
+
}>(AsyncProcessConfig: AsyncProcessConfig<AsyncProcesstate, AsyncProcessParams, AsyncProcessArgsParams, SourceParams, GroupIdentifier>, insertion1: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<AsyncProcesstate>>, NoInfer<StripCraftException<AsyncProcessParams>>, Exceptions, Insertion1>, insertion2: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<AsyncProcesstate>>, NoInfer<StripCraftException<AsyncProcessParams>>, Exceptions, Insertion2, Insertion1>, insertion3: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<AsyncProcesstate>>, NoInfer<StripCraftException<AsyncProcessParams>>, Exceptions, Insertion3, Insertion1 & Insertion2>, insertion4: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<AsyncProcesstate>>, NoInfer<StripCraftException<AsyncProcessParams>>, Exceptions, Insertion4, Insertion1 & Insertion2 & Insertion3>, insertion5: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<AsyncProcesstate>>, NoInfer<StripCraftException<AsyncProcessParams>>, Exceptions, Insertion5, Insertion1 & Insertion2 & Insertion3 & Insertion4>): AsyncProcessOutput<StripCraftException<AsyncProcesstate>, StripCraftException<AsyncProcessParams>, AsyncProcessArgsParams, StripCraftException<AsyncProcessParams>, GroupIdentifier, Insertion1 & Insertion2 & Insertion3 & Insertion4 & Insertion5, Exceptions>;
|
|
3342
|
+
declare function asyncProcess<AsyncProcesstate extends object | undefined, AsyncProcessParams, AsyncProcessArgsParams, SourceParams, GroupIdentifier, Insertion1, Insertion2, Insertion3, Insertion4, Insertion5, Insertion6, Exceptions extends AsyncProcessExceptionConstraints = {
|
|
3343
|
+
params: ExtractCraftException<AsyncProcessParams>;
|
|
3344
|
+
loader: ExtractCraftException<AsyncProcesstate>;
|
|
3345
|
+
}>(AsyncProcessConfig: AsyncProcessConfig<AsyncProcesstate, AsyncProcessParams, AsyncProcessArgsParams, SourceParams, GroupIdentifier>, insertion1: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<AsyncProcesstate>>, NoInfer<StripCraftException<AsyncProcessParams>>, Exceptions, Insertion1>, insertion2: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<AsyncProcesstate>>, NoInfer<StripCraftException<AsyncProcessParams>>, Exceptions, Insertion2, Insertion1>, insertion3: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<AsyncProcesstate>>, NoInfer<StripCraftException<AsyncProcessParams>>, Exceptions, Insertion3, Insertion1 & Insertion2>, insertion4: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<AsyncProcesstate>>, NoInfer<StripCraftException<AsyncProcessParams>>, Exceptions, Insertion4, Insertion1 & Insertion2 & Insertion3>, insertion5: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<AsyncProcesstate>>, NoInfer<StripCraftException<AsyncProcessParams>>, Exceptions, Insertion5, Insertion1 & Insertion2 & Insertion3 & Insertion4>, insertion6: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<AsyncProcesstate>>, NoInfer<StripCraftException<AsyncProcessParams>>, Exceptions, Insertion6, Insertion1 & Insertion2 & Insertion3 & Insertion4 & Insertion5>): AsyncProcessOutput<StripCraftException<AsyncProcesstate>, StripCraftException<AsyncProcessParams>, AsyncProcessArgsParams, StripCraftException<AsyncProcessParams>, GroupIdentifier, Insertion1 & Insertion2 & Insertion3 & Insertion4 & Insertion5 & Insertion6, Exceptions>;
|
|
3346
|
+
declare function asyncProcess<AsyncProcesstate extends object | undefined, AsyncProcessParams, AsyncProcessArgsParams, SourceParams, GroupIdentifier, Insertion1, Insertion2, Insertion3, Insertion4, Insertion5, Insertion6, Insertion7, Exceptions extends AsyncProcessExceptionConstraints = {
|
|
3347
|
+
params: ExtractCraftException<AsyncProcessParams>;
|
|
3348
|
+
loader: ExtractCraftException<AsyncProcesstate>;
|
|
3349
|
+
}>(AsyncProcessConfig: AsyncProcessConfig<AsyncProcesstate, AsyncProcessParams, AsyncProcessArgsParams, SourceParams, GroupIdentifier>, insertion1: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<AsyncProcesstate>>, NoInfer<StripCraftException<AsyncProcessParams>>, Exceptions, Insertion1>, insertion2: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<AsyncProcesstate>>, NoInfer<StripCraftException<AsyncProcessParams>>, Exceptions, Insertion2, Insertion1>, insertion3: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<AsyncProcesstate>>, NoInfer<StripCraftException<AsyncProcessParams>>, Exceptions, Insertion3, Insertion1 & Insertion2>, insertion4: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<AsyncProcesstate>>, NoInfer<StripCraftException<AsyncProcessParams>>, Exceptions, Insertion4, Insertion1 & Insertion2 & Insertion3>, insertion5: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<AsyncProcesstate>>, NoInfer<StripCraftException<AsyncProcessParams>>, Exceptions, Insertion5, Insertion1 & Insertion2 & Insertion3 & Insertion4>, insertion6: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<AsyncProcesstate>>, NoInfer<StripCraftException<AsyncProcessParams>>, Exceptions, Insertion6, Insertion1 & Insertion2 & Insertion3 & Insertion4 & Insertion5>, insertion7: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<AsyncProcesstate>>, NoInfer<StripCraftException<AsyncProcessParams>>, Exceptions, Insertion7, Insertion1 & Insertion2 & Insertion3 & Insertion4 & Insertion5 & Insertion6>): AsyncProcessOutput<StripCraftException<AsyncProcesstate>, StripCraftException<AsyncProcessParams>, AsyncProcessArgsParams, StripCraftException<AsyncProcessParams>, GroupIdentifier, Insertion1 & Insertion2 & Insertion3 & Insertion4 & Insertion5 & Insertion6 & Insertion7, Exceptions>;
|
|
3127
3350
|
|
|
3128
3351
|
/**
|
|
3129
3352
|
* Creates a derived readonly source that transforms values from an origin source using a computation function.
|
|
@@ -5175,7 +5398,7 @@ type QueryConfig<ResourceState, Params, ParamsArgs, SourceParams, GroupIdentifie
|
|
|
5175
5398
|
* If a request function isn't provided, the loader won't rerun unless the resource is reloaded.
|
|
5176
5399
|
*/
|
|
5177
5400
|
params: () => Params;
|
|
5178
|
-
loader: (param: NoInfer<ResourceLoaderParams<Params
|
|
5401
|
+
loader: (param: NoInfer<ResourceLoaderParams<StripCraftException<Params>>>) => Promise<ResourceState>;
|
|
5179
5402
|
method?: never;
|
|
5180
5403
|
fromResourceById?: never;
|
|
5181
5404
|
stream?: never;
|
|
@@ -5194,7 +5417,9 @@ type QueryConfig<ResourceState, Params, ParamsArgs, SourceParams, GroupIdentifie
|
|
|
5194
5417
|
* It also accepts a ReadonlySource<SourceParams> to connect the query params to an external signal source.
|
|
5195
5418
|
*/
|
|
5196
5419
|
method: ((args: ParamsArgs) => Params) | ReadonlySource<SourceParams>;
|
|
5197
|
-
loader: (param:
|
|
5420
|
+
loader: (param: ResourceLoaderParams<NonNullable<[
|
|
5421
|
+
unknown
|
|
5422
|
+
] extends [Params] ? NoInfer<StripCraftException<SourceParams>> : NoInfer<StripCraftException<Params>>>>) => Promise<ResourceState>;
|
|
5198
5423
|
params?: never;
|
|
5199
5424
|
fromResourceById?: never;
|
|
5200
5425
|
stream?: never;
|
|
@@ -5259,7 +5484,7 @@ type QueryConfig<ResourceState, Params, ParamsArgs, SourceParams, GroupIdentifie
|
|
|
5259
5484
|
* A unique identifier for the resource, derived from the params.
|
|
5260
5485
|
* It should be a string that uniquely identifies the resource based on the params.
|
|
5261
5486
|
*/
|
|
5262
|
-
identifier?: (params: NoInfer<NonNullable<Params
|
|
5487
|
+
identifier?: (params: NoInfer<NonNullable<StripCraftException<Params>>>) => GroupIdentifier;
|
|
5263
5488
|
/**
|
|
5264
5489
|
* Under the hood, a resource is generated for each new identifier generated when the params source change.
|
|
5265
5490
|
*
|
|
@@ -5280,7 +5505,23 @@ type QueryConfig<ResourceState, Params, ParamsArgs, SourceParams, GroupIdentifie
|
|
|
5280
5505
|
*/
|
|
5281
5506
|
equalParams?: Params extends object ? 'default' | 'useIdentifier' | ((a: Params, b: Params, identifierFn: (params: Params) => GroupIdentifier) => boolean) : never;
|
|
5282
5507
|
};
|
|
5283
|
-
type
|
|
5508
|
+
type ResourceLikeExceptions<QueryException extends ResourceExceptionConstraints, GroupIdentifier = unknown> = {
|
|
5509
|
+
hasException: Signal<boolean>;
|
|
5510
|
+
exceptions: Signal<{
|
|
5511
|
+
list: (InsertMetaInCraftExceptionIfExists<QueryException['params'], 'params', unknown> | InsertMetaInCraftExceptionIfExists<QueryException['loader'], 'loader', GroupIdentifier>)[];
|
|
5512
|
+
params?: InsertMetaInCraftExceptionIfExists<QueryException['params'], 'params', unknown>;
|
|
5513
|
+
loader?: InsertMetaInCraftExceptionIfExists<QueryException['loader'], 'loader', GroupIdentifier>;
|
|
5514
|
+
}>;
|
|
5515
|
+
};
|
|
5516
|
+
type ResourceByIdLikeExceptions<QueryException extends ResourceExceptionConstraints, GroupIdentifier extends string> = {
|
|
5517
|
+
hasException: Signal<boolean>;
|
|
5518
|
+
exceptions: Signal<{
|
|
5519
|
+
list: (InsertMetaInCraftExceptionIfExists<QueryException['params'], 'params', unknown> | InsertMetaInCraftExceptionIfExists<QueryException['loader'], 'loader', GroupIdentifier>)[];
|
|
5520
|
+
params?: InsertMetaInCraftExceptionIfExists<QueryException['params'], 'params', unknown>;
|
|
5521
|
+
loader: Partial<Record<GroupIdentifier, InsertMetaInCraftExceptionIfExists<QueryException['loader'], 'loader', GroupIdentifier>>>;
|
|
5522
|
+
}>;
|
|
5523
|
+
};
|
|
5524
|
+
type ResourceLikeQueryRef<Value, Params, IsMethod, ArgParams, SourceParams, Insertions, QueryException extends ResourceExceptionConstraints> = {
|
|
5284
5525
|
type: 'resourceLike';
|
|
5285
5526
|
kind: 'query';
|
|
5286
5527
|
} & MergeObjects$1<[
|
|
@@ -5299,16 +5540,17 @@ type ResourceLikeQueryRef<Value, Params, IsMethod, ArgParams, SourceParams, Inse
|
|
|
5299
5540
|
readonly resourceParamsSrc: WritableSignal<NoInfer<Params>>;
|
|
5300
5541
|
},
|
|
5301
5542
|
IsMethod extends true ? {
|
|
5302
|
-
|
|
5543
|
+
call: (args: ArgParams) => Params;
|
|
5303
5544
|
} : {
|
|
5304
5545
|
source: ReadonlySource<SourceParams>;
|
|
5305
5546
|
},
|
|
5306
5547
|
Insertions,
|
|
5548
|
+
ResourceLikeExceptions<QueryException>,
|
|
5307
5549
|
{
|
|
5308
5550
|
[key in `~InternalType`]: 'Used to avoid TS type erasure';
|
|
5309
5551
|
}
|
|
5310
5552
|
]>;
|
|
5311
|
-
type ResourceByIdLikeQueryRef<Value, Params, IsMethod, ArgParams, SourceParams, Insertions, GroupIdentifier> = {
|
|
5553
|
+
type ResourceByIdLikeQueryRef<Value, Params, IsMethod, ArgParams, SourceParams, Insertions, GroupIdentifier, QueryException extends ResourceExceptionConstraints> = {
|
|
5312
5554
|
type: 'resourceByGroupLike';
|
|
5313
5555
|
kind: 'query';
|
|
5314
5556
|
} & {
|
|
@@ -5322,7 +5564,7 @@ type ResourceByIdLikeQueryRef<Value, Params, IsMethod, ArgParams, SourceParams,
|
|
|
5322
5564
|
*
|
|
5323
5565
|
* return the associated resource or undefined if not existing
|
|
5324
5566
|
*/
|
|
5325
|
-
select: (id: GroupIdentifier) => {
|
|
5567
|
+
select: (id: GroupIdentifier) => ({
|
|
5326
5568
|
readonly value: Signal<Value | undefined>;
|
|
5327
5569
|
/**
|
|
5328
5570
|
* Avoids to throw error when accessing value during error state
|
|
@@ -5332,39 +5574,66 @@ type ResourceByIdLikeQueryRef<Value, Params, IsMethod, ArgParams, SourceParams,
|
|
|
5332
5574
|
readonly error: Signal<Error | undefined>;
|
|
5333
5575
|
readonly isLoading: Signal<boolean>;
|
|
5334
5576
|
hasValue(): boolean;
|
|
5335
|
-
} | undefined;
|
|
5577
|
+
} & ResourceLikeExceptions<QueryException, GroupIdentifier>) | undefined;
|
|
5336
5578
|
} & MergeObjects$1<[
|
|
5337
5579
|
Insertions,
|
|
5338
5580
|
IsMethod extends true ? {
|
|
5339
|
-
|
|
5581
|
+
call: (args: ArgParams) => Params;
|
|
5340
5582
|
} : {
|
|
5341
5583
|
source: ReadonlySource<SourceParams>;
|
|
5342
5584
|
},
|
|
5343
|
-
ResourceByIdRef<GroupIdentifier & string, Value, Params
|
|
5585
|
+
ResourceByIdRef<GroupIdentifier & string, Value, Params>,
|
|
5586
|
+
[
|
|
5587
|
+
GroupIdentifier
|
|
5588
|
+
] extends [string] ? ResourceByIdLikeExceptions<QueryException, GroupIdentifier> : {}
|
|
5344
5589
|
]>;
|
|
5345
|
-
type QueryRef<Value, Params, ArgParams, Insertions, IsMethod, SourceParams, GroupIdentifier> = [unknown] extends [GroupIdentifier] ? ResourceLikeQueryRef<Value, Params, IsMethod, ArgParams, SourceParams, Insertions> : ResourceByIdLikeQueryRef<Value, Params, IsMethod, ArgParams, SourceParams, Insertions, GroupIdentifier>;
|
|
5346
|
-
type QueryOutput<State extends object | undefined, Params, ArgParams, SourceParams, GroupIdentifier, Insertions> = QueryRef<State, Params, ArgParams, Insertions, [
|
|
5590
|
+
type QueryRef<Value, Params, ArgParams, Insertions, IsMethod, SourceParams, GroupIdentifier, QueryExceptions extends ResourceExceptionConstraints> = [unknown] extends [GroupIdentifier] ? ResourceLikeQueryRef<Value, Params, IsMethod, ArgParams, SourceParams, Insertions, QueryExceptions> : ResourceByIdLikeQueryRef<Value, Params, IsMethod, ArgParams, SourceParams, Insertions, GroupIdentifier, QueryExceptions>;
|
|
5591
|
+
type QueryOutput<State extends object | undefined, Params, ArgParams, SourceParams, GroupIdentifier, Insertions, QueryExceptions extends ResourceExceptionConstraints> = QueryRef<State, Params, ArgParams, Insertions, [
|
|
5347
5592
|
unknown
|
|
5348
5593
|
] extends [ArgParams] ? false : true, // ! force to method to have one arg minimum, we can not compare SourceParams type, because it also infer Params
|
|
5349
|
-
SourceParams, GroupIdentifier>;
|
|
5350
|
-
declare function query<QueryState extends object | undefined, QueryParams, QueryArgsParams, SourceParams, GroupIdentifier, FromObjectGroupIdentifier extends string, FromObjectState, FromObjectResourceParams
|
|
5351
|
-
|
|
5352
|
-
|
|
5353
|
-
|
|
5354
|
-
declare function query<QueryState extends object | undefined, QueryParams, QueryArgsParams, SourceParams, GroupIdentifier, FromObjectGroupIdentifier extends string, FromObjectState, FromObjectResourceParams, Insertion1,
|
|
5355
|
-
|
|
5356
|
-
|
|
5357
|
-
|
|
5594
|
+
SourceParams, GroupIdentifier, QueryExceptions>;
|
|
5595
|
+
declare function query<QueryState extends object | undefined, QueryParams, QueryArgsParams, SourceParams, GroupIdentifier, FromObjectGroupIdentifier extends string, FromObjectState, FromObjectResourceParams, Exceptions extends ResourceExceptionConstraints = {
|
|
5596
|
+
params: ExtractCraftException<QueryParams>;
|
|
5597
|
+
loader: ExtractCraftException<QueryState>;
|
|
5598
|
+
}>(queryConfig: QueryConfig<QueryState, QueryParams, QueryArgsParams, SourceParams, GroupIdentifier, FromObjectGroupIdentifier, FromObjectState, FromObjectResourceParams>): QueryOutput<StripCraftException<QueryState>, StripCraftException<QueryParams>, QueryArgsParams, StripCraftException<QueryParams>, GroupIdentifier, {}, Exceptions>;
|
|
5599
|
+
declare function query<QueryState extends object | undefined, QueryParams, QueryArgsParams, SourceParams, GroupIdentifier, FromObjectGroupIdentifier extends string, FromObjectState, FromObjectResourceParams, Insertion1, Exceptions extends ResourceExceptionConstraints = {
|
|
5600
|
+
params: ExtractCraftException<QueryParams>;
|
|
5601
|
+
loader: ExtractCraftException<QueryState>;
|
|
5602
|
+
}>(queryConfig: QueryConfig<QueryState, QueryParams, QueryArgsParams, SourceParams, GroupIdentifier, FromObjectGroupIdentifier, FromObjectState, FromObjectResourceParams>, insertion1: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<QueryState>>, NoInfer<StripCraftException<QueryParams>>, Exceptions, Insertion1, {}>): QueryOutput<StripCraftException<QueryState>, StripCraftException<QueryParams>, QueryArgsParams, StripCraftException<QueryParams>, GroupIdentifier, Insertion1, Exceptions>;
|
|
5603
|
+
declare function query<QueryState extends object | undefined, QueryParams, QueryArgsParams, SourceParams, GroupIdentifier, FromObjectGroupIdentifier extends string, FromObjectState, FromObjectResourceParams, Insertion1, Insertion2, Exceptions extends ResourceExceptionConstraints = {
|
|
5604
|
+
params: ExtractCraftException<QueryParams>;
|
|
5605
|
+
loader: ExtractCraftException<QueryState>;
|
|
5606
|
+
}>(queryConfig: QueryConfig<QueryState, QueryParams, QueryArgsParams, SourceParams, GroupIdentifier, FromObjectGroupIdentifier, FromObjectState, FromObjectResourceParams>, insertion1: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<QueryState>>, NoInfer<StripCraftException<QueryParams>>, Exceptions, Insertion1>, insertion2: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<QueryState>>, NoInfer<StripCraftException<QueryParams>>, Exceptions, Insertion2, Insertion1>): QueryOutput<StripCraftException<QueryState>, StripCraftException<QueryParams>, QueryArgsParams, StripCraftException<QueryParams>, GroupIdentifier, Insertion1 & Insertion2, Exceptions>;
|
|
5607
|
+
declare function query<QueryState extends object | undefined, QueryParams, QueryArgsParams, SourceParams, GroupIdentifier, FromObjectGroupIdentifier extends string, FromObjectState, FromObjectResourceParams, Insertion1, Insertion2, Insertion3, Exceptions extends ResourceExceptionConstraints = {
|
|
5608
|
+
params: ExtractCraftException<QueryParams>;
|
|
5609
|
+
loader: ExtractCraftException<QueryState>;
|
|
5610
|
+
}>(queryConfig: QueryConfig<QueryState, QueryParams, QueryArgsParams, SourceParams, GroupIdentifier, FromObjectGroupIdentifier, FromObjectState, FromObjectResourceParams>, insertion1: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<QueryState>>, NoInfer<StripCraftException<QueryParams>>, Exceptions, Insertion1>, insertion2: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<QueryState>>, NoInfer<StripCraftException<QueryParams>>, Exceptions, Insertion2, Insertion1>, insertion3: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<QueryState>>, NoInfer<StripCraftException<QueryParams>>, Exceptions, Insertion3, Insertion1 & Insertion2>): QueryOutput<StripCraftException<QueryState>, StripCraftException<QueryParams>, QueryArgsParams, StripCraftException<QueryParams>, GroupIdentifier, Insertion1 & Insertion2 & Insertion3, Exceptions>;
|
|
5611
|
+
declare function query<QueryState extends object | undefined, QueryParams, QueryArgsParams, SourceParams, GroupIdentifier, FromObjectGroupIdentifier extends string, FromObjectState, FromObjectResourceParams, Insertion1, Insertion2, Insertion3, Insertion4, Exceptions extends ResourceExceptionConstraints = {
|
|
5612
|
+
params: ExtractCraftException<QueryParams>;
|
|
5613
|
+
loader: ExtractCraftException<QueryState>;
|
|
5614
|
+
}>(queryConfig: QueryConfig<QueryState, QueryParams, QueryArgsParams, SourceParams, GroupIdentifier, FromObjectGroupIdentifier, FromObjectState, FromObjectResourceParams>, insertion1: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<QueryState>>, NoInfer<StripCraftException<QueryParams>>, Exceptions, Insertion1>, insertion2: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<QueryState>>, NoInfer<StripCraftException<QueryParams>>, Exceptions, Insertion2, Insertion1>, insertion3: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<QueryState>>, NoInfer<StripCraftException<QueryParams>>, Exceptions, Insertion3, Insertion1 & Insertion2>, insertion4: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<QueryState>>, NoInfer<StripCraftException<QueryParams>>, Exceptions, Insertion4, Insertion1 & Insertion2 & Insertion3>): QueryOutput<StripCraftException<QueryState>, StripCraftException<QueryParams>, QueryArgsParams, StripCraftException<QueryParams>, GroupIdentifier, Insertion1 & Insertion2 & Insertion3 & Insertion4, Exceptions>;
|
|
5615
|
+
declare function query<QueryState extends object | undefined, QueryParams, QueryArgsParams, SourceParams, GroupIdentifier, FromObjectGroupIdentifier extends string, FromObjectState, FromObjectResourceParams, Insertion1, Insertion2, Insertion3, Insertion4, Insertion5, Exceptions extends ResourceExceptionConstraints = {
|
|
5616
|
+
params: ExtractCraftException<QueryParams>;
|
|
5617
|
+
loader: ExtractCraftException<QueryState>;
|
|
5618
|
+
}>(queryConfig: QueryConfig<QueryState, QueryParams, QueryArgsParams, SourceParams, GroupIdentifier, FromObjectGroupIdentifier, FromObjectState, FromObjectResourceParams>, insertion1: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<QueryState>>, NoInfer<StripCraftException<QueryParams>>, Exceptions, Insertion1>, insertion2: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<QueryState>>, NoInfer<StripCraftException<QueryParams>>, Exceptions, Insertion2, Insertion1>, insertion3: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<QueryState>>, NoInfer<StripCraftException<QueryParams>>, Exceptions, Insertion3, Insertion1 & Insertion2>, insertion4: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<QueryState>>, NoInfer<StripCraftException<QueryParams>>, Exceptions, Insertion4, Insertion1 & Insertion2 & Insertion3>, insertion5: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<QueryState>>, NoInfer<StripCraftException<QueryParams>>, Exceptions, Insertion5, Insertion1 & Insertion2 & Insertion3 & Insertion4>): QueryOutput<StripCraftException<QueryState>, StripCraftException<QueryParams>, QueryArgsParams, StripCraftException<QueryParams>, GroupIdentifier, Insertion1 & Insertion2 & Insertion3 & Insertion4 & Insertion5, Exceptions>;
|
|
5619
|
+
declare function query<QueryState extends object | undefined, QueryParams, QueryArgsParams, SourceParams, GroupIdentifier, FromObjectGroupIdentifier extends string, FromObjectState, FromObjectResourceParams, Insertion1, Insertion2, Insertion3, Insertion4, Insertion5, Insertion6, Exceptions extends ResourceExceptionConstraints = {
|
|
5620
|
+
params: ExtractCraftException<QueryParams>;
|
|
5621
|
+
loader: ExtractCraftException<QueryState>;
|
|
5622
|
+
}>(queryConfig: QueryConfig<QueryState, QueryParams, QueryArgsParams, SourceParams, GroupIdentifier, FromObjectGroupIdentifier, FromObjectState, FromObjectResourceParams>, insertion1: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<QueryState>>, NoInfer<StripCraftException<QueryParams>>, Exceptions, Insertion1>, insertion2: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<QueryState>>, NoInfer<StripCraftException<QueryParams>>, Exceptions, Insertion2, Insertion1>, insertion3: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<QueryState>>, NoInfer<StripCraftException<QueryParams>>, Exceptions, Insertion3, Insertion1 & Insertion2>, insertion4: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<QueryState>>, NoInfer<StripCraftException<QueryParams>>, Exceptions, Insertion4, Insertion1 & Insertion2 & Insertion3>, insertion5: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<QueryState>>, NoInfer<StripCraftException<QueryParams>>, Exceptions, Insertion5, Insertion1 & Insertion2 & Insertion3 & Insertion4>, insertion6: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<QueryState>>, NoInfer<StripCraftException<QueryParams>>, Exceptions, Insertion6, Insertion1 & Insertion2 & Insertion3 & Insertion4 & Insertion5>): QueryOutput<StripCraftException<QueryState>, StripCraftException<QueryParams>, QueryArgsParams, StripCraftException<QueryParams>, GroupIdentifier, Insertion1 & Insertion2 & Insertion3 & Insertion4 & Insertion5 & Insertion6, Exceptions>;
|
|
5623
|
+
declare function query<QueryState extends object | undefined, QueryParams, QueryArgsParams, SourceParams, GroupIdentifier, FromObjectGroupIdentifier extends string, FromObjectState, FromObjectResourceParams, Insertion1, Insertion2, Insertion3, Insertion4, Insertion5, Insertion6, Insertion7, Exceptions extends ResourceExceptionConstraints = {
|
|
5624
|
+
params: ExtractCraftException<QueryParams>;
|
|
5625
|
+
loader: ExtractCraftException<QueryState>;
|
|
5626
|
+
}>(queryConfig: QueryConfig<QueryState, QueryParams, QueryArgsParams, SourceParams, GroupIdentifier, FromObjectGroupIdentifier, FromObjectState, FromObjectResourceParams>, insertion1: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<QueryState>>, NoInfer<StripCraftException<QueryParams>>, Exceptions, Insertion1>, insertion2: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<QueryState>>, NoInfer<StripCraftException<QueryParams>>, Exceptions, Insertion2, Insertion1>, insertion3: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<QueryState>>, NoInfer<StripCraftException<QueryParams>>, Exceptions, Insertion3, Insertion1 & Insertion2>, insertion4: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<QueryState>>, NoInfer<StripCraftException<QueryParams>>, Exceptions, Insertion4, Insertion1 & Insertion2 & Insertion3>, insertion5: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<QueryState>>, NoInfer<StripCraftException<QueryParams>>, Exceptions, Insertion5, Insertion1 & Insertion2 & Insertion3 & Insertion4>, insertion6: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<QueryState>>, NoInfer<StripCraftException<QueryParams>>, Exceptions, Insertion6, Insertion1 & Insertion2 & Insertion3 & Insertion4 & Insertion5>, insertion7: InsertionsResourcesFactory<NoInfer<GroupIdentifier>, NoInfer<StripCraftException<QueryState>>, NoInfer<StripCraftException<QueryParams>>, Exceptions, Insertion7, Insertion1 & Insertion2 & Insertion3 & Insertion4 & Insertion5 & Insertion6>): QueryOutput<StripCraftException<QueryState>, StripCraftException<QueryParams>, QueryArgsParams, StripCraftException<QueryParams>, GroupIdentifier, Insertion1 & Insertion2 & Insertion3 & Insertion4 & Insertion5 & Insertion6 & Insertion7, Exceptions>;
|
|
5358
5627
|
|
|
5359
|
-
type SpecificCraftQueryOutputs<ResourceName extends string, ResourceState extends object | undefined, ResourceParams, ResourceArgsParams, IsMethod, SourceParams, GroupIdentifier, InsertionsOutputs> = PartialContext<{
|
|
5628
|
+
type SpecificCraftQueryOutputs<ResourceName extends string, ResourceState extends object | undefined, ResourceParams, ResourceArgsParams, IsMethod, SourceParams, GroupIdentifier, InsertionsOutputs, QueryExceptions extends ResourceExceptionConstraints> = PartialContext<{
|
|
5360
5629
|
props: {
|
|
5361
|
-
[key in `${ResourceName & string}`]: QueryOutput<ResourceState, ResourceArgsParams, ResourceParams, SourceParams, GroupIdentifier, InsertionsOutputs>;
|
|
5630
|
+
[key in `${ResourceName & string}`]: QueryOutput<ResourceState, ResourceArgsParams, ResourceParams, SourceParams, GroupIdentifier, InsertionsOutputs, QueryExceptions>;
|
|
5362
5631
|
};
|
|
5363
5632
|
_query: {
|
|
5364
|
-
[key in ResourceName & string]: QueryOutput<ResourceState, ResourceArgsParams, ResourceParams, SourceParams, GroupIdentifier, InsertionsOutputs>;
|
|
5633
|
+
[key in ResourceName & string]: QueryOutput<ResourceState, ResourceArgsParams, ResourceParams, SourceParams, GroupIdentifier, InsertionsOutputs, QueryExceptions>;
|
|
5365
5634
|
};
|
|
5366
5635
|
}>;
|
|
5367
|
-
type CraftQueryOutputs<Context extends ContextConstraints, StoreConfig extends StoreConfigConstraints, ResourceName extends string, ResourceState extends object | undefined, ResourceParams, ResourceArgsParams, IsMethod, SourceParams, GroupIdentifier, InsertionsOutputs> = CraftFactoryUtility<Context, StoreConfig, SpecificCraftQueryOutputs<ResourceName, ResourceState, ResourceParams, ResourceArgsParams, IsMethod, SourceParams, GroupIdentifier, InsertionsOutputs>>;
|
|
5636
|
+
type CraftQueryOutputs<Context extends ContextConstraints, StoreConfig extends StoreConfigConstraints, ResourceName extends string, ResourceState extends object | undefined, ResourceParams, ResourceArgsParams, IsMethod, SourceParams, GroupIdentifier, InsertionsOutputs, QueryExceptions extends ResourceExceptionConstraints> = CraftFactoryUtility<Context, StoreConfig, SpecificCraftQueryOutputs<ResourceName, ResourceState, ResourceParams, ResourceArgsParams, IsMethod, SourceParams, GroupIdentifier, InsertionsOutputs, QueryExceptions>>;
|
|
5368
5637
|
type ContextQueryEntries<Context extends ContextConstraints, StoreConfig extends StoreConfigConstraints, ResourceName extends string> = Context['_inputs'] & Context['_injections'] & Context['_sources'] & Omit<Context['props'], keyof Context['_mutation']> & Context['_AsyncProcess'] & Context['_mutation'] & {
|
|
5369
5638
|
INSERT_CONFIG: {
|
|
5370
5639
|
storeName: StoreConfig['name'];
|
|
@@ -5768,7 +6037,7 @@ type ContextQueryEntries<Context extends ContextConstraints, StoreConfig extends
|
|
|
5768
6037
|
* );
|
|
5769
6038
|
* ```
|
|
5770
6039
|
*/
|
|
5771
|
-
declare function craftQuery<Context extends ContextConstraints, StoreConfig extends StoreConfigConstraints, const ResourceName extends string, ResourceState extends object | undefined, ResourceParams, ResourceArgsParams, InsertionsOutputs, IsMethod, SourceParams, GroupIdentifier>(resourceName: ResourceName, queryFactory: (context: ContextQueryEntries<Context, StoreConfig, ResourceName>) => QueryOutput<ResourceState, ResourceArgsParams, ResourceParams, SourceParams, GroupIdentifier, InsertionsOutputs>): CraftQueryOutputs<Context, StoreConfig, ResourceName, NoInfer<ResourceState>, ResourceParams, ResourceArgsParams, IsMethod, SourceParams, GroupIdentifier, InsertionsOutputs>;
|
|
6040
|
+
declare function craftQuery<Context extends ContextConstraints, StoreConfig extends StoreConfigConstraints, const ResourceName extends string, ResourceState extends object | undefined, ResourceParams, ResourceArgsParams, InsertionsOutputs, IsMethod, SourceParams, GroupIdentifier, QueryExceptions extends ResourceExceptionConstraints>(resourceName: ResourceName, queryFactory: (context: ContextQueryEntries<Context, StoreConfig, ResourceName>) => QueryOutput<ResourceState, ResourceArgsParams, ResourceParams, SourceParams, GroupIdentifier, InsertionsOutputs, QueryExceptions>): CraftQueryOutputs<Context, StoreConfig, ResourceName, NoInfer<ResourceState>, ResourceParams, ResourceArgsParams, IsMethod, SourceParams, GroupIdentifier, InsertionsOutputs, QueryExceptions>;
|
|
5772
6041
|
|
|
5773
6042
|
type InferQueryParamsState<T> = T extends WritableSignal<infer U> ? U : never;
|
|
5774
6043
|
type SpecificCraftSetAllQueriesParamsStandaloneOutputs<Context extends ContextConstraints> = {
|
|
@@ -6192,8 +6461,12 @@ interface _Subscribable<T> {
|
|
|
6192
6461
|
*/
|
|
6193
6462
|
declare function craftSources<Context extends ContextConstraints, StoreConfig extends StoreConfigConstraints, Sources extends Record<string, SignalSource<any> | Source$<any> | _Subscribable<any>>>(sourcesFactory: () => Sources): CraftSourcesOutputs<Context, StoreConfig, Sources>;
|
|
6194
6463
|
|
|
6195
|
-
type
|
|
6196
|
-
type
|
|
6464
|
+
type Source$Method$2<SourceType> = [SourceType] extends [void] ? () => void : (value: SourceType) => void;
|
|
6465
|
+
type ExposedStateInsertions<Insertions> = MergeObject<IsEmptyObject<Insertions> extends true ? {} : FilterSource<Insertions>, {
|
|
6466
|
+
[K in keyof FilterSource<Insertions> as FilterSource<Insertions>[K] extends Source$<any> ? K : never]: FilterSource<Insertions>[K] extends Source$<infer SourceType> ? Source$Method$2<SourceType> : never;
|
|
6467
|
+
}>;
|
|
6468
|
+
type StateOutput<StateType, Insertions> = MergeObject<Signal<StateType>, ExposedStateInsertions<Insertions>>;
|
|
6469
|
+
type StateConfig<State> = State | Signal<State>;
|
|
6197
6470
|
/**
|
|
6198
6471
|
* Creates a signal state with optional insertions for adding methods and computed properties.
|
|
6199
6472
|
*
|
|
@@ -6201,7 +6474,11 @@ type StateConfig<State> = State | WritableSignal<State>;
|
|
|
6201
6474
|
* methods and properties through insertions. Each insertion receives a context object with
|
|
6202
6475
|
* `state`, `set`, `update` methods and previous insertions.
|
|
6203
6476
|
*
|
|
6204
|
-
* @
|
|
6477
|
+
* @remarks
|
|
6478
|
+
* For the best TypeScript inference, pass Angular `Signal` values (e.g. `signal`, `linkedSignal`)
|
|
6479
|
+
* rather than manually widening to `WritableSignal`. This avoids some overload inference limits.
|
|
6480
|
+
*
|
|
6481
|
+
* @param stateConfig - The initial state value or a Signal (e.g., linkedSignal)
|
|
6205
6482
|
* @param insertions - Optional insertion functions to extend the state with methods and properties
|
|
6206
6483
|
* @returns A Signal representing the state, merged with all insertion properties and methods
|
|
6207
6484
|
*
|
|
@@ -6274,7 +6551,7 @@ declare function state<StateType, Insertion1, Insertion2, Insertion3, Insertion4
|
|
|
6274
6551
|
declare function state<StateType, Insertion1, Insertion2, Insertion3, Insertion4, Insertion5, Insertion6>(stateConfig: StateConfig<StateType>, insertion1: InsertionsStateFactory<NoInfer<StateType>, Insertion1>, insertion2: InsertionsStateFactory<NoInfer<StateType>, Insertion2, Insertion1>, insertion3: InsertionsStateFactory<NoInfer<StateType>, Insertion3, Insertion1 & Insertion2>, insertion4: InsertionsStateFactory<NoInfer<StateType>, Insertion4, Insertion1 & Insertion2 & Insertion3>, insertion5: InsertionsStateFactory<NoInfer<StateType>, Insertion5, Insertion1 & Insertion2 & Insertion3 & Insertion4>, insertion6: InsertionsStateFactory<NoInfer<StateType>, Insertion6, Insertion1 & Insertion2 & Insertion3 & Insertion4 & Insertion5>): StateOutput<StateType, Insertion1 & Insertion2 & Insertion3 & Insertion4 & Insertion5 & Insertion6>;
|
|
6275
6552
|
declare function state<StateType, Insertion1, Insertion2, Insertion3, Insertion4, Insertion5, Insertion6, Insertion7>(stateConfig: StateConfig<StateType>, insertion1: InsertionsStateFactory<NoInfer<StateType>, Insertion1>, insertion2: InsertionsStateFactory<NoInfer<StateType>, Insertion2, Insertion1>, insertion3: InsertionsStateFactory<NoInfer<StateType>, Insertion3, Insertion1 & Insertion2>, insertion4: InsertionsStateFactory<NoInfer<StateType>, Insertion4, Insertion1 & Insertion2 & Insertion3>, insertion5: InsertionsStateFactory<NoInfer<StateType>, Insertion5, Insertion1 & Insertion2 & Insertion3 & Insertion4>, insertion6: InsertionsStateFactory<NoInfer<StateType>, Insertion6, Insertion1 & Insertion2 & Insertion3 & Insertion4 & Insertion5>, insertion7: InsertionsStateFactory<NoInfer<StateType>, Insertion7, Insertion1 & Insertion2 & Insertion3 & Insertion4 & Insertion5 & Insertion6>): StateOutput<StateType, Insertion1 & Insertion2 & Insertion3 & Insertion4 & Insertion5 & Insertion6 & Insertion7>;
|
|
6276
6553
|
|
|
6277
|
-
type SpecificCraftStateOutputs<StateName extends string, State, Insertions> = DeferredExtract<Insertions
|
|
6554
|
+
type SpecificCraftStateOutputs<StateName extends string, State, Insertions> = DeferredExtract<ExposedStateInsertions<Insertions>> extends infer Extracted ? Extracted extends {
|
|
6278
6555
|
props: unknown;
|
|
6279
6556
|
methods: Record<string, Function>;
|
|
6280
6557
|
} ? PartialContext<{
|
|
@@ -6794,7 +7071,7 @@ interface QueriesPersister {
|
|
|
6794
7071
|
* dataQuery.persister.runGarbageCollection();
|
|
6795
7072
|
* ```
|
|
6796
7073
|
*/
|
|
6797
|
-
declare function insertLocalStoragePersister<GroupIdentifier extends string, ResourceState extends object | undefined, ResourceParams, PreviousInsertionsOutputs, StateType, const CacheTime = 300000>(config: {
|
|
7074
|
+
declare function insertLocalStoragePersister<GroupIdentifier extends string, ResourceState extends object | undefined, ResourceParams, PreviousInsertionsOutputs, StateType, QueryExceptions extends ResourceExceptionConstraints, const CacheTime = 300000>(config: {
|
|
6798
7075
|
/** Name of your current store, it is mainly used as a prefix for localStorage keys */
|
|
6799
7076
|
storeName: string;
|
|
6800
7077
|
/** Key used to identify the specific data within the store */
|
|
@@ -6810,10 +7087,152 @@ declare function insertLocalStoragePersister<GroupIdentifier extends string, Res
|
|
|
6810
7087
|
* If not specified, the default is 5 minutes (300000 ms).
|
|
6811
7088
|
*/
|
|
6812
7089
|
cacheTime?: CacheTime;
|
|
6813
|
-
}): (
|
|
7090
|
+
}): (_context: unknown) => {
|
|
6814
7091
|
persister: QueriesPersister;
|
|
6815
7092
|
};
|
|
6816
7093
|
|
|
7094
|
+
/**
|
|
7095
|
+
* No-op insertion used to preserve contextual typing in insertion chains.
|
|
7096
|
+
*
|
|
7097
|
+
* Usage:
|
|
7098
|
+
* `insertSelect('grid', insertNoopTypingAnchor, insertSelect('row', ...))`
|
|
7099
|
+
*/
|
|
7100
|
+
declare function insertNoopTypingAnchor<StateType, PreviousInsertionsOutputs = {}>(_context: InsertionStateFactoryContext<StateType, PreviousInsertionsOutputs>): {};
|
|
7101
|
+
|
|
7102
|
+
type SelectedTarget<StateType, Name extends string> = StateType extends readonly (infer Item)[] ? Extract<Item, object> : StateType extends Record<string, unknown> ? Name extends keyof StateType ? StateType[Name] : never : never;
|
|
7103
|
+
type MergeInsertions$1<Insertions extends readonly unknown[], Acc = {}> = Insertions extends readonly [infer Head, ...infer Tail] ? MergeInsertions$1<Tail, Acc & Head> : Acc;
|
|
7104
|
+
type Source$Method$1<SourceType> = [SourceType] extends [void] ? () => void : (value: SourceType) => void;
|
|
7105
|
+
type ExposedInsertions<Insertions> = MergeObject<IsEmptyObject<Insertions> extends true ? {} : FilterSource<Insertions>, {
|
|
7106
|
+
[K in keyof FilterSource<Insertions> as FilterSource<Insertions>[K] extends Source$<any> ? K : never]: FilterSource<Insertions>[K] extends Source$<infer SourceType> ? Source$Method$1<SourceType> : never;
|
|
7107
|
+
}>;
|
|
7108
|
+
type SelectItemMethodName<Name extends string> = `select${Capitalize<Name>}`;
|
|
7109
|
+
type SelectPropertyMethodName<Name extends string> = `select${Capitalize<Name>}`;
|
|
7110
|
+
type SelectedItem<StateType> = StateType extends readonly (infer Item)[] ? Extract<Item, object> : never;
|
|
7111
|
+
type ArraySelectedOutput<StateType, Insertions> = MergeObject<SelectedItem<StateType>, ExposedInsertions<Insertions>>;
|
|
7112
|
+
type ObjectSelectedOutput<StateType, Name extends string, Insertions> = StateType extends Record<string, unknown> ? Name extends keyof StateType & string ? MergeObject<Extract<StateType[Name], object>, ExposedInsertions<Insertions>> : never : never;
|
|
7113
|
+
type ArrayInsertSelectOutput<StateType, Name extends string, Insertions extends readonly unknown[]> = {
|
|
7114
|
+
[K in SelectItemMethodName<Name>]: (id: number) => ArraySelectedOutput<StateType, MergeInsertions$1<Insertions>> | undefined;
|
|
7115
|
+
} & {
|
|
7116
|
+
items: () => Array<ArraySelectedOutput<StateType, MergeInsertions$1<Insertions>>>;
|
|
7117
|
+
};
|
|
7118
|
+
type ObjectInsertSelectOutput<StateType, Name extends string, Insertions extends readonly unknown[]> = {
|
|
7119
|
+
[K in SelectPropertyMethodName<Name>]: () => ObjectSelectedOutput<StateType, Name, MergeInsertions$1<Insertions>>;
|
|
7120
|
+
};
|
|
7121
|
+
type InsertSelectReturn<StateType, Name extends string, Insertions extends readonly unknown[], PreviousInsertionsOutputs> = InsertionsStateFactory<StateType, StateType extends readonly object[] ? ArrayInsertSelectOutput<StateType, Name, Insertions> : ObjectInsertSelectOutput<StateType, Name, Insertions>, PreviousInsertionsOutputs>;
|
|
7122
|
+
type IsArray$1<T> = T extends any[] ? true : false;
|
|
7123
|
+
/**
|
|
7124
|
+
* Unified selector insertion for nested object properties and array items.
|
|
7125
|
+
*
|
|
7126
|
+
* `insertSelect` lets you compose nested insertions with the same API regardless
|
|
7127
|
+
* of whether the current state is an object or an array.
|
|
7128
|
+
*
|
|
7129
|
+
* You interact with the selected sub-state through generated methods like:
|
|
7130
|
+
* - `selectCell()` for object properties
|
|
7131
|
+
* - `selectCell(index)` for array items
|
|
7132
|
+
* The returned selection exposes both the original state fields and the
|
|
7133
|
+
* insertion methods/computed values.
|
|
7134
|
+
*
|
|
7135
|
+
* @example
|
|
7136
|
+
* ```ts
|
|
7137
|
+
* const board = state(
|
|
7138
|
+
* {
|
|
7139
|
+
* cell: { color: 'white', paintCount: 0 },
|
|
7140
|
+
* },
|
|
7141
|
+
* insertSelect('cell', ({ update }) => ({
|
|
7142
|
+
* paintBlack: () =>
|
|
7143
|
+
* update((cell) => ({
|
|
7144
|
+
* ...cell,
|
|
7145
|
+
* color: 'black',
|
|
7146
|
+
* paintCount: cell.paintCount + 1,
|
|
7147
|
+
* })),
|
|
7148
|
+
* })),
|
|
7149
|
+
* );
|
|
7150
|
+
*
|
|
7151
|
+
* board.selectCell().paintBlack();
|
|
7152
|
+
* console.log(board.selectCell().color); // 'black'
|
|
7153
|
+
* ```
|
|
7154
|
+
*
|
|
7155
|
+
* @example
|
|
7156
|
+
* ```ts
|
|
7157
|
+
* const cells = state(
|
|
7158
|
+
* [{ color: 'white', paintCount: 0 }],
|
|
7159
|
+
* insertSelect('cell', ({ update }) => ({
|
|
7160
|
+
* paint: () =>
|
|
7161
|
+
* update((cell) => ({
|
|
7162
|
+
* ...cell,
|
|
7163
|
+
* color: 'black',
|
|
7164
|
+
* paintCount: cell.paintCount + 1,
|
|
7165
|
+
* })),
|
|
7166
|
+
* })),
|
|
7167
|
+
* );
|
|
7168
|
+
*
|
|
7169
|
+
* cells.selectCell(0)?.paint();
|
|
7170
|
+
* console.log(cells.selectCell(0)?.paintCount); // 1
|
|
7171
|
+
* ```
|
|
7172
|
+
*
|
|
7173
|
+
* In some nested cases, TypeScript may lose contextual typing (notably when a
|
|
7174
|
+
* property is an array and the next insertion is another `insertSelect`).
|
|
7175
|
+
* In those cases, insert `insertNoopTypingAnchor` before the nested insertion
|
|
7176
|
+
* to preserve inference.
|
|
7177
|
+
*
|
|
7178
|
+
* @example
|
|
7179
|
+
* ```ts
|
|
7180
|
+
* insertSelect(
|
|
7181
|
+
* 'grid',
|
|
7182
|
+
* insertNoopTypingAnchor,
|
|
7183
|
+
* insertSelect('row', ({ update }) => ({
|
|
7184
|
+
* // ...
|
|
7185
|
+
* })),
|
|
7186
|
+
* );
|
|
7187
|
+
* ```
|
|
7188
|
+
*/
|
|
7189
|
+
declare function insertSelect<StateType, const Name extends AutoCompleteName & string, Insertions1 = {}, PreviousInsertionsOutputs = {}, AutoCompleteName = NoInfer<StateType> extends readonly object[] ? string : keyof NoInfer<StateType>>(name: Name, insertion1: InsertionsStateFactory<SelectedTarget<StateType, Name>, Insertions1, PreviousInsertionsOutputs>): InsertSelectReturn<[
|
|
7190
|
+
Name
|
|
7191
|
+
] extends [keyof StateType] ? IsArray$1<StateType[Name]> extends true ? `craft-ng error, typing limitation: insertSelect does not currently support selecting items from an array property in first insertion position (e.g. insertSelect('grid', insertSelect('row', ...))). Consider using insertNoopTypingAnchor:
|
|
7192
|
+
insertSelect('${Name}', insertNoopTypingAnchor, insertSelect(...)) ` : StateType : StateType, Name, [
|
|
7193
|
+
Insertions1
|
|
7194
|
+
], PreviousInsertionsOutputs>;
|
|
7195
|
+
declare function insertSelect<StateType, const Name extends AutoCompleteName & string, Insertions1 = {}, Insertions2 = {}, PreviousInsertionsOutputs = {}, AutoCompleteName = StateType extends readonly object[] ? string : keyof StateType>(name: Name, insertion1: InsertionsStateFactory<SelectedTarget<StateType, Name>, Insertions1, PreviousInsertionsOutputs>, insertion2: InsertionsStateFactory<SelectedTarget<StateType, Name>, Insertions2, PreviousInsertionsOutputs & Insertions1>): InsertSelectReturn<StateType, Name, [
|
|
7196
|
+
Insertions1,
|
|
7197
|
+
Insertions2
|
|
7198
|
+
], PreviousInsertionsOutputs>;
|
|
7199
|
+
declare function insertSelect<StateType, const Name extends AutoCompleteName & string, Insertions1 = {}, Insertions2 = {}, Insertions3 = {}, PreviousInsertionsOutputs = {}, AutoCompleteName = StateType extends readonly object[] ? string : keyof StateType>(name: Name, insertion1: InsertionsStateFactory<SelectedTarget<StateType, Name>, Insertions1, PreviousInsertionsOutputs>, insertion2: InsertionsStateFactory<SelectedTarget<StateType, Name>, Insertions2, PreviousInsertionsOutputs & Insertions1>, insertion3: InsertionsStateFactory<SelectedTarget<StateType, Name>, Insertions3, PreviousInsertionsOutputs & Insertions1 & Insertions2>): InsertSelectReturn<StateType, Name, [
|
|
7200
|
+
Insertions1,
|
|
7201
|
+
Insertions2,
|
|
7202
|
+
Insertions3
|
|
7203
|
+
], PreviousInsertionsOutputs>;
|
|
7204
|
+
declare function insertSelect<StateType, const Name extends AutoCompleteName & string, Insertions1 = {}, Insertions2 = {}, Insertions3 = {}, Insertions4 = {}, PreviousInsertionsOutputs = {}, AutoCompleteName = StateType extends readonly object[] ? string : keyof StateType>(name: Name, insertion1: InsertionsStateFactory<SelectedTarget<StateType, Name>, Insertions1, PreviousInsertionsOutputs>, insertion2: InsertionsStateFactory<SelectedTarget<StateType, Name>, Insertions2, PreviousInsertionsOutputs & Insertions1>, insertion3: InsertionsStateFactory<SelectedTarget<StateType, Name>, Insertions3, PreviousInsertionsOutputs & Insertions1 & Insertions2>, insertion4: InsertionsStateFactory<SelectedTarget<StateType, Name>, Insertions4, PreviousInsertionsOutputs & Insertions1 & Insertions2 & Insertions3>): InsertSelectReturn<StateType, Name, [
|
|
7205
|
+
Insertions1,
|
|
7206
|
+
Insertions2,
|
|
7207
|
+
Insertions3,
|
|
7208
|
+
Insertions4
|
|
7209
|
+
], PreviousInsertionsOutputs>;
|
|
7210
|
+
declare function insertSelect<StateType, const Name extends AutoCompleteName & string, Insertions1 = {}, Insertions2 = {}, Insertions3 = {}, Insertions4 = {}, Insertions5 = {}, PreviousInsertionsOutputs = {}, AutoCompleteName = StateType extends readonly object[] ? string : keyof StateType>(name: Name, insertion1: InsertionsStateFactory<SelectedTarget<StateType, Name>, Insertions1, PreviousInsertionsOutputs>, insertion2: InsertionsStateFactory<SelectedTarget<StateType, Name>, Insertions2, PreviousInsertionsOutputs & Insertions1>, insertion3: InsertionsStateFactory<SelectedTarget<StateType, Name>, Insertions3, PreviousInsertionsOutputs & Insertions1 & Insertions2>, insertion4: InsertionsStateFactory<SelectedTarget<StateType, Name>, Insertions4, PreviousInsertionsOutputs & Insertions1 & Insertions2 & Insertions3>, insertion5: InsertionsStateFactory<SelectedTarget<StateType, Name>, Insertions5, PreviousInsertionsOutputs & Insertions1 & Insertions2 & Insertions3 & Insertions4>): InsertSelectReturn<StateType, Name, [
|
|
7211
|
+
Insertions1,
|
|
7212
|
+
Insertions2,
|
|
7213
|
+
Insertions3,
|
|
7214
|
+
Insertions4,
|
|
7215
|
+
Insertions5
|
|
7216
|
+
], PreviousInsertionsOutputs>;
|
|
7217
|
+
|
|
7218
|
+
type PublicServiceEntry<Entry> = Entry extends WritableSignal<any> ? Entry : Entry extends Signal<any> ? Entry : Entry extends (...args: infer Args) => infer Result ? (...args: Args) => Result : Entry;
|
|
7219
|
+
type InjectService2Public<Service> = Prettify<RemoveIndexSignature<{
|
|
7220
|
+
[K in keyof Service]: PublicServiceEntry<Service[K]>;
|
|
7221
|
+
}>>;
|
|
7222
|
+
type InjectService2Insertions<Service> = Prettify<Record<string, unknown> & {
|
|
7223
|
+
[K in keyof InjectService2Public<Service>]?: InjectService2Public<Service>[K] | SourceBranded;
|
|
7224
|
+
}>;
|
|
7225
|
+
type InjectService2InsertionContext<Service, PreviousInsertions = {}> = InjectService2Public<Service> & {
|
|
7226
|
+
insertions: HasKeys<PreviousInsertions> extends true ? PreviousInsertions : never;
|
|
7227
|
+
};
|
|
7228
|
+
type InjectService2InsertionFactory<Service, Insertions, PreviousInsertions = {}> = (context: InjectService2InsertionContext<Service, PreviousInsertions>) => InjectService2Insertions<Service> & Insertions;
|
|
7229
|
+
type InjectService2Output<Service, Insertions> = Prettify<FilterSource<Insertions>>;
|
|
7230
|
+
declare function injectService<Service, Insertion1>(token: Type<Service>, insertion1: InjectService2InsertionFactory<Service, Insertion1>): InjectService2Output<Service, Insertion1>;
|
|
7231
|
+
declare function injectService<Service, Insertion1, Insertion2>(token: Type<Service>, insertion1: InjectService2InsertionFactory<Service, Insertion1>, insertion2: InjectService2InsertionFactory<Service, Insertion2, Insertion1>): InjectService2Output<Service, Insertion1 & Insertion2>;
|
|
7232
|
+
declare function injectService<Service, Insertion1, Insertion2, Insertion3>(token: Type<Service>, insertion1: InjectService2InsertionFactory<Service, Insertion1>, insertion2: InjectService2InsertionFactory<Service, Insertion2, Insertion1>, insertion3: InjectService2InsertionFactory<Service, Insertion3, Insertion1 & Insertion2>): InjectService2Output<Service, Insertion1 & Insertion2 & Insertion3>;
|
|
7233
|
+
declare function injectService<Service, Insertion1, Insertion2, Insertion3, Insertion4>(token: Type<Service>, insertion1: InjectService2InsertionFactory<Service, Insertion1>, insertion2: InjectService2InsertionFactory<Service, Insertion2, Insertion1>, insertion3: InjectService2InsertionFactory<Service, Insertion3, Insertion1 & Insertion2>, insertion4: InjectService2InsertionFactory<Service, Insertion4, Insertion1 & Insertion2 & Insertion3>): InjectService2Output<Service, Insertion1 & Insertion2 & Insertion3 & Insertion4>;
|
|
7234
|
+
declare function injectService<Service, Insertion1, Insertion2, Insertion3, Insertion4, Insertion5>(token: Type<Service>, insertion1: InjectService2InsertionFactory<Service, Insertion1>, insertion2: InjectService2InsertionFactory<Service, Insertion2, Insertion1>, insertion3: InjectService2InsertionFactory<Service, Insertion3, Insertion1 & Insertion2>, insertion4: InjectService2InsertionFactory<Service, Insertion4, Insertion1 & Insertion2 & Insertion3>, insertion5: InjectService2InsertionFactory<Service, Insertion5, Insertion1 & Insertion2 & Insertion3 & Insertion4>): InjectService2Output<Service, Insertion1 & Insertion2 & Insertion3 & Insertion4 & Insertion5>;
|
|
7235
|
+
|
|
6817
7236
|
declare function linkedSource<SourceState, ComputedValue>(signalOrigin: SignalSource<SourceState> | ReadonlySource<SourceState>, computedFn: (sourceValue: NoInfer<SourceState>) => ComputedValue, options?: {
|
|
6818
7237
|
equal?: ValueEqualityFn<NoInfer<ComputedValue> | undefined>;
|
|
6819
7238
|
debugName?: string;
|
|
@@ -7501,6 +7920,35 @@ declare function toSource<SourceState, ComputedValue>(signalOrigin: Signal<Sourc
|
|
|
7501
7920
|
debugName?: string;
|
|
7502
7921
|
}): ReadonlySource<IsUnknown<ComputedValue> extends true ? SourceState : ComputedValue>;
|
|
7503
7922
|
|
|
7923
|
+
type EntryBindings<Service> = Prettify<Partial<{
|
|
7924
|
+
[K in keyof Service as K extends `${infer EntryKey}Entry` ? Service[K] extends WritableSignal<infer Value> ? EntryKey : never : never]: Service[K] extends WritableSignal<infer Value> ? Signal<Value> : never;
|
|
7925
|
+
}>>;
|
|
7926
|
+
type ToInjectBindings<Service> = EntryBindings<Service>;
|
|
7927
|
+
/**
|
|
7928
|
+
* Creates an Angular `inject()` helper bound to a service and keeps selected
|
|
7929
|
+
* `...Entry` writable signals synchronized with external signals.
|
|
7930
|
+
*
|
|
7931
|
+
* Service properties ending with `Entry` are exposed as configuration keys
|
|
7932
|
+
* without the suffix.
|
|
7933
|
+
*
|
|
7934
|
+
* @example
|
|
7935
|
+
* ```ts
|
|
7936
|
+
* @Injectable({ providedIn: 'root' })
|
|
7937
|
+
* class MyService {
|
|
7938
|
+
* myIdEntry = signal<string | undefined>(undefined);
|
|
7939
|
+
* }
|
|
7940
|
+
*
|
|
7941
|
+
* const injectMyService = toInject(MyService);
|
|
7942
|
+
*
|
|
7943
|
+
* @Component({})
|
|
7944
|
+
* class MyComponent {
|
|
7945
|
+
* id = input<string>();
|
|
7946
|
+
* myService = injectMyService({ myId: this.id });
|
|
7947
|
+
* }
|
|
7948
|
+
* ```
|
|
7949
|
+
*/
|
|
7950
|
+
declare function toInject<Service>(token: Type<Service>): (bindings?: ToInjectBindings<Service>) => Service;
|
|
7951
|
+
|
|
7504
7952
|
/**
|
|
7505
7953
|
* Creates an insertion function that makes a query react to mutation state changes.
|
|
7506
7954
|
*
|
|
@@ -7717,14 +8165,14 @@ declare function toSource<SourceState, ComputedValue>(signalOrigin: Signal<Sourc
|
|
|
7717
8165
|
* });
|
|
7718
8166
|
* ```
|
|
7719
8167
|
*/
|
|
7720
|
-
declare function insertReactOnMutation<QueryResourceState extends object | undefined, QueryResourceParams, QueryResourceArgsParams, QueryIsMethod extends boolean, QuerySourceParams, QueryGroupIdentifier, QueryInsertions, MutationResourceState, MutationResourceParams, MutationResourceArgsParams, MutationIsMethod, MutationSourceParams, MutationGroupIdentifier, MutationInsertions>(mutation: ResourceLikeMutationRef<MutationResourceState, MutationResourceParams, MutationIsMethod, MutationResourceArgsParams, MutationSourceParams, MutationInsertions> | ResourceByIdLikeMutationRef<MutationResourceState, MutationResourceParams, MutationIsMethod, MutationResourceArgsParams, MutationSourceParams, MutationInsertions, MutationGroupIdentifier>, mutationEffectOptions: QueryDeclarativeEffect<{
|
|
8168
|
+
declare function insertReactOnMutation<QueryResourceState extends object | undefined, QueryResourceParams, QueryResourceArgsParams, QueryIsMethod extends boolean, QuerySourceParams, QueryGroupIdentifier, QueryInsertions, MutationResourceState, MutationResourceParams, MutationResourceArgsParams, MutationIsMethod, MutationSourceParams, MutationGroupIdentifier, MutationInsertions, MutationExceptions extends ResourceExceptionConstraints, QueryExceptions extends ResourceExceptionConstraints>(mutation: ResourceLikeMutationRef<MutationResourceState, MutationResourceParams, MutationIsMethod, MutationResourceArgsParams, MutationSourceParams, MutationInsertions, MutationExceptions> | ResourceByIdLikeMutationRef<MutationResourceState, MutationResourceParams, MutationIsMethod, MutationResourceArgsParams, MutationSourceParams, MutationInsertions, MutationGroupIdentifier, MutationExceptions>, mutationEffectOptions: QueryDeclarativeEffect<{
|
|
7721
8169
|
query: InternalType<NoInfer<QueryResourceState>, NoInfer<QueryResourceParams>, NoInfer<QueryResourceArgsParams>, [
|
|
7722
8170
|
unknown
|
|
7723
|
-
] extends [NoInfer<QueryGroupIdentifier>] ? false : true, NoInfer<QueryIsMethod>, NoInfer<QueryInsertions>, NoInfer<QueryGroupIdentifier>, NoInfer<QuerySourceParams>>;
|
|
8171
|
+
] extends [NoInfer<QueryGroupIdentifier>] ? false : true, NoInfer<QueryIsMethod>, NoInfer<QueryInsertions>, NoInfer<QueryGroupIdentifier>, NoInfer<QuerySourceParams>, NoInfer<QueryExceptions>>;
|
|
7724
8172
|
mutation: InternalType<NoInfer<MutationResourceState>, NoInfer<MutationResourceParams>, NoInfer<MutationResourceArgsParams>, [
|
|
7725
8173
|
unknown
|
|
7726
|
-
] extends [MutationGroupIdentifier] ? false : true, NoInfer<MutationIsMethod>, NoInfer<MutationInsertions>, NoInfer<MutationGroupIdentifier>, NoInfer<MutationSourceParams>>;
|
|
7727
|
-
}>): (context: InsertionParams<QueryResourceState, QueryResourceParams, QueryInsertions> | {
|
|
8174
|
+
] extends [MutationGroupIdentifier] ? false : true, NoInfer<MutationIsMethod>, NoInfer<MutationInsertions>, NoInfer<MutationGroupIdentifier>, NoInfer<MutationSourceParams>, NoInfer<MutationExceptions>>;
|
|
8175
|
+
}>): (context: InsertionParams<QueryResourceState, QueryResourceParams, QueryExceptions, QueryInsertions> | {
|
|
7728
8176
|
resourceById: ResourceByIdRef<QueryGroupIdentifier & string, QueryResourceState, QueryResourceParams>;
|
|
7729
8177
|
resourceParamsSrc: WritableSignal<QueryResourceParams | undefined>;
|
|
7730
8178
|
identifier: (params: NonNullable<QueryResourceParams>) => QueryGroupIdentifier;
|
|
@@ -7763,7 +8211,7 @@ declare function insertReactOnMutation<QueryResourceState extends object | undef
|
|
|
7763
8211
|
* const isPlaceholder = userQuery.isPlaceHolderData();
|
|
7764
8212
|
* ```
|
|
7765
8213
|
*/
|
|
7766
|
-
declare const insertPaginationPlaceholderData: <QueryResourceState extends object | undefined, QueryResourceParams, QueryResourceArgsParams, QueryIsMethod extends boolean, QuerySourceParams, QueryGroupIdentifier extends string, QueryInsertions, PreviousInsertionsOutputs>({ resourceById, resourceParamsSrc, identifier, }: InsertionByIdParams<QueryGroupIdentifier, QueryResourceState, QueryResourceParams, PreviousInsertionsOutputs>) => {
|
|
8214
|
+
declare const insertPaginationPlaceholderData: <QueryResourceState extends object | undefined, QueryResourceParams, QueryResourceArgsParams, QueryIsMethod extends boolean, QuerySourceParams, QueryGroupIdentifier extends string, QueryInsertions, PreviousInsertionsOutputs, Exceptions extends ResourceExceptionConstraints>({ resourceById, resourceParamsSrc, identifier, }: InsertionByIdParams<QueryGroupIdentifier, QueryResourceState, QueryResourceParams, Exceptions, PreviousInsertionsOutputs>) => {
|
|
7767
8215
|
currentPageData: _angular_core.Signal<QueryResourceState | undefined>;
|
|
7768
8216
|
currentPageStatus: _angular_core.Signal<_angular_core.ResourceStatus>;
|
|
7769
8217
|
isPlaceHolderData: _angular_core.Signal<boolean>;
|
|
@@ -8442,5 +8890,380 @@ declare function on$<State, SourceType>(_source: {
|
|
|
8442
8890
|
subscribe: EventEmitter<SourceType>['subscribe'];
|
|
8443
8891
|
}, callback: (source: SourceType) => State): SourceBranded;
|
|
8444
8892
|
|
|
8445
|
-
|
|
8446
|
-
|
|
8893
|
+
type Source$Method<SourceType> = [SourceType] extends [void] ? () => void : (value: SourceType) => void;
|
|
8894
|
+
type ExposedFormInsertions<Insertions> = MergeObject<IsEmptyObject<Insertions> extends true ? {} : FilterSource<Insertions>, {
|
|
8895
|
+
[K in keyof FilterSource<Insertions> as FilterSource<Insertions>[K] extends Source$<any> ? K : never]: FilterSource<Insertions>[K] extends Source$<infer SourceType> ? Source$Method<SourceType> : never;
|
|
8896
|
+
}>;
|
|
8897
|
+
type FormExceptionSignal<Insertions, ExceptionName extends string> = `${Uncapitalize<ExceptionName>}Exceptions` extends keyof ExposedFormInsertions<Insertions> ? ExposedFormInsertions<Insertions>[`${Uncapitalize<ExceptionName>}Exceptions`] extends Signal<infer Exceptions> ? Exceptions : never : never;
|
|
8898
|
+
type HasFormExceptionSignalPair<Insertions, ExceptionName extends string, HasExceptionKey extends keyof ExposedFormInsertions<Insertions>> = ExposedFormInsertions<Insertions>[HasExceptionKey] extends Signal<boolean> ? `${Uncapitalize<ExceptionName>}Exceptions` extends keyof ExposedFormInsertions<Insertions> ? ExposedFormInsertions<Insertions>[`${Uncapitalize<ExceptionName>}Exceptions`] extends Signal<unknown> ? true : false : false : false;
|
|
8899
|
+
type FormExceptionMap<Insertions> = {
|
|
8900
|
+
[K in keyof ExposedFormInsertions<Insertions> as K extends string ? K extends `has${infer Name}Exceptions` ? HasFormExceptionSignalPair<Insertions, Name, K> extends true ? Uncapitalize<Name> : never : never : never]: K extends `has${infer Name}Exceptions` ? FormExceptionSignal<Insertions, Name> : never;
|
|
8901
|
+
};
|
|
8902
|
+
type FormExceptionsInsertion<Insertions> = keyof FormExceptionMap<Insertions> extends never ? {} : {
|
|
8903
|
+
hasExceptions: Signal<boolean>;
|
|
8904
|
+
exceptions: Signal<FormExceptionMap<Insertions>>;
|
|
8905
|
+
};
|
|
8906
|
+
type CraftFieldTree<TModel, Insertions, TKey extends string | number = string | number> = (() => [TModel] extends [AbstractControl] ? CompatFieldState<TModel, TKey> & Insertions : FieldState<TModel, TKey> & Insertions) & ([TModel] extends [AbstractControl] ? object : [TModel] extends [ReadonlyArray<infer U>] ? ReadonlyArrayLike<MaybeFieldTree<U, number>> : TModel extends Record<string, any> ? Subfields<TModel> : object);
|
|
8907
|
+
type FormWithInsertions<Model, Insertions> = CraftFieldTree<Model, ExposedFormInsertions<Insertions> & {
|
|
8908
|
+
hasAttemptedSubmit: Signal<boolean>;
|
|
8909
|
+
validatedFormValue: Signal<ValidatedFormValue<Model>>;
|
|
8910
|
+
} & FormExceptionsInsertion<Insertions>, string | number>;
|
|
8911
|
+
type InsertionFormFactoryContext<StateType, PreviousInsertionsOutputs, FormIdentifier extends string | number | unknown> = InsertionStateFactoryContext<StateType, PreviousInsertionsOutputs> & {
|
|
8912
|
+
form: FieldTree<StateType, string | number>;
|
|
8913
|
+
schemaPath: SchemaPathTree<StateType>;
|
|
8914
|
+
validatedFormValue: Signal<ValidatedFormValue<StateType>>;
|
|
8915
|
+
validatorModelRef: Signal<StateType>;
|
|
8916
|
+
setValidatorModelRef: (nextModel: Signal<StateType>) => void;
|
|
8917
|
+
setAttemptedSubmit: () => void;
|
|
8918
|
+
setSubmitting: (submitting: boolean) => void;
|
|
8919
|
+
formIdentifier: FormIdentifier;
|
|
8920
|
+
};
|
|
8921
|
+
type InsertionsFormFactory<State, FormIdentifier extends string | number | unknown, InsertionsOutputs, PreviousInsertionsOutputs = {}> = (context: InsertionFormFactoryContext<State, PreviousInsertionsOutputs, FormIdentifier>) => InsertionsOutputs;
|
|
8922
|
+
declare const validatedFormValueSymbol: unique symbol;
|
|
8923
|
+
type ValidatedFormValue<FormValue> = (FormValue & {
|
|
8924
|
+
[validatedFormValueSymbol]: true;
|
|
8925
|
+
}) | undefined;
|
|
8926
|
+
|
|
8927
|
+
type ExtractItemType$1<T> = T extends readonly (infer Item)[] ? Item : never;
|
|
8928
|
+
type InsertFormSimpleOutput<StateType, Insertions> = {
|
|
8929
|
+
form: FormWithInsertions<StateType, Insertions>;
|
|
8930
|
+
};
|
|
8931
|
+
type InsertFormParallelOutput<StateType, Insertions> = {
|
|
8932
|
+
forms: Signal<FieldTree<ExtractItemType$1<StateType>, string | number>[]>;
|
|
8933
|
+
select: (formIdentifier: string | number) => FormWithInsertions<ExtractItemType$1<StateType>, Insertions>;
|
|
8934
|
+
};
|
|
8935
|
+
type InsertFormSimpleReturn<StateType, Insertions, PreviousInsertionsOutputs> = InsertionsStateFactory<StateType, InsertFormSimpleOutput<StateType, Insertions>, PreviousInsertionsOutputs>;
|
|
8936
|
+
type InsertFormParallelReturn<StateType, Insertions, PreviousInsertionsOutputs> = InsertionsStateFactory<StateType, InsertFormParallelOutput<StateType, Insertions>, PreviousInsertionsOutputs>;
|
|
8937
|
+
type ParallelInsertFormConfig<ItemType, GroupIdentifier extends string | number> = {
|
|
8938
|
+
identifier: (context: {
|
|
8939
|
+
item: ItemType;
|
|
8940
|
+
index: number;
|
|
8941
|
+
}) => GroupIdentifier;
|
|
8942
|
+
};
|
|
8943
|
+
declare function insertForm<StateType, PreviousInsertionsOutputs = {}>(): InsertFormSimpleReturn<StateType, {}, PreviousInsertionsOutputs>;
|
|
8944
|
+
declare function insertForm<StateType, Insertion1, PreviousInsertionsOutputs = {}>(insertion1: InsertionsFormFactory<StateType, unknown, Insertion1, PreviousInsertionsOutputs>): InsertFormSimpleReturn<StateType, Insertion1, PreviousInsertionsOutputs>;
|
|
8945
|
+
declare function insertForm<StateType, Insertion1, Insertion2, PreviousInsertionsOutputs = {}>(insertion1: InsertionsFormFactory<StateType, unknown, Insertion1, PreviousInsertionsOutputs>, insertion2: InsertionsFormFactory<StateType, unknown, Insertion2, PreviousInsertionsOutputs & Insertion1>): InsertFormSimpleReturn<StateType, Insertion1 & Insertion2, PreviousInsertionsOutputs>;
|
|
8946
|
+
declare function insertForm<StateType, Insertion1, Insertion2, Insertion3, PreviousInsertionsOutputs = {}>(insertion1: InsertionsFormFactory<StateType, unknown, Insertion1, PreviousInsertionsOutputs>, insertion2: InsertionsFormFactory<StateType, unknown, Insertion2, PreviousInsertionsOutputs & Insertion1>, insertion3: InsertionsFormFactory<StateType, unknown, Insertion3, PreviousInsertionsOutputs & Insertion1 & Insertion2>): InsertFormSimpleReturn<StateType, Insertion1 & Insertion2 & Insertion3, PreviousInsertionsOutputs>;
|
|
8947
|
+
declare function insertForm<StateType, Insertion1, Insertion2, Insertion3, Insertion4, PreviousInsertionsOutputs = {}>(insertion1: InsertionsFormFactory<StateType, unknown, Insertion1, PreviousInsertionsOutputs>, insertion2: InsertionsFormFactory<StateType, unknown, Insertion2, PreviousInsertionsOutputs & Insertion1>, insertion3: InsertionsFormFactory<StateType, unknown, Insertion3, PreviousInsertionsOutputs & Insertion1 & Insertion2>, insertion4: InsertionsFormFactory<StateType, unknown, Insertion4, PreviousInsertionsOutputs & Insertion1 & Insertion2 & Insertion3>): InsertFormSimpleReturn<StateType, Insertion1 & Insertion2 & Insertion3 & Insertion4, PreviousInsertionsOutputs>;
|
|
8948
|
+
declare function insertForm<StateType, Insertion1, Insertion2, Insertion3, Insertion4, Insertion5, PreviousInsertionsOutputs = {}>(insertion1: InsertionsFormFactory<StateType, unknown, Insertion1, PreviousInsertionsOutputs>, insertion2: InsertionsFormFactory<StateType, unknown, Insertion2, PreviousInsertionsOutputs & Insertion1>, insertion3: InsertionsFormFactory<StateType, unknown, Insertion3, PreviousInsertionsOutputs & Insertion1 & Insertion2>, insertion4: InsertionsFormFactory<StateType, unknown, Insertion4, PreviousInsertionsOutputs & Insertion1 & Insertion2 & Insertion3>, insertion5: InsertionsFormFactory<StateType, unknown, Insertion5, PreviousInsertionsOutputs & Insertion1 & Insertion2 & Insertion3 & Insertion4>): InsertFormSimpleReturn<StateType, Insertion1 & Insertion2 & Insertion3 & Insertion4 & Insertion5, PreviousInsertionsOutputs>;
|
|
8949
|
+
declare function insertForm<StateType, Insertion1, Insertion2, Insertion3, Insertion4, Insertion5, Insertion6, PreviousInsertionsOutputs = {}>(insertion1: InsertionsFormFactory<StateType, unknown, Insertion1, PreviousInsertionsOutputs>, insertion2: InsertionsFormFactory<StateType, unknown, Insertion2, PreviousInsertionsOutputs & Insertion1>, insertion3: InsertionsFormFactory<StateType, unknown, Insertion3, PreviousInsertionsOutputs & Insertion1 & Insertion2>, insertion4: InsertionsFormFactory<StateType, unknown, Insertion4, PreviousInsertionsOutputs & Insertion1 & Insertion2 & Insertion3>, insertion5: InsertionsFormFactory<StateType, unknown, Insertion5, PreviousInsertionsOutputs & Insertion1 & Insertion2 & Insertion3 & Insertion4>, insertion6: InsertionsFormFactory<StateType, unknown, Insertion6, PreviousInsertionsOutputs & Insertion1 & Insertion2 & Insertion3 & Insertion4 & Insertion5>): InsertFormSimpleReturn<StateType, Insertion1 & Insertion2 & Insertion3 & Insertion4 & Insertion5 & Insertion6, PreviousInsertionsOutputs>;
|
|
8950
|
+
declare function insertForm<StateType, Insertion1, Insertion2, Insertion3, Insertion4, Insertion5, Insertion6, Insertion7, PreviousInsertionsOutputs = {}>(insertion1: InsertionsFormFactory<StateType, unknown, Insertion1, PreviousInsertionsOutputs>, insertion2: InsertionsFormFactory<StateType, unknown, Insertion2, PreviousInsertionsOutputs & Insertion1>, insertion3: InsertionsFormFactory<StateType, unknown, Insertion3, PreviousInsertionsOutputs & Insertion1 & Insertion2>, insertion4: InsertionsFormFactory<StateType, unknown, Insertion4, PreviousInsertionsOutputs & Insertion1 & Insertion2 & Insertion3>, insertion5: InsertionsFormFactory<StateType, unknown, Insertion5, PreviousInsertionsOutputs & Insertion1 & Insertion2 & Insertion3 & Insertion4>, insertion6: InsertionsFormFactory<StateType, unknown, Insertion6, PreviousInsertionsOutputs & Insertion1 & Insertion2 & Insertion3 & Insertion4 & Insertion5>, insertion7: InsertionsFormFactory<StateType, unknown, Insertion7, PreviousInsertionsOutputs & Insertion1 & Insertion2 & Insertion3 & Insertion4 & Insertion5 & Insertion6>): InsertFormSimpleReturn<StateType, Insertion1 & Insertion2 & Insertion3 & Insertion4 & Insertion5 & Insertion6 & Insertion7, PreviousInsertionsOutputs>;
|
|
8951
|
+
declare function insertForm<StateType, Insertion1, Insertion2, Insertion3, Insertion4, Insertion5, Insertion6, Insertion7, Insertion8, PreviousInsertionsOutputs = {}>(insertion1: InsertionsFormFactory<StateType, unknown, Insertion1, PreviousInsertionsOutputs>, insertion2: InsertionsFormFactory<StateType, unknown, Insertion2, PreviousInsertionsOutputs & Insertion1>, insertion3: InsertionsFormFactory<StateType, unknown, Insertion3, PreviousInsertionsOutputs & Insertion1 & Insertion2>, insertion4: InsertionsFormFactory<StateType, unknown, Insertion4, PreviousInsertionsOutputs & Insertion1 & Insertion2 & Insertion3>, insertion5: InsertionsFormFactory<StateType, unknown, Insertion5, PreviousInsertionsOutputs & Insertion1 & Insertion2 & Insertion3 & Insertion4>, insertion6: InsertionsFormFactory<StateType, unknown, Insertion6, PreviousInsertionsOutputs & Insertion1 & Insertion2 & Insertion3 & Insertion4 & Insertion5>, insertion7: InsertionsFormFactory<StateType, unknown, Insertion7, PreviousInsertionsOutputs & Insertion1 & Insertion2 & Insertion3 & Insertion4 & Insertion5 & Insertion6>, insertion8: InsertionsFormFactory<StateType, unknown, Insertion8, PreviousInsertionsOutputs & Insertion1 & Insertion2 & Insertion3 & Insertion4 & Insertion5 & Insertion6 & Insertion7>): InsertFormSimpleReturn<StateType, Insertion1 & Insertion2 & Insertion3 & Insertion4 & Insertion5 & Insertion6 & Insertion7 & Insertion8, PreviousInsertionsOutputs>;
|
|
8952
|
+
declare function insertForm<StateType, Insertion1, Insertion2, Insertion3, Insertion4, Insertion5, Insertion6, Insertion7, Insertion8, Insertion9, PreviousInsertionsOutputs = {}>(insertion1: InsertionsFormFactory<StateType, unknown, Insertion1, PreviousInsertionsOutputs>, insertion2: InsertionsFormFactory<StateType, unknown, Insertion2, PreviousInsertionsOutputs & Insertion1>, insertion3: InsertionsFormFactory<StateType, unknown, Insertion3, PreviousInsertionsOutputs & Insertion1 & Insertion2>, insertion4: InsertionsFormFactory<StateType, unknown, Insertion4, PreviousInsertionsOutputs & Insertion1 & Insertion2 & Insertion3>, insertion5: InsertionsFormFactory<StateType, unknown, Insertion5, PreviousInsertionsOutputs & Insertion1 & Insertion2 & Insertion3 & Insertion4>, insertion6: InsertionsFormFactory<StateType, unknown, Insertion6, PreviousInsertionsOutputs & Insertion1 & Insertion2 & Insertion3 & Insertion4 & Insertion5>, insertion7: InsertionsFormFactory<StateType, unknown, Insertion7, PreviousInsertionsOutputs & Insertion1 & Insertion2 & Insertion3 & Insertion4 & Insertion5 & Insertion6>, insertion8: InsertionsFormFactory<StateType, unknown, Insertion8, PreviousInsertionsOutputs & Insertion1 & Insertion2 & Insertion3 & Insertion4 & Insertion5 & Insertion6 & Insertion7>, insertion9: InsertionsFormFactory<StateType, unknown, Insertion9, PreviousInsertionsOutputs & Insertion1 & Insertion2 & Insertion3 & Insertion4 & Insertion5 & Insertion6 & Insertion7 & Insertion8>): InsertFormSimpleReturn<StateType, Insertion1 & Insertion2 & Insertion3 & Insertion4 & Insertion5 & Insertion6 & Insertion7 & Insertion8 & Insertion9, PreviousInsertionsOutputs>;
|
|
8953
|
+
declare function insertForm<StateType, Insertion1, Insertion2, Insertion3, Insertion4, Insertion5, Insertion6, Insertion7, Insertion8, Insertion9, Insertion10, PreviousInsertionsOutputs = {}>(insertion1: InsertionsFormFactory<StateType, unknown, Insertion1, PreviousInsertionsOutputs>, insertion2: InsertionsFormFactory<StateType, unknown, Insertion2, PreviousInsertionsOutputs & Insertion1>, insertion3: InsertionsFormFactory<StateType, unknown, Insertion3, PreviousInsertionsOutputs & Insertion1 & Insertion2>, insertion4: InsertionsFormFactory<StateType, unknown, Insertion4, PreviousInsertionsOutputs & Insertion1 & Insertion2 & Insertion3>, insertion5: InsertionsFormFactory<StateType, unknown, Insertion5, PreviousInsertionsOutputs & Insertion1 & Insertion2 & Insertion3 & Insertion4>, insertion6: InsertionsFormFactory<StateType, unknown, Insertion6, PreviousInsertionsOutputs & Insertion1 & Insertion2 & Insertion3 & Insertion4 & Insertion5>, insertion7: InsertionsFormFactory<StateType, unknown, Insertion7, PreviousInsertionsOutputs & Insertion1 & Insertion2 & Insertion3 & Insertion4 & Insertion5 & Insertion6>, insertion8: InsertionsFormFactory<StateType, unknown, Insertion8, PreviousInsertionsOutputs & Insertion1 & Insertion2 & Insertion3 & Insertion4 & Insertion5 & Insertion6 & Insertion7>, insertion9: InsertionsFormFactory<StateType, unknown, Insertion9, PreviousInsertionsOutputs & Insertion1 & Insertion2 & Insertion3 & Insertion4 & Insertion5 & Insertion6 & Insertion7 & Insertion8>, insertion10: InsertionsFormFactory<StateType, unknown, Insertion10, PreviousInsertionsOutputs & Insertion1 & Insertion2 & Insertion3 & Insertion4 & Insertion5 & Insertion6 & Insertion7 & Insertion8 & Insertion9>): InsertFormSimpleReturn<StateType, Insertion1 & Insertion2 & Insertion3 & Insertion4 & Insertion5 & Insertion6 & Insertion7 & Insertion8 & Insertion9 & Insertion10, PreviousInsertionsOutputs>;
|
|
8954
|
+
declare function insertForm<StateType extends unknown[], GroupIdentifier extends string | number, PreviousInsertionsOutputs = {}>(config: ParallelInsertFormConfig<ExtractItemType$1<StateType>, GroupIdentifier>): InsertFormParallelReturn<StateType, {}, PreviousInsertionsOutputs>;
|
|
8955
|
+
declare function insertForm<StateType extends unknown[], GroupIdentifier extends string | number, Insertion1, PreviousInsertionsOutputs = {}>(config: ParallelInsertFormConfig<ExtractItemType$1<StateType>, GroupIdentifier>, insertion1: InsertionsFormFactory<ExtractItemType$1<StateType>, GroupIdentifier, Insertion1, PreviousInsertionsOutputs>): InsertFormParallelReturn<StateType, Insertion1, PreviousInsertionsOutputs>;
|
|
8956
|
+
declare function insertForm<StateType extends unknown[], GroupIdentifier extends string | number, Insertion1, Insertion2, PreviousInsertionsOutputs = {}>(config: ParallelInsertFormConfig<ExtractItemType$1<StateType>, GroupIdentifier>, insertion1: InsertionsFormFactory<ExtractItemType$1<StateType>, GroupIdentifier, Insertion1, PreviousInsertionsOutputs>, insertion2: InsertionsFormFactory<ExtractItemType$1<StateType>, GroupIdentifier, Insertion2, PreviousInsertionsOutputs & Insertion1>): InsertFormParallelReturn<StateType, Insertion1 & Insertion2, PreviousInsertionsOutputs>;
|
|
8957
|
+
declare function insertForm<StateType extends unknown[], GroupIdentifier extends string | number, Insertion1, Insertion2, Insertion3, PreviousInsertionsOutputs = {}>(config: ParallelInsertFormConfig<ExtractItemType$1<StateType>, GroupIdentifier>, insertion1: InsertionsFormFactory<ExtractItemType$1<StateType>, GroupIdentifier, Insertion1, PreviousInsertionsOutputs>, insertion2: InsertionsFormFactory<ExtractItemType$1<StateType>, GroupIdentifier, Insertion2, PreviousInsertionsOutputs & Insertion1>, insertion3: InsertionsFormFactory<ExtractItemType$1<StateType>, GroupIdentifier, Insertion3, PreviousInsertionsOutputs & Insertion1 & Insertion2>): InsertFormParallelReturn<StateType, Insertion1 & Insertion2 & Insertion3, PreviousInsertionsOutputs>;
|
|
8958
|
+
declare function insertForm<StateType extends unknown[], GroupIdentifier extends string | number, Insertion1, Insertion2, Insertion3, Insertion4, PreviousInsertionsOutputs = {}>(config: ParallelInsertFormConfig<ExtractItemType$1<StateType>, GroupIdentifier>, insertion1: InsertionsFormFactory<ExtractItemType$1<StateType>, GroupIdentifier, Insertion1, PreviousInsertionsOutputs>, insertion2: InsertionsFormFactory<ExtractItemType$1<StateType>, GroupIdentifier, Insertion2, PreviousInsertionsOutputs & Insertion1>, insertion3: InsertionsFormFactory<ExtractItemType$1<StateType>, GroupIdentifier, Insertion3, PreviousInsertionsOutputs & Insertion1 & Insertion2>, insertion4: InsertionsFormFactory<ExtractItemType$1<StateType>, GroupIdentifier, Insertion4, PreviousInsertionsOutputs & Insertion1 & Insertion2 & Insertion3>): InsertFormParallelReturn<StateType, Insertion1 & Insertion2 & Insertion3 & Insertion4, PreviousInsertionsOutputs>;
|
|
8959
|
+
declare function insertForm<StateType extends unknown[], GroupIdentifier extends string | number, Insertion1, Insertion2, Insertion3, Insertion4, Insertion5, PreviousInsertionsOutputs = {}>(config: ParallelInsertFormConfig<ExtractItemType$1<StateType>, GroupIdentifier>, insertion1: InsertionsFormFactory<ExtractItemType$1<StateType>, GroupIdentifier, Insertion1, PreviousInsertionsOutputs>, insertion2: InsertionsFormFactory<ExtractItemType$1<StateType>, GroupIdentifier, Insertion2, PreviousInsertionsOutputs & Insertion1>, insertion3: InsertionsFormFactory<ExtractItemType$1<StateType>, GroupIdentifier, Insertion3, PreviousInsertionsOutputs & Insertion1 & Insertion2>, insertion4: InsertionsFormFactory<ExtractItemType$1<StateType>, GroupIdentifier, Insertion4, PreviousInsertionsOutputs & Insertion1 & Insertion2 & Insertion3>, insertion5: InsertionsFormFactory<ExtractItemType$1<StateType>, GroupIdentifier, Insertion5, PreviousInsertionsOutputs & Insertion1 & Insertion2 & Insertion3 & Insertion4>): InsertFormParallelReturn<StateType, Insertion1 & Insertion2 & Insertion3 & Insertion4 & Insertion5, PreviousInsertionsOutputs>;
|
|
8960
|
+
declare function insertForm<StateType extends unknown[], GroupIdentifier extends string | number, Insertion1, Insertion2, Insertion3, Insertion4, Insertion5, Insertion6, PreviousInsertionsOutputs = {}>(config: ParallelInsertFormConfig<ExtractItemType$1<StateType>, GroupIdentifier>, insertion1: InsertionsFormFactory<ExtractItemType$1<StateType>, GroupIdentifier, Insertion1, PreviousInsertionsOutputs>, insertion2: InsertionsFormFactory<ExtractItemType$1<StateType>, GroupIdentifier, Insertion2, PreviousInsertionsOutputs & Insertion1>, insertion3: InsertionsFormFactory<ExtractItemType$1<StateType>, GroupIdentifier, Insertion3, PreviousInsertionsOutputs & Insertion1 & Insertion2>, insertion4: InsertionsFormFactory<ExtractItemType$1<StateType>, GroupIdentifier, Insertion4, PreviousInsertionsOutputs & Insertion1 & Insertion2 & Insertion3>, insertion5: InsertionsFormFactory<ExtractItemType$1<StateType>, GroupIdentifier, Insertion5, PreviousInsertionsOutputs & Insertion1 & Insertion2 & Insertion3 & Insertion4>, insertion6: InsertionsFormFactory<ExtractItemType$1<StateType>, GroupIdentifier, Insertion6, PreviousInsertionsOutputs & Insertion1 & Insertion2 & Insertion3 & Insertion4 & Insertion5>): InsertFormParallelReturn<StateType, Insertion1 & Insertion2 & Insertion3 & Insertion4 & Insertion5 & Insertion6, PreviousInsertionsOutputs>;
|
|
8961
|
+
declare function insertForm<StateType extends unknown[], GroupIdentifier extends string | number, Insertion1, Insertion2, Insertion3, Insertion4, Insertion5, Insertion6, Insertion7, PreviousInsertionsOutputs = {}>(config: ParallelInsertFormConfig<ExtractItemType$1<StateType>, GroupIdentifier>, insertion1: InsertionsFormFactory<ExtractItemType$1<StateType>, GroupIdentifier, Insertion1, PreviousInsertionsOutputs>, insertion2: InsertionsFormFactory<ExtractItemType$1<StateType>, GroupIdentifier, Insertion2, PreviousInsertionsOutputs & Insertion1>, insertion3: InsertionsFormFactory<ExtractItemType$1<StateType>, GroupIdentifier, Insertion3, PreviousInsertionsOutputs & Insertion1 & Insertion2>, insertion4: InsertionsFormFactory<ExtractItemType$1<StateType>, GroupIdentifier, Insertion4, PreviousInsertionsOutputs & Insertion1 & Insertion2 & Insertion3>, insertion5: InsertionsFormFactory<ExtractItemType$1<StateType>, GroupIdentifier, Insertion5, PreviousInsertionsOutputs & Insertion1 & Insertion2 & Insertion3 & Insertion4>, insertion6: InsertionsFormFactory<ExtractItemType$1<StateType>, GroupIdentifier, Insertion6, PreviousInsertionsOutputs & Insertion1 & Insertion2 & Insertion3 & Insertion4 & Insertion5>, insertion7: InsertionsFormFactory<ExtractItemType$1<StateType>, GroupIdentifier, Insertion7, PreviousInsertionsOutputs & Insertion1 & Insertion2 & Insertion3 & Insertion4 & Insertion5 & Insertion6>): InsertFormParallelReturn<StateType, Insertion1 & Insertion2 & Insertion3 & Insertion4 & Insertion5 & Insertion6 & Insertion7, PreviousInsertionsOutputs>;
|
|
8962
|
+
declare function insertForm<StateType extends unknown[], GroupIdentifier extends string | number, Insertion1, Insertion2, Insertion3, Insertion4, Insertion5, Insertion6, Insertion7, Insertion8, PreviousInsertionsOutputs = {}>(config: ParallelInsertFormConfig<ExtractItemType$1<StateType>, GroupIdentifier>, insertion1: InsertionsFormFactory<ExtractItemType$1<StateType>, GroupIdentifier, Insertion1, PreviousInsertionsOutputs>, insertion2: InsertionsFormFactory<ExtractItemType$1<StateType>, GroupIdentifier, Insertion2, PreviousInsertionsOutputs & Insertion1>, insertion3: InsertionsFormFactory<ExtractItemType$1<StateType>, GroupIdentifier, Insertion3, PreviousInsertionsOutputs & Insertion1 & Insertion2>, insertion4: InsertionsFormFactory<ExtractItemType$1<StateType>, GroupIdentifier, Insertion4, PreviousInsertionsOutputs & Insertion1 & Insertion2 & Insertion3>, insertion5: InsertionsFormFactory<ExtractItemType$1<StateType>, GroupIdentifier, Insertion5, PreviousInsertionsOutputs & Insertion1 & Insertion2 & Insertion3 & Insertion4>, insertion6: InsertionsFormFactory<ExtractItemType$1<StateType>, GroupIdentifier, Insertion6, PreviousInsertionsOutputs & Insertion1 & Insertion2 & Insertion3 & Insertion4 & Insertion5>, insertion7: InsertionsFormFactory<ExtractItemType$1<StateType>, GroupIdentifier, Insertion7, PreviousInsertionsOutputs & Insertion1 & Insertion2 & Insertion3 & Insertion4 & Insertion5 & Insertion6>, insertion8: InsertionsFormFactory<ExtractItemType$1<StateType>, GroupIdentifier, Insertion8, PreviousInsertionsOutputs & Insertion1 & Insertion2 & Insertion3 & Insertion4 & Insertion5 & Insertion6 & Insertion7>): InsertFormParallelReturn<StateType, Insertion1 & Insertion2 & Insertion3 & Insertion4 & Insertion5 & Insertion6 & Insertion7 & Insertion8, PreviousInsertionsOutputs>;
|
|
8963
|
+
declare function insertForm<StateType extends unknown[], GroupIdentifier extends string | number, Insertion1, Insertion2, Insertion3, Insertion4, Insertion5, Insertion6, Insertion7, Insertion8, Insertion9, PreviousInsertionsOutputs = {}>(config: ParallelInsertFormConfig<ExtractItemType$1<StateType>, GroupIdentifier>, insertion1: InsertionsFormFactory<ExtractItemType$1<StateType>, GroupIdentifier, Insertion1, PreviousInsertionsOutputs>, insertion2: InsertionsFormFactory<ExtractItemType$1<StateType>, GroupIdentifier, Insertion2, PreviousInsertionsOutputs & Insertion1>, insertion3: InsertionsFormFactory<ExtractItemType$1<StateType>, GroupIdentifier, Insertion3, PreviousInsertionsOutputs & Insertion1 & Insertion2>, insertion4: InsertionsFormFactory<ExtractItemType$1<StateType>, GroupIdentifier, Insertion4, PreviousInsertionsOutputs & Insertion1 & Insertion2 & Insertion3>, insertion5: InsertionsFormFactory<ExtractItemType$1<StateType>, GroupIdentifier, Insertion5, PreviousInsertionsOutputs & Insertion1 & Insertion2 & Insertion3 & Insertion4>, insertion6: InsertionsFormFactory<ExtractItemType$1<StateType>, GroupIdentifier, Insertion6, PreviousInsertionsOutputs & Insertion1 & Insertion2 & Insertion3 & Insertion4 & Insertion5>, insertion7: InsertionsFormFactory<ExtractItemType$1<StateType>, GroupIdentifier, Insertion7, PreviousInsertionsOutputs & Insertion1 & Insertion2 & Insertion3 & Insertion4 & Insertion5 & Insertion6>, insertion8: InsertionsFormFactory<ExtractItemType$1<StateType>, GroupIdentifier, Insertion8, PreviousInsertionsOutputs & Insertion1 & Insertion2 & Insertion3 & Insertion4 & Insertion5 & Insertion6 & Insertion7>, insertion9: InsertionsFormFactory<ExtractItemType$1<StateType>, GroupIdentifier, Insertion9, PreviousInsertionsOutputs & Insertion1 & Insertion2 & Insertion3 & Insertion4 & Insertion5 & Insertion6 & Insertion7 & Insertion8>): InsertFormParallelReturn<StateType, Insertion1 & Insertion2 & Insertion3 & Insertion4 & Insertion5 & Insertion6 & Insertion7 & Insertion8 & Insertion9, PreviousInsertionsOutputs>;
|
|
8964
|
+
declare function insertForm<StateType extends unknown[], GroupIdentifier extends string | number, Insertion1, Insertion2, Insertion3, Insertion4, Insertion5, Insertion6, Insertion7, Insertion8, Insertion9, Insertion10, PreviousInsertionsOutputs = {}>(config: ParallelInsertFormConfig<ExtractItemType$1<StateType>, GroupIdentifier>, insertion1: InsertionsFormFactory<ExtractItemType$1<StateType>, GroupIdentifier, Insertion1, PreviousInsertionsOutputs>, insertion2: InsertionsFormFactory<ExtractItemType$1<StateType>, GroupIdentifier, Insertion2, PreviousInsertionsOutputs & Insertion1>, insertion3: InsertionsFormFactory<ExtractItemType$1<StateType>, GroupIdentifier, Insertion3, PreviousInsertionsOutputs & Insertion1 & Insertion2>, insertion4: InsertionsFormFactory<ExtractItemType$1<StateType>, GroupIdentifier, Insertion4, PreviousInsertionsOutputs & Insertion1 & Insertion2 & Insertion3>, insertion5: InsertionsFormFactory<ExtractItemType$1<StateType>, GroupIdentifier, Insertion5, PreviousInsertionsOutputs & Insertion1 & Insertion2 & Insertion3 & Insertion4>, insertion6: InsertionsFormFactory<ExtractItemType$1<StateType>, GroupIdentifier, Insertion6, PreviousInsertionsOutputs & Insertion1 & Insertion2 & Insertion3 & Insertion4 & Insertion5>, insertion7: InsertionsFormFactory<ExtractItemType$1<StateType>, GroupIdentifier, Insertion7, PreviousInsertionsOutputs & Insertion1 & Insertion2 & Insertion3 & Insertion4 & Insertion5 & Insertion6>, insertion8: InsertionsFormFactory<ExtractItemType$1<StateType>, GroupIdentifier, Insertion8, PreviousInsertionsOutputs & Insertion1 & Insertion2 & Insertion3 & Insertion4 & Insertion5 & Insertion6 & Insertion7>, insertion9: InsertionsFormFactory<ExtractItemType$1<StateType>, GroupIdentifier, Insertion9, PreviousInsertionsOutputs & Insertion1 & Insertion2 & Insertion3 & Insertion4 & Insertion5 & Insertion6 & Insertion7 & Insertion8>, insertion10: InsertionsFormFactory<ExtractItemType$1<StateType>, GroupIdentifier, Insertion10, PreviousInsertionsOutputs & Insertion1 & Insertion2 & Insertion3 & Insertion4 & Insertion5 & Insertion6 & Insertion7 & Insertion8 & Insertion9>): InsertFormParallelReturn<StateType, Insertion1 & Insertion2 & Insertion3 & Insertion4 & Insertion5 & Insertion6 & Insertion7 & Insertion8 & Insertion9 & Insertion10, PreviousInsertionsOutputs>;
|
|
8965
|
+
|
|
8966
|
+
declare const VALIDATOR_OUTPUT_SYMBOL: unique symbol;
|
|
8967
|
+
type ValidatorType = 'sync' | 'async';
|
|
8968
|
+
type ValidatorUtilBrand<Name, Type extends ValidatorType = ValidatorType, Meta extends object = {}> = {
|
|
8969
|
+
__brand: Name;
|
|
8970
|
+
type: Type;
|
|
8971
|
+
} & Meta;
|
|
8972
|
+
type ValidatorSuccess<Name extends string, Type extends ValidatorType = 'sync', Meta extends object = {}> = {
|
|
8973
|
+
valid: true;
|
|
8974
|
+
} & ValidatorUtilBrand<Name, Type, Meta>;
|
|
8975
|
+
type ValidatorPending<Name extends string, Type extends ValidatorType = 'async', Meta extends object = {}> = {
|
|
8976
|
+
valid: false;
|
|
8977
|
+
} & ValidatorUtilBrand<Name, Type, Meta>;
|
|
8978
|
+
type ValidatorExceptionOutput<Name extends string, Exceptions, Type extends ValidatorType, Meta extends object> = Exclude<Exceptions, undefined> extends never ? never : (Exclude<Exceptions, undefined> & ValidatorUtilBrand<Name, Type, Meta>) | ((Exclude<Exceptions, undefined>[] | readonly Exclude<Exceptions, undefined>[]) & ValidatorUtilBrand<Name, Type, Meta>);
|
|
8979
|
+
type DirectValidatorExecutionOutput<Name extends string, Exceptions, Type extends ValidatorType, Meta extends object> = undefined | ValidatorSuccess<Name, Type, Meta> | ValidatorPending<Name, Type, Meta> | ValidatorExceptionOutput<Name, Exceptions, Type, Meta>;
|
|
8980
|
+
type ValidatorRuntimeKind = 'signal';
|
|
8981
|
+
type ValidatorRuntime<Name extends string = string, Type extends ValidatorType = ValidatorType, Kind extends ValidatorRuntimeKind = ValidatorRuntimeKind> = {
|
|
8982
|
+
readonly name: Name;
|
|
8983
|
+
readonly type: Type;
|
|
8984
|
+
readonly kind: Kind;
|
|
8985
|
+
};
|
|
8986
|
+
type ValidatorRuntimeCarrier<Name extends string = string, Type extends ValidatorType = ValidatorType, Kind extends ValidatorRuntimeKind = ValidatorRuntimeKind> = {
|
|
8987
|
+
readonly [VALIDATOR_OUTPUT_SYMBOL]: ValidatorRuntime<Name, Type, Kind>;
|
|
8988
|
+
};
|
|
8989
|
+
type ValidatorOutput<TValue, Name extends string, Exceptions, Type extends ValidatorType = 'sync', Identifier = unknown, Meta extends object = {}, TPathKind extends PathKind = PathKind.Root> = ((context: ValidatorBindingContext<TValue, Identifier, TPathKind>) => Signal<DirectValidatorExecutionOutput<Name, Exceptions, Type, Meta>>) & ValidatorRuntimeCarrier<Name, Type, 'signal'>;
|
|
8990
|
+
type ValidatorModel<TValue> = () => {
|
|
8991
|
+
value: () => TValue;
|
|
8992
|
+
};
|
|
8993
|
+
type ValidatorOption<TValue> = TValue | (() => TValue);
|
|
8994
|
+
type ValidatorConfig = {
|
|
8995
|
+
when?: ValidatorOption<boolean>;
|
|
8996
|
+
};
|
|
8997
|
+
type ValidatorBindingContext<TValue, Identifier = unknown, TPathKind extends PathKind = PathKind.Root> = {
|
|
8998
|
+
schemaPath: SchemaPath<TValue, SchemaPathRules.Supported, TPathKind>;
|
|
8999
|
+
errors: Signal<ValidationError.WithFieldTree[]>;
|
|
9000
|
+
} & ([unknown] extends [Identifier] ? {
|
|
9001
|
+
identifier?: undefined;
|
|
9002
|
+
} : {
|
|
9003
|
+
identifier: Identifier;
|
|
9004
|
+
});
|
|
9005
|
+
type ValueWithLengthOrSize = {
|
|
9006
|
+
length: number;
|
|
9007
|
+
} | {
|
|
9008
|
+
size: number;
|
|
9009
|
+
};
|
|
9010
|
+
type ValidatorException<Code extends string, Payload = undefined> = CraftExceptionResult<{
|
|
9011
|
+
code: Code;
|
|
9012
|
+
}, Payload>;
|
|
9013
|
+
type CRequiredException = ValidatorException<'required'>;
|
|
9014
|
+
type CEmailException = ValidatorException<'email'>;
|
|
9015
|
+
type CMinException = ValidatorException<'min', number>;
|
|
9016
|
+
type CMaxException = ValidatorException<'max', number>;
|
|
9017
|
+
type CMinLengthException = ValidatorException<'minLength', number>;
|
|
9018
|
+
type CMaxLengthException = ValidatorException<'maxLength', number>;
|
|
9019
|
+
type CPatternException = ValidatorException<'pattern', RegExp>;
|
|
9020
|
+
type CRequiredConfig<TValue> = ValidatorConfig;
|
|
9021
|
+
type CEmailConfig<TValue extends string | null | undefined> = ValidatorConfig;
|
|
9022
|
+
type CMinConfig<TValue extends number | string | null | undefined> = ValidatorConfig & ({
|
|
9023
|
+
min: ValidatorOption<number | undefined>;
|
|
9024
|
+
minValue?: never;
|
|
9025
|
+
} | {
|
|
9026
|
+
min?: never;
|
|
9027
|
+
minValue: ValidatorOption<number | undefined>;
|
|
9028
|
+
});
|
|
9029
|
+
type CMaxConfig<TValue extends number | string | null | undefined> = ValidatorConfig & ({
|
|
9030
|
+
max: ValidatorOption<number | undefined>;
|
|
9031
|
+
maxValue?: never;
|
|
9032
|
+
} | {
|
|
9033
|
+
max?: never;
|
|
9034
|
+
maxValue: ValidatorOption<number | undefined>;
|
|
9035
|
+
});
|
|
9036
|
+
type CMinLengthConfig<TValue extends ValueWithLengthOrSize> = ValidatorConfig & {
|
|
9037
|
+
minLength: ValidatorOption<number | undefined>;
|
|
9038
|
+
};
|
|
9039
|
+
type CMaxLengthConfig<TValue extends ValueWithLengthOrSize> = ValidatorConfig & {
|
|
9040
|
+
maxLength: ValidatorOption<number | undefined>;
|
|
9041
|
+
};
|
|
9042
|
+
type CPatternConfig<TValue extends string | null | undefined> = ValidatorConfig & {
|
|
9043
|
+
pattern: ValidatorOption<RegExp | undefined>;
|
|
9044
|
+
};
|
|
9045
|
+
type CValidateBaseConfig<TValue, Name extends string, Identifier = unknown, TPathKind extends PathKind = PathKind.Root> = {
|
|
9046
|
+
name: Name;
|
|
9047
|
+
type?: 'sync';
|
|
9048
|
+
};
|
|
9049
|
+
type CValidateAdvancedSyncConfig<TValue, Name extends string, Exceptions, Identifier = unknown, TPathKind extends PathKind = PathKind.Root> = CValidateBaseConfig<TValue, Name, Identifier, TPathKind> & {
|
|
9050
|
+
validate: (context: ValidatorBindingContext<TValue, Identifier, TPathKind>) => Signal<Exceptions | undefined>;
|
|
9051
|
+
};
|
|
9052
|
+
type CValidateSimpleSyncConfig<TValue, Name extends string, Exceptions, Identifier = unknown, TPathKind extends PathKind = PathKind.Root> = CValidateBaseConfig<TValue, Name, Identifier, TPathKind> & ValidatorConfig & {
|
|
9053
|
+
validWhen: ValidatorOption<boolean>;
|
|
9054
|
+
exception: ValidatorOption<Exceptions>;
|
|
9055
|
+
};
|
|
9056
|
+
type CValidateSyncConfig<TValue, Name extends string, Exceptions, Identifier = unknown, TPathKind extends PathKind = PathKind.Root> = CValidateAdvancedSyncConfig<TValue, Name, Exceptions, Identifier, TPathKind> | CValidateSimpleSyncConfig<TValue, Name, Exceptions, Identifier, TPathKind>;
|
|
9057
|
+
type AnyAsyncCraftResourceRef = ResourceLikeQueryRef<any, any, any, any, any, any, any> | ResourceByIdLikeQueryRef<any, any, any, any, any, any, any, any> | ResourceLikeMutationRef<any, any, any, any, any, any, any> | ResourceByIdLikeMutationRef<any, any, any, any, any, any, any, any>;
|
|
9058
|
+
type AsyncValidatorResourceTarget<TResourceRef> = TResourceRef extends {
|
|
9059
|
+
select: (...args: any[]) => infer SelectedResource;
|
|
9060
|
+
} ? NonNullable<SelectedResource> : TResourceRef;
|
|
9061
|
+
type AsyncValidatorResourceIdentifier<TResourceRef> = TResourceRef extends ResourceByIdLikeQueryRef<any, any, any, any, any, any, infer Identifier, any> ? Identifier : TResourceRef extends ResourceByIdLikeMutationRef<any, any, any, any, any, any, infer Identifier, any> ? Identifier : unknown;
|
|
9062
|
+
type AsyncValidatorResourceExceptionUnion<TResource> = TResource extends {
|
|
9063
|
+
exceptions: Signal<{
|
|
9064
|
+
list: (infer Exception)[];
|
|
9065
|
+
}>;
|
|
9066
|
+
} ? Exception : never;
|
|
9067
|
+
type ExtractValidatorExceptionItems<T> = T extends readonly (infer Item)[] ? Item : T;
|
|
9068
|
+
type AsyncValidatorContext<TValue, TResourceRef extends AnyAsyncCraftResourceRef, Identifier = unknown, TPathKind extends PathKind = PathKind.Root, TResource = AsyncValidatorResourceTarget<TResourceRef>, ResourceExceptions = AsyncValidatorResourceExceptionUnion<TResource>, ResourceExceptionCodes = ExtractCodeFromCraftResultUnion<ResourceExceptions>> = ValidatorBindingContext<TValue, Identifier, TPathKind> & {
|
|
9069
|
+
validateAsyncCraftResource: TResource;
|
|
9070
|
+
omitExceptions: <C extends ResourceExceptionCodes>(codes: readonly C[]) => ExcludeByCode<ResourceExceptions, C>[];
|
|
9071
|
+
};
|
|
9072
|
+
type IsValidAsyncExceptions<T> = [unknown] extends [T] ? true : NonNullable<T> extends AnyCraftException ? true : NonNullable<T> extends readonly (infer Item)[] ? Item extends AnyCraftException ? true : false : false;
|
|
9073
|
+
type HasValidAsyncExceptionReturn<SuccessExceptions, ErrorExceptions, ExceptionExceptions> = IsValidAsyncExceptions<SuccessExceptions> extends true ? IsValidAsyncExceptions<ErrorExceptions> extends true ? IsValidAsyncExceptions<ExceptionExceptions> extends true ? true : {
|
|
9074
|
+
success: true;
|
|
9075
|
+
error: true;
|
|
9076
|
+
exceptions: false;
|
|
9077
|
+
} : {
|
|
9078
|
+
success: true;
|
|
9079
|
+
error: false;
|
|
9080
|
+
exceptions: IsValidAsyncExceptions<ExceptionExceptions>;
|
|
9081
|
+
} : {
|
|
9082
|
+
success: false;
|
|
9083
|
+
error: IsValidAsyncExceptions<ErrorExceptions>;
|
|
9084
|
+
exceptions: IsValidAsyncExceptions<ExceptionExceptions>;
|
|
9085
|
+
};
|
|
9086
|
+
type ValidationDetails$1 = {
|
|
9087
|
+
success: boolean;
|
|
9088
|
+
error: boolean;
|
|
9089
|
+
exceptions: boolean;
|
|
9090
|
+
};
|
|
9091
|
+
type InvalidAsyncExceptionsMessage<T> = T extends true ? never : T extends ValidationDetails$1 ? `Not valid ${(T['success'] extends false ? 'exceptionsOnSuccess callback' : never) | (T['error'] extends false ? 'error callback' : never) | (T['exceptions'] extends false ? 'onException callback' : never)}` : never;
|
|
9092
|
+
type CAsyncValidateConfig<TValue, Name extends string, TResourceRef extends AnyAsyncCraftResourceRef, SuccessExceptions, ErrorExceptions, ExceptionExceptions, Identifier = unknown, TPathKind extends PathKind = PathKind.Root> = MergeObjects$1<[
|
|
9093
|
+
ValidatorConfig & {
|
|
9094
|
+
name: Name;
|
|
9095
|
+
isValidSuccess?: (context: AsyncValidatorContext<TValue, TResourceRef, Identifier, TPathKind>) => boolean;
|
|
9096
|
+
exceptionsOnSuccess?: (context: AsyncValidatorContext<TValue, TResourceRef, Identifier, TPathKind>) => SuccessExceptions;
|
|
9097
|
+
error?: (context: AsyncValidatorContext<TValue, TResourceRef, Identifier, TPathKind>) => ErrorExceptions;
|
|
9098
|
+
onException?: (context: AsyncValidatorContext<TValue, TResourceRef, Identifier, TPathKind>) => ExceptionExceptions;
|
|
9099
|
+
},
|
|
9100
|
+
HasValidAsyncExceptionReturn<SuccessExceptions, ErrorExceptions, ExceptionExceptions> extends true ? {} : {
|
|
9101
|
+
typingError: `cAsyncValidate callbacks must only return Craft exceptions, arrays of Craft exceptions, or undefined. ${InvalidAsyncExceptionsMessage<HasValidAsyncExceptionReturn<SuccessExceptions, ErrorExceptions, ExceptionExceptions>>}`;
|
|
9102
|
+
}
|
|
9103
|
+
]>;
|
|
9104
|
+
type ToAsyncValidatorExceptions<ResourceExceptions, SuccessExceptions, ErrorExceptions, ExceptionExceptions> = [unknown] extends [ExceptionExceptions] ? Exclude<ResourceExceptions | ExtractValidatorExceptionItems<SuccessExceptions> | ExtractValidatorExceptionItems<ErrorExceptions>, undefined> : Exclude<ExtractValidatorExceptionItems<SuccessExceptions> | ExtractValidatorExceptionItems<ErrorExceptions> | ExtractValidatorExceptionItems<ExceptionExceptions>, undefined>;
|
|
9105
|
+
declare function cRequired<TValue>(config?: CRequiredConfig<TValue>): ValidatorOutput<TValue, 'cRequired', CRequiredException>;
|
|
9106
|
+
declare function cEmail<TValue extends string | null | undefined>(config?: CEmailConfig<TValue>): ValidatorOutput<TValue, 'cEmail', CEmailException>;
|
|
9107
|
+
declare function cMin<TValue extends number | string | null | undefined>(config: CMinConfig<TValue>): ValidatorOutput<TValue, 'cMin', CMinException>;
|
|
9108
|
+
declare function cMax<TValue extends number | string | null | undefined>(config: CMaxConfig<TValue>): ValidatorOutput<TValue, 'cMax', CMaxException>;
|
|
9109
|
+
declare function cMinLength<TValue extends ValueWithLengthOrSize>(config: CMinLengthConfig<TValue>): ValidatorOutput<TValue, 'cMinLength', CMinLengthException>;
|
|
9110
|
+
declare function cMaxLength<TValue extends ValueWithLengthOrSize>(config: CMaxLengthConfig<TValue>): ValidatorOutput<TValue, 'cMaxLength', CMaxLengthException>;
|
|
9111
|
+
declare function cPattern<TValue extends string | null | undefined>(config: CPatternConfig<TValue>): ValidatorOutput<TValue, 'cPattern', CPatternException>;
|
|
9112
|
+
declare function cValidate<TValue, const Name extends string, Exceptions, Identifier = unknown, TPathKind extends PathKind = PathKind.Root>(config: CValidateSyncConfig<TValue, Name, Exceptions, Identifier, TPathKind>): ValidatorOutput<TValue, Name, Exceptions, 'sync', Identifier, {}, TPathKind>;
|
|
9113
|
+
declare const cValidator: typeof cValidate;
|
|
9114
|
+
declare function cAsyncValidate<TValue, TResourceRef extends AnyAsyncCraftResourceRef, const Name extends string, SuccessExceptions = undefined, ErrorExceptions = undefined, ExceptionExceptions = unknown, TPathKind extends PathKind = PathKind.Root, Identifier = AsyncValidatorResourceIdentifier<TResourceRef>>(resourceRef: TResourceRef, config: CAsyncValidateConfig<TValue, Name, TResourceRef, SuccessExceptions, ErrorExceptions, ExceptionExceptions, Identifier, TPathKind>): ValidatorOutput<TValue, Name, ToAsyncValidatorExceptions<AsyncValidatorResourceExceptionUnion<AsyncValidatorResourceTarget<TResourceRef>>, SuccessExceptions, ErrorExceptions, ExceptionExceptions>, 'async', Identifier, {}, TPathKind>;
|
|
9115
|
+
declare const cAsyncValidator: typeof cAsyncValidate;
|
|
9116
|
+
|
|
9117
|
+
type FormAttributeInput<T> = Signal<T> | (() => T);
|
|
9118
|
+
type AnySignalValidatorOutput = ValidatorOutput<any, string, any, any, any, any, any>;
|
|
9119
|
+
type FormNodeExceptions = {
|
|
9120
|
+
list: unknown[];
|
|
9121
|
+
byValidator: Record<string, unknown>;
|
|
9122
|
+
};
|
|
9123
|
+
type InsertFormAttributesConfig<S, Validators extends AnySignalValidatorOutput = never> = {
|
|
9124
|
+
disable?: FormAttributeInput<boolean>;
|
|
9125
|
+
hidden?: FormAttributeInput<boolean>;
|
|
9126
|
+
readonly?: FormAttributeInput<boolean>;
|
|
9127
|
+
validators?: Validators[];
|
|
9128
|
+
};
|
|
9129
|
+
type InsertFormAttributesContext<TValue, PreviousInsertionsOutputs = {}, FormIdentifier extends string | number | unknown = unknown> = InsertionFormFactoryContext<TValue, PreviousInsertionsOutputs, FormIdentifier> & {
|
|
9130
|
+
nodeModel: ValidatorModel<TValue>;
|
|
9131
|
+
};
|
|
9132
|
+
type ExtractValidatorMetadata<Validator> = Validator extends ValidatorOutput<infer TValue, infer Name, infer Exceptions, infer Type, infer Identifier, infer Meta, infer TPathKind> ? Exceptions : never;
|
|
9133
|
+
type ExceptionsByValidatorFromTuple<ExceptionsTuple extends unknown[], Acc = {}> = ExceptionsTuple extends [infer Head, ...infer Tail] ? ExceptionsByValidatorFromTuple<Tail, Head extends CraftExceptionResult<infer M, infer P> ? MergeObject$1<Acc, {
|
|
9134
|
+
[Key in M['code']]: Head;
|
|
9135
|
+
}> : Head> : Prettify<Acc>;
|
|
9136
|
+
type ExceptionsList<Exception> = UnionToTuple$1<ExtractValidatorMetadata<NonNullable<Exception>>>;
|
|
9137
|
+
type ExceptionsByValidator<Validators> = ExceptionsByValidatorFromTuple<UnionToTuple$1<ExtractValidatorMetadata<NonNullable<Validators>>>>;
|
|
9138
|
+
declare function insertFormAttributes<StateType, Validators extends AnySignalValidatorOutput = never, FormIdentifier extends string | number | unknown = unknown, PreviousInsertionsOutputs = {}>(_factory: (context: InsertFormAttributesContext<StateType, PreviousInsertionsOutputs, FormIdentifier>) => InsertFormAttributesConfig<StateType, Validators>): InsertionsFormFactory<StateType, FormIdentifier, {
|
|
9139
|
+
exceptions: Signal<{
|
|
9140
|
+
list: ExceptionsList<Validators>;
|
|
9141
|
+
byValidator: ExceptionsByValidator<NonNullable<Validators>>;
|
|
9142
|
+
}>;
|
|
9143
|
+
/**
|
|
9144
|
+
* Exceptions that should be visible to the user. By default, all exceptions are hidden until the field is dirty or the form has been attempted to be submitted at least once.
|
|
9145
|
+
*/
|
|
9146
|
+
visibleExceptions: Signal<{
|
|
9147
|
+
list: ExceptionsList<Validators>;
|
|
9148
|
+
byValidator: ExceptionsByValidator<NonNullable<Validators>>;
|
|
9149
|
+
}>;
|
|
9150
|
+
hasExceptions: Signal<boolean>;
|
|
9151
|
+
}, PreviousInsertionsOutputs>;
|
|
9152
|
+
|
|
9153
|
+
type ExtractItemType<T> = T extends readonly (infer Item)[] ? Item : never;
|
|
9154
|
+
type MergeInsertions<Insertions extends readonly unknown[], Acc = {}> = Insertions extends readonly [infer Head, ...infer Tail] ? MergeInsertions<Tail, Acc & Head> : Acc;
|
|
9155
|
+
type SelectedFormTreeTarget<StateType, Name extends string> = StateType extends readonly (infer Item)[] ? Extract<Item, object> : StateType extends Record<string, unknown> ? Name extends keyof StateType ? StateType[Name] : never : never;
|
|
9156
|
+
type IsArray<T> = T extends any[] ? true : false;
|
|
9157
|
+
type MaybeFormWithInsertions<Model, Insertions> = [Model] extends [never] ? never : undefined extends Model ? FormWithInsertions<Extract<Model, object>, Insertions> | undefined : FormWithInsertions<Extract<Model, object>, Insertions>;
|
|
9158
|
+
type SelectFormTreeMethodName<Name extends string> = `select${Capitalize<Name>}`;
|
|
9159
|
+
type ArrayInsertSelectFormTreeOutput<StateType, Name extends string, Insertions extends readonly unknown[]> = {
|
|
9160
|
+
[K in SelectFormTreeMethodName<Name>]: (id: number) => FormWithInsertions<Extract<ExtractItemType<StateType>, object>, MergeInsertions<Insertions>> | undefined;
|
|
9161
|
+
} & {
|
|
9162
|
+
items: () => Array<FormWithInsertions<Extract<ExtractItemType<StateType>, object>, MergeInsertions<Insertions>>>;
|
|
9163
|
+
};
|
|
9164
|
+
type ObjectInsertSelectFormTreeOutput<StateType, Name extends string, Insertions extends readonly unknown[]> = {
|
|
9165
|
+
[K in SelectFormTreeMethodName<Name>]: () => MaybeFormWithInsertions<StateType extends Record<string, unknown> ? Name extends keyof StateType ? StateType[Name] : never : never, MergeInsertions<Insertions>>;
|
|
9166
|
+
};
|
|
9167
|
+
type InsertSelectFormTreeReturn<StateType, Name extends string, FormIdentifier extends string | number | unknown, Insertions extends readonly unknown[], PreviousInsertionsOutputs> = InsertionsFormFactory<StateType, FormIdentifier, StateType extends readonly unknown[] ? ArrayInsertSelectFormTreeOutput<StateType, Name, Insertions> : ObjectInsertSelectFormTreeOutput<StateType, Name, Insertions>, PreviousInsertionsOutputs>;
|
|
9168
|
+
declare function insertSelectFormTree<StateType, const Name extends AutoCompleteName & string, FormIdentifier extends string | number | unknown = unknown, Insertion1 = {}, PreviousInsertionsOutputs = {}, AutoCompleteName = NoInfer<StateType> extends readonly object[] ? string : keyof NoInfer<StateType>>(name: Name, insertion1: InsertionsFormFactory<SelectedFormTreeTarget<StateType, Name>, FormIdentifier, Insertion1, PreviousInsertionsOutputs>): InsertSelectFormTreeReturn<[
|
|
9169
|
+
Name
|
|
9170
|
+
] extends [keyof StateType] ? IsArray<StateType[Name]> extends true ? `craft-ng error, typing limitation: insertSelectFormTree does not currently support selecting items from an array property in first insertion position (e.g. insertSelectFormTree('addresses', insertSelectFormTree('address', ...))). Consider using insertNoopTypingAnchor:
|
|
9171
|
+
insertSelectFormTree('${Name}', insertNoopTypingAnchor, insertSelectFormTree(...)) ` : StateType : StateType, Name, FormIdentifier, [
|
|
9172
|
+
Insertion1
|
|
9173
|
+
], PreviousInsertionsOutputs>;
|
|
9174
|
+
declare function insertSelectFormTree<StateType, const Name extends AutoCompleteName & string, FormIdentifier extends string | number | unknown = unknown, Insertion1 = {}, Insertion2 = {}, PreviousInsertionsOutputs = {}, AutoCompleteName = StateType extends readonly object[] ? string : keyof StateType>(name: Name, insertion1: InsertionsFormFactory<SelectedFormTreeTarget<StateType, Name>, FormIdentifier, Insertion1, PreviousInsertionsOutputs>, insertion2: InsertionsFormFactory<SelectedFormTreeTarget<StateType, Name>, FormIdentifier, Insertion2, PreviousInsertionsOutputs & Insertion1>): InsertSelectFormTreeReturn<StateType, Name, FormIdentifier, [
|
|
9175
|
+
Insertion1,
|
|
9176
|
+
Insertion2
|
|
9177
|
+
], PreviousInsertionsOutputs>;
|
|
9178
|
+
declare function insertSelectFormTree<StateType, const Name extends AutoCompleteName & string, FormIdentifier extends string | number | unknown = unknown, Insertion1 = {}, Insertion2 = {}, Insertion3 = {}, PreviousInsertionsOutputs = {}, AutoCompleteName = StateType extends readonly object[] ? string : keyof StateType>(name: Name, insertion1: InsertionsFormFactory<SelectedFormTreeTarget<StateType, Name>, FormIdentifier, Insertion1, PreviousInsertionsOutputs>, insertion2: InsertionsFormFactory<SelectedFormTreeTarget<StateType, Name>, FormIdentifier, Insertion2, PreviousInsertionsOutputs & Insertion1>, insertion3: InsertionsFormFactory<SelectedFormTreeTarget<StateType, Name>, FormIdentifier, Insertion3, PreviousInsertionsOutputs & Insertion1 & Insertion2>): InsertSelectFormTreeReturn<StateType, Name, FormIdentifier, [
|
|
9179
|
+
Insertion1,
|
|
9180
|
+
Insertion2,
|
|
9181
|
+
Insertion3
|
|
9182
|
+
], PreviousInsertionsOutputs>;
|
|
9183
|
+
declare function insertSelectFormTree<StateType, const Name extends AutoCompleteName & string, FormIdentifier extends string | number | unknown = unknown, Insertion1 = {}, Insertion2 = {}, Insertion3 = {}, Insertion4 = {}, PreviousInsertionsOutputs = {}, AutoCompleteName = StateType extends readonly object[] ? string : keyof StateType>(name: Name, insertion1: InsertionsFormFactory<SelectedFormTreeTarget<StateType, Name>, FormIdentifier, Insertion1, PreviousInsertionsOutputs>, insertion2: InsertionsFormFactory<SelectedFormTreeTarget<StateType, Name>, FormIdentifier, Insertion2, PreviousInsertionsOutputs & Insertion1>, insertion3: InsertionsFormFactory<SelectedFormTreeTarget<StateType, Name>, FormIdentifier, Insertion3, PreviousInsertionsOutputs & Insertion1 & Insertion2>, insertion4: InsertionsFormFactory<SelectedFormTreeTarget<StateType, Name>, FormIdentifier, Insertion4, PreviousInsertionsOutputs & Insertion1 & Insertion2 & Insertion3>): InsertSelectFormTreeReturn<StateType, Name, FormIdentifier, [
|
|
9184
|
+
Insertion1,
|
|
9185
|
+
Insertion2,
|
|
9186
|
+
Insertion3,
|
|
9187
|
+
Insertion4
|
|
9188
|
+
], PreviousInsertionsOutputs>;
|
|
9189
|
+
declare function insertSelectFormTree<StateType, const Name extends AutoCompleteName & string, FormIdentifier extends string | number | unknown = unknown, Insertion1 = {}, Insertion2 = {}, Insertion3 = {}, Insertion4 = {}, Insertion5 = {}, PreviousInsertionsOutputs = {}, AutoCompleteName = StateType extends readonly object[] ? string : keyof StateType>(name: Name, insertion1: InsertionsFormFactory<SelectedFormTreeTarget<StateType, Name>, FormIdentifier, Insertion1, PreviousInsertionsOutputs>, insertion2: InsertionsFormFactory<SelectedFormTreeTarget<StateType, Name>, FormIdentifier, Insertion2, PreviousInsertionsOutputs & Insertion1>, insertion3: InsertionsFormFactory<SelectedFormTreeTarget<StateType, Name>, FormIdentifier, Insertion3, PreviousInsertionsOutputs & Insertion1 & Insertion2>, insertion4: InsertionsFormFactory<SelectedFormTreeTarget<StateType, Name>, FormIdentifier, Insertion4, PreviousInsertionsOutputs & Insertion1 & Insertion2 & Insertion3>, insertion5: InsertionsFormFactory<SelectedFormTreeTarget<StateType, Name>, FormIdentifier, Insertion5, PreviousInsertionsOutputs & Insertion1 & Insertion2 & Insertion3 & Insertion4>): InsertSelectFormTreeReturn<StateType, Name, FormIdentifier, [
|
|
9190
|
+
Insertion1,
|
|
9191
|
+
Insertion2,
|
|
9192
|
+
Insertion3,
|
|
9193
|
+
Insertion4,
|
|
9194
|
+
Insertion5
|
|
9195
|
+
], PreviousInsertionsOutputs>;
|
|
9196
|
+
|
|
9197
|
+
type SubmitExceptionUnion<SubmitCraftResource> = SubmitCraftResource extends {
|
|
9198
|
+
exceptions: Signal<{
|
|
9199
|
+
list: (infer ExceptionList)[];
|
|
9200
|
+
}>;
|
|
9201
|
+
} ? ExceptionList : AnyCraftException;
|
|
9202
|
+
type SubmitContext<FormValue, MutationValue, MutationParams, MutationArgParams, MutationSourceParams, MutationInsertions, MutationExceptions extends ResourceExceptionConstraints, SubmitCraftResource = ResourceLikeMutationRef<MutationValue, MutationParams, true, MutationArgParams, MutationSourceParams, MutationInsertions, MutationExceptions>, SubmitExceptions = ExtractCodeFromCraftResultUnion<SubmitExceptionUnion<SubmitCraftResource>>> = {
|
|
9203
|
+
submitCraftResource: SubmitCraftResource;
|
|
9204
|
+
form: FormWithInsertions<FormValue, {}>;
|
|
9205
|
+
exceptions: SubmitExceptionUnion<SubmitCraftResource>;
|
|
9206
|
+
omitExceptions: <C extends SubmitExceptions>(codes: readonly C[]) => ExcludeByCode<SubmitExceptionUnion<SubmitCraftResource>, C>;
|
|
9207
|
+
};
|
|
9208
|
+
type IsValidExceptions<T> = NonNullable<T> extends AnyCraftException ? true : [unknown] extends [T] ? true : false;
|
|
9209
|
+
type HasReturnValidExceptions<SuccessExceptions, ErrorExceptions, ExceptionExceptions> = IsValidExceptions<SuccessExceptions> extends true ? IsValidExceptions<ErrorExceptions> extends true ? IsValidExceptions<ExceptionExceptions> extends true ? true : {
|
|
9210
|
+
success: true;
|
|
9211
|
+
error: true;
|
|
9212
|
+
exceptions: false;
|
|
9213
|
+
} : {
|
|
9214
|
+
success: true;
|
|
9215
|
+
error: false;
|
|
9216
|
+
exceptions: IsValidExceptions<ExceptionExceptions>;
|
|
9217
|
+
} : {
|
|
9218
|
+
success: false;
|
|
9219
|
+
error: IsValidExceptions<ErrorExceptions>;
|
|
9220
|
+
exceptions: IsValidExceptions<ExceptionExceptions>;
|
|
9221
|
+
};
|
|
9222
|
+
type ValidationDetails = {
|
|
9223
|
+
success: boolean;
|
|
9224
|
+
error: boolean;
|
|
9225
|
+
exceptions: boolean;
|
|
9226
|
+
};
|
|
9227
|
+
type InvalidExceptionsMessage<T> = T extends true ? never : T extends ValidationDetails ? `Not valid ${(T['success'] extends false ? 'success callback' : never) | (T['error'] extends false ? 'error callback' : never) | (T['exceptions'] extends false ? 'exceptions callback' : never)}` : never;
|
|
9228
|
+
type InsertFormSubmitConfig<FormValue, SuccessExceptions, ErrorExceptions, ExceptionExceptions, MutationValue, MutationParams, MutationArgParams, MutationSourceParams, MutationInsertions, MutationExceptions extends ResourceExceptionConstraints, MutationIdentifier extends string | number | unknown, FormIdentifier extends string | number | unknown> = MergeObjects$1<[
|
|
9229
|
+
{
|
|
9230
|
+
/**
|
|
9231
|
+
* Add more exceptions on success, for example to handle specific cases where the resource returns a successful response but you want to display an exception
|
|
9232
|
+
*/
|
|
9233
|
+
success?: (context: SubmitContext<FormValue, MutationValue, MutationParams, MutationArgParams, MutationSourceParams, MutationInsertions, MutationExceptions>) => SuccessExceptions;
|
|
9234
|
+
/**
|
|
9235
|
+
* Add more exceptions on error, for example to handle specific cases where the resource returns an error response but you want to display a different exception
|
|
9236
|
+
*/
|
|
9237
|
+
error?: (context: SubmitContext<FormValue, MutationValue, MutationParams, MutationArgParams, MutationSourceParams, MutationInsertions, MutationExceptions>) => ErrorExceptions;
|
|
9238
|
+
/**
|
|
9239
|
+
* Override and add more exceptions on exception, for example to handle specific cases where the resource throws an exception but you want to display a different exception
|
|
9240
|
+
*/
|
|
9241
|
+
exception?: (context: SubmitContext<FormValue, MutationValue, MutationParams, MutationArgParams, MutationSourceParams, MutationInsertions, MutationExceptions>) => ExceptionExceptions;
|
|
9242
|
+
},
|
|
9243
|
+
HasReturnValidExceptions<SuccessExceptions, ErrorExceptions, ExceptionExceptions> extends true ? {} : {
|
|
9244
|
+
typingError: `insertFormSubmit callbacks must only return Craft exceptions or undefined. ${InvalidExceptionsMessage<HasReturnValidExceptions<SuccessExceptions, ErrorExceptions, ExceptionExceptions>>}`;
|
|
9245
|
+
},
|
|
9246
|
+
[
|
|
9247
|
+
unknown
|
|
9248
|
+
] extends [FormIdentifier] ? {} : {
|
|
9249
|
+
filter?: ({ formIdentifier, mutationIdentifier, mutationResource, }: {
|
|
9250
|
+
formIdentifier: FormIdentifier;
|
|
9251
|
+
mutationIdentifier: MutationIdentifier;
|
|
9252
|
+
mutationResource: ResourceLikeMutationRef<MutationValue, MutationParams, true, MutationArgParams, MutationSourceParams, MutationInsertions, MutationExceptions>;
|
|
9253
|
+
}) => boolean;
|
|
9254
|
+
}
|
|
9255
|
+
]>;
|
|
9256
|
+
type ToSubmitExceptions<SubmitExceptions extends AnyCraftException | undefined | unknown, SuccessExceptions, ErrorExceptions, ExceptionExceptions, FormIdentifier extends string | number | unknown> = [unknown] extends [ExceptionExceptions] ? Exclude<SubmitExceptions & InsertMetaInCraftExceptionIfExists<SuccessExceptions, 'insertFormSubmitSuccess', FormIdentifier> & InsertMetaInCraftExceptionIfExists<ErrorExceptions, 'insertFormSubmitError', FormIdentifier>, undefined> : Exclude<InsertMetaInCraftExceptionIfExists<ExceptionExceptions, 'insertFormSubmitException', FormIdentifier> | InsertMetaInCraftExceptionIfExists<SuccessExceptions, 'insertFormSubmitSuccess', FormIdentifier> | InsertMetaInCraftExceptionIfExists<ErrorExceptions, 'insertFormSubmitError', FormIdentifier>, undefined>;
|
|
9257
|
+
declare function insertFormSubmit<FormValue, MutationValue, MutationParams, MutationArgParams, MutationSourceParams, MutationInsertions, MutationExceptions extends ResourceExceptionConstraints, SuccessExceptions, ErrorExceptions, ExceptionExceptions>(submitCraftResource: ResourceLikeMutationRef<MutationValue, MutationParams, true, MutationArgParams, MutationSourceParams, MutationInsertions, MutationExceptions>, config?: InsertFormSubmitConfig<FormValue, SuccessExceptions, ErrorExceptions, ExceptionExceptions, NoInfer<MutationValue>, NoInfer<MutationParams>, NoInfer<MutationArgParams>, NoInfer<MutationSourceParams>, NoInfer<MutationInsertions>, NoInfer<MutationExceptions>, unknown, unknown>): InsertionsFormFactory<FormValue, unknown, {
|
|
9258
|
+
submit: () => void;
|
|
9259
|
+
hasSubmitExceptions: Signal<boolean>;
|
|
9260
|
+
submitExceptions: Signal<ToSubmitExceptions<InsertMetaInCraftExceptionIfExists<MutationExceptions['params'], 'params', unknown> | InsertMetaInCraftExceptionIfExists<MutationExceptions['loader'], 'loader', unknown>, SuccessExceptions, ErrorExceptions, ExceptionExceptions, unknown>[]>;
|
|
9261
|
+
}>;
|
|
9262
|
+
declare function insertFormSubmit<FormValue, MutationValue, MutationParams, MutationArgParams, MutationSourceParams, MutationInsertions, MutationExceptions extends ResourceExceptionConstraints, SuccessExceptions, ErrorExceptions, ExceptionExceptions, MutationIdentifier extends string | number, FormIdentifier extends string | number>(submitCraftResourceById: ResourceByIdLikeMutationRef<MutationValue, MutationParams, true, MutationArgParams, MutationSourceParams, MutationInsertions, MutationIdentifier, MutationExceptions>, config?: InsertFormSubmitConfig<FormValue, SuccessExceptions, ErrorExceptions, ExceptionExceptions, NoInfer<MutationValue>, NoInfer<MutationParams>, NoInfer<MutationArgParams>, NoInfer<MutationSourceParams>, NoInfer<MutationInsertions>, NoInfer<MutationExceptions>, NoInfer<MutationIdentifier>, NoInfer<FormIdentifier>>): InsertionsFormFactory<FormValue, FormIdentifier, {
|
|
9263
|
+
submit: () => void;
|
|
9264
|
+
hasSubmitExceptions: Signal<boolean>;
|
|
9265
|
+
submitExceptions: Signal<ToSubmitExceptions<InsertMetaInCraftExceptionIfExists<MutationExceptions['params'], 'params', MutationIdentifier> | InsertMetaInCraftExceptionIfExists<MutationExceptions['loader'], 'loader', MutationIdentifier>, SuccessExceptions, ErrorExceptions, ExceptionExceptions, FormIdentifier>[]>;
|
|
9266
|
+
}>;
|
|
9267
|
+
|
|
9268
|
+
export { CRAFT_EXCEPTION_SYMBOL, EXTERNALLY_PROVIDED, EmptyContext, GlobalPersisterHandlerService, STORE_CONFIG_TOKEN, SourceBrand, SourceBranded, VALIDATOR_OUTPUT_SYMBOL, addMany, addOne, afterRecomputation, asyncProcess, cAsyncValidate, cAsyncValidator, cEmail, cMax, cMaxLength, cMin, cMinLength, cPattern, cRequired, cValidate, cValidator, capitalize, computedIds, computedSource, computedTotal, contract, craft, craftAsyncProcesses, craftComputedStates, craftException, craftFactoryEntries, craftInject, craftInputs, craftMutations, craftQuery, craftQueryParam, craftQueryParams, craftSetAllQueriesParamsStandalone, craftSources, craftState, createMethodHandlers, fromEventToSource$, injectService, insertForm, insertFormAttributes, insertFormSubmit, insertLocalStoragePersister, insertNoopTypingAnchor, insertPaginationPlaceholderData, insertReactOnMutation, insertSelect, insertSelectFormTree, isCraftException, isSource, linkedSource, localStoragePersister, map, mapOne, mutation, on$, partialContext, query, queryParam, reactiveWritableSignal, removeAll, removeMany, removeOne, resourceById, serializeQueryParams, serializedQueryParamsObjectToString, setAll, setMany, setOne, signalSource, source$, sourceFromEvent, stackedSource, state, toInject, toSource, toggleMany, toggleOne, updateMany, updateOne, upsertMany, upsertOne, validatedFormValueSymbol };
|
|
9269
|
+
export type { AnyCraftException, AsyncProcessExceptionConstraints, AsyncProcessOutput, AsyncProcessRef, CEmailException, CMaxException, CMaxLengthException, CMinException, CMinLengthException, CRequiredException, CloudProxy, CloudProxySource, ContextConstraints, ContextInput, CraftException, CraftExceptionMeta, CraftExceptionResult, CraftFactory, CraftFactoryEntries, CraftFactoryUtility, DeferredExtract, EntitiesUtilBrand, EqualParams, ExcludeByCode, ExcludeCommonKeys, ExposedStateInsertions, ExtractCodeFromCraftResultUnion, ExtractCraftException, ExtractSignalPropsAndMethods, FilterMethodsBoundToSources, FilterPrivateFields, FilterSource, FlatRecord, FormNodeExceptions, FormWithInsertions, FromEventToSource$, HasChild$1 as HasChild, HasKeys, IdSelector, Identifier, InferInjectedType, InjectService2InsertionContext, InjectService2InsertionFactory, InjectService2Insertions, InjectService2Output, InjectService2Public, InsertFormAttributesConfig, InsertFormAttributesContext, InsertMetaInCraftExceptionIfExists, InsertionFormFactoryContext, InsertionsFormFactory, IsAny, IsEmptyObject, IsNever, IsUnknown, MakeOptionalPropertiesRequired$1 as MakeOptionalPropertiesRequired, MergeObject$1 as MergeObject, MergeObjects$1 as MergeObjects, MergeTwoContexts, MutationOutput, MutationRef, Not, OmitStrict, PartialContext, Prettify, QueryOutput, QueryParamConfig, QueryParamExceptions, QueryParamNavigationOptions$1 as QueryParamNavigationOptions, QueryParamOutput, QueryParamsToState, QueryRef, ReadonlySource, ReadonlySource$, RemoveIndexSignature, ReplaceStoreConfigToken, ResourceByIdHandler, ResourceByIdLikeAsyncProcessExceptions, ResourceByIdLikeExceptions, ResourceByIdLikeMutationExceptions, ResourceByIdLikeMutationRef, ResourceByIdLikeQueryRef, ResourceByIdRef, ResourceLikeAsyncProcessExceptions, ResourceLikeExceptions, ResourceLikeMutationExceptions, ResourceLikeMutationRef, ResourceLikeQueryRef, SignalSource, Source$, SourceFromEvent, SourceSetterMethods, SourceSubscribe, SpecificCraftQueryParamOutputs, SpecificCraftQueryParamsOutputs, StackSource, StateOutput, StoreConfigConstraints, StoreConfigToken, StripCraftException, ToConnectableMethodFromInject, ToConnectableSourceFromInject, ToInjectBindings, UnionToIntersection$1 as UnionToIntersection, UnionToTuple$1 as UnionToTuple, Update, ValidatedFormValue, ValidatorBindingContext, ValidatorModel, ValidatorOutput, ValidatorPending, ValidatorSuccess, ValidatorType, ValidatorUtilBrand };
|