Socket
Socket
Sign inDemoInstall

druxt

Package Overview
Dependencies
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

druxt - npm Package Compare versions

Comparing version 0.11.0 to 0.12.0

29

CHANGELOG.md
# druxt
## 0.12.0
### Minor Changes
- 897dcbc: Added createResource method to DruxtClient
```js
this.$druxt.createResource({ type, attributes: {}, relationships: {} });
```
- 897dcbc: Added updateResource method to DruxtClient
```js
await this.$druxt.updateResource({
type,
id,
attributes: {},
relationships: {}
});
```
- 4504a2f: Added getRelated() method
```js
await this.$druxt.getRelated(type, id, related);
```
- e3e634c: Enabled Components auto-discovery by default
## 0.11.0

@@ -4,0 +33,0 @@

@@ -11,2 +11,3 @@ import chalk from 'chalk';

const DruxtNuxtModule = function(moduleOptions = {}) {
var _a;
const options = {

@@ -31,2 +32,3 @@ endpoint: "/jsonapi",

this.options.store = true;
this.options.components = (_a = this.options.components) != null ? _a : true;
this.options.cli.badgeMessages.push(`${chalk.bold("Druxt API:")} ${chalk.blue.underline(options.baseUrl + options.endpoint)}`);

@@ -93,2 +95,22 @@ };

}
async createResource(resource) {
if (resource.id) {
return this.updateResource(resource);
}
const { href } = await this.getIndex(resource.type);
if (!href) {
return false;
}
let response;
try {
response = await this.axios.post(href, { data: resource }, {
headers: {
"Content-Type": "application/vnd.api+json"
}
});
} catch (err) {
response = (err.response || {}).data || err.message;
}
return response;
}
async getCollection(type, query) {

@@ -147,2 +169,18 @@ const { href } = await this.getIndex(type);

}
async getRelated(type, id, related, query) {
if (!id || !type || !related) {
return false;
}
let { href } = await this.getIndex(type);
if (!href) {
href = this.options.endpoint + "/" + type.replace("--", "/");
}
const url = this.buildQueryUrl(`${href}/${id}/${related}`, query);
try {
const related2 = await this.axios.get(url);
return related2.data;
} catch (e) {
return false;
}
}
async getResource(type, id, query) {

@@ -164,2 +202,20 @@ if (!id || !type) {

}
async updateResource(resource) {
const { href } = await this.getIndex(resource.type);
if (!href) {
return false;
}
const url = [href, resource.id].join("/");
let response;
try {
response = await this.axios.patch(url, { data: resource }, {
headers: {
"Content-Type": "application/vnd.api+json"
}
});
} catch (err) {
response = (err.response || {}).data || err.message;
}
return response;
}
}

@@ -166,0 +222,0 @@

@@ -23,2 +23,3 @@ 'use strict';

const DruxtNuxtModule = function(moduleOptions = {}) {
var _a;
const options = {

@@ -43,2 +44,3 @@ endpoint: "/jsonapi",

this.options.store = true;
this.options.components = (_a = this.options.components) != null ? _a : true;
this.options.cli.badgeMessages.push(`${chalk__default['default'].bold("Druxt API:")} ${chalk__default['default'].blue.underline(options.baseUrl + options.endpoint)}`);

@@ -105,2 +107,22 @@ };

}
async createResource(resource) {
if (resource.id) {
return this.updateResource(resource);
}
const { href } = await this.getIndex(resource.type);
if (!href) {
return false;
}
let response;
try {
response = await this.axios.post(href, { data: resource }, {
headers: {
"Content-Type": "application/vnd.api+json"
}
});
} catch (err) {
response = (err.response || {}).data || err.message;
}
return response;
}
async getCollection(type, query) {

@@ -159,2 +181,18 @@ const { href } = await this.getIndex(type);

}
async getRelated(type, id, related, query) {
if (!id || !type || !related) {
return false;
}
let { href } = await this.getIndex(type);
if (!href) {
href = this.options.endpoint + "/" + type.replace("--", "/");
}
const url = this.buildQueryUrl(`${href}/${id}/${related}`, query);
try {
const related2 = await this.axios.get(url);
return related2.data;
} catch (e) {
return false;
}
}
async getResource(type, id, query) {

@@ -176,2 +214,20 @@ if (!id || !type) {

}
async updateResource(resource) {
const { href } = await this.getIndex(resource.type);
if (!href) {
return false;
}
const url = [href, resource.id].join("/");
let response;
try {
response = await this.axios.patch(url, { data: resource }, {
headers: {
"Content-Type": "application/vnd.api+json"
}
});
} catch (err) {
response = (err.response || {}).data || err.message;
}
return response;
}
}

@@ -178,0 +234,0 @@

2

package.json
{
"name": "druxt",
"version": "0.11.0",
"version": "0.12.0",
"description": "The Fully Decoupled Drupal Framework for Nuxt.js.",

@@ -5,0 +5,0 @@ "keywords": [

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc