@chartguard/config-highcharts 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +26 -2
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +70 -0
- package/dist/index.js.map +1 -0
- package/package.json +39 -5
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ChartGuard contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,27 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @chartguard/config-highcharts
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Highcharts configuration validator. **Partial coverage**: a clean result means no confirmed error was found, not that the configuration is complete or correct (read `status`).
|
|
4
|
+
|
|
5
|
+
**Status:** pre-release (0.x). Coverage is partial, and the API and settings may still change between minor versions.
|
|
6
|
+
|
|
7
|
+
This package does **not** ship a schema derived from Highcharts. The Highcharts license does not clear redistributing option metadata derived from its declarations, so the full schema is generated on your machine from your own installed `highcharts`, under your own license.
|
|
8
|
+
|
|
9
|
+
## Two ways to validate
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { readFileSync } from "node:fs";
|
|
13
|
+
import { createValidator, validate } from "@chartguard/config-highcharts";
|
|
14
|
+
|
|
15
|
+
// 1. A small hand-written subset, always available.
|
|
16
|
+
validate(config);
|
|
17
|
+
|
|
18
|
+
// 2. The full option set of your installed version, from a locally generated schema artifact.
|
|
19
|
+
const validateFull = createValidator(JSON.parse(readFileSync(artifactPath, "utf8")));
|
|
20
|
+
validateFull(config, { libraryVersion: "13.1.1" });
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
`createValidator` throws for a malformed artifact or one generated for another library.
|
|
24
|
+
|
|
25
|
+
A series type added by a plugin is an unknown variant (a warning); describe it to have it checked: `createValidator(artifact, { extensions: [{ id: "flame3d", variants: { "highcharts.series": { flame3d: s.object({ depth: s.number() }) } } }] })` (`s` from `@chartguard/config-core`). A variant may extend a built-in series and add its own options (`{ flame3d: { extends: "line", schema: s.object({ depth: s.number() }) } }`); `chart.type: "flame3d"` then selects it for series without `type`. A built-in type cannot be replaced; a refused extension throws `ExtensionError`. A series without `type` is checked as the type the runtime gives it: `chart.type`, else `line` (the runtime's default); when `chart.type` cannot be read without running code, or names no known or described series type, the series is inconclusive (`CFG_AMBIGUOUS`), never checked against a guessed type.
|
|
26
|
+
|
|
27
|
+
Generate the artifact from your installed `highcharts` with `npx chartguard schema build --library highcharts` (or `buildLocalSchema` from `@chartguard/schema-generator`); it is written to `node_modules/.cache/chartguard/highcharts-<version>.json`, which `chartguard validate --library highcharts` reads. Inside the ChartGuard repository, `npm run build` writes it there too.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type Extension, type SchemaManifest } from '@chartguard/config-core';
|
|
2
|
+
import type { ConfigValidator, ValidationOptions, ValidationResult } from '@chartguard/core';
|
|
3
|
+
export { type Extension, ExtensionError } from '@chartguard/config-core';
|
|
4
|
+
/**
|
|
5
|
+
* The hand-written starter subset of the Highcharts options (partial coverage): no Highcharts-derived
|
|
6
|
+
* schema ships with this package. Union-typed fields stay open.
|
|
7
|
+
*/
|
|
8
|
+
export declare const manifest: SchemaManifest;
|
|
9
|
+
/** Validates Highcharts options against the curated subset `manifest`; `createValidator` checks the full schema. */
|
|
10
|
+
export declare function validate(input: unknown, options?: ValidationOptions): ValidationResult;
|
|
11
|
+
/**
|
|
12
|
+
* A validator for a schema artifact generated from the caller's own installed `highcharts`
|
|
13
|
+
* (`chartguard schema build --library highcharts`, written to `node_modules/.cache/chartguard/`). This package never ships a Highcharts-derived schema: the
|
|
14
|
+
* Highcharts license does not clear redistributing it (CG-01-05). `extensions` add plugin series to
|
|
15
|
+
* the `highcharts.series` registry (CG-02-05). Throws for a malformed artifact, one generated for
|
|
16
|
+
* another library, or a refused extension (`ExtensionError`).
|
|
17
|
+
*/
|
|
18
|
+
export declare function createValidator(artifact: unknown, { extensions }?: {
|
|
19
|
+
readonly extensions?: readonly Extension[];
|
|
20
|
+
}): ConfigValidator;
|
|
21
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,SAAS,EAGd,KAAK,cAAc,EAGnB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAE7F,OAAO,EAAE,KAAK,SAAS,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AA6BzE;;;GAGG;AACH,eAAO,MAAM,QAAQ,EAAE,cAqBtB,CAAC;AAEF,oHAAoH;AACpH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,gBAAgB,CAEtF;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC9B,QAAQ,EAAE,OAAO,EACjB,EAAE,UAAe,EAAE,GAAE;IAAE,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS,SAAS,EAAE,CAAA;CAAO,GACtE,eAAe,CAMjB"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { manifestFromArtifact, s, validateConfig, withExtensions } from '@chartguard/config-core';
|
|
2
|
+
export { ExtensionError } from '@chartguard/config-core';
|
|
3
|
+
/**
|
|
4
|
+
* Highcharts reads its options with `pick()`, which skips `null` like `undefined`
|
|
5
|
+
* (highcharts@13.1.1 highcharts.src.js `if (typeof arg !== 'undefined' && arg !== null) {`): a `null`
|
|
6
|
+
* option is unset, as in the generated schema. `title.text: null` is how a title is hidden (K12).
|
|
7
|
+
*/
|
|
8
|
+
const object = (properties) => ({
|
|
9
|
+
...s.object(properties),
|
|
10
|
+
nullAsAbsent: true
|
|
11
|
+
});
|
|
12
|
+
const toggle = object({ enabled: s.boolean() });
|
|
13
|
+
const text = object({ text: s.string() });
|
|
14
|
+
/**
|
|
15
|
+
* Union-typed upstream fields stay open in this hand-written subset: a hand-written union would be a
|
|
16
|
+
* guess narrower than the declarations and could reject valid configs. The generated schema
|
|
17
|
+
* (`createValidator`) checks them.
|
|
18
|
+
*/
|
|
19
|
+
const union = s.any;
|
|
20
|
+
const series = object({
|
|
21
|
+
type: s.string(),
|
|
22
|
+
name: s.string(),
|
|
23
|
+
data: s.array(s.any()),
|
|
24
|
+
color: union() // ColorString | GradientColorObject | PatternObject
|
|
25
|
+
});
|
|
26
|
+
/**
|
|
27
|
+
* The hand-written starter subset of the Highcharts options (partial coverage): no Highcharts-derived
|
|
28
|
+
* schema ships with this package. Union-typed fields stay open.
|
|
29
|
+
*/
|
|
30
|
+
export const manifest = {
|
|
31
|
+
library: 'highcharts',
|
|
32
|
+
version: '13.x (starter subset)',
|
|
33
|
+
coverage: 'partial',
|
|
34
|
+
source: 'manually curated; field types checked against highcharts@13.1.1 TypeScript declarations',
|
|
35
|
+
root: object({
|
|
36
|
+
chart: object({
|
|
37
|
+
type: s.string(),
|
|
38
|
+
height: union(), // number | string | null
|
|
39
|
+
width: union(), // number | string | null
|
|
40
|
+
zooming: s.any()
|
|
41
|
+
}),
|
|
42
|
+
title: text,
|
|
43
|
+
subtitle: text,
|
|
44
|
+
xAxis: union(), // XAxisOptions | XAxisOptions[]
|
|
45
|
+
yAxis: union(), // YAxisOptions | YAxisOptions[]
|
|
46
|
+
series: s.array(series),
|
|
47
|
+
legend: toggle,
|
|
48
|
+
credits: toggle,
|
|
49
|
+
tooltip: toggle
|
|
50
|
+
})
|
|
51
|
+
};
|
|
52
|
+
/** Validates Highcharts options against the curated subset `manifest`; `createValidator` checks the full schema. */
|
|
53
|
+
export function validate(input, options) {
|
|
54
|
+
return validateConfig(input, manifest, options);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* A validator for a schema artifact generated from the caller's own installed `highcharts`
|
|
58
|
+
* (`chartguard schema build --library highcharts`, written to `node_modules/.cache/chartguard/`). This package never ships a Highcharts-derived schema: the
|
|
59
|
+
* Highcharts license does not clear redistributing it (CG-01-05). `extensions` add plugin series to
|
|
60
|
+
* the `highcharts.series` registry (CG-02-05). Throws for a malformed artifact, one generated for
|
|
61
|
+
* another library, or a refused extension (`ExtensionError`).
|
|
62
|
+
*/
|
|
63
|
+
export function createValidator(artifact, { extensions = [] } = {}) {
|
|
64
|
+
const generated = manifestFromArtifact(artifact);
|
|
65
|
+
if (generated.library !== 'highcharts')
|
|
66
|
+
throw new Error(`Expected a highcharts schema artifact, got one for ${generated.library}.`);
|
|
67
|
+
const extended = extensions.length === 0 ? generated : withExtensions(generated, extensions);
|
|
68
|
+
return (input, options) => validateConfig(input, extended, options);
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,oBAAoB,EACpB,CAAC,EAED,cAAc,EACd,cAAc,EACd,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAAkB,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAEzE;;;;GAIG;AACH,MAAM,MAAM,GAAG,CAAC,UAA0C,EAA+B,EAAE,CAAC,CAAC;IAC5F,GAAG,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC;IACvB,YAAY,EAAE,IAAI;CAClB,CAAC,CAAC;AAEH,MAAM,MAAM,GAAG,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;AAChD,MAAM,IAAI,GAAG,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AAE1C;;;;GAIG;AACH,MAAM,KAAK,GAAG,CAAC,CAAC,GAAG,CAAC;AAEpB,MAAM,MAAM,GAAG,MAAM,CAAC;IACrB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;IACtB,KAAK,EAAE,KAAK,EAAE,CAAC,oDAAoD;CACnE,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAmB;IACvC,OAAO,EAAE,YAAY;IACrB,OAAO,EAAE,uBAAuB;IAChC,QAAQ,EAAE,SAA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C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,40 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
"name": "@chartguard/config-highcharts",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Highcharts configuration validator (partial, explicit coverage)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/dovicsin/chartguard.git",
|
|
10
|
+
"directory": "packages/config/highcharts"
|
|
11
|
+
},
|
|
12
|
+
"sideEffects": false,
|
|
13
|
+
"engines": {
|
|
14
|
+
"node": ">=22.12.0"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist/",
|
|
18
|
+
"README.md"
|
|
19
|
+
],
|
|
20
|
+
"main": "./dist/index.js",
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"types": "./dist/index.d.ts",
|
|
25
|
+
"import": "./dist/index.js",
|
|
26
|
+
"default": "./dist/index.js"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"scripts": {
|
|
30
|
+
"build": "tsc -b",
|
|
31
|
+
"test": "node --test tests/*.test.mjs"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@chartguard/core": "0.1.0",
|
|
35
|
+
"@chartguard/config-core": "0.1.0"
|
|
36
|
+
},
|
|
37
|
+
"publishConfig": {
|
|
38
|
+
"access": "public"
|
|
39
|
+
}
|
|
40
|
+
}
|