Skip to content

Embedded json schema #139

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

Merged
merged 29 commits into from
Apr 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
15b1562
Implement basic zoom; TODO: fix angle in skewT
Peter9192 Apr 11, 2025
4b9625c
Add logarithmic zoom for skew-T diagram; TODO: T calculations should …
Peter9192 Apr 11, 2025
89f028b
Fix skew-T lines responding to original extent instead of actual; now…
Peter9192 Apr 11, 2025
8e29a5a
Add panning effect, but it is stroboscopic and doesn't work for skewT…
Peter9192 Apr 11, 2025
53f2cb1
combine side-effects for both axes in a single callback
Peter9192 Apr 11, 2025
23f4dae
Merge remote-tracking branch 'origin/main' into pan-zoom
Peter9192 Apr 18, 2025
ca46f1f
Remove animationframe
Peter9192 Apr 18, 2025
8be9635
Use produce to update both scales in a single call
Peter9192 Apr 18, 2025
859557b
Don't update panstart; this fixes the jittering
Peter9192 Apr 18, 2025
9c32384
Also work in log space
Peter9192 Apr 18, 2025
d3fae43
Make consistent for x-direction
Peter9192 Apr 18, 2025
ea696fc
zoom towards cursor
Peter9192 Apr 18, 2025
b65f516
Add reset plot button
Peter9192 Apr 18, 2025
69e93d4
Thinner lines
Peter9192 Apr 18, 2025
1ca0f68
Higher resolution plot
Peter9192 Apr 18, 2025
8953c43
Round time to steps of 10 minutes
Peter9192 Apr 18, 2025
0d72ef1
Use runClass from package, skipping BMI altogher + rich metadata for …
Peter9192 Apr 18, 2025
d072e56
Fix hanging issue: wrap only once...
Peter9192 Apr 18, 2025
cd10da8
Make sure initial state is included in output
Peter9192 Apr 18, 2025
f085554
Reset pan/zoom when variable changes
Peter9192 Apr 18, 2025
202d144
formatting
Peter9192 Apr 18, 2025
1e1399a
Use output metadata in plot labels and variable pickers
Peter9192 Apr 18, 2025
eeb62df
ditch BMI
Peter9192 Apr 18, 2025
8e9dddf
Fix xlabel in timeseries plot; fix axes extent for non-time on x-axis
Peter9192 Apr 22, 2025
638ccfc
Remove config.JSON everywhere; only keep the embedded version
Peter9192 Apr 22, 2025
5faf60c
Change units to use superscript
Peter9192 Apr 22, 2025
8bb3259
Add `pnpx @classmodel/class schema` cli subcommand
sverhoeven Apr 24, 2025
0951d69
Merge remote-tracking branch 'origin/main' into embedded-json-schema
Peter9192 Apr 24, 2025
3904050
Update lockfile
Peter9192 Apr 24, 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
2 changes: 1 addition & 1 deletion apps/class-solid/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ This allows you to trigger tests from the [playwright ui](https://playwright.dev
An experiment can get started from a preset.

The presets are stored in the `src/lib/presets/` directory.
The format is JSON with content adhering to the [JSON schema](https://github.com/classmodel/class-web/blob/main/packages/class/src/config.json).
The format is JSON with content adhering to the [JSON schema](https://github.com/classmodel/class-web/blob/main/packages/class/src/config.ts).

The `src/lib/presets.ts` is used as an index of presets.
If you add a preset the `src/lib/presets.ts` file needs to be updated.
Expand Down
15 changes: 4 additions & 11 deletions packages/class/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ pnpx @classmodel/class run --output output.csv --format csv config.json

# To read from stdin use
cat config.json | pnpx @classmodel/class -

# To get the JSON schema of the config file use
pnpx @classmodel/class schema -o config.schema.json
```
If you do not have `pnpx` installed you can use `npx` instead.

Expand Down Expand Up @@ -70,20 +73,10 @@ This package is part of a [monorepo](https://github.com/classmodel/class-web) wi

### JSON schema

The Class model uses a JSON schema to validate the input configuration. The schema is defined in the `@classmodel/class` package and can be found at [src/config.json](https://github.com/classmodel/class-web/blob/main/packages/class/src/config.json) (in [repo](./src/config.json)). The schema is used to validate the input configuration and to generate a form to input the configuration.
The Class model uses a JSON schema to validate the input configuration. The schema is defined in the `@classmodel/class` package and can be found at [src/config.ts](https://github.com/classmodel/class-web/blob/main/packages/class/src/config.ts) (in [repo](./src/config.ts)). The schema is used to validate the input configuration and to generate a form to input the configuration.

The `src/config.ts` file contains the embedded JSON schema and its Typescript type definition.

<!-- When runnning `pnpm dev` or `pnpm build` the `src/config.ts` file is generated from the `src/config.json` file.

To manually generate the `src/config.ts` file run the following command:

```shell
pnpm json2ts
``` -->

At the moment you manually have to keep the `src/config.ts` file in sync with the `src/config.json` file. By copying the content over and updating the TypeScript Config type.

See the [form package](../form/README.md#json-schema) for additional keywords in the JSON schema.

#### Conditional properties
Expand Down
11 changes: 2 additions & 9 deletions packages/class/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"types": "./dist/config.d.ts"
}
},
"./config.json": "./dist/config.json",
"./config_utils": {
"import": {
"default": "./dist/config_utils.js",
Expand Down Expand Up @@ -54,23 +53,17 @@
"files": ["dist"],
"license": "GPL-3.0-only",
"scripts": {
"dev": "concurrently -n \"tsc,json2ts\" -c \"blue,green\" \"pnpm dev:tsc\" \"pnpm json2ts --watch\"",
"dev:tsc": "tsc --watch",
"build:tsc": "tsc",
"build:config": "cp src/config.json dist/config.json",
"build": "pnpm json2ts && pnpm build:tsc && pnpm build:config",
"dev": "tsc --watch",
"build": "tsc",
"prepack": "pnpm build",
"test": "tsx --test src/*.test.ts",
"typecheck": "tsc --noEmit",
"json2ts": "node scripts/json2ts.mjs",
"docs": "typedoc",
"clean": "rm -rf dist"
},
"bin": "./dist/cli.js",
"devDependencies": {
"@types/node": "^20.13.1",
"concurrently": "^9.0.1",
"json-schema-to-typescript": "^15.0.2",
"tsx": "^4.16.5",
"typedoc": "^0.26.10",
"typescript": "^5.3.3"
Expand Down
135 changes: 0 additions & 135 deletions packages/class/scripts/json2ts.mjs

This file was deleted.

14 changes: 14 additions & 0 deletions packages/class/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import { readFile, writeFile } from "node:fs/promises";
import { EOL } from "node:os";
import { Command, Option } from "@commander-js/extra-typings";
import { jsonSchemaOfConfig } from "./config.js";
import type { ClassOutput } from "./runner.js";
import { runClass } from "./runner.js";
import { parse } from "./validate.js";
Expand Down Expand Up @@ -142,6 +143,19 @@ function buildCommand() {
}
});

program
.command("schema")
.description("Print the JSON schema for the configuration file")
.option("-o, --output <output-file>", "Output file. Default is stdout", "-")
.action((options) => {
const output = JSON.stringify(jsonSchemaOfConfig, null, 2);
if (options.output === "-") {
console.log(output);
} else {
writeTextFile(output, options.output);
}
});

return program;
}

Expand Down
Loading