Skip to content

Commit

Permalink
[cascading] from release/11.0 to release/11.1 (#2632)
Browse files Browse the repository at this point in the history
<!--
{"currentBranch":"release/11.0","targetBranch":"release/11.1","bypassReviewers":false,"isConflicting":false}
-->

## Cascading from release/11.0 to release/11.1





---

:heavy_exclamation_mark: The pull request is conflicting with the target
branch.
You can fix the issue locally with the following commands:

<details open>
  <summary>Using <b>gh CLI</b></summary>

  ```shell
  gh pr checkout 2632
  git pull --ff origin release/11.1
  ```

  and update this Pull Request with

  ```shell
  gh pr push 2632
  ```
</details>

<details>
  <summary>Using <b>git</b> only</summary>

  ```shell
  git fetch origin
  git checkout origin/cascading/11.0.0-11.1.0
  git pull --ff origin release/11.1
  ```

  and update this Pull Request with

  ```shell
  git push origin HEAD:cascading/11.0.0-11.1.0
  ```
</details>



---

<small>This Pull Request has been generated with :heart: by the
[Otter](https://github.com/AmadeusITGroup/otter) cascading tool.</small>
  • Loading branch information
fpaul-1A authored Dec 20, 2024
2 parents 52808d2 + d1e2985 commit c343340
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 75 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@
"jest-preset-angular": "~14.2.0",
"js-yaml": "^4.1.0",
"jsonc-eslint-parser": "~2.4.0",
"jsonpath-plus": "~10.0.0",
"jsonpath-plus": "~10.2.0",
"lighthouse": "9.6.8",
"lint-staged": "^15.0.0",
"minimist": "^1.2.6",
Expand Down
2 changes: 1 addition & 1 deletion packages/@o3r/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@
"jest-junit": "~16.0.0",
"jest-preset-angular": "~14.2.0",
"jsonc-eslint-parser": "~2.4.0",
"jsonpath-plus": "~10.0.0",
"jsonpath-plus": "~10.2.0",
"memfs": "~4.11.0",
"nx": "~19.5.0",
"pid-from-port": "^1.1.3",
Expand Down
14 changes: 14 additions & 0 deletions packages/@o3r/core/src/utils/deep-fill/deep-fill.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@ describe('Deep fill function', () => {
expect(deepFill(base, source)).toEqual(base);
});

it('should support "null" value in source', () => {
const base = { selection: { field: 'test-field' }, a: 'string' };
const source = { selection: null } as any;

expect(deepFill(base, source)).toEqual({ selection: null, a: 'string' });
});

it('should support "null" value in base', () => {
const base = { selection: null, a: 'string' } as any;
const source = { selection: { field: 'test-field' } };

expect(deepFill(base, source)).toEqual({ selection: { field: 'test-field' }, a: 'string' });
});

it('should keep properties from base not present in the source', () => {
const base = Object.freeze({a: 1, b: '2', c: true});
const source = Object.freeze({c: false, a: 3});
Expand Down
6 changes: 4 additions & 2 deletions packages/@o3r/core/src/utils/deep-fill/deep-fill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,11 @@ export function deepFill<T extends { [x: string]: any }>(base: T, source?: { [x:
}
const newObj = {...base};
for (const key in base) {
if (key in source && typeof base[key] === typeof source[key]) {
if (source[key] === null) {
newObj[key] = immutablePrimitive(null, additionalMappers);
} else if (key in source && typeof base[key] === typeof source[key]) {
const keyOfSource = source[key];
newObj[key] = typeof keyOfSource === 'undefined' ? immutablePrimitive(base[key], additionalMappers) : deepFill(base[key], source[key], additionalMappers);
newObj[key] = typeof keyOfSource === 'undefined' ? immutablePrimitive(base[key], additionalMappers) : deepFill(base[key], keyOfSource, additionalMappers);
} else {
newObj[key] = immutablePrimitive(base[key], additionalMappers);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/@o3r/rules-engine/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
"jest-junit": "~16.0.0",
"jest-preset-angular": "~14.2.0",
"jsonc-eslint-parser": "~2.4.0",
"jsonpath-plus": "~10.0.0",
"jsonpath-plus": "~10.2.0",
"memfs": "~4.11.0",
"nx": "~19.5.0",
"pid-from-port": "^1.1.3",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { BehaviorSubject, of } from 'rxjs';
import { BehaviorSubject, firstValueFrom, of } from 'rxjs';
import { Operator } from '../operator/operator.interface';
import { operatorList } from '../operator/operators/index';
import { RulesetExecutor } from '../ruleset-executor';
import { ActionBlock, Ruleset } from '../structure';
import { Ruleset } from '../structure';
import { filterRulesetsEventStream } from './filter-ruleset-event.operator';

describe('Filter rulesets event operator', () => {
Expand Down Expand Up @@ -134,68 +134,45 @@ describe('Filter rulesets event operator', () => {
}, {});

const firstValue = rulesets.reduce<Record<string, RulesetExecutor>>((accRuleset, ruleset) => {
accRuleset[ruleset.id] = new RulesetExecutor(ruleset, {retrieveOrCreateFactStream: () => of(undefined), operators} as any);
accRuleset[ruleset.id] = new RulesetExecutor(ruleset, { retrieveOrCreateFactStream: () => of(undefined), operators } as any);
return accRuleset;
}, {});

const rulesetsMapSubject$ = new BehaviorSubject<Record<string, RulesetExecutor>>(firstValue);

test('should consider only first ruleset', (done) => {
test('should consider only first ruleset', async () => {

rulesetsMapSubject$.pipe(
filterRulesetsEventStream(['ruleset1'])
).subscribe(data => {
expect(data.length).toBe(2);
done();
});
const data = await firstValueFrom(rulesetsMapSubject$.pipe(filterRulesetsEventStream(['ruleset1'])));
expect(data.length).toBe(2);

});

test('should consider only second ruleset', (done) => {
test('should consider only second ruleset', async () => {

rulesetsMapSubject$.pipe(
filterRulesetsEventStream(['ruleset2'])
).subscribe(data => {
expect(data.length).toBe(1);
done();
});
const data = await firstValueFrom(rulesetsMapSubject$.pipe(filterRulesetsEventStream(['ruleset2'])));
expect(data.length).toBe(1);

});

test('should consider all rulesets by not passing any filter', (done) => {
test('should consider all rulesets by not passing any filter', async () => {

rulesetsMapSubject$.pipe(
filterRulesetsEventStream()
).subscribe(data => {
expect(data.length).toBe(3);
done();
});
const data = await firstValueFrom(rulesetsMapSubject$.pipe(filterRulesetsEventStream()));
expect(data.length).toBe(3);

});

test('should consider all rulesets ids passed', (done) => {
test('should consider all rulesets ids passed', async () => {

rulesetsMapSubject$.pipe(
filterRulesetsEventStream(['ruleset1', 'ruleset2'])
).subscribe(data => {
expect(data.length).toBe(3);
done();
});
const data = await firstValueFrom(rulesetsMapSubject$.pipe(filterRulesetsEventStream(['ruleset1', 'ruleset2'])));
expect(data.length).toBe(3);

});

test('should not emit if ruleset id does not match any registered ruleset', async () => {
test('should emit an empty array when no rulesets remain active', async () => {

let emittedActions: ActionBlock[] | undefined;
const data = await firstValueFrom(rulesetsMapSubject$.pipe(filterRulesetsEventStream(['ruleset3'])));
expect(data.length).toBe(0);

rulesetsMapSubject$.pipe(
filterRulesetsEventStream(['ruleset3'])
).subscribe(data => {
emittedActions = data;
});

await jest.advanceTimersByTimeAsync(500);
expect(emittedActions).toBe(undefined);
});

});
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { combineLatest, Observable } from 'rxjs';
import { combineLatest, Observable, of } from 'rxjs';
import { map, shareReplay, switchMap } from 'rxjs/operators';
import { RulesetExecutor } from '../ruleset-executor';

Expand All @@ -14,11 +14,13 @@ export function filterRulesetsEventStream(restrictiveRuleSets?: string[]) {
Object.values(rulesets).filter((ruleSet) => restrictiveRuleSets.indexOf(ruleSet.id) > -1) :
Object.values(rulesets);

return combineLatest(activeRulesets.map((ruleset) => ruleset.rulesResultsSubject$)).pipe(
map((item) => item.reduce((acc, currentValue) => {
acc.push(...currentValue);
return acc;
}, [])));
return activeRulesets?.length > 0
? combineLatest(activeRulesets.map((ruleset) => ruleset.rulesResultsSubject$)).pipe(
map((item) => item.reduce((acc, currentValue) => {
acc.push(...currentValue);
return acc;
}, [])))
: of([]);
}),
shareReplay(1)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ describe('Rules engine service', () => {
next: value => nextFn(value)
});
// should output no actions as all rulesets are on demand
expect(nextFn).not.toHaveBeenCalled();
expect(nextFn).toHaveBeenCalledWith([]);
sub.unsubscribe();

// activate ruleset 1 via his own linked component
Expand Down
44 changes: 22 additions & 22 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4870,21 +4870,21 @@ __metadata:
languageName: node
linkType: hard

"@jsep-plugin/assignment@npm:^1.2.1":
version: 1.2.1
resolution: "@jsep-plugin/assignment@npm:1.2.1"
"@jsep-plugin/assignment@npm:^1.3.0":
version: 1.3.0
resolution: "@jsep-plugin/assignment@npm:1.3.0"
peerDependencies:
jsep: ^0.4.0||^1.0.0
checksum: 10/d8db45f052fd95b33207ded7f49af9ae48ff5ce10cb898e28a6fca722863f4a3330892c3a2c355a1a8c94fd230eef3db9be0c45324cb526e5edff7085c1f7a37
checksum: 10/0c93b703d84af95b4be9fb6c23fbdbe7c7b6985b41c98fd10386cd54686ed1eb751cb39f5d54abcb621e4da2a0900a3b2a852e5bf7f2d322b756db3b22e42a45
languageName: node
linkType: hard

"@jsep-plugin/regex@npm:^1.0.3":
version: 1.0.3
resolution: "@jsep-plugin/regex@npm:1.0.3"
"@jsep-plugin/regex@npm:^1.0.4":
version: 1.0.4
resolution: "@jsep-plugin/regex@npm:1.0.4"
peerDependencies:
jsep: ^0.4.0||^1.0.0
checksum: 10/c08c7bd79a164995923ea799949b9f6b18dcf2bd314522ed0dcfc669fd249a06fea200606086c7d54b12d39ce3cfa61d910229e5184c667ead135f6da6997532
checksum: 10/0ea6ba81f03955972b762fd9fbc8e3fd7e1c1c12e52ce3d4366e23c0a63c8bff8528687b8b3d8f641cf9f626f8bf5a7841efcd31a2489fe967e1900e5738ee3a
languageName: node
linkType: hard

Expand Down Expand Up @@ -6646,7 +6646,7 @@ __metadata:
jest-junit: "npm:~16.0.0"
jest-preset-angular: "npm:~14.2.0"
jsonc-eslint-parser: "npm:~2.4.0"
jsonpath-plus: "npm:~10.0.0"
jsonpath-plus: "npm:~10.2.0"
memfs: "npm:~4.11.0"
nx: "npm:~19.5.0"
pid-from-port: "npm:^1.1.3"
Expand Down Expand Up @@ -7681,7 +7681,7 @@ __metadata:
jest-preset-angular: "npm:~14.2.0"
js-yaml: "npm:^4.1.0"
jsonc-eslint-parser: "npm:~2.4.0"
jsonpath-plus: "npm:~10.0.0"
jsonpath-plus: "npm:~10.2.0"
lighthouse: "npm:9.6.8"
lint-staged: "npm:^15.0.0"
minimist: "npm:^1.2.6"
Expand Down Expand Up @@ -8249,7 +8249,7 @@ __metadata:
jest-junit: "npm:~16.0.0"
jest-preset-angular: "npm:~14.2.0"
jsonc-eslint-parser: "npm:~2.4.0"
jsonpath-plus: "npm:~10.0.0"
jsonpath-plus: "npm:~10.2.0"
memfs: "npm:~4.11.0"
nx: "npm:~19.5.0"
pid-from-port: "npm:^1.1.3"
Expand Down Expand Up @@ -22752,10 +22752,10 @@ __metadata:
languageName: node
linkType: hard

"jsep@npm:^1.3.9":
version: 1.3.9
resolution: "jsep@npm:1.3.9"
checksum: 10/c60d7064c3b5047f58345e65e7618bbaecf2f46338e56689244db057b0550bf8fb7c1457a7384dfd38aca9acde3ff851d062c3f182cc1fbc66c13cb2ca0b579d
"jsep@npm:^1.4.0":
version: 1.4.0
resolution: "jsep@npm:1.4.0"
checksum: 10/935824fe6ac28fcff3cd13878f508f99f6c13e7f0f53ec9fca0d3db465e6dd15f8af030bcdc75a38b07c78359c656647435923a26aceb91607027021f00c17f2
languageName: node
linkType: hard

Expand Down Expand Up @@ -22923,17 +22923,17 @@ __metadata:
languageName: node
linkType: hard

"jsonpath-plus@npm:~10.0.0":
version: 10.0.6
resolution: "jsonpath-plus@npm:10.0.6"
"jsonpath-plus@npm:~10.2.0":
version: 10.2.0
resolution: "jsonpath-plus@npm:10.2.0"
dependencies:
"@jsep-plugin/assignment": "npm:^1.2.1"
"@jsep-plugin/regex": "npm:^1.0.3"
jsep: "npm:^1.3.9"
"@jsep-plugin/assignment": "npm:^1.3.0"
"@jsep-plugin/regex": "npm:^1.0.4"
jsep: "npm:^1.4.0"
bin:
jsonpath: bin/jsonpath-cli.js
jsonpath-plus: bin/jsonpath-cli.js
checksum: 10/1d57988878f095d2fdc6efdbdfb612472c4961882a8e1dc3333e540880689be823cf7fc6fcdd36311c246adf96293796cf2d5992eff3ce82044a39ceb74abea6
checksum: 10/3a6bd775d4348f5e014249a11abb635af2f1265d83ba716b3d633ca3f118e79c318223dd685170c50652494a492f3354163bbe4cd5554bb4d7992fecf53c4874
languageName: node
linkType: hard

Expand Down

0 comments on commit c343340

Please sign in to comment.