@payloadcms/plugin-import-export 4.0.0-internal.38b7f1d → 4.0.0-internal.4c792ad
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/@types/assets.d.js +2 -0
- package/dist/@types/assets.d.js.map +1 -0
- package/dist/components/FieldsToExport/reduceFields.d.ts.map +1 -1
- package/dist/components/ImportPreview/index.d.ts.map +1 -1
- package/dist/components/ImportPreview/index.js +16 -2
- package/dist/components/ImportPreview/index.js.map +1 -1
- package/dist/export/createExport.d.ts.map +1 -1
- package/dist/export/getCreateExportCollectionTask.d.ts.map +1 -1
- package/dist/export/getExportCollection.d.ts.map +1 -1
- package/dist/export/getFields.d.ts.map +1 -1
- package/dist/export/handleDownload.d.ts.map +1 -1
- package/dist/export/handlePreview.d.ts.map +1 -1
- package/dist/export/handlePreview.js +1 -1
- 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/createImport.d.ts.map +1 -1
- package/dist/import/createImport.js +1 -1
- package/dist/import/createImport.js.map +1 -1
- package/dist/import/getCreateImportCollectionTask.d.ts.map +1 -1
- package/dist/import/getFields.d.ts.map +1 -1
- package/dist/import/getImportCollection.d.ts.map +1 -1
- package/dist/import/handlePreview.d.ts.map +1 -1
- package/dist/index.d.ts +1 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -5
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +0 -32
- 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/buildDisabledFieldRegex.d.ts.map +1 -1
- package/dist/utilities/collectDisabledFieldPaths.d.ts.map +1 -1
- package/dist/utilities/fieldToRegex.d.ts.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.d.ts.map +1 -1
- package/dist/utilities/getExportFieldFunctions.js +0 -8
- package/dist/utilities/getExportFieldFunctions.js.map +1 -1
- package/dist/utilities/getFileFromDoc.d.ts.map +1 -1
- package/dist/utilities/getFlattenedFieldKeys.d.ts.map +1 -1
- package/dist/utilities/getImportFieldFunctions.d.ts.map +1 -1
- package/dist/utilities/getImportFieldFunctions.js +0 -8
- package/dist/utilities/getImportFieldFunctions.js.map +1 -1
- package/dist/utilities/getPluginCollections.d.ts.map +1 -1
- package/dist/utilities/getSchemaColumns.d.ts +1 -1
- package/dist/utilities/getSchemaColumns.d.ts.map +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/isPlainObject.d.ts.map +1 -1
- package/dist/utilities/parseCSV.d.ts.map +1 -1
- package/dist/utilities/parseJSON.d.ts.map +1 -1
- package/dist/utilities/polymorphicRel.d.ts.map +1 -1
- 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/processRichTextField.spec.js +308 -0
- package/dist/utilities/processRichTextField.spec.js.map +1 -0
- package/dist/utilities/removeDisabledFields.d.ts.map +1 -1
- package/dist/utilities/setNestedValue.d.ts.map +1 -1
- package/dist/utilities/sortHelpers.d.ts.map +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/unflattenObject.spec.js +106 -0
- package/dist/utilities/unflattenObject.spec.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/dist/utilities/validateLimitValue.d.ts.map +1 -1
- package/package.json +8 -8
- package/dist/utilities/legacyHookDispatch.spec.js +0 -227
- package/dist/utilities/legacyHookDispatch.spec.js.map +0 -1
|
@@ -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,
|
|
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.
|
|
3
|
+
"version": "4.0.0-internal.4c792ad",
|
|
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/
|
|
68
|
-
"@payloadcms/
|
|
67
|
+
"@payloadcms/ui": "4.0.0-internal.4c792ad",
|
|
68
|
+
"@payloadcms/translations": "4.0.0-internal.4c792ad"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
|
-
"@payloadcms/
|
|
72
|
-
"
|
|
73
|
-
"
|
|
71
|
+
"@payloadcms/eslint-config": "3.28.0",
|
|
72
|
+
"@payloadcms/ui": "4.0.0-internal.4c792ad",
|
|
73
|
+
"payload": "4.0.0-internal.4c792ad"
|
|
74
74
|
},
|
|
75
75
|
"peerDependencies": {
|
|
76
|
-
"@payloadcms/ui": "4.0.0-internal.
|
|
77
|
-
"payload": "4.0.0-internal.
|
|
76
|
+
"@payloadcms/ui": "4.0.0-internal.4c792ad",
|
|
77
|
+
"payload": "4.0.0-internal.4c792ad"
|
|
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,EAAEC,MAAM,EAAEC,EAAE,EAAEC,EAAE,QAAQ,SAAQ;AAEjD,MAAMC,UAAU;IACdC,SAAS;QACPC,QAAQ;YACNC,OAAOJ,GAAGK,EAAE;QACd;IACF;AACF;AAEAR,SAAS,yCAAyC;IAChDA,SAAS,oEAAoE;QAC3EE,GAAG,+FAA+F;YAChG,MAAMO,WAA2C,EAAE;YAEnD,MAAMC,SAA2B;gBAC/B;oB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