Files
directus/docs/reference/system/extensions.md
daedalus b189fd4594 Add enable/disable support for bundle type extensions (#20940)
* Add enable/disable support for bundle type extensions

* added changeset

* Update app/src/modules/settings/routes/extensions/components/extension-item.vue

Co-authored-by: Brainslug <br41nslug@users.noreply.github.com>

* add docs

* bundle with app extensions should display reload on prod

* use early returns for toggle logic

Co-Authored-By: Brainslug <br41nslug@users.noreply.github.com>

* add enable/disable all for partially enabled

* refresh message should work for enable and disable all

* Clearer tooltip for app extensions in dev

---------

Co-authored-by: Brainslug <br41nslug@users.noreply.github.com>
Co-authored-by: Pascal Jufer <pascal-jufer@bluewin.ch>
2024-01-05 13:03:24 +01:00

4.4 KiB

description, readTime, pageClass
description readTime pageClass
REST and GraphQL API documentation on the Extensions collection in Directus. 1 min read page-reference

Extensions

The extensions endpoints are used by the Admin App to retrieve what extensions to install. Learn more about Extensions.

The Extension Object

bundle string | null
Name of the bundle the extension is in.

name string
Unique name of the extension.

Meta

Directus metadata for the extension. Where the configuration for the extension in the current project is stored.

enabled boolean
Whether or not the extension is enabled.

Schema

Information about the installed extension. Can't be changed.

type string
Type of the extension. One of 'interface', 'display', 'layout', 'module', 'panel', 'hook', 'endpoint', 'operation', 'bundle'.

local boolean
Whether the extension exists in the local extensions folder or is loaded from node_modules.

version string
The currently loaded version of the plugin as defined by its package.json.

partial boolean
Whether or not a bundles entries can be individually disabled. This is applicable to bundle type extensions only.

{
  "name": "my-bundle-operation",
  "bundle": "directus-extension-my-bundle",
  "schema": {
    "type": "operation",
    "local": true,
    "version": "1.0.0"
  },
  "meta": {
    "enabled": true
  }
}

List Extensions

List the installed extensions and their configuration in the project.

Request

GET /extensions/

POST /graphql/system

type Query {
	extensions: [extension]
}
import { createDirectus, rest, readExtensions } from '@directus/sdk';

const client = createDirectus('directus_project_url').with(rest());

const result = await client.request(readExtensions());

Query Parameters

This endpoint doesn't currently support any query parameters.

Response

An array of interface extension keys.

Example

GET /extensions/

POST /graphql/system

query {
	extensions {
		name
		type
	}
}
import { createDirectus, rest, readExtensions } from '@directus/sdk';

const client = createDirectus('https://directus.example.com').with(rest());

const result = await client.request(readExtensions());

Update an Extension

Update an existing extension.

Request

PATCH /extension/:bundleOrName/:name?

Provide a partial extension object as the body of your request.

POST /graphql/system

type Mutation {
	update_extensions_item(bundle: String, name: String!, data: update_directus_extensions_input!): directus_extensions
}
import { createDirectus, rest, updateExtension } from '@directus/sdk';

const client = createDirectus('directus_project_url').with(rest());

const result = await client.request(updateExtension(bundle, name, partial_extension_object));

Query Parameters

Doesn't support any query parameters.

Request Body

A partial extension object.

Response

Returns the extension object for the updated extension.

Example

PATCH /extensions/my-bundle/draw-interface

{
	"meta": {
		"enabled": false
	}
}

POST /graphql/system

mutation {
	update_extensions_item(bundle: null, name: "my-custom-display", data: { meta: { enabled: true } }) {
		name
		type
	}
}
import { createDirectus, rest, updateExtension } from '@directus/sdk';

const client = createDirectus('https://directus.example.com').with(rest());

const result = await client.request(
	updateExtension('directus-extension-bundle', 'stock-display', {
		meta: {
			enabled: false
		},
	})
);