open-index/open-npm huggingface dataset:
npm package: @ria-pro/mfe-integration
Description: Library for Micro-Frontends (MFE) integrating with the **eesti.ee** portal. It provides a standard interface for MFEs to interact with the portal shell, access user information, language settings, and configuration.
Latest version: 1.0.0

# @ria/mfe-integration

Library for Micro-Frontends (MFE) integrating with the **eesti.ee** portal. It provides a standard interface for MFEs to interact with the portal shell, access user information, language settings, and configuration.

## Core Interface: `MfeIntegration`

The main interface provided by this library is `MfeIntegration`. It allows the MFE to communicate with the portal shell and retrieve essential data.

### Methods

- `userInfo()`: Returns a `BehaviorSubject<IntegrationUserInfo | undefined>`. Provides information about the currently authenticated user.
- `language()`: Returns a `BehaviorSubject<Language>`. Provides the current language of the portal (e.g., ET, EN, RU).
- `portalType()`: Returns a `BehaviorSubject<PortalType>`. Indicates the current portal type (e.g., CITIZEN, BUSINESS).
- `getShellConfig()`: Returns a `Promise<AppConfig>`. Retrieves the shell configuration (primarily for RIA-handled MFEs).
- `getApiBaseUrl()`: Returns the API base URL for the MFE.
- `getOtherData()`: Returns a `Map<string, string>` containing additional configuration or data.
- `loaded()`: Should be called by the MFE when it is fully loaded and ready to be displayed.
- `destruct()`: Used to clean up resources when the MFE is being destroyed.

## Data Models

### `IntegrationUserInfo`
Contains detailed information about the authenticated user:
- `firstName`, `lastName`, `fullName`
- `personalCode`
- `loggedInDate`, `loginExpireDate` (Unix timestamps)
- `representedParty`: Information about the party the user is representing (Citizen or Business).

### `Language`
Enum representing the portal's supported languages.

### `PortalType`
Enum representing the type of portal environment (e.g., Citizen, Business).

## Usage Example

```typescript
import { MfeIntegration, IntegrationUserInfo } from '@ria/mfe-integration';

// Assuming the 'mfeIntegration' instance is provided by the portal shell
const integration: MfeIntegration = getMfeIntegrationInstance();

// Subscribe to user info updates
integration.userInfo().subscribe((user: IntegrationUserInfo | undefined) => {
  if (user) {
    console.log(`Hello, ${user.firstName}!`);
  } else {
    console.log('User is not authenticated.');
  }
});

// Subscribe to language changes
integration.language().subscribe(lang => {
  console.log(`Current language: ${lang}`);
});

// Notify the shell that MFE is loaded
integration.loaded();
```