Fixtures
Declaring the dev data `concrete dev` and `concrete check` run a template over — a property, and the content a fill would generate for it.
A fixture is one property plus the content layer a fill would produce for it. It
is what concrete dev renders, what concrete check grades marker coverage
over, and what the playground lists — and it never reaches a published
bundle.
Fixtures are data: three kinds of JSON document, which nothing evaluates.
template.ts names a fixture list; the list names the content fixtures;
each content fixture names the property document it is on. template.ts is
the only file the framework finds by name — a document the list does not reach is
not a fixture, wherever it sits, and fixtures/ is a convention rather than a
reserved directory. There is no import to make and no subpath to reach: the
resolver is the framework's own and runs inside concrete dev, concrete check
and concrete build.
A published bundle is an immutable artifact outside the author's control, so dev
data must not be reachable from it: no module template.ts reaches may import a
file the fixture list reaches, or the sample library. concrete check refuses
either, naming the file (fixtures/reachable-from-bundle).
Every path a document states is relative to that document and stays inside its
own folder (fixtures/reference-invalid). concrete dev writes a JSON Schema for
each kind to .concrete/schema/ — fixture-list.schema.json,
content-fixture.schema.json and property.schema.json — and a document that
names its schema in a $schema member is completed and checked by your editor as
you type. concrete check grades every document against the template whether it
names one or not (fixtures/document-invalid).
A property lives at properties/<slug>/ beside the fixture list, as plain data
beside its media files. npx concrete property list shows the sample library and
npx concrete property add <slug> copies one in; the copy is yours to edit. There
is no builder and no derivation, and no property spreads another, so a variation
is a copy of the folder, edited.
A workspace whose fixtures are TypeScript modules, from the major before this
one, converts with concrete upgrade.
fixtures/index.json
Parameters
properties is the list of property documents, each a path relative to the list,
in the order the playground offers them; a property's name is its folder's, its
folder holds nothing of another fixture, and it is listed whether or not a content
fixture is on it. fixtures is the list of content fixtures, each a path relative
to the list, in the order the playground offers them; a content fixture's name is
its file name, and its property must be listed. Names are unique across the
template. $schema is optional.
Constraints
template.ts names the list by its path relative to template.ts:
fixtures: "./fixtures/index.json" is the scaffold's. A template that names no
list, or a list that names no content fixture that loads, has nothing to grade
marker coverage over, and concrete check reports fixtures/none. A second
fixture is a second document and one more entry here.
Example
{
"$schema": "../.concrete/schema/fixture-list.schema.json",
"properties": ["properties/riverside/property.json"],
"fixtures": ["typical.json", "sparse.json"]
}Rules that apply
fixtures/none,
fixtures/reference-invalid.
fixtures/<id>.json
Parameters
property is the property document this fixture is on, a path relative to the
fixture. The fixture has no name member: its name is its file name. content is the content
layer, one entry per placed section instance; absent means the sparse case, where
every generative slot resolves to its empty value. $schema and notes are
optional, and notes is for whoever reads the document next.
Each entry of content is keyed by the instance id the page probe gives the
placement: <section key>-1, and -2 for a second placement of the same
section. It states:
slots— the values a fill would write, by slot id;slot_overrides—{ "scalar": { "<slot>": true, "<object>.<field>": true } }, marking a value inslotsas the user's override of its source;enabled—falseswitches an optional section off;variant— the declared display case to render.
Constraints
The file name is the fixture id: typical.json is typical, so renaming the
file renames the fixture. An instance id the composition does not place is
fixtures/instance-not-placed, and an instance stated twice, a slot or field the
section does not declare, a stray key, or a value of the wrong kind is
fixtures/document-invalid — a value that fails is dropped and its slot renders
empty.
Never state a derived slot as a fill's. A slot sourced by a fact, a row's member or
a compute() resolves from the property; a value stated for one is the user's
override of that source, and counts only with its mark in slot_overrides.scalar
— exactly as the platform marks the same edit in its editor. Nothing re-derives
it, and a slot that reads it re-derives from the user's value. null is a value
the user cleared.
A list, a row and an object are always statable, each by its own value: a row
states the identity of the row it holds, an object its fields, and a list of
objects its items, each item the fields it sets — the field holding the item's
element included, which is how a fixture states the photo a filled list picked. A
list sourced by a table is the platform's own shape: its items are the table's
rows, so an entry states only the fields a fill writes onto them, item by item in
the property's order, while the fields its rows bind stay the bake's. More items
than the property carries rows is fixtures/rows-not-in-property.
Media is stated as a pick of the property's own uploads, { "media": "<upload id>" },
and its kind must match the slot's exactly. A cropped image states its crop beside
the pick, { "media": "<id>", "crop": { "x": …, "y": …, "width": …, "height": … } },
each a share of the image from 0 to 1, with an optional "mobile": { "crop": … };
a malformed crop is fixtures/value-invalid. A contact's headshot or logo is not an
upload, so it is named through the contact:
{ "media": "contact:<contact id>:headshot" }, or logo_dark / logo_light. An
upload the property does not carry is fixtures/media-not-in-property.
Example
import { fact, fill, image, list, object, section, text } from "@homepages/concrete";
const photo = image({ label: "Photo", from: fact.property.property_media });
export const Gallery = section(
{
key: "gallery",
label: "Gallery",
slots: {
caption: text.short({
label: "Caption",
cap: 80,
source: fill.write({ reads: [fact.property.description], brief: "What the gallery shows. Write one sentence. Plain and factual." }),
}),
street: text.short({ label: "Street", source: fact.property.address.street }),
slides: list({
label: "Slides",
max: 12,
source: fill.pick({
brief: "A photograph of every room, front door first. Never anything that is not a photograph of the property.",
}),
item: object({
label: text.short({ cap: 60, source: fill.write({ reads: [fact.property.description, photo], brief: "Name the room the photo shows." }) }),
fields: { photo },
}),
}),
},
},
() => null,
);{
"$schema": "../.concrete/schema/content-fixture.schema.json",
"property": "properties/riverside/property.json",
"content": {
"gallery-1": {
"slots": {
"caption": "Every room, south-facing",
"street": "12 Harbor Lane",
"slides": [
{ "photo": { "media": "deck" }, "label": "The deck at golden hour" },
{ "photo": { "media": "kitchen" }, "label": "Galley kitchen" }
]
},
"slot_overrides": { "scalar": { "street": true } }
}
}
}street is bound to a fact, so it is stated only as the user's override, with its
mark.
Rules that apply
fixtures/document-invalid,
fixtures/media-not-in-property,
fixtures/rows-not-in-property,
fixtures/instance-not-placed.
properties/<slug>/property.json
Parameters
The platform's own facts document, member for member, with two substitutions: a
file is named by its path relative to the document, and a pick of an upload is
{ "media": "<upload id>" }. Its uploads are one uploads list, each entry
stating its id, its kind and its file, and it states the sorted lists as the
platform sorts them, each entry a pick — the photos, videos and tours that show the
property in property_media, its floor plans in floor_plans, and what sets out
its specifics in property_documents (absent, it holds none); one upload may sit
in several or in none. A unit's floor_plans[].image and its photos are picks
too; its floor, hoa_monthly, parking, lot_sqft, amenities and photos
may be left out, each loading unanswered (a list, empty). A contact's headshot and
logos and a comparable's photo are files of their own, named by path. $schema
is optional.
Constraints
Facts only. Unit copy, points of interest, amenities and anything else a fill produces are not facts and belong in a content fixture. What the platform derives — an address's display line, a comparable's standing, distance and price period — is never stated, and contacts rank by their order alone.
A property that fails the platform schema, names a missing file or repeats an id
within one of its lists is fixtures/property-invalid; a file outside the
property's own folder is fixtures/reference-invalid. Every reference stays
inside the folder, so removing the folder removes the property and nothing else.
No property spreads another: two properties that need the same photo each keep a
copy.
Example
{
"$schema": "../../../.concrete/schema/property.schema.json",
"address": { "street": "12 Harbor Lane", "city": "Salem", "state": "MA", "postal": "01970", "latitude": 42.5195, "longitude": -70.8967 },
"listing_intent": "for_sale",
"description": "A two-bedroom cape on the water, with a deck off the kitchen.",
"uploads": [
{ "id": "deck", "kind": "image", "file": "media/deck.jpg" },
{ "id": "kitchen", "kind": "image", "file": "media/kitchen.jpg" },
{ "id": "plan", "kind": "image", "file": "media/plan.png" }
],
"property_media": [{ "media": "deck" }, { "media": "kitchen" }],
"floor_plans": [{ "media": "plan" }],
"units": [
{ "id": "unit_01", "label": null, "beds": 2, "baths": 1, "sqft": 1120, "price": "540000", "floor_plans": [{ "image": { "media": "plan" }, "floor": "Main Floor" }] }
]
}Rules that apply
fixtures/property-invalid,
fixtures/reference-invalid,
fixtures/reachable-from-bundle.
See also
The workspace for where the fixtures sit and what excludes
them from a bundle, concrete property add, the
rest of the reference, and every rule.
