@rxap/config 13.0.0 → 14.0.1

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.
@@ -21,9 +21,9 @@ export class ConfigLoaderService {
21
21
  return loading$.toPromise();
22
22
  }
23
23
  }
24
- ConfigLoaderService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: ConfigLoaderService, deps: [{ token: HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
25
- ConfigLoaderService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: ConfigLoaderService, providedIn: 'root' });
26
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: ConfigLoaderService, decorators: [{
24
+ ConfigLoaderService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: ConfigLoaderService, deps: [{ token: HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
25
+ ConfigLoaderService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: ConfigLoaderService, providedIn: 'root' });
26
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: ConfigLoaderService, decorators: [{
27
27
  type: Injectable,
28
28
  args: [{ providedIn: 'root' }]
29
29
  }], ctorParameters: function () { return [{ type: i1.HttpClient, decorators: [{
@@ -140,9 +140,9 @@ ConfigService.Defaults = {};
140
140
  ConfigService.Overwrites = {};
141
141
  ConfigService.LocalStorageKey = 'rxap/config/local-config';
142
142
  ConfigService.Urls = ['config.json'];
143
- ConfigService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: ConfigService, deps: [{ token: RXAP_CONFIG, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
144
- ConfigService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: ConfigService, providedIn: 'root' });
145
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: ConfigService, decorators: [{
143
+ ConfigService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: ConfigService, deps: [{ token: RXAP_CONFIG, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
144
+ ConfigService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: ConfigService, providedIn: 'root' });
145
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: ConfigService, decorators: [{
146
146
  type: Injectable,
147
147
  args: [{
148
148
  providedIn: 'root'
@@ -151,9 +151,9 @@ ConfigService.Defaults = {};
151
151
  ConfigService.Overwrites = {};
152
152
  ConfigService.LocalStorageKey = 'rxap/config/local-config';
153
153
  ConfigService.Urls = ['config.json'];
154
- ConfigService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: ConfigService, deps: [{ token: RXAP_CONFIG, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
155
- ConfigService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: ConfigService, providedIn: 'root' });
156
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: ConfigService, decorators: [{
154
+ ConfigService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: ConfigService, deps: [{ token: RXAP_CONFIG, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
155
+ ConfigService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: ConfigService, providedIn: 'root' });
156
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: ConfigService, decorators: [{
157
157
  type: Injectable,
158
158
  args: [{
159
159
  providedIn: 'root'
@@ -187,9 +187,9 @@ class ConfigLoaderService {
187
187
  });
188
188
  }
189
189
  }
190
- ConfigLoaderService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: ConfigLoaderService, deps: [{ token: HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
191
- ConfigLoaderService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: ConfigLoaderService, providedIn: 'root' });
192
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: ConfigLoaderService, decorators: [{
190
+ ConfigLoaderService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: ConfigLoaderService, deps: [{ token: HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
191
+ ConfigLoaderService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: ConfigLoaderService, providedIn: 'root' });
192
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: ConfigLoaderService, decorators: [{
193
193
  type: Injectable,
194
194
  args: [{ providedIn: 'root' }]
195
195
  }], ctorParameters: function () {
@@ -1 +1 @@
1
- {"version":3,"file":"rxap-config.mjs","sources":["../../../../libs/config/src/lib/tokens.ts","../../../../libs/config/src/lib/config.service.ts","../../../../libs/config/src/lib/config-loader.service.ts","../../../../libs/config/src/rxap-config.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\n\nexport const RXAP_CONFIG = new InjectionToken('rxap/config');\n","import {\n Injectable,\n Optional,\n Inject\n} from '@angular/core';\nimport {\n deepMerge,\n SetObjectValue\n} from '@rxap/utilities';\nimport { RXAP_CONFIG } from './tokens';\nimport { NoInferType } from './types';\n\nexport interface ConfigLoadOptions {\n fromUrlParam?: string | boolean;\n fromLocalStorage?: boolean;\n}\n\n@Injectable({\n providedIn: 'root'\n})\nexport class ConfigService<Config extends Record<string, any> = Record<string, any>> {\n\n public static Config: any = null;\n\n /**\n * Static default values for the config object.\n * Will be overwritten by an dynamic config file specified in\n * the Urls array.\n */\n public static Defaults: any = {};\n\n /**\n * Any value definition in the Overwrites object will overwrite any\n * value form the Defaults values or dynamic config files\n */\n public static Overwrites: any = {};\n\n public static LocalStorageKey = 'rxap/config/local-config';\n\n public static Urls = [ 'config.json' ];\n\n public static async SideLoad(url: string, propertyPath: string, required?: boolean): Promise<void> {\n\n if (!this.Config) {\n throw new Error('Config side load is only possible after the initial config load.');\n }\n\n try {\n\n const response = await fetch(url);\n SetObjectValue(this.Config, propertyPath, await response.json());\n\n } catch (error: any) {\n if (required) {\n throw new Error(`Could not side load config '${url}': ${error.message}`);\n } else {\n console.warn(url, error.message);\n }\n }\n\n console.debug(`app config side load '${propertyPath}'`, this.Config);\n\n }\n\n /**\n * Used to load the app config from a remote resource.\n *\n * Promise.all([ ConfigService.Load() ])\n * .then(() => platformBrowserDynamic().bootstrapModule(AppModule))\n * .catch(err => console.error(err))\n *\n */\n public static async Load(options?: ConfigLoadOptions): Promise<void> {\n let config = this.Defaults;\n for (const url of ConfigService.Urls) {\n try {\n\n const response = await fetch(url);\n config = deepMerge(config, await response.json());\n\n } catch (error: any) {\n console.error(url, error.message);\n }\n }\n\n config = deepMerge(config, this.Overwrites);\n\n if (options?.fromLocalStorage !== false) {\n\n const localConfig = localStorage.getItem(ConfigService.LocalStorageKey);\n\n if (localConfig) {\n try {\n config = deepMerge(config, JSON.parse(localConfig));\n } catch (e: any) {\n console.error('local config could not be parsed');\n }\n }\n\n }\n\n if (options?.fromUrlParam) {\n const param = typeof options.fromUrlParam === 'string' ? options.fromUrlParam : 'config';\n config = deepMerge(config, this.LoadConfigDefaultFromUrlParam(param));\n }\n\n console.debug('app config', config);\n\n ConfigService.Config = config;\n }\n\n private static LoadConfigDefaultFromUrlParam(param: string = 'config') {\n\n const queryString = window.location.search;\n const urlParams = new URLSearchParams(queryString);\n\n const configFromParams = {};\n\n for (const configParam of urlParams.getAll('config')) {\n\n try {\n const split = configParam.split(';');\n if (split.length === 2) {\n const keyPath = split[ 0 ];\n const value = split[ 1 ];\n SetObjectValue(configFromParams, keyPath, value);\n }\n } catch (e: any) {\n console.warn(`Parsing of url config param failed for '${configParam}': ${e.message}`);\n }\n\n }\n\n return configFromParams;\n\n }\n\n public static Get<T = any, K extends Record<string, any> = Record<string, any>>(path: string, defaultValue: T | undefined, config: Record<string, any>): T\n public static Get<T = any, K extends Record<string, any> = Record<string, any>>(\n path: string,\n defaultValue: NoInferType<T>,\n config: Record<string, any> = this.Config\n ): T {\n if (!config) {\n throw new Error('config not loaded');\n }\n let configValue: any = config;\n if (typeof path !== 'string') {\n throw new Error('The config property path is not a string');\n }\n for (const fragment of (path as any).split('.')) {\n if (configValue.hasOwnProperty(fragment)) {\n configValue = configValue[ fragment ];\n } else {\n if (defaultValue !== undefined) {\n return defaultValue;\n }\n console.warn(`Config with path '${path}' not found`);\n return undefined as any;\n }\n }\n return configValue;\n }\n\n public readonly config!: Config;\n\n constructor(@Optional() @Inject(RXAP_CONFIG) config: any | null = null) {\n this.config = ConfigService.Config;\n if (config) {\n this.config = deepMerge(this.config ?? {}, config);\n }\n if (!this.config) {\n throw new Error('config not available');\n }\n }\n\n public setLocalConfig(config: Config): void {\n localStorage.setItem(ConfigService.LocalStorageKey, JSON.stringify(config));\n }\n\n public clearLocalConfig(): void {\n localStorage.removeItem(ConfigService.LocalStorageKey);\n }\n\n public get<T = any>(propertyPath: string): T | undefined;\n public get<T = any>(propertyPath: string, defaultValue: NoInferType<T>): T;\n public get<T = any>(propertyPath: string, defaultValue?: T): T | undefined {\n return ConfigService.Get(propertyPath, defaultValue, this.config);\n }\n\n public getOrThrow<T = any>(propertyPath: string): T;\n public getOrThrow<T = any>(propertyPath: string, defaultValue: NoInferType<T>): T;\n public getOrThrow<T = any>(propertyPath: string, defaultValue?: T): T {\n const value = ConfigService.Get(propertyPath, defaultValue, this.config);\n if (value === undefined) {\n throw new Error(`Could not find config in path '${propertyPath}'`);\n }\n return value;\n }\n\n}\n","import { Injectable, Inject } from '@angular/core';\nimport { Observable } from 'rxjs';\nimport { HttpClient } from '@angular/common/http';\nimport { finalize, share } from 'rxjs/operators';\n\n@Injectable({ providedIn: 'root' })\nexport class ConfigLoaderService {\n public readonly configs = new Map<string, any>();\n\n public readonly configLoading = new Map<string, Observable<any>>();\n\n constructor(\n @Inject(HttpClient)\n public readonly http: HttpClient\n ) {}\n\n public async load$<T = any>(url: string): Promise<T> {\n if (this.configs.has(url)) {\n return this.configs.get(url);\n }\n\n if (this.configLoading.has(url)) {\n return this.configLoading.get(url)!.toPromise();\n }\n\n const loading$ = this.http.get<T>(url).pipe(\n finalize(() => this.configLoading.delete(url)),\n share()\n );\n\n this.configLoading.set(url, loading$);\n\n return loading$.toPromise();\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;MAEa,WAAW,GAAG,IAAI,cAAc,CAAC,aAAa;;MCkB9C,aAAa;IAkJxB,YAA6C,SAAqB,IAAI;;QACpE,IAAI,CAAC,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC;QACnC,IAAI,MAAM,EAAE;YACV,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC,MAAA,IAAI,CAAC,MAAM,mCAAI,EAAE,EAAE,MAAM,CAAC,CAAC;SACpD;QACD,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;SACzC;KACF;IArIM,OAAa,QAAQ,CAAC,GAAW,EAAE,YAAoB,EAAE,QAAkB;;YAEhF,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;gB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,CAAC,CAAC,EAC9C,KAAK,EAAE,CACR,CAAC;YAEF,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;YAEtC,OAAO,QAAQ,CAAC,SAAS,EAAE,CAAC;SAC7B;KAAA;;gHA3BU,mBAAmB,kBAMpB,UAAU;oHANT,mBAAmB,cADN,MAAM;2FACnB,mBAAmB;kBAD/B,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;;8BAO7B,MAAM;+BAAC,UAAU;;;;ACZtB;;;;;;"}
1
+ {"version":3,"file":"rxap-config.mjs","sources":["../../../../libs/config/src/lib/tokens.ts","../../../../libs/config/src/lib/config.service.ts","../../../../libs/config/src/lib/config-loader.service.ts","../../../../libs/config/src/rxap-config.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\n\nexport const RXAP_CONFIG = new InjectionToken('rxap/config');\n","import {\n Injectable,\n Optional,\n Inject\n} from '@angular/core';\nimport {\n deepMerge,\n SetObjectValue\n} from '@rxap/utilities';\nimport { RXAP_CONFIG } from './tokens';\nimport { NoInferType } from './types';\n\nexport interface ConfigLoadOptions {\n fromUrlParam?: string | boolean;\n fromLocalStorage?: boolean;\n}\n\n@Injectable({\n providedIn: 'root'\n})\nexport class ConfigService<Config extends Record<string, any> = Record<string, any>> {\n\n public static Config: any = null;\n\n /**\n * Static default values for the config object.\n * Will be overwritten by an dynamic config file specified in\n * the Urls array.\n */\n public static Defaults: any = {};\n\n /**\n * Any value definition in the Overwrites object will overwrite any\n * value form the Defaults values or dynamic config files\n */\n public static Overwrites: any = {};\n\n public static LocalStorageKey = 'rxap/config/local-config';\n\n public static Urls = [ 'config.json' ];\n\n public static async SideLoad(url: string, propertyPath: string, required?: boolean): Promise<void> {\n\n if (!this.Config) {\n throw new Error('Config side load is only possible after the initial config load.');\n }\n\n try {\n\n const response = await fetch(url);\n SetObjectValue(this.Config, propertyPath, await response.json());\n\n } catch (error: any) {\n if (required) {\n throw new Error(`Could not side load config '${url}': ${error.message}`);\n } else {\n console.warn(url, error.message);\n }\n }\n\n console.debug(`app config side load '${propertyPath}'`, this.Config);\n\n }\n\n /**\n * Used to load the app config from a remote resource.\n *\n * Promise.all([ ConfigService.Load() ])\n * .then(() => platformBrowserDynamic().bootstrapModule(AppModule))\n * .catch(err => console.error(err))\n *\n */\n public static async Load(options?: ConfigLoadOptions): Promise<void> {\n let config = this.Defaults;\n for (const url of ConfigService.Urls) {\n try {\n\n const response = await fetch(url);\n config = deepMerge(config, await response.json());\n\n } catch (error: any) {\n console.error(url, error.message);\n }\n }\n\n config = deepMerge(config, this.Overwrites);\n\n if (options?.fromLocalStorage !== false) {\n\n const localConfig = localStorage.getItem(ConfigService.LocalStorageKey);\n\n if (localConfig) {\n try {\n config = deepMerge(config, JSON.parse(localConfig));\n } catch (e: any) {\n console.error('local config could not be parsed');\n }\n }\n\n }\n\n if (options?.fromUrlParam) {\n const param = typeof options.fromUrlParam === 'string' ? options.fromUrlParam : 'config';\n config = deepMerge(config, this.LoadConfigDefaultFromUrlParam(param));\n }\n\n console.debug('app config', config);\n\n ConfigService.Config = config;\n }\n\n private static LoadConfigDefaultFromUrlParam(param: string = 'config') {\n\n const queryString = window.location.search;\n const urlParams = new URLSearchParams(queryString);\n\n const configFromParams = {};\n\n for (const configParam of urlParams.getAll('config')) {\n\n try {\n const split = configParam.split(';');\n if (split.length === 2) {\n const keyPath = split[ 0 ];\n const value = split[ 1 ];\n SetObjectValue(configFromParams, keyPath, value);\n }\n } catch (e: any) {\n console.warn(`Parsing of url config param failed for '${configParam}': ${e.message}`);\n }\n\n }\n\n return configFromParams;\n\n }\n\n public static Get<T = any, K extends Record<string, any> = Record<string, any>>(path: string, defaultValue: T | undefined, config: Record<string, any>): T\n public static Get<T = any, K extends Record<string, any> = Record<string, any>>(\n path: string,\n defaultValue: NoInferType<T>,\n config: Record<string, any> = this.Config\n ): T {\n if (!config) {\n throw new Error('config not loaded');\n }\n let configValue: any = config;\n if (typeof path !== 'string') {\n throw new Error('The config property path is not a string');\n }\n for (const fragment of (path as any).split('.')) {\n if (configValue.hasOwnProperty(fragment)) {\n configValue = configValue[ fragment ];\n } else {\n if (defaultValue !== undefined) {\n return defaultValue;\n }\n console.warn(`Config with path '${path}' not found`);\n return undefined as any;\n }\n }\n return configValue;\n }\n\n public readonly config!: Config;\n\n constructor(@Optional() @Inject(RXAP_CONFIG) config: any | null = null) {\n this.config = ConfigService.Config;\n if (config) {\n this.config = deepMerge(this.config ?? {}, config);\n }\n if (!this.config) {\n throw new Error('config not available');\n }\n }\n\n public setLocalConfig(config: Config): void {\n localStorage.setItem(ConfigService.LocalStorageKey, JSON.stringify(config));\n }\n\n public clearLocalConfig(): void {\n localStorage.removeItem(ConfigService.LocalStorageKey);\n }\n\n public get<T = any>(propertyPath: string): T | undefined;\n public get<T = any>(propertyPath: string, defaultValue: NoInferType<T>): T;\n public get<T = any>(propertyPath: string, defaultValue?: T): T | undefined {\n return ConfigService.Get(propertyPath, defaultValue, this.config);\n }\n\n public getOrThrow<T = any>(propertyPath: string): T;\n public getOrThrow<T = any>(propertyPath: string, defaultValue: NoInferType<T>): T;\n public getOrThrow<T = any>(propertyPath: string, defaultValue?: T): T {\n const value = ConfigService.Get(propertyPath, defaultValue, this.config);\n if (value === undefined) {\n throw new Error(`Could not find config in path '${propertyPath}'`);\n }\n return value;\n }\n\n}\n","import { Injectable, Inject } from '@angular/core';\nimport { Observable } from 'rxjs';\nimport { HttpClient } from '@angular/common/http';\nimport { finalize, share } from 'rxjs/operators';\n\n@Injectable({ providedIn: 'root' })\nexport class ConfigLoaderService {\n public readonly configs = new Map<string, any>();\n\n public readonly configLoading = new Map<string, Observable<any>>();\n\n constructor(\n @Inject(HttpClient)\n public readonly http: HttpClient\n ) {}\n\n public async load$<T = any>(url: string): Promise<T> {\n if (this.configs.has(url)) {\n return this.configs.get(url);\n }\n\n if (this.configLoading.has(url)) {\n return this.configLoading.get(url)!.toPromise();\n }\n\n const loading$ = this.http.get<T>(url).pipe(\n finalize(() => this.configLoading.delete(url)),\n share()\n );\n\n this.configLoading.set(url, loading$);\n\n return loading$.toPromise();\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;MAEa,WAAW,GAAG,IAAI,cAAc,CAAC,aAAa;;MCkB9C,aAAa,CAAA;IAkJxB,WAA6C,CAAA,SAAqB,IAAI,EAAA;;AACpE,QAAA,IAAI,CAAC,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC;AACnC,QAAA,IAAI,MAAM,EAAE;AACV,YAAA,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC,CAAA,EAAA,GAAA,IAAI,CAAC,MAAM,MAAI,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAA,EAAE,EAAE,MAAM,CAAC,CAAC;AACpD,SAAA;AACD,QAAA,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;AAChB,YAAA,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;AACzC,SAAA;KACF;AArIM,IAAA,OAAa,QAAQ,CAAC,GAAW,EAAE,YAAoB,EAAE,QAAkB,EAAA;;AAEhF,YAAA,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;AAChB,gBAAA,MAAM,IAAI,KAAK,CAAC,kEAAkE,CAAC,CAAC;AACrF,aAAA;YAED,IAAI;AAEF,gBAAA,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;AAClC,gBAAA,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;AAElE,aAAA;AAAC,YAAA,OAAO,KAAU,EAAE;AACnB,gBAAA,IAAI,QAAQ,EAAE;oBACZ,MAAM,IAAI,KAAK,CAAC,CAA+B,4BAAA,EAAA,GAAG,CAAM,GAAA,EAAA,KAAK,CAAC,OAAO,CAAE,CAAA,CAAC,CAAC;A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AU,EAAA,CAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;AANT,mBAAA,CAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,mBAAmB,cADN,MAAM,EAAA,CAAA,CAAA;2FACnB,mBAAmB,EAAA,UAAA,EAAA,CAAA;kBAD/B,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE,CAAA;;;8BAO7B,MAAM;+BAAC,UAAU,CAAA;;;;ACZtB;;AAEG;;;;"}
@@ -145,9 +145,9 @@ ConfigService.Defaults = {};
145
145
  ConfigService.Overwrites = {};
146
146
  ConfigService.LocalStorageKey = 'rxap/config/local-config';
147
147
  ConfigService.Urls = ['config.json'];
148
- ConfigService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: ConfigService, deps: [{ token: RXAP_CONFIG, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
149
- ConfigService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: ConfigService, providedIn: 'root' });
150
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: ConfigService, decorators: [{
148
+ ConfigService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: ConfigService, deps: [{ token: RXAP_CONFIG, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
149
+ ConfigService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: ConfigService, providedIn: 'root' });
150
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: ConfigService, decorators: [{
151
151
  type: Injectable,
152
152
  args: [{
153
153
  providedIn: 'root'
@@ -177,9 +177,9 @@ class ConfigLoaderService {
177
177
  return loading$.toPromise();
178
178
  }
179
179
  }
180
- ConfigLoaderService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: ConfigLoaderService, deps: [{ token: HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
181
- ConfigLoaderService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: ConfigLoaderService, providedIn: 'root' });
182
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: ConfigLoaderService, decorators: [{
180
+ ConfigLoaderService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: ConfigLoaderService, deps: [{ token: HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
181
+ ConfigLoaderService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: ConfigLoaderService, providedIn: 'root' });
182
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: ConfigLoaderService, decorators: [{
183
183
  type: Injectable,
184
184
  args: [{ providedIn: 'root' }]
185
185
  }], ctorParameters: function () { return [{ type: i1.HttpClient, decorators: [{
@@ -1 +1 @@
1
- {"version":3,"file":"rxap-config.mjs","sources":["../../../../libs/config/src/lib/tokens.ts","../../../../libs/config/src/lib/config.service.ts","../../../../libs/config/src/lib/config-loader.service.ts","../../../../libs/config/src/rxap-config.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\n\nexport const RXAP_CONFIG = new InjectionToken('rxap/config');\n","import {\n Injectable,\n Optional,\n Inject\n} from '@angular/core';\nimport {\n deepMerge,\n SetObjectValue\n} from '@rxap/utilities';\nimport { RXAP_CONFIG } from './tokens';\nimport { NoInferType } from './types';\n\nexport interface ConfigLoadOptions {\n fromUrlParam?: string | boolean;\n fromLocalStorage?: boolean;\n}\n\n@Injectable({\n providedIn: 'root'\n})\nexport class ConfigService<Config extends Record<string, any> = Record<string, any>> {\n\n public static Config: any = null;\n\n /**\n * Static default values for the config object.\n * Will be overwritten by an dynamic config file specified in\n * the Urls array.\n */\n public static Defaults: any = {};\n\n /**\n * Any value definition in the Overwrites object will overwrite any\n * value form the Defaults values or dynamic config files\n */\n public static Overwrites: any = {};\n\n public static LocalStorageKey = 'rxap/config/local-config';\n\n public static Urls = [ 'config.json' ];\n\n public static async SideLoad(url: string, propertyPath: string, required?: boolean): Promise<void> {\n\n if (!this.Config) {\n throw new Error('Config side load is only possible after the initial config load.');\n }\n\n try {\n\n const response = await fetch(url);\n SetObjectValue(this.Config, propertyPath, await response.json());\n\n } catch (error: any) {\n if (required) {\n throw new Error(`Could not side load config '${url}': ${error.message}`);\n } else {\n console.warn(url, error.message);\n }\n }\n\n console.debug(`app config side load '${propertyPath}'`, this.Config);\n\n }\n\n /**\n * Used to load the app config from a remote resource.\n *\n * Promise.all([ ConfigService.Load() ])\n * .then(() => platformBrowserDynamic().bootstrapModule(AppModule))\n * .catch(err => console.error(err))\n *\n */\n public static async Load(options?: ConfigLoadOptions): Promise<void> {\n let config = this.Defaults;\n for (const url of ConfigService.Urls) {\n try {\n\n const response = await fetch(url);\n config = deepMerge(config, await response.json());\n\n } catch (error: any) {\n console.error(url, error.message);\n }\n }\n\n config = deepMerge(config, this.Overwrites);\n\n if (options?.fromLocalStorage !== false) {\n\n const localConfig = localStorage.getItem(ConfigService.LocalStorageKey);\n\n if (localConfig) {\n try {\n config = deepMerge(config, JSON.parse(localConfig));\n } catch (e: any) {\n console.error('local config could not be parsed');\n }\n }\n\n }\n\n if (options?.fromUrlParam) {\n const param = typeof options.fromUrlParam === 'string' ? options.fromUrlParam : 'config';\n config = deepMerge(config, this.LoadConfigDefaultFromUrlParam(param));\n }\n\n console.debug('app config', config);\n\n ConfigService.Config = config;\n }\n\n private static LoadConfigDefaultFromUrlParam(param: string = 'config') {\n\n const queryString = window.location.search;\n const urlParams = new URLSearchParams(queryString);\n\n const configFromParams = {};\n\n for (const configParam of urlParams.getAll('config')) {\n\n try {\n const split = configParam.split(';');\n if (split.length === 2) {\n const keyPath = split[ 0 ];\n const value = split[ 1 ];\n SetObjectValue(configFromParams, keyPath, value);\n }\n } catch (e: any) {\n console.warn(`Parsing of url config param failed for '${configParam}': ${e.message}`);\n }\n\n }\n\n return configFromParams;\n\n }\n\n public static Get<T = any, K extends Record<string, any> = Record<string, any>>(path: string, defaultValue: T | undefined, config: Record<string, any>): T\n public static Get<T = any, K extends Record<string, any> = Record<string, any>>(\n path: string,\n defaultValue: NoInferType<T>,\n config: Record<string, any> = this.Config\n ): T {\n if (!config) {\n throw new Error('config not loaded');\n }\n let configValue: any = config;\n if (typeof path !== 'string') {\n throw new Error('The config property path is not a string');\n }\n for (const fragment of (path as any).split('.')) {\n if (configValue.hasOwnProperty(fragment)) {\n configValue = configValue[ fragment ];\n } else {\n if (defaultValue !== undefined) {\n return defaultValue;\n }\n console.warn(`Config with path '${path}' not found`);\n return undefined as any;\n }\n }\n return configValue;\n }\n\n public readonly config!: Config;\n\n constructor(@Optional() @Inject(RXAP_CONFIG) config: any | null = null) {\n this.config = ConfigService.Config;\n if (config) {\n this.config = deepMerge(this.config ?? {}, config);\n }\n if (!this.config) {\n throw new Error('config not available');\n }\n }\n\n public setLocalConfig(config: Config): void {\n localStorage.setItem(ConfigService.LocalStorageKey, JSON.stringify(config));\n }\n\n public clearLocalConfig(): void {\n localStorage.removeItem(ConfigService.LocalStorageKey);\n }\n\n public get<T = any>(propertyPath: string): T | undefined;\n public get<T = any>(propertyPath: string, defaultValue: NoInferType<T>): T;\n public get<T = any>(propertyPath: string, defaultValue?: T): T | undefined {\n return ConfigService.Get(propertyPath, defaultValue, this.config);\n }\n\n public getOrThrow<T = any>(propertyPath: string): T;\n public getOrThrow<T = any>(propertyPath: string, defaultValue: NoInferType<T>): T;\n public getOrThrow<T = any>(propertyPath: string, defaultValue?: T): T {\n const value = ConfigService.Get(propertyPath, defaultValue, this.config);\n if (value === undefined) {\n throw new Error(`Could not find config in path '${propertyPath}'`);\n }\n return value;\n }\n\n}\n","import { Injectable, Inject } from '@angular/core';\nimport { Observable } from 'rxjs';\nimport { HttpClient } from '@angular/common/http';\nimport { finalize, share } from 'rxjs/operators';\n\n@Injectable({ providedIn: 'root' })\nexport class ConfigLoaderService {\n public readonly configs = new Map<string, any>();\n\n public readonly configLoading = new Map<string, Observable<any>>();\n\n constructor(\n @Inject(HttpClient)\n public readonly http: HttpClient\n ) {}\n\n public async load$<T = any>(url: string): Promise<T> {\n if (this.configs.has(url)) {\n return this.configs.get(url);\n }\n\n if (this.configLoading.has(url)) {\n return this.configLoading.get(url)!.toPromise();\n }\n\n const loading$ = this.http.get<T>(url).pipe(\n finalize(() => this.configLoading.delete(url)),\n share()\n );\n\n this.configLoading.set(url, loading$);\n\n return loading$.toPromise();\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;MAEa,WAAW,GAAG,IAAI,cAAc,CAAC,aAAa;;MCkB9C,aAAa;IAkJxB,YAA6C,SAAqB,IAAI;QACpE,IAAI,CAAC,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC;QACnC,IAAI,MAAM,EAAE;YACV,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC,IAAI,CAAC,MAAM,IAAI,EAAE,EAAE,MAAM,CAAC,CAAC;SACpD;QACD,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;SACzC;KACF;IArIM,aAAa,QAAQ,CAAC,GAAW,EAAE,YAAoB,EAAE,QAAkB;QAEhF,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,kEAAkE,CAAC,CAAC;SACrF;QAED,IAAI;YAEF,MAAM,QAAQ,GA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3BU,mBAAmB,kBAMpB,UAAU;oHANT,mBAAmB,cADN,MAAM;2FACnB,mBAAmB;kBAD/B,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;0BAO7B,MAAM;2BAAC,UAAU;;;ACZtB;;;;;;"}
1
+ {"version":3,"file":"rxap-config.mjs","sources":["../../../../libs/config/src/lib/tokens.ts","../../../../libs/config/src/lib/config.service.ts","../../../../libs/config/src/lib/config-loader.service.ts","../../../../libs/config/src/rxap-config.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\n\nexport const RXAP_CONFIG = new InjectionToken('rxap/config');\n","import {\n Injectable,\n Optional,\n Inject\n} from '@angular/core';\nimport {\n deepMerge,\n SetObjectValue\n} from '@rxap/utilities';\nimport { RXAP_CONFIG } from './tokens';\nimport { NoInferType } from './types';\n\nexport interface ConfigLoadOptions {\n fromUrlParam?: string | boolean;\n fromLocalStorage?: boolean;\n}\n\n@Injectable({\n providedIn: 'root'\n})\nexport class ConfigService<Config extends Record<string, any> = Record<string, any>> {\n\n public static Config: any = null;\n\n /**\n * Static default values for the config object.\n * Will be overwritten by an dynamic config file specified in\n * the Urls array.\n */\n public static Defaults: any = {};\n\n /**\n * Any value definition in the Overwrites object will overwrite any\n * value form the Defaults values or dynamic config files\n */\n public static Overwrites: any = {};\n\n public static LocalStorageKey = 'rxap/config/local-config';\n\n public static Urls = [ 'config.json' ];\n\n public static async SideLoad(url: string, propertyPath: string, required?: boolean): Promise<void> {\n\n if (!this.Config) {\n throw new Error('Config side load is only possible after the initial config load.');\n }\n\n try {\n\n const response = await fetch(url);\n SetObjectValue(this.Config, propertyPath, await response.json());\n\n } catch (error: any) {\n if (required) {\n throw new Error(`Could not side load config '${url}': ${error.message}`);\n } else {\n console.warn(url, error.message);\n }\n }\n\n console.debug(`app config side load '${propertyPath}'`, this.Config);\n\n }\n\n /**\n * Used to load the app config from a remote resource.\n *\n * Promise.all([ ConfigService.Load() ])\n * .then(() => platformBrowserDynamic().bootstrapModule(AppModule))\n * .catch(err => console.error(err))\n *\n */\n public static async Load(options?: ConfigLoadOptions): Promise<void> {\n let config = this.Defaults;\n for (const url of ConfigService.Urls) {\n try {\n\n const response = await fetch(url);\n config = deepMerge(config, await response.json());\n\n } catch (error: any) {\n console.error(url, error.message);\n }\n }\n\n config = deepMerge(config, this.Overwrites);\n\n if (options?.fromLocalStorage !== false) {\n\n const localConfig = localStorage.getItem(ConfigService.LocalStorageKey);\n\n if (localConfig) {\n try {\n config = deepMerge(config, JSON.parse(localConfig));\n } catch (e: any) {\n console.error('local config could not be parsed');\n }\n }\n\n }\n\n if (options?.fromUrlParam) {\n const param = typeof options.fromUrlParam === 'string' ? options.fromUrlParam : 'config';\n config = deepMerge(config, this.LoadConfigDefaultFromUrlParam(param));\n }\n\n console.debug('app config', config);\n\n ConfigService.Config = config;\n }\n\n private static LoadConfigDefaultFromUrlParam(param: string = 'config') {\n\n const queryString = window.location.search;\n const urlParams = new URLSearchParams(queryString);\n\n const configFromParams = {};\n\n for (const configParam of urlParams.getAll('config')) {\n\n try {\n const split = configParam.split(';');\n if (split.length === 2) {\n const keyPath = split[ 0 ];\n const value = split[ 1 ];\n SetObjectValue(configFromParams, keyPath, value);\n }\n } catch (e: any) {\n console.warn(`Parsing of url config param failed for '${configParam}': ${e.message}`);\n }\n\n }\n\n return configFromParams;\n\n }\n\n public static Get<T = any, K extends Record<string, any> = Record<string, any>>(path: string, defaultValue: T | undefined, config: Record<string, any>): T\n public static Get<T = any, K extends Record<string, any> = Record<string, any>>(\n path: string,\n defaultValue: NoInferType<T>,\n config: Record<string, any> = this.Config\n ): T {\n if (!config) {\n throw new Error('config not loaded');\n }\n let configValue: any = config;\n if (typeof path !== 'string') {\n throw new Error('The config property path is not a string');\n }\n for (const fragment of (path as any).split('.')) {\n if (configValue.hasOwnProperty(fragment)) {\n configValue = configValue[ fragment ];\n } else {\n if (defaultValue !== undefined) {\n return defaultValue;\n }\n console.warn(`Config with path '${path}' not found`);\n return undefined as any;\n }\n }\n return configValue;\n }\n\n public readonly config!: Config;\n\n constructor(@Optional() @Inject(RXAP_CONFIG) config: any | null = null) {\n this.config = ConfigService.Config;\n if (config) {\n this.config = deepMerge(this.config ?? {}, config);\n }\n if (!this.config) {\n throw new Error('config not available');\n }\n }\n\n public setLocalConfig(config: Config): void {\n localStorage.setItem(ConfigService.LocalStorageKey, JSON.stringify(config));\n }\n\n public clearLocalConfig(): void {\n localStorage.removeItem(ConfigService.LocalStorageKey);\n }\n\n public get<T = any>(propertyPath: string): T | undefined;\n public get<T = any>(propertyPath: string, defaultValue: NoInferType<T>): T;\n public get<T = any>(propertyPath: string, defaultValue?: T): T | undefined {\n return ConfigService.Get(propertyPath, defaultValue, this.config);\n }\n\n public getOrThrow<T = any>(propertyPath: string): T;\n public getOrThrow<T = any>(propertyPath: string, defaultValue: NoInferType<T>): T;\n public getOrThrow<T = any>(propertyPath: string, defaultValue?: T): T {\n const value = ConfigService.Get(propertyPath, defaultValue, this.config);\n if (value === undefined) {\n throw new Error(`Could not find config in path '${propertyPath}'`);\n }\n return value;\n }\n\n}\n","import { Injectable, Inject } from '@angular/core';\nimport { Observable } from 'rxjs';\nimport { HttpClient } from '@angular/common/http';\nimport { finalize, share } from 'rxjs/operators';\n\n@Injectable({ providedIn: 'root' })\nexport class ConfigLoaderService {\n public readonly configs = new Map<string, any>();\n\n public readonly configLoading = new Map<string, Observable<any>>();\n\n constructor(\n @Inject(HttpClient)\n public readonly http: HttpClient\n ) {}\n\n public async load$<T = any>(url: string): Promise<T> {\n if (this.configs.has(url)) {\n return this.configs.get(url);\n }\n\n if (this.configLoading.has(url)) {\n return this.configLoading.get(url)!.toPromise();\n }\n\n const loading$ = this.http.get<T>(url).pipe(\n finalize(() => this.configLoading.delete(url)),\n share()\n );\n\n this.configLoading.set(url, loading$);\n\n return loading$.toPromise();\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;MAEa,WAAW,GAAG,IA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
2
  "name": "@rxap/config",
3
- "version": "13.0.0",
3
+ "version": "14.0.1",
4
4
  "private": false,
5
5
  "author": "Merzough Münker",
6
6
  "homepage": "https://gitlab.com/rxap/packages/libs/config",
@@ -17,13 +17,13 @@
17
17
  },
18
18
  "description": "Simple config file manager for angular applications.",
19
19
  "peerDependencies": {
20
- "@angular-devkit/schematics": "^13.2.4",
21
- "@angular/common": "^13.2.3",
22
- "@angular/core": "^13.2.3",
23
- "@angular/platform-browser-dynamic": "^13.2.3",
24
- "@rxap/utilities": "^13.0.0",
20
+ "@angular-devkit/schematics": "^14.2.3",
21
+ "@angular/common": "^14.2.2",
22
+ "@angular/core": "^14.2.2",
23
+ "@angular/platform-browser-dynamic": "^14.2.2",
24
+ "@rxap/utilities": "^14.0.1",
25
25
  "reflect-metadata": "^0.1.13",
26
- "rxjs": "^6.5.5"
26
+ "rxjs": "^6.6.0"
27
27
  },
28
28
  "schematics": "./collection.json",
29
29
  "ng-update": {
@@ -41,8 +41,8 @@
41
41
  "save": "dependencies"
42
42
  },
43
43
  "dependencies": {
44
- "@rxap/schematics-ts-morph": "^13.0.0-next.1",
45
- "@rxap/schematics-utilities": "^13.0.0-next.1",
44
+ "@rxap/schematics-ts-morph": "^14.0.0",
45
+ "@rxap/schematics-utilities": "^14.0.0",
46
46
  "ts-morph": "^13.0.3",
47
47
  "tslib": "^2.3.1"
48
48
  },
@@ -51,13 +51,13 @@
51
51
  "esm2020": "esm2020/rxap-config.mjs",
52
52
  "fesm2020": "fesm2020/rxap-config.mjs",
53
53
  "fesm2015": "fesm2015/rxap-config.mjs",
54
- "typings": "rxap-config.d.ts",
54
+ "typings": "index.d.ts",
55
55
  "exports": {
56
56
  "./package.json": {
57
57
  "default": "./package.json"
58
58
  },
59
59
  ".": {
60
- "types": "./rxap-config.d.ts",
60
+ "types": "./index.d.ts",
61
61
  "esm2020": "./esm2020/rxap-config.mjs",
62
62
  "es2020": "./fesm2020/rxap-config.mjs",
63
63
  "es2015": "./fesm2015/rxap-config.mjs",
@@ -7,7 +7,7 @@ const schematics_utilities_1 = require("@rxap/schematics-utilities");
7
7
  const schematics_ts_morph_1 = require("@rxap/schematics-ts-morph");
8
8
  const path_1 = require("path");
9
9
  function default_1(options) {
10
- return (host) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
10
+ return (host) => tslib_1.__awaiter(this, void 0, void 0, function* () {
11
11
  var _a;
12
12
  const project = new ts_morph_1.Project({
13
13
  manipulationSettings: {
package/rxap-config.d.ts DELETED
@@ -1,5 +0,0 @@
1
- /**
2
- * Generated bundle index. Do not edit.
3
- */
4
- /// <amd-module name="@rxap/config" />
5
- export * from './index';