Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove deprecated from v10 #941

Merged
merged 1 commit into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/2-AMA-SDK-ISSUE-FORM.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ body:
multiple: true
options: [
core,
generator-sdk,
schematics,
swagger-builder
]
validations:
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/code-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ jobs:
${{ runner.os }}-jest-${{ env.hash }}
${{ runner.os }}-jest
${{ runner.os }}
- name: Build swagger generator
run: yarn nx run ama-sdk-generator-sdk:build-swagger
- name: Test
env:
testCmd: ${{ inputs.affected && format('test:affected --base=remotes/origin/{0}', github.base_ref || github.ref_name) || 'test'}}
Expand Down
1 change: 0 additions & 1 deletion .nxignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
**/src/package.json
packages/@ama-sdk/generator-sdk/src/**/templates/**/*.{j,t}s
packages/@*/*/{builders,schematics}/**/templates/**/*.ts
packages/@*/*/{builders,schematics}/**/mocks/**/*.ts
packages/@*/*/build/**
26 changes: 12 additions & 14 deletions docs/localization/LOCALIZATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Localization module is built on top of an open source [ngx-translate](https://gi

- Intelligent fallback support. For any un-supported language request, localization service fallback to fallback locale map language OR first nearest supported language. More information in the `intelligent fallback` section below.

- Ability to toggle translations on and off to help identify the key corresponding to a translation.
- Ability to toggle translations on and off to help identify the key corresponding to a translation.

# How to use

Expand Down Expand Up @@ -378,8 +378,6 @@ constructor(private router: Router,

### How to add RTL support in my app

* Note: **TextDirectionDirective** is deprecated. Please refer to **TextDirectionService**.

The **TextDirectionService** has to be injected in `app.component.ts` as follows.

```typescript
Expand Down Expand Up @@ -407,7 +405,7 @@ import {
LazyMessageFormatConfig,
LocalizationModule,
translateLoaderProvider,
TranslateMessageFormatLazyCompiler
TranslateMessageFormatLazyCompiler
} from "@o3r/localization";
import { TranslateModule } from "@ngx-translate/core";
import { MESSAGE_FORMAT_CONFIG } from 'ngx-translate-messageformat-compiler';
Expand Down Expand Up @@ -446,8 +444,8 @@ class AppModule {}

### How to localize plural expression

For pluralizations, we are using _TranslateMessageFormatCompiler_, coming from [ngx-translate-messageformat-compiler](https://www.npmjs.com/package/ngx-translate-messageformat-compiler) package, which is a compiler for _ngx-translate_ that uses _messageformat.js_ to compile translations using ICU syntax for handling pluralization and gender.
[ICU Message Format](http://userguide.icu-project.org/formatparse/messages) is a standardized syntax for dealing with the translation of user-visible strings into various languages that may have different requirements for the correct declension of words (e.g. according to number, gender, case) - or to simplify: pluralization.
For pluralizations, we are using _TranslateMessageFormatCompiler_, coming from [ngx-translate-messageformat-compiler](https://www.npmjs.com/package/ngx-translate-messageformat-compiler) package, which is a compiler for _ngx-translate_ that uses _messageformat.js_ to compile translations using ICU syntax for handling pluralization and gender.
[ICU Message Format](http://userguide.icu-project.org/formatparse/messages) is a standardized syntax for dealing with the translation of user-visible strings into various languages that may have different requirements for the correct declension of words (e.g. according to number, gender, case) - or to simplify: pluralization.
Simple pluralization rules like _0, 1 or other_ fits well for English but may not fit for many other languages (Eastern Europe languages, Asiatic languages) where pluralization rules are much more complex. If this does not fit your requirement we recommend to reformulate your text, so that you do not need to use pluralization. Example: instead of saying 'You have added 2 baggages' you may want to say 'Pieces of baggage: 2' which should be fine for most languages no matter which number is considered to be plural.

#### Integration with ngx-translate
Expand Down Expand Up @@ -492,7 +490,7 @@ import {MESSAGE_FORMAT_CONFIG} from 'ngx-translate-messageformat-compiler';
```
The value of _translations.nbOfErrors_ is the translation key 'o3r-list-inline-messages-pres.nbOfErrors'. The next step translates the key passing some parameters to translate pipe.
__Output__
The output will be
The output will be
- _No errors_ if _countMessages_ is 0
- _1 error_ if _countMessages_ is 1
- _'Value of count messages' errors_ if _countMessages_ is greater than 1 (ex: 10 Errors)
Expand All @@ -508,7 +506,7 @@ Sometimes you may want to display a different resource based on some property va
```

```typescript
// in component html
// in component html
<ul>
<li>{{ translations.people | translate: { gender: 'female', how: 'influential' } }}</li>
<li>{{ translations.people | translate: { gender: 'male', how: 'funny' } }}</li>
Expand All @@ -519,22 +517,22 @@ Note again that _translations.people_ matches _global.people_ key

__Output__
```
- She is influential
- He is funny
- They are affectionate
- She is influential
- He is funny
- They are affectionate
```

# Debugging

## Runtime: toggle translation on and off

In order to be able to more easily identify which key corresponds to a given text, the ``LocalizationService`` exposes a function ``toggleShowKeys()`` that can be called in order to deactivate or reactivate the translation mechanism at __runtime__.
In order to be able to more easily identify which key corresponds to a given text, the ``LocalizationService`` exposes a function ``toggleShowKeys()`` that can be called in order to deactivate or reactivate the translation mechanism at __runtime__.
While deactivated, the ``translate`` __pipe__ and __directive__ will output the translation keys instead of their resolved values.

> __Important__: this mechanism only applies to the pipe and directive exported by Otter's ``LocalizationModule``. The original ones from ``ngx-translate`` do not support it.

First, this mechanism has to be activated via the ``LocalizationConfiguration`` that you can provide in your ``ApplicationModule``.
This is mainly for performances reason: the way it works is it adds a new subscription to every ``translate`` pipe and directive in order to know when translations are turned on or off.
First, this mechanism has to be activated via the ``LocalizationConfiguration`` that you can provide in your ``ApplicationModule``.
This is mainly for performances reason: the way it works is it adds a new subscription to every ``translate`` pipe and directive in order to know when translations are turned on or off.
Not enabling it allows to avoid all those subscriptions, and should be the baseline for a production environment.

Example:
Expand Down
4 changes: 2 additions & 2 deletions docs/sdk-tools/SDK_MODELS_HIERARCHY.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SDK models hierarchy

The purpose of this documentation is to provide a high-level overview of models' hierarchy of an SDK generated via the [@ama-sdk/generator-sdk](../packages/@ama-sdk/generator-sdk/) generator.
The purpose of this documentation is to provide a high-level overview of models' hierarchy of an SDK generated via the [@ama-sdk/schematics](../packages/@ama-sdk/schematics/) generator.

## Overview

Expand Down Expand Up @@ -79,7 +79,7 @@ import type { MyModelCoreIfy } from './my-model';

/**
* Generate reviver for MyModel core model
*
*
* @param baseRevive
*/
export function reviveMyModelFactory<R extends typeof reviveMyModel>(baseRevive: R) {
Expand Down
2 changes: 1 addition & 1 deletion docs/swagger-builder/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ To perform validity check of a set of Swagger Specifications, additional tools a
A code generator is provided to generate an extension of the **Amadeus Digital Experience API**.

```bash
yarn yo @ama-sdk/sdk:api-extension
yarn dlx -p @angular-devkit/schematics-cli schematics @ama-sdk/schematics:api-extension
matthieu-crouzet marked this conversation as resolved.
Show resolved Hide resolved
```

> More information on [Generators documentation](../../README.md).
Expand Down
6 changes: 1 addition & 5 deletions packages/@ama-sdk/core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This package contains all the [plugins](/packages/@ama-sdk/core/src/plugins), helpers and object definitions to dialog with an API following the `ama-sdk` architecture.

Please refer to the [generator-sdk](/packages/@ama-sdk/generator-sdk/README.md) package for getting started with an API based on `ama-sdk`.
Please refer to the [ama-sdk-schematics](/packages/@ama-sdk/schematics/README.md) package for getting started with an API based on `ama-sdk`.

## Available plugins

Expand All @@ -17,15 +17,11 @@ Please refer to the [generator-sdk](/packages/@ama-sdk/generator-sdk/README.md)
- [exception](/packages/@ama-sdk/core/src/plugins/exception)
- [fetch-cache](/packages/@ama-sdk/core/src/plugins/fetch-cache)
- [fetch-credentials](/packages/@ama-sdk/core/src/plugins/fetch-credentials)
- [fetch-options](/packages/@ama-sdk/core/src/plugins/fetch-options)
- [gateway-token](/packages/@ama-sdk/core/src/plugins/gateway-token)
- [imperva](/packages/@ama-sdk/core/src/plugins/imperva)
- [json-token](/packages/@ama-sdk/core/src/plugins/json-token)
- [keepalive](/packages/@ama-sdk/core/src/plugins/keepalive)
- [mock-intercept](/packages/@ama-sdk/core/src/plugins/mock-intercept)
- [perf-metric](/packages/@ama-sdk/core/src/plugins/perf-metric)
- [pii-tokenizer](/packages/@ama-sdk/core/src/plugins/pii-tokenizer)
- [public-facts](/packages/@ama-sdk/core/src/plugins/public-facts)
- [raw-response-info](/packages/@ama-sdk/core/src/plugins/raw-response-info)
- [retry](/packages/@ama-sdk/core/src/plugins/retry)
- [reviver](/packages/@ama-sdk/core/src/plugins/reviver)
Expand Down
40 changes: 0 additions & 40 deletions packages/@ama-sdk/core/src/fwk/date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ export class CommonDate extends Date {
super(...(args as []));
}

/** @deprecated will be removed in v10 */
public get dateInstance(): Date { return this; }

/**
* Overrides the JSON conversion to remove any timezone information.
*/
Expand Down Expand Up @@ -130,42 +127,5 @@ export namespace utils {
* To ensure that users cannot use a standard Date instead of utils.DateTime
*/
protected _DateTime(): void {}

/**
* Get an instance of utils.Date base on the current date
*
* @deprecated will be removed in v10
*/
public getUtilsDate(): Date {
return new Date(this);
}
}

/**
* Receives an object containing key/value pairs
* Encodes this object to match application/x-www-urlencoded or multipart/form-data
*
* @deprecated Please use processFormData in api.helpers, will be removed in v10
*/
export function processFormData(headers: Headers, data: any, type: string): any {

let encodedData: any;

if (type === 'multipart/form-data') {
const formData: FormData = new FormData();
for (const i in data) {
formData.append(i, data[i]);
}
encodedData = formData;
} else {
headers.set('Content-Type', 'application/x-www-form-urlencoded');
const formData: string[] = [];
for (const i in data) {
formData.push(`${i}=${encodeURIComponent(data[i])}`);
}
encodedData = formData.join('&');
}

return encodedData;
}
}
11 changes: 0 additions & 11 deletions packages/@ama-sdk/core/src/fwk/mocks/base-mock-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,6 @@ export abstract class BaseMockAdapter implements MockAdapter {
return id;
}

/**
* @inheritDoc
*/
public getOperationId(request: EncodedApiRequest): string {
if (typeof this.pathObjects === 'function') {
throw new Error('The pathObjects argument must be of type PathObject[]');
}
const object = getPath(request.basePath, this.pathObjects, request.method);
return this.extractOperationIdFromPath(request, object);
}

/**
* @inheritDoc
*/
Expand Down
8 changes: 0 additions & 8 deletions packages/@ama-sdk/core/src/fwk/mocks/mock-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,6 @@ export interface MockAdapter {
*/
getLatestMock(operationId: string): Mock<any>;

/**
* Retrieves an operation ID from an API request
*
* @param request the api request
* @deprecated Please use retrieveOperationId instead
*/
getOperationId(request: EncodedApiRequest): string;

/**
* Retrieves an operation ID from an API request
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,6 @@ import {PluginRunner, RequestOptions, RequestPlugin} from '../core';
*/
export type BotProtectionFingerprintRetriever = () => string | undefined | Promise<string | undefined>;

/**
* Implementation of a retriever based on a cookie.
* Creates a reused RegExp based on the cookieName and tries to extract its value from document.cookie.
*
* @param cookieName Name of the cookie to search for
* @deprecated Imperva integration should rely on the latest impervaProtectionRetrieverFactory
*/
export function cookieRetrieverFactory(cookieName: string): BotProtectionFingerprintRetriever {
const cookieRegExp = new RegExp(`(?:^|;)\\s*${cookieName}\\s*=\\s*([^;]+)`);
return () => {
if (typeof document === 'undefined') {
throw new Error('[SDK][Plug-in][BotProtectionFingerprintRequest] Trying to use cookieRetrieverFactory but "document" is not defined.');
}
const cookieMatcher = document.cookie && document.cookie.match(cookieRegExp);
if (cookieMatcher) {
return cookieMatcher[cookieMatcher.length - 1];
}
};
}

/**
* Represents the object exposed by Imperva for the integration of their Advanced Bot Protection script with Singe Page Apps.
*/
Expand Down Expand Up @@ -119,32 +99,6 @@ export function akamaiTelemetryRetrieverFactory(bmakOpt?: AkamaiObject): BotProt
};
}

/**
* Implementation of a retriever based on the way Imperva stores the fingerprint information in localStorage.
* Since it contains the expiry time of the fingerprint we are able to ignore it if it has to be recomputed.
*
* @param storageKey The name of the property in local storage where the fingerprint is saved
* @param ignoreExpired Return the fingerprint even if it is expired. Default: false
* @deprecated Imperva integration should rely on the latest impervaProtectionRetrieverFactory
*/
export function impervaLocalStorageRetrieverFactory(storageKey: string, ignoreExpired = false): BotProtectionFingerprintRetriever {
return () => {
if (typeof localStorage === 'undefined') {
throw new Error('[SDK][Plug-in][BotProtectionFingerprintRequest] Trying to use localStorageRetrieverFactory but localStorage is not defined.');
}
const storedFingerprint = localStorage.getItem(storageKey);

try {
const parsedFingerprint = storedFingerprint && JSON.parse(storedFingerprint) as { token?: string; renewTime?: number };

if (parsedFingerprint && (ignoreExpired || parsedFingerprint.renewTime && parsedFingerprint.renewTime >= Date.now())) {
return parsedFingerprint.token;
}
} catch {
}
};
}

/**
* Options to configure the fingerprint poller
*/
Expand Down
Loading
Loading