@flowerforce/flower-core 3.1.1-beta.1 → 3.1.2-beta.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/CHANGELOG.md +7 -0
- package/dist/index.cjs.js +83 -4
- package/dist/index.esm.js +83 -5
- package/dist/src/CoreUtils.d.ts +3 -0
- package/dist/src/FlowerCoreStateFunctions.d.ts +3 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/interfaces/CoreInterface.d.ts +87 -0
- package/dist/src/interfaces/ReducerInterface.d.ts +203 -0
- package/dist/src/interfaces/SelectorsInterface.d.ts +70 -0
- package/dist/src/interfaces/UtilsInterface.d.ts +37 -0
- package/dist/src/rules-matcher/interface.d.ts +259 -0
- package/dist/src/rules-matcher/utils.d.ts +3 -0
- package/package.json +1 -1
@@ -6,25 +6,158 @@ export type CheckOperationObj = {
|
|
6
6
|
opt?: any;
|
7
7
|
};
|
8
8
|
export interface RulesMatcherUtils {
|
9
|
+
/**
|
10
|
+
* @param el
|
11
|
+
*
|
12
|
+
* Determines if a given value is a number.
|
13
|
+
* It checks if the value matches a numeric pattern using a regular expression.
|
14
|
+
*
|
15
|
+
* @returns
|
16
|
+
*/
|
9
17
|
isNumber: <T>(el: T) => boolean;
|
18
|
+
/**
|
19
|
+
* @param val
|
20
|
+
* @param data
|
21
|
+
* @param options
|
22
|
+
*
|
23
|
+
* Processes a single rule against provided data to check its validity.
|
24
|
+
* Returns a boolean indicating whether the rule is valid and a name for the rule.
|
25
|
+
*
|
26
|
+
* @returns
|
27
|
+
*/
|
10
28
|
rule: (block: Record<string, any>, keys: Record<string, any>, options: Record<string, any>) => {
|
11
29
|
valid: boolean;
|
12
30
|
name: string;
|
13
31
|
};
|
32
|
+
/**
|
33
|
+
* @param block
|
34
|
+
* @param keys
|
35
|
+
* @param options
|
36
|
+
*
|
37
|
+
* Extracts keys from a rule object.
|
38
|
+
* It recursively traverses through the rule object and extracts keys while handling $and and $or logical operators.
|
39
|
+
*
|
40
|
+
* @returns
|
41
|
+
*/
|
14
42
|
getKey: (block: RulesObject<any>, keys: Record<string, any>, options: Record<string, any>) => Record<string, any>;
|
43
|
+
/**
|
44
|
+
* @param v
|
45
|
+
*
|
46
|
+
* Checks if a given value is a Date object.
|
47
|
+
*
|
48
|
+
* @returns
|
49
|
+
*/
|
15
50
|
isDate: CheckTypeOf;
|
51
|
+
/**
|
52
|
+
* @param v
|
53
|
+
*
|
54
|
+
* Checks if a given value is defined (neither null nor undefined).
|
55
|
+
*
|
56
|
+
* @returns
|
57
|
+
*/
|
16
58
|
isDefined: CheckTypeOf;
|
59
|
+
/**
|
60
|
+
* @param v
|
61
|
+
*
|
62
|
+
* Checks if a given value is an object (it will return true if pass an Array).
|
63
|
+
*
|
64
|
+
* @returns
|
65
|
+
*/
|
17
66
|
isObject: CheckTypeOf;
|
67
|
+
/**
|
68
|
+
* @param v
|
69
|
+
*
|
70
|
+
* Checks if a given value is a function.
|
71
|
+
*
|
72
|
+
* @returns
|
73
|
+
*/
|
18
74
|
isFunction: CheckTypeOf;
|
75
|
+
/**
|
76
|
+
* @param v
|
77
|
+
*
|
78
|
+
* Checks if a given value is a string.
|
79
|
+
*
|
80
|
+
* @returns
|
81
|
+
*/
|
19
82
|
isString: CheckTypeOf;
|
83
|
+
/**
|
84
|
+
* @param value
|
85
|
+
*
|
86
|
+
* Returns the default comparison operation for a string value.
|
87
|
+
*
|
88
|
+
* @returns
|
89
|
+
*/
|
20
90
|
getDefaultStringValue: (value: '$required' | '$exists' | string) => CheckOperationObj;
|
91
|
+
/**
|
92
|
+
* @param value
|
93
|
+
*
|
94
|
+
* Determines the type of a given value.
|
95
|
+
*
|
96
|
+
* @returns
|
97
|
+
*/
|
21
98
|
getTypeOf: (value: any) => string | null;
|
99
|
+
/**
|
100
|
+
* @param value
|
101
|
+
*
|
102
|
+
* Returns the default rule configuration based on the type of the value.
|
103
|
+
*
|
104
|
+
* @returns
|
105
|
+
*/
|
22
106
|
getDefaultRule: (value: any) => CheckOperationObj;
|
107
|
+
/**
|
108
|
+
* @param value
|
109
|
+
*
|
110
|
+
* Checks if a value is empty.
|
111
|
+
* Handles various data types including null, undefined, functions, strings, arrays, objects, and dates.
|
112
|
+
*
|
113
|
+
* @returns
|
114
|
+
*/
|
23
115
|
isEmpty: (value: any) => boolean;
|
116
|
+
/**
|
117
|
+
* @param a
|
118
|
+
*
|
119
|
+
* Converts a value into an array if it is not already.
|
120
|
+
*
|
121
|
+
* @returns
|
122
|
+
*/
|
24
123
|
forceArray: <T>(value: T) => Array<T>;
|
124
|
+
/**
|
125
|
+
* @param path
|
126
|
+
* @param prefix
|
127
|
+
*
|
128
|
+
* Constructs a path with a prefix if provided.
|
129
|
+
* Handles special characters such as '^' and '$'.
|
130
|
+
*
|
131
|
+
* @returns
|
132
|
+
*/
|
25
133
|
getPath: (path: string, prefix?: string) => string;
|
134
|
+
/**
|
135
|
+
* @param el
|
136
|
+
*
|
137
|
+
* Converts a value into a number.
|
138
|
+
* Handles cases where the value might be a string representation of a number or an array.
|
139
|
+
*
|
140
|
+
* @returns
|
141
|
+
*/
|
26
142
|
forceNumber: <T>(value: T) => number;
|
143
|
+
/**
|
144
|
+
* @param block
|
145
|
+
* @param data
|
146
|
+
* @param options
|
147
|
+
*
|
148
|
+
* Checks if a given rule is valid against the provided data.
|
149
|
+
*
|
150
|
+
* @returns
|
151
|
+
*/
|
27
152
|
checkRule: <T extends Record<string, any>>(block: RulesObject<T>, data: T, options: Record<string, any>) => boolean;
|
153
|
+
/**
|
154
|
+
* @param rules
|
155
|
+
* @param options
|
156
|
+
*
|
157
|
+
* Extracts keys from a set of rules.
|
158
|
+
*
|
159
|
+
* @returns
|
160
|
+
*/
|
28
161
|
getKeys: <T extends Record<string, any>>(rules?: T, options?: Record<string, any>) => string[] | null;
|
29
162
|
}
|
30
163
|
export declare enum OperatorsKeys {
|
@@ -46,19 +179,145 @@ export declare enum OperatorsKeys {
|
|
46
179
|
}
|
47
180
|
export type OperatorsFunction = (a: any, b: any, opt?: any, data?: any) => boolean;
|
48
181
|
export type Operators = {
|
182
|
+
/**
|
183
|
+
* @param a
|
184
|
+
* @param b
|
185
|
+
*
|
186
|
+
* Checks if a value exists or not.
|
187
|
+
* If the user input is not empty, it returns true if the rule value is true, otherwise false.
|
188
|
+
*
|
189
|
+
* @returns
|
190
|
+
*/
|
49
191
|
$exists: OperatorsFunction;
|
192
|
+
/**
|
193
|
+
* @param a
|
194
|
+
* @param b
|
195
|
+
*
|
196
|
+
* Checks if two values are equal.
|
197
|
+
*
|
198
|
+
* @returns
|
199
|
+
*/
|
50
200
|
$eq: OperatorsFunction;
|
201
|
+
/**
|
202
|
+
* @param a
|
203
|
+
* @param b
|
204
|
+
*
|
205
|
+
* Checks if two values are not equal.
|
206
|
+
*
|
207
|
+
* @returns
|
208
|
+
*/
|
51
209
|
$ne: OperatorsFunction;
|
210
|
+
/**
|
211
|
+
* @param a
|
212
|
+
* @param b
|
213
|
+
*
|
214
|
+
* Checks if the user input value is greater than the rule value after converting them both to numbers.
|
215
|
+
*
|
216
|
+
* @returns
|
217
|
+
*/
|
52
218
|
$gt: OperatorsFunction;
|
219
|
+
/**
|
220
|
+
* @param a
|
221
|
+
* @param b
|
222
|
+
*
|
223
|
+
* Checks if the user input value is greater than or equal to the rule value.
|
224
|
+
*
|
225
|
+
* @returns
|
226
|
+
*/
|
53
227
|
$gte: OperatorsFunction;
|
228
|
+
/**
|
229
|
+
* @param a
|
230
|
+
* @param b
|
231
|
+
*
|
232
|
+
* Checks if the user input value is less than the rule value.
|
233
|
+
*
|
234
|
+
* @returns
|
235
|
+
*/
|
54
236
|
$lt: OperatorsFunction;
|
237
|
+
/**
|
238
|
+
* @param a
|
239
|
+
* @param b
|
240
|
+
*
|
241
|
+
* Checks if the user input value is less than or equal to the rule value.
|
242
|
+
*
|
243
|
+
* @returns
|
244
|
+
*/
|
55
245
|
$lte: OperatorsFunction;
|
246
|
+
/**
|
247
|
+
* @param a
|
248
|
+
* @param b
|
249
|
+
*
|
250
|
+
* Compares the lengths of two strings and checks if the length of the user input string is greater than the rule value.
|
251
|
+
*
|
252
|
+
* @returns
|
253
|
+
*/
|
56
254
|
$strGt: OperatorsFunction;
|
255
|
+
/**
|
256
|
+
* @param a
|
257
|
+
* @param b
|
258
|
+
*
|
259
|
+
* Compares the lengths of two strings and checks if the length of the user input string is greater than or equal to the rule value.
|
260
|
+
*
|
261
|
+
* @returns
|
262
|
+
*/
|
57
263
|
$strGte: OperatorsFunction;
|
264
|
+
/**
|
265
|
+
* @param a
|
266
|
+
* @param b
|
267
|
+
*
|
268
|
+
* Compares the lengths of two strings and checks if the length of the user input string is less than the rule value.
|
269
|
+
*
|
270
|
+
* @returns
|
271
|
+
*/
|
58
272
|
$strLt: OperatorsFunction;
|
273
|
+
/**
|
274
|
+
* @param a
|
275
|
+
* @param b
|
276
|
+
*
|
277
|
+
* Compares the lengths of two strings and checks if the length of the user input string is less than or equal to the rule value.
|
278
|
+
*
|
279
|
+
* @returns
|
280
|
+
*/
|
59
281
|
$strLte: OperatorsFunction;
|
282
|
+
/**
|
283
|
+
* @param a
|
284
|
+
* @param b
|
285
|
+
*
|
286
|
+
* Checks if the user input value is in the array of rule values.
|
287
|
+
* It checks for intersection between the user input array and each rule value array.
|
288
|
+
*
|
289
|
+
* @returns
|
290
|
+
*/
|
60
291
|
$in: OperatorsFunction;
|
292
|
+
/**
|
293
|
+
* @param a
|
294
|
+
* @param b
|
295
|
+
*
|
296
|
+
* Checks if the user input value is not in the array of rule values.
|
297
|
+
* It checks for the absence of intersection between the user input array and each rule value array.
|
298
|
+
*
|
299
|
+
* @returns
|
300
|
+
*/
|
61
301
|
$nin: OperatorsFunction;
|
302
|
+
/**
|
303
|
+
* @param a
|
304
|
+
* @param b
|
305
|
+
*
|
306
|
+
* Checks if all elements in the user input array are present in the array of rule values.
|
307
|
+
* It checks for intersection between each element of the user input array and each rule value array.
|
308
|
+
*
|
309
|
+
* @returns
|
310
|
+
*/
|
62
311
|
$all: OperatorsFunction;
|
312
|
+
/**
|
313
|
+
* @param a
|
314
|
+
* @param b
|
315
|
+
* @param opt
|
316
|
+
*
|
317
|
+
* Performs a regular expression match on the user input value with the rule value(s).
|
318
|
+
* It supports either a single regular expression or an array of regular expressions.
|
319
|
+
*
|
320
|
+
* @returns
|
321
|
+
*/
|
63
322
|
$regex: OperatorsFunction;
|
64
323
|
};
|
@@ -1,3 +1,6 @@
|
|
1
1
|
import { RulesMatcherUtils } from './interface';
|
2
|
+
/**
|
3
|
+
* Defines a utility object named rulesMatcherUtils, which contains various helper functions used for processing rules and data in a rule-matching context.
|
4
|
+
*/
|
2
5
|
declare const rulesMatcherUtils: RulesMatcherUtils;
|
3
6
|
export default rulesMatcherUtils;
|