Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
6bb780f
add global-state expression
zbigniewmatysek-tomtom Mar 11, 2025
b088f0e
self review
zbigniewmatysek-tomtom Mar 11, 2025
85616b8
Merge branch 'main' of github.com:tomtom-forks/maplibre-style-spec in…
zbigniewmatysek-tomtom Mar 11, 2025
c9724a6
code hygiene
zbigniewmatysek-tomtom Mar 11, 2025
c6034a0
add integration tests
zbigniewmatysek-tomtom Mar 12, 2025
bbb988c
add unit tests
zbigniewmatysek-tomtom Mar 12, 2025
7987b5c
update sdk-support
zbigniewmatysek-tomtom Mar 12, 2025
d2cd15f
use getOwn
zbigniewmatysek-tomtom Mar 12, 2025
2031d0e
add state root property
zbigniewmatysek-tomtom Mar 13, 2025
6af796a
state property validation
zbigniewmatysek-tomtom Mar 13, 2025
1dd679e
validate state keys existance when global-state is used
zbigniewmatysek-tomtom Mar 14, 2025
a776b4c
improve expression parsing
zbigniewmatysek-tomtom Mar 14, 2025
377cc6f
refactor
zbigniewmatysek-tomtom Mar 17, 2025
2c64ac7
temporarily build for testing purposes
zbigniewmatysek-tomtom Mar 17, 2025
dba4c4f
improve docs
zbigniewmatysek-tomtom Mar 18, 2025
cd861b9
schema support
zbigniewmatysek-tomtom Mar 27, 2025
7e70626
cleanout
zbigniewmatysek-tomtom Mar 27, 2025
b98c7bd
export schema validator
zbigniewmatysek-tomtom Mar 28, 2025
ed13aa9
minor fix
zbigniewmatysek-tomtom Mar 28, 2025
c0e90a3
cleanout
zbigniewmatysek-tomtom Mar 28, 2025
e476181
update types
zbigniewmatysek-tomtom Mar 28, 2025
cd68ddb
docs
zbigniewmatysek-tomtom Mar 31, 2025
3bc66a0
minor fixes
zbigniewmatysek-tomtom Mar 31, 2025
830552b
add schema ts types
zbigniewmatysek-tomtom Apr 1, 2025
915a264
cleanout
zbigniewmatysek-tomtom Apr 1, 2025
bdab151
fixes + increase test coverage
zbigniewmatysek-tomtom Apr 1, 2025
fe0fe42
review fixes
zbigniewmatysek-tomtom Apr 1, 2025
9dd0595
make default optional in the ts types
zbigniewmatysek-tomtom Apr 1, 2025
09f9767
docs update
zbigniewmatysek-tomtom Apr 1, 2025
5281217
docs fixes
zbigniewmatysek-tomtom Apr 1, 2025
6f3ffc8
review fixes
zbigniewmatysek-tomtom Apr 2, 2025
1dfc05f
minor fix
zbigniewmatysek-tomtom Apr 2, 2025
2ff83bc
Merge branch 'main' into NAV-171460-global-state-expression
zbigniewmatysek-tomtom Apr 2, 2025
3d356fb
review fixes
zbigniewmatysek-tomtom Apr 2, 2025
6300620
Merge branch 'NAV-171460-global-state-expression' of github.com:tomto…
zbigniewmatysek-tomtom Apr 2, 2025
7a26fe1
remove annotations section
zbigniewmatysek-tomtom Apr 2, 2025
81d498d
remove validation
zbigniewmatysek-tomtom Apr 16, 2025
9c042f5
Merge branch 'main' into NAV-171460-global-state-expression
zbigniewmatysek-tomtom Apr 16, 2025
c15c12e
cleanout
zbigniewmatysek-tomtom Apr 16, 2025
ba2a103
Merge branch 'NAV-171460-global-state-expression' of github.com:tomto…
zbigniewmatysek-tomtom Apr 16, 2025
4e591d2
add changelog
zbigniewmatysek-tomtom Apr 16, 2025
ce515fb
Review fix: update src/reference/v8.json
stanislawpuda-tomtom Apr 22, 2025
205d379
Review fix: update src/reference/v8.json
stanislawpuda-tomtom Apr 22, 2025
82b028d
Merge branch 'main' of https://github.com/tomtom-forks/maplibre-style…
stanislawpuda-tomtom Apr 22, 2025
2a27194
fix links
stanislawpuda-tomtom Apr 22, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions build/generate-docs.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import v8 from '../src/reference/v8.json' with { type: 'json' };
import fs from 'fs';
import jsonStringify from 'json-stringify-pretty-compact';
import { isFunction } from 'util';

Check failure on line 4 in build/generate-docs.ts

View workflow job for this annotation

GitHub Actions / Code Hygiene

There should be no space after '{'

Check warning on line 4 in build/generate-docs.ts

View workflow job for this annotation

GitHub Actions / Code Hygiene

'isFunction' is defined but never used

Check failure on line 4 in build/generate-docs.ts

View workflow job for this annotation

GitHub Actions / Code Hygiene

There should be no space before '}'

/**
* This script generates markdown documentation from the JSON schema.
Expand Down Expand Up @@ -517,6 +518,11 @@
fs.writeFileSync(`${BASE_PATH}/expressions.md`, content);
}

function createSchemaContent() {
const content = fs.readFileSync('build/schema.md', 'utf-8');
fs.writeFileSync(`${BASE_PATH}/schema.md`, content);
}

/**
* Creates the main topics markdown files.
*/
Expand All @@ -543,4 +549,5 @@
createLayersContent();
createSourcesContent();
createExpressionsContent();
createSchemaContent();
createMainTopics();
79 changes: 79 additions & 0 deletions build/schema.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Schema

The value for `state` properties. Defines the default state property value, and its type.

The schema definition follows a subset of [JSON Schema](https://json-schema.org/) but is more strict in terms of what properties are required.

## Data types

### enum


The `enum` keyword is used to restrict a value to a fixed set of values. It must be an array with at least one element, where each element is unique.

```json
{
"enum": ["red", "amber", "green"],
"default": "red"
}
```

### number

The `number` type is used for any numeric type, either integers or floating point numbers.

```json
{
"type": "number",
"minimum": 0, // optional
"maximum": 100, // optional
"default": 42
}
```

You can define range using optional `minimum` and `maximum` keywords. Range is inclusive.

### string

The `string` type is used for strings of text. It may contain Unicode characters.

```json
{
"type": "string",
"default": "Montréal"
}
```

### boolean

The `boolean` type matches only two special values: `true` and `false`.

```json
{
"type": "boolean",
"default": true
}
```

### array

Arrays are used for ordered elements. Type of items in an array is defined with required `items`. Allowed item types are all schema types.

```json
{
"type": "array",
"items": {
"type": "string"
},
"default": ["red", "amber", "green"]
}
```

## Default values

A default value is required for each data type and is defined with the `default` keyword. The value of the default will be validated against the data type during style validation.


## Annotations

The `title` and `description` keywords must be strings. A "title" will preferably be short, whereas a "description" will provide a more lengthy explanation of the purpose of the data described by the schema.
6 changes: 4 additions & 2 deletions src/reference/v8.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,13 @@
"state": {
"type": "state",
"default": {},
"doc": "The initial state of the style. This object is a set of key-value pairs. The state key must be a string. The value is a JSON Schema. Supported types are: number, boolean, string, array, enum. Property \"default\" is required. State values can be retrieved with the [`global-state`](https://maplibre.org/maplibre-style-spec/expressions/#global-state) expression.\n\nThis property is required if any layer uses the `global-state` expression.",
"doc": "The initial state of the style. This object where keys are property names and value a [`schema`](https://maplibre.org/maplibre-style-spec/schema) definition. State property value can be retrieved with the [`global-state`](https://maplibre.org/maplibre-style-spec/expressions/#global-state) expression.\n\n State is required when `global-state` is used in the style",
"example": {
"chargerType": {
"type": "array",
"items": "string",
"items": {
"type": "string"
},
"default": ["CCS", "CHAdeMO", "Type2"]
},
"minPreferredChargingSpeed": {
Expand Down
Loading