@payloadcms/plugin-import-export 4.0.0-internal.38b7f1d → 4.0.0-internal.c2b57ce

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.
Files changed (67) hide show
  1. package/dist/components/FieldsToExport/reduceFields.d.ts.map +1 -1
  2. package/dist/export/createExport.d.ts.map +1 -1
  3. package/dist/export/getCreateExportCollectionTask.d.ts.map +1 -1
  4. package/dist/export/getExportCollection.d.ts.map +1 -1
  5. package/dist/export/getFields.d.ts.map +1 -1
  6. package/dist/export/handleDownload.d.ts.map +1 -1
  7. package/dist/export/handlePreview.d.ts.map +1 -1
  8. package/dist/export/handlePreview.js +1 -1
  9. package/dist/export/handlePreview.js.map +1 -1
  10. package/dist/exports/types.d.ts +1 -1
  11. package/dist/exports/types.d.ts.map +1 -1
  12. package/dist/exports/types.js.map +1 -1
  13. package/dist/import/createImport.d.ts.map +1 -1
  14. package/dist/import/createImport.js +1 -1
  15. package/dist/import/createImport.js.map +1 -1
  16. package/dist/import/getCreateImportCollectionTask.d.ts.map +1 -1
  17. package/dist/import/getFields.d.ts.map +1 -1
  18. package/dist/import/getImportCollection.d.ts.map +1 -1
  19. package/dist/import/handlePreview.d.ts.map +1 -1
  20. package/dist/index.d.ts +1 -11
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +13 -5
  23. package/dist/index.js.map +1 -1
  24. package/dist/types.d.ts +0 -32
  25. package/dist/types.d.ts.map +1 -1
  26. package/dist/types.js.map +1 -1
  27. package/dist/utilities/applyFieldHooks.d.ts +1 -2
  28. package/dist/utilities/applyFieldHooks.d.ts.map +1 -1
  29. package/dist/utilities/applyFieldHooks.js +1 -2
  30. package/dist/utilities/applyFieldHooks.js.map +1 -1
  31. package/dist/utilities/buildDisabledFieldRegex.d.ts.map +1 -1
  32. package/dist/utilities/collectDisabledFieldPaths.d.ts.map +1 -1
  33. package/dist/utilities/fieldToRegex.d.ts.map +1 -1
  34. package/dist/utilities/flattenObject.d.ts.map +1 -1
  35. package/dist/utilities/flattenObject.js +3 -13
  36. package/dist/utilities/flattenObject.js.map +1 -1
  37. package/dist/utilities/flattenedFields.d.ts.map +1 -1
  38. package/dist/utilities/getExportFieldFunctions.d.ts.map +1 -1
  39. package/dist/utilities/getExportFieldFunctions.js +0 -8
  40. package/dist/utilities/getExportFieldFunctions.js.map +1 -1
  41. package/dist/utilities/getFileFromDoc.d.ts.map +1 -1
  42. package/dist/utilities/getFlattenedFieldKeys.d.ts.map +1 -1
  43. package/dist/utilities/getImportFieldFunctions.d.ts.map +1 -1
  44. package/dist/utilities/getImportFieldFunctions.js +0 -8
  45. package/dist/utilities/getImportFieldFunctions.js.map +1 -1
  46. package/dist/utilities/getPluginCollections.d.ts.map +1 -1
  47. package/dist/utilities/getSchemaColumns.d.ts +1 -1
  48. package/dist/utilities/getSchemaColumns.d.ts.map +1 -1
  49. package/dist/utilities/getSchemaColumns.js +2 -2
  50. package/dist/utilities/getSchemaColumns.js.map +1 -1
  51. package/dist/utilities/getSelect.d.ts.map +1 -1
  52. package/dist/utilities/isPlainObject.d.ts.map +1 -1
  53. package/dist/utilities/parseCSV.d.ts.map +1 -1
  54. package/dist/utilities/parseJSON.d.ts.map +1 -1
  55. package/dist/utilities/polymorphicRel.d.ts.map +1 -1
  56. package/dist/utilities/processRichTextField.d.ts.map +1 -1
  57. package/dist/utilities/removeDisabledFields.d.ts.map +1 -1
  58. package/dist/utilities/setNestedValue.d.ts.map +1 -1
  59. package/dist/utilities/sortHelpers.d.ts.map +1 -1
  60. package/dist/utilities/unflattenObject.d.ts.map +1 -1
  61. package/dist/utilities/unflattenObject.js +8 -16
  62. package/dist/utilities/unflattenObject.js.map +1 -1
  63. package/dist/utilities/unflattenPostProcess.d.ts.map +1 -1
  64. package/dist/utilities/validateLimitValue.d.ts.map +1 -1
  65. package/package.json +8 -8
  66. package/dist/utilities/legacyHookDispatch.spec.js +0 -227
  67. package/dist/utilities/legacyHookDispatch.spec.js.map +0 -1
@@ -103,22 +103,14 @@ const collectArrayLikeNames = (fields, into)=>{
103
103
  const importHookEntry = importFieldHooks[flatKey] ?? importFieldHooks[toLogicalKey(flatKey, arrayLikeNames)];
104
104
  if (importHookEntry) {
105
105
  try {
106
- if (importHookEntry.type === 'beforeImport') {
107
- value = importHookEntry.fn({
108
- columnName: flatKey,
109
- data,
110
- format,
111
- siblingData: data,
112
- siblingDoc: data,
113
- value
114
- });
115
- } else {
116
- value = importHookEntry.fn({
117
- columnName: flatKey,
118
- data,
119
- value
120
- });
121
- }
106
+ value = importHookEntry.fn({
107
+ columnName: flatKey,
108
+ data,
109
+ format,
110
+ siblingData: data,
111
+ siblingDoc: data,
112
+ value
113
+ });
122
114
  } catch (error) {
123
115
  req.payload.logger.error({
124
116
  err: error,
@@ -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;AAErB,MAAMC,wBAAwB,CAACC,QAA0BC;IACvD,KAAK,MAAMC,SAASF,OAAQ;QAC1B,IAAI,CAAE,CAAA,UAAUE,KAAI,KAAM,CAACA,MAAMC,IAAI,EAAE;YACrC;QACF;QACA,IAAID,MAAME,IAAI,KAAK,WAAWF,MAAME,IAAI,KAAK,UAAU;YACrDH,KAAKI,GAAG,CAACH,MAAMC,IAAI;QACrB;QACA,MAAMG,SAASV,yBAAyBM;QACxC,IAAII,QAAQ;YACVP,sBAAsBO,QAAQL;QAChC;IACF;AACF;AAEA;;;;;;CAMC,GACD,MAAMM,eAAe,CAACC,SAAiBC;IACrC,MAAMC,WAAWF,QAAQG,KAAK,CAAC;IAC/B,OAAOD,SACJE,MAAM,CAAC,CAACC,KAAKC,IAAM,CAAChB,aAAaiB,IAAI,CAACF,QAAQ,CAACJ,eAAeO,GAAG,CAACN,QAAQ,CAACI,IAAI,EAAE,IAAI,KACrFG,IAAI,CAAC;AACV;AAEA;;;;;;;;;;;;CAYC,GACD,OAAO,MAAMC,kBAAkB,CAAC,EAC9BC,IAAI,EACJnB,MAAM,E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AAC0C,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 { 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 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 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,uBAAs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CD;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 +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;AAuK7C;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,QACzB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,UACpB,cAAc,EAAE,KACvB,IAMF,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;AAuK7C;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,GAC9B,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,QAAQ,cAAc,EAAE,KACvB,IAMF,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"validateLimitValue.d.ts","sourceRoot":"","sources":["../../src/utilities/validateLimitValue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AAEzD,eAAO,MAAM,kBAAkB,UACtB,IAAI,GAAG,MAAM,GAAG,SAAS,KAC7B,SAAS,KACX,MAAM,GAAG,SAMX,CAAA"}
1
+ {"version":3,"file":"validateLimitValue.d.ts","sourceRoot":"","sources":["../../src/utilities/validateLimitValue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AAEzD,eAAO,MAAM,kBAAkB,GAC7B,OAAO,IAAI,GAAG,MAAM,GAAG,SAAS,EAChC,GAAG,SAAS,KACX,MAAM,GAAG,SAMX,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/plugin-import-export",
3
- "version": "4.0.0-internal.38b7f1d",
3
+ "version": "4.0.0-internal.c2b57ce",
4
4
  "description": "Import-Export plugin for Payload",
5
5
  "keywords": [
6
6
  "payload",
@@ -64,17 +64,17 @@
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.38b7f1d",
68
- "@payloadcms/ui": "4.0.0-internal.38b7f1d"
67
+ "@payloadcms/translations": "4.0.0-internal.c2b57ce",
68
+ "@payloadcms/ui": "4.0.0-internal.c2b57ce"
69
69
  },
70
70
  "devDependencies": {
71
- "@payloadcms/ui": "4.0.0-internal.38b7f1d",
72
- "payload": "4.0.0-internal.38b7f1d",
73
- "@payloadcms/eslint-config": "3.28.0"
71
+ "@payloadcms/eslint-config": "3.28.0",
72
+ "@payloadcms/ui": "4.0.0-internal.c2b57ce",
73
+ "payload": "4.0.0-internal.c2b57ce"
74
74
  },
75
75
  "peerDependencies": {
76
- "@payloadcms/ui": "4.0.0-internal.38b7f1d",
77
- "payload": "4.0.0-internal.38b7f1d"
76
+ "@payloadcms/ui": "4.0.0-internal.c2b57ce",
77
+ "payload": "4.0.0-internal.c2b57ce"
78
78
  },
79
79
  "homepage:": "https://payloadcms.com",
80
80
  "scripts": {
@@ -1,227 +0,0 @@
1
- import { flattenObject } from './flattenObject.js';
2
- import { getExportFieldFunctions } from './getExportFieldFunctions.js';
3
- import { getImportFieldFunctions } from './getImportFieldFunctions.js';
4
- import { unflattenObject } from './unflattenObject.js';
5
- import { describe, expect, it, vi } from 'vitest';
6
- const mockReq = {
7
- payload: {
8
- logger: {
9
- error: vi.fn()
10
- }
11
- }
12
- };
13
- describe('legacy toCSV / fromCSV argument shape', ()=>{
14
- describe('toCSV receives { columnName, data, doc, row, siblingDoc, value }', ()=>{
15
- it('should pass row as flat row accumulator, doc as top-level doc, and siblingDoc as source doc', ()=>{
16
- const received = [];
17
- const fields = [
18
- {
19
- name: 'legacy',
20
- type: 'text',
21
- custom: {
22
- 'plugin-import-export': {
23
- toCSV: (args)=>{
24
- received.push(args);
25
- args.row[`${args.columnName}_extra`] = 'added';
26
- return String(args.value) + '_transformed';
27
- }
28
- }
29
- }
30
- }
31
- ];
32
- const exportFieldHooks = getExportFieldFunctions({
33
- fields
34
- });
35
- const doc = {
36
- legacy: 'hello',
37
- title: 'Top'
38
- };
39
- const result = flattenObject({
40
- data: doc,
41
- exportFieldHooks,
42
- format: 'csv',
43
- req: mockReq
44
- });
45
- expect(received).toHaveLength(1);
46
- const args = received[0];
47
- expect(args.columnName).toBe('legacy');
48
- expect(args.value).toBe('hello');
49
- // doc should be the top-level document
50
- expect(args.doc).toBe(doc);
51
- // siblingDoc should be the source doc at the current nesting level (top-level == doc)
52
- expect(args.siblingDoc).toBe(doc);
53
- // row should be the flat row accumulator (a different object from doc)
54
- expect(args.row).not.toBe(doc);
55
- // data is kept as alias for row to avoid breaking legacy usage
56
- expect(args.data).toBe(args.row);
57
- expect(result.legacy).toBe('hello_transformed');
58
- expect(result.legacy_extra).toBe('added');
59
- });
60
- it('should not pass legacy args to hooks.beforeExport', ()=>{
61
- const received = [];
62
- const fields = [
63
- {
64
- name: 'modern',
65
- type: 'text',
66
- custom: {
67
- 'plugin-import-export': {
68
- hooks: {
69
- beforeExport: (args)=>{
70
- received.push(args);
71
- return String(args.value) + '_modern';
72
- }
73
- }
74
- }
75
- }
76
- }
77
- ];
78
- const exportFieldHooks = getExportFieldFunctions({
79
- fields
80
- });
81
- const doc = {
82
- modern: 'v',
83
- title: 'Top'
84
- };
85
- flattenObject({
86
- data: doc,
87
- exportFieldHooks,
88
- format: 'csv',
89
- req: mockReq
90
- });
91
- expect(received).toHaveLength(1);
92
- const args = received[0];
93
- // Modern signature: data === top-level doc
94
- expect(args.data).toBe(doc);
95
- // Modern signature: siblingData === flat row accumulator (not source doc)
96
- expect(args.siblingData).not.toBe(doc);
97
- expect(args.format).toBe('csv');
98
- // Legacy-only args should not be present
99
- expect(args.doc).toBeUndefined();
100
- expect(args.row).toBeUndefined();
101
- // `siblingDoc` is part of the modern signature too (read-only source view)
102
- expect(args.siblingDoc).toBeDefined();
103
- });
104
- it('should prefer hooks.beforeExport when both are defined on a field', ()=>{
105
- const legacyCalls = [];
106
- const modernCalls = [];
107
- const fields = [
108
- {
109
- name: 'both',
110
- type: 'text',
111
- custom: {
112
- 'plugin-import-export': {
113
- hooks: {
114
- beforeExport: ({ value })=>{
115
- modernCalls.push(String(value));
116
- return `${value}_modern`;
117
- }
118
- },
119
- toCSV: ({ value })=>{
120
- legacyCalls.push(String(value));
121
- return `${value}_legacy`;
122
- }
123
- }
124
- }
125
- }
126
- ];
127
- const exportFieldHooks = getExportFieldFunctions({
128
- fields
129
- });
130
- const result = flattenObject({
131
- data: {
132
- both: 'x'
133
- },
134
- exportFieldHooks,
135
- format: 'csv',
136
- req: mockReq
137
- });
138
- expect(modernCalls).toEqual([
139
- 'x'
140
- ]);
141
- expect(legacyCalls).toEqual([]);
142
- expect(result.both).toBe('x_modern');
143
- });
144
- });
145
- describe('fromCSV receives { columnName, data, value } with data as full flat row', ()=>{
146
- it('should pass the full flat row as data', ()=>{
147
- const received = [];
148
- const fields = [
149
- {
150
- name: 'legacy',
151
- type: 'text',
152
- custom: {
153
- 'plugin-import-export': {
154
- fromCSV: (args)=>{
155
- received.push(args);
156
- return String(args.value) + '_imported';
157
- }
158
- }
159
- }
160
- }
161
- ];
162
- const importFieldHooks = getImportFieldFunctions({
163
- fields
164
- });
165
- const flatRow = {
166
- legacy: 'incoming',
167
- title: 'Top'
168
- };
169
- const result = unflattenObject({
170
- data: flatRow,
171
- fields,
172
- format: 'csv',
173
- importFieldHooks,
174
- req: mockReq
175
- });
176
- expect(received).toHaveLength(1);
177
- expect(received[0].columnName).toBe('legacy');
178
- expect(received[0].value).toBe('incoming');
179
- // data should be the full flat row
180
- expect(received[0].data).toBe(flatRow);
181
- expect(result.legacy).toBe('incoming_imported');
182
- });
183
- it('should prefer hooks.beforeImport when both are defined on a field', ()=>{
184
- const legacyCalls = [];
185
- const modernCalls = [];
186
- const fields = [
187
- {
188
- name: 'both',
189
- type: 'text',
190
- custom: {
191
- 'plugin-import-export': {
192
- fromCSV: ({ value })=>{
193
- legacyCalls.push(String(value));
194
- return `${value}_legacy`;
195
- },
196
- hooks: {
197
- beforeImport: ({ value })=>{
198
- modernCalls.push(String(value));
199
- return `${value}_modern`;
200
- }
201
- }
202
- }
203
- }
204
- }
205
- ];
206
- const importFieldHooks = getImportFieldFunctions({
207
- fields
208
- });
209
- const result = unflattenObject({
210
- data: {
211
- both: 'x'
212
- },
213
- fields,
214
- format: 'csv',
215
- importFieldHooks,
216
- req: mockReq
217
- });
218
- expect(modernCalls).toEqual([
219
- 'x'
220
- ]);
221
- expect(legacyCalls).toEqual([]);
222
- expect(result.both).toBe('x_modern');
223
- });
224
- });
225
- });
226
-
227
- //# sourceMappingURL=legacyHookDispatch.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/utilities/legacyHookDispatch.spec.ts"],"sourcesContent":["import { FlattenedField, PayloadRequest } from 'payload'\n\nimport type { FromCSVFunction, ToCSVFunction } from '../types.js'\n\nimport { flattenObject } from './flattenObject.js'\nimport { getExportFieldFunctions } from './getExportFieldFunctions.js'\nimport { getImportFieldFunctions } from './getImportFieldFunctions.js'\nimport { unflattenObject } from './unflattenObject.js'\n\nimport { describe, expect, it, vi } from 'vitest'\n\nconst mockReq = {\n payload: {\n logger: {\n error: vi.fn(),\n },\n },\n} as unknown as PayloadRequest\n\ndescribe('legacy toCSV / fromCSV argument shape', () => {\n describe('toCSV receives { columnName, data, doc, row, siblingDoc, value }', () => {\n it('should pass row as flat row accumulator, doc as top-level doc, and siblingDoc as source doc', () => {\n const received: Parameters<ToCSVFunction>[0][] = []\n\n const fields: FlattenedField[] = [\n {\n name: 'legacy',\n type: 'text',\n custom: {\n 'plugin-import-export': {\n toCSV: ((args) => {\n received.push(args)\n args.row[`${args.columnName}_extra`] = 'added'\n return String(args.value) + '_transformed'\n }) satisfies ToCSVFunction,\n },\n },\n } as FlattenedField,\n ]\n\n const exportFieldHooks = getExportFieldFunctions({ fields })\n\n const doc = { legacy: 'hello', title: 'Top' }\n const result = flattenObject({\n data: doc,\n exportFieldHooks,\n format: 'csv',\n req: mockReq,\n })\n\n expect(received).toHaveLength(1)\n const args = received[0]!\n expect(args.columnName).toBe('legacy')\n expect(args.value).toBe('hello')\n // doc should be the top-level document\n expect(args.doc).toBe(doc)\n // siblingDoc should be the source doc at the current nesting level (top-level == doc)\n expect(args.siblingDoc).toBe(doc)\n // row should be the flat row accumulator (a different object from doc)\n expect(args.row).not.toBe(doc)\n // data is kept as alias for row to avoid breaking legacy usage\n expect(args.data).toBe(args.row)\n\n expect(result.legacy).toBe('hello_transformed')\n expect(result.legacy_extra).toBe('added')\n })\n\n it('should not pass legacy args to hooks.beforeExport', () => {\n const received: Array<Record<string, unknown>> = []\n\n const fields: FlattenedField[] = [\n {\n name: 'modern',\n type: 'text',\n custom: {\n 'plugin-import-export': {\n hooks: {\n beforeExport: (args) => {\n received.push(args as unknown as Record<string, unknown>)\n return String(args.value) + '_modern'\n },\n },\n },\n },\n } as FlattenedField,\n ]\n\n const exportFieldHooks = getExportFieldFunctions({ fields })\n\n const doc = { modern: 'v', title: 'Top' }\n flattenObject({ data: doc, exportFieldHooks, format: 'csv', req: mockReq })\n\n expect(received).toHaveLength(1)\n const args = received[0]!\n // Modern signature: data === top-level doc\n expect(args.data).toBe(doc)\n // Modern signature: siblingData === flat row accumulator (not source doc)\n expect(args.siblingData).not.toBe(doc)\n expect(args.format).toBe('csv')\n // Legacy-only args should not be present\n expect(args.doc).toBeUndefined()\n expect(args.row).toBeUndefined()\n // `siblingDoc` is part of the modern signature too (read-only source view)\n expect(args.siblingDoc).toBeDefined()\n })\n\n it('should prefer hooks.beforeExport when both are defined on a field', () => {\n const legacyCalls: string[] = []\n const modernCalls: string[] = []\n\n const fields: FlattenedField[] = [\n {\n name: 'both',\n type: 'text',\n custom: {\n 'plugin-import-export': {\n hooks: {\n beforeExport: ({ value }) => {\n modernCalls.push(String(value))\n return `${value}_modern`\n },\n },\n toCSV: ({ value }: { value: unknown }) => {\n legacyCalls.push(String(value))\n return `${value}_legacy`\n },\n },\n },\n } as FlattenedField,\n ]\n\n const exportFieldHooks = getExportFieldFunctions({ fields })\n const result = flattenObject({\n data: { both: 'x' },\n exportFieldHooks,\n format: 'csv',\n req: mockReq,\n })\n\n expect(modernCalls).toEqual(['x'])\n expect(legacyCalls).toEqual([])\n expect(result.both).toBe('x_modern')\n })\n })\n\n describe('fromCSV receives { columnName, data, value } with data as full flat row', () => {\n it('should pass the full flat row as data', () => {\n const received: Parameters<FromCSVFunction>[0][] = []\n\n const fields: FlattenedField[] = [\n {\n name: 'legacy',\n type: 'text',\n custom: {\n 'plugin-import-export': {\n fromCSV: ((args) => {\n received.push(args)\n return String(args.value) + '_imported'\n }) satisfies FromCSVFunction,\n },\n },\n } as FlattenedField,\n ]\n\n const importFieldHooks = getImportFieldFunctions({ fields })\n\n const flatRow = { legacy: 'incoming', title: 'Top' }\n const result = unflattenObject({\n data: flatRow,\n fields,\n format: 'csv',\n importFieldHooks,\n req: mockReq,\n })\n\n expect(received).toHaveLength(1)\n expect(received[0]!.columnName).toBe('legacy')\n expect(received[0]!.value).toBe('incoming')\n // data should be the full flat row\n expect(received[0]!.data).toBe(flatRow)\n\n expect(result.legacy).toBe('incoming_imported')\n })\n\n it('should prefer hooks.beforeImport when both are defined on a field', () => {\n const legacyCalls: string[] = []\n const modernCalls: string[] = []\n\n const fields: FlattenedField[] = [\n {\n name: 'both',\n type: 'text',\n custom: {\n 'plugin-import-export': {\n fromCSV: ({ value }: { value: unknown }) => {\n legacyCalls.push(String(value))\n return `${value}_legacy`\n },\n hooks: {\n beforeImport: ({ value }) => {\n modernCalls.push(String(value))\n return `${value}_modern`\n },\n },\n },\n },\n } as FlattenedField,\n ]\n\n const importFieldHooks = getImportFieldFunctions({ fields })\n const result = unflattenObject({\n data: { both: 'x' },\n fields,\n format: 'csv',\n importFieldHooks,\n req: mockReq,\n })\n\n expect(modernCalls).toEqual(['x'])\n expect(legacyCalls).toEqual([])\n expect(result.both).toBe('x_modern')\n })\n })\n})\n"],"names":["flattenObject","getExportFieldFunctions","getImportFieldFunctions","unflattenObject","describe","expect","it","vi","mockReq","payload","logger","error","fn","received","fields","name","type","custom","toCSV","args","push","row","columnName","String","value","exportFieldHooks","doc","legacy","title","result","data","format","req","toHaveLength","toBe","siblingDoc","not","legacy_extra","hooks","beforeExport","modern","siblingData","toBeUndefined","toBeDefined","legacyCalls","modernCalls","both","toEqual","fromCSV","importFieldHooks","flatRow","beforeImport"],"mappings":"AAIA,SAASA,aAAa,QAAQ,qBAAoB;AAClD,SAASC,uBAAuB,QAAQ,+BAA8B;AACtE,SAASC,uBAAuB,QAAQ,+BAA8B;AACtE,SAASC,eAAe,QAAQ,uBAAsB;AAEtD,SAASC,QAAQ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