ms-config-ng 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.editorconfig ADDED
@@ -0,0 +1,17 @@
1
+ # Editor configuration, see https://editorconfig.org
2
+ root = true
3
+
4
+ [*]
5
+ charset = utf-8
6
+ indent_style = space
7
+ indent_size = 2
8
+ insert_final_newline = true
9
+ trim_trailing_whitespace = true
10
+
11
+ [*.ts]
12
+ quote_type = single
13
+ ij_typescript_use_double_quotes = false
14
+
15
+ [*.md]
16
+ max_line_length = off
17
+ trim_trailing_whitespace = false
@@ -0,0 +1,54 @@
1
+
2
+ You are an expert in TypeScript, Angular, and scalable web application development. You write functional, maintainable, performant, and accessible code following Angular and TypeScript best practices.
3
+
4
+ ## TypeScript Best Practices
5
+
6
+ - Use strict type checking
7
+ - Prefer type inference when the type is obvious
8
+ - Avoid the `any` type; use `unknown` when type is uncertain
9
+
10
+ ## Angular Best Practices
11
+
12
+ - Always use standalone components over NgModules
13
+ - Must NOT set `standalone: true` inside Angular decorators. It's the default in Angular v20+.
14
+ - Use signals for state management
15
+ - Implement lazy loading for feature routes
16
+ - Do NOT use the `@HostBinding` and `@HostListener` decorators. Put host bindings inside the `host` object of the `@Component` or `@Directive` decorator instead
17
+ - Use `NgOptimizedImage` for all static images.
18
+ - `NgOptimizedImage` does not work for inline base64 images.
19
+
20
+ ## Accessibility Requirements
21
+
22
+ - It MUST pass all AXE checks.
23
+ - It MUST follow all WCAG AA minimums, including focus management, color contrast, and ARIA attributes.
24
+
25
+ ### Components
26
+
27
+ - Keep components small and focused on a single responsibility
28
+ - Use `input()` and `output()` functions instead of decorators
29
+ - Use `computed()` for derived state
30
+ - Prefer inline templates for small components
31
+ - Prefer Reactive forms instead of Template-driven ones
32
+ - Do NOT use `ngClass`, use `class` bindings instead
33
+ - Do NOT use `ngStyle`, use `style` bindings instead
34
+ - When using external templates/styles, use paths relative to the component TS file.
35
+
36
+ ## State Management
37
+
38
+ - Use signals for local component state
39
+ - Use `computed()` for derived state
40
+ - Keep state transformations pure and predictable
41
+ - Do NOT use `mutate` on signals, use `update` or `set` instead
42
+
43
+ ## Templates
44
+
45
+ - Keep templates simple and avoid complex logic
46
+ - Use native control flow (`@if`, `@for`, `@switch`) instead of `*ngIf`, `*ngFor`, `*ngSwitch`
47
+ - Use the async pipe to handle observables
48
+ - Do not assume globals like (`new Date()`) are available.
49
+
50
+ ## Services
51
+
52
+ - Design services around a single responsibility
53
+ - Use the `providedIn: 'root'` option for singleton services
54
+ - Use the `inject()` function instead of constructor injection
package/.prettierrc ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "printWidth": 100,
3
+ "singleQuote": true,
4
+ "overrides": [
5
+ {
6
+ "files": "*.html",
7
+ "options": {
8
+ "parser": "angular"
9
+ }
10
+ }
11
+ ]
12
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=827846
3
+ "recommendations": ["angular.ng-template"]
4
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
3
+ "version": "0.2.0",
4
+ "configurations": [
5
+ {
6
+ "name": "ng serve",
7
+ "type": "chrome",
8
+ "request": "launch",
9
+ "preLaunchTask": "npm: start",
10
+ "url": "http://localhost:4200/"
11
+ },
12
+ {
13
+ "name": "ng test",
14
+ "type": "chrome",
15
+ "request": "launch",
16
+ "preLaunchTask": "npm: test",
17
+ "url": "http://localhost:9876/debug.html"
18
+ }
19
+ ]
20
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ // For more information, visit: https://angular.dev/ai/mcp
3
+ "servers": {
4
+ "angular-cli": {
5
+ "command": "npx",
6
+ "args": ["-y", "@angular/cli", "mcp"]
7
+ }
8
+ }
9
+ }
@@ -0,0 +1,42 @@
1
+ {
2
+ // For more information, visit: https://go.microsoft.com/fwlink/?LinkId=733558
3
+ "version": "2.0.0",
4
+ "tasks": [
5
+ {
6
+ "type": "npm",
7
+ "script": "start",
8
+ "isBackground": true,
9
+ "problemMatcher": {
10
+ "owner": "typescript",
11
+ "pattern": "$tsc",
12
+ "background": {
13
+ "activeOnStart": true,
14
+ "beginsPattern": {
15
+ "regexp": "Changes detected"
16
+ },
17
+ "endsPattern": {
18
+ "regexp": "bundle generation (complete|failed)"
19
+ }
20
+ }
21
+ }
22
+ },
23
+ {
24
+ "type": "npm",
25
+ "script": "test",
26
+ "isBackground": true,
27
+ "problemMatcher": {
28
+ "owner": "typescript",
29
+ "pattern": "$tsc",
30
+ "background": {
31
+ "activeOnStart": true,
32
+ "beginsPattern": {
33
+ "regexp": "Changes detected"
34
+ },
35
+ "endsPattern": {
36
+ "regexp": "bundle generation (complete|failed)"
37
+ }
38
+ }
39
+ }
40
+ }
41
+ ]
42
+ }
package/README.md ADDED
@@ -0,0 +1,59 @@
1
+ # MsConfigNg
2
+
3
+ This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version 22.0.1.
4
+
5
+ ## Development server
6
+
7
+ To start a local development server, run:
8
+
9
+ ```bash
10
+ ng serve
11
+ ```
12
+
13
+ Once the server is running, open your browser and navigate to `http://localhost:4200/`. The application will automatically reload whenever you modify any of the source files.
14
+
15
+ ## Code scaffolding
16
+
17
+ Angular CLI includes powerful code scaffolding tools. To generate a new component, run:
18
+
19
+ ```bash
20
+ ng generate component component-name
21
+ ```
22
+
23
+ For a complete list of available schematics (such as `components`, `directives`, or `pipes`), run:
24
+
25
+ ```bash
26
+ ng generate --help
27
+ ```
28
+
29
+ ## Building
30
+
31
+ To build the project run:
32
+
33
+ ```bash
34
+ ng build
35
+ ```
36
+
37
+ This will compile your project and store the build artifacts in the `dist/` directory. By default, the production build optimizes your application for performance and speed.
38
+
39
+ ## Running unit tests
40
+
41
+ To execute unit tests with the [Vitest](https://vitest.dev/) test runner, use the following command:
42
+
43
+ ```bash
44
+ ng test
45
+ ```
46
+
47
+ ## Running end-to-end tests
48
+
49
+ For end-to-end (e2e) testing, run:
50
+
51
+ ```bash
52
+ ng e2e
53
+ ```
54
+
55
+ Angular CLI does not come with an end-to-end testing framework by default. You can choose one that suits your needs.
56
+
57
+ ## Additional Resources
58
+
59
+ For more information on using the Angular CLI, including detailed command references, visit the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page.
package/add.sh ADDED
@@ -0,0 +1,15 @@
1
+ #!/bin/bash
2
+
3
+ # Leer la versión actual desde el archivo package.json
4
+ current_version=$(grep -oP '(?<="version": ")[^"]*' projects/$1/package.json)
5
+
6
+ # Incrementar la versión
7
+ IFS='.' read -ra version_parts <<< "$current_version"
8
+ ((version_parts[2]++))
9
+ new_version="${version_parts[0]}.${version_parts[1]}.${version_parts[2]}"
10
+
11
+ # Reemplazar la versión en el archivo package.json
12
+ sed -i "s/\"version\": \"$current_version\"/\"version\": \"$new_version\"/g" projects/$1/package.json
13
+
14
+ # Marcar la versión con un tag en Git
15
+ git tag -a "$1/v$new_version" -m "$1 release $new_version"
package/angular.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3
+ "version": 1,
4
+ "cli": {
5
+ "packageManager": "npm"
6
+ },
7
+ "newProjectRoot": "projects",
8
+ "projects": {
9
+ "ms-config-ng": {
10
+ "projectType": "library",
11
+ "root": "projects/ms-config-ng",
12
+ "sourceRoot": "projects/ms-config-ng/src",
13
+ "prefix": "lib",
14
+ "architect": {
15
+ "build": {
16
+ "builder": "@angular/build:ng-packagr",
17
+ "configurations": {
18
+ "production": {
19
+ "tsConfig": "projects/ms-config-ng/tsconfig.lib.prod.json"
20
+ },
21
+ "development": {
22
+ "tsConfig": "projects/ms-config-ng/tsconfig.lib.json"
23
+ }
24
+ },
25
+ "defaultConfiguration": "production"
26
+ },
27
+ "test": {
28
+ "builder": "@angular/build:unit-test",
29
+ "options": {
30
+ "tsConfig": "projects/ms-config-ng/tsconfig.spec.json"
31
+ }
32
+ }
33
+ }
34
+ }
35
+ }
36
+ }
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "ms-config-ng",
3
+ "version": "0.0.0",
4
+ "scripts": {
5
+ "ng": "ng",
6
+ "start": "ng serve",
7
+ "build": "ng build",
8
+ "watch": "ng build --watch --configuration development",
9
+ "test": "ng test"
10
+ },
11
+ "packageManager": "npm@11.13.0",
12
+ "dependencies": {
13
+ "@angular/common": "^22.0.0",
14
+ "@angular/compiler": "^22.0.0",
15
+ "@angular/core": "^22.0.0",
16
+ "@angular/forms": "^22.0.0",
17
+ "@angular/platform-browser": "^22.0.0",
18
+ "@angular/router": "^22.0.0",
19
+ "rxjs": "~7.8.0",
20
+ "tslib": "^2.3.0"
21
+ },
22
+ "devDependencies": {
23
+ "@angular/build": "^22.0.1",
24
+ "@angular/cli": "^22.0.1",
25
+ "@angular/compiler-cli": "^22.0.0",
26
+ "jsdom": "^28.0.0",
27
+ "ng-packagr": "^22.0.0",
28
+ "prettier": "^3.8.1",
29
+ "typescript": "~6.0.2",
30
+ "vitest": "^4.0.8"
31
+ }
32
+ }
@@ -0,0 +1,64 @@
1
+ # MsConfig
2
+
3
+ This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version 22.0.0.
4
+
5
+ ## Code scaffolding
6
+
7
+ Angular CLI includes powerful code scaffolding tools. To generate a new component, run:
8
+
9
+ ```bash
10
+ ng generate component component-name
11
+ ```
12
+
13
+ For a complete list of available schematics (such as `components`, `directives`, or `pipes`), run:
14
+
15
+ ```bash
16
+ ng generate --help
17
+ ```
18
+
19
+ ## Building
20
+
21
+ To build the library, run:
22
+
23
+ ```bash
24
+ ng build ms-config-ng
25
+ ```
26
+
27
+ This command will compile your project, and the build artifacts will be placed in the `dist/` directory.
28
+
29
+ ### Publishing the Library
30
+
31
+ Once the project is built, you can publish your library by following these steps:
32
+
33
+ 1. Navigate to the `dist` directory:
34
+
35
+ ```bash
36
+ cd dist/ms-config-ng
37
+ ```
38
+
39
+ 2. Run the `npm publish` command to publish your library to the npm registry:
40
+ ```bash
41
+ npm publish
42
+ ```
43
+
44
+ ## Running unit tests
45
+
46
+ To execute unit tests with the [Karma](https://karma-runner.github.io) test runner, use the following command:
47
+
48
+ ```bash
49
+ ng test
50
+ ```
51
+
52
+ ## Running end-to-end tests
53
+
54
+ For end-to-end (e2e) testing, run:
55
+
56
+ ```bash
57
+ ng e2e
58
+ ```
59
+
60
+ Angular CLI does not come with an end-to-end testing framework by default. You can choose one that suits your needs.
61
+
62
+ ## Additional Resources
63
+
64
+ For more information on using the Angular CLI, including detailed command references, visit the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page.
@@ -0,0 +1,7 @@
1
+ {
2
+ "$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
3
+ "dest": "../../dist/ms-config-ng",
4
+ "lib": {
5
+ "entryFile": "src/public-api.ts"
6
+ }
7
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "@jrosadob/ms-config-ng",
3
+ "version": "0.1.6",
4
+ "peerDependencies": {
5
+ "@angular/common": "^19.0.5 || ^20.0.0 || ^21.0.0 || ^22.0.0",
6
+ "@angular/core": "^19.0.5 || ^20.0.0 || ^21.0.0 || ^22.0.0"
7
+ },
8
+ "dependencies": {
9
+ "tslib": "^2.3.0"
10
+ },
11
+ "sideEffects": false,
12
+ "publishConfig": {
13
+ "access": "public"
14
+ }
15
+ }
@@ -0,0 +1,159 @@
1
+ import { provideHttpClient } from '@angular/common/http';
2
+ import {
3
+ ApplicationConfig,
4
+ inject,
5
+ isDevMode,
6
+ provideAppInitializer,
7
+ } from '@angular/core';
8
+ import { LuxonDateAdapter } from '@angular/material-luxon-adapter';
9
+ import { DateAdapter, MAT_DATE_FORMATS } from '@angular/material/core';
10
+ import { Settings } from 'luxon';
11
+ import { CustomLuxonDateAdapter } from './core/date-adapter/custom-luxon-date-adapter';
12
+ import { provideAnimations } from '@angular/platform-browser/animations';
13
+ import { provideRouter, withInMemoryScrolling } from '@angular/router';
14
+ import { provideFuse } from '@fuse';
15
+ import { TranslocoService, provideTransloco } from '@jsverse/transloco';
16
+ // import { appRoutes } from 'app/app.routes';
17
+ import { provideConfig } from '@jrosadob/ms-config-ng';
18
+ import { provideAuth } from 'app/core/auth/auth.provider';
19
+ import { provideIcons } from 'app/core/icons/icons.provider';
20
+ import { MockApiService } from 'app/mock-api';
21
+ import { environment } from 'environments/environment';
22
+ import { firstValueFrom } from 'rxjs';
23
+ import { appRoutes } from './app.routes';
24
+ import { TranslocoHttpLoader } from './core/transloco/transloco.http-loader';
25
+ import { Logger } from '@jrosadob/ms-logger-ng';
26
+ import { withHttpRetry } from '@jrosadob/ms-http-retry-ng';
27
+
28
+ Settings.defaultLocale = 'es';
29
+
30
+ // Logger se inicializa antes del arranque Angular, por eso usa el environment del consumidor.
31
+ Logger.init({
32
+ appName: environment.appName,
33
+ apiLogs: environment.openTelemetry.urlLogs,
34
+ host: '',
35
+ });
36
+ Logger.log(`ConfigServive initialized with environment: ${JSON.stringify(environment)}`);
37
+ Logger.log(`LoggerService initialized with config: ${JSON.stringify({
38
+ appName: environment.appName,
39
+ apiLogs: environment.openTelemetry.urlLogs,
40
+ host: '',
41
+ })}`);
42
+
43
+ export const appConfig: ApplicationConfig = {
44
+ providers: [
45
+ provideConfig(environment),
46
+ provideAnimations(),
47
+ provideHttpClient(
48
+ withHttpRetry(
49
+ // {
50
+ // maxRetries: Config.get('httpRetry.maxRetries') ?? 3,
51
+ // initialDelayMs: Config.get('httpRetry.initialDelayMs') ?? 300,
52
+ // retriableMethods: Config.get('httpRetry.retriableMethods'),
53
+ // retriableStatusCodes: Config.get('httpRetry.retriableStatusCodes'),
54
+ // retryOnNetworkError: Config.get('httpRetry.retryOnNetworkError') ?? true,
55
+ // backoffMultiplier: Config.get('httpRetry.backoffMultiplier') ?? 2,
56
+ // maxDelayMs: Config.get('httpRetry.maxDelayMs') ?? 4000,
57
+ // },
58
+ environment.httpRetry,
59
+ Logger,
60
+ ),
61
+ ),
62
+ provideRouter(appRoutes, withInMemoryScrolling({ scrollPositionRestoration: 'enabled' })),
63
+
64
+ // Material Date Adapter
65
+ {
66
+ provide: DateAdapter,
67
+ useClass: CustomLuxonDateAdapter,
68
+ },
69
+ {
70
+ provide: MAT_DATE_FORMATS,
71
+ useValue: {
72
+ parse: {
73
+ dateInput: 'dd/MM/yyyy',
74
+ },
75
+ display: {
76
+ dateInput: 'dd/MM/yyyy',
77
+ monthYearLabel: 'MMM yyyy',
78
+ dateA11yLabel: 'dd/MM/yyyy',
79
+ monthYearA11yLabel: 'MMMM yyyy',
80
+ },
81
+ },
82
+ },
83
+
84
+ // Transloco Config
85
+ provideTransloco({
86
+ config: {
87
+ availableLangs: [
88
+ {
89
+ id: 'en',
90
+ label: 'English',
91
+ },
92
+ {
93
+ id: 'tr',
94
+ label: 'Turkish',
95
+ },
96
+ ],
97
+ defaultLang: 'en',
98
+ fallbackLang: 'en',
99
+ reRenderOnLangChange: true,
100
+ prodMode: !isDevMode(),
101
+ },
102
+ loader: TranslocoHttpLoader,
103
+ }),
104
+ provideAppInitializer(() => {
105
+ const translocoService = inject(TranslocoService);
106
+ const defaultLang = translocoService.getDefaultLang();
107
+ translocoService.setActiveLang(defaultLang);
108
+
109
+ return firstValueFrom(translocoService.load(defaultLang));
110
+ }),
111
+
112
+ // Fuse
113
+ provideAuth(),
114
+ provideIcons(),
115
+ provideFuse({
116
+ mockApi: {
117
+ delay: 0,
118
+ service: MockApiService,
119
+ },
120
+ fuse: {
121
+ layout: 'classy',
122
+ scheme: 'light',
123
+ screens: {
124
+ sm: '600px',
125
+ md: '960px',
126
+ lg: '1280px',
127
+ xl: '1440px',
128
+ },
129
+ theme: 'theme-brand',
130
+ themes: [
131
+ {
132
+ id: 'theme-default',
133
+ name: 'Default',
134
+ },
135
+ {
136
+ id: 'theme-brand',
137
+ name: 'Brand',
138
+ },
139
+ {
140
+ id: 'theme-teal',
141
+ name: 'Teal',
142
+ },
143
+ {
144
+ id: 'theme-rose',
145
+ name: 'Rose',
146
+ },
147
+ {
148
+ id: 'theme-purple',
149
+ name: 'Purple',
150
+ },
151
+ {
152
+ id: 'theme-amber',
153
+ name: 'Amber',
154
+ },
155
+ ],
156
+ },
157
+ }),
158
+ ],
159
+ };
@@ -0,0 +1,7 @@
1
+ import { InjectionToken } from '@angular/core';
2
+
3
+ export type ConfigEnvironment = Record<string, unknown>;
4
+
5
+ export const CONFIG_ENVIRONMENT = new InjectionToken<ConfigEnvironment>(
6
+ 'CONFIG_ENVIRONMENT',
7
+ );
@@ -0,0 +1,192 @@
1
+ import { inject, Injectable } from '@angular/core';
2
+ import { CONFIG_ENVIRONMENT, ConfigEnvironment } from './config-token';
3
+
4
+ function resolveConfigValue(
5
+ environment: ConfigEnvironment | undefined,
6
+ path: string,
7
+ defaultValue?: unknown,
8
+ ): unknown {
9
+ if (!path || typeof path !== 'string' || !environment) {
10
+ return defaultValue;
11
+ }
12
+
13
+ const keys = path.split('.').filter(Boolean);
14
+ let current: unknown = environment;
15
+
16
+ for (const key of keys) {
17
+ if (
18
+ current == null ||
19
+ typeof current !== 'object' ||
20
+ !(key in (current as Record<string, unknown>))
21
+ ) {
22
+ return defaultValue;
23
+ }
24
+
25
+ current = (current as Record<string, unknown>)[key];
26
+ }
27
+
28
+ return current;
29
+ }
30
+
31
+ @Injectable({
32
+ providedIn: 'root',
33
+ })
34
+ class ConfigService {
35
+ private host: string = '';
36
+ private readonly injectedEnvironment = inject(CONFIG_ENVIRONMENT, {
37
+ optional: true,
38
+ });
39
+
40
+ constructor() {
41
+ this.setHost();
42
+ }
43
+
44
+ private requireEnvironment(): ConfigEnvironment {
45
+ if (!this.injectedEnvironment) {
46
+ throw new Error(
47
+ 'Config no ha sido inicializado. Registra provideConfig(environment) en la aplicacion consumidora.',
48
+ );
49
+ }
50
+
51
+ return this.injectedEnvironment;
52
+ }
53
+
54
+ /**
55
+ * Obtiene un valor del environment usando notacion por puntos.
56
+ * @param path Ruta de la propiedad, por ejemplo: msAuth.clientId.
57
+ * @param defaultValue Valor por defecto cuando la ruta no existe.
58
+ * @returns El valor encontrado o el valor por defecto.
59
+ * @example
60
+ * Config.get('msAuth.clientId')
61
+ */
62
+ get<T = unknown>(path: string, defaultValue?: T): T | undefined {
63
+ return resolveConfigValue(
64
+ this.requireEnvironment(),
65
+ path,
66
+ defaultValue,
67
+ ) as T | undefined;
68
+ }
69
+
70
+ /**
71
+ * Construye la URL base del backend segun la URL actual del frontend.
72
+ * Regla local: localhost usa el puerto actual + 1.
73
+ * Regla remota: subdominio.dominio -> subdominio-backend.dominio.
74
+ * @returns URL base del API backend.
75
+ * @example
76
+ * http://localhost:3001 -> http://localhost:3002
77
+ * https://localhost:3001 -> https://localhost:3002
78
+ * https://subdominio.dominio -> https://subdominio-backend.dominio
79
+ */
80
+ getApi(): string {
81
+ const url = new URL(window.location.href);
82
+
83
+ if (url.hostname === 'localhost') {
84
+ const port = Number(url.port);
85
+ return `${url.protocol}//localhost:${port + 1}`;
86
+ }
87
+
88
+ const hostParts = url.hostname.split('.');
89
+ const subdomain = hostParts[0];
90
+ const domain = hostParts.slice(1).join('.');
91
+ const suffix = this.get('backendSuffix') ?? '';
92
+ return `${url.protocol}//${subdomain}${suffix}.${domain}`;
93
+ }
94
+
95
+ /**
96
+ * Obtiene el nombre de la aplicacion.
97
+ * @returns Devuelve el valor de environment.appName.
98
+ */
99
+ getAppName(): string {
100
+ return (this.get('appName') ?? '') as string;
101
+ }
102
+
103
+ /**
104
+ * Obtiene el tipo de usuario que usa la aplicacion.
105
+ * @returns Devuelve el valor de environment.signInTypeId.
106
+ */
107
+ getSignInTypeId(): number {
108
+ return (this.get('signInTypeId') ?? 0) as number;
109
+ }
110
+
111
+ /**
112
+ * Indica si OpenTelemetry debe imprimir en consola.
113
+ * @returns Devuelve el valor de environment.openTelemetry.console.
114
+ */
115
+ getOpenTelemetryConsole(): boolean {
116
+ return this.get('openTelemetry.console') === true || this.get('openTelemetry.console') === 'true';
117
+ }
118
+
119
+ /**
120
+ * Obtiene el endpoint de logs para OpenTelemetry.
121
+ * @returns Devuelve el valor de environment.openTelemetry.urlLogs.
122
+ */
123
+ getOpenTelemetryUrlLogs(): string {
124
+ return (this.get('openTelemetry.urlLogs') ?? '') as string;
125
+ }
126
+
127
+ /**
128
+ * Obtiene el endpoint de trazas para OpenTelemetry.
129
+ * @returns Devuelve el valor de environment.openTelemetry.urlTrace.
130
+ */
131
+ getOpenTelemetryUrlTrace(): string {
132
+ return (this.get('openTelemetry.urlTrace') ?? '') as string;
133
+ }
134
+
135
+ /**
136
+ * Obtiene el nivel de log configurado para OpenTelemetry.
137
+ * @returns Devuelve el valor de environment.openTelemetry.logLevel.
138
+ */
139
+ getOpenTelemetryLogLevel(): string {
140
+ return (this.get('openTelemetry.logLevel') ?? '') as string;
141
+ }
142
+
143
+ /**
144
+ * Obtiene el nivel de log para consola.
145
+ * @returns Devuelve el valor de environment.console.logLevel.
146
+ */
147
+ getConsoleLogLevel(): string {
148
+ return (this.get('console.logLevel') ?? '') as string;
149
+ }
150
+
151
+ /**
152
+ * Obtiene el porcentaje o probabilidad de muestreo de OpenTelemetry.
153
+ * @returns Devuelve el valor de environment.openTelemetry.probabilitySampler.
154
+ */
155
+ getOpenTelemetryProbabilitySampler(): string {
156
+ return (this.get('openTelemetry.probabilitySampler') ?? '') as string;
157
+ }
158
+
159
+ /**
160
+ * Indica si la aplicacion esta ejecutandose en produccion.
161
+ * @returns Devuelve el valor de environment.production.
162
+ */
163
+ isProduction(): boolean {
164
+ return this.get('production') === true;
165
+ }
166
+
167
+ /**
168
+ * Obtiene y guarda la IP publica del cliente para telemetria.
169
+ */
170
+ private setHost() {
171
+ if (!this.host) {
172
+ fetch('https://api.ipify.org?format=text')
173
+ .then((response) => response.text())
174
+ .then((data) => {
175
+ this.host = data;
176
+ })
177
+ .catch((error) => {
178
+ this.host = 'Undefined';
179
+ });
180
+ }
181
+ }
182
+
183
+ /**
184
+ * Devuelve la IP publica detectada o el error de resolucion.
185
+ * @returns IP publica o mensaje de error.
186
+ */
187
+ getHost() {
188
+ return this.host;
189
+ }
190
+ }
191
+
192
+ export { ConfigService as Config };
@@ -0,0 +1,33 @@
1
+ export const environment = {
2
+ appName: 'gestor-cms',
3
+ backendUrl: 'https://gestor-cms-backend.mantix.com.pe',
4
+ wienerApiUrl: 'https://test-services2-appmovil.uwiener.edu.pe',
5
+ apiwToken: '' as string,
6
+ signInTypeId: 2,
7
+ production: false,
8
+ msAuth: {
9
+ clientId: 'YOUR_AZURE_AD_CLIENT_ID',
10
+ tenantId: 'common',
11
+ redirectUri: 'http://localhost:3001/auth/ms-callback',
12
+ scopes: 'openid email profile User.Read',
13
+ },
14
+ openTelemetry: {
15
+ console: true,
16
+ probabilitySampler: '1',
17
+ urlTrace: 'http://localhost:4318/v1/traces',
18
+ urlLogs: 'http://localhost:8082',
19
+ logLevel: 'ALL',
20
+ },
21
+ console: {
22
+ logLevel: 'LOG',
23
+ },
24
+ httpRetry: {
25
+ maxRetries: 3,
26
+ initialDelayMs: 1000,
27
+ retriableMethods: ['GET', 'POST', 'PUT', 'DELETE'],
28
+ retriableStatusCodes: [401, 500, 502, 503, 504],
29
+ retryOnNetworkError: true,
30
+ backoffMultiplier: 2,
31
+ maxDelayMs: 10000
32
+ }
33
+ };
@@ -0,0 +1,13 @@
1
+ import { EnvironmentProviders, makeEnvironmentProviders } from '@angular/core';
2
+ import { CONFIG_ENVIRONMENT, ConfigEnvironment } from './config-token';
3
+
4
+ export function provideConfig(
5
+ environment: ConfigEnvironment,
6
+ ): EnvironmentProviders {
7
+ return makeEnvironmentProviders([
8
+ {
9
+ provide: CONFIG_ENVIRONMENT,
10
+ useValue: environment,
11
+ },
12
+ ]);
13
+ }
@@ -0,0 +1,7 @@
1
+ /*
2
+ * Public API Surface of ms-config
3
+ */
4
+
5
+ // export * from './lib/config-token';
6
+ export * from './lib/provide-config';
7
+ export * from './lib/config.service';
@@ -0,0 +1,18 @@
1
+ /* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
2
+ /* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
3
+ {
4
+ "extends": "../../tsconfig.json",
5
+ "compilerOptions": {
6
+ "outDir": "../../out-tsc/lib",
7
+ "rootDir": "src",
8
+ "declaration": true,
9
+ "declarationMap": true,
10
+ "types": []
11
+ },
12
+ "include": ["src/**/*.ts"],
13
+ "exclude": [
14
+ "**/*.spec.ts",
15
+ "src/lib/app.config.ts",
16
+ "src/lib/environment.ts"
17
+ ]
18
+ }
@@ -0,0 +1,11 @@
1
+ /* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
2
+ /* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
3
+ {
4
+ "extends": "./tsconfig.lib.json",
5
+ "compilerOptions": {
6
+ "declarationMap": false
7
+ },
8
+ "angularCompilerOptions": {
9
+ "compilationMode": "partial"
10
+ }
11
+ }
@@ -0,0 +1,11 @@
1
+ /* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
2
+ /* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
3
+ {
4
+ "extends": "../../tsconfig.json",
5
+ "compilerOptions": {
6
+ "outDir": "../../out-tsc/spec",
7
+ "rootDir": "src",
8
+ "types": ["vitest/globals"]
9
+ },
10
+ "include": ["src/**/*.d.ts", "src/**/*.spec.ts"]
11
+ }
package/publish ADDED
@@ -0,0 +1,9 @@
1
+ #!/bin/bash
2
+
3
+ # Use: publish ms-config-ng
4
+ source add.sh $1
5
+ npm run build $1
6
+ cd dist/$1
7
+ npm publish
8
+ cd ..
9
+ cd ..
package/tsconfig.json ADDED
@@ -0,0 +1,34 @@
1
+ /* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
2
+ /* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
3
+ {
4
+ "compileOnSave": false,
5
+ "compilerOptions": {
6
+ "noImplicitOverride": true,
7
+ "noPropertyAccessFromIndexSignature": true,
8
+ "noImplicitReturns": true,
9
+ "noFallthroughCasesInSwitch": true,
10
+ "paths": {
11
+ "ms-config-ng": ["./dist/ms-config-ng"]
12
+ },
13
+ "skipLibCheck": true,
14
+ "isolatedModules": true,
15
+ "experimentalDecorators": true,
16
+ "importHelpers": true,
17
+ "target": "ES2022",
18
+ "module": "preserve"
19
+ },
20
+ "angularCompilerOptions": {
21
+ "enableI18nLegacyMessageIdFormat": false,
22
+ "strictInjectionParameters": true,
23
+ "strictInputAccessModifiers": true
24
+ },
25
+ "files": [],
26
+ "references": [
27
+ {
28
+ "path": "./projects/ms-config-ng/tsconfig.lib.json"
29
+ },
30
+ {
31
+ "path": "./projects/ms-config-ng/tsconfig.spec.json"
32
+ }
33
+ ]
34
+ }