# proto-file: metacore/api/v1/schema.proto # proto-message: metacore.api.v1.Schema # The content of a site: pages with their texts and their pictures, in # sections, with an editorial workflow. A message of metacore.api.v1.Schema, # in the text format of Protocol Buffers. # # A page is one record, by its slug: # # main global what the page is, and where it stands # texts language what a reader reads: a change waits for a second person # media language its cover and its attachments # stats global how often it is read: an overlay that the site writes live # # The reading time is derived by an enricher, and a gate rule judges a change # of the texts against the style guide: both are atoms, because a schema # holds no formula and no condition. # # A writer sends a page to its review, which starts a workflow instance for # its slug: a reviewer who did not send it approves it, and then the handler # publishes it. The translation vendor tells through a webhook when the texts # of a language are ready. # # The org declares the scope language under global before the first # deployment. entities { name: "page" key { name: "slug" type: FIELD_TYPE_TEXT } layers { name: "main" scope: "global" fields { name: "kind" type: FIELD_TYPE_TEXT required: true allowed_values: "news" allowed_values: "guide" allowed_values: "landing" } fields { name: "author" type: FIELD_TYPE_REFERENCE reference { entity: "author" carries: "name" } } fields { name: "section" type: FIELD_TYPE_REFERENCE reference { entity: "section" } } fields { name: "published_on" type: FIELD_TYPE_DATE exposed: true } fields { name: "featured" type: FIELD_TYPE_BOOLEAN } } layers { name: "texts" scope: "language" second_person: true hold_timeout { seconds: 259200 } fields { name: "headline" type: FIELD_TYPE_TEXT max_length: 140 exposed: true } fields { name: "summary" type: FIELD_TYPE_TEXT max_length: 300 } fields { name: "body" type: FIELD_TYPE_TEXT } fields { name: "reading_minutes" type: FIELD_TYPE_INTEGER derived_by: "reading_time" } } # A cover stated at the global root shows in every language, and one stated # for a language replaces it there. The engine renders it at three widths. layers { name: "media" scope: "language" fields { name: "cover" type: FIELD_TYPE_FILE file { media_types: [FILE_MEDIA_TYPE_JPEG, FILE_MEDIA_TYPE_PNG, FILE_MEDIA_TYPE_WEBP] public: true widths: [640, 1280, 1920] max_bytes: 20971520 min_width: 1280 } } fields { name: "attachments" type: FIELD_TYPE_FILE list: true file { media_types: FILE_MEDIA_TYPE_PDF public: true max_bytes: 10485760 } } } layers { name: "stats" scope: "global" overlay: true fields { name: "views" type: FIELD_TYPE_INTEGER } } } entities { name: "section" key { name: "code" type: FIELD_TYPE_TEXT } layers { name: "main" scope: "global" fields { name: "parent" type: FIELD_TYPE_REFERENCE reference { entity: "section" } } fields { name: "position" type: FIELD_TYPE_INTEGER least { integer: 0 } } } layers { name: "texts" scope: "language" fields { name: "title" type: FIELD_TYPE_TEXT max_length: 80 } fields { name: "path" type: FIELD_TYPE_TEXT pattern: "[a-z0-9-]{1,60}" } # The address of a section in each language: two sections may share a # path in two languages, never in one. uniques { name: "path" fields: "path" scope: "language" ignore_case: true } } } entities { name: "author" key { name: "handle" type: FIELD_TYPE_TEXT } layers { name: "main" scope: "global" fields { name: "name" type: FIELD_TYPE_TEXT required: true } fields { name: "bio" type: FIELD_TYPE_TEXT max_length: 1000 } fields { name: "email" type: FIELD_TYPE_TEXT restricted { read_roles: "chief" write_roles: "chief" } } uniques { name: "email" fields: "email" scope: "global" ignore_case: true } } } roles { name: "writer" permissions { operation: OPERATION_READ entity: "page" } permissions { operation: OPERATION_READ entity: "section" } permissions { operation: OPERATION_READ entity: "author" } permissions { operation: OPERATION_CHANGE entity: "page" layer: "main" } permissions { operation: OPERATION_CHANGE entity: "page" layer: "texts" } permissions { operation: OPERATION_CHANGE entity: "page" layer: "media" } permissions { operation: OPERATION_START workflow: "editorial" } } roles { name: "reviewer" permissions { operation: OPERATION_READ entity: "page" } permissions { operation: OPERATION_DECIDE entity: "page" layer: "texts" } permissions { operation: OPERATION_GO_BACK entity: "page" layer: "texts" } } roles { name: "chief" permissions { operation: OPERATION_READ entity: "page" } permissions { operation: OPERATION_READ entity: "section" } permissions { operation: OPERATION_READ entity: "author" } permissions { operation: OPERATION_CHANGE entity: "section" layer: "main" } permissions { operation: OPERATION_CHANGE entity: "section" layer: "texts" } permissions { operation: OPERATION_CHANGE entity: "author" layer: "main" } permissions { operation: OPERATION_CALL procedure: "publish" } } roles { name: "site" permissions { operation: OPERATION_CHANGE entity: "page" layer: "stats" } } atoms { name: "reading_time" connection: "editorial" timeout { seconds: 2 } enricher { layer { entity: "page" layer: "texts" } } } atoms { name: "style_guide" connection: "editorial" timeout { seconds: 10 } gate_rule { layer { entity: "page" layer: "texts" } } } atoms { name: "publish" connection: "site" timeout { seconds: 30 } handler { inputs { name: "slug" type: FIELD_TYPE_TEXT required: true } outcomes: "published" outcomes: "rejected" changes { entity: "page" layer: "main" } events: "page_published" exposed: true } } atoms { name: "refresh" connection: "site" timeout { seconds: 30 } handler { outcomes: "done" } } events { name: "page_published" entity: "page" exposed: true } triggers { name: "after_publish" event { event: "page_published" } atom: "refresh" } # A reviewer approves a page, then the handler publishes it. Each outcome # names what follows: no stage holds a condition. workflows { name: "editorial" inputs { name: "slug" type: FIELD_TYPE_TEXT required: true } first_stage: "review" stages { name: "review" person { roles { role: "reviewer" } timeout { seconds: 259200 } outcomes: "approved" outcomes: "sent_back" second_person: true } transitions { outcome: "approved" next_stage: "go_live" } transitions { outcome: "sent_back" } } stages { name: "go_live" handler: "publish" transitions { outcome: "published" } transitions { outcome: "rejected" next_stage: "review" } } } # The translation vendor tells when the texts of a page are ready, and the # site is built again. It sends the secret of the webhook as a bearer token. webhooks { name: "translations" handler: "refresh" proof: WEBHOOK_PROOF_HEADER proof_header: "Authorization" proof_prefix: "Bearer " }