SSyncropel Docs

Apps that read, and published pages

How an app reads live workspace data, and how the owner publishes an app's files as a page.

Both features can be switched off on a workspace. When one is off, its endpoints answer exactly as an unknown path does, so a client can't tell a switched-off endpoint from one that doesn't exist.

Apps read live data

A core.app.v1 record can declare what it reads:

{ "reads": { "kinds": ["core.task.record.v1"], "threads": [] } }

The declaration is checked when the app is saved. A bad one is 422 APP_READS_INVALID {field, reason}. The rules:

  • kinds is an exact list of the record kinds the app may read. Account, keyring, private, connection, run, workspace-settings, assistant-memory and site kinds can never be read by an app.
  • Built-in system threads (th_site*, th_alerts, and the like) can never be read by an app.
  • Each thread must be one the person saving the app can read.
  • A new version of an app can't widen reads unless it is saved by the same person as the current version, or by the owner. A venture update that widens an app's reads is refused with UPDATE_WIDENING_NOT_ACCEPTED unless you accept the change.
  • Package apps declare kinds only.

POST /v1/apps/{app_id}/read (feature flag apps_read, scope records:read) returns only what the viewer is allowed to read and what the app's current version declares in reads.

StatusCodeMeaning
404APP_NOT_FOUNDOne answer for an unknown, unreachable or hidden app.
404APP_HAS_NO_READSThe app declares no reads.
403APP_READ_UNDECLAREDThe request names something the app didn't declare.

A read by ID of anything missing, unreachable or undeclared answers {record: null}. An answer holds at most 200 rows and 1 MiB, with read.truncated {at, next} when it is cut short. The next cursor works only for the same viewer, app and filter. A read through an app counts as the viewer's own read: the owner's GET /v1/reads lists it with reader_kind: app, app:<id>, and app {id, title}, via and for_name.

An app receives the actor ids of the records it reads, exactly as POST /v1/records/query would serve them to that viewer.

Suggested wording to show people:

  • APP_READS_INVALID: "This app's list of what it reads has a problem, so it wasn't saved." followed by the reason line.
  • APP_NOT_FOUND: "This app isn't available to you."
  • APP_READ_UNDECLARED: "This app tried to read something it didn't say it would, so nothing was read."
  • APP_HAS_NO_READS: "This app doesn't read anything." (never shown on screen; the command line and developers only)

Publishing pages

The owner can publish an app's files as a page at the workspace's own address. The sites feature flag turns this on.

  • core.app.v1 has a slug, the label in the page's address, set by the owner. Only one app can hold a slug.
  • POST /v1/sites/propose raises a publish proposal (proposal.proposes: "publish"). The owner's yes at POST /v1/decisions/{id}/decide settles it. The proposal is tied to {site, version, manifest_digest} and is checked again when accepted.
  • GET /v1/sites lists published sites. POST /v1/sites/unpublish and POST /v1/sites/checked finish the set.
  • A page's history lives on a thread named th_site_<label>, which only the workspace itself can write to. A client write to any thread whose id starts th_site_ is 403 SITE_THREAD_KERNEL_ONLY. Use a different thread name for your own records.
  • Records: core.site.publish.v1, core.site.publish_result.v1, core.site.purge.v1 (written by the workspace) and core.site.checked.v1 (written by the owner). Only the owner can read them.
  • A file's first write also writes a core.data.revision.v1 (prev_hash: null) naming its writer. An older file uploaded without one can't be published and answers SITE_FILE_NOT_OWNERS. Re-save the file, then publish it.
  • A site file removed by an erase is served as {path: null, sha256: null, removed_by_erase: true} everywhere, to the owner too.
  • Settings: SPL_SITES_DOOR_URL (the address of the publishing service) and SITES_RECEIPT_PUBLIC_KEY (normally fetched from GET /v1/sites/keys).

A file that only certain people can read is never published (SITE_SOURCE_PRIVATE).

Known limits: if two apps claim one address after an import, the older claim wins. The assistant can't publish; only the owner can propose a publish.

Suggested wording to show people for each code:

  • SITE_THREAD_KERNEL_ONLY: "Only the workspace itself writes a page's history, so this wasn't saved."
  • SITE_FILE_NOT_OWNERS: "That file wasn't added by the owner, so it can't go on a page."
  • SITE_SOURCE_PRIVATE: "Only some people can read that file, so it can't go on a page."
  • SITE_PUBLISH_STALE: "The files changed since this was asked, or it was asked more than a day ago, so nothing was published. Ask again."

See also

On this page