@flowerforce/flower-core 4.0.1-beta.0 → 4.0.1-beta.10
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 +35 -0
- package/dist/index.cjs.js +171 -102
- package/dist/index.esm.js +162 -101
- package/dist/src/ABAC/abacEngine.d.ts +32 -0
- package/dist/src/ABAC/abacSingleton.d.ts +8 -0
- package/dist/src/ABAC/index.d.ts +2 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/interfaces/CoreInterface.d.ts +16 -23
- package/dist/src/interfaces/ReducerInterface.d.ts +26 -28
- package/dist/src/interfaces/RulesMatcherInterface.d.ts +11 -0
- package/dist/src/interfaces/SelectorsInterface.d.ts +17 -17
- package/dist/src/interfaces/Store.d.ts +1 -1
- package/dist/src/interfaces/UtilsInterface.d.ts +1 -1
- package/dist/src/rules-matcher/RulesMatcher.d.ts +1 -1
- package/dist/src/state-manager/state-functions/FlowerCoreMergedReducers.d.ts +2 -2
- package/dist/src/state-manager/state-functions/FlowerDataStateFunctions.d.ts +2 -13
- package/dist/src/state-manager/state-functions/index.d.ts +1 -1
- package/dist/src/state-manager/state-selectors/FlowerDataStateSelectors.d.ts +2 -0
- package/dist/src/state-manager/state-selectors/FlowerSelectorsMerged.d.ts +2 -2
- package/dist/src/state-manager/state-selectors/index.d.ts +2 -2
- package/dist/src/utils/FlowerCoreStateUtils.d.ts +1 -1
- package/dist/src/utils/FlowerDataCoreUtils.d.ts +2 -0
- package/dist/src/utils/index.d.ts +1 -1
- package/package.json +1 -1
- package/dist/src/state-manager/state-selectors/FlowerFormStateSelectors.d.ts +0 -2
- package/dist/src/utils/FlowerFormCoreUtils.d.ts +0 -2
|
@@ -1,18 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { NodeConfig } from './CoreInterface';
|
|
2
2
|
import { Flower } from './Store';
|
|
3
3
|
export type ActionWithPayload<T> = {
|
|
4
4
|
type: string;
|
|
5
5
|
payload: T;
|
|
6
6
|
};
|
|
7
7
|
type ReducerFunctionSign<T extends object, R> = (state: Record<string, Flower<T>>, action: ActionWithPayload<R>) => Record<string, Flower<T>> | void;
|
|
8
|
-
type
|
|
9
|
-
formName: string;
|
|
10
|
-
} & R>) => Record<string, T> | void;
|
|
11
|
-
export type ActionsTypes = 'historyAdd' | 'historyPrevToNode' | 'setFormTouched' | 'forceAddHistory' | 'historyPop' | 'restoreHistory' | 'replaceNode' | 'initializeFromNode' | 'forceResetHistory' | 'destroy' | 'initNodes' | 'setCurrentNode' | 'formAddErrors' | 'formRemoveErrors' | 'addData' | 'addDataByPath' | 'replaceData' | 'unsetData' | 'setFormIsValidating' | 'resetForm' | 'formFieldTouch' | 'formFieldFocus' | 'node' | 'prevToNode' | 'next' | 'prev' | 'reset';
|
|
12
|
-
/**
|
|
13
|
-
* These functions are Redux reducers used in a Flux architecture for managing state transitions and updates in a Flower application.
|
|
14
|
-
*/
|
|
15
|
-
export type CoreReducersFunctions<T extends Record<string, any> = Record<string, Flower<Record<string, any>>>> = {
|
|
8
|
+
export type CoreReducersFunctions<T extends Record<string, any> = Record<FlowCaseReducersNames, Flower<Record<string, any>>>> = {
|
|
16
9
|
/**
|
|
17
10
|
* @param state
|
|
18
11
|
* @param action
|
|
@@ -133,7 +126,7 @@ export type CoreReducersFunctions<T extends Record<string, any> = Record<string,
|
|
|
133
126
|
name: string;
|
|
134
127
|
startId: string;
|
|
135
128
|
persist: boolean;
|
|
136
|
-
nodes:
|
|
129
|
+
nodes: NodeConfig[];
|
|
137
130
|
initialState: {
|
|
138
131
|
startId?: string;
|
|
139
132
|
current?: string;
|
|
@@ -204,7 +197,7 @@ export type CoreReducersFunctions<T extends Record<string, any> = Record<string,
|
|
|
204
197
|
*
|
|
205
198
|
* @returns state
|
|
206
199
|
*/
|
|
207
|
-
|
|
200
|
+
back: ReducerFunctionSign<T, {
|
|
208
201
|
name?: string;
|
|
209
202
|
flowName?: string;
|
|
210
203
|
}>;
|
|
@@ -242,7 +235,11 @@ export type CoreReducersFunctions<T extends Record<string, any> = Record<string,
|
|
|
242
235
|
*/
|
|
243
236
|
>;
|
|
244
237
|
};
|
|
245
|
-
export type
|
|
238
|
+
export type FlowCaseReducersNames = 'historyAdd' | 'historyPrevToNode' | 'forceAddHistory' | 'historyPop' | 'restoreHistory' | 'replaceNode' | 'forceResetHistory' | 'destroy' | 'initNodes' | 'setCurrentNode' | 'node' | 'prevToNode' | 'next' | 'back' | 'restart' | 'reset';
|
|
239
|
+
type DataReducerFunctionSign<T extends object, R = object> = (state: Record<string, T>, action: ActionWithPayload<{
|
|
240
|
+
rootName: string;
|
|
241
|
+
} & R>) => Record<string, T> | void;
|
|
242
|
+
export type DataReducersFunctions<T extends Record<string, any> = Record<DataCaseReducersNames, Record<string, any>>> = {
|
|
246
243
|
/**
|
|
247
244
|
* @param state
|
|
248
245
|
* @param action
|
|
@@ -251,7 +248,7 @@ export type FormReducersFunctions<T extends Record<string, any> = Record<string,
|
|
|
251
248
|
*
|
|
252
249
|
* @returns state
|
|
253
250
|
*/
|
|
254
|
-
|
|
251
|
+
setFormSubmitted: DataReducerFunctionSign<T>;
|
|
255
252
|
/**
|
|
256
253
|
* @param state
|
|
257
254
|
* @param action
|
|
@@ -260,7 +257,7 @@ export type FormReducersFunctions<T extends Record<string, any> = Record<string,
|
|
|
260
257
|
*
|
|
261
258
|
* @returns state
|
|
262
259
|
*/
|
|
263
|
-
|
|
260
|
+
addCustomDataErrors: DataReducerFunctionSign<T, {
|
|
264
261
|
id: string;
|
|
265
262
|
errors: string[];
|
|
266
263
|
}>;
|
|
@@ -272,7 +269,7 @@ export type FormReducersFunctions<T extends Record<string, any> = Record<string,
|
|
|
272
269
|
*
|
|
273
270
|
* @returns state
|
|
274
271
|
*/
|
|
275
|
-
|
|
272
|
+
addDataErrors: DataReducerFunctionSign<T, {
|
|
276
273
|
id: string;
|
|
277
274
|
errors: {
|
|
278
275
|
[x: string]: string[];
|
|
@@ -286,7 +283,7 @@ export type FormReducersFunctions<T extends Record<string, any> = Record<string,
|
|
|
286
283
|
*
|
|
287
284
|
* @returns state
|
|
288
285
|
*/
|
|
289
|
-
|
|
286
|
+
fieldDirty: DataReducerFunctionSign<T, {
|
|
290
287
|
id: string;
|
|
291
288
|
dirty?: boolean;
|
|
292
289
|
}>;
|
|
@@ -298,7 +295,7 @@ export type FormReducersFunctions<T extends Record<string, any> = Record<string,
|
|
|
298
295
|
*
|
|
299
296
|
* @returns state
|
|
300
297
|
*/
|
|
301
|
-
|
|
298
|
+
fieldTouch: DataReducerFunctionSign<T, {
|
|
302
299
|
id: string;
|
|
303
300
|
touched?: boolean;
|
|
304
301
|
}>;
|
|
@@ -310,7 +307,7 @@ export type FormReducersFunctions<T extends Record<string, any> = Record<string,
|
|
|
310
307
|
*
|
|
311
308
|
* @returns state
|
|
312
309
|
*/
|
|
313
|
-
|
|
310
|
+
fieldFocus: DataReducerFunctionSign<T, {
|
|
314
311
|
id: string;
|
|
315
312
|
focused?: boolean;
|
|
316
313
|
}>;
|
|
@@ -322,7 +319,7 @@ export type FormReducersFunctions<T extends Record<string, any> = Record<string,
|
|
|
322
319
|
*
|
|
323
320
|
* @returns state
|
|
324
321
|
*/
|
|
325
|
-
|
|
322
|
+
removeDataErrors: DataReducerFunctionSign<T, {
|
|
326
323
|
id: string;
|
|
327
324
|
}>;
|
|
328
325
|
/**
|
|
@@ -333,7 +330,7 @@ export type FormReducersFunctions<T extends Record<string, any> = Record<string,
|
|
|
333
330
|
*
|
|
334
331
|
* @returns state
|
|
335
332
|
*/
|
|
336
|
-
addData:
|
|
333
|
+
addData: DataReducerFunctionSign<T, {
|
|
337
334
|
value: T;
|
|
338
335
|
}>;
|
|
339
336
|
/**
|
|
@@ -344,7 +341,7 @@ export type FormReducersFunctions<T extends Record<string, any> = Record<string,
|
|
|
344
341
|
*
|
|
345
342
|
* @returns state
|
|
346
343
|
*/
|
|
347
|
-
addDataByPath:
|
|
344
|
+
addDataByPath: DataReducerFunctionSign<T, {
|
|
348
345
|
id: string;
|
|
349
346
|
value: T | string;
|
|
350
347
|
dirty?: boolean;
|
|
@@ -357,7 +354,7 @@ export type FormReducersFunctions<T extends Record<string, any> = Record<string,
|
|
|
357
354
|
*
|
|
358
355
|
* @returns state
|
|
359
356
|
*/
|
|
360
|
-
replaceData:
|
|
357
|
+
replaceData: DataReducerFunctionSign<T, {
|
|
361
358
|
value: T;
|
|
362
359
|
}>;
|
|
363
360
|
/**
|
|
@@ -368,7 +365,7 @@ export type FormReducersFunctions<T extends Record<string, any> = Record<string,
|
|
|
368
365
|
*
|
|
369
366
|
* @returns state
|
|
370
367
|
*/
|
|
371
|
-
unsetData:
|
|
368
|
+
unsetData: DataReducerFunctionSign<T, {
|
|
372
369
|
id: string[] | string;
|
|
373
370
|
}>;
|
|
374
371
|
/**
|
|
@@ -379,7 +376,7 @@ export type FormReducersFunctions<T extends Record<string, any> = Record<string,
|
|
|
379
376
|
*
|
|
380
377
|
* @returns state
|
|
381
378
|
*/
|
|
382
|
-
|
|
379
|
+
setIsDataValidating: DataReducerFunctionSign<T, {
|
|
383
380
|
isValidating?: boolean;
|
|
384
381
|
}>;
|
|
385
382
|
/**
|
|
@@ -390,8 +387,8 @@ export type FormReducersFunctions<T extends Record<string, any> = Record<string,
|
|
|
390
387
|
*
|
|
391
388
|
* @returns state
|
|
392
389
|
*/
|
|
393
|
-
|
|
394
|
-
|
|
390
|
+
resetData: DataReducerFunctionSign<T, {
|
|
391
|
+
rootName: string;
|
|
395
392
|
initialData?: Record<string, any>;
|
|
396
393
|
}>;
|
|
397
394
|
/**
|
|
@@ -402,9 +399,10 @@ export type FormReducersFunctions<T extends Record<string, any> = Record<string,
|
|
|
402
399
|
*
|
|
403
400
|
* @returns state
|
|
404
401
|
*/
|
|
405
|
-
|
|
406
|
-
|
|
402
|
+
initData: DataReducerFunctionSign<T, {
|
|
403
|
+
rootName: string;
|
|
407
404
|
initialData: Record<string, any>;
|
|
408
405
|
}>;
|
|
409
406
|
};
|
|
407
|
+
export type DataCaseReducersNames = 'setFormSubmitted' | 'addCustomDataErrors' | 'addDataErrors' | 'fieldDirty' | 'fieldTouch' | 'fieldFocus' | 'removeDataErrors' | 'addData' | 'addDataByPath' | 'replaceData' | 'unsetData' | 'setIsDataValidating' | 'resetData' | 'initData';
|
|
410
408
|
export {};
|
|
@@ -161,7 +161,18 @@ export interface RulesMatcherUtils {
|
|
|
161
161
|
getKeys: <T extends Record<string, any>>(rules?: T, options?: Record<string, any>) => string[] | null;
|
|
162
162
|
}
|
|
163
163
|
export type OperatorsFunction = (a: any, b: any, opt?: any, data?: any) => boolean;
|
|
164
|
+
export type DecisionFunction = (subject: Record<string, any>, action: string, resource: Record<string, any>) => boolean;
|
|
164
165
|
export type Operators = {
|
|
166
|
+
/**
|
|
167
|
+
* @param subject
|
|
168
|
+
* @param action
|
|
169
|
+
* @param resource
|
|
170
|
+
*
|
|
171
|
+
* Checks if a operation is denied or permitted based on ABAC rules.
|
|
172
|
+
*
|
|
173
|
+
* @returns
|
|
174
|
+
*/
|
|
175
|
+
$can: DecisionFunction;
|
|
165
176
|
/**
|
|
166
177
|
* @param a
|
|
167
178
|
* @param b
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { REDUCER_NAME } from '../constants';
|
|
2
2
|
import { RulesObject } from './CoreInterface';
|
|
3
|
-
import { Flower,
|
|
3
|
+
import { Flower, Data, INode } from './Store';
|
|
4
4
|
export interface IFlowerSelectors {
|
|
5
5
|
/**
|
|
6
6
|
* @param state
|
|
@@ -57,7 +57,7 @@ export interface IFlowerSelectors {
|
|
|
57
57
|
[x: string]: Partial<INode>;
|
|
58
58
|
}, current: Flower<T>['current']): boolean;
|
|
59
59
|
}
|
|
60
|
-
export interface
|
|
60
|
+
export interface IDataSelectors {
|
|
61
61
|
/**
|
|
62
62
|
* @param state
|
|
63
63
|
* @returns
|
|
@@ -67,18 +67,18 @@ export interface IFormSelectors {
|
|
|
67
67
|
* @param state
|
|
68
68
|
* @returns
|
|
69
69
|
*/
|
|
70
|
-
|
|
70
|
+
selectGlobalData<T extends Record<string, any>>(state: {
|
|
71
71
|
[REDUCER_NAME.FLOWER_DATA]: {
|
|
72
|
-
[x: string]:
|
|
72
|
+
[x: string]: Data<T>;
|
|
73
73
|
};
|
|
74
74
|
}): {
|
|
75
|
-
[x: string]:
|
|
75
|
+
[x: string]: Data<T>;
|
|
76
76
|
};
|
|
77
77
|
/**
|
|
78
|
-
* @param
|
|
78
|
+
* @param data
|
|
79
79
|
* @returns
|
|
80
80
|
*/
|
|
81
|
-
makeSelectNodeErrors<T extends Record<string, any>>(
|
|
81
|
+
makeSelectNodeErrors<T extends Record<string, any>>(data: Data<T> | undefined): {
|
|
82
82
|
isSubmitted: boolean;
|
|
83
83
|
isDirty: boolean;
|
|
84
84
|
hasFocus: string | undefined;
|
|
@@ -88,30 +88,30 @@ export interface IFormSelectors {
|
|
|
88
88
|
isValidating?: boolean;
|
|
89
89
|
};
|
|
90
90
|
/**
|
|
91
|
-
* @param
|
|
91
|
+
* @param data
|
|
92
92
|
* @returns
|
|
93
93
|
*/
|
|
94
|
-
|
|
94
|
+
makeSelectNodeDataFieldTouched<T extends Record<string, any>>(id: string): (data: Data<T> | undefined) => boolean | undefined;
|
|
95
95
|
/**
|
|
96
|
-
* @param
|
|
96
|
+
* @param data
|
|
97
97
|
* @returns
|
|
98
98
|
*/
|
|
99
|
-
|
|
99
|
+
makeSelectNodeDataFieldFocused<T extends Record<string, any>>(id: string): (data: Data<T> | undefined) => string | undefined;
|
|
100
100
|
/**
|
|
101
|
-
* @param
|
|
101
|
+
* @param data
|
|
102
102
|
* @returns
|
|
103
103
|
*/
|
|
104
|
-
|
|
104
|
+
makeSelectNodeDataFieldDirty<T extends Record<string, any>>(id: string): (data: Data<T> | undefined) => boolean | undefined;
|
|
105
105
|
/**
|
|
106
106
|
* @param id
|
|
107
107
|
* @returns
|
|
108
108
|
*/
|
|
109
109
|
getDataFromState<T extends Record<string, any>>(id: string | string[]): (data: T) => Partial<T>;
|
|
110
110
|
/**
|
|
111
|
-
* @param
|
|
111
|
+
* @param data
|
|
112
112
|
* @returns
|
|
113
113
|
*/
|
|
114
|
-
|
|
114
|
+
makeSelectNodeDataSubmitted<T extends Record<string, any>>(data: Data<T>): boolean | undefined;
|
|
115
115
|
/**
|
|
116
116
|
* @param name
|
|
117
117
|
* @param id
|
|
@@ -121,7 +121,7 @@ export interface IFormSelectors {
|
|
|
121
121
|
makeSelectFieldError<T extends Record<string, any>>(name: string, id: string, validate: {
|
|
122
122
|
rules?: RulesObject<any>;
|
|
123
123
|
message?: string;
|
|
124
|
-
}[] | null): (
|
|
124
|
+
}[] | null): (globalData: T | undefined, data: Data<T>) => Array<string>;
|
|
125
125
|
/**
|
|
126
126
|
* @param id
|
|
127
127
|
* @param rules
|
|
@@ -130,5 +130,5 @@ export interface IFormSelectors {
|
|
|
130
130
|
* @param value
|
|
131
131
|
* @returns
|
|
132
132
|
*/
|
|
133
|
-
selectorRulesDisabled<T extends Record<string, any>>(id: string, rules: any, keys: string[] | null, flowName: string, value: any): (
|
|
133
|
+
selectorRulesDisabled<T extends Record<string, any>>(id: string, rules: any, keys: string[] | null, flowName: string, value: any): (globalData: T | undefined, data: Data<T>) => boolean;
|
|
134
134
|
}
|
|
@@ -17,7 +17,7 @@ export interface INode {
|
|
|
17
17
|
retain?: boolean;
|
|
18
18
|
disabled?: boolean;
|
|
19
19
|
}
|
|
20
|
-
export type
|
|
20
|
+
export type Data<T extends Record<string, unknown>> = {
|
|
21
21
|
isSubmitted?: boolean;
|
|
22
22
|
isDirty?: boolean;
|
|
23
23
|
hasFocus?: string;
|
|
@@ -14,7 +14,7 @@ export interface CoreStateUtils {
|
|
|
14
14
|
* Selects the form node with a specific ID from a given flow.
|
|
15
15
|
* It returns a selector function that accepts the state as an argument and retrieves the form node
|
|
16
16
|
*/
|
|
17
|
-
|
|
17
|
+
selectFlowerDataNode<T extends object>(name: string): (state: T) => Record<string, any>;
|
|
18
18
|
/**
|
|
19
19
|
*
|
|
20
20
|
* @param name
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { FunctionRule } from '../interfaces';
|
|
2
|
-
export declare const rulesMatcher: (rules?: Record<string, any> | Record<string, any>[] | FunctionRule,
|
|
2
|
+
export declare const rulesMatcher: (rules?: Record<string, any> | Record<string, any>[] | FunctionRule, dataValue?: Record<string, any>, apply?: boolean, options?: Record<string, any>) => boolean[];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { CoreReducersFunctions,
|
|
2
|
-
export declare const FlowerCoreReducers:
|
|
1
|
+
import { CoreReducersFunctions, DataReducersFunctions } from '../../interfaces';
|
|
2
|
+
export declare const FlowerCoreReducers: DataReducersFunctions & CoreReducersFunctions;
|
|
@@ -1,13 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
* formName => FlowerForm
|
|
4
|
-
* initialData => FlowerForm
|
|
5
|
-
* fieldName => FlowerField
|
|
6
|
-
* fieldValue => FlowerField
|
|
7
|
-
* errors => FlowerField
|
|
8
|
-
* customErrors => FlowerField
|
|
9
|
-
* fieldTouched => FlowerField
|
|
10
|
-
* fieldDirty => FlowerField
|
|
11
|
-
* fieldHasFocus => FlowerField
|
|
12
|
-
*/
|
|
13
|
-
export declare const FlowerCoreDataReducers: FormReducersFunctions;
|
|
1
|
+
import { DataReducersFunctions } from '../../interfaces/ReducerInterface';
|
|
2
|
+
export declare const FlowerCoreDataReducers: DataReducersFunctions;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { CoreReducersFunctions,
|
|
1
|
+
export type { CoreReducersFunctions, DataReducersFunctions } from '../../interfaces';
|
|
2
2
|
export { FlowerCoreBaseReducers } from './FlowerCoreStateFunctions';
|
|
3
3
|
export { FlowerCoreDataReducers } from './FlowerDataStateFunctions';
|
|
4
4
|
export { FlowerCoreReducers } from './FlowerCoreMergedReducers';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { IFlowerSelectors,
|
|
2
|
-
export declare const FlowerCoreStateSelectors: IFlowerSelectors &
|
|
1
|
+
import { IFlowerSelectors, IDataSelectors } from '../../interfaces';
|
|
2
|
+
export declare const FlowerCoreStateSelectors: IFlowerSelectors & IDataSelectors;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { IFlowerSelectors,
|
|
1
|
+
export type { IFlowerSelectors, IDataSelectors } from '../../interfaces';
|
|
2
2
|
export { FlowerCoreStateBaseSelectors } from './FlowerCoreStateSelectors';
|
|
3
|
-
export { FlowerCoreStateDataSelectors } from './
|
|
3
|
+
export { FlowerCoreStateDataSelectors } from './FlowerDataStateSelectors';
|
|
4
4
|
export { FlowerCoreStateSelectors } from './FlowerSelectorsMerged';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CoreStateUtils } from '../interfaces/UtilsInterface';
|
|
2
2
|
export declare const FlowerStateUtils: CoreStateUtils;
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const generateData: (data: Record<string, any>) => {
|
|
4
4
|
isSubmitted: any;
|
|
5
5
|
isDirty: boolean;
|
|
6
6
|
hasFocus: any;
|
package/package.json
CHANGED