payload 3.78.0-internal-debug.f663370 → 3.78.0-internal.ab11ffa
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/admin/forms/Form.d.ts +6 -0
- package/dist/admin/forms/Form.d.ts.map +1 -1
- package/dist/admin/forms/Form.js.map +1 -1
- package/dist/admin/views/dashboard.d.ts +19 -4
- package/dist/admin/views/dashboard.d.ts.map +1 -1
- package/dist/admin/views/dashboard.js.map +1 -1
- package/dist/admin/views/list.d.ts +2 -0
- package/dist/admin/views/list.d.ts.map +1 -1
- package/dist/admin/views/list.js.map +1 -1
- package/dist/bin/generateImportMap/iterateConfig.d.ts.map +1 -1
- package/dist/bin/generateImportMap/iterateConfig.js +10 -0
- package/dist/bin/generateImportMap/iterateConfig.js.map +1 -1
- package/dist/collections/config/types.d.ts +0 -1
- package/dist/collections/config/types.d.ts.map +1 -1
- package/dist/collections/config/types.js.map +1 -1
- package/dist/collections/operations/update.d.ts.map +1 -1
- package/dist/collections/operations/update.js +2 -0
- package/dist/collections/operations/update.js.map +1 -1
- package/dist/collections/operations/updateByID.d.ts.map +1 -1
- package/dist/collections/operations/updateByID.js +2 -0
- package/dist/collections/operations/updateByID.js.map +1 -1
- package/dist/config/client.d.ts +4 -2
- package/dist/config/client.d.ts.map +1 -1
- package/dist/config/client.js +10 -2
- package/dist/config/client.js.map +1 -1
- package/dist/config/sanitize.d.ts.map +1 -1
- package/dist/config/sanitize.js +13 -0
- package/dist/config/sanitize.js.map +1 -1
- package/dist/config/types.d.ts +14 -5
- package/dist/config/types.d.ts.map +1 -1
- package/dist/config/types.js.map +1 -1
- package/dist/database/queryValidation/validateQueryPaths.d.ts.map +1 -1
- package/dist/database/queryValidation/validateQueryPaths.js +4 -0
- package/dist/database/queryValidation/validateQueryPaths.js.map +1 -1
- package/dist/exports/shared.d.ts +1 -0
- package/dist/exports/shared.d.ts.map +1 -1
- package/dist/exports/shared.js +1 -0
- package/dist/exports/shared.js.map +1 -1
- package/dist/index.bundled.d.ts +60 -11
- package/dist/index.d.ts +13 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/uploads/endpoints/getFileFromURL.d.ts.map +1 -1
- package/dist/uploads/endpoints/getFileFromURL.js +4 -1
- package/dist/uploads/endpoints/getFileFromURL.js.map +1 -1
- package/dist/uploads/generateFileData.js +1 -1
- package/dist/uploads/generateFileData.js.map +1 -1
- package/dist/utilities/addDataAndFileToRequest.d.ts.map +1 -1
- package/dist/utilities/addDataAndFileToRequest.js +7 -5
- package/dist/utilities/addDataAndFileToRequest.js.map +1 -1
- package/dist/utilities/configToJSONSchema.d.ts.map +1 -1
- package/dist/utilities/configToJSONSchema.js +105 -6
- package/dist/utilities/configToJSONSchema.js.map +1 -1
- package/dist/utilities/configToJSONSchema.spec.js +36 -4
- package/dist/utilities/configToJSONSchema.spec.js.map +1 -1
- package/dist/utilities/filterDataToSelectedLocales.d.ts.map +1 -1
- package/dist/utilities/filterDataToSelectedLocales.js +7 -1
- package/dist/utilities/filterDataToSelectedLocales.js.map +1 -1
- package/dist/utilities/filterDataToSelectedLocales.spec.js +193 -0
- package/dist/utilities/filterDataToSelectedLocales.spec.js.map +1 -0
- package/dist/utilities/mergeLocalizedData.d.ts.map +1 -1
- package/dist/utilities/mergeLocalizedData.js +51 -16
- package/dist/utilities/mergeLocalizedData.js.map +1 -1
- package/dist/utilities/mergeLocalizedData.spec.js +324 -0
- package/dist/utilities/mergeLocalizedData.spec.js.map +1 -1
- package/dist/utilities/sanitizeFilename.d.ts +6 -0
- package/dist/utilities/sanitizeFilename.d.ts.map +1 -0
- package/dist/utilities/sanitizeFilename.js +22 -0
- package/dist/utilities/sanitizeFilename.js.map +1 -0
- package/dist/versions/saveVersion.js +1 -1
- package/dist/versions/saveVersion.js.map +1 -1
- package/package.json +2 -2
|
@@ -778,6 +778,330 @@ describe('mergeLocalizedData', ()=>{
|
|
|
778
778
|
es: 'Spanish Description'
|
|
779
779
|
});
|
|
780
780
|
});
|
|
781
|
+
it('should not lose other locale data when processing unnamed groups', ()=>{
|
|
782
|
+
// https://github.com/payloadcms/payload/issues/15642
|
|
783
|
+
const fields = [
|
|
784
|
+
{
|
|
785
|
+
name: 'textFieldRoot',
|
|
786
|
+
type: 'text'
|
|
787
|
+
},
|
|
788
|
+
{
|
|
789
|
+
name: 'textFieldRootLocalized',
|
|
790
|
+
type: 'text',
|
|
791
|
+
localized: true
|
|
792
|
+
},
|
|
793
|
+
// Unnamed group - fields at same data level as root
|
|
794
|
+
{
|
|
795
|
+
type: 'group',
|
|
796
|
+
fields: [
|
|
797
|
+
{
|
|
798
|
+
name: 'textFieldNested',
|
|
799
|
+
type: 'text'
|
|
800
|
+
},
|
|
801
|
+
{
|
|
802
|
+
name: 'textFieldNestedLocalized',
|
|
803
|
+
type: 'text',
|
|
804
|
+
localized: true
|
|
805
|
+
}
|
|
806
|
+
]
|
|
807
|
+
}
|
|
808
|
+
];
|
|
809
|
+
// Document already has English data published
|
|
810
|
+
const docWithLocales = {
|
|
811
|
+
textFieldRoot: 'Root Value',
|
|
812
|
+
textFieldRootLocalized: {
|
|
813
|
+
en: 'English Root Localized',
|
|
814
|
+
es: 'Spanish Root Localized'
|
|
815
|
+
},
|
|
816
|
+
textFieldNested: 'Nested Value',
|
|
817
|
+
textFieldNestedLocalized: {
|
|
818
|
+
en: 'English Nested Localized',
|
|
819
|
+
es: 'Spanish Nested Localized'
|
|
820
|
+
}
|
|
821
|
+
};
|
|
822
|
+
// Publishing only English locale with updated data
|
|
823
|
+
const dataWithLocales = {
|
|
824
|
+
textFieldRoot: 'Updated Root Value',
|
|
825
|
+
textFieldRootLocalized: {
|
|
826
|
+
en: 'Updated English Root Localized'
|
|
827
|
+
},
|
|
828
|
+
textFieldNested: 'Updated Nested Value',
|
|
829
|
+
textFieldNestedLocalized: {
|
|
830
|
+
en: 'Updated English Nested Localized'
|
|
831
|
+
}
|
|
832
|
+
};
|
|
833
|
+
const result = mergeLocalizedData({
|
|
834
|
+
configBlockReferences: [],
|
|
835
|
+
dataWithLocales,
|
|
836
|
+
docWithLocales,
|
|
837
|
+
fields,
|
|
838
|
+
selectedLocales: [
|
|
839
|
+
'en'
|
|
840
|
+
]
|
|
841
|
+
});
|
|
842
|
+
// Root non-localized field should be updated
|
|
843
|
+
expect(result.textFieldRoot).toBe('Updated Root Value');
|
|
844
|
+
// Root localized field should merge: update en, preserve es
|
|
845
|
+
expect(result.textFieldRootLocalized).toEqual({
|
|
846
|
+
en: 'Updated English Root Localized',
|
|
847
|
+
es: 'Spanish Root Localized'
|
|
848
|
+
});
|
|
849
|
+
// Nested non-localized field should be updated
|
|
850
|
+
expect(result.textFieldNested).toBe('Updated Nested Value');
|
|
851
|
+
// Nested localized field should merge: update en, preserve es
|
|
852
|
+
// This is the bug - es data is lost
|
|
853
|
+
expect(result.textFieldNestedLocalized).toEqual({
|
|
854
|
+
en: 'Updated English Nested Localized',
|
|
855
|
+
es: 'Spanish Nested Localized'
|
|
856
|
+
});
|
|
857
|
+
});
|
|
858
|
+
it('should not lose other locale data when processing row fields', ()=>{
|
|
859
|
+
const fields = [
|
|
860
|
+
{
|
|
861
|
+
type: 'row',
|
|
862
|
+
fields: [
|
|
863
|
+
{
|
|
864
|
+
name: 'rowFieldLocalized',
|
|
865
|
+
type: 'text',
|
|
866
|
+
localized: true
|
|
867
|
+
}
|
|
868
|
+
]
|
|
869
|
+
}
|
|
870
|
+
];
|
|
871
|
+
const docWithLocales = {
|
|
872
|
+
rowFieldLocalized: {
|
|
873
|
+
en: 'English Value',
|
|
874
|
+
es: 'Spanish Value'
|
|
875
|
+
}
|
|
876
|
+
};
|
|
877
|
+
const dataWithLocales = {
|
|
878
|
+
rowFieldLocalized: {
|
|
879
|
+
en: 'Updated English Value'
|
|
880
|
+
}
|
|
881
|
+
};
|
|
882
|
+
const result = mergeLocalizedData({
|
|
883
|
+
configBlockReferences: [],
|
|
884
|
+
dataWithLocales,
|
|
885
|
+
docWithLocales,
|
|
886
|
+
fields,
|
|
887
|
+
selectedLocales: [
|
|
888
|
+
'en'
|
|
889
|
+
]
|
|
890
|
+
});
|
|
891
|
+
expect(result.rowFieldLocalized).toEqual({
|
|
892
|
+
en: 'Updated English Value',
|
|
893
|
+
es: 'Spanish Value'
|
|
894
|
+
});
|
|
895
|
+
});
|
|
896
|
+
it('should preserve other locale data when updating through unnamed tabs', ()=>{
|
|
897
|
+
const fields = [
|
|
898
|
+
{
|
|
899
|
+
type: 'tabs',
|
|
900
|
+
tabs: [
|
|
901
|
+
{
|
|
902
|
+
label: 'Tab 1',
|
|
903
|
+
fields: [
|
|
904
|
+
{
|
|
905
|
+
name: 'tabFieldLocalized',
|
|
906
|
+
type: 'text',
|
|
907
|
+
localized: true
|
|
908
|
+
}
|
|
909
|
+
]
|
|
910
|
+
}
|
|
911
|
+
]
|
|
912
|
+
}
|
|
913
|
+
];
|
|
914
|
+
// Document has both en and es data
|
|
915
|
+
const docWithLocales = {
|
|
916
|
+
tabFieldLocalized: {
|
|
917
|
+
en: 'English Value',
|
|
918
|
+
es: 'Spanish Value'
|
|
919
|
+
}
|
|
920
|
+
};
|
|
921
|
+
// Only updating en
|
|
922
|
+
const dataWithLocales = {
|
|
923
|
+
tabFieldLocalized: {
|
|
924
|
+
en: 'Updated English Value'
|
|
925
|
+
}
|
|
926
|
+
};
|
|
927
|
+
const result = mergeLocalizedData({
|
|
928
|
+
configBlockReferences: [],
|
|
929
|
+
dataWithLocales,
|
|
930
|
+
docWithLocales,
|
|
931
|
+
fields,
|
|
932
|
+
selectedLocales: [
|
|
933
|
+
'en'
|
|
934
|
+
]
|
|
935
|
+
});
|
|
936
|
+
// es should be preserved
|
|
937
|
+
expect(result.tabFieldLocalized).toEqual({
|
|
938
|
+
en: 'Updated English Value',
|
|
939
|
+
es: 'Spanish Value'
|
|
940
|
+
});
|
|
941
|
+
});
|
|
942
|
+
});
|
|
943
|
+
describe('block metadata preservation', ()=>{
|
|
944
|
+
it('should preserve blockType, id, and blockName when existing doc has no blocks', ()=>{
|
|
945
|
+
// Reproduces the bug where autosave creates a doc without blocks,
|
|
946
|
+
// then blocks are added and publishSpecificLocale drops metadata
|
|
947
|
+
const fields = [
|
|
948
|
+
{
|
|
949
|
+
name: 'layout',
|
|
950
|
+
type: 'blocks',
|
|
951
|
+
blocks: [
|
|
952
|
+
{
|
|
953
|
+
slug: 'content',
|
|
954
|
+
fields: [
|
|
955
|
+
{
|
|
956
|
+
name: 'richText',
|
|
957
|
+
type: 'richText',
|
|
958
|
+
localized: true
|
|
959
|
+
}
|
|
960
|
+
]
|
|
961
|
+
}
|
|
962
|
+
]
|
|
963
|
+
}
|
|
964
|
+
];
|
|
965
|
+
// Main doc has no blocks (autosave wrote before blocks were added)
|
|
966
|
+
const docWithLocales = {};
|
|
967
|
+
const dataWithLocales = {
|
|
968
|
+
layout: [
|
|
969
|
+
{
|
|
970
|
+
blockType: 'content',
|
|
971
|
+
id: 'abc123',
|
|
972
|
+
blockName: 'My Content Block',
|
|
973
|
+
richText: {
|
|
974
|
+
en: 'Hello'
|
|
975
|
+
}
|
|
976
|
+
}
|
|
977
|
+
]
|
|
978
|
+
};
|
|
979
|
+
const result = mergeLocalizedData({
|
|
980
|
+
configBlockReferences: [],
|
|
981
|
+
dataWithLocales,
|
|
982
|
+
docWithLocales,
|
|
983
|
+
fields,
|
|
984
|
+
selectedLocales: [
|
|
985
|
+
'en'
|
|
986
|
+
]
|
|
987
|
+
});
|
|
988
|
+
expect(result.layout).toHaveLength(1);
|
|
989
|
+
expect(result.layout[0].blockType).toBe('content');
|
|
990
|
+
expect(result.layout[0].id).toBe('abc123');
|
|
991
|
+
expect(result.layout[0].blockName).toBe('My Content Block');
|
|
992
|
+
});
|
|
993
|
+
it('should preserve blockType and id when existing doc has undefined for block field', ()=>{
|
|
994
|
+
const fields = [
|
|
995
|
+
{
|
|
996
|
+
name: 'layout',
|
|
997
|
+
type: 'blocks',
|
|
998
|
+
blocks: [
|
|
999
|
+
{
|
|
1000
|
+
slug: 'text',
|
|
1001
|
+
fields: [
|
|
1002
|
+
{
|
|
1003
|
+
name: 'text',
|
|
1004
|
+
type: 'text',
|
|
1005
|
+
localized: true
|
|
1006
|
+
}
|
|
1007
|
+
]
|
|
1008
|
+
}
|
|
1009
|
+
]
|
|
1010
|
+
}
|
|
1011
|
+
];
|
|
1012
|
+
// existingValue is undefined (field not present in existing doc)
|
|
1013
|
+
const docWithLocales = {
|
|
1014
|
+
layout: undefined
|
|
1015
|
+
};
|
|
1016
|
+
const dataWithLocales = {
|
|
1017
|
+
layout: [
|
|
1018
|
+
{
|
|
1019
|
+
blockType: 'text',
|
|
1020
|
+
id: 'def456',
|
|
1021
|
+
text: {
|
|
1022
|
+
en: 'English text',
|
|
1023
|
+
es: 'Spanish text'
|
|
1024
|
+
}
|
|
1025
|
+
}
|
|
1026
|
+
]
|
|
1027
|
+
};
|
|
1028
|
+
const result = mergeLocalizedData({
|
|
1029
|
+
configBlockReferences: [],
|
|
1030
|
+
dataWithLocales,
|
|
1031
|
+
docWithLocales,
|
|
1032
|
+
fields,
|
|
1033
|
+
selectedLocales: [
|
|
1034
|
+
'en'
|
|
1035
|
+
]
|
|
1036
|
+
});
|
|
1037
|
+
expect(result.layout).toHaveLength(1);
|
|
1038
|
+
expect(result.layout[0].blockType).toBe('text');
|
|
1039
|
+
expect(result.layout[0].id).toBe('def456');
|
|
1040
|
+
expect(result.layout[0].text).toEqual({
|
|
1041
|
+
en: 'English text'
|
|
1042
|
+
});
|
|
1043
|
+
});
|
|
1044
|
+
it('should preserve blockType when existing doc already has blocks', ()=>{
|
|
1045
|
+
// Ensures the fix doesn't break the happy path
|
|
1046
|
+
const fields = [
|
|
1047
|
+
{
|
|
1048
|
+
name: 'layout',
|
|
1049
|
+
type: 'blocks',
|
|
1050
|
+
blocks: [
|
|
1051
|
+
{
|
|
1052
|
+
slug: 'content',
|
|
1053
|
+
fields: [
|
|
1054
|
+
{
|
|
1055
|
+
name: 'body',
|
|
1056
|
+
type: 'text',
|
|
1057
|
+
localized: true
|
|
1058
|
+
}
|
|
1059
|
+
]
|
|
1060
|
+
}
|
|
1061
|
+
]
|
|
1062
|
+
}
|
|
1063
|
+
];
|
|
1064
|
+
const docWithLocales = {
|
|
1065
|
+
layout: [
|
|
1066
|
+
{
|
|
1067
|
+
blockType: 'content',
|
|
1068
|
+
id: 'existing-id',
|
|
1069
|
+
body: {
|
|
1070
|
+
en: 'Old English',
|
|
1071
|
+
es: 'Old Spanish'
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
]
|
|
1075
|
+
};
|
|
1076
|
+
const dataWithLocales = {
|
|
1077
|
+
layout: [
|
|
1078
|
+
{
|
|
1079
|
+
blockType: 'content',
|
|
1080
|
+
id: 'existing-id',
|
|
1081
|
+
body: {
|
|
1082
|
+
en: 'New English',
|
|
1083
|
+
es: 'New Spanish'
|
|
1084
|
+
}
|
|
1085
|
+
}
|
|
1086
|
+
]
|
|
1087
|
+
};
|
|
1088
|
+
const result = mergeLocalizedData({
|
|
1089
|
+
configBlockReferences: [],
|
|
1090
|
+
dataWithLocales,
|
|
1091
|
+
docWithLocales,
|
|
1092
|
+
fields,
|
|
1093
|
+
selectedLocales: [
|
|
1094
|
+
'en'
|
|
1095
|
+
]
|
|
1096
|
+
});
|
|
1097
|
+
expect(result.layout).toHaveLength(1);
|
|
1098
|
+
expect(result.layout[0].blockType).toBe('content');
|
|
1099
|
+
expect(result.layout[0].id).toBe('existing-id');
|
|
1100
|
+
expect(result.layout[0].body).toEqual({
|
|
1101
|
+
en: 'New English',
|
|
1102
|
+
es: 'Old Spanish'
|
|
1103
|
+
});
|
|
1104
|
+
});
|
|
781
1105
|
});
|
|
782
1106
|
});
|
|
783
1107
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/mergeLocalizedData.spec.ts"],"sourcesContent":["import type { Field } from '../fields/config/types.js'\n\nimport { describe, expect, it } from 'vitest'\n\nimport { mergeLocalizedData } from './mergeLocalizedData.js'\n\ndescribe('mergeLocalizedData', () => {\n const selectedLocales = ['en']\n const configBlockReferences = []\n\n describe('simple fields', () => {\n it('should merge localized field values for selected locales', () => {\n const fields: Field[] = [\n {\n name: 'title',\n type: 'text',\n localized: true,\n },\n ]\n\n const docWithLocales = {\n title: {\n en: 'English Title',\n es: 'Spanish Title',\n de: 'German Title',\n },\n }\n\n const dataWithLocales = {\n title: {\n en: 'Updated English Title',\n es: 'Updated Spanish Title',\n },\n }\n\n const result = mergeLocalizedData({\n configBlockReferences: [],\n dataWithLocales,\n docWithLocales,\n fields,\n selectedLocales,\n })\n\n expect(result.title).toEqual({\n en: 'Updated English Title',\n es: 'Spanish Title',\n de: 'German Title',\n })\n })\n\n it('should keep doc value for non-localized fields', () => {\n const fields: Field[] = [\n {\n name: 'title',\n type: 'text',\n localized: false,\n },\n ]\n\n const result = mergeLocalizedData({\n configBlockReferences: [],\n dataWithLocales: {\n title: 'New Title',\n },\n docWithLocales: {\n title: 'Old Title',\n },\n fields,\n selectedLocales,\n })\n\n expect(result.title).toBe('New Title')\n\n const missingData = mergeLocalizedData({\n configBlockReferences: [],\n dataWithLocales: {},\n docWithLocales: {\n title: 'Old Title',\n },\n fields,\n selectedLocales,\n })\n\n expect(missingData.title).toBe('Old Title')\n\n const updatedData = mergeLocalizedData({\n configBlockReferences: [],\n dataWithLocales: {\n title: 'Updated Title',\n },\n docWithLocales: {},\n fields,\n selectedLocales,\n })\n\n expect(updatedData.title).toBe('Updated Title')\n })\n })\n\n describe('groups', () => {\n it('should merge localized group with locale keys at top level', () => {\n const fields: Field[] = [\n {\n name: 'meta',\n type: 'group',\n localized: true,\n fields: [\n {\n name: 'title',\n type: 'text',\n },\n {\n name: 'description',\n type: 'text',\n },\n ],\n },\n ]\n\n const docWithLocales = {\n meta: {\n en: {\n title: 'EN Title',\n description: 'EN Desc',\n },\n es: {\n title: 'ES Title',\n description: 'ES Desc',\n },\n },\n }\n\n const dataWithLocales = {\n meta: {\n en: {\n title: 'Updated EN Title',\n description: 'Updated EN Desc',\n },\n },\n }\n\n const result = mergeLocalizedData({\n configBlockReferences: [],\n dataWithLocales,\n docWithLocales,\n fields,\n selectedLocales,\n })\n\n expect(result.meta).toEqual({\n en: {\n title: 'Updated EN Title',\n description: 'Updated EN Desc',\n },\n es: {\n title: 'ES Title',\n description: 'ES Desc',\n },\n })\n })\n\n it('should handle non-localized group with localized children', () => {\n const fields: Field[] = [\n {\n name: 'meta',\n type: 'group',\n localized: false,\n fields: [\n {\n name: 'title',\n type: 'text',\n localized: true,\n },\n {\n name: 'version',\n type: 'number',\n localized: false,\n },\n ],\n },\n ]\n\n const docWithLocales = {\n meta: {\n title: {\n en: 'EN Title',\n es: 'ES Title',\n },\n version: 1,\n },\n }\n\n const dataWithLocales = {\n meta: {\n title: {\n en: 'Updated EN Title',\n },\n version: 2,\n },\n }\n\n const result = mergeLocalizedData({\n configBlockReferences: [],\n dataWithLocales,\n docWithLocales,\n fields,\n selectedLocales,\n })\n\n expect(result.meta).toEqual({\n title: {\n en: 'Updated EN Title',\n es: 'ES Title',\n },\n version: 2,\n })\n })\n })\n\n describe('arrays', () => {\n it('should merge localized array with locale keys at top level', () => {\n const fields: Field[] = [\n {\n name: 'items',\n type: 'array',\n localized: true,\n fields: [\n {\n name: 'name',\n type: 'text',\n },\n ],\n },\n ]\n\n const docWithLocales = {\n items: {\n en: [{ name: 'EN Item 1' }, { name: 'EN Item 2' }],\n es: [{ name: 'ES Item 1' }],\n },\n }\n\n const dataWithLocales = {\n items: {\n en: [{ name: 'Updated EN Item 1' }, { name: 'Updated EN Item 2' }],\n },\n }\n\n const result = mergeLocalizedData({\n configBlockReferences: [],\n dataWithLocales,\n docWithLocales,\n fields,\n selectedLocales,\n })\n\n expect(result.items).toEqual({\n en: [{ name: 'Updated EN Item 1' }, { name: 'Updated EN Item 2' }],\n es: [{ name: 'ES Item 1' }],\n })\n })\n\n it('should handle non-localized array with localized children', () => {\n const fields: Field[] = [\n {\n name: 'items',\n type: 'array',\n localized: false,\n fields: [\n {\n name: 'name',\n type: 'text',\n localized: true,\n },\n ],\n },\n ]\n\n const docWithLocales = {\n items: [\n {\n name: {\n en: 'EN Item 1',\n es: 'ES Item 1',\n },\n },\n {\n name: {\n en: 'EN Item 2',\n es: 'ES Item 2',\n },\n },\n ],\n }\n\n const dataWithLocales = {\n items: [\n {\n name: {\n en: 'Updated EN Item 1',\n },\n },\n {\n name: {\n en: 'Updated EN Item 2',\n },\n },\n ],\n }\n\n const result = mergeLocalizedData({\n configBlockReferences: [],\n dataWithLocales,\n docWithLocales,\n fields,\n selectedLocales,\n })\n\n expect(result.items).toEqual([\n {\n name: {\n en: 'Updated EN Item 1',\n es: 'ES Item 1',\n },\n },\n {\n name: {\n en: 'Updated EN Item 2',\n es: 'ES Item 2',\n },\n },\n ])\n })\n })\n\n describe('blocks', () => {\n it('should merge localized blocks with locale keys at top level', () => {\n const fields: Field[] = [\n {\n name: 'content',\n type: 'blocks',\n localized: true,\n blocks: [\n {\n slug: 'text',\n fields: [\n {\n name: 'text',\n type: 'text',\n },\n ],\n },\n ],\n },\n ]\n\n const docWithLocales = {\n content: {\n en: [{ blockType: 'text', text: 'EN Text' }],\n es: [{ blockType: 'text', text: 'ES Text' }],\n },\n }\n\n const dataWithLocales = {\n content: {\n en: [{ blockType: 'text', text: 'Updated EN Text' }],\n },\n }\n\n const result = mergeLocalizedData({\n configBlockReferences: [],\n dataWithLocales,\n docWithLocales,\n fields,\n selectedLocales,\n })\n\n expect(result.content).toEqual({\n en: [{ blockType: 'text', text: 'Updated EN Text' }],\n es: [{ blockType: 'text', text: 'ES Text' }],\n })\n })\n\n it('should handle blocks with nested arrays', () => {\n const fields: Field[] = [\n {\n name: 'content',\n type: 'blocks',\n localized: true,\n blocks: [\n {\n slug: 'nested',\n fields: [\n {\n name: 'items',\n type: 'array',\n fields: [\n {\n name: 'name',\n type: 'text',\n },\n ],\n },\n ],\n },\n ],\n },\n ]\n\n const docWithLocales = {\n content: {\n en: [\n {\n blockType: 'nested',\n items: [{ name: 'EN Item 1' }],\n },\n ],\n es: [\n {\n blockType: 'nested',\n items: [{ name: 'ES Item 1' }],\n },\n ],\n },\n }\n\n const dataWithLocales = {\n content: {\n en: [\n {\n blockType: 'nested',\n items: [{ name: 'Updated EN Item 1' }],\n },\n ],\n },\n }\n\n const result = mergeLocalizedData({\n configBlockReferences: [],\n dataWithLocales,\n docWithLocales,\n fields,\n selectedLocales,\n })\n\n expect(result.content).toEqual({\n en: [\n {\n blockType: 'nested',\n items: [{ name: 'Updated EN Item 1' }],\n },\n ],\n es: [\n {\n blockType: 'nested',\n items: [{ name: 'ES Item 1' }],\n },\n ],\n })\n })\n })\n\n describe('tabs', () => {\n it('should merge localized named tabs with locale keys at top level', () => {\n const fields: Field[] = [\n {\n type: 'tabs',\n tabs: [\n {\n name: 'meta',\n localized: true,\n fields: [\n {\n name: 'title',\n type: 'text',\n },\n ],\n },\n ],\n },\n ]\n\n const docWithLocales = {\n meta: {\n en: {\n title: 'EN Title',\n },\n es: {\n title: 'ES Title',\n },\n },\n }\n\n const dataWithLocales = {\n meta: {\n en: {\n title: 'Updated EN Title',\n },\n },\n }\n\n const result = mergeLocalizedData({\n configBlockReferences: [],\n dataWithLocales,\n docWithLocales,\n fields,\n selectedLocales,\n })\n\n expect(result.meta).toEqual({\n en: {\n title: 'Updated EN Title',\n },\n es: {\n title: 'ES Title',\n },\n })\n })\n\n it('should handle unnamed tabs with localized fields', () => {\n const fields: Field[] = [\n {\n type: 'tabs',\n tabs: [\n {\n label: 'tab1',\n fields: [\n {\n name: 'title',\n type: 'text',\n localized: true,\n },\n ],\n },\n ],\n },\n ]\n\n const docWithLocales = {\n title: {\n en: 'EN Title',\n es: 'ES Title',\n },\n }\n\n const dataWithLocales = {\n title: {\n en: 'Updated EN Title',\n },\n }\n\n const result = mergeLocalizedData({\n configBlockReferences: [],\n dataWithLocales,\n docWithLocales,\n fields,\n selectedLocales,\n })\n\n expect(result.title).toEqual({\n en: 'Updated EN Title',\n es: 'ES Title',\n })\n })\n })\n\n describe('deeply nested structures', () => {\n it('should handle multiple levels of nesting with locale keys only at topmost localized field', () => {\n const fields: Field[] = [\n {\n name: 'outer',\n type: 'group',\n localized: true,\n fields: [\n {\n name: 'inner',\n type: 'group',\n localized: false,\n fields: [\n {\n name: 'items',\n type: 'array',\n localized: false,\n fields: [\n {\n name: 'text',\n type: 'text',\n localized: false,\n },\n ],\n },\n ],\n },\n ],\n },\n ]\n\n const docWithLocales = {\n outer: {\n en: {\n inner: {\n items: [{ text: 'EN Item 1' }],\n },\n },\n es: {\n inner: {\n items: [{ text: 'ES Item 1' }],\n },\n },\n },\n }\n\n const dataWithLocales = {\n outer: {\n en: {\n inner: {\n items: [{ text: 'Updated EN Item 1' }],\n },\n },\n },\n }\n\n const result = mergeLocalizedData({\n configBlockReferences: [],\n dataWithLocales,\n docWithLocales,\n fields,\n selectedLocales,\n })\n\n expect(result.outer).toEqual({\n en: {\n inner: {\n items: [{ text: 'Updated EN Item 1' }],\n },\n },\n es: {\n inner: {\n items: [{ text: 'ES Item 1' }],\n },\n },\n })\n })\n })\n\n describe('multiple selected locales', () => {\n it('should merge multiple locales when selected', () => {\n const fields: Field[] = [\n {\n name: 'title',\n type: 'text',\n localized: true,\n },\n ]\n\n const docWithLocales = {\n title: {\n en: 'EN Title',\n es: 'ES Title',\n de: 'DE Title',\n fr: 'FR Title',\n },\n }\n\n const dataWithLocales = {\n title: {\n en: 'Updated EN Title',\n es: 'Updated ES Title',\n },\n }\n\n const result = mergeLocalizedData({\n configBlockReferences: [],\n dataWithLocales,\n docWithLocales,\n fields,\n selectedLocales: ['en', 'es'],\n })\n\n expect(result.title).toEqual({\n en: 'Updated EN Title',\n es: 'Updated ES Title',\n de: 'DE Title',\n fr: 'FR Title',\n })\n })\n })\n\n describe('pass through fields, rows, collapsibles, unnamed tabs, unnamed groups', () => {\n it('should not lose merged locale data when processing unnamed tabs', () => {\n const fields: Field[] = [\n {\n name: 'title',\n type: 'text',\n localized: true,\n },\n {\n type: 'tabs',\n tabs: [\n {\n label: 'Other Fields',\n fields: [\n {\n name: 'description',\n type: 'text',\n localized: true,\n },\n ],\n },\n ],\n },\n ]\n\n const docWithLocales = {\n title: {\n en: 'English Title',\n },\n description: {\n en: 'English Description',\n },\n }\n\n const dataWithLocales = {\n title: {\n en: 'English Title',\n es: 'Spanish Title',\n },\n description: {\n en: 'English Description',\n es: 'Spanish Description',\n },\n }\n\n const result = mergeLocalizedData({\n configBlockReferences: [],\n dataWithLocales,\n docWithLocales,\n fields,\n selectedLocales: ['es'],\n })\n\n expect(result.title).toEqual({\n en: 'English Title',\n es: 'Spanish Title',\n })\n\n expect(result.description).toEqual({\n en: 'English Description',\n es: 'Spanish Description',\n })\n })\n })\n})\n"],"names":["describe","expect","it","mergeLocalizedData","selectedLocales","configBlockReferences","fields","name","type","localized","docWithLocales","title","en","es","de","dataWithLocales","result","toEqual","toBe","missingData","updatedData","meta","description","version","items","blocks","slug","content","blockType","text","tabs","label","outer","inner","fr"],"mappings":"AAEA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,SAAQ;AAE7C,SAASC,kBAAkB,QAAQ,0BAAyB;AAE5DH,SAAS,sBAAsB;IAC7B,MAAMI,kBAAkB;QAAC;KAAK;IAC9B,MAAMC,wBAAwB,EAAE;IAEhCL,SAAS,iBAAiB;QACxBE,GAAG,4DAA4D;YAC7D,MAAMI,SAAkB;gBACtB;oBACEC,MAAM;oBACNC,MAAM;oBACNC,WAAW;gBACb;aACD;YAED,MAAMC,iBAAiB;gBACrBC,OAAO;oBACLC,IAAI;oBACJC,IAAI;oBACJC,IAAI;gBACN;YACF;YAEA,MAAMC,kBAAkB;gBACtBJ,OAAO;oBACLC,IAAI;oBACJC,IAAI;gBACN;YACF;YAEA,MAAMG,SAASb,mBAAmB;gBAChCE,uBAAuB,EAAE;gBACzBU;gBACAL;gBACAJ;gBACAF;YACF;YA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BACAL;gBACAJ;gBACAF,iBAAiB;oBAAC;iBAAK;YACzB;YAEAH,OAAOe,OAAOL,KAAK,EAAEM,OAAO,CAAC;gBAC3BL,IAAI;gBACJC,IAAI;YACN;YAEAZ,OAAOe,OAAOM,WAAW,EAAEL,OAAO,CAAC;gBACjCL,IAAI;gBACJC,IAAI;YACN;QACF;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/mergeLocalizedData.spec.ts"],"sourcesContent":["import type { Field } from '../fields/config/types.js'\n\nimport { describe, expect, it } from 'vitest'\n\nimport { mergeLocalizedData } from './mergeLocalizedData.js'\n\ndescribe('mergeLocalizedData', () => {\n const selectedLocales = ['en']\n const configBlockReferences = []\n\n describe('simple fields', () => {\n it('should merge localized field values for selected locales', () => {\n const fields: Field[] = [\n {\n name: 'title',\n type: 'text',\n localized: true,\n },\n ]\n\n const docWithLocales = {\n title: {\n en: 'English Title',\n es: 'Spanish Title',\n de: 'German Title',\n },\n }\n\n const dataWithLocales = {\n title: {\n en: 'Updated English Title',\n es: 'Updated Spanish Title',\n },\n }\n\n const result = mergeLocalizedData({\n configBlockReferences: [],\n dataWithLocales,\n docWithLocales,\n fields,\n selectedLocales,\n })\n\n expect(result.title).toEqual({\n en: 'Updated English Title',\n es: 'Spanish Title',\n de: 'German Title',\n })\n })\n\n it('should keep doc value for non-localized fields', () => {\n const fields: Field[] = [\n {\n name: 'title',\n type: 'text',\n localized: false,\n },\n ]\n\n const result = mergeLocalizedData({\n configBlockReferences: [],\n dataWithLocales: {\n title: 'New Title',\n },\n docWithLocales: {\n title: 'Old Title',\n },\n fields,\n selectedLocales,\n })\n\n expect(result.title).toBe('New Title')\n\n const missingData = mergeLocalizedData({\n configBlockReferences: [],\n dataWithLocales: {},\n docWithLocales: {\n title: 'Old Title',\n },\n fields,\n selectedLocales,\n })\n\n expect(missingData.title).toBe('Old Title')\n\n const updatedData = mergeLocalizedData({\n configBlockReferences: [],\n dataWithLocales: {\n title: 'Updated Title',\n },\n docWithLocales: {},\n fields,\n selectedLocales,\n })\n\n expect(updatedData.title).toBe('Updated Title')\n })\n })\n\n describe('groups', () => {\n it('should merge localized group with locale keys at top level', () => {\n const fields: Field[] = [\n {\n name: 'meta',\n type: 'group',\n localized: true,\n fields: [\n {\n name: 'title',\n type: 'text',\n },\n {\n name: 'description',\n type: 'text',\n },\n ],\n },\n ]\n\n const docWithLocales = {\n meta: {\n en: {\n title: 'EN Title',\n description: 'EN Desc',\n },\n es: {\n title: 'ES Title',\n description: 'ES Desc',\n },\n },\n }\n\n const dataWithLocales = {\n meta: {\n en: {\n title: 'Updated EN Title',\n description: 'Updated EN Desc',\n },\n },\n }\n\n const result = mergeLocalizedData({\n configBlockReferences: [],\n dataWithLocales,\n docWithLocales,\n fields,\n selectedLocales,\n })\n\n expect(result.meta).toEqual({\n en: {\n title: 'Updated EN Title',\n description: 'Updated EN Desc',\n },\n es: {\n title: 'ES Title',\n description: 'ES Desc',\n },\n })\n })\n\n it('should handle non-localized group with localized children', () => {\n const fields: Field[] = [\n {\n name: 'meta',\n type: 'group',\n localized: false,\n fields: [\n {\n name: 'title',\n type: 'text',\n localized: true,\n },\n {\n name: 'version',\n type: 'number',\n localized: false,\n },\n ],\n },\n ]\n\n const docWithLocales = {\n meta: {\n title: {\n en: 'EN Title',\n es: 'ES Title',\n },\n version: 1,\n },\n }\n\n const dataWithLocales = {\n meta: {\n title: {\n en: 'Updated EN Title',\n },\n version: 2,\n },\n }\n\n const result = mergeLocalizedData({\n configBlockReferences: [],\n dataWithLocales,\n docWithLocales,\n fields,\n selectedLocales,\n })\n\n expect(result.meta).toEqual({\n title: {\n en: 'Updated EN Title',\n es: 'ES Title',\n },\n version: 2,\n })\n })\n })\n\n describe('arrays', () => {\n it('should merge localized array with locale keys at top level', () => {\n const fields: Field[] = [\n {\n name: 'items',\n type: 'array',\n localized: true,\n fields: [\n {\n name: 'name',\n type: 'text',\n },\n ],\n },\n ]\n\n const docWithLocales = {\n items: {\n en: [{ name: 'EN Item 1' }, { name: 'EN Item 2' }],\n es: [{ name: 'ES Item 1' }],\n },\n }\n\n const dataWithLocales = {\n items: {\n en: [{ name: 'Updated EN Item 1' }, { name: 'Updated EN Item 2' }],\n },\n }\n\n const result = mergeLocalizedData({\n configBlockReferences: [],\n dataWithLocales,\n docWithLocales,\n fields,\n selectedLocales,\n })\n\n expect(result.items).toEqual({\n en: [{ name: 'Updated EN Item 1' }, { name: 'Updated EN Item 2' }],\n es: [{ name: 'ES Item 1' }],\n })\n })\n\n it('should handle non-localized array with localized children', () => {\n const fields: Field[] = [\n {\n name: 'items',\n type: 'array',\n localized: false,\n fields: [\n {\n name: 'name',\n type: 'text',\n localized: true,\n },\n ],\n },\n ]\n\n const docWithLocales = {\n items: [\n {\n name: {\n en: 'EN Item 1',\n es: 'ES Item 1',\n },\n },\n {\n name: {\n en: 'EN Item 2',\n es: 'ES Item 2',\n },\n },\n ],\n }\n\n const dataWithLocales = {\n items: [\n {\n name: {\n en: 'Updated EN Item 1',\n },\n },\n {\n name: {\n en: 'Updated EN Item 2',\n },\n },\n ],\n }\n\n const result = mergeLocalizedData({\n configBlockReferences: [],\n dataWithLocales,\n docWithLocales,\n fields,\n selectedLocales,\n })\n\n expect(result.items).toEqual([\n {\n name: {\n en: 'Updated EN Item 1',\n es: 'ES Item 1',\n },\n },\n {\n name: {\n en: 'Updated EN Item 2',\n es: 'ES Item 2',\n },\n },\n ])\n })\n })\n\n describe('blocks', () => {\n it('should merge localized blocks with locale keys at top level', () => {\n const fields: Field[] = [\n {\n name: 'content',\n type: 'blocks',\n localized: true,\n blocks: [\n {\n slug: 'text',\n fields: [\n {\n name: 'text',\n type: 'text',\n },\n ],\n },\n ],\n },\n ]\n\n const docWithLocales = {\n content: {\n en: [{ blockType: 'text', text: 'EN Text' }],\n es: [{ blockType: 'text', text: 'ES Text' }],\n },\n }\n\n const dataWithLocales = {\n content: {\n en: [{ blockType: 'text', text: 'Updated EN Text' }],\n },\n }\n\n const result = mergeLocalizedData({\n configBlockReferences: [],\n dataWithLocales,\n docWithLocales,\n fields,\n selectedLocales,\n })\n\n expect(result.content).toEqual({\n en: [{ blockType: 'text', text: 'Updated EN Text' }],\n es: [{ blockType: 'text', text: 'ES Text' }],\n })\n })\n\n it('should handle blocks with nested arrays', () => {\n const fields: Field[] = [\n {\n name: 'content',\n type: 'blocks',\n localized: true,\n blocks: [\n {\n slug: 'nested',\n fields: [\n {\n name: 'items',\n type: 'array',\n fields: [\n {\n name: 'name',\n type: 'text',\n },\n ],\n },\n ],\n },\n ],\n },\n ]\n\n const docWithLocales = {\n content: {\n en: [\n {\n blockType: 'nested',\n items: [{ name: 'EN Item 1' }],\n },\n ],\n es: [\n {\n blockType: 'nested',\n items: [{ name: 'ES Item 1' }],\n },\n ],\n },\n }\n\n const dataWithLocales = {\n content: {\n en: [\n {\n blockType: 'nested',\n items: [{ name: 'Updated EN Item 1' }],\n },\n ],\n },\n }\n\n const result = mergeLocalizedData({\n configBlockReferences: [],\n dataWithLocales,\n docWithLocales,\n fields,\n selectedLocales,\n })\n\n expect(result.content).toEqual({\n en: [\n {\n blockType: 'nested',\n items: [{ name: 'Updated EN Item 1' }],\n },\n ],\n es: [\n {\n blockType: 'nested',\n items: [{ name: 'ES Item 1' }],\n },\n ],\n })\n })\n })\n\n describe('tabs', () => {\n it('should merge localized named tabs with locale keys at top level', () => {\n const fields: Field[] = [\n {\n type: 'tabs',\n tabs: [\n {\n name: 'meta',\n localized: true,\n fields: [\n {\n name: 'title',\n type: 'text',\n },\n ],\n },\n ],\n },\n ]\n\n const docWithLocales = {\n meta: {\n en: {\n title: 'EN Title',\n },\n es: {\n title: 'ES Title',\n },\n },\n }\n\n const dataWithLocales = {\n meta: {\n en: {\n title: 'Updated EN Title',\n },\n },\n }\n\n const result = mergeLocalizedData({\n configBlockReferences: [],\n dataWithLocales,\n docWithLocales,\n fields,\n selectedLocales,\n })\n\n expect(result.meta).toEqual({\n en: {\n title: 'Updated EN Title',\n },\n es: {\n title: 'ES Title',\n },\n })\n })\n\n it('should handle unnamed tabs with localized fields', () => {\n const fields: Field[] = [\n {\n type: 'tabs',\n tabs: [\n {\n label: 'tab1',\n fields: [\n {\n name: 'title',\n type: 'text',\n localized: true,\n },\n ],\n },\n ],\n },\n ]\n\n const docWithLocales = {\n title: {\n en: 'EN Title',\n es: 'ES Title',\n },\n }\n\n const dataWithLocales = {\n title: {\n en: 'Updated EN Title',\n },\n }\n\n const result = mergeLocalizedData({\n configBlockReferences: [],\n dataWithLocales,\n docWithLocales,\n fields,\n selectedLocales,\n })\n\n expect(result.title).toEqual({\n en: 'Updated EN Title',\n es: 'ES Title',\n })\n })\n })\n\n describe('deeply nested structures', () => {\n it('should handle multiple levels of nesting with locale keys only at topmost localized field', () => {\n const fields: Field[] = [\n {\n name: 'outer',\n type: 'group',\n localized: true,\n fields: [\n {\n name: 'inner',\n type: 'group',\n localized: false,\n fields: [\n {\n name: 'items',\n type: 'array',\n localized: false,\n fields: [\n {\n name: 'text',\n type: 'text',\n localized: false,\n },\n ],\n },\n ],\n },\n ],\n },\n ]\n\n const docWithLocales = {\n outer: {\n en: {\n inner: {\n items: [{ text: 'EN Item 1' }],\n },\n },\n es: {\n inner: {\n items: [{ text: 'ES Item 1' }],\n },\n },\n },\n }\n\n const dataWithLocales = {\n outer: {\n en: {\n inner: {\n items: [{ text: 'Updated EN Item 1' }],\n },\n },\n },\n }\n\n const result = mergeLocalizedData({\n configBlockReferences: [],\n dataWithLocales,\n docWithLocales,\n fields,\n selectedLocales,\n })\n\n expect(result.outer).toEqual({\n en: {\n inner: {\n items: [{ text: 'Updated EN Item 1' }],\n },\n },\n es: {\n inner: {\n items: [{ text: 'ES Item 1' }],\n },\n },\n })\n })\n })\n\n describe('multiple selected locales', () => {\n it('should merge multiple locales when selected', () => {\n const fields: Field[] = [\n {\n name: 'title',\n type: 'text',\n localized: true,\n },\n ]\n\n const docWithLocales = {\n title: {\n en: 'EN Title',\n es: 'ES Title',\n de: 'DE Title',\n fr: 'FR Title',\n },\n }\n\n const dataWithLocales = {\n title: {\n en: 'Updated EN Title',\n es: 'Updated ES Title',\n },\n }\n\n const result = mergeLocalizedData({\n configBlockReferences: [],\n dataWithLocales,\n docWithLocales,\n fields,\n selectedLocales: ['en', 'es'],\n })\n\n expect(result.title).toEqual({\n en: 'Updated EN Title',\n es: 'Updated ES Title',\n de: 'DE Title',\n fr: 'FR Title',\n })\n })\n })\n\n describe('pass through fields, rows, collapsibles, unnamed tabs, unnamed groups', () => {\n it('should not lose merged locale data when processing unnamed tabs', () => {\n const fields: Field[] = [\n {\n name: 'title',\n type: 'text',\n localized: true,\n },\n {\n type: 'tabs',\n tabs: [\n {\n label: 'Other Fields',\n fields: [\n {\n name: 'description',\n type: 'text',\n localized: true,\n },\n ],\n },\n ],\n },\n ]\n\n const docWithLocales = {\n title: {\n en: 'English Title',\n },\n description: {\n en: 'English Description',\n },\n }\n\n const dataWithLocales = {\n title: {\n en: 'English Title',\n es: 'Spanish Title',\n },\n description: {\n en: 'English Description',\n es: 'Spanish Description',\n },\n }\n\n const result = mergeLocalizedData({\n configBlockReferences: [],\n dataWithLocales,\n docWithLocales,\n fields,\n selectedLocales: ['es'],\n })\n\n expect(result.title).toEqual({\n en: 'English Title',\n es: 'Spanish Title',\n })\n\n expect(result.description).toEqual({\n en: 'English Description',\n es: 'Spanish Description',\n })\n })\n\n it('should not lose other locale data when processing unnamed groups', () => {\n // https://github.com/payloadcms/payload/issues/15642\n const fields: Field[] = [\n {\n name: 'textFieldRoot',\n type: 'text',\n },\n {\n name: 'textFieldRootLocalized',\n type: 'text',\n localized: true,\n },\n // Unnamed group - fields at same data level as root\n {\n type: 'group',\n fields: [\n {\n name: 'textFieldNested',\n type: 'text',\n },\n {\n name: 'textFieldNestedLocalized',\n type: 'text',\n localized: true,\n },\n ],\n },\n ]\n\n // Document already has English data published\n const docWithLocales = {\n textFieldRoot: 'Root Value',\n textFieldRootLocalized: {\n en: 'English Root Localized',\n es: 'Spanish Root Localized',\n },\n textFieldNested: 'Nested Value',\n textFieldNestedLocalized: {\n en: 'English Nested Localized',\n es: 'Spanish Nested Localized',\n },\n }\n\n // Publishing only English locale with updated data\n const dataWithLocales = {\n textFieldRoot: 'Updated Root Value',\n textFieldRootLocalized: {\n en: 'Updated English Root Localized',\n },\n textFieldNested: 'Updated Nested Value',\n textFieldNestedLocalized: {\n en: 'Updated English Nested Localized',\n },\n }\n\n const result = mergeLocalizedData({\n configBlockReferences: [],\n dataWithLocales,\n docWithLocales,\n fields,\n selectedLocales: ['en'],\n })\n\n // Root non-localized field should be updated\n expect(result.textFieldRoot).toBe('Updated Root Value')\n\n // Root localized field should merge: update en, preserve es\n expect(result.textFieldRootLocalized).toEqual({\n en: 'Updated English Root Localized',\n es: 'Spanish Root Localized',\n })\n\n // Nested non-localized field should be updated\n expect(result.textFieldNested).toBe('Updated Nested Value')\n\n // Nested localized field should merge: update en, preserve es\n // This is the bug - es data is lost\n expect(result.textFieldNestedLocalized).toEqual({\n en: 'Updated English Nested Localized',\n es: 'Spanish Nested Localized',\n })\n })\n\n it('should not lose other locale data when processing row fields', () => {\n const fields: Field[] = [\n {\n type: 'row',\n fields: [\n {\n name: 'rowFieldLocalized',\n type: 'text',\n localized: true,\n },\n ],\n },\n ]\n\n const docWithLocales = {\n rowFieldLocalized: {\n en: 'English Value',\n es: 'Spanish Value',\n },\n }\n\n const dataWithLocales = {\n rowFieldLocalized: {\n en: 'Updated English Value',\n },\n }\n\n const result = mergeLocalizedData({\n configBlockReferences: [],\n dataWithLocales,\n docWithLocales,\n fields,\n selectedLocales: ['en'],\n })\n\n expect(result.rowFieldLocalized).toEqual({\n en: 'Updated English Value',\n es: 'Spanish Value',\n })\n })\n\n it('should preserve other locale data when updating through unnamed tabs', () => {\n const fields: Field[] = [\n {\n type: 'tabs',\n tabs: [\n {\n label: 'Tab 1',\n fields: [\n {\n name: 'tabFieldLocalized',\n type: 'text',\n localized: true,\n },\n ],\n },\n ],\n },\n ]\n\n // Document has both en and es data\n const docWithLocales = {\n tabFieldLocalized: {\n en: 'English Value',\n es: 'Spanish Value',\n },\n }\n\n // Only updating en\n const dataWithLocales = {\n tabFieldLocalized: {\n en: 'Updated English Value',\n },\n }\n\n const result = mergeLocalizedData({\n configBlockReferences: [],\n dataWithLocales,\n docWithLocales,\n fields,\n selectedLocales: ['en'],\n })\n\n // es should be preserved\n expect(result.tabFieldLocalized).toEqual({\n en: 'Updated English Value',\n es: 'Spanish Value',\n })\n })\n })\n\n describe('block metadata preservation', () => {\n it('should preserve blockType, id, and blockName when existing doc has no blocks', () => {\n // Reproduces the bug where autosave creates a doc without blocks,\n // then blocks are added and publishSpecificLocale drops metadata\n const fields: Field[] = [\n {\n name: 'layout',\n type: 'blocks',\n blocks: [\n {\n slug: 'content',\n fields: [\n {\n name: 'richText',\n type: 'richText',\n localized: true,\n },\n ],\n },\n ],\n },\n ]\n\n // Main doc has no blocks (autosave wrote before blocks were added)\n const docWithLocales = {}\n\n const dataWithLocales = {\n layout: [\n {\n blockType: 'content',\n id: 'abc123',\n blockName: 'My Content Block',\n richText: { en: 'Hello' },\n },\n ],\n }\n\n const result = mergeLocalizedData({\n configBlockReferences: [],\n dataWithLocales,\n docWithLocales,\n fields,\n selectedLocales: ['en'],\n })\n\n expect(result.layout).toHaveLength(1)\n expect(result.layout[0].blockType).toBe('content')\n expect(result.layout[0].id).toBe('abc123')\n expect(result.layout[0].blockName).toBe('My Content Block')\n })\n\n it('should preserve blockType and id when existing doc has undefined for block field', () => {\n const fields: Field[] = [\n {\n name: 'layout',\n type: 'blocks',\n blocks: [\n {\n slug: 'text',\n fields: [\n {\n name: 'text',\n type: 'text',\n localized: true,\n },\n ],\n },\n ],\n },\n ]\n\n // existingValue is undefined (field not present in existing doc)\n const docWithLocales = {\n layout: undefined,\n }\n\n const dataWithLocales = {\n layout: [\n {\n blockType: 'text',\n id: 'def456',\n text: { en: 'English text', es: 'Spanish text' },\n },\n ],\n }\n\n const result = mergeLocalizedData({\n configBlockReferences: [],\n dataWithLocales,\n docWithLocales,\n fields,\n selectedLocales: ['en'],\n })\n\n expect(result.layout).toHaveLength(1)\n expect(result.layout[0].blockType).toBe('text')\n expect(result.layout[0].id).toBe('def456')\n expect(result.layout[0].text).toEqual({ en: 'English text' })\n })\n\n it('should preserve blockType when existing doc already has blocks', () => {\n // Ensures the fix doesn't break the happy path\n const fields: Field[] = [\n {\n name: 'layout',\n type: 'blocks',\n blocks: [\n {\n slug: 'content',\n fields: [\n {\n name: 'body',\n type: 'text',\n localized: true,\n },\n ],\n },\n ],\n },\n ]\n\n const docWithLocales = {\n layout: [\n {\n blockType: 'content',\n id: 'existing-id',\n body: { en: 'Old English', es: 'Old Spanish' },\n },\n ],\n }\n\n const dataWithLocales = {\n layout: [\n {\n blockType: 'content',\n id: 'existing-id',\n body: { en: 'New English', es: 'New Spanish' },\n },\n ],\n }\n\n const result = mergeLocalizedData({\n configBlockReferences: [],\n dataWithLocales,\n docWithLocales,\n fields,\n selectedLocales: ['en'],\n })\n\n expect(result.layout).toHaveLength(1)\n expect(result.layout[0].blockType).toBe('content')\n expect(result.layout[0].id).toBe('existing-id')\n expect(result.layout[0].body).toEqual({ en: 'New English', es: 'Old Spanish' })\n })\n })\n})\n"],"names":["describe","expect","it","mergeLocalizedData","selectedLocales","configBlockReferences","fields","name","type","localized","docWithLocales","title","en","es","de","dataWithLocales","result","toEqual","toBe","missingData","updatedData","meta","description","version","items","blocks","slug","content","blockType","text","tabs","label","outer","inner","fr","textFieldRoot","textFieldRootLocalized","textFieldNested","textFieldNestedLocalized","rowFieldLocalized","tabFieldLocalized","layout","id","blockName","richText","toHaveLength","undefined","body"],"mappings":"AAEA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,SAAQ;AAE7C,SAASC,kBAAkB,QAAQ,0BAAyB;AAE5DH,SAAS,sBAAsB;IAC7B,MAAMI,kBAAkB;QAAC;KAAK;IAC9B,MAAMC,wBAAwB,EAAE;IAEhCL,SAAS,iBAAiB;QAC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gBACAL;gBACAJ;gBACAF,iBAAiB;oBAAC;iBAAK;YACzB;YAEAH,OAAOe,OAAOyB,MAAM,EAAEI,YAAY,CAAC;YACnC5C,OAAOe,OAAOyB,MAAM,CAAC,EAAE,CAACb,SAAS,EAAEV,IAAI,CAAC;YACxCjB,OAAOe,OAAOyB,MAAM,CAAC,EAAE,CAACC,EAAE,EAAExB,IAAI,CAAC;YACjCjB,OAAOe,OAAOyB,MAAM,CAAC,EAAE,CAACM,IAAI,EAAE9B,OAAO,CAAC;gBAAEL,IAAI;gBAAeC,IAAI;YAAc;QAC/E;IACF;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sanitizeFilename.d.ts","sourceRoot":"","sources":["../../src/utilities/sanitizeFilename.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAoBzD"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { APIError } from '../errors/APIError.js';
|
|
2
|
+
/**
|
|
3
|
+
* Strips directory components and control characters from a filename,
|
|
4
|
+
* leaving only the base filename.
|
|
5
|
+
*/ export function sanitizeFilename(filename) {
|
|
6
|
+
let sanitized = filename.replace(/\\/g, '/');
|
|
7
|
+
const lastSlash = sanitized.lastIndexOf('/');
|
|
8
|
+
if (lastSlash !== -1) {
|
|
9
|
+
sanitized = sanitized.slice(lastSlash + 1);
|
|
10
|
+
}
|
|
11
|
+
if (sanitized === '.' || sanitized === '..') {
|
|
12
|
+
sanitized = '';
|
|
13
|
+
}
|
|
14
|
+
// eslint-disable-next-line no-control-regex
|
|
15
|
+
sanitized = sanitized.replace(/[\x00-\x1f\x80-\x9f]/g, '');
|
|
16
|
+
if (!sanitized) {
|
|
17
|
+
throw new APIError('Invalid filename', 400);
|
|
18
|
+
}
|
|
19
|
+
return sanitized;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=sanitizeFilename.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/sanitizeFilename.ts"],"sourcesContent":["import { APIError } from '../errors/APIError.js'\n\n/**\n * Strips directory components and control characters from a filename,\n * leaving only the base filename.\n */\nexport function sanitizeFilename(filename: string): string {\n let sanitized = filename.replace(/\\\\/g, '/')\n\n const lastSlash = sanitized.lastIndexOf('/')\n if (lastSlash !== -1) {\n sanitized = sanitized.slice(lastSlash + 1)\n }\n\n if (sanitized === '.' || sanitized === '..') {\n sanitized = ''\n }\n\n // eslint-disable-next-line no-control-regex\n sanitized = sanitized.replace(/[\\x00-\\x1f\\x80-\\x9f]/g, '')\n\n if (!sanitized) {\n throw new APIError('Invalid filename', 400)\n }\n\n return sanitized\n}\n"],"names":["APIError","sanitizeFilename","filename","sanitized","replace","lastSlash","lastIndexOf","slice"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,wBAAuB;AAEhD;;;CAGC,GACD,OAAO,SAASC,iBAAiBC,QAAgB;IAC/C,IAAIC,YAAYD,SAASE,OAAO,CAAC,OAAO;IAExC,MAAMC,YAAYF,UAAUG,WAAW,CAAC;IACxC,IAAID,cAAc,CAAC,GAAG;QACpBF,YAAYA,UAAUI,KAAK,CAACF,YAAY;IAC1C;IAEA,IAAIF,cAAc,OAAOA,cAAc,MAAM;QAC3CA,YAAY;IACd;IAEA,4CAA4C;IAC5CA,YAAYA,UAAUC,OAAO,CAAC,yBAAyB;IAEvD,IAAI,CAACD,WAAW;QACd,MAAM,IAAIH,SAAS,oBAAoB;IACzC;IAEA,OAAOG;AACT"}
|
|
@@ -9,7 +9,7 @@ export async function saveVersion({ id, autosave, collection, docWithLocales, dr
|
|
|
9
9
|
let createNewVersion = true;
|
|
10
10
|
const now = new Date().toISOString();
|
|
11
11
|
const versionData = deepCopyObjectSimple(docWithLocales);
|
|
12
|
-
if (collection?.timestamps && draft) {
|
|
12
|
+
if ((collection?.timestamps || global) && draft) {
|
|
13
13
|
versionData.updatedAt = now;
|
|
14
14
|
}
|
|
15
15
|
if (versionData._id) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/versions/saveVersion.ts"],"sourcesContent":["import type { SanitizedCollectionConfig } from '../collections/config/types.js'\nimport type { SanitizedGlobalConfig } from '../globals/config/types.js'\nimport type { CreateGlobalVersionArgs, CreateVersionArgs, Payload } from '../index.js'\nimport type { JsonObject, PayloadRequest, SelectType } from '../types/index.js'\n\nimport { deepCopyObjectSimple } from '../index.js'\nimport { getVersionsMax } from '../utilities/getVersionsConfig.js'\nimport { sanitizeInternalFields } from '../utilities/sanitizeInternalFields.js'\nimport { getQueryDraftsSelect } from './drafts/getQueryDraftsSelect.js'\nimport { enforceMaxVersions } from './enforceMaxVersions.js'\nimport { saveSnapshot } from './saveSnapshot.js'\n\ntype Args<T extends JsonObject = JsonObject> = {\n autosave?: boolean\n collection?: SanitizedCollectionConfig\n docWithLocales: T\n draft?: boolean\n global?: SanitizedGlobalConfig\n id?: number | string\n operation?: 'create' | 'restoreVersion' | 'update'\n payload: Payload\n publishSpecificLocale?: string\n req?: PayloadRequest\n returning?: boolean\n select?: SelectType\n snapshot?: any\n}\n\nexport async function saveVersion<TData extends JsonObject = JsonObject>(\n args: { returning: false } & Args<TData>,\n): Promise<null>\nexport async function saveVersion<TData extends JsonObject = JsonObject>(\n args: { returning: true } & Args<TData>,\n): Promise<JsonObject>\nexport async function saveVersion<TData extends JsonObject = JsonObject>(\n args: Omit<Args<TData>, 'returning'>,\n): Promise<JsonObject>\nexport async function saveVersion<TData extends JsonObject = JsonObject>({\n id,\n autosave,\n collection,\n docWithLocales,\n draft,\n global,\n operation,\n payload,\n publishSpecificLocale,\n req,\n returning,\n select,\n snapshot,\n}: Args<TData>): Promise<JsonObject | null> {\n let result: JsonObject | undefined\n let createNewVersion = true\n const now = new Date().toISOString()\n const versionData: {\n _status?: 'draft'\n updatedAt?: string\n } & TData = deepCopyObjectSimple(docWithLocales)\n\n if (collection?.timestamps && draft) {\n versionData.updatedAt = now\n }\n\n if (versionData._id) {\n delete versionData._id\n }\n\n try {\n if (autosave) {\n let docs\n const findVersionArgs = {\n limit: 1,\n pagination: false,\n req,\n sort: '-updatedAt',\n }\n\n if (collection) {\n ;({ docs } = await payload.db.findVersions<TData>({\n ...findVersionArgs,\n collection: collection.slug,\n limit: 1,\n pagination: false,\n req,\n where: {\n parent: {\n equals: id,\n },\n },\n }))\n } else {\n ;({ docs } = await payload.db.findGlobalVersions<TData>({\n ...findVersionArgs,\n global: global!.slug,\n limit: 1,\n pagination: false,\n req,\n }))\n }\n const [latestVersion] = docs\n\n // overwrite the latest version if it's set to autosave\n if (latestVersion && 'autosave' in latestVersion && latestVersion.autosave === true) {\n createNewVersion = false\n\n const updateVersionArgs = {\n id: latestVersion.id,\n req,\n versionData: {\n createdAt: new Date(latestVersion.createdAt).toISOString(),\n latest: true,\n parent: id,\n updatedAt: now,\n version: {\n ...versionData,\n },\n },\n }\n\n if (collection) {\n result = await payload.db.updateVersion<TData>({\n ...updateVersionArgs,\n collection: collection.slug,\n req,\n })\n } else {\n result = await payload.db.updateGlobalVersion<TData>({\n ...updateVersionArgs,\n global: global!.slug,\n req,\n })\n }\n }\n }\n\n if (createNewVersion) {\n const createVersionArgs = {\n autosave: Boolean(autosave),\n collectionSlug: undefined as string | undefined,\n createdAt: operation === 'restoreVersion' ? versionData.createdAt : now,\n globalSlug: undefined as string | undefined,\n parent: collection ? id : undefined,\n publishedLocale: publishSpecificLocale || undefined,\n req,\n returning,\n select: getQueryDraftsSelect({ select }),\n updatedAt: now,\n versionData,\n }\n\n if (collection) {\n createVersionArgs.collectionSlug = collection.slug\n result = await payload.db.createVersion(createVersionArgs as CreateVersionArgs)\n }\n\n if (global) {\n createVersionArgs.globalSlug = global.slug\n result = await payload.db.createGlobalVersion(createVersionArgs as CreateGlobalVersionArgs)\n }\n\n if (snapshot) {\n await saveSnapshot<TData>({\n id,\n autosave,\n collection,\n data: snapshot,\n global,\n payload,\n publishSpecificLocale,\n req,\n select,\n })\n }\n }\n } catch (err) {\n let errorMessage: string | undefined\n\n if (collection) {\n errorMessage = `There was an error while saving a version for the ${typeof collection.labels.singular === 'string' ? collection.labels.singular : collection.slug} with ID ${id}.`\n }\n if (global) {\n errorMessage = `There was an error while saving a version for the global ${typeof global.label === 'string' ? global.label : global.slug}.`\n }\n payload.logger.error({ err, msg: errorMessage })\n return undefined!\n }\n\n const max = getVersionsMax(collection || global!)\n\n if (createNewVersion && max > 0) {\n await enforceMaxVersions({\n id,\n collection,\n global,\n max,\n payload,\n req,\n })\n }\n if (returning === false) {\n return null\n }\n\n let createdVersion = (result as any).version\n\n createdVersion = sanitizeInternalFields(createdVersion)\n createdVersion.id = (result as any).parent\n\n return createdVersion\n}\n"],"names":["deepCopyObjectSimple","getVersionsMax","sanitizeInternalFields","getQueryDraftsSelect","enforceMaxVersions","saveSnapshot","saveVersion","id","autosave","collection","docWithLocales","draft","global","operation","payload","publishSpecificLocale","req","returning","select","snapshot","result","createNewVersion","now","Date","toISOString","versionData","timestamps","updatedAt","_id","docs","findVersionArgs","limit","pagination","sort","db","findVersions","slug","where","parent","equals","findGlobalVersions","latestVersion","updateVersionArgs","createdAt","latest","version","updateVersion","updateGlobalVersion","createVersionArgs","Boolean","collectionSlug","undefined","globalSlug","publishedLocale","createVersion","createGlobalVersion","data","err","errorMessage","labels","singular","label","logger","error","msg","max","createdVersion"],"mappings":"AAKA,SAASA,oBAAoB,QAAQ,cAAa;AAClD,SAASC,cAAc,QAAQ,oCAAmC;AAClE,SAASC,sBAAsB,QAAQ,yCAAwC;AAC/E,SAASC,oBAAoB,QAAQ,mCAAkC;AACvE,SAASC,kBAAkB,QAAQ,0BAAyB;AAC5D,SAASC,YAAY,QAAQ,oBAAmB;AA2BhD,OAAO,eAAeC,YAAmD,EACvEC,EAAE,EACFC,QAAQ,EACRC,UAAU,EACVC,cAAc,EACdC,KAAK,EACLC,MAAM,EACNC,SAAS,EACTC,OAAO,EACPC,qBAAq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AAS,EAAE7B,GAAG,CAAC,CAAC;QACpL;QACA,IAAIK,QAAQ;YACV8C,eAAe,CAAC,yDAAyD,EAAE,OAAO9C,OAAOiD,KAAK,KAAK,WAAWjD,OAAOiD,KAAK,GAAGjD,OAAOwB,IAAI,CAAC,CAAC,CAAC;QAC7I;QACAtB,QAAQgD,MAAM,CAACC,KAAK,CAAC;YAAEN;YAAKO,KAAKN;QAAa;QAC9C,OAAOP;IACT;IAEA,MAAMc,MAAMhE,eAAeQ,cAAcG;IAEzC,IAAIS,oBAAoB4C,MAAM,GAAG;QAC/B,MAAM7D,mBAAmB;YACvBG;YACAE;YACAG;YACAqD;YACAnD;YACAE;QACF;IACF;IACA,IAAIC,cAAc,OAAO;QACvB,OAAO;IACT;IAEA,IAAIiD,iBAAiB,AAAC9C,OAAeyB,OAAO;IAE5CqB,iBAAiBhE,uBAAuBgE;IACxCA,eAAe3D,EAAE,GAAG,AAACa,OAAekB,MAAM;IAE1C,OAAO4B;AACT"}
|
|
1
|
+
{"version":3,"sources":["../../src/versions/saveVersion.ts"],"sourcesContent":["import type { SanitizedCollectionConfig } from '../collections/config/types.js'\nimport type { SanitizedGlobalConfig } from '../globals/config/types.js'\nimport type { CreateGlobalVersionArgs, CreateVersionArgs, Payload } from '../index.js'\nimport type { JsonObject, PayloadRequest, SelectType } from '../types/index.js'\n\nimport { deepCopyObjectSimple } from '../index.js'\nimport { getVersionsMax } from '../utilities/getVersionsConfig.js'\nimport { sanitizeInternalFields } from '../utilities/sanitizeInternalFields.js'\nimport { getQueryDraftsSelect } from './drafts/getQueryDraftsSelect.js'\nimport { enforceMaxVersions } from './enforceMaxVersions.js'\nimport { saveSnapshot } from './saveSnapshot.js'\n\ntype Args<T extends JsonObject = JsonObject> = {\n autosave?: boolean\n collection?: SanitizedCollectionConfig\n docWithLocales: T\n draft?: boolean\n global?: SanitizedGlobalConfig\n id?: number | string\n operation?: 'create' | 'restoreVersion' | 'update'\n payload: Payload\n publishSpecificLocale?: string\n req?: PayloadRequest\n returning?: boolean\n select?: SelectType\n snapshot?: any\n}\n\nexport async function saveVersion<TData extends JsonObject = JsonObject>(\n args: { returning: false } & Args<TData>,\n): Promise<null>\nexport async function saveVersion<TData extends JsonObject = JsonObject>(\n args: { returning: true } & Args<TData>,\n): Promise<JsonObject>\nexport async function saveVersion<TData extends JsonObject = JsonObject>(\n args: Omit<Args<TData>, 'returning'>,\n): Promise<JsonObject>\nexport async function saveVersion<TData extends JsonObject = JsonObject>({\n id,\n autosave,\n collection,\n docWithLocales,\n draft,\n global,\n operation,\n payload,\n publishSpecificLocale,\n req,\n returning,\n select,\n snapshot,\n}: Args<TData>): Promise<JsonObject | null> {\n let result: JsonObject | undefined\n let createNewVersion = true\n const now = new Date().toISOString()\n const versionData: {\n _status?: 'draft'\n updatedAt?: string\n } & TData = deepCopyObjectSimple(docWithLocales)\n\n if ((collection?.timestamps || global) && draft) {\n versionData.updatedAt = now\n }\n\n if (versionData._id) {\n delete versionData._id\n }\n\n try {\n if (autosave) {\n let docs\n const findVersionArgs = {\n limit: 1,\n pagination: false,\n req,\n sort: '-updatedAt',\n }\n\n if (collection) {\n ;({ docs } = await payload.db.findVersions<TData>({\n ...findVersionArgs,\n collection: collection.slug,\n limit: 1,\n pagination: false,\n req,\n where: {\n parent: {\n equals: id,\n },\n },\n }))\n } else {\n ;({ docs } = await payload.db.findGlobalVersions<TData>({\n ...findVersionArgs,\n global: global!.slug,\n limit: 1,\n pagination: false,\n req,\n }))\n }\n const [latestVersion] = docs\n\n // overwrite the latest version if it's set to autosave\n if (latestVersion && 'autosave' in latestVersion && latestVersion.autosave === true) {\n createNewVersion = false\n\n const updateVersionArgs = {\n id: latestVersion.id,\n req,\n versionData: {\n createdAt: new Date(latestVersion.createdAt).toISOString(),\n latest: true,\n parent: id,\n updatedAt: now,\n version: {\n ...versionData,\n },\n },\n }\n\n if (collection) {\n result = await payload.db.updateVersion<TData>({\n ...updateVersionArgs,\n collection: collection.slug,\n req,\n })\n } else {\n result = await payload.db.updateGlobalVersion<TData>({\n ...updateVersionArgs,\n global: global!.slug,\n req,\n })\n }\n }\n }\n\n if (createNewVersion) {\n const createVersionArgs = {\n autosave: Boolean(autosave),\n collectionSlug: undefined as string | undefined,\n createdAt: operation === 'restoreVersion' ? versionData.createdAt : now,\n globalSlug: undefined as string | undefined,\n parent: collection ? id : undefined,\n publishedLocale: publishSpecificLocale || undefined,\n req,\n returning,\n select: getQueryDraftsSelect({ select }),\n updatedAt: now,\n versionData,\n }\n\n if (collection) {\n createVersionArgs.collectionSlug = collection.slug\n result = await payload.db.createVersion(createVersionArgs as CreateVersionArgs)\n }\n\n if (global) {\n createVersionArgs.globalSlug = global.slug\n result = await payload.db.createGlobalVersion(createVersionArgs as CreateGlobalVersionArgs)\n }\n\n if (snapshot) {\n await saveSnapshot<TData>({\n id,\n autosave,\n collection,\n data: snapshot,\n global,\n payload,\n publishSpecificLocale,\n req,\n select,\n })\n }\n }\n } catch (err) {\n let errorMessage: string | undefined\n\n if (collection) {\n errorMessage = `There was an error while saving a version for the ${typeof collection.labels.singular === 'string' ? collection.labels.singular : collection.slug} with ID ${id}.`\n }\n if (global) {\n errorMessage = `There was an error while saving a version for the global ${typeof global.label === 'string' ? global.label : global.slug}.`\n }\n payload.logger.error({ err, msg: errorMessage })\n return undefined!\n }\n\n const max = getVersionsMax(collection || global!)\n\n if (createNewVersion && max > 0) {\n await enforceMaxVersions({\n id,\n collection,\n global,\n max,\n payload,\n req,\n })\n }\n if (returning === false) {\n return null\n }\n\n let createdVersion = (result as any).version\n\n createdVersion = sanitizeInternalFields(createdVersion)\n createdVersion.id = (result as any).parent\n\n return createdVersion\n}\n"],"names":["deepCopyObjectSimple","getVersionsMax","sanitizeInternalFields","getQueryDraftsSelect","enforceMaxVersions","saveSnapshot","saveVersion","id","autosave","collection","docWithLocales","draft","global","operation","payload","publishSpecificLocale","req","returning","select","snapshot","result","createNewVersion","now","Date","toISOString","versionData","timestamps","updatedAt","_id","docs","findVersionArgs","limit","pagination","sort","db","findVersions","slug","where","parent","equals","findGlobalVersions","latestVersion","updateVersionArgs","createdAt","latest","version","updateVersion","updateGlobalVersion","createVersionArgs","Boolean","collectionSlug","undefined","globalSlug","publishedLocale","createVersion","createGlobalVersion","data","err","errorMessage","labels","singular","label","logger","error","msg","max","createdVersion"],"mappings":"AAKA,SAASA,oBAAoB,QAAQ,cAAa;AAClD,SAASC,cAAc,QAAQ,oCAAmC;AAClE,SAASC,sBAAsB,QAAQ,yCAAwC;AAC/E,SAASC,oBAAoB,QAAQ,mCAAkC;AACvE,SAASC,kBAAkB,QAAQ,0BAAyB;AAC5D,SAASC,YAAY,QAAQ,oBAAmB;AA2BhD,OAAO,eAAeC,YAAmD,EACvEC,EAAE,EACFC,QAAQ,EACRC,UAAU,EACVC,cAAc,EACdC,KAAK,EACLC,MAAM,EACNC,SAAS,EACTC,OAAO,EACPC,qBAAqB,EACrBC,GAAG,EACHC,SAAS,EACTC,MAAM,EACNC,QAAQ,EACI;IACZ,IAAIC;IACJ,IAAIC,mBAAmB;IACvB,MAAMC,MAAM,IAAIC,OAAOC,WAAW;IAClC,MAAMC,cAGMzB,qBAAqBU;IAEjC,IAAI,AAACD,CAAAA,YAAYiB,cAAcd,MAAK,KAAMD,OAAO;QAC/Cc,YAAYE,SAAS,GAAGL;IAC1B;IAEA,IAAIG,YAAYG,GAAG,EAAE;QACnB,OAAOH,YAAYG,GAAG;IACxB;IAEA,IAAI;QACF,IAAIpB,UAAU;YACZ,IAAIqB;YACJ,MAAMC,kBAAkB;gBACtBC,OAAO;gBACPC,YAAY;gBACZhB;gBACAiB,MAAM;YACR;YAEA,IAAIxB,YAAY;;gBACZ,CAAA,EAAEoB,IAAI,EAAE,GAAG,MAAMf,QAAQoB,EAAE,CAACC,YAAY,CAAQ;oBAChD,GAAGL,eAAe;oBAClBrB,YAAYA,WAAW2B,IAAI;oBAC3BL,OAAO;oBACPC,YAAY;oBACZhB;oBACAqB,OAAO;wBACLC,QAAQ;4BACNC,Q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
|
|
|
1
1
|
{
|
|
2
2
|
"name": "payload",
|
|
3
|
-
"version": "3.78.0-internal
|
|
3
|
+
"version": "3.78.0-internal.ab11ffa",
|
|
4
4
|
"description": "Node, React, Headless CMS and Application Framework built on Next.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"admin panel",
|
|
@@ -115,7 +115,7 @@
|
|
|
115
115
|
"undici": "7.18.2",
|
|
116
116
|
"uuid": "10.0.0",
|
|
117
117
|
"ws": "^8.16.0",
|
|
118
|
-
"@payloadcms/translations": "3.78.0-internal
|
|
118
|
+
"@payloadcms/translations": "3.78.0-internal.ab11ffa"
|
|
119
119
|
},
|
|
120
120
|
"devDependencies": {
|
|
121
121
|
"@hyrious/esbuild-plugin-commonjs": "0.2.6",
|