@payloadcms/plugin-import-export 4.0.0-internal.38b7f1d → 4.0.0-internal.3b50481
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/components/CollectionField/index.d.ts +3 -2
- package/dist/components/CollectionField/index.d.ts.map +1 -1
- package/dist/components/CollectionField/index.js.map +1 -1
- package/dist/components/ExportListMenuItem/index.d.ts.map +1 -1
- package/dist/components/ExportListMenuItem/index.js +14 -12
- package/dist/components/ExportListMenuItem/index.js.map +1 -1
- package/dist/components/ExportPreview/index.css +52 -0
- package/dist/components/ExportPreview/index.d.ts +1 -1
- package/dist/components/ExportPreview/index.d.ts.map +1 -1
- package/dist/components/ExportPreview/index.js +12 -2
- package/dist/components/ExportPreview/index.js.map +1 -1
- package/dist/components/FieldsToExport/index.d.ts +3 -2
- package/dist/components/FieldsToExport/index.d.ts.map +1 -1
- package/dist/components/FieldsToExport/index.js +18 -15
- package/dist/components/FieldsToExport/index.js.map +1 -1
- package/dist/components/FieldsToExport/reduceFields.d.ts +6 -0
- package/dist/components/FieldsToExport/reduceFields.d.ts.map +1 -1
- package/dist/components/FieldsToExport/reduceFields.js +4 -0
- package/dist/components/FieldsToExport/reduceFields.js.map +1 -1
- package/dist/components/FormatField/index.d.ts +3 -2
- package/dist/components/FormatField/index.d.ts.map +1 -1
- package/dist/components/FormatField/index.js +6 -3
- package/dist/components/FormatField/index.js.map +1 -1
- package/dist/components/ImportListMenuItem/index.d.ts.map +1 -1
- package/dist/components/ImportListMenuItem/index.js +14 -12
- package/dist/components/ImportListMenuItem/index.js.map +1 -1
- package/dist/components/ImportPreview/index.css +45 -0
- package/dist/components/ImportPreview/index.d.ts +1 -1
- package/dist/components/ImportPreview/index.d.ts.map +1 -1
- package/dist/components/ImportPreview/index.js +44 -11
- package/dist/components/ImportPreview/index.js.map +1 -1
- package/dist/components/LimitField/index.d.ts +3 -2
- package/dist/components/LimitField/index.d.ts.map +1 -1
- package/dist/components/LimitField/index.js.map +1 -1
- package/dist/components/LocaleField/index.d.ts +3 -2
- package/dist/components/LocaleField/index.d.ts.map +1 -1
- package/dist/components/LocaleField/index.js.map +1 -1
- package/dist/components/Page/index.d.ts +4 -3
- package/dist/components/Page/index.d.ts.map +1 -1
- package/dist/components/Page/index.js +1 -1
- package/dist/components/Page/index.js.map +1 -1
- package/dist/components/RelationshipCell/getRelationshipGroupKey.d.ts +7 -0
- package/dist/components/RelationshipCell/getRelationshipGroupKey.d.ts.map +1 -0
- package/dist/components/RelationshipCell/getRelationshipGroupKey.js +3 -0
- package/dist/components/RelationshipCell/getRelationshipGroupKey.js.map +1 -0
- package/dist/components/RelationshipCell/getRelationshipGroups.d.ts +43 -0
- package/dist/components/RelationshipCell/getRelationshipGroups.d.ts.map +1 -0
- package/dist/components/RelationshipCell/getRelationshipGroups.js +109 -0
- package/dist/components/RelationshipCell/getRelationshipGroups.js.map +1 -0
- package/dist/components/RelationshipCell/index.css +30 -0
- package/dist/components/RelationshipCell/index.d.ts +15 -0
- package/dist/components/RelationshipCell/index.d.ts.map +1 -0
- package/dist/components/RelationshipCell/index.js +57 -0
- package/dist/components/RelationshipCell/index.js.map +1 -0
- package/dist/components/SortBy/index.css +9 -0
- package/dist/components/SortBy/index.d.ts +4 -3
- package/dist/components/SortBy/index.d.ts.map +1 -1
- package/dist/components/SortBy/index.js +1 -2
- package/dist/components/SortBy/index.js.map +1 -1
- package/dist/components/SortOrder/index.css +9 -0
- package/dist/components/SortOrder/index.d.ts +4 -3
- package/dist/components/SortOrder/index.d.ts.map +1 -1
- package/dist/components/SortOrder/index.js +1 -2
- package/dist/components/SortOrder/index.js.map +1 -1
- package/dist/export/batchProcessor.d.ts +4 -3
- package/dist/export/batchProcessor.d.ts.map +1 -1
- package/dist/export/batchProcessor.js +6 -2
- package/dist/export/batchProcessor.js.map +1 -1
- package/dist/export/createExport.d.ts +4 -2
- package/dist/export/createExport.d.ts.map +1 -1
- package/dist/export/createExport.js +7 -2
- package/dist/export/createExport.js.map +1 -1
- package/dist/export/getCreateExportCollectionTask.d.ts.map +1 -1
- package/dist/export/getCreateExportCollectionTask.js +11 -0
- package/dist/export/getCreateExportCollectionTask.js.map +1 -1
- package/dist/export/getExportCollection.d.ts.map +1 -1
- package/dist/export/getExportCollection.js +9 -4
- package/dist/export/getExportCollection.js.map +1 -1
- package/dist/export/handleDownload.d.ts.map +1 -1
- package/dist/export/handleDownload.js +7 -3
- package/dist/export/handleDownload.js.map +1 -1
- package/dist/export/handlePreview.d.ts.map +1 -1
- package/dist/export/handlePreview.js +25 -6
- package/dist/export/handlePreview.js.map +1 -1
- package/dist/exports/types.d.ts +1 -1
- package/dist/exports/types.d.ts.map +1 -1
- package/dist/exports/types.js.map +1 -1
- package/dist/import/batchProcessor.d.ts +4 -3
- package/dist/import/batchProcessor.d.ts.map +1 -1
- package/dist/import/batchProcessor.js +15 -8
- package/dist/import/batchProcessor.js.map +1 -1
- package/dist/import/createImport.d.ts +3 -2
- package/dist/import/createImport.d.ts.map +1 -1
- package/dist/import/createImport.js +9 -2
- package/dist/import/createImport.js.map +1 -1
- package/dist/import/getCreateImportCollectionTask.d.ts.map +1 -1
- package/dist/import/getCreateImportCollectionTask.js +5 -2
- package/dist/import/getCreateImportCollectionTask.js.map +1 -1
- package/dist/import/getImportCollection.d.ts.map +1 -1
- package/dist/import/getImportCollection.js +6 -4
- package/dist/import/getImportCollection.js.map +1 -1
- package/dist/import/handlePreview.d.ts.map +1 -1
- package/dist/import/handlePreview.js +5 -1
- package/dist/import/handlePreview.js.map +1 -1
- package/dist/index.d.ts +2 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -8
- package/dist/index.js.map +1 -1
- package/dist/translations/languages/en.d.ts.map +1 -1
- package/dist/types.d.ts +17 -33
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utilities/applyFieldHooks.d.ts +1 -2
- package/dist/utilities/applyFieldHooks.d.ts.map +1 -1
- package/dist/utilities/applyFieldHooks.js +2 -3
- package/dist/utilities/applyFieldHooks.js.map +1 -1
- package/dist/utilities/flattenObject.d.ts.map +1 -1
- package/dist/utilities/flattenObject.js +3 -13
- package/dist/utilities/flattenObject.js.map +1 -1
- package/dist/utilities/flattenedFields.d.ts.map +1 -1
- package/dist/utilities/flattenedFields.js +3 -0
- package/dist/utilities/flattenedFields.js.map +1 -1
- package/dist/utilities/getExportFieldFunctions.js +64 -35
- package/dist/utilities/getExportFieldFunctions.js.map +1 -1
- package/dist/utilities/getFileFromDoc.js +3 -3
- package/dist/utilities/getFileFromDoc.js.map +1 -1
- package/dist/utilities/getImportFieldFunctions.js +0 -8
- package/dist/utilities/getImportFieldFunctions.js.map +1 -1
- package/dist/utilities/getSchemaColumns.d.ts +1 -1
- package/dist/utilities/getSchemaColumns.js +2 -2
- package/dist/utilities/getSchemaColumns.js.map +1 -1
- package/dist/utilities/getSelect.d.ts.map +1 -1
- package/dist/utilities/getSelect.js +11 -3
- package/dist/utilities/getSelect.js.map +1 -1
- package/dist/utilities/getSubmittedFormValues.d.ts +12 -0
- package/dist/utilities/getSubmittedFormValues.d.ts.map +1 -0
- package/dist/utilities/getSubmittedFormValues.js +24 -0
- package/dist/utilities/getSubmittedFormValues.js.map +1 -0
- package/dist/utilities/processRichTextField.d.ts.map +1 -1
- package/dist/utilities/processRichTextField.js +7 -0
- package/dist/utilities/processRichTextField.js.map +1 -1
- package/dist/utilities/setNestedValue.d.ts +2 -1
- package/dist/utilities/setNestedValue.d.ts.map +1 -1
- package/dist/utilities/setNestedValue.js +65 -34
- package/dist/utilities/setNestedValue.js.map +1 -1
- package/dist/utilities/sortHelpers.d.ts +1 -1
- package/dist/utilities/unflattenObject.d.ts.map +1 -1
- package/dist/utilities/unflattenObject.js +29 -18
- package/dist/utilities/unflattenObject.js.map +1 -1
- package/dist/utilities/unflattenPostProcess.d.ts.map +1 -1
- package/dist/utilities/unflattenPostProcess.js +39 -13
- package/dist/utilities/unflattenPostProcess.js.map +1 -1
- package/license.md +1 -1
- package/package.json +10 -10
- package/dist/components/ExportPreview/index.scss +0 -48
- package/dist/components/FieldsToExport/index.scss +0 -0
- package/dist/components/FieldsToExport/reduceFields.spec.js +0 -239
- package/dist/components/FieldsToExport/reduceFields.spec.js.map +0 -1
- package/dist/components/ImportPreview/index.scss +0 -41
- package/dist/components/SortBy/index.scss +0 -3
- package/dist/components/SortOrder/index.scss +0 -3
- package/dist/utilities/applyFieldHooks.spec.js +0 -205
- package/dist/utilities/applyFieldHooks.spec.js.map +0 -1
- package/dist/utilities/buildDisabledFieldRegex.spec.js +0 -64
- package/dist/utilities/buildDisabledFieldRegex.spec.js.map +0 -1
- package/dist/utilities/fieldToRegex.spec.js +0 -151
- package/dist/utilities/fieldToRegex.spec.js.map +0 -1
- package/dist/utilities/filterToSelectedFields.spec.js +0 -204
- package/dist/utilities/filterToSelectedFields.spec.js.map +0 -1
- package/dist/utilities/flattenObject.spec.js +0 -158
- package/dist/utilities/flattenObject.spec.js.map +0 -1
- package/dist/utilities/getExportFieldFunctions.spec.js +0 -50
- package/dist/utilities/getExportFieldFunctions.spec.js.map +0 -1
- package/dist/utilities/getImportFieldFunctions.spec.js +0 -167
- package/dist/utilities/getImportFieldFunctions.spec.js.map +0 -1
- package/dist/utilities/getSchemaColumns.spec.js +0 -157
- package/dist/utilities/getSchemaColumns.spec.js.map +0 -1
- package/dist/utilities/legacyHookDispatch.spec.js +0 -227
- package/dist/utilities/legacyHookDispatch.spec.js.map +0 -1
- package/dist/utilities/parseCSV.spec.js +0 -195
- package/dist/utilities/parseCSV.spec.js.map +0 -1
- package/dist/utilities/siblingDoc.spec.js +0 -278
- package/dist/utilities/siblingDoc.spec.js.map +0 -1
- package/dist/utilities/unflattenObject.spec.js +0 -713
- package/dist/utilities/unflattenObject.spec.js.map +0 -1
- /package/dist/components/Page/{index.scss → index.css} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/unflattenObject.ts"],"sourcesContent":["import type { FlattenedField, PayloadRequest } from 'payload'\n\nimport type { ImportFieldHookEntry } from '../types.js'\n\nimport { getNestedFlattenedFields } from './flattenedFields.js'\nimport { postProcessDocument } from './unflattenPostProcess.js'\n\ntype UnflattenArgs = {\n data: Record<string, unknown>\n fields: FlattenedField[]\n format?: 'csv' | 'json' | ({} & string)\n importFieldHooks?: Record<string, ImportFieldHookEntry>\n req: PayloadRequest\n}\n\nconst indexSegment = /^\\d+$/\n\nconst collectArrayLikeNames = (fields: FlattenedField[], into: Set<string>): void => {\n for (const field of fields) {\n if (!('name' in field) || !field.name) {\n continue\n }\n if (field.type === 'array' || field.type === 'blocks') {\n into.add(field.name)\n }\n const nested = getNestedFlattenedFields(field)\n if (nested) {\n collectArrayLikeNames(nested, into)\n }\n }\n}\n\n/**\n * Drops numeric array-index segments from a flat key so a runtime key like\n * `items_0_note` matches the static, index-free key a user hook is registered\n * under. A digit-only segment is only stripped when the segment immediately\n * before it names an array or blocks field, so a literal field name like\n * `2024` is preserved.\n */\nconst toLogicalKey = (flatKey: string, arrayLikeNames: Set<string>): string => {\n const segments = flatKey.split('_')\n return segments\n .filter((seg, i) => !indexSegment.test(seg) || !arrayLikeNames.has(segments[i - 1] ?? ''))\n .join('_')\n}\n\n/**\n * Converts flattened CSV data back into a nested document structure.\n *\n * The algorithm:\n * 1. Sorts keys to ensure array indices are processed in order\n * 2. For each flattened key (e.g., \"blocks_0_hero_title\"), splits by underscore into path segments\n * 3. Traverses/builds the nested structure, handling:\n * - Arrays (numeric segments like \"0\", \"1\")\n * - Blocks (blockType detection from slug patterns)\n * - Polymorphic relationships (_relationTo and _id suffix pairs)\n * - Regular nested objects\n * 4. Post-processes to handle localized fields, hasMany conversions, and relationship transforms\n */\nexport const unflattenObject = ({\n data,\n fields,\n format = 'csv',\n importFieldHooks = {},\n req,\n}: UnflattenArgs): Record<string, unknown> => {\n if (!data || typeof data !== 'object') {\n return {}\n }\n\n const result: Record<string, unknown> = {}\n\n const arrayLikeNames = new Set<string>()\n collectArrayLikeNames(fields, arrayLikeNames)\n\n // Sort keys to ensure array indices are processed in order\n const sortedKeys = Object.keys(data).sort((a, b) => {\n // Extract array indices from flattened keys (e.g., \"field_0_subfield\" -> \"0\")\n const aMatch = a.match(/_(\\d+)(?:_|$)/)\n const bMatch = b.match(/_(\\d+)(?:_|$)/)\n\n if (aMatch && bMatch && aMatch.index !== undefined && bMatch.index !== undefined) {\n const aBase = a.substring(0, aMatch.index)\n const bBase = b.substring(0, bMatch.index)\n\n if (aBase === bBase) {\n return (parseInt(aMatch?.[1] ?? '0', 10) || 0) - (parseInt(bMatch?.[1] ?? '0', 10) || 0)\n }\n }\n\n return a.localeCompare(b)\n })\n\n for (const flatKey of sortedKeys) {\n let value = data[flatKey]\n\n // Skip undefined values but keep null for required field validation\n if (value === undefined) {\n continue\n }\n\n // Preserve system fields with underscore prefix (like _status) without splitting\n if (flatKey === '_status') {\n result[flatKey] = value\n continue\n }\n\n // Check if this is a _relationTo key for a polymorphic relationship\n if (flatKey.endsWith('_relationTo')) {\n const baseKey = flatKey.replace(/_relationTo$/, '')\n const idKey = `${baseKey}_id`\n\n // Check if this is a polymorphic relationship field\n const isPolymorphic = fields.some(\n (field) =>\n field.name === baseKey &&\n field.type === 'relationship' &&\n 'relationTo' in field &&\n Array.isArray(field.relationTo),\n )\n\n if (isPolymorphic) {\n if (baseKey in result) {\n continue\n }\n\n // If the corresponding _id key is undefined, skip processing entirely\n // This prevents creating empty objects when we should preserve existing data\n if (!(idKey in data) || data[idKey] === undefined) {\n continue\n }\n }\n }\n\n // Check if this is a _id key for a polymorphic relationship where _relationTo is undefined\n if (flatKey.endsWith('_id')) {\n const baseKey = flatKey.replace(/_id$/, '')\n const relationToKey = `${baseKey}_relationTo`\n\n // Check if this is a polymorphic relationship field\n const isPolymorphic = fields.some(\n (field) =>\n field.name === baseKey &&\n field.type === 'relationship' &&\n 'relationTo' in field &&\n Array.isArray(field.relationTo),\n )\n\n if (isPolymorphic) {\n // If the corresponding _relationTo key is undefined, skip processing entirely\n // This prevents creating empty objects when we should preserve existing data\n if (!(relationToKey in data) || data[relationToKey] === undefined) {\n continue\n }\n }\n }\n\n const importHookEntry =\n importFieldHooks[flatKey] ?? importFieldHooks[toLogicalKey(flatKey, arrayLikeNames)]\n if (importHookEntry) {\n try {\n if (importHookEntry.type === 'beforeImport') {\n value = importHookEntry.fn({\n columnName: flatKey,\n data,\n format,\n siblingData: data,\n siblingDoc: data,\n value,\n })\n } else {\n value = importHookEntry.fn({\n columnName: flatKey,\n data,\n value,\n })\n }\n } catch (error) {\n req.payload.logger.error({\n err: error,\n msg: `[plugin-import-export] Field-level beforeImport hook for \"${flatKey}\" threw — falling back to original value`,\n })\n // Keep the original value so the row is not dropped — downstream\n // validation will surface any deeper issue per-row.\n }\n }\n\n // Example: \"blocks_0_content_text\" -> [\"blocks\", \"0\", \"content\", \"text\"]\n const pathSegments = flatKey.split('_')\n let currentObject: Record<string, unknown> = result\n\n for (let i = 0; i < pathSegments.length; i++) {\n const segment = pathSegments[i]\n if (!segment) {\n continue\n } // Skip empty segments\n\n const nextSegment = pathSegments[i + 1]\n const isLast = i === pathSegments.length - 1\n\n // Check if next segment is a numeric array index (e.g., \"0\", \"1\", \"2\")\n const isArrayIndex = nextSegment !== undefined && /^\\d+$/.test(nextSegment)\n\n if (isLast) {\n // Special handling for blockType suffix in blocks\n if (segment === 'blockType' && i >= 3) {\n // Pattern: blocks_0_hero_blockType -> set blockType on the block\n const blockFieldName = pathSegments[0] // 'blocks'\n const isBlockField = fields.some(\n (field) => field.name === blockFieldName && field.type === 'blocks',\n )\n\n if (isBlockField && pathSegments[1]?.match(/^\\d+$/)) {\n const parent = getParentObject(result, pathSegments.slice(0, 2))\n if (parent && typeof parent === 'object') {\n parent.blockType = value\n }\n continue\n }\n }\n\n // Special handling for relationship fields with _id suffix\n if (segment === 'id' && i > 0) {\n const parentKey = pathSegments[i - 1]\n const isPreviousSegmentArrayIndex = parentKey ? /^\\d+$/.test(parentKey) : false\n\n if (!isPreviousSegmentArrayIndex) {\n // Check if this is a relationship field\n const isRelationship = fields.some(\n (field) => field.name === parentKey && field.type === 'relationship',\n )\n\n if (isRelationship) {\n // Check if this is a polymorphic relationship field\n const field = fields.find((f) => f.name === parentKey && f.type === 'relationship')\n const isPolymorphic =\n field && 'relationTo' in field && Array.isArray(field.relationTo)\n\n if (isPolymorphic) {\n const relationToKey = pathSegments.slice(0, i).concat('relationTo').join('_')\n const relationToValue = data[relationToKey]\n\n const parent = getParentObject(result, pathSegments.slice(0, i - 1))\n if (parent && parentKey && typeof parent === 'object') {\n // Both fields must be defined to create/update the relationship\n // If either is undefined, skip the field entirely (preserve existing data)\n if (value !== undefined && relationToValue !== undefined) {\n // Check if both are explicitly null\n if (relationToValue === null && value === null) {\n // Only set to null if explicitly null (user typed \"null\" in CSV)\n parent[parentKey] = null\n } else if (relationToValue || value) {\n // At least one has a value, create the relationship\n parent[parentKey] = {\n relationTo: relationToValue,\n value, // This will be transformed to proper format in postProcess\n }\n }\n // If both are empty strings, don't set the field (handled by not meeting the above conditions)\n }\n // If either is undefined, don't set the field at all (preserve existing data)\n }\n continue\n } else if (!isPolymorphic) {\n const parent = getParentObject(result, pathSegments.slice(0, i - 1))\n if (parent && parentKey && typeof parent === 'object') {\n parent[parentKey] = value\n }\n continue\n }\n }\n }\n }\n\n // _relationTo suffix is handled when processing the _id field above\n if (segment === 'relationTo' && i > 0) {\n const parentKey = pathSegments[i - 1]\n if (parentKey && !parentKey.match(/^\\d+$/)) {\n const field = fields.find((f) => f.name === parentKey && f.type === 'relationship')\n const isPolymorphic = field && 'relationTo' in field && Array.isArray(field.relationTo)\n\n if (isPolymorphic) {\n // For polymorphic relationships, this is handled when processing the _id field\n // Skip it entirely\n continue\n }\n }\n }\n\n currentObject[segment] = value\n } else if (isArrayIndex && nextSegment !== undefined) {\n if (!currentObject[segment] || !Array.isArray(currentObject[segment])) {\n currentObject[segment] = []\n }\n\n const arrayIndex = parseInt(nextSegment)\n const arr = currentObject[segment] as unknown[]\n\n // Ensure array has sufficient length\n while (arr.length <= arrayIndex) {\n arr.push(null)\n }\n\n // Handle array of objects\n if (arr[arrayIndex] === null || arr[arrayIndex] === undefined) {\n arr[arrayIndex] = {}\n }\n\n // Handle blocks field with block slug pattern (e.g., blocks_0_hero_title)\n const isBlocksField = fields.some((f) => f.name === segment && f.type === 'blocks')\n if (isBlocksField && i + 3 < pathSegments.length) {\n const blockSlug = pathSegments[i + 2]\n const blockFieldName = pathSegments[i + 3]\n\n if (blockSlug && blockFieldName) {\n const blockObject = arr[arrayIndex] as Record<string, unknown>\n blockObject.blockType = blockSlug\n\n if (i + 3 === pathSegments.length - 1) {\n blockObject[blockFieldName] = value\n } else {\n if (!blockObject[blockFieldName] || typeof blockObject[blockFieldName] !== 'object') {\n blockObject[blockFieldName] = {}\n }\n currentObject = blockObject[blockFieldName] as Record<string, unknown>\n i = i + 3\n continue\n }\n break\n }\n }\n\n if (i + 2 === pathSegments.length - 1) {\n const lastSegment = pathSegments[pathSegments.length - 1]\n if (lastSegment && arr[arrayIndex] && typeof arr[arrayIndex] === 'object') {\n ;(arr[arrayIndex] as Record<string, unknown>)[lastSegment] = value\n }\n break\n } else if (i + 1 === pathSegments.length - 1) {\n // Direct array value (e.g., tags_0 = \"value\")\n arr[arrayIndex] = value\n break\n } else {\n currentObject = arr[arrayIndex] as Record<string, unknown>\n i++\n }\n } else {\n // Skip if already set to null (polymorphic relationship already processed)\n if (currentObject[segment] === null && isLast && segment === 'relationTo') {\n continue\n }\n\n if (\n !currentObject[segment] ||\n typeof currentObject[segment] !== 'object' ||\n Array.isArray(currentObject[segment])\n ) {\n currentObject[segment] = {}\n }\n\n // Handle polymorphic relationship arrays\n if (segment === 'relationTo' && i > 0 && pathSegments[i - 1]?.match(/^\\d+$/)) {\n currentObject[segment] = value\n } else if (\n typeof currentObject[segment] === 'object' &&\n !Array.isArray(currentObject[segment]) &&\n currentObject[segment] !== null\n ) {\n currentObject = currentObject[segment] as Record<string, unknown>\n }\n }\n }\n }\n\n try {\n // Post-process to handle special structures\n postProcessDocument(result, fields)\n } catch (err) {\n // Log but don't throw - return partially processed result\n\n req.payload.logger.error({\n err,\n msg: '[plugin-import-export] Error in postProcessDocument',\n })\n }\n\n return result\n}\n\nconst getParentObject = (\n obj: Record<string, unknown>,\n segments: string[],\n): Record<string, unknown> | undefined => {\n let current: Record<string, unknown> = obj\n\n for (let i = 0; i < segments.length; i++) {\n const segment = segments[i]\n const nextSegment = segments[i + 1]\n\n if (!segment) {\n continue\n }\n\n if (nextSegment && /^\\d+$/.test(nextSegment)) {\n const arrayIndex = parseInt(nextSegment)\n const arr = current[segment] as unknown[]\n\n if (Array.isArray(arr) && arr[arrayIndex]) {\n current = arr[arrayIndex] as Record<string, unknown>\n i++ // Skip the index\n } else {\n return undefined\n }\n } else {\n const next = current[segment]\n if (typeof next === 'object' && next !== null && !Array.isArray(next)) {\n current = next as Record<string, unknown>\n } else {\n return undefined\n }\n }\n }\n\n return current\n}\n"],"names":["getNestedFlattenedFields","postProcessDocument","indexSegment","collectArrayLikeNames","fields","into","field","name","type","add","nested","toLogicalKey","flatKey","arrayLikeNames","segments","split","filter","seg","i","test","has","join","unflattenObject","data","format","importFieldHooks","req","result","Set","sortedKeys","Object","keys","sort","a","b","aMatch","match","bMatch","index","undefined","aBase","substring","bBase","parseInt","localeCompare","value","endsWith","baseKey","replace","idKey","isPolymorphic","some","Array","isArray","relationTo","relationToKey","importHookEntry","fn","columnName","siblingData","siblingDoc","error","payload","logger","err","msg","pathSegments","currentObject","length","segment","nextSegment","isLast","isArrayIndex","blockFieldName","isBlockField","parent","getParentObject","slice","blockType","parentKey","isPreviousSegmentArrayIndex","isRelationship","find","f","concat","relationToValue","arrayIndex","arr","push","isBlocksField","blockSlug","blockObject","lastSegment","obj","current","next"],"mappings":"AAIA,SAASA,wBAAwB,QAAQ,uBAAsB;AAC/D,SAASC,mBAAmB,QAAQ,4BAA2B;AAU/D,MAAMC,eAAe;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AEA,OAAOtC;AACT,EAAC;AAED,MAAMiD,kBAAkB,CACtBiB,KACA/E;IAEA,IAAIgF,UAAmCD;IAEvC,IAAK,IAAI3E,IAAI,GAAGA,IAAIJ,SAASsD,MAAM,EAAElD,IAAK;QACxC,MAAMmD,UAAUvD,QAAQ,CAACI,EAAE;QAC3B,MAAMoD,cAAcxD,QAAQ,CAACI,IAAI,EAAE;QAEnC,IAAI,CAACmD,SAAS;YACZ;QACF;QAEA,IAAIC,eAAe,QAAQnD,IAAI,CAACmD,cAAc;YAC5C,MAAMgB,aAAa3C,SAAS2B;YAC5B,MAAMiB,MAAMO,OAAO,CAACzB,QAAQ;YAE5B,IAAIjB,MAAMC,OAAO,CAACkC,QAAQA,GAAG,CAACD,WAAW,EAAE;gBACzCQ,UAAUP,GAAG,CAACD,WAAW;gBACzBpE,KAAI,iBAAiB;YACvB,OAAO;gBACL,OAAOqB;YACT;QACF,OAAO;YACL,MAAMwD,OAAOD,OAAO,CAACzB,QAAQ;YAC7B,IAAI,OAAO0B,SAAS,YAAYA,SAAS,QAAQ,CAAC3C,MAAMC,OAAO,CAAC0C,OAAO;gBACrED,UAAUC;YACZ,OAAO;gBACL,OAAOxD;YACT;QACF;IACF;IAEA,OAAOuD;AACT"}
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/unflattenObject.ts"],"sourcesContent":["import type { FlattenedField, PayloadRequest } from 'payload'\n\nimport type { ImportFieldHookEntry } from '../types.js'\n\nimport { getBlockFlattenedFields, getNestedFlattenedFields } from './flattenedFields.js'\nimport { postProcessDocument } from './unflattenPostProcess.js'\n\ntype UnflattenArgs = {\n data: Record<string, unknown>\n fields: FlattenedField[]\n format?: 'csv' | 'json' | ({} & string)\n importFieldHooks?: Record<string, ImportFieldHookEntry>\n req: PayloadRequest\n}\n\nconst indexSegment = /^\\d+$/\n\nconst collectArrayLikeNames = (fields: FlattenedField[], into: Set<string>): void => {\n for (const field of fields) {\n if (!('name' in field) || !field.name) {\n continue\n }\n if (field.type === 'array' || field.type === 'blocks') {\n into.add(field.name)\n }\n if (field.type === 'blocks') {\n for (const block of (field as { blocks?: Array<{ flattenedFields?: FlattenedField[] }> })\n .blocks ?? []) {\n collectArrayLikeNames(getBlockFlattenedFields(block), into)\n }\n }\n const nested = getNestedFlattenedFields(field)\n if (nested) {\n collectArrayLikeNames(nested, into)\n }\n }\n}\n\n/**\n * Drops numeric array-index segments from a flat key so a runtime key like\n * `items_0_note` matches the static, index-free key a user hook is registered\n * under. A digit-only segment is only stripped when the segment immediately\n * before it names an array or blocks field, so a literal field name like\n * `2024` is preserved.\n */\nconst toLogicalKey = (flatKey: string, arrayLikeNames: Set<string>): string => {\n const segments = flatKey.split('_')\n return segments\n .filter((seg, i) => !indexSegment.test(seg) || !arrayLikeNames.has(segments[i - 1] ?? ''))\n .join('_')\n}\n\n/**\n * Converts flattened CSV data back into a nested document structure.\n *\n * The algorithm:\n * 1. Sorts keys to ensure array indices are processed in order\n * 2. For each flattened key (e.g., \"blocks_0_hero_title\"), splits by underscore into path segments\n * 3. Traverses/builds the nested structure, handling:\n * - Arrays (numeric segments like \"0\", \"1\")\n * - Blocks (blockType detection from slug patterns)\n * - Polymorphic relationships (_relationTo and _id suffix pairs)\n * - Regular nested objects\n * 4. Post-processes to handle localized fields, hasMany conversions, and relationship transforms\n */\nexport const unflattenObject = ({\n data,\n fields,\n format = 'csv',\n importFieldHooks = {},\n req,\n}: UnflattenArgs): Record<string, unknown> => {\n if (!data || typeof data !== 'object') {\n return {}\n }\n\n const result: Record<string, unknown> = {}\n\n const arrayLikeNames = new Set<string>()\n collectArrayLikeNames(fields, arrayLikeNames)\n\n // Sort keys to ensure array indices are processed in order\n const sortedKeys = Object.keys(data).sort((a, b) => {\n // Extract array indices from flattened keys (e.g., \"field_0_subfield\" -> \"0\")\n const aMatch = a.match(/_(\\d+)(?:_|$)/)\n const bMatch = b.match(/_(\\d+)(?:_|$)/)\n\n if (aMatch && bMatch && aMatch.index !== undefined && bMatch.index !== undefined) {\n const aBase = a.substring(0, aMatch.index)\n const bBase = b.substring(0, bMatch.index)\n\n if (aBase === bBase) {\n return (parseInt(aMatch?.[1] ?? '0', 10) || 0) - (parseInt(bMatch?.[1] ?? '0', 10) || 0)\n }\n }\n\n return a.localeCompare(b)\n })\n\n for (const flatKey of sortedKeys) {\n let value = data[flatKey]\n\n // Skip undefined values but keep null for required field validation\n if (value === undefined) {\n continue\n }\n\n // Preserve system fields with underscore prefix (like _status) without splitting\n if (flatKey === '_status') {\n result[flatKey] = value\n continue\n }\n\n // Check if this is a _relationTo key for a polymorphic relationship\n if (flatKey.endsWith('_relationTo')) {\n const baseKey = flatKey.replace(/_relationTo$/, '')\n const idKey = `${baseKey}_id`\n\n // Check if this is a polymorphic relationship field\n const isPolymorphic = fields.some(\n (field) =>\n field.name === baseKey &&\n field.type === 'relationship' &&\n 'relationTo' in field &&\n Array.isArray(field.relationTo),\n )\n\n if (isPolymorphic) {\n if (baseKey in result) {\n continue\n }\n\n // If the corresponding _id key is undefined, skip processing entirely\n // This prevents creating empty objects when we should preserve existing data\n if (!(idKey in data) || data[idKey] === undefined) {\n continue\n }\n }\n }\n\n // Check if this is a _id key for a polymorphic relationship where _relationTo is undefined\n if (flatKey.endsWith('_id')) {\n const baseKey = flatKey.replace(/_id$/, '')\n const relationToKey = `${baseKey}_relationTo`\n\n // Check if this is a polymorphic relationship field\n const isPolymorphic = fields.some(\n (field) =>\n field.name === baseKey &&\n field.type === 'relationship' &&\n 'relationTo' in field &&\n Array.isArray(field.relationTo),\n )\n\n if (isPolymorphic) {\n // If the corresponding _relationTo key is undefined, skip processing entirely\n // This prevents creating empty objects when we should preserve existing data\n if (!(relationToKey in data) || data[relationToKey] === undefined) {\n continue\n }\n }\n }\n\n const importHookEntry =\n importFieldHooks[flatKey] ?? importFieldHooks[toLogicalKey(flatKey, arrayLikeNames)]\n if (importHookEntry) {\n try {\n value = importHookEntry.fn({\n columnName: flatKey,\n data,\n format,\n siblingData: data,\n siblingDoc: data,\n value,\n })\n } catch (error) {\n req.payload.logger.error({\n err: error,\n msg: `[plugin-import-export] Field-level beforeImport hook for \"${flatKey}\" threw — falling back to original value`,\n })\n // Keep the original value so the row is not dropped — downstream\n // validation will surface any deeper issue per-row.\n }\n }\n\n // Example: \"blocks_0_content_text\" -> [\"blocks\", \"0\", \"content\", \"text\"]\n const pathSegments = flatKey.split('_')\n let currentObject: Record<string, unknown> = result\n\n for (let i = 0; i < pathSegments.length; i++) {\n const segment = pathSegments[i]\n if (!segment) {\n continue\n } // Skip empty segments\n\n const nextSegment = pathSegments[i + 1]\n const isLast = i === pathSegments.length - 1\n\n // Check if next segment is a numeric array index (e.g., \"0\", \"1\", \"2\")\n const isArrayIndex = nextSegment !== undefined && /^\\d+$/.test(nextSegment)\n\n if (isLast) {\n // Special handling for blockType suffix in blocks\n if (segment === 'blockType' && i >= 3) {\n // Pattern: blocks_0_hero_blockType -> set blockType on the block\n const blockFieldName = pathSegments[0] // 'blocks'\n const isBlockField = fields.some(\n (field) => field.name === blockFieldName && field.type === 'blocks',\n )\n\n if (isBlockField && pathSegments[1]?.match(/^\\d+$/)) {\n const parent = getParentObject(result, pathSegments.slice(0, 2))\n if (parent && typeof parent === 'object') {\n parent.blockType = value\n }\n continue\n }\n }\n\n // Special handling for relationship fields with _id suffix\n if (segment === 'id' && i > 0) {\n const parentKey = pathSegments[i - 1]\n const isPreviousSegmentArrayIndex = parentKey ? /^\\d+$/.test(parentKey) : false\n\n if (!isPreviousSegmentArrayIndex) {\n // Check if this is a relationship field\n const isRelationship = fields.some(\n (field) => field.name === parentKey && field.type === 'relationship',\n )\n\n if (isRelationship) {\n // Check if this is a polymorphic relationship field\n const field = fields.find((f) => f.name === parentKey && f.type === 'relationship')\n const isPolymorphic =\n field && 'relationTo' in field && Array.isArray(field.relationTo)\n\n if (isPolymorphic) {\n const relationToKey = pathSegments.slice(0, i).concat('relationTo').join('_')\n const relationToValue = data[relationToKey]\n\n const parent = getParentObject(result, pathSegments.slice(0, i - 1))\n if (parent && parentKey && typeof parent === 'object') {\n // Both fields must be defined to create/update the relationship\n // If either is undefined, skip the field entirely (preserve existing data)\n if (value !== undefined && relationToValue !== undefined) {\n // Check if both are explicitly null\n if (relationToValue === null && value === null) {\n // Only set to null if explicitly null (user typed \"null\" in CSV)\n parent[parentKey] = null\n } else if (relationToValue || value) {\n // At least one has a value, create the relationship\n parent[parentKey] = {\n relationTo: relationToValue,\n value, // This will be transformed to proper format in postProcess\n }\n }\n // If both are empty strings, don't set the field (handled by not meeting the above conditions)\n }\n // If either is undefined, don't set the field at all (preserve existing data)\n }\n continue\n } else if (!isPolymorphic) {\n const parent = getParentObject(result, pathSegments.slice(0, i - 1))\n if (parent && parentKey && typeof parent === 'object') {\n parent[parentKey] = value\n }\n continue\n }\n }\n }\n }\n\n // _relationTo suffix is handled when processing the _id field above\n if (segment === 'relationTo' && i > 0) {\n const parentKey = pathSegments[i - 1]\n if (parentKey && !parentKey.match(/^\\d+$/)) {\n const field = fields.find((f) => f.name === parentKey && f.type === 'relationship')\n const isPolymorphic = field && 'relationTo' in field && Array.isArray(field.relationTo)\n\n if (isPolymorphic) {\n // For polymorphic relationships, this is handled when processing the _id field\n // Skip it entirely\n continue\n }\n }\n }\n\n currentObject[segment] = value\n } else if (isArrayIndex && nextSegment !== undefined) {\n if (!currentObject[segment] || !Array.isArray(currentObject[segment])) {\n currentObject[segment] = []\n }\n\n const arrayIndex = parseInt(nextSegment)\n const arr = currentObject[segment] as unknown[]\n\n // Ensure array has sufficient length\n while (arr.length <= arrayIndex) {\n arr.push(null)\n }\n\n // Handle array of objects\n if (arr[arrayIndex] === null || arr[arrayIndex] === undefined) {\n arr[arrayIndex] = {}\n }\n\n // Handle blocks field with block slug pattern (e.g., blocks_0_hero_title)\n const isBlocksField = fields.some((f) => f.name === segment && f.type === 'blocks')\n if (isBlocksField && i + 3 < pathSegments.length) {\n const blockSlug = pathSegments[i + 2]\n const blockFieldName = pathSegments[i + 3]\n\n if (blockSlug && blockFieldName) {\n const blockObject = arr[arrayIndex] as Record<string, unknown>\n blockObject.blockType = blockSlug\n\n if (i + 3 === pathSegments.length - 1) {\n blockObject[blockFieldName] = value\n } else {\n if (!blockObject[blockFieldName] || typeof blockObject[blockFieldName] !== 'object') {\n const segmentAfterBlockField = pathSegments[i + 4]\n const blockFieldIsArray =\n segmentAfterBlockField !== undefined && indexSegment.test(segmentAfterBlockField)\n blockObject[blockFieldName] = blockFieldIsArray ? [] : {}\n }\n currentObject = blockObject[blockFieldName] as Record<string, unknown>\n i = i + 3\n continue\n }\n break\n }\n }\n\n if (i + 2 === pathSegments.length - 1) {\n const lastSegment = pathSegments[pathSegments.length - 1]\n if (lastSegment && arr[arrayIndex] && typeof arr[arrayIndex] === 'object') {\n ;(arr[arrayIndex] as Record<string, unknown>)[lastSegment] = value\n }\n break\n } else if (i + 1 === pathSegments.length - 1) {\n // Direct array value (e.g., tags_0 = \"value\")\n arr[arrayIndex] = value\n break\n } else {\n currentObject = arr[arrayIndex] as Record<string, unknown>\n i++\n }\n } else if (Array.isArray(currentObject) && indexSegment.test(segment)) {\n // currentObject is an array we arrived at via block field traversal — treat the\n // segment as a numeric index rather than a plain property name.\n const idx = parseInt(segment, 10)\n const arr = currentObject as unknown[]\n while (arr.length <= idx) {\n arr.push(null)\n }\n if (arr[idx] === null || arr[idx] === undefined) {\n arr[idx] = {}\n }\n currentObject = arr[idx] as Record<string, unknown>\n } else {\n // Skip if already set to null (polymorphic relationship already processed)\n if (currentObject[segment] === null && isLast && segment === 'relationTo') {\n continue\n }\n\n if (\n !currentObject[segment] ||\n typeof currentObject[segment] !== 'object' ||\n Array.isArray(currentObject[segment])\n ) {\n currentObject[segment] = {}\n }\n\n // Handle polymorphic relationship arrays\n if (segment === 'relationTo' && i > 0 && pathSegments[i - 1]?.match(/^\\d+$/)) {\n currentObject[segment] = value\n } else if (\n typeof currentObject[segment] === 'object' &&\n !Array.isArray(currentObject[segment]) &&\n currentObject[segment] !== null\n ) {\n currentObject = currentObject[segment] as Record<string, unknown>\n }\n }\n }\n }\n\n try {\n // Post-process to handle special structures\n postProcessDocument(result, fields)\n } catch (err) {\n // Log but don't throw - return partially processed result\n\n req.payload.logger.error({\n err,\n msg: '[plugin-import-export] Error in postProcessDocument',\n })\n }\n\n return result\n}\n\nconst getParentObject = (\n obj: Record<string, unknown>,\n segments: string[],\n): Record<string, unknown> | undefined => {\n let current: Record<string, unknown> = obj\n\n for (let i = 0; i < segments.length; i++) {\n const segment = segments[i]\n const nextSegment = segments[i + 1]\n\n if (!segment) {\n continue\n }\n\n if (nextSegment && /^\\d+$/.test(nextSegment)) {\n const arrayIndex = parseInt(nextSegment)\n const arr = current[segment] as unknown[]\n\n if (Array.isArray(arr) && arr[arrayIndex]) {\n current = arr[arrayIndex] as Record<string, unknown>\n i++ // Skip the index\n } else {\n return undefined\n }\n } else {\n const next = current[segment]\n if (typeof next === 'object' && next !== null && !Array.isArray(next)) {\n current = next as Record<string, unknown>\n } else {\n return undefined\n }\n }\n }\n\n return current\n}\n"],"names":["getBlockFlattenedFields","getNestedFlattenedFields","postProcessDocument","indexSegment","collectArrayLikeNames","fields","into","field","name","type","add","block","blocks","nested","toLogicalKey","flatKey","arrayLikeNames","segments","split","filter","seg","i","test","has","join","unflattenObject","data","format","importFieldHooks","req","result","Set","sortedKeys","Object","keys","sort","a","b","aMatch","match","bMatch","index","undefined","aBase","substring","bBase","parseInt","localeCompare","value","endsWith","baseKey","replace","idKey","isPolymorphic","some","Array","isArray","relationTo","relationToKey","importHookEntry","fn","columnName","siblingData","siblingDoc","error","payload","logger","err","msg","pathSegments","currentObject","length","segment","nextSegment","isLast","isArrayIndex","blockFieldName","isBlockField","parent","getParentObject","slice","blockType","parentKey","isPreviousSegmentArrayIndex","isRelationship","find","f","concat","relationToValue","arrayIndex","arr","push","isBlocksField","blockSlug","blockObject","segmentAfterBlockField","blockFieldIsArray","lastSegment","idx","obj","current","next"],"mappings":"AAIA,SAASA,uBAAuB,EAAEC,wBAAwB,QAA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AQ;YAC7B,IAAI,OAAO6B,SAAS,YAAYA,SAAS,QAAQ,CAAC9C,MAAMC,OAAO,CAAC6C,OAAO;gBACrED,UAAUC;YACZ,OAAO;gBACL,OAAO3D;YACT;QACF;IACF;IAEA,OAAO0D;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unflattenPostProcess.d.ts","sourceRoot":"","sources":["../../src/utilities/unflattenPostProcess.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"unflattenPostProcess.d.ts","sourceRoot":"","sources":["../../src/utilities/unflattenPostProcess.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAuM7C;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,QACzB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,UACpB,cAAc,EAAE,KACvB,IAMF,CAAA"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getBlockFlattenedFields, getNestedFlattenedFields } from './flattenedFields.js';
|
|
1
2
|
import { isPlainObject } from './isPlainObject.js';
|
|
2
3
|
import { processRichTextField } from './processRichTextField.js';
|
|
3
4
|
const normalizeLocalizedFields = (doc, fields)=>{
|
|
@@ -107,29 +108,54 @@ const normalizePolymorphicRelationships = (doc, fields)=>{
|
|
|
107
108
|
}
|
|
108
109
|
}
|
|
109
110
|
};
|
|
110
|
-
const
|
|
111
|
-
for (const field of fields
|
|
112
|
-
if (
|
|
113
|
-
|
|
111
|
+
const normalizeRichTextInFields = (doc, fields)=>{
|
|
112
|
+
for (const field of fields){
|
|
113
|
+
if (!('name' in field) || !field.name || !(field.name in doc)) {
|
|
114
|
+
continue;
|
|
114
115
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
const blocks = doc[field.name];
|
|
118
|
-
if (!Array.isArray(blocks)) {
|
|
116
|
+
const value = doc[field.name];
|
|
117
|
+
if (value === null || value === undefined) {
|
|
119
118
|
continue;
|
|
120
119
|
}
|
|
121
|
-
|
|
122
|
-
|
|
120
|
+
if (field.type === 'richText') {
|
|
121
|
+
doc[field.name] = processRichTextField(value);
|
|
122
|
+
} else if (field.type === 'blocks') {
|
|
123
|
+
if (!Array.isArray(value)) {
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
const blockDefs = field.blocks ?? [];
|
|
127
|
+
for (const blockItem of value){
|
|
128
|
+
if (!isPlainObject(blockItem)) {
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
const blockDef = blockDefs.find((b)=>b.slug === blockItem.blockType);
|
|
132
|
+
if (blockDef) {
|
|
133
|
+
normalizeRichTextInFields(blockItem, getBlockFlattenedFields(blockDef));
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
} else if (field.type === 'array') {
|
|
137
|
+
if (!Array.isArray(value)) {
|
|
123
138
|
continue;
|
|
124
139
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
140
|
+
const nestedFields = getNestedFlattenedFields(field) ?? [];
|
|
141
|
+
for (const item of value){
|
|
142
|
+
if (!isPlainObject(item)) {
|
|
143
|
+
continue;
|
|
128
144
|
}
|
|
145
|
+
normalizeRichTextInFields(item, nestedFields);
|
|
129
146
|
}
|
|
147
|
+
} else if (field.type === 'group' || field.type === 'tab') {
|
|
148
|
+
if (!isPlainObject(value)) {
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
const nestedFields = getNestedFlattenedFields(field) ?? [];
|
|
152
|
+
normalizeRichTextInFields(value, nestedFields);
|
|
130
153
|
}
|
|
131
154
|
}
|
|
132
155
|
};
|
|
156
|
+
const normalizeRichText = (doc, fields)=>{
|
|
157
|
+
normalizeRichTextInFields(doc, fields);
|
|
158
|
+
};
|
|
133
159
|
/**
|
|
134
160
|
* Post-processes the unflattened document to handle special field types:
|
|
135
161
|
* - Localized fields: transforms field_locale keys to nested { field: { locale: value } }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/unflattenPostProcess.ts"],"sourcesContent":["import type { FlattenedField } from 'payload'\n\nimport { isPlainObject } from './isPlainObject.js'\nimport { processRichTextField } from './processRichTextField.js'\n\nconst normalizeLocalizedFields = (doc: Record<string, unknown>, fields: FlattenedField[]): void => {\n const processed = new Set<string>()\n\n for (const field of fields.filter((f) => f.localized)) {\n if (processed.has(field.name)) {\n continue\n }\n\n const localePattern = new RegExp(`^${field.name}_([a-z]{2}(?:_[A-Z]{2})?)$`)\n const localeData: Record<string, unknown> = {}\n const keysToDelete: string[] = []\n\n for (const [key, value] of Object.entries(doc)) {\n const match = key.match(localePattern)\n if (match && match[1]) {\n localeData[match[1]] = value\n keysToDelete.push(key)\n }\n }\n\n if (Object.keys(localeData).length > 0) {\n doc[field.name] = localeData\n keysToDelete.forEach((key) => delete doc[key])\n processed.add(field.name)\n }\n }\n}\n\nconst normalizeHasManyNumbers = (doc: Record<string, unknown>, fields: FlattenedField[]): void => {\n const numberFields = fields.filter((field) => field.type === 'number' && field.hasMany)\n for (const field of numberFields) {\n if (!(field.name in doc)) {\n continue\n }\n const value = doc[field.name]\n\n if (typeof value === 'string' && value.includes(',')) {\n doc[field.name] = value\n .split(',')\n .map((v) => v.trim())\n .filter((v) => v !== '')\n .map((v) => {\n const num = parseFloat(v)\n return isNaN(num) ? 0 : num\n })\n } else if (Array.isArray(value)) {\n doc[field.name] = value\n .filter((v) => v !== null && v !== undefined && v !== '')\n .map((v) => {\n if (typeof v === 'string') {\n const num = parseFloat(v)\n return isNaN(num) ? 0 : num\n }\n return v\n })\n } else if (value !== null && value !== undefined && value !== '') {\n const num = typeof value === 'string' ? parseFloat(value) : value\n doc[field.name] = isNaN(num as number) ? [] : [num]\n } else {\n doc[field.name] = []\n }\n }\n}\n\nconst normalizeHasManyRelationships = (\n doc: Record<string, unknown>,\n fields: FlattenedField[],\n): void => {\n const relationshipFields = fields.filter(\n (field) =>\n (field.type === 'relationship' || field.type === 'upload') &&\n field.hasMany === true &&\n !Array.isArray(field.relationTo),\n )\n\n for (const field of relationshipFields) {\n const value = doc[field.name]\n\n if (typeof value === 'string' && value.includes(',')) {\n doc[field.name] = value\n .split(',')\n .map((v) => v.trim())\n .filter((v) => v !== '')\n } else if (Array.isArray(value)) {\n doc[field.name] = value.filter((v) => v !== null && v !== undefined && v !== '')\n } else if (value !== null && value !== undefined && value !== '') {\n doc[field.name] = [value]\n }\n }\n}\n\nconst normalizePolymorphicRelationships = (\n doc: Record<string, unknown>,\n fields: FlattenedField[],\n): void => {\n for (const [key, value] of Object.entries(doc)) {\n if (Array.isArray(value)) {\n const hasPolymorphicItems = value.some((item) => isPlainObject(item) && 'relationTo' in item)\n\n if (!hasPolymorphicItems) {\n continue\n }\n\n const processedArray: unknown[] = []\n for (const item of value) {\n if (isPlainObject(item) && 'relationTo' in item) {\n if (!item.relationTo || (!item.id && !item.value)) {\n continue\n }\n if ('id' in item) {\n item.value = item.id\n delete item.id\n }\n processedArray.push(item)\n } else if (item !== null && item !== undefined) {\n processedArray.push(item)\n }\n }\n\n if (value.length !== processedArray.length) {\n doc[key] = processedArray.length > 0 ? processedArray : []\n }\n } else if (isPlainObject(value)) {\n if ('relationTo' in value && ('id' in value || 'value' in value)) {\n if (!value.relationTo || (!value.id && !value.value)) {\n doc[key] = null\n } else if ('id' in value && !('value' in value)) {\n value.value = value.id\n delete value.id\n }\n } else {\n normalizePolymorphicRelationships(value, fields)\n }\n }\n }\n}\n\nconst normalizeRichText = (doc: Record<string, unknown>, fields: FlattenedField[]): void => {\n for (const field of fields.filter((f) => f.type === 'richText')) {\n if (field.name in doc && doc[field.name]) {\n doc[field.name] = processRichTextField(doc[field.name])\n }\n }\n\n for (const field of fields.filter((f) => f.type === 'blocks')) {\n const blocks = doc[field.name]\n if (!Array.isArray(blocks)) {\n continue\n }\n for (const block of blocks) {\n if (!isPlainObject(block)) {\n continue\n }\n for (const [key, value] of Object.entries(block)) {\n if (key === 'richText' || (typeof key === 'string' && key.includes('richText'))) {\n block[key] = processRichTextField(value)\n }\n }\n }\n }\n}\n\n/**\n * Post-processes the unflattened document to handle special field types:\n * - Localized fields: transforms field_locale keys to nested { field: { locale: value } }\n * - Number hasMany: converts comma-separated strings or arrays to number arrays\n * - Relationship hasMany: converts comma-separated IDs to arrays\n * - Polymorphic relationships: transforms flat {relationTo, id} to {relationTo, value}\n * - Rich text fields: ensures proper data structure\n */\nexport const postProcessDocument = (\n doc: Record<string, unknown>,\n fields: FlattenedField[],\n): void => {\n normalizeLocalizedFields(doc, fields)\n normalizeHasManyNumbers(doc, fields)\n normalizeHasManyRelationships(doc, fields)\n normalizePolymorphicRelationships(doc, fields)\n normalizeRichText(doc, fields)\n}\n"],"names":["isPlainObject","processRichTextField","normalizeLocalizedFields","doc","fields","processed","Set","field","filter","f","localized","has","name","localePattern","RegExp","localeData","keysToDelete","key","value","Object","entries","match","push","keys","length","forEach","add","normalizeHasManyNumbers","numberFields","type","hasMany","includes","split","map","v","trim","num","parseFloat","isNaN","Array","isArray","undefined","normalizeHasManyRelationships","relationshipFields","relationTo","normalizePolymorphicRelationships","hasPolymorphicItems","some","item","processedArray","id","normalizeRichText","blocks","block","postProcessDocument"],"mappings":"AAEA,SAASA,aAAa,QAAQ,qBAAoB;AAClD,SAASC,oBAAoB,QAAQ,4BAA2B;AAEhE,MAAMC,2BAA2B,CAACC,KAA8BC;IAC9D,MAAMC,YAAY,IAAIC;IAEtB,KAAK,MAAMC,SAASH,OAAOI,MAAM,CAAC,CAACC,IAAMA,EAAEC,SAAS,EAAG;QACrD,IAAIL,UAAUM,GAAG,CAACJ,MAAMK,IAAI,GAAG;YAC7B;QACF;QAEA,MAAMC,gBAAgB,IAAIC,OAAO,CAAC,CAAC,EAAEP,MAAMK,IAAI,CAAC,0BAA0B,CAAC;QAC3E,MAAMG,aAAsC,CAAC;QAC7C,MAAMC,eAAyB,EAAE;QAEjC,KAAK,MAAM,CAACC,KA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AAMgC,EAAE;gBACjB;YACF,OAAO;gBACLL,kCAAkC3B,OAAOd;YAC3C;QACF;IACF;AACF;AAEA,MAAM+C,oBAAoB,CAAChD,KAA8BC;IACvD,KAAK,MAAMG,SAASH,OAAOI,MAAM,CAAC,CAACC,IAAMA,EAAEoB,IAAI,KAAK,YAAa;QAC/D,IAAItB,MAAMK,IAAI,IAAIT,OAAOA,GAAG,CAACI,MAAMK,IAAI,CAAC,EAAE;YACxCT,GAAG,CAACI,MAAMK,IAAI,CAAC,GAAGX,qBAAqBE,GAAG,CAACI,MAAMK,IAAI,CAAC;QACxD;IACF;IAEA,KAAK,MAAML,SAASH,OAAOI,MAAM,CAAC,CAACC,IAAMA,EAAEoB,IAAI,KAAK,UAAW;QAC7D,MAAMuB,SAASjD,GAAG,CAACI,MAAMK,IAAI,CAAC;QAC9B,IAAI,CAAC2B,MAAMC,OAAO,CAACY,SAAS;YAC1B;QACF;QACA,KAAK,MAAMC,SAASD,OAAQ;YAC1B,IAAI,CAACpD,cAAcqD,QAAQ;gBACzB;YACF;YACA,KAAK,MAAM,CAACpC,KAAKC,MAAM,IAAIC,OAAOC,OAAO,CAACiC,OAAQ;gBAChD,IAAIpC,QAAQ,cAAe,OAAOA,QAAQ,YAAYA,IAAIc,QAAQ,CAAC,aAAc;oBAC/EsB,KAAK,CAACpC,IAAI,GAAGhB,qBAAqBiB;gBACpC;YACF;QACF;IACF;AACF;AAEA;;;;;;;CAOC,GACD,OAAO,MAAMoC,sBAAsB,CACjCnD,KACAC;IAEAF,yBAAyBC,KAAKC;IAC9BuB,wBAAwBxB,KAAKC;IAC7BsC,8BAA8BvC,KAAKC;IACnCyC,kCAAkC1C,KAAKC;IACvC+C,kBAAkBhD,KAAKC;AACzB,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/unflattenPostProcess.ts"],"sourcesContent":["import type { FlattenedField } from 'payload'\n\nimport { getBlockFlattenedFields, getNestedFlattenedFields } from './flattenedFields.js'\nimport { isPlainObject } from './isPlainObject.js'\nimport { processRichTextField } from './processRichTextField.js'\n\nconst normalizeLocalizedFields = (doc: Record<string, unknown>, fields: FlattenedField[]): void => {\n const processed = new Set<string>()\n\n for (const field of fields.filter((f) => f.localized)) {\n if (processed.has(field.name)) {\n continue\n }\n\n const localePattern = new RegExp(`^${field.name}_([a-z]{2}(?:_[A-Z]{2})?)$`)\n const localeData: Record<string, unknown> = {}\n const keysToDelete: string[] = []\n\n for (const [key, value] of Object.entries(doc)) {\n const match = key.match(localePattern)\n if (match && match[1]) {\n localeData[match[1]] = value\n keysToDelete.push(key)\n }\n }\n\n if (Object.keys(localeData).length > 0) {\n doc[field.name] = localeData\n keysToDelete.forEach((key) => delete doc[key])\n processed.add(field.name)\n }\n }\n}\n\nconst normalizeHasManyNumbers = (doc: Record<string, unknown>, fields: FlattenedField[]): void => {\n const numberFields = fields.filter((field) => field.type === 'number' && field.hasMany)\n for (const field of numberFields) {\n if (!(field.name in doc)) {\n continue\n }\n const value = doc[field.name]\n\n if (typeof value === 'string' && value.includes(',')) {\n doc[field.name] = value\n .split(',')\n .map((v) => v.trim())\n .filter((v) => v !== '')\n .map((v) => {\n const num = parseFloat(v)\n return isNaN(num) ? 0 : num\n })\n } else if (Array.isArray(value)) {\n doc[field.name] = value\n .filter((v) => v !== null && v !== undefined && v !== '')\n .map((v) => {\n if (typeof v === 'string') {\n const num = parseFloat(v)\n return isNaN(num) ? 0 : num\n }\n return v\n })\n } else if (value !== null && value !== undefined && value !== '') {\n const num = typeof value === 'string' ? parseFloat(value) : value\n doc[field.name] = isNaN(num as number) ? [] : [num]\n } else {\n doc[field.name] = []\n }\n }\n}\n\nconst normalizeHasManyRelationships = (\n doc: Record<string, unknown>,\n fields: FlattenedField[],\n): void => {\n const relationshipFields = fields.filter(\n (field) =>\n (field.type === 'relationship' || field.type === 'upload') &&\n field.hasMany === true &&\n !Array.isArray(field.relationTo),\n )\n\n for (const field of relationshipFields) {\n const value = doc[field.name]\n\n if (typeof value === 'string' && value.includes(',')) {\n doc[field.name] = value\n .split(',')\n .map((v) => v.trim())\n .filter((v) => v !== '')\n } else if (Array.isArray(value)) {\n doc[field.name] = value.filter((v) => v !== null && v !== undefined && v !== '')\n } else if (value !== null && value !== undefined && value !== '') {\n doc[field.name] = [value]\n }\n }\n}\n\nconst normalizePolymorphicRelationships = (\n doc: Record<string, unknown>,\n fields: FlattenedField[],\n): void => {\n for (const [key, value] of Object.entries(doc)) {\n if (Array.isArray(value)) {\n const hasPolymorphicItems = value.some((item) => isPlainObject(item) && 'relationTo' in item)\n\n if (!hasPolymorphicItems) {\n continue\n }\n\n const processedArray: unknown[] = []\n for (const item of value) {\n if (isPlainObject(item) && 'relationTo' in item) {\n if (!item.relationTo || (!item.id && !item.value)) {\n continue\n }\n if ('id' in item) {\n item.value = item.id\n delete item.id\n }\n processedArray.push(item)\n } else if (item !== null && item !== undefined) {\n processedArray.push(item)\n }\n }\n\n if (value.length !== processedArray.length) {\n doc[key] = processedArray.length > 0 ? processedArray : []\n }\n } else if (isPlainObject(value)) {\n if ('relationTo' in value && ('id' in value || 'value' in value)) {\n if (!value.relationTo || (!value.id && !value.value)) {\n doc[key] = null\n } else if ('id' in value && !('value' in value)) {\n value.value = value.id\n delete value.id\n }\n } else {\n normalizePolymorphicRelationships(value, fields)\n }\n }\n }\n}\n\nconst normalizeRichTextInFields = (\n doc: Record<string, unknown>,\n fields: FlattenedField[],\n): void => {\n for (const field of fields) {\n if (!('name' in field) || !field.name || !(field.name in doc)) {\n continue\n }\n const value = doc[field.name]\n if (value === null || value === undefined) {\n continue\n }\n\n if (field.type === 'richText') {\n doc[field.name] = processRichTextField(value)\n } else if (field.type === 'blocks') {\n if (!Array.isArray(value)) {\n continue\n }\n const blockDefs =\n (field as { blocks?: Array<{ flattenedFields?: FlattenedField[]; slug: string }> })\n .blocks ?? []\n for (const blockItem of value) {\n if (!isPlainObject(blockItem)) {\n continue\n }\n const blockDef = blockDefs.find((b) => b.slug === blockItem.blockType)\n if (blockDef) {\n normalizeRichTextInFields(blockItem, getBlockFlattenedFields(blockDef))\n }\n }\n } else if (field.type === 'array') {\n if (!Array.isArray(value)) {\n continue\n }\n const nestedFields = getNestedFlattenedFields(field) ?? []\n for (const item of value) {\n if (!isPlainObject(item)) {\n continue\n }\n normalizeRichTextInFields(item, nestedFields)\n }\n } else if (field.type === 'group' || field.type === 'tab') {\n if (!isPlainObject(value)) {\n continue\n }\n const nestedFields = getNestedFlattenedFields(field) ?? []\n normalizeRichTextInFields(value, nestedFields)\n }\n }\n}\n\nconst normalizeRichText = (doc: Record<string, unknown>, fields: FlattenedField[]): void => {\n normalizeRichTextInFields(doc, fields)\n}\n\n/**\n * Post-processes the unflattened document to handle special field types:\n * - Localized fields: transforms field_locale keys to nested { field: { locale: value } }\n * - Number hasMany: converts comma-separated strings or arrays to number arrays\n * - Relationship hasMany: converts comma-separated IDs to arrays\n * - Polymorphic relationships: transforms flat {relationTo, id} to {relationTo, value}\n * - Rich text fields: ensures proper data structure\n */\nexport const postProcessDocument = (\n doc: Record<string, unknown>,\n fields: FlattenedField[],\n): void => {\n normalizeLocalizedFields(doc, fields)\n normalizeHasManyNumbers(doc, fields)\n normalizeHasManyRelationships(doc, fields)\n normalizePolymorphicRelationships(doc, fields)\n normalizeRichText(doc, fields)\n}\n"],"names":["getBlockFlattenedFields","getNestedFlattenedFields","isPlainObject","processRichTextField","normalizeLocalizedFields","doc","fields","processed","Set","field","filter","f","localized","has","name","localePattern","RegExp","localeData","keysToDelete","key","value","Object","entries","match","push","keys","length","forEach","add","normalizeHasManyNumbers","numberFields","type","hasMany","includes","split","map","v","trim","num","parseFloat","isNaN","Array","isArray","undefined","normalizeHasManyRelationships","relationshipFields","relationTo","normalizePolymorphicRelationships","hasPolymorphicItems","some","item","processedArray","id","normalizeRichTextInFields","blockDefs","blocks","blockItem","blockDef","find","b","slug","blockType","nestedFields","normalizeRichText","postProcessDocument"],"mappings":"AAEA,SAASA,uBAAuB,EAAEC,wBAAwB,QAAQ,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EC,IAAI,KAAKJ,UAAUK,SAAS;gBACrE,IAAIJ,UAAU;oBACZJ,0BAA0BG,WAAWxD,wBAAwByD;gBAC/D;YACF;QACF,OAAO,IAAIhD,MAAMsB,IAAI,KAAK,SAAS;YACjC,IAAI,CAACU,MAAMC,OAAO,CAACtB,QAAQ;gBACzB;YACF;YACA,MAAM0C,eAAe7D,yBAAyBQ,UAAU,EAAE;YAC1D,KAAK,MAAMyC,QAAQ9B,MAAO;gBACxB,IAAI,CAAClB,cAAcgD,OAAO;oBACxB;gBACF;gBACAG,0BAA0BH,MAAMY;YAClC;QACF,OAAO,IAAIrD,MAAMsB,IAAI,KAAK,WAAWtB,MAAMsB,IAAI,KAAK,OAAO;YACzD,IAAI,CAAC7B,cAAckB,QAAQ;gBACzB;YACF;YACA,MAAM0C,eAAe7D,yBAAyBQ,UAAU,EAAE;YAC1D4C,0BAA0BjC,OAAO0C;QACnC;IACF;AACF;AAEA,MAAMC,oBAAoB,CAAC1D,KAA8BC;IACvD+C,0BAA0BhD,KAAKC;AACjC;AAEA;;;;;;;CAOC,GACD,OAAO,MAAM0D,sBAAsB,CACjC3D,KACAC;IAEAF,yBAAyBC,KAAKC;IAC9BuB,wBAAwBxB,KAAKC;IAC7BsC,8BAA8BvC,KAAKC;IACnCyC,kCAAkC1C,KAAKC;IACvCyD,kBAAkB1D,KAAKC;AACzB,EAAC"}
|
package/license.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2018-
|
|
3
|
+
Copyright (c) 2018-2026 Payload CMS, LLC <info@payloadcms.com>
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
6
|
a copy of this software and associated documentation files (the
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/plugin-import-export",
|
|
3
|
-
"version": "4.0.0-internal.
|
|
3
|
+
"version": "4.0.0-internal.3b50481",
|
|
4
4
|
"description": "Import-Export plugin for Payload",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"payload",
|
|
@@ -60,21 +60,21 @@
|
|
|
60
60
|
"dist"
|
|
61
61
|
],
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@faceless-ui/modal": "3.0.
|
|
63
|
+
"@faceless-ui/modal": "3.0.2",
|
|
64
64
|
"csv-parse": "5.6.0",
|
|
65
65
|
"csv-stringify": "6.5.2",
|
|
66
66
|
"qs-esm": "8.0.1",
|
|
67
|
-
"@payloadcms/translations": "4.0.0-internal.
|
|
68
|
-
"@payloadcms/ui": "4.0.0-internal.
|
|
67
|
+
"@payloadcms/translations": "4.0.0-internal.3b50481",
|
|
68
|
+
"@payloadcms/ui": "4.0.0-internal.3b50481"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
|
-
"@payloadcms/
|
|
72
|
-
"
|
|
73
|
-
"
|
|
71
|
+
"@payloadcms/eslint-config": "3.28.0",
|
|
72
|
+
"@payloadcms/ui": "4.0.0-internal.3b50481",
|
|
73
|
+
"payload": "4.0.0-internal.3b50481"
|
|
74
74
|
},
|
|
75
75
|
"peerDependencies": {
|
|
76
|
-
"
|
|
77
|
-
"
|
|
76
|
+
"payload": "4.0.0-internal.3b50481",
|
|
77
|
+
"@payloadcms/ui": "4.0.0-internal.3b50481"
|
|
78
78
|
},
|
|
79
79
|
"homepage:": "https://payloadcms.com",
|
|
80
80
|
"scripts": {
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
"build:swc": "swc ./src -d ./dist --config-file .swcrc --strip-leading-paths",
|
|
84
84
|
"build:types": "tsc --emitDeclarationOnly --outDir dist",
|
|
85
85
|
"clean": "rimraf {dist,*.tsbuildinfo}",
|
|
86
|
-
"copyfiles": "copyfiles -u 1 \"src/**/*.{html,css,scss,ttf,woff,woff2,eot,svg,jpg,png,json}\" dist/",
|
|
86
|
+
"copyfiles": "copyfiles -u 1 -e \"**/*.spec.*\" \"src/**/*.{html,css,scss,ttf,woff,woff2,eot,svg,jpg,png,json}\" dist/",
|
|
87
87
|
"lint": "eslint .",
|
|
88
88
|
"lint:fix": "eslint . --fix"
|
|
89
89
|
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
@layer payload-default {
|
|
2
|
-
.export-preview {
|
|
3
|
-
&__header {
|
|
4
|
-
display: flex;
|
|
5
|
-
justify-content: space-between;
|
|
6
|
-
align-items: flex-end;
|
|
7
|
-
margin-bottom: 10px;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
&__export-info {
|
|
11
|
-
display: flex;
|
|
12
|
-
flex-direction: column;
|
|
13
|
-
align-items: flex-end;
|
|
14
|
-
gap: 2px;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
&__export-count {
|
|
18
|
-
font-size: var(--font-size-small);
|
|
19
|
-
color: var(--theme-elevation-500);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
&__limit-capped {
|
|
23
|
-
font-size: var(--font-size-small);
|
|
24
|
-
color: var(--theme-warning-500);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
&__pagination {
|
|
28
|
-
display: flex;
|
|
29
|
-
align-items: center;
|
|
30
|
-
justify-content: space-between;
|
|
31
|
-
gap: var(--base);
|
|
32
|
-
margin-top: var(--base);
|
|
33
|
-
padding-top: var(--base);
|
|
34
|
-
border-top: 1px solid var(--theme-elevation-100);
|
|
35
|
-
|
|
36
|
-
// When only PerPage is present (no Pagination), keep it on the right
|
|
37
|
-
.per-page:only-child {
|
|
38
|
-
margin-left: auto;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
&__page-info {
|
|
43
|
-
font-size: var(--font-size-small);
|
|
44
|
-
color: var(--theme-elevation-500);
|
|
45
|
-
white-space: nowrap;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
File without changes
|
|
@@ -1,239 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { reduceFields } from './reduceFields.js';
|
|
3
|
-
const values = (result)=>result.map((f)=>f.value);
|
|
4
|
-
describe('reduceFields', ()=>{
|
|
5
|
-
describe('excludeUnsortable', ()=>{
|
|
6
|
-
it('should include array and blocks fields by default', ()=>{
|
|
7
|
-
const fields = [
|
|
8
|
-
{
|
|
9
|
-
name: 'title',
|
|
10
|
-
type: 'text'
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
name: 'items',
|
|
14
|
-
type: 'array',
|
|
15
|
-
fields: [
|
|
16
|
-
{
|
|
17
|
-
name: 'text',
|
|
18
|
-
type: 'text'
|
|
19
|
-
}
|
|
20
|
-
]
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
name: 'layout',
|
|
24
|
-
type: 'blocks',
|
|
25
|
-
blocks: []
|
|
26
|
-
}
|
|
27
|
-
];
|
|
28
|
-
const result = values(reduceFields({
|
|
29
|
-
fields
|
|
30
|
-
}));
|
|
31
|
-
expect(result).toContain('title');
|
|
32
|
-
expect(result).toContain('items');
|
|
33
|
-
expect(result).toContain('layout');
|
|
34
|
-
});
|
|
35
|
-
it('should exclude array fields when excludeUnsortable is true', ()=>{
|
|
36
|
-
const fields = [
|
|
37
|
-
{
|
|
38
|
-
name: 'title',
|
|
39
|
-
type: 'text'
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
name: 'items',
|
|
43
|
-
type: 'array',
|
|
44
|
-
fields: [
|
|
45
|
-
{
|
|
46
|
-
name: 'text',
|
|
47
|
-
type: 'text'
|
|
48
|
-
}
|
|
49
|
-
]
|
|
50
|
-
}
|
|
51
|
-
];
|
|
52
|
-
const result = values(reduceFields({
|
|
53
|
-
excludeUnsortable: true,
|
|
54
|
-
fields
|
|
55
|
-
}));
|
|
56
|
-
expect(result).toContain('title');
|
|
57
|
-
expect(result).not.toContain('items');
|
|
58
|
-
});
|
|
59
|
-
it('should exclude blocks fields when excludeUnsortable is true', ()=>{
|
|
60
|
-
const fields = [
|
|
61
|
-
{
|
|
62
|
-
name: 'title',
|
|
63
|
-
type: 'text'
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
name: 'layout',
|
|
67
|
-
type: 'blocks',
|
|
68
|
-
blocks: []
|
|
69
|
-
}
|
|
70
|
-
];
|
|
71
|
-
const result = values(reduceFields({
|
|
72
|
-
excludeUnsortable: true,
|
|
73
|
-
fields
|
|
74
|
-
}));
|
|
75
|
-
expect(result).toContain('title');
|
|
76
|
-
expect(result).not.toContain('layout');
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
describe('disabledFields', ()=>{
|
|
80
|
-
it('should include all fields when disabledFields is empty', ()=>{
|
|
81
|
-
const fields = [
|
|
82
|
-
{
|
|
83
|
-
name: 'title',
|
|
84
|
-
type: 'text'
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
name: 'slug',
|
|
88
|
-
type: 'text'
|
|
89
|
-
}
|
|
90
|
-
];
|
|
91
|
-
const result = values(reduceFields({
|
|
92
|
-
disabledFields: [],
|
|
93
|
-
fields
|
|
94
|
-
}));
|
|
95
|
-
expect(result).toContain('title');
|
|
96
|
-
expect(result).toContain('slug');
|
|
97
|
-
});
|
|
98
|
-
it('should exclude a field whose path is in disabledFields', ()=>{
|
|
99
|
-
const fields = [
|
|
100
|
-
{
|
|
101
|
-
name: 'title',
|
|
102
|
-
type: 'text'
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
name: 'slug',
|
|
106
|
-
type: 'text'
|
|
107
|
-
}
|
|
108
|
-
];
|
|
109
|
-
const result = values(reduceFields({
|
|
110
|
-
disabledFields: [
|
|
111
|
-
'slug'
|
|
112
|
-
],
|
|
113
|
-
fields
|
|
114
|
-
}));
|
|
115
|
-
expect(result).toContain('title');
|
|
116
|
-
expect(result).not.toContain('slug');
|
|
117
|
-
});
|
|
118
|
-
it('should exclude nested fields whose paths start with a disabled parent path', ()=>{
|
|
119
|
-
const fields = [
|
|
120
|
-
{
|
|
121
|
-
name: 'meta',
|
|
122
|
-
type: 'group',
|
|
123
|
-
fields: [
|
|
124
|
-
{
|
|
125
|
-
name: 'title',
|
|
126
|
-
type: 'text'
|
|
127
|
-
},
|
|
128
|
-
{
|
|
129
|
-
name: 'description',
|
|
130
|
-
type: 'text'
|
|
131
|
-
}
|
|
132
|
-
]
|
|
133
|
-
}
|
|
134
|
-
];
|
|
135
|
-
const result = values(reduceFields({
|
|
136
|
-
disabledFields: [
|
|
137
|
-
'meta.description'
|
|
138
|
-
],
|
|
139
|
-
fields
|
|
140
|
-
}));
|
|
141
|
-
expect(result).toContain('meta.title');
|
|
142
|
-
expect(result).not.toContain('meta.description');
|
|
143
|
-
});
|
|
144
|
-
});
|
|
145
|
-
describe('combined excludeUnsortable and disabledFields', ()=>{
|
|
146
|
-
it('should apply both filters simultaneously', ()=>{
|
|
147
|
-
const fields = [
|
|
148
|
-
{
|
|
149
|
-
name: 'title',
|
|
150
|
-
type: 'text'
|
|
151
|
-
},
|
|
152
|
-
{
|
|
153
|
-
name: 'slug',
|
|
154
|
-
type: 'text'
|
|
155
|
-
},
|
|
156
|
-
{
|
|
157
|
-
name: 'items',
|
|
158
|
-
type: 'array',
|
|
159
|
-
fields: [
|
|
160
|
-
{
|
|
161
|
-
name: 'text',
|
|
162
|
-
type: 'text'
|
|
163
|
-
}
|
|
164
|
-
]
|
|
165
|
-
}
|
|
166
|
-
];
|
|
167
|
-
const result = values(reduceFields({
|
|
168
|
-
disabledFields: [
|
|
169
|
-
'slug'
|
|
170
|
-
],
|
|
171
|
-
excludeUnsortable: true,
|
|
172
|
-
fields
|
|
173
|
-
}));
|
|
174
|
-
expect(result).toContain('title');
|
|
175
|
-
expect(result).not.toContain('slug');
|
|
176
|
-
expect(result).not.toContain('items');
|
|
177
|
-
});
|
|
178
|
-
});
|
|
179
|
-
describe('recursive propagation through group sub-fields', ()=>{
|
|
180
|
-
it('should propagate excludeUnsortable into group sub-fields', ()=>{
|
|
181
|
-
const fields = [
|
|
182
|
-
{
|
|
183
|
-
name: 'meta',
|
|
184
|
-
type: 'group',
|
|
185
|
-
fields: [
|
|
186
|
-
{
|
|
187
|
-
name: 'title',
|
|
188
|
-
type: 'text'
|
|
189
|
-
},
|
|
190
|
-
{
|
|
191
|
-
name: 'tags',
|
|
192
|
-
type: 'array',
|
|
193
|
-
fields: [
|
|
194
|
-
{
|
|
195
|
-
name: 'tag',
|
|
196
|
-
type: 'text'
|
|
197
|
-
}
|
|
198
|
-
]
|
|
199
|
-
}
|
|
200
|
-
]
|
|
201
|
-
}
|
|
202
|
-
];
|
|
203
|
-
const result = values(reduceFields({
|
|
204
|
-
excludeUnsortable: true,
|
|
205
|
-
fields
|
|
206
|
-
}));
|
|
207
|
-
expect(result).toContain('meta.title');
|
|
208
|
-
expect(result).not.toContain('meta.tags');
|
|
209
|
-
});
|
|
210
|
-
it('should propagate disabledFields into group sub-fields', ()=>{
|
|
211
|
-
const fields = [
|
|
212
|
-
{
|
|
213
|
-
name: 'meta',
|
|
214
|
-
type: 'group',
|
|
215
|
-
fields: [
|
|
216
|
-
{
|
|
217
|
-
name: 'title',
|
|
218
|
-
type: 'text'
|
|
219
|
-
},
|
|
220
|
-
{
|
|
221
|
-
name: 'description',
|
|
222
|
-
type: 'text'
|
|
223
|
-
}
|
|
224
|
-
]
|
|
225
|
-
}
|
|
226
|
-
];
|
|
227
|
-
const result = values(reduceFields({
|
|
228
|
-
disabledFields: [
|
|
229
|
-
'meta.description'
|
|
230
|
-
],
|
|
231
|
-
fields
|
|
232
|
-
}));
|
|
233
|
-
expect(result).toContain('meta.title');
|
|
234
|
-
expect(result).not.toContain('meta.description');
|
|
235
|
-
});
|
|
236
|
-
});
|
|
237
|
-
});
|
|
238
|
-
|
|
239
|
-
//# sourceMappingURL=reduceFields.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/FieldsToExport/reduceFields.spec.ts"],"sourcesContent":["import type { ClientField } from 'payload'\n\nimport { describe, expect, it } from 'vitest'\n\nimport { reduceFields } from './reduceFields.js'\n\nconst values = (result: ReturnType<typeof reduceFields>) => result.map((f) => f.value)\n\ndescribe('reduceFields', () => {\n describe('excludeUnsortable', () => {\n it('should include array and blocks fields by default', () => {\n const fields: ClientField[] = [\n { name: 'title', type: 'text' },\n { name: 'items', type: 'array', fields: [{ name: 'text', type: 'text' }] },\n { name: 'layout', type: 'blocks', blocks: [] },\n ]\n\n const result = values(reduceFields({ fields }))\n\n expect(result).toContain('title')\n expect(result).toContain('items')\n expect(result).toContain('layout')\n })\n\n it('should exclude array fields when excludeUnsortable is true', () => {\n const fields: ClientField[] = [\n { name: 'title', type: 'text' },\n { name: 'items', type: 'array', fields: [{ name: 'text', type: 'text' }] },\n ]\n\n const result = values(reduceFields({ excludeUnsortable: true, fields }))\n\n expect(result).toContain('title')\n expect(result).not.toContain('items')\n })\n\n it('should exclude blocks fields when excludeUnsortable is true', () => {\n const fields: ClientField[] = [\n { name: 'title', type: 'text' },\n { name: 'layout', type: 'blocks', blocks: [] },\n ]\n\n const result = values(reduceFields({ excludeUnsortable: true, fields }))\n\n expect(result).toContain('title')\n expect(result).not.toContain('layout')\n })\n })\n\n describe('disabledFields', () => {\n it('should include all fields when disabledFields is empty', () => {\n const fields: ClientField[] = [\n { name: 'title', type: 'text' },\n { name: 'slug', type: 'text' },\n ]\n\n const result = values(reduceFields({ disabledFields: [], fields }))\n\n expect(result).toContain('title')\n expect(result).toContain('slug')\n })\n\n it('should exclude a field whose path is in disabledFields', () => {\n const fields: ClientField[] = [\n { name: 'title', type: 'text' },\n { name: 'slug', type: 'text' },\n ]\n\n const result = values(reduceFields({ disabledFields: ['slug'], fields }))\n\n expect(result).toContain('title')\n expect(result).not.toContain('slug')\n })\n\n it('should exclude nested fields whose paths start with a disabled parent path', () => {\n const fields: ClientField[] = [\n {\n name: 'meta',\n type: 'group',\n fields: [\n { name: 'title', type: 'text' },\n { name: 'description', type: 'text' },\n ],\n },\n ]\n\n const result = values(reduceFields({ disabledFields: ['meta.description'], fields }))\n\n expect(result).toContain('meta.title')\n expect(result).not.toContain('meta.description')\n })\n })\n\n describe('combined excludeUnsortable and disabledFields', () => {\n it('should apply both filters simultaneously', () => {\n const fields: ClientField[] = [\n { name: 'title', type: 'text' },\n { name: 'slug', type: 'text' },\n { name: 'items', type: 'array', fields: [{ name: 'text', type: 'text' }] },\n ]\n\n const result = values(\n reduceFields({ disabledFields: ['slug'], excludeUnsortable: true, fields }),\n )\n\n expect(result).toContain('title')\n expect(result).not.toContain('slug')\n expect(result).not.toContain('items')\n })\n })\n\n describe('recursive propagation through group sub-fields', () => {\n it('should propagate excludeUnsortable into group sub-fields', () => {\n const fields: ClientField[] = [\n {\n name: 'meta',\n type: 'group',\n fields: [\n { name: 'title', type: 'text' },\n { name: 'tags', type: 'array', fields: [{ name: 'tag', type: 'text' }] },\n ],\n },\n ]\n\n const result = values(reduceFields({ excludeUnsortable: true, fields }))\n\n expect(result).toContain('meta.title')\n expect(result).not.toContain('meta.tags')\n })\n\n it('should propagate disabledFields into group sub-fields', () => {\n const fields: ClientField[] = [\n {\n name: 'meta',\n type: 'group',\n fields: [\n { name: 'title', type: 'text' },\n { name: 'description', type: 'text' },\n ],\n },\n ]\n\n const result = values(reduceFields({ disabledFields: ['meta.description'], fields }))\n\n expect(result).toContain('meta.title')\n expect(result).not.toContain('meta.description')\n })\n })\n})\n"],"names":["describe","expect","it","reduceFields","values","result","map","f","value","fields","name","type","blocks","toContain","excludeUnsortable","not","disabledFields"],"mappings":"AAEA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,SAAQ;AAE7C,SAASC,YAAY,QAAQ,oBAAmB;AAEhD,MAAMC,SAAS,CAACC,SAA4CA,OAAOC,GAAG,CAAC,CAACC,IAAMA,EAAEC,KAAK;AAErFR,SAAS,gBAAgB;IACvBA,SAAS,qBAAqB;QAC5BE,GAAG,qDAAqD;YACtD,MAAMO,SAAwB;gBAC5B;oBAAEC,MA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