11# Drupal JSON: API  Entities  
22
33[ ![ CircleCI] ( https://circleci.com/gh/Realityloop/drupal_jsonapi_entities.svg?style=svg )] ( https://circleci.com/gh/Realityloop/drupal_jsonapi_entities ) 
4+ [ ![ Known Vulnerabilities] ( https://snyk.io//test/github/Realityloop/drupal_jsonapi_entities/badge.svg?targetFile=package.json )] ( https://snyk.io//test/github/Realityloop/drupal_jsonapi_entities?targetFile=package.json ) 
5+ [ ![ codecov] ( https://codecov.io/gh/Realityloop/drupal_jsonapi_entities/branch/develop/graph/badge.svg )] ( https://codecov.io/gh/Realityloop/drupal_jsonapi_entities ) 
46
5- Pull Drupal Entity form and field schemas into your Node.js app with ease.
7+ Build a Drupal Entity form/view field schema from your Drupal JSON: API  entitiy
8+ with ease.
69
710## Installation  
811
@@ -35,7 +38,7 @@ The constructor takes two arguments:
3538### getFormSchema()  
3639
3740``` js 
38- const  schema  =  await  drupalEntities .getFormSchema (entityType, bundle, mode)
41+ const  formSchema  =  await  drupalEntities .getFormSchema (entityType, bundle, mode)
3942``` 
4043
4144The method takes three arguments:
@@ -50,6 +53,7 @@ Returns a JSON object:
5053  -  ** cardinality** : Allowed number of values.
5154  -  ** description** : Help text.
5255  -  ** id** : Machine name.
56+   -  ** property** : True if field is a property on the Drupal entity.
5357  -  ** label** : Label.
5458  -  ** required** : Required field.
5559  -  ** settings** : Merged object of field settings.
@@ -58,10 +62,11 @@ Returns a JSON object:
5862  -  ** group** : (optional) Group.
5963-  ** groups** : An array of Drupal Field Group module group objects, sorted by weight.
6064  -  ** children** : Array of fields in group.
65+   -  ** format_settings** : Settings for the display of the group.
66+   -  ** format_type** : Type of group for display.
6167  -  ** id** : Machine name.
6268  -  ** label** : Label.
63-   -  ** weight** : Form display weight.
64- -  ** keys** : An array of field keys.
69+   -  ** weight** : Weight.
6570
6671#### Drupal requirements  
6772
@@ -76,10 +81,58 @@ Permissions:
7681-  ` administer display modes ` 
7782-  ` administer ENTITY_TYPE fields ` 
7883
84+ ### getViewSchema()  
85+ 
86+ ``` js 
87+ const  viewSchema  =  await  drupalEntities .getViewSchema (entityType, bundle, mode)
88+ ``` 
89+ 
90+ The method takes three arguments:
91+ 
92+ -  ` entityType ` : The Drupal entity type ID.
93+ -  ` bundle ` : The Drupal bundle ID for the entity type.
94+ -  ` mode ` : The view display mode. Default: ` default ` .
95+ 
96+ Returns a JSON object:
97+ 
98+ -  ** fields** : An array of field objects, sorted by weight.
99+   -  ** description** : Help text.
100+   -  ** id** : Machine name.
101+   -  ** property** : True if field is a property on the Drupal entity.
102+   -  ** label** : Label.
103+   -  ** labelPosition** : Label position.
104+   -  ** required** : Required field.
105+   -  ** settings** : Merged object of field settings.
106+   -  ** thirdPartySettings** : Settings of any third party modules.
107+   -  ** type** : Field type machine name.
108+   -  ** weight** : Form display field weight.
109+   -  ** group** : (optional) Group.
110+ -  ** groups** : An array of Drupal Field Group module group objects, sorted by weight.
111+   -  ** children** : Array of fields in group.
112+   -  ** format_settings** : Settings for the display of the group.
113+   -  ** format_type** : Type of group for display.
114+   -  ** id** : Machine name.
115+   -  ** label** : Label.
116+   -  ** weight** : Weight.
117+ 
118+ #### Drupal requirements  
119+ 
120+ JSON: API  resources:
121+ 
122+ -  ` entity_form_display--entity_form_display ` 
123+ -  ` entity_view_display--entity_view_display ` 
124+ -  ` field_config--field_config ` 
125+ -  ` field_storage_config--field_storage_config ` 
126+ 
127+ Permissions:
128+ 
129+ -  ` administer display modes ` 
130+ -  ` administer ENTITY_TYPE fields ` 
131+ 
79132## Nuxt.js module  
80133
81134Drupal JSON: API  Entities provides a Nuxt.js module for easily caching the
82- schema.
135+ schema(s) .
83136
84137### Getting started with Nuxt.js  
85138
@@ -106,17 +159,34 @@ module.exports = {
106159}
107160``` 
108161
109- Add a ` drupalJSONAPIEntities `  section to your ` nuxt.config.js `  file.
162+ Add a ` drupalJSONAPIEntities `  section to your ` nuxt.config.js `  file in the
163+ following format for all required Entity types, Bundles, Schema types and
164+ Modes:
110165
111166``` js 
112167module .exports  =  {
113168  drupalJSONAPIEntities:  {
114-     ' entityType' :  { ' bundle' :  [' mode'  ] }
169+     ' entityType' :  { ' bundle' :  { ' type' :  [ ' mode'   ] } }
170+   }
171+ }
172+ ``` 
173+ 
174+ Example:
175+ ``` js 
176+ module .exports  =  {
177+   drupalJSONAPIEntities:  {
178+     ' node' :  {
179+       ' recipe' :  {
180+         form:  [ ' default'   ],
181+         view:  [ ' default'   ],
182+       }
183+     }
115184  }
116185}
117186``` 
118187
119- The module provides a plugin, which returns the Drupal JSON: API  Entities schema.
188+ The module provides a plugin, which returns the Drupal JSON: API  Entities
189+ schema(s).
120190
121191``` js 
122192this .$drupalJSONAPIEntities ()
0 commit comments