Skip to content

Commit ab5352c

Browse files
authored
Schemas for Glides Events (#2)
* Schema, docs, and examples for Glides Events * Tweaks to docs organization, don't use auto-generated categories * Tweaks to Examples component * Refactor test script into a single script that compiles all schemas and checks all examples.
1 parent 31396be commit ab5352c

24 files changed

+1189
-592
lines changed

README.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ This website is built using [Docusaurus 2](https://docusaurus.io/), a modern sta
55
### Installation
66

77
```
8+
$ asdf install
89
$ yarn
910
```
1011

@@ -16,23 +17,21 @@ $ yarn start
1617

1718
This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server.
1819

19-
### Schema Validation
20+
### Testing
21+
22+
To check that the schemas in `schemas/` and the examples in `examples/` are valid:
2023

2124
``` shell
22-
# Check that the schemas in `schemas/` are valid
2325
$ yarn test:schemas
24-
25-
# Check that the examples in `examples/` match the schemas in `schemas/`
26-
$ yarn test:examples
2726
```
2827

29-
### Testing
28+
Each file `examples/<schema name>/<example name>.json` is validated against the schema `schemas/<schema name>.json`.
29+
30+
To run all tests:
3031

3132
``` shell
3233
$ yarn ci
33-
# or
34-
$ yarn format --check
35-
$ yarn typecheck
34+
# or
3635
$ yarn test
3736
```
3837

docs/events/_category_.json

Lines changed: 0 additions & 8 deletions
This file was deleted.

docs/events/com.mbta.ocs.raw_message.mdx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,10 @@ Originally described in [RFC4](https://github.com/mbta/technology-docs/blob/main
1111

1212
If you are internal to the MBTA, documentation for the contents of the `raw` field live in [SharePoint](https://mbta.sharepoint.com/:w:/r/sites/CTD/Shared%20Documents/General/Transit%20Tech%20CTD-wide/Transit%20Data/Product%20Documentation/RTR%20+%20Prediction%20Analyzer/Notes/ocs_messages.docx?d=wd7d5fea4e2104a4cac86b296e3083a47&csf=1&web=1&e=0vRTqp).
1313

14-
<Examples examples={{ RGPS }} />
14+
## Examples
15+
16+
<Examples examples={[{ label: "RGPS", json: RGPS }]} />
17+
18+
## Schema
19+
1520
<EventSchemaPath event="com.mbta.ocs.raw_message" />

docs/events/glides/_category_.json

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 51 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,65 @@
11
---
2+
sidebar_label: glides.editors_changed
23
---
34

4-
import GlidesExamples from "@site/examples/glides-events-schema/glides-examples.json";
55
import EventSchemaPath from "@site/src/components/EventSchemaPath.tsx";
66
import Examples from "@site/src/components/Examples.tsx";
7+
import example from "@site/examples/glides-events/editors_changed.v1.take_over.json";
78

8-
Operator sign in and out of editing specific trainsheets. This event publishes
9-
changes to who is editing. Since one action by an inspector might result in
10-
multiple changes, for example if they sign out of one location and in to
11-
another, the changes are published in a list.
9+
# editors_changed
1210

13-
In practice, we limit each location to have only one editor, and limit each
14-
editor to only one location, but that rule may or may not change and this data
15-
in this event doesn't guarantee that.
11+
event type: `com.mbta.ctd.glides.editors_changed.v1`
1612

17-
Note that the author may or may not match the editors in changes, since
18-
inspectors can change whether other people are editing. For example, when an
19-
inspector takes over editing at a location, they may sign out the previous
20-
editor. Then they would issue a stop change for the previous editor and a start
21-
change for themself.
13+
Inspectors sign in and out of editing specific trainsheets. This event publishes changes to who is editing.
2214

23-
Fields in the event:
15+
Since one action by an inspector might result in
16+
multiple changes, for example if they sign out of one location and in to another, the changes are published in a list.
2417

25-
- `metadata` (Metadata): how the changes were entered in Glides, including the author.
26-
- `changes` (array of EditorChange): a list of start and stop editing events
18+
In practice, we limit each location to have only one editor, and limit each editor to only one location, but that rule may or may not change and this event schema doesn't guarantee that.
19+
20+
Note that the author may or may not match the editors in changes, since inspectors can change whether other people are editing.
21+
For example, when an inspector takes over editing at a location, they may sign out the previous editor.
22+
Then they would issue a stop change for the previous editor and a start change for themself.
23+
24+
## Data
25+
26+
Fields in the event's `data`:
27+
28+
- `metadata` ([Metadata](.#metadata)): how the changes were entered in Glides, including the author.
29+
- `changes` (array of [EditorChange](#editorchange)): a list of start and stop editing events.
30+
31+
### EditorChange
32+
33+
Fields:
34+
35+
- `type` (string `"start"`|`"stop"`): Whether the editor started or stopped editing.
36+
- `location` ([Location](.#location)): the location the editor started or stopped managing.
37+
- `editor` ([GlidesUser](.#glidesuser)): the affected editor.
38+
39+
### GlidesUser
40+
41+
See [GlidesUser](.#glidesuser)
42+
43+
### Location
44+
45+
See [Location](.#location)
46+
47+
### Metadata
48+
49+
See [Metadata](.#metadata)
50+
51+
## Examples
2752

2853
<Examples
29-
examples={{
30-
Example: GlidesExamples.find(
31-
(example) => example.type == "com.mbta.ctd.glides.editors_changed.v1"
32-
),
33-
}}
54+
examples={[
55+
{
56+
description:
57+
'Inspector Alice (badge number: 123) starts her shift at Boston College. The previous inspector (badge number: 456) did not stop editing, so Alice clicks the "Take Over" button in Glides.',
58+
json: example,
59+
},
60+
]}
3461
/>
62+
63+
## Schema
64+
3565
<EventSchemaPath event="com.mbta.ctd.glides.editors_changed.v1" />
Lines changed: 50 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,63 @@
11
---
2+
sidebar_label: glides.operator_signed_in
23
---
34

4-
import GlidesExamples from "@site/examples/glides-events-schema/glides-examples.json";
55
import EventSchemaPath from "@site/src/components/EventSchemaPath.tsx";
66
import Examples from "@site/src/components/Examples.tsx";
7+
import example from "@site/examples/glides-events/operator_signed_in.v1.json";
78

8-
At the start of their shift, operators need to confirm that they are
9-
fit-for-duty and do not have any electronic devices. They currently do this by
10-
physically signing a paper trainsheet: in the future, they will do this
11-
digitally.
9+
# operator_signed_in
1210

13-
Fields in the event:
11+
event type: `com.mbta.ctd.glides.operator_signed_in.v1`
1412

15-
- `metadata` (Metadata): how the operator was signed in in Glides, including the inspector who signed them in.
16-
- `operator` (Operator): the operator who signed in
17-
- `signedInAt` (RFC3999 timestamp): the time at which they signed in (separate from the time of the event)
18-
- `signature` (Signature): how the operator confirmed that they signed in.
13+
At the start of their shift, operators need to confirm in Glides (on an inspector's device) that they are fit-for-duty and do not have any electronic devices.
1914

20-
Originally described in [RFC18](https://github.com/mbta/technology-docs/blob/main/rfcs/accepted/0018-glides-trainsheet-events.md).
15+
## Data
16+
17+
Fields in the event's `data`:
18+
19+
- `metadata` ([Metadata](.#metadata)): how the operator was signed in in Glides, including the inspector who signed them in.
20+
- `operator` ([Operator](.#operator)): the operator who signed in
21+
- `signedInAt` (RFC3999 timestamp): the time at which they signed in (this is separate from the event timestamp)
22+
- `signature` ([Signature](#signature)): how the operator signed in.
23+
24+
### Metadata
25+
26+
See [Metadata](.#metadata)
27+
28+
### Operator
29+
30+
See [Operator](.#operator)
31+
32+
### Signature
33+
34+
How the operator signed that they were fit for duty.
35+
36+
Fields:
37+
38+
- `type` (string): How the the operator made their signature.
39+
40+
Current values for `type` are
41+
42+
- `"tap"` if they signed in by tapping their badge to an RFID scanner.
43+
- `"type"` if they signed in by typing their badge number into Glides as a signature.
44+
45+
Represented as an object with a string field instead of `const`s, so that we could include other types of signatures or other data about the signature in the future without a breaking change.
46+
47+
The tapped badge's RFID serial number is not included in the stream for security reasons (it could be used to impersonate an employee).
48+
49+
## Examples
2150

2251
<Examples
23-
examples={{
24-
Example: GlidesExamples.find(
25-
(example) => example.type == "com.mbta.ctd.glides.operator_signed_in.v1"
26-
),
27-
}}
52+
examples={[
53+
{
54+
description:
55+
"Operator Charlie (badge: 789) returns from his break and stops by Inspector Alice's booth. Alice checks him as fit for duty, and he signs in by tapping his badge to the RFID reader attached to Alice's computer.",
56+
json: example,
57+
},
58+
]}
2859
/>
60+
61+
## Schema
62+
2963
<EventSchemaPath event="com.mbta.ctd.glides.operator_signed_in.v1" />

0 commit comments

Comments
 (0)