geonetwork-ui 2.11.0-dev.0559cfd9d → 2.11.0-dev.05fe30eee

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 (34) hide show
  1. package/fesm2022/geonetwork-ui.mjs +373 -181
  2. package/fesm2022/geonetwork-ui.mjs.map +1 -1
  3. package/index.d.ts +74 -10
  4. package/index.d.ts.map +1 -1
  5. package/package.json +1 -1
  6. package/src/libs/api/repository/src/lib/gn4/gn4-repository.ts +78 -1
  7. package/src/libs/api/repository/src/lib/gn4/platform/gn4-platform.service.ts +11 -0
  8. package/src/libs/common/domain/src/lib/model/record/flags.model.ts +1 -0
  9. package/src/libs/common/domain/src/lib/model/record/index.ts +1 -0
  10. package/src/libs/common/domain/src/lib/platform.service.interface.ts +1 -0
  11. package/src/libs/common/domain/src/lib/repository/records-repository.interface.ts +19 -0
  12. package/src/libs/feature/editor/src/lib/components/record-form/form-field/form-field-constraints/form-field-constraints.component.ts +3 -5
  13. package/src/libs/feature/editor/src/lib/components/record-form/form-field/form-field-contacts/form-field-contacts.component.ts +2 -2
  14. package/src/libs/feature/editor/src/lib/components/record-form/form-field/form-field-record-flags/form-field-record-flag-component.css +0 -0
  15. package/src/libs/feature/editor/src/lib/components/record-form/form-field/form-field-record-flags/form-field-record-flag-component.html +18 -0
  16. package/src/libs/feature/editor/src/lib/components/record-form/form-field/form-field-record-flags/form-field-record-flag-component.ts +86 -0
  17. package/src/libs/feature/editor/src/lib/components/record-form/form-field/form-field.component.html +100 -88
  18. package/src/libs/feature/editor/src/lib/components/record-form/form-field/form-field.component.ts +11 -4
  19. package/src/libs/feature/editor/src/lib/components/record-form/record-form.component.ts +18 -4
  20. package/src/libs/feature/editor/src/lib/expressions.ts +67 -0
  21. package/src/libs/feature/editor/src/lib/fields.config.ts +13 -0
  22. package/src/libs/feature/editor/src/lib/models/editor-config.model.ts +10 -4
  23. package/src/libs/util/app-config/src/index.ts +1 -0
  24. package/src/libs/util/app-config/src/lib/app-config.ts +338 -284
  25. package/src/libs/util/app-config/src/lib/model.ts +17 -0
  26. package/src/libs/util/app-config/src/lib/parse-utils.ts +8 -4
  27. package/translations/de.json +4 -0
  28. package/translations/en.json +4 -0
  29. package/translations/es.json +4 -0
  30. package/translations/fr.json +4 -0
  31. package/translations/it.json +4 -0
  32. package/translations/nl.json +4 -0
  33. package/translations/pt.json +4 -0
  34. package/translations/sk.json +4 -0
@@ -8,6 +8,9 @@ import {
8
8
  parseTranslationsConfigSection,
9
9
  } from './parse-utils'
10
10
  import {
11
+ AppConfig,
12
+ ConfigIssues,
13
+ ConfigSectionName,
11
14
  CustomTranslations,
12
15
  CustomTranslationsAllLanguages,
13
16
  EditorConfig,
@@ -84,7 +87,319 @@ export function getCustomTranslations(langCode: string): CustomTranslations {
84
87
 
85
88
  let appConfigLoaded = false
86
89
 
87
- export function loadAppConfig(configUrl = 'assets/configuration/default.toml') {
90
+ function parseGlobalSection(
91
+ parsed: Record<string, unknown>,
92
+ { warnings, errors }: ConfigIssues
93
+ ): GlobalConfig | null {
94
+ let parsedGlobalSection = parseConfigSection(
95
+ parsed,
96
+ 'global',
97
+ ['geonetwork4_api_url'],
98
+ [
99
+ 'datahub_url',
100
+ 'edit_url_template',
101
+ 'proxy_path',
102
+ 'metadata_language',
103
+ 'login_url',
104
+ 'logout_url',
105
+ 'settings_url',
106
+ 'web_component_embedder_url',
107
+ 'languages',
108
+ 'contact_email',
109
+ 'reuse_form_url',
110
+ ],
111
+ warnings,
112
+ errors
113
+ )
114
+ if (parsedGlobalSection?.metadata_language) {
115
+ parsedGlobalSection = checkMetadataLanguage(parsedGlobalSection, warnings)
116
+ }
117
+ return parsedGlobalSection === null
118
+ ? null
119
+ : ({
120
+ GN4_API_URL: parsedGlobalSection.geonetwork4_api_url,
121
+ DATAHUB_URL: parsedGlobalSection.datahub_url,
122
+ EDIT_URL_TEMPLATE: parsedGlobalSection.edit_url_template,
123
+ PROXY_PATH: parsedGlobalSection.proxy_path,
124
+ METADATA_LANGUAGE: parsedGlobalSection.metadata_language
125
+ ? (parsedGlobalSection.metadata_language as string).toLowerCase()
126
+ : undefined,
127
+ LOGIN_URL: parsedGlobalSection.login_url,
128
+ LOGOUT_URL: parsedGlobalSection.logout_url,
129
+ SETTINGS_URL: parsedGlobalSection.settings_url,
130
+ WEB_COMPONENT_EMBEDDER_URL:
131
+ parsedGlobalSection.web_component_embedder_url,
132
+ LANGUAGES: parsedGlobalSection.languages,
133
+ CONTACT_EMAIL: parsedGlobalSection.contact_email,
134
+ REUSE_FORM_URL: parsedGlobalSection.reuse_form_url,
135
+ } as GlobalConfig)
136
+ }
137
+
138
+ function parseMapSection(
139
+ parsed: Record<string, unknown>,
140
+ { warnings, errors }: ConfigIssues
141
+ ): MapConfig | null {
142
+ const parsedLayersSections = parseMultiConfigSection(
143
+ parsed,
144
+ 'map_layer',
145
+ ['type'],
146
+ ['name', 'url', 'data', 'styleUrl', 'accessToken'],
147
+ warnings,
148
+ errors
149
+ )
150
+ const parsedMapSection = parseConfigSection(
151
+ parsed,
152
+ 'map',
153
+ [],
154
+ [
155
+ 'max_zoom',
156
+ 'do_not_tile_wms',
157
+ 'max_extent',
158
+ 'max_feature_count',
159
+ 'baselayer',
160
+ 'do_not_use_default_basemap',
161
+ 'external_viewer_url_template',
162
+ 'external_viewer_open_new_tab',
163
+ ],
164
+ warnings,
165
+ errors
166
+ )
167
+ return parsedMapSection === null || parsedLayersSections === null
168
+ ? null
169
+ : ({
170
+ MAX_ZOOM: parsedMapSection.max_zoom,
171
+ DO_NOT_TILE_WMS: parsedMapSection.do_not_tile_wms,
172
+ MAX_EXTENT: parsedMapSection.max_extent,
173
+ MAX_FEATURE_COUNT: parsedMapSection.max_feature_count,
174
+ EXTERNAL_VIEWER_URL_TEMPLATE:
175
+ parsedMapSection.external_viewer_url_template,
176
+ EXTERNAL_VIEWER_OPEN_NEW_TAB:
177
+ parsedMapSection.external_viewer_open_new_tab,
178
+ DO_NOT_USE_DEFAULT_BASEMAP:
179
+ !!parsedMapSection.do_not_use_default_basemap,
180
+ MAP_LAYERS: parsedLayersSections.map(
181
+ (map_layer) =>
182
+ ({
183
+ TYPE: map_layer.type,
184
+ URL: map_layer.url,
185
+ NAME: map_layer.name,
186
+ DATA: map_layer.data,
187
+ STYLE_URL: map_layer.styleUrl,
188
+ ACCESS_TOKEN: map_layer.accessToken,
189
+ }) as LayerConfig
190
+ ),
191
+ } as MapConfig)
192
+ }
193
+
194
+ function parseThemeSection(
195
+ parsed: Record<string, unknown>,
196
+ { warnings, errors }: ConfigIssues
197
+ ): ThemeConfig | null {
198
+ const parsedThemeSection = parseConfigSection(
199
+ parsed,
200
+ 'theme',
201
+ ['primary_color', 'secondary_color', 'main_color', 'background_color'],
202
+ [
203
+ 'header_foreground_color',
204
+ 'main_font',
205
+ 'title_font',
206
+ 'fonts_stylesheet_url',
207
+ 'thumbnail_placeholder',
208
+ 'header_background',
209
+ 'favicon',
210
+ ],
211
+ warnings,
212
+ errors
213
+ )
214
+ return parsedThemeSection === null
215
+ ? null
216
+ : ({
217
+ PRIMARY_COLOR: parsedThemeSection.primary_color,
218
+ SECONDARY_COLOR: parsedThemeSection.secondary_color,
219
+ MAIN_COLOR: parsedThemeSection.main_color,
220
+ BACKGROUND_COLOR: parsedThemeSection.background_color,
221
+ HEADER_FOREGROUND_COLOR: parsedThemeSection.header_foreground_color,
222
+ THUMBNAIL_PLACEHOLDER: parsedThemeSection.thumbnail_placeholder,
223
+ HEADER_BACKGROUND: parsedThemeSection.header_background,
224
+ TITLE_FONT: parsedThemeSection.title_font,
225
+ MAIN_FONT: parsedThemeSection.main_font,
226
+ FONTS_STYLESHEET_URL: parsedThemeSection.fonts_stylesheet_url,
227
+ FAVICON: parsedThemeSection.favicon,
228
+ } as ThemeConfig)
229
+ }
230
+
231
+ function parseSearchSection(
232
+ parsed: Record<string, unknown>,
233
+ { warnings, errors }: ConfigIssues
234
+ ): SearchConfig | null {
235
+ const parsedSearchSection = parseConfigSection(
236
+ parsed,
237
+ 'search',
238
+ [],
239
+ [
240
+ 'record_kind_quick_filter',
241
+ 'filter_geometry_data',
242
+ 'filter_geometry_url',
243
+ 'do_not_use_default_search_preset',
244
+ 'search_preset',
245
+ 'advanced_filters',
246
+ 'limit',
247
+ 'spatial_extent_max_file_size',
248
+ 'geocoding_provider',
249
+ 'geocoding_provider_options',
250
+ 'geocoding_provider_labels',
251
+ ],
252
+ warnings,
253
+ errors
254
+ )
255
+ const parsedSearchParams = parseMultiConfigSection(
256
+ parsed,
257
+ 'search_preset',
258
+ ['name'],
259
+ ['sort', 'filters'],
260
+ warnings,
261
+ errors
262
+ )
263
+ const parsedCustomFilters = parseMultiConfigSection(
264
+ parsed,
265
+ 'custom_filter',
266
+ ['name', 'base_filter'],
267
+ ['exclude_values', 'include_values', 'label_key'],
268
+ warnings,
269
+ errors
270
+ )
271
+ const parsedGeocodingProviderLabels =
272
+ parsedSearchSection?.geocoding_provider_labels as
273
+ | Record<string, string>
274
+ | undefined
275
+ return parsedSearchSection === null
276
+ ? null
277
+ : ({
278
+ RECORD_KIND_QUICK_FILTER: parsedSearchSection.record_kind_quick_filter,
279
+ FILTER_GEOMETRY_DATA: parsedSearchSection.filter_geometry_data,
280
+ FILTER_GEOMETRY_URL: parsedSearchSection.filter_geometry_url,
281
+ DO_NOT_USE_DEFAULT_SEARCH_PRESET:
282
+ !!parsedSearchSection.do_not_use_default_search_preset,
283
+ SEARCH_PRESET: parsedSearchParams.map((param) => ({
284
+ sort: param.sort,
285
+ name: param.name,
286
+ filters: param.filters,
287
+ })),
288
+ ADVANCED_FILTERS: parsedSearchSection.advanced_filters,
289
+ CUSTOM_FILTERS: (parsedCustomFilters ?? []).map((customFilter) => ({
290
+ name: customFilter.name,
291
+ baseFilter: customFilter.base_filter,
292
+ excludeValues: customFilter.exclude_values,
293
+ includeValues: customFilter.include_values,
294
+ labelKey: customFilter.label_key,
295
+ })),
296
+ LIMIT: parsedSearchSection.limit,
297
+ SPATIAL_EXTENT_MAX_FILE_SIZE:
298
+ parsedSearchSection.spatial_extent_max_file_size,
299
+ GEOCODING_PROVIDER: parsedSearchSection.geocoding_provider,
300
+ GEOCODING_PROVIDER_OPTIONS:
301
+ parsedSearchSection.geocoding_provider_options,
302
+ GEOCODING_PROVIDER_LABELS: parsedGeocodingProviderLabels
303
+ ? {
304
+ MAIN: parsedGeocodingProviderLabels.main,
305
+ SECONDARY: parsedGeocodingProviderLabels.secondary,
306
+ TERTIARY: parsedGeocodingProviderLabels.tertiary,
307
+ }
308
+ : undefined,
309
+ } as SearchConfig)
310
+ }
311
+
312
+ function parseMetadataQualitySection(
313
+ parsed: Record<string, unknown>,
314
+ { warnings, errors }: ConfigIssues
315
+ ): MetadataQualityConfig | null {
316
+ const parsedMetadataQualitySection = parseConfigSection(
317
+ parsed,
318
+ 'metadata-quality',
319
+ [],
320
+ ['enabled'],
321
+ warnings,
322
+ errors
323
+ )
324
+ return parsedMetadataQualitySection === null
325
+ ? null
326
+ : ({
327
+ ENABLED: parsedMetadataQualitySection.enabled,
328
+ SORTABLE: parsedMetadataQualitySection.sortable,
329
+ } as MetadataQualityConfig)
330
+ }
331
+
332
+ function parseEditingSection(
333
+ parsed: Record<string, unknown>,
334
+ { warnings, errors }: ConfigIssues
335
+ ): EditorConfig | null {
336
+ let parsedEditingSection = parseConfigSection(
337
+ parsed,
338
+ 'editing',
339
+ [],
340
+ ['new_record_default_language', 'new_record_standard'],
341
+ warnings,
342
+ errors
343
+ )
344
+ if (
345
+ parsedEditingSection !== null &&
346
+ parsedEditingSection.new_record_default_language !== undefined
347
+ ) {
348
+ parsedEditingSection = checkNewRecordDefaultLanguage(
349
+ parsedEditingSection,
350
+ warnings
351
+ )
352
+ }
353
+ if (
354
+ parsedEditingSection !== null &&
355
+ parsedEditingSection.new_record_standard !== undefined
356
+ ) {
357
+ parsedEditingSection = checkNewRecordStandard(
358
+ parsedEditingSection,
359
+ warnings
360
+ )
361
+ }
362
+ return parsedEditingSection === null
363
+ ? null
364
+ : ({
365
+ NEW_RECORD_DEFAULT_LANGUAGE:
366
+ parsedEditingSection.new_record_default_language as
367
+ | string
368
+ | undefined,
369
+ NEW_RECORD_STANDARD: parsedEditingSection.new_record_standard as
370
+ | EditorConfig['NEW_RECORD_STANDARD']
371
+ | undefined,
372
+ } as EditorConfig)
373
+ }
374
+
375
+ const SECTION_PARSERS: {
376
+ [name in ConfigSectionName]: (
377
+ parsed: Record<string, unknown>,
378
+ issues: ConfigIssues
379
+ ) => AppConfig[name]
380
+ } = {
381
+ global: parseGlobalSection,
382
+ map: parseMapSection,
383
+ theme: parseThemeSection,
384
+ search: parseSearchSection,
385
+ metadataQuality: parseMetadataQualitySection,
386
+ editor: parseEditingSection,
387
+ translations: (parsed) =>
388
+ parseTranslationsConfigSection(
389
+ parsed,
390
+ 'translations'
391
+ ) as CustomTranslationsAllLanguages,
392
+ }
393
+
394
+ /**
395
+ * Loads the configuration file and stores the given sections (all by default);
396
+ * omitted sections are reset (their getters will throw or return null);
397
+ * resolves with the parsed configuration file, e.g. to read sections with a custom parser
398
+ */
399
+ export function loadAppConfig(
400
+ configUrl = 'assets/configuration/default.toml',
401
+ sections = Object.keys(SECTION_PARSERS) as ConfigSectionName[]
402
+ ): Promise<Record<string, unknown>> {
88
403
  console.log(
89
404
  `[geonetwork-ui] Loading application configuration from ${configUrl}`
90
405
  )
@@ -94,301 +409,36 @@ export function loadAppConfig(configUrl = 'assets/configuration/default.toml') {
94
409
  return resp.text()
95
410
  })
96
411
  .then((conf) => {
97
- let parsed
412
+ let parsed: Record<string, unknown>
98
413
  try {
99
- parsed = TOML.parse(conf, { joiner: '\n', bigint: false }) as any
414
+ parsed = TOML.parse(conf, { joiner: '\n', bigint: false })
100
415
  } catch (e: any) {
101
416
  throw new Error(
102
417
  `An error occurred when parsing the configuration file: ${e.message}`
103
418
  )
104
419
  }
105
- const errors = []
106
- const warnings = []
107
-
108
- let parsedGlobalSection = parseConfigSection(
109
- parsed,
110
- 'global',
111
- ['geonetwork4_api_url'],
112
- [
113
- 'datahub_url',
114
- 'edit_url_template',
115
- 'proxy_path',
116
- 'metadata_language',
117
- 'login_url',
118
- 'logout_url',
119
- 'settings_url',
120
- 'web_component_embedder_url',
121
- 'languages',
122
- 'contact_email',
123
- 'reuse_form_url',
124
- ],
125
- warnings,
126
- errors
127
- )
128
- if (parsedGlobalSection?.metadata_language) {
129
- parsedGlobalSection = checkMetadataLanguage(
130
- parsedGlobalSection,
131
- warnings
132
- )
133
- }
134
- globalConfig =
135
- parsedGlobalSection === null
136
- ? null
137
- : ({
138
- GN4_API_URL: parsedGlobalSection.geonetwork4_api_url,
139
- DATAHUB_URL: parsedGlobalSection.datahub_url,
140
- EDIT_URL_TEMPLATE: parsedGlobalSection.edit_url_template,
141
- PROXY_PATH: parsedGlobalSection.proxy_path,
142
- METADATA_LANGUAGE: parsedGlobalSection.metadata_language
143
- ? (
144
- parsedGlobalSection.metadata_language as string
145
- ).toLowerCase()
146
- : undefined,
147
- LOGIN_URL: parsedGlobalSection.login_url,
148
- LOGOUT_URL: parsedGlobalSection.logout_url,
149
- SETTINGS_URL: parsedGlobalSection.settings_url,
150
- WEB_COMPONENT_EMBEDDER_URL:
151
- parsedGlobalSection.web_component_embedder_url,
152
- LANGUAGES: parsedGlobalSection.languages,
153
- CONTACT_EMAIL: parsedGlobalSection.contact_email,
154
- REUSE_FORM_URL: parsedGlobalSection.reuse_form_url,
155
- } as GlobalConfig)
156
-
157
- const parsedLayersSections = parseMultiConfigSection(
158
- parsed,
159
- 'map_layer',
160
- ['type'],
161
- ['name', 'url', 'data', 'styleUrl', 'accessToken'],
162
- warnings,
163
- errors
164
- )
165
- const parsedMapSection = parseConfigSection(
166
- parsed,
167
- 'map',
168
- [],
169
- [
170
- 'max_zoom',
171
- 'do_not_tile_wms',
172
- 'max_extent',
173
- 'max_feature_count',
174
- 'baselayer',
175
- 'do_not_use_default_basemap',
176
- 'external_viewer_url_template',
177
- 'external_viewer_open_new_tab',
178
- ],
179
- warnings,
180
- errors
181
- )
182
- mapConfig =
183
- parsedMapSection === null || parsedLayersSections === null
184
- ? null
185
- : ({
186
- MAX_ZOOM: parsedMapSection.max_zoom,
187
- DO_NOT_TILE_WMS: parsedMapSection.do_not_tile_wms,
188
- MAX_EXTENT: parsedMapSection.max_extent,
189
- MAX_FEATURE_COUNT: parsedMapSection.max_feature_count,
190
- EXTERNAL_VIEWER_URL_TEMPLATE:
191
- parsedMapSection.external_viewer_url_template,
192
- EXTERNAL_VIEWER_OPEN_NEW_TAB:
193
- parsedMapSection.external_viewer_open_new_tab,
194
- DO_NOT_USE_DEFAULT_BASEMAP:
195
- !!parsedMapSection.do_not_use_default_basemap,
196
- MAP_LAYERS: parsedLayersSections.map(
197
- (map_layer) =>
198
- ({
199
- TYPE: map_layer.type,
200
- URL: map_layer.url,
201
- NAME: map_layer.name,
202
- DATA: map_layer.data,
203
- STYLE_URL: map_layer.styleUrl,
204
- ACCESS_TOKEN: map_layer.accessToken,
205
- }) as LayerConfig
206
- ),
207
- } as MapConfig)
208
-
209
- const parsedThemeSection = parseConfigSection(
210
- parsed,
211
- 'theme',
212
- ['primary_color', 'secondary_color', 'main_color', 'background_color'],
213
- [
214
- 'header_foreground_color',
215
- 'main_font',
216
- 'title_font',
217
- 'fonts_stylesheet_url',
218
- 'thumbnail_placeholder',
219
- 'header_background',
220
- 'favicon',
221
- ],
222
- warnings,
223
- errors
224
- )
225
- themeConfig =
226
- parsedThemeSection === null
227
- ? null
228
- : ({
229
- PRIMARY_COLOR: parsedThemeSection.primary_color,
230
- SECONDARY_COLOR: parsedThemeSection.secondary_color,
231
- MAIN_COLOR: parsedThemeSection.main_color,
232
- BACKGROUND_COLOR: parsedThemeSection.background_color,
233
- HEADER_FOREGROUND_COLOR:
234
- parsedThemeSection.header_foreground_color,
235
- THUMBNAIL_PLACEHOLDER: parsedThemeSection.thumbnail_placeholder,
236
- HEADER_BACKGROUND: parsedThemeSection.header_background,
237
- TITLE_FONT: parsedThemeSection.title_font,
238
- MAIN_FONT: parsedThemeSection.main_font,
239
- FONTS_STYLESHEET_URL: parsedThemeSection.fonts_stylesheet_url,
240
- FAVICON: parsedThemeSection.favicon,
241
- } as ThemeConfig)
242
-
243
- const parsedSearchSection = parseConfigSection(
244
- parsed,
245
- 'search',
246
- [],
247
- [
248
- 'record_kind_quick_filter',
249
- 'filter_geometry_data',
250
- 'filter_geometry_url',
251
- 'do_not_use_default_search_preset',
252
- 'search_preset',
253
- 'advanced_filters',
254
- 'limit',
255
- 'spatial_extent_max_file_size',
256
- 'geocoding_provider',
257
- 'geocoding_provider_options',
258
- 'geocoding_provider_labels',
259
- ],
260
- warnings,
261
- errors
262
- )
263
- const parsedSearchParams = parseMultiConfigSection(
264
- parsed,
265
- 'search_preset',
266
- ['name'],
267
- ['sort', 'filters'],
268
- warnings,
269
- errors
270
- )
271
- const parsedCustomFilters = parseMultiConfigSection(
272
- parsed,
273
- 'custom_filter',
274
- ['name', 'base_filter'],
275
- ['exclude_values', 'include_values', 'label_key'],
276
- warnings,
277
- errors
278
- )
279
- const parsedGeocodingProviderLabels =
280
- parsedSearchSection?.geocoding_provider_labels as
281
- | Record<string, string>
282
- | undefined
283
- searchConfig =
284
- parsedSearchSection === null
285
- ? null
286
- : ({
287
- RECORD_KIND_QUICK_FILTER:
288
- parsedSearchSection.record_kind_quick_filter,
289
- FILTER_GEOMETRY_DATA: parsedSearchSection.filter_geometry_data,
290
- FILTER_GEOMETRY_URL: parsedSearchSection.filter_geometry_url,
291
- DO_NOT_USE_DEFAULT_SEARCH_PRESET:
292
- !!parsedSearchSection.do_not_use_default_search_preset,
293
- SEARCH_PRESET: parsedSearchParams.map((param) => ({
294
- sort: param.sort,
295
- name: param.name,
296
- filters: param.filters,
297
- })),
298
- ADVANCED_FILTERS: parsedSearchSection.advanced_filters,
299
- CUSTOM_FILTERS: (parsedCustomFilters ?? []).map(
300
- (customFilter) => ({
301
- name: customFilter.name,
302
- baseFilter: customFilter.base_filter,
303
- excludeValues: customFilter.exclude_values,
304
- includeValues: customFilter.include_values,
305
- labelKey: customFilter.label_key,
306
- })
307
- ),
308
- LIMIT: parsedSearchSection.limit,
309
- SPATIAL_EXTENT_MAX_FILE_SIZE:
310
- parsedSearchSection.spatial_extent_max_file_size,
311
- GEOCODING_PROVIDER: parsedSearchSection.geocoding_provider,
312
- GEOCODING_PROVIDER_OPTIONS:
313
- parsedSearchSection.geocoding_provider_options,
314
- GEOCODING_PROVIDER_LABELS: parsedGeocodingProviderLabels
315
- ? {
316
- MAIN: parsedGeocodingProviderLabels.main,
317
- SECONDARY: parsedGeocodingProviderLabels.secondary,
318
- TERTIARY: parsedGeocodingProviderLabels.tertiary,
319
- }
320
- : undefined,
321
- } as SearchConfig)
322
-
323
- const parsedMetadataQualitySection = parseConfigSection(
324
- parsed,
325
- 'metadata-quality',
326
- [],
327
- ['enabled'],
328
- warnings,
329
- errors
330
- )
331
- metadataQualityConfig =
332
- parsedMetadataQualitySection === null
333
- ? null
334
- : ({
335
- ENABLED: parsedMetadataQualitySection.enabled,
336
- SORTABLE: parsedMetadataQualitySection.sortable,
337
- } as MetadataQualityConfig)
338
-
339
- let parsedEditingSection = parseConfigSection(
340
- parsed,
341
- 'editing',
342
- [],
343
- ['new_record_default_language', 'new_record_standard'],
344
- warnings,
345
- errors
346
- )
347
- if (
348
- parsedEditingSection !== null &&
349
- parsedEditingSection.new_record_default_language !== undefined
350
- ) {
351
- parsedEditingSection = checkNewRecordDefaultLanguage(
352
- parsedEditingSection,
353
- warnings
354
- )
355
- }
356
- if (
357
- parsedEditingSection !== null &&
358
- parsedEditingSection.new_record_standard !== undefined
359
- ) {
360
- parsedEditingSection = checkNewRecordStandard(
361
- parsedEditingSection,
362
- warnings
363
- )
364
- }
365
- editorConfig =
366
- parsedEditingSection === null
367
- ? null
368
- : ({
369
- NEW_RECORD_DEFAULT_LANGUAGE:
370
- parsedEditingSection.new_record_default_language as
371
- | string
372
- | undefined,
373
- NEW_RECORD_STANDARD: parsedEditingSection.new_record_standard as
374
- | EditorConfig['NEW_RECORD_STANDARD']
375
- | undefined,
376
- } as EditorConfig)
377
-
378
- customTranslations = parseTranslationsConfigSection(
379
- parsed,
380
- 'translations'
381
- ) as CustomTranslationsAllLanguages
420
+ const issues: ConfigIssues = { warnings: [], errors: [] }
421
+ const config = Object.fromEntries(
422
+ sections.map((name) => [name, SECTION_PARSERS[name](parsed, issues)])
423
+ ) as Partial<AppConfig>
382
424
 
383
- if (errors.length) {
425
+ if (issues.errors.length) {
384
426
  throw new Error(`One or more mandatory settings were missing from the configuration file.
385
- ${errors.join('\n')}`)
386
- } else if (warnings.length) {
427
+ ${issues.errors.join('\n')}`)
428
+ } else if (issues.warnings.length) {
387
429
  console.warn(`One or more unexpected settings were encountered in the configuration file.
388
- ${warnings.join('\n')}`)
430
+ ${issues.warnings.join('\n')}`)
389
431
  }
390
432
 
433
+ globalConfig = config.global ?? null
434
+ themeConfig = config.theme ?? null
435
+ mapConfig = config.map ?? null
436
+ searchConfig = config.search ?? null
437
+ metadataQualityConfig = config.metadataQuality ?? null
438
+ editorConfig = config.editor ?? null
439
+ customTranslations = config.translations ?? {}
391
440
  appConfigLoaded = true
441
+ return parsed
392
442
  })
393
443
  }
394
444
 
@@ -399,8 +449,12 @@ export function isConfigLoaded() {
399
449
  export function _reset() {
400
450
  globalConfig = null
401
451
  themeConfig = null
452
+ mapConfig = null
453
+ searchConfig = null
454
+ metadataQualityConfig = null
402
455
  editorConfig = null
403
456
  customTranslations = null
457
+ appConfigLoaded = false
404
458
  }
405
459
 
406
460
  export const TRANSLATE_WITH_OVERRIDES_CONFIG: TranslateModuleConfig = {
@@ -105,6 +105,23 @@ export type CustomTranslationsAllLanguages = {
105
105
  [lang: string]: CustomTranslations
106
106
  }
107
107
 
108
+ export interface ConfigIssues {
109
+ warnings: string[]
110
+ errors: string[]
111
+ }
112
+
113
+ export interface AppConfig {
114
+ global: GlobalConfig | null
115
+ theme: ThemeConfig | null
116
+ map: MapConfig | null
117
+ search: SearchConfig | null
118
+ metadataQuality: MetadataQualityConfig | null
119
+ editor: EditorConfig | null
120
+ translations: CustomTranslationsAllLanguages
121
+ }
122
+
123
+ export type ConfigSectionName = keyof AppConfig
124
+
108
125
  export interface SearchConfig {
109
126
  FILTER_GEOMETRY?: Geometry
110
127
  }