@akemona-org/strapi-plugin-content-type-builder 3.7.0 → 3.7.2

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.
Files changed (87) hide show
  1. package/admin/src/components/AllowedTypesSelect/index.js +1 -1
  2. package/admin/src/components/AttributeOption/index.js +1 -1
  3. package/admin/src/components/BooleanBox/icons/CTSelected.js +1 -1
  4. package/admin/src/components/BooleanBox/icons/CTUnselected.js +1 -1
  5. package/admin/src/components/BooleanBox/icons/STSelected.js +1 -1
  6. package/admin/src/components/BooleanBox/icons/STUnselected.js +1 -1
  7. package/admin/src/components/BooleanBox/index.js +3 -3
  8. package/admin/src/components/ComponentCard/index.js +1 -1
  9. package/admin/src/components/ComponentIconPicker/CellRenderer.js +1 -6
  10. package/admin/src/components/ComponentIconPicker/index.js +4 -4
  11. package/admin/src/components/ComponentList/index.js +1 -3
  12. package/admin/src/components/ComponentSelect/MenuList.js +5 -6
  13. package/admin/src/components/ComponentSelect/MultipleMenuList.js +15 -15
  14. package/admin/src/components/ComponentSelect/Value.js +3 -11
  15. package/admin/src/components/ComponentSelect/utils/HasSomeSubArray.js +1 -1
  16. package/admin/src/components/ComponentSelect/utils/hasSubArray.js +1 -1
  17. package/admin/src/components/CreatableSelect/index.js +2 -2
  18. package/admin/src/components/CustomCheckbox/index.js +1 -1
  19. package/admin/src/components/DynamicZoneList/index.js +1 -1
  20. package/admin/src/components/HeaderNavLink/index.js +2 -4
  21. package/admin/src/components/List/index.js +1 -1
  22. package/admin/src/components/ListHeader/index.js +1 -1
  23. package/admin/src/components/ListRow/index.js +3 -3
  24. package/admin/src/components/ModalHeader/DropdownInfos.js +1 -1
  25. package/admin/src/components/ModalHeader/index.js +2 -8
  26. package/admin/src/components/RelationForm/index.js +2 -8
  27. package/admin/src/components/RelationFormBox/index.js +1 -3
  28. package/admin/src/components/RelationFormNaturePicker/index.js +1 -1
  29. package/admin/src/components/RelationTargetPicker/index.js +2 -2
  30. package/admin/src/components/SelectMenuUl/index.js +1 -1
  31. package/admin/src/components/WrapperSelect/index.js +2 -2
  32. package/admin/src/containers/DataManagerProvider/constants.js +10 -5
  33. package/admin/src/containers/DataManagerProvider/index.js +15 -17
  34. package/admin/src/containers/DataManagerProvider/reducer.js +25 -25
  35. package/admin/src/containers/DataManagerProvider/selectors.js +2 -2
  36. package/admin/src/containers/DataManagerProvider/utils/cleanData.js +8 -8
  37. package/admin/src/containers/DataManagerProvider/utils/createDataObject.js +1 -1
  38. package/admin/src/containers/DataManagerProvider/utils/createModifiedDataSchema.js +25 -42
  39. package/admin/src/containers/DataManagerProvider/utils/retrieveComponentsFromSchema.js +6 -21
  40. package/admin/src/containers/DataManagerProvider/utils/retrieveComponentsThatHaveComponents.js +12 -18
  41. package/admin/src/containers/DataManagerProvider/utils/retrieveNestedComponents.js +4 -10
  42. package/admin/src/containers/DataManagerProvider/utils/retrieveSpecificInfoFromComponents.js +1 -1
  43. package/admin/src/containers/FormModal/attributes/advancedForm.js +6 -6
  44. package/admin/src/containers/FormModal/attributes/baseForm.js +5 -5
  45. package/admin/src/containers/FormModal/attributes/types.js +10 -23
  46. package/admin/src/containers/FormModal/attributes/validation/common.js +8 -16
  47. package/admin/src/containers/FormModal/category/createCategorySchema.js +2 -2
  48. package/admin/src/containers/FormModal/component/createComponentSchema.js +2 -2
  49. package/admin/src/containers/FormModal/constants.js +10 -5
  50. package/admin/src/containers/FormModal/contentType/createContentTypeSchema.js +2 -2
  51. package/admin/src/containers/FormModal/contentType/form.js +1 -1
  52. package/admin/src/containers/FormModal/forms/index.js +5 -5
  53. package/admin/src/containers/FormModal/index.js +15 -15
  54. package/admin/src/containers/FormModal/reducer.js +9 -9
  55. package/admin/src/containers/FormModal/selectors.js +2 -2
  56. package/admin/src/containers/FormModal/utils/createHeadersArray.js +3 -6
  57. package/admin/src/containers/FormModal/utils/createHeadersObjectFromArray.js +1 -1
  58. package/admin/src/containers/FormModal/utils/createUid.js +2 -2
  59. package/admin/src/containers/FormModal/utils/getModalTitleSubHeader.js +1 -1
  60. package/admin/src/containers/FormModal/utils/relations.js +2 -2
  61. package/admin/src/containers/LeftMenu/index.js +11 -11
  62. package/admin/src/containers/ListView/index.js +4 -4
  63. package/admin/src/icons/Curve.js +1 -1
  64. package/admin/src/icons/ManyToMany.js +3 -12
  65. package/admin/src/icons/ManyToOne.js +1 -4
  66. package/admin/src/icons/OneToMany.js +2 -8
  67. package/admin/src/index.js +1 -1
  68. package/admin/src/pluginId.js +1 -1
  69. package/admin/src/utils/convertAttrObjToArray.js +1 -1
  70. package/admin/src/utils/formAPI.js +2 -2
  71. package/admin/src/utils/getAttributeDisplayedType.js +1 -1
  72. package/admin/src/utils/getComponents.js +2 -2
  73. package/admin/src/utils/getTrad.js +1 -1
  74. package/admin/src/utils/makeUnique.js +1 -1
  75. package/controllers/Components.js +7 -15
  76. package/controllers/validation/common.js +12 -18
  77. package/controllers/validation/data-transform.js +4 -4
  78. package/controllers/validation/model-schema.js +5 -14
  79. package/controllers/validation/relations.js +8 -20
  80. package/controllers/validation/types.js +12 -35
  81. package/package.json +6 -6
  82. package/services/Components.js +4 -4
  83. package/services/ContentTypes.js +2 -1
  84. package/services/api-handler.js +5 -5
  85. package/services/schema-builder/index.js +12 -14
  86. package/services/schema-builder/schema-handler.js +5 -5
  87. package/utils/helpers.js +1 -1
@@ -77,7 +77,7 @@ async function rollback(uid) {
77
77
  * Creates a delete function to clear an api folder
78
78
  * @param {string} baseName
79
79
  */
80
- const createDeleteApiFunction = baseName => {
80
+ const createDeleteApiFunction = (baseName) => {
81
81
  const startWithBaseName = startWithName(baseName + '.');
82
82
 
83
83
  /**
@@ -85,7 +85,7 @@ const createDeleteApiFunction = baseName => {
85
85
  * Will only update routes.json instead of deleting it if other routes are present
86
86
  * @param {string} filePath file path to delete
87
87
  */
88
- return async filePath => {
88
+ return async (filePath) => {
89
89
  const fileName = path.basename(filePath);
90
90
 
91
91
  if (startWithBaseName(fileName)) return fse.remove(filePath);
@@ -93,7 +93,7 @@ const createDeleteApiFunction = baseName => {
93
93
  if (fileName === 'routes.json') {
94
94
  const { routes } = await fse.readJSON(filePath);
95
95
 
96
- const routesToKeep = routes.filter(route => !startWithBaseName(route.handler));
96
+ const routesToKeep = routes.filter((route) => !startWithBaseName(route.handler));
97
97
 
98
98
  if (routesToKeep.length === 0) {
99
99
  return fse.remove(filePath);
@@ -117,12 +117,12 @@ const createDeleteApiFunction = baseName => {
117
117
  * @param {string} prefix
118
118
  * @returns {Function} a comparing function
119
119
  */
120
- const startWithName = prefix => {
120
+ const startWithName = (prefix) => {
121
121
  /**
122
122
  * Checks if str starts with prefix case insensitive
123
123
  * @param {string} str string to compare
124
124
  */
125
- return str => _.startsWith(_.toLower(str), _.toLower(prefix));
125
+ return (str) => _.startsWith(_.toLower(str), _.toLower(prefix));
126
126
  };
127
127
 
128
128
  /**
@@ -11,7 +11,7 @@ const MODEL_RELATIONS = ['oneWay', 'oneToOne', 'manyToOne'];
11
11
  const COLLECTION_RELATIONS = ['manyWay', 'manyToMany', 'oneToMany'];
12
12
 
13
13
  module.exports = function createBuilder() {
14
- const components = Object.keys(strapi.components).map(key => {
14
+ const components = Object.keys(strapi.components).map((key) => {
15
15
  const compo = strapi.components[key];
16
16
 
17
17
  return {
@@ -25,7 +25,7 @@ module.exports = function createBuilder() {
25
25
  };
26
26
  });
27
27
 
28
- const contentTypes = Object.keys(strapi.contentTypes).map(key => {
28
+ const contentTypes = Object.keys(strapi.contentTypes).map((key) => {
29
29
  const contentType = strapi.contentTypes[key];
30
30
 
31
31
  let dir;
@@ -59,12 +59,12 @@ function createSchemaBuilder({ components, contentTypes }) {
59
59
  const tmpContentTypes = new Map();
60
60
 
61
61
  // init temporary ContentTypes
62
- Object.keys(contentTypes).forEach(key => {
62
+ Object.keys(contentTypes).forEach((key) => {
63
63
  tmpContentTypes.set(contentTypes[key].uid, createSchemaHandler(contentTypes[key]));
64
64
  });
65
65
 
66
66
  // init temporary components
67
- Object.keys(components).forEach(key => {
67
+ Object.keys(components).forEach((key) => {
68
68
  tmpComponents.set(components[key].uid, createSchemaHandler(components[key]));
69
69
  });
70
70
 
@@ -161,17 +161,16 @@ function createSchemaBuilder({ components, contentTypes }) {
161
161
  */
162
162
  writeFiles() {
163
163
  return Promise.all(
164
- [
165
- ...Array.from(tmpComponents.values()),
166
- ...Array.from(tmpContentTypes.values()),
167
- ].map(schema => schema.flush())
164
+ [...Array.from(tmpComponents.values()), ...Array.from(tmpContentTypes.values())].map(
165
+ (schema) => schema.flush()
166
+ )
168
167
  )
169
- .catch(error => {
168
+ .catch((error) => {
170
169
  strapi.log.error('Error writing schema files');
171
170
  strapi.log.error(error);
172
171
  return this.rollback();
173
172
  })
174
- .catch(error => {
173
+ .catch((error) => {
175
174
  strapi.log.error(
176
175
  'Error rolling back schema files. You might need to fix your files manually'
177
176
  );
@@ -186,10 +185,9 @@ function createSchemaBuilder({ components, contentTypes }) {
186
185
  */
187
186
  rollback() {
188
187
  return Promise.all(
189
- [
190
- ...Array.from(tmpComponents.values()),
191
- ...Array.from(tmpContentTypes.values()),
192
- ].map(schema => schema.rollback())
188
+ [...Array.from(tmpComponents.values()), ...Array.from(tmpContentTypes.values())].map(
189
+ (schema) => schema.rollback()
190
+ )
193
191
  );
194
192
  },
195
193
  };
@@ -140,7 +140,7 @@ module.exports = function createSchemaHandler(infos) {
140
140
  removeContentType(uid) {
141
141
  const { attributes } = state.schema;
142
142
 
143
- Object.keys(attributes).forEach(key => {
143
+ Object.keys(attributes).forEach((key) => {
144
144
  const attr = attributes[key];
145
145
  const target = attr.model || attr.collection;
146
146
  const plugin = attr.plugin;
@@ -159,7 +159,7 @@ module.exports = function createSchemaHandler(infos) {
159
159
  removeComponent(uid) {
160
160
  const { attributes } = state.schema;
161
161
 
162
- Object.keys(attributes).forEach(key => {
162
+ Object.keys(attributes).forEach((key) => {
163
163
  const attr = attributes[key];
164
164
 
165
165
  if (attr.type === 'component' && attr.component === uid) {
@@ -171,7 +171,7 @@ module.exports = function createSchemaHandler(infos) {
171
171
  Array.isArray(attr.components) &&
172
172
  attr.components.includes(uid)
173
173
  ) {
174
- const updatedComponentList = attributes[key].components.filter(val => val !== uid);
174
+ const updatedComponentList = attributes[key].components.filter((val) => val !== uid);
175
175
  this.set(['attributes', key, 'components'], updatedComponentList);
176
176
  }
177
177
  });
@@ -182,7 +182,7 @@ module.exports = function createSchemaHandler(infos) {
182
182
  updateComponent(uid, newUID) {
183
183
  const { attributes } = state.schema;
184
184
 
185
- Object.keys(attributes).forEach(key => {
185
+ Object.keys(attributes).forEach((key) => {
186
186
  const attr = attributes[key];
187
187
 
188
188
  if (attr.type === 'component' && attr.component === uid) {
@@ -194,7 +194,7 @@ module.exports = function createSchemaHandler(infos) {
194
194
  Array.isArray(attr.components) &&
195
195
  attr.components.includes(uid)
196
196
  ) {
197
- const updatedComponentList = attr.components.map(val => (val === uid ? newUID : val));
197
+ const updatedComponentList = attr.components.map((val) => (val === uid ? newUID : val));
198
198
 
199
199
  this.set(['attributes', key, 'components'], updatedComponentList);
200
200
  }
package/utils/helpers.js CHANGED
@@ -4,7 +4,7 @@ const escapeNewlines = (content = '', placeholder = '\n') => {
4
4
  return content.replace(/[\r\n]+/g, placeholder);
5
5
  };
6
6
 
7
- const deepTrimObject = attribute => {
7
+ const deepTrimObject = (attribute) => {
8
8
  if (Array.isArray(attribute)) {
9
9
  return attribute.map(deepTrimObject);
10
10
  }