@regle/core 0.1.5 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1663 -0
- package/dist/index.d.cts +485 -0
- package/dist/index.d.ts +6 -4
- package/dist/index.js +33 -18
- package/package.json +2 -1
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,485 @@
|
|
|
1
|
+
import * as vue from 'vue';
|
|
2
|
+
import { MaybeRef, Ref, ComputedRef, UnwrapNestedRefs } from 'vue';
|
|
3
|
+
|
|
4
|
+
type Maybe<T = any> = T | null | undefined;
|
|
5
|
+
type MaybeGetter<T, V = any> = T | ((value: Ref<V>, index: number) => T);
|
|
6
|
+
type ExtractFromGetter<T extends MaybeGetter<any, any>> = T extends MaybeGetter<infer U, any> ? U : never;
|
|
7
|
+
type DeepMaybeRef<T extends Record<string, any>> = {
|
|
8
|
+
[K in keyof T]: MaybeRef<T[K]>;
|
|
9
|
+
};
|
|
10
|
+
type ExcludeByType<T, U> = {
|
|
11
|
+
[K in keyof T as T[K] extends U ? never : K]: T[K] extends U ? never : T[K];
|
|
12
|
+
};
|
|
13
|
+
type NonPresentKeys<TSource extends Record<string, any>, Target extends Record<string, any>> = Omit<Target, keyof TSource>;
|
|
14
|
+
|
|
15
|
+
type ArrayElement<T> = T extends Array<infer U> ? U : never;
|
|
16
|
+
|
|
17
|
+
declare global {
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
|
|
19
|
+
interface SymbolConstructor {
|
|
20
|
+
readonly observable: symbol;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
declare const emptyObjectSymbol: unique symbol;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
Represents a strictly empty plain object, the `{}` value.
|
|
28
|
+
|
|
29
|
+
When you annotate something as the type `{}`, it can be anything except `null` and `undefined`. This means that you cannot use `{}` to represent an empty plain object ([read more](https://stackoverflow.com/questions/47339869/typescript-empty-object-and-any-difference/52193484#52193484)).
|
|
30
|
+
|
|
31
|
+
@example
|
|
32
|
+
```
|
|
33
|
+
import type {EmptyObject} from 'type-fest';
|
|
34
|
+
|
|
35
|
+
// The following illustrates the problem with `{}`.
|
|
36
|
+
const foo1: {} = {}; // Pass
|
|
37
|
+
const foo2: {} = []; // Pass
|
|
38
|
+
const foo3: {} = 42; // Pass
|
|
39
|
+
const foo4: {} = {a: 1}; // Pass
|
|
40
|
+
|
|
41
|
+
// With `EmptyObject` only the first case is valid.
|
|
42
|
+
const bar1: EmptyObject = {}; // Pass
|
|
43
|
+
const bar2: EmptyObject = 42; // Fail
|
|
44
|
+
const bar3: EmptyObject = []; // Fail
|
|
45
|
+
const bar4: EmptyObject = {a: 1}; // Fail
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Unfortunately, `Record<string, never>`, `Record<keyof any, never>` and `Record<never, never>` do not work. See {@link https://github.com/sindresorhus/type-fest/issues/395 #395}.
|
|
49
|
+
|
|
50
|
+
@category Object
|
|
51
|
+
*/
|
|
52
|
+
type EmptyObject = {[emptyObjectSymbol]?: never};
|
|
53
|
+
|
|
54
|
+
interface RegleBehaviourOptions {
|
|
55
|
+
/**
|
|
56
|
+
* Only display error when calling `validateState()`
|
|
57
|
+
* @default false
|
|
58
|
+
*/
|
|
59
|
+
lazy?: boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Automaticaly set the dirty set without the need of `$value` or `$touch`
|
|
62
|
+
* @default true
|
|
63
|
+
*/
|
|
64
|
+
autoDirty?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* The fields will turn valid when they are, but not invalid unless calling `validateState()`
|
|
67
|
+
* @default false
|
|
68
|
+
*
|
|
69
|
+
* @experimental report any bug
|
|
70
|
+
*/
|
|
71
|
+
rewardEarly?: boolean;
|
|
72
|
+
}
|
|
73
|
+
interface LocalRegleBehaviourOptions<TState extends Record<string, any>, TRules extends ReglePartialValidationTree<TState, CustomRulesDeclarationTree>, TExternal extends RegleExternalErrorTree<TState>, TValidationGroups extends Record<string, RegleValidationGroupEntry[]>> {
|
|
74
|
+
externalErrors?: MaybeRef<TExternal>;
|
|
75
|
+
validationGroups?: (fields: RegleStatus<TState, TRules>['$fields']) => TValidationGroups;
|
|
76
|
+
}
|
|
77
|
+
type RegleValidationGroupEntry = RegleFieldStatus<any, any, any>;
|
|
78
|
+
interface RegleValidationGroupOutput {
|
|
79
|
+
$invalid: boolean;
|
|
80
|
+
$error: boolean;
|
|
81
|
+
$pending: boolean;
|
|
82
|
+
$dirty: boolean;
|
|
83
|
+
$valid: boolean;
|
|
84
|
+
$errors: string[];
|
|
85
|
+
$silentErrors: string[];
|
|
86
|
+
}
|
|
87
|
+
type FieldRegleBehaviourOptions = AddDollarToOptions<RegleBehaviourOptions> & {
|
|
88
|
+
$debounce?: number;
|
|
89
|
+
};
|
|
90
|
+
type AddDollarToOptions<T extends Record<string, any>> = {
|
|
91
|
+
[K in keyof T as `$${string & K}`]: T[K];
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
interface Regle<TState extends Record<string, any> = EmptyObject, TRules extends ReglePartialValidationTree<TState, CustomRulesDeclarationTree> = EmptyObject, TExternal extends RegleExternalErrorTree<TState> = never, TValidationGroups extends Record<string, RegleValidationGroupEntry[]> = never> {
|
|
95
|
+
regle: RegleStatus<TState, TRules, TValidationGroups>;
|
|
96
|
+
r$: RegleStatus<TState, TRules, TValidationGroups>;
|
|
97
|
+
/** Show active errors based on your behaviour options (lazy, autoDirty)
|
|
98
|
+
* It allow you to skip scouting the `regle` object
|
|
99
|
+
*/
|
|
100
|
+
errors: RegleErrorTree<TRules, TExternal>;
|
|
101
|
+
ready: ComputedRef<boolean>;
|
|
102
|
+
resetAll: () => void;
|
|
103
|
+
validateState: () => Promise<false | DeepSafeFormState<TState, TRules>>;
|
|
104
|
+
state: Ref<TState>;
|
|
105
|
+
}
|
|
106
|
+
type DeepReactiveState<T extends Record<string, any>> = {
|
|
107
|
+
[K in keyof T]: MaybeRef<T[K]>;
|
|
108
|
+
};
|
|
109
|
+
type DeepSafeFormState<TState extends Record<string, any>, TRules extends ReglePartialValidationTree<TState, CustomRulesDeclarationTree>> = [unknown] extends [TState] ? {} : {
|
|
110
|
+
[K in keyof TState as [SafeProperty<TState[K], TRules[K]>] extends [never] ? K : never]?: [
|
|
111
|
+
SafeProperty<TState[K], TRules[K]>
|
|
112
|
+
] extends [never] ? TState[K] : SafeProperty<TState[K], TRules[K]>;
|
|
113
|
+
} & {
|
|
114
|
+
[K in keyof TState as [SafeProperty<TState[K], TRules[K]>] extends [never] ? never : K]-?: SafeProperty<TState[K], TRules[K]>;
|
|
115
|
+
};
|
|
116
|
+
type SafeProperty<TState, TRule extends RegleFormPropertyType<any, any> | undefined = never> = TRule extends RegleCollectionRuleDefinition<any, any> ? TState extends Array<any> ? SafeProperty<TState[number], ExtractFromGetter<TRule['$each']>>[] : never : TRule extends ReglePartialValidationTree<any, any> ? TState extends Record<string, any> ? DeepSafeFormState<TState, TRule> : TRule extends RegleRuleDecl<any, any> ? unknown extends TRule['required'] ? never : TRule['required'] extends undefined ? never : TRule['required'] extends RegleRuleDefinition<any, infer Params, any, any, any> ? Params extends never[] ? TState : never : never : never : never;
|
|
117
|
+
|
|
118
|
+
type ParamDecl<T = any> = MaybeRef<Maybe<T>> | (() => Maybe<T>);
|
|
119
|
+
type CreateFn<T extends any[]> = (...args: T) => any;
|
|
120
|
+
/**
|
|
121
|
+
* Transform normal parameters tuple declaration to a rich tuple declaration
|
|
122
|
+
*
|
|
123
|
+
* [foo: string, bar?: number] => [foo: MaybeRef<string> | (() => string), bar?: MaybeRef<number | undefined> | (() => number) | undefined]
|
|
124
|
+
*/
|
|
125
|
+
type RegleUniversalParams<T extends any[] = [], F = CreateFn<T>> = [T] extends [[]] ? [] : Parameters<F extends (...args: infer Args) => any ? (...args: {
|
|
126
|
+
[K in keyof Args]: ParamDecl<Args[K]>;
|
|
127
|
+
}) => any : never>;
|
|
128
|
+
type UnwrapRegleUniversalParams<T extends ParamDecl[] = [], F = CreateFn<T>> = [T] extends [
|
|
129
|
+
[
|
|
130
|
+
]
|
|
131
|
+
] ? [] : Parameters<F extends (...args: infer Args) => any ? (...args: {
|
|
132
|
+
[K in keyof Args]: Args[K] extends ParamDecl<infer U> ? U : Args[K];
|
|
133
|
+
}) => any : never>;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Internal definition of the rule, can be used to reset or patch the rule
|
|
137
|
+
*/
|
|
138
|
+
interface RegleInternalRuleDefs<TValue extends any = any, TParams extends any[] = [], TAsync extends boolean = false, TMetadata extends RegleRuleMetadataDefinition = boolean> {
|
|
139
|
+
_validator: (value: Maybe<TValue>, ...args: TParams) => TAsync extends false ? TMetadata : Promise<TMetadata>;
|
|
140
|
+
_message: string | string[] | ((value: Maybe<TValue>, metadata: PossibleRegleRuleMetadataConsumer) => string | string[]);
|
|
141
|
+
_active?: boolean | ((value: Maybe<TValue>, metadata: PossibleRegleRuleMetadataConsumer) => boolean);
|
|
142
|
+
_type?: string;
|
|
143
|
+
_patched: boolean;
|
|
144
|
+
_params?: RegleUniversalParams<TParams>;
|
|
145
|
+
_async: TAsync;
|
|
146
|
+
}
|
|
147
|
+
declare enum InternalRuleType {
|
|
148
|
+
Inline = "__inline",
|
|
149
|
+
Async = "__async"
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Returned typed of rules created with `createRule`
|
|
154
|
+
* */
|
|
155
|
+
interface RegleRuleDefinition<TValue extends any = any, TParams extends any[] = [], TAsync extends boolean = boolean, TMetaData extends RegleRuleMetadataDefinition = RegleRuleMetadataDefinition, TFilteredValue extends any = TValue extends Date & File & infer M ? M : TValue> extends RegleInternalRuleDefs<TFilteredValue, TParams, TAsync, TMetaData> {
|
|
156
|
+
validator: RegleRuleDefinitionProcessor<TFilteredValue, TParams, TAsync extends false ? TMetaData : Promise<TMetaData>>;
|
|
157
|
+
message: RegleRuleDefinitionWithMetadataProcessor<TFilteredValue, PossibleRegleRuleMetadataConsumer, string | string[]>;
|
|
158
|
+
active: RegleRuleDefinitionWithMetadataProcessor<TFilteredValue, PossibleRegleRuleMetadataConsumer, boolean>;
|
|
159
|
+
type?: string;
|
|
160
|
+
exec: (value: Maybe<TFilteredValue>) => TAsync extends false ? TMetaData : Promise<TMetaData>;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Rules with params created with `createRules` are callable while being customizable
|
|
164
|
+
*/
|
|
165
|
+
interface RegleRuleWithParamsDefinition<TValue extends any = any, TParams extends any[] = [], TAsync extends boolean = false, TMetadata extends RegleRuleMetadataDefinition = boolean> extends RegleRuleCore<TValue, TParams, TAsync, TMetadata>, RegleInternalRuleDefs<TValue, TParams, TAsync, TMetadata> {
|
|
166
|
+
(...params: RegleUniversalParams<TParams>): RegleRuleDefinition<TValue, TParams, TAsync, TMetadata>;
|
|
167
|
+
}
|
|
168
|
+
type RegleRuleMetadataExtended = {
|
|
169
|
+
$valid: boolean;
|
|
170
|
+
[x: string]: any;
|
|
171
|
+
};
|
|
172
|
+
/**
|
|
173
|
+
* Define a rule Metadata definition
|
|
174
|
+
*/
|
|
175
|
+
type RegleRuleMetadataDefinition = RegleRuleMetadataExtended | boolean;
|
|
176
|
+
type DefaultMetadataProperties = Pick<ExcludeByType<RegleCommonStatus, Function>, '$invalid'>;
|
|
177
|
+
/**
|
|
178
|
+
* Will be used to consumme metadata on related helpers and rule status
|
|
179
|
+
*/
|
|
180
|
+
type RegleRuleMetadataConsumer<TParams extends any[] = never, TMetadata extends RegleRuleMetadataDefinition = boolean> = DefaultMetadataProperties & (TParams extends never ? {} : {
|
|
181
|
+
$params: TParams;
|
|
182
|
+
}) & (Exclude<TMetadata, boolean> extends RegleRuleMetadataExtended ? TMetadata extends boolean ? Partial<Omit<Exclude<TMetadata, boolean>, '$valid'>> : Omit<Exclude<TMetadata, boolean>, '$valid'> : {});
|
|
183
|
+
/**
|
|
184
|
+
* Will be used to consumme metadata on related helpers and rule status
|
|
185
|
+
*/
|
|
186
|
+
type PossibleRegleRuleMetadataConsumer = DefaultMetadataProperties & {
|
|
187
|
+
$params?: any[];
|
|
188
|
+
};
|
|
189
|
+
/**
|
|
190
|
+
* Generic types for a created RegleRule
|
|
191
|
+
*/
|
|
192
|
+
type RegleRuleRaw<TValue extends any = any, TParams extends any[] = [], TAsync extends boolean = false, TMetaData extends RegleRuleMetadataDefinition = boolean> = RegleRuleDefinition<TValue, TParams, TAsync, TMetaData> | RegleRuleWithParamsDefinition<TValue, TParams, TAsync, TMetaData>;
|
|
193
|
+
/**
|
|
194
|
+
* Process the type of a created rule with `createRule`.
|
|
195
|
+
* For a rule with params it will return a function
|
|
196
|
+
* Otherwise it will return the rule definition
|
|
197
|
+
*/
|
|
198
|
+
type InferRegleRule<TValue extends any = any, TParams extends any[] = [], TAsync extends boolean = false, TMetaData extends RegleRuleMetadataDefinition = boolean> = [TParams] extends [[]] ? RegleRuleDefinition<TValue, TParams, TAsync, TMetaData> : RegleRuleWithParamsDefinition<TValue, TParams, TAsync, TMetaData>;
|
|
199
|
+
type RegleRuleDefinitionProcessor<TValue extends any = any, TParams extends any[] = [], TReturn = any> = (value: Maybe<TValue>, ...params: TParams) => TReturn;
|
|
200
|
+
type RegleRuleDefinitionWithMetadataProcessor<TValue extends any, TMetadata extends RegleRuleMetadataConsumer<any, any>, TReturn = any> = ((value: Maybe<TValue>, metadata: TMetadata) => TReturn) | TReturn;
|
|
201
|
+
type RegleCollectionRuleDefinition<TValue = any[], TCustomRules extends Partial<AllRulesDeclarations> = Partial<AllRulesDeclarations>> = (RegleRuleDecl<NonNullable<TValue>, TCustomRules> & {
|
|
202
|
+
$each: MaybeGetter<RegleFormPropertyType<ArrayElement<NonNullable<TValue>>, TCustomRules>, ArrayElement<TValue>>;
|
|
203
|
+
}) | {
|
|
204
|
+
$each: MaybeGetter<RegleFormPropertyType<ArrayElement<NonNullable<TValue>>, TCustomRules>, ArrayElement<TValue>>;
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* @argument
|
|
209
|
+
* createRule arguments options
|
|
210
|
+
*/
|
|
211
|
+
interface RegleRuleInit<TValue extends any, TParams extends [...any[]] = [], TReturn extends RegleRuleMetadataDefinition | Promise<RegleRuleMetadataDefinition> = boolean, TMetadata extends RegleRuleMetadataDefinition = RegleRuleMetadataDefinition, TAsync extends boolean = TReturn extends Promise<any> ? true : false> {
|
|
212
|
+
type?: string;
|
|
213
|
+
validator: (value: Maybe<TValue>, ...args: TParams) => TReturn;
|
|
214
|
+
message: string | string[] | ((value: Maybe<TValue>, metadata: RegleRuleMetadataConsumer<TParams, TMetadata>) => string | string[]);
|
|
215
|
+
active?: boolean | ((value: Maybe<TValue>, metadata: RegleRuleMetadataConsumer<TParams, TMetadata>) => boolean);
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* @argument
|
|
219
|
+
* Rule core
|
|
220
|
+
*/
|
|
221
|
+
interface RegleRuleCore<TValue extends any, TParams extends any[] = [], TAsync extends boolean = false, TMetadata extends RegleRuleMetadataDefinition = boolean> {
|
|
222
|
+
validator: (value: Maybe<TValue>, ...args: TParams) => TAsync extends false ? TMetadata : Promise<TMetadata>;
|
|
223
|
+
message: string | ((value: Maybe<TValue>, metadata: RegleRuleMetadataConsumer<TParams, TMetadata>) => string | string[]);
|
|
224
|
+
active?: boolean | ((value: Maybe<TValue>, metadata: RegleRuleMetadataConsumer<TParams, TMetadata>) => boolean);
|
|
225
|
+
type?: string;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
type DefaultValidators = {
|
|
229
|
+
alpha: RegleRuleDefinition<string>;
|
|
230
|
+
alphaNum: RegleRuleDefinition<string | number>;
|
|
231
|
+
between: RegleRuleWithParamsDefinition<number, [min: Maybe<number>, max: Maybe<number>]>;
|
|
232
|
+
checked: RegleRuleDefinition<boolean, [], false, boolean, boolean>;
|
|
233
|
+
contains: RegleRuleWithParamsDefinition<string, [part: Maybe<string>], false, boolean>;
|
|
234
|
+
dateAfter: RegleRuleWithParamsDefinition<string | Date, [
|
|
235
|
+
after: Maybe<string | Date>
|
|
236
|
+
], false, true | {
|
|
237
|
+
$valid: false;
|
|
238
|
+
error: 'date-not-after';
|
|
239
|
+
} | {
|
|
240
|
+
$valid: false;
|
|
241
|
+
error: 'value-or-paramater-not-a-date';
|
|
242
|
+
}>;
|
|
243
|
+
dateBefore: RegleRuleWithParamsDefinition<string | Date, [
|
|
244
|
+
before: Maybe<string | Date>
|
|
245
|
+
], false, true | {
|
|
246
|
+
$valid: false;
|
|
247
|
+
error: 'date-not-before';
|
|
248
|
+
} | {
|
|
249
|
+
$valid: false;
|
|
250
|
+
error: 'value-or-paramater-not-a-date';
|
|
251
|
+
}>;
|
|
252
|
+
dateBetween: RegleRuleWithParamsDefinition<string | Date, [
|
|
253
|
+
before: Maybe<string | Date>,
|
|
254
|
+
after: Maybe<string | Date>
|
|
255
|
+
], false, boolean>;
|
|
256
|
+
decimal: RegleRuleDefinition<string | number, [], false, boolean, string | number>;
|
|
257
|
+
email: RegleRuleDefinition<string, [], false, boolean, string>;
|
|
258
|
+
endsWith: RegleRuleWithParamsDefinition<string, [part: Maybe<string>], false, boolean>;
|
|
259
|
+
exactLength: RegleRuleWithParamsDefinition<string | any[] | Record<PropertyKey, any>, [
|
|
260
|
+
count: number
|
|
261
|
+
], false, boolean>;
|
|
262
|
+
integer: RegleRuleDefinition<string | number, [], false, boolean, string | number>;
|
|
263
|
+
ipAddress: RegleRuleDefinition<string, [], false, boolean, string>;
|
|
264
|
+
macAddress: RegleRuleWithParamsDefinition<string, [
|
|
265
|
+
separator?: string | undefined
|
|
266
|
+
], false, boolean>;
|
|
267
|
+
maxLength: RegleRuleWithParamsDefinition<string | any[] | Record<PropertyKey, any>, [
|
|
268
|
+
count: number
|
|
269
|
+
], false, boolean>;
|
|
270
|
+
maxValue: RegleRuleWithParamsDefinition<number, [count: number], false, boolean>;
|
|
271
|
+
minLength: RegleRuleWithParamsDefinition<string | any[] | Record<PropertyKey, any>, [
|
|
272
|
+
count: number
|
|
273
|
+
], false, boolean>;
|
|
274
|
+
minValue: RegleRuleWithParamsDefinition<number, [count: number], false, boolean>;
|
|
275
|
+
numeric: RegleRuleDefinition<string | number, [], false, boolean, string | number>;
|
|
276
|
+
regex: RegleRuleWithParamsDefinition<string, [regexp: RegExp], false, boolean>;
|
|
277
|
+
required: RegleRuleDefinition<unknown, []>;
|
|
278
|
+
sameAs: RegleRuleWithParamsDefinition<unknown, [target: unknown], false, boolean>;
|
|
279
|
+
startsWith: RegleRuleWithParamsDefinition<string, [part: Maybe<string>], false, boolean>;
|
|
280
|
+
url: RegleRuleDefinition<string, [], false, boolean, string>;
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
type CustomRulesDeclarationTree = {
|
|
284
|
+
[x: string]: RegleRuleRaw<any, any, boolean, any> | undefined;
|
|
285
|
+
};
|
|
286
|
+
type AllRulesDeclarations = CustomRulesDeclarationTree & DefaultValidators;
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* @public
|
|
290
|
+
*/
|
|
291
|
+
type ReglePartialValidationTree<TForm extends Record<string, any>, TCustomRules extends Partial<AllRulesDeclarations> = Partial<AllRulesDeclarations>> = {
|
|
292
|
+
[TKey in keyof TForm]?: RegleFormPropertyType<TForm[TKey], TCustomRules>;
|
|
293
|
+
};
|
|
294
|
+
/**
|
|
295
|
+
* @public
|
|
296
|
+
*/
|
|
297
|
+
type RegleValidationTree<TForm extends Record<string, any>, TCustomRules extends Partial<AllRulesDeclarations> = Partial<AllRulesDeclarations>> = {
|
|
298
|
+
[TKey in keyof TForm]: RegleFormPropertyType<TForm[TKey], TCustomRules>;
|
|
299
|
+
};
|
|
300
|
+
/**
|
|
301
|
+
* @public
|
|
302
|
+
*/
|
|
303
|
+
type RegleComputedRules<TForm extends MaybeRef<Record<string, any>>, TCustomRules extends Partial<AllRulesDeclarations> | Regle<any, any> = Partial<AllRulesDeclarations>, TState = TForm extends Ref<infer R> ? R : TForm, TCustom = TCustomRules extends Regle<any, infer R> ? R extends ReglePartialValidationTree<any, infer C> ? C : Partial<AllRulesDeclarations> : TCustomRules> = {
|
|
304
|
+
[TKey in keyof TState]?: RegleFormPropertyType<TState[TKey], TCustom extends Partial<AllRulesDeclarations> ? TCustom : {}>;
|
|
305
|
+
};
|
|
306
|
+
/**
|
|
307
|
+
* @public
|
|
308
|
+
*/
|
|
309
|
+
type RegleFormPropertyType<TValue = any, TCustomRules extends Partial<AllRulesDeclarations> = Partial<AllRulesDeclarations>> = [NonNullable<TValue>] extends [never] ? RegleRuleDecl<TValue, TCustomRules> : NonNullable<TValue> extends Array<any> ? RegleCollectionRuleDecl<TValue, TCustomRules> : NonNullable<TValue> extends Date ? RegleRuleDecl<NonNullable<TValue>, TCustomRules> : NonNullable<TValue> extends File ? RegleRuleDecl<NonNullable<TValue>, TCustomRules> : NonNullable<TValue> extends Ref<infer V> ? RegleFormPropertyType<V, TCustomRules> : NonNullable<TValue> extends Record<string, any> ? ReglePartialValidationTree<NonNullable<TValue>, TCustomRules> : RegleRuleDecl<NonNullable<TValue>, TCustomRules>;
|
|
310
|
+
/**
|
|
311
|
+
* @public
|
|
312
|
+
* Rule tree for a form property
|
|
313
|
+
*/
|
|
314
|
+
type RegleRuleDecl<TValue extends any = any, TCustomRules extends Partial<AllRulesDeclarations> = Partial<AllRulesDeclarations>> = FieldRegleBehaviourOptions & {
|
|
315
|
+
[TKey in keyof TCustomRules]?: NonNullable<TCustomRules[TKey]> extends RegleRuleWithParamsDefinition<any, infer TParams> ? RegleRuleDefinition<TValue, TParams, boolean> : NonNullable<TCustomRules[TKey]> extends RegleRuleDefinition<any, any, any, any> ? FormRuleDeclaration<TValue, any> : FormRuleDeclaration<TValue, any> | FieldRegleBehaviourOptions[keyof FieldRegleBehaviourOptions];
|
|
316
|
+
};
|
|
317
|
+
/**
|
|
318
|
+
* @public
|
|
319
|
+
*/
|
|
320
|
+
type RegleCollectionRuleDeclKeyProperty = {
|
|
321
|
+
$key?: PropertyKey;
|
|
322
|
+
};
|
|
323
|
+
/**
|
|
324
|
+
* @public
|
|
325
|
+
*/
|
|
326
|
+
type RegleCollectionRuleDecl<TValue = any[], TCustomRules extends Partial<AllRulesDeclarations> = Partial<AllRulesDeclarations>> = (RegleRuleDecl<NonNullable<TValue>, TCustomRules> & {
|
|
327
|
+
$each?: MaybeGetter<RegleFormPropertyType<ArrayElement<NonNullable<TValue>>, TCustomRules> & RegleCollectionRuleDeclKeyProperty, ArrayElement<TValue>>;
|
|
328
|
+
}) | {
|
|
329
|
+
$each?: MaybeGetter<RegleFormPropertyType<ArrayElement<NonNullable<TValue>>, TCustomRules>, ArrayElement<TValue>>;
|
|
330
|
+
};
|
|
331
|
+
/**
|
|
332
|
+
* @public
|
|
333
|
+
*/
|
|
334
|
+
type InlineRuleDeclaration<TValue extends any = any, TParams extends any[] = any[], TReturn extends RegleRuleMetadataDefinition | Promise<RegleRuleMetadataDefinition> = RegleRuleMetadataDefinition | Promise<RegleRuleMetadataDefinition>> = (value: Maybe<TValue>, ...args: UnwrapRegleUniversalParams<TParams>) => TReturn;
|
|
335
|
+
/**
|
|
336
|
+
* @public
|
|
337
|
+
* Regroup inline and registered rules
|
|
338
|
+
* */
|
|
339
|
+
type FormRuleDeclaration<TValue extends any, TParams extends any[], TReturn extends RegleRuleMetadataDefinition | Promise<RegleRuleMetadataDefinition> = RegleRuleMetadataDefinition | Promise<RegleRuleMetadataDefinition>, TMetadata extends RegleRuleMetadataDefinition = TReturn extends Promise<infer M> ? M : TReturn, TAsync extends boolean = boolean> = InlineRuleDeclaration<TValue, TParams, TReturn> | RegleRuleDefinition<TValue, TParams, TAsync, TMetadata>;
|
|
340
|
+
|
|
341
|
+
type RegleErrorTree<TRules extends ReglePartialValidationTree<any, any>, TExternal extends RegleExternalErrorTree<Record<string, unknown>> = never> = {
|
|
342
|
+
readonly [K in keyof TRules]: RegleValidationErrors<TRules[K], K extends keyof TExternal ? TExternal[K] : never>;
|
|
343
|
+
} & {
|
|
344
|
+
readonly [K in keyof NonPresentKeys<TRules, TExternal>]: RegleExternalValidationErrorsReport<TExternal[K]>;
|
|
345
|
+
};
|
|
346
|
+
type RegleValidationErrors<TRule extends RegleFormPropertyType<any, any> | undefined = never, TExternalError extends RegleExternalValidationErrors<any> | undefined = never> = TRule extends RegleCollectionRuleDefinition ? RegleCollectionErrors<ExtractFromGetter<TRule['$each']>, TExternalError extends RegleExternalCollectionErrors ? ArrayElement<TExternalError['$each']> : never> : TRule extends RegleRuleDecl<any, any> ? string[] : TRule extends ReglePartialValidationTree<any, any> ? RegleErrorTree<TRule, TExternalError extends RegleExternalErrorTree ? TExternalError : never> : string[];
|
|
347
|
+
type RegleCollectionErrors<TRule extends RegleFormPropertyType<any, any> | undefined = never, TExternalError extends RegleExternalValidationErrors<any> | undefined = never> = {
|
|
348
|
+
readonly $errors: string[];
|
|
349
|
+
readonly $each: RegleValidationErrors<TRule, TExternalError>[];
|
|
350
|
+
};
|
|
351
|
+
type RegleExternalErrorTree<TState extends Record<string, any> = Record<string, any>> = {
|
|
352
|
+
[K in keyof TState]?: RegleExternalValidationErrors<TState[K]>;
|
|
353
|
+
};
|
|
354
|
+
type RegleExternalValidationErrors<TValue extends any> = [NonNullable<TValue>] extends [
|
|
355
|
+
never
|
|
356
|
+
] ? string[] : TValue extends Array<infer U> ? RegleExternalCollectionErrors<U> : NonNullable<TValue> extends Date ? string[] : NonNullable<TValue> extends File ? string[] : TValue extends Record<string, any> ? RegleExternalErrorTree<TValue> : string[];
|
|
357
|
+
type RegleExternalCollectionErrors<TValue extends any = any> = {
|
|
358
|
+
$errors?: string[];
|
|
359
|
+
$each?: RegleExternalValidationErrors<TValue>[];
|
|
360
|
+
};
|
|
361
|
+
type RegleExternalValidationErrorsReport<TExternalError extends RegleExternalValidationErrors<any> | undefined = never> = TExternalError extends RegleExternalCollectionErrors ? RegleCollectionErrors<TExternalError['$each']> : TExternalError extends string[] ? string[] : TExternalError extends RegleExternalErrorTree<any> ? RegleErrorTree<TExternalError> : string[];
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* @public
|
|
365
|
+
*/
|
|
366
|
+
type RegleStatus<TState extends Record<string, any> = Record<string, any>, TRules extends ReglePartialValidationTree<TState> = Record<string, any>, TValidationGroups extends Record<string, RegleValidationGroupEntry[]> = never> = RegleCommonStatus<TState> & {
|
|
367
|
+
readonly $fields: {
|
|
368
|
+
readonly [TKey in keyof TRules]: InferRegleStatusType<NonNullable<TRules[TKey]>, TState, TKey>;
|
|
369
|
+
};
|
|
370
|
+
readonly $errors: RegleErrorTree<TRules>;
|
|
371
|
+
readonly $silentErrors: RegleErrorTree<TRules>;
|
|
372
|
+
} & ([TValidationGroups] extends [never] ? {} : {
|
|
373
|
+
$groups: {
|
|
374
|
+
readonly [TKey in keyof TValidationGroups]: RegleValidationGroupOutput;
|
|
375
|
+
};
|
|
376
|
+
});
|
|
377
|
+
/**
|
|
378
|
+
* @public
|
|
379
|
+
*/
|
|
380
|
+
type InferRegleStatusType<TRule extends RegleCollectionRuleDecl | RegleRuleDecl | ReglePartialValidationTree<any>, TState extends Record<PropertyKey, any> = any, TKey extends PropertyKey = string> = TRule extends RegleCollectionRuleDefinition<any, any> ? NonNullable<TState[TKey]> extends Array<Record<string, any> | any> ? ExtractFromGetter<TRule['$each']> extends RegleRuleDecl | ReglePartialValidationTree<any> ? RegleCollectionStatus<ExtractFromGetter<TRule['$each']>, TState[TKey], TRule> : never : RegleFieldStatus<TRule, TState, TKey> : TRule extends ReglePartialValidationTree<any> ? NonNullable<TState[TKey]> extends Array<any> ? RegleCommonStatus<TState[TKey]> : NonNullable<TState[TKey]> extends Record<PropertyKey, any> ? RegleStatus<TState[TKey], TRule> : RegleFieldStatus<TRule, TState, TKey> : RegleFieldStatus<TRule, TState, TKey>;
|
|
381
|
+
/**
|
|
382
|
+
* @public
|
|
383
|
+
*/
|
|
384
|
+
interface RegleFieldStatus<TRules extends RegleFormPropertyType<any, Partial<AllRulesDeclarations>> = Record<string, any>, TState extends Record<PropertyKey, any> = any, TKey extends PropertyKey = string> extends RegleCommonStatus<TState> {
|
|
385
|
+
$value: UnwrapNestedRefs<TState[TKey]>;
|
|
386
|
+
readonly $errors: string[];
|
|
387
|
+
readonly $silentErrors: string[];
|
|
388
|
+
readonly $externalErrors?: string[];
|
|
389
|
+
readonly $rules: {
|
|
390
|
+
readonly [TRuleKey in keyof Omit<TRules, '$each' | keyof FieldRegleBehaviourOptions>]: RegleRuleStatus<TState[TKey], TRules[TRuleKey] extends RegleRuleDefinition<any, infer TParams, any> ? TParams : [], TRules[TRuleKey] extends RegleRuleDefinition<any, any, any, infer TMetadata> ? TMetadata : TRules[TRuleKey] extends InlineRuleDeclaration<any, any[], infer TMetadata> ? TMetadata extends Promise<infer P> ? P : TMetadata : never>;
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* @public
|
|
395
|
+
*/
|
|
396
|
+
interface RegleCommonStatus<TValue = any> {
|
|
397
|
+
readonly $valid: boolean;
|
|
398
|
+
readonly $invalid: boolean;
|
|
399
|
+
readonly $dirty: boolean;
|
|
400
|
+
readonly $anyDirty: boolean;
|
|
401
|
+
readonly $pending: boolean;
|
|
402
|
+
readonly $error: boolean;
|
|
403
|
+
$id?: string;
|
|
404
|
+
$value: UnwrapNestedRefs<TValue>;
|
|
405
|
+
$touch(): void;
|
|
406
|
+
$reset(): void;
|
|
407
|
+
$validate(): Promise<boolean>;
|
|
408
|
+
$unwatch(): void;
|
|
409
|
+
$watch(): void;
|
|
410
|
+
$clearExternalErrors(): void;
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* @public
|
|
414
|
+
*/
|
|
415
|
+
type RegleRuleStatus<TValue = any, TParams extends any[] = any[], TMetadata extends RegleRuleMetadataDefinition = never> = {
|
|
416
|
+
readonly $type: string;
|
|
417
|
+
readonly $message: string | string[];
|
|
418
|
+
readonly $active: boolean;
|
|
419
|
+
readonly $valid: boolean;
|
|
420
|
+
readonly $pending: boolean;
|
|
421
|
+
readonly $path: string;
|
|
422
|
+
readonly $metadata: TMetadata;
|
|
423
|
+
$validator: (value: TValue, ...args: TParams) => boolean | Promise<boolean>;
|
|
424
|
+
$validate(): Promise<boolean>;
|
|
425
|
+
$reset(): void;
|
|
426
|
+
} & ([TParams] extends [[]] ? {} : {
|
|
427
|
+
readonly $params: TParams;
|
|
428
|
+
});
|
|
429
|
+
/**
|
|
430
|
+
* @public
|
|
431
|
+
*/
|
|
432
|
+
interface RegleCollectionStatus<TRules extends RegleRuleDecl | ReglePartialValidationTree<any>, TState extends any[], TFieldRule extends RegleCollectionRuleDecl<any, any> = never> extends Omit<RegleFieldStatus<TRules, TState>, '$errors' | '$silentErrors'> {
|
|
433
|
+
readonly $each: Array<InferRegleStatusType<NonNullable<TRules>, NonNullable<TState>, number>>;
|
|
434
|
+
readonly $field: RegleFieldStatus<TFieldRule, TState>;
|
|
435
|
+
readonly $errors: RegleErrorTree<TRules>;
|
|
436
|
+
readonly $silentErrors: RegleErrorTree<TRules>;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
/**
|
|
440
|
+
* @description
|
|
441
|
+
* Create a typed custom rule that can be used like default rules.
|
|
442
|
+
* It can also be declared in the global options
|
|
443
|
+
*
|
|
444
|
+
* It will automatically detect if the rule is async
|
|
445
|
+
*
|
|
446
|
+
* @typeParam TValue - The input value the rule should receive
|
|
447
|
+
* @typeParam TParams - Tuple declaration of the rule parameters (if any)
|
|
448
|
+
*
|
|
449
|
+
* @param definition - The rule processors object
|
|
450
|
+
*
|
|
451
|
+
* @returns A rule definition that can be callable depending on params presence
|
|
452
|
+
*
|
|
453
|
+
* @exemple
|
|
454
|
+
*
|
|
455
|
+
* ```ts
|
|
456
|
+
* // Create a simple rule with no params
|
|
457
|
+
* import {ruleHelpers} from '@regle/rules';
|
|
458
|
+
*
|
|
459
|
+
* export const isFoo = createRule({
|
|
460
|
+
* validator(value: string) {
|
|
461
|
+
* if (ruleHelpers.isFilled(value)) {
|
|
462
|
+
* return value === 'foo';
|
|
463
|
+
* }
|
|
464
|
+
* return true
|
|
465
|
+
* },
|
|
466
|
+
* message: "The value should be 'foo'"
|
|
467
|
+
* })
|
|
468
|
+
* ```
|
|
469
|
+
*/
|
|
470
|
+
declare function createRule<TValue extends any, TParams extends any[], TReturn extends RegleRuleMetadataDefinition | Promise<RegleRuleMetadataDefinition>, TMetadata extends RegleRuleMetadataDefinition = TReturn extends Promise<infer M> ? M : TReturn, TAsync extends boolean = TReturn extends Promise<any> ? true : false>(definition: RegleRuleInit<TValue, TParams, TReturn, TMetadata, TAsync>): InferRegleRule<TValue, TParams, TAsync, TMetadata>;
|
|
471
|
+
|
|
472
|
+
/**
|
|
473
|
+
* Returns a clean list of parameters
|
|
474
|
+
* Removing Ref and executing function to return the unwraped value
|
|
475
|
+
*/
|
|
476
|
+
declare function unwrapRuleParameters<TParams extends any[]>(params: ParamDecl[]): TParams;
|
|
477
|
+
|
|
478
|
+
declare const useRegle: <TState extends Record<string, any>, TRules extends ReglePartialValidationTree<TState, Partial<AllRulesDeclarations>>, TExternal extends RegleExternalErrorTree<TState>, TValidationGroups extends Record<string, RegleValidationGroupEntry[]>, TValid = keyof TRules extends keyof TState ? true : false>(state: MaybeRef<TState> | DeepReactiveState<TState>, rulesFactory: TValid extends true ? TRules | ComputedRef<TRules> | (() => TRules) : never, options?: (Partial<DeepMaybeRef<RegleBehaviourOptions>> & LocalRegleBehaviourOptions<TState, TRules, TExternal, TValidationGroups>) | undefined) => Regle<TState, TRules, TExternal, TValidationGroups>;
|
|
479
|
+
|
|
480
|
+
declare function defineRegleConfig<TCustomRules extends Partial<AllRulesDeclarations>>({ rules, modifiers, }: {
|
|
481
|
+
rules?: () => TCustomRules;
|
|
482
|
+
modifiers?: RegleBehaviourOptions;
|
|
483
|
+
}): <TState extends Record<string, any>, TRules extends ReglePartialValidationTree<TState, Partial<AllRulesDeclarations> & TCustomRules>, TExternal extends RegleExternalErrorTree<TState>, TValidationGroups extends Record<string, RegleValidationGroupEntry[]>, TValid = keyof TRules extends keyof TState ? true : false>(state: vue.MaybeRef<TState> | DeepReactiveState<TState>, rulesFactory: TValid extends true ? TRules | vue.ComputedRef<TRules> | (() => TRules) : never, options?: (Partial<DeepMaybeRef<RegleBehaviourOptions>> & LocalRegleBehaviourOptions<TState, TRules, TExternal, TValidationGroups>) | undefined) => Regle<TState, TRules, TExternal, TValidationGroups>;
|
|
484
|
+
|
|
485
|
+
export { type DeepMaybeRef, type FormRuleDeclaration, type InlineRuleDeclaration, InternalRuleType, type LocalRegleBehaviourOptions, type Maybe, type ParamDecl, type Regle, type RegleBehaviourOptions, type RegleCollectionErrors, type RegleCollectionRuleDecl, type RegleCollectionRuleDefinition, type RegleCollectionStatus, type RegleCommonStatus, type RegleComputedRules, type RegleErrorTree, type RegleExternalCollectionErrors, type RegleExternalErrorTree, type RegleExternalValidationErrors, type RegleExternalValidationErrorsReport, type RegleFieldStatus, type RegleFormPropertyType, type RegleInternalRuleDefs, type ReglePartialValidationTree, type RegleRuleCore, type RegleRuleDecl, type RegleRuleDefinition, type RegleRuleDefinitionProcessor, type RegleRuleDefinitionWithMetadataProcessor, type RegleRuleInit, type RegleRuleMetadataConsumer, type RegleRuleMetadataDefinition, type RegleRuleRaw, type RegleRuleStatus, type RegleRuleWithParamsDefinition, type RegleStatus, type RegleUniversalParams, type RegleValidationErrors, type RegleValidationGroupEntry, type RegleValidationGroupOutput, type RegleValidationTree, type UnwrapRegleUniversalParams, createRule, defineRegleConfig, unwrapRuleParameters, useRegle };
|
package/dist/index.d.ts
CHANGED
|
@@ -93,6 +93,7 @@ type AddDollarToOptions<T extends Record<string, any>> = {
|
|
|
93
93
|
|
|
94
94
|
interface Regle<TState extends Record<string, any> = EmptyObject, TRules extends ReglePartialValidationTree<TState, CustomRulesDeclarationTree> = EmptyObject, TExternal extends RegleExternalErrorTree<TState> = never, TValidationGroups extends Record<string, RegleValidationGroupEntry[]> = never> {
|
|
95
95
|
regle: RegleStatus<TState, TRules, TValidationGroups>;
|
|
96
|
+
r$: RegleStatus<TState, TRules, TValidationGroups>;
|
|
96
97
|
/** Show active errors based on your behaviour options (lazy, autoDirty)
|
|
97
98
|
* It allow you to skip scouting the `regle` object
|
|
98
99
|
*/
|
|
@@ -105,14 +106,14 @@ interface Regle<TState extends Record<string, any> = EmptyObject, TRules extends
|
|
|
105
106
|
type DeepReactiveState<T extends Record<string, any>> = {
|
|
106
107
|
[K in keyof T]: MaybeRef<T[K]>;
|
|
107
108
|
};
|
|
108
|
-
type DeepSafeFormState<TState extends Record<string, any>, TRules extends ReglePartialValidationTree<TState, CustomRulesDeclarationTree>> = [unknown] extends [TState] ?
|
|
109
|
+
type DeepSafeFormState<TState extends Record<string, any>, TRules extends ReglePartialValidationTree<TState, CustomRulesDeclarationTree>> = [unknown] extends [TState] ? {} : {
|
|
109
110
|
[K in keyof TState as [SafeProperty<TState[K], TRules[K]>] extends [never] ? K : never]?: [
|
|
110
111
|
SafeProperty<TState[K], TRules[K]>
|
|
111
112
|
] extends [never] ? TState[K] : SafeProperty<TState[K], TRules[K]>;
|
|
112
113
|
} & {
|
|
113
114
|
[K in keyof TState as [SafeProperty<TState[K], TRules[K]>] extends [never] ? never : K]-?: SafeProperty<TState[K], TRules[K]>;
|
|
114
115
|
};
|
|
115
|
-
type SafeProperty<TState, TRule extends RegleFormPropertyType<any, any> | undefined = never> = TRule extends RegleCollectionRuleDefinition ? TState extends Array<any> ? SafeProperty<TState[number], ExtractFromGetter<TRule['$each']>>[] : never : TRule extends ReglePartialValidationTree<any, any> ? TState extends Record<string, any> ? DeepSafeFormState<TState, TRule> :
|
|
116
|
+
type SafeProperty<TState, TRule extends RegleFormPropertyType<any, any> | undefined = never> = TRule extends RegleCollectionRuleDefinition<any, any> ? TState extends Array<any> ? SafeProperty<TState[number], ExtractFromGetter<TRule['$each']>>[] : never : TRule extends ReglePartialValidationTree<any, any> ? TState extends Record<string, any> ? DeepSafeFormState<TState, TRule> : TRule extends RegleRuleDecl<any, any> ? unknown extends TRule['required'] ? never : TRule['required'] extends undefined ? never : TRule['required'] extends RegleRuleDefinition<any, infer Params, any, any, any> ? Params extends never[] ? TState : never : never : never : never;
|
|
116
117
|
|
|
117
118
|
type ParamDecl<T = any> = MaybeRef<Maybe<T>> | (() => Maybe<T>);
|
|
118
119
|
type CreateFn<T extends any[]> = (...args: T) => any;
|
|
@@ -272,6 +273,7 @@ type DefaultValidators = {
|
|
|
272
273
|
], false, boolean>;
|
|
273
274
|
minValue: RegleRuleWithParamsDefinition<number, [count: number], false, boolean>;
|
|
274
275
|
numeric: RegleRuleDefinition<string | number, [], false, boolean, string | number>;
|
|
276
|
+
regex: RegleRuleWithParamsDefinition<string, [regexp: RegExp], false, boolean>;
|
|
275
277
|
required: RegleRuleDefinition<unknown, []>;
|
|
276
278
|
sameAs: RegleRuleWithParamsDefinition<unknown, [target: unknown], false, boolean>;
|
|
277
279
|
startsWith: RegleRuleWithParamsDefinition<string, [part: Maybe<string>], false, boolean>;
|
|
@@ -367,7 +369,7 @@ type RegleStatus<TState extends Record<string, any> = Record<string, any>, TRule
|
|
|
367
369
|
};
|
|
368
370
|
readonly $errors: RegleErrorTree<TRules>;
|
|
369
371
|
readonly $silentErrors: RegleErrorTree<TRules>;
|
|
370
|
-
} & ([TValidationGroups] extends [never] ?
|
|
372
|
+
} & ([TValidationGroups] extends [never] ? {} : {
|
|
371
373
|
$groups: {
|
|
372
374
|
readonly [TKey in keyof TValidationGroups]: RegleValidationGroupOutput;
|
|
373
375
|
};
|
|
@@ -421,7 +423,7 @@ type RegleRuleStatus<TValue = any, TParams extends any[] = any[], TMetadata exte
|
|
|
421
423
|
$validator: (value: TValue, ...args: TParams) => boolean | Promise<boolean>;
|
|
422
424
|
$validate(): Promise<boolean>;
|
|
423
425
|
$reset(): void;
|
|
424
|
-
} & ([TParams] extends [[]] ?
|
|
426
|
+
} & ([TParams] extends [[]] ? {} : {
|
|
425
427
|
readonly $params: TParams;
|
|
426
428
|
});
|
|
427
429
|
/**
|