Skip to content

Commit

Permalink
Add JSON schema generation. (#358)
Browse files Browse the repository at this point in the history
* feat: Add JSON schema generation.

* fix: update schema generator

* chore: update schema generator

* Lockfile

* Ups typo

* feat: Omit unneeded CSS declaration properties in types.

* fix: Add base interface to DataFile type.

* test: Add JSON schema validation tests.

* No need to literal hack in ReducerPercentile

* Revert "No need to literal hack in ReducerPercentile"

This reverts commit 2627f46.

* Update schema generator

---------

Co-authored-by: Dominik Moritz <[email protected]>
  • Loading branch information
jheer and domoritz authored Apr 20, 2024
1 parent eccba17 commit ae7bca6
Show file tree
Hide file tree
Showing 8 changed files with 172 additions and 48 deletions.
143 changes: 114 additions & 29 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 9 additions & 3 deletions packages/spec/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,21 @@
},
"scripts": {
"prebuild": "rimraf dist && mkdir dist",
"build": "tsc && node ../../esbuild.js mosaic-spec",
"build": "npm run types && node ../../esbuild.js mosaic-spec",
"lint": "eslint src test",
"pretest": "tsc",
"types": "tsc -p tsconfig.json && npm run schema",
"schema": "ts-json-schema-generator -f tsconfig.json -p src/spec/Spec.ts -t Spec --no-type-check --no-ref-encode --functions hide > dist/mosaic-schema.json",
"pretest": "npm run prebuild && npm run types",
"test": "mocha 'test/**/*-test.js' && tsc -p jsconfig.json",
"prepublishOnly": "npm run test && npm run lint && npm run build"
},
"dependencies": {
"@uwdata/mosaic-core": "^0.7.1",
"@uwdata/mosaic-sql": "^0.7.0",
"@uwdata/vgplot": "^0.7.1"
"@uwdata/vgplot": "^0.7.1",
"ts-json-schema-generator": "^2.1.0"
},
"devDependencies": {
"ajv": "^8.12.0"
}
}
9 changes: 9 additions & 0 deletions packages/spec/src/spec/CSSStyles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
type OmittedProperties =
| 'parentRule'
| 'getPropertyPriority'
| 'getPropertyValue'
| 'item'
| 'removeProperty'
| 'setProperty';

export type CSSStyles = Partial<Omit<CSSStyleDeclaration, OmittedProperties>>;
2 changes: 1 addition & 1 deletion packages/spec/src/spec/Data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export type DataArray = object[];
/**
* A data definition that loads an external data file.
*/
export interface DataFile {
export interface DataFile extends DataBaseOptions {
/**
* The data file to load. If no type option is provided,
* the file suffix must be one of `.csv`, `.json`, or `.parquet`.
Expand Down
Loading

0 comments on commit ae7bca6

Please sign in to comment.