Skip to content

Commit

Permalink
feat(#1693): create interface itemidentifier (#2057)
Browse files Browse the repository at this point in the history
## Proposed change
Create interface ItemIdentifier

## Related issues

- 🚀 Feature #1693

<!-- Please make sure to follow the contributing guidelines on
https://github.com/amadeus-digital/Otter/blob/main/CONTRIBUTING.md -->
  • Loading branch information
matthieu-crouzet committed Aug 19, 2024
2 parents f442d31 + 0f9560e commit 976ffce
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { logging } from '@angular-devkit/core';
import type { ConfigProperty, ConfigPropertyTypes, ConfigType, NestedConfiguration } from '@o3r/components';
import { CategoryDescription } from '@o3r/core';
import type { CategoryDescription, ItemIdentifier } from '@o3r/core';
import { ConfigDocParser } from '@o3r/extractors';
import { O3rCliError } from '@o3r/schematics';
import { readFileSync } from 'node:fs';
Expand Down Expand Up @@ -63,7 +63,7 @@ export class ComponentConfigExtractor {
public readonly DEFAULT_UNKNOWN_TYPE = 'unknown';

/** Parser of configuration doc */
private configDocParser: ConfigDocParser;
private readonly configDocParser: ConfigDocParser;

/**
* @param libraryName
Expand All @@ -75,10 +75,10 @@ export class ComponentConfigExtractor {
* @param libraries
*/
constructor(
private libraryName: string,
private strictMode: boolean,
private readonly libraryName: string,
private readonly strictMode: boolean,
public source: ts.SourceFile,
private logger: logging.LoggerApi,
private readonly logger: logging.LoggerApi,
public filePath: string,
public checker: ts.TypeChecker,
public libraries: string[] = []
Expand Down Expand Up @@ -129,7 +129,7 @@ export class ComponentConfigExtractor {
* @param source
*/
private getTypeFromNode(node: ts.Node | undefined, configurationWrapper?: ConfigurationInformationWrapper, source: ts.SourceFile = this.source):
{type: ConfigPropertyTypes; ref?: {library: string; name: string}; choices?: string[]} {
{type: ConfigPropertyTypes; ref?: ItemIdentifier; choices?: string[]} {
const nestedConfiguration = configurationWrapper?.nestedConfiguration;
const enumTypesAlias = configurationWrapper?.unionTypeStringLiteral;
if (!node) {
Expand Down
4 changes: 2 additions & 2 deletions packages/@o3r/components/src/core/component.output.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { CategoryDescription, ConfigPropertyWidget, Output } from '@o3r/core';
import type { CategoryDescription, ConfigPropertyWidget, ItemIdentifier, Output } from '@o3r/core';

/** Types of components config */
export type ConfigType = 'Block' | 'Page' | 'AppRuntimeConfiguration' | 'AppBuildConfiguration' | 'ExposedComponent';
Expand Down Expand Up @@ -92,7 +92,7 @@ export interface ConfigProperty {
/** Label to be used in the CMS for this config */
label: string;
/** Reference to the nested configuration if applicable */
reference?: { library: string; name: string };
reference?: ItemIdentifier;
/** List of possible value options */
choices?: string[];
/** The category of the config property */
Expand Down
1 change: 1 addition & 0 deletions packages/@o3r/core/src/core/interfaces/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './configuration';
export * from './context';
export * from './item-identifier';
export * from './translation';
13 changes: 13 additions & 0 deletions packages/@o3r/core/src/core/interfaces/item-identifier.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* Unique identifier of an item in the extracted metadata
*/
export interface ItemIdentifier {
/**
* Name of the library where the item is originally from
*/
library: string;
/**
* Name of the item
*/
name: string;
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import type { ItemIdentifier } from '@o3r/core';

/** Metadata information added in the design token extension for Metadata extraction */
export interface DesignTokenMetadata {
tags?: string[];
Expand All @@ -6,12 +8,7 @@ export interface DesignTokenMetadata {
/** Name of a group of variables */
category?: string;
/** Component reference if the variable is linked to one */
component?: {
/** Name of the component */
name: string;
/** Name of the library containing the component */
library: string;
};
component?: ItemIdentifier;
}

/** Design Token Group Extension fields supported by the default renderer */
Expand Down
6 changes: 3 additions & 3 deletions packages/@o3r/rules-engine/src/engine/engine.interface.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Logger } from '@o3r/core';
import type { ItemIdentifier, Logger } from '@o3r/core';
import { BehaviorSubject, Observable } from 'rxjs';
import type { EngineDebugger } from './debug/engine.debug';
import type { Fact, Facts } from './fact';
Expand Down Expand Up @@ -79,12 +79,12 @@ export interface EngineRuleset {
* 'or' condition: If at least one component has subscribed, the ruleset will become active.
* If present, the {@link linkedComponent} property will not be taken into consideration
*/
linkedComponents?: {or: { library: string; name: string }[]};
linkedComponents?: {or: ItemIdentifier[]};
/**
* Component linked to the ruleset, if set it will disable the ruleset execution per default, waiting to a subscription
* @deprecated It will be removed in v12, use {@link linkedComponents} instead
*/
linkedComponent?: { library: string; name: string };
linkedComponent?: ItemIdentifier;
/** Unique id of the ruleset*/
id: string;
/** Stores the result of each rules from the ruleset */
Expand Down
6 changes: 3 additions & 3 deletions packages/@o3r/rules-engine/src/engine/structure.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { RulesEngineAction } from '@o3r/core';
import type { ItemIdentifier, RulesEngineAction } from '@o3r/core';

export type NativeTypes = string | boolean | number;
/** Generic operand */
Expand Down Expand Up @@ -141,10 +141,10 @@ export interface Ruleset {
* 'or' condition: If at least one component has subscribed, the ruleset will become active.
* If provided, the {@link linkedComponent} property will not be taken into consideration
*/
linkedComponents?: {or: {library: string; name: string}[]};
linkedComponents?: {or: ItemIdentifier[]};
/**
* Component linked to the ruleset, if set it will disable the ruleset execution per default, waiting to a subscription
* @deprecated It will be removed in v12, use {@link linkedComponents} instead
*/
linkedComponent?: {library: string; name: string};
linkedComponent?: ItemIdentifier;
}
4 changes: 3 additions & 1 deletion packages/@o3r/styling/src/core/styles.interface.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import type { ItemIdentifier } from '@o3r/core';

export type CssVariableType = 'string' | 'color';

/** Metadata for a CSS Variable */
Expand All @@ -19,7 +21,7 @@ export interface CssVariable {
/** Name of a group of variables */
category?: string;
/** component reference if the variable is linked to one */
component?: { library: string; name: string };
component?: ItemIdentifier;
}

/** Style Metadata map */
Expand Down

0 comments on commit 976ffce

Please sign in to comment.