@horizon36596/zenith-schema 0.1.1
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/NOTICE +18 -0
- package/README.md +24 -0
- package/dist/auto.d.ts +1882 -0
- package/dist/auto.d.ts.map +1 -0
- package/dist/auto.js +236 -0
- package/dist/auto.js.map +1 -0
- package/dist/common.d.ts +76 -0
- package/dist/common.d.ts.map +1 -0
- package/dist/common.js +30 -0
- package/dist/common.js.map +1 -0
- package/dist/expr.d.ts +56 -0
- package/dist/expr.d.ts.map +1 -0
- package/dist/expr.js +245 -0
- package/dist/expr.js.map +1 -0
- package/dist/field.d.ts +719 -0
- package/dist/field.d.ts.map +1 -0
- package/dist/field.js +158 -0
- package/dist/field.js.map +1 -0
- package/dist/ids.d.ts +62 -0
- package/dist/ids.d.ts.map +1 -0
- package/dist/ids.js +79 -0
- package/dist/ids.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/jsonschema.d.ts +14 -0
- package/dist/jsonschema.d.ts.map +1 -0
- package/dist/jsonschema.js +31 -0
- package/dist/jsonschema.js.map +1 -0
- package/dist/link.d.ts +117 -0
- package/dist/link.d.ts.map +1 -0
- package/dist/link.js +58 -0
- package/dist/link.js.map +1 -0
- package/dist/migrate.d.ts +2699 -0
- package/dist/migrate.d.ts.map +1 -0
- package/dist/migrate.js +109 -0
- package/dist/migrate.js.map +1 -0
- package/dist/parse.d.ts +28 -0
- package/dist/parse.d.ts.map +1 -0
- package/dist/parse.js +46 -0
- package/dist/parse.js.map +1 -0
- package/dist/robot.d.ts +2935 -0
- package/dist/robot.d.ts.map +1 -0
- package/dist/robot.js +231 -0
- package/dist/robot.js.map +1 -0
- package/dist/waypoints.d.ts +63 -0
- package/dist/waypoints.d.ts.map +1 -0
- package/dist/waypoints.js +20 -0
- package/dist/waypoints.js.map +1 -0
- package/json/auto.json +683 -0
- package/json/field.json +457 -0
- package/json/link.json +110 -0
- package/json/robot.json +664 -0
- package/json/waypoints.json +50 -0
- package/package.json +65 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field.d.ts","sourceRoot":"","sources":["../src/field.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,2EAA2E;AAC3E,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAWzB,CAAC;AAEH,qFAAqF;AACrF,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAUrB,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;gCAWV,CAAC;AAEjB,8DAA8D;AAC9D,eAAO,MAAM,YAAY;;;;;;;;;;;;gCAMT,CAAC;AAEjB;;;GAGG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;EAS5B,CAAC;AAEL,0FAA0F;AAC1F,eAAO,MAAM,uBAAuB;;;;;;;;;EAGlC,CAAC;AAEH;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAa3B,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmDtB,CAAC;AAEH,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AACtD,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAC9C,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AACzD,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AACvD,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAC1D,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AACxE,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAChE,MAAM,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC"}
|
package/dist/field.js
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { provenanceSchema } from "./common.js";
|
|
3
|
+
import { formatVersionFor, schemaIdField } from "./ids.js";
|
|
4
|
+
/** An axis-aligned box the robot may not drive through, with a z range. */
|
|
5
|
+
export const obstacleSchema = z.object({
|
|
6
|
+
id: z.string().min(1),
|
|
7
|
+
kind: z.literal("box"),
|
|
8
|
+
minXIn: z.number(),
|
|
9
|
+
maxXIn: z.number(),
|
|
10
|
+
minYIn: z.number(),
|
|
11
|
+
maxYIn: z.number(),
|
|
12
|
+
minZIn: z.number(),
|
|
13
|
+
maxZIn: z.number(),
|
|
14
|
+
solidToRobot: z.boolean().optional(),
|
|
15
|
+
provenance: provenanceSchema.optional(),
|
|
16
|
+
});
|
|
17
|
+
/** An axis-aligned rectangle a rule talks about (a loading zone, a parking zone). */
|
|
18
|
+
export const zoneSchema = z.object({
|
|
19
|
+
id: z.string().min(1),
|
|
20
|
+
kind: z.literal("rect"),
|
|
21
|
+
minXIn: z.number(),
|
|
22
|
+
maxXIn: z.number(),
|
|
23
|
+
minYIn: z.number(),
|
|
24
|
+
maxYIn: z.number(),
|
|
25
|
+
rule: z.string().optional(),
|
|
26
|
+
appliesInAuto: z.boolean().optional(),
|
|
27
|
+
provenance: provenanceSchema.optional(),
|
|
28
|
+
});
|
|
29
|
+
/**
|
|
30
|
+
* A game element or container. Seasons differ wildly here, so the known keys are optional and
|
|
31
|
+
* unknown ones survive a round trip: the season plugin reads what it put there.
|
|
32
|
+
*/
|
|
33
|
+
export const elementSchema = z
|
|
34
|
+
.object({
|
|
35
|
+
id: z.string().min(1),
|
|
36
|
+
kind: z.string().min(1),
|
|
37
|
+
container: z.union([z.string(), z.null()]).optional(),
|
|
38
|
+
xIn: z.number().optional(),
|
|
39
|
+
yIn: z.number().optional(),
|
|
40
|
+
radiusIn: z.number().optional(),
|
|
41
|
+
holds: z.array(z.string()).optional(),
|
|
42
|
+
provenance: provenanceSchema.optional(),
|
|
43
|
+
})
|
|
44
|
+
.passthrough();
|
|
45
|
+
/** Something the robot aims at. Same openness as elements. */
|
|
46
|
+
export const targetSchema = z
|
|
47
|
+
.object({
|
|
48
|
+
id: z.string().min(1),
|
|
49
|
+
kind: z.string().min(1),
|
|
50
|
+
provenance: provenanceSchema.optional(),
|
|
51
|
+
})
|
|
52
|
+
.passthrough();
|
|
53
|
+
/**
|
|
54
|
+
* Where the field perimeter sits in the image, in image pixels (x right, y down from the image's
|
|
55
|
+
* top-left corner). The canvas maps this box onto the field's `sizeIn` in the declared frame.
|
|
56
|
+
*/
|
|
57
|
+
export const imagePxBoundsSchema = z
|
|
58
|
+
.object({
|
|
59
|
+
left: z.number().nonnegative(),
|
|
60
|
+
top: z.number().nonnegative(),
|
|
61
|
+
right: z.number().positive(),
|
|
62
|
+
bottom: z.number().positive(),
|
|
63
|
+
})
|
|
64
|
+
.refine((box) => box.right > box.left && box.bottom > box.top, {
|
|
65
|
+
message: "pxBoundsIn needs right > left and bottom > top: it is the perimeter's box in the image",
|
|
66
|
+
});
|
|
67
|
+
/** One named look of the same picture, such as a dark or a printable light background. */
|
|
68
|
+
export const fieldImageVariantSchema = z.object({
|
|
69
|
+
name: z.string().min(1),
|
|
70
|
+
src: z.string().min(1),
|
|
71
|
+
});
|
|
72
|
+
/**
|
|
73
|
+
* An optional picture of the field drawn under the vector layer (format version 2;
|
|
74
|
+
* site/docs/file-format.md has the exact mapping).
|
|
75
|
+
*
|
|
76
|
+
* - `src`: a path relative to the field file, or `app:<path>` for an asset the app ships (resolved
|
|
77
|
+
* against the app's public root, so `app:fields/biobuzz/biobuzz-dark.webp` is
|
|
78
|
+
* `apps/web/public/fields/biobuzz/biobuzz-dark.webp`).
|
|
79
|
+
* - `pxBoundsIn`: the box in the stored image, in image pixels, that the field perimeter occupies,
|
|
80
|
+
* or `"fullBleed"` when the perimeter is the image's own edge.
|
|
81
|
+
* - `rotationDeg`: how far the cropped image is turned **clockwise as seen on screen** before it is
|
|
82
|
+
* laid over the field in the field's default view; absent means 0.
|
|
83
|
+
* - `variants`: other looks of the same picture (same geometry, same credit), by name, for a
|
|
84
|
+
* field-style setting; `src` is the one drawn when nothing else is chosen.
|
|
85
|
+
*
|
|
86
|
+
* The image is only a picture: no check reads it, and the vector geometry stays the truth.
|
|
87
|
+
*/
|
|
88
|
+
export const fieldImageSchema = z.object({
|
|
89
|
+
src: z.string().min(1),
|
|
90
|
+
credit: z.string().min(1),
|
|
91
|
+
pxBoundsIn: z.union([z.literal("fullBleed"), imagePxBoundsSchema]),
|
|
92
|
+
rotationDeg: z.union([z.literal(0), z.literal(90), z.literal(180), z.literal(270)]).optional(),
|
|
93
|
+
variants: z
|
|
94
|
+
.array(fieldImageVariantSchema)
|
|
95
|
+
.min(1)
|
|
96
|
+
.refine((variants) => new Set(variants.map((variant) => variant.name)).size === variants.length, {
|
|
97
|
+
message: "every image variant needs its own name",
|
|
98
|
+
})
|
|
99
|
+
.optional(),
|
|
100
|
+
provenance: provenanceSchema.optional(),
|
|
101
|
+
});
|
|
102
|
+
/**
|
|
103
|
+
* `*.field.json`: the season, as vector geometry in the declared frame
|
|
104
|
+
* (site/docs/file-format.md). Key declaration order is the canonical file order.
|
|
105
|
+
*/
|
|
106
|
+
export const fieldSchema = z.object({
|
|
107
|
+
$schema: schemaIdField("field"),
|
|
108
|
+
formatVersion: formatVersionFor("field"),
|
|
109
|
+
season: z.string().min(1),
|
|
110
|
+
name: z.string().min(1),
|
|
111
|
+
frame: z.object({
|
|
112
|
+
origin: z.enum(["centre", "corner"]),
|
|
113
|
+
xAxis: z.string().min(1),
|
|
114
|
+
yAxis: z.string().min(1),
|
|
115
|
+
headingZero: z.enum(["+x", "+y"]),
|
|
116
|
+
headingPositive: z.enum(["ccw", "cw"]),
|
|
117
|
+
units: z.enum(["in"]),
|
|
118
|
+
canonicalAlliance: z.enum(["RED", "BLUE"]),
|
|
119
|
+
mirror: z.enum(["pointSymmetry", "mirrorX", "mirrorY", "none"]),
|
|
120
|
+
view: z
|
|
121
|
+
.object({
|
|
122
|
+
audienceAt: z.enum(["bottom", "top", "left", "right"]),
|
|
123
|
+
})
|
|
124
|
+
.optional(),
|
|
125
|
+
}),
|
|
126
|
+
sizeIn: z.object({
|
|
127
|
+
xIn: z.number().positive(),
|
|
128
|
+
yIn: z.number().positive(),
|
|
129
|
+
}),
|
|
130
|
+
image: fieldImageSchema.optional(),
|
|
131
|
+
periods: z
|
|
132
|
+
.object({
|
|
133
|
+
autoS: z.number().positive(),
|
|
134
|
+
teleopS: z.number().positive(),
|
|
135
|
+
})
|
|
136
|
+
.optional(),
|
|
137
|
+
obstacles: z.array(obstacleSchema).optional(),
|
|
138
|
+
zones: z.array(zoneSchema).optional(),
|
|
139
|
+
elements: z.array(elementSchema).optional(),
|
|
140
|
+
targets: z.array(targetSchema).optional(),
|
|
141
|
+
startRules: z
|
|
142
|
+
.object({
|
|
143
|
+
touchingWall: z.boolean().optional(),
|
|
144
|
+
ownHalf: z.boolean().optional(),
|
|
145
|
+
notInZones: z.array(z.string()).optional(),
|
|
146
|
+
notTouchingContainers: z.array(z.string()).optional(),
|
|
147
|
+
holds: z.record(z.string(), z.number()).optional(),
|
|
148
|
+
})
|
|
149
|
+
.passthrough()
|
|
150
|
+
.optional(),
|
|
151
|
+
rules: z
|
|
152
|
+
.object({
|
|
153
|
+
plugin: z.string().min(1),
|
|
154
|
+
})
|
|
155
|
+
.passthrough()
|
|
156
|
+
.optional(),
|
|
157
|
+
});
|
|
158
|
+
//# sourceMappingURL=field.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field.js","sourceRoot":"","sources":["../src/field.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE3D,2EAA2E;AAC3E,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC;IACrC,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACrB,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC;IACtB,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;IAClB,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;IAClB,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;IAClB,MAAM,EA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DED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** The five kinds of file Zenith reads and writes (site/docs/file-format.md). */
|
|
3
|
+
export declare const KINDS: readonly ["link", "robot", "field", "waypoints", "auto"];
|
|
4
|
+
export type Kind = (typeof KINDS)[number];
|
|
5
|
+
/** Where the v1 schemas are served, one file per kind. */
|
|
6
|
+
export declare const SCHEMA_ID_BASE = "https://libraries.horizon36596.org/zenith/schema/v1/";
|
|
7
|
+
/**
|
|
8
|
+
* The schema ids, one per kind. The docs site serves the schemas at these URLs, and they also ship
|
|
9
|
+
* in this package under `json/`; a reader never needs to fetch them.
|
|
10
|
+
*/
|
|
11
|
+
export declare const SCHEMA_ID: Record<Kind, string>;
|
|
12
|
+
/**
|
|
13
|
+
* The ids files carried before v0.1.0, on a host that was never served. Files written in
|
|
14
|
+
* development still name them, so every reader accepts them as aliases of `SCHEMA_ID`; every writer
|
|
15
|
+
* writes the current id instead (site/docs/file-format.md, Schema ids). The data format is the
|
|
16
|
+
* same under both, so this is not a `formatVersion` bump.
|
|
17
|
+
*/
|
|
18
|
+
export declare const LEGACY_SCHEMA_ID_BASE = "https://zenith.horizon36596.org/schema/v1/";
|
|
19
|
+
export declare const LEGACY_SCHEMA_ID: Record<Kind, string>;
|
|
20
|
+
/** Whether `id` names `kind`, by its current id or its legacy alias. */
|
|
21
|
+
export declare const isSchemaIdFor: (kind: Kind, id: string) => boolean;
|
|
22
|
+
/**
|
|
23
|
+
* The same document with a legacy `$schema` alias replaced by the current id; anything else is
|
|
24
|
+
* returned as it is. Pure; never mutates.
|
|
25
|
+
*/
|
|
26
|
+
export declare function withCurrentSchemaId<T>(kind: Kind, doc: T): T;
|
|
27
|
+
/**
|
|
28
|
+
* The `formatVersion` Zenith writes for each kind of file. Each kind is versioned on its own and
|
|
29
|
+
* bumped only when its own canonical form changes, with a migration and a fixture
|
|
30
|
+
* (`migrate.ts`). Version 2 (2026-09-22) added the `sequence` step to
|
|
31
|
+
* autos and the optional `image` to fields; auto version 3 (2026-09-24) added the `piecewise`
|
|
32
|
+
* heading mode. The link, robot and waypoints files did not change and stay at 1.
|
|
33
|
+
*
|
|
34
|
+
* The `$schema` ids above do not move with the version: they name the kind of file, and the
|
|
35
|
+
* `formatVersion` inside it says which revision of that kind it is.
|
|
36
|
+
*/
|
|
37
|
+
export declare const FORMAT_VERSIONS: {
|
|
38
|
+
readonly link: 1;
|
|
39
|
+
readonly robot: 1;
|
|
40
|
+
readonly field: 2;
|
|
41
|
+
readonly waypoints: 1;
|
|
42
|
+
readonly auto: 3;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* The newest format version of any kind, which is the auto file's. Code that writes an auto file
|
|
46
|
+
* uses this; code that writes any other kind reads `FORMAT_VERSIONS` for that kind.
|
|
47
|
+
*/
|
|
48
|
+
export declare const FORMAT_VERSION: 3;
|
|
49
|
+
/**
|
|
50
|
+
* `$schema` is optional on read, and the legacy alias is accepted; every file Zenith writes carries
|
|
51
|
+
* the current id for its kind.
|
|
52
|
+
*/
|
|
53
|
+
export declare const schemaIdField: (kind: Kind) => z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
54
|
+
/** The `formatVersion` key of one kind's current schema: exactly the version Zenith writes. */
|
|
55
|
+
export declare const formatVersionFor: <K extends Kind>(kind: K) => z.ZodLiteral<{
|
|
56
|
+
readonly link: 1;
|
|
57
|
+
readonly robot: 1;
|
|
58
|
+
readonly field: 2;
|
|
59
|
+
readonly waypoints: 1;
|
|
60
|
+
readonly auto: 3;
|
|
61
|
+
}[K]>;
|
|
62
|
+
//# sourceMappingURL=ids.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ids.d.ts","sourceRoot":"","sources":["../src/ids.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,iFAAiF;AACjF,eAAO,MAAM,KAAK,0DAA2D,CAAC;AAC9E,MAAM,MAAM,IAAI,GAAG,CAAC,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC;AAE1C,0DAA0D;AAC1D,eAAO,MAAM,cAAc,yDAAyD,CAAC;AAErF;;;GAGG;AACH,eAAO,MAAM,SAAS,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAM1C,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,+CAA+C,CAAC;AAElF,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAMjD,CAAC;AAEF,wEAAwE;AACxE,eAAO,MAAM,aAAa,GAAI,MAAM,IAAI,EAAE,IAAI,MAAM,KAAG,OACE,CAAC;AAE1D;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAK5D;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe;;;;;;CAMuB,CAAC;AAEpD;;;GAGG;AACH,eAAO,MAAM,cAAc,GAAuB,CAAC;AAEnD;;;GAGG;AACH,eAAO,MAAM,aAAa,GAAI,MAAM,IAAI,6DAMzB,CAAC;AAEhB,+FAA+F;AAC/F,eAAO,MAAM,gBAAgB,GAAI,CAAC,SAAS,IAAI,EAAE,MAAM,CAAC;;;;;;KACO,CAAC"}
|
package/dist/ids.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** The five kinds of file Zenith reads and writes (site/docs/file-format.md). */
|
|
3
|
+
export const KINDS = ["link", "robot", "field", "waypoints", "auto"];
|
|
4
|
+
/** Where the v1 schemas are served, one file per kind. */
|
|
5
|
+
export const SCHEMA_ID_BASE = "https://libraries.horizon36596.org/zenith/schema/v1/";
|
|
6
|
+
/**
|
|
7
|
+
* The schema ids, one per kind. The docs site serves the schemas at these URLs, and they also ship
|
|
8
|
+
* in this package under `json/`; a reader never needs to fetch them.
|
|
9
|
+
*/
|
|
10
|
+
export const SCHEMA_ID = {
|
|
11
|
+
link: `${SCHEMA_ID_BASE}link.json`,
|
|
12
|
+
robot: `${SCHEMA_ID_BASE}robot.json`,
|
|
13
|
+
field: `${SCHEMA_ID_BASE}field.json`,
|
|
14
|
+
waypoints: `${SCHEMA_ID_BASE}waypoints.json`,
|
|
15
|
+
auto: `${SCHEMA_ID_BASE}auto.json`,
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* The ids files carried before v0.1.0, on a host that was never served. Files written in
|
|
19
|
+
* development still name them, so every reader accepts them as aliases of `SCHEMA_ID`; every writer
|
|
20
|
+
* writes the current id instead (site/docs/file-format.md, Schema ids). The data format is the
|
|
21
|
+
* same under both, so this is not a `formatVersion` bump.
|
|
22
|
+
*/
|
|
23
|
+
export const LEGACY_SCHEMA_ID_BASE = "https://zenith.horizon36596.org/schema/v1/";
|
|
24
|
+
export const LEGACY_SCHEMA_ID = {
|
|
25
|
+
link: `${LEGACY_SCHEMA_ID_BASE}link.json`,
|
|
26
|
+
robot: `${LEGACY_SCHEMA_ID_BASE}robot.json`,
|
|
27
|
+
field: `${LEGACY_SCHEMA_ID_BASE}field.json`,
|
|
28
|
+
waypoints: `${LEGACY_SCHEMA_ID_BASE}waypoints.json`,
|
|
29
|
+
auto: `${LEGACY_SCHEMA_ID_BASE}auto.json`,
|
|
30
|
+
};
|
|
31
|
+
/** Whether `id` names `kind`, by its current id or its legacy alias. */
|
|
32
|
+
export const isSchemaIdFor = (kind, id) => id === SCHEMA_ID[kind] || id === LEGACY_SCHEMA_ID[kind];
|
|
33
|
+
/**
|
|
34
|
+
* The same document with a legacy `$schema` alias replaced by the current id; anything else is
|
|
35
|
+
* returned as it is. Pure; never mutates.
|
|
36
|
+
*/
|
|
37
|
+
export function withCurrentSchemaId(kind, doc) {
|
|
38
|
+
if (typeof doc !== "object" || doc === null || Array.isArray(doc))
|
|
39
|
+
return doc;
|
|
40
|
+
const record = doc;
|
|
41
|
+
if (record["$schema"] !== LEGACY_SCHEMA_ID[kind])
|
|
42
|
+
return doc;
|
|
43
|
+
return { ...record, $schema: SCHEMA_ID[kind] };
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The `formatVersion` Zenith writes for each kind of file. Each kind is versioned on its own and
|
|
47
|
+
* bumped only when its own canonical form changes, with a migration and a fixture
|
|
48
|
+
* (`migrate.ts`). Version 2 (2026-09-22) added the `sequence` step to
|
|
49
|
+
* autos and the optional `image` to fields; auto version 3 (2026-09-24) added the `piecewise`
|
|
50
|
+
* heading mode. The link, robot and waypoints files did not change and stay at 1.
|
|
51
|
+
*
|
|
52
|
+
* The `$schema` ids above do not move with the version: they name the kind of file, and the
|
|
53
|
+
* `formatVersion` inside it says which revision of that kind it is.
|
|
54
|
+
*/
|
|
55
|
+
export const FORMAT_VERSIONS = {
|
|
56
|
+
link: 1,
|
|
57
|
+
robot: 1,
|
|
58
|
+
field: 2,
|
|
59
|
+
waypoints: 1,
|
|
60
|
+
auto: 3,
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* The newest format version of any kind, which is the auto file's. Code that writes an auto file
|
|
64
|
+
* uses this; code that writes any other kind reads `FORMAT_VERSIONS` for that kind.
|
|
65
|
+
*/
|
|
66
|
+
export const FORMAT_VERSION = FORMAT_VERSIONS.auto;
|
|
67
|
+
/**
|
|
68
|
+
* `$schema` is optional on read, and the legacy alias is accepted; every file Zenith writes carries
|
|
69
|
+
* the current id for its kind.
|
|
70
|
+
*/
|
|
71
|
+
export const schemaIdField = (kind) => z
|
|
72
|
+
.string()
|
|
73
|
+
.refine((value) => isSchemaIdFor(kind, value), {
|
|
74
|
+
message: `$schema must be ${SCHEMA_ID[kind]}`,
|
|
75
|
+
})
|
|
76
|
+
.optional();
|
|
77
|
+
/** The `formatVersion` key of one kind's current schema: exactly the version Zenith writes. */
|
|
78
|
+
export const formatVersionFor = (kind) => z.literal(FORMAT_VERSIONS[kind]);
|
|
79
|
+
//# sourceMappingURL=ids.js.map
|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KAAK,CAAC,OAAO,CAAC,GAAG,CAAC;QAAE,OAAO,GAAG,CAAC;IAC9E,MAAM,MAAM,GAAG,GAA8B,CAAC;IAC9C,IAAI,MAAM,CAAC,SAAS,CAAC,KAAK,gBAAgB,CAAC,IAAI,CAAC;QAAE,OAAO,GAAG,CAAC;IAC7D,OAAO,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,SAAS,CAAC,IAAI,CAAC,EAAO,CAAC;AACtD,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,IAAI,EAAE,CAAC;IACP,KAAK,EAAE,CAAC;IACR,KAAK,EAAE,CAAC;IACR,SAAS,EAAE,CAAC;IACZ,IAAI,EAAE,CAAC;CAC0C,CAAC;AAEpD;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,eAAe,CAAC,IAAI,CAAC;AAEnD;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,IAAU,EAAE,EAAE,CAC1C,CAAC;KACE,MAAM,EAAE;KACR,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,aAAa,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE;IAC7C,OAAO,EAAE,mBAAmB,SAAS,CAAC,IAAI,CAAC,EAAE;CAC9C,CAAC;KACD,QAAQ,EAAE,CAAC;AAEhB,+FAA+F;AAC/F,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAiB,IAAO,EAAE,EAAE,CAC1D,CAAC,CAAC,OAAO,CAA8B,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @horizon36596/zenith-schema: the five file formats of site/docs/file-format.md as zod schemas,
|
|
3
|
+
* the TypeScript types inferred from them, the `estimateS` expression grammar and the migrations.
|
|
4
|
+
*
|
|
5
|
+
* Pure: no DOM, no clock, no randomness, no Node APIs (CLAUDE.md rule 1).
|
|
6
|
+
*/
|
|
7
|
+
export * from "./ids.js";
|
|
8
|
+
export * from "./common.js";
|
|
9
|
+
export * from "./expr.js";
|
|
10
|
+
export * from "./link.js";
|
|
11
|
+
export * from "./robot.js";
|
|
12
|
+
export * from "./field.js";
|
|
13
|
+
export * from "./waypoints.js";
|
|
14
|
+
export * from "./auto.js";
|
|
15
|
+
export * from "./migrate.js";
|
|
16
|
+
export * from "./parse.js";
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @horizon36596/zenith-schema: the five file formats of site/docs/file-format.md as zod schemas,
|
|
3
|
+
* the TypeScript types inferred from them, the `estimateS` expression grammar and the migrations.
|
|
4
|
+
*
|
|
5
|
+
* Pure: no DOM, no clock, no randomness, no Node APIs (CLAUDE.md rule 1).
|
|
6
|
+
*/
|
|
7
|
+
export * from "./ids.js";
|
|
8
|
+
export * from "./common.js";
|
|
9
|
+
export * from "./expr.js";
|
|
10
|
+
export * from "./link.js";
|
|
11
|
+
export * from "./robot.js";
|
|
12
|
+
export * from "./field.js";
|
|
13
|
+
export * from "./waypoints.js";
|
|
14
|
+
export * from "./auto.js";
|
|
15
|
+
export * from "./migrate.js";
|
|
16
|
+
export * from "./parse.js";
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type Kind } from "./ids.js";
|
|
2
|
+
/** The meta-schema every generated file declares. */
|
|
3
|
+
export declare const JSON_SCHEMA_DIALECT = "https://json-schema.org/draft/2020-12/schema";
|
|
4
|
+
/**
|
|
5
|
+
* Generates the JSON Schema for one kind from its zod schema.
|
|
6
|
+
*
|
|
7
|
+
* zod-to-json-schema has no 2020-12 target; its 2019-09 output is a subset that validates
|
|
8
|
+
* unchanged under 2020-12 (we use no tuples, so there is no `prefixItems` question), so the
|
|
9
|
+
* dialect and the `$id` are set here rather than by the converter.
|
|
10
|
+
*/
|
|
11
|
+
export declare function toJsonSchema(kind: Kind): Record<string, unknown>;
|
|
12
|
+
/** The canonical text of a generated schema file: two-space indent, LF, trailing newline. */
|
|
13
|
+
export declare function jsonSchemaText(kind: Kind): string;
|
|
14
|
+
//# sourceMappingURL=jsonschema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsonschema.d.ts","sourceRoot":"","sources":["../src/jsonschema.ts"],"names":[],"mappings":"AACA,OAAO,EAA8B,KAAK,IAAI,EAAE,MAAM,UAAU,CAAC;AAGjE,qDAAqD;AACrD,eAAO,MAAM,mBAAmB,iDAAiD,CAAC;AAElF;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAahE;AAED,6FAA6F;AAC7F,wBAAgB,cAAc,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAEjD"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { zodToJsonSchema } from "zod-to-json-schema";
|
|
2
|
+
import { FORMAT_VERSIONS, SCHEMA_ID } from "./ids.js";
|
|
3
|
+
import { schemaByKind } from "./migrate.js";
|
|
4
|
+
/** The meta-schema every generated file declares. */
|
|
5
|
+
export const JSON_SCHEMA_DIALECT = "https://json-schema.org/draft/2020-12/schema";
|
|
6
|
+
/**
|
|
7
|
+
* Generates the JSON Schema for one kind from its zod schema.
|
|
8
|
+
*
|
|
9
|
+
* zod-to-json-schema has no 2020-12 target; its 2019-09 output is a subset that validates
|
|
10
|
+
* unchanged under 2020-12 (we use no tuples, so there is no `prefixItems` question), so the
|
|
11
|
+
* dialect and the `$id` are set here rather than by the converter.
|
|
12
|
+
*/
|
|
13
|
+
export function toJsonSchema(kind) {
|
|
14
|
+
const generated = zodToJsonSchema(schemaByKind[kind], {
|
|
15
|
+
target: "jsonSchema2019-09",
|
|
16
|
+
definitionPath: "$defs",
|
|
17
|
+
errorMessages: false,
|
|
18
|
+
});
|
|
19
|
+
delete generated["$schema"];
|
|
20
|
+
return {
|
|
21
|
+
$schema: JSON_SCHEMA_DIALECT,
|
|
22
|
+
$id: SCHEMA_ID[kind],
|
|
23
|
+
title: `Zenith ${kind} file, formatVersion ${String(FORMAT_VERSIONS[kind])}`,
|
|
24
|
+
...generated,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/** The canonical text of a generated schema file: two-space indent, LF, trailing newline. */
|
|
28
|
+
export function jsonSchemaText(kind) {
|
|
29
|
+
return `${JSON.stringify(toJsonSchema(kind), null, 2)}\n`;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=jsonschema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsonschema.js","sourceRoot":"","sources":["../src/jsonschema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,SAAS,EAAa,MAAM,UAAU,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,qDAAqD;AACrD,MAAM,CAAC,MAAM,mBAAmB,GAAG,8CAA8C,CAAC;AAElF;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAC,IAAU;IACrC,MAAM,SAAS,GAAG,eAAe,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE;QACpD,MAAM,EAAE,mBAAmB;QAC3B,cAAc,EAAE,OAAO;QACvB,aAAa,EAAE,KAAK;KACrB,CAA4B,CAAC;IAC9B,OAAO,SAAS,CAAC,SAAS,CAAC,CAAC;IAC5B,OAAO;QACL,OAAO,EAAE,mBAAmB;QAC5B,GAAG,EAAE,SAAS,CAAC,IAAI,CAAC;QACpB,KAAK,EAAE,UAAU,IAAI,wBAAwB,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,EAAE;QAC5E,GAAG,SAAS;KACb,CAAC;AACJ,CAAC;AAED,6FAA6F;AAC7F,MAAM,UAAU,cAAc,CAAC,IAAU;IACvC,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC;AAC5D,CAAC"}
|
package/dist/link.d.ts
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* `zenith.json`: the link file at the robot repository root. It says where everything else lives
|
|
4
|
+
* and how to run the simulator (site/docs/file-format.md).
|
|
5
|
+
*
|
|
6
|
+
* Key declaration order below is the canonical file order; canonicalize() follows it.
|
|
7
|
+
*/
|
|
8
|
+
export declare const linkSchema: z.ZodObject<{
|
|
9
|
+
$schema: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
10
|
+
formatVersion: z.ZodLiteral<1>;
|
|
11
|
+
autosDir: z.ZodString;
|
|
12
|
+
robot: z.ZodString;
|
|
13
|
+
field: z.ZodString;
|
|
14
|
+
waypoints: z.ZodOptional<z.ZodString>;
|
|
15
|
+
deploy: z.ZodOptional<z.ZodObject<{
|
|
16
|
+
kind: z.ZodEnum<["androidAssets", "directory"]>;
|
|
17
|
+
dir: z.ZodString;
|
|
18
|
+
/**
|
|
19
|
+
* The command library the robot runtime builds on: `"solverslib"` (the
|
|
20
|
+
* `org.horizon36596.zenith.solverslib` classes) or `"ivy"` (the `org.horizon36596.zenith.ivy` classes).
|
|
21
|
+
* Neither is a default. It is optional here so that a file without it still loads in the editor
|
|
22
|
+
* and validates, and so that a project that writes no Java needs none. Every command that writes
|
|
23
|
+
* Java refuses until it is set: `zenith codegen`, and `zenith deploy` and the desktop app's Deploy
|
|
24
|
+
* when there is a `codegen` section, because only then do they write OpMode stubs
|
|
25
|
+
* (site/docs/command-libraries.md). It decides what the stubs and generated classes import;
|
|
26
|
+
* nothing in an `*.auto.json` names a library.
|
|
27
|
+
*/
|
|
28
|
+
commandLibrary: z.ZodOptional<z.ZodEnum<["solverslib", "ivy"]>>;
|
|
29
|
+
/**
|
|
30
|
+
* The team's `ZenithRobot` implementation, fully qualified, with a public
|
|
31
|
+
* no-argument constructor. Every OpMode stub `zenith deploy` writes constructs one, so it is
|
|
32
|
+
* required once `codegen` is set. A dotted Java name and nothing else, because it is written into
|
|
33
|
+
* Java source.
|
|
34
|
+
*/
|
|
35
|
+
robotClass: z.ZodOptional<z.ZodString>;
|
|
36
|
+
/** The TeleOp the Driver Station preselects after each generated auto. Omitted when unset. */
|
|
37
|
+
preselectTeleOp: z.ZodOptional<z.ZodString>;
|
|
38
|
+
}, "strip", z.ZodTypeAny, {
|
|
39
|
+
kind: "androidAssets" | "directory";
|
|
40
|
+
dir: string;
|
|
41
|
+
commandLibrary?: "solverslib" | "ivy" | undefined;
|
|
42
|
+
robotClass?: string | undefined;
|
|
43
|
+
preselectTeleOp?: string | undefined;
|
|
44
|
+
}, {
|
|
45
|
+
kind: "androidAssets" | "directory";
|
|
46
|
+
dir: string;
|
|
47
|
+
commandLibrary?: "solverslib" | "ivy" | undefined;
|
|
48
|
+
robotClass?: string | undefined;
|
|
49
|
+
preselectTeleOp?: string | undefined;
|
|
50
|
+
}>>;
|
|
51
|
+
sim: z.ZodOptional<z.ZodObject<{
|
|
52
|
+
command: z.ZodString;
|
|
53
|
+
trace: z.ZodString;
|
|
54
|
+
}, "strip", z.ZodTypeAny, {
|
|
55
|
+
command: string;
|
|
56
|
+
trace: string;
|
|
57
|
+
}, {
|
|
58
|
+
command: string;
|
|
59
|
+
trace: string;
|
|
60
|
+
}>>;
|
|
61
|
+
codegen: z.ZodOptional<z.ZodObject<{
|
|
62
|
+
package: z.ZodString;
|
|
63
|
+
dir: z.ZodString;
|
|
64
|
+
}, "strip", z.ZodTypeAny, {
|
|
65
|
+
dir: string;
|
|
66
|
+
package: string;
|
|
67
|
+
}, {
|
|
68
|
+
dir: string;
|
|
69
|
+
package: string;
|
|
70
|
+
}>>;
|
|
71
|
+
}, "strip", z.ZodTypeAny, {
|
|
72
|
+
robot: string;
|
|
73
|
+
field: string;
|
|
74
|
+
formatVersion: 1;
|
|
75
|
+
autosDir: string;
|
|
76
|
+
waypoints?: string | undefined;
|
|
77
|
+
$schema?: string | undefined;
|
|
78
|
+
deploy?: {
|
|
79
|
+
kind: "androidAssets" | "directory";
|
|
80
|
+
dir: string;
|
|
81
|
+
commandLibrary?: "solverslib" | "ivy" | undefined;
|
|
82
|
+
robotClass?: string | undefined;
|
|
83
|
+
preselectTeleOp?: string | undefined;
|
|
84
|
+
} | undefined;
|
|
85
|
+
sim?: {
|
|
86
|
+
command: string;
|
|
87
|
+
trace: string;
|
|
88
|
+
} | undefined;
|
|
89
|
+
codegen?: {
|
|
90
|
+
dir: string;
|
|
91
|
+
package: string;
|
|
92
|
+
} | undefined;
|
|
93
|
+
}, {
|
|
94
|
+
robot: string;
|
|
95
|
+
field: string;
|
|
96
|
+
formatVersion: 1;
|
|
97
|
+
autosDir: string;
|
|
98
|
+
waypoints?: string | undefined;
|
|
99
|
+
$schema?: string | undefined;
|
|
100
|
+
deploy?: {
|
|
101
|
+
kind: "androidAssets" | "directory";
|
|
102
|
+
dir: string;
|
|
103
|
+
commandLibrary?: "solverslib" | "ivy" | undefined;
|
|
104
|
+
robotClass?: string | undefined;
|
|
105
|
+
preselectTeleOp?: string | undefined;
|
|
106
|
+
} | undefined;
|
|
107
|
+
sim?: {
|
|
108
|
+
command: string;
|
|
109
|
+
trace: string;
|
|
110
|
+
} | undefined;
|
|
111
|
+
codegen?: {
|
|
112
|
+
dir: string;
|
|
113
|
+
package: string;
|
|
114
|
+
} | undefined;
|
|
115
|
+
}>;
|
|
116
|
+
export type Link = z.infer<typeof linkSchema>;
|
|
117
|
+
//# sourceMappingURL=link.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"link.d.ts","sourceRoot":"","sources":["../src/link.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB;;;;;GAKG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;QAWjB;;;;;;;;;WASG;;QAEH;;;;;WAKG;;QAKH,8FAA8F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgBlG,CAAC;AAEH,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC"}
|
package/dist/link.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { formatVersionFor, schemaIdField } from "./ids.js";
|
|
3
|
+
/**
|
|
4
|
+
* `zenith.json`: the link file at the robot repository root. It says where everything else lives
|
|
5
|
+
* and how to run the simulator (site/docs/file-format.md).
|
|
6
|
+
*
|
|
7
|
+
* Key declaration order below is the canonical file order; canonicalize() follows it.
|
|
8
|
+
*/
|
|
9
|
+
export const linkSchema = z.object({
|
|
10
|
+
$schema: schemaIdField("link"),
|
|
11
|
+
formatVersion: formatVersionFor("link"),
|
|
12
|
+
autosDir: z.string().min(1),
|
|
13
|
+
robot: z.string().min(1),
|
|
14
|
+
field: z.string().min(1),
|
|
15
|
+
waypoints: z.string().min(1).optional(),
|
|
16
|
+
deploy: z
|
|
17
|
+
.object({
|
|
18
|
+
kind: z.enum(["androidAssets", "directory"]),
|
|
19
|
+
dir: z.string().min(1),
|
|
20
|
+
/**
|
|
21
|
+
* The command library the robot runtime builds on: `"solverslib"` (the
|
|
22
|
+
* `org.horizon36596.zenith.solverslib` classes) or `"ivy"` (the `org.horizon36596.zenith.ivy` classes).
|
|
23
|
+
* Neither is a default. It is optional here so that a file without it still loads in the editor
|
|
24
|
+
* and validates, and so that a project that writes no Java needs none. Every command that writes
|
|
25
|
+
* Java refuses until it is set: `zenith codegen`, and `zenith deploy` and the desktop app's Deploy
|
|
26
|
+
* when there is a `codegen` section, because only then do they write OpMode stubs
|
|
27
|
+
* (site/docs/command-libraries.md). It decides what the stubs and generated classes import;
|
|
28
|
+
* nothing in an `*.auto.json` names a library.
|
|
29
|
+
*/
|
|
30
|
+
commandLibrary: z.enum(["solverslib", "ivy"]).optional(),
|
|
31
|
+
/**
|
|
32
|
+
* The team's `ZenithRobot` implementation, fully qualified, with a public
|
|
33
|
+
* no-argument constructor. Every OpMode stub `zenith deploy` writes constructs one, so it is
|
|
34
|
+
* required once `codegen` is set. A dotted Java name and nothing else, because it is written into
|
|
35
|
+
* Java source.
|
|
36
|
+
*/
|
|
37
|
+
robotClass: z
|
|
38
|
+
.string()
|
|
39
|
+
.regex(/^[A-Za-z_$][A-Za-z0-9_$]*(\.[A-Za-z_$][A-Za-z0-9_$]*)*$/, "a fully qualified Java class name")
|
|
40
|
+
.optional(),
|
|
41
|
+
/** The TeleOp the Driver Station preselects after each generated auto. Omitted when unset. */
|
|
42
|
+
preselectTeleOp: z.string().min(1).optional(),
|
|
43
|
+
})
|
|
44
|
+
.optional(),
|
|
45
|
+
sim: z
|
|
46
|
+
.object({
|
|
47
|
+
command: z.string().min(1),
|
|
48
|
+
trace: z.string().min(1),
|
|
49
|
+
})
|
|
50
|
+
.optional(),
|
|
51
|
+
codegen: z
|
|
52
|
+
.object({
|
|
53
|
+
package: z.string().min(1),
|
|
54
|
+
dir: z.string().min(1),
|
|
55
|
+
})
|
|
56
|
+
.optional(),
|
|
57
|
+
});
|
|
58
|
+
//# sourceMappingURL=link.js.map
|
package/dist/link.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"link.js","sourceRoot":"","sources":["../src/link.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE3D;;;;;GAKG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC;IACjC,OAAO,EAAE,aAAa,CAAC,MAAM,CAAC;IAC9B,aAAa,EAAE,gBAAgB,CAAC,MAAM,CAAC;IACvC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC3B,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACxB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACxB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IACvC,MAAM,EAAE,CAAC;SACN,MAAM,CAAC;QACN,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,eAAe,EAAE,WAAW,CAAC,CAAC;QAC5C,GAAG,EAAE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