@firecms/core 3.0.0-canary.244 → 3.0.0-canary.245

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/dist/index.es.js CHANGED
@@ -251,31 +251,36 @@ function isObject(item) {
251
251
  return item && typeof item === "object" && !Array.isArray(item);
252
252
  }
253
253
  function mergeDeep(target, source, ignoreUndefined = false) {
254
- const targetIsObject = isObject(target);
255
- const output = targetIsObject ? {
254
+ if (!isObject(target)) {
255
+ return target;
256
+ }
257
+ const output = {
256
258
  ...target
257
- } : target;
258
- if (targetIsObject && isObject(source)) {
259
- Object.keys(source).forEach((key) => {
260
- const sourceElement = source[key];
261
- if (ignoreUndefined && sourceElement === void 0) {
262
- return;
259
+ };
260
+ if (!isObject(source)) {
261
+ return output;
262
+ }
263
+ for (const key in source) {
264
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
265
+ const sourceValue = source[key];
266
+ const outputValue = output[key];
267
+ if (ignoreUndefined && sourceValue === void 0) {
268
+ continue;
263
269
  }
264
- if (sourceElement instanceof Date) {
265
- Object.assign(output, {
266
- [key]: new Date(sourceElement.getTime())
267
- });
268
- } else if (isObject(sourceElement)) {
269
- if (!(key in target)) Object.assign(output, {
270
- [key]: sourceElement
271
- });
272
- else output[key] = mergeDeep(target[key], sourceElement);
270
+ if (sourceValue instanceof Date) {
271
+ output[key] = new Date(sourceValue.getTime());
272
+ } else if (Array.isArray(sourceValue)) {
273
+ output[key] = [...sourceValue];
274
+ } else if (isObject(sourceValue)) {
275
+ if (isObject(outputValue)) {
276
+ output[key] = mergeDeep(outputValue, sourceValue, ignoreUndefined);
277
+ } else {
278
+ output[key] = sourceValue;
279
+ }
273
280
  } else {
274
- Object.assign(output, {
275
- [key]: sourceElement
276
- });
281
+ output[key] = sourceValue;
277
282
  }
278
- });
283
+ }
279
284
  }
280
285
  return output;
281
286
  }
@@ -4406,11 +4411,6 @@ async function saveEntityWithCallbacks({
4406
4411
  } else {
4407
4412
  updatedValues = values;
4408
4413
  }
4409
- console.debug("Saving entity", {
4410
- entityId,
4411
- updatedValues,
4412
- collection
4413
- });
4414
4414
  return dataSource.saveEntity({
4415
4415
  collection,
4416
4416
  path: resolvedPath,
@@ -4445,7 +4445,6 @@ async function saveEntityWithCallbacks({
4445
4445
  }
4446
4446
  if (onSaveSuccess) onSaveSuccess(entity);
4447
4447
  }).catch((e) => {
4448
- console.error("!!!", e);
4449
4448
  if (callbacks?.onSaveFailure) {
4450
4449
  const resolvedCollection = resolveCollection({
4451
4450
  collection,