@rsuci/shared-form-components 1.0.18 → 1.0.20

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.
@@ -1 +1 @@
1
- {"version":3,"file":"roster-condition-engine.d.ts","sourceRoot":"","sources":["../../src/lib/roster-condition-engine.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,MAAM,MAAM,wBAAwB,GAChC,uBAAuB,GACvB,mBAAmB,GACnB,eAAe,GACf,gBAAgB,GAChB,cAAc,CAAC;AAEnB,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,wBAAwB,CAAC;IAC/B,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,+BAA+B;IAC9C,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,oBAAoB,EAAE,CAAC;CAChC;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;GAGG;AACH,qBAAa,qBAAqB;IAEhC;;;OAGG;IACH,MAAM,CAAC,iBAAiB,CACtB,SAAS,EAAE,MAAM,EACjB,kBAAkB,EAAE,iBAAiB,EAAE,EACvC,mBAAmB,EAAE,MAAM,EAC3B,oBAAoB,EAAE,MAAM,GAC3B,+BAA+B;IAgElC;;;OAGG;IACH,MAAM,CAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO;IAyB5E;;;OAGG;IACH,MAAM,CAAC,yBAAyB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE;IAO7D;;;;OAIG;IACH,MAAM,CAAC,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAO1D;;;;OAIG;IACH,MAAM,CAAC,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,KAAK,CAAC;QAC/C,cAAc,EAAE,MAAM,CAAC;QACvB,cAAc,EAAE,MAAM,CAAC;QACvB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IAoBF;;;;;OAKG;IACH,MAAM,CAAC,sBAAsB,CAC3B,eAAe,EAAE,iBAAiB,EAAE,EACpC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAC9B,GAAG,CAAC,MAAM,CAAC;IAmCd;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,sBAAsB;IA6BrC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,cAAc;CA0B9B"}
1
+ {"version":3,"file":"roster-condition-engine.d.ts","sourceRoot":"","sources":["../../src/lib/roster-condition-engine.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,MAAM,MAAM,wBAAwB,GAChC,uBAAuB,GACvB,mBAAmB,GACnB,eAAe,GACf,gBAAgB,GAChB,cAAc,CAAC;AAEnB,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,wBAAwB,CAAC;IAC/B,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,+BAA+B;IAC9C,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,oBAAoB,EAAE,CAAC;CAChC;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;GAGG;AACH,qBAAa,qBAAqB;IAEhC;;;OAGG;IACH,MAAM,CAAC,iBAAiB,CACtB,SAAS,EAAE,MAAM,EACjB,kBAAkB,EAAE,iBAAiB,EAAE,EACvC,mBAAmB,EAAE,MAAM,EAC3B,oBAAoB,EAAE,MAAM,GAC3B,+BAA+B;IA6ElC;;;OAGG;IACH,MAAM,CAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO;IAyB5E;;;OAGG;IACH,MAAM,CAAC,yBAAyB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE;IAO7D;;;;OAIG;IACH,MAAM,CAAC,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAO1D;;;;OAIG;IACH,MAAM,CAAC,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,KAAK,CAAC;QAC/C,cAAc,EAAE,MAAM,CAAC;QACvB,cAAc,EAAE,MAAM,CAAC;QACvB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IAoBF;;;;;OAKG;IACH,MAAM,CAAC,sBAAsB,CAC3B,eAAe,EAAE,iBAAiB,EAAE,EACpC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAC9B,GAAG,CAAC,MAAM,CAAC;IAmCd;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,sBAAsB;IA6BrC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,cAAc;CAsD9B"}
@@ -24,13 +24,24 @@ export class RosterConditionEngine {
24
24
  const availableCodes = new Set(availableVariables.map(v => v.code));
25
25
  // 1. Vérifier les références de variables
26
26
  const refs = this.extractVariableReferences(condition);
27
+ // Collecter les références utilisées dans les conditions internes des jumps
28
+ // L'auto-référence est autorisée UNIQUEMENT dans les conditions de jump
29
+ const allJumps = this.extractAllJumps(condition);
30
+ const refsInJumpConditions = new Set();
31
+ for (const jump of allJumps) {
32
+ const jumpRefs = this.extractVariableReferences(jump.innerCondition);
33
+ jumpRefs.forEach(r => refsInJumpConditions.add(r));
34
+ }
27
35
  for (const ref of refs) {
28
36
  if (ref === currentVariableCode) {
29
- errors.push({
30
- type: 'self_reference',
31
- variableCode: ref,
32
- message: 'Une variable ne peut pas se référencer elle-même'
33
- });
37
+ // Auto-référence autorisée UNIQUEMENT dans les conditions de jump
38
+ if (!refsInJumpConditions.has(ref)) {
39
+ errors.push({
40
+ type: 'self_reference',
41
+ variableCode: ref,
42
+ message: 'Une variable ne peut pas se référencer elle-même (sauf dans un jump)'
43
+ });
44
+ }
34
45
  }
35
46
  else if (!availableCodes.has(ref)) {
36
47
  errors.push({
@@ -41,7 +52,7 @@ export class RosterConditionEngine {
41
52
  }
42
53
  }
43
54
  // 2. Vérifier TOUS les jumps (supporte jump() || jump() || ...)
44
- const allJumps = this.extractAllJumps(condition);
55
+ // Note: allJumps déjà extrait plus haut
45
56
  for (const jump of allJumps) {
46
57
  if (!availableCodes.has(jump.target)) {
47
58
  errors.push({
@@ -234,6 +245,31 @@ export class RosterConditionEngine {
234
245
  if (!functionMatch && !condition.includes('${')) {
235
246
  return 'Condition invalide: utilisez showMe(), hideMe() ou jump()';
236
247
  }
248
+ // Vérifier que les jumps multiples utilisent uniquement ||
249
+ const allJumps = this.extractAllJumps(condition);
250
+ if (allJumps.length > 1) {
251
+ // Retirer tous les jumps et vérifier ce qui reste entre eux
252
+ let remaining = condition;
253
+ for (const jump of allJumps) {
254
+ remaining = remaining.replace(jump.fullExpression, '###JUMP###');
255
+ }
256
+ // Entre les ###JUMP###, seul || est autorisé (avec espaces optionnels)
257
+ const betweenJumps = remaining.split('###JUMP###').slice(1, -1);
258
+ for (const between of betweenJumps) {
259
+ const trimmed = between.trim();
260
+ if (trimmed !== '||') {
261
+ return `Seul l'opérateur || est autorisé entre les jumps multiples (trouvé: "${trimmed || 'rien'}")`;
262
+ }
263
+ }
264
+ // Vérifier aussi avant le premier et après le dernier jump
265
+ const parts = remaining.split('###JUMP###');
266
+ if (parts[0].trim() !== '') {
267
+ return `Syntaxe invalide avant le premier jump: "${parts[0].trim()}"`;
268
+ }
269
+ if (parts[parts.length - 1].trim() !== '') {
270
+ return `Syntaxe invalide après le dernier jump: "${parts[parts.length - 1].trim()}"`;
271
+ }
272
+ }
237
273
  return null;
238
274
  }
239
275
  catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsuci/shared-form-components",
3
- "version": "1.0.18",
3
+ "version": "1.0.20",
4
4
  "description": "Composants partagés de rendu de formulaires RSU v2 - Package local pour frontend Admin et Public",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",