@strapi/strapi 4.4.0-alpha.0 → 4.4.0-beta.3
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/README.md +17 -8
- package/lib/Strapi.js +2 -2
- package/lib/commands/admin-create.js +1 -1
- package/lib/commands/configurationDump.js +2 -2
- package/lib/core/loaders/apis.js +1 -1
- package/lib/core/loaders/plugins/get-enabled-plugins.js +3 -1
- package/lib/core/loaders/plugins/index.js +5 -5
- package/lib/core/registries/content-types.js +2 -2
- package/lib/core/registries/controllers.js +2 -2
- package/lib/core/registries/custom-fields.js +1 -1
- package/lib/core/registries/hooks.js +1 -1
- package/lib/core/registries/middlewares.js +2 -2
- package/lib/core/registries/policies.js +1 -1
- package/lib/core/registries/services.js +2 -2
- package/lib/core-api/controller/transform.js +1 -1
- package/lib/services/cron.js +1 -1
- package/lib/services/custom-fields.js +1 -1
- package/lib/services/entity-service/components.js +28 -8
- package/lib/services/entity-service/index.js +9 -2
- package/lib/services/entity-validator/index.js +22 -17
- package/lib/services/metrics/middleware.js +1 -1
- package/lib/services/metrics/sender.js +2 -2
- package/lib/services/server/register-routes.js +2 -2
- package/lib/services/utils/upload-files.js +1 -1
- package/lib/services/worker-queue.js +2 -2
- package/lib/types/core/strapi/index.d.ts +36 -7
- package/lib/utils/addSlash.js +6 -5
- package/lib/utils/convert-custom-field-type.js +3 -3
- package/package.json +14 -14
package/README.md
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<a href="https://strapi.io">
|
|
2
|
+
<a href="https://strapi.io/#gh-light-mode-only">
|
|
3
3
|
<img src="https://strapi.io/assets/strapi-logo-dark.svg" width="318px" alt="Strapi logo" />
|
|
4
4
|
</a>
|
|
5
|
+
<a href="https://strapi.io/#gh-dark-mode-only">
|
|
6
|
+
<img src="https://strapi.io/assets/strapi-logo-light.svg" width="318px" alt="Strapi logo" />
|
|
7
|
+
</a>
|
|
5
8
|
</p>
|
|
9
|
+
|
|
6
10
|
<h3 align="center">API creation made simple, secure and fast.</h3>
|
|
7
11
|
<p align="center">The most advanced open-source headless CMS to build powerful APIs with no effort.</p>
|
|
8
12
|
<p align="center"><a href="https://strapi.io/demo">Try live demo</a></p>
|
|
@@ -18,6 +22,9 @@
|
|
|
18
22
|
<a href="https://discord.strapi.io">
|
|
19
23
|
<img src="https://img.shields.io/discord/811989166782021633?label=Discord" alt="Strapi on Discord" />
|
|
20
24
|
</a>
|
|
25
|
+
<a href="https://github.com/strapi/strapi/actions/workflows/nightly.yml">
|
|
26
|
+
<img src="https://github.com/strapi/strapi/actions/workflows/nightly.yml/badge.svg" alt="Strapi Nightly Release Build Status" />
|
|
27
|
+
</a>
|
|
21
28
|
</p>
|
|
22
29
|
|
|
23
30
|
<br>
|
|
@@ -79,15 +86,17 @@ Complete installation requirements can be found in the documentation under <a hr
|
|
|
79
86
|
|
|
80
87
|
**Node:**
|
|
81
88
|
|
|
82
|
-
- NodeJS >=
|
|
89
|
+
- NodeJS >= 14 <= 18
|
|
83
90
|
- NPM >= 6.x
|
|
84
91
|
|
|
85
92
|
**Database:**
|
|
86
93
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
94
|
+
| Database | Minimum | Recommended |
|
|
95
|
+
| ---------- | ------- | ----------- |
|
|
96
|
+
| MySQL | 5.7.8 | 8.0 |
|
|
97
|
+
| MariaDB | 10.3 | 10.6 |
|
|
98
|
+
| PostgreSQL | 11.0 | 14.0 |
|
|
99
|
+
| SQLite | 3 | 3 |
|
|
91
100
|
|
|
92
101
|
**We recommend always using the latest version of Strapi to start your new projects**.
|
|
93
102
|
|
|
@@ -114,7 +123,7 @@ For general help using Strapi, please refer to [the official Strapi documentatio
|
|
|
114
123
|
- [Discord](https://discord.strapi.io) (For live discussion with the Community and Strapi team)
|
|
115
124
|
- [GitHub](https://github.com/strapi/strapi) (Bug reports, Contributions)
|
|
116
125
|
- [Community Forum](https://forum.strapi.io) (Questions and Discussions)
|
|
117
|
-
- [
|
|
126
|
+
- [Feedback section](https://feedback.strapi.io) (Roadmap, Feature requests)
|
|
118
127
|
- [Twitter](https://twitter.com/strapijs) (Get the news fast)
|
|
119
128
|
- [Facebook](https://www.facebook.com/Strapi-616063331867161)
|
|
120
129
|
- [YouTube Channel](https://www.youtube.com/strapi) (Learn from Video Tutorials)
|
|
@@ -125,7 +134,7 @@ Follow our [migration guides](https://docs.strapi.io/developer-docs/latest/updat
|
|
|
125
134
|
|
|
126
135
|
## Roadmap
|
|
127
136
|
|
|
128
|
-
Check out our [roadmap](https://feedback.strapi.io
|
|
137
|
+
Check out our [roadmap](https://feedback.strapi.io) to get informed of the latest features released and the upcoming ones. You may also give us insights and vote for a specific feature.
|
|
129
138
|
|
|
130
139
|
## Documentation
|
|
131
140
|
|
package/lib/Strapi.js
CHANGED
|
@@ -383,6 +383,8 @@ class Strapi {
|
|
|
383
383
|
this.telemetry.register();
|
|
384
384
|
|
|
385
385
|
await this.runLifecyclesFunctions(LIFECYCLES.REGISTER);
|
|
386
|
+
// NOTE: Swap type customField for underlying data type
|
|
387
|
+
convertCustomFieldType(this);
|
|
386
388
|
|
|
387
389
|
return this;
|
|
388
390
|
}
|
|
@@ -460,8 +462,6 @@ class Strapi {
|
|
|
460
462
|
|
|
461
463
|
async load() {
|
|
462
464
|
await this.register();
|
|
463
|
-
// Swap type customField for underlying data type
|
|
464
|
-
convertCustomFieldType(this);
|
|
465
465
|
await this.bootstrap();
|
|
466
466
|
|
|
467
467
|
this.isLoaded = true;
|
|
@@ -17,7 +17,7 @@ const passwordValidator = yup
|
|
|
17
17
|
const adminCreateSchema = yup.object().shape({
|
|
18
18
|
email: emailValidator,
|
|
19
19
|
password: passwordValidator,
|
|
20
|
-
firstname: yup.string().required('First name is required'),
|
|
20
|
+
firstname: yup.string().trim().required('First name is required'),
|
|
21
21
|
lastname: yup.string(),
|
|
22
22
|
});
|
|
23
23
|
|
|
@@ -9,7 +9,7 @@ const CHUNK_SIZE = 100;
|
|
|
9
9
|
* Will dump configurations to a file or stdout
|
|
10
10
|
* @param {string} file filepath to use as output
|
|
11
11
|
*/
|
|
12
|
-
module.exports = async
|
|
12
|
+
module.exports = async ({ file: filePath, pretty }) => {
|
|
13
13
|
const output = filePath ? fs.createWriteStream(filePath) : process.stdout;
|
|
14
14
|
|
|
15
15
|
const appContext = await strapi.compile();
|
|
@@ -21,7 +21,7 @@ module.exports = async function ({ file: filePath, pretty }) {
|
|
|
21
21
|
|
|
22
22
|
const pageCount = Math.ceil(count / CHUNK_SIZE);
|
|
23
23
|
|
|
24
|
-
for (let page = 0; page < pageCount; page
|
|
24
|
+
for (let page = 0; page < pageCount; page += 1) {
|
|
25
25
|
const results = await app
|
|
26
26
|
.query('strapi::core-store')
|
|
27
27
|
.findMany({ limit: CHUNK_SIZE, offset: page * CHUNK_SIZE, orderBy: 'key' });
|
package/lib/core/loaders/apis.js
CHANGED
|
@@ -59,7 +59,9 @@ const getEnabledPlugins = async (strapi) => {
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
const installedPlugins = {};
|
|
62
|
-
|
|
62
|
+
const dependencies = strapi.config.get('info.dependencies', {});
|
|
63
|
+
|
|
64
|
+
for (const dep of Object.keys(dependencies)) {
|
|
63
65
|
const packagePath = join(dep, 'package.json');
|
|
64
66
|
let packageInfo;
|
|
65
67
|
try {
|
|
@@ -34,10 +34,10 @@ const applyUserExtension = async (plugins) => {
|
|
|
34
34
|
const extendedSchemas = await loadFiles(extensionsDir, '**/content-types/**/schema.json');
|
|
35
35
|
const strapiServers = await loadFiles(extensionsDir, '**/strapi-server.js');
|
|
36
36
|
|
|
37
|
-
for (const pluginName
|
|
37
|
+
for (const pluginName of Object.keys(plugins)) {
|
|
38
38
|
const plugin = plugins[pluginName];
|
|
39
39
|
// first: load json schema
|
|
40
|
-
for (const ctName
|
|
40
|
+
for (const ctName of Object.keys(plugin.contentTypes)) {
|
|
41
41
|
const extendedSchema = get([pluginName, 'content-types', ctName, 'schema'], extendedSchemas);
|
|
42
42
|
if (extendedSchema) {
|
|
43
43
|
plugin.contentTypes[ctName].schema = {
|
|
@@ -57,7 +57,7 @@ const applyUserExtension = async (plugins) => {
|
|
|
57
57
|
const applyUserConfig = async (plugins) => {
|
|
58
58
|
const userPluginsConfig = await getUserPluginsConfig();
|
|
59
59
|
|
|
60
|
-
for (const pluginName
|
|
60
|
+
for (const pluginName of Object.keys(plugins)) {
|
|
61
61
|
const plugin = plugins[pluginName];
|
|
62
62
|
const userPluginConfig = getOr({}, `${pluginName}.config`, userPluginsConfig);
|
|
63
63
|
const defaultConfig =
|
|
@@ -82,7 +82,7 @@ const loadPlugins = async (strapi) => {
|
|
|
82
82
|
|
|
83
83
|
strapi.config.set('enabledPlugins', enabledPlugins);
|
|
84
84
|
|
|
85
|
-
for (const pluginName
|
|
85
|
+
for (const pluginName of Object.keys(enabledPlugins)) {
|
|
86
86
|
const enabledPlugin = enabledPlugins[pluginName];
|
|
87
87
|
|
|
88
88
|
const serverEntrypointPath = join(enabledPlugin.pathToPlugin, 'strapi-server.js');
|
|
@@ -100,7 +100,7 @@ const loadPlugins = async (strapi) => {
|
|
|
100
100
|
await applyUserConfig(plugins);
|
|
101
101
|
await applyUserExtension(plugins);
|
|
102
102
|
|
|
103
|
-
for (const pluginName
|
|
103
|
+
for (const pluginName of Object.keys(plugins)) {
|
|
104
104
|
strapi.container.get('plugins').add(pluginName, plugins[pluginName]);
|
|
105
105
|
}
|
|
106
106
|
};
|
|
@@ -5,7 +5,7 @@ const { createContentType } = require('../domain/content-type');
|
|
|
5
5
|
const { addNamespace, hasNamespace } = require('../utils');
|
|
6
6
|
|
|
7
7
|
const validateKeySameToSingularName = (contentTypes) => {
|
|
8
|
-
for (const ctName
|
|
8
|
+
for (const ctName of Object.keys(contentTypes)) {
|
|
9
9
|
const contentType = contentTypes[ctName];
|
|
10
10
|
|
|
11
11
|
if (ctName !== contentType.schema.info.singularName) {
|
|
@@ -63,7 +63,7 @@ const contentTypesRegistry = () => {
|
|
|
63
63
|
add(namespace, newContentTypes) {
|
|
64
64
|
validateKeySameToSingularName(newContentTypes);
|
|
65
65
|
|
|
66
|
-
for (const rawCtName
|
|
66
|
+
for (const rawCtName of Object.keys(newContentTypes)) {
|
|
67
67
|
const uid = addNamespace(rawCtName, namespace);
|
|
68
68
|
|
|
69
69
|
if (has(uid, contentTypes)) {
|
|
@@ -48,7 +48,7 @@ const controllersRegistry = () => {
|
|
|
48
48
|
const filteredControllers = pickBy((_, uid) => hasNamespace(uid, namespace))(controllers);
|
|
49
49
|
|
|
50
50
|
const map = {};
|
|
51
|
-
for (const uid
|
|
51
|
+
for (const uid of Object.keys(filteredControllers)) {
|
|
52
52
|
Object.defineProperty(map, uid, {
|
|
53
53
|
enumerable: true,
|
|
54
54
|
get: () => {
|
|
@@ -78,7 +78,7 @@ const controllersRegistry = () => {
|
|
|
78
78
|
* @returns
|
|
79
79
|
*/
|
|
80
80
|
add(namespace, newControllers) {
|
|
81
|
-
for (const controllerName
|
|
81
|
+
for (const controllerName of Object.keys(newControllers)) {
|
|
82
82
|
const controller = newControllers[controllerName];
|
|
83
83
|
const uid = addNamespace(controllerName, namespace);
|
|
84
84
|
|
|
@@ -54,8 +54,8 @@ const middlewaresRegistry = () => {
|
|
|
54
54
|
* @param {{ [key: string]: Middleware }} newMiddlewares
|
|
55
55
|
* @returns
|
|
56
56
|
*/
|
|
57
|
-
add(namespace, rawMiddlewares) {
|
|
58
|
-
for (const middlewareName
|
|
57
|
+
add(namespace, rawMiddlewares = {}) {
|
|
58
|
+
for (const middlewareName of Object.keys(rawMiddlewares)) {
|
|
59
59
|
const middleware = rawMiddlewares[middlewareName];
|
|
60
60
|
const uid = addNamespace(middlewareName, namespace);
|
|
61
61
|
|
|
@@ -55,7 +55,7 @@ const policiesRegistry = () => {
|
|
|
55
55
|
* @returns
|
|
56
56
|
*/
|
|
57
57
|
add(namespace, newPolicies) {
|
|
58
|
-
for (const policyName
|
|
58
|
+
for (const policyName of Object.keys(newPolicies)) {
|
|
59
59
|
const policy = newPolicies[policyName];
|
|
60
60
|
const uid = addNamespace(policyName, namespace);
|
|
61
61
|
|
|
@@ -48,7 +48,7 @@ const servicesRegistry = (strapi) => {
|
|
|
48
48
|
|
|
49
49
|
// create lazy accessor to avoid instantiating the services;
|
|
50
50
|
const map = {};
|
|
51
|
-
for (const uid
|
|
51
|
+
for (const uid of Object.keys(filteredServices)) {
|
|
52
52
|
Object.defineProperty(map, uid, {
|
|
53
53
|
enumerable: true,
|
|
54
54
|
get: () => {
|
|
@@ -78,7 +78,7 @@ const servicesRegistry = (strapi) => {
|
|
|
78
78
|
* @returns
|
|
79
79
|
*/
|
|
80
80
|
add(namespace, newServices) {
|
|
81
|
-
for (const serviceName
|
|
81
|
+
for (const serviceName of Object.keys(newServices)) {
|
|
82
82
|
const service = newServices[serviceName];
|
|
83
83
|
const uid = addNamespace(serviceName, namespace);
|
|
84
84
|
|
package/lib/services/cron.js
CHANGED
|
@@ -5,6 +5,7 @@ const { has, prop, omit, toString } = require('lodash/fp');
|
|
|
5
5
|
|
|
6
6
|
const { contentTypes: contentTypesUtils } = require('@strapi/utils');
|
|
7
7
|
const { ApplicationError } = require('@strapi/utils').errors;
|
|
8
|
+
const { getComponentAttributes } = require('@strapi/utils').contentTypes;
|
|
8
9
|
|
|
9
10
|
const omitComponentData = (contentType, data) => {
|
|
10
11
|
const { attributes } = contentType;
|
|
@@ -17,11 +18,11 @@ const omitComponentData = (contentType, data) => {
|
|
|
17
18
|
|
|
18
19
|
// NOTE: we could generalize the logic to allow CRUD of relation directly in the DB layer
|
|
19
20
|
const createComponents = async (uid, data) => {
|
|
20
|
-
const { attributes } = strapi.getModel(uid);
|
|
21
|
+
const { attributes = {} } = strapi.getModel(uid);
|
|
21
22
|
|
|
22
23
|
const componentBody = {};
|
|
23
24
|
|
|
24
|
-
for (const attributeName
|
|
25
|
+
for (const attributeName of Object.keys(attributes)) {
|
|
25
26
|
const attribute = attributes[attributeName];
|
|
26
27
|
|
|
27
28
|
if (!has(attributeName, data) || !contentTypesUtils.isComponentAttribute(attribute)) {
|
|
@@ -100,16 +101,28 @@ const createComponents = async (uid, data) => {
|
|
|
100
101
|
return componentBody;
|
|
101
102
|
};
|
|
102
103
|
|
|
104
|
+
/**
|
|
105
|
+
* @param {str} uid
|
|
106
|
+
* @param {object} entity
|
|
107
|
+
* @return {Promise<{uid: string, entity: object}>}
|
|
108
|
+
*/
|
|
109
|
+
const getComponents = async (uid, entity) => {
|
|
110
|
+
const componentAttributes = getComponentAttributes(strapi.getModel(uid));
|
|
111
|
+
|
|
112
|
+
if (_.isEmpty(componentAttributes)) return {};
|
|
113
|
+
return strapi.query(uid).load(entity, componentAttributes);
|
|
114
|
+
};
|
|
115
|
+
|
|
103
116
|
/*
|
|
104
117
|
delete old components
|
|
105
118
|
create or update
|
|
106
119
|
*/
|
|
107
120
|
const updateComponents = async (uid, entityToUpdate, data) => {
|
|
108
|
-
const { attributes } = strapi.getModel(uid);
|
|
121
|
+
const { attributes = {} } = strapi.getModel(uid);
|
|
109
122
|
|
|
110
123
|
const componentBody = {};
|
|
111
124
|
|
|
112
|
-
for (const attributeName
|
|
125
|
+
for (const attributeName of Object.keys(attributes)) {
|
|
113
126
|
const attribute = attributes[attributeName];
|
|
114
127
|
|
|
115
128
|
if (!has(attributeName, data)) {
|
|
@@ -262,15 +275,18 @@ const deleteOldDZComponents = async (uid, entityToUpdate, attributeName, dynamic
|
|
|
262
275
|
};
|
|
263
276
|
|
|
264
277
|
const deleteComponents = async (uid, entityToDelete) => {
|
|
265
|
-
const { attributes } = strapi.getModel(uid);
|
|
278
|
+
const { attributes = {} } = strapi.getModel(uid);
|
|
266
279
|
|
|
267
|
-
for (const attributeName
|
|
280
|
+
for (const attributeName of Object.keys(attributes)) {
|
|
268
281
|
const attribute = attributes[attributeName];
|
|
269
282
|
|
|
270
283
|
if (attribute.type === 'component') {
|
|
271
284
|
const { component: componentUID } = attribute;
|
|
272
285
|
|
|
273
|
-
|
|
286
|
+
// Load attribute value if it's not already loaded
|
|
287
|
+
const value =
|
|
288
|
+
entityToDelete[attributeName] ||
|
|
289
|
+
(await strapi.query(uid).load(entityToDelete, attributeName));
|
|
274
290
|
|
|
275
291
|
if (!value) {
|
|
276
292
|
continue;
|
|
@@ -286,7 +302,9 @@ const deleteComponents = async (uid, entityToDelete) => {
|
|
|
286
302
|
}
|
|
287
303
|
|
|
288
304
|
if (attribute.type === 'dynamiczone') {
|
|
289
|
-
const value =
|
|
305
|
+
const value =
|
|
306
|
+
entityToDelete[attributeName] ||
|
|
307
|
+
(await strapi.query(uid).load(entityToDelete, attributeName));
|
|
290
308
|
|
|
291
309
|
if (!value) {
|
|
292
310
|
continue;
|
|
@@ -352,7 +370,9 @@ const deleteComponent = async (uid, componentToDelete) => {
|
|
|
352
370
|
|
|
353
371
|
module.exports = {
|
|
354
372
|
omitComponentData,
|
|
373
|
+
getComponents,
|
|
355
374
|
createComponents,
|
|
356
375
|
updateComponents,
|
|
357
376
|
deleteComponents,
|
|
377
|
+
deleteComponent,
|
|
358
378
|
};
|
|
@@ -14,6 +14,7 @@ const uploadFiles = require('../utils/upload-files');
|
|
|
14
14
|
|
|
15
15
|
const {
|
|
16
16
|
omitComponentData,
|
|
17
|
+
getComponents,
|
|
17
18
|
createComponents,
|
|
18
19
|
updateComponents,
|
|
19
20
|
deleteComponents,
|
|
@@ -213,8 +214,10 @@ const createDefaultImplementation = ({ strapi, db, eventHub, entityValidator })
|
|
|
213
214
|
return null;
|
|
214
215
|
}
|
|
215
216
|
|
|
217
|
+
const componentsToDelete = await getComponents(uid, entityToDelete);
|
|
218
|
+
|
|
216
219
|
await db.query(uid).delete({ where: { id: entityToDelete.id } });
|
|
217
|
-
await deleteComponents(uid, entityToDelete);
|
|
220
|
+
await deleteComponents(uid, { ...entityToDelete, ...componentsToDelete });
|
|
218
221
|
|
|
219
222
|
await this.emitEvent(uid, ENTRY_DELETE, entityToDelete);
|
|
220
223
|
|
|
@@ -234,8 +237,12 @@ const createDefaultImplementation = ({ strapi, db, eventHub, entityValidator })
|
|
|
234
237
|
return null;
|
|
235
238
|
}
|
|
236
239
|
|
|
240
|
+
const componentsToDelete = await Promise.all(
|
|
241
|
+
entitiesToDelete.map((entityToDelete) => getComponents(uid, entityToDelete))
|
|
242
|
+
);
|
|
243
|
+
|
|
237
244
|
const deletedEntities = await db.query(uid).deleteMany(query);
|
|
238
|
-
await Promise.all(
|
|
245
|
+
await Promise.all(componentsToDelete.map((compos) => deleteComponents(uid, compos)));
|
|
239
246
|
|
|
240
247
|
// Trigger webhooks. One for each entity
|
|
241
248
|
await Promise.all(entitiesToDelete.map((entity) => this.emitEvent(uid, ENTRY_DELETE, entity)));
|
|
@@ -14,51 +14,56 @@ const { isMediaAttribute, isScalarAttribute, getWritableAttributes } = strapiUti
|
|
|
14
14
|
const { ValidationError } = strapiUtils.errors;
|
|
15
15
|
|
|
16
16
|
const addMinMax = (validator, { attr, updatedAttribute }) => {
|
|
17
|
+
let nextValidator = validator;
|
|
18
|
+
|
|
17
19
|
if (
|
|
18
20
|
Number.isInteger(attr.min) &&
|
|
19
21
|
(attr.required || (Array.isArray(updatedAttribute.value) && updatedAttribute.value.length > 0))
|
|
20
22
|
) {
|
|
21
|
-
|
|
23
|
+
nextValidator = nextValidator.min(attr.min);
|
|
22
24
|
}
|
|
23
25
|
if (Number.isInteger(attr.max)) {
|
|
24
|
-
|
|
26
|
+
nextValidator = nextValidator.max(attr.max);
|
|
25
27
|
}
|
|
26
|
-
return
|
|
28
|
+
return nextValidator;
|
|
27
29
|
};
|
|
28
30
|
|
|
29
|
-
const addRequiredValidation =
|
|
30
|
-
(
|
|
31
|
-
|
|
31
|
+
const addRequiredValidation = (createOrUpdate) => {
|
|
32
|
+
return (validator, { attr: { required } }) => {
|
|
33
|
+
let nextValidator = validator;
|
|
32
34
|
if (required) {
|
|
33
35
|
if (createOrUpdate === 'creation') {
|
|
34
|
-
|
|
36
|
+
nextValidator = nextValidator.notNil();
|
|
35
37
|
} else if (createOrUpdate === 'update') {
|
|
36
|
-
|
|
38
|
+
nextValidator = nextValidator.notNull();
|
|
37
39
|
}
|
|
38
40
|
} else {
|
|
39
|
-
|
|
41
|
+
nextValidator = nextValidator.nullable();
|
|
40
42
|
}
|
|
41
|
-
return
|
|
43
|
+
return nextValidator;
|
|
42
44
|
};
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const addDefault = (createOrUpdate) => {
|
|
48
|
+
return (validator, { attr }) => {
|
|
49
|
+
let nextValidator = validator;
|
|
43
50
|
|
|
44
|
-
const addDefault =
|
|
45
|
-
(createOrUpdate) =>
|
|
46
|
-
(validator, { attr }) => {
|
|
47
51
|
if (createOrUpdate === 'creation') {
|
|
48
52
|
if (
|
|
49
53
|
((attr.type === 'component' && attr.repeatable) || attr.type === 'dynamiczone') &&
|
|
50
54
|
!attr.required
|
|
51
55
|
) {
|
|
52
|
-
|
|
56
|
+
nextValidator = nextValidator.default([]);
|
|
53
57
|
} else {
|
|
54
|
-
|
|
58
|
+
nextValidator = nextValidator.default(attr.default);
|
|
55
59
|
}
|
|
56
60
|
} else {
|
|
57
|
-
|
|
61
|
+
nextValidator = nextValidator.default(undefined);
|
|
58
62
|
}
|
|
59
63
|
|
|
60
|
-
return
|
|
64
|
+
return nextValidator;
|
|
61
65
|
};
|
|
66
|
+
};
|
|
62
67
|
|
|
63
68
|
const preventCast = (validator) => validator.transform((val, originalVal) => originalVal);
|
|
64
69
|
|
|
@@ -45,12 +45,12 @@ module.exports = (strapi) => {
|
|
|
45
45
|
environment: strapi.config.environment,
|
|
46
46
|
os: os.type(),
|
|
47
47
|
osPlatform: os.platform(),
|
|
48
|
+
osArch: os.arch(),
|
|
48
49
|
osRelease: os.release(),
|
|
49
|
-
nodeVersion: process.
|
|
50
|
+
nodeVersion: process.versions.node,
|
|
50
51
|
docker: process.env.DOCKER || isDocker(),
|
|
51
52
|
isCI: ciEnv.isCI,
|
|
52
53
|
version: strapi.config.get('info.strapi'),
|
|
53
|
-
strapiVersion: strapi.config.get('info.strapi'),
|
|
54
54
|
projectType: isEE ? 'Enterprise' : 'Community',
|
|
55
55
|
useTypescriptOnServer: isUsingTypeScriptSync(serverRootPath),
|
|
56
56
|
useTypescriptOnAdmin: isUsingTypeScriptSync(adminRootPath),
|
|
@@ -50,7 +50,7 @@ const registerAdminRoutes = (strapi) => {
|
|
|
50
50
|
* @param {import('../../').Strapi} strapi
|
|
51
51
|
*/
|
|
52
52
|
const registerPluginRoutes = (strapi) => {
|
|
53
|
-
for (const pluginName
|
|
53
|
+
for (const pluginName of Object.keys(strapi.plugins)) {
|
|
54
54
|
const plugin = strapi.plugins[pluginName];
|
|
55
55
|
|
|
56
56
|
const generateRouteScope = createRouteScopeGenerator(`plugin::${pluginName}`);
|
|
@@ -86,7 +86,7 @@ const registerPluginRoutes = (strapi) => {
|
|
|
86
86
|
* @param {import('../../').Strapi} strapi
|
|
87
87
|
*/
|
|
88
88
|
const registerAPIRoutes = (strapi) => {
|
|
89
|
-
for (const apiName
|
|
89
|
+
for (const apiName of Object.keys(strapi.api)) {
|
|
90
90
|
const api = strapi.api[apiName];
|
|
91
91
|
|
|
92
92
|
const generateRouteScope = createRouteScopeGenerator(`api::${apiName}`);
|
|
@@ -27,7 +27,7 @@ module.exports = async (uid, entity, files) => {
|
|
|
27
27
|
let tmpModel = modelDef;
|
|
28
28
|
let modelUID = uid;
|
|
29
29
|
|
|
30
|
-
for (let i = 0; i < path.length; i
|
|
30
|
+
for (let i = 0; i < path.length; i += 1) {
|
|
31
31
|
if (!tmpModel) return {};
|
|
32
32
|
const part = path[i];
|
|
33
33
|
const attr = tmpModel.attributes[part];
|
|
@@ -26,7 +26,7 @@ module.exports = class WorkerQueue {
|
|
|
26
26
|
enqueue(payload) {
|
|
27
27
|
debug('Enqueue event in worker queue');
|
|
28
28
|
if (this.running < this.concurrency) {
|
|
29
|
-
this.running
|
|
29
|
+
this.running += 1;
|
|
30
30
|
this.execute(payload);
|
|
31
31
|
} else {
|
|
32
32
|
this.queue.unshift(payload);
|
|
@@ -40,7 +40,7 @@ module.exports = class WorkerQueue {
|
|
|
40
40
|
if (payload) {
|
|
41
41
|
this.execute(payload);
|
|
42
42
|
} else {
|
|
43
|
-
this.running
|
|
43
|
+
this.running -= 1;
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
|
|
@@ -5,6 +5,28 @@ import type { StringMap } from './utils';
|
|
|
5
5
|
import type { GenericController } from '../../../core-api/controller'
|
|
6
6
|
import type { GenericService } from '../../../core-api/service'
|
|
7
7
|
|
|
8
|
+
// TODO move custom fields types to a separate file
|
|
9
|
+
interface CustomFieldServerOptions {
|
|
10
|
+
/**
|
|
11
|
+
* The name of the custom field
|
|
12
|
+
*/
|
|
13
|
+
name: string;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The name of the plugin creating the custom field
|
|
17
|
+
*/
|
|
18
|
+
plugin?: string;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The existing Strapi data type the custom field uses
|
|
22
|
+
*/
|
|
23
|
+
type: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
interface CustomFields {
|
|
27
|
+
register: (customFields: CustomFieldServerOptions[] | CustomFieldServerOptions) => void;
|
|
28
|
+
}
|
|
29
|
+
|
|
8
30
|
/**
|
|
9
31
|
* The Strapi interface implemented by the main Strapi class.
|
|
10
32
|
*/
|
|
@@ -65,6 +87,13 @@ export interface Strapi {
|
|
|
65
87
|
*/
|
|
66
88
|
contentType(uid: string): any;
|
|
67
89
|
|
|
90
|
+
/**
|
|
91
|
+
* The custom fields registry
|
|
92
|
+
*
|
|
93
|
+
* It returns the custom fields interface
|
|
94
|
+
*/
|
|
95
|
+
readonly customFields: CustomFields;
|
|
96
|
+
|
|
68
97
|
/**
|
|
69
98
|
* Getter for the Strapi policies container
|
|
70
99
|
*
|
|
@@ -195,7 +224,7 @@ export interface Strapi {
|
|
|
195
224
|
/**
|
|
196
225
|
* Restart the server and reload all the configuration.
|
|
197
226
|
* It re-runs all the lifecycles phases.
|
|
198
|
-
*
|
|
227
|
+
*
|
|
199
228
|
* @example
|
|
200
229
|
* ``` ts
|
|
201
230
|
* setImmediate(() => strapi.reload());
|
|
@@ -223,13 +252,13 @@ export interface Strapi {
|
|
|
223
252
|
/**
|
|
224
253
|
* Opent he administration panel in a browser if the option is enabled.
|
|
225
254
|
* You can disable it using the admin.autoOpen configuration variable.
|
|
226
|
-
*
|
|
255
|
+
*
|
|
227
256
|
* Note: It only works in development envs.
|
|
228
257
|
*/
|
|
229
258
|
openAdmin(options: { isInitialized: boolean }): Promise<void>;
|
|
230
259
|
|
|
231
260
|
/**
|
|
232
|
-
* Load the admin panel server logic into the server code and initialize its configuration.
|
|
261
|
+
* Load the admin panel server logic into the server code and initialize its configuration.
|
|
233
262
|
*/
|
|
234
263
|
loadAdmin(): Promise<void>;
|
|
235
264
|
|
|
@@ -288,7 +317,7 @@ export interface Strapi {
|
|
|
288
317
|
container: any;
|
|
289
318
|
|
|
290
319
|
/**
|
|
291
|
-
* References to all the directories handled by Strapi
|
|
320
|
+
* References to all the directories handled by Strapi
|
|
292
321
|
*/
|
|
293
322
|
dirs: StrapiDirectories;
|
|
294
323
|
|
|
@@ -323,7 +352,7 @@ export interface Strapi {
|
|
|
323
352
|
startupLogger: any;
|
|
324
353
|
|
|
325
354
|
/**
|
|
326
|
-
* Strapi logger used to send errors, warning or information messages
|
|
355
|
+
* Strapi logger used to send errors, warning or information messages
|
|
327
356
|
*/
|
|
328
357
|
log: any;
|
|
329
358
|
|
|
@@ -356,7 +385,7 @@ export interface Strapi {
|
|
|
356
385
|
/**
|
|
357
386
|
* Entity Service instance
|
|
358
387
|
*/
|
|
359
|
-
entityService: any;
|
|
388
|
+
entityService: any;
|
|
360
389
|
}
|
|
361
390
|
|
|
362
391
|
export interface Lifecycles {
|
|
@@ -389,4 +418,4 @@ export interface StrapiDirectories {
|
|
|
389
418
|
middlewares: string;
|
|
390
419
|
config: string;
|
|
391
420
|
};
|
|
392
|
-
}
|
|
421
|
+
}
|
package/lib/utils/addSlash.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
module.exports = (path) => {
|
|
4
|
-
|
|
5
|
-
if (
|
|
4
|
+
let tmpPath = path;
|
|
5
|
+
if (typeof tmpPath !== 'string') throw new Error('admin.url must be a string');
|
|
6
|
+
if (tmpPath === '' || tmpPath === '/') return '/';
|
|
6
7
|
|
|
7
|
-
if (
|
|
8
|
-
if (
|
|
9
|
-
return
|
|
8
|
+
if (tmpPath[0] !== '/') tmpPath = `/${tmpPath}`;
|
|
9
|
+
if (tmpPath[tmpPath.length - 1] !== '/') tmpPath += '/';
|
|
10
|
+
return tmpPath;
|
|
10
11
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const convertCustomFieldType = strapi => {
|
|
3
|
+
const convertCustomFieldType = (strapi) => {
|
|
4
4
|
const allContentTypeSchemaAttributes = Object.values(strapi.contentTypes).map(
|
|
5
|
-
schema => schema.attributes
|
|
5
|
+
(schema) => schema.attributes
|
|
6
6
|
);
|
|
7
7
|
const allComponentSchemaAttributes = Object.values(strapi.components).map(
|
|
8
|
-
schema => schema.attributes
|
|
8
|
+
(schema) => schema.attributes
|
|
9
9
|
);
|
|
10
10
|
const allSchemasAttributes = [...allContentTypeSchemaAttributes, ...allComponentSchemaAttributes];
|
|
11
11
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/strapi",
|
|
3
|
-
"version": "4.4.0-
|
|
3
|
+
"version": "4.4.0-beta.3",
|
|
4
4
|
"description": "An open source headless CMS solution to create and manage your own API. It provides a powerful dashboard and features to make your life easier. Databases supported: MySQL, MariaDB, PostgreSQL, SQLite",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"strapi",
|
|
@@ -80,17 +80,17 @@
|
|
|
80
80
|
"dependencies": {
|
|
81
81
|
"@koa/cors": "3.4.1",
|
|
82
82
|
"@koa/router": "10.1.1",
|
|
83
|
-
"@strapi/admin": "4.4.0-
|
|
84
|
-
"@strapi/database": "4.4.0-
|
|
85
|
-
"@strapi/generate-new": "4.4.0-
|
|
86
|
-
"@strapi/generators": "4.4.0-
|
|
87
|
-
"@strapi/logger": "4.4.0-
|
|
88
|
-
"@strapi/plugin-content-manager": "4.4.0-
|
|
89
|
-
"@strapi/plugin-content-type-builder": "4.4.0-
|
|
90
|
-
"@strapi/plugin-email": "4.4.0-
|
|
91
|
-
"@strapi/plugin-upload": "4.4.0-
|
|
92
|
-
"@strapi/typescript-utils": "4.4.0-
|
|
93
|
-
"@strapi/utils": "4.4.0-
|
|
83
|
+
"@strapi/admin": "4.4.0-beta.3",
|
|
84
|
+
"@strapi/database": "4.4.0-beta.3",
|
|
85
|
+
"@strapi/generate-new": "4.4.0-beta.3",
|
|
86
|
+
"@strapi/generators": "4.4.0-beta.3",
|
|
87
|
+
"@strapi/logger": "4.4.0-beta.3",
|
|
88
|
+
"@strapi/plugin-content-manager": "4.4.0-beta.3",
|
|
89
|
+
"@strapi/plugin-content-type-builder": "4.4.0-beta.3",
|
|
90
|
+
"@strapi/plugin-email": "4.4.0-beta.3",
|
|
91
|
+
"@strapi/plugin-upload": "4.4.0-beta.3",
|
|
92
|
+
"@strapi/typescript-utils": "4.4.0-beta.3",
|
|
93
|
+
"@strapi/utils": "4.4.0-beta.3",
|
|
94
94
|
"bcryptjs": "2.4.3",
|
|
95
95
|
"boxen": "5.1.2",
|
|
96
96
|
"chalk": "4.1.2",
|
|
@@ -136,8 +136,8 @@
|
|
|
136
136
|
"typescript": "4.6.2"
|
|
137
137
|
},
|
|
138
138
|
"engines": {
|
|
139
|
-
"node": ">=14.19.1 <=
|
|
139
|
+
"node": ">=14.19.1 <=18.x.x",
|
|
140
140
|
"npm": ">=6.0.0"
|
|
141
141
|
},
|
|
142
|
-
"gitHead": "
|
|
142
|
+
"gitHead": "baad89e67844d972ef53a6f1b0839a361bf968c0"
|
|
143
143
|
}
|