@alchemy_cms/json_api 1.1.0 → 1.1.1

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,6 +1,14 @@
1
1
  # Changelog
2
2
 
3
- ## [v1.1.0](https://github.com/AlchemyCMS/alchemy-json_api/tree/v1.0.0) (2022-09-16)
3
+ ## [v1.1.1](https://github.com/AlchemyCMS/alchemy-json_api/tree/v1.1.1) (2022-09-16)
4
+
5
+ [Full Changelog](https://github.com/AlchemyCMS/alchemy-json_api/compare/v1.1.0...v1.1.1)
6
+
7
+ **Merged pull requests:**
8
+
9
+ - JS: Fix browser build [\#66](https://github.com/AlchemyCMS/alchemy-json_api/pull/66) ([tvdeyen](https://github.com/tvdeyen))
10
+
11
+ ## [v1.1.0](https://github.com/AlchemyCMS/alchemy-json_api/tree/v1.1.0) (2022-09-16)
4
12
 
5
13
  [Full Changelog](https://github.com/AlchemyCMS/alchemy-json_api/compare/v1.0.0...v1.1.0)
6
14
 
@@ -8,17 +8,13 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
8
8
 
9
9
  var structuredClone__default = /*#__PURE__*/_interopDefaultLegacy(structuredClone);
10
10
 
11
- function deserialize(originalResponse, options = {}) {
12
- const response = structuredClone__default["default"](originalResponse);
11
+ function deserialize(originalResponse) {
12
+ var response = structuredClone__default["default"](originalResponse);
13
13
 
14
- if (!options) {
15
- options = {};
16
- }
17
-
18
- const included = response.included || [];
14
+ var included = response.included || [];
19
15
 
20
16
  if (Array.isArray(response.data)) {
21
- return response.data.map(data => {
17
+ return response.data.map(function (data) {
22
18
  return parseJsonApiSimpleResourceData(data, included, false);
23
19
  });
24
20
  } else {
@@ -39,22 +35,25 @@ function parseJsonApiSimpleResourceData(data, included, useCache, options) {
39
35
  return included.cached[data.type][data.id];
40
36
  }
41
37
 
42
- const attributes = data.attributes || {};
43
- const resource = attributes;
38
+ var attributes = data.attributes || {};
39
+ var resource = attributes;
44
40
  resource.id = data.id;
45
41
  included.cached[data.type][data.id] = resource;
46
42
 
47
43
  if (data.relationships) {
48
- for (const relationName of Object.keys(data.relationships)) {
49
- const relationRef = data.relationships[relationName];
44
+ for (var _i = 0, _Object$keys = Object.keys(data.relationships); _i < _Object$keys.length; _i++) {
45
+ var relationName = _Object$keys[_i];
46
+ var relationRef = data.relationships[relationName];
50
47
 
51
48
  if (Array.isArray(relationRef.data)) {
52
- const items = [];
53
- relationRef.data.forEach(relationData => {
54
- const item = findJsonApiIncluded(included, relationData.type, relationData.id);
55
- items.push(item);
56
- });
57
- resource[relationName] = items;
49
+ (function () {
50
+ var items = [];
51
+ relationRef.data.forEach(function (relationData) {
52
+ var item = findJsonApiIncluded(included, relationData.type, relationData.id);
53
+ items.push(item);
54
+ });
55
+ resource[relationName] = items;
56
+ })();
58
57
  } else if (relationRef && relationRef.data) {
59
58
  resource[relationName] = findJsonApiIncluded(included, relationRef.data.type, relationRef.data.id);
60
59
  } else {
@@ -67,8 +66,8 @@ function parseJsonApiSimpleResourceData(data, included, useCache, options) {
67
66
  }
68
67
 
69
68
  function findJsonApiIncluded(included, type, id, options) {
70
- let found = null;
71
- included.forEach(item => {
69
+ var found = null;
70
+ included.forEach(function (item) {
72
71
  if (item.type === type && item.id === id) {
73
72
  found = parseJsonApiSimpleResourceData(item, included, true);
74
73
  }
@@ -76,7 +75,7 @@ function findJsonApiIncluded(included, type, id, options) {
76
75
 
77
76
  if (!found) {
78
77
  found = {
79
- id
78
+ id: id
80
79
  };
81
80
  }
82
81
 
@@ -84,18 +83,20 @@ function findJsonApiIncluded(included, type, id, options) {
84
83
  }
85
84
 
86
85
  function filterDeprecatedElements(elements) {
87
- const els = [];
88
- elements.forEach(element => {
89
- if (element.nested_elements?.length > 0) {
86
+ var els = [];
87
+ elements.forEach(function (element) {
88
+ var _element$nested_eleme, _element$nestedElemen, _element$essences;
89
+
90
+ if (((_element$nested_eleme = element.nested_elements) === null || _element$nested_eleme === void 0 ? void 0 : _element$nested_eleme.length) > 0) {
90
91
  element.nested_elements = filterDeprecatedElements(element.nested_elements);
91
92
  }
92
93
 
93
- if (element.nestedElements?.length > 0) {
94
+ if (((_element$nestedElemen = element.nestedElements) === null || _element$nestedElemen === void 0 ? void 0 : _element$nestedElemen.length) > 0) {
94
95
  element.nestedElements = filterDeprecatedElements(element.nestedElements);
95
96
  }
96
97
 
97
- if (element.essences?.length > 0) {
98
- element.essences = element.essences.filter(essence => {
98
+ if (((_element$essences = element.essences) === null || _element$essences === void 0 ? void 0 : _element$essences.length) > 0) {
99
+ element.essences = element.essences.filter(function (essence) {
99
100
  return !essence.deprecated;
100
101
  });
101
102
  }
@@ -109,14 +110,14 @@ function filterDeprecatedElements(elements) {
109
110
 
110
111
 
111
112
  function deserializePage(pageData) {
112
- const page = deserialize(pageData);
113
+ var page = deserialize(pageData);
113
114
  page.elements = filterDeprecatedElements(page.elements);
114
115
  return page;
115
116
  } // Returns deserialized pages without deprecated content
116
117
 
117
118
  function deserializePages(pagesData) {
118
- const pages = deserialize(pagesData);
119
- pages.forEach(page => {
119
+ var pages = deserialize(pagesData);
120
+ pages.forEach(function (page) {
120
121
  page.elements = filterDeprecatedElements(page.elements);
121
122
  });
122
123
  return pages;
@@ -8,17 +8,13 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
8
8
 
9
9
  var structuredClone__default = /*#__PURE__*/_interopDefaultLegacy(structuredClone);
10
10
 
11
- function deserialize(originalResponse, options = {}) {
12
- const response = structuredClone__default["default"](originalResponse);
11
+ function deserialize(originalResponse) {
12
+ var response = structuredClone__default["default"](originalResponse);
13
13
 
14
- if (!options) {
15
- options = {};
16
- }
17
-
18
- const included = response.included || [];
14
+ var included = response.included || [];
19
15
 
20
16
  if (Array.isArray(response.data)) {
21
- return response.data.map(data => {
17
+ return response.data.map(function (data) {
22
18
  return parseJsonApiSimpleResourceData(data, included, false);
23
19
  });
24
20
  } else {
@@ -39,22 +35,25 @@ function parseJsonApiSimpleResourceData(data, included, useCache, options) {
39
35
  return included.cached[data.type][data.id];
40
36
  }
41
37
 
42
- const attributes = data.attributes || {};
43
- const resource = attributes;
38
+ var attributes = data.attributes || {};
39
+ var resource = attributes;
44
40
  resource.id = data.id;
45
41
  included.cached[data.type][data.id] = resource;
46
42
 
47
43
  if (data.relationships) {
48
- for (const relationName of Object.keys(data.relationships)) {
49
- const relationRef = data.relationships[relationName];
44
+ for (var _i = 0, _Object$keys = Object.keys(data.relationships); _i < _Object$keys.length; _i++) {
45
+ var relationName = _Object$keys[_i];
46
+ var relationRef = data.relationships[relationName];
50
47
 
51
48
  if (Array.isArray(relationRef.data)) {
52
- const items = [];
53
- relationRef.data.forEach(relationData => {
54
- const item = findJsonApiIncluded(included, relationData.type, relationData.id);
55
- items.push(item);
56
- });
57
- resource[relationName] = items;
49
+ (function () {
50
+ var items = [];
51
+ relationRef.data.forEach(function (relationData) {
52
+ var item = findJsonApiIncluded(included, relationData.type, relationData.id);
53
+ items.push(item);
54
+ });
55
+ resource[relationName] = items;
56
+ })();
58
57
  } else if (relationRef && relationRef.data) {
59
58
  resource[relationName] = findJsonApiIncluded(included, relationRef.data.type, relationRef.data.id);
60
59
  } else {
@@ -67,8 +66,8 @@ function parseJsonApiSimpleResourceData(data, included, useCache, options) {
67
66
  }
68
67
 
69
68
  function findJsonApiIncluded(included, type, id, options) {
70
- let found = null;
71
- included.forEach(item => {
69
+ var found = null;
70
+ included.forEach(function (item) {
72
71
  if (item.type === type && item.id === id) {
73
72
  found = parseJsonApiSimpleResourceData(item, included, true);
74
73
  }
@@ -76,7 +75,7 @@ function findJsonApiIncluded(included, type, id, options) {
76
75
 
77
76
  if (!found) {
78
77
  found = {
79
- id
78
+ id: id
80
79
  };
81
80
  }
82
81
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alchemy_cms/json_api",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "JSON API deserializer for AlchemyCMS",
5
5
  "license": "BSD-3-Clause",
6
6
  "repository": {
@@ -36,5 +36,6 @@
36
36
  "scripts": {
37
37
  "build": "rollup --config",
38
38
  "test": "jest"
39
- }
39
+ },
40
+ "browserslist": "> 0.25%, not dead"
40
41
  }