druxt 0.21.0 → 0.22.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/dist/druxt.esm.js CHANGED
@@ -250,7 +250,7 @@ class DruxtClient {
250
250
  }
251
251
 
252
252
  var name = "druxt";
253
- var version = "0.21.0";
253
+ var version = "0.22.0";
254
254
  var description = "The Fully Decoupled Drupal Framework for Nuxt.js.";
255
255
  var keywords = [
256
256
  "cms",
@@ -292,26 +292,26 @@ var files = [
292
292
  var dependencies = {
293
293
  "@nuxtjs/axios": "^5.13.6",
294
294
  "@nuxtjs/proxy": "^2.1.0",
295
- "@vue/devtools-api": "^6.4.5",
295
+ "@vue/devtools-api": "^6.5.0",
296
296
  chalk: "^4.1.2",
297
- deepmerge: "^4.2.2",
298
- "drupal-jsonapi-params": "^2.1.0",
299
- "express-rate-limit": "^6.6.0",
297
+ deepmerge: "^4.3.1",
298
+ "drupal-jsonapi-params": "^2.2.0",
299
+ "express-rate-limit": "^6.7.0",
300
300
  "launch-editor": "^2.6.0",
301
301
  md5: "^2.3.0",
302
302
  querystring: "^0.2.1",
303
303
  scule: "^0.3.2"
304
304
  };
305
305
  var devDependencies = {
306
- "@storybook/addon-docs": "^6.5.10"
306
+ "@storybook/addon-docs": "^6.5.16"
307
307
  };
308
308
  var peerDependencies = {
309
309
  axios: "*",
310
310
  consola: "*"
311
311
  };
312
312
  var optionalDependencies = {
313
- "core-js": "^3.25.1",
314
- vue: "^2.7.10",
313
+ "core-js": "^3.31.0",
314
+ vue: "^2.7.14",
315
315
  vuex: "^3.6.2"
316
316
  };
317
317
  var publishConfig = {
@@ -521,13 +521,33 @@ const DruxtStore = ({ store }) => {
521
521
  }
522
522
  resource = merge(state.resources[type][id][prefix] || {}, resource, { arrayMerge: (dst, src) => src });
523
523
  Vue.set(state.resources[type][id], prefix, resource);
524
+ },
525
+ flushCollection(state, { type, hash, prefix }) {
526
+ if (!type)
527
+ Vue.set(state, "collections", {});
528
+ else if (type && !hash && !prefix)
529
+ Vue.set(state.collections, type, {});
530
+ else if (type && hash && !prefix)
531
+ Vue.set(state.collections[type], hash, {});
532
+ else if (type && hash && prefix)
533
+ Vue.set(state.collections[type][hash], prefix, {});
534
+ },
535
+ flushResource(state, { type, id, prefix }) {
536
+ if (!type)
537
+ Vue.set(state, "resources", {});
538
+ else if (type && !id && !prefix)
539
+ Vue.set(state.resources, type, {});
540
+ else if (type && id && !prefix)
541
+ Vue.set(state.resources[type], id, {});
542
+ else if (type && id && prefix)
543
+ Vue.set(state.resources[type][id], prefix, {});
524
544
  }
525
545
  },
526
546
  actions: {
527
- async getCollection({ commit, state }, { type, query, prefix }) {
547
+ async getCollection({ commit, state }, { type, query, prefix, bypassCache = false }) {
528
548
  const queryObject = getDrupalJsonApiParams(query).getQueryObject();
529
549
  const hash = query ? md5(JSON.stringify({ ...queryObject, fields: {}, include: [] })) : "_default";
530
- if (((state.collections[type] || {})[hash] || {})[prefix]) {
550
+ if (!bypassCache && ((state.collections[type] || {})[hash] || {})[prefix]) {
531
551
  return {
532
552
  ...state.collections[type][hash][prefix],
533
553
  data: state.collections[type][hash][prefix].data.map((o) => ((state.resources[o.type][o.id] || {})[prefix] || {}).data)
@@ -537,7 +557,7 @@ const DruxtStore = ({ store }) => {
537
557
  commit("addCollection", { collection: { ...collection }, type, hash, prefix });
538
558
  return collection;
539
559
  },
540
- async getResource({ commit, dispatch, state }, { type, id, query, prefix }) {
560
+ async getResource({ commit, dispatch, state }, { type, id, query, prefix, bypassCache = false }) {
541
561
  const storedResource = ((state.resources[type] || {})[id] || {})[prefix] ? { ...state.resources[type][id][prefix] } : null;
542
562
  const queryObject = getDrupalJsonApiParams(query).getQueryObject();
543
563
  queryObject.include = Array.isArray(queryObject.include) ? queryObject.include.join(",") : queryObject.include;
@@ -554,8 +574,9 @@ const DruxtStore = ({ store }) => {
554
574
  const include = queryObject.include.split(",").filter((s) => s.startsWith(`${key}.`)).map((s) => s.slice(key.length + 1)).join(",");
555
575
  return data.filter((o) => typeof o === "object" && o).map((o) => {
556
576
  return dispatch("getResource", {
557
- type: o.type,
558
577
  id: o.id,
578
+ prefix,
579
+ type: o.type,
559
580
  query: { ...queryObject, include }
560
581
  });
561
582
  });
@@ -565,7 +586,7 @@ const DruxtStore = ({ store }) => {
565
586
  }
566
587
  storedResource.included = included;
567
588
  }
568
- if ((storedResource || {})._druxt_full) {
589
+ if (!bypassCache && (storedResource || {})._druxt_full) {
569
590
  return storedResource;
570
591
  }
571
592
  const isFull = typeof (queryObject.fields || {})[type] !== "string";
@@ -581,9 +602,12 @@ const DruxtStore = ({ store }) => {
581
602
  queryObject.fields[type] = (missingFields || []).join(",") || void 0;
582
603
  }
583
604
  let resource;
584
- if (!storedResource || fields) {
585
- resource = await this.$druxt.getResource(type, id, getDrupalJsonApiParams(queryObject), prefix);
586
- commit("addResource", { prefix, resource: { ...resource } });
605
+ if (bypassCache || !storedResource || fields) {
606
+ try {
607
+ resource = await this.$druxt.getResource(type, id, getDrupalJsonApiParams(queryObject), prefix);
608
+ commit("addResource", { prefix, resource: { ...resource } });
609
+ } catch (e) {
610
+ }
587
611
  }
588
612
  const result = { ...((state.resources[type] || {})[id] || {})[prefix] };
589
613
  if (queryObject.include && ((resource || {}).included || (storedResource || {}).included)) {
package/dist/druxt.ssr.js CHANGED
@@ -263,7 +263,7 @@ class DruxtClient {
263
263
  }
264
264
 
265
265
  var name = "druxt";
266
- var version = "0.21.0";
266
+ var version = "0.22.0";
267
267
  var description = "The Fully Decoupled Drupal Framework for Nuxt.js.";
268
268
  var keywords = [
269
269
  "cms",
@@ -305,26 +305,26 @@ var files = [
305
305
  var dependencies = {
306
306
  "@nuxtjs/axios": "^5.13.6",
307
307
  "@nuxtjs/proxy": "^2.1.0",
308
- "@vue/devtools-api": "^6.4.5",
308
+ "@vue/devtools-api": "^6.5.0",
309
309
  chalk: "^4.1.2",
310
- deepmerge: "^4.2.2",
311
- "drupal-jsonapi-params": "^2.1.0",
312
- "express-rate-limit": "^6.6.0",
310
+ deepmerge: "^4.3.1",
311
+ "drupal-jsonapi-params": "^2.2.0",
312
+ "express-rate-limit": "^6.7.0",
313
313
  "launch-editor": "^2.6.0",
314
314
  md5: "^2.3.0",
315
315
  querystring: "^0.2.1",
316
316
  scule: "^0.3.2"
317
317
  };
318
318
  var devDependencies = {
319
- "@storybook/addon-docs": "^6.5.10"
319
+ "@storybook/addon-docs": "^6.5.16"
320
320
  };
321
321
  var peerDependencies = {
322
322
  axios: "*",
323
323
  consola: "*"
324
324
  };
325
325
  var optionalDependencies = {
326
- "core-js": "^3.25.1",
327
- vue: "^2.7.10",
326
+ "core-js": "^3.31.0",
327
+ vue: "^2.7.14",
328
328
  vuex: "^3.6.2"
329
329
  };
330
330
  var publishConfig = {
@@ -534,13 +534,33 @@ const DruxtStore = ({ store }) => {
534
534
  }
535
535
  resource = merge__default["default"](state.resources[type][id][prefix] || {}, resource, { arrayMerge: (dst, src) => src });
536
536
  Vue__default["default"].set(state.resources[type][id], prefix, resource);
537
+ },
538
+ flushCollection(state, { type, hash, prefix }) {
539
+ if (!type)
540
+ Vue__default["default"].set(state, "collections", {});
541
+ else if (type && !hash && !prefix)
542
+ Vue__default["default"].set(state.collections, type, {});
543
+ else if (type && hash && !prefix)
544
+ Vue__default["default"].set(state.collections[type], hash, {});
545
+ else if (type && hash && prefix)
546
+ Vue__default["default"].set(state.collections[type][hash], prefix, {});
547
+ },
548
+ flushResource(state, { type, id, prefix }) {
549
+ if (!type)
550
+ Vue__default["default"].set(state, "resources", {});
551
+ else if (type && !id && !prefix)
552
+ Vue__default["default"].set(state.resources, type, {});
553
+ else if (type && id && !prefix)
554
+ Vue__default["default"].set(state.resources[type], id, {});
555
+ else if (type && id && prefix)
556
+ Vue__default["default"].set(state.resources[type][id], prefix, {});
537
557
  }
538
558
  },
539
559
  actions: {
540
- async getCollection({ commit, state }, { type, query, prefix }) {
560
+ async getCollection({ commit, state }, { type, query, prefix, bypassCache = false }) {
541
561
  const queryObject = getDrupalJsonApiParams(query).getQueryObject();
542
562
  const hash = query ? md5__default["default"](JSON.stringify({ ...queryObject, fields: {}, include: [] })) : "_default";
543
- if (((state.collections[type] || {})[hash] || {})[prefix]) {
563
+ if (!bypassCache && ((state.collections[type] || {})[hash] || {})[prefix]) {
544
564
  return {
545
565
  ...state.collections[type][hash][prefix],
546
566
  data: state.collections[type][hash][prefix].data.map((o) => ((state.resources[o.type][o.id] || {})[prefix] || {}).data)
@@ -550,7 +570,7 @@ const DruxtStore = ({ store }) => {
550
570
  commit("addCollection", { collection: { ...collection }, type, hash, prefix });
551
571
  return collection;
552
572
  },
553
- async getResource({ commit, dispatch, state }, { type, id, query, prefix }) {
573
+ async getResource({ commit, dispatch, state }, { type, id, query, prefix, bypassCache = false }) {
554
574
  const storedResource = ((state.resources[type] || {})[id] || {})[prefix] ? { ...state.resources[type][id][prefix] } : null;
555
575
  const queryObject = getDrupalJsonApiParams(query).getQueryObject();
556
576
  queryObject.include = Array.isArray(queryObject.include) ? queryObject.include.join(",") : queryObject.include;
@@ -567,8 +587,9 @@ const DruxtStore = ({ store }) => {
567
587
  const include = queryObject.include.split(",").filter((s) => s.startsWith(`${key}.`)).map((s) => s.slice(key.length + 1)).join(",");
568
588
  return data.filter((o) => typeof o === "object" && o).map((o) => {
569
589
  return dispatch("getResource", {
570
- type: o.type,
571
590
  id: o.id,
591
+ prefix,
592
+ type: o.type,
572
593
  query: { ...queryObject, include }
573
594
  });
574
595
  });
@@ -578,7 +599,7 @@ const DruxtStore = ({ store }) => {
578
599
  }
579
600
  storedResource.included = included;
580
601
  }
581
- if ((storedResource || {})._druxt_full) {
602
+ if (!bypassCache && (storedResource || {})._druxt_full) {
582
603
  return storedResource;
583
604
  }
584
605
  const isFull = typeof (queryObject.fields || {})[type] !== "string";
@@ -594,9 +615,12 @@ const DruxtStore = ({ store }) => {
594
615
  queryObject.fields[type] = (missingFields || []).join(",") || void 0;
595
616
  }
596
617
  let resource;
597
- if (!storedResource || fields) {
598
- resource = await this.$druxt.getResource(type, id, getDrupalJsonApiParams(queryObject), prefix);
599
- commit("addResource", { prefix, resource: { ...resource } });
618
+ if (bypassCache || !storedResource || fields) {
619
+ try {
620
+ resource = await this.$druxt.getResource(type, id, getDrupalJsonApiParams(queryObject), prefix);
621
+ commit("addResource", { prefix, resource: { ...resource } });
622
+ } catch (e) {
623
+ }
600
624
  }
601
625
  const result = { ...((state.resources[type] || {})[id] || {})[prefix] };
602
626
  if (queryObject.include && ((resource || {}).included || (storedResource || {}).included)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "druxt",
3
- "version": "0.21.0",
3
+ "version": "0.22.0",
4
4
  "description": "The Fully Decoupled Drupal Framework for Nuxt.js.",
5
5
  "keywords": [
6
6
  "cms",
@@ -42,26 +42,26 @@
42
42
  "dependencies": {
43
43
  "@nuxtjs/axios": "^5.13.6",
44
44
  "@nuxtjs/proxy": "^2.1.0",
45
- "@vue/devtools-api": "^6.4.5",
45
+ "@vue/devtools-api": "^6.5.0",
46
46
  "chalk": "^4.1.2",
47
- "deepmerge": "^4.2.2",
48
- "drupal-jsonapi-params": "^2.1.0",
49
- "express-rate-limit": "^6.6.0",
47
+ "deepmerge": "^4.3.1",
48
+ "drupal-jsonapi-params": "^2.2.0",
49
+ "express-rate-limit": "^6.7.0",
50
50
  "launch-editor": "^2.6.0",
51
51
  "md5": "^2.3.0",
52
52
  "querystring": "^0.2.1",
53
53
  "scule": "^0.3.2"
54
54
  },
55
55
  "devDependencies": {
56
- "@storybook/addon-docs": "^6.5.10"
56
+ "@storybook/addon-docs": "^6.5.16"
57
57
  },
58
58
  "peerDependencies": {
59
59
  "axios": "*",
60
60
  "consola": "*"
61
61
  },
62
62
  "optionalDependencies": {
63
- "core-js": "^3.25.1",
64
- "vue": "^2.7.10",
63
+ "core-js": "^3.31.0",
64
+ "vue": "^2.7.14",
65
65
  "vuex": "^3.6.2"
66
66
  },
67
67
  "publishConfig": {