@opengeoweb/sigmet-airmet 9.32.1 → 9.34.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/README.md +7 -58
- package/index.esm.js +4288 -7618
- package/package.json +1 -1
- package/src/lib/AirmetDemo.stories.d.ts +3 -4
- package/src/lib/SigmetDemo.stories.d.ts +3 -4
- package/src/lib/components/MetInfoWrapper/utils.d.ts +1 -3
- package/src/lib/components/ProductForms/AirmetForm/AirmetForm.d.ts +3 -0
- package/src/lib/components/ProductForms/SigmetForm/SigmetForm.d.ts +3 -0
- package/src/lib/components/ProductList/ProductList.stories.d.ts +1 -0
- package/src/lib/utils/config/index.d.ts +0 -1
- package/src/lib/components/ConfigurationDemo/configurations.spec.d.ts +0 -1
- package/src/lib/utils/config/config.d.ts +0 -17
- package/src/lib/utils/config/config.spec.d.ts +0 -1
package/README.md
CHANGED
|
@@ -100,9 +100,7 @@ const Component = () => {
|
|
|
100
100
|
|
|
101
101
|
### Configuration
|
|
102
102
|
|
|
103
|
-
Every country has different rules for aviation so a configuration file is required to let the module work correctly. Airmet uses basic configuration which has been expanded for sigmet to contain more custom properties. The validation rules are stored in schema files following the conventions of https://json-schema.org/. The
|
|
104
|
-
|
|
105
|
-
Currently the validation is strict meaning that every missing or wrongly typed prop results in an error. All errors should be readable and give hints to the developer.
|
|
103
|
+
Every country has different rules for aviation so a configuration file is required to let the module work correctly. Airmet uses basic configuration which has been expanded for sigmet to contain more custom properties. The validation rules are stored in schema files following the conventions of https://json-schema.org/. The configuration file is fetched from the backend.
|
|
106
104
|
|
|
107
105
|
#### Configuration file location
|
|
108
106
|
|
|
@@ -111,30 +109,13 @@ These are the default configuration files for both products. They are being used
|
|
|
111
109
|
- airmet: `libs/sigmet-airmet/src/lib/utils/config/airmet.config.json`
|
|
112
110
|
- sigmet: `libs/sigmet-airmet/src/lib/utils/config/sigmet.config.json`
|
|
113
111
|
|
|
114
|
-
#### Configuration schema location
|
|
115
|
-
|
|
116
|
-
Schema files define all required properties and types for the configuration files. Sigmet and airmet share some properties, these can be found in `firArea.schema.json`.
|
|
117
|
-
|
|
118
|
-
- firArea.schema: `tools/build-static-schemas/firArea.schema.json`
|
|
119
|
-
Defines the shared properties and validations of sigmet and airmet.
|
|
120
|
-
- airmet.schema: `tools/build-static-schemas/airmet.schema.json`
|
|
121
|
-
Defines the airmet config validations. Airmet uses the firArea scheme and adds unique properties via the $merge prop: ```"$merge": {
|
|
122
|
-
"source": { "$ref": "firArea.schema.json" } ```
|
|
123
|
-
- sigmet.schema: `tools/build-static-schemas/sigmet.schema.json`
|
|
124
|
-
Defines the sigmet config validations. Sigmet uses the firArea scheme and adds unique properties via the $merge prop: ```"$merge": {
|
|
125
|
-
"source": { "$ref": "firArea.schema.json" } ```
|
|
126
|
-
|
|
127
|
-
These schema files are build using the schema building tool in tools/build-static-schemas/generateStaticSchemas.js, see tools/build-static-schemas/Readme.md
|
|
128
|
-
|
|
129
112
|
#### Configuration typescript types
|
|
130
113
|
|
|
131
114
|
The `SigmetConfig` and `AirmetConfig` types can be found in `libs/sigmet-airmet/src/lib/types.ts` and are leading in defining the configuration files.
|
|
132
115
|
|
|
133
116
|
#### Add a new configuration key
|
|
134
117
|
|
|
135
|
-
Follow these steps to add a new key to the configuration file.
|
|
136
|
-
|
|
137
|
-
**Note: Before being able to see your changes to the validation in storybook, ensure you compile the validation schemas as described in [tools/build-static-schemas/Readme.md**](https://gitlab.com/opengeoweb/opengeoweb/-/tree/master/tools/build-static-schemas)
|
|
118
|
+
Follow these steps to add a new key to the configuration file.
|
|
138
119
|
|
|
139
120
|
In this example, we're going to add a new property called `my_new_config`: an array with strings that is used by sigmet and airmet.
|
|
140
121
|
|
|
@@ -150,50 +131,18 @@ export type FIRArea = {
|
|
|
150
131
|
|
|
151
132
|
If you now run `nx typecheck sigmet-airmet` it will fail, and that's expected as we added a new required prop but we have not added it to our configs. We will fix this later
|
|
152
133
|
|
|
153
|
-
2. Add
|
|
154
|
-
|
|
155
|
-
```
|
|
156
|
-
"my_new_config": {
|
|
157
|
-
"type": "array",
|
|
158
|
-
"items": {
|
|
159
|
-
"type": "string"
|
|
160
|
-
},
|
|
161
|
-
"minItems": 1
|
|
162
|
-
}
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
2.1. Make the `my_new_config` prop also required by adding it to the `required` list:
|
|
166
|
-
|
|
167
|
-
```
|
|
168
|
-
"required": [
|
|
169
|
-
// ...other,
|
|
170
|
-
"units",
|
|
171
|
-
"my_new_config"
|
|
172
|
-
],
|
|
173
|
-
```
|
|
174
|
-
|
|
175
|
-
2.2 Time to test out the validations. First airmet, go to http://localhost:4400/?path=/story/demo-airmet--airmet-dialog-demo. We expect there to be an error since you added a new required property but the story is still working. The same goes for sigmet http://localhost:4400/?path=/story/demo-sigmet--sigmet-dialog-demo. This is because we are merging the firArea scheme, but this overwrites the required list. To fix this, open `tools/build-static-schemas/sigmet.schema.json` and add `my_new_config` to the required prop in the `fir_areas` key. Do the same in `tools/build-static-schemas/airmet.schema.json` Afterwards an error should show for both.
|
|
176
|
-
|
|
177
|
-
```
|
|
178
|
-
"required": [
|
|
179
|
-
// ...other,
|
|
180
|
-
"units",
|
|
181
|
-
"my_new_config"
|
|
182
|
-
],
|
|
183
|
-
```
|
|
184
|
-
|
|
185
|
-
3. Now we know the validations are working, it's time to add `my_new_config` to the configuration files. After this both stories of sigmet and airmet should work again without errors:
|
|
134
|
+
2. Add `my_new_config` to the configuration files. After this both stories of sigmet and airmet should work again without errors:
|
|
186
135
|
|
|
187
136
|
- inside `libs/sigmet-airmet/src/lib/utils/config/sigmet.config.json` add `"my_new_config": ["test"]`
|
|
188
137
|
- inside `libs/sigmet-airmet/src/lib/utils/config/airmet.config.json` add `"my_new_config": ["test"]`
|
|
189
138
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
139
|
+
3. Next fix the typescript errors. When running `nx typecheck sigmet-airmet` it will complain on missing props inside the `libs/sigmet-airmet/src/lib/components/ProductForms/utils.spec.tsx` test. Add the new config keys to config examples. After this typescript should be fixed. We will add tests later for this file when we want to use the new property.
|
|
140
|
+
|
|
141
|
+
4. Last but not least, don't forget to add the new keys in other configs (here and in opmet-backend).
|
|
193
142
|
|
|
194
143
|
#### Using a new configuration key
|
|
195
144
|
|
|
196
|
-
Every config key can be used throughout the aviationmodule. If
|
|
145
|
+
Every config key can be used throughout the aviationmodule. If we have a new property that we want to use, follow these steps.
|
|
197
146
|
|
|
198
147
|
1. Create a new method inside `libs/sigmet-airmet/src/lib/components/ProductForms/utils.tsx`. This method should have the config as param to extract the value to use inside the code. Afterwards add the tests in `libs/sigmet-airmet/src/lib/components/ProductForms/utils.spec.tsx`.
|
|
199
148
|
|