@payloadcms/plugin-import-export 4.0.0-internal.cc18726 → 4.0.0-internal.cd47d20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/CollectionField/index.d.ts +3 -2
- package/dist/components/CollectionField/index.d.ts.map +1 -1
- package/dist/components/CollectionField/index.js.map +1 -1
- package/dist/components/ExportListMenuItem/index.d.ts.map +1 -1
- package/dist/components/ExportListMenuItem/index.js +14 -12
- package/dist/components/ExportListMenuItem/index.js.map +1 -1
- package/dist/components/ExportPreview/index.d.ts.map +1 -1
- package/dist/components/ExportPreview/index.js +11 -1
- package/dist/components/ExportPreview/index.js.map +1 -1
- package/dist/components/FieldsToExport/index.d.ts +3 -2
- package/dist/components/FieldsToExport/index.d.ts.map +1 -1
- package/dist/components/FieldsToExport/index.js.map +1 -1
- package/dist/components/FormatField/index.d.ts +3 -2
- package/dist/components/FormatField/index.d.ts.map +1 -1
- package/dist/components/FormatField/index.js.map +1 -1
- package/dist/components/ImportListMenuItem/index.d.ts.map +1 -1
- package/dist/components/ImportListMenuItem/index.js +14 -12
- package/dist/components/ImportListMenuItem/index.js.map +1 -1
- package/dist/components/ImportPreview/index.d.ts.map +1 -1
- package/dist/components/ImportPreview/index.js +17 -1
- package/dist/components/ImportPreview/index.js.map +1 -1
- package/dist/components/LimitField/index.d.ts +3 -2
- package/dist/components/LimitField/index.d.ts.map +1 -1
- package/dist/components/LimitField/index.js.map +1 -1
- package/dist/components/LocaleField/index.d.ts +3 -2
- package/dist/components/LocaleField/index.d.ts.map +1 -1
- package/dist/components/LocaleField/index.js.map +1 -1
- package/dist/components/Page/index.d.ts +3 -2
- package/dist/components/Page/index.d.ts.map +1 -1
- package/dist/components/Page/index.js.map +1 -1
- package/dist/components/SortBy/index.d.ts +3 -2
- package/dist/components/SortBy/index.d.ts.map +1 -1
- package/dist/components/SortBy/index.js.map +1 -1
- package/dist/components/SortOrder/index.d.ts +3 -2
- package/dist/components/SortOrder/index.d.ts.map +1 -1
- package/dist/components/SortOrder/index.js.map +1 -1
- package/dist/export/batchProcessor.d.ts +2 -1
- package/dist/export/batchProcessor.d.ts.map +1 -1
- package/dist/export/batchProcessor.js +6 -2
- package/dist/export/batchProcessor.js.map +1 -1
- package/dist/export/createExport.d.ts +2 -0
- package/dist/export/createExport.d.ts.map +1 -1
- package/dist/export/createExport.js +6 -1
- package/dist/export/createExport.js.map +1 -1
- package/dist/export/getCreateExportCollectionTask.d.ts.map +1 -1
- package/dist/export/getCreateExportCollectionTask.js +11 -0
- package/dist/export/getCreateExportCollectionTask.js.map +1 -1
- package/dist/export/getExportCollection.d.ts.map +1 -1
- package/dist/export/getExportCollection.js +5 -0
- package/dist/export/getExportCollection.js.map +1 -1
- package/dist/export/handleDownload.d.ts.map +1 -1
- package/dist/export/handleDownload.js +7 -3
- package/dist/export/handleDownload.js.map +1 -1
- package/dist/export/handlePreview.d.ts.map +1 -1
- package/dist/export/handlePreview.js +23 -4
- package/dist/export/handlePreview.js.map +1 -1
- package/dist/exports/types.d.ts +1 -1
- package/dist/exports/types.d.ts.map +1 -1
- package/dist/exports/types.js.map +1 -1
- package/dist/import/batchProcessor.d.ts +2 -1
- package/dist/import/batchProcessor.d.ts.map +1 -1
- package/dist/import/batchProcessor.js +15 -8
- package/dist/import/batchProcessor.js.map +1 -1
- package/dist/import/createImport.d.ts +3 -2
- package/dist/import/createImport.d.ts.map +1 -1
- package/dist/import/createImport.js +8 -1
- package/dist/import/createImport.js.map +1 -1
- package/dist/import/getCreateImportCollectionTask.d.ts.map +1 -1
- package/dist/import/getCreateImportCollectionTask.js +5 -2
- package/dist/import/getCreateImportCollectionTask.js.map +1 -1
- package/dist/import/getImportCollection.d.ts.map +1 -1
- package/dist/import/getImportCollection.js +2 -0
- package/dist/import/getImportCollection.js.map +1 -1
- package/dist/import/handlePreview.d.ts.map +1 -1
- package/dist/import/handlePreview.js +5 -1
- package/dist/import/handlePreview.js.map +1 -1
- package/dist/types.d.ts +17 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utilities/getFileFromDoc.js +3 -3
- package/dist/utilities/getFileFromDoc.js.map +1 -1
- package/dist/utilities/getSelect.d.ts.map +1 -1
- package/dist/utilities/getSelect.js +4 -2
- package/dist/utilities/getSelect.js.map +1 -1
- package/dist/utilities/getSubmittedFormValues.d.ts +12 -0
- package/dist/utilities/getSubmittedFormValues.d.ts.map +1 -0
- package/dist/utilities/getSubmittedFormValues.js +24 -0
- package/dist/utilities/getSubmittedFormValues.js.map +1 -0
- package/dist/utilities/setNestedValue.d.ts.map +1 -1
- package/dist/utilities/setNestedValue.js +20 -6
- package/dist/utilities/setNestedValue.js.map +1 -1
- package/package.json +8 -8
- package/dist/components/FieldsToExport/reduceFields.spec.js +0 -239
- package/dist/components/FieldsToExport/reduceFields.spec.js.map +0 -1
- package/dist/utilities/applyFieldHooks.spec.js +0 -205
- package/dist/utilities/applyFieldHooks.spec.js.map +0 -1
- package/dist/utilities/buildDisabledFieldRegex.spec.js +0 -64
- package/dist/utilities/buildDisabledFieldRegex.spec.js.map +0 -1
- package/dist/utilities/fieldPath.d.ts +0 -2
- package/dist/utilities/fieldPath.d.ts.map +0 -1
- package/dist/utilities/fieldPath.js +0 -8
- package/dist/utilities/fieldPath.js.map +0 -1
- package/dist/utilities/fieldToRegex.spec.js +0 -151
- package/dist/utilities/fieldToRegex.spec.js.map +0 -1
- package/dist/utilities/filterToSelectedFields.spec.js +0 -204
- package/dist/utilities/filterToSelectedFields.spec.js.map +0 -1
- package/dist/utilities/flattenObject.spec.js +0 -158
- package/dist/utilities/flattenObject.spec.js.map +0 -1
- package/dist/utilities/getExportFieldFunctions.spec.js +0 -50
- package/dist/utilities/getExportFieldFunctions.spec.js.map +0 -1
- package/dist/utilities/getImportFieldFunctions.spec.js +0 -167
- package/dist/utilities/getImportFieldFunctions.spec.js.map +0 -1
- package/dist/utilities/getSchemaColumns.spec.js +0 -157
- package/dist/utilities/getSchemaColumns.spec.js.map +0 -1
- package/dist/utilities/getSelect.spec.js +0 -70
- package/dist/utilities/getSelect.spec.js.map +0 -1
- package/dist/utilities/parseCSV.spec.js +0 -195
- package/dist/utilities/parseCSV.spec.js.map +0 -1
- package/dist/utilities/processRichTextField.spec.js +0 -308
- package/dist/utilities/processRichTextField.spec.js.map +0 -1
- package/dist/utilities/setNestedValue.spec.js +0 -164
- package/dist/utilities/setNestedValue.spec.js.map +0 -1
- package/dist/utilities/siblingDoc.spec.js +0 -278
- package/dist/utilities/siblingDoc.spec.js.map +0 -1
- package/dist/utilities/unflattenObject.spec.js +0 -819
- package/dist/utilities/unflattenObject.spec.js.map +0 -1
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.cd47d20",
|
|
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.
|
|
68
|
-
"@payloadcms/ui": "4.0.0-internal.
|
|
67
|
+
"@payloadcms/translations": "4.0.0-internal.cd47d20",
|
|
68
|
+
"@payloadcms/ui": "4.0.0-internal.cd47d20"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
71
|
"@payloadcms/eslint-config": "3.28.0",
|
|
72
|
-
"@payloadcms/ui": "4.0.0-internal.
|
|
73
|
-
"payload": "4.0.0-internal.
|
|
72
|
+
"@payloadcms/ui": "4.0.0-internal.cd47d20",
|
|
73
|
+
"payload": "4.0.0-internal.cd47d20"
|
|
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.cd47d20",
|
|
77
|
+
"payload": "4.0.0-internal.cd47d20"
|
|
78
78
|
},
|
|
79
79
|
"homepage:": "https://payloadcms.com",
|
|
80
80
|
"scripts": {
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
"build:swc": "swc ./src -d ./dist --config-file .swcrc --strip-leading-paths",
|
|
84
84
|
"build:types": "tsc --emitDeclarationOnly --outDir dist",
|
|
85
85
|
"clean": "rimraf {dist,*.tsbuildinfo}",
|
|
86
|
-
"copyfiles": "copyfiles -u 1 \"src/**/*.{html,css,scss,ttf,woff,woff2,eot,svg,jpg,png,json}\" dist/",
|
|
86
|
+
"copyfiles": "copyfiles -u 1 -e \"**/*.spec.*\" \"src/**/*.{html,css,scss,ttf,woff,woff2,eot,svg,jpg,png,json}\" dist/",
|
|
87
87
|
"lint": "eslint .",
|
|
88
88
|
"lint:fix": "eslint . --fix"
|
|
89
89
|
}
|
|
@@ -1,239 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { reduceFields } from './reduceFields.js';
|
|
3
|
-
const values = (result)=>result.map((f)=>f.value);
|
|
4
|
-
describe('reduceFields', ()=>{
|
|
5
|
-
describe('excludeUnsortable', ()=>{
|
|
6
|
-
it('should include array and blocks fields by default', ()=>{
|
|
7
|
-
const fields = [
|
|
8
|
-
{
|
|
9
|
-
name: 'title',
|
|
10
|
-
type: 'text'
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
name: 'items',
|
|
14
|
-
type: 'array',
|
|
15
|
-
fields: [
|
|
16
|
-
{
|
|
17
|
-
name: 'text',
|
|
18
|
-
type: 'text'
|
|
19
|
-
}
|
|
20
|
-
]
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
name: 'layout',
|
|
24
|
-
type: 'blocks',
|
|
25
|
-
blocks: []
|
|
26
|
-
}
|
|
27
|
-
];
|
|
28
|
-
const result = values(reduceFields({
|
|
29
|
-
fields
|
|
30
|
-
}));
|
|
31
|
-
expect(result).toContain('title');
|
|
32
|
-
expect(result).toContain('items');
|
|
33
|
-
expect(result).toContain('layout');
|
|
34
|
-
});
|
|
35
|
-
it('should exclude array fields when excludeUnsortable is true', ()=>{
|
|
36
|
-
const fields = [
|
|
37
|
-
{
|
|
38
|
-
name: 'title',
|
|
39
|
-
type: 'text'
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
name: 'items',
|
|
43
|
-
type: 'array',
|
|
44
|
-
fields: [
|
|
45
|
-
{
|
|
46
|
-
name: 'text',
|
|
47
|
-
type: 'text'
|
|
48
|
-
}
|
|
49
|
-
]
|
|
50
|
-
}
|
|
51
|
-
];
|
|
52
|
-
const result = values(reduceFields({
|
|
53
|
-
excludeUnsortable: true,
|
|
54
|
-
fields
|
|
55
|
-
}));
|
|
56
|
-
expect(result).toContain('title');
|
|
57
|
-
expect(result).not.toContain('items');
|
|
58
|
-
});
|
|
59
|
-
it('should exclude blocks fields when excludeUnsortable is true', ()=>{
|
|
60
|
-
const fields = [
|
|
61
|
-
{
|
|
62
|
-
name: 'title',
|
|
63
|
-
type: 'text'
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
name: 'layout',
|
|
67
|
-
type: 'blocks',
|
|
68
|
-
blocks: []
|
|
69
|
-
}
|
|
70
|
-
];
|
|
71
|
-
const result = values(reduceFields({
|
|
72
|
-
excludeUnsortable: true,
|
|
73
|
-
fields
|
|
74
|
-
}));
|
|
75
|
-
expect(result).toContain('title');
|
|
76
|
-
expect(result).not.toContain('layout');
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
describe('disabledFields', ()=>{
|
|
80
|
-
it('should include all fields when disabledFields is empty', ()=>{
|
|
81
|
-
const fields = [
|
|
82
|
-
{
|
|
83
|
-
name: 'title',
|
|
84
|
-
type: 'text'
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
name: 'slug',
|
|
88
|
-
type: 'text'
|
|
89
|
-
}
|
|
90
|
-
];
|
|
91
|
-
const result = values(reduceFields({
|
|
92
|
-
disabledFields: [],
|
|
93
|
-
fields
|
|
94
|
-
}));
|
|
95
|
-
expect(result).toContain('title');
|
|
96
|
-
expect(result).toContain('slug');
|
|
97
|
-
});
|
|
98
|
-
it('should exclude a field whose path is in disabledFields', ()=>{
|
|
99
|
-
const fields = [
|
|
100
|
-
{
|
|
101
|
-
name: 'title',
|
|
102
|
-
type: 'text'
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
name: 'slug',
|
|
106
|
-
type: 'text'
|
|
107
|
-
}
|
|
108
|
-
];
|
|
109
|
-
const result = values(reduceFields({
|
|
110
|
-
disabledFields: [
|
|
111
|
-
'slug'
|
|
112
|
-
],
|
|
113
|
-
fields
|
|
114
|
-
}));
|
|
115
|
-
expect(result).toContain('title');
|
|
116
|
-
expect(result).not.toContain('slug');
|
|
117
|
-
});
|
|
118
|
-
it('should exclude nested fields whose paths start with a disabled parent path', ()=>{
|
|
119
|
-
const fields = [
|
|
120
|
-
{
|
|
121
|
-
name: 'meta',
|
|
122
|
-
type: 'group',
|
|
123
|
-
fields: [
|
|
124
|
-
{
|
|
125
|
-
name: 'title',
|
|
126
|
-
type: 'text'
|
|
127
|
-
},
|
|
128
|
-
{
|
|
129
|
-
name: 'description',
|
|
130
|
-
type: 'text'
|
|
131
|
-
}
|
|
132
|
-
]
|
|
133
|
-
}
|
|
134
|
-
];
|
|
135
|
-
const result = values(reduceFields({
|
|
136
|
-
disabledFields: [
|
|
137
|
-
'meta.description'
|
|
138
|
-
],
|
|
139
|
-
fields
|
|
140
|
-
}));
|
|
141
|
-
expect(result).toContain('meta.title');
|
|
142
|
-
expect(result).not.toContain('meta.description');
|
|
143
|
-
});
|
|
144
|
-
});
|
|
145
|
-
describe('combined excludeUnsortable and disabledFields', ()=>{
|
|
146
|
-
it('should apply both filters simultaneously', ()=>{
|
|
147
|
-
const fields = [
|
|
148
|
-
{
|
|
149
|
-
name: 'title',
|
|
150
|
-
type: 'text'
|
|
151
|
-
},
|
|
152
|
-
{
|
|
153
|
-
name: 'slug',
|
|
154
|
-
type: 'text'
|
|
155
|
-
},
|
|
156
|
-
{
|
|
157
|
-
name: 'items',
|
|
158
|
-
type: 'array',
|
|
159
|
-
fields: [
|
|
160
|
-
{
|
|
161
|
-
name: 'text',
|
|
162
|
-
type: 'text'
|
|
163
|
-
}
|
|
164
|
-
]
|
|
165
|
-
}
|
|
166
|
-
];
|
|
167
|
-
const result = values(reduceFields({
|
|
168
|
-
disabledFields: [
|
|
169
|
-
'slug'
|
|
170
|
-
],
|
|
171
|
-
excludeUnsortable: true,
|
|
172
|
-
fields
|
|
173
|
-
}));
|
|
174
|
-
expect(result).toContain('title');
|
|
175
|
-
expect(result).not.toContain('slug');
|
|
176
|
-
expect(result).not.toContain('items');
|
|
177
|
-
});
|
|
178
|
-
});
|
|
179
|
-
describe('recursive propagation through group sub-fields', ()=>{
|
|
180
|
-
it('should propagate excludeUnsortable into group sub-fields', ()=>{
|
|
181
|
-
const fields = [
|
|
182
|
-
{
|
|
183
|
-
name: 'meta',
|
|
184
|
-
type: 'group',
|
|
185
|
-
fields: [
|
|
186
|
-
{
|
|
187
|
-
name: 'title',
|
|
188
|
-
type: 'text'
|
|
189
|
-
},
|
|
190
|
-
{
|
|
191
|
-
name: 'tags',
|
|
192
|
-
type: 'array',
|
|
193
|
-
fields: [
|
|
194
|
-
{
|
|
195
|
-
name: 'tag',
|
|
196
|
-
type: 'text'
|
|
197
|
-
}
|
|
198
|
-
]
|
|
199
|
-
}
|
|
200
|
-
]
|
|
201
|
-
}
|
|
202
|
-
];
|
|
203
|
-
const result = values(reduceFields({
|
|
204
|
-
excludeUnsortable: true,
|
|
205
|
-
fields
|
|
206
|
-
}));
|
|
207
|
-
expect(result).toContain('meta.title');
|
|
208
|
-
expect(result).not.toContain('meta.tags');
|
|
209
|
-
});
|
|
210
|
-
it('should propagate disabledFields into group sub-fields', ()=>{
|
|
211
|
-
const fields = [
|
|
212
|
-
{
|
|
213
|
-
name: 'meta',
|
|
214
|
-
type: 'group',
|
|
215
|
-
fields: [
|
|
216
|
-
{
|
|
217
|
-
name: 'title',
|
|
218
|
-
type: 'text'
|
|
219
|
-
},
|
|
220
|
-
{
|
|
221
|
-
name: 'description',
|
|
222
|
-
type: 'text'
|
|
223
|
-
}
|
|
224
|
-
]
|
|
225
|
-
}
|
|
226
|
-
];
|
|
227
|
-
const result = values(reduceFields({
|
|
228
|
-
disabledFields: [
|
|
229
|
-
'meta.description'
|
|
230
|
-
],
|
|
231
|
-
fields
|
|
232
|
-
}));
|
|
233
|
-
expect(result).toContain('meta.title');
|
|
234
|
-
expect(result).not.toContain('meta.description');
|
|
235
|
-
});
|
|
236
|
-
});
|
|
237
|
-
});
|
|
238
|
-
|
|
239
|
-
//# sourceMappingURL=reduceFields.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/FieldsToExport/reduceFields.spec.ts"],"sourcesContent":["import type { ClientField } from 'payload'\n\nimport { describe, expect, it } from 'vitest'\n\nimport { reduceFields } from './reduceFields.js'\n\nconst values = (result: ReturnType<typeof reduceFields>) => result.map((f) => f.value)\n\ndescribe('reduceFields', () => {\n describe('excludeUnsortable', () => {\n it('should include array and blocks fields by default', () => {\n const fields: ClientField[] = [\n { name: 'title', type: 'text' },\n { name: 'items', type: 'array', fields: [{ name: 'text', type: 'text' }] },\n { name: 'layout', type: 'blocks', blocks: [] },\n ]\n\n const result = values(reduceFields({ fields }))\n\n expect(result).toContain('title')\n expect(result).toContain('items')\n expect(result).toContain('layout')\n })\n\n it('should exclude array fields when excludeUnsortable is true', () => {\n const fields: ClientField[] = [\n { name: 'title', type: 'text' },\n { name: 'items', type: 'array', fields: [{ name: 'text', type: 'text' }] },\n ]\n\n const result = values(reduceFields({ excludeUnsortable: true, fields }))\n\n expect(result).toContain('title')\n expect(result).not.toContain('items')\n })\n\n it('should exclude blocks fields when excludeUnsortable is true', () => {\n const fields: ClientField[] = [\n { name: 'title', type: 'text' },\n { name: 'layout', type: 'blocks', blocks: [] },\n ]\n\n const result = values(reduceFields({ excludeUnsortable: true, fields }))\n\n expect(result).toContain('title')\n expect(result).not.toContain('layout')\n })\n })\n\n describe('disabledFields', () => {\n it('should include all fields when disabledFields is empty', () => {\n const fields: ClientField[] = [\n { name: 'title', type: 'text' },\n { name: 'slug', type: 'text' },\n ]\n\n const result = values(reduceFields({ disabledFields: [], fields }))\n\n expect(result).toContain('title')\n expect(result).toContain('slug')\n })\n\n it('should exclude a field whose path is in disabledFields', () => {\n const fields: ClientField[] = [\n { name: 'title', type: 'text' },\n { name: 'slug', type: 'text' },\n ]\n\n const result = values(reduceFields({ disabledFields: ['slug'], fields }))\n\n expect(result).toContain('title')\n expect(result).not.toContain('slug')\n })\n\n it('should exclude nested fields whose paths start with a disabled parent path', () => {\n const fields: ClientField[] = [\n {\n name: 'meta',\n type: 'group',\n fields: [\n { name: 'title', type: 'text' },\n { name: 'description', type: 'text' },\n ],\n },\n ]\n\n const result = values(reduceFields({ disabledFields: ['meta.description'], fields }))\n\n expect(result).toContain('meta.title')\n expect(result).not.toContain('meta.description')\n })\n })\n\n describe('combined excludeUnsortable and disabledFields', () => {\n it('should apply both filters simultaneously', () => {\n const fields: ClientField[] = [\n { name: 'title', type: 'text' },\n { name: 'slug', type: 'text' },\n { name: 'items', type: 'array', fields: [{ name: 'text', type: 'text' }] },\n ]\n\n const result = values(\n reduceFields({ disabledFields: ['slug'], excludeUnsortable: true, fields }),\n )\n\n expect(result).toContain('title')\n expect(result).not.toContain('slug')\n expect(result).not.toContain('items')\n })\n })\n\n describe('recursive propagation through group sub-fields', () => {\n it('should propagate excludeUnsortable into group sub-fields', () => {\n const fields: ClientField[] = [\n {\n name: 'meta',\n type: 'group',\n fields: [\n { name: 'title', type: 'text' },\n { name: 'tags', type: 'array', fields: [{ name: 'tag', type: 'text' }] },\n ],\n },\n ]\n\n const result = values(reduceFields({ excludeUnsortable: true, fields }))\n\n expect(result).toContain('meta.title')\n expect(result).not.toContain('meta.tags')\n })\n\n it('should propagate disabledFields into group sub-fields', () => {\n const fields: ClientField[] = [\n {\n name: 'meta',\n type: 'group',\n fields: [\n { name: 'title', type: 'text' },\n { name: 'description', type: 'text' },\n ],\n },\n ]\n\n const result = values(reduceFields({ disabledFields: ['meta.description'], fields }))\n\n expect(result).toContain('meta.title')\n expect(result).not.toContain('meta.description')\n })\n })\n})\n"],"names":["describe","expect","it","reduceFields","values","result","map","f","value","fields","name","type","blocks","toContain","excludeUnsortable","not","disabledFields"],"mappings":"AAEA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,SAAQ;AAE7C,SAASC,YAAY,QAAQ,oBAAmB;AAEhD,MAAMC,SAAS,CAACC,SAA4CA,OAAOC,GAAG,CAAC,CAACC,IAAMA,EAAEC,KAAK;AAErFR,SAAS,gBAAgB;IACvBA,SAAS,qBAAqB;QAC5BE,GAAG,qDAAqD;YACtD,MAAMO,SAAwB;gBAC5B;oBAAEC,MAAM;oBAASC,MAAM;gBAAO;gBAC9B;oBAAED,MAAM;oBAASC,MAAM;oBAASF,QAAQ;wBAAC;4BAAEC,MAAM;4BAAQC,MAAM;wBAAO;qBAAE;gBAAC;gBACzE;oBAAED,MAAM;oBAAUC,MAAM;oBAAUC,QAAQ,EAAE;gBAAC;aAC9C;YAED,MAAMP,SAASD,OAAOD,aAAa;gBAAEM;YAAO;YAE5CR,OAAOI,QAAQQ,SAAS,CAAC;YACzBZ,OAAOI,QAAQQ,SAAS,CAAC;YACzBZ,OAAOI,QAAQQ,SAAS,CAAC;QAC3B;QAEAX,GAAG,8DAA8D;YAC/D,MAAMO,SAAwB;gBAC5B;oBAAEC,MAAM;oBAASC,MAAM;gBAAO;gBAC9B;oBAAED,MAAM;oBAASC,MAAM;oBAASF,QAAQ;wBAAC;4BAAEC,MAAM;4BAAQC,MAAM;wBAAO;qBAAE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ACNF,QAAQ;wBACN;4BAAEC,MAAM;4BAASC,MAAM;wBAAO;wBAC9B;4BAAED,MAAM;4BAAeC,MAAM;wBAAO;qBACrC;gBACH;aACD;YAED,MAAMN,SAASD,OAAOD,aAAa;gBAAEa,gBAAgB;oBAAC;iBAAmB;gBAAEP;YAAO;YAElFR,OAAOI,QAAQQ,SAAS,CAAC;YACzBZ,OAAOI,QAAQU,GAAG,CAACF,SAAS,CAAC;QAC/B;IACF;AACF"}
|
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it, vi } from 'vitest';
|
|
2
|
-
import { applyFieldHooks } from './applyFieldHooks.js';
|
|
3
|
-
const mockReq = {
|
|
4
|
-
payload: {
|
|
5
|
-
logger: {
|
|
6
|
-
error: vi.fn()
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
describe('applyFieldHooks parent + child traversal', ()=>{
|
|
11
|
-
it('should run a parent group hook and still run child field hooks against the transformed value (export)', ()=>{
|
|
12
|
-
const fields = [
|
|
13
|
-
{
|
|
14
|
-
name: 'meta',
|
|
15
|
-
type: 'group',
|
|
16
|
-
flattenedFields: [
|
|
17
|
-
{
|
|
18
|
-
name: 'slug',
|
|
19
|
-
type: 'text'
|
|
20
|
-
}
|
|
21
|
-
]
|
|
22
|
-
}
|
|
23
|
-
];
|
|
24
|
-
const fieldHooks = {
|
|
25
|
-
meta: {
|
|
26
|
-
type: 'beforeExport',
|
|
27
|
-
fn: ({ value })=>{
|
|
28
|
-
const obj = value ?? {};
|
|
29
|
-
return {
|
|
30
|
-
...obj,
|
|
31
|
-
slug: `${obj.slug ?? ''}-from-parent`
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
meta_slug: {
|
|
36
|
-
type: 'beforeExport',
|
|
37
|
-
fn: ({ value })=>`${value}-from-child`
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
const result = applyFieldHooks({
|
|
41
|
-
type: 'beforeExport',
|
|
42
|
-
data: {
|
|
43
|
-
meta: {
|
|
44
|
-
slug: 'raw'
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
fieldHooks,
|
|
48
|
-
fields,
|
|
49
|
-
format: 'json',
|
|
50
|
-
operation: 'export',
|
|
51
|
-
req: mockReq
|
|
52
|
-
});
|
|
53
|
-
// Parent hook ran first ('raw' → 'raw-from-parent'), then child hook ran against
|
|
54
|
-
// the transformed value ('raw-from-parent' → 'raw-from-parent-from-child').
|
|
55
|
-
expect(result.meta).toEqual({
|
|
56
|
-
slug: 'raw-from-parent-from-child'
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
it('should run a parent group hook and still run child field hooks (import)', ()=>{
|
|
60
|
-
const fields = [
|
|
61
|
-
{
|
|
62
|
-
name: 'meta',
|
|
63
|
-
type: 'group',
|
|
64
|
-
flattenedFields: [
|
|
65
|
-
{
|
|
66
|
-
name: 'slug',
|
|
67
|
-
type: 'text'
|
|
68
|
-
}
|
|
69
|
-
]
|
|
70
|
-
}
|
|
71
|
-
];
|
|
72
|
-
const fieldHooks = {
|
|
73
|
-
meta: {
|
|
74
|
-
type: 'beforeImport',
|
|
75
|
-
fn: ({ value })=>{
|
|
76
|
-
const obj = value ?? {};
|
|
77
|
-
return {
|
|
78
|
-
...obj,
|
|
79
|
-
slug: `${obj.slug ?? ''}-from-parent`
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
},
|
|
83
|
-
meta_slug: {
|
|
84
|
-
type: 'beforeImport',
|
|
85
|
-
fn: ({ value })=>`${value}-from-child`
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
const result = applyFieldHooks({
|
|
89
|
-
type: 'beforeImport',
|
|
90
|
-
data: {
|
|
91
|
-
meta: {
|
|
92
|
-
slug: 'raw'
|
|
93
|
-
}
|
|
94
|
-
},
|
|
95
|
-
fieldHooks,
|
|
96
|
-
fields,
|
|
97
|
-
format: 'json',
|
|
98
|
-
operation: 'import',
|
|
99
|
-
req: mockReq
|
|
100
|
-
});
|
|
101
|
-
expect(result.meta).toEqual({
|
|
102
|
-
slug: 'raw-from-parent-from-child'
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
it('should run a parent array hook then child hooks for each item', ()=>{
|
|
106
|
-
const fields = [
|
|
107
|
-
{
|
|
108
|
-
name: 'items',
|
|
109
|
-
type: 'array',
|
|
110
|
-
flattenedFields: [
|
|
111
|
-
{
|
|
112
|
-
name: 'note',
|
|
113
|
-
type: 'text'
|
|
114
|
-
}
|
|
115
|
-
]
|
|
116
|
-
}
|
|
117
|
-
];
|
|
118
|
-
const fieldHooks = {
|
|
119
|
-
items: {
|
|
120
|
-
type: 'beforeExport',
|
|
121
|
-
fn: ({ value })=>{
|
|
122
|
-
if (!Array.isArray(value)) {
|
|
123
|
-
return value;
|
|
124
|
-
}
|
|
125
|
-
return value.map((item)=>({
|
|
126
|
-
...item,
|
|
127
|
-
note: `${item.note ?? ''}-parent`
|
|
128
|
-
}));
|
|
129
|
-
}
|
|
130
|
-
},
|
|
131
|
-
items_note: {
|
|
132
|
-
type: 'beforeExport',
|
|
133
|
-
fn: ({ value })=>`${value}-child`
|
|
134
|
-
}
|
|
135
|
-
};
|
|
136
|
-
const result = applyFieldHooks({
|
|
137
|
-
type: 'beforeExport',
|
|
138
|
-
data: {
|
|
139
|
-
items: [
|
|
140
|
-
{
|
|
141
|
-
note: 'a'
|
|
142
|
-
},
|
|
143
|
-
{
|
|
144
|
-
note: 'b'
|
|
145
|
-
}
|
|
146
|
-
]
|
|
147
|
-
},
|
|
148
|
-
fieldHooks,
|
|
149
|
-
fields,
|
|
150
|
-
format: 'json',
|
|
151
|
-
operation: 'export',
|
|
152
|
-
req: mockReq
|
|
153
|
-
});
|
|
154
|
-
expect(result.items).toEqual([
|
|
155
|
-
{
|
|
156
|
-
note: 'a-parent-child'
|
|
157
|
-
},
|
|
158
|
-
{
|
|
159
|
-
note: 'b-parent-child'
|
|
160
|
-
}
|
|
161
|
-
]);
|
|
162
|
-
});
|
|
163
|
-
it('should not recurse into children when the parent hook returns a primitive', ()=>{
|
|
164
|
-
const fields = [
|
|
165
|
-
{
|
|
166
|
-
name: 'meta',
|
|
167
|
-
type: 'group',
|
|
168
|
-
flattenedFields: [
|
|
169
|
-
{
|
|
170
|
-
name: 'slug',
|
|
171
|
-
type: 'text'
|
|
172
|
-
}
|
|
173
|
-
]
|
|
174
|
-
}
|
|
175
|
-
];
|
|
176
|
-
const childFn = vi.fn(({ value })=>`${value}-from-child`);
|
|
177
|
-
const fieldHooks = {
|
|
178
|
-
meta: {
|
|
179
|
-
type: 'beforeExport',
|
|
180
|
-
fn: ()=>'serialized'
|
|
181
|
-
},
|
|
182
|
-
meta_slug: {
|
|
183
|
-
type: 'beforeExport',
|
|
184
|
-
fn: childFn
|
|
185
|
-
}
|
|
186
|
-
};
|
|
187
|
-
const result = applyFieldHooks({
|
|
188
|
-
type: 'beforeExport',
|
|
189
|
-
data: {
|
|
190
|
-
meta: {
|
|
191
|
-
slug: 'raw'
|
|
192
|
-
}
|
|
193
|
-
},
|
|
194
|
-
fieldHooks,
|
|
195
|
-
fields,
|
|
196
|
-
format: 'json',
|
|
197
|
-
operation: 'export',
|
|
198
|
-
req: mockReq
|
|
199
|
-
});
|
|
200
|
-
expect(result.meta).toBe('serialized');
|
|
201
|
-
expect(childFn).not.toHaveBeenCalled();
|
|
202
|
-
});
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
//# sourceMappingURL=applyFieldHooks.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/applyFieldHooks.spec.ts"],"sourcesContent":["import { FlattenedField, PayloadRequest } from 'payload'\n\nimport type { ExportFieldHookEntry, ImportFieldHookEntry } from '../types.js'\n\nimport { describe, expect, it, vi } from 'vitest'\n\nimport { applyFieldHooks } from './applyFieldHooks.js'\n\nconst mockReq = {\n payload: {\n logger: {\n error: vi.fn(),\n },\n },\n} as unknown as PayloadRequest\n\ndescribe('applyFieldHooks parent + child traversal', () => {\n it('should run a parent group hook and still run child field hooks against the transformed value (export)', () => {\n const fields: FlattenedField[] = [\n {\n name: 'meta',\n type: 'group',\n flattenedFields: [{ name: 'slug', type: 'text' } as FlattenedField],\n } as unknown as FlattenedField,\n ]\n\n const fieldHooks: Record<string, ExportFieldHookEntry> = {\n meta: {\n type: 'beforeExport',\n fn: ({ value }) => {\n const obj = (value ?? {}) as Record<string, unknown>\n return { ...obj, slug: `${obj.slug ?? ''}-from-parent` }\n },\n },\n meta_slug: {\n type: 'beforeExport',\n fn: ({ value }) => `${value}-from-child`,\n },\n }\n\n const result = applyFieldHooks({\n type: 'beforeExport',\n data: { meta: { slug: 'raw' } },\n fieldHooks,\n fields,\n format: 'json',\n operation: 'export',\n req: mockReq,\n })\n\n // Parent hook ran first ('raw' → 'raw-from-parent'), then child hook ran against\n // the transformed value ('raw-from-parent' → 'raw-from-parent-from-child').\n expect(result.meta).toEqual({ slug: 'raw-from-parent-from-child' })\n })\n\n it('should run a parent group hook and still run child field hooks (import)', () => {\n const fields: FlattenedField[] = [\n {\n name: 'meta',\n type: 'group',\n flattenedFields: [{ name: 'slug', type: 'text' } as FlattenedField],\n } as unknown as FlattenedField,\n ]\n\n const fieldHooks: Record<string, ImportFieldHookEntry> = {\n meta: {\n type: 'beforeImport',\n fn: ({ value }) => {\n const obj = (value ?? {}) as Record<string, unknown>\n return { ...obj, slug: `${obj.slug ?? ''}-from-parent` }\n },\n },\n meta_slug: {\n type: 'beforeImport',\n fn: ({ value }) => `${value}-from-child`,\n },\n }\n\n const result = applyFieldHooks({\n type: 'beforeImport',\n data: { meta: { slug: 'raw' } },\n fieldHooks,\n fields,\n format: 'json',\n operation: 'import',\n req: mockReq,\n })\n\n expect(result.meta).toEqual({ slug: 'raw-from-parent-from-child' })\n })\n\n it('should run a parent array hook then child hooks for each item', () => {\n const fields: FlattenedField[] = [\n {\n name: 'items',\n type: 'array',\n flattenedFields: [{ name: 'note', type: 'text' } as FlattenedField],\n } as unknown as FlattenedField,\n ]\n\n const fieldHooks: Record<string, ExportFieldHookEntry> = {\n items: {\n type: 'beforeExport',\n fn: ({ value }) => {\n if (!Array.isArray(value)) {\n return value\n }\n return value.map((item) => ({\n ...(item as Record<string, unknown>),\n note: `${(item as Record<string, unknown>).note ?? ''}-parent`,\n }))\n },\n },\n items_note: {\n type: 'beforeExport',\n fn: ({ value }) => `${value}-child`,\n },\n }\n\n const result = applyFieldHooks({\n type: 'beforeExport',\n data: { items: [{ note: 'a' }, { note: 'b' }] },\n fieldHooks,\n fields,\n format: 'json',\n operation: 'export',\n req: mockReq,\n })\n\n expect(result.items).toEqual([{ note: 'a-parent-child' }, { note: 'b-parent-child' }])\n })\n\n it('should not recurse into children when the parent hook returns a primitive', () => {\n const fields: FlattenedField[] = [\n {\n name: 'meta',\n type: 'group',\n flattenedFields: [{ name: 'slug', type: 'text' } as FlattenedField],\n } as unknown as FlattenedField,\n ]\n\n const childFn = vi.fn(({ value }: { value: unknown }) => `${value}-from-child`)\n const fieldHooks: Record<string, ExportFieldHookEntry> = {\n meta: {\n type: 'beforeExport',\n fn: () => 'serialized',\n },\n meta_slug: {\n type: 'beforeExport',\n fn: childFn,\n },\n }\n\n const result = applyFieldHooks({\n type: 'beforeExport',\n data: { meta: { slug: 'raw' } },\n fieldHooks,\n fields,\n format: 'json',\n operation: 'export',\n req: mockReq,\n })\n\n expect(result.meta).toBe('serialized')\n expect(childFn).not.toHaveBeenCalled()\n })\n})\n"],"names":["describe","expect","it","vi","applyFieldHooks","mockReq","payload","logger","error","fn","fields","name","type","flattenedFields","fieldHooks","meta","value","obj","slug","meta_slug","result","data","format","operation","req","toEqual","items","Array","isArray","map","item","note","items_note","childFn","toBe","not","toHaveBeenCalled"],"mappings":"AAIA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,EAAEC,EAAE,QAAQ,SAAQ;AAEjD,SAASC,eAAe,QAAQ,uBAAsB;AAEtD,MAAMC,UAAU;I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F;IAEA7B,GAAG,6EAA6E;QAC9E,MAAMQ,SAA2B;YAC/B;gBACEC,MAAM;gBACNC,MAAM;gBACNC,iBAAiB;oBAAC;wBAAEF,MAAM;wBAAQC,MAAM;oBAAO;iBAAoB;YACrE;SACD;QAED,MAAMqB,UAAU9B,GAAGM,EAAE,CAAC,CAAC,EAAEO,KAAK,EAAsB,GAAK,GAAGA,MAAM,WAAW,CAAC;QAC9E,MAAMF,aAAmD;YACvDC,MAAM;gBACJH,MAAM;gBACNH,IAAI,IAAM;YACZ;YACAU,WAAW;gBACTP,MAAM;gBACNH,IAAIwB;YACN;QACF;QAEA,MAAMb,SAAShB,gBAAgB;YAC7BQ,MAAM;YACNS,MAAM;gBAAEN,MAAM;oBAAEG,MAAM;gBAAM;YAAE;YAC9BJ;YACAJ;YACAY,QAAQ;YACRC,WAAW;YACXC,KAAKnB;QACP;QAEAJ,OAAOmB,OAAOL,IAAI,EAAEmB,IAAI,CAAC;QACzBjC,OAAOgC,SAASE,GAAG,CAACC,gBAAgB;IACtC;AACF"}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { buildDisabledFieldRegex } from './buildDisabledFieldRegex.js';
|
|
3
|
-
describe('buildDisabledFieldRegex', ()=>{
|
|
4
|
-
describe('simple field paths', ()=>{
|
|
5
|
-
it('should match exact field name', ()=>{
|
|
6
|
-
const matcher = buildDisabledFieldRegex('title');
|
|
7
|
-
expect(matcher.test('title')).toBe(true);
|
|
8
|
-
});
|
|
9
|
-
it('should match field with array index', ()=>{
|
|
10
|
-
const matcher = buildDisabledFieldRegex('items');
|
|
11
|
-
expect(matcher.test('items_0')).toBe(true);
|
|
12
|
-
expect(matcher.test('items_1')).toBe(true);
|
|
13
|
-
});
|
|
14
|
-
it('should match nested fields under array items', ()=>{
|
|
15
|
-
const matcher = buildDisabledFieldRegex('items');
|
|
16
|
-
expect(matcher.test('items_0_title')).toBe(true);
|
|
17
|
-
});
|
|
18
|
-
it('should not match unrelated fields', ()=>{
|
|
19
|
-
const matcher = buildDisabledFieldRegex('title');
|
|
20
|
-
expect(matcher.test('otherField')).toBe(false);
|
|
21
|
-
expect(matcher.test('titleExtra')).toBe(false);
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
describe('block type slug handling', ()=>{
|
|
25
|
-
it('should match field path with block type slug', ()=>{
|
|
26
|
-
const matcher = buildDisabledFieldRegex('blocks.content');
|
|
27
|
-
// Standard cases
|
|
28
|
-
expect(matcher.test('blocks_content')).toBe(true);
|
|
29
|
-
expect(matcher.test('blocks_0_content')).toBe(true);
|
|
30
|
-
// With block type slug (hero, cta, etc.)
|
|
31
|
-
expect(matcher.test('blocks_0_hero_content')).toBe(true);
|
|
32
|
-
expect(matcher.test('blocks_1_cta_content')).toBe(true);
|
|
33
|
-
expect(matcher.test('blocks_hero_content')).toBe(true);
|
|
34
|
-
});
|
|
35
|
-
it('should match nested fields within blocks', ()=>{
|
|
36
|
-
const matcher = buildDisabledFieldRegex('blocks.content');
|
|
37
|
-
expect(matcher.test('blocks_0_hero_content_title')).toBe(true);
|
|
38
|
-
expect(matcher.test('blocks_0_content_richText')).toBe(true);
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
describe('deeply nested paths', ()=>{
|
|
42
|
-
it('should match three-level nesting with indices and slugs', ()=>{
|
|
43
|
-
const matcher = buildDisabledFieldRegex('layout.sections.items');
|
|
44
|
-
expect(matcher.test('layout_sections_items')).toBe(true);
|
|
45
|
-
expect(matcher.test('layout_0_sections_items')).toBe(true);
|
|
46
|
-
expect(matcher.test('layout_0_sections_1_items')).toBe(true);
|
|
47
|
-
expect(matcher.test('layout_0_hero_sections_1_items')).toBe(true);
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
describe('edge cases', ()=>{
|
|
51
|
-
it('should not match partial field names', ()=>{
|
|
52
|
-
const matcher = buildDisabledFieldRegex('block');
|
|
53
|
-
expect(matcher.test('blocks')).toBe(false);
|
|
54
|
-
expect(matcher.test('blockType')).toBe(false);
|
|
55
|
-
});
|
|
56
|
-
it('should handle field names with numbers', ()=>{
|
|
57
|
-
const matcher = buildDisabledFieldRegex('field1.field2');
|
|
58
|
-
expect(matcher.test('field1_field2')).toBe(true);
|
|
59
|
-
expect(matcher.test('field1_0_field2')).toBe(true);
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
//# sourceMappingURL=buildDisabledFieldRegex.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/buildDisabledFieldRegex.spec.ts"],"sourcesContent":["import { describe, expect, it } from 'vitest'\n\nimport { buildDisabledFieldRegex } from './buildDisabledFieldRegex.js'\n\ndescribe('buildDisabledFieldRegex', () => {\n describe('simple field paths', () => {\n it('should match exact field name', () => {\n const matcher = buildDisabledFieldRegex('title')\n\n expect(matcher.test('title')).toBe(true)\n })\n\n it('should match field with array index', () => {\n const matcher = buildDisabledFieldRegex('items')\n\n expect(matcher.test('items_0')).toBe(true)\n expect(matcher.test('items_1')).toBe(true)\n })\n\n it('should match nested fields under array items', () => {\n const matcher = buildDisabledFieldRegex('items')\n\n expect(matcher.test('items_0_title')).toBe(true)\n })\n\n it('should not match unrelated fields', () => {\n const matcher = buildDisabledFieldRegex('title')\n\n expect(matcher.test('otherField')).toBe(false)\n expect(matcher.test('titleExtra')).toBe(false)\n })\n })\n\n describe('block type slug handling', () => {\n it('should match field path with block type slug', () => {\n const matcher = buildDisabledFieldRegex('blocks.content')\n\n // Standard cases\n expect(matcher.test('blocks_content')).toBe(true)\n expect(matcher.test('blocks_0_content')).toBe(true)\n\n // With block type slug (hero, cta, etc.)\n expect(matcher.test('blocks_0_hero_content')).toBe(true)\n expect(matcher.test('blocks_1_cta_content')).toBe(true)\n expect(matcher.test('blocks_hero_content')).toBe(true)\n })\n\n it('should match nested fields within blocks', () => {\n const matcher = buildDisabledFieldRegex('blocks.content')\n\n expect(matcher.test('blocks_0_hero_content_title')).toBe(true)\n expect(matcher.test('blocks_0_content_richText')).toBe(true)\n })\n })\n\n describe('deeply nested paths', () => {\n it('should match three-level nesting with indices and slugs', () => {\n const matcher = buildDisabledFieldRegex('layout.sections.items')\n\n expect(matcher.test('layout_sections_items')).toBe(true)\n expect(matcher.test('layout_0_sections_items')).toBe(true)\n expect(matcher.test('layout_0_sections_1_items')).toBe(true)\n expect(matcher.test('layout_0_hero_sections_1_items')).toBe(true)\n })\n })\n\n describe('edge cases', () => {\n it('should not match partial field names', () => {\n const matcher = buildDisabledFieldRegex('block')\n\n expect(matcher.test('blocks')).toBe(false)\n expect(matcher.test('blockType')).toBe(false)\n })\n\n it('should handle field names with numbers', () => {\n const matcher = buildDisabledFieldRegex('field1.field2')\n\n expect(matcher.test('field1_field2')).toBe(true)\n expect(matcher.test('field1_0_field2')).toBe(true)\n })\n })\n})\n"],"names":["describe","expect","it","buildDisabledFieldRegex","matcher","test","toBe"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,SAAQ;AAE7C,SAASC,uBAAuB,QAAQ,+BAA8B;AAEtEH,SAAS,2BAA2B;IAClCA,SAAS,sBAAsB;QAC7BE,GAAG,iCAAiC;YAClC,MAAME,UAAUD,wBAAwB;YAExCF,OAAOG,QAAQC,IAAI,CAAC,UAAUC,IAAI,CAAC;QACrC;QAEAJ,GAAG,uCAAuC;YACxC,MAAME,UAAUD,wBAAwB;YAExCF,OAAOG,QAAQC,IAAI,CAAC,YAAYC,IAAI,CAAC;YACrCL,OAAOG,QAAQC,IAAI,CAAC,YAAYC,IAAI,CAAC;QACvC;QAEAJ,GAAG,gDAAgD;YACjD,MAAME,UAAUD,wBAAwB;YAExCF,OAAOG,QAAQC,IAAI,CAAC,kBAAkBC,IAAI,CAAC;QAC7C;QAEAJ,GAAG,qCAAqC;YACtC,MAAME,UAAUD,wBAAwB;YAExCF,OAAOG,QAAQC,IAAI,CAAC,eAAeC,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C3CL,OAAOG,QAAQC,IAAI,CAAC,oBAAoBC,IAAI,CAAC;QAC/C;IACF;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fieldPath.d.ts","sourceRoot":"","sources":["../../src/utilities/fieldPath.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,8BAA8B,aAAc,MAAM,EAAE,KAAG,OACG,CAAA"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
const unsupportedFieldPathSegments = new Set([
|
|
2
|
-
'__proto__',
|
|
3
|
-
'constructor',
|
|
4
|
-
'prototype'
|
|
5
|
-
]);
|
|
6
|
-
export const hasUnsupportedFieldPathSegment = (segments)=>segments.some((segment)=>unsupportedFieldPathSegments.has(segment));
|
|
7
|
-
|
|
8
|
-
//# sourceMappingURL=fieldPath.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/fieldPath.ts"],"sourcesContent":["const unsupportedFieldPathSegments = new Set(['__proto__', 'constructor', 'prototype'])\n\nexport const hasUnsupportedFieldPathSegment = (segments: string[]): boolean =>\n segments.some((segment) => unsupportedFieldPathSegments.has(segment))\n"],"names":["unsupportedFieldPathSegments","Set","hasUnsupportedFieldPathSegment","segments","some","segment","has"],"mappings":"AAAA,MAAMA,+BAA+B,IAAIC,IAAI;IAAC;IAAa;IAAe;CAAY;AAEtF,OAAO,MAAMC,iCAAiC,CAACC,WAC7CA,SAASC,IAAI,CAAC,CAACC,UAAYL,6BAA6BM,GAAG,CAACD,UAAS"}
|