content-serialization 1.0.0 → 2.0.0

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.
@@ -156,6 +156,8 @@ function recursiveSanitize(data, attributes, componentSchemas) {
156
156
  if (compSchema) {
157
157
  currentAttributes = compSchema.attributes;
158
158
  sanitized.__component = data.__component;
159
+ } else {
160
+ strapi.log.warn(`[Content Serialization] Component schema not found for: ${data.__component}`);
159
161
  }
160
162
  }
161
163
  keys.forEach((key) => {
@@ -164,19 +166,25 @@ function recursiveSanitize(data, attributes, componentSchemas) {
164
166
  const value = data[key];
165
167
  const attr = currentAttributes ? currentAttributes[key] : null;
166
168
  if (!attr) {
169
+ if (value && typeof value === "object") {
170
+ strapi.log.warn(`[Content Serialization] Attribute not found for key: ${key}. Keeping value as-is (potential error source).`);
171
+ }
167
172
  sanitized[key] = value;
168
173
  return;
169
174
  }
170
175
  if (attr.type === "relation" || attr.type === "media") {
171
176
  if (Array.isArray(value)) {
172
- sanitized[key] = value.map((v) => v?.documentId || v?.id).filter((v) => v);
177
+ sanitized[key] = value.map((v) => v?.id || v?.documentId).filter((v) => v);
173
178
  } else if (value && typeof value === "object") {
174
- sanitized[key] = value.documentId || value.id;
179
+ sanitized[key] = value.id || value.documentId;
175
180
  } else {
176
181
  sanitized[key] = value;
177
182
  }
178
183
  } else if (attr.type === "component") {
179
184
  const compSchema = componentSchemas[attr.component];
185
+ if (!compSchema) {
186
+ strapi.log.warn(`[Content Serialization] Schema not found for component attribute: ${key} (uid: ${attr.component})`);
187
+ }
180
188
  const compAttributes = compSchema ? compSchema.attributes : {};
181
189
  sanitized[key] = recursiveSanitize(value, compAttributes, componentSchemas);
182
190
  } else if (attr.type === "dynamiczone") {
@@ -150,6 +150,8 @@ function recursiveSanitize(data, attributes, componentSchemas) {
150
150
  if (compSchema) {
151
151
  currentAttributes = compSchema.attributes;
152
152
  sanitized.__component = data.__component;
153
+ } else {
154
+ strapi.log.warn(`[Content Serialization] Component schema not found for: ${data.__component}`);
153
155
  }
154
156
  }
155
157
  keys.forEach((key) => {
@@ -158,19 +160,25 @@ function recursiveSanitize(data, attributes, componentSchemas) {
158
160
  const value = data[key];
159
161
  const attr = currentAttributes ? currentAttributes[key] : null;
160
162
  if (!attr) {
163
+ if (value && typeof value === "object") {
164
+ strapi.log.warn(`[Content Serialization] Attribute not found for key: ${key}. Keeping value as-is (potential error source).`);
165
+ }
161
166
  sanitized[key] = value;
162
167
  return;
163
168
  }
164
169
  if (attr.type === "relation" || attr.type === "media") {
165
170
  if (Array.isArray(value)) {
166
- sanitized[key] = value.map((v) => v?.documentId || v?.id).filter((v) => v);
171
+ sanitized[key] = value.map((v) => v?.id || v?.documentId).filter((v) => v);
167
172
  } else if (value && typeof value === "object") {
168
- sanitized[key] = value.documentId || value.id;
173
+ sanitized[key] = value.id || value.documentId;
169
174
  } else {
170
175
  sanitized[key] = value;
171
176
  }
172
177
  } else if (attr.type === "component") {
173
178
  const compSchema = componentSchemas[attr.component];
179
+ if (!compSchema) {
180
+ strapi.log.warn(`[Content Serialization] Schema not found for component attribute: ${key} (uid: ${attr.component})`);
181
+ }
174
182
  const compAttributes = compSchema ? compSchema.attributes : {};
175
183
  sanitized[key] = recursiveSanitize(value, compAttributes, componentSchemas);
176
184
  } else if (attr.type === "dynamiczone") {
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.0.0",
2
+ "version": "2.0.0",
3
3
  "keywords": [],
4
4
  "type": "commonjs",
5
5
  "exports": {