Blueprint

blueprint.yml sits beside site.yml in a site that has its own Application Engine, the backend service. It says how the engine started for the site begins: who may create an account, its teams, who adds entries of each type and who reads or edits all of them, what visitors may read, and the integrations it starts with.

# site/blueprint.yml
signup: invite_only

teams:
  sales: { label: Sales }
  service: { label: Service }
  paid-members:                  # whoever holds a membership, bought or subscribed
    label: Paid members
    joins: { holds: ['@/membership'] }

access:
  '@/vehicle':
    add: [sales]                 # Sales adds vehicles
    all: { sales: edit }         # …and reads and edits every one, not only its own
  '@/store':
    add: []                      # nobody but the account that runs the site
    all: { members: read }       # every member reads every store

publicQueries:
  '@/vehicle': { whole: true, where: { status: { in: [available, pending] } } }
  '@/store': { whole: true }

integrations:
  meta-catalog: { label: Meta catalog, mapping: '@/vehicle-to-meta', channel: feed, trigger: on_fetch, enabled: true }
  dms-sold:     { label: Sold to the DMS, mapping: '@/vehicle-to-dms', channel: http, trigger: on_match,
                  filter: { where: { status: sold } } }

Every type starts closed

When a backend is started for a site, every type it installs starts closed: the data schemas of the site's foundations, its primary foundation and each extension. Only the account that runs the site adds entries of a closed type. A blueprint opens what the site's members or its teams create, and a type the file doesn't list stays closed.

One entry is still protected by the entry itself: its owner edits it, and shares it as they choose. The blueprint says who may add entries of a type, and who reads or edits every entry of it.

The keys

keyholdsmeans
signupopen · invite_onlywho may create an account: anyone, or only someone invited. Absent: open
teams<id>: { label, joins? }the teams the backend begins with, each one empty. The id is how access names the team: lowercase letters, digits and dashes, never members. label is the team's name, the id when absent, and no two teams share one. joins is who the engine keeps in the team (below)
access<type>: { add?, all? }add: open lets every signed-in account add entries of the type; a list of teams lets those teams add them; [] lets nobody but the account that runs the site. all: <team or members>: read or edit, over every entry of the type, not only one's own. A type not listed, or an add not given, stays closed
publicQueries<type>: { whole, where?, sort?, limit? }visitors who aren't signed in may read the type's entries. whole is required: true for whole entries, false for their briefs. where, sort and limit narrow them, in the language of queries
integrations<id>: { mapping, channel, trigger, label?, filter?, settings?, enabled?, reply?, reply_about?, requires_role?, vendor? }what the backend starts connected to; see Integrations

A type is named as your foundation names it: @/vehicle for its own, and the full name for any other (@std/person). A push sends each one in full, in your foundation's scope. While your foundation has no scope yet, a push sends @/vehicle as written, and says so.

A team's edit reaches every entry once its member confirms it is them: until then, a session holds what a team gives it as a reader. members: edit, and a team's add, need no confirming.

Who is put in a team is never the file's, and neither are roles. They belong to people, and when a backend starts, no one is there but the site's owner.

A team the engine keeps by condition

members in access is everyone with an account. A group that has paid, such as a club's members or a newsletter's subscribers, is a team the engine keeps by condition:

teams:
  paid-members:
    label: Paid members
    joins: { holds: ['@/membership'] }
access:
  '@/photo': { add: [paid-members] }    # paid members post photos
  • holds lists types. Whoever holds a record of one of them, bought or by a live subscription, is in the team, and leaves it when the subscription lapses or the purchase is refunded. A list means any of: ['@/membership', '@/pass']. A record given as a gift doesn't count.
  • The owner can still put someone in by hand, an honorary member, and either reason keeps them in.
  • The file names types only, since no record exists when a backend starts. A condition on one record ("holds the Annual membership"), and which teams may buy an offering, are set in the Admin App.
  • A site never learns which teams the viewer is in. It asks what they may do, and a team's members get different answers: whether they may add a type (useMayCreate), what each entry allows (mayDo), and whether they may buy an offering (offeringState reads 'not-eligible' when the owner sells it only to teams they aren't in, and who_may_buy holds the owner's own words, such as "Members only").

joins takes holds alone for now. A uuid in it, or any other key, is refused.

Integrations

An integration moves entries of one type to or from another system, through one of your foundation's mappings. A mapping says how a vendor's file translates to and from a type, such as a catalog feed's CSV from @/vehicle. It is a file in the foundation's src/mappings/, one per file, named by the file, the same way src/schemas/ holds data schemas:

# foundation/src/mappings/vehicle-to-meta.yml
label: Meta catalog
model: '@/vehicle'            # the type it translates
direction: out                # in | out
shape: list                   # list | document
format: { type: csv }
key: id
keys_from: '@/dms-inventory'  # optional: another of the foundation's mappings
fields:
  - { title: listing.title }
  - { vin: listing.vin }

A mapping can also read related entries through follow, a list of one-entry maps, each naming an alias. A line that names a model finds entries of that type, and its model is named as the mapping's own model is:

follow:
  - { quiz: { field: identity.quiz_ref } }
  - { key:  { model: '@/quiz-key', field: identity.quiz, names: quiz } }

A mapping several foundations use can live in a library they share instead, and each foundation that carries it names it in its main.js (Libraries → Mappings in a library); a line then names it in full, mapping: '@acme/vehicle-to-meta'.

Everything a mapping may say, and what register refuses, is in Mappings.

uniweb register registers a foundation's mappings with it, each type a mapping names written in full, in the foundation's scope. A foundation build refuses a mapping that names no model, or names a type (its model, or a model in follow) or a keys_from mapping of its own that it doesn't define. The backend judges the rest of the mapping when the foundation registers.

Each integration line in blueprint.yml takes:

keymeans
mappingrequired: the mapping, as the foundation names it (@/vehicle-to-meta), sent in its scope. Its direction and shape fit the channel: a feed takes an outbound list mapping, an email or http line an outbound document, a hook an inbound list, and a file line any mapping, importing through an inbound one and exporting through an outbound one. A push and a build refuse a line whose mapping doesn't fit, naming it, and uniweb doctor reports it
channelfile, feed, email, http or hook
triggerfile runs manual; feed runs on_fetch; email and http run on_create, on_match, on_change (once for each change a person makes) or manual; hook runs on_event, once for each event the other system posts to it
labelits name; the id when absent. The id is lowercase letters, digits and dashes
filterwhich entries it acts on, { where: … } in the language of queries
settingshook only: how the other system signs its events, which every backend of your solution shares. signature is standard_webhooks, the default, or hmac_sha256: the base64 HMAC-SHA256 of each event's body, in the header signature_header names, with the event's id in the header id_header names. A build and uniweb doctor check that it is a map on a hook line; a push refuses a setting the backend doesn't read, naming it
enabledtrue starts a file or feed integration switched on, or an http one that names a vendor. Leave it out for email and other http lines: the site's owner gives their address in the Solution Owner Console and switches them on there. A hook takes no enabled at all: it starts switched off, and its owner switches it on there once its signing key is set
replyhttp only: an inbound document or list mapping, named as mapping is, through which the endpoint's answer is written back (Mappings § An http reply: a list reply takes no path). A push and a build refuse one that goes out or is a set
reply_aboutwith a reply that writes a list of entries: the field of the reply's type (section.field, such as identity.submission) that the backend fills with the entry it sent. Nothing in it is a type, so it is sent as written
requires_roleonly on an integration a person runs, a file line or an email or http line that runs manual: the role a member needs to run it, system_admin, unit_admin, content_editor, content_reader or user. Absent, every member may run it
vendorhttp only: a function the platform runs in place of an address, '@/courses#grade': a compute file the site's foundations carry, named as mapping is, then # and the function it exports. See Compute Functions

A hook integration is the other way in: it has an address of its own on the site's backend, where the other system posts its events, and each event is written through the line's mapping, an inbound list mapping. It starts switched off: in the Solution Owner Console its owner gives the key the other system signs its events with, and then switches it on. By default the other system signs as Standard Webhooks do, with a key in their form (whsec_ and base64), which the owner can also have the backend make, shown once. A system that signs another way is named on the line by its settings, since it signs the same way for every backend of your solution, and its key is then the one that system gives:

integrations:
  stock-arrivals: { label: Arrivals from inventory, mapping: '@/stock-arrivals', channel: hook, trigger: on_event }
  shop-products:
    label: Products from Shopify
    mapping: '@/shopify-product'
    channel: hook
    trigger: on_event
    settings: { signature: hmac_sha256, signature_header: X-Shopify-Hmac-Sha256, id_header: X-Shopify-Webhook-Id }

An address, a URL or a key is never the file's: any other key on a line is refused.

A blueprint line ships an integration preinstalled. Once the backend has started, its administrators add and remove integrations themselves in the Solution Owner Console. When it runs, an integration acts as an account of its own, holding what its mappings need, so no access line names it.

When it applies

Once, when an engine is started for the site. That can be the site's own engine, the engine of a site copied from it when it is a template, or an engine started again after the site's was destroyed. After that, the site's owner changes these settings in the Solution Owner Console, and those changes are what the engine holds. An edited file is still checked and carried with each push and pull, but it reaches no backend that is already running. Once the site's backend has started, uniweb push and uniweb publish say so when they send a changed file, and uniweb status says it too.

What is checked, and where

  • A build, a push and uniweb doctor refuse a file that isn't a blueprint, naming the key. That includes an unknown key, a level other than read or edit, a team the file doesn't found and a public query without whole. A push carrying one is refused whole, content included.
  • A type or a mapping none of the site's foundations declares only warns. A backend started for the site leaves that line out, and the publish that started it says so.
  • where, sort and limit are the backend's to judge, against the types as it holds them. A public query it can't serve is left out the same way, and named.
  • blueprint.yml needs site.yml to name the backend service. The blueprint is a file of its own: a blueprint key under services.backend is refused.

A static build carries nothing of the file, since there is no backend to start. A pull writes it back to blueprint.yml, never into site.yml, and a pull of what you pushed changes no file.

In uniweb dev

The engine on your machine, its Developer Edition, starts from the blueprint as a live engine does: every type closed until the blueprint opens it, with its sign-up mode and its teams. uniweb dev sends it blueprint.yml the first time it serves the site, and the engine takes it once. After that, change a setting in the engine's Admin App, or start the engine over with uniweb engine reset. Who is in each team is set there too, since the file never names people. To see the entries the blueprint opens to visitors, name the engine's records beside its API in $devBackend (Testing a Web App Locally).

The conference template is a worked example. The organiser adds the programme's tracks, every member reads them, and each attendee keeps their own attendance:

uniweb create my-event --template conference

See also