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

Add JSON schema generation. #358

Merged
merged 12 commits into from
Apr 20, 2024
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",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW this fails on a fresh clone of the repo bc the dist/ directory doesn't exist

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Yeah, this is still WIP, but also schema is not meant to typically be run in isolation; it's now tied in to both the prebuild and pretest hooks.

"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