@payloadcms/plugin-import-export 4.0.0-internal.c2b57ce → 4.0.0-internal.c6494b5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/CollectionField/index.d.ts +3 -2
- package/dist/components/CollectionField/index.d.ts.map +1 -1
- package/dist/components/CollectionField/index.js.map +1 -1
- package/dist/components/ExportListMenuItem/index.d.ts.map +1 -1
- package/dist/components/ExportListMenuItem/index.js +14 -12
- package/dist/components/ExportListMenuItem/index.js.map +1 -1
- package/dist/components/ExportPreview/index.css +52 -0
- package/dist/components/ExportPreview/index.d.ts +1 -1
- package/dist/components/ExportPreview/index.d.ts.map +1 -1
- package/dist/components/ExportPreview/index.js +12 -2
- package/dist/components/ExportPreview/index.js.map +1 -1
- package/dist/components/FieldsToExport/index.d.ts +3 -2
- package/dist/components/FieldsToExport/index.d.ts.map +1 -1
- package/dist/components/FieldsToExport/index.js +18 -15
- package/dist/components/FieldsToExport/index.js.map +1 -1
- package/dist/components/FieldsToExport/reduceFields.d.ts +6 -0
- package/dist/components/FieldsToExport/reduceFields.d.ts.map +1 -1
- package/dist/components/FieldsToExport/reduceFields.js +4 -0
- package/dist/components/FieldsToExport/reduceFields.js.map +1 -1
- package/dist/components/FormatField/index.d.ts +3 -2
- package/dist/components/FormatField/index.d.ts.map +1 -1
- package/dist/components/FormatField/index.js +6 -3
- package/dist/components/FormatField/index.js.map +1 -1
- package/dist/components/ImportListMenuItem/index.d.ts.map +1 -1
- package/dist/components/ImportListMenuItem/index.js +14 -12
- package/dist/components/ImportListMenuItem/index.js.map +1 -1
- package/dist/components/ImportPreview/index.css +45 -0
- package/dist/components/ImportPreview/index.d.ts +1 -1
- package/dist/components/ImportPreview/index.d.ts.map +1 -1
- package/dist/components/ImportPreview/index.js +44 -11
- package/dist/components/ImportPreview/index.js.map +1 -1
- package/dist/components/LimitField/index.d.ts +3 -2
- package/dist/components/LimitField/index.d.ts.map +1 -1
- package/dist/components/LimitField/index.js.map +1 -1
- package/dist/components/LocaleField/index.d.ts +3 -2
- package/dist/components/LocaleField/index.d.ts.map +1 -1
- package/dist/components/LocaleField/index.js.map +1 -1
- package/dist/components/Page/index.d.ts +4 -3
- package/dist/components/Page/index.d.ts.map +1 -1
- package/dist/components/Page/index.js +1 -1
- package/dist/components/Page/index.js.map +1 -1
- package/dist/components/RelationshipCell/getRelationshipGroupKey.d.ts +7 -0
- package/dist/components/RelationshipCell/getRelationshipGroupKey.d.ts.map +1 -0
- package/dist/components/RelationshipCell/getRelationshipGroupKey.js +3 -0
- package/dist/components/RelationshipCell/getRelationshipGroupKey.js.map +1 -0
- package/dist/components/RelationshipCell/getRelationshipGroups.d.ts +43 -0
- package/dist/components/RelationshipCell/getRelationshipGroups.d.ts.map +1 -0
- package/dist/components/RelationshipCell/getRelationshipGroups.js +109 -0
- package/dist/components/RelationshipCell/getRelationshipGroups.js.map +1 -0
- package/dist/components/RelationshipCell/index.css +30 -0
- package/dist/components/RelationshipCell/index.d.ts +15 -0
- package/dist/components/RelationshipCell/index.d.ts.map +1 -0
- package/dist/components/RelationshipCell/index.js +57 -0
- package/dist/components/RelationshipCell/index.js.map +1 -0
- package/dist/components/SortBy/index.css +9 -0
- package/dist/components/SortBy/index.d.ts +4 -3
- package/dist/components/SortBy/index.d.ts.map +1 -1
- package/dist/components/SortBy/index.js +1 -2
- package/dist/components/SortBy/index.js.map +1 -1
- package/dist/components/SortOrder/index.css +9 -0
- package/dist/components/SortOrder/index.d.ts +4 -3
- package/dist/components/SortOrder/index.d.ts.map +1 -1
- package/dist/components/SortOrder/index.js +1 -2
- package/dist/components/SortOrder/index.js.map +1 -1
- package/dist/export/batchProcessor.d.ts +4 -3
- package/dist/export/batchProcessor.d.ts.map +1 -1
- package/dist/export/batchProcessor.js +6 -2
- package/dist/export/batchProcessor.js.map +1 -1
- package/dist/export/createExport.d.ts +4 -2
- package/dist/export/createExport.d.ts.map +1 -1
- package/dist/export/createExport.js +7 -2
- package/dist/export/createExport.js.map +1 -1
- package/dist/export/getCreateExportCollectionTask.d.ts.map +1 -1
- package/dist/export/getCreateExportCollectionTask.js +11 -0
- package/dist/export/getCreateExportCollectionTask.js.map +1 -1
- package/dist/export/getExportCollection.d.ts.map +1 -1
- package/dist/export/getExportCollection.js +9 -4
- package/dist/export/getExportCollection.js.map +1 -1
- package/dist/export/getFields.d.ts.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 +24 -5
- package/dist/export/handlePreview.js.map +1 -1
- package/dist/exports/types.d.ts +1 -1
- package/dist/exports/types.d.ts.map +1 -1
- package/dist/exports/types.js.map +1 -1
- package/dist/import/batchProcessor.d.ts +4 -3
- package/dist/import/batchProcessor.d.ts.map +1 -1
- package/dist/import/batchProcessor.js +15 -8
- package/dist/import/batchProcessor.js.map +1 -1
- package/dist/import/createImport.d.ts +3 -2
- package/dist/import/createImport.d.ts.map +1 -1
- package/dist/import/createImport.js +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/getFields.d.ts.map +1 -1
- package/dist/import/getImportCollection.d.ts.map +1 -1
- package/dist/import/getImportCollection.js +6 -4
- package/dist/import/getImportCollection.js.map +1 -1
- package/dist/import/handlePreview.d.ts.map +1 -1
- package/dist/import/handlePreview.js +5 -1
- package/dist/import/handlePreview.js.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -3
- package/dist/index.js.map +1 -1
- package/dist/translations/languages/en.d.ts.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/applyFieldHooks.d.ts.map +1 -1
- package/dist/utilities/applyFieldHooks.js +1 -1
- 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/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 +64 -27
- package/dist/utilities/getExportFieldFunctions.js.map +1 -1
- package/dist/utilities/getFileFromDoc.d.ts.map +1 -1
- package/dist/utilities/getFileFromDoc.js +3 -3
- package/dist/utilities/getFileFromDoc.js.map +1 -1
- package/dist/utilities/getFlattenedFieldKeys.d.ts.map +1 -1
- package/dist/utilities/getImportFieldFunctions.d.ts.map +1 -1
- package/dist/utilities/getPluginCollections.d.ts.map +1 -1
- package/dist/utilities/getSchemaColumns.d.ts.map +1 -1
- package/dist/utilities/getSelect.d.ts.map +1 -1
- package/dist/utilities/getSelect.js +11 -3
- package/dist/utilities/getSelect.js.map +1 -1
- package/dist/utilities/getSubmittedFormValues.d.ts +12 -0
- package/dist/utilities/getSubmittedFormValues.d.ts.map +1 -0
- package/dist/utilities/getSubmittedFormValues.js +24 -0
- package/dist/utilities/getSubmittedFormValues.js.map +1 -0
- package/dist/utilities/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/removeDisabledFields.d.ts.map +1 -1
- package/dist/utilities/setNestedValue.d.ts +2 -1
- package/dist/utilities/setNestedValue.d.ts.map +1 -1
- package/dist/utilities/setNestedValue.js +65 -34
- package/dist/utilities/setNestedValue.js.map +1 -1
- package/dist/utilities/sortHelpers.d.ts +1 -1
- package/dist/utilities/sortHelpers.d.ts.map +1 -1
- package/dist/utilities/unflattenObject.d.ts.map +1 -1
- package/dist/utilities/unflattenObject.js +21 -2
- package/dist/utilities/unflattenObject.js.map +1 -1
- package/dist/utilities/unflattenPostProcess.d.ts.map +1 -1
- package/dist/utilities/unflattenPostProcess.js +39 -13
- package/dist/utilities/unflattenPostProcess.js.map +1 -1
- package/dist/utilities/validateLimitValue.d.ts.map +1 -1
- package/license.md +1 -1
- package/package.json +9 -9
- package/dist/components/ExportPreview/index.scss +0 -48
- package/dist/components/FieldsToExport/index.scss +0 -0
- package/dist/components/FieldsToExport/reduceFields.spec.js +0 -239
- package/dist/components/FieldsToExport/reduceFields.spec.js.map +0 -1
- package/dist/components/ImportPreview/index.scss +0 -41
- package/dist/components/SortBy/index.scss +0 -3
- package/dist/components/SortOrder/index.scss +0 -3
- package/dist/utilities/applyFieldHooks.spec.js +0 -205
- package/dist/utilities/applyFieldHooks.spec.js.map +0 -1
- package/dist/utilities/buildDisabledFieldRegex.spec.js +0 -64
- package/dist/utilities/buildDisabledFieldRegex.spec.js.map +0 -1
- package/dist/utilities/fieldToRegex.spec.js +0 -151
- package/dist/utilities/fieldToRegex.spec.js.map +0 -1
- package/dist/utilities/filterToSelectedFields.spec.js +0 -204
- package/dist/utilities/filterToSelectedFields.spec.js.map +0 -1
- package/dist/utilities/flattenObject.spec.js +0 -158
- package/dist/utilities/flattenObject.spec.js.map +0 -1
- package/dist/utilities/getExportFieldFunctions.spec.js +0 -50
- package/dist/utilities/getExportFieldFunctions.spec.js.map +0 -1
- package/dist/utilities/getImportFieldFunctions.spec.js +0 -167
- package/dist/utilities/getImportFieldFunctions.spec.js.map +0 -1
- package/dist/utilities/getSchemaColumns.spec.js +0 -157
- package/dist/utilities/getSchemaColumns.spec.js.map +0 -1
- package/dist/utilities/parseCSV.spec.js +0 -195
- package/dist/utilities/parseCSV.spec.js.map +0 -1
- package/dist/utilities/siblingDoc.spec.js +0 -278
- package/dist/utilities/siblingDoc.spec.js.map +0 -1
- package/dist/utilities/unflattenObject.spec.js +0 -713
- package/dist/utilities/unflattenObject.spec.js.map +0 -1
- /package/dist/components/Page/{index.scss → index.css} +0 -0
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
@layer payload-default {
|
|
2
|
-
.export-preview {
|
|
3
|
-
&__header {
|
|
4
|
-
display: flex;
|
|
5
|
-
justify-content: space-between;
|
|
6
|
-
align-items: flex-end;
|
|
7
|
-
margin-bottom: 10px;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
&__export-info {
|
|
11
|
-
display: flex;
|
|
12
|
-
flex-direction: column;
|
|
13
|
-
align-items: flex-end;
|
|
14
|
-
gap: 2px;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
&__export-count {
|
|
18
|
-
font-size: var(--font-size-small);
|
|
19
|
-
color: var(--theme-elevation-500);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
&__limit-capped {
|
|
23
|
-
font-size: var(--font-size-small);
|
|
24
|
-
color: var(--theme-warning-500);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
&__pagination {
|
|
28
|
-
display: flex;
|
|
29
|
-
align-items: center;
|
|
30
|
-
justify-content: space-between;
|
|
31
|
-
gap: var(--base);
|
|
32
|
-
margin-top: var(--base);
|
|
33
|
-
padding-top: var(--base);
|
|
34
|
-
border-top: 1px solid var(--theme-elevation-100);
|
|
35
|
-
|
|
36
|
-
// When only PerPage is present (no Pagination), keep it on the right
|
|
37
|
-
.per-page:only-child {
|
|
38
|
-
margin-left: auto;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
&__page-info {
|
|
43
|
-
font-size: var(--font-size-small);
|
|
44
|
-
color: var(--theme-elevation-500);
|
|
45
|
-
white-space: nowrap;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
File without changes
|
|
@@ -1,239 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { reduceFields } from './reduceFields.js';
|
|
3
|
-
const values = (result)=>result.map((f)=>f.value);
|
|
4
|
-
describe('reduceFields', ()=>{
|
|
5
|
-
describe('excludeUnsortable', ()=>{
|
|
6
|
-
it('should include array and blocks fields by default', ()=>{
|
|
7
|
-
const fields = [
|
|
8
|
-
{
|
|
9
|
-
name: 'title',
|
|
10
|
-
type: 'text'
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
name: 'items',
|
|
14
|
-
type: 'array',
|
|
15
|
-
fields: [
|
|
16
|
-
{
|
|
17
|
-
name: 'text',
|
|
18
|
-
type: 'text'
|
|
19
|
-
}
|
|
20
|
-
]
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
name: 'layout',
|
|
24
|
-
type: 'blocks',
|
|
25
|
-
blocks: []
|
|
26
|
-
}
|
|
27
|
-
];
|
|
28
|
-
const result = values(reduceFields({
|
|
29
|
-
fields
|
|
30
|
-
}));
|
|
31
|
-
expect(result).toContain('title');
|
|
32
|
-
expect(result).toContain('items');
|
|
33
|
-
expect(result).toContain('layout');
|
|
34
|
-
});
|
|
35
|
-
it('should exclude array fields when excludeUnsortable is true', ()=>{
|
|
36
|
-
const fields = [
|
|
37
|
-
{
|
|
38
|
-
name: 'title',
|
|
39
|
-
type: 'text'
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
name: 'items',
|
|
43
|
-
type: 'array',
|
|
44
|
-
fields: [
|
|
45
|
-
{
|
|
46
|
-
name: 'text',
|
|
47
|
-
type: 'text'
|
|
48
|
-
}
|
|
49
|
-
]
|
|
50
|
-
}
|
|
51
|
-
];
|
|
52
|
-
const result = values(reduceFields({
|
|
53
|
-
excludeUnsortable: true,
|
|
54
|
-
fields
|
|
55
|
-
}));
|
|
56
|
-
expect(result).toContain('title');
|
|
57
|
-
expect(result).not.toContain('items');
|
|
58
|
-
});
|
|
59
|
-
it('should exclude blocks fields when excludeUnsortable is true', ()=>{
|
|
60
|
-
const fields = [
|
|
61
|
-
{
|
|
62
|
-
name: 'title',
|
|
63
|
-
type: 'text'
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
name: 'layout',
|
|
67
|
-
type: 'blocks',
|
|
68
|
-
blocks: []
|
|
69
|
-
}
|
|
70
|
-
];
|
|
71
|
-
const result = values(reduceFields({
|
|
72
|
-
excludeUnsortable: true,
|
|
73
|
-
fields
|
|
74
|
-
}));
|
|
75
|
-
expect(result).toContain('title');
|
|
76
|
-
expect(result).not.toContain('layout');
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
describe('disabledFields', ()=>{
|
|
80
|
-
it('should include all fields when disabledFields is empty', ()=>{
|
|
81
|
-
const fields = [
|
|
82
|
-
{
|
|
83
|
-
name: 'title',
|
|
84
|
-
type: 'text'
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
name: 'slug',
|
|
88
|
-
type: 'text'
|
|
89
|
-
}
|
|
90
|
-
];
|
|
91
|
-
const result = values(reduceFields({
|
|
92
|
-
disabledFields: [],
|
|
93
|
-
fields
|
|
94
|
-
}));
|
|
95
|
-
expect(result).toContain('title');
|
|
96
|
-
expect(result).toContain('slug');
|
|
97
|
-
});
|
|
98
|
-
it('should exclude a field whose path is in disabledFields', ()=>{
|
|
99
|
-
const fields = [
|
|
100
|
-
{
|
|
101
|
-
name: 'title',
|
|
102
|
-
type: 'text'
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
name: 'slug',
|
|
106
|
-
type: 'text'
|
|
107
|
-
}
|
|
108
|
-
];
|
|
109
|
-
const result = values(reduceFields({
|
|
110
|
-
disabledFields: [
|
|
111
|
-
'slug'
|
|
112
|
-
],
|
|
113
|
-
fields
|
|
114
|
-
}));
|
|
115
|
-
expect(result).toContain('title');
|
|
116
|
-
expect(result).not.toContain('slug');
|
|
117
|
-
});
|
|
118
|
-
it('should exclude nested fields whose paths start with a disabled parent path', ()=>{
|
|
119
|
-
const fields = [
|
|
120
|
-
{
|
|
121
|
-
name: 'meta',
|
|
122
|
-
type: 'group',
|
|
123
|
-
fields: [
|
|
124
|
-
{
|
|
125
|
-
name: 'title',
|
|
126
|
-
type: 'text'
|
|
127
|
-
},
|
|
128
|
-
{
|
|
129
|
-
name: 'description',
|
|
130
|
-
type: 'text'
|
|
131
|
-
}
|
|
132
|
-
]
|
|
133
|
-
}
|
|
134
|
-
];
|
|
135
|
-
const result = values(reduceFields({
|
|
136
|
-
disabledFields: [
|
|
137
|
-
'meta.description'
|
|
138
|
-
],
|
|
139
|
-
fields
|
|
140
|
-
}));
|
|
141
|
-
expect(result).toContain('meta.title');
|
|
142
|
-
expect(result).not.toContain('meta.description');
|
|
143
|
-
});
|
|
144
|
-
});
|
|
145
|
-
describe('combined excludeUnsortable and disabledFields', ()=>{
|
|
146
|
-
it('should apply both filters simultaneously', ()=>{
|
|
147
|
-
const fields = [
|
|
148
|
-
{
|
|
149
|
-
name: 'title',
|
|
150
|
-
type: 'text'
|
|
151
|
-
},
|
|
152
|
-
{
|
|
153
|
-
name: 'slug',
|
|
154
|
-
type: 'text'
|
|
155
|
-
},
|
|
156
|
-
{
|
|
157
|
-
name: 'items',
|
|
158
|
-
type: 'array',
|
|
159
|
-
fields: [
|
|
160
|
-
{
|
|
161
|
-
name: 'text',
|
|
162
|
-
type: 'text'
|
|
163
|
-
}
|
|
164
|
-
]
|
|
165
|
-
}
|
|
166
|
-
];
|
|
167
|
-
const result = values(reduceFields({
|
|
168
|
-
disabledFields: [
|
|
169
|
-
'slug'
|
|
170
|
-
],
|
|
171
|
-
excludeUnsortable: true,
|
|
172
|
-
fields
|
|
173
|
-
}));
|
|
174
|
-
expect(result).toContain('title');
|
|
175
|
-
expect(result).not.toContain('slug');
|
|
176
|
-
expect(result).not.toContain('items');
|
|
177
|
-
});
|
|
178
|
-
});
|
|
179
|
-
describe('recursive propagation through group sub-fields', ()=>{
|
|
180
|
-
it('should propagate excludeUnsortable into group sub-fields', ()=>{
|
|
181
|
-
const fields = [
|
|
182
|
-
{
|
|
183
|
-
name: 'meta',
|
|
184
|
-
type: 'group',
|
|
185
|
-
fields: [
|
|
186
|
-
{
|
|
187
|
-
name: 'title',
|
|
188
|
-
type: 'text'
|
|
189
|
-
},
|
|
190
|
-
{
|
|
191
|
-
name: 'tags',
|
|
192
|
-
type: 'array',
|
|
193
|
-
fields: [
|
|
194
|
-
{
|
|
195
|
-
name: 'tag',
|
|
196
|
-
type: 'text'
|
|
197
|
-
}
|
|
198
|
-
]
|
|
199
|
-
}
|
|
200
|
-
]
|
|
201
|
-
}
|
|
202
|
-
];
|
|
203
|
-
const result = values(reduceFields({
|
|
204
|
-
excludeUnsortable: true,
|
|
205
|
-
fields
|
|
206
|
-
}));
|
|
207
|
-
expect(result).toContain('meta.title');
|
|
208
|
-
expect(result).not.toContain('meta.tags');
|
|
209
|
-
});
|
|
210
|
-
it('should propagate disabledFields into group sub-fields', ()=>{
|
|
211
|
-
const fields = [
|
|
212
|
-
{
|
|
213
|
-
name: 'meta',
|
|
214
|
-
type: 'group',
|
|
215
|
-
fields: [
|
|
216
|
-
{
|
|
217
|
-
name: 'title',
|
|
218
|
-
type: 'text'
|
|
219
|
-
},
|
|
220
|
-
{
|
|
221
|
-
name: 'description',
|
|
222
|
-
type: 'text'
|
|
223
|
-
}
|
|
224
|
-
]
|
|
225
|
-
}
|
|
226
|
-
];
|
|
227
|
-
const result = values(reduceFields({
|
|
228
|
-
disabledFields: [
|
|
229
|
-
'meta.description'
|
|
230
|
-
],
|
|
231
|
-
fields
|
|
232
|
-
}));
|
|
233
|
-
expect(result).toContain('meta.title');
|
|
234
|
-
expect(result).not.toContain('meta.description');
|
|
235
|
-
});
|
|
236
|
-
});
|
|
237
|
-
});
|
|
238
|
-
|
|
239
|
-
//# sourceMappingURL=reduceFields.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/FieldsToExport/reduceFields.spec.ts"],"sourcesContent":["import type { ClientField } from 'payload'\n\nimport { describe, expect, it } from 'vitest'\n\nimport { reduceFields } from './reduceFields.js'\n\nconst values = (result: ReturnType<typeof reduceFields>) => result.map((f) => f.value)\n\ndescribe('reduceFields', () => {\n describe('excludeUnsortable', () => {\n it('should include array and blocks fields by default', () => {\n const fields: ClientField[] = [\n { name: 'title', type: 'text' },\n { name: 'items', type: 'array', fields: [{ name: 'text', type: 'text' }] },\n { name: 'layout', type: 'blocks', blocks: [] },\n ]\n\n const result = values(reduceFields({ fields }))\n\n expect(result).toContain('title')\n expect(result).toContain('items')\n expect(result).toContain('layout')\n })\n\n it('should exclude array fields when excludeUnsortable is true', () => {\n const fields: ClientField[] = [\n { name: 'title', type: 'text' },\n { name: 'items', type: 'array', fields: [{ name: 'text', type: 'text' }] },\n ]\n\n const result = values(reduceFields({ excludeUnsortable: true, fields }))\n\n expect(result).toContain('title')\n expect(result).not.toContain('items')\n })\n\n it('should exclude blocks fields when excludeUnsortable is true', () => {\n const fields: ClientField[] = [\n { name: 'title', type: 'text' },\n { name: 'layout', type: 'blocks', blocks: [] },\n ]\n\n const result = values(reduceFields({ excludeUnsortable: true, fields }))\n\n expect(result).toContain('title')\n expect(result).not.toContain('layout')\n })\n })\n\n describe('disabledFields', () => {\n it('should include all fields when disabledFields is empty', () => {\n const fields: ClientField[] = [\n { name: 'title', type: 'text' },\n { name: 'slug', type: 'text' },\n ]\n\n const result = values(reduceFields({ disabledFields: [], fields }))\n\n expect(result).toContain('title')\n expect(result).toContain('slug')\n })\n\n it('should exclude a field whose path is in disabledFields', () => {\n const fields: ClientField[] = [\n { name: 'title', type: 'text' },\n { name: 'slug', type: 'text' },\n ]\n\n const result = values(reduceFields({ disabledFields: ['slug'], fields }))\n\n expect(result).toContain('title')\n expect(result).not.toContain('slug')\n })\n\n it('should exclude nested fields whose paths start with a disabled parent path', () => {\n const fields: ClientField[] = [\n {\n name: 'meta',\n type: 'group',\n fields: [\n { name: 'title', type: 'text' },\n { name: 'description', type: 'text' },\n ],\n },\n ]\n\n const result = values(reduceFields({ disabledFields: ['meta.description'], fields }))\n\n expect(result).toContain('meta.title')\n expect(result).not.toContain('meta.description')\n })\n })\n\n describe('combined excludeUnsortable and disabledFields', () => {\n it('should apply both filters simultaneously', () => {\n const fields: ClientField[] = [\n { name: 'title', type: 'text' },\n { name: 'slug', type: 'text' },\n { name: 'items', type: 'array', fields: [{ name: 'text', type: 'text' }] },\n ]\n\n const result = values(\n reduceFields({ disabledFields: ['slug'], excludeUnsortable: true, fields }),\n )\n\n expect(result).toContain('title')\n expect(result).not.toContain('slug')\n expect(result).not.toContain('items')\n })\n })\n\n describe('recursive propagation through group sub-fields', () => {\n it('should propagate excludeUnsortable into group sub-fields', () => {\n const fields: ClientField[] = [\n {\n name: 'meta',\n type: 'group',\n fields: [\n { name: 'title', type: 'text' },\n { name: 'tags', type: 'array', fields: [{ name: 'tag', type: 'text' }] },\n ],\n },\n ]\n\n const result = values(reduceFields({ excludeUnsortable: true, fields }))\n\n expect(result).toContain('meta.title')\n expect(result).not.toContain('meta.tags')\n })\n\n it('should propagate disabledFields into group sub-fields', () => {\n const fields: ClientField[] = [\n {\n name: 'meta',\n type: 'group',\n fields: [\n { name: 'title', type: 'text' },\n { name: 'description', type: 'text' },\n ],\n },\n ]\n\n const result = values(reduceFields({ disabledFields: ['meta.description'], fields }))\n\n expect(result).toContain('meta.title')\n expect(result).not.toContain('meta.description')\n })\n })\n})\n"],"names":["describe","expect","it","reduceFields","values","result","map","f","value","fields","name","type","blocks","toContain","excludeUnsortable","not","disabledFields"],"mappings":"AAEA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,SAAQ;AAE7C,SAASC,YAAY,QAAQ,oBAAmB;AAEhD,MAAMC,SAAS,CAACC,SAA4CA,OAAOC,GAAG,CAAC,CAACC,IAAMA,EAAEC,K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AAO;YAG3ER,OAAOI,QAAQQ,SAAS,CAAC;YACzBZ,OAAOI,QAAQU,GAAG,CAACF,SAAS,CAAC;YAC7BZ,OAAOI,QAAQU,GAAG,CAACF,SAAS,CAAC;QAC/B;IACF;IAEAb,SAAS,kDAAkD;QACzDE,GAAG,4DAA4D;YAC7D,MAAMO,SAAwB;gBAC5B;oBACEC,MAAM;oBACNC,MAAM;oBACNF,QAAQ;wBACN;4BAAEC,MAAM;4BAASC,MAAM;wBAAO;wBAC9B;4BAAED,MAAM;4BAAQC,MAAM;4BAASF,QAAQ;gCAAC;oCAAEC,MAAM;oCAAOC,MAAM;gCAAO;6BAAE;wBAAC;qBACxE;gBACH;aACD;YAED,MAAMN,SAASD,OAAOD,aAAa;gBAAEW,mBAAmB;gBAAML;YAAO;YAErER,OAAOI,QAAQQ,SAAS,CAAC;YACzBZ,OAAOI,QAAQU,GAAG,CAACF,SAAS,CAAC;QAC/B;QAEAX,GAAG,yDAAyD;YAC1D,MAAMO,SAAwB;gBAC5B;oBACEC,MAAM;oBACNC,MAAM;oBACNF,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,41 +0,0 @@
|
|
|
1
|
-
@layer payload-default {
|
|
2
|
-
.import-preview {
|
|
3
|
-
&__header {
|
|
4
|
-
display: flex;
|
|
5
|
-
justify-content: space-between;
|
|
6
|
-
align-items: flex-end;
|
|
7
|
-
margin-bottom: 10px;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
&__info {
|
|
11
|
-
font-size: var(--font-size-small);
|
|
12
|
-
color: var(--theme-elevation-500);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
&__import-count {
|
|
16
|
-
font-size: var(--font-size-small);
|
|
17
|
-
color: var(--theme-elevation-500);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
&__pagination {
|
|
21
|
-
display: flex;
|
|
22
|
-
align-items: center;
|
|
23
|
-
justify-content: space-between;
|
|
24
|
-
gap: var(--base);
|
|
25
|
-
margin-top: var(--base);
|
|
26
|
-
padding-top: var(--base);
|
|
27
|
-
border-top: 1px solid var(--theme-elevation-100);
|
|
28
|
-
|
|
29
|
-
// When only PerPage is present (no Pagination), keep it on the right
|
|
30
|
-
.per-page:only-child {
|
|
31
|
-
margin-left: auto;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
&__page-info {
|
|
36
|
-
font-size: var(--font-size-small);
|
|
37
|
-
color: var(--theme-elevation-500);
|
|
38
|
-
white-space: nowrap;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
@@ -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;IACdC,SAAS;QACPC,QAAQ;YACNC,OAAOL,GAAGM,EAAE;QACd;IACF;AACF;AAEAT,SAAS,4CAA4C;IACnDE,GAAG,yGAAyG;QAC1G,MAAMQ,SAA2B;YAC/B;gBACEC,MAAM;gBACNC,MAAM;gBACNC,iBAAiB;oBAAC;wBAAEF,MAAM;wBAAQC,MAAM;oBAAO;iBAAoB;YACrE;SACD;QAED,MAAME,aAAmD;YACvDC,MAAM;gBACJH,MAAM;gBACNH,IAAI,CAAC,EAAEO,KAAK,EAAE;oBACZ,MAAMC,MAAOD,SAAS,CAAC;oBACvB,OAAO;wBAAE,GAAGC,GAAG;wBAAEC,MAAM,GAAGD,IAAIC,IAAI,IAAI,GAAG,YAAY,CAAC;oBAAC;gBACzD;YACF;YACAC,WAAW;gBACTP,MAAM;gBACNH,IAAI,CAAC,EAAEO,KAAK,EAAE,GAAK,GAAGA,MAAM,WAAW,CAAC;YAC1C;QACF;QAEA,MAAMI,SAAShB,gBAAgB;YAC7BQ,MAAM;YACNS,MAAM;gBAAEN,MAAM;oBAAEG,MAAM;gBAAM;YAAE;YAC9BJ;YACAJ;YACAY,QAAQ;YACRC,WAAW;YACXC,KAAKnB;QACP;QAEA,iFAAiF;QACjF,4EAA4E;QAC5EJ,OAAOmB,OAAOL,IAAI,EAAEU,OAAO,CAAC;YAAEP,MAAM;QAA6B;IACnE;IAEAhB,GAAG,2EAA2E;QAC5E,MAAMQ,SAA2B;YAC/B;gBACEC,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YACrC;QACF;QAEA,MAAMI,SAAShB,gBAAgB;YAC7BQ,MAAM;YACNS,MAAM;gBAAEK,OAAO;oBAAC;wBAAEK,MAAM;oBAAI;oBAAG;wBAAEA,MAAM;oBAAI;iBAAE;YAAC;YAC9CjB;YACAJ;YACAY,QAAQ;YACRC,WAAW;YACXC,KAAKnB;QACP;QAEAJ,OAAOmB,OAAOM,KAAK,EAAED,OAAO,CAAC;YAAC;gBAAEM,MAAM;YAAiB;YAAG;gBAAEA,MAAM;YAAiB;SAAE;IACvF;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,UAAU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