@payloadcms/plugin-import-export 3.71.0-internal.ef75fa0 → 3.71.1
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.map +1 -1
- package/dist/components/CollectionField/index.js +8 -3
- package/dist/components/CollectionField/index.js.map +1 -1
- package/dist/components/ExportListMenuItem/index.d.ts +0 -1
- package/dist/components/ExportListMenuItem/index.d.ts.map +1 -1
- package/dist/components/ExportListMenuItem/index.js +0 -1
- package/dist/components/ExportListMenuItem/index.js.map +1 -1
- package/dist/components/ExportPreview/index.d.ts +4 -0
- package/dist/components/ExportPreview/index.d.ts.map +1 -0
- package/dist/components/ExportPreview/index.js +252 -0
- package/dist/components/ExportPreview/index.js.map +1 -0
- package/dist/components/ExportPreview/index.scss +36 -0
- package/dist/components/ImportCollectionField/index.d.ts +3 -0
- package/dist/components/ImportCollectionField/index.d.ts.map +1 -0
- package/dist/components/ImportCollectionField/index.js +17 -0
- package/dist/components/ImportCollectionField/index.js.map +1 -0
- package/dist/components/ImportListMenuItem/index.d.ts +6 -0
- package/dist/components/ImportListMenuItem/index.d.ts.map +1 -0
- package/dist/components/ImportListMenuItem/index.js +48 -0
- package/dist/components/ImportListMenuItem/index.js.map +1 -0
- package/dist/components/ImportPreview/index.d.ts +4 -0
- package/dist/components/ImportPreview/index.d.ts.map +1 -0
- package/dist/components/ImportPreview/index.js +624 -0
- package/dist/components/ImportPreview/index.js.map +1 -0
- package/dist/components/ImportPreview/index.scss +41 -0
- package/dist/components/ImportSaveButton/index.d.ts +2 -0
- package/dist/components/ImportSaveButton/index.d.ts.map +1 -0
- package/dist/components/ImportSaveButton/index.js +18 -0
- package/dist/components/ImportSaveButton/index.js.map +1 -0
- package/dist/components/Page/index.scss +4 -2
- package/dist/constants.d.ts +21 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +21 -0
- package/dist/constants.js.map +1 -0
- package/dist/export/batchProcessor.d.ts +107 -0
- package/dist/export/batchProcessor.d.ts.map +1 -0
- package/dist/export/batchProcessor.js +187 -0
- package/dist/export/batchProcessor.js.map +1 -0
- package/dist/export/createExport.d.ts +9 -4
- package/dist/export/createExport.d.ts.map +1 -1
- package/dist/export/createExport.js +163 -111
- package/dist/export/createExport.js.map +1 -1
- package/dist/export/getCreateExportCollectionTask.d.ts +1 -2
- package/dist/export/getCreateExportCollectionTask.d.ts.map +1 -1
- package/dist/export/getCreateExportCollectionTask.js +10 -18
- package/dist/export/getCreateExportCollectionTask.js.map +1 -1
- package/dist/export/getExportCollection.d.ts +8 -0
- package/dist/export/getExportCollection.d.ts.map +1 -0
- package/dist/export/getExportCollection.js +100 -0
- package/dist/export/getExportCollection.js.map +1 -0
- package/dist/export/getFields.d.ts +8 -2
- package/dist/export/getFields.d.ts.map +1 -1
- package/dist/export/getFields.js +7 -9
- package/dist/export/getFields.js.map +1 -1
- package/dist/export/handleDownload.d.ts +3 -0
- package/dist/export/handleDownload.d.ts.map +1 -0
- package/dist/export/{download.js → handleDownload.js} +7 -6
- package/dist/export/handleDownload.js.map +1 -0
- package/dist/export/handlePreview.d.ts +3 -0
- package/dist/export/handlePreview.d.ts.map +1 -0
- package/dist/export/handlePreview.js +163 -0
- package/dist/export/handlePreview.js.map +1 -0
- package/dist/exports/rsc.d.ts +5 -1
- package/dist/exports/rsc.d.ts.map +1 -1
- package/dist/exports/rsc.js +5 -1
- package/dist/exports/rsc.js.map +1 -1
- package/dist/import/batchProcessor.d.ts +46 -0
- package/dist/import/batchProcessor.d.ts.map +1 -0
- package/dist/import/batchProcessor.js +529 -0
- package/dist/import/batchProcessor.js.map +1 -0
- package/dist/import/createImport.d.ts +45 -0
- package/dist/import/createImport.d.ts.map +1 -0
- package/dist/import/createImport.js +175 -0
- package/dist/import/createImport.js.map +1 -0
- package/dist/import/getCreateImportCollectionTask.d.ts +13 -0
- package/dist/import/getCreateImportCollectionTask.d.ts.map +1 -0
- package/dist/import/getCreateImportCollectionTask.js +81 -0
- package/dist/import/getCreateImportCollectionTask.js.map +1 -0
- package/dist/import/getFields.d.ts +7 -0
- package/dist/import/getFields.d.ts.map +1 -0
- package/dist/import/getFields.js +150 -0
- package/dist/import/getFields.js.map +1 -0
- package/dist/import/getImportCollection.d.ts +8 -0
- package/dist/import/getImportCollection.d.ts.map +1 -0
- package/dist/import/getImportCollection.js +258 -0
- package/dist/import/getImportCollection.js.map +1 -0
- package/dist/import/handlePreview.d.ts +3 -0
- package/dist/import/handlePreview.d.ts.map +1 -0
- package/dist/import/handlePreview.js +94 -0
- package/dist/import/handlePreview.js.map +1 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +68 -110
- package/dist/index.js.map +1 -1
- package/dist/translations/languages/ar.d.ts.map +1 -1
- package/dist/translations/languages/ar.js +21 -1
- package/dist/translations/languages/ar.js.map +1 -1
- package/dist/translations/languages/az.d.ts.map +1 -1
- package/dist/translations/languages/az.js +21 -1
- package/dist/translations/languages/az.js.map +1 -1
- package/dist/translations/languages/bg.d.ts.map +1 -1
- package/dist/translations/languages/bg.js +21 -1
- package/dist/translations/languages/bg.js.map +1 -1
- package/dist/translations/languages/bnBd.d.ts +4 -0
- package/dist/translations/languages/bnBd.d.ts.map +1 -0
- package/dist/translations/languages/bnBd.js +48 -0
- package/dist/translations/languages/bnBd.js.map +1 -0
- package/dist/translations/languages/bnIn.d.ts +4 -0
- package/dist/translations/languages/bnIn.d.ts.map +1 -0
- package/dist/translations/languages/bnIn.js +48 -0
- package/dist/translations/languages/bnIn.js.map +1 -0
- package/dist/translations/languages/ca.d.ts.map +1 -1
- package/dist/translations/languages/ca.js +21 -1
- package/dist/translations/languages/ca.js.map +1 -1
- package/dist/translations/languages/cs.d.ts.map +1 -1
- package/dist/translations/languages/cs.js +21 -1
- package/dist/translations/languages/cs.js.map +1 -1
- package/dist/translations/languages/da.d.ts.map +1 -1
- package/dist/translations/languages/da.js +21 -1
- package/dist/translations/languages/da.js.map +1 -1
- package/dist/translations/languages/de.d.ts.map +1 -1
- package/dist/translations/languages/de.js +21 -1
- package/dist/translations/languages/de.js.map +1 -1
- package/dist/translations/languages/en.d.ts +20 -0
- package/dist/translations/languages/en.d.ts.map +1 -1
- package/dist/translations/languages/en.js +21 -1
- package/dist/translations/languages/en.js.map +1 -1
- package/dist/translations/languages/es.d.ts.map +1 -1
- package/dist/translations/languages/es.js +21 -1
- package/dist/translations/languages/es.js.map +1 -1
- package/dist/translations/languages/et.d.ts.map +1 -1
- package/dist/translations/languages/et.js +21 -1
- package/dist/translations/languages/et.js.map +1 -1
- package/dist/translations/languages/fa.d.ts.map +1 -1
- package/dist/translations/languages/fa.js +21 -1
- package/dist/translations/languages/fa.js.map +1 -1
- package/dist/translations/languages/fr.d.ts.map +1 -1
- package/dist/translations/languages/fr.js +21 -1
- package/dist/translations/languages/fr.js.map +1 -1
- package/dist/translations/languages/he.d.ts.map +1 -1
- package/dist/translations/languages/he.js +21 -1
- package/dist/translations/languages/he.js.map +1 -1
- package/dist/translations/languages/hr.d.ts.map +1 -1
- package/dist/translations/languages/hr.js +21 -1
- package/dist/translations/languages/hr.js.map +1 -1
- package/dist/translations/languages/hu.d.ts.map +1 -1
- package/dist/translations/languages/hu.js +21 -1
- package/dist/translations/languages/hu.js.map +1 -1
- package/dist/translations/languages/hy.d.ts.map +1 -1
- package/dist/translations/languages/hy.js +21 -1
- package/dist/translations/languages/hy.js.map +1 -1
- package/dist/translations/languages/id.d.ts +4 -0
- package/dist/translations/languages/id.d.ts.map +1 -0
- package/dist/translations/languages/id.js +48 -0
- package/dist/translations/languages/id.js.map +1 -0
- package/dist/translations/languages/is.d.ts.map +1 -1
- package/dist/translations/languages/is.js +21 -1
- package/dist/translations/languages/is.js.map +1 -1
- package/dist/translations/languages/it.d.ts.map +1 -1
- package/dist/translations/languages/it.js +21 -1
- package/dist/translations/languages/it.js.map +1 -1
- package/dist/translations/languages/ja.d.ts.map +1 -1
- package/dist/translations/languages/ja.js +21 -1
- package/dist/translations/languages/ja.js.map +1 -1
- package/dist/translations/languages/ko.d.ts.map +1 -1
- package/dist/translations/languages/ko.js +21 -1
- package/dist/translations/languages/ko.js.map +1 -1
- package/dist/translations/languages/lt.d.ts.map +1 -1
- package/dist/translations/languages/lt.js +21 -1
- package/dist/translations/languages/lt.js.map +1 -1
- package/dist/translations/languages/lv.d.ts.map +1 -1
- package/dist/translations/languages/lv.js +26 -6
- package/dist/translations/languages/lv.js.map +1 -1
- package/dist/translations/languages/my.d.ts.map +1 -1
- package/dist/translations/languages/my.js +21 -1
- package/dist/translations/languages/my.js.map +1 -1
- package/dist/translations/languages/nb.d.ts.map +1 -1
- package/dist/translations/languages/nb.js +21 -1
- package/dist/translations/languages/nb.js.map +1 -1
- package/dist/translations/languages/nl.d.ts.map +1 -1
- package/dist/translations/languages/nl.js +21 -1
- package/dist/translations/languages/nl.js.map +1 -1
- package/dist/translations/languages/pl.d.ts.map +1 -1
- package/dist/translations/languages/pl.js +21 -1
- package/dist/translations/languages/pl.js.map +1 -1
- package/dist/translations/languages/pt.d.ts.map +1 -1
- package/dist/translations/languages/pt.js +21 -1
- package/dist/translations/languages/pt.js.map +1 -1
- package/dist/translations/languages/ro.d.ts.map +1 -1
- package/dist/translations/languages/ro.js +21 -1
- package/dist/translations/languages/ro.js.map +1 -1
- package/dist/translations/languages/rs.d.ts.map +1 -1
- package/dist/translations/languages/rs.js +21 -1
- package/dist/translations/languages/rs.js.map +1 -1
- package/dist/translations/languages/rsLatin.d.ts.map +1 -1
- package/dist/translations/languages/rsLatin.js +21 -1
- package/dist/translations/languages/rsLatin.js.map +1 -1
- package/dist/translations/languages/ru.d.ts.map +1 -1
- package/dist/translations/languages/ru.js +21 -1
- package/dist/translations/languages/ru.js.map +1 -1
- package/dist/translations/languages/sk.d.ts.map +1 -1
- package/dist/translations/languages/sk.js +21 -1
- package/dist/translations/languages/sk.js.map +1 -1
- package/dist/translations/languages/sl.d.ts.map +1 -1
- package/dist/translations/languages/sl.js +21 -1
- package/dist/translations/languages/sl.js.map +1 -1
- package/dist/translations/languages/sv.d.ts.map +1 -1
- package/dist/translations/languages/sv.js +21 -1
- package/dist/translations/languages/sv.js.map +1 -1
- package/dist/translations/languages/ta.d.ts.map +1 -1
- package/dist/translations/languages/ta.js +21 -1
- package/dist/translations/languages/ta.js.map +1 -1
- package/dist/translations/languages/th.d.ts.map +1 -1
- package/dist/translations/languages/th.js +21 -1
- package/dist/translations/languages/th.js.map +1 -1
- package/dist/translations/languages/tr.d.ts.map +1 -1
- package/dist/translations/languages/tr.js +21 -1
- package/dist/translations/languages/tr.js.map +1 -1
- package/dist/translations/languages/uk.d.ts.map +1 -1
- package/dist/translations/languages/uk.js +21 -1
- package/dist/translations/languages/uk.js.map +1 -1
- package/dist/translations/languages/vi.d.ts.map +1 -1
- package/dist/translations/languages/vi.js +21 -1
- package/dist/translations/languages/vi.js.map +1 -1
- package/dist/translations/languages/zh.d.ts.map +1 -1
- package/dist/translations/languages/zh.js +21 -1
- package/dist/translations/languages/zh.js.map +1 -1
- package/dist/translations/languages/zhTw.d.ts.map +1 -1
- package/dist/translations/languages/zhTw.js +21 -1
- package/dist/translations/languages/zhTw.js.map +1 -1
- package/dist/translations/types.d.ts +13 -0
- package/dist/translations/types.d.ts.map +1 -1
- package/dist/translations/types.js.map +1 -1
- package/dist/types.d.ts +166 -22
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utilities/flattenObject.d.ts.map +1 -0
- package/dist/{export → utilities}/flattenObject.js +13 -6
- package/dist/utilities/flattenObject.js.map +1 -0
- package/dist/utilities/getExportFieldFunctions.d.ts +12 -0
- package/dist/utilities/getExportFieldFunctions.d.ts.map +1 -0
- package/dist/{export/getCustomFieldFunctions.js → utilities/getExportFieldFunctions.js} +18 -2
- package/dist/utilities/getExportFieldFunctions.js.map +1 -0
- package/dist/utilities/getFilename.d.ts +6 -0
- package/dist/utilities/getFilename.d.ts.map +1 -0
- package/dist/{export → utilities}/getFilename.js +4 -1
- package/dist/utilities/getFilename.js.map +1 -0
- package/dist/utilities/getFlattenedFieldKeys.d.ts +12 -1
- package/dist/utilities/getFlattenedFieldKeys.d.ts.map +1 -1
- package/dist/utilities/getFlattenedFieldKeys.js +35 -10
- package/dist/utilities/getFlattenedFieldKeys.js.map +1 -1
- package/dist/utilities/getImportFieldFunctions.d.ts +12 -0
- package/dist/utilities/getImportFieldFunctions.d.ts.map +1 -0
- package/dist/utilities/getImportFieldFunctions.js +130 -0
- package/dist/utilities/getImportFieldFunctions.js.map +1 -0
- package/dist/utilities/getPluginCollections.d.ts +39 -0
- package/dist/utilities/getPluginCollections.d.ts.map +1 -0
- package/dist/utilities/getPluginCollections.js +102 -0
- package/dist/utilities/getPluginCollections.js.map +1 -0
- package/dist/utilities/getSchemaColumns.d.ts +43 -0
- package/dist/utilities/getSchemaColumns.d.ts.map +1 -0
- package/dist/utilities/getSchemaColumns.js +163 -0
- package/dist/utilities/getSchemaColumns.js.map +1 -0
- package/dist/utilities/getSelect.d.ts +11 -0
- package/dist/utilities/getSelect.d.ts.map +1 -0
- package/dist/{export → utilities}/getSelect.js +6 -2
- package/dist/utilities/getSelect.js.map +1 -0
- package/dist/utilities/parseCSV.d.ts +11 -0
- package/dist/utilities/parseCSV.d.ts.map +1 -0
- package/dist/utilities/parseCSV.js +67 -0
- package/dist/utilities/parseCSV.js.map +1 -0
- package/dist/utilities/parseCSV.spec.js +169 -0
- package/dist/utilities/parseCSV.spec.js.map +1 -0
- package/dist/utilities/parseJSON.d.ts +11 -0
- package/dist/utilities/parseJSON.d.ts.map +1 -0
- package/dist/utilities/parseJSON.js +25 -0
- package/dist/utilities/parseJSON.js.map +1 -0
- package/dist/utilities/processRichTextField.d.ts +6 -0
- package/dist/utilities/processRichTextField.d.ts.map +1 -0
- package/dist/utilities/processRichTextField.js +45 -0
- package/dist/utilities/processRichTextField.js.map +1 -0
- package/dist/utilities/unflattenObject.d.ts +11 -0
- package/dist/utilities/unflattenObject.d.ts.map +1 -0
- package/dist/utilities/unflattenObject.js +431 -0
- package/dist/utilities/unflattenObject.js.map +1 -0
- package/dist/utilities/unflattenObject.spec.js +680 -0
- package/dist/utilities/unflattenObject.spec.js.map +1 -0
- package/dist/utilities/useBatchProcessor.d.ts +103 -0
- package/dist/utilities/useBatchProcessor.d.ts.map +1 -0
- package/dist/utilities/useBatchProcessor.js +88 -0
- package/dist/utilities/useBatchProcessor.js.map +1 -0
- package/dist/utilities/validateLimitValue.d.ts +1 -1
- package/dist/utilities/validateLimitValue.d.ts.map +1 -1
- package/dist/utilities/validateLimitValue.js +1 -4
- package/dist/utilities/validateLimitValue.js.map +1 -1
- package/package.json +9 -9
- package/dist/components/ExportListMenuItem/index.scss +0 -52
- package/dist/components/Preview/index.d.ts +0 -4
- package/dist/components/Preview/index.d.ts.map +0 -1
- package/dist/components/Preview/index.js +0 -180
- package/dist/components/Preview/index.js.map +0 -1
- package/dist/components/Preview/index.scss +0 -8
- package/dist/export/download.d.ts +0 -3
- package/dist/export/download.d.ts.map +0 -1
- package/dist/export/download.js.map +0 -1
- package/dist/export/flattenObject.d.ts.map +0 -1
- package/dist/export/flattenObject.js.map +0 -1
- package/dist/export/getCustomFieldFunctions.d.ts +0 -8
- package/dist/export/getCustomFieldFunctions.d.ts.map +0 -1
- package/dist/export/getCustomFieldFunctions.js.map +0 -1
- package/dist/export/getFilename.d.ts +0 -2
- package/dist/export/getFilename.d.ts.map +0 -1
- package/dist/export/getFilename.js.map +0 -1
- package/dist/export/getSelect.d.ts +0 -7
- package/dist/export/getSelect.d.ts.map +0 -1
- package/dist/export/getSelect.js.map +0 -1
- package/dist/getExportCollection.d.ts +0 -7
- package/dist/getExportCollection.d.ts.map +0 -1
- package/dist/getExportCollection.js +0 -86
- package/dist/getExportCollection.js.map +0 -1
- /package/dist/{export → utilities}/flattenObject.d.ts +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/export/flattenObject.ts"],"sourcesContent":["import type { Document } from 'payload'\n\nimport type { ToCSVFunction } from '../types.js'\n\ntype Args = {\n doc: Document\n fields?: string[]\n prefix?: string\n toCSVFunctions: Record<string, ToCSVFunction>\n}\n\nexport const flattenObject = ({\n doc,\n fields,\n prefix,\n toCSVFunctions,\n}: Args): Record<string, unknown> => {\n const row: Record<string, unknown> = {}\n\n const flatten = (siblingDoc: Document, prefix?: string) => {\n Object.entries(siblingDoc).forEach(([key, value]) => {\n const newKey = prefix ? `${prefix}_${key}` : key\n\n if (Array.isArray(value)) {\n // If a custom toCSV function exists for this array field, run it first.\n // If it produces output, skip per-item handling; otherwise, fall back.\n if (toCSVFunctions?.[newKey]) {\n try {\n const result = toCSVFunctions[newKey]({\n columnName: newKey,\n data: row,\n doc,\n row,\n siblingDoc,\n value, // whole array\n })\n\n if (typeof result !== 'undefined') {\n // Custom function returned a single value for this array field.\n row[newKey] = result\n return\n }\n\n // If the custom function wrote any keys for this field, consider it handled.\n for (const k in row) {\n if (k === newKey || k.startsWith(`${newKey}_`)) {\n return\n }\n }\n // Otherwise, fall through to per-item handling.\n } catch (error) {\n throw new Error(\n `Error in toCSVFunction for array \"${newKey}\": ${JSON.stringify(value)}\\n${\n (error as Error).message\n }`,\n )\n }\n }\n\n value.forEach((item, index) => {\n if (typeof item === 'object' && item !== null) {\n const blockType = typeof item.blockType === 'string' ? item.blockType : undefined\n const itemPrefix = blockType ? `${newKey}_${index}_${blockType}` : `${newKey}_${index}`\n\n // Case: hasMany polymorphic relationships\n if (\n 'relationTo' in item &&\n 'value' in item &&\n typeof item.value === 'object' &&\n item.value !== null\n ) {\n row[`${itemPrefix}_relationTo`] = item.relationTo\n row[`${itemPrefix}_id`] = item.value.id\n return\n }\n\n // Fallback: deep-flatten nested objects\n flatten(item, itemPrefix)\n } else {\n // Primitive array item.\n row[`${newKey}_${index}`] = item\n }\n })\n } else if (typeof value === 'object' && value !== null) {\n // Object field: use custom toCSV if present, else recurse.\n if (!toCSVFunctions?.[newKey]) {\n flatten(value, newKey)\n } else {\n try {\n const result = toCSVFunctions[newKey]({\n columnName: newKey,\n data: row,\n doc,\n row,\n siblingDoc,\n value,\n })\n if (typeof result !== 'undefined') {\n row[newKey] = result\n }\n } catch (error) {\n throw new Error(\n `Error in toCSVFunction for nested object \"${newKey}\": ${JSON.stringify(value)}\\n${\n (error as Error).message\n }`,\n )\n }\n }\n } else {\n if (toCSVFunctions?.[newKey]) {\n try {\n const result = toCSVFunctions[newKey]({\n columnName: newKey,\n data: row,\n doc,\n row,\n siblingDoc,\n value,\n })\n if (typeof result !== 'undefined') {\n row[newKey] = result\n }\n } catch (error) {\n throw new Error(\n `Error in toCSVFunction for field \"${newKey}\": ${JSON.stringify(value)}\\n${\n (error as Error).message\n }`,\n )\n }\n } else {\n row[newKey] = value\n }\n }\n })\n }\n\n flatten(doc, prefix)\n\n if (Array.isArray(fields) && fields.length > 0) {\n const orderedResult: Record<string, unknown> = {}\n\n const fieldToRegex = (field: string): RegExp => {\n const parts = field.split('.').map((part) => `${part}(?:_\\\\d+)?`)\n const pattern = `^${parts.join('_')}`\n return new RegExp(pattern)\n }\n\n fields.forEach((field) => {\n if (row[field.replace(/\\./g, '_')]) {\n const sanitizedField = field.replace(/\\./g, '_')\n orderedResult[sanitizedField] = row[sanitizedField]\n } else {\n const regex = fieldToRegex(field)\n Object.keys(row).forEach((key) => {\n if (regex.test(key)) {\n orderedResult[key] = row[key]\n }\n })\n }\n })\n\n return orderedResult\n }\n\n return row\n}\n"],"names":["flattenObject","doc","fields","prefix","toCSVFunctions","row","flatten","siblingDoc","Object","entries","forEach","key","value","newKey","Array","isArray","result","columnName","data","k","startsWith","error","Error","JSON","stringify","message","item","index","blockType","undefined","itemPrefix","relationTo","id","length","orderedResult","fieldToRegex","field","parts","split","map","part","pattern","join","RegExp","replace","sanitizedField","regex","keys","test"],"mappings":"AAWA,OAAO,MAAMA,gBAAgB,CAAC,EAC5BC,GAAG,EACHC,MAAM,EACNC,MAAM,EACNC,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,SAAS,CAACZ,OAAO,EAAE,EACvE,AAACS,MAAgBI,OAAO,EACxB;oBAEN;gBACF,OAAO;oBACLpB,GAAG,CAACQ,OAAO,GAAGD;gBAChB;YACF;QACF;IACF;IAEAN,QAAQL,KAAKE;IAEb,IAAIW,MAAMC,OAAO,CAACb,WAAWA,OAAO+B,MAAM,GAAG,GAAG;QAC9C,MAAMC,gBAAyC,CAAC;QAEhD,MAAMC,eAAe,CAACC;YACpB,MAAMC,QAAQD,MAAME,KAAK,CAAC,KAAKC,GAAG,CAAC,CAACC,OAAS,GAAGA,KAAK,UAAU,CAAC;YAChE,MAAMC,UAAU,CAAC,CAAC,EAAEJ,MAAMK,IAAI,CAAC,MAAM;YACrC,OAAO,IAAIC,OAAOF;QACpB;QAEAvC,OAAOQ,OAAO,CAAC,CAAC0B;YACd,IAAI/B,GAAG,CAAC+B,MAAMQ,OAAO,CAAC,OAAO,KAAK,EAAE;gBAClC,MAAMC,iBAAiBT,MAAMQ,OAAO,CAAC,OAAO;gBAC5CV,aAAa,CAACW,eAAe,GAAGxC,GAAG,CAACwC,eAAe;YACrD,OAAO;gBACL,MAAMC,QAAQX,aAAaC;gBAC3B5B,OAAOuC,IAAI,CAAC1C,KAAKK,OAAO,CAAC,CAACC;oBACxB,IAAImC,MAAME,IAAI,CAACrC,MAAM;wBACnBuB,aAAa,CAACvB,IAAI,GAAGN,GAAG,CAACM,IAAI;oBAC/B;gBACF;YACF;QACF;QAEA,OAAOuB;IACT;IAEA,OAAO7B;AACT,EAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { type FlattenedField } from 'payload';
|
|
2
|
-
import type { ToCSVFunction } from '../types.js';
|
|
3
|
-
type Args = {
|
|
4
|
-
fields: FlattenedField[];
|
|
5
|
-
};
|
|
6
|
-
export declare const getCustomFieldFunctions: ({ fields }: Args) => Record<string, ToCSVFunction>;
|
|
7
|
-
export {};
|
|
8
|
-
//# sourceMappingURL=getCustomFieldFunctions.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getCustomFieldFunctions.d.ts","sourceRoot":"","sources":["../../src/export/getCustomFieldFunctions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAA+C,MAAM,SAAS,CAAA;AAE1F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAEhD,KAAK,IAAI,GAAG;IACV,MAAM,EAAE,cAAc,EAAE,CAAA;CACzB,CAAA;AAED,eAAO,MAAM,uBAAuB,eAAgB,IAAI,KAAG,MAAM,CAAC,MAAM,EAAE,aAAa,CAgGtF,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/export/getCustomFieldFunctions.ts"],"sourcesContent":["import { type FlattenedField, traverseFields, type TraverseFieldsCallback } from 'payload'\n\nimport type { ToCSVFunction } from '../types.js'\n\ntype Args = {\n fields: FlattenedField[]\n}\n\nexport const getCustomFieldFunctions = ({ fields }: Args): Record<string, ToCSVFunction> => {\n const result: Record<string, ToCSVFunction> = {}\n\n const buildCustomFunctions: TraverseFieldsCallback = ({ field, parentRef, ref }) => {\n // @ts-expect-error ref is untyped\n ref.prefix = parentRef.prefix || ''\n if (field.type === 'group' || field.type === 'tab') {\n // @ts-expect-error ref is untyped\n const parentPrefix = parentRef?.prefix ? `${parentRef.prefix}_` : ''\n // @ts-expect-error ref is untyped\n ref.prefix = `${parentPrefix}${field.name}_`\n }\n\n if (typeof field.custom?.['plugin-import-export']?.toCSV === 'function') {\n // @ts-expect-error ref is untyped\n result[`${ref.prefix}${field.name}`] = field.custom['plugin-import-export']?.toCSV\n } else if (field.type === 'relationship' || field.type === 'upload') {\n if (field.hasMany !== true) {\n if (!Array.isArray(field.relationTo)) {\n // monomorphic single\n // @ts-expect-error ref is untyped\n result[`${ref.prefix}${field.name}`] = ({ value }) =>\n typeof value === 'object' && value && 'id' in value ? value.id : value\n } else {\n // polymorphic single\n // @ts-expect-error ref is untyped\n result[`${ref.prefix}${field.name}`] = ({ data, value }) => {\n if (value && typeof value === 'object' && 'relationTo' in value && 'value' in value) {\n const relationTo = (value as { relationTo: string; value: { id: number | string } })\n .relationTo\n const relatedDoc = (value as { relationTo: string; value: { id: number | string } })\n .value\n if (relatedDoc && typeof relatedDoc === 'object') {\n // @ts-expect-error ref is untyped\n data[`${ref.prefix}${field.name}_id`] = relatedDoc.id\n // @ts-expect-error ref is untyped\n data[`${ref.prefix}${field.name}_relationTo`] = relationTo\n }\n }\n return undefined // prevents further flattening\n }\n }\n } else {\n if (!Array.isArray(field.relationTo)) {\n // monomorphic many\n // @ts-expect-error ref is untyped\n result[`${ref.prefix}${field.name}`] = ({\n data,\n value,\n }: {\n data: Record<string, unknown>\n value: Array<number | Record<string, any> | string> | undefined\n }) => {\n if (Array.isArray(value)) {\n value.forEach((val, i) => {\n const id = typeof val === 'object' && val ? val.id : val\n // @ts-expect-error ref is untyped\n data[`${ref.prefix}${field.name}_${i}_id`] = id\n })\n }\n return undefined // prevents further flattening\n }\n } else {\n // polymorphic many\n // @ts-expect-error ref is untyped\n result[`${ref.prefix}${field.name}`] = ({\n data,\n value,\n }: {\n data: Record<string, unknown>\n value: Array<Record<string, any>> | undefined\n }) => {\n if (Array.isArray(value)) {\n value.forEach((val, i) => {\n if (val && typeof val === 'object') {\n const relationTo = val.relationTo\n const relatedDoc = val.value\n if (relationTo && relatedDoc && typeof relatedDoc === 'object') {\n // @ts-expect-error ref is untyped\n data[`${ref.prefix}${field.name}_${i}_id`] = relatedDoc.id\n // @ts-expect-error ref is untyped\n data[`${ref.prefix}${field.name}_${i}_relationTo`] = relationTo\n }\n }\n })\n }\n return undefined\n }\n }\n }\n }\n }\n\n traverseFields({ callback: buildCustomFunctions, fields })\n\n return result\n}\n"],"names":["traverseFields","getCustomFieldFunctions","fields","result","buildCustomFunctions","field","parentRef","ref","prefix","type","parentPrefix","name","custom","toCSV","hasMany","Array","isArray","relationTo","value","id","data","relatedDoc","undefined","forEach","val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CAACE,QAAQ;4BACxBA,MAAMK,OAAO,CAAC,CAACC,KAAKC;gCAClB,IAAID,OAAO,OAAOA,QAAQ,UAAU;oCAClC,MAAMP,aAAaO,IAAIP,UAAU;oCACjC,MAAMI,aAAaG,IAAIN,KAAK;oCAC5B,IAAID,cAAcI,cAAc,OAAOA,eAAe,UAAU;wCAC9D,kCAAkC;wCAClCD,IAAI,CAAC,GAAGb,IAAIC,MAAM,GAAGH,MAAMM,IAAI,CAAC,CAAC,EAAEc,EAAE,GAAG,CAAC,CAAC,GAAGJ,WAAWF,EAAE;wCAC1D,kCAAkC;wCAClCC,IAAI,CAAC,GAAGb,IAAIC,MAAM,GAAGH,MAAMM,IAAI,CAAC,CAAC,EAAEc,EAAE,WAAW,CAAC,CAAC,GAAGR;oCACvD;gCACF;4BACF;wBACF;wBACA,OAAOK;oBACT;gBACF;YACF;QACF;IACF;IAEAtB,eAAe;QAAE0B,UAAUtB;QAAsBF;IAAO;IAExD,OAAOC;AACT,EAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getFilename.d.ts","sourceRoot":"","sources":["../../src/export/getFilename.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,cAMvB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/export/getFilename.ts"],"sourcesContent":["export const getFilename = () => {\n const now = new Date()\n const yyymmdd = now.toISOString().split('T')[0] // \"YYYY-MM-DD\"\n const hhmmss = now.toTimeString().split(' ')[0] // \"HH:MM:SS\"\n\n return `${yyymmdd} ${hhmmss}`\n}\n"],"names":["getFilename","now","Date","yyymmdd","toISOString","split","hhmmss","toTimeString"],"mappings":"AAAA,OAAO,MAAMA,cAAc;IACzB,MAAMC,MAAM,IAAIC;IAChB,MAAMC,UAAUF,IAAIG,WAAW,GAAGC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,eAAe;;IAC/D,MAAMC,SAASL,IAAIM,YAAY,GAAGF,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,aAAa;;IAE7D,OAAO,GAAGF,QAAQ,CAAC,EAAEG,QAAQ;AAC/B,EAAC"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { SelectIncludeType } from 'payload';
|
|
2
|
-
/**
|
|
3
|
-
* Takes an input of array of string paths in dot notation and returns a select object
|
|
4
|
-
* example args: ['id', 'title', 'group.value', 'createdAt', 'updatedAt']
|
|
5
|
-
*/
|
|
6
|
-
export declare const getSelect: (fields: string[]) => SelectIncludeType;
|
|
7
|
-
//# sourceMappingURL=getSelect.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getSelect.d.ts","sourceRoot":"","sources":["../../src/export/getSelect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAEhD;;;GAGG;AACH,eAAO,MAAM,SAAS,WAAY,MAAM,EAAE,KAAG,iBAoB5C,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/export/getSelect.ts"],"sourcesContent":["import type { SelectIncludeType } from 'payload'\n\n/**\n * Takes an input of array of string paths in dot notation and returns a select object\n * example args: ['id', 'title', 'group.value', 'createdAt', 'updatedAt']\n */\nexport const getSelect = (fields: string[]): SelectIncludeType => {\n const select: SelectIncludeType = {}\n\n fields.forEach((field) => {\n const segments = field.split('.')\n let selectRef = select\n\n segments.forEach((segment, i) => {\n if (i === segments.length - 1) {\n selectRef[segment] = true\n } else {\n if (!selectRef[segment]) {\n selectRef[segment] = {}\n }\n selectRef = selectRef[segment] as SelectIncludeType\n }\n })\n })\n\n return select\n}\n"],"names":["getSelect","fields","select","forEach","field","segments","split","selectRef","segment","i","length"],"mappings":"AAEA;;;CAGC,GACD,OAAO,MAAMA,YAAY,CAACC;IACxB,MAAMC,SAA4B,CAAC;IAEnCD,OAAOE,OAAO,CAAC,CAACC;QACd,MAAMC,WAAWD,MAAME,KAAK,CAAC;QAC7B,IAAIC,YAAYL;QAEhBG,SAASF,OAAO,CAAC,CAACK,SAASC;YACzB,IAAIA,MAAMJ,SAASK,MAAM,GAAG,GAAG;gBAC7BH,SAAS,CAACC,QAAQ,GAAG;YACvB,OAAO;gBACL,IAAI,CAACD,SAAS,CAACC,QAAQ,EAAE;oBACvBD,SAAS,CAACC,QAAQ,GAAG,CAAC;gBACxB;gBACAD,YAAYA,SAAS,CAACC,QAAQ;YAChC;QACF;IACF;IAEA,OAAON;AACT,EAAC"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { CollectionConfig, Config } from 'payload';
|
|
2
|
-
import type { ImportExportPluginConfig } from './types.js';
|
|
3
|
-
export declare const getExportCollection: ({ config, pluginConfig, }: {
|
|
4
|
-
config: Config;
|
|
5
|
-
pluginConfig: ImportExportPluginConfig;
|
|
6
|
-
}) => CollectionConfig;
|
|
7
|
-
//# sourceMappingURL=getExportCollection.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getExportCollection.d.ts","sourceRoot":"","sources":["../src/getExportCollection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,gBAAgB,EAChB,MAAM,EACP,MAAM,SAAS,CAAA;AAEhB,OAAO,KAAK,EAAsB,wBAAwB,EAAE,MAAM,YAAY,CAAA;AAM9E,eAAO,MAAM,mBAAmB,8BAG7B;IACD,MAAM,EAAE,MAAM,CAAA;IACd,YAAY,EAAE,wBAAwB,CAAA;CACvC,KAAG,gBA+EH,CAAA"}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { createExport } from './export/createExport.js';
|
|
2
|
-
import { download } from './export/download.js';
|
|
3
|
-
import { getFields } from './export/getFields.js';
|
|
4
|
-
export const getExportCollection = ({ config, pluginConfig })=>{
|
|
5
|
-
const { overrideExportCollection } = pluginConfig;
|
|
6
|
-
const beforeOperation = [];
|
|
7
|
-
const afterChange = [];
|
|
8
|
-
let collection = {
|
|
9
|
-
slug: 'exports',
|
|
10
|
-
access: {
|
|
11
|
-
update: ()=>false
|
|
12
|
-
},
|
|
13
|
-
admin: {
|
|
14
|
-
components: {
|
|
15
|
-
edit: {
|
|
16
|
-
SaveButton: '@payloadcms/plugin-import-export/rsc#ExportSaveButton'
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
custom: {
|
|
20
|
-
disableDownload: pluginConfig.disableDownload ?? false,
|
|
21
|
-
disableSave: pluginConfig.disableSave ?? false
|
|
22
|
-
},
|
|
23
|
-
group: false,
|
|
24
|
-
useAsTitle: 'name'
|
|
25
|
-
},
|
|
26
|
-
disableDuplicate: true,
|
|
27
|
-
endpoints: [
|
|
28
|
-
{
|
|
29
|
-
handler: (req)=>{
|
|
30
|
-
return download(req, pluginConfig.debug);
|
|
31
|
-
},
|
|
32
|
-
method: 'post',
|
|
33
|
-
path: '/download'
|
|
34
|
-
}
|
|
35
|
-
],
|
|
36
|
-
fields: getFields(config, pluginConfig),
|
|
37
|
-
hooks: {
|
|
38
|
-
afterChange,
|
|
39
|
-
beforeOperation
|
|
40
|
-
},
|
|
41
|
-
upload: {
|
|
42
|
-
filesRequiredOnCreate: false,
|
|
43
|
-
hideFileInputOnCreate: true,
|
|
44
|
-
hideRemoveFile: true
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
if (typeof overrideExportCollection === 'function') {
|
|
48
|
-
collection = overrideExportCollection(collection);
|
|
49
|
-
}
|
|
50
|
-
if (pluginConfig.disableJobsQueue) {
|
|
51
|
-
beforeOperation.push(async ({ args, operation, req })=>{
|
|
52
|
-
if (operation !== 'create') {
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
const { user } = req;
|
|
56
|
-
const debug = pluginConfig.debug;
|
|
57
|
-
await createExport({
|
|
58
|
-
input: {
|
|
59
|
-
...args.data,
|
|
60
|
-
debug
|
|
61
|
-
},
|
|
62
|
-
req,
|
|
63
|
-
user
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
} else {
|
|
67
|
-
afterChange.push(async ({ doc, operation, req })=>{
|
|
68
|
-
if (operation !== 'create') {
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
const input = {
|
|
72
|
-
...doc,
|
|
73
|
-
exportsCollection: collection.slug,
|
|
74
|
-
user: req?.user?.id || req?.user?.user?.id,
|
|
75
|
-
userCollection: req.payload.config.admin.user
|
|
76
|
-
};
|
|
77
|
-
await req.payload.jobs.queue({
|
|
78
|
-
input,
|
|
79
|
-
task: 'createCollectionExport'
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
return collection;
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
//# sourceMappingURL=getExportCollection.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/getExportCollection.ts"],"sourcesContent":["import type {\n CollectionAfterChangeHook,\n CollectionBeforeOperationHook,\n CollectionConfig,\n Config,\n} from 'payload'\n\nimport type { CollectionOverride, ImportExportPluginConfig } from './types.js'\n\nimport { createExport } from './export/createExport.js'\nimport { download } from './export/download.js'\nimport { getFields } from './export/getFields.js'\n\nexport const getExportCollection = ({\n config,\n pluginConfig,\n}: {\n config: Config\n pluginConfig: ImportExportPluginConfig\n}): CollectionConfig => {\n const { overrideExportCollection } = pluginConfig\n\n const beforeOperation: CollectionBeforeOperationHook[] = []\n const afterChange: CollectionAfterChangeHook[] = []\n\n let collection: CollectionOverride = {\n slug: 'exports',\n access: {\n update: () => false,\n },\n admin: {\n components: {\n edit: {\n SaveButton: '@payloadcms/plugin-import-export/rsc#ExportSaveButton',\n },\n },\n custom: {\n disableDownload: pluginConfig.disableDownload ?? false,\n disableSave: pluginConfig.disableSave ?? false,\n },\n group: false,\n useAsTitle: 'name',\n },\n disableDuplicate: true,\n endpoints: [\n {\n handler: (req) => {\n return download(req, pluginConfig.debug)\n },\n method: 'post',\n path: '/download',\n },\n ],\n fields: getFields(config, pluginConfig),\n hooks: {\n afterChange,\n beforeOperation,\n },\n upload: {\n filesRequiredOnCreate: false,\n hideFileInputOnCreate: true,\n hideRemoveFile: true,\n },\n }\n\n if (typeof overrideExportCollection === 'function') {\n collection = overrideExportCollection(collection)\n }\n\n if (pluginConfig.disableJobsQueue) {\n beforeOperation.push(async ({ args, operation, req }) => {\n if (operation !== 'create') {\n return\n }\n const { user } = req\n const debug = pluginConfig.debug\n await createExport({ input: { ...args.data, debug } as any, req, user })\n })\n } else {\n afterChange.push(async ({ doc, operation, req }) => {\n if (operation !== 'create') {\n return\n }\n\n const input = {\n ...doc,\n exportsCollection: collection.slug,\n user: req?.user?.id || req?.user?.user?.id,\n userCollection: req.payload.config.admin.user,\n }\n await req.payload.jobs.queue({\n input,\n task: 'createCollectionExport',\n })\n })\n }\n\n return collection\n}\n"],"names":["createExport","download","getFields","getExportCollection","config","pluginConfig","overrideExportCollection","beforeOperation","afterChange","collection","slug","access","update","admin","components","edit","SaveButton","custom","disableDownload","disableSave","group","useAsTitle","disableDuplicate","endpoints","handler","req","debug","method","path","fields","hooks","upload","filesRequiredOnCreate","hideFileInputOnCreate","hideRemoveFile","disableJobsQueue","push","args","operation","user","input","data","doc","exportsCollection","id","userCollection","payload","jobs","queue","task"],"mappings":"AASA,SAASA,YAAY,QAAQ,2BAA0B;AACvD,SAASC,QAAQ,QAAQ,uBAAsB;AAC/C,SAASC,SAAS,QAAQ,wBAAuB;AAEjD,OAAO,MAAMC,sBAAsB,CAAC,EAClCC,MAAM,EACNC,YAAY,EAIb;IACC,MAAM,EAAEC,wBAAwB,EAAE,GAAGD;IAErC,MAAME,kBAAmD,EAAE;IAC3D,MAAMC,cAA2C,EAAE;IAEnD,IAAIC,aAAiC;QACnCC,MAAM;QACNC,QAAQ;YACNC,QAAQ,IAAM;QAChB;QACAC,OAAO;YACLC,YAAY;gBACVC,MAAM;oBACJC,YAAY;gBACd;YACF;YACAC,QAAQ;gBACNC,iBAAiBb,aAAaa,eAAe,IAAI;gBACjDC,aAAad,aA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