|
@@ -47,6 +47,15 @@ export namespace Transformer {
|
|
|
|
|
|
export enum UpdateResult { Unchanged, Updated, Recreate }
|
|
export enum UpdateResult { Unchanged, Updated, Recreate }
|
|
|
|
|
|
|
|
+ export interface ParamsProvider<A extends StateObject = StateObject, P = any> {
|
|
|
|
+ /** Check the parameters and return a list of errors if the are not valid. */
|
|
|
|
+ default?(a: A, globalCtx: unknown): P,
|
|
|
|
+ /** Specify default control descriptors for the parameters */
|
|
|
|
+ definition?(a: A, globalCtx: unknown): { [K in keyof P]?: PD.Any },
|
|
|
|
+ /** Optional custom parameter equality. Use shallow structural equal by default. */
|
|
|
|
+ areEqual?(oldParams: P, newParams: P): boolean
|
|
|
|
+ }
|
|
|
|
+
|
|
export interface Definition<A extends StateObject = StateObject, B extends StateObject = StateObject, P = unknown> {
|
|
export interface Definition<A extends StateObject = StateObject, B extends StateObject = StateObject, P = unknown> {
|
|
readonly name: string,
|
|
readonly name: string,
|
|
readonly from: StateObject.Ctor[],
|
|
readonly from: StateObject.Ctor[],
|
|
@@ -66,7 +75,7 @@ export namespace Transformer {
|
|
*/
|
|
*/
|
|
update?(params: UpdateParams<A, B, P>, globalCtx: unknown): Task<UpdateResult> | UpdateResult,
|
|
update?(params: UpdateParams<A, B, P>, globalCtx: unknown): Task<UpdateResult> | UpdateResult,
|
|
|
|
|
|
- readonly params?: PD.Provider<A, P, unknown>,
|
|
|
|
|
|
+ readonly params?: ParamsProvider<A, P>,
|
|
|
|
|
|
/** Test if the transform can be applied to a given node */
|
|
/** Test if the transform can be applied to a given node */
|
|
isApplicable?(a: A, globalCtx: unknown): boolean,
|
|
isApplicable?(a: A, globalCtx: unknown): boolean,
|