@strapi/strapi 4.5.1 → 4.5.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.
@@ -54,7 +54,7 @@ const createContentType = (uid, definition) => {
54
54
  });
55
55
  } else {
56
56
  throw new Error(
57
- `Incorrect Content Type UID "${uid}". The UID should start with api::, plugin:: or strapi::.`
57
+ `Incorrect Content Type UID "${uid}". The UID should start with api::, plugin:: or admin::.`
58
58
  );
59
59
  }
60
60
 
@@ -134,17 +134,20 @@ const createDefaultImplementation = ({ strapi, db, eventHub, entityValidator })
134
134
  // TODO: wrap into transaction
135
135
  const componentData = await createComponents(uid, validData);
136
136
 
137
+ const entityData = creationPipeline(
138
+ Object.assign(omitComponentData(model, validData), componentData),
139
+ {
140
+ contentType: model,
141
+ }
142
+ );
137
143
  let entity = await db.query(uid).create({
138
144
  ...query,
139
- data: creationPipeline(Object.assign(omitComponentData(model, validData), componentData), {
140
- contentType: model,
141
- }),
145
+ data: entityData,
142
146
  });
143
147
 
144
148
  // TODO: upload the files then set the links in the entity like with compo to avoid making too many queries
145
- // FIXME: upload in components
146
149
  if (files && Object.keys(files).length > 0) {
147
- await this.uploadFiles(uid, entity, files);
150
+ await this.uploadFiles(uid, Object.assign(entityData, entity), files);
148
151
  entity = await this.findOne(uid, entity.id, wrappedParams);
149
152
  }
150
153
 
@@ -180,19 +183,22 @@ const createDefaultImplementation = ({ strapi, db, eventHub, entityValidator })
180
183
 
181
184
  // TODO: wrap in transaction
182
185
  const componentData = await updateComponents(uid, entityToUpdate, validData);
186
+ const entityData = updatePipeline(
187
+ Object.assign(omitComponentData(model, validData), componentData),
188
+ {
189
+ contentType: model,
190
+ }
191
+ );
183
192
 
184
193
  let entity = await db.query(uid).update({
185
194
  ...query,
186
195
  where: { id: entityId },
187
- data: updatePipeline(Object.assign(omitComponentData(model, validData), componentData), {
188
- contentType: model,
189
- }),
196
+ data: entityData,
190
197
  });
191
198
 
192
199
  // TODO: upload the files then set the links in the entity like with compo to avoid making too many queries
193
- // FIXME: upload in components
194
200
  if (files && Object.keys(files).length > 0) {
195
- await this.uploadFiles(uid, entity, files);
201
+ await this.uploadFiles(uid, Object.assign(entityData, entity), files);
196
202
  entity = await this.findOne(uid, entity.id, wrappedParams);
197
203
  }
198
204
 
@@ -5,8 +5,8 @@
5
5
 
6
6
  'use strict';
7
7
 
8
- const { uniqBy, castArray, isNil } = require('lodash');
9
- const { has, assoc, prop, isObject, isEmpty, merge } = require('lodash/fp');
8
+ const { uniqBy, castArray, isNil, isArray, mergeWith } = require('lodash');
9
+ const { has, assoc, prop, isObject, isEmpty } = require('lodash/fp');
10
10
  const strapiUtils = require('@strapi/utils');
11
11
  const validators = require('./validators');
12
12
 
@@ -247,9 +247,14 @@ const createValidateEntity =
247
247
  * @returns {Object}
248
248
  */
249
249
  const buildRelationsStore = ({ uid, data }) => {
250
+ if (!uid) {
251
+ throw new ValidationError(`Cannot build relations store: "uid" is undefined`);
252
+ }
253
+
250
254
  if (isEmpty(data)) {
251
255
  return {};
252
256
  }
257
+
253
258
  const currentModel = strapi.getModel(uid);
254
259
 
255
260
  return Object.keys(currentModel.attributes).reduce((result, attributeName) => {
@@ -290,12 +295,17 @@ const buildRelationsStore = ({ uid, data }) => {
290
295
  case 'component': {
291
296
  return castArray(value).reduce(
292
297
  (relationsStore, componentValue) =>
293
- merge(
298
+ mergeWith(
294
299
  relationsStore,
295
300
  buildRelationsStore({
296
301
  uid: attribute.component,
297
302
  data: componentValue,
298
- })
303
+ }),
304
+ (objValue, srcValue) => {
305
+ if (isArray(objValue)) {
306
+ return objValue.concat(srcValue);
307
+ }
308
+ }
299
309
  ),
300
310
  result
301
311
  );
@@ -303,12 +313,17 @@ const buildRelationsStore = ({ uid, data }) => {
303
313
  case 'dynamiczone': {
304
314
  return value.reduce(
305
315
  (relationsStore, dzValue) =>
306
- merge(
316
+ mergeWith(
307
317
  relationsStore,
308
318
  buildRelationsStore({
309
319
  uid: dzValue.__component,
310
320
  data: dzValue,
311
- })
321
+ }),
322
+ (objValue, srcValue) => {
323
+ if (isArray(objValue)) {
324
+ return objValue.concat(srcValue);
325
+ }
326
+ }
312
327
  ),
313
328
  result
314
329
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strapi/strapi",
3
- "version": "4.5.1",
3
+ "version": "4.5.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,18 +80,18 @@
80
80
  "dependencies": {
81
81
  "@koa/cors": "3.4.3",
82
82
  "@koa/router": "10.1.1",
83
- "@strapi/admin": "4.5.1",
84
- "@strapi/database": "4.5.1",
85
- "@strapi/generate-new": "4.5.1",
86
- "@strapi/generators": "4.5.1",
87
- "@strapi/logger": "4.5.1",
88
- "@strapi/permissions": "4.5.1",
89
- "@strapi/plugin-content-manager": "4.5.1",
90
- "@strapi/plugin-content-type-builder": "4.5.1",
91
- "@strapi/plugin-email": "4.5.1",
92
- "@strapi/plugin-upload": "4.5.1",
93
- "@strapi/typescript-utils": "4.5.1",
94
- "@strapi/utils": "4.5.1",
83
+ "@strapi/admin": "4.5.3",
84
+ "@strapi/database": "4.5.3",
85
+ "@strapi/generate-new": "4.5.3",
86
+ "@strapi/generators": "4.5.3",
87
+ "@strapi/logger": "4.5.3",
88
+ "@strapi/permissions": "4.5.3",
89
+ "@strapi/plugin-content-manager": "4.5.3",
90
+ "@strapi/plugin-content-type-builder": "4.5.3",
91
+ "@strapi/plugin-email": "4.5.3",
92
+ "@strapi/plugin-upload": "4.5.3",
93
+ "@strapi/typescript-utils": "4.5.3",
94
+ "@strapi/utils": "4.5.3",
95
95
  "bcryptjs": "2.4.3",
96
96
  "boxen": "5.1.2",
97
97
  "chalk": "4.1.2",
@@ -128,7 +128,7 @@
128
128
  "package-json": "7.0.0",
129
129
  "qs": "6.10.1",
130
130
  "resolve-cwd": "3.0.0",
131
- "semver": "7.3.7",
131
+ "semver": "7.3.8",
132
132
  "statuses": "2.0.1",
133
133
  "uuid": "^8.3.2"
134
134
  },
@@ -140,5 +140,5 @@
140
140
  "node": ">=14.19.1 <=18.x.x",
141
141
  "npm": ">=6.0.0"
142
142
  },
143
- "gitHead": "8c20ea2b5c5a115b78454086ea270dcd59b06004"
143
+ "gitHead": "5453885f7aa329f98d047a6030a8e98ba3cbdb41"
144
144
  }