Link Integrity

When you create relations between content objects in Nick (for example, via relation fields or links in text blocks), these relations are stored in the database. The user interface will use those stored relations to show a warning when you try to delete a content object that is still referenced elsewhere. Link integrity avoids broken links (“breaches”) in the site.

The @linkintegrity endpoint returns the list of reference breaches that would happen if some content items would be deleted. This information can be used to show the editor a confirmation dialog.

This check includes content objects that are located within a content object (“folderish content”).

You can call the /@linkintegrity endpoint on the site root with a GET request and a list of content UIDs as a query parameter:

GET /@linkintegrity?uids=32215c67-86de-462a-8cc0-eabcd2b39c26 HTTP/1.1
Accept: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJhZG1pbiIsImZ1bGxuYW1lIjoiQWRtaW4iLCJpYXQiOjE2NDkzMTI0NDl9.RS1Ny_r0v7vIylFfK6q0JVJrkiDuTOh9iG9IL8xbzAk

Or use the client directly:

import { Client } from '@robgietema/nick';

const cli = Client.initialize({ apiPath: 'http://localhost:8080' });
const login = await cli.login({
  data: { login: 'admin', password: 'admin' },
});

const { data } = await cli.linkintegrity({
  token: login.data.token,
  query: {
    uids: '32215c67-86de-462a-8cc0-eabcd2b39c26',
  },
});

The endpoint accepts a single parameter:

  • uids: A list of object UIDs that you want to check.

The server will respond with the result:

HTTP/1.1 200 OK
Content-Type: application/json

[
  {
    "@id": "http://localhost:8080/news",
    "@type": "Folder",
    "title": "News",
    "description": "News Items",
    "review_state": "published",
    "breaches": [
      {
        "@id": "http://localhost:8080/events",
        "uid": "1a2123ba-14e8-4910-8e6b-c04a40d72a41",
        "title": "Events"
      }
    ],
    "items_total": 1
  }
]

The result includes a list of objects corresponding to the UIDs that were requested. Each result object includes:

  • breaches: A list of breaches (sources of relations that would be broken)
  • items_total: Count of items contained inside the specified UIDs.

This site uses Just the Docs, a documentation theme for Jekyll.