Collections
What a collection is: a folder of pages of one type and a page describing their fields. The kinds of fields on one page and three schema norms with checks: a relation points to a record of the right collection, a value is from the list, a required field is filled.
About the package
The package explains what a collection is and what fields there are, and brings three schema norms; their enforcers are the package checks. A collection schema (properties: in its page) already says which field points to which collection, which values are valid and what is required; the package checks read the schemas and compare the records with them. New collections come under the check by themselves.
The checks do not let a violation pass: they print what they find, one line per record, and finish with an error.
Where the boundary is
- Here: the collection format, the kinds of fields, relations, values, requiredness.
- A field of kind "phase" (the state of a record) is checked by the package
contours. - The norm "One kind of record, one place" is checked by the package
layers. - Which collections a project has is decided by the packages that bring them.
The checks are written in TypeScript and run by Bun from the project root. The shared part is checks/lib/: pages.ts (reading pages, front matter, paths, collection records), speclib.ts (the project, the result of a rule, the run), schemalib.ts (schemas, values, findings) and runner.ts (running one check as an action); the checks of other packages build on it.
Norms 3
| ID | Norm | Level | Mode | Enforcer |
|---|---|---|---|---|
| SCH-R01 | MUST | blocks | check |
|
| SCH-R02 | MUST | blocks | check |
|
| SCH-R03 | MUST | blocks | check |
"Blocks": the enforcer stops a violation. "Observes": it only notes it. Level MUST means required; SHOULD means yes by default.
Actions 3
| Name | What it does | File | When |
|---|---|---|---|
| relations | A relation field points to an existing record of the right collection norm SCH-R01 | checks/s01_relations.ts | check |
| values | Select, date, number and checkbox values are valid norm SCH-R02 | checks/s02_values.ts | check |
| required | Required fields are filled norm SCH-R03 | checks/s03_required.ts | check |
shtuk check runs the checks; shtuk run collections <name> runs any action. "After install" actions run by themselves only if the package comes from a trusted source.
Pages 5
They go into the project at these paths.
- /base/
- Collections page
- Kinds of fields page
- /norms/rules/collections/
- A relation field points to a record of the right collection SCH-R01
- A field value is from the list of valid ones SCH-R02
- The required fields of the schema are filled SCH-R03
Package files 9
They go into .shtukbase/packages/collections/; actions run from there.