@rxap/config 19.3.0-dev.4 → 21.0.1-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 +20 -0
- package/compodoc/changelog.html +26 -0
- package/compodoc/dependencies.html +6 -6
- package/compodoc/index.html +69 -1
- package/compodoc/injectables/ConfigService.html +210 -102
- package/compodoc/interfaces/ConfigLoadError.html +610 -0
- package/compodoc/interfaces/ConfigLoadOptions.html +213 -66
- package/compodoc/js/menu-wc.js +3 -0
- package/compodoc/js/menu-wc_es5.js +1 -1
- package/compodoc/js/search/search_index.js +2 -2
- package/compodoc/miscellaneous/functions.html +130 -1
- package/compodoc/miscellaneous/typealiases.html +78 -0
- package/compodoc/overview.html +1 -1
- package/compodoc/properties.html +1 -1
- package/docs/documentation.json +2445 -1297
- package/docs/html/assets/hierarchy.js +1 -1
- package/docs/html/assets/highlight.css +42 -0
- 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 +8 -6
- package/docs/html/classes/ConfigTestingService.html +2 -2
- package/docs/html/enums/ConfigLoadMethod.html +2 -2
- package/docs/html/enums/ConfigLoadingStrategy.html +2 -2
- package/docs/html/functions/ProvideConfig.html +1 -1
- package/docs/html/functions/defaultConfigLoadErrorHandler.html +4 -0
- 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/localPathIpfsGateway.html +1 -1
- package/docs/html/functions/localSubDomainIpfsGateway.html +1 -1
- package/docs/html/functions/raceSuccess.html +2 -2
- package/docs/html/functions/showConfigLoadError.html +2 -0
- package/docs/html/functions/storachaIpfsGateway.html +1 -1
- package/docs/html/functions/w3sIpfsGateway.html +1 -1
- package/docs/html/hierarchy.html +1 -1
- package/docs/html/index.html +54 -2
- package/docs/html/interfaces/AppsNavigationConfig.html +2 -2
- package/docs/html/interfaces/Config.html +2 -2
- package/docs/html/interfaces/ConfigLoadError.html +11 -0
- package/docs/html/interfaces/ConfigLoadOptions.html +13 -6
- 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/ConfigLoadErrorHandler.html +2 -0
- package/docs/html/types/ConfigLoadErrorKind.html +9 -0
- package/docs/html/types/ConfigRequestOptions.html +1 -0
- package/docs/html/types/IpfsGatewayFunction.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/html/variables/defaultDnsServers.html +1 -1
- package/docs/html/variables/defaultIpfsGatewayServers.html +1 -1
- package/docs/markdown/README.md +54 -1
- package/docs/markdown/classes/ConfigLoaderService.md +7 -7
- package/docs/markdown/classes/ConfigService.md +37 -23
- package/docs/markdown/classes/ConfigTestingService.md +8 -8
- package/docs/markdown/enumerations/ConfigLoadMethod.md +6 -6
- package/docs/markdown/enumerations/ConfigLoadingStrategy.md +4 -4
- package/docs/markdown/functions/ProvideConfig.md +2 -2
- package/docs/markdown/functions/defaultConfigLoadErrorHandler.md +26 -0
- 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/localPathIpfsGateway.md +2 -2
- package/docs/markdown/functions/localSubDomainIpfsGateway.md +2 -2
- package/docs/markdown/functions/raceSuccess.md +2 -2
- package/docs/markdown/functions/showConfigLoadError.md +23 -0
- package/docs/markdown/functions/storachaIpfsGateway.md +2 -2
- package/docs/markdown/functions/w3sIpfsGateway.md +2 -2
- package/docs/markdown/globals.md +8 -2
- package/docs/markdown/interfaces/AppsNavigationConfig.md +12 -12
- package/docs/markdown/interfaces/Config.md +6 -6
- package/docs/markdown/interfaces/ConfigLoadError.md +70 -0
- package/docs/markdown/interfaces/ConfigLoadOptions.md +39 -15
- 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/ConfigLoadErrorHandler.md +23 -0
- package/docs/markdown/type-aliases/ConfigLoadErrorKind.md +19 -0
- package/docs/markdown/type-aliases/ConfigRequestOptions.md +11 -0
- package/docs/markdown/type-aliases/IpfsGatewayFunction.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/markdown/variables/defaultDnsServers.md +2 -2
- package/docs/markdown/variables/defaultIpfsGatewayServers.md +2 -2
- package/docs/wiki/Class.ConfigLoaderService.md +6 -6
- package/docs/wiki/Class.ConfigService.md +36 -22
- package/docs/wiki/Class.ConfigTestingService.md +7 -7
- package/docs/wiki/Enumeration.ConfigLoadMethod.md +5 -5
- package/docs/wiki/Enumeration.ConfigLoadingStrategy.md +3 -3
- package/docs/wiki/Function.ProvideConfig.md +1 -1
- package/docs/wiki/Function.defaultConfigLoadErrorHandler.md +22 -0
- 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.localPathIpfsGateway.md +1 -1
- package/docs/wiki/Function.localSubDomainIpfsGateway.md +1 -1
- package/docs/wiki/Function.raceSuccess.md +1 -1
- package/docs/wiki/Function.showConfigLoadError.md +19 -0
- package/docs/wiki/Function.storachaIpfsGateway.md +1 -1
- package/docs/wiki/Function.w3sIpfsGateway.md +1 -1
- package/docs/wiki/Home.md +53 -0
- package/docs/wiki/Interface.AppsNavigationConfig.md +11 -11
- package/docs/wiki/Interface.Config.md +5 -5
- package/docs/wiki/Interface.ConfigLoadError.md +66 -0
- package/docs/wiki/Interface.ConfigLoadOptions.md +38 -14
- 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.ConfigLoadErrorHandler.md +19 -0
- package/docs/wiki/TypeAlias.ConfigLoadErrorKind.md +15 -0
- package/docs/wiki/TypeAlias.ConfigRequestOptions.md +7 -0
- package/docs/wiki/TypeAlias.IpfsGatewayFunction.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/Variable.defaultDnsServers.md +1 -1
- package/docs/wiki/Variable.defaultIpfsGatewayServers.md +1 -1
- package/docs/wiki/_Sidebar.md +6 -0
- package/docs/wiki/globals.md +7 -1
- package/fesm2022/rxap-config.mjs +10 -10
- package/fesm2022/rxap-config.mjs.map +1 -1
- package/package.json +15 -14
- package/types/rxap-config.d.ts +298 -0
- package/index.d.ts +0 -9
- package/lib/config-load-error.d.ts +0 -41
- package/lib/config-loader.service.d.ts +0 -12
- package/lib/config-testing-service.d.ts +0 -12
- package/lib/config.d.ts +0 -41
- package/lib/config.service.d.ts +0 -129
- package/lib/provide-config.d.ts +0 -4
- package/lib/tokens.d.ts +0 -2
- package/lib/types.d.ts +0 -34
- package/lib/utilities.d.ts +0 -19
|
@@ -147,6 +147,13 @@
|
|
|
147
147
|
dnsServers
|
|
148
148
|
</a>
|
|
149
149
|
</li>
|
|
150
|
+
<li>
|
|
151
|
+
<span class="modifier">Optional</span>
|
|
152
|
+
<a href="#errorHandler"
|
|
153
|
+
>
|
|
154
|
+
errorHandler
|
|
155
|
+
</a>
|
|
156
|
+
</li>
|
|
150
157
|
<li>
|
|
151
158
|
<span class="modifier">Optional</span>
|
|
152
159
|
<a href="#fetchCidContent"
|
|
@@ -203,6 +210,13 @@
|
|
|
203
210
|
order
|
|
204
211
|
</a>
|
|
205
212
|
</li>
|
|
213
|
+
<li>
|
|
214
|
+
<span class="modifier">Optional</span>
|
|
215
|
+
<a href="#requestInit"
|
|
216
|
+
>
|
|
217
|
+
requestInit
|
|
218
|
+
</a>
|
|
219
|
+
</li>
|
|
206
220
|
<li>
|
|
207
221
|
<span class="modifier">Optional</span>
|
|
208
222
|
<a href="#schema"
|
|
@@ -278,6 +292,53 @@
|
|
|
278
292
|
|
|
279
293
|
|
|
280
294
|
|
|
295
|
+
</tbody>
|
|
296
|
+
</table>
|
|
297
|
+
<table class="table table-sm table-bordered">
|
|
298
|
+
<tbody>
|
|
299
|
+
<tr>
|
|
300
|
+
<td class="col-md-4">
|
|
301
|
+
<a name="errorHandler"></a>
|
|
302
|
+
<span class="name "><b>errorHandler</b>
|
|
303
|
+
<a href="#errorHandler">
|
|
304
|
+
<span class="icon ion-ios-link"></span>
|
|
305
|
+
</a>
|
|
306
|
+
</span>
|
|
307
|
+
</td>
|
|
308
|
+
</tr>
|
|
309
|
+
<tr>
|
|
310
|
+
<td class="col-md-4">
|
|
311
|
+
<code>errorHandler: <code><a href="../miscellaneous/typealiases.html#ConfigLoadErrorHandler" target="_self" >ConfigLoadErrorHandler</a></code>
|
|
312
|
+
</code>
|
|
313
|
+
</td>
|
|
314
|
+
</tr>
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
<tr>
|
|
318
|
+
<td class="col-md-4">
|
|
319
|
+
<i>Type : </i> <code><a href="../miscellaneous/typealiases.html#ConfigLoadErrorHandler" target="_self" >ConfigLoadErrorHandler</a></code>
|
|
320
|
+
|
|
321
|
+
</td>
|
|
322
|
+
</tr>
|
|
323
|
+
|
|
324
|
+
<tr>
|
|
325
|
+
<td class="col-md-4">
|
|
326
|
+
<i>Optional</i>
|
|
327
|
+
</td>
|
|
328
|
+
</tr>
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
<tr>
|
|
334
|
+
<td class="col-md-4">
|
|
335
|
+
<div class="io-description"><p>Replaces the default error handling (error overlay + page reload after 30 s) for failed
|
|
336
|
+
config url requests. Used for the <code>url</code> / <code>fromUrls</code> source and for <code>SideLoad</code>.</p>
|
|
337
|
+
<p>Afterwards a required url still throws and an optional url resolves with <code>null</code>. The
|
|
338
|
+
<code>onError</code> / <code>onRequestError</code> hooks are still called.</p>
|
|
339
|
+
</div>
|
|
340
|
+
</td>
|
|
341
|
+
</tr>
|
|
281
342
|
</tbody>
|
|
282
343
|
</table>
|
|
283
344
|
<table class="table table-sm table-bordered">
|
|
@@ -602,6 +663,50 @@ If true, uses <code>location.hostname</code>. If a string, uses that domain.</p>
|
|
|
602
663
|
If not specified, defaults to: [FROM_URLS, FROM_LOCAL_STORAGE, FROM_URL_PARAM, FROM_CID]</p>
|
|
603
664
|
<p>Note: static config is always merged first, and Overwrites are always merged last.
|
|
604
665
|
Note: fromDns is not a source itself - it resolves the CID for FROM_CID.</p>
|
|
666
|
+
</div>
|
|
667
|
+
</td>
|
|
668
|
+
</tr>
|
|
669
|
+
</tbody>
|
|
670
|
+
</table>
|
|
671
|
+
<table class="table table-sm table-bordered">
|
|
672
|
+
<tbody>
|
|
673
|
+
<tr>
|
|
674
|
+
<td class="col-md-4">
|
|
675
|
+
<a name="requestInit"></a>
|
|
676
|
+
<span class="name "><b>requestInit</b>
|
|
677
|
+
<a href="#requestInit">
|
|
678
|
+
<span class="icon ion-ios-link"></span>
|
|
679
|
+
</a>
|
|
680
|
+
</span>
|
|
681
|
+
</td>
|
|
682
|
+
</tr>
|
|
683
|
+
<tr>
|
|
684
|
+
<td class="col-md-4">
|
|
685
|
+
<code>requestInit: <code>RequestInit</code>
|
|
686
|
+
</code>
|
|
687
|
+
</td>
|
|
688
|
+
</tr>
|
|
689
|
+
|
|
690
|
+
|
|
691
|
+
<tr>
|
|
692
|
+
<td class="col-md-4">
|
|
693
|
+
<i>Type : </i> <code>RequestInit</code>
|
|
694
|
+
|
|
695
|
+
</td>
|
|
696
|
+
</tr>
|
|
697
|
+
|
|
698
|
+
<tr>
|
|
699
|
+
<td class="col-md-4">
|
|
700
|
+
<i>Optional</i>
|
|
701
|
+
</td>
|
|
702
|
+
</tr>
|
|
703
|
+
|
|
704
|
+
|
|
705
|
+
|
|
706
|
+
|
|
707
|
+
<tr>
|
|
708
|
+
<td class="col-md-4">
|
|
709
|
+
<div class="io-description"><p>Passed to <code>fetch()</code> for config url requests, e.g. <code>{ redirect: 'manual' }</code>.</p>
|
|
605
710
|
</div>
|
|
606
711
|
</td>
|
|
607
712
|
</tr>
|
|
@@ -784,6 +889,11 @@ import {
|
|
|
784
889
|
SetToObject,
|
|
785
890
|
} from '@rxap/utilities';
|
|
786
891
|
import { ReplaySubject } from 'rxjs';
|
|
892
|
+
import {
|
|
893
|
+
ConfigLoadError,
|
|
894
|
+
ConfigLoadErrorHandler,
|
|
895
|
+
defaultConfigLoadErrorHandler,
|
|
896
|
+
} from './config-load-error';
|
|
787
897
|
import { RXAP_CONFIG } from './tokens';
|
|
788
898
|
import { NoInferType } from './types';
|
|
789
899
|
import {
|
|
@@ -837,8 +947,22 @@ export interface ConfigLoadOptions {
|
|
|
837
947
|
* Note: fromDns is not a source itself - it resolves the CID for FROM_CID.
|
|
838
948
|
*/
|
|
839
949
|
order?: ConfigLoadMethod[];
|
|
950
|
+
/**
|
|
951
|
+
* Replaces the default error handling (error overlay + page reload after 30 s) for failed
|
|
952
|
+
* config url requests. Used for the `url` / `fromUrls` source and for `SideLoad`.
|
|
953
|
+
*
|
|
954
|
+
* Afterwards a required url still throws and an optional url resolves with `null`. The
|
|
955
|
+
* `onError` / `onRequestError` hooks are still called.
|
|
956
|
+
*/
|
|
957
|
+
errorHandler?: ConfigLoadErrorHandler;
|
|
958
|
+
/**
|
|
959
|
+
* Passed to `fetch()` for config url requests, e.g. `{ redirect: 'manual' }`.
|
|
960
|
+
*/
|
|
961
|
+
requestInit?: RequestInit;
|
|
840
962
|
}
|
|
841
963
|
|
|
964
|
+
export type ConfigRequestOptions = Pick<ConfigLoadOptions, 'errorHandler' | 'requestInit'>;
|
|
965
|
+
|
|
842
966
|
@Injectable({
|
|
843
967
|
providedIn: 'root',
|
|
844
968
|
})
|
|
@@ -867,6 +991,11 @@ export class ConfigService<Config extends Record<string, any> = Re
|
|
|
867
991
|
|
|
868
992
|
public static LocalStorageKey = 'rxap/config/local-config';
|
|
869
993
|
|
|
994
|
+
/**
|
|
995
|
+
* The errorHandler and requestInit of the last Load call. Used by SideLoad.
|
|
996
|
+
*/
|
|
997
|
+
public static RequestOptions: ConfigRequestOptions = {};
|
|
998
|
+
|
|
870
999
|
/**
|
|
871
1000
|
* @deprecated instead use the url property of the ConfigLoadOptions
|
|
872
1001
|
*/
|
|
@@ -894,6 +1023,11 @@ export class ConfigService<Config extends Record<string, any> = Re
|
|
|
894
1023
|
public static async Load(options?: ConfigLoadOptions, environment?: Environment): Promise<void> {
|
|
895
1024
|
options ??= {};
|
|
896
1025
|
|
|
1026
|
+
this.RequestOptions = {
|
|
1027
|
+
errorHandler: options.errorHandler,
|
|
1028
|
+
requestInit: options.requestInit,
|
|
1029
|
+
};
|
|
1030
|
+
|
|
897
1031
|
let config: any = deepMerge(this.Defaults, {});
|
|
898
1032
|
|
|
899
1033
|
if (environment?.config) {
|
|
@@ -1048,7 +1182,7 @@ export class ConfigService<Config extends Record<string, any> = Re
|
|
|
1048
1182
|
}).flat();
|
|
1049
1183
|
|
|
1050
1184
|
for (const url of urls) {
|
|
1051
|
-
const loadedConfig = await this.loadConfig(url, true, options?.schema);
|
|
1185
|
+
const loadedConfig = await this.loadConfig(url, true, options?.schema, options);
|
|
1052
1186
|
const match = url.match(/config\.([a-zA-Z0-9.\-_]+)\.json/);
|
|
1053
1187
|
if (match) {
|
|
1054
1188
|
SetToObject(config, match[1], loadedConfig);
|
|
@@ -1142,23 +1276,37 @@ export class ConfigService<Config extends Record<string, any> = Re
|
|
|
1142
1276
|
}
|
|
1143
1277
|
}
|
|
1144
1278
|
|
|
1145
|
-
private static async loadConfig<T = any>(
|
|
1279
|
+
private static async loadConfig<T = any>(
|
|
1280
|
+
url: string,
|
|
1281
|
+
required = false,
|
|
1282
|
+
schema?: AnySchema,
|
|
1283
|
+
options: ConfigRequestOptions = this.RequestOptions,
|
|
1284
|
+
): Promise<T | null> {
|
|
1146
1285
|
|
|
1147
1286
|
let config: any;
|
|
1148
|
-
let response:
|
|
1287
|
+
let response: Response;
|
|
1149
1288
|
|
|
1150
1289
|
try {
|
|
1151
|
-
response = await fetch(url);
|
|
1290
|
+
response = await fetch(url, options.requestInit);
|
|
1152
1291
|
} catch (error: any) {
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1292
|
+
return this.handleLoadError({
|
|
1293
|
+
kind: 'network',
|
|
1294
|
+
url,
|
|
1295
|
+
required,
|
|
1296
|
+
cause: error,
|
|
1297
|
+
message: `Could not fetch config from '${ url }': ${ error.message }`,
|
|
1298
|
+
}, options);
|
|
1299
|
+
}
|
|
1300
|
+
|
|
1301
|
+
if (response.type === 'opaqueredirect') {
|
|
1302
|
+
return this.handleLoadError({
|
|
1303
|
+
kind: 'redirect',
|
|
1304
|
+
url,
|
|
1305
|
+
required,
|
|
1306
|
+
status: response.status,
|
|
1307
|
+
response,
|
|
1308
|
+
message: `Config request for '${ url }' was redirected`,
|
|
1309
|
+
}, options);
|
|
1162
1310
|
}
|
|
1163
1311
|
|
|
1164
1312
|
if (!response.ok) {
|
|
@@ -1174,43 +1322,43 @@ export class ConfigService<Config extends Record<string, any> = Re
|
|
|
1174
1322
|
message = `Unauthorized to fetch config from '${ url }'`;
|
|
1175
1323
|
break;
|
|
1176
1324
|
}
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
}
|
|
1325
|
+
return this.handleLoadError({
|
|
1326
|
+
kind: 'http',
|
|
1327
|
+
url,
|
|
1328
|
+
required,
|
|
1329
|
+
status: response.status,
|
|
1330
|
+
response,
|
|
1331
|
+
message,
|
|
1332
|
+
}, options);
|
|
1185
1333
|
}
|
|
1186
1334
|
|
|
1187
1335
|
try {
|
|
1188
1336
|
config = await response.json();
|
|
1189
1337
|
} catch (error: any) {
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
}
|
|
1338
|
+
return this.handleLoadError({
|
|
1339
|
+
kind: 'parse',
|
|
1340
|
+
url,
|
|
1341
|
+
required,
|
|
1342
|
+
status: response.status,
|
|
1343
|
+
response,
|
|
1344
|
+
cause: error,
|
|
1345
|
+
message: `Could not parse config from '${ url }' to a json object: ${ error.message }`,
|
|
1346
|
+
}, options);
|
|
1199
1347
|
}
|
|
1200
1348
|
|
|
1201
1349
|
if (schema) {
|
|
1202
1350
|
try {
|
|
1203
1351
|
config = await schema.validateAsync(config);
|
|
1204
1352
|
} catch (error: any) {
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
}
|
|
1353
|
+
return this.handleLoadError({
|
|
1354
|
+
kind: 'schema',
|
|
1355
|
+
url,
|
|
1356
|
+
required,
|
|
1357
|
+
status: response.status,
|
|
1358
|
+
response,
|
|
1359
|
+
cause: error,
|
|
1360
|
+
message: `Config from '${ url }' is not valid: ${ error.message }`,
|
|
1361
|
+
}, options);
|
|
1214
1362
|
}
|
|
1215
1363
|
}
|
|
1216
1364
|
|
|
@@ -1218,6 +1366,30 @@ export class ConfigService<Config extends Record<string, any> = Re
|
|
|
1218
1366
|
|
|
1219
1367
|
}
|
|
1220
1368
|
|
|
1369
|
+
/**
|
|
1370
|
+
* Notifies the onError/onRequestError hooks (required urls only), calls the error handler and
|
|
1371
|
+
* throws for required urls. Resolves with null for optional urls.
|
|
1372
|
+
*/
|
|
1373
|
+
private static async handleLoadError(error: ConfigLoadError, options: ConfigRequestOptions): Promise<null> {
|
|
1374
|
+
if (error.required) {
|
|
1375
|
+
if (error.response && (error.kind === 'http' || error.kind === 'redirect')) {
|
|
1376
|
+
this.handleRequestError(error.response);
|
|
1377
|
+
} else {
|
|
1378
|
+
this.handleError(error.cause);
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1381
|
+
const errorHandler = options.errorHandler ?? defaultConfigLoadErrorHandler;
|
|
1382
|
+
try {
|
|
1383
|
+
await errorHandler(error);
|
|
1384
|
+
} catch (e: any) {
|
|
1385
|
+
console.error('Error in config load error handler', e);
|
|
1386
|
+
}
|
|
1387
|
+
if (error.required) {
|
|
1388
|
+
throw new Error(error.message);
|
|
1389
|
+
}
|
|
1390
|
+
return null;
|
|
1391
|
+
}
|
|
1392
|
+
|
|
1221
1393
|
private static LoadConfigDefaultFromUrlParam(param = 'config') {
|
|
1222
1394
|
|
|
1223
1395
|
const queryString = window.location.search;
|
|
@@ -1249,13 +1421,14 @@ export class ConfigService<Config extends Record<string, any> = Re
|
|
|
1249
1421
|
propertyPath: string,
|
|
1250
1422
|
required?: boolean,
|
|
1251
1423
|
schema?: AnySchema,
|
|
1424
|
+
options: ConfigRequestOptions = this.RequestOptions,
|
|
1252
1425
|
): Promise<void> {
|
|
1253
1426
|
|
|
1254
1427
|
if (!this.Config) {
|
|
1255
1428
|
throw new Error('Config side load is only possible after the initial config load.');
|
|
1256
1429
|
}
|
|
1257
1430
|
|
|
1258
|
-
const config = await this.loadConfig(url, required, schema);
|
|
1431
|
+
const config = await this.loadConfig(url, required, schema, options);
|
|
1259
1432
|
|
|
1260
1433
|
SetObjectValue(this.Config, propertyPath, config);
|
|
1261
1434
|
|
|
@@ -1295,32 +1468,6 @@ export class ConfigService<Config extends Record<string, any> = Re
|
|
|
1295
1468
|
return configValue;
|
|
1296
1469
|
}
|
|
1297
1470
|
|
|
1298
|
-
private static showError(message: string) {
|
|
1299
|
-
const hasUl = document.getElementById('rxap-config-error') !== null;
|
|
1300
|
-
const ul = document.getElementById('rxap-config-error') ?? document.createElement('ul');
|
|
1301
|
-
ul.id = 'rxap-config-error';
|
|
1302
|
-
ul.style.position = 'fixed';
|
|
1303
|
-
ul.style.bottom = '16px';
|
|
1304
|
-
ul.style.right = '16px';
|
|
1305
|
-
ul.style.backgroundColor = 'white';
|
|
1306
|
-
ul.style.padding = '32px';
|
|
1307
|
-
ul.style.zIndex = '99999999';
|
|
1308
|
-
ul.style.color = 'black';
|
|
1309
|
-
const messageLi = document.createElement('li');
|
|
1310
|
-
messageLi.innerText = message;
|
|
1311
|
-
ul.appendChild(messageLi);
|
|
1312
|
-
const refreshHintLi = document.createElement('li');
|
|
1313
|
-
refreshHintLi.innerText = 'Please refresh the page to try again.';
|
|
1314
|
-
ul.appendChild(refreshHintLi);
|
|
1315
|
-
const autoRefreshHintLi = document.createElement('li');
|
|
1316
|
-
autoRefreshHintLi.innerText = 'The page will refresh automatically in 30 seconds.';
|
|
1317
|
-
ul.appendChild(autoRefreshHintLi);
|
|
1318
|
-
if (!hasUl) {
|
|
1319
|
-
document.body.appendChild(ul);
|
|
1320
|
-
}
|
|
1321
|
-
setTimeout(() => location.reload(), 30000);
|
|
1322
|
-
}
|
|
1323
|
-
|
|
1324
1471
|
public setLocalConfig(config: Config): void {
|
|
1325
1472
|
localStorage.setItem(ConfigService.LocalStorageKey, JSON.stringify(config));
|
|
1326
1473
|
}
|
package/compodoc/js/menu-wc.js
CHANGED
|
@@ -88,6 +88,9 @@ customElements.define('compodoc-menu', class extends HTMLElement {
|
|
|
88
88
|
<li class="link">
|
|
89
89
|
<a href="interfaces/Config.html" data-type="entity-link" >Config</a>
|
|
90
90
|
</li>
|
|
91
|
+
<li class="link">
|
|
92
|
+
<a href="interfaces/ConfigLoadError.html" data-type="entity-link" >ConfigLoadError</a>
|
|
93
|
+
</li>
|
|
91
94
|
<li class="link">
|
|
92
95
|
<a href="interfaces/ConfigLoadOptions.html" data-type="entity-link" >ConfigLoadOptions</a>
|
|
93
96
|
</li>
|
|
@@ -33,7 +33,7 @@ customElements.define('compodoc-menu', /*#__PURE__*/function (_HTMLElement) {
|
|
|
33
33
|
}, {
|
|
34
34
|
key: "render",
|
|
35
35
|
value: function render(isNormalMode) {
|
|
36
|
-
var tp = lithtml.html("\n <nav>\n <ul class=\"list\">\n <li class=\"title\">\n <a href=\"index.html\" data-type=\"index-link\">angular-config</a>\n </li>\n\n <li class=\"divider\"></li>\n ".concat(isNormalMode ? "<div id=\"book-search-input\" role=\"search\"><input type=\"text\" placeholder=\"Type to search\"></div>" : '', "\n <li class=\"chapter\">\n <a data-type=\"chapter-link\" href=\"index.html\"><span class=\"icon ion-ios-home\"></span>Getting started</a>\n <ul class=\"links\">\n <li class=\"link\">\n <a href=\"overview.html\" data-type=\"chapter-link\">\n <span class=\"icon ion-ios-keypad\"></span>Overview\n </a>\n </li>\n <li class=\"link\">\n <a href=\"index.html\" data-type=\"chapter-link\">\n <span class=\"icon ion-ios-paper\"></span>README\n </a>\n </li>\n <li class=\"link\">\n <a href=\"changelog.html\" data-type=\"chapter-link\">\n <span class=\"icon ion-ios-paper\"></span>CHANGELOG\n </a>\n </li>\n <li class=\"link\">\n <a href=\"license.html\" data-type=\"chapter-link\">\n <span class=\"icon ion-ios-paper\"></span>LICENSE\n </a>\n </li>\n <li class=\"link\">\n <a href=\"dependencies.html\" data-type=\"chapter-link\">\n <span class=\"icon ion-ios-list\"></span>Dependencies\n </a>\n </li>\n <li class=\"link\">\n <a href=\"properties.html\" data-type=\"chapter-link\">\n <span class=\"icon ion-ios-apps\"></span>Properties\n </a>\n </li>\n </ul>\n </li>\n <li class=\"chapter\">\n <div class=\"simple menu-toggler\" data-bs-toggle=\"collapse\" ").concat(isNormalMode ? 'data-bs-target="#injectables-links"' : 'data-bs-target="#xs-injectables-links"', ">\n <span class=\"icon ion-md-arrow-round-down\"></span>\n <span>Injectables</span>\n <span class=\"icon ion-ios-arrow-down\"></span>\n </div>\n <ul class=\"links collapse \" ").concat(isNormalMode ? 'id="injectables-links"' : 'id="xs-injectables-links"', ">\n <li class=\"link\">\n <a href=\"injectables/ConfigLoaderService.html\" data-type=\"entity-link\" >ConfigLoaderService</a>\n </li>\n <li class=\"link\">\n <a href=\"injectables/ConfigService.html\" data-type=\"entity-link\" >ConfigService</a>\n </li>\n <li class=\"link\">\n <a href=\"injectables/ConfigTestingService.html\" data-type=\"entity-link\" >ConfigTestingService</a>\n </li>\n </ul>\n </li>\n <li class=\"chapter\">\n <div class=\"simple menu-toggler\" data-bs-toggle=\"collapse\" ").concat(isNormalMode ? 'data-bs-target="#interfaces-links"' : 'data-bs-target="#xs-interfaces-links"', ">\n <span class=\"icon ion-md-information-circle-outline\"></span>\n <span>Interfaces</span>\n <span class=\"icon ion-ios-arrow-down\"></span>\n </div>\n <ul class=\"links collapse \" ").concat(isNormalMode ? ' id="interfaces-links"' : 'id="xs-interfaces-links"', ">\n <li class=\"link\">\n <a href=\"interfaces/AppsNavigationConfig.html\" data-type=\"entity-link\" >AppsNavigationConfig</a>\n </li>\n <li class=\"link\">\n <a href=\"interfaces/Config.html\" data-type=\"entity-link\" >Config</a>\n </li>\n <li class=\"link\">\n <a href=\"interfaces/ConfigLoadOptions.html\" data-type=\"entity-link\" >ConfigLoadOptions</a>\n </li>\n <li class=\"link\">\n <a href=\"interfaces/i18nConfig.html\" data-type=\"entity-link\" >i18nConfig</a>\n </li>\n <li class=\"link\">\n <a href=\"interfaces/LogoConfig.html\" data-type=\"entity-link\" >LogoConfig</a>\n </li>\n <li class=\"link\">\n <a href=\"interfaces/NavigationConfig.html\" data-type=\"entity-link\" >NavigationConfig</a>\n </li>\n <li class=\"link\">\n <a href=\"interfaces/Oauth2Config.html\" data-type=\"entity-link\" >Oauth2Config</a>\n </li>\n </ul>\n </li>\n <li class=\"chapter\">\n <div class=\"simple menu-toggler\" data-bs-toggle=\"collapse\" ").concat(isNormalMode ? 'data-bs-target="#miscellaneous-links"' : 'data-bs-target="#xs-miscellaneous-links"', ">\n <span class=\"icon ion-ios-cube\"></span>\n <span>Miscellaneous</span>\n <span class=\"icon ion-ios-arrow-down\"></span>\n </div>\n <ul class=\"links collapse \" ").concat(isNormalMode ? 'id="miscellaneous-links"' : 'id="xs-miscellaneous-links"', ">\n <li class=\"link\">\n <a href=\"miscellaneous/enumerations.html\" data-type=\"entity-link\">Enums</a>\n </li>\n <li class=\"link\">\n <a href=\"miscellaneous/functions.html\" data-type=\"entity-link\">Functions</a>\n </li>\n <li class=\"link\">\n <a href=\"miscellaneous/typealiases.html\" data-type=\"entity-link\">Type aliases</a>\n </li>\n <li class=\"link\">\n <a href=\"miscellaneous/variables.html\" data-type=\"entity-link\">Variables</a>\n </li>\n </ul>\n </li>\n <li class=\"divider\"></li>\n <li class=\"copyright\">\n Documentation generated using <a href=\"https://compodoc.app/\" target=\"_blank\" rel=\"noopener noreferrer\">\n <img data-src=\"images/compodoc-vectorise.png\" class=\"img-responsive\" data-type=\"compodoc-logo\">\n </a>\n </li>\n </ul>\n </nav>\n "));
|
|
36
|
+
var tp = lithtml.html("\n <nav>\n <ul class=\"list\">\n <li class=\"title\">\n <a href=\"index.html\" data-type=\"index-link\">angular-config</a>\n </li>\n\n <li class=\"divider\"></li>\n ".concat(isNormalMode ? "<div id=\"book-search-input\" role=\"search\"><input type=\"text\" placeholder=\"Type to search\"></div>" : '', "\n <li class=\"chapter\">\n <a data-type=\"chapter-link\" href=\"index.html\"><span class=\"icon ion-ios-home\"></span>Getting started</a>\n <ul class=\"links\">\n <li class=\"link\">\n <a href=\"overview.html\" data-type=\"chapter-link\">\n <span class=\"icon ion-ios-keypad\"></span>Overview\n </a>\n </li>\n <li class=\"link\">\n <a href=\"index.html\" data-type=\"chapter-link\">\n <span class=\"icon ion-ios-paper\"></span>README\n </a>\n </li>\n <li class=\"link\">\n <a href=\"changelog.html\" data-type=\"chapter-link\">\n <span class=\"icon ion-ios-paper\"></span>CHANGELOG\n </a>\n </li>\n <li class=\"link\">\n <a href=\"license.html\" data-type=\"chapter-link\">\n <span class=\"icon ion-ios-paper\"></span>LICENSE\n </a>\n </li>\n <li class=\"link\">\n <a href=\"dependencies.html\" data-type=\"chapter-link\">\n <span class=\"icon ion-ios-list\"></span>Dependencies\n </a>\n </li>\n <li class=\"link\">\n <a href=\"properties.html\" data-type=\"chapter-link\">\n <span class=\"icon ion-ios-apps\"></span>Properties\n </a>\n </li>\n </ul>\n </li>\n <li class=\"chapter\">\n <div class=\"simple menu-toggler\" data-bs-toggle=\"collapse\" ").concat(isNormalMode ? 'data-bs-target="#injectables-links"' : 'data-bs-target="#xs-injectables-links"', ">\n <span class=\"icon ion-md-arrow-round-down\"></span>\n <span>Injectables</span>\n <span class=\"icon ion-ios-arrow-down\"></span>\n </div>\n <ul class=\"links collapse \" ").concat(isNormalMode ? 'id="injectables-links"' : 'id="xs-injectables-links"', ">\n <li class=\"link\">\n <a href=\"injectables/ConfigLoaderService.html\" data-type=\"entity-link\" >ConfigLoaderService</a>\n </li>\n <li class=\"link\">\n <a href=\"injectables/ConfigService.html\" data-type=\"entity-link\" >ConfigService</a>\n </li>\n <li class=\"link\">\n <a href=\"injectables/ConfigTestingService.html\" data-type=\"entity-link\" >ConfigTestingService</a>\n </li>\n </ul>\n </li>\n <li class=\"chapter\">\n <div class=\"simple menu-toggler\" data-bs-toggle=\"collapse\" ").concat(isNormalMode ? 'data-bs-target="#interfaces-links"' : 'data-bs-target="#xs-interfaces-links"', ">\n <span class=\"icon ion-md-information-circle-outline\"></span>\n <span>Interfaces</span>\n <span class=\"icon ion-ios-arrow-down\"></span>\n </div>\n <ul class=\"links collapse \" ").concat(isNormalMode ? ' id="interfaces-links"' : 'id="xs-interfaces-links"', ">\n <li class=\"link\">\n <a href=\"interfaces/AppsNavigationConfig.html\" data-type=\"entity-link\" >AppsNavigationConfig</a>\n </li>\n <li class=\"link\">\n <a href=\"interfaces/Config.html\" data-type=\"entity-link\" >Config</a>\n </li>\n <li class=\"link\">\n <a href=\"interfaces/ConfigLoadError.html\" data-type=\"entity-link\" >ConfigLoadError</a>\n </li>\n <li class=\"link\">\n <a href=\"interfaces/ConfigLoadOptions.html\" data-type=\"entity-link\" >ConfigLoadOptions</a>\n </li>\n <li class=\"link\">\n <a href=\"interfaces/i18nConfig.html\" data-type=\"entity-link\" >i18nConfig</a>\n </li>\n <li class=\"link\">\n <a href=\"interfaces/LogoConfig.html\" data-type=\"entity-link\" >LogoConfig</a>\n </li>\n <li class=\"link\">\n <a href=\"interfaces/NavigationConfig.html\" data-type=\"entity-link\" >NavigationConfig</a>\n </li>\n <li class=\"link\">\n <a href=\"interfaces/Oauth2Config.html\" data-type=\"entity-link\" >Oauth2Config</a>\n </li>\n </ul>\n </li>\n <li class=\"chapter\">\n <div class=\"simple menu-toggler\" data-bs-toggle=\"collapse\" ").concat(isNormalMode ? 'data-bs-target="#miscellaneous-links"' : 'data-bs-target="#xs-miscellaneous-links"', ">\n <span class=\"icon ion-ios-cube\"></span>\n <span>Miscellaneous</span>\n <span class=\"icon ion-ios-arrow-down\"></span>\n </div>\n <ul class=\"links collapse \" ").concat(isNormalMode ? 'id="miscellaneous-links"' : 'id="xs-miscellaneous-links"', ">\n <li class=\"link\">\n <a href=\"miscellaneous/enumerations.html\" data-type=\"entity-link\">Enums</a>\n </li>\n <li class=\"link\">\n <a href=\"miscellaneous/functions.html\" data-type=\"entity-link\">Functions</a>\n </li>\n <li class=\"link\">\n <a href=\"miscellaneous/typealiases.html\" data-type=\"entity-link\">Type aliases</a>\n </li>\n <li class=\"link\">\n <a href=\"miscellaneous/variables.html\" data-type=\"entity-link\">Variables</a>\n </li>\n </ul>\n </li>\n <li class=\"divider\"></li>\n <li class=\"copyright\">\n Documentation generated using <a href=\"https://compodoc.app/\" target=\"_blank\" rel=\"noopener noreferrer\">\n <img data-src=\"images/compodoc-vectorise.png\" class=\"img-responsive\" data-type=\"compodoc-logo\">\n </a>\n </li>\n </ul>\n </nav>\n "));
|
|
37
37
|
this.innerHTML = tp.strings;
|
|
38
38
|
}
|
|
39
39
|
}]);
|