@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.
- package/admin/src/components/AllowedTypesSelect/index.js +1 -1
- package/admin/src/components/AttributeOption/index.js +1 -1
- package/admin/src/components/BooleanBox/icons/CTSelected.js +1 -1
- package/admin/src/components/BooleanBox/icons/CTUnselected.js +1 -1
- package/admin/src/components/BooleanBox/icons/STSelected.js +1 -1
- package/admin/src/components/BooleanBox/icons/STUnselected.js +1 -1
- package/admin/src/components/BooleanBox/index.js +3 -3
- package/admin/src/components/ComponentCard/index.js +1 -1
- package/admin/src/components/ComponentIconPicker/CellRenderer.js +1 -6
- package/admin/src/components/ComponentIconPicker/index.js +4 -4
- package/admin/src/components/ComponentList/index.js +1 -3
- package/admin/src/components/ComponentSelect/MenuList.js +5 -6
- package/admin/src/components/ComponentSelect/MultipleMenuList.js +15 -15
- package/admin/src/components/ComponentSelect/Value.js +3 -11
- package/admin/src/components/ComponentSelect/utils/HasSomeSubArray.js +1 -1
- package/admin/src/components/ComponentSelect/utils/hasSubArray.js +1 -1
- package/admin/src/components/CreatableSelect/index.js +2 -2
- package/admin/src/components/CustomCheckbox/index.js +1 -1
- package/admin/src/components/DynamicZoneList/index.js +1 -1
- package/admin/src/components/HeaderNavLink/index.js +2 -4
- package/admin/src/components/List/index.js +1 -1
- package/admin/src/components/ListHeader/index.js +1 -1
- package/admin/src/components/ListRow/index.js +3 -3
- package/admin/src/components/ModalHeader/DropdownInfos.js +1 -1
- package/admin/src/components/ModalHeader/index.js +2 -8
- package/admin/src/components/RelationForm/index.js +2 -8
- package/admin/src/components/RelationFormBox/index.js +1 -3
- package/admin/src/components/RelationFormNaturePicker/index.js +1 -1
- package/admin/src/components/RelationTargetPicker/index.js +2 -2
- package/admin/src/components/SelectMenuUl/index.js +1 -1
- package/admin/src/components/WrapperSelect/index.js +2 -2
- package/admin/src/containers/DataManagerProvider/constants.js +10 -5
- package/admin/src/containers/DataManagerProvider/index.js +15 -17
- package/admin/src/containers/DataManagerProvider/reducer.js +25 -25
- package/admin/src/containers/DataManagerProvider/selectors.js +2 -2
- package/admin/src/containers/DataManagerProvider/utils/cleanData.js +8 -8
- package/admin/src/containers/DataManagerProvider/utils/createDataObject.js +1 -1
- package/admin/src/containers/DataManagerProvider/utils/createModifiedDataSchema.js +25 -42
- package/admin/src/containers/DataManagerProvider/utils/retrieveComponentsFromSchema.js +6 -21
- package/admin/src/containers/DataManagerProvider/utils/retrieveComponentsThatHaveComponents.js +12 -18
- package/admin/src/containers/DataManagerProvider/utils/retrieveNestedComponents.js +4 -10
- package/admin/src/containers/DataManagerProvider/utils/retrieveSpecificInfoFromComponents.js +1 -1
- package/admin/src/containers/FormModal/attributes/advancedForm.js +6 -6
- package/admin/src/containers/FormModal/attributes/baseForm.js +5 -5
- package/admin/src/containers/FormModal/attributes/types.js +10 -23
- package/admin/src/containers/FormModal/attributes/validation/common.js +8 -16
- package/admin/src/containers/FormModal/category/createCategorySchema.js +2 -2
- package/admin/src/containers/FormModal/component/createComponentSchema.js +2 -2
- package/admin/src/containers/FormModal/constants.js +10 -5
- package/admin/src/containers/FormModal/contentType/createContentTypeSchema.js +2 -2
- package/admin/src/containers/FormModal/contentType/form.js +1 -1
- package/admin/src/containers/FormModal/forms/index.js +5 -5
- package/admin/src/containers/FormModal/index.js +15 -15
- package/admin/src/containers/FormModal/reducer.js +9 -9
- package/admin/src/containers/FormModal/selectors.js +2 -2
- package/admin/src/containers/FormModal/utils/createHeadersArray.js +3 -6
- package/admin/src/containers/FormModal/utils/createHeadersObjectFromArray.js +1 -1
- package/admin/src/containers/FormModal/utils/createUid.js +2 -2
- package/admin/src/containers/FormModal/utils/getModalTitleSubHeader.js +1 -1
- package/admin/src/containers/FormModal/utils/relations.js +2 -2
- package/admin/src/containers/LeftMenu/index.js +11 -11
- package/admin/src/containers/ListView/index.js +4 -4
- package/admin/src/icons/Curve.js +1 -1
- package/admin/src/icons/ManyToMany.js +3 -12
- package/admin/src/icons/ManyToOne.js +1 -4
- package/admin/src/icons/OneToMany.js +2 -8
- package/admin/src/index.js +1 -1
- package/admin/src/pluginId.js +1 -1
- package/admin/src/utils/convertAttrObjToArray.js +1 -1
- package/admin/src/utils/formAPI.js +2 -2
- package/admin/src/utils/getAttributeDisplayedType.js +1 -1
- package/admin/src/utils/getComponents.js +2 -2
- package/admin/src/utils/getTrad.js +1 -1
- package/admin/src/utils/makeUnique.js +1 -1
- package/controllers/Components.js +7 -15
- package/controllers/validation/common.js +12 -18
- package/controllers/validation/data-transform.js +4 -4
- package/controllers/validation/model-schema.js +5 -14
- package/controllers/validation/relations.js +8 -20
- package/controllers/validation/types.js +12 -35
- package/package.json +6 -6
- package/services/Components.js +4 -4
- package/services/ContentTypes.js +2 -1
- package/services/api-handler.js +5 -5
- package/services/schema-builder/index.js +12 -14
- package/services/schema-builder/schema-handler.js +5 -5
- package/utils/helpers.js +1 -1
|
@@ -87,7 +87,7 @@ const ListView = () => {
|
|
|
87
87
|
push({ search: makeSearch(searchObj) });
|
|
88
88
|
};
|
|
89
89
|
|
|
90
|
-
const handleClickAddComponentToDZ = async dzName => {
|
|
90
|
+
const handleClickAddComponentToDZ = async (dzName) => {
|
|
91
91
|
const firstHeaderObject = {
|
|
92
92
|
header_label_1: currentDataName,
|
|
93
93
|
header_icon_name_1: 'dynamiczone',
|
|
@@ -163,7 +163,7 @@ const ListView = () => {
|
|
|
163
163
|
const wait = async () => {
|
|
164
164
|
togglePrompt(false);
|
|
165
165
|
|
|
166
|
-
return new Promise(resolve => setTimeout(resolve, 100));
|
|
166
|
+
return new Promise((resolve) => setTimeout(resolve, 100));
|
|
167
167
|
};
|
|
168
168
|
const label = get(modifiedData, [firstMainDataPath, 'schema', 'name'], '');
|
|
169
169
|
const kind = get(modifiedData, [firstMainDataPath, 'schema', 'kind'], '');
|
|
@@ -269,7 +269,7 @@ const ListView = () => {
|
|
|
269
269
|
? [...listInjectedComponents, <ListButton {...addButtonProps} key="add-button" />]
|
|
270
270
|
: listInjectedComponents;
|
|
271
271
|
|
|
272
|
-
const CustomRow = props => {
|
|
272
|
+
const CustomRow = (props) => {
|
|
273
273
|
const { name } = props;
|
|
274
274
|
|
|
275
275
|
return <ListRow {...props} attributeName={name} name={name} onClick={handleClickEditField} />;
|
|
@@ -301,7 +301,7 @@ const ListView = () => {
|
|
|
301
301
|
<ListHeader actions={listActions} title={listTitle} />
|
|
302
302
|
<List
|
|
303
303
|
items={convertAttrObjToArray(attributes)}
|
|
304
|
-
customRowComponent={props => <CustomRow {...props} />}
|
|
304
|
+
customRowComponent={(props) => <CustomRow {...props} />}
|
|
305
305
|
addComponentToDZ={handleClickAddComponentToDZ}
|
|
306
306
|
targetUid={targetUid}
|
|
307
307
|
dataType={forTarget}
|
package/admin/src/icons/Curve.js
CHANGED
|
@@ -34,10 +34,7 @@ const ManyToMany = ({ isSelected, ...rest }) => {
|
|
|
34
34
|
/>
|
|
35
35
|
<rect stroke={stroke} x="27.5" y="17.5" width="6" height="6" rx="3" />
|
|
36
36
|
<rect stroke={stroke} x="27.5" y="8.5" width="6" height="6" rx="3" />
|
|
37
|
-
<path
|
|
38
|
-
stroke={stroke}
|
|
39
|
-
d="M26.85 28.813L13.37 22.238l-.439.898 13.482 6.576z"
|
|
40
|
-
/>
|
|
37
|
+
<path stroke={stroke} d="M26.85 28.813L13.37 22.238l-.439.898 13.482 6.576z" />
|
|
41
38
|
<rect
|
|
42
39
|
stroke={stroke}
|
|
43
40
|
transform="matrix(-1 0 0 1 61 0)"
|
|
@@ -47,10 +44,7 @@ const ManyToMany = ({ isSelected, ...rest }) => {
|
|
|
47
44
|
height="6"
|
|
48
45
|
rx="3"
|
|
49
46
|
/>
|
|
50
|
-
<path
|
|
51
|
-
stroke={stroke}
|
|
52
|
-
d="M13.52 12.687l13.482 6.575.439-.898-13.482-6.576z"
|
|
53
|
-
/>
|
|
47
|
+
<path stroke={stroke} d="M13.52 12.687l13.482 6.575.439-.898-13.482-6.576z" />
|
|
54
48
|
<rect
|
|
55
49
|
stroke={stroke}
|
|
56
50
|
transform="matrix(1 0 0 -1 0 41)"
|
|
@@ -69,10 +63,7 @@ const ManyToMany = ({ isSelected, ...rest }) => {
|
|
|
69
63
|
height="6"
|
|
70
64
|
rx="3"
|
|
71
65
|
/>
|
|
72
|
-
<path
|
|
73
|
-
stroke={stroke}
|
|
74
|
-
d="M12.668 29.229l14.335-6.992.439.899-14.335 6.992z"
|
|
75
|
-
/>
|
|
66
|
+
<path stroke={stroke} d="M12.668 29.229l14.335-6.992.439.899-14.335 6.992z" />
|
|
76
67
|
<rect
|
|
77
68
|
stroke={stroke}
|
|
78
69
|
transform="matrix(1 0 0 -1 0 59)"
|
|
@@ -35,10 +35,7 @@ const ManyToOne = ({ isSelected, ...rest }) => {
|
|
|
35
35
|
<rect stroke={stroke} x="6.5" y="18.5" width="6" height="6" rx="3" />
|
|
36
36
|
<rect stroke={stroke} x="27.5" y="18.5" width="6" height="6" rx="3" />
|
|
37
37
|
<rect stroke={stroke} x="27.5" y="8.5" width="6" height="6" rx="3" />
|
|
38
|
-
<path
|
|
39
|
-
stroke={stroke}
|
|
40
|
-
d="M27.275 30.142l-14.83-7.233-.439.899 14.83 7.233z"
|
|
41
|
-
/>
|
|
38
|
+
<path stroke={stroke} d="M27.275 30.142l-14.83-7.233-.439.899 14.83 7.233z" />
|
|
42
39
|
<rect
|
|
43
40
|
stroke={stroke}
|
|
44
41
|
transform="matrix(-1 0 0 1 61 0)"
|
|
@@ -29,17 +29,11 @@ const OneToMany = ({ isSelected, ...rest }) => {
|
|
|
29
29
|
<use fill="#FFF" xlinkHref="#a" />
|
|
30
30
|
<rect {...rectProps} x=".5" y=".5" width="40" height="40" rx="2" />
|
|
31
31
|
<path fill={stroke} d="M13 20.75h14v2H13z" />
|
|
32
|
-
<path
|
|
33
|
-
fill={stroke}
|
|
34
|
-
d="M11.447 19.437l15.73-7.672.876 1.798-15.729 7.672z"
|
|
35
|
-
/>
|
|
32
|
+
<path fill={stroke} d="M11.447 19.437l15.73-7.672.876 1.798-15.729 7.672z" />
|
|
36
33
|
<rect stroke={stroke} x="6.5" y="18.5" width="6" height="6" rx="3" />
|
|
37
34
|
<rect stroke={stroke} x="27.5" y="18.5" width="6" height="6" rx="3" />
|
|
38
35
|
<rect stroke={stroke} x="27.5" y="8.5" width="6" height="6" rx="3" />
|
|
39
|
-
<path
|
|
40
|
-
fill={stroke}
|
|
41
|
-
d="M27.943 29.912L12.214 22.24l-.657 1.348 15.729 7.672z"
|
|
42
|
-
/>
|
|
36
|
+
<path fill={stroke} d="M27.943 29.912L12.214 22.24l-.657 1.348 15.729 7.672z" />
|
|
43
37
|
<rect
|
|
44
38
|
stroke={stroke}
|
|
45
39
|
transform="matrix(-1 0 0 1 61 0)"
|
package/admin/src/index.js
CHANGED
|
@@ -18,7 +18,7 @@ import pluginId from './pluginId';
|
|
|
18
18
|
import reducers from './reducers';
|
|
19
19
|
import formsAPI from './utils/formAPI';
|
|
20
20
|
|
|
21
|
-
export default strapi => {
|
|
21
|
+
export default (strapi) => {
|
|
22
22
|
const pluginDescription = pluginPkg.strapi.description || pluginPkg.description;
|
|
23
23
|
const icon = pluginPkg.strapi.icon;
|
|
24
24
|
const name = pluginPkg.strapi.name;
|
package/admin/src/pluginId.js
CHANGED
|
@@ -53,7 +53,7 @@ const formsAPI = {
|
|
|
53
53
|
extendFields(fields, { validator, form: { advanced, base } }) {
|
|
54
54
|
const formType = this.types.attribute;
|
|
55
55
|
|
|
56
|
-
fields.forEach(field => {
|
|
56
|
+
fields.forEach((field) => {
|
|
57
57
|
if (!formType[field]) {
|
|
58
58
|
formType[field] = {
|
|
59
59
|
validators: [],
|
|
@@ -101,7 +101,7 @@ const formsAPI = {
|
|
|
101
101
|
|
|
102
102
|
const refData = cloneDeep(initialData);
|
|
103
103
|
|
|
104
|
-
this.contentTypeSchemaMutations.forEach(cb => {
|
|
104
|
+
this.contentTypeSchemaMutations.forEach((cb) => {
|
|
105
105
|
enhancedData = cb(enhancedData, refData);
|
|
106
106
|
});
|
|
107
107
|
|
|
@@ -13,10 +13,10 @@ const getInjectedComponents = (container, area, plugins, rest) => {
|
|
|
13
13
|
const injectedComponents = get(currentPlugin, 'injectedComponents', []);
|
|
14
14
|
|
|
15
15
|
const compos = injectedComponents
|
|
16
|
-
.filter(compo => {
|
|
16
|
+
.filter((compo) => {
|
|
17
17
|
return compo.plugin === `${pluginId}.${container}` && compo.area === area;
|
|
18
18
|
})
|
|
19
|
-
.map(compo => {
|
|
19
|
+
.map((compo) => {
|
|
20
20
|
const Component = compo.component;
|
|
21
21
|
|
|
22
22
|
return <Component {...compo} {...rest} key={compo.key} />;
|
|
@@ -2,10 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const _ = require('lodash');
|
|
4
4
|
|
|
5
|
-
const {
|
|
6
|
-
validateComponentInput,
|
|
7
|
-
validateUpdateComponentInput,
|
|
8
|
-
} = require('./validation/component');
|
|
5
|
+
const { validateComponentInput, validateUpdateComponentInput } = require('./validation/component');
|
|
9
6
|
|
|
10
7
|
/**
|
|
11
8
|
* Components controller
|
|
@@ -18,10 +15,9 @@ module.exports = {
|
|
|
18
15
|
* @param {Object} ctx - koa context
|
|
19
16
|
*/
|
|
20
17
|
async getComponents(ctx) {
|
|
21
|
-
const componentService =
|
|
22
|
-
strapi.plugins['content-type-builder'].services.components;
|
|
18
|
+
const componentService = strapi.plugins['content-type-builder'].services.components;
|
|
23
19
|
|
|
24
|
-
const data = Object.keys(strapi.components).map(uid => {
|
|
20
|
+
const data = Object.keys(strapi.components).map((uid) => {
|
|
25
21
|
return componentService.formatComponent(strapi.components[uid]);
|
|
26
22
|
});
|
|
27
23
|
|
|
@@ -42,8 +38,7 @@ module.exports = {
|
|
|
42
38
|
return ctx.send({ error: 'component.notFound' }, 404);
|
|
43
39
|
}
|
|
44
40
|
|
|
45
|
-
const componentService =
|
|
46
|
-
strapi.plugins['content-type-builder'].services.components;
|
|
41
|
+
const componentService = strapi.plugins['content-type-builder'].services.components;
|
|
47
42
|
|
|
48
43
|
ctx.send({ data: componentService.formatComponent(component) });
|
|
49
44
|
},
|
|
@@ -65,8 +60,7 @@ module.exports = {
|
|
|
65
60
|
try {
|
|
66
61
|
strapi.reload.isWatching = false;
|
|
67
62
|
|
|
68
|
-
const componentService =
|
|
69
|
-
strapi.plugins['content-type-builder'].services.components;
|
|
63
|
+
const componentService = strapi.plugins['content-type-builder'].services.components;
|
|
70
64
|
|
|
71
65
|
const component = await componentService.createComponent({
|
|
72
66
|
component: body.component,
|
|
@@ -104,8 +98,7 @@ module.exports = {
|
|
|
104
98
|
try {
|
|
105
99
|
strapi.reload.isWatching = false;
|
|
106
100
|
|
|
107
|
-
const componentService =
|
|
108
|
-
strapi.plugins['content-type-builder'].services.components;
|
|
101
|
+
const componentService = strapi.plugins['content-type-builder'].services.components;
|
|
109
102
|
|
|
110
103
|
const component = await componentService.editComponent(uid, {
|
|
111
104
|
component: body.component,
|
|
@@ -136,8 +129,7 @@ module.exports = {
|
|
|
136
129
|
try {
|
|
137
130
|
strapi.reload.isWatching = false;
|
|
138
131
|
|
|
139
|
-
const componentService =
|
|
140
|
-
strapi.plugins['content-type-builder'].services.components;
|
|
132
|
+
const componentService = strapi.plugins['content-type-builder'].services.components;
|
|
141
133
|
|
|
142
134
|
const component = await componentService.deleteComponent(uid);
|
|
143
135
|
|
|
@@ -6,14 +6,8 @@ const _ = require('lodash');
|
|
|
6
6
|
const validators = {
|
|
7
7
|
required: yup.boolean(),
|
|
8
8
|
unique: yup.boolean(),
|
|
9
|
-
minLength: yup
|
|
10
|
-
|
|
11
|
-
.integer()
|
|
12
|
-
.positive(),
|
|
13
|
-
maxLength: yup
|
|
14
|
-
.number()
|
|
15
|
-
.integer()
|
|
16
|
-
.positive(),
|
|
9
|
+
minLength: yup.number().integer().positive(),
|
|
10
|
+
maxLength: yup.number().integer().positive(),
|
|
17
11
|
};
|
|
18
12
|
|
|
19
13
|
const NAME_REGEX = new RegExp('^[A-Za-z][_0-9A-Za-z]*$');
|
|
@@ -26,34 +20,34 @@ const UID_REGEX = new RegExp('^[A-Za-z0-9-_.~]*$');
|
|
|
26
20
|
const isValidName = {
|
|
27
21
|
name: 'isValidName',
|
|
28
22
|
message: '${path} must match the following regex: ' + NAME_REGEX,
|
|
29
|
-
test: val => val === '' || NAME_REGEX.test(val),
|
|
23
|
+
test: (val) => val === '' || NAME_REGEX.test(val),
|
|
30
24
|
};
|
|
31
25
|
|
|
32
26
|
const isValidUID = {
|
|
33
27
|
name: 'isValidUID',
|
|
34
28
|
message: '${path} must match the following regex: ' + UID_REGEX,
|
|
35
|
-
test: val => val === '' || UID_REGEX.test(val),
|
|
29
|
+
test: (val) => val === '' || UID_REGEX.test(val),
|
|
36
30
|
};
|
|
37
31
|
|
|
38
32
|
const isValidCategoryName = {
|
|
39
33
|
name: 'isValidCategoryName',
|
|
40
34
|
message: '${path} must match the following regex: ' + CATEGORY_NAME_REGEX,
|
|
41
|
-
test: val => val === '' || CATEGORY_NAME_REGEX.test(val),
|
|
35
|
+
test: (val) => val === '' || CATEGORY_NAME_REGEX.test(val),
|
|
42
36
|
};
|
|
43
37
|
|
|
44
38
|
const isValidCollectionName = {
|
|
45
39
|
name: 'isValidCollectionName',
|
|
46
40
|
message: '${path} must match the following regex: ' + COLLECTION_NAME_REGEX,
|
|
47
|
-
test: val => val === '' || COLLECTION_NAME_REGEX.test(val),
|
|
41
|
+
test: (val) => val === '' || COLLECTION_NAME_REGEX.test(val),
|
|
48
42
|
};
|
|
49
43
|
|
|
50
44
|
const isValidIcon = {
|
|
51
45
|
name: 'isValidIcon',
|
|
52
46
|
message: '${path} must match the following regex: ' + ICON_REGEX,
|
|
53
|
-
test: val => val === '' || ICON_REGEX.test(val),
|
|
47
|
+
test: (val) => val === '' || ICON_REGEX.test(val),
|
|
54
48
|
};
|
|
55
49
|
|
|
56
|
-
const isValidKey = key => ({
|
|
50
|
+
const isValidKey = (key) => ({
|
|
57
51
|
name: 'isValidKey',
|
|
58
52
|
message: `Attribute name '${key}' must match the following regex: ${NAME_REGEX}`,
|
|
59
53
|
test: () => NAME_REGEX.test(key),
|
|
@@ -62,13 +56,13 @@ const isValidKey = key => ({
|
|
|
62
56
|
const isValidEnum = {
|
|
63
57
|
name: 'isValidEnum',
|
|
64
58
|
message: '${path} must match the following regex: ' + ENUM_REGEX,
|
|
65
|
-
test: val => val === '' || ENUM_REGEX.test(val),
|
|
59
|
+
test: (val) => val === '' || ENUM_REGEX.test(val),
|
|
66
60
|
};
|
|
67
61
|
|
|
68
62
|
const areEnumValuesUnique = {
|
|
69
63
|
name: 'areEnumValuesUnique',
|
|
70
64
|
message: '${path} cannot contain duplicate values',
|
|
71
|
-
test: values => {
|
|
65
|
+
test: (values) => {
|
|
72
66
|
const filtered = [...new Set(values)];
|
|
73
67
|
|
|
74
68
|
return filtered.length === values.length;
|
|
@@ -78,13 +72,13 @@ const areEnumValuesUnique = {
|
|
|
78
72
|
const isValidRegExpPattern = {
|
|
79
73
|
name: 'isValidRegExpPattern',
|
|
80
74
|
message: '${path} must be a valid RexExp pattern string',
|
|
81
|
-
test: val => val === '' || new RegExp(val),
|
|
75
|
+
test: (val) => val === '' || new RegExp(val),
|
|
82
76
|
};
|
|
83
77
|
|
|
84
78
|
const isValidDefaultJSON = {
|
|
85
79
|
name: 'isValidDefaultJSON',
|
|
86
80
|
message: '${path} is not a valid JSON',
|
|
87
|
-
test: val => {
|
|
81
|
+
test: (val) => {
|
|
88
82
|
if (val === undefined) {
|
|
89
83
|
return true;
|
|
90
84
|
}
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
const _ = require('lodash');
|
|
4
4
|
|
|
5
|
-
const removeEmptyDefaults = data => {
|
|
5
|
+
const removeEmptyDefaults = (data) => {
|
|
6
6
|
if (_.has(data, 'attributes')) {
|
|
7
|
-
Object.keys(data.attributes).forEach(attribute => {
|
|
7
|
+
Object.keys(data.attributes).forEach((attribute) => {
|
|
8
8
|
if (data.attributes[attribute].default === '') {
|
|
9
9
|
data.attributes[attribute].default = undefined;
|
|
10
10
|
}
|
|
@@ -12,9 +12,9 @@ const removeEmptyDefaults = data => {
|
|
|
12
12
|
}
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
-
const removeDeletedUIDTargetFields = data => {
|
|
15
|
+
const removeDeletedUIDTargetFields = (data) => {
|
|
16
16
|
if (_.has(data, 'attributes')) {
|
|
17
|
-
Object.values(data.attributes).forEach(attribute => {
|
|
17
|
+
Object.values(data.attributes).forEach((attribute) => {
|
|
18
18
|
if (
|
|
19
19
|
attribute.type === 'uid' &&
|
|
20
20
|
!_.isUndefined(attribute.targetField) &&
|
|
@@ -10,33 +10,24 @@ const getRelationValidator = require('./relations');
|
|
|
10
10
|
|
|
11
11
|
const createSchema = (types, relations, { modelType } = {}) => {
|
|
12
12
|
const shape = {
|
|
13
|
-
name: yup
|
|
14
|
-
.string()
|
|
15
|
-
.min(1)
|
|
16
|
-
.required('name.required'),
|
|
13
|
+
name: yup.string().min(1).required('name.required'),
|
|
17
14
|
description: yup.string(),
|
|
18
15
|
draftAndPublish: yup.boolean(),
|
|
19
16
|
pluginOptions: yup.object(),
|
|
20
17
|
connection: yup.string(),
|
|
21
|
-
collectionName: yup
|
|
22
|
-
.string()
|
|
23
|
-
.nullable()
|
|
24
|
-
.test(isValidCollectionName),
|
|
18
|
+
collectionName: yup.string().nullable().test(isValidCollectionName),
|
|
25
19
|
attributes: createAttributesValidator({ types, relations, modelType }),
|
|
26
20
|
};
|
|
27
21
|
|
|
28
22
|
if (modelType === modelTypes.CONTENT_TYPE) {
|
|
29
|
-
shape.kind = yup
|
|
30
|
-
.string()
|
|
31
|
-
.oneOf([typeKinds.SINGLE_TYPE, typeKinds.COLLECTION_TYPE])
|
|
32
|
-
.nullable();
|
|
23
|
+
shape.kind = yup.string().oneOf([typeKinds.SINGLE_TYPE, typeKinds.COLLECTION_TYPE]).nullable();
|
|
33
24
|
}
|
|
34
25
|
|
|
35
26
|
return yup.object(shape).noUnknown();
|
|
36
27
|
};
|
|
37
28
|
|
|
38
29
|
const createAttributesValidator = ({ types, modelType, relations }) => {
|
|
39
|
-
return yup.lazy(attributes => {
|
|
30
|
+
return yup.lazy((attributes) => {
|
|
40
31
|
return yup
|
|
41
32
|
.object()
|
|
42
33
|
.shape(
|
|
@@ -62,7 +53,7 @@ const createAttributesValidator = ({ types, modelType, relations }) => {
|
|
|
62
53
|
});
|
|
63
54
|
};
|
|
64
55
|
|
|
65
|
-
const isForbiddenKey = key => {
|
|
56
|
+
const isForbiddenKey = (key) => {
|
|
66
57
|
return [
|
|
67
58
|
...FORBIDDEN_ATTRIBUTE_NAMES,
|
|
68
59
|
...strapi.plugins['content-type-builder'].services.builder.getReservedNames().attributes,
|
|
@@ -7,8 +7,8 @@ const { validators, isValidName } = require('./common');
|
|
|
7
7
|
const REVERSE_RELATIONS = ['oneToOne', 'oneToMany', 'manyToOne', 'manyToMany'];
|
|
8
8
|
const STRAPI_USER_RELATIONS = ['oneWay', 'manyWay'];
|
|
9
9
|
|
|
10
|
-
const isValidNature = validNatures =>
|
|
11
|
-
function(value) {
|
|
10
|
+
const isValidNature = (validNatures) =>
|
|
11
|
+
function (value) {
|
|
12
12
|
const allowedRelations =
|
|
13
13
|
this.parent.target === coreUids.STRAPI_USER ? STRAPI_USER_RELATIONS : validNatures;
|
|
14
14
|
|
|
@@ -22,33 +22,21 @@ const isValidNature = validNatures =>
|
|
|
22
22
|
|
|
23
23
|
module.exports = (obj, validNatures) => {
|
|
24
24
|
const contentTypesUIDs = Object.keys(strapi.contentTypes)
|
|
25
|
-
.filter(key => strapi.contentTypes[key].kind === typeKinds.COLLECTION_TYPE)
|
|
26
|
-
.filter(key => !key.startsWith(coreUids.PREFIX) || key === coreUids.STRAPI_USER)
|
|
25
|
+
.filter((key) => strapi.contentTypes[key].kind === typeKinds.COLLECTION_TYPE)
|
|
26
|
+
.filter((key) => !key.startsWith(coreUids.PREFIX) || key === coreUids.STRAPI_USER)
|
|
27
27
|
.concat(['__self__', '__contentType__']);
|
|
28
28
|
|
|
29
29
|
return {
|
|
30
|
-
target: yup
|
|
31
|
-
|
|
32
|
-
.oneOf(contentTypesUIDs)
|
|
33
|
-
.required(),
|
|
34
|
-
nature: yup
|
|
35
|
-
.string()
|
|
36
|
-
.test('isValidNature', isValidNature(validNatures))
|
|
37
|
-
.required(),
|
|
30
|
+
target: yup.string().oneOf(contentTypesUIDs).required(),
|
|
31
|
+
nature: yup.string().test('isValidNature', isValidNature(validNatures)).required(),
|
|
38
32
|
unique: validators.unique.nullable(),
|
|
39
33
|
configurable: yup.boolean().nullable(),
|
|
40
34
|
autoPopulate: yup.boolean().nullable(),
|
|
41
35
|
dominant: yup.boolean().nullable(),
|
|
42
36
|
columnName: yup.string().nullable(),
|
|
43
37
|
targetAttribute: REVERSE_RELATIONS.includes(obj.nature)
|
|
44
|
-
? yup
|
|
45
|
-
|
|
46
|
-
.test(isValidName)
|
|
47
|
-
.required()
|
|
48
|
-
: yup
|
|
49
|
-
.string()
|
|
50
|
-
.test(isValidName)
|
|
51
|
-
.nullable(),
|
|
38
|
+
? yup.string().test(isValidName).required()
|
|
39
|
+
: yup.string().test(isValidName).nullable(),
|
|
52
40
|
targetColumnName: yup.string().nullable(),
|
|
53
41
|
private: yup.boolean().nullable(),
|
|
54
42
|
pluginOptions: yup.object(),
|
|
@@ -18,7 +18,7 @@ const {
|
|
|
18
18
|
const maxLengthIsGreaterThanOrEqualToMinLength = {
|
|
19
19
|
name: 'isGreaterThanMin',
|
|
20
20
|
message: 'maxLength must be greater or equal to minLength',
|
|
21
|
-
test: function(value) {
|
|
21
|
+
test: function (value) {
|
|
22
22
|
const { minLength } = this.parent;
|
|
23
23
|
if (!_.isUndefined(minLength) && !_.isUndefined(value) && value < minLength) {
|
|
24
24
|
return false;
|
|
@@ -30,10 +30,7 @@ const maxLengthIsGreaterThanOrEqualToMinLength = {
|
|
|
30
30
|
|
|
31
31
|
const getTypeValidator = (attribute, { types, modelType, attributes }) => {
|
|
32
32
|
return yup.object({
|
|
33
|
-
type: yup
|
|
34
|
-
.string()
|
|
35
|
-
.oneOf(types)
|
|
36
|
-
.required(),
|
|
33
|
+
type: yup.string().oneOf(types).required(),
|
|
37
34
|
configurable: yup.boolean().nullable(),
|
|
38
35
|
private: yup.boolean().nullable(),
|
|
39
36
|
pluginOptions: yup.object(),
|
|
@@ -65,7 +62,7 @@ const getTypeShape = (attribute, { modelType, attributes } = {}) => {
|
|
|
65
62
|
targetField: yup
|
|
66
63
|
.string()
|
|
67
64
|
.oneOf(
|
|
68
|
-
Object.keys(attributes).filter(key =>
|
|
65
|
+
Object.keys(attributes).filter((key) =>
|
|
69
66
|
VALID_UID_TARGETS.includes(_.get(attributes[key], 'type'))
|
|
70
67
|
)
|
|
71
68
|
)
|
|
@@ -75,7 +72,7 @@ const getTypeShape = (attribute, { modelType, attributes } = {}) => {
|
|
|
75
72
|
.test(
|
|
76
73
|
'isValidDefaultUID',
|
|
77
74
|
'cannot define a default UID if the targetField is set',
|
|
78
|
-
function(value) {
|
|
75
|
+
function (value) {
|
|
79
76
|
const { targetField } = this.parent;
|
|
80
77
|
if (_.isNil(targetField) || _.isNil(value)) {
|
|
81
78
|
return true;
|
|
@@ -91,13 +88,7 @@ const getTypeShape = (attribute, { modelType, attributes } = {}) => {
|
|
|
91
88
|
separator: yup.string(),
|
|
92
89
|
lowercase: yup.boolean(),
|
|
93
90
|
decamelize: yup.boolean(),
|
|
94
|
-
customReplacements: yup.array().of(
|
|
95
|
-
yup
|
|
96
|
-
.array()
|
|
97
|
-
.of(yup.string())
|
|
98
|
-
.min(2)
|
|
99
|
-
.max(2)
|
|
100
|
-
),
|
|
91
|
+
customReplacements: yup.array().of(yup.array().of(yup.string()).min(2).max(2)),
|
|
101
92
|
preserveLeadingUnderscore: yup.boolean(),
|
|
102
93
|
}),
|
|
103
94
|
};
|
|
@@ -136,16 +127,11 @@ const getTypeShape = (attribute, { modelType, attributes } = {}) => {
|
|
|
136
127
|
return {
|
|
137
128
|
enum: yup
|
|
138
129
|
.array()
|
|
139
|
-
.of(
|
|
140
|
-
yup
|
|
141
|
-
.string()
|
|
142
|
-
.test(isValidEnum)
|
|
143
|
-
.required()
|
|
144
|
-
)
|
|
130
|
+
.of(yup.string().test(isValidEnum).required())
|
|
145
131
|
.min(1)
|
|
146
132
|
.test(areEnumValuesUnique)
|
|
147
133
|
.required(),
|
|
148
|
-
default: yup.string().when('enum', enumVal => yup.string().oneOf(enumVal)),
|
|
134
|
+
default: yup.string().when('enum', (enumVal) => yup.string().oneOf(enumVal)),
|
|
149
135
|
enumName: yup.string().test(isValidName),
|
|
150
136
|
required: validators.required,
|
|
151
137
|
unique: validators.unique,
|
|
@@ -178,20 +164,11 @@ const getTypeShape = (attribute, { modelType, attributes } = {}) => {
|
|
|
178
164
|
}
|
|
179
165
|
case 'biginteger': {
|
|
180
166
|
return {
|
|
181
|
-
default: yup
|
|
182
|
-
.string()
|
|
183
|
-
.nullable()
|
|
184
|
-
.matches(/^\d*$/),
|
|
167
|
+
default: yup.string().nullable().matches(/^\d*$/),
|
|
185
168
|
required: validators.required,
|
|
186
169
|
unique: validators.unique,
|
|
187
|
-
min: yup
|
|
188
|
-
|
|
189
|
-
.nullable()
|
|
190
|
-
.matches(/^\d*$/),
|
|
191
|
-
max: yup
|
|
192
|
-
.string()
|
|
193
|
-
.nullable()
|
|
194
|
-
.matches(/^\d*$/),
|
|
170
|
+
min: yup.string().nullable().matches(/^\d*$/),
|
|
171
|
+
max: yup.string().nullable().matches(/^\d*$/),
|
|
195
172
|
};
|
|
196
173
|
}
|
|
197
174
|
case 'float': {
|
|
@@ -237,7 +214,7 @@ const getTypeShape = (attribute, { modelType, attributes } = {}) => {
|
|
|
237
214
|
.string()
|
|
238
215
|
.test({
|
|
239
216
|
name: 'Check max component nesting is 1 lvl',
|
|
240
|
-
test: function(compoUID) {
|
|
217
|
+
test: function (compoUID) {
|
|
241
218
|
const targetCompo = strapi.components[compoUID];
|
|
242
219
|
if (!targetCompo) return true; // ignore this error as it will fail beforehand
|
|
243
220
|
|
|
@@ -262,7 +239,7 @@ const getTypeShape = (attribute, { modelType, attributes } = {}) => {
|
|
|
262
239
|
components: yup
|
|
263
240
|
.array()
|
|
264
241
|
.of(yup.string().required())
|
|
265
|
-
.test('isArray', '${path} must be an array', value => Array.isArray(value)),
|
|
242
|
+
.test('isArray', '${path} must be an array', (value) => Array.isArray(value)),
|
|
266
243
|
min: yup.number(),
|
|
267
244
|
max: yup.number(),
|
|
268
245
|
};
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "3.7.
|
|
6
|
+
"version": "3.7.2",
|
|
7
7
|
"description": "Strapi plugin to create content type (API).",
|
|
8
8
|
"strapi": {
|
|
9
9
|
"name": "Content Type Builder",
|
|
@@ -11,10 +11,10 @@
|
|
|
11
11
|
"description": "content-type-builder.plugin.description"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@akemona-org/strapi-generate": "3.7.
|
|
15
|
-
"@akemona-org/strapi-generate-api": "3.7.
|
|
16
|
-
"@akemona-org/strapi-helper-plugin": "3.7.
|
|
17
|
-
"@akemona-org/strapi-utils": "3.7.
|
|
14
|
+
"@akemona-org/strapi-generate": "3.7.2",
|
|
15
|
+
"@akemona-org/strapi-generate-api": "3.7.2",
|
|
16
|
+
"@akemona-org/strapi-helper-plugin": "3.7.2",
|
|
17
|
+
"@akemona-org/strapi-utils": "3.7.2",
|
|
18
18
|
"@buffetjs/core": "3.3.8",
|
|
19
19
|
"@buffetjs/custom": "3.3.8",
|
|
20
20
|
"@buffetjs/hooks": "3.3.8",
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"npm": ">=6.0.0"
|
|
60
60
|
},
|
|
61
61
|
"license": "SEE LICENSE IN LICENSE",
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "4ab59dbae5135819558c6ae27b45a556ff27cf55"
|
|
63
63
|
}
|
package/services/Components.js
CHANGED
|
@@ -11,7 +11,7 @@ const createBuilder = require('./schema-builder');
|
|
|
11
11
|
* @param {string} uid - string
|
|
12
12
|
* @param {Object} component - strapi component model
|
|
13
13
|
*/
|
|
14
|
-
const formatComponent = component => {
|
|
14
|
+
const formatComponent = (component) => {
|
|
15
15
|
const { uid, modelName, connection, collectionName, info, category } = component;
|
|
16
16
|
|
|
17
17
|
return {
|
|
@@ -44,7 +44,7 @@ const createComponent = async ({ component, components = [] }) => {
|
|
|
44
44
|
|
|
45
45
|
const newComponent = builder.createComponent(replaceTmpUIDs(component));
|
|
46
46
|
|
|
47
|
-
components.forEach(component => {
|
|
47
|
+
components.forEach((component) => {
|
|
48
48
|
if (!_.has(component, 'uid')) {
|
|
49
49
|
return builder.createComponent(replaceTmpUIDs(component));
|
|
50
50
|
}
|
|
@@ -73,7 +73,7 @@ const editComponent = async (uid, { component, components = [] }) => {
|
|
|
73
73
|
...replaceTmpUIDs(component),
|
|
74
74
|
});
|
|
75
75
|
|
|
76
|
-
components.forEach(component => {
|
|
76
|
+
components.forEach((component) => {
|
|
77
77
|
if (!_.has(component, 'uid')) {
|
|
78
78
|
return builder.createComponent(replaceTmpUIDs(component));
|
|
79
79
|
}
|
|
@@ -85,7 +85,7 @@ const editComponent = async (uid, { component, components = [] }) => {
|
|
|
85
85
|
return updatedComponent;
|
|
86
86
|
};
|
|
87
87
|
|
|
88
|
-
const deleteComponent = async uid => {
|
|
88
|
+
const deleteComponent = async (uid) => {
|
|
89
89
|
const builder = createBuilder();
|
|
90
90
|
|
|
91
91
|
const deletedComponent = builder.deleteComponent(uid);
|
package/services/ContentTypes.js
CHANGED
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
const _ = require('lodash');
|
|
4
4
|
const { getOr } = require('lodash/fp');
|
|
5
5
|
const pluralize = require('pluralize');
|
|
6
|
-
const generator = require('strapi-generate');
|
|
7
6
|
|
|
7
|
+
// eslint-disable-next-line node/no-extraneous-require
|
|
8
|
+
const generator = require('strapi-generate');
|
|
8
9
|
const { nameToSlug, contentTypes: contentTypesUtils } = require('@akemona-org/strapi-utils');
|
|
9
10
|
const { formatAttributes, replaceTemporaryUIDs } = require('../utils/attributes');
|
|
10
11
|
const createBuilder = require('./schema-builder');
|