@wildwinter/toolkit 0.1.0 → 0.2.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/CHANGELOG.md +45 -0
- package/README.md +17 -2
- package/conformance/extensions/defaults.json +69 -0
- package/conformance/extensions/manifest.json +264 -0
- package/conformance/extensions/merge.json +154 -0
- package/conformance/extensions/values.json +96 -0
- package/dist/chunk-ONEAWPDZ.js +11 -0
- package/dist/chunk-ONEAWPDZ.js.map +1 -0
- package/dist/extensions.cjs +933 -0
- package/dist/extensions.cjs.map +1 -0
- package/dist/extensions.d.cts +313 -0
- package/dist/extensions.d.ts +313 -0
- package/dist/extensions.js +888 -0
- package/dist/extensions.js.map +1 -0
- package/dist/index.js +2 -6
- package/dist/index.js.map +1 -1
- package/extensions.md +189 -0
- package/package.json +29 -3
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
{
|
|
2
|
+
"about": "Value validation. A case gives a field declaration and a value (valueProblems), or a target and a node's entry (entryProblems), with the nodes that exist for references as kind:id. Paths are relative to the value or entry. A problem's severity is error unless the case says warning; `options` is checked where given.",
|
|
3
|
+
"cases": [
|
|
4
|
+
{ "name": "scalars that fit pass", "decl": { "name": "a", "type": "text" }, "value": "hello", "problems": [] },
|
|
5
|
+
{ "name": "multiline is text", "decl": { "name": "a", "type": "multiline" }, "value": "one\ntwo", "problems": [] },
|
|
6
|
+
{ "name": "text is not a number", "decl": { "name": "a", "type": "text" }, "value": 3,
|
|
7
|
+
"problems": [{ "path": "", "code": "wrong-type" }] },
|
|
8
|
+
{ "name": "a number within its range", "decl": { "name": "a", "type": "number", "min": 0, "max": 5 }, "value": 5, "problems": [] },
|
|
9
|
+
{ "name": "a number below its minimum", "decl": { "name": "a", "type": "number", "min": 0 }, "value": -1,
|
|
10
|
+
"problems": [{ "path": "", "code": "below-min" }] },
|
|
11
|
+
{ "name": "a number above its maximum", "decl": { "name": "a", "type": "number", "max": 5 }, "value": 6,
|
|
12
|
+
"problems": [{ "path": "", "code": "above-max" }] },
|
|
13
|
+
{ "name": "a boolean is not a string", "decl": { "name": "a", "type": "boolean" }, "value": "true",
|
|
14
|
+
"problems": [{ "path": "", "code": "wrong-type" }] },
|
|
15
|
+
{ "name": "an enum value", "decl": { "name": "a", "type": "enum", "values": ["x", "y"] }, "value": "y", "problems": [] },
|
|
16
|
+
{ "name": "an enum may be none chosen", "decl": { "name": "a", "type": "enum", "values": ["x", "y"] }, "value": "", "problems": [] },
|
|
17
|
+
{ "name": "an enum value that is not listed", "decl": { "name": "a", "type": "enum", "values": ["x", "y"] }, "value": "z",
|
|
18
|
+
"problems": [{ "path": "", "code": "not-a-value", "options": ["x", "y"] }] },
|
|
19
|
+
{ "name": "flags, a subset", "decl": { "name": "a", "type": "flags", "values": ["x", "y"] }, "value": ["y"], "problems": [] },
|
|
20
|
+
{ "name": "flags naming something unlisted", "decl": { "name": "a", "type": "flags", "values": ["x", "y"] }, "value": ["x", "q"],
|
|
21
|
+
"problems": [{ "path": "", "code": "not-a-value", "options": ["x", "y"] }] },
|
|
22
|
+
{ "name": "flags are a list", "decl": { "name": "a", "type": "flags", "values": ["x"] }, "value": "x",
|
|
23
|
+
"problems": [{ "path": "", "code": "wrong-type" }] },
|
|
24
|
+
{ "name": "a quality on a stage", "decl": { "name": "a", "type": "quality", "stages": ["p", "q", "r", "s"] }, "value": "q", "problems": [] },
|
|
25
|
+
{ "name": "a quality may not be none chosen", "decl": { "name": "a", "type": "quality", "stages": ["p", "q"] }, "value": "",
|
|
26
|
+
"problems": [{ "path": "", "code": "not-a-stage", "options": ["p", "q"] }] },
|
|
27
|
+
{ "name": "a stage that is gone offers the whole ladder", "decl": { "name": "a", "type": "quality", "stages": ["p", "q", "r", "s"] }, "value": "gone",
|
|
28
|
+
"problems": [{ "path": "", "code": "not-a-stage", "options": ["p", "q", "r", "s"] }] },
|
|
29
|
+
{ "name": "a renamed stage is a warning until the project takes the new name", "decl": { "name": "a", "type": "quality", "stages": ["p", "q"], "renamedStages": { "old": "q" } }, "value": "old",
|
|
30
|
+
"problems": [{ "path": "", "code": "renamed-stage", "severity": "warning", "options": ["q"] }] },
|
|
31
|
+
{ "name": "a reference to a node that exists", "decl": { "name": "a", "type": "reference", "to": "card" }, "value": "c_1",
|
|
32
|
+
"refs": ["card:c_1"], "problems": [] },
|
|
33
|
+
{ "name": "a reference to a node that does not", "decl": { "name": "a", "type": "reference", "to": "card" }, "value": "c_2",
|
|
34
|
+
"refs": ["card:c_1", "deck:c_2"], "problems": [{ "path": "", "code": "no-such-node" }] },
|
|
35
|
+
{ "name": "an empty reference names nothing and is allowed", "decl": { "name": "a", "type": "reference", "to": "card" }, "value": "",
|
|
36
|
+
"refs": [], "problems": [] },
|
|
37
|
+
{ "name": "a reference is a string", "decl": { "name": "a", "type": "reference", "to": "card" }, "value": 7,
|
|
38
|
+
"problems": [{ "path": "", "code": "wrong-type" }] },
|
|
39
|
+
{ "name": "references are not checked when the host gives no nodes", "decl": { "name": "a", "type": "reference", "to": "card" }, "value": "c_9",
|
|
40
|
+
"problems": [] },
|
|
41
|
+
{ "name": "a record, field by field",
|
|
42
|
+
"decl": { "name": "cue", "type": "record", "fields": [
|
|
43
|
+
{ "name": "sound", "type": "text", "required": true }, { "name": "gain", "type": "number", "max": 1 }, { "name": "at", "type": "reference", "to": "tag" }
|
|
44
|
+
] },
|
|
45
|
+
"value": { "gain": 2, "at": "v_x", "colour": "red" }, "refs": ["tag:v_y"],
|
|
46
|
+
"problems": [
|
|
47
|
+
{ "path": "sound", "code": "required" },
|
|
48
|
+
{ "path": "gain", "code": "above-max" },
|
|
49
|
+
{ "path": "at", "code": "no-such-node" },
|
|
50
|
+
{ "path": "colour", "code": "unknown-field", "severity": "warning" }
|
|
51
|
+
] },
|
|
52
|
+
{ "name": "a record is an object", "decl": { "name": "cue", "type": "record", "fields": [{ "name": "s", "type": "text" }] }, "value": ["s"],
|
|
53
|
+
"problems": [{ "path": "", "code": "wrong-type" }] },
|
|
54
|
+
{ "name": "a map keyed by reference: keys and values checked",
|
|
55
|
+
"decl": { "name": "perf", "type": "map", "key": { "type": "reference", "to": "tag" }, "of": { "type": "enum", "values": ["smile", "frown"] } },
|
|
56
|
+
"value": { "v_a": "smile", "v_gone": "frown", "v_b": "shrug" }, "refs": ["tag:v_a", "tag:v_b"],
|
|
57
|
+
"problems": [
|
|
58
|
+
{ "path": "v_gone", "code": "no-such-node" },
|
|
59
|
+
{ "path": "v_b", "code": "not-a-value", "options": ["smile", "frown"] }
|
|
60
|
+
] },
|
|
61
|
+
{ "name": "a map keyed by text takes any key, quoted in a path when it must be",
|
|
62
|
+
"decl": { "name": "m", "type": "map", "key": { "type": "text" }, "of": { "type": "number" } },
|
|
63
|
+
"value": { "first one": "1", "b": 2 },
|
|
64
|
+
"problems": [{ "path": "[\"first one\"]", "code": "wrong-type" }] },
|
|
65
|
+
{ "name": "a list with ids: each id present and unique, each item checked",
|
|
66
|
+
"decl": { "name": "beats", "type": "list", "id": "id", "of": { "type": "record", "fields": [{ "name": "id", "type": "text" }, { "name": "at", "type": "number", "min": 0 }] } },
|
|
67
|
+
"value": [{ "id": "b1", "at": 1 }, { "id": "b1", "at": 2 }, { "at": -1 }],
|
|
68
|
+
"problems": [
|
|
69
|
+
{ "path": "[1].id", "code": "duplicate-id" },
|
|
70
|
+
{ "path": "[2].id", "code": "missing-id" },
|
|
71
|
+
{ "path": "[2].at", "code": "below-min" }
|
|
72
|
+
] },
|
|
73
|
+
{ "name": "a list without ids: each item checked",
|
|
74
|
+
"decl": { "name": "words", "type": "list", "of": { "type": "text" } },
|
|
75
|
+
"value": ["a", 2, "c"],
|
|
76
|
+
"problems": [{ "path": "[1]", "code": "wrong-type" }] },
|
|
77
|
+
{ "name": "a list is an array", "decl": { "name": "words", "type": "list", "of": { "type": "text" } }, "value": "a",
|
|
78
|
+
"problems": [{ "path": "", "code": "wrong-type" }] },
|
|
79
|
+
{ "name": "an entry: required fields, unknown fields, each value",
|
|
80
|
+
"target": { "fields": [
|
|
81
|
+
{ "name": "loud", "type": "boolean", "required": true },
|
|
82
|
+
{ "name": "tone", "type": "enum", "values": ["calm", "tense"] },
|
|
83
|
+
{ "name": "note", "type": "text" }
|
|
84
|
+
] },
|
|
85
|
+
"entry": { "tone": "wild", "tune": "calm" },
|
|
86
|
+
"problems": [
|
|
87
|
+
{ "path": "loud", "code": "required" },
|
|
88
|
+
{ "path": "tone", "code": "not-a-value", "options": ["calm", "tense"] },
|
|
89
|
+
{ "path": "tune", "code": "unknown-field", "severity": "warning" }
|
|
90
|
+
] },
|
|
91
|
+
{ "name": "an empty entry is fine when nothing is required",
|
|
92
|
+
"target": { "fields": [{ "name": "note", "type": "text" }] }, "entry": {}, "problems": [] },
|
|
93
|
+
{ "name": "an entry is an object", "target": { "fields": [{ "name": "note", "type": "text" }] }, "entry": "note",
|
|
94
|
+
"problems": [{ "path": "", "code": "wrong-type" }] }
|
|
95
|
+
]
|
|
96
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import JSON5 from 'json5';
|
|
2
|
+
|
|
3
|
+
// src/source.ts
|
|
4
|
+
function parseSource(text) {
|
|
5
|
+
const body = text.charCodeAt(0) === 65279 ? text.slice(1) : text;
|
|
6
|
+
return JSON5.parse(body);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export { parseSource };
|
|
10
|
+
//# sourceMappingURL=chunk-ONEAWPDZ.js.map
|
|
11
|
+
//# sourceMappingURL=chunk-ONEAWPDZ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/source.ts"],"names":[],"mappings":";;;AAWO,SAAS,YAAY,IAAA,EAAuB;AACjD,EAAA,MAAM,IAAA,GAAO,KAAK,UAAA,CAAW,CAAC,MAAM,KAAA,GAAS,IAAA,CAAK,KAAA,CAAM,CAAC,CAAA,GAAI,IAAA;AAC7D,EAAA,OAAO,KAAA,CAAM,MAAM,IAAI,CAAA;AACzB","file":"chunk-ONEAWPDZ.js","sourcesContent":["// ---------------------------------------------------------------------------\n// Reading authored source files.\n// ---------------------------------------------------------------------------\n\nimport JSON5 from \"json5\";\n\n/**\n * Parse JSON5 source text. A leading byte-order mark is tolerated, because\n * editors on Windows add one and JSON5 will not accept it. Throws on malformed\n * input.\n */\nexport function parseSource(text: string): unknown {\n const body = text.charCodeAt(0) === 0xfeff ? text.slice(1) : text;\n return JSON5.parse(body);\n}\n"]}
|