Skip to content

Commit

Permalink
Merge branch 'main' into layercontrol/feat/layer-config-styles
Browse files Browse the repository at this point in the history
  • Loading branch information
A-Behairi committed Jul 9, 2024
2 parents 53dcb2a + dcde0a8 commit 930a142
Show file tree
Hide file tree
Showing 5 changed files with 133 additions and 147 deletions.
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
"elements/timecontrol": "0.5.1",
"elements/jsonform": "0.8.1",
"elements/layout": "0.1.0",
"elements/storytelling": "1.0.5",
"elements/storytelling": "1.0.6",
"elements/geosearch": "0.1.2"
}
7 changes: 7 additions & 0 deletions elements/storytelling/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## [1.0.6](https://github.com/EOX-A/EOxElements/compare/storytelling-v1.0.5...storytelling-v1.0.6) (2024-07-09)


### Bug Fixes

* Validation for STAC layers ([#1080](https://github.com/EOX-A/EOxElements/issues/1080)) ([cc5f5db](https://github.com/EOX-A/EOxElements/commit/cc5f5dba3295c9e2ee80fa7877826818f555b754))

## [1.0.5](https://github.com/EOX-A/EOxElements/compare/storytelling-v1.0.4...storytelling-v1.0.5) (2024-06-21)


Expand Down
2 changes: 1 addition & 1 deletion elements/storytelling/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@eox/storytelling",
"version": "1.0.5",
"version": "1.0.6",
"type": "module",
"devDependencies": {
"@eox/eslint-config": "^1.0.0",
Expand Down
81 changes: 49 additions & 32 deletions elements/storytelling/src/helpers/validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,47 +14,64 @@ const basicHeroSchema = {
"data-parallax": joi.boolean().required(),
};

const basicLayerSchema = {
layers: joi.array().items(
joi
const basicLayerSchema = joi
.object({
type: joi.string().required(),
url: joi.string().when("type", {
is: "STAC",
then: joi.string().required(),
otherwise: joi.string().optional(),
}),
properties: joi
.object({
id: joi.string().required(),
})
.unknown()
.required(),
source: joi
.object({
type: joi.string().required(),
properties: joi
.object({
id: joi.string().required(),
})
.unknown()
.required(),
source: joi
.object({
type: joi.string().required(),
})
.unknown()
.required(),
})
.unknown()
.required()
),
};
.when("type", {
is: "STAC",
then: joi.optional(),
otherwise: joi.required(),
}),
})
.pattern(joi.string(), joi.any());

const groupLayerSchema = joi.object({
type: joi.string().valid("group", "Group"),
properties: joi
.object({
id: joi.string().required(),
})
.unknown()
.required(),
layers: basicLayerSchema,
});

// EOxMap validation schema
const eoxMapSchema = {
layers: joi
.alternatives()
.try(
basicLayerSchema.layers,
joi.array().items(
joi.object({
type: joi.string().valid("group", "Group"),
properties: joi
.object({
id: joi.string().required(),
})
.unknown()
.required(),
layers: basicLayerSchema.layers,
.array()
.items(
joi
.object()
.keys({
type: joi.string().required(),
})
)
.unknown()
.custom((value, helpers) => {
const { error } =
value.type === "Group"
? groupLayerSchema.validate(value)
: basicLayerSchema.validate(value);

if (error) return helpers.message(error.message);
return value;
}, "Custom validator for map schema.")
)
.optional(),
center: joi.array().items(joi.number()).min(2).max(2).optional(),
Expand Down
Loading

0 comments on commit 930a142

Please sign in to comment.