# @cauca-911/core

Run `npm install @cauca-911/core` to add this library to your project.

## Setup

Use `provideCaucaCore()` in your application configuration:

```typescript
export const appConfig: ApplicationConfig = {
  providers: [
    provideCaucaCore({
      logLevel: LogLevel.warning,                      // default: LogLevel.error
      logError: (logLevel, message, data) => void,     // default: no-op
      apiUrl: 'http://example.com/api/',               // default: ''
      languages: ['fr'],                               // default: ['fr', 'en']
      loginURL: () => '/login',                        // default: () => '/login/'
      allowRefreshToken: true,                         // default: false
      refreshLoginURL: '/refreshLogin',                // default: ''
      libraries: ['devextreme', 'material'],           // default: []
      i18nPaths: ['additional-folder'],                // default: []
      locale: 'fr',                                    // default: ''
      jsonConfigFile: 'path/config.json',              // default: ''
      nbRetryOnNetworkError: 2,                        // default: 0
      contentSecurityPolicyActivated: true,            // default: false
    }),
    provideHttpClient(withInterceptorsFromDi()),
  ]
};
```

See `CoreModuleOptions` for all available options.

## Unit Testing

Use `provideTestingTranslation()` to replace `TranslateService` with a lightweight synchronous mock:

```typescript
TestBed.configureTestingModule({
  providers: [
    ...provideTestingTranslation(),
  ]
});
```

Pass an optional key→value map to control resolved translations:

```typescript
...provideTestingTranslation({ 'my.key': 'My Value' })
```

## Components

- `CaucaPageNotFoundComponent` — Add the `**` route to your routing:
  ```typescript
  { path: '**', component: CaucaPageNotFoundComponent }
  ```

## Services

- `CaucaCoreService` — `getConfig()` returns the active configuration.
- `ClientInformationService`
- `FullscreenService`
- `ImageService`
- `LogService`
  - `publishError` — Posts errors to the web API at `{apiUrl}Error/logErrors` or `{apiUrl}logErrors`.
  - `information`, `warning`, `error`, `disconnection` — Log at the corresponding `LogLevel`.
- `NetworkInformationService`
- `VersionCheckService`

## HTTP Interceptors

- `HttpOfflineInterceptor` — Returns an error when the client is offline.
- `HttpTokenWriterInterceptor` — Adds `Authorization` and `CSRF` headers when configured.
- `HttpTokenReaderInterceptor` — Reads the CSRF token from responses.
- `HttpErrorInterceptor` — Catches HTTP errors and displays them via Angular Material's snack bar.

## Generic Classes

- `Configuration`
- `Browser`
- `Color`
- `OperatingSystem`
