Skip to content

Commit 33d8090

Browse files
committed
Merge branch 'release/0.3.0'
2 parents 642282e + f688cd5 commit 33d8090

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+14808
-3887
lines changed

.circleci/config.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ jobs:
1111
steps:
1212
- checkout
1313

14+
- run:
15+
name: Install Codecov
16+
command: npm install codecov
17+
1418
- restore_cache:
1519
keys:
1620
- v1-dependencies-{{ checksum "package.json" }}
@@ -22,6 +26,10 @@ jobs:
2226
name: Run tests
2327
command: npm test
2428

29+
- run:
30+
name: Upload coverage report
31+
command: npx codecov
32+
2533
- save_cache:
2634
paths:
2735
- node_modules

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
node_modules
1+
coverage
2+
node_modules
3+
.nuxt
4+
.vscode

README.md

Lines changed: 78 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
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

4144
The 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

81134
Drupal 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
112167
module.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
122192
this.$drupalJSONAPIEntities()

nuxt/__fixtures__/nuxt.config.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
const path = require('path')
2+
3+
module.exports = {
4+
srcDir: __dirname,
5+
rootDir: path.resolve(__dirname),
6+
buildDir: path.resolve(__dirname, '.nuxt'),
7+
dev: false,
8+
9+
modules: [
10+
{
11+
handler: require('../index').default,
12+
options: {
13+
baseUrl: 'https://example.com'
14+
}
15+
}
16+
],
17+
drupalJSONAPIEntities: {
18+
node: [ 'recipe' ]
19+
}
20+
}

0 commit comments

Comments
 (0)