@flowerforce/flower-core 3.1.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/dist/index.cjs.js CHANGED
@@ -23,6 +23,9 @@ var flat = require('flat');
23
23
  const Emitter = new tinyEmitter.TinyEmitter();
24
24
 
25
25
  const EMPTY_STRING_REGEXP = /^\s*$/;
26
+ /**
27
+ * Defines a utility object named rulesMatcherUtils, which contains various helper functions used for processing rules and data in a rule-matching context.
28
+ */
26
29
  const rulesMatcherUtils = {
27
30
  isNumber: el => {
28
31
  const num = String(el);
@@ -134,21 +137,31 @@ const rulesMatcherUtils = {
134
137
  }
135
138
  },
136
139
  isEmpty: value => {
140
+ // Null and undefined are empty
137
141
  if (!rulesMatcherUtils.isDefined(value)) {
138
142
  return true;
139
143
  }
144
+ // functions are non empty
140
145
  if (rulesMatcherUtils.isFunction(value)) {
141
146
  return false;
142
147
  }
148
+ /* if (isBool(value)) {
149
+ return false;
150
+ }
151
+ */
152
+ // Whitespace only strings are empty
143
153
  if (rulesMatcherUtils.isString(value)) {
144
154
  return EMPTY_STRING_REGEXP.test(value);
145
155
  }
156
+ // For arrays we use the length property
146
157
  if (Array.isArray(value)) {
147
158
  return value.length === 0;
148
159
  }
160
+ // Dates have no attributes but aren't empty
149
161
  if (rulesMatcherUtils.isDate(value)) {
150
162
  return false;
151
163
  }
164
+ // If we find at least one property we consider it non empty
152
165
  let attr;
153
166
  if (rulesMatcherUtils.isObject(value)) {
154
167
  for (attr in value) {
@@ -163,11 +176,13 @@ const rulesMatcherUtils = {
163
176
  if (path.indexOf('^') === 0) {
164
177
  return _trimStart(path, '^');
165
178
  }
179
+ // da verificare se è ancora utilizzato
166
180
  if (path.indexOf('$') === 0) {
167
181
  return path;
168
182
  }
169
183
  return prefix ? `${prefix}.${path}` : path;
170
184
  },
185
+ // TODO BUG NUMERI CON LETTERE 1asdas o solo
171
186
  forceNumber: el => {
172
187
  if (Array.isArray(el)) {
173
188
  return el.length;
@@ -175,6 +190,7 @@ const rulesMatcherUtils = {
175
190
  if (rulesMatcherUtils.isNumber(String(el))) {
176
191
  return parseFloat(String(el));
177
192
  }
193
+ // fix perchè un valore false < 1 è true, quindi sbagliato, mentre un valore undefined < 1 è false
178
194
  return 0;
179
195
  },
180
196
  checkRule: (block, data, options) => {
@@ -201,6 +217,9 @@ const rulesMatcherUtils = {
201
217
  return Object.keys(keys);
202
218
  }
203
219
  };
220
+ /**
221
+ * Defines a set of comparison operators used for matching rules against user input.
222
+ */
204
223
  const operators = {
205
224
  $exists: (a, b) => !rulesMatcherUtils.isEmpty(a) === b,
206
225
  $eq: (a, b) => a === b,
@@ -221,6 +240,9 @@ const operators = {
221
240
 
222
241
  const rulesMatcher = (rules, formValue = {}, apply = true, options) => {
223
242
  if (!rules) return [apply];
243
+ // if (typeof rules !== 'object' && !Array.isArray(rules)) {
244
+ // throw new Error('Rules accept only array or object');
245
+ // }
224
246
  if (typeof rules === 'function') {
225
247
  return [rules(formValue) === apply];
226
248
  }
@@ -235,6 +257,8 @@ const MatchRules = {
235
257
  utils: rulesMatcherUtils
236
258
  };
237
259
 
260
+ /* eslint-disable no-useless-escape */
261
+ // TODO align this set of functions to selectors and reducers functions
238
262
  const flattenRules = ob => {
239
263
  const result = {};
240
264
  for (const i in ob) {
@@ -252,9 +276,33 @@ const flattenRules = ob => {
252
276
  }
253
277
  return result;
254
278
  };
279
+ // export const searchEmptyKeyRecursively = <T extends object>(
280
+ // _key: "$and" | "$or",
281
+ // obj: T
282
+ // ) => {
283
+ // if (
284
+ // isEmpty(obj) ||
285
+ // typeof obj !== "object" ||
286
+ // Object.keys(obj).length === 0
287
+ // ) {
288
+ // return true;
289
+ // }
290
+ // if (Object.keys(obj).includes(_key)) {
291
+ // if (obj[_key] && obj[_key].length === 0) return true;
292
+ // return Object.keys(obj).map((key) =>
293
+ // searchEmptyKeyRecursively(_key, obj[key])
294
+ // );
295
+ // }
296
+ // return Object.keys(obj)
297
+ // .map((key) => searchEmptyKeyRecursively(_key, obj[key]))
298
+ // .every((v) => v === true);
299
+ // };
255
300
  const getRulesExists = rules => {
256
301
  return Object.keys(rules).length ? CoreUtils.mapEdge(rules) : undefined;
257
302
  };
303
+ /**
304
+ * Defines a collection of utility functions for processing rules, nodes and graph-like structures
305
+ */
258
306
  const CoreUtils = {
259
307
  generateRulesName: nextRules => {
260
308
  const a = nextRules.reduce((acc, inc) => {
@@ -267,10 +315,12 @@ const CoreUtils = {
267
315
  return a;
268
316
  },
269
317
  mapKeysDeepLodash: (obj, cb, isRecursive) => {
318
+ /* istanbul ignore next */
270
319
  if (!obj && !isRecursive) {
271
320
  return {};
272
321
  }
273
322
  if (!isRecursive) {
323
+ /* istanbul ignore next */
274
324
  if (typeof obj === 'string' || typeof obj === 'number' || typeof obj === 'boolean') {
275
325
  return {};
276
326
  }
@@ -349,6 +399,8 @@ const CoreUtils = {
349
399
  },
350
400
  allEqual: (arr, arr2) => arr.length === arr2.length && arr.every(v => arr2.includes(v)),
351
401
  findValidRule: (nextRules, value, prefix) => find(nextRules, rule => {
402
+ // fix per evitare di entrare in un nodo senza regole, ma con un name,
403
+ // invocando un next() senza paramentri
352
404
  if (typeof rule.rules === 'string') {
353
405
  return false;
354
406
  }
@@ -405,6 +457,9 @@ const {
405
457
  generateRulesName,
406
458
  findValidRule
407
459
  } = CoreUtils;
460
+ /**
461
+ * These functions are Redux reducers used in a Flux architecture for managing state transitions and updates in a Flower application.
462
+ */
408
463
  const FlowerCoreReducers = {
409
464
  historyAdd: (state, {
410
465
  payload
@@ -420,6 +475,7 @@ const FlowerCoreReducers = {
420
475
  }) => {
421
476
  const history = _get(state[typeof payload === 'string' ? payload : payload.name], ['history'], []);
422
477
  const lastIndex = lastIndexOf(history, typeof payload === 'string' ? payload : payload.node);
478
+ // se passo un nodo che non esiste
423
479
  if (lastIndex >= 0) {
424
480
  const newHistory = _slice(history, 0, lastIndex + 1);
425
481
  _set(state, [typeof payload === 'string' ? payload : payload.name, 'history'], newHistory);
@@ -436,6 +492,8 @@ const FlowerCoreReducers = {
436
492
  _set(state, [typeof payload === 'string' ? payload : payload.flowName, 'form', typeof payload === 'string' ? payload : payload.currentNode, 'touched'], true);
437
493
  return state;
438
494
  },
495
+ // TODO check internal logic and use case
496
+ /* istanbul ignore next */
439
497
  forceAddHistory: (state, {
440
498
  payload
441
499
  }) => {
@@ -461,8 +519,10 @@ const FlowerCoreReducers = {
461
519
  _set(state, [payload.name, 'history'], [startId]);
462
520
  return state;
463
521
  }
522
+ // elimino lo node corrente
464
523
  history.pop();
465
524
  const total = originHistory.length - 2;
525
+ // eslint-disable-next-line no-plusplus
466
526
  for (let index = total; index > 0; index--) {
467
527
  const curr = originHistory[index];
468
528
  const nodeType = _get(container, ['nodes', curr, 'nodeType']);
@@ -493,12 +553,16 @@ const FlowerCoreReducers = {
493
553
  flowName,
494
554
  node
495
555
  } = payload;
556
+ // non ancora implementanto nell'hook useFlower
557
+ /* istanbul ignore next */
496
558
  if (hasNode(state, name || flowName || '', node)) {
497
559
  _set(state, [name || flowName || '', 'current'], node);
498
560
  _set(state, [name || flowName || '', 'history'], [node]);
499
561
  }
562
+ /* istanbul ignore next */
500
563
  return state;
501
564
  },
565
+ /* istanbul ignore next */
502
566
  initializeFromNode: (state, {
503
567
  payload
504
568
  }) => {
@@ -514,6 +578,7 @@ const FlowerCoreReducers = {
514
578
  }
515
579
  return state;
516
580
  },
581
+ /* istanbul ignore next */
517
582
  forceResetHistory: (state, {
518
583
  payload
519
584
  }) => {
@@ -535,7 +600,10 @@ const FlowerCoreReducers = {
535
600
  }) => {
536
601
  if (payload.persist && _get(state, [payload.name, 'persist'])) return;
537
602
  const startId = payload.startId || _get(payload, 'nodes.0.nodeId');
603
+ // TODO non verificato, controllo precendente che non lo permette
604
+ /* istanbul ignore next */
538
605
  if (!startId) {
606
+ // eslint-disable-next-line no-console
539
607
  console.warn('Flower is empty');
540
608
  return;
541
609
  }
@@ -549,9 +617,11 @@ const FlowerCoreReducers = {
549
617
  data: payload.initialData
550
618
  });
551
619
  },
552
- setCurrentNode: (state, {
620
+ // TODO usato solo da flower su vscode
621
+ setCurrentNode: /* istanbul ignore next */(state, {
553
622
  payload
554
623
  }) => {
624
+ /* istanbul ignore next */
555
625
  if (hasNode(state, payload.name, payload.node)) {
556
626
  const startId = _get(state, [payload.name, 'startId']);
557
627
  if (payload.node === startId) {
@@ -589,9 +659,11 @@ const FlowerCoreReducers = {
589
659
  _set(state, [payload.flowName, 'data', ...payload.id], payload.value);
590
660
  }
591
661
  },
592
- replaceData: (state, {
662
+ // TODO usato al momento solo il devtool
663
+ replaceData: /* istanbul ignore next */(state, {
593
664
  payload
594
665
  }) => {
666
+ /* istanbul ignore next */
595
667
  _set(state, [payload.flowName, 'data'], payload.value);
596
668
  },
597
669
  unsetData: (state, {
@@ -622,7 +694,9 @@ const FlowerCoreReducers = {
622
694
  currentNode: currentNodeId
623
695
  }
624
696
  });
625
- if (global.window && _get(global.window, '__FLOWER_DEVTOOLS__') && history) {
697
+ /* istanbul ignore next */
698
+ // eslint-disable-next-line no-underscore-dangle
699
+ if (devtoolState && _get(devtoolState, '__FLOWER_DEVTOOLS__') && history) {
626
700
  FlowerCoreReducers.forceAddHistory(state, {
627
701
  type: 'forceAddHistory',
628
702
  payload: {
@@ -779,9 +853,11 @@ const FlowerCoreStateSelectors = {
779
853
  } = nodes[el];
780
854
  return nodeType === 'FlowerNode' || retain;
781
855
  });
856
+ // eslint-disable-next-line consistent-return
782
857
  if (nodes[current].nodeType === 'FlowerNode' || nodes[current].retain) return;
783
858
  if (!prevFlowerNode) return;
784
859
  if (nodes[prevFlowerNode] && nodes[prevFlowerNode].disabled) return;
860
+ // eslint-disable-next-line consistent-return
785
861
  return nodes[prevFlowerNode] && nodes[prevFlowerNode].retain && prevFlowerNode;
786
862
  },
787
863
  makeSelectNodeErrors: form => {
@@ -878,9 +954,12 @@ exports.RulesOperators = void 0;
878
954
  RulesOperators["$regex"] = "$regex";
879
955
  })(exports.RulesOperators || (exports.RulesOperators = {}));
880
956
 
957
+ const devtoolState = {};
958
+
881
959
  exports.CoreUtils = CoreUtils;
882
960
  exports.Emitter = Emitter;
883
961
  exports.FlowerCoreReducers = FlowerCoreReducers;
884
962
  exports.FlowerStateUtils = FlowerStateUtils;
885
963
  exports.MatchRules = MatchRules;
886
964
  exports.Selectors = FlowerCoreStateSelectors;
965
+ exports.devtoolState = devtoolState;
package/dist/index.esm.js CHANGED
@@ -21,6 +21,9 @@ import { unflatten } from 'flat';
21
21
  const Emitter = new TinyEmitter();
22
22
 
23
23
  const EMPTY_STRING_REGEXP = /^\s*$/;
24
+ /**
25
+ * Defines a utility object named rulesMatcherUtils, which contains various helper functions used for processing rules and data in a rule-matching context.
26
+ */
24
27
  const rulesMatcherUtils = {
25
28
  isNumber: el => {
26
29
  const num = String(el);
@@ -132,21 +135,31 @@ const rulesMatcherUtils = {
132
135
  }
133
136
  },
134
137
  isEmpty: value => {
138
+ // Null and undefined are empty
135
139
  if (!rulesMatcherUtils.isDefined(value)) {
136
140
  return true;
137
141
  }
142
+ // functions are non empty
138
143
  if (rulesMatcherUtils.isFunction(value)) {
139
144
  return false;
140
145
  }
146
+ /* if (isBool(value)) {
147
+ return false;
148
+ }
149
+ */
150
+ // Whitespace only strings are empty
141
151
  if (rulesMatcherUtils.isString(value)) {
142
152
  return EMPTY_STRING_REGEXP.test(value);
143
153
  }
154
+ // For arrays we use the length property
144
155
  if (Array.isArray(value)) {
145
156
  return value.length === 0;
146
157
  }
158
+ // Dates have no attributes but aren't empty
147
159
  if (rulesMatcherUtils.isDate(value)) {
148
160
  return false;
149
161
  }
162
+ // If we find at least one property we consider it non empty
150
163
  let attr;
151
164
  if (rulesMatcherUtils.isObject(value)) {
152
165
  for (attr in value) {
@@ -161,11 +174,13 @@ const rulesMatcherUtils = {
161
174
  if (path.indexOf('^') === 0) {
162
175
  return _trimStart(path, '^');
163
176
  }
177
+ // da verificare se è ancora utilizzato
164
178
  if (path.indexOf('$') === 0) {
165
179
  return path;
166
180
  }
167
181
  return prefix ? `${prefix}.${path}` : path;
168
182
  },
183
+ // TODO BUG NUMERI CON LETTERE 1asdas o solo
169
184
  forceNumber: el => {
170
185
  if (Array.isArray(el)) {
171
186
  return el.length;
@@ -173,6 +188,7 @@ const rulesMatcherUtils = {
173
188
  if (rulesMatcherUtils.isNumber(String(el))) {
174
189
  return parseFloat(String(el));
175
190
  }
191
+ // fix perchè un valore false < 1 è true, quindi sbagliato, mentre un valore undefined < 1 è false
176
192
  return 0;
177
193
  },
178
194
  checkRule: (block, data, options) => {
@@ -199,6 +215,9 @@ const rulesMatcherUtils = {
199
215
  return Object.keys(keys);
200
216
  }
201
217
  };
218
+ /**
219
+ * Defines a set of comparison operators used for matching rules against user input.
220
+ */
202
221
  const operators = {
203
222
  $exists: (a, b) => !rulesMatcherUtils.isEmpty(a) === b,
204
223
  $eq: (a, b) => a === b,
@@ -219,6 +238,9 @@ const operators = {
219
238
 
220
239
  const rulesMatcher = (rules, formValue = {}, apply = true, options) => {
221
240
  if (!rules) return [apply];
241
+ // if (typeof rules !== 'object' && !Array.isArray(rules)) {
242
+ // throw new Error('Rules accept only array or object');
243
+ // }
222
244
  if (typeof rules === 'function') {
223
245
  return [rules(formValue) === apply];
224
246
  }
@@ -233,6 +255,8 @@ const MatchRules = {
233
255
  utils: rulesMatcherUtils
234
256
  };
235
257
 
258
+ /* eslint-disable no-useless-escape */
259
+ // TODO align this set of functions to selectors and reducers functions
236
260
  const flattenRules = ob => {
237
261
  const result = {};
238
262
  for (const i in ob) {
@@ -250,9 +274,33 @@ const flattenRules = ob => {
250
274
  }
251
275
  return result;
252
276
  };
277
+ // export const searchEmptyKeyRecursively = <T extends object>(
278
+ // _key: "$and" | "$or",
279
+ // obj: T
280
+ // ) => {
281
+ // if (
282
+ // isEmpty(obj) ||
283
+ // typeof obj !== "object" ||
284
+ // Object.keys(obj).length === 0
285
+ // ) {
286
+ // return true;
287
+ // }
288
+ // if (Object.keys(obj).includes(_key)) {
289
+ // if (obj[_key] && obj[_key].length === 0) return true;
290
+ // return Object.keys(obj).map((key) =>
291
+ // searchEmptyKeyRecursively(_key, obj[key])
292
+ // );
293
+ // }
294
+ // return Object.keys(obj)
295
+ // .map((key) => searchEmptyKeyRecursively(_key, obj[key]))
296
+ // .every((v) => v === true);
297
+ // };
253
298
  const getRulesExists = rules => {
254
299
  return Object.keys(rules).length ? CoreUtils.mapEdge(rules) : undefined;
255
300
  };
301
+ /**
302
+ * Defines a collection of utility functions for processing rules, nodes and graph-like structures
303
+ */
256
304
  const CoreUtils = {
257
305
  generateRulesName: nextRules => {
258
306
  const a = nextRules.reduce((acc, inc) => {
@@ -265,10 +313,12 @@ const CoreUtils = {
265
313
  return a;
266
314
  },
267
315
  mapKeysDeepLodash: (obj, cb, isRecursive) => {
316
+ /* istanbul ignore next */
268
317
  if (!obj && !isRecursive) {
269
318
  return {};
270
319
  }
271
320
  if (!isRecursive) {
321
+ /* istanbul ignore next */
272
322
  if (typeof obj === 'string' || typeof obj === 'number' || typeof obj === 'boolean') {
273
323
  return {};
274
324
  }
@@ -347,6 +397,8 @@ const CoreUtils = {
347
397
  },
348
398
  allEqual: (arr, arr2) => arr.length === arr2.length && arr.every(v => arr2.includes(v)),
349
399
  findValidRule: (nextRules, value, prefix) => find(nextRules, rule => {
400
+ // fix per evitare di entrare in un nodo senza regole, ma con un name,
401
+ // invocando un next() senza paramentri
350
402
  if (typeof rule.rules === 'string') {
351
403
  return false;
352
404
  }
@@ -403,6 +455,9 @@ const {
403
455
  generateRulesName,
404
456
  findValidRule
405
457
  } = CoreUtils;
458
+ /**
459
+ * These functions are Redux reducers used in a Flux architecture for managing state transitions and updates in a Flower application.
460
+ */
406
461
  const FlowerCoreReducers = {
407
462
  historyAdd: (state, {
408
463
  payload
@@ -418,6 +473,7 @@ const FlowerCoreReducers = {
418
473
  }) => {
419
474
  const history = _get(state[typeof payload === 'string' ? payload : payload.name], ['history'], []);
420
475
  const lastIndex = lastIndexOf(history, typeof payload === 'string' ? payload : payload.node);
476
+ // se passo un nodo che non esiste
421
477
  if (lastIndex >= 0) {
422
478
  const newHistory = _slice(history, 0, lastIndex + 1);
423
479
  _set(state, [typeof payload === 'string' ? payload : payload.name, 'history'], newHistory);
@@ -434,6 +490,8 @@ const FlowerCoreReducers = {
434
490
  _set(state, [typeof payload === 'string' ? payload : payload.flowName, 'form', typeof payload === 'string' ? payload : payload.currentNode, 'touched'], true);
435
491
  return state;
436
492
  },
493
+ // TODO check internal logic and use case
494
+ /* istanbul ignore next */
437
495
  forceAddHistory: (state, {
438
496
  payload
439
497
  }) => {
@@ -459,8 +517,10 @@ const FlowerCoreReducers = {
459
517
  _set(state, [payload.name, 'history'], [startId]);
460
518
  return state;
461
519
  }
520
+ // elimino lo node corrente
462
521
  history.pop();
463
522
  const total = originHistory.length - 2;
523
+ // eslint-disable-next-line no-plusplus
464
524
  for (let index = total; index > 0; index--) {
465
525
  const curr = originHistory[index];
466
526
  const nodeType = _get(container, ['nodes', curr, 'nodeType']);
@@ -491,12 +551,16 @@ const FlowerCoreReducers = {
491
551
  flowName,
492
552
  node
493
553
  } = payload;
554
+ // non ancora implementanto nell'hook useFlower
555
+ /* istanbul ignore next */
494
556
  if (hasNode(state, name || flowName || '', node)) {
495
557
  _set(state, [name || flowName || '', 'current'], node);
496
558
  _set(state, [name || flowName || '', 'history'], [node]);
497
559
  }
560
+ /* istanbul ignore next */
498
561
  return state;
499
562
  },
563
+ /* istanbul ignore next */
500
564
  initializeFromNode: (state, {
501
565
  payload
502
566
  }) => {
@@ -512,6 +576,7 @@ const FlowerCoreReducers = {
512
576
  }
513
577
  return state;
514
578
  },
579
+ /* istanbul ignore next */
515
580
  forceResetHistory: (state, {
516
581
  payload
517
582
  }) => {
@@ -533,7 +598,10 @@ const FlowerCoreReducers = {
533
598
  }) => {
534
599
  if (payload.persist && _get(state, [payload.name, 'persist'])) return;
535
600
  const startId = payload.startId || _get(payload, 'nodes.0.nodeId');
601
+ // TODO non verificato, controllo precendente che non lo permette
602
+ /* istanbul ignore next */
536
603
  if (!startId) {
604
+ // eslint-disable-next-line no-console
537
605
  console.warn('Flower is empty');
538
606
  return;
539
607
  }
@@ -547,9 +615,11 @@ const FlowerCoreReducers = {
547
615
  data: payload.initialData
548
616
  });
549
617
  },
550
- setCurrentNode: (state, {
618
+ // TODO usato solo da flower su vscode
619
+ setCurrentNode: /* istanbul ignore next */(state, {
551
620
  payload
552
621
  }) => {
622
+ /* istanbul ignore next */
553
623
  if (hasNode(state, payload.name, payload.node)) {
554
624
  const startId = _get(state, [payload.name, 'startId']);
555
625
  if (payload.node === startId) {
@@ -587,9 +657,11 @@ const FlowerCoreReducers = {
587
657
  _set(state, [payload.flowName, 'data', ...payload.id], payload.value);
588
658
  }
589
659
  },
590
- replaceData: (state, {
660
+ // TODO usato al momento solo il devtool
661
+ replaceData: /* istanbul ignore next */(state, {
591
662
  payload
592
663
  }) => {
664
+ /* istanbul ignore next */
593
665
  _set(state, [payload.flowName, 'data'], payload.value);
594
666
  },
595
667
  unsetData: (state, {
@@ -620,7 +692,9 @@ const FlowerCoreReducers = {
620
692
  currentNode: currentNodeId
621
693
  }
622
694
  });
623
- if (global.window && _get(global.window, '__FLOWER_DEVTOOLS__') && history) {
695
+ /* istanbul ignore next */
696
+ // eslint-disable-next-line no-underscore-dangle
697
+ if (devtoolState && _get(devtoolState, '__FLOWER_DEVTOOLS__') && history) {
624
698
  FlowerCoreReducers.forceAddHistory(state, {
625
699
  type: 'forceAddHistory',
626
700
  payload: {
@@ -777,9 +851,11 @@ const FlowerCoreStateSelectors = {
777
851
  } = nodes[el];
778
852
  return nodeType === 'FlowerNode' || retain;
779
853
  });
854
+ // eslint-disable-next-line consistent-return
780
855
  if (nodes[current].nodeType === 'FlowerNode' || nodes[current].retain) return;
781
856
  if (!prevFlowerNode) return;
782
857
  if (nodes[prevFlowerNode] && nodes[prevFlowerNode].disabled) return;
858
+ // eslint-disable-next-line consistent-return
783
859
  return nodes[prevFlowerNode] && nodes[prevFlowerNode].retain && prevFlowerNode;
784
860
  },
785
861
  makeSelectNodeErrors: form => {
@@ -876,4 +952,6 @@ var RulesOperators;
876
952
  RulesOperators["$regex"] = "$regex";
877
953
  })(RulesOperators || (RulesOperators = {}));
878
954
 
879
- export { CoreUtils, Emitter, FlowerCoreReducers, FlowerStateUtils, MatchRules, RulesModes, RulesOperators, FlowerCoreStateSelectors as Selectors };
955
+ const devtoolState = {};
956
+
957
+ export { CoreUtils, Emitter, FlowerCoreReducers, FlowerStateUtils, MatchRules, RulesModes, RulesOperators, FlowerCoreStateSelectors as Selectors, devtoolState };
@@ -1,3 +1,6 @@
1
1
  import { CoreUtilitiesFunctions } from './interfaces/CoreInterface';
2
2
  export declare const flattenRules: (ob: Record<string, any>) => Record<string, any>;
3
+ /**
4
+ * Defines a collection of utility functions for processing rules, nodes and graph-like structures
5
+ */
3
6
  export declare const CoreUtils: CoreUtilitiesFunctions;
@@ -1,2 +1,5 @@
1
1
  import { ReducersFunctions } from './interfaces/ReducerInterface';
2
+ /**
3
+ * These functions are Redux reducers used in a Flux architecture for managing state transitions and updates in a Flower application.
4
+ */
2
5
  export declare const FlowerCoreReducers: ReducersFunctions;
@@ -5,3 +5,5 @@ export { FlowerCoreStateSelectors as Selectors } from './FlowerCoreStateSelector
5
5
  export { CoreUtils } from './CoreUtils';
6
6
  export { MatchRules } from './RulesMatcher';
7
7
  export * from './interfaces';
8
+ declare const devtoolState: {};
9
+ export { devtoolState };
@@ -113,18 +113,105 @@ export type GenerateRulesName = (nextRules: RulesWithName[]) => {
113
113
  [X: string]: string;
114
114
  };
115
115
  export interface CoreUtilitiesFunctions {
116
+ /**
117
+ *
118
+ * Generates rule names from a set of rules.
119
+ * @param nextRules
120
+ *
121
+ * @returns
122
+ *
123
+ */
116
124
  generateRulesName: GenerateRulesName;
125
+ /**
126
+ * Recursively maps keys of an object using a callback function.
127
+ * @param obj
128
+ * @param cb
129
+ * @param isRecursive
130
+ *
131
+ * @returns
132
+ */
117
133
  mapKeysDeepLodash: MapKeysDeepLodash;
134
+ /**
135
+ * Generates a object of nodes from an array of nodes, using nodeId as keys
136
+ * @param nodes
137
+ * @returns
138
+ */
118
139
  generateNodes: GenerateNodes;
140
+ /**
141
+ * Converts nodes into an object with node IDs as keys and their respective rules as values.
142
+ * @param nodes
143
+ *
144
+ * @returns
145
+ */
119
146
  makeObjectRules: MakeObjectRules;
147
+ /**
148
+ * Checks if a node exists within a specific state.
149
+ * @param state
150
+ * @param name
151
+ * @param node
152
+ *
153
+ * @returns
154
+ */
120
155
  hasNode: HasNode;
156
+ /**
157
+ * Checks if a set of rules is empty.
158
+ * @param rules
159
+ *
160
+ * @returns
161
+ */
121
162
  isEmptyRules: IsEmptyRules;
163
+ /**
164
+ * Maps edges and sorts them moving empty rules to the bottom.
165
+ * @param nextNode
166
+ *
167
+ * @returns
168
+ */
122
169
  mapEdge: MapEdge;
170
+ /**
171
+ * Converts a rules object into an array of rule objects.
172
+ * @param rules
173
+ *
174
+ * @returns
175
+ */
123
176
  makeRules: MakeRules;
177
+ /**
178
+ * Generates nodes for a flower JSON structure, extracting rules and other properties.
179
+ * @param nodes
180
+ *
181
+ * @returns
182
+ */
124
183
  generateNodesForFlowerJson: GenerateNodesForFlowerJson;
184
+ /**
185
+ * Removes specified characters from the beginning of a string (default char -> '^').
186
+ * @param name
187
+ * @param char
188
+ *
189
+ * @returns
190
+ */
125
191
  cleanPath: CleanPath;
192
+ /**
193
+ * Creates a valid path from idValue
194
+ * @param idValue
195
+ *
196
+ * @returns
197
+ */
126
198
  getPath: GetPath;
199
+ /**
200
+ * Checks if two arrays are equal in length and have the same elements.
201
+ * @param arr
202
+ * @param arr2
203
+ *
204
+ * @returns
205
+ */
127
206
  allEqual: AllEqual;
207
+ /**
208
+ * Finds the first valid rule for a given value within a set of rules.
209
+ * @param nextRules
210
+ * @param value
211
+ * @param prefix
212
+ *
213
+ * @returns
214
+ */
128
215
  findValidRule: FindValidRule;
129
216
  }
130
217
  export {};