druxt 0.13.0 → 0.14.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # druxt
2
2
 
3
+ ## 0.14.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 85fff42: Added debug mode and Axios request logging.
8
+
9
+ ```
10
+ export default {
11
+ druxt: {
12
+ // Enable debug log messages.
13
+ debug: true,
14
+ }
15
+ }
16
+ ```
17
+
18
+ - 39e2e2e: Added ability to render readable JSON with the DruxtDebug component
19
+
20
+ ```jsx
21
+ <DruxtDebug :json="{ data: [{ one: true, two: false }] }" />
22
+ ```
23
+
24
+ - 9c33d82: Made summary prop optional on DruxtDebug component
25
+ - 45bc0b9: Added Druxt version to Nuxt badge
26
+
3
27
  ## 0.13.0
4
28
 
5
29
  ### Minor Changes
@@ -1,6 +1,9 @@
1
1
  <template>
2
2
  <details v-if="$nuxt.context.isDev">
3
3
  <summary v-text="title" />
4
+ <pre v-if="json"><!--
5
+ --><code>{{ JSON.stringify(json, null, ' ') }}</code><!--
6
+ --></pre>
4
7
  <slot />
5
8
  </details>
6
9
 
@@ -10,19 +13,36 @@
10
13
  <script>
11
14
 
12
15
  /**
13
- * Debug component for use by Druxt modules.
16
+ * Renders Debug data only when Nuxt is in development mode.
17
+ *
18
+ * @example @lang vue
19
+ * <DruxtDebug :json="entity" />
14
20
  */
15
21
  export default {
16
22
  /** */
17
23
  props: {
18
24
  /**
19
- * Text to display in summary.
25
+ * JSON data to format for readability.
26
+ *
27
+ * @type {*}
28
+ * @example @lang vue
29
+ * <DruxtDebug :json="{ data: [{ one: true, two: false }] }" />
30
+ */
31
+ json: {
32
+ type: [Array, Boolean, Object, Number, String],
33
+ default: undefined
34
+ },
35
+
36
+ /**
37
+ * Text to use for debug summary.
20
38
  *
21
39
  * @type {string}
40
+ * @example @lang vue
41
+ * <DruxtDebug summary="Foo bar" />
22
42
  */
23
43
  summary: {
24
44
  type: String,
25
- required: true,
45
+ default: 'Debug',
26
46
  },
27
47
  },
28
48
 
@@ -43,7 +63,9 @@ export default {
43
63
  *
44
64
  * @return {string}
45
65
  */
46
- title: ({ module, summary }) => `[${module.$options._componentTag}] ${summary}`,
66
+ title: ({ module, summary }) => module.$options._componentTag
67
+ ? `[${module.$options._componentTag}] ${summary}`
68
+ : summary,
47
69
  },
48
70
  };
49
71
  </script>
package/dist/druxt.esm.js CHANGED
@@ -2,11 +2,89 @@ import chalk from 'chalk';
2
2
  import { join, resolve } from 'path';
3
3
  import axios from 'axios';
4
4
  import { stringify } from 'querystring';
5
+ import consola from 'consola';
5
6
  import merge from 'deepmerge';
6
7
  import md5 from 'md5';
7
8
  import Vue from 'vue';
8
9
  import { DrupalJsonApiParams } from 'drupal-jsonapi-params';
9
10
 
11
+ var name = "druxt";
12
+ var version = "0.14.0";
13
+ var description = "The Fully Decoupled Drupal Framework for Nuxt.js.";
14
+ var keywords = [
15
+ "cms",
16
+ "decoupled",
17
+ "drupal",
18
+ "druxt",
19
+ "headless",
20
+ "jsonapi",
21
+ "json:api",
22
+ "nuxt",
23
+ "module",
24
+ "vue"
25
+ ];
26
+ var homepage = "https://druxtjs.org";
27
+ var bugs = {
28
+ url: "https://github.com/druxt/druxt.js/issues"
29
+ };
30
+ var repository = {
31
+ type: "git",
32
+ url: "git+https://github.com/druxt/druxt.js"
33
+ };
34
+ var license = "MIT";
35
+ var exports = {
36
+ ".": {
37
+ require: "./dist/druxt.ssr.js",
38
+ "import": "./dist/druxt.esm.js"
39
+ },
40
+ "./components/*": "./dist/components/*"
41
+ };
42
+ var main = "dist/druxt.ssr.js";
43
+ var module = "dist/druxt.esm.js";
44
+ var files = [
45
+ "dist",
46
+ "templates"
47
+ ];
48
+ var dependencies = {
49
+ "@nuxtjs/proxy": "^2.1.0",
50
+ axios: "^0.21.1",
51
+ chalk: "^4.1.2",
52
+ deepmerge: "^4.2.2",
53
+ "drupal-jsonapi-params": "^1.2.1",
54
+ md5: "^2.3.0",
55
+ querystring: "^0.2.0",
56
+ scule: "^0.2.0"
57
+ };
58
+ var peerDependencies = {
59
+ consola: "*"
60
+ };
61
+ var optionalDependencies = {
62
+ "core-js": "^3.16.1",
63
+ vue: "^2.6.14",
64
+ vuex: "^3.6.2"
65
+ };
66
+ var publishConfig = {
67
+ access: "public"
68
+ };
69
+ var meta = {
70
+ name: name,
71
+ version: version,
72
+ description: description,
73
+ keywords: keywords,
74
+ homepage: homepage,
75
+ bugs: bugs,
76
+ repository: repository,
77
+ license: license,
78
+ exports: exports,
79
+ main: main,
80
+ module: module,
81
+ files: files,
82
+ dependencies: dependencies,
83
+ peerDependencies: peerDependencies,
84
+ optionalDependencies: optionalDependencies,
85
+ publishConfig: publishConfig
86
+ };
87
+
10
88
  const DruxtNuxtModule = function(moduleOptions = {}) {
11
89
  var _a;
12
90
  const options = {
@@ -56,12 +134,16 @@ const DruxtNuxtModule = function(moduleOptions = {}) {
56
134
  });
57
135
  this.options.store = true;
58
136
  this.options.components = (_a = this.options.components) != null ? _a : true;
59
- this.options.cli.badgeMessages.push(`${chalk.bold("Druxt API:")} ${chalk.blue.underline(options.baseUrl + options.endpoint)}`);
137
+ this.options.cli.badgeMessages.push(`${chalk.blue.bold("Druxt")} @ v${meta.version}`);
138
+ this.options.cli.badgeMessages.push(`${chalk.bold("API:")} ${chalk.blue.underline(options.baseUrl + options.endpoint)}`);
60
139
  };
61
- DruxtNuxtModule.meta = require("../package.json");
140
+ DruxtNuxtModule.meta = meta;
62
141
 
63
142
  class DruxtClient {
64
143
  constructor(baseUrl, options = {}) {
144
+ this.log = consola.create({ defaults: {
145
+ tag: "DruxtClient"
146
+ } });
65
147
  if (!baseUrl) {
66
148
  throw new Error("The 'baseUrl' parameter is required.");
67
149
  }
@@ -73,6 +155,16 @@ class DruxtClient {
73
155
  axiosSettings = Object.assign(axiosSettings, options.axios);
74
156
  }
75
157
  this.axios = axios.create(axiosSettings);
158
+ if (options.debug) {
159
+ const log = this.log;
160
+ this.axios.interceptors.request.use((config) => {
161
+ log.info(config.url);
162
+ return config;
163
+ }, (error) => {
164
+ log.error(error);
165
+ return Promise.reject(error);
166
+ });
167
+ }
76
168
  this.options = {
77
169
  endpoint: "/jsonapi",
78
170
  jsonapiResourceConfig: "jsonapi_resource_config--jsonapi_resource_config",
package/dist/druxt.ssr.js CHANGED
@@ -6,6 +6,7 @@ const chalk = require('chalk');
6
6
  const path = require('path');
7
7
  const axios = require('axios');
8
8
  const querystring = require('querystring');
9
+ const consola = require('consola');
9
10
  const merge = require('deepmerge');
10
11
  const md5 = require('md5');
11
12
  const Vue = require('vue');
@@ -15,10 +16,88 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
15
16
 
16
17
  const chalk__default = /*#__PURE__*/_interopDefaultLegacy(chalk);
17
18
  const axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
19
+ const consola__default = /*#__PURE__*/_interopDefaultLegacy(consola);
18
20
  const merge__default = /*#__PURE__*/_interopDefaultLegacy(merge);
19
21
  const md5__default = /*#__PURE__*/_interopDefaultLegacy(md5);
20
22
  const Vue__default = /*#__PURE__*/_interopDefaultLegacy(Vue);
21
23
 
24
+ var name = "druxt";
25
+ var version = "0.14.0";
26
+ var description = "The Fully Decoupled Drupal Framework for Nuxt.js.";
27
+ var keywords = [
28
+ "cms",
29
+ "decoupled",
30
+ "drupal",
31
+ "druxt",
32
+ "headless",
33
+ "jsonapi",
34
+ "json:api",
35
+ "nuxt",
36
+ "module",
37
+ "vue"
38
+ ];
39
+ var homepage = "https://druxtjs.org";
40
+ var bugs = {
41
+ url: "https://github.com/druxt/druxt.js/issues"
42
+ };
43
+ var repository = {
44
+ type: "git",
45
+ url: "git+https://github.com/druxt/druxt.js"
46
+ };
47
+ var license = "MIT";
48
+ var exports$1 = {
49
+ ".": {
50
+ require: "./dist/druxt.ssr.js",
51
+ "import": "./dist/druxt.esm.js"
52
+ },
53
+ "./components/*": "./dist/components/*"
54
+ };
55
+ var main = "dist/druxt.ssr.js";
56
+ var module$1 = "dist/druxt.esm.js";
57
+ var files = [
58
+ "dist",
59
+ "templates"
60
+ ];
61
+ var dependencies = {
62
+ "@nuxtjs/proxy": "^2.1.0",
63
+ axios: "^0.21.1",
64
+ chalk: "^4.1.2",
65
+ deepmerge: "^4.2.2",
66
+ "drupal-jsonapi-params": "^1.2.1",
67
+ md5: "^2.3.0",
68
+ querystring: "^0.2.0",
69
+ scule: "^0.2.0"
70
+ };
71
+ var peerDependencies = {
72
+ consola: "*"
73
+ };
74
+ var optionalDependencies = {
75
+ "core-js": "^3.16.1",
76
+ vue: "^2.6.14",
77
+ vuex: "^3.6.2"
78
+ };
79
+ var publishConfig = {
80
+ access: "public"
81
+ };
82
+ const meta = {
83
+ name: name,
84
+ version: version,
85
+ description: description,
86
+ keywords: keywords,
87
+ homepage: homepage,
88
+ bugs: bugs,
89
+ repository: repository,
90
+ license: license,
91
+ exports: exports$1,
92
+ main: main,
93
+ module: module$1,
94
+ files: files,
95
+ dependencies: dependencies,
96
+ peerDependencies: peerDependencies,
97
+ optionalDependencies: optionalDependencies,
98
+ publishConfig: publishConfig
99
+ };
100
+
22
101
  const DruxtNuxtModule = function(moduleOptions = {}) {
23
102
  var _a;
24
103
  const options = {
@@ -68,12 +147,16 @@ const DruxtNuxtModule = function(moduleOptions = {}) {
68
147
  });
69
148
  this.options.store = true;
70
149
  this.options.components = (_a = this.options.components) != null ? _a : true;
71
- this.options.cli.badgeMessages.push(`${chalk__default['default'].bold("Druxt API:")} ${chalk__default['default'].blue.underline(options.baseUrl + options.endpoint)}`);
150
+ this.options.cli.badgeMessages.push(`${chalk__default['default'].blue.bold("Druxt")} @ v${meta.version}`);
151
+ this.options.cli.badgeMessages.push(`${chalk__default['default'].bold("API:")} ${chalk__default['default'].blue.underline(options.baseUrl + options.endpoint)}`);
72
152
  };
73
- DruxtNuxtModule.meta = require("../package.json");
153
+ DruxtNuxtModule.meta = meta;
74
154
 
75
155
  class DruxtClient {
76
156
  constructor(baseUrl, options = {}) {
157
+ this.log = consola__default['default'].create({ defaults: {
158
+ tag: "DruxtClient"
159
+ } });
77
160
  if (!baseUrl) {
78
161
  throw new Error("The 'baseUrl' parameter is required.");
79
162
  }
@@ -85,6 +168,16 @@ class DruxtClient {
85
168
  axiosSettings = Object.assign(axiosSettings, options.axios);
86
169
  }
87
170
  this.axios = axios__default['default'].create(axiosSettings);
171
+ if (options.debug) {
172
+ const log = this.log;
173
+ this.axios.interceptors.request.use((config) => {
174
+ log.info(config.url);
175
+ return config;
176
+ }, (error) => {
177
+ log.error(error);
178
+ return Promise.reject(error);
179
+ });
180
+ }
88
181
  this.options = {
89
182
  endpoint: "/jsonapi",
90
183
  jsonapiResourceConfig: "jsonapi_resource_config--jsonapi_resource_config",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "druxt",
3
- "version": "0.13.0",
3
+ "version": "0.14.0",
4
4
  "description": "The Fully Decoupled Drupal Framework for Nuxt.js.",
5
5
  "keywords": [
6
6
  "cms",
@@ -46,6 +46,9 @@
46
46
  "querystring": "^0.2.0",
47
47
  "scule": "^0.2.0"
48
48
  },
49
+ "peerDependencies": {
50
+ "consola": "*"
51
+ },
49
52
  "optionalDependencies": {
50
53
  "core-js": "^3.16.1",
51
54
  "vue": "^2.6.14",