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
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { filterDataToSelectedLocales } from './filterDataToSelectedLocales.js';
|
|
3
|
+
describe('filterDataToSelectedLocales', ()=>{
|
|
4
|
+
const selectedLocales = [
|
|
5
|
+
'en'
|
|
6
|
+
];
|
|
7
|
+
const configBlockReferences = [];
|
|
8
|
+
describe('block metadata preservation', ()=>{
|
|
9
|
+
it('should preserve blockType, id, and blockName on non-localized blocks', ()=>{
|
|
10
|
+
const fields = [
|
|
11
|
+
{
|
|
12
|
+
name: 'layout',
|
|
13
|
+
type: 'blocks',
|
|
14
|
+
blocks: [
|
|
15
|
+
{
|
|
16
|
+
slug: 'content',
|
|
17
|
+
fields: [
|
|
18
|
+
{
|
|
19
|
+
name: 'richText',
|
|
20
|
+
type: 'richText',
|
|
21
|
+
localized: true
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
];
|
|
28
|
+
const docWithLocales = {
|
|
29
|
+
layout: [
|
|
30
|
+
{
|
|
31
|
+
blockType: 'content',
|
|
32
|
+
id: 'abc123',
|
|
33
|
+
blockName: 'My Block',
|
|
34
|
+
richText: {
|
|
35
|
+
en: 'English',
|
|
36
|
+
es: 'Spanish'
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
]
|
|
40
|
+
};
|
|
41
|
+
const result = filterDataToSelectedLocales({
|
|
42
|
+
configBlockReferences: [],
|
|
43
|
+
docWithLocales,
|
|
44
|
+
fields,
|
|
45
|
+
selectedLocales
|
|
46
|
+
});
|
|
47
|
+
expect(result.layout).toHaveLength(1);
|
|
48
|
+
expect(result.layout[0].blockType).toBe('content');
|
|
49
|
+
expect(result.layout[0].id).toBe('abc123');
|
|
50
|
+
expect(result.layout[0].blockName).toBe('My Block');
|
|
51
|
+
expect(result.layout[0].richText).toEqual({
|
|
52
|
+
en: 'English'
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
it('should preserve blockType and id when block has no blockName', ()=>{
|
|
56
|
+
const fields = [
|
|
57
|
+
{
|
|
58
|
+
name: 'layout',
|
|
59
|
+
type: 'blocks',
|
|
60
|
+
blocks: [
|
|
61
|
+
{
|
|
62
|
+
slug: 'text',
|
|
63
|
+
fields: [
|
|
64
|
+
{
|
|
65
|
+
name: 'text',
|
|
66
|
+
type: 'text',
|
|
67
|
+
localized: true
|
|
68
|
+
}
|
|
69
|
+
]
|
|
70
|
+
}
|
|
71
|
+
]
|
|
72
|
+
}
|
|
73
|
+
];
|
|
74
|
+
const docWithLocales = {
|
|
75
|
+
layout: [
|
|
76
|
+
{
|
|
77
|
+
blockType: 'text',
|
|
78
|
+
id: 'def456',
|
|
79
|
+
text: {
|
|
80
|
+
en: 'English',
|
|
81
|
+
es: 'Spanish'
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
]
|
|
85
|
+
};
|
|
86
|
+
const result = filterDataToSelectedLocales({
|
|
87
|
+
configBlockReferences: [],
|
|
88
|
+
docWithLocales,
|
|
89
|
+
fields,
|
|
90
|
+
selectedLocales
|
|
91
|
+
});
|
|
92
|
+
expect(result.layout).toHaveLength(1);
|
|
93
|
+
expect(result.layout[0].blockType).toBe('text');
|
|
94
|
+
expect(result.layout[0].id).toBe('def456');
|
|
95
|
+
expect(result.layout[0].text).toEqual({
|
|
96
|
+
en: 'English'
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
it('should preserve blockType and id with configBlockReferences', ()=>{
|
|
100
|
+
const fields = [
|
|
101
|
+
{
|
|
102
|
+
name: 'layout',
|
|
103
|
+
type: 'blocks',
|
|
104
|
+
blocks: [],
|
|
105
|
+
blockReferences: [
|
|
106
|
+
'content'
|
|
107
|
+
]
|
|
108
|
+
}
|
|
109
|
+
];
|
|
110
|
+
const result = filterDataToSelectedLocales({
|
|
111
|
+
configBlockReferences: [
|
|
112
|
+
{
|
|
113
|
+
slug: 'content',
|
|
114
|
+
fields: [
|
|
115
|
+
{
|
|
116
|
+
name: 'body',
|
|
117
|
+
type: 'text',
|
|
118
|
+
localized: true
|
|
119
|
+
}
|
|
120
|
+
]
|
|
121
|
+
}
|
|
122
|
+
],
|
|
123
|
+
docWithLocales: {
|
|
124
|
+
layout: [
|
|
125
|
+
{
|
|
126
|
+
blockType: 'content',
|
|
127
|
+
id: 'ref123',
|
|
128
|
+
body: {
|
|
129
|
+
en: 'English',
|
|
130
|
+
es: 'Spanish'
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
]
|
|
134
|
+
},
|
|
135
|
+
fields,
|
|
136
|
+
selectedLocales
|
|
137
|
+
});
|
|
138
|
+
expect(result.layout).toHaveLength(1);
|
|
139
|
+
expect(result.layout[0].blockType).toBe('content');
|
|
140
|
+
expect(result.layout[0].id).toBe('ref123');
|
|
141
|
+
expect(result.layout[0].body).toEqual({
|
|
142
|
+
en: 'English'
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
describe('simple fields', ()=>{
|
|
147
|
+
it('should filter localized field values to selected locales', ()=>{
|
|
148
|
+
const fields = [
|
|
149
|
+
{
|
|
150
|
+
name: 'title',
|
|
151
|
+
type: 'text',
|
|
152
|
+
localized: true
|
|
153
|
+
}
|
|
154
|
+
];
|
|
155
|
+
const docWithLocales = {
|
|
156
|
+
title: {
|
|
157
|
+
en: 'English Title',
|
|
158
|
+
es: 'Spanish Title',
|
|
159
|
+
de: 'German Title'
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
const result = filterDataToSelectedLocales({
|
|
163
|
+
configBlockReferences: [],
|
|
164
|
+
docWithLocales,
|
|
165
|
+
fields,
|
|
166
|
+
selectedLocales
|
|
167
|
+
});
|
|
168
|
+
expect(result.title).toEqual({
|
|
169
|
+
en: 'English Title'
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
it('should pass through non-localized fields as-is', ()=>{
|
|
173
|
+
const fields = [
|
|
174
|
+
{
|
|
175
|
+
name: 'slug',
|
|
176
|
+
type: 'text'
|
|
177
|
+
}
|
|
178
|
+
];
|
|
179
|
+
const docWithLocales = {
|
|
180
|
+
slug: 'my-slug'
|
|
181
|
+
};
|
|
182
|
+
const result = filterDataToSelectedLocales({
|
|
183
|
+
configBlockReferences: [],
|
|
184
|
+
docWithLocales,
|
|
185
|
+
fields,
|
|
186
|
+
selectedLocales
|
|
187
|
+
});
|
|
188
|
+
expect(result.slug).toBe('my-slug');
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
//# sourceMappingURL=filterDataToSelectedLocales.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/filterDataToSelectedLocales.spec.ts"],"sourcesContent":["import type { Field } from '../fields/config/types.js'\n\nimport { describe, expect, it } from 'vitest'\n\nimport { filterDataToSelectedLocales } from './filterDataToSelectedLocales.js'\n\ndescribe('filterDataToSelectedLocales', () => {\n const selectedLocales = ['en']\n const configBlockReferences = []\n\n describe('block metadata preservation', () => {\n it('should preserve blockType, id, and blockName on non-localized blocks', () => {\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 const docWithLocales = {\n layout: [\n {\n blockType: 'content',\n id: 'abc123',\n blockName: 'My Block',\n richText: { en: 'English', es: 'Spanish' },\n },\n ],\n }\n\n const result = filterDataToSelectedLocales({\n configBlockReferences: [],\n docWithLocales,\n fields,\n selectedLocales,\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 Block')\n expect(result.layout[0].richText).toEqual({ en: 'English' })\n })\n\n it('should preserve blockType and id when block has no blockName', () => {\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 const docWithLocales = {\n layout: [\n {\n blockType: 'text',\n id: 'def456',\n text: { en: 'English', es: 'Spanish' },\n },\n ],\n }\n\n const result = filterDataToSelectedLocales({\n configBlockReferences: [],\n docWithLocales,\n fields,\n selectedLocales,\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' })\n })\n\n it('should preserve blockType and id with configBlockReferences', () => {\n const fields: Field[] = [\n {\n name: 'layout',\n type: 'blocks',\n blocks: [],\n blockReferences: ['content'],\n },\n ]\n\n const result = filterDataToSelectedLocales({\n configBlockReferences: [\n {\n slug: 'content',\n fields: [\n {\n name: 'body',\n type: 'text',\n localized: true,\n },\n ],\n },\n ],\n docWithLocales: {\n layout: [\n {\n blockType: 'content',\n id: 'ref123',\n body: { en: 'English', es: 'Spanish' },\n },\n ],\n },\n fields,\n selectedLocales,\n })\n\n expect(result.layout).toHaveLength(1)\n expect(result.layout[0].blockType).toBe('content')\n expect(result.layout[0].id).toBe('ref123')\n expect(result.layout[0].body).toEqual({ en: 'English' })\n })\n })\n\n describe('simple fields', () => {\n it('should filter localized field values to 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 result = filterDataToSelectedLocales({\n configBlockReferences: [],\n docWithLocales,\n fields,\n selectedLocales,\n })\n\n expect(result.title).toEqual({ en: 'English Title' })\n })\n\n it('should pass through non-localized fields as-is', () => {\n const fields: Field[] = [\n {\n name: 'slug',\n type: 'text',\n },\n ]\n\n const docWithLocales = {\n slug: 'my-slug',\n }\n\n const result = filterDataToSelectedLocales({\n configBlockReferences: [],\n docWithLocales,\n fields,\n selectedLocales,\n })\n\n expect(result.slug).toBe('my-slug')\n })\n })\n})\n"],"names":["describe","expect","it","filterDataToSelectedLocales","selectedLocales","configBlockReferences","fields","name","type","blocks","slug","localized","docWithLocales","layout","blockType","id","blockName","richText","en","es","result","toHaveLength","toBe","toEqual","text","blockReferences","body","title","de"],"mappings":"AAEA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,SAAQ;AAE7C,SAASC,2BAA2B,QAAQ,mCAAkC;AAE9EH,SAAS,+BAA+B;IACtC,MAAMI,kBAAkB;QAAC;KAAK;IAC9B,MAAMC,wBAAwB,EAAE;IAEhCL,SAAS,+BAA+B;QACtCE,GAAG,wEAAwE;YACzE,MAAMI,SAAkB;gBACtB;oBACEC,MAAM;oBACNC,MAAM;oBACNC,QAAQ;wBACN;4BACEC,MAAM;4BACNJ,QAAQ;gCACN;oCACEC,MAAM;oCACNC,MAAM;oCACNG,WAAW;gCACb;6BACD;wBACH;qBACD;gBACH;aACD;YAED,MAAMC,iBAAiB;gBACrBC,QAAQ;oBACN;wBACEC,WAAW;wBACXC,IAAI;wBACJC,WAAW;wBACXC,UAAU;4BAAEC,IAAI;4BAAWC,IAAI;wBAAU;oBAC3C;iBACD;YACH;YAEA,MAAMC,SAASjB,4BAA4B;gBACzCE,uBAAuB,EAAE;gBACzBO;gBACAN;gBACAF;YACF;YAEAH,OAAOmB,OAAOP,MAAM,EAAEQ,YAAY,CAAC;YACnCpB,OAAOmB,OAAOP,MAAM,CAAC,EAAE,CAACC,SAAS,EAAEQ,IAAI,CAAC;YACxCrB,OAAOmB,OAAOP,MAAM,CAAC,EAAE,CAACE,EAAE,EAAEO,IAAI,CAAC;YACjCrB,OAAOmB,OAAOP,MAAM,CAAC,EAAE,CAACG,SAAS,EAAEM,IAAI,CAAC;YACxCrB,OAAOmB,OAAOP,MAAM,CAAC,EAAE,CAACI,QAAQ,EAAEM,OAAO,CAAC;gBAAEL,IAAI;YAAU;QAC5D;QAEAhB,GAAG,gEAAgE;YACjE,MAAMI,SAAkB;gBACtB;oBACEC,MAAM;oBACNC,MAAM;oBACNC,QAAQ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E,CAACE,EAAE,EAAEO,IAAI,CAAC;YACjCrB,OAAOmB,OAAOP,MAAM,CAAC,EAAE,CAACa,IAAI,EAAEH,OAAO,CAAC;gBAAEL,IAAI;YAAU;QACxD;IACF;IAEAlB,SAAS,iBAAiB;QACxBE,GAAG,4DAA4D;YAC7D,MAAMI,SAAkB;gBACtB;oBACEC,MAAM;oBACNC,MAAM;oBACNG,WAAW;gBACb;aACD;YAED,MAAMC,iBAAiB;gBACrBe,OAAO;oBACLT,IAAI;oBACJC,IAAI;oBACJS,IAAI;gBACN;YACF;YAEA,MAAMR,SAASjB,4BAA4B;gBACzCE,uBAAuB,EAAE;gBACzBO;gBACAN;gBACAF;YACF;YAEAH,OAAOmB,OAAOO,KAAK,EAAEJ,OAAO,CAAC;gBAAEL,IAAI;YAAgB;QACrD;QAEAhB,GAAG,kDAAkD;YACnD,MAAMI,SAAkB;gBACtB;oBACEC,MAAM;oBACNC,MAAM;gBACR;aACD;YAED,MAAMI,iBAAiB;gBACrBF,MAAM;YACR;YAEA,MAAMU,SAASjB,4BAA4B;gBACzCE,uBAAuB,EAAE;gBACzBO;gBACAN;gBACAF;YACF;YAEAH,OAAOmB,OAAOV,IAAI,EAAEY,IAAI,CAAC;QAC3B;IACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mergeLocalizedData.d.ts","sourceRoot":"","sources":["../../src/utilities/mergeLocalizedData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,KAAK,EAAkB,MAAM,2BAA2B,CAAA;AAC7E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"mergeLocalizedData.d.ts","sourceRoot":"","sources":["../../src/utilities/mergeLocalizedData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,KAAK,EAAkB,MAAM,2BAA2B,CAAA;AAC7E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAiCnD,KAAK,8BAA8B,GAAG;IACpC,qBAAqB,EAAE,eAAe,CAAC,QAAQ,CAAC,CAAA;IAChD,eAAe,EAAE,UAAU,CAAA;IAC3B,cAAc,EAAE,UAAU,CAAA;IAC1B,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,eAAe,EAAE,MAAM,EAAE,CAAA;CAC1B,CAAA;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,EACjC,qBAAqB,EACrB,eAAe,EACf,cAAc,EACd,MAAM,EACN,iBAAyB,EACzB,eAAe,GAChB,EAAE,8BAA8B,GAAG,UAAU,CAiS7C"}
|
|
@@ -1,4 +1,31 @@
|
|
|
1
1
|
import { fieldAffectsData, fieldShouldBeLocalized, tabHasName } from '../fields/config/types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Collects field names at the current data level, recursing through pass-through fields
|
|
4
|
+
* (row, collapsible, unnamed group, unnamed tab) but stopping at named fields.
|
|
5
|
+
*/ function collectFlattenedFieldNames(fields) {
|
|
6
|
+
const names = new Set();
|
|
7
|
+
for (const field of fields){
|
|
8
|
+
if (fieldAffectsData(field)) {
|
|
9
|
+
names.add(field.name);
|
|
10
|
+
} else if ('fields' in field && Array.isArray(field.fields)) {
|
|
11
|
+
// Pass-through fields (row, collapsible, unnamed group)
|
|
12
|
+
for (const name of collectFlattenedFieldNames(field.fields)){
|
|
13
|
+
names.add(name);
|
|
14
|
+
}
|
|
15
|
+
} else if (field.type === 'tabs') {
|
|
16
|
+
for (const tab of field.tabs){
|
|
17
|
+
if (tabHasName(tab)) {
|
|
18
|
+
names.add(tab.name);
|
|
19
|
+
} else {
|
|
20
|
+
for (const name of collectFlattenedFieldNames(tab.fields)){
|
|
21
|
+
names.add(name);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return names;
|
|
28
|
+
}
|
|
2
29
|
/**
|
|
3
30
|
* Merges data from dataWithLocales onto docWithLocales for specified locales.
|
|
4
31
|
* For localized fields, merges only the specified locales while preserving others.
|
|
@@ -99,7 +126,7 @@ import { fieldAffectsData, fieldShouldBeLocalized, tabHasName } from '../fields/
|
|
|
99
126
|
}
|
|
100
127
|
if (block) {
|
|
101
128
|
const blockData = Array.isArray(existingValue) && existingValue[index] ? existingValue[index] : {};
|
|
102
|
-
|
|
129
|
+
const merged = mergeLocalizedData({
|
|
103
130
|
configBlockReferences,
|
|
104
131
|
dataWithLocales: newBlockData,
|
|
105
132
|
docWithLocales: blockData,
|
|
@@ -107,6 +134,12 @@ import { fieldAffectsData, fieldShouldBeLocalized, tabHasName } from '../fields/
|
|
|
107
134
|
parentIsLocalized,
|
|
108
135
|
selectedLocales
|
|
109
136
|
});
|
|
137
|
+
// blockType, id, blockName are set by Payload internally
|
|
138
|
+
// and not part of block.fields, so they must be preserved explicitly
|
|
139
|
+
merged.blockType = newBlockData.blockType;
|
|
140
|
+
merged.id = newBlockData.id;
|
|
141
|
+
merged.blockName = newBlockData.blockName;
|
|
142
|
+
return merged;
|
|
110
143
|
}
|
|
111
144
|
return newBlockData;
|
|
112
145
|
});
|
|
@@ -148,17 +181,6 @@ import { fieldAffectsData, fieldShouldBeLocalized, tabHasName } from '../fields/
|
|
|
148
181
|
});
|
|
149
182
|
}
|
|
150
183
|
}
|
|
151
|
-
} else {
|
|
152
|
-
// Unnamed groups pass through the same data level
|
|
153
|
-
const merged = mergeLocalizedData({
|
|
154
|
-
configBlockReferences,
|
|
155
|
-
dataWithLocales,
|
|
156
|
-
docWithLocales: result,
|
|
157
|
-
fields: field.fields,
|
|
158
|
-
parentIsLocalized,
|
|
159
|
-
selectedLocales
|
|
160
|
-
});
|
|
161
|
-
Object.assign(result, merged);
|
|
162
184
|
}
|
|
163
185
|
break;
|
|
164
186
|
}
|
|
@@ -200,18 +222,25 @@ import { fieldAffectsData, fieldShouldBeLocalized, tabHasName } from '../fields/
|
|
|
200
222
|
// Layout-only fields that don't affect data structure
|
|
201
223
|
switch(field.type){
|
|
202
224
|
case 'collapsible':
|
|
225
|
+
case 'group':
|
|
203
226
|
case 'row':
|
|
204
227
|
{
|
|
205
228
|
// These pass through the same data level
|
|
206
229
|
const merged = mergeLocalizedData({
|
|
207
230
|
configBlockReferences,
|
|
208
231
|
dataWithLocales,
|
|
209
|
-
docWithLocales
|
|
232
|
+
docWithLocales,
|
|
210
233
|
fields: field.fields,
|
|
211
234
|
parentIsLocalized,
|
|
212
235
|
selectedLocales
|
|
213
236
|
});
|
|
214
|
-
|
|
237
|
+
// Only copy fields that belong to this layout field to avoid overwriting already-processed fields
|
|
238
|
+
const fieldNames = collectFlattenedFieldNames(field.fields);
|
|
239
|
+
for (const name of fieldNames){
|
|
240
|
+
if (name in merged) {
|
|
241
|
+
result[name] = merged[name];
|
|
242
|
+
}
|
|
243
|
+
}
|
|
215
244
|
break;
|
|
216
245
|
}
|
|
217
246
|
case 'tabs':
|
|
@@ -258,12 +287,18 @@ import { fieldAffectsData, fieldShouldBeLocalized, tabHasName } from '../fields/
|
|
|
258
287
|
const merged = mergeLocalizedData({
|
|
259
288
|
configBlockReferences,
|
|
260
289
|
dataWithLocales,
|
|
261
|
-
docWithLocales
|
|
290
|
+
docWithLocales,
|
|
262
291
|
fields: tab.fields,
|
|
263
292
|
parentIsLocalized,
|
|
264
293
|
selectedLocales
|
|
265
294
|
});
|
|
266
|
-
|
|
295
|
+
// Only copy fields that belong to this tab to avoid overwriting already-processed fields
|
|
296
|
+
const tabFieldNames = collectFlattenedFieldNames(tab.fields);
|
|
297
|
+
for (const name of tabFieldNames){
|
|
298
|
+
if (name in merged) {
|
|
299
|
+
result[name] = merged[name];
|
|
300
|
+
}
|
|
301
|
+
}
|
|
267
302
|
}
|
|
268
303
|
}
|
|
269
304
|
break;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/mergeLocalizedData.ts"],"sourcesContent":["import type { Block, Field, FlattenedBlock } from '../fields/config/types.js'\nimport type { SanitizedConfig } from '../index.js'\nimport type { JsonObject } from '../types/index.js'\n\nimport { fieldAffectsData, fieldShouldBeLocalized, tabHasName } from '../fields/config/types.js'\n\ntype MergeDataToSelectedLocalesArgs = {\n configBlockReferences: SanitizedConfig['blocks']\n dataWithLocales: JsonObject\n docWithLocales: JsonObject\n fields: Field[]\n parentIsLocalized?: boolean\n selectedLocales: string[]\n}\n\n/**\n * Merges data from dataWithLocales onto docWithLocales for specified locales.\n * For localized fields, merges only the specified locales while preserving others.\n * For non-localized fields, keeps existing values from docWithLocales unchanged.\n * Returns a new object without mutating the original.\n */\nexport function mergeLocalizedData({\n configBlockReferences,\n dataWithLocales,\n docWithLocales,\n fields,\n parentIsLocalized = false,\n selectedLocales,\n}: MergeDataToSelectedLocalesArgs): JsonObject {\n if (!docWithLocales || typeof docWithLocales !== 'object') {\n return dataWithLocales || docWithLocales\n }\n\n const result: JsonObject = { ...docWithLocales }\n\n for (const field of fields) {\n if (fieldAffectsData(field)) {\n // If the parent is localized, all children are inherently \"localized\"\n if (parentIsLocalized && dataWithLocales[field.name]) {\n result[field.name] = dataWithLocales[field.name]\n continue\n }\n\n const fieldIsLocalized = fieldShouldBeLocalized({ field, parentIsLocalized })\n\n switch (field.type) {\n case 'array': {\n if (field.name in dataWithLocales) {\n const newValue = dataWithLocales[field.name]\n const existingValue = docWithLocales[field.name]\n\n if (fieldIsLocalized) {\n // If localized, handle locale keys\n if (newValue && typeof newValue === 'object' && !Array.isArray(newValue)) {\n const updatedArray: Record<string, unknown> = { ...(existingValue || {}) }\n\n for (const locale of selectedLocales) {\n if (locale in newValue) {\n updatedArray[locale] = newValue[locale]\n }\n }\n\n result[field.name] = updatedArray\n } else {\n // Preserve existing value if new value is not a valid object\n result[field.name] = existingValue\n }\n } else if (Array.isArray(newValue)) {\n // Non-localized array - still process children for any localized fields\n result[field.name] = newValue.map((newItem: JsonObject, index: number) => {\n const existingItem = existingValue?.[index] || {}\n\n return mergeLocalizedData({\n configBlockReferences,\n dataWithLocales: newItem,\n docWithLocales: existingItem,\n fields: field.fields,\n parentIsLocalized,\n selectedLocales,\n })\n })\n }\n }\n break\n }\n\n case 'blocks': {\n if (field.name in dataWithLocales) {\n const newValue = dataWithLocales[field.name]\n const existingValue = docWithLocales[field.name]\n\n if (fieldIsLocalized) {\n // If localized, handle locale keys\n if (newValue && typeof newValue === 'object' && !Array.isArray(newValue)) {\n const updatedData: Record<string, unknown> = { ...(existingValue || {}) }\n\n for (const locale of selectedLocales) {\n if (locale in newValue) {\n updatedData[locale] = newValue[locale]\n }\n }\n\n result[field.name] = updatedData\n } else {\n // Preserve existing value if new value is not a valid object\n result[field.name] = existingValue\n }\n } else if (Array.isArray(newValue)) {\n // Non-localized blocks - still process children for any localized fields\n result[field.name] = newValue.map((newBlockData: JsonObject, index: number) => {\n let block: Block | FlattenedBlock | undefined\n if (configBlockReferences && field.blockReferences) {\n for (const blockOrReference of field.blockReferences) {\n if (typeof blockOrReference === 'string') {\n block = configBlockReferences.find((b) => b.slug === newBlockData.blockType)\n } else {\n block = blockOrReference\n }\n }\n } else if (field.blocks) {\n block = field.blocks.find((b) => b.slug === newBlockData.blockType)\n }\n\n if (block) {\n const blockData =\n Array.isArray(existingValue) && existingValue[index]\n ? (existingValue[index] as JsonObject)\n : {}\n\n return mergeLocalizedData({\n configBlockReferences,\n dataWithLocales: newBlockData,\n docWithLocales: blockData,\n fields: block?.fields || [],\n parentIsLocalized,\n selectedLocales,\n })\n }\n\n return newBlockData\n })\n }\n }\n break\n }\n\n case 'group': {\n if (fieldAffectsData(field) && field.name) {\n // Named groups create a nested data structure\n if (field.name in dataWithLocales) {\n const newValue = dataWithLocales[field.name]\n const existingValue = docWithLocales[field.name]\n\n if (fieldIsLocalized) {\n if (newValue && typeof newValue === 'object' && !Array.isArray(newValue)) {\n const groupData: Record<string, unknown> = { ...(existingValue || {}) }\n\n for (const locale of selectedLocales) {\n if (locale in newValue && typeof newValue[locale] === 'object') {\n groupData[locale] = newValue[locale]\n }\n }\n\n result[field.name] = groupData\n } else {\n // Preserve existing value if new value is not a valid object\n result[field.name] = existingValue\n }\n } else if (typeof newValue === 'object' && !Array.isArray(newValue)) {\n // Non-localized group - still process children for any localized fields\n result[field.name] = mergeLocalizedData({\n configBlockReferences,\n dataWithLocales: newValue,\n docWithLocales: existingValue || {},\n fields: field.fields,\n parentIsLocalized,\n selectedLocales,\n })\n }\n }\n } else {\n // Unnamed groups pass through the same data level\n const merged = mergeLocalizedData({\n configBlockReferences,\n dataWithLocales,\n docWithLocales: result, // Use current result to avoid re-processing already-handled fields\n fields: field.fields,\n parentIsLocalized,\n selectedLocales,\n })\n Object.assign(result, merged)\n }\n break\n }\n\n default: {\n // For all other data-affecting fields (text, number, select, etc.)\n if (fieldIsLocalized) {\n if (field.name in dataWithLocales) {\n const newValue = dataWithLocales[field.name]\n const existingValue = docWithLocales[field.name] || {}\n\n // If localized, handle locale keys\n if (newValue && typeof newValue === 'object' && !Array.isArray(newValue)) {\n const merged: Record<string, unknown> = { ...existingValue }\n\n for (const locale of selectedLocales) {\n if (locale in newValue) {\n merged[locale] = newValue[locale]\n }\n }\n\n result[field.name] = merged\n } else if (parentIsLocalized) {\n // Child of localized parent - replace with new value\n result[field.name] = newValue\n } else {\n // Preserve existing value if new value is not a valid object\n result[field.name] = existingValue\n }\n }\n } else if (parentIsLocalized) {\n result[field.name] = dataWithLocales[field.name]\n } else {\n result[field.name] =\n field.name in dataWithLocales\n ? dataWithLocales[field.name]\n : docWithLocales[field.name]\n }\n break\n }\n }\n } else {\n // Layout-only fields that don't affect data structure\n switch (field.type) {\n case 'collapsible':\n case 'row': {\n // These pass through the same data level\n const merged = mergeLocalizedData({\n configBlockReferences,\n dataWithLocales,\n docWithLocales: result, // Use current result to avoid re-processing already-handled fields\n fields: field.fields,\n parentIsLocalized,\n selectedLocales,\n })\n Object.assign(result, merged)\n break\n }\n\n case 'tabs': {\n for (const tab of field.tabs) {\n if (tabHasName(tab)) {\n // Named tabs create a nested data structure and can be localized\n const tabIsLocalized = fieldShouldBeLocalized({ field: tab, parentIsLocalized })\n\n if (tab.name in dataWithLocales) {\n const newValue = dataWithLocales[tab.name]\n const existingValue = docWithLocales[tab.name]\n\n if (tabIsLocalized) {\n if (newValue && typeof newValue === 'object' && !Array.isArray(newValue)) {\n const merged: Record<string, unknown> = { ...(existingValue || {}) }\n\n for (const locale of selectedLocales) {\n if (locale in newValue && typeof newValue[locale] === 'object') {\n merged[locale] = newValue[locale]\n }\n }\n\n result[tab.name] = merged\n } else {\n // Preserve existing value if new value is not a valid object\n result[tab.name] = existingValue\n }\n } else if (typeof newValue === 'object' && !Array.isArray(newValue)) {\n // Non-localized tab - still process children for any localized fields\n result[tab.name] = mergeLocalizedData({\n configBlockReferences,\n dataWithLocales: newValue as JsonObject,\n docWithLocales: existingValue || {},\n fields: tab.fields,\n parentIsLocalized,\n selectedLocales,\n })\n }\n }\n } else {\n // Unnamed tabs pass through the same data level\n const merged = mergeLocalizedData({\n configBlockReferences,\n dataWithLocales,\n docWithLocales: result, // Use current result to avoid re-processing already-handled fields\n fields: tab.fields,\n parentIsLocalized,\n selectedLocales,\n })\n Object.assign(result, merged)\n }\n }\n break\n }\n }\n }\n }\n\n return result\n}\n"],"names":["fieldAffectsData","fieldShouldBeLocalized","tabHasName","mergeLocalizedData","configBlockReferences","dataWithLocales","docWithLocales","fields","parentIsLocalized","selectedLocales","result","field","name","fieldIsLocalized","type","newValue","existingValue","Array","isArray","updatedArray","locale","map","newItem","index","existingItem","updatedData","newBlockData","block","blockReferences","blockOrReference","find","b","slug","blockType","blocks","blockData","groupData","merged","Object","assign","tab","tabs","tabIsLocalized"],"mappings":"AAIA,SAASA,gBAAgB,EAAEC,sBAAsB,EAAEC,UAAU,QAAQ,4BAA2B;AAWhG;;;;;CA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I,CAAC,GAAGyB;wCACrB,OAAO;4CACL,6DAA6D;4CAC7D3B,MAAM,CAAC8B,IAAI5B,IAAI,CAAC,GAAGI;wCACrB;oCACF,OAAO,IAAI,OAAOD,aAAa,YAAY,CAACE,MAAMC,OAAO,CAACH,WAAW;wCACnE,sEAAsE;wCACtEL,MAAM,CAAC8B,IAAI5B,IAAI,CAAC,GAAGT,mBAAmB;4CACpCC;4CACAC,iBAAiBU;4CACjBT,gBAAgBU,iBAAiB,CAAC;4CAClCT,QAAQiC,IAAIjC,MAAM;4CAClBC;4CACAC;wCACF;oCACF;gCACF;4BACF,OAAO;gCACL,gDAAgD;gCAChD,MAAM4B,SAASlC,mBAAmB;oCAChCC;oCACAC;oCACAC,gBAAgBI;oCAChBH,QAAQiC,IAAIjC,MAAM;oCAClBC;oCACAC;gCACF;gCACA6B,OAAOC,MAAM,CAAC7B,QAAQ2B;4BACxB;wBACF;wBACA;oBACF;YACF;QACF;IACF;IAEA,OAAO3B;AACT"}
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/mergeLocalizedData.ts"],"sourcesContent":["import type { Block, Field, FlattenedBlock } from '../fields/config/types.js'\nimport type { SanitizedConfig } from '../index.js'\nimport type { JsonObject } from '../types/index.js'\n\nimport { fieldAffectsData, fieldShouldBeLocalized, tabHasName } from '../fields/config/types.js'\n\n/**\n * Collects field names at the current data level, recursing through pass-through fields\n * (row, collapsible, unnamed group, unnamed tab) but stopping at named fields.\n */\nfunction collectFlattenedFieldNames(fields: Field[]): Set<string> {\n const names = new Set<string>()\n for (const field of fields) {\n if (fieldAffectsData(field)) {\n names.add(field.name)\n } else if ('fields' in field && Array.isArray(field.fields)) {\n // Pass-through fields (row, collapsible, unnamed group)\n for (const name of collectFlattenedFieldNames(field.fields)) {\n names.add(name)\n }\n } else if (field.type === 'tabs') {\n for (const tab of field.tabs) {\n if (tabHasName(tab)) {\n names.add(tab.name)\n } else {\n for (const name of collectFlattenedFieldNames(tab.fields)) {\n names.add(name)\n }\n }\n }\n }\n }\n return names\n}\n\ntype MergeDataToSelectedLocalesArgs = {\n configBlockReferences: SanitizedConfig['blocks']\n dataWithLocales: JsonObject\n docWithLocales: JsonObject\n fields: Field[]\n parentIsLocalized?: boolean\n selectedLocales: string[]\n}\n\n/**\n * Merges data from dataWithLocales onto docWithLocales for specified locales.\n * For localized fields, merges only the specified locales while preserving others.\n * For non-localized fields, keeps existing values from docWithLocales unchanged.\n * Returns a new object without mutating the original.\n */\nexport function mergeLocalizedData({\n configBlockReferences,\n dataWithLocales,\n docWithLocales,\n fields,\n parentIsLocalized = false,\n selectedLocales,\n}: MergeDataToSelectedLocalesArgs): JsonObject {\n if (!docWithLocales || typeof docWithLocales !== 'object') {\n return dataWithLocales || docWithLocales\n }\n\n const result: JsonObject = { ...docWithLocales }\n\n for (const field of fields) {\n if (fieldAffectsData(field)) {\n // If the parent is localized, all children are inherently \"localized\"\n if (parentIsLocalized && dataWithLocales[field.name]) {\n result[field.name] = dataWithLocales[field.name]\n continue\n }\n\n const fieldIsLocalized = fieldShouldBeLocalized({ field, parentIsLocalized })\n\n switch (field.type) {\n case 'array': {\n if (field.name in dataWithLocales) {\n const newValue = dataWithLocales[field.name]\n const existingValue = docWithLocales[field.name]\n\n if (fieldIsLocalized) {\n // If localized, handle locale keys\n if (newValue && typeof newValue === 'object' && !Array.isArray(newValue)) {\n const updatedArray: Record<string, unknown> = { ...(existingValue || {}) }\n\n for (const locale of selectedLocales) {\n if (locale in newValue) {\n updatedArray[locale] = newValue[locale]\n }\n }\n\n result[field.name] = updatedArray\n } else {\n // Preserve existing value if new value is not a valid object\n result[field.name] = existingValue\n }\n } else if (Array.isArray(newValue)) {\n // Non-localized array - still process children for any localized fields\n result[field.name] = newValue.map((newItem: JsonObject, index: number) => {\n const existingItem = existingValue?.[index] || {}\n\n return mergeLocalizedData({\n configBlockReferences,\n dataWithLocales: newItem,\n docWithLocales: existingItem,\n fields: field.fields,\n parentIsLocalized,\n selectedLocales,\n })\n })\n }\n }\n break\n }\n\n case 'blocks': {\n if (field.name in dataWithLocales) {\n const newValue = dataWithLocales[field.name]\n const existingValue = docWithLocales[field.name]\n\n if (fieldIsLocalized) {\n // If localized, handle locale keys\n if (newValue && typeof newValue === 'object' && !Array.isArray(newValue)) {\n const updatedData: Record<string, unknown> = { ...(existingValue || {}) }\n\n for (const locale of selectedLocales) {\n if (locale in newValue) {\n updatedData[locale] = newValue[locale]\n }\n }\n\n result[field.name] = updatedData\n } else {\n // Preserve existing value if new value is not a valid object\n result[field.name] = existingValue\n }\n } else if (Array.isArray(newValue)) {\n // Non-localized blocks - still process children for any localized fields\n result[field.name] = newValue.map((newBlockData: JsonObject, index: number) => {\n let block: Block | FlattenedBlock | undefined\n if (configBlockReferences && field.blockReferences) {\n for (const blockOrReference of field.blockReferences) {\n if (typeof blockOrReference === 'string') {\n block = configBlockReferences.find((b) => b.slug === newBlockData.blockType)\n } else {\n block = blockOrReference\n }\n }\n } else if (field.blocks) {\n block = field.blocks.find((b) => b.slug === newBlockData.blockType)\n }\n\n if (block) {\n const blockData =\n Array.isArray(existingValue) && existingValue[index]\n ? (existingValue[index] as JsonObject)\n : {}\n\n const merged = mergeLocalizedData({\n configBlockReferences,\n dataWithLocales: newBlockData,\n docWithLocales: blockData,\n fields: block?.fields || [],\n parentIsLocalized,\n selectedLocales,\n })\n\n // blockType, id, blockName are set by Payload internally\n // and not part of block.fields, so they must be preserved explicitly\n merged.blockType = newBlockData.blockType\n merged.id = newBlockData.id\n merged.blockName = newBlockData.blockName\n\n return merged\n }\n\n return newBlockData\n })\n }\n }\n break\n }\n\n case 'group': {\n if (fieldAffectsData(field) && field.name) {\n // Named groups create a nested data structure\n if (field.name in dataWithLocales) {\n const newValue = dataWithLocales[field.name]\n const existingValue = docWithLocales[field.name]\n\n if (fieldIsLocalized) {\n if (newValue && typeof newValue === 'object' && !Array.isArray(newValue)) {\n const groupData: Record<string, unknown> = { ...(existingValue || {}) }\n\n for (const locale of selectedLocales) {\n if (locale in newValue && typeof newValue[locale] === 'object') {\n groupData[locale] = newValue[locale]\n }\n }\n\n result[field.name] = groupData\n } else {\n // Preserve existing value if new value is not a valid object\n result[field.name] = existingValue\n }\n } else if (typeof newValue === 'object' && !Array.isArray(newValue)) {\n // Non-localized group - still process children for any localized fields\n result[field.name] = mergeLocalizedData({\n configBlockReferences,\n dataWithLocales: newValue,\n docWithLocales: existingValue || {},\n fields: field.fields,\n parentIsLocalized,\n selectedLocales,\n })\n }\n }\n }\n break\n }\n\n default: {\n // For all other data-affecting fields (text, number, select, etc.)\n if (fieldIsLocalized) {\n if (field.name in dataWithLocales) {\n const newValue = dataWithLocales[field.name]\n const existingValue = docWithLocales[field.name] || {}\n\n // If localized, handle locale keys\n if (newValue && typeof newValue === 'object' && !Array.isArray(newValue)) {\n const merged: Record<string, unknown> = { ...existingValue }\n\n for (const locale of selectedLocales) {\n if (locale in newValue) {\n merged[locale] = newValue[locale]\n }\n }\n\n result[field.name] = merged\n } else if (parentIsLocalized) {\n // Child of localized parent - replace with new value\n result[field.name] = newValue\n } else {\n // Preserve existing value if new value is not a valid object\n result[field.name] = existingValue\n }\n }\n } else if (parentIsLocalized) {\n result[field.name] = dataWithLocales[field.name]\n } else {\n result[field.name] =\n field.name in dataWithLocales\n ? dataWithLocales[field.name]\n : docWithLocales[field.name]\n }\n break\n }\n }\n } else {\n // Layout-only fields that don't affect data structure\n switch (field.type) {\n case 'collapsible':\n case 'group':\n case 'row': {\n // These pass through the same data level\n const merged = mergeLocalizedData({\n configBlockReferences,\n dataWithLocales,\n docWithLocales,\n fields: field.fields,\n parentIsLocalized,\n selectedLocales,\n })\n // Only copy fields that belong to this layout field to avoid overwriting already-processed fields\n const fieldNames = collectFlattenedFieldNames(field.fields)\n for (const name of fieldNames) {\n if (name in merged) {\n result[name] = merged[name]\n }\n }\n break\n }\n\n case 'tabs': {\n for (const tab of field.tabs) {\n if (tabHasName(tab)) {\n // Named tabs create a nested data structure and can be localized\n const tabIsLocalized = fieldShouldBeLocalized({ field: tab, parentIsLocalized })\n\n if (tab.name in dataWithLocales) {\n const newValue = dataWithLocales[tab.name]\n const existingValue = docWithLocales[tab.name]\n\n if (tabIsLocalized) {\n if (newValue && typeof newValue === 'object' && !Array.isArray(newValue)) {\n const merged: Record<string, unknown> = { ...(existingValue || {}) }\n\n for (const locale of selectedLocales) {\n if (locale in newValue && typeof newValue[locale] === 'object') {\n merged[locale] = newValue[locale]\n }\n }\n\n result[tab.name] = merged\n } else {\n // Preserve existing value if new value is not a valid object\n result[tab.name] = existingValue\n }\n } else if (typeof newValue === 'object' && !Array.isArray(newValue)) {\n // Non-localized tab - still process children for any localized fields\n result[tab.name] = mergeLocalizedData({\n configBlockReferences,\n dataWithLocales: newValue as JsonObject,\n docWithLocales: existingValue || {},\n fields: tab.fields,\n parentIsLocalized,\n selectedLocales,\n })\n }\n }\n } else {\n // Unnamed tabs pass through the same data level\n const merged = mergeLocalizedData({\n configBlockReferences,\n dataWithLocales,\n docWithLocales,\n fields: tab.fields,\n parentIsLocalized,\n selectedLocales,\n })\n // Only copy fields that belong to this tab to avoid overwriting already-processed fields\n const tabFieldNames = collectFlattenedFieldNames(tab.fields)\n for (const name of tabFieldNames) {\n if (name in merged) {\n result[name] = merged[name]\n }\n }\n }\n }\n break\n }\n }\n }\n }\n\n return result\n}\n"],"names":["fieldAffectsData","fieldShouldBeLocalized","tabHasName","collectFlattenedFieldNames","fields","names","Set","field","add","name","Array","isArray","type","tab","tabs","mergeLocalizedData","configBlockReferences","dataWithLocales","docWithLocales","parentIsLocalized","selectedLocales","result","fieldIsLocalized","newValue","existingValue","updatedArray","locale","map","newItem","index","existingItem","updatedData","newBlockData","block","blockReferences","blockOrReference","find","b","slug","blockType","blocks","blockData","merged","id","blockName","groupData","fieldNames","tabIsLocalized","tabFieldNames"],"mappings":"AAIA,SAASA,gBAAgB,EAAEC,sBAAsB,EAAEC,UAAU,QAAQ,4BAA2B;AAEhG;;;CAGC,GACD,SAASC,2BAA2BC,MAAe;IACjD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