@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.
Files changed (104) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/compodoc/changelog.html +7 -0
  3. package/compodoc/dependencies.html +2 -2
  4. package/compodoc/injectables/ConfigService.html +130 -87
  5. package/compodoc/interfaces/ConfigLoadOptions.html +149 -52
  6. package/compodoc/js/search/search_index.js +2 -2
  7. package/compodoc/miscellaneous/enumerations.html +53 -0
  8. package/compodoc/properties.html +1 -1
  9. package/docs/documentation.json +820 -656
  10. package/docs/html/assets/hierarchy.js +1 -1
  11. package/docs/html/assets/navigation.js +1 -1
  12. package/docs/html/assets/search.js +1 -1
  13. package/docs/html/classes/ConfigLoaderService.html +2 -2
  14. package/docs/html/classes/ConfigService.html +6 -6
  15. package/docs/html/classes/ConfigTestingService.html +2 -2
  16. package/docs/html/enums/ConfigLoadMethod.html +5 -0
  17. package/docs/html/enums/ConfigLoadingStrategy.html +2 -2
  18. package/docs/html/functions/ProvideConfig.html +1 -1
  19. package/docs/html/functions/dnsLookup.html +1 -1
  20. package/docs/html/functions/dnsResolver.html +1 -1
  21. package/docs/html/functions/fetchCidContent.html +1 -1
  22. package/docs/html/functions/fetchCidContentAsJson.html +1 -1
  23. package/docs/html/functions/fetchCidContentViaHttp.html +1 -1
  24. package/docs/html/functions/fetchContentViaHttp.html +1 -1
  25. package/docs/html/functions/raceSuccess.html +2 -2
  26. package/docs/html/hierarchy.html +1 -1
  27. package/docs/html/index.html +2 -2
  28. package/docs/html/interfaces/AppsNavigationConfig.html +2 -2
  29. package/docs/html/interfaces/Config.html +2 -2
  30. package/docs/html/interfaces/ConfigLoadOptions.html +10 -5
  31. package/docs/html/interfaces/LogoConfig.html +2 -2
  32. package/docs/html/interfaces/NavigationConfig.html +2 -2
  33. package/docs/html/interfaces/Oauth2Config.html +2 -2
  34. package/docs/html/interfaces/i18nConfig.html +2 -2
  35. package/docs/html/modules.html +1 -1
  36. package/docs/html/types/AnySchema.html +1 -1
  37. package/docs/html/types/Join.html +1 -1
  38. package/docs/html/types/LanguagesConfig.html +1 -1
  39. package/docs/html/types/Leaves.html +1 -1
  40. package/docs/html/types/NoInferType.html +1 -1
  41. package/docs/html/types/Paths.html +1 -1
  42. package/docs/html/variables/RXAP_CONFIG.html +1 -1
  43. package/docs/markdown/README.md +1 -1
  44. package/docs/markdown/classes/ConfigLoaderService.md +7 -7
  45. package/docs/markdown/classes/ConfigService.md +22 -22
  46. package/docs/markdown/classes/ConfigTestingService.md +8 -8
  47. package/docs/markdown/enumerations/ConfigLoadMethod.md +41 -0
  48. package/docs/markdown/enumerations/ConfigLoadingStrategy.md +4 -4
  49. package/docs/markdown/functions/ProvideConfig.md +2 -2
  50. package/docs/markdown/functions/dnsLookup.md +2 -2
  51. package/docs/markdown/functions/dnsResolver.md +2 -2
  52. package/docs/markdown/functions/fetchCidContent.md +2 -2
  53. package/docs/markdown/functions/fetchCidContentAsJson.md +2 -2
  54. package/docs/markdown/functions/fetchCidContentViaHttp.md +2 -2
  55. package/docs/markdown/functions/fetchContentViaHttp.md +2 -2
  56. package/docs/markdown/functions/raceSuccess.md +2 -2
  57. package/docs/markdown/globals.md +3 -2
  58. package/docs/markdown/interfaces/AppsNavigationConfig.md +12 -12
  59. package/docs/markdown/interfaces/Config.md +6 -6
  60. package/docs/markdown/interfaces/ConfigLoadOptions.md +27 -13
  61. package/docs/markdown/interfaces/LogoConfig.md +5 -5
  62. package/docs/markdown/interfaces/NavigationConfig.md +9 -9
  63. package/docs/markdown/interfaces/Oauth2Config.md +3 -3
  64. package/docs/markdown/interfaces/i18nConfig.md +4 -4
  65. package/docs/markdown/type-aliases/AnySchema.md +2 -2
  66. package/docs/markdown/type-aliases/Join.md +2 -2
  67. package/docs/markdown/type-aliases/LanguagesConfig.md +2 -2
  68. package/docs/markdown/type-aliases/Leaves.md +2 -2
  69. package/docs/markdown/type-aliases/NoInferType.md +2 -2
  70. package/docs/markdown/type-aliases/Paths.md +2 -2
  71. package/docs/markdown/variables/RXAP_CONFIG.md +2 -2
  72. package/docs/wiki/Class.ConfigLoaderService.md +6 -6
  73. package/docs/wiki/Class.ConfigService.md +21 -21
  74. package/docs/wiki/Class.ConfigTestingService.md +7 -7
  75. package/docs/wiki/Enumeration.ConfigLoadMethod.md +37 -0
  76. package/docs/wiki/Enumeration.ConfigLoadingStrategy.md +3 -3
  77. package/docs/wiki/Function.ProvideConfig.md +1 -1
  78. package/docs/wiki/Function.dnsLookup.md +1 -1
  79. package/docs/wiki/Function.dnsResolver.md +1 -1
  80. package/docs/wiki/Function.fetchCidContent.md +1 -1
  81. package/docs/wiki/Function.fetchCidContentAsJson.md +1 -1
  82. package/docs/wiki/Function.fetchCidContentViaHttp.md +1 -1
  83. package/docs/wiki/Function.fetchContentViaHttp.md +1 -1
  84. package/docs/wiki/Function.raceSuccess.md +1 -1
  85. package/docs/wiki/Interface.AppsNavigationConfig.md +11 -11
  86. package/docs/wiki/Interface.Config.md +5 -5
  87. package/docs/wiki/Interface.ConfigLoadOptions.md +26 -12
  88. package/docs/wiki/Interface.LogoConfig.md +4 -4
  89. package/docs/wiki/Interface.NavigationConfig.md +8 -8
  90. package/docs/wiki/Interface.Oauth2Config.md +2 -2
  91. package/docs/wiki/Interface.i18nConfig.md +3 -3
  92. package/docs/wiki/TypeAlias.AnySchema.md +1 -1
  93. package/docs/wiki/TypeAlias.Join.md +1 -1
  94. package/docs/wiki/TypeAlias.LanguagesConfig.md +1 -1
  95. package/docs/wiki/TypeAlias.Leaves.md +1 -1
  96. package/docs/wiki/TypeAlias.NoInferType.md +1 -1
  97. package/docs/wiki/TypeAlias.Paths.md +1 -1
  98. package/docs/wiki/Variable.RXAP_CONFIG.md +1 -1
  99. package/docs/wiki/_Sidebar.md +1 -0
  100. package/docs/wiki/globals.md +2 -1
  101. package/fesm2022/rxap-config.mjs +78 -57
  102. package/fesm2022/rxap-config.mjs.map +1 -1
  103. package/lib/config.service.d.ts +17 -0
  104. 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 &#x3D; &#x27;fifo&#x27;,
700
754
  }
701
755
 
756
+ export enum ConfigLoadMethod {
757
+ FROM_URLS &#x3D; &#x27;fromUrls&#x27;,
758
+ FROM_LOCAL_STORAGE &#x3D; &#x27;fromLocalStorage&#x27;,
759
+ FROM_URL_PARAM &#x3D; &#x27;fromUrlParam&#x27;,
760
+ FROM_CID &#x3D; &#x27;fromCid&#x27;,
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) &#x3D;&gt; Promise&lt;Blob | null&gt;;
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&lt;Config extends Record&lt;string, any&gt; &#x3D; Re
794
863
  }
795
864
  }
796
865
 
866
+ // Always merge static config first
797
867
  config &#x3D; deepMerge(config, options?.static ?? {});
798
- let done &#x3D; false;
799
868
 
800
- if (!done &amp;&amp; options?.fromUrls !&#x3D;&#x3D; false) {
801
- try {
802
- config &#x3D; deepMerge(config, await this.loadConfigFromUrls(options, environment));
803
- if (options.strategy &#x3D;&#x3D;&#x3D; ConfigLoadingStrategy.FIFO) {
804
- done &#x3D; true;
805
- }
806
- } catch (error: any) {
807
- if (options.strategy !&#x3D;&#x3D; ConfigLoadingStrategy.FIFO) {
808
- console.error(&#x27;Could not load config from urls&#x27;, error);
809
- throw error;
810
- } else {
811
- console.warn(&#x27;Could not load config from urls: &#x27; + error.message + &#x27;. Will try next strategy.&#x27;);
812
- }
813
- }
814
- }
869
+ // Determine the order of config sources to load
870
+ const order &#x3D; options.order ?? [
871
+ ConfigLoadMethod.FROM_URLS,
872
+ ConfigLoadMethod.FROM_LOCAL_STORAGE,
873
+ ConfigLoadMethod.FROM_URL_PARAM,
874
+ ConfigLoadMethod.FROM_CID,
875
+ ];
815
876
 
816
- if (!done &amp;&amp; options?.fromLocalStorage !&#x3D;&#x3D; false) {
817
- try {
818
- config &#x3D; deepMerge(config, this.loadConfigFromLocalStorage(options));
819
- if (options.strategy &#x3D;&#x3D;&#x3D; ConfigLoadingStrategy.FIFO) {
820
- done &#x3D; true;
821
- }
822
- } catch (error: any) {
823
- if (options.strategy !&#x3D;&#x3D; ConfigLoadingStrategy.FIFO) {
824
- console.error(&#x27;Could not load config from local storage&#x27;, error);
825
- throw error;
826
- } else {
827
- console.warn(&#x27;Could not load config from local storage: &#x27; + error.message + &#x27;. Will try next strategy.&#x27;);
828
- }
829
- }
877
+ // If fromDns is enabled and FROM_CID is in the order, resolve CID first
878
+ if (options.fromDns &amp;&amp; order.includes(ConfigLoadMethod.FROM_CID) &amp;&amp; !options.fromCid) {
879
+ await this.loadConfigFromDns(options as any);
830
880
  }
831
881
 
832
- if (!done &amp;&amp; options?.fromUrlParam) {
833
- try {
834
- config &#x3D; deepMerge(config, this.loadConfigFromUrlParam(options as any));
835
- if (options.strategy &#x3D;&#x3D;&#x3D; ConfigLoadingStrategy.FIFO) {
836
- done &#x3D; true;
837
- }
838
- } catch (error: any) {
839
- if (options.strategy !&#x3D;&#x3D; ConfigLoadingStrategy.FIFO) {
840
- console.error(&#x27;Could not load config from url param&#x27;, error);
841
- throw error;
842
- } else {
843
- console.warn(&#x27;Could not load config from url param: &#x27; + error.message + &#x27;. Will try next strategy.&#x27;);
844
- }
882
+ // Load configs from sources in the specified order
883
+ let done &#x3D; false;
884
+ for (const method of order) {
885
+ if (done) {
886
+ break;
845
887
  }
846
- }
847
888
 
848
- if (!done &amp;&amp; options?.fromDns) {
849
- await this.loadConfigFromDns(options as any);
850
- }
889
+ // Check if the source is enabled
890
+ if (!this.isSourceEnabled(options, method)) {
891
+ continue;
892
+ }
851
893
 
852
- if (!done &amp;&amp; options?.fromCid) {
853
894
  try {
854
- config &#x3D; deepMerge(config, await this.loadConfigFromCid(options as any));
895
+ const loadedConfig &#x3D; await this.loadConfigFromMethod(method, options, environment);
896
+ if (loadedConfig) {
897
+ config &#x3D; deepMerge(config, loadedConfig);
898
+ }
899
+
900
+ // If using FIFO strategy, stop after first successful load
855
901
  if (options.strategy &#x3D;&#x3D;&#x3D; ConfigLoadingStrategy.FIFO) {
856
902
  done &#x3D; true;
857
903
  }
858
904
  } catch (error: any) {
905
+ const methodName &#x3D; this.getMethodName(method);
859
906
  if (options.strategy !&#x3D;&#x3D; ConfigLoadingStrategy.FIFO) {
860
- console.error(&#x27;Could not load config from cid&#x27;, error);
907
+ console.error(&#x60;Could not load config from ${methodName}&#x60;, error);
861
908
  throw error;
862
909
  } else {
863
- console.warn(&#x27;Could not load config from cid: &#x27; + error.message + &#x27;. Will try next strategy.&#x27;);
910
+ console.warn(&#x60;Could not load config from ${methodName}: ${error.message}. Will try next strategy.&#x60;);
864
911
  }
865
912
  }
866
913
  }
867
914
 
868
- if (!done) {
915
+ if (!done &amp;&amp; order.length &gt; 0) {
869
916
  console.warn(&#x27;No config loading strategy succeeded. Using default config.&#x27;);
870
917
  }
871
918
 
919
+ // Always merge overwrites last
872
920
  config &#x3D; deepMerge(config, this.Overwrites);
873
921
 
874
922
  console.debug(&#x27;app config&#x27;, config);
@@ -876,6 +924,55 @@ export class ConfigService&lt;Config extends Record&lt;string, any&gt; &#x3D; Re
876
924
  this.Config &#x3D; 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 !&#x3D;&#x3D; false;
931
+ case ConfigLoadMethod.FROM_LOCAL_STORAGE:
932
+ return options.fromLocalStorage !&#x3D;&#x3D; 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&lt;any&gt; {
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 &#x27;urls&#x27;;
965
+ case ConfigLoadMethod.FROM_LOCAL_STORAGE:
966
+ return &#x27;local storage&#x27;;
967
+ case ConfigLoadMethod.FROM_URL_PARAM:
968
+ return &#x27;url param&#x27;;
969
+ case ConfigLoadMethod.FROM_CID:
970
+ return &#x27;cid&#x27;;
971
+ default:
972
+ return &#x27;unknown&#x27;;
973
+ }
974
+ }
975
+
879
976
  private static loadConfigFromUrlParam(options: ConfigLoadOptions &amp; { fromUrlParam: string | true }) {
880
977
  const param &#x3D; typeof options.fromUrlParam &#x3D;&#x3D;&#x3D; &#x27;string&#x27; ? options.fromUrlParam : &#x27;config&#x27;;
881
978
  return this.LoadConfigDefaultFromUrlParam(param);