@chronicle.app/schema 0.3.0 → 0.4.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/README.md CHANGED
@@ -4,7 +4,8 @@ A deliberately small extraction vocabulary with generated TypeScript interfaces
4
4
  and Zod validators. The canonical file is [chronicle.ttl](chronicle.ttl); edit it and run
5
5
  `npm run schema:generate` from the repository root to regenerate the TypeScript/Zod
6
6
  schemas. `npm run schema:check` verifies that the committed output matches the
7
- ontology without rewriting it.
7
+ ontology without rewriting it. Write each term's `rdfs:comment` by the rules in
8
+ [WRITING.md](WRITING.md).
8
9
 
9
10
  ## Documentation site
10
11
 
@@ -13,6 +14,40 @@ The schema is documented at https://schema.chronicle.app, built from
13
14
  site lives in [apps/schema-site](../../apps/schema-site), which also describes
14
15
  the examples format.
15
16
 
17
+ ## Other vocabularies
18
+
19
+ Chronicle's vocabulary stands on its own. It borrows schema.org's model and
20
+ names, and `chronicle.ttl` points each term to the closest schema.org term as a
21
+ hint for mapping data between them: `skos:exactMatch` for the same meaning,
22
+ `skos:closeMatch` for a similar one, and `skos:broadMatch` when schema.org's
23
+ term is broader. A reasoner draws nothing from SKOS mappings, so the hints
24
+ don't claim the vocabularies are compatible. They aren't: values, scope, and
25
+ structure differ in places. No `rdfs:subClassOf`, `rdfs:subPropertyOf`,
26
+ `owl:equivalentClass`, or `owl:equivalentProperty` points to another
27
+ vocabulary, and the schema site's build fails on one.
28
+
29
+ [alignments/](alignments) holds one file for each vocabulary that Chronicle's
30
+ terms relate to, `schemaorg.ttl` and `activitystreams.ttl`. Each names the
31
+ release its terms were checked against, and holds:
32
+
33
+ - `doc:note`: how a Chronicle term differs from the term it maps to, written
34
+ by the rules in [WRITING.md](WRITING.md#8-notes-on-other-vocabularies).
35
+ - `doc:unlike`: a term with the same name as a Chronicle term but a different
36
+ meaning, such as schema.org's `Project`.
37
+ - The mappings to any vocabulary other than schema.org. They can change
38
+ without a vocabulary release.
39
+
40
+ `<name>.terms.json` lists the classes and properties of the release. To move to
41
+ a newer one, run `node scripts/snapshot-vocabulary.js schemaorg <release>` (or
42
+ `activitystreams`), update `doc:release`, and fix what the schema site's build
43
+ reports. The site shows each term's relations, has a page for each vocabulary,
44
+ and fails when a mapping names a term the release does not have, or when a
45
+ Chronicle term shares a name with a term it neither maps to nor marks unlike.
46
+ Names are also compared without the endings in `doc:nameEnding`, so
47
+ `LikeAction` is compared with Activity Streams' `Like`. To relate the
48
+ vocabulary to another one, add its alignment, its `.terms.json`, and a
49
+ comparison in [the site's vocabularies/](../../apps/schema-site/vocabularies).
50
+
16
51
  ## Vocabulary
17
52
 
18
53
  - `Base`: an identity-bearing node; carries `sourceId`.
@@ -27,9 +62,10 @@ visits, trips, places, and journeys; WhatsApp adds group channels, members, and
27
62
  quoted replies. Shared properties cover source identity,
28
63
  event time, agents, membership, authors, and recipients.
29
64
 
30
- `Text`, `URL`, `DateTime`, `Date`, and `Number` are literal datatypes, under `DataType`. Cardinality in
31
- `chronicle.ttl` defines each property's constraints: `owl:minCardinality 1` makes
32
- it required, and `owl:maxCardinality 1` makes it single-valued; otherwise it is a list. Records carry `@type` and at least one of `@key` (a nonempty list of
65
+ `Text`, `URL`, `DateTime`, and `Number` are datatypes. A
66
+ `DateTime` is a `Date` or an EDTF string at the source's precision, such as `1987` or
67
+ `XXXX-03-12`; `isDateTime` checks a string. A property takes a list of values
68
+ unless its SHACL shape sets `sh:maxCount 1`. Records carry `@type` and at least one of `@key` (a nonempty list of
33
69
  identity fields or computed key entries) or `@id` (an existing identity). A
34
70
  record can also carry `@assertedAt`, the instant its source observed it, and
35
71
  `@asserts`, the predicates it states completely (`'*'` for all of them).
@@ -64,12 +100,33 @@ and cardinality. Unknown object fields are stripped by Zod; undeclared record
64
100
  types are rejected. Import interfaces such as `Entity` and `Action` for static
65
101
  typing; use validators at runtime to enforce identity requirements.
66
102
 
103
+ ## Writing the ontology
104
+
105
+ `chronicle.ttl` says what terms mean in OWL, and how records use them in SHACL:
106
+
107
+ - A class is an `owl:Class`. `:Base` is the disjoint union of `:Entity` and
108
+ `:Action`, so nothing is both.
109
+ - A property is an `owl:ObjectProperty` when it links to records and an
110
+ `owl:DatatypeProperty` when it holds values. `:sameAs` takes either, so it is
111
+ an `rdf:Property`.
112
+ - A property's `rdfs:domain` and `rdfs:range` name one term, or several in one
113
+ `owl:unionOf`. Don't add a second `rdfs:domain` or `rdfs:range`: OWL reads two
114
+ as both at once, so the generator rejects it.
115
+ - A datatype is an `rdfs:Datatype` defined over XSD. Each accepts the plain
116
+ strings that Chronicle JSON becomes in JSON-LD as well as typed values, such
117
+ as an `xsd:dateTime` for an instant.
118
+ - A SHACL property shape after a property holds its record rules. `sh:maxCount 1`
119
+ makes it take one value. A shape with `sh:targetClass` and `sh:minCount 1`
120
+ makes it required on that class.
121
+
67
122
  ## Generation and compatibility
68
123
 
69
- The generator turns N3/Turtle into TypeScript types and Zod validators. It handles
70
- inheritance, domain/range, and OWL cardinality and fails for cyclic inheritance or
71
- undeclared referenced classes. The package has no persistence metadata, derived
72
- effects, or runtime filesystem parser.
124
+ The generator turns the ontology into TypeScript types and Zod validators. It
125
+ reads terms through `scripts/terms.js`, which the schema site also uses. It
126
+ handles inheritance, including a class with two parents, domains and ranges,
127
+ and SHACL counts, and it fails for cyclic inheritance, undeclared referenced
128
+ classes, or a property with two domains or ranges. The package has no
129
+ persistence metadata, derived effects, or runtime filesystem parser.
73
130
  Generated runtime code depends only on Zod; the TTL is also included in the package.
74
131
 
75
132
  ## Schema versions
@@ -84,12 +141,13 @@ Release notes map software versions to vocabulary versions.
84
141
  The package exports `@chronicle.app/schema/chronicle.ttl`; the former
85
142
  `@chronicle.app/schema/schema.ttl` export remains an alias for compatibility.
86
143
 
87
- Use patch releases for description corrections that preserve meaning, minor
88
- releases for compatible vocabulary additions, and major releases for removed
89
- terms, changed meanings, or incompatible constraints. These compatibility rules
90
- also apply during `0.x`. Keep term identifiers such as
91
- `https://schema.chronicle.app/Task` stable; introduce a new term and deprecate the
92
- old one when its concept changes fundamentally.
144
+ Use patch releases for description corrections that preserve meaning and minor
145
+ releases for anything else. Until 1.0, a minor release can rename or remove
146
+ terms, change what they mean, or add constraints, so data that validates against
147
+ one minor version may not validate against the next. From 1.0, those changes need
148
+ a major release. Term identifiers such as `https://schema.chronicle.app/Task` are
149
+ unversioned, so don't reuse one for a different concept. Give that concept a new
150
+ term.
93
151
 
94
152
  Snapshot paths use the vocabulary version, not the npm package version.
95
153
  The publication convention is
@@ -102,9 +160,8 @@ publish: work on new terms in a branch until it is ready. Any change to
102
160
  `npm run schema:check` enforces this against the latest release tag. See [Preparing a release](../../RELEASING.md) for the
103
161
  release procedure.
104
162
 
105
- The vocabulary is intentionally small. Add terms only when a plugin needs them,
106
- keeping existing term identifiers and meanings stable; regenerate and add
107
- focused tests alongside each addition.
163
+ The vocabulary is intentionally small. Add terms only when a plugin needs them;
164
+ regenerate and add focused tests alongside each addition.
108
165
 
109
166
  Node.js 22.13+. MIT covers the ontology, generator, generated code, and docs;
110
167
  see [LICENSE](LICENSE).