@dropsh/plugin-schemata 0.0.2 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -6
- package/dist/plugins/schemata/src/index.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -3,11 +3,14 @@
|
|
|
3
3
|
Authoritative JSON Schema source for [dropsh](https://github.com/pen-drop/dropsh),
|
|
4
4
|
the entity-agnostic CLI for Drupal 11 JSON:API.
|
|
5
5
|
|
|
6
|
-
By default
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
`
|
|
6
|
+
dropsh works without this plugin. By default it derives a shallow schema from
|
|
7
|
+
JSON:API sample records, which is enough to discover field names but does not
|
|
8
|
+
know Drupal's required fields or constraints.
|
|
9
|
+
|
|
10
|
+
With this plugin installed, `dropsh schema` reads the **authoritative** schema
|
|
11
|
+
from Drupal's `schemata` module. The generated schema is more precise, so
|
|
12
|
+
client-side validation in `create` / `update` can catch invalid payloads before
|
|
13
|
+
they are sent to Drupal.
|
|
11
14
|
|
|
12
15
|
## Install
|
|
13
16
|
|
|
@@ -40,7 +43,23 @@ falls back to the base schema.
|
|
|
40
43
|
## Required Drupal modules
|
|
41
44
|
|
|
42
45
|
- [`schemata`](https://www.drupal.org/project/schemata)
|
|
43
|
-
- `
|
|
46
|
+
- `schemata_json_schema` (submodule of the schemata project)
|
|
47
|
+
|
|
48
|
+
Install and enable both on the Drupal site:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
composer require drupal/schemata
|
|
52
|
+
drush en schemata schemata_json_schema
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Grant the role used by dropsh access to the Schemata data model endpoint:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
drush role:perm:add "content_editor" "access schemata data models"
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
For OAuth2, grant the permission to the user role or client credential access
|
|
62
|
+
context used by the configured auth provider.
|
|
44
63
|
|
|
45
64
|
## License
|
|
46
65
|
|
|
@@ -3,7 +3,7 @@ import { fetchSchemata, SCHEMATA_MISS } from "./schemata.js";
|
|
|
3
3
|
export function schemataPlugin() {
|
|
4
4
|
return {
|
|
5
5
|
id: "schemata",
|
|
6
|
-
requiredModules: ["schemata", "
|
|
6
|
+
requiredModules: ["schemata", "schemata_json_schema"],
|
|
7
7
|
async extendSchema(entityType, bundle, baseSchema, ctx) {
|
|
8
8
|
let result;
|
|
9
9
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dropsh/plugin-schemata",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/plugins/schemata/src/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"typescript": "^5.6.0",
|
|
21
21
|
"vitest": "^4.1.8",
|
|
22
|
-
"dropsh": "0.
|
|
22
|
+
"dropsh": "0.1.1"
|
|
23
23
|
},
|
|
24
24
|
"scripts": {
|
|
25
25
|
"build": "tsc",
|