@rxap/config 16.0.0-dev.2 → 16.0.0-dev.21
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 +371 -0
- package/LICENSE +621 -21
- package/LICENSE.md +621 -0
- package/README.md +8 -63
- package/esm2022/index.mjs +6 -2
- package/esm2022/lib/config-loader.service.mjs +9 -9
- package/esm2022/lib/config-testing-service.mjs +33 -0
- package/esm2022/lib/config.service.mjs +114 -76
- package/esm2022/lib/tokens.mjs +1 -1
- package/esm2022/lib/types.mjs +1 -1
- package/esm2022/rxap-config.mjs +1 -1
- package/fesm2022/rxap-config.mjs +174 -101
- package/fesm2022/rxap-config.mjs.map +1 -1
- package/index.d.ts +3 -1
- package/lib/config-testing-service.d.ts +12 -0
- package/lib/config.service.d.ts +19 -8
- package/package.json +47 -41
- package/theme.css +1 -0
- package/collection.json +0 -15
- package/migration.json +0 -4
- package/src/schematics/ng-add/index.d.ts +0 -3
- package/src/schematics/ng-add/index.js +0 -59
- package/src/schematics/ng-add/index.js.map +0 -1
- package/src/schematics/ng-add/schema.json +0 -15
- package/src/schematics/side-load/index.d.ts +0 -3
- package/src/schematics/side-load/index.js +0 -27
- package/src/schematics/side-load/index.js.map +0 -1
- package/src/schematics/side-load/schema.json +0 -29
package/fesm2022/rxap-config.mjs
CHANGED
|
@@ -1,9 +1,68 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { Injectable, Inject, InjectionToken, Optional } from '@angular/core';
|
|
3
|
+
import { firstValueFrom } from 'rxjs';
|
|
4
4
|
import * as i1 from '@angular/common/http';
|
|
5
5
|
import { HttpClient } from '@angular/common/http';
|
|
6
6
|
import { finalize, share } from 'rxjs/operators';
|
|
7
|
+
import { SetToObject, getFromObject, deepMerge, coerceArray, SetObjectValue } from '@rxap/utilities';
|
|
8
|
+
|
|
9
|
+
class ConfigLoaderService {
|
|
10
|
+
constructor(http) {
|
|
11
|
+
this.http = http;
|
|
12
|
+
this.configs = new Map();
|
|
13
|
+
this.configLoading = new Map();
|
|
14
|
+
}
|
|
15
|
+
async load$(url) {
|
|
16
|
+
if (this.configs.has(url)) {
|
|
17
|
+
return this.configs.get(url);
|
|
18
|
+
}
|
|
19
|
+
if (this.configLoading.has(url)) {
|
|
20
|
+
return this.configLoading.get(url).toPromise();
|
|
21
|
+
}
|
|
22
|
+
const loading$ = this.http.get(url).pipe(finalize(() => this.configLoading.delete(url)), share());
|
|
23
|
+
this.configLoading.set(url, loading$);
|
|
24
|
+
return firstValueFrom(loading$);
|
|
25
|
+
}
|
|
26
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: ConfigLoaderService, deps: [{ token: HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
27
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: ConfigLoaderService, providedIn: 'root' }); }
|
|
28
|
+
}
|
|
29
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: ConfigLoaderService, decorators: [{
|
|
30
|
+
type: Injectable,
|
|
31
|
+
args: [{ providedIn: 'root' }]
|
|
32
|
+
}], ctorParameters: function () { return [{ type: i1.HttpClient, decorators: [{
|
|
33
|
+
type: Inject,
|
|
34
|
+
args: [HttpClient]
|
|
35
|
+
}] }]; } });
|
|
36
|
+
|
|
37
|
+
class ConfigTestingService {
|
|
38
|
+
constructor() {
|
|
39
|
+
this.config = {};
|
|
40
|
+
}
|
|
41
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
42
|
+
clearLocalConfig() {
|
|
43
|
+
}
|
|
44
|
+
set(propertyPath, value) {
|
|
45
|
+
SetToObject(this.config, propertyPath, value);
|
|
46
|
+
}
|
|
47
|
+
get(propertyPath, defaultValue) {
|
|
48
|
+
return getFromObject(this.config, propertyPath, defaultValue);
|
|
49
|
+
}
|
|
50
|
+
getOrThrow(propertyPath) {
|
|
51
|
+
const value = this.get(propertyPath);
|
|
52
|
+
if (value === undefined) {
|
|
53
|
+
throw new Error(`Could not find config in path '${propertyPath}'`);
|
|
54
|
+
}
|
|
55
|
+
return value;
|
|
56
|
+
}
|
|
57
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
58
|
+
setLocalConfig(config) {
|
|
59
|
+
}
|
|
60
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: ConfigTestingService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
61
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: ConfigTestingService }); }
|
|
62
|
+
}
|
|
63
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: ConfigTestingService, decorators: [{
|
|
64
|
+
type: Injectable
|
|
65
|
+
}] });
|
|
7
66
|
|
|
8
67
|
const RXAP_CONFIG = new InjectionToken('rxap/config');
|
|
9
68
|
|
|
@@ -21,7 +80,60 @@ class ConfigService {
|
|
|
21
80
|
*/
|
|
22
81
|
static { this.Overwrites = {}; }
|
|
23
82
|
static { this.LocalStorageKey = 'rxap/config/local-config'; }
|
|
24
|
-
|
|
83
|
+
/**
|
|
84
|
+
* @deprecated instead use the url property of the ConfigLoadOptions
|
|
85
|
+
*/
|
|
86
|
+
static { this.Urls = []; }
|
|
87
|
+
constructor(config = null) {
|
|
88
|
+
this.config = ConfigService.Config;
|
|
89
|
+
if (config) {
|
|
90
|
+
this.config = deepMerge(this.config ?? {}, config);
|
|
91
|
+
}
|
|
92
|
+
if (!this.config) {
|
|
93
|
+
throw new Error('config not available');
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Used to load the app config from a remote resource.
|
|
98
|
+
*
|
|
99
|
+
* Promise.all([ ConfigService.Load() ])
|
|
100
|
+
* .then(() => platformBrowserDynamic().bootstrapModule(AppModule))
|
|
101
|
+
* .catch(err => console.error(err))
|
|
102
|
+
*
|
|
103
|
+
*/
|
|
104
|
+
static async Load(options, environment) {
|
|
105
|
+
let config = deepMerge(this.Defaults, options?.static ?? {});
|
|
106
|
+
const urls = (options?.url ? coerceArray(options.url) : ConfigService.Urls).map(url => {
|
|
107
|
+
if (typeof url === 'function') {
|
|
108
|
+
if (!environment) {
|
|
109
|
+
throw new Error('environment is required when url is a function');
|
|
110
|
+
}
|
|
111
|
+
return coerceArray(url(environment));
|
|
112
|
+
}
|
|
113
|
+
return coerceArray(url);
|
|
114
|
+
}).flat();
|
|
115
|
+
for (const url of urls) {
|
|
116
|
+
config = deepMerge(config, await this.loadConfig(url, true, options?.schema));
|
|
117
|
+
}
|
|
118
|
+
config = deepMerge(config, this.Overwrites);
|
|
119
|
+
if (options?.fromLocalStorage !== false) {
|
|
120
|
+
const localConfig = localStorage.getItem(ConfigService.LocalStorageKey);
|
|
121
|
+
if (localConfig) {
|
|
122
|
+
try {
|
|
123
|
+
config = deepMerge(config, JSON.parse(localConfig));
|
|
124
|
+
}
|
|
125
|
+
catch (e) {
|
|
126
|
+
console.error('local config could not be parsed');
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
if (options?.fromUrlParam) {
|
|
131
|
+
const param = typeof options.fromUrlParam === 'string' ? options.fromUrlParam : 'config';
|
|
132
|
+
config = deepMerge(config, this.LoadConfigDefaultFromUrlParam(param));
|
|
133
|
+
}
|
|
134
|
+
console.debug('app config', config);
|
|
135
|
+
this.Config = config;
|
|
136
|
+
}
|
|
25
137
|
static async loadConfig(url, required, schema) {
|
|
26
138
|
let config;
|
|
27
139
|
let response;
|
|
@@ -39,6 +151,25 @@ class ConfigService {
|
|
|
39
151
|
return null;
|
|
40
152
|
}
|
|
41
153
|
}
|
|
154
|
+
if (!response.ok) {
|
|
155
|
+
let message = `Config request results in non ok response for '${url}': (${response.status}) ${response.statusText}`;
|
|
156
|
+
switch (response.status) {
|
|
157
|
+
case 404:
|
|
158
|
+
message = `Config not found at '${url}'`;
|
|
159
|
+
break;
|
|
160
|
+
case 405:
|
|
161
|
+
message = `Config service is not started yet. Wait 30s and try again.`;
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
if (required) {
|
|
165
|
+
this.showError(message);
|
|
166
|
+
throw new Error(message);
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
console.warn(message);
|
|
170
|
+
return null;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
42
173
|
try {
|
|
43
174
|
config = await response.json();
|
|
44
175
|
}
|
|
@@ -71,64 +202,6 @@ class ConfigService {
|
|
|
71
202
|
}
|
|
72
203
|
return config;
|
|
73
204
|
}
|
|
74
|
-
static showError(message) {
|
|
75
|
-
const hasUl = document.getElementById('rxap-config-error') !== null;
|
|
76
|
-
const ul = document.getElementById('rxap-config-error') ?? document.createElement('ul');
|
|
77
|
-
ul.id = 'rxap-config-error';
|
|
78
|
-
ul.style.position = 'fixed';
|
|
79
|
-
ul.style.bottom = '16px';
|
|
80
|
-
ul.style.right = '16px';
|
|
81
|
-
ul.style.backgroundColor = 'white';
|
|
82
|
-
ul.style.padding = '32px';
|
|
83
|
-
ul.style.zIndex = '99999999';
|
|
84
|
-
ul.style.color = 'black';
|
|
85
|
-
const li = document.createElement('li');
|
|
86
|
-
li.innerText = message;
|
|
87
|
-
ul.appendChild(li);
|
|
88
|
-
if (!hasUl) {
|
|
89
|
-
document.body.appendChild(ul);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
static async SideLoad(url, propertyPath, required, schema) {
|
|
93
|
-
if (!this.Config) {
|
|
94
|
-
throw new Error('Config side load is only possible after the initial config load.');
|
|
95
|
-
}
|
|
96
|
-
const config = await this.loadConfig(url, required, schema);
|
|
97
|
-
SetObjectValue(this.Config, propertyPath, config);
|
|
98
|
-
console.debug(`Side loaded config for '${propertyPath}' successful`, this.Config);
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Used to load the app config from a remote resource.
|
|
102
|
-
*
|
|
103
|
-
* Promise.all([ ConfigService.Load() ])
|
|
104
|
-
* .then(() => platformBrowserDynamic().bootstrapModule(AppModule))
|
|
105
|
-
* .catch(err => console.error(err))
|
|
106
|
-
*
|
|
107
|
-
*/
|
|
108
|
-
static async Load(options) {
|
|
109
|
-
let config = this.Defaults;
|
|
110
|
-
for (const url of ConfigService.Urls) {
|
|
111
|
-
config = await this.loadConfig(url, true, options?.schema);
|
|
112
|
-
}
|
|
113
|
-
config = deepMerge(config, this.Overwrites);
|
|
114
|
-
if (options?.fromLocalStorage !== false) {
|
|
115
|
-
const localConfig = localStorage.getItem(ConfigService.LocalStorageKey);
|
|
116
|
-
if (localConfig) {
|
|
117
|
-
try {
|
|
118
|
-
config = deepMerge(config, JSON.parse(localConfig));
|
|
119
|
-
}
|
|
120
|
-
catch (e) {
|
|
121
|
-
console.error('local config could not be parsed');
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
if (options?.fromUrlParam) {
|
|
126
|
-
const param = typeof options.fromUrlParam === 'string' ? options.fromUrlParam : 'config';
|
|
127
|
-
config = deepMerge(config, this.LoadConfigDefaultFromUrlParam(param));
|
|
128
|
-
}
|
|
129
|
-
console.debug('app config', config);
|
|
130
|
-
this.Config = config;
|
|
131
|
-
}
|
|
132
205
|
static LoadConfigDefaultFromUrlParam(param = 'config') {
|
|
133
206
|
const queryString = window.location.search;
|
|
134
207
|
const urlParams = new URLSearchParams(queryString);
|
|
@@ -148,6 +221,14 @@ class ConfigService {
|
|
|
148
221
|
}
|
|
149
222
|
return configFromParams;
|
|
150
223
|
}
|
|
224
|
+
static async SideLoad(url, propertyPath, required, schema) {
|
|
225
|
+
if (!this.Config) {
|
|
226
|
+
throw new Error('Config side load is only possible after the initial config load.');
|
|
227
|
+
}
|
|
228
|
+
const config = await this.loadConfig(url, required, schema);
|
|
229
|
+
SetObjectValue(this.Config, propertyPath, config);
|
|
230
|
+
console.debug(`Side loaded config for '${propertyPath}' successful`, this.Config);
|
|
231
|
+
}
|
|
151
232
|
static Get(path, defaultValue, config = this.Config) {
|
|
152
233
|
if (!config) {
|
|
153
234
|
throw new Error('config not loaded');
|
|
@@ -157,7 +238,8 @@ class ConfigService {
|
|
|
157
238
|
throw new Error('The config property path is not a string');
|
|
158
239
|
}
|
|
159
240
|
for (const fragment of path.split('.')) {
|
|
160
|
-
|
|
241
|
+
// eslint-disable-next-line no-prototype-builtins
|
|
242
|
+
if (configValue.hasOwnProperty(fragment)) {
|
|
161
243
|
configValue = configValue[fragment];
|
|
162
244
|
}
|
|
163
245
|
else {
|
|
@@ -170,14 +252,30 @@ class ConfigService {
|
|
|
170
252
|
}
|
|
171
253
|
return configValue;
|
|
172
254
|
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
255
|
+
static showError(message) {
|
|
256
|
+
const hasUl = document.getElementById('rxap-config-error') !== null;
|
|
257
|
+
const ul = document.getElementById('rxap-config-error') ?? document.createElement('ul');
|
|
258
|
+
ul.id = 'rxap-config-error';
|
|
259
|
+
ul.style.position = 'fixed';
|
|
260
|
+
ul.style.bottom = '16px';
|
|
261
|
+
ul.style.right = '16px';
|
|
262
|
+
ul.style.backgroundColor = 'white';
|
|
263
|
+
ul.style.padding = '32px';
|
|
264
|
+
ul.style.zIndex = '99999999';
|
|
265
|
+
ul.style.color = 'black';
|
|
266
|
+
const messageLi = document.createElement('li');
|
|
267
|
+
messageLi.innerText = message;
|
|
268
|
+
ul.appendChild(messageLi);
|
|
269
|
+
const refreshHintLi = document.createElement('li');
|
|
270
|
+
refreshHintLi.innerText = 'Please refresh the page to try again.';
|
|
271
|
+
ul.appendChild(refreshHintLi);
|
|
272
|
+
const autoRefreshHintLi = document.createElement('li');
|
|
273
|
+
autoRefreshHintLi.innerText = 'The page will refresh automatically in 30 seconds.';
|
|
274
|
+
ul.appendChild(autoRefreshHintLi);
|
|
275
|
+
if (!hasUl) {
|
|
276
|
+
document.body.appendChild(ul);
|
|
180
277
|
}
|
|
278
|
+
setTimeout(() => location.reload(), 30000);
|
|
181
279
|
}
|
|
182
280
|
setLocalConfig(config) {
|
|
183
281
|
localStorage.setItem(ConfigService.LocalStorageKey, JSON.stringify(config));
|
|
@@ -195,13 +293,13 @@ class ConfigService {
|
|
|
195
293
|
}
|
|
196
294
|
return value;
|
|
197
295
|
}
|
|
198
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.
|
|
199
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.
|
|
296
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: ConfigService, deps: [{ token: RXAP_CONFIG, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
297
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: ConfigService, providedIn: 'root' }); }
|
|
200
298
|
}
|
|
201
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.
|
|
299
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: ConfigService, decorators: [{
|
|
202
300
|
type: Injectable,
|
|
203
301
|
args: [{
|
|
204
|
-
providedIn: 'root'
|
|
302
|
+
providedIn: 'root',
|
|
205
303
|
}]
|
|
206
304
|
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
207
305
|
type: Optional
|
|
@@ -210,37 +308,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.2", ngImpor
|
|
|
210
308
|
args: [RXAP_CONFIG]
|
|
211
309
|
}] }]; } });
|
|
212
310
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
this.http = http;
|
|
216
|
-
this.configs = new Map();
|
|
217
|
-
this.configLoading = new Map();
|
|
218
|
-
}
|
|
219
|
-
async load$(url) {
|
|
220
|
-
if (this.configs.has(url)) {
|
|
221
|
-
return this.configs.get(url);
|
|
222
|
-
}
|
|
223
|
-
if (this.configLoading.has(url)) {
|
|
224
|
-
return this.configLoading.get(url).toPromise();
|
|
225
|
-
}
|
|
226
|
-
const loading$ = this.http.get(url).pipe(finalize(() => this.configLoading.delete(url)), share());
|
|
227
|
-
this.configLoading.set(url, loading$);
|
|
228
|
-
return loading$.toPromise();
|
|
229
|
-
}
|
|
230
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.2", ngImport: i0, type: ConfigLoaderService, deps: [{ token: HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
231
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.2", ngImport: i0, type: ConfigLoaderService, providedIn: 'root' }); }
|
|
232
|
-
}
|
|
233
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.2", ngImport: i0, type: ConfigLoaderService, decorators: [{
|
|
234
|
-
type: Injectable,
|
|
235
|
-
args: [{ providedIn: 'root' }]
|
|
236
|
-
}], ctorParameters: function () { return [{ type: i1.HttpClient, decorators: [{
|
|
237
|
-
type: Inject,
|
|
238
|
-
args: [HttpClient]
|
|
239
|
-
}] }]; } });
|
|
311
|
+
// region
|
|
312
|
+
// endregion
|
|
240
313
|
|
|
241
314
|
/**
|
|
242
315
|
* Generated bundle index. Do not edit.
|
|
243
316
|
*/
|
|
244
317
|
|
|
245
|
-
export { ConfigLoaderService, ConfigService, RXAP_CONFIG };
|
|
318
|
+
export { ConfigLoaderService, ConfigService, ConfigTestingService, RXAP_CONFIG };
|
|
246
319
|
//# sourceMappingURL=rxap-config.mjs.map
|
|
@@ -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';\nimport { AnySchema } from 'joi';\n\nexport interface ConfigLoadOptions {\n fromUrlParam?: string | boolean;\n fromLocalStorage?: boolean;\n schema?: AnySchema;\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 private static async loadConfig<T = any>(url: string, required?: boolean, schema?: AnySchema): Promise<T | null> {\n\n let config: any;\n let response: any;\n\n try {\n response = await fetch(url)\n } catch (error: any) {\n const message = `Could not fetch config from '${url}': ${error.message}`;\n if (required) {\n this.showError(message);\n throw new Error(message);\n } else {\n console.warn(message);\n return null;\n }\n }\n\n try {\n config = await response.json()\n } catch (error: any) {\n const message = `Could not parse config from '${url}' to a json object: ${error.message}`;\n if (required) {\n this.showError(message);\n throw new Error(message);\n } else {\n console.warn(message);\n return null;\n }\n }\n\n if (schema) {\n try {\n config = await schema.validateAsync(config);\n } catch (error: any) {\n const message = `Config from '${url}' is not valid: ${error.message}`;\n if (required) {\n this.showError(message);\n throw new Error(message);\n } else {\n console.warn(message);\n return null;\n }\n }\n }\n\n return config;\n\n }\n\n private static showError(message: string) {\n const hasUl = document.getElementById('rxap-config-error') !== null;\n const ul = document.getElementById('rxap-config-error') ?? document.createElement('ul');\n ul.id = 'rxap-config-error';\n ul.style.position = 'fixed';\n ul.style.bottom = '16px';\n ul.style.right = '16px';\n ul.style.backgroundColor = 'white';\n ul.style.padding = '32px';\n ul.style.zIndex = '99999999';\n ul.style.color = 'black';\n const li = document.createElement('li');\n li.innerText = message;\n ul.appendChild(li);\n if (!hasUl) {\n document.body.appendChild(ul);\n }\n }\n\n public static async SideLoad(url: string, propertyPath: string, required?: boolean, schema?: AnySchema): 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 const config = await this.loadConfig(url, required, schema);\n\n SetObjectValue(this.Config, propertyPath, config);\n\n console.debug(`Side loaded config for '${propertyPath}' successful`, 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 config = await this.loadConfig(url, true, options?.schema);\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 this.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;;ACiB3D,MAGa,aAAa,CAAA;aAEV,IAAM,CAAA,MAAA,GAAQ,IAAR,CAAa,EAAA;AAEjC;;;;AAIG;aACW,IAAQ,CAAA,QAAA,GAAQ,EAAR,CAAW,EAAA;AAEjC;;;AAGG;aACW,IAAU,CAAA,UAAA,GAAQ,EAAR,CAAW,EAAA;aAErB,IAAe,CAAA,eAAA,GAAG,0BAAH,CAA8B,EAAA;AAE7C,IAAA,SAAA,IAAA,CAAA,IAAI,GAAG,CAAE,aAAa,CAAE,CAAC,EAAA;IAE/B,aAAa,UAAU,CAAU,GAAW,EAAE,QAAkB,EAAE,MAAkB,EAAA;AAE1F,QAAA,IAAI,MAAW,CAAC;AAChB,QAAA,IAAI,QAAa,CAAC;QAElB,IAAI;AACF,YAAA,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,CAAA;AAC5B,SAAA;AAAC,QAAA,OAAO,KAAU,EAAE;YACnB,MAAM,OAAO,GAAG,CAAgC,6BAA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AAA,EAAA,CAAA,CAAA,EAAA;AANT,IAAA,SAAA,IAAA,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,EAAA;;2FACnB,mBAAmB,EAAA,UAAA,EAAA,CAAA;kBAD/B,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE,CAAA;;0BAO7B,MAAM;2BAAC,UAAU,CAAA;;;ACZtB;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"rxap-config.mjs","sources":["../../../../../packages/angular/config/src/lib/config-loader.service.ts","../../../../../packages/angular/config/src/lib/config-testing-service.ts","../../../../../packages/angular/config/src/lib/tokens.ts","../../../../../packages/angular/config/src/lib/config.service.ts","../../../../../packages/angular/config/src/index.ts","../../../../../packages/angular/config/src/rxap-config.ts"],"sourcesContent":["import {\n Inject,\n Injectable,\n} from '@angular/core';\nimport {\n firstValueFrom,\n Observable,\n} from 'rxjs';\nimport { HttpClient } from '@angular/common/http';\nimport {\n finalize,\n share,\n} 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\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 firstValueFrom(loading$);\n }\n}\n","import { Injectable } from '@angular/core';\nimport {\n getFromObject,\n SetToObject,\n} from '@rxap/utilities';\nimport { ConfigService } from './config.service';\n\n@Injectable()\nexport class ConfigTestingService implements ConfigService {\n readonly config: Record<string, any> = {};\n\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n clearLocalConfig(): void {\n }\n\n set<T>(propertyPath: string, value: T): void {\n SetToObject(this.config, propertyPath, value);\n }\n\n get<T>(propertyPath: string, defaultValue?: T): T | undefined {\n return getFromObject<T, T>(this.config, propertyPath, defaultValue);\n }\n\n getOrThrow<T>(propertyPath: string): T {\n const value = this.get<T>(propertyPath);\n if (value === undefined) {\n throw new Error(`Could not find config in path '${ propertyPath }'`);\n }\n return value;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n setLocalConfig(config: Record<string, any>): void {\n }\n}\n","import { InjectionToken } from '@angular/core';\n\nexport const RXAP_CONFIG = new InjectionToken('rxap/config');\n","import {\n Inject,\n Injectable,\n Optional,\n} from '@angular/core';\nimport { Environment } from '@rxap/environment';\nimport {\n coerceArray,\n deepMerge,\n SetObjectValue,\n} from '@rxap/utilities';\nimport { RXAP_CONFIG } from './tokens';\nimport { NoInferType } from './types';\n\nexport type AnySchema = { validateAsync: (...args: any[]) => any };\n\nexport interface ConfigLoadOptions {\n fromUrlParam?: string | boolean;\n fromLocalStorage?: boolean;\n schema?: AnySchema;\n url?: string | string[] | ((environment: Environment) => string | string[]);\n /**\n * static config values\n */\n static?: Record<string, any>;\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 /**\n * @deprecated instead use the url property of the ConfigLoadOptions\n */\n public static Urls = [];\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 /**\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, environment?: Environment): Promise<void> {\n let config = deepMerge(this.Defaults, options?.static ?? {});\n\n const urls = (options?.url ? coerceArray(options.url) : ConfigService.Urls).map(url => {\n if (typeof url === 'function') {\n if (!environment) {\n throw new Error('environment is required when url is a function');\n }\n return coerceArray(url(environment));\n }\n return coerceArray(url);\n }).flat();\n\n for (const url of urls) {\n config = deepMerge(config, await this.loadConfig(url, true, options?.schema));\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 this.Config = config;\n }\n\n private static async loadConfig<T = any>(url: string, required?: boolean, schema?: AnySchema): Promise<T | null> {\n\n let config: any;\n let response: any;\n\n try {\n response = await fetch(url);\n } catch (error: any) {\n const message = `Could not fetch config from '${ url }': ${ error.message }`;\n if (required) {\n this.showError(message);\n throw new Error(message);\n } else {\n console.warn(message);\n return null;\n }\n }\n\n if (!response.ok) {\n let message = `Config request results in non ok response for '${ url }': (${ response.status }) ${ response.statusText }`;\n switch (response.status) {\n case 404:\n message = `Config not found at '${ url }'`;\n break;\n case 405:\n message = `Config service is not started yet. Wait 30s and try again.`;\n break;\n }\n if (required) {\n this.showError(message);\n throw new Error(message);\n } else {\n console.warn(message);\n return null;\n }\n }\n\n try {\n config = await response.json();\n } catch (error: any) {\n const message = `Could not parse config from '${ url }' to a json object: ${ error.message }`;\n if (required) {\n this.showError(message);\n throw new Error(message);\n } else {\n console.warn(message);\n return null;\n }\n }\n\n if (schema) {\n try {\n config = await schema.validateAsync(config);\n } catch (error: any) {\n const message = `Config from '${ url }' is not valid: ${ error.message }`;\n if (required) {\n this.showError(message);\n throw new Error(message);\n } else {\n console.warn(message);\n return null;\n }\n }\n }\n\n return config;\n\n }\n\n private static LoadConfigDefaultFromUrlParam(param = '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 async SideLoad(\n url: string,\n propertyPath: string,\n required?: boolean,\n schema?: AnySchema,\n ): 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 const config = await this.loadConfig(url, required, schema);\n\n SetObjectValue(this.Config, propertyPath, config);\n\n console.debug(`Side loaded config for '${ propertyPath }' successful`, this.Config);\n\n }\n\n public static Get<T = any, K extends Record<string, any> = Record<string, any>>(\n path: string,\n defaultValue: T | undefined,\n config: Record<string, any>,\n ): T\n\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 // eslint-disable-next-line no-prototype-builtins\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 private static showError(message: string) {\n const hasUl = document.getElementById('rxap-config-error') !== null;\n const ul = document.getElementById('rxap-config-error') ?? document.createElement('ul');\n ul.id = 'rxap-config-error';\n ul.style.position = 'fixed';\n ul.style.bottom = '16px';\n ul.style.right = '16px';\n ul.style.backgroundColor = 'white';\n ul.style.padding = '32px';\n ul.style.zIndex = '99999999';\n ul.style.color = 'black';\n const messageLi = document.createElement('li');\n messageLi.innerText = message;\n ul.appendChild(messageLi);\n const refreshHintLi = document.createElement('li');\n refreshHintLi.innerText = 'Please refresh the page to try again.';\n ul.appendChild(refreshHintLi);\n const autoRefreshHintLi = document.createElement('li');\n autoRefreshHintLi.innerText = 'The page will refresh automatically in 30 seconds.';\n ul.appendChild(autoRefreshHintLi);\n if (!hasUl) {\n document.body.appendChild(ul);\n }\n setTimeout(() => location.reload(), 30000);\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","// region \nexport * from './lib/config-loader.service';\nexport * from './lib/config-testing-service';\nexport * from './lib/config.service';\nexport * from './lib/tokens';\nexport * from './lib/types';\n// endregion\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;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
import * as i0 from "@angular/core";
|
|
3
|
+
export declare class ConfigTestingService implements ConfigService {
|
|
4
|
+
readonly config: Record<string, any>;
|
|
5
|
+
clearLocalConfig(): void;
|
|
6
|
+
set<T>(propertyPath: string, value: T): void;
|
|
7
|
+
get<T>(propertyPath: string, defaultValue?: T): T | undefined;
|
|
8
|
+
getOrThrow<T>(propertyPath: string): T;
|
|
9
|
+
setLocalConfig(config: Record<string, any>): void;
|
|
10
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ConfigTestingService, never>;
|
|
11
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<ConfigTestingService>;
|
|
12
|
+
}
|
package/lib/config.service.d.ts
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
|
+
import { Environment } from '@rxap/environment';
|
|
1
2
|
import { NoInferType } from './types';
|
|
2
|
-
import { AnySchema } from 'joi';
|
|
3
3
|
import * as i0 from "@angular/core";
|
|
4
|
+
export type AnySchema = {
|
|
5
|
+
validateAsync: (...args: any[]) => any;
|
|
6
|
+
};
|
|
4
7
|
export interface ConfigLoadOptions {
|
|
5
8
|
fromUrlParam?: string | boolean;
|
|
6
9
|
fromLocalStorage?: boolean;
|
|
7
10
|
schema?: AnySchema;
|
|
11
|
+
url?: string | string[] | ((environment: Environment) => string | string[]);
|
|
12
|
+
/**
|
|
13
|
+
* static config values
|
|
14
|
+
*/
|
|
15
|
+
static?: Record<string, any>;
|
|
8
16
|
}
|
|
9
17
|
export declare class ConfigService<Config extends Record<string, any> = Record<string, any>> {
|
|
10
18
|
static Config: any;
|
|
@@ -20,10 +28,12 @@ export declare class ConfigService<Config extends Record<string, any> = Record<s
|
|
|
20
28
|
*/
|
|
21
29
|
static Overwrites: any;
|
|
22
30
|
static LocalStorageKey: string;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
static
|
|
31
|
+
/**
|
|
32
|
+
* @deprecated instead use the url property of the ConfigLoadOptions
|
|
33
|
+
*/
|
|
34
|
+
static Urls: never[];
|
|
35
|
+
readonly config: Config;
|
|
36
|
+
constructor(config?: any | null);
|
|
27
37
|
/**
|
|
28
38
|
* Used to load the app config from a remote resource.
|
|
29
39
|
*
|
|
@@ -32,11 +42,12 @@ export declare class ConfigService<Config extends Record<string, any> = Record<s
|
|
|
32
42
|
* .catch(err => console.error(err))
|
|
33
43
|
*
|
|
34
44
|
*/
|
|
35
|
-
static Load(options?: ConfigLoadOptions): Promise<void>;
|
|
45
|
+
static Load(options?: ConfigLoadOptions, environment?: Environment): Promise<void>;
|
|
46
|
+
private static loadConfig;
|
|
36
47
|
private static LoadConfigDefaultFromUrlParam;
|
|
48
|
+
static SideLoad(url: string, propertyPath: string, required?: boolean, schema?: AnySchema): Promise<void>;
|
|
37
49
|
static Get<T = any, K extends Record<string, any> = Record<string, any>>(path: string, defaultValue: T | undefined, config: Record<string, any>): T;
|
|
38
|
-
|
|
39
|
-
constructor(config?: any | null);
|
|
50
|
+
private static showError;
|
|
40
51
|
setLocalConfig(config: Config): void;
|
|
41
52
|
clearLocalConfig(): void;
|
|
42
53
|
get<T = any>(propertyPath: string): T | undefined;
|
package/package.json
CHANGED
|
@@ -1,52 +1,58 @@
|
|
|
1
1
|
{
|
|
2
|
+
"version": "16.0.0-dev.21",
|
|
2
3
|
"name": "@rxap/config",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
|
|
4
|
+
"description": "Simple config file manager for angular applications.",
|
|
5
|
+
"license": "GPL-3.0-or-later",
|
|
6
|
+
"dependencies": {
|
|
7
|
+
"tslib": "2.6.2"
|
|
8
|
+
},
|
|
9
|
+
"peerDependencies": {
|
|
10
|
+
"@angular/common": "^16.1.4",
|
|
11
|
+
"@angular/core": "^16.1.4",
|
|
12
|
+
"@rxap/environment": "^16.0.0-dev.18",
|
|
13
|
+
"@rxap/utilities": "^16.0.0-dev.23",
|
|
14
|
+
"rxjs": "^7.8.0"
|
|
15
|
+
},
|
|
16
|
+
"author": {
|
|
17
|
+
"name": "Merzough Münker",
|
|
18
|
+
"email": "mmuenker@digitaix.com"
|
|
19
|
+
},
|
|
14
20
|
"bugs": {
|
|
15
21
|
"url": "https://gitlab.com/rxap/packages/-/issues",
|
|
16
22
|
"email": "incoming+rxap-packages-14898188-issue-@incoming.gitlab.com"
|
|
17
23
|
},
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
},
|
|
29
|
-
"schematics": "./collection.json",
|
|
30
|
-
"ng-update": {
|
|
31
|
-
"migrations": "./migration.json",
|
|
24
|
+
"homepage": "https:/gitlab.com/rxap/packages/packages/angular/config",
|
|
25
|
+
"keywords": [
|
|
26
|
+
"angular",
|
|
27
|
+
"angular-config",
|
|
28
|
+
"config",
|
|
29
|
+
"ngx",
|
|
30
|
+
"packages",
|
|
31
|
+
"rxap"
|
|
32
|
+
],
|
|
33
|
+
"nx-migrations": {
|
|
32
34
|
"packageGroup": [
|
|
33
|
-
|
|
34
|
-
|
|
35
|
+
{
|
|
36
|
+
"package": "@rxap/environment",
|
|
37
|
+
"version": "16.0.0-dev.18"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"package": "@rxap/utilities",
|
|
41
|
+
"version": "16.0.0-dev.23"
|
|
42
|
+
}
|
|
35
43
|
]
|
|
36
44
|
},
|
|
37
45
|
"publishConfig": {
|
|
38
|
-
"
|
|
39
|
-
"
|
|
46
|
+
"access": "public",
|
|
47
|
+
"directory": "../../../dist/packages/angular/config"
|
|
40
48
|
},
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
"@rxap/schematics-ts-morph": "^16.0.0-dev.1",
|
|
46
|
-
"@rxap/schematics-utilities": "^16.0.0-dev.1",
|
|
47
|
-
"ts-morph": "^13.0.3",
|
|
48
|
-
"tslib": "^2.3.1"
|
|
49
|
+
"repository": {
|
|
50
|
+
"type": "git",
|
|
51
|
+
"url": "https://gitlab.com/rxap/packages.git",
|
|
52
|
+
"directory": "packages/angular/config"
|
|
49
53
|
},
|
|
54
|
+
"sideEffects": false,
|
|
55
|
+
"gitHead": "7d83c61e6ca182ff72370418155415d23855fd8c",
|
|
50
56
|
"module": "fesm2022/rxap-config.mjs",
|
|
51
57
|
"typings": "index.d.ts",
|
|
52
58
|
"exports": {
|
|
@@ -58,7 +64,7 @@
|
|
|
58
64
|
"esm2022": "./esm2022/rxap-config.mjs",
|
|
59
65
|
"esm": "./esm2022/rxap-config.mjs",
|
|
60
66
|
"default": "./fesm2022/rxap-config.mjs"
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
67
|
+
},
|
|
68
|
+
"./theme": "./theme.css"
|
|
69
|
+
}
|
|
70
|
+
}
|
package/theme.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.visible{visibility:visible}.static{position:static}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.sticky{position:sticky}.block{display:block}.inline{display:inline}.table{display:table}.contents{display:contents}.hidden{display:none}.capitalize{text-transform:capitalize}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}
|
package/collection.json
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"schematics": {
|
|
3
|
-
"ng-add": {
|
|
4
|
-
"description": "Setup the package @rxap/config for the workspace.",
|
|
5
|
-
"factory": "./src/schematics/ng-add/index",
|
|
6
|
-
"schema": "./src/schematics/ng-add/schema.json"
|
|
7
|
-
},
|
|
8
|
-
"side-load": {
|
|
9
|
-
"description": "Add a side load config to the project main file.",
|
|
10
|
-
"factory": "./src/schematics/side-load/index",
|
|
11
|
-
"schema": "./src/schematics/side-load/schema.json"
|
|
12
|
-
}
|
|
13
|
-
},
|
|
14
|
-
"$schema": "../../node_modules/@angular-devkit/schematics/collection-schema.json"
|
|
15
|
-
}
|
package/migration.json
DELETED