Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export v8.json file as latest.json in dist folder #490

Merged
merged 6 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

### ✨ Features and improvements

- Add `latest.json` to dist folder to allow using the full version of the spec [#490](https://github.com/maplibre/maplibre-style-spec/pull/490)
- _...Add new stuff here..._

### 🐞 Bug fixes

- _...Add new stuff here..._

## 20.0.0
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"types": "./dist/index.d.ts",
"type": "module",
"scripts": {
"build": "rollup --configPlugin @rollup/plugin-typescript -c rollup.config.ts",
"build": "rollup --configPlugin @rollup/plugin-typescript -c rollup.config.ts && cp ./src/reference/v8.json ./dist/latest.json",
HarelM marked this conversation as resolved.
Show resolved Hide resolved
"generate-style-spec": "node --no-warnings --loader ts-node/esm build/generate-style-spec.ts",
"generate-typings": "node --no-warnings --loader ts-node/esm build/generate-typings.ts",
"test-build": "jest --selectProjects=build",
Expand Down
76 changes: 0 additions & 76 deletions src/migrate/v9.test.ts

This file was deleted.

27 changes: 0 additions & 27 deletions src/migrate/v9.ts

This file was deleted.

11 changes: 0 additions & 11 deletions src/validate/latest.ts

This file was deleted.

33 changes: 22 additions & 11 deletions src/validate/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,28 @@
'sprite': validateSprite,
};

// Main recursive validation function. Tracks:
//
// - key: string representing location of validation in style tree. Used only
// for more informative error reporting.
// - value: current value from style being evaluated. May be anything from a
// high level object that needs to be descended into deeper or a simple
// scalar value.
// - valueSpec: current spec being evaluated. Tracks value.
// - styleSpec: current full spec being evaluated.

export default function validate(options) {
/**

Check warning on line 55 in src/validate/validate.ts

View workflow job for this annotation

GitHub Actions / Code Hygiene

Missing JSDoc @param "options.key" declaration

Check warning on line 55 in src/validate/validate.ts

View workflow job for this annotation

GitHub Actions / Code Hygiene

Missing JSDoc @param "options.value" declaration

Check warning on line 55 in src/validate/validate.ts

View workflow job for this annotation

GitHub Actions / Code Hygiene

Missing JSDoc @param "options.valueSpec" declaration

Check warning on line 55 in src/validate/validate.ts

View workflow job for this annotation

GitHub Actions / Code Hygiene

Missing JSDoc @param "options.styleSpec" declaration

Check warning on line 55 in src/validate/validate.ts

View workflow job for this annotation

GitHub Actions / Code Hygiene

Missing JSDoc @param "options.validateSpec" declaration

Check warning on line 55 in src/validate/validate.ts

View workflow job for this annotation

GitHub Actions / Code Hygiene

Missing JSDoc @param "options.style" declaration

Check warning on line 55 in src/validate/validate.ts

View workflow job for this annotation

GitHub Actions / Code Hygiene

Missing JSDoc @param "options.objectElementValidators" declaration
* Main recursive validation function used internally.
* You should use `validateStyleMin` in the browser or `validateStyle` in node env.
* Tracks:
* - key: string representing location of validation in style tree. Used only
* for more informative error reporting.
* - value: current value from style being evaluated. May be anything from a
* high level object that needs to be descended into deeper or a simple
* scalar value.
* - valueSpec: current spec being evaluated. Tracks value.
* - styleSpec: current full spec being evaluated.
* @param options

Check warning on line 66 in src/validate/validate.ts

View workflow job for this annotation

GitHub Actions / Code Hygiene

Missing @param "options.key"

Check warning on line 66 in src/validate/validate.ts

View workflow job for this annotation

GitHub Actions / Code Hygiene

Missing @param "options.value"

Check warning on line 66 in src/validate/validate.ts

View workflow job for this annotation

GitHub Actions / Code Hygiene

Missing @param "options.valueSpec"

Check failure on line 66 in src/validate/validate.ts

View workflow job for this annotation

GitHub Actions / Code Hygiene

Trailing spaces not allowed
* @returns

Check failure on line 67 in src/validate/validate.ts

View workflow job for this annotation

GitHub Actions / Code Hygiene

Trailing spaces not allowed
*/
export default function validate(options: {
key: any,

Check failure on line 70 in src/validate/validate.ts

View workflow job for this annotation

GitHub Actions / Code Hygiene

Expected indentation of 4 spaces but found 8

Check failure on line 70 in src/validate/validate.ts

View workflow job for this annotation

GitHub Actions / Code Hygiene

Trailing spaces not allowed

Check failure on line 70 in src/validate/validate.ts

View workflow job for this annotation

GitHub Actions / Code Hygiene

Expected a semicolon
value: any;

Check failure on line 71 in src/validate/validate.ts

View workflow job for this annotation

GitHub Actions / Code Hygiene

Expected indentation of 4 spaces but found 8

Check failure on line 71 in src/validate/validate.ts

View workflow job for this annotation

GitHub Actions / Code Hygiene

Trailing spaces not allowed
valueSpec: any;

Check failure on line 72 in src/validate/validate.ts

View workflow job for this annotation

GitHub Actions / Code Hygiene

Expected indentation of 4 spaces but found 8

Check failure on line 72 in src/validate/validate.ts

View workflow job for this annotation

GitHub Actions / Code Hygiene

Trailing spaces not allowed
styleSpec: any,

Check failure on line 73 in src/validate/validate.ts

View workflow job for this annotation

GitHub Actions / Code Hygiene

Expected indentation of 4 spaces but found 8
validateSpec?: any,
style: any,
objectElementValidators?: any}) {
const value = options.value;
const valueSpec = options.valueSpec;
const styleSpec = options.styleSpec;
Expand Down
2 changes: 1 addition & 1 deletion src/validate/validate_object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default function validateObject(options): Array<ValidationError> {
const style = options.style;
const styleSpec = options.styleSpec;
const validateSpec = options.validateSpec;
let errors = [] as Array<ValidationError>;
let errors: ValidationError[] = [];

const type = getType(object);
if (type !== 'object') {
Expand Down
26 changes: 12 additions & 14 deletions src/validate_style.min.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,26 @@ import validateLayer from './validate/validate_layer';
import validateFilter from './validate/validate_filter';
import validatePaintProperty from './validate/validate_paint_property';
import validateLayoutProperty from './validate/validate_layout_property';
import type {StyleSpecification} from './types.g';
import validateSprite from './validate/validate_sprite';
import validateGlyphsUrl from './validate/validate_glyphs_url';
import ValidationError from './error/validation_error';
import type {StyleSpecification} from './types.g';

/**
* Validate a MapLibre style against the style specification. This entrypoint,
* `maplibre-gl-style-spec/lib/validate_style.min`, is designed to produce as
* small a browserify bundle as possible by omitting unnecessary functionality
* and legacy style specifications.
*
* @private
* @param {Object} style The style to be validated.
* @param {Object} [styleSpec] The style specification to validate against.
* Validate a MapLibre style against the style specification.
* Use this when running in the browser.
*
* @param style - The style to be validated.
* @param styleSpec - The style specification to validate against.
* If omitted, the latest style spec is used.
* @returns {Array<ValidationError>}
* @returns an array of errors, or an empty array if no errors are found.
* @example
* var validate = require('maplibre-gl-style-spec/lib/validate_style.min');
* var errors = validate(style);
* const validate = require('@maplibre/maplibre-gl-style-spec/').validateStyleMin;
* const errors = validate(style);
*/
function validateStyleMin(style: StyleSpecification, styleSpec = latestStyleSpec) {
function validateStyleMin(style: StyleSpecification, styleSpec = latestStyleSpec): Array<ValidationError> {

let errors = [];
let errors: ValidationError[] = [];

errors = errors.concat(validate({
key: '',
Expand Down
20 changes: 9 additions & 11 deletions src/validate_style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,17 @@ import readStyle from './read_style';
import type {StyleSpecification} from './types.g';

/**
* Validate a Mapbox GL style against the style specification.
* Validate a Maplibre GL style against the style specification.
neodescis marked this conversation as resolved.
Show resolved Hide resolved
*
* @private
* @alias validate
* @param {StyleSpecification|string|Buffer} style The style to be validated. If a `String`
* or `Buffer` is provided, the returned errors will contain line numbers.
* @param {Object} [styleSpec] The style specification to validate against.
* If omitted, the spec version is inferred from the stylesheet.
* @returns {Array<ValidationError|ParsingError>}
* @param style - The style to be validated. If a `String` or `Buffer` is provided,
* the returned errors will contain line numbers.
* @param styleSpec - The style specification to validate against.
* If omitted, the spec version is inferred from the stylesheet.
* @returns an array of errors, or an empty array if no errors are found.
* @example
* var validate = require('maplibre-gl-style-spec').validate;
* var style = fs.readFileSync('./style.json', 'utf8');
* var errors = validate(style);
* const validate = require('maplibre-gl-style-spec').validate;
* const style = fs.readFileSync('./style.json', 'utf8');
* const errors = validate(style);
*/

export default function validateStyle(style: StyleSpecification | string | Buffer, styleSpec = v8): Array<ValidationError> {
Expand Down
Loading