@rxap/config 19.2.0-dev.3 → 19.3.0-dev.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/CHANGELOG.md +10 -0
- package/compodoc/changelog.html +7 -0
- package/compodoc/dependencies.html +2 -2
- package/compodoc/injectables/ConfigService.html +130 -87
- package/compodoc/interfaces/ConfigLoadOptions.html +149 -52
- package/compodoc/js/search/search_index.js +2 -2
- package/compodoc/miscellaneous/enumerations.html +53 -0
- package/compodoc/properties.html +1 -1
- package/docs/documentation.json +820 -656
- package/docs/html/assets/hierarchy.js +1 -1
- package/docs/html/assets/navigation.js +1 -1
- package/docs/html/assets/search.js +1 -1
- package/docs/html/classes/ConfigLoaderService.html +2 -2
- package/docs/html/classes/ConfigService.html +6 -6
- package/docs/html/classes/ConfigTestingService.html +2 -2
- package/docs/html/enums/ConfigLoadMethod.html +5 -0
- package/docs/html/enums/ConfigLoadingStrategy.html +2 -2
- package/docs/html/functions/ProvideConfig.html +1 -1
- package/docs/html/functions/dnsLookup.html +1 -1
- package/docs/html/functions/dnsResolver.html +1 -1
- package/docs/html/functions/fetchCidContent.html +1 -1
- package/docs/html/functions/fetchCidContentAsJson.html +1 -1
- package/docs/html/functions/fetchCidContentViaHttp.html +1 -1
- package/docs/html/functions/fetchContentViaHttp.html +1 -1
- package/docs/html/functions/raceSuccess.html +2 -2
- package/docs/html/hierarchy.html +1 -1
- package/docs/html/index.html +2 -2
- package/docs/html/interfaces/AppsNavigationConfig.html +2 -2
- package/docs/html/interfaces/Config.html +2 -2
- package/docs/html/interfaces/ConfigLoadOptions.html +10 -5
- package/docs/html/interfaces/LogoConfig.html +2 -2
- package/docs/html/interfaces/NavigationConfig.html +2 -2
- package/docs/html/interfaces/Oauth2Config.html +2 -2
- package/docs/html/interfaces/i18nConfig.html +2 -2
- package/docs/html/modules.html +1 -1
- package/docs/html/types/AnySchema.html +1 -1
- package/docs/html/types/Join.html +1 -1
- package/docs/html/types/LanguagesConfig.html +1 -1
- package/docs/html/types/Leaves.html +1 -1
- package/docs/html/types/NoInferType.html +1 -1
- package/docs/html/types/Paths.html +1 -1
- package/docs/html/variables/RXAP_CONFIG.html +1 -1
- package/docs/markdown/README.md +1 -1
- package/docs/markdown/classes/ConfigLoaderService.md +7 -7
- package/docs/markdown/classes/ConfigService.md +22 -22
- package/docs/markdown/classes/ConfigTestingService.md +8 -8
- package/docs/markdown/enumerations/ConfigLoadMethod.md +41 -0
- package/docs/markdown/enumerations/ConfigLoadingStrategy.md +4 -4
- package/docs/markdown/functions/ProvideConfig.md +2 -2
- package/docs/markdown/functions/dnsLookup.md +2 -2
- package/docs/markdown/functions/dnsResolver.md +2 -2
- package/docs/markdown/functions/fetchCidContent.md +2 -2
- package/docs/markdown/functions/fetchCidContentAsJson.md +2 -2
- package/docs/markdown/functions/fetchCidContentViaHttp.md +2 -2
- package/docs/markdown/functions/fetchContentViaHttp.md +2 -2
- package/docs/markdown/functions/raceSuccess.md +2 -2
- package/docs/markdown/globals.md +3 -2
- package/docs/markdown/interfaces/AppsNavigationConfig.md +12 -12
- package/docs/markdown/interfaces/Config.md +6 -6
- package/docs/markdown/interfaces/ConfigLoadOptions.md +27 -13
- package/docs/markdown/interfaces/LogoConfig.md +5 -5
- package/docs/markdown/interfaces/NavigationConfig.md +9 -9
- package/docs/markdown/interfaces/Oauth2Config.md +3 -3
- package/docs/markdown/interfaces/i18nConfig.md +4 -4
- package/docs/markdown/type-aliases/AnySchema.md +2 -2
- package/docs/markdown/type-aliases/Join.md +2 -2
- package/docs/markdown/type-aliases/LanguagesConfig.md +2 -2
- package/docs/markdown/type-aliases/Leaves.md +2 -2
- package/docs/markdown/type-aliases/NoInferType.md +2 -2
- package/docs/markdown/type-aliases/Paths.md +2 -2
- package/docs/markdown/variables/RXAP_CONFIG.md +2 -2
- package/docs/wiki/Class.ConfigLoaderService.md +6 -6
- package/docs/wiki/Class.ConfigService.md +21 -21
- package/docs/wiki/Class.ConfigTestingService.md +7 -7
- package/docs/wiki/Enumeration.ConfigLoadMethod.md +37 -0
- package/docs/wiki/Enumeration.ConfigLoadingStrategy.md +3 -3
- package/docs/wiki/Function.ProvideConfig.md +1 -1
- package/docs/wiki/Function.dnsLookup.md +1 -1
- package/docs/wiki/Function.dnsResolver.md +1 -1
- package/docs/wiki/Function.fetchCidContent.md +1 -1
- package/docs/wiki/Function.fetchCidContentAsJson.md +1 -1
- package/docs/wiki/Function.fetchCidContentViaHttp.md +1 -1
- package/docs/wiki/Function.fetchContentViaHttp.md +1 -1
- package/docs/wiki/Function.raceSuccess.md +1 -1
- package/docs/wiki/Interface.AppsNavigationConfig.md +11 -11
- package/docs/wiki/Interface.Config.md +5 -5
- package/docs/wiki/Interface.ConfigLoadOptions.md +26 -12
- package/docs/wiki/Interface.LogoConfig.md +4 -4
- package/docs/wiki/Interface.NavigationConfig.md +8 -8
- package/docs/wiki/Interface.Oauth2Config.md +2 -2
- package/docs/wiki/Interface.i18nConfig.md +3 -3
- package/docs/wiki/TypeAlias.AnySchema.md +1 -1
- package/docs/wiki/TypeAlias.Join.md +1 -1
- package/docs/wiki/TypeAlias.LanguagesConfig.md +1 -1
- package/docs/wiki/TypeAlias.Leaves.md +1 -1
- package/docs/wiki/TypeAlias.NoInferType.md +1 -1
- package/docs/wiki/TypeAlias.Paths.md +1 -1
- package/docs/wiki/Variable.RXAP_CONFIG.md +1 -1
- package/docs/wiki/_Sidebar.md +1 -0
- package/docs/wiki/globals.md +2 -1
- package/fesm2022/rxap-config.mjs +78 -57
- package/fesm2022/rxap-config.mjs.map +1 -1
- package/lib/config.service.d.ts +17 -0
- package/package.json +6 -6
|
@@ -189,6 +189,13 @@
|
|
|
189
189
|
fromUrls
|
|
190
190
|
</a>
|
|
191
191
|
</li>
|
|
192
|
+
<li>
|
|
193
|
+
<span class="modifier">Optional</span>
|
|
194
|
+
<a href="#order"
|
|
195
|
+
>
|
|
196
|
+
order
|
|
197
|
+
</a>
|
|
198
|
+
</li>
|
|
192
199
|
<li>
|
|
193
200
|
<span class="modifier">Optional</span>
|
|
194
201
|
<a href="#schema"
|
|
@@ -506,6 +513,53 @@ If true, uses <code>location.hostname</code>. If a string, uses that domain.</p>
|
|
|
506
513
|
|
|
507
514
|
|
|
508
515
|
|
|
516
|
+
</tbody>
|
|
517
|
+
</table>
|
|
518
|
+
<table class="table table-sm table-bordered">
|
|
519
|
+
<tbody>
|
|
520
|
+
<tr>
|
|
521
|
+
<td class="col-md-4">
|
|
522
|
+
<a name="order"></a>
|
|
523
|
+
<span class="name "><b>order</b>
|
|
524
|
+
<a href="#order">
|
|
525
|
+
<span class="icon ion-ios-link"></span>
|
|
526
|
+
</a>
|
|
527
|
+
</span>
|
|
528
|
+
</td>
|
|
529
|
+
</tr>
|
|
530
|
+
<tr>
|
|
531
|
+
<td class="col-md-4">
|
|
532
|
+
<code>order: <code><a href="../interfaces/Config.html" target="_self" >ConfigLoadMethod[]</a></code>
|
|
533
|
+
</code>
|
|
534
|
+
</td>
|
|
535
|
+
</tr>
|
|
536
|
+
|
|
537
|
+
|
|
538
|
+
<tr>
|
|
539
|
+
<td class="col-md-4">
|
|
540
|
+
<i>Type : </i> <code><a href="../interfaces/Config.html" target="_self" >ConfigLoadMethod[]</a></code>
|
|
541
|
+
|
|
542
|
+
</td>
|
|
543
|
+
</tr>
|
|
544
|
+
|
|
545
|
+
<tr>
|
|
546
|
+
<td class="col-md-4">
|
|
547
|
+
<i>Optional</i>
|
|
548
|
+
</td>
|
|
549
|
+
</tr>
|
|
550
|
+
|
|
551
|
+
|
|
552
|
+
|
|
553
|
+
|
|
554
|
+
<tr>
|
|
555
|
+
<td class="col-md-4">
|
|
556
|
+
<div class="io-description"><p>Defines the order and subset of config sources to load.
|
|
557
|
+
If not specified, defaults to: [FROM_URLS, FROM_LOCAL_STORAGE, FROM_URL_PARAM, FROM_CID]</p>
|
|
558
|
+
<p>Note: static config is always merged first, and Overwrites are always merged last.
|
|
559
|
+
Note: fromDns is not a source itself - it resolves the CID for FROM_CID.</p>
|
|
560
|
+
</div>
|
|
561
|
+
</td>
|
|
562
|
+
</tr>
|
|
509
563
|
</tbody>
|
|
510
564
|
</table>
|
|
511
565
|
<table class="table table-sm table-bordered">
|
|
@@ -699,6 +753,13 @@ export enum ConfigLoadingStrategy {
|
|
|
699
753
|
FIFO = 'fifo',
|
|
700
754
|
}
|
|
701
755
|
|
|
756
|
+
export enum ConfigLoadMethod {
|
|
757
|
+
FROM_URLS = 'fromUrls',
|
|
758
|
+
FROM_LOCAL_STORAGE = 'fromLocalStorage',
|
|
759
|
+
FROM_URL_PARAM = 'fromUrlParam',
|
|
760
|
+
FROM_CID = 'fromCid',
|
|
761
|
+
}
|
|
762
|
+
|
|
702
763
|
export interface ConfigLoadOptions {
|
|
703
764
|
fromUrlParam?: string | boolean;
|
|
704
765
|
fromUrls?: boolean;
|
|
@@ -722,6 +783,14 @@ export interface ConfigLoadOptions {
|
|
|
722
783
|
fetchCidContent?: (cid: string, path?: string) => Promise<Blob | null>;
|
|
723
784
|
dnsServers?: string[];
|
|
724
785
|
strategy?: ConfigLoadingStrategy;
|
|
786
|
+
/**
|
|
787
|
+
* Defines the order and subset of config sources to load.
|
|
788
|
+
* If not specified, defaults to: [FROM_URLS, FROM_LOCAL_STORAGE, FROM_URL_PARAM, FROM_CID]
|
|
789
|
+
*
|
|
790
|
+
* Note: static config is always merged first, and Overwrites are always merged last.
|
|
791
|
+
* Note: fromDns is not a source itself - it resolves the CID for FROM_CID.
|
|
792
|
+
*/
|
|
793
|
+
order?: ConfigLoadMethod[];
|
|
725
794
|
}
|
|
726
795
|
|
|
727
796
|
@Injectable({
|
|
@@ -794,81 +863,60 @@ export class ConfigService<Config extends Record<string, any> = Re
|
|
|
794
863
|
}
|
|
795
864
|
}
|
|
796
865
|
|
|
866
|
+
// Always merge static config first
|
|
797
867
|
config = deepMerge(config, options?.static ?? {});
|
|
798
|
-
let done = false;
|
|
799
868
|
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
if (options.strategy !== ConfigLoadingStrategy.FIFO) {
|
|
808
|
-
console.error('Could not load config from urls', error);
|
|
809
|
-
throw error;
|
|
810
|
-
} else {
|
|
811
|
-
console.warn('Could not load config from urls: ' + error.message + '. Will try next strategy.');
|
|
812
|
-
}
|
|
813
|
-
}
|
|
814
|
-
}
|
|
869
|
+
// Determine the order of config sources to load
|
|
870
|
+
const order = options.order ?? [
|
|
871
|
+
ConfigLoadMethod.FROM_URLS,
|
|
872
|
+
ConfigLoadMethod.FROM_LOCAL_STORAGE,
|
|
873
|
+
ConfigLoadMethod.FROM_URL_PARAM,
|
|
874
|
+
ConfigLoadMethod.FROM_CID,
|
|
875
|
+
];
|
|
815
876
|
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
if (options.strategy === ConfigLoadingStrategy.FIFO) {
|
|
820
|
-
done = true;
|
|
821
|
-
}
|
|
822
|
-
} catch (error: any) {
|
|
823
|
-
if (options.strategy !== ConfigLoadingStrategy.FIFO) {
|
|
824
|
-
console.error('Could not load config from local storage', error);
|
|
825
|
-
throw error;
|
|
826
|
-
} else {
|
|
827
|
-
console.warn('Could not load config from local storage: ' + error.message + '. Will try next strategy.');
|
|
828
|
-
}
|
|
829
|
-
}
|
|
877
|
+
// If fromDns is enabled and FROM_CID is in the order, resolve CID first
|
|
878
|
+
if (options.fromDns && order.includes(ConfigLoadMethod.FROM_CID) && !options.fromCid) {
|
|
879
|
+
await this.loadConfigFromDns(options as any);
|
|
830
880
|
}
|
|
831
881
|
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
}
|
|
838
|
-
} catch (error: any) {
|
|
839
|
-
if (options.strategy !== ConfigLoadingStrategy.FIFO) {
|
|
840
|
-
console.error('Could not load config from url param', error);
|
|
841
|
-
throw error;
|
|
842
|
-
} else {
|
|
843
|
-
console.warn('Could not load config from url param: ' + error.message + '. Will try next strategy.');
|
|
844
|
-
}
|
|
882
|
+
// Load configs from sources in the specified order
|
|
883
|
+
let done = false;
|
|
884
|
+
for (const method of order) {
|
|
885
|
+
if (done) {
|
|
886
|
+
break;
|
|
845
887
|
}
|
|
846
|
-
}
|
|
847
888
|
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
889
|
+
// Check if the source is enabled
|
|
890
|
+
if (!this.isSourceEnabled(options, method)) {
|
|
891
|
+
continue;
|
|
892
|
+
}
|
|
851
893
|
|
|
852
|
-
if (!done && options?.fromCid) {
|
|
853
894
|
try {
|
|
854
|
-
|
|
895
|
+
const loadedConfig = await this.loadConfigFromMethod(method, options, environment);
|
|
896
|
+
if (loadedConfig) {
|
|
897
|
+
config = deepMerge(config, loadedConfig);
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
// If using FIFO strategy, stop after first successful load
|
|
855
901
|
if (options.strategy === ConfigLoadingStrategy.FIFO) {
|
|
856
902
|
done = true;
|
|
857
903
|
}
|
|
858
904
|
} catch (error: any) {
|
|
905
|
+
const methodName = this.getMethodName(method);
|
|
859
906
|
if (options.strategy !== ConfigLoadingStrategy.FIFO) {
|
|
860
|
-
console.error(&#
|
|
907
|
+
console.error(`Could not load config from ${methodName}`, error);
|
|
861
908
|
throw error;
|
|
862
909
|
} else {
|
|
863
|
-
console.warn(&#
|
|
910
|
+
console.warn(`Could not load config from ${methodName}: ${error.message}. Will try next strategy.`);
|
|
864
911
|
}
|
|
865
912
|
}
|
|
866
913
|
}
|
|
867
914
|
|
|
868
|
-
if (!done) {
|
|
915
|
+
if (!done && order.length > 0) {
|
|
869
916
|
console.warn('No config loading strategy succeeded. Using default config.');
|
|
870
917
|
}
|
|
871
918
|
|
|
919
|
+
// Always merge overwrites last
|
|
872
920
|
config = deepMerge(config, this.Overwrites);
|
|
873
921
|
|
|
874
922
|
console.debug('app config', config);
|
|
@@ -876,6 +924,55 @@ export class ConfigService<Config extends Record<string, any> = Re
|
|
|
876
924
|
this.Config = config;
|
|
877
925
|
}
|
|
878
926
|
|
|
927
|
+
private static isSourceEnabled(options: ConfigLoadOptions, method: ConfigLoadMethod): boolean {
|
|
928
|
+
switch (method) {
|
|
929
|
+
case ConfigLoadMethod.FROM_URLS:
|
|
930
|
+
return options.fromUrls !== false;
|
|
931
|
+
case ConfigLoadMethod.FROM_LOCAL_STORAGE:
|
|
932
|
+
return options.fromLocalStorage !== false;
|
|
933
|
+
case ConfigLoadMethod.FROM_URL_PARAM:
|
|
934
|
+
return !!options.fromUrlParam;
|
|
935
|
+
case ConfigLoadMethod.FROM_CID:
|
|
936
|
+
return !!options.fromCid;
|
|
937
|
+
default:
|
|
938
|
+
return false;
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
private static async loadConfigFromMethod(
|
|
943
|
+
method: ConfigLoadMethod,
|
|
944
|
+
options: ConfigLoadOptions,
|
|
945
|
+
environment?: Environment,
|
|
946
|
+
): Promise<any> {
|
|
947
|
+
switch (method) {
|
|
948
|
+
case ConfigLoadMethod.FROM_URLS:
|
|
949
|
+
return await this.loadConfigFromUrls(options, environment);
|
|
950
|
+
case ConfigLoadMethod.FROM_LOCAL_STORAGE:
|
|
951
|
+
return this.loadConfigFromLocalStorage(options);
|
|
952
|
+
case ConfigLoadMethod.FROM_URL_PARAM:
|
|
953
|
+
return this.loadConfigFromUrlParam(options as any);
|
|
954
|
+
case ConfigLoadMethod.FROM_CID:
|
|
955
|
+
return await this.loadConfigFromCid(options as any);
|
|
956
|
+
default:
|
|
957
|
+
return null;
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
private static getMethodName(method: ConfigLoadMethod): string {
|
|
962
|
+
switch (method) {
|
|
963
|
+
case ConfigLoadMethod.FROM_URLS:
|
|
964
|
+
return 'urls';
|
|
965
|
+
case ConfigLoadMethod.FROM_LOCAL_STORAGE:
|
|
966
|
+
return 'local storage';
|
|
967
|
+
case ConfigLoadMethod.FROM_URL_PARAM:
|
|
968
|
+
return 'url param';
|
|
969
|
+
case ConfigLoadMethod.FROM_CID:
|
|
970
|
+
return 'cid';
|
|
971
|
+
default:
|
|
972
|
+
return 'unknown';
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
|
|
879
976
|
private static loadConfigFromUrlParam(options: ConfigLoadOptions & { fromUrlParam: string | true }) {
|
|
880
977
|
const param = typeof options.fromUrlParam === 'string' ? options.fromUrlParam : 'config';
|
|
881
978
|
return this.LoadConfigDefaultFromUrlParam(param);
|