chore(schema): Add a belongsTo field in the schema.

The goal is to use this as a security measure, to check that the
updated properties belong the the "subject" when receiving sync
operations.
This commit is contained in:
Alexis Métaireau 2024-05-09 12:46:52 +02:00
parent 28a359e03f
commit 25ccdde0b0

View file

@ -1,22 +1,40 @@
import { translate } from './i18n.js'
// Possible impacts
// ['ui', 'data', 'limit-bounds', 'datalayer-index', 'remote-data', 'background' 'sync']
/**
* This SCHEMA defines metadata about properties.
*
* This is here in order to have a centered place where all properties are specified.
*
* Each property defines:
*
* - `type`: The type of the data
* - `impacts`: A list of impacts than happen when this property is updated, among
* 'ui', 'data', 'limit-bounds', 'datalayer-index', 'remote-data',
* 'background' 'sync'.
* - `belongsTo`: A list of conceptual objects this property belongs to, among
* 'map', 'feature', 'datalayer'.
*
* - Extra keys are being passed to the FormBuilder automatically.
*/
// This is sorted alphabetically
export const SCHEMA = {
browsable: {
impacts: ['ui'],
type: Boolean,
impacts: ['ui'],
belongsTo: ['datalayer'],
},
captionBar: {
type: Boolean,
impacts: ['ui'],
belongsTo: ['map'],
label: translate('Do you want to display a caption bar?'),
default: false,
},
captionControl: {
type: Boolean,
impacts: ['ui'],
belongsTo: ['map'],
nullable: true,
label: translate('Display the caption control'),
default: true,
@ -24,12 +42,14 @@ export const SCHEMA = {
captionMenus: {
type: Boolean,
impacts: ['ui'],
belongsTo: ['map'],
label: translate('Do you want to display caption menus?'),
default: true,
},
color: {
type: String,
impacts: ['data'],
belongsTo: ['map', 'datalayer', 'feature'],
handler: 'ColorPicker',
label: translate('color'),
helpEntries: 'colorValue',
@ -39,14 +59,17 @@ export const SCHEMA = {
choropleth: {
type: Object,
impacts: ['data'],
belongsTo: ['datalayer'],
},
cluster: {
type: Object,
impacts: ['data'],
belongsTo: ['datalayer'],
},
dashArray: {
type: String,
impacts: ['data'],
belongsTo: ['map', 'datalayer'],
label: translate('dash array'),
helpEntries: 'dashArray',
inheritable: true,
@ -54,6 +77,7 @@ export const SCHEMA = {
datalayersControl: {
type: Boolean,
impacts: ['ui'],
belongsTo: ['map'],
nullable: true,
handler: 'DataLayersControl',
label: translate('Display the data layers control'),
@ -62,6 +86,7 @@ export const SCHEMA = {
defaultView: {
type: String,
impacts: [], // no need to update the ui, only useful when loading the map
belongsTo: ['map'],
label: translate('Default view'),
choices: [
['center', translate('Saved center and zoom')],
@ -74,27 +99,32 @@ export const SCHEMA = {
description: {
type: 'Text',
impacts: ['ui'],
belongsTo: ['map', 'datalayer'],
label: translate('description'),
helpEntries: 'textFormatting',
},
displayOnLoad: {
type: Boolean,
impacts: [],
belongsTo: ['datalayer'], // XXX ?
},
displayPopupFooter: {
type: Boolean,
impacts: ['ui'],
belongsTo: ['map'], // XXX ?
label: translate('Do you want to display popup footer?'),
default: false,
},
easing: {
type: Boolean,
impacts: [],
belongsTo: ['feature'], // XXX ?
default: false,
},
editinosmControl: {
type: Boolean,
impacts: ['ui'],
belongsTo: ['map'],
nullable: true,
label: translate('Display the control to open OpenStreetMap editor'),
default: null,
@ -102,6 +132,7 @@ export const SCHEMA = {
embedControl: {
type: Boolean,
impacts: ['ui'],
belongsTo: ['map'],
nullable: true,
label: translate('Display the embed control'),
default: true,
@ -109,10 +140,12 @@ export const SCHEMA = {
facetKey: {
type: String,
impacts: ['ui'],
belongsTo: ['datalayer'],
},
fill: {
type: Boolean,
impacts: ['data'],
belongsTo: ['map', 'datalayer', 'feature'],
label: translate('fill'),
helpEntries: 'fill',
inheritable: true,
@ -121,6 +154,7 @@ export const SCHEMA = {
fillColor: {
type: String,
impacts: ['data'],
belongsTo: ['map', 'datalayer', 'feature'],
handler: 'ColorPicker',
label: translate('fill color'),
helpEntries: 'fillColor',
@ -129,6 +163,7 @@ export const SCHEMA = {
fillOpacity: {
type: Number,
impacts: ['data'],
belongsTo: ['map', 'datalayer', 'feature'],
min: 0.1,
max: 1,
step: 0.1,
@ -139,16 +174,19 @@ export const SCHEMA = {
filterKey: {
type: String,
impacts: [],
belongsTo: ['map', 'datalayer', 'feature'], // XXX ?
},
fromZoom: {
type: Number,
impacts: [], // not needed
belongsTo: ['map'], // XXX ?
label: translate('From zoom'),
helpText: translate('Optional.'),
},
fullscreenControl: {
type: Boolean,
impacts: ['ui'],
belongsTo: ['map'],
nullable: true,
label: translate('Display the fullscreen control'),
default: true,
@ -156,10 +194,12 @@ export const SCHEMA = {
heat: {
type: Object,
impacts: ['data'],
belongsTo: ['datalayer'],
},
iconClass: {
type: String,
impacts: ['data'],
belongsTo: ['map', 'datalayer', 'feature'],
label: translate('Icon shape'),
inheritable: true,
choices: [
@ -173,6 +213,7 @@ export const SCHEMA = {
iconOpacity: {
type: Number,
impacts: ['data'],
belongsTo: ['map', 'datalayer', 'feature'],
min: 0.1,
max: 1,
step: 0.1,
@ -183,6 +224,7 @@ export const SCHEMA = {
iconUrl: {
type: String,
impacts: ['data'],
belongsTo: ['map', 'datalayer', 'feature'],
handler: 'IconUrl',
label: translate('Icon symbol'),
inheritable: true,
@ -190,10 +232,12 @@ export const SCHEMA = {
inCaption: {
type: Boolean,
impacts: ['ui'],
belongsTo: [], // XXX ?
},
interactive: {
type: Boolean,
impacts: ['data'],
belongsTo: ['map', 'datalayer', 'feature'],
label: translate('Allow interactions'),
helpEntries: 'interactive',
inheritable: true,
@ -202,6 +246,7 @@ export const SCHEMA = {
labelDirection: {
type: String,
impacts: ['data'],
belongsTo: ['map', 'datalayer', 'feature'],
label: translate('Label direction'),
inheritable: true,
choices: [
@ -216,12 +261,14 @@ export const SCHEMA = {
labelInteractive: {
type: Boolean,
impacts: ['data'],
belongsTo: ['map', 'datalayer', 'feature'],
label: translate('Labels are clickable'),
inheritable: true,
},
labelKey: {
type: String,
impacts: ['data'],
belongsTo: ['map', 'datalayer', 'feature'], // XXX ?
helpEntries: 'labelKey',
placeholder: translate('Default: name'),
label: translate('Label key'),
@ -230,50 +277,59 @@ export const SCHEMA = {
licence: {
type: String,
impacts: ['ui'],
belongsTo: ['map', 'datalayer'], // XXX ?
label: translate('licence'),
},
limitBounds: {
type: Object,
impacts: ['limit-bounds'],
belongsTo: ['map'],
},
locateControl: {
type: Boolean,
impacts: ['ui'],
belongsTo: ['map'],
nullable: true,
label: translate('Display the locate control'),
},
longCredit: {
type: 'Text',
impacts: ['ui'],
belongsTo: ['map'],
label: translate('Long credits'),
helpEntries: ['longCredit', 'textFormatting'],
},
measureControl: {
type: Boolean,
impacts: ['ui'],
belongsTo: ['map'],
nullable: true,
label: translate('Display the measure control'),
},
miniMap: {
type: Boolean,
impacts: ['ui'],
belongsTo: ['map'],
label: translate('Do you want to display a minimap?'),
default: false,
},
moreControl: {
type: Boolean,
impacts: ['ui'],
belongsTo: ['map'],
label: translate('Do you want to display the «more» control?'),
default: true,
},
name: {
type: String,
impacts: ['ui', 'data'],
belongsTo: ['map', 'datalayer', 'feature'],
label: translate('name'),
},
onLoadPanel: {
type: String,
impacts: [], // This is what happens during the map instantiation
belongsTo: ['map'],
label: translate('Do you want to display a panel on load?'),
choices: [
['none', translate('None')],
@ -287,6 +343,7 @@ export const SCHEMA = {
opacity: {
type: Number,
impacts: ['data'],
belongsTo: ['map', 'datalayer', 'feature'],
min: 0.1,
max: 1,
step: 0.1,
@ -296,6 +353,8 @@ export const SCHEMA = {
},
outlink: {
type: String,
impacts: ['data'],
belongsTo: ['feature'],
label: translate('Link to…'),
helpEntries: 'outlink',
placeholder: 'http://...',
@ -303,7 +362,8 @@ export const SCHEMA = {
},
outlinkTarget: {
type: String,
impacts: [],
impacts: ['data'],
belongsTo: ['feature'],
label: translate('Open link in…'),
inheritable: true,
default: 'blank',
@ -316,22 +376,26 @@ export const SCHEMA = {
overlay: {
type: Object,
impacts: ['background'],
belongsTo: ['map'],
},
permanentCredit: {
type: 'Text',
impacts: ['ui'],
belongsTo: ['map'],
label: translate('Permanent credits'),
helpEntries: ['permanentCredit', 'textFormatting'],
},
permanentCreditBackground: {
type: Boolean,
impacts: ['ui'],
belongsTo: ['map'],
label: translate('Permanent credits background'),
default: true,
},
popupContentTemplate: {
type: 'Text',
impacts: [], // not needed
belongsTo: ['map', 'datalayer', 'feature'],
label: translate('Popup content template'),
helpEntries: ['dynamicProperties', 'textFormatting'],
placeholder: '# {name}',
@ -341,6 +405,7 @@ export const SCHEMA = {
popupShape: {
type: String,
impacts: [], // not needed
belongsTo: ['map', 'datalayer', 'feature'], // XXX ?
label: translate('Popup shape'),
inheritable: true,
choices: [
@ -353,6 +418,7 @@ export const SCHEMA = {
popupTemplate: {
type: String,
impacts: [], // not needed
belongsTo: ['map', 'datalayer', 'feature'], // XXX ?
label: translate('Popup content style'),
inheritable: true,
choices: [
@ -367,21 +433,25 @@ export const SCHEMA = {
remoteData: {
type: Object,
impacts: ['remote-data'],
belongsTo: ['datalayer'],
},
scaleControl: {
type: Boolean,
impacts: ['ui'],
belongsTo: ['map'],
label: translate('Do you want to display the scale control?'),
default: true,
},
scrollWheelZoom: {
type: Boolean,
impacts: ['ui'],
belongsTo: ['map'],
label: translate('Allow scroll wheel zoom?'),
},
searchControl: {
type: Boolean,
impacts: ['ui'],
belongsTo: ['map'],
nullable: true,
label: translate('Display the search control'),
default: true,
@ -389,28 +459,33 @@ export const SCHEMA = {
shortCredit: {
type: String,
impacts: ['ui'],
belongsTo: ['map'],
label: translate('Short credits'),
helpEntries: ['shortCredit', 'textFormatting'],
},
showLabel: {
type: Boolean,
impacts: ['data'],
belongsTo: ['map', 'datalayer', 'feature'],
nullable: true,
label: translate('Display label'),
inheritable: true,
default: false,
},
slideshow: {
belongsTo: ['map'],
type: Object,
impacts: ['ui'],
},
slugKey: {
type: String,
impacts: [],
belongsTo: ['map', 'datalayer', 'feature'], // XXX ?
},
smoothFactor: {
type: Number,
impacts: ['data'],
belongsTo: ['map', 'datalayer', 'feature'],
min: 0,
max: 10,
step: 0.5,
@ -422,16 +497,19 @@ export const SCHEMA = {
sortKey: {
type: String,
impacts: ['datalayer-index', 'data'],
belongsTo: ['map', 'datalayer'],
},
starControl: {
type: Boolean,
impacts: ['ui'],
belongsTo: ['map'],
nullable: true,
label: translate('Display the star map button'),
},
stroke: {
type: Boolean,
impacts: ['data'],
belongsTo: ['map', 'datalayer', 'feature'],
label: translate('stroke'),
helpEntries: 'stroke',
inheritable: true,
@ -440,6 +518,7 @@ export const SCHEMA = {
syncEnabled: {
type: Boolean,
impacts: ['sync', 'ui'],
belongsTo: ['map'],
label: translate('Enable real-time collaboration'),
helpEntries: 'sync',
default: false,
@ -447,26 +526,31 @@ export const SCHEMA = {
tilelayer: {
type: Object,
impacts: ['background'],
belongsTo: ['map'],
},
tilelayersControl: {
type: Boolean,
impacts: ['ui'],
belongsTo: ['map'],
nullable: true,
label: translate('Display the tile layers control'),
},
toZoom: {
type: Number,
impacts: [], // not needed
belongsTo: ['map'],
label: translate('To zoom'),
helpText: translate('Optional.'),
},
type: {
type: 'String',
impacts: ['data'],
belongsTo: [], // XXX ?
},
weight: {
type: Number,
impacts: ['data'],
belongsTo: ['feature'], // XXX ?,
min: 1,
max: 20,
step: 1,
@ -477,10 +561,12 @@ export const SCHEMA = {
zoom: {
type: Number,
impacts: [], // default zoom, doesn't need to be updated
belongsTo: ['map'],
},
zoomControl: {
type: Boolean,
impacts: ['ui'],
belongsTo: ['map'],
nullable: true,
label: translate('Display the zoom control'),
default: true,
@ -488,6 +574,7 @@ export const SCHEMA = {
zoomTo: {
type: Number,
impacts: [], // not need to update the view
belongsTo: ['map'],
placeholder: translate('Inherit'),
helpEntries: 'zoomTo',
label: translate('Default zoom level'),