Skip to content

Commit

Permalink
feat: clean up deprecated items for Otter v12
Browse files Browse the repository at this point in the history
  • Loading branch information
sdo-1A committed Dec 20, 2024
1 parent 91befdd commit 98a984f
Show file tree
Hide file tree
Showing 132 changed files with 166 additions and 3,380 deletions.
2 changes: 1 addition & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ packageExtensions:
"@swc/types": "*"
"@typescript-eslint/rule-tester@*":
dependencies:
"@typescript-eslint/parser": ~8.17.0
"@typescript-eslint/parser": ~8.18.0
"@angular-eslint/eslint-plugin-template@*":
dependencies:
"@typescript-eslint/types": "^8.0.0"
Expand Down
3 changes: 1 addition & 2 deletions apps/chrome-devtools/src/app-components/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,7 @@ export class AppComponent {
]).pipe(
map(([info, executions]) =>
executions.filter((execution) =>
(execution.rulesetInformation?.linkedComponent?.name === info.componentName)
|| (execution.rulesetInformation?.linkedComponents?.or.some((linkedComp) => linkedComp.name === info.componentName))
(execution.rulesetInformation?.linkedComponents?.or.some((linkedComp) => linkedComp.name === info.componentName))
)
)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@ export class ComponentPanelPresComponent {
]).pipe(
map(([info, executions]) =>
executions.filter((execution) =>
(execution.rulesetInformation?.linkedComponent?.name === info.componentName)
|| (execution.rulesetInformation?.linkedComponents?.or.some((linkedComp) => linkedComp.name === info.componentName))
(execution.rulesetInformation?.linkedComponents?.or.some((linkedComp) => linkedComp.name === info.componentName))
)
)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,10 @@ export class OtterComponentComponent implements OnChanges {
this.librariesLinkedToRulesetExecutions = [...(
new Set((this.rulesetExecutions || [])
.flatMap((execution) => {
const linkedComponent = execution.rulesetInformation?.linkedComponent;
const linkedComponents = execution.rulesetInformation?.linkedComponents?.or;
return (linkedComponents?.map((lc) => lc.library) || [linkedComponent?.library]).filter((lib): lib is string => !!lib);
return linkedComponents
? (linkedComponents.map((lc) => lc.library)).filter((lib): lib is string => !!lib)
: [];
})
)
)];
Expand Down
2 changes: 0 additions & 2 deletions docs/ab-testing/AB_TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,5 +261,3 @@ You can now create A/B testing-driven rulesets .
}

```
> Note: In v10 and previously, we used `linkedComponent` property to activate a ruleset on demand. This becomes deprecated and will be removed in v12. Use `linkedComponents` instead;
5 changes: 3 additions & 2 deletions docs/components/COMPONENT_REPLACEMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ That information is expected to be a property of the **component's configuration
Since configurations **have** to have a default value, in this specific instance it must always be the **empty string**. The default presenter will be declared in the component's class.

````typescript
import { computeConfigurationName, Configuration } from '@o3r/configuration';
import { Configuration } from '@o3r/configuration';
import { computeItemIdentifier } from '@o3r/core';

export interface DummyContConfig extends Configuration {
/** Key used to identify a custom component, if provided */
Expand All @@ -174,7 +175,7 @@ export const DUMMY_CONT_DEFAULT_CONFIG: DummyContConfig = {
customDummyKey: ''
}

export const DUMMY_CONT_CONFIG_ID = computeConfigurationName('DummyContConfig', '@scope/o3r-components');
export const DUMMY_CONT_CONFIG_ID = computeItemIdentifier('DummyContConfig', '@scope/o3r-components');
````

For more information on configuration, you can check this [documentation](../configuration/OVERVIEW.md).
Expand Down
101 changes: 0 additions & 101 deletions docs/components/PLACEHOLDERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -296,107 +296,6 @@ Thanks to the parameters map you can use fact variables with JSONPath in localiz
}
```

#### Variable support for localization variables (DEPRECATED)

Before, localization variables could reference facts via variables instead of parameters. This feature is currently deprecated and will be removed from Otter v12 as it is replaced by the parameters explained above.

``en-GB.json``

```json
{
"o3r-increment-key": "{increment, plural, =1 {1 second has} other {{{increment}} seconds have}} elapsed since you opened the page"
}
```

``template.json``

```json
{
"vars": {
"incrementKey": {
"type": "localisation",
"value": "o3r-increment-key",
"vars": [
"incrementVar"
]
},
"incrementVar": {
"type": "fact",
"value": "increment"
}
},
"template": "<div style=\"border-radius:10%; background:red;\"><%= incrementKey %></div>"
}
```

The 1-to-1 mapping between the fact name and the reference in the translation brings many inconveniences as explained below.

> [!CAUTION]
> **Limitations**
> Today you can only make a reference to a fact with the same name. You also cannot use JSON path to resolve your fact.
This means the following is not possible:

``ruleset.json``

```json
{
"vars": {
"incrementKey": {
"type": "localisation",
"value": "o3r-increment-key",
"vars": [
"incrementVar"
]
},
"incrementVar": {
"type": "fact",
"value": "incrementFact",
"path": "$.this.is.a.json.path"
}
},
"template": "<div style=\"border-radius:10%; background:red;\"><%= incrementKey %></div>"
}
```

> [!TIPS]
> **General notice**
Keep in mind that this feature deeply binds functional facts exposed in your application to your translations.
You will need to carefully plan the way you bind your localization key to your facts to avoid messy references.

For example, let's imagine you want a generic counter until specific events.
You will probably want to reuse your placeholder in different pages for different events:

```json
{
"vars": {
"titleKey": {
"type": "localisation",
"value": "o3r-event-title-key"
},
"contentWithCounterKey": {
"type": "localisation",
"value": "o3r-event-counter-key",
"vars": [
"increment"
]
},
"increment": {
"type": "fact",
"value": "increment"
}
},
"template": "<div style=\"fancy-style: with-many-properties;\"><span style=\"fancy-title-style: nice-properties;\"><%= titleKey %></span><div><%= contentWithCounterKey %></div></div>"
}
```

You might be tempted to use this generic template for all your events but the value of your counter parameter will
depend on the event itself (Easter or next Summer Holidays for example).
This means that ``increment`` might have a different value depending on the context of the page which might be tricky to
maintain and to debug.
Try to keep it as simple as possible.

### Multiple templates in same placeholder

You can use placeholder actions to target the same placeholderId with different template URLs.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# @o3r/matching-configuration-name

Ensures that the configuration interface name matches the first parameter of `computeConfigurationName` used beside the configuration interface to expose its ID (as generated by the configuration module).
Ensures that the configuration interface name matches the first parameter of `computeItemIdentifier` used beside the configuration interface to expose its ID (as generated by the configuration module).

## How to use

Expand Down
3 changes: 0 additions & 3 deletions docs/rules-engine/how-to-use/dedicated-component-ruleset.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,6 @@ prevent the execution of the Ruleset until your component is available in the pa
]
}
```
> [!INFO]
> In v10 and the previous version, the Otter framework exposed the `linkedComponent` property to activate a ruleset on demand.
> This is now deprecated and will be removed in v12. Use `linkedComponents` instead.

## How it works

Expand Down
3 changes: 1 addition & 2 deletions packages/@ama-sdk/client-angular/src/api-angular-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,7 @@ export class ApiAngularClient implements ApiClient {
exception = new EmptyResponseError(e.message || 'Fail to Fetch', undefined, { apiName, operationId, url, origin });
}

// eslint-disable-next-line no-console -- `console.error` is supposed to be the default value if the `options` argument is not provided, can be removed in Otter v12.
const reviver = getResponseReviver(revivers, response, operationId, { disableFallback: this.options.disableFallback, log: console.error });
const reviver = getResponseReviver(revivers, response, operationId, { disableFallback: this.options.disableFallback });
const replyPlugins = this.options.replyPlugins
? this.options.replyPlugins.map((plugin) => plugin.load<T>({
dictionaries: root && root.dictionaries,
Expand Down
1 change: 1 addition & 0 deletions packages/@ama-sdk/client-fetch/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
},
"dependencies": {
"@swc/helpers": "~0.5.0",
"ts-node": "~10.9.2",
"tslib": "^2.6.2",
"uuid": "^10.0.0"
},
Expand Down
1 change: 1 addition & 0 deletions packages/@ama-sdk/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
},
"dependencies": {
"@swc/helpers": "~0.5.0",
"ts-node": "~10.9.2",
"tslib": "^2.6.2",
"uuid": "^10.0.0"
},
Expand Down
3 changes: 1 addition & 2 deletions packages/@ama-sdk/core/src/clients/api-angular-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,7 @@ export class ApiAngularClient implements ApiClient {
exception = new EmptyResponseError(e.message || 'Fail to Fetch', undefined, { apiName, operationId, url, origin });
}

// eslint-disable-next-line no-console -- `console.error` is supposed to be the default value if the `options` argument is not provided, can be removed in Otter v12.
const reviver = getResponseReviver(revivers, response, operationId, { disableFallback: this.options.disableFallback, log: console.error });
const reviver = getResponseReviver(revivers, response, operationId, { disableFallback: this.options.disableFallback });
const replyPlugins = this.options.replyPlugins
? this.options.replyPlugins.map((plugin) => plugin.load<T>({
dictionaries: root && root.dictionaries,
Expand Down
4 changes: 2 additions & 2 deletions packages/@ama-sdk/core/src/fwk/api.helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export function tokenizeRequestOptions(tokenizedUrl: string, queryParameters: {
* @param endpoint
* @param options `{ disableFallback: false, log: console.error }` by default
* @param options.disableFallback `false` by default
* @param options.log `() => {}` by default -- warning: default value will change to `console.error` in Otter v12.
* @param options.log `console.error` by default
*/
export function getResponseReviver<T>(
revivers: { [statusCode: number]: ReviverType<T> | undefined } | undefined | ReviverType<T>,
Expand All @@ -124,7 +124,7 @@ export function getResponseReviver<T>(
options?: { disableFallback?: boolean; log?: (...args: any[]) => void }
): ReviverType<T> | undefined {
// eslint-disable-next-line no-console -- set as default value
const { disableFallback = false, log: logMsg = options ? () => {} : console.error } = options ?? {};
const { disableFallback = false, log: logMsg = console.error } = options ?? {};
const logPrefix = `API status code error for ${endpoint || 'unknown'} endpoint`;
if (!response || !response.ok) {
return undefined;
Expand Down
21 changes: 1 addition & 20 deletions packages/@ama-sdk/schematics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@
[![Bundle Size](https://img.shields.io/bundlephobia/min/@ama-sdk/schematics?color=green&style=for-the-badge)](https://www.npmjs.com/package/@ama-sdk/schematics)

This package provides `schematics` generators to create an SDK based on an OpenAPI specifications.
There are two SDK generators in the Otter Framework: Typescript and Java. The Java generator is currently in maintenance
mode and only the Typescript generator is actively supported and will see future evolutions.

- [Typescript SDK](#typescript-sdk)
- [Java SDK](#java-client-core-sdk)
The Otter framework provides a Typescript SDK generator.

## Typescript SDK

Expand Down Expand Up @@ -287,21 +283,6 @@ For more information on the generated SDK and how the framework supports differe
- [Generated SDK hierarchy and extension](https://github.com/AmadeusITGroup/otter/blob/main/docs/api-sdk/SDK_MODELS_HIERARCHY.md)
- [Composition and Inheritance support](https://github.com/AmadeusITGroup/otter/blob/main/docs/api-sdk/COMPOSITION_INHERITANCE.md)

## Java Client Core SDK

> [!WARNING]
> This feature is on maintenance mode and will see no future evolution
Generate a Java Client Core SDK:

Make sure to have a `./swagger-spec.yaml` file at the root of your project and run:

```shell
yarn schematics @ama-sdk/schematics:java-client-core --spec-path ./swagger-spec.yaml --swagger-config-path ./swagger-codegen-config.json
```

[Default swagger config](schematics/java/client-core/swagger-codegen-java-client/config/swagger-codegen-config.json) will be used if `--swagger-config-path` is not provided.

## Command Line Interface

This package also comes with CLI scripts that can facilitate the upgrade and publication of an SDK.
Expand Down
5 changes: 0 additions & 5 deletions packages/@ama-sdk/schematics/collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@
"description": "Generate a typescript SDK repository shell",
"factory": "./schematics/typescript/shell/index#ngGenerateTypescriptSDK",
"schema": "./schematics/typescript/shell/schema.json"
},
"java-client-core": {
"description": "[Deprecated - Removed in v12] Generate a Java SDK source code based on swagger specification",
"factory": "./schematics/java/client-core/index#ngGenerateJavaClientCore",
"schema": "./schematics/java/client-core/schema.json"
}
}
}
6 changes: 3 additions & 3 deletions packages/@ama-sdk/schematics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@
"postbuild": "patch-package-json-main",
"build:builders": "tsc -b tsconfig.builders.json --pretty && yarn generate-cjs-manifest",
"install-swagger-cli": "mvn install:install-file -DgroupId=io.swagger -DartifactId=swagger-codegen-cli -Dversion=2.4.0-AMADEUS -Dpackaging=jar -Dfile=./schematics/resources/swagger-codegen-cli.jar",
"build:swagger": "yarn install-swagger-cli && run-p 'build:swagger-*' 'build:openapi-*'",
"build:swagger": "yarn install-swagger-cli && run-p 'build:openapi-*'",
"build:openapi-typescript-gen": "mvn clean package -f ./schematics/typescript/core/openapi-codegen-typescript/pom.xml",
"build:swagger-java-client-gen": "mvn clean package -f ./schematics/java/client-core/swagger-codegen-java-client/pom.xml",
"build:cli": "tsc -b tsconfig.cli.json --pretty && yarn generate-cjs-manifest",
"prepare:publish": "prepare-publish ./dist"
},
Expand Down Expand Up @@ -70,6 +69,7 @@
"@o3r/schematics": "workspace:^",
"@openapitools/openapi-generator-cli": "^2.15.0",
"openapi-types": "^12.0.0",
"ts-node": "~10.9.2",
"type-fest": "^4.10.2"
},
"dependencies": {
Expand Down Expand Up @@ -144,7 +144,7 @@
"@swc/helpers": "~0.5.0",
"@commitlint/cli": "^19.0.0",
"@commitlint/config-conventional": "^19.0.0",
"@typescript-eslint/eslint-plugin": "~8.17.0",
"@typescript-eslint/eslint-plugin": "~8.18.0",
"jest-junit": "~16.0.0",
"lint-staged": "^15.0.0",
"minimist": "^1.2.6",
Expand Down

This file was deleted.

Loading

0 comments on commit 98a984f

Please sign in to comment.