Skip to content

General

Reindert edited this page Apr 1, 2023 · 40 revisions

The most admin pages will consist of 1 section. You will receive an array with components per section. The first component will consist of type section. This array is completed by other components.

All possible keys in an object will always be present. In an array, you do not get back the objects that are not defined (in the blade files). For example, the object with type help will not be present if it is not defined.

[
  {
    "parent_key": "object",
    "key": "/object/views/home.blade.php",
    "type": "object",
    "decorations": [
      {
        "type": "name",
        "data": {
          "name": "19d2d8b610f7e538c42674286011fb66b63acb32"
        }
      }
    ],
    "source": {
      "directory": "views",
      "file": "home.blade.php",
      "line": 0,
      "from": 0,
      "to": 0
    }
  },
  {
    "parent_key": "section",
    "key": "/section/pages",
    "type": "section",
    "decorations": [
      {
        "type": "label",
        "data": {
          "value": "Pages"
        }
      }
    ],
    "source": {
      "directory": "views",
      "file": "home.blade.php",
      "line": 43,
      "from": 27,
      "to": 34
    }
  },
  {
    "parent_key": "pages",
    "key": "/section/pages/intro",
    "type": "group",
    "decorations": [
      {
        "type": "label",
        "data": {
          "value": "Intro"
        }
      }
    ],
    "source": {
      "directory": "views",
      "file": "home.blade.php",
      "line": 43,
      "from": 27,
      "to": 34
    }
  },
  {
    "parent_key": "pages.intro",
    "key": "/section/pages/intro/shape",
    "type": "select",
    "decorations": [
      {
        "type": "label",
        "value": "Shape"
      },
      {
        "type": "options",
        "data": {
          "options": [
            {
              "key": "shape1",
              "value": "Cycle"
            },
            {
              "key": "shape2",
              "value": "Square"
            }
          }
        ]
      }
    ],
    "source": {
      "directory": "views",
      "file": "home.blade.php",
      "line": 43,
      "from": 27,
      "to": 34
    }
  }
]

Get components endpoint parameters

Get one component

GET /structure/components?key=/section/intro/title

Get the components with a specific parent key

GET /structure/components?parent_key=/section/intro

Get the components with prefixed with this key

GET /structure/components?key_path=/section/intro

Key prefix

All components have a prefix. This is to differentiate between the different components.

Section

The section arises because the helper function section(...) has been called. This will usually be used to show fields in the admin.

Objects

The object prefix is used to be a reference to a file. This component contains a decoration of type "object_name". The admin will probably have nothing to do with object names. "Object Names" is in GitHub a concept: An object name consists of a hash created by the contents of a file. This hash is made in an old way (SHA-1) and is insecure. So don't just use this hash in a way that a user can see.

https://git-scm.com/book/en/v2/Git-Internals-Git-Objects

JSON:API

We cannot use the JSON:API standard because we want to save a file with supplied components in 1 request. This is possible in a fairly new version, but is not possible at all in libraries.

See https://jsonapi.org/ext/atomic/

Clone this wiki locally