@payloadcms/db-postgres 3.0.0-canary.92e4997 → 3.0.0-canary.c13f9ba
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/connect.d.ts.map +1 -1
- package/dist/connect.js +12 -7
- package/dist/connect.js.map +1 -1
- package/dist/count.d.ts.map +1 -1
- package/dist/count.js +1 -10
- package/dist/count.js.map +1 -1
- package/dist/createMigration.d.ts.map +1 -1
- package/dist/createMigration.js +58 -37
- package/dist/createMigration.js.map +1 -1
- package/dist/createVersion.d.ts.map +1 -1
- package/dist/createVersion.js +2 -6
- package/dist/createVersion.js.map +1 -1
- package/dist/deleteOne.js +2 -2
- package/dist/deleteOne.js.map +1 -1
- package/dist/destroy.d.ts.map +1 -1
- package/dist/destroy.js +4 -0
- package/dist/destroy.js.map +1 -1
- package/dist/exports/migration-utils.d.ts +2 -0
- package/dist/exports/migration-utils.d.ts.map +1 -0
- package/dist/exports/migration-utils.js +3 -0
- package/dist/exports/migration-utils.js.map +1 -0
- package/dist/find/buildFindManyArgs.d.ts +5 -1
- package/dist/find/buildFindManyArgs.d.ts.map +1 -1
- package/dist/find/buildFindManyArgs.js +2 -1
- package/dist/find/buildFindManyArgs.js.map +1 -1
- package/dist/find/findMany.d.ts.map +1 -1
- package/dist/find/findMany.js +4 -15
- package/dist/find/findMany.js.map +1 -1
- package/dist/find/traverseFields.d.ts +3 -2
- package/dist/find/traverseFields.d.ts.map +1 -1
- package/dist/find/traverseFields.js +22 -4
- package/dist/find/traverseFields.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -1
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +14 -19
- package/dist/init.js.map +1 -1
- package/dist/predefinedMigrations/relationships-v2-v3.d.ts +4 -0
- package/dist/predefinedMigrations/relationships-v2-v3.d.ts.map +1 -0
- package/dist/predefinedMigrations/relationships-v2-v3.js.map +1 -0
- package/dist/predefinedMigrations/relationships-v2-v3.mjs +11 -0
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.d.ts +20 -0
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.d.ts.map +1 -0
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.js +170 -0
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.js.map +1 -0
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.d.ts +11 -0
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.d.ts.map +1 -0
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.js +191 -0
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.js.map +1 -0
- package/dist/predefinedMigrations/v2-v3/groupUpSQLStatements.d.ts +3 -0
- package/dist/predefinedMigrations/v2-v3/groupUpSQLStatements.d.ts.map +1 -0
- package/dist/predefinedMigrations/v2-v3/groupUpSQLStatements.js +56 -0
- package/dist/predefinedMigrations/v2-v3/groupUpSQLStatements.js.map +1 -0
- package/dist/predefinedMigrations/v2-v3/index.d.ts +24 -0
- package/dist/predefinedMigrations/v2-v3/index.d.ts.map +1 -0
- package/dist/predefinedMigrations/v2-v3/index.js +211 -0
- package/dist/predefinedMigrations/v2-v3/index.js.map +1 -0
- package/dist/predefinedMigrations/v2-v3/migrateRelationships.d.ts +19 -0
- package/dist/predefinedMigrations/v2-v3/migrateRelationships.d.ts.map +1 -0
- package/dist/predefinedMigrations/v2-v3/migrateRelationships.js +57 -0
- package/dist/predefinedMigrations/v2-v3/migrateRelationships.js.map +1 -0
- package/dist/predefinedMigrations/v2-v3/traverseFields.d.ts +23 -0
- package/dist/predefinedMigrations/v2-v3/traverseFields.d.ts.map +1 -0
- package/dist/predefinedMigrations/v2-v3/traverseFields.js +85 -0
- package/dist/predefinedMigrations/v2-v3/traverseFields.js.map +1 -0
- package/dist/predefinedMigrations/v2-v3/types.d.ts +9 -0
- package/dist/predefinedMigrations/v2-v3/types.d.ts.map +1 -0
- package/dist/predefinedMigrations/v2-v3/types.js +6 -0
- package/dist/predefinedMigrations/v2-v3/types.js.map +1 -0
- package/dist/queries/buildAndOrConditions.d.ts +3 -4
- package/dist/queries/buildAndOrConditions.d.ts.map +1 -1
- package/dist/queries/buildAndOrConditions.js +1 -2
- package/dist/queries/buildAndOrConditions.js.map +1 -1
- package/dist/queries/buildQuery.d.ts +1 -2
- package/dist/queries/buildQuery.d.ts.map +1 -1
- package/dist/queries/buildQuery.js +1 -5
- package/dist/queries/buildQuery.js.map +1 -1
- package/dist/queries/getTableColumnFromPath.d.ts +3 -4
- package/dist/queries/getTableColumnFromPath.d.ts.map +1 -1
- package/dist/queries/getTableColumnFromPath.js +168 -96
- package/dist/queries/getTableColumnFromPath.js.map +1 -1
- package/dist/queries/parseParams.d.ts +3 -4
- package/dist/queries/parseParams.d.ts.map +1 -1
- package/dist/queries/parseParams.js +7 -6
- package/dist/queries/parseParams.js.map +1 -1
- package/dist/queries/selectDistinct.d.ts +3 -4
- package/dist/queries/selectDistinct.d.ts.map +1 -1
- package/dist/queries/selectDistinct.js +3 -14
- package/dist/queries/selectDistinct.js.map +1 -1
- package/dist/schema/build.d.ts +8 -4
- package/dist/schema/build.d.ts.map +1 -1
- package/dist/schema/build.js +161 -112
- package/dist/schema/build.js.map +1 -1
- package/dist/schema/traverseFields.d.ts +4 -6
- package/dist/schema/traverseFields.d.ts.map +1 -1
- package/dist/schema/traverseFields.js +103 -40
- package/dist/schema/traverseFields.js.map +1 -1
- package/dist/transactions/beginTransaction.d.ts.map +1 -1
- package/dist/transactions/beginTransaction.js +4 -0
- package/dist/transactions/beginTransaction.js.map +1 -1
- package/dist/transform/read/index.d.ts +3 -1
- package/dist/transform/read/index.d.ts.map +1 -1
- package/dist/transform/read/index.js +2 -1
- package/dist/transform/read/index.js.map +1 -1
- package/dist/transform/read/relationship.d.ts.map +1 -1
- package/dist/transform/read/relationship.js +0 -4
- package/dist/transform/read/relationship.js.map +1 -1
- package/dist/transform/read/traverseFields.d.ts +6 -1
- package/dist/transform/read/traverseFields.d.ts.map +1 -1
- package/dist/transform/read/traverseFields.js +69 -55
- package/dist/transform/read/traverseFields.js.map +1 -1
- package/dist/transform/write/traverseFields.d.ts.map +1 -1
- package/dist/transform/write/traverseFields.js +20 -3
- package/dist/transform/write/traverseFields.js.map +1 -1
- package/dist/types.d.ts +3 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/update.d.ts.map +1 -1
- package/dist/update.js +1 -2
- package/dist/update.js.map +1 -1
- package/dist/upsertRow/index.d.ts +1 -1
- package/dist/upsertRow/index.d.ts.map +1 -1
- package/dist/upsertRow/index.js +3 -1
- package/dist/upsertRow/index.js.map +1 -1
- package/dist/upsertRow/types.d.ts +5 -0
- package/dist/upsertRow/types.d.ts.map +1 -1
- package/dist/upsertRow/types.js.map +1 -1
- package/package.json +12 -6
@@ -4,11 +4,12 @@ import { transformHasManyText } from './hasManyText.js';
|
|
4
4
|
import { transformRelationship } from './relationship.js';
|
5
5
|
// Traverse fields recursively, transforming data
|
6
6
|
// for each field type into required Payload shape
|
7
|
-
export const traverseFields = ({ blocks, config, dataRef, deletions, fieldPrefix, fields, numbers, path, relationships, table, texts })=>{
|
7
|
+
export const traverseFields = ({ adapter, blocks, config, dataRef, deletions, fieldPrefix, fields, numbers, path, relationships, table, texts })=>{
|
8
8
|
const sanitizedPath = path ? `${path}.` : path;
|
9
9
|
const formatted = fields.reduce((result, field)=>{
|
10
10
|
if (field.type === 'tabs') {
|
11
11
|
traverseFields({
|
12
|
+
adapter,
|
12
13
|
blocks,
|
13
14
|
config,
|
14
15
|
dataRef,
|
@@ -27,6 +28,7 @@ export const traverseFields = ({ blocks, config, dataRef, deletions, fieldPrefix
|
|
27
28
|
}
|
28
29
|
if (field.type === 'collapsible' || field.type === 'row' || field.type === 'tab' && !('name' in field)) {
|
29
30
|
traverseFields({
|
31
|
+
adapter,
|
30
32
|
blocks,
|
31
33
|
config,
|
32
34
|
dataRef,
|
@@ -43,6 +45,8 @@ export const traverseFields = ({ blocks, config, dataRef, deletions, fieldPrefix
|
|
43
45
|
if (fieldAffectsData(field)) {
|
44
46
|
const fieldName = `${fieldPrefix || ''}${field.name}`;
|
45
47
|
const fieldData = table[fieldName];
|
48
|
+
const localizedFieldData = {};
|
49
|
+
const valuesToTransform = [];
|
46
50
|
if (fieldPrefix) {
|
47
51
|
deletions.push(()=>delete table[fieldName]);
|
48
52
|
}
|
@@ -60,6 +64,7 @@ export const traverseFields = ({ blocks, config, dataRef, deletions, fieldPrefix
|
|
60
64
|
delete row._uuid;
|
61
65
|
}
|
62
66
|
const rowResult = traverseFields({
|
67
|
+
adapter,
|
63
68
|
blocks,
|
64
69
|
config,
|
65
70
|
dataRef: data,
|
@@ -89,6 +94,7 @@ export const traverseFields = ({ blocks, config, dataRef, deletions, fieldPrefix
|
|
89
94
|
delete row._order;
|
90
95
|
}
|
91
96
|
return traverseFields({
|
97
|
+
adapter,
|
92
98
|
blocks,
|
93
99
|
config,
|
94
100
|
dataRef: row,
|
@@ -127,6 +133,7 @@ export const traverseFields = ({ blocks, config, dataRef, deletions, fieldPrefix
|
|
127
133
|
const block = field.blocks.find(({ slug })=>slug === row.blockType);
|
128
134
|
if (block) {
|
129
135
|
const blockResult = traverseFields({
|
136
|
+
adapter,
|
130
137
|
blocks,
|
131
138
|
config,
|
132
139
|
dataRef: row,
|
@@ -155,6 +162,7 @@ export const traverseFields = ({ blocks, config, dataRef, deletions, fieldPrefix
|
|
155
162
|
const block = field.blocks.find(({ slug })=>slug === row.blockType);
|
156
163
|
if (block) {
|
157
164
|
return traverseFields({
|
165
|
+
adapter,
|
158
166
|
blocks,
|
159
167
|
config,
|
160
168
|
dataRef: row,
|
@@ -175,44 +183,59 @@ export const traverseFields = ({ blocks, config, dataRef, deletions, fieldPrefix
|
|
175
183
|
return result;
|
176
184
|
}
|
177
185
|
if (field.type === 'relationship' || field.type === 'upload') {
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
if (field.localized && config.localization && config.localization.locales) {
|
186
|
+
if (typeof field.relationTo === 'string' && !('hasMany' in field && field.hasMany)) {
|
187
|
+
if (field.localized && config.localization && config.localization.locales && Array.isArray(table?._locales)) {
|
188
|
+
table._locales.forEach((localeRow)=>{
|
182
189
|
result[field.name] = {
|
183
|
-
[
|
190
|
+
[localeRow._locale]: localeRow[fieldName]
|
184
191
|
};
|
185
|
-
}
|
186
|
-
|
187
|
-
|
192
|
+
});
|
193
|
+
} else {
|
194
|
+
valuesToTransform.push({
|
195
|
+
ref: result,
|
196
|
+
table
|
197
|
+
});
|
188
198
|
}
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
199
|
+
} else {
|
200
|
+
const relationPathMatch = relationships[`${sanitizedPath}${field.name}`];
|
201
|
+
if (!relationPathMatch) {
|
202
|
+
if ('hasMany' in field && field.hasMany) {
|
203
|
+
if (field.localized && config.localization && config.localization.locales) {
|
204
|
+
result[field.name] = {
|
205
|
+
[config.localization.defaultLocale]: []
|
206
|
+
};
|
207
|
+
} else {
|
208
|
+
result[field.name] = [];
|
209
|
+
}
|
198
210
|
}
|
199
|
-
|
200
|
-
|
211
|
+
return result;
|
212
|
+
}
|
213
|
+
if (field.localized) {
|
214
|
+
result[field.name] = {};
|
215
|
+
const relationsByLocale = {};
|
216
|
+
relationPathMatch.forEach((row)=>{
|
217
|
+
if (typeof row.locale === 'string') {
|
218
|
+
if (!relationsByLocale[row.locale]) relationsByLocale[row.locale] = [];
|
219
|
+
relationsByLocale[row.locale].push(row);
|
220
|
+
}
|
221
|
+
});
|
222
|
+
Object.entries(relationsByLocale).forEach(([locale, relations])=>{
|
223
|
+
transformRelationship({
|
224
|
+
field,
|
225
|
+
locale,
|
226
|
+
ref: result,
|
227
|
+
relations
|
228
|
+
});
|
229
|
+
});
|
230
|
+
} else {
|
201
231
|
transformRelationship({
|
202
232
|
field,
|
203
|
-
locale,
|
204
233
|
ref: result,
|
205
|
-
relations
|
234
|
+
relations: relationPathMatch
|
206
235
|
});
|
207
|
-
}
|
208
|
-
|
209
|
-
transformRelationship({
|
210
|
-
field,
|
211
|
-
ref: result,
|
212
|
-
relations: relationPathMatch
|
213
|
-
});
|
236
|
+
}
|
237
|
+
return result;
|
214
238
|
}
|
215
|
-
return result;
|
216
239
|
}
|
217
240
|
if (field.type === 'text' && field?.hasMany) {
|
218
241
|
const textPathMatch = texts[`${sanitizedPath}${field.name}`];
|
@@ -288,8 +311,6 @@ export const traverseFields = ({ blocks, config, dataRef, deletions, fieldPrefix
|
|
288
311
|
}
|
289
312
|
return result;
|
290
313
|
}
|
291
|
-
const localizedFieldData = {};
|
292
|
-
const valuesToTransform = [];
|
293
314
|
if (field.localized && Array.isArray(table._locales)) {
|
294
315
|
table._locales.forEach((localeRow)=>{
|
295
316
|
valuesToTransform.push({
|
@@ -306,6 +327,7 @@ export const traverseFields = ({ blocks, config, dataRef, deletions, fieldPrefix
|
|
306
327
|
valuesToTransform.forEach(({ ref, table })=>{
|
307
328
|
const fieldData = table[`${fieldPrefix || ''}${field.name}`];
|
308
329
|
const locale = table?._locale;
|
330
|
+
let val = fieldData;
|
309
331
|
switch(field.type){
|
310
332
|
case 'tab':
|
311
333
|
case 'group':
|
@@ -318,6 +340,7 @@ export const traverseFields = ({ blocks, config, dataRef, deletions, fieldPrefix
|
|
318
340
|
}
|
319
341
|
Object.entries(ref).forEach(([groupLocale, groupLocaleData])=>{
|
320
342
|
ref[groupLocale] = traverseFields({
|
343
|
+
adapter,
|
321
344
|
blocks,
|
322
345
|
config,
|
323
346
|
dataRef: groupLocaleData,
|
@@ -337,6 +360,7 @@ export const traverseFields = ({ blocks, config, dataRef, deletions, fieldPrefix
|
|
337
360
|
} else {
|
338
361
|
const groupData = {};
|
339
362
|
ref[field.name] = traverseFields({
|
363
|
+
adapter,
|
340
364
|
blocks,
|
341
365
|
config,
|
342
366
|
dataRef: groupData,
|
@@ -353,57 +377,47 @@ export const traverseFields = ({ blocks, config, dataRef, deletions, fieldPrefix
|
|
353
377
|
delete ref._order;
|
354
378
|
}
|
355
379
|
}
|
356
|
-
|
380
|
+
return;
|
357
381
|
}
|
358
382
|
case 'text':
|
359
383
|
{
|
360
|
-
let val = fieldData;
|
361
384
|
if (typeof fieldData === 'string') {
|
362
385
|
val = String(fieldData);
|
363
386
|
}
|
364
|
-
if (typeof locale === 'string') {
|
365
|
-
ref[locale] = val;
|
366
|
-
} else {
|
367
|
-
result[field.name] = val;
|
368
|
-
}
|
369
387
|
break;
|
370
388
|
}
|
371
389
|
case 'number':
|
372
390
|
{
|
373
|
-
let val = fieldData;
|
374
391
|
if (typeof fieldData === 'string') {
|
375
392
|
val = Number.parseFloat(fieldData);
|
376
393
|
}
|
377
|
-
if (typeof locale === 'string') {
|
378
|
-
ref[locale] = val;
|
379
|
-
} else {
|
380
|
-
result[field.name] = val;
|
381
|
-
}
|
382
394
|
break;
|
383
395
|
}
|
384
396
|
case 'date':
|
385
397
|
{
|
386
|
-
let val = fieldData;
|
387
398
|
if (typeof fieldData === 'string') {
|
388
399
|
val = new Date(fieldData).toISOString();
|
389
400
|
}
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
401
|
+
break;
|
402
|
+
}
|
403
|
+
case 'relationship':
|
404
|
+
case 'upload':
|
405
|
+
{
|
406
|
+
if (val && typeof field.relationTo === 'string' && adapter.payload.collections[field.relationTo].customIDType === 'number') {
|
407
|
+
val = Number(val);
|
394
408
|
}
|
395
409
|
break;
|
396
410
|
}
|
397
411
|
default:
|
398
412
|
{
|
399
|
-
if (typeof locale === 'string') {
|
400
|
-
ref[locale] = fieldData;
|
401
|
-
} else {
|
402
|
-
result[field.name] = fieldData;
|
403
|
-
}
|
404
413
|
break;
|
405
414
|
}
|
406
415
|
}
|
416
|
+
if (typeof locale === 'string') {
|
417
|
+
ref[locale] = val;
|
418
|
+
} else {
|
419
|
+
result[field.name] = val;
|
420
|
+
}
|
407
421
|
});
|
408
422
|
if (Object.keys(localizedFieldData).length > 0) {
|
409
423
|
result[field.name] = localizedFieldData;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/transform/read/traverseFields.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\nimport type { SanitizedConfig } from 'payload/config'\nimport type { Field, TabAsField } from 'payload/types'\n\nimport { fieldAffectsData } from 'payload/types'\n\nimport type { BlocksMap } from '../../utilities/createBlocksMap.js'\n\nimport { transformHasManyNumber } from './hasManyNumber.js'\nimport { transformHasManyText } from './hasManyText.js'\nimport { transformRelationship } from './relationship.js'\n\ntype TraverseFieldsArgs = {\n /**\n * Pre-formatted blocks map\n */\n blocks: BlocksMap\n /**\n * The full Payload config\n */\n config: SanitizedConfig\n /**\n * The data reference to be mutated within this recursive function\n */\n dataRef: Record<string, unknown>\n /**\n * Data that needs to be removed from the result after all fields have populated\n */\n deletions: (() => void)[]\n /**\n * Column prefix can be built up by group and named tab fields\n */\n fieldPrefix: string\n /**\n * An array of Payload fields to traverse\n */\n fields: (Field | TabAsField)[]\n /**\n * All hasMany number fields, as returned by Drizzle, keyed on an object by field path\n */\n numbers: Record<string, Record<string, unknown>[]>\n /**\n * The current field path (in dot notation), used to merge in relationships\n */\n path: string\n /**\n * All related documents, as returned by Drizzle, keyed on an object by field path\n */\n relationships: Record<string, Record<string, unknown>[]>\n /**\n * Data structure representing the nearest table from db\n */\n table: Record<string, unknown>\n /**\n * All hasMany text fields, as returned by Drizzle, keyed on an object by field path\n */\n texts: Record<string, Record<string, unknown>[]>\n}\n\n// Traverse fields recursively, transforming data\n// for each field type into required Payload shape\nexport const traverseFields = <T extends Record<string, unknown>>({\n blocks,\n config,\n dataRef,\n deletions,\n fieldPrefix,\n fields,\n numbers,\n path,\n relationships,\n table,\n texts,\n}: TraverseFieldsArgs): T => {\n const sanitizedPath = path ? `${path}.` : path\n\n const formatted = fields.reduce((result, field) => {\n if (field.type === 'tabs') {\n traverseFields({\n blocks,\n config,\n dataRef,\n deletions,\n fieldPrefix,\n fields: field.tabs.map((tab) => ({ ...tab, type: 'tab' })),\n numbers,\n path,\n relationships,\n table,\n texts,\n })\n }\n\n if (\n field.type === 'collapsible' ||\n field.type === 'row' ||\n (field.type === 'tab' && !('name' in field))\n ) {\n traverseFields({\n blocks,\n config,\n dataRef,\n deletions,\n fieldPrefix,\n fields: field.fields,\n numbers,\n path,\n relationships,\n table,\n texts,\n })\n }\n\n if (fieldAffectsData(field)) {\n const fieldName = `${fieldPrefix || ''}${field.name}`\n const fieldData = table[fieldName]\n\n if (fieldPrefix) {\n deletions.push(() => delete table[fieldName])\n }\n\n if (field.type === 'array') {\n if (Array.isArray(fieldData)) {\n if (field.localized) {\n result[field.name] = fieldData.reduce((arrayResult, row) => {\n if (typeof row._locale === 'string') {\n if (!arrayResult[row._locale]) arrayResult[row._locale] = []\n const locale = row._locale\n const data = {}\n delete row._locale\n if (row._uuid) {\n row.id = row._uuid\n delete row._uuid\n }\n\n const rowResult = traverseFields<T>({\n blocks,\n config,\n dataRef: data,\n deletions,\n fieldPrefix: '',\n fields: field.fields,\n numbers,\n path: `${sanitizedPath}${field.name}.${row._order - 1}`,\n relationships,\n table: row,\n texts,\n })\n\n if ('_order' in rowResult) {\n delete rowResult._order\n }\n\n arrayResult[locale].push(rowResult)\n }\n\n return arrayResult\n }, {})\n } else {\n result[field.name] = fieldData.map((row, i) => {\n if (row._uuid) {\n row.id = row._uuid\n delete row._uuid\n }\n\n if ('_order' in row) {\n delete row._order\n }\n\n return traverseFields<T>({\n blocks,\n config,\n dataRef: row,\n deletions,\n fieldPrefix: '',\n fields: field.fields,\n numbers,\n path: `${sanitizedPath}${field.name}.${i}`,\n relationships,\n table: row,\n texts,\n })\n })\n }\n }\n\n return result\n }\n\n if (field.type === 'blocks') {\n const blockFieldPath = `${sanitizedPath}${field.name}`\n\n if (Array.isArray(blocks[blockFieldPath])) {\n if (field.localized) {\n result[field.name] = {}\n\n blocks[blockFieldPath].forEach((row) => {\n if (row._uuid) {\n row.id = row._uuid\n delete row._uuid\n }\n if (typeof row._locale === 'string') {\n if (!result[field.name][row._locale]) result[field.name][row._locale] = []\n result[field.name][row._locale].push(row)\n delete row._locale\n }\n })\n\n Object.entries(result[field.name]).forEach(([locale, localizedBlocks]) => {\n result[field.name][locale] = localizedBlocks.map((row) => {\n const block = field.blocks.find(({ slug }) => slug === row.blockType)\n\n if (block) {\n const blockResult = traverseFields<T>({\n blocks,\n config,\n dataRef: row,\n deletions,\n fieldPrefix: '',\n fields: block.fields,\n numbers,\n path: `${blockFieldPath}.${row._order - 1}`,\n relationships,\n table: row,\n texts,\n })\n\n delete blockResult._order\n return blockResult\n }\n\n return {}\n })\n })\n } else {\n result[field.name] = blocks[blockFieldPath].map((row, i) => {\n delete row._order\n if (row._uuid) {\n row.id = row._uuid\n delete row._uuid\n }\n const block = field.blocks.find(({ slug }) => slug === row.blockType)\n\n if (block) {\n return traverseFields<T>({\n blocks,\n config,\n dataRef: row,\n deletions,\n fieldPrefix: '',\n fields: block.fields,\n numbers,\n path: `${blockFieldPath}.${i}`,\n relationships,\n table: row,\n texts,\n })\n }\n\n return {}\n })\n }\n }\n\n return result\n }\n\n if (field.type === 'relationship' || field.type === 'upload') {\n const relationPathMatch = relationships[`${sanitizedPath}${field.name}`]\n if (!relationPathMatch) {\n if ('hasMany' in field && field.hasMany) {\n if (field.localized && config.localization && config.localization.locales) {\n result[field.name] = {\n [config.localization.defaultLocale]: [],\n }\n } else {\n result[field.name] = []\n }\n }\n\n return result\n }\n\n if (field.localized) {\n result[field.name] = {}\n const relationsByLocale: Record<string, Record<string, unknown>[]> = {}\n\n relationPathMatch.forEach((row) => {\n if (typeof row.locale === 'string') {\n if (!relationsByLocale[row.locale]) relationsByLocale[row.locale] = []\n relationsByLocale[row.locale].push(row)\n }\n })\n\n Object.entries(relationsByLocale).forEach(([locale, relations]) => {\n transformRelationship({\n field,\n locale,\n ref: result,\n relations,\n })\n })\n } else {\n transformRelationship({\n field,\n ref: result,\n relations: relationPathMatch,\n })\n }\n\n return result\n }\n\n if (field.type === 'text' && field?.hasMany) {\n const textPathMatch = texts[`${sanitizedPath}${field.name}`]\n if (!textPathMatch) return result\n\n if (field.localized) {\n result[field.name] = {}\n const textsByLocale: Record<string, Record<string, unknown>[]> = {}\n\n textPathMatch.forEach((row) => {\n if (typeof row.locale === 'string') {\n if (!textsByLocale[row.locale]) textsByLocale[row.locale] = []\n textsByLocale[row.locale].push(row)\n }\n })\n\n Object.entries(textsByLocale).forEach(([locale, texts]) => {\n transformHasManyText({\n field,\n locale,\n ref: result,\n textRows: texts,\n })\n })\n } else {\n transformHasManyText({\n field,\n ref: result,\n textRows: textPathMatch,\n })\n }\n\n return result\n }\n\n if (field.type === 'number' && field.hasMany) {\n const numberPathMatch = numbers[`${sanitizedPath}${field.name}`]\n if (!numberPathMatch) return result\n\n if (field.localized) {\n result[field.name] = {}\n const numbersByLocale: Record<string, Record<string, unknown>[]> = {}\n\n numberPathMatch.forEach((row) => {\n if (typeof row.locale === 'string') {\n if (!numbersByLocale[row.locale]) numbersByLocale[row.locale] = []\n numbersByLocale[row.locale].push(row)\n }\n })\n\n Object.entries(numbersByLocale).forEach(([locale, numbers]) => {\n transformHasManyNumber({\n field,\n locale,\n numberRows: numbers,\n ref: result,\n })\n })\n } else {\n transformHasManyNumber({\n field,\n numberRows: numberPathMatch,\n ref: result,\n })\n }\n\n return result\n }\n\n if (field.type === 'select' && field.hasMany) {\n if (Array.isArray(fieldData)) {\n if (field.localized) {\n result[field.name] = fieldData.reduce((selectResult, row) => {\n if (typeof row.locale === 'string') {\n if (!selectResult[row.locale]) selectResult[row.locale] = []\n selectResult[row.locale].push(row.value)\n }\n\n return selectResult\n }, {})\n } else {\n result[field.name] = fieldData.map(({ value }) => value)\n }\n }\n return result\n }\n\n const localizedFieldData = {}\n const valuesToTransform: {\n ref: Record<string, unknown>\n table: Record<string, unknown>\n }[] = []\n\n if (field.localized && Array.isArray(table._locales)) {\n table._locales.forEach((localeRow) => {\n valuesToTransform.push({ ref: localizedFieldData, table: localeRow })\n })\n } else {\n valuesToTransform.push({ ref: result, table })\n }\n\n valuesToTransform.forEach(({ ref, table }) => {\n const fieldData = table[`${fieldPrefix || ''}${field.name}`]\n const locale = table?._locale\n\n switch (field.type) {\n case 'tab':\n case 'group': {\n const groupFieldPrefix = `${fieldPrefix || ''}${field.name}_`\n\n if (field.localized) {\n if (typeof locale === 'string' && !ref[locale]) {\n ref[locale] = {}\n delete table._locale\n }\n\n Object.entries(ref).forEach(([groupLocale, groupLocaleData]) => {\n ref[groupLocale] = traverseFields<Record<string, unknown>>({\n blocks,\n config,\n dataRef: groupLocaleData as Record<string, unknown>,\n deletions,\n fieldPrefix: groupFieldPrefix,\n fields: field.fields,\n numbers,\n path: `${sanitizedPath}${field.name}`,\n relationships,\n table,\n texts,\n })\n })\n if ('_order' in ref) {\n delete ref._order\n }\n } else {\n const groupData = {}\n\n ref[field.name] = traverseFields<Record<string, unknown>>({\n blocks,\n config,\n dataRef: groupData as Record<string, unknown>,\n deletions,\n fieldPrefix: groupFieldPrefix,\n fields: field.fields,\n numbers,\n path: `${sanitizedPath}${field.name}`,\n relationships,\n table,\n texts,\n })\n if ('_order' in ref) {\n delete ref._order\n }\n }\n\n break\n }\n\n case 'text': {\n let val = fieldData\n if (typeof fieldData === 'string') {\n val = String(fieldData)\n }\n\n if (typeof locale === 'string') {\n ref[locale] = val\n } else {\n result[field.name] = val\n }\n\n break\n }\n\n case 'number': {\n let val = fieldData\n if (typeof fieldData === 'string') {\n val = Number.parseFloat(fieldData)\n }\n\n if (typeof locale === 'string') {\n ref[locale] = val\n } else {\n result[field.name] = val\n }\n\n break\n }\n\n case 'date': {\n let val = fieldData\n\n if (typeof fieldData === 'string') {\n val = new Date(fieldData).toISOString()\n }\n\n if (typeof locale === 'string') {\n ref[locale] = val\n } else {\n result[field.name] = val\n }\n\n break\n }\n\n default: {\n if (typeof locale === 'string') {\n ref[locale] = fieldData\n } else {\n result[field.name] = fieldData\n }\n\n break\n }\n }\n })\n\n if (Object.keys(localizedFieldData).length > 0) {\n result[field.name] = localizedFieldData\n }\n\n return result\n }\n\n return result\n }, dataRef)\n\n if (Array.isArray(table._locales)) {\n deletions.push(() => delete table._locales)\n }\n\n return formatted as T\n}\n"],"names":["fieldAffectsData","transformHasManyNumber","transformHasManyText","transformRelationship","traverseFields","blocks","config","dataRef","deletions","fieldPrefix","fields","numbers","path","relationships","table","texts","sanitizedPath","formatted","reduce","result","field","type","tabs","map","tab","fieldName","name","fieldData","push","Array","isArray","localized","arrayResult","row","_locale","locale","data","_uuid","id","rowResult","_order","i","blockFieldPath","forEach","Object","entries","localizedBlocks","block","find","slug","blockType","blockResult","relationPathMatch","hasMany","localization","locales","defaultLocale","relationsByLocale","relations","ref","textPathMatch","textsByLocale","textRows","numberPathMatch","numbersByLocale","numberRows","selectResult","value","localizedFieldData","valuesToTransform","_locales","localeRow","groupFieldPrefix","groupLocale","groupLocaleData","groupData","val","String","Number","parseFloat","Date","toISOString","keys","length"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,oCAAoC,GAIpC,SAASA,gBAAgB,QAAQ,gBAAe;AAIhD,SAASC,sBAAsB,QAAQ,qBAAoB;AAC3D,SAASC,oBAAoB,QAAQ,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ields.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\nimport type { SanitizedConfig } from 'payload/config'\nimport type { Field, TabAsField } from 'payload/types'\n\nimport { fieldAffectsData } from 'payload/types'\n\nimport type { PostgresAdapter } from '../../types.js'\nimport type { BlocksMap } from '../../utilities/createBlocksMap.js'\n\nimport { transformHasManyNumber } from './hasManyNumber.js'\nimport { transformHasManyText } from './hasManyText.js'\nimport { transformRelationship } from './relationship.js'\n\ntype TraverseFieldsArgs = {\n /**\n * The DB adapter\n */\n adapter: PostgresAdapter\n /**\n * Pre-formatted blocks map\n */\n blocks: BlocksMap\n /**\n * The full Payload config\n */\n config: SanitizedConfig\n /**\n * The data reference to be mutated within this recursive function\n */\n dataRef: Record<string, unknown>\n /**\n * Data that needs to be removed from the result after all fields have populated\n */\n deletions: (() => void)[]\n /**\n * Column prefix can be built up by group and named tab fields\n */\n fieldPrefix: string\n /**\n * An array of Payload fields to traverse\n */\n fields: (Field | TabAsField)[]\n /**\n * All hasMany number fields, as returned by Drizzle, keyed on an object by field path\n */\n numbers: Record<string, Record<string, unknown>[]>\n /**\n * The current field path (in dot notation), used to merge in relationships\n */\n path: string\n /**\n * All related documents, as returned by Drizzle, keyed on an object by field path\n */\n relationships: Record<string, Record<string, unknown>[]>\n /**\n * Data structure representing the nearest table from db\n */\n table: Record<string, unknown>\n /**\n * All hasMany text fields, as returned by Drizzle, keyed on an object by field path\n */\n texts: Record<string, Record<string, unknown>[]>\n}\n\n// Traverse fields recursively, transforming data\n// for each field type into required Payload shape\nexport const traverseFields = <T extends Record<string, unknown>>({\n adapter,\n blocks,\n config,\n dataRef,\n deletions,\n fieldPrefix,\n fields,\n numbers,\n path,\n relationships,\n table,\n texts,\n}: TraverseFieldsArgs): T => {\n const sanitizedPath = path ? `${path}.` : path\n\n const formatted = fields.reduce((result, field) => {\n if (field.type === 'tabs') {\n traverseFields({\n adapter,\n blocks,\n config,\n dataRef,\n deletions,\n fieldPrefix,\n fields: field.tabs.map((tab) => ({ ...tab, type: 'tab' })),\n numbers,\n path,\n relationships,\n table,\n texts,\n })\n }\n\n if (\n field.type === 'collapsible' ||\n field.type === 'row' ||\n (field.type === 'tab' && !('name' in field))\n ) {\n traverseFields({\n adapter,\n blocks,\n config,\n dataRef,\n deletions,\n fieldPrefix,\n fields: field.fields,\n numbers,\n path,\n relationships,\n table,\n texts,\n })\n }\n\n if (fieldAffectsData(field)) {\n const fieldName = `${fieldPrefix || ''}${field.name}`\n const fieldData = table[fieldName]\n const localizedFieldData = {}\n const valuesToTransform: {\n ref: Record<string, unknown>\n table: Record<string, unknown>\n }[] = []\n\n if (fieldPrefix) {\n deletions.push(() => delete table[fieldName])\n }\n\n if (field.type === 'array') {\n if (Array.isArray(fieldData)) {\n if (field.localized) {\n result[field.name] = fieldData.reduce((arrayResult, row) => {\n if (typeof row._locale === 'string') {\n if (!arrayResult[row._locale]) arrayResult[row._locale] = []\n const locale = row._locale\n const data = {}\n delete row._locale\n if (row._uuid) {\n row.id = row._uuid\n delete row._uuid\n }\n\n const rowResult = traverseFields<T>({\n adapter,\n blocks,\n config,\n dataRef: data,\n deletions,\n fieldPrefix: '',\n fields: field.fields,\n numbers,\n path: `${sanitizedPath}${field.name}.${row._order - 1}`,\n relationships,\n table: row,\n texts,\n })\n\n if ('_order' in rowResult) {\n delete rowResult._order\n }\n\n arrayResult[locale].push(rowResult)\n }\n\n return arrayResult\n }, {})\n } else {\n result[field.name] = fieldData.map((row, i) => {\n if (row._uuid) {\n row.id = row._uuid\n delete row._uuid\n }\n\n if ('_order' in row) {\n delete row._order\n }\n\n return traverseFields<T>({\n adapter,\n blocks,\n config,\n dataRef: row,\n deletions,\n fieldPrefix: '',\n fields: field.fields,\n numbers,\n path: `${sanitizedPath}${field.name}.${i}`,\n relationships,\n table: row,\n texts,\n })\n })\n }\n }\n\n return result\n }\n\n if (field.type === 'blocks') {\n const blockFieldPath = `${sanitizedPath}${field.name}`\n\n if (Array.isArray(blocks[blockFieldPath])) {\n if (field.localized) {\n result[field.name] = {}\n\n blocks[blockFieldPath].forEach((row) => {\n if (row._uuid) {\n row.id = row._uuid\n delete row._uuid\n }\n if (typeof row._locale === 'string') {\n if (!result[field.name][row._locale]) result[field.name][row._locale] = []\n result[field.name][row._locale].push(row)\n delete row._locale\n }\n })\n\n Object.entries(result[field.name]).forEach(([locale, localizedBlocks]) => {\n result[field.name][locale] = localizedBlocks.map((row) => {\n const block = field.blocks.find(({ slug }) => slug === row.blockType)\n\n if (block) {\n const blockResult = traverseFields<T>({\n adapter,\n blocks,\n config,\n dataRef: row,\n deletions,\n fieldPrefix: '',\n fields: block.fields,\n numbers,\n path: `${blockFieldPath}.${row._order - 1}`,\n relationships,\n table: row,\n texts,\n })\n\n delete blockResult._order\n return blockResult\n }\n\n return {}\n })\n })\n } else {\n result[field.name] = blocks[blockFieldPath].map((row, i) => {\n delete row._order\n if (row._uuid) {\n row.id = row._uuid\n delete row._uuid\n }\n const block = field.blocks.find(({ slug }) => slug === row.blockType)\n\n if (block) {\n return traverseFields<T>({\n adapter,\n blocks,\n config,\n dataRef: row,\n deletions,\n fieldPrefix: '',\n fields: block.fields,\n numbers,\n path: `${blockFieldPath}.${i}`,\n relationships,\n table: row,\n texts,\n })\n }\n\n return {}\n })\n }\n }\n\n return result\n }\n\n if (field.type === 'relationship' || field.type === 'upload') {\n if (typeof field.relationTo === 'string' && !('hasMany' in field && field.hasMany)) {\n if (\n field.localized &&\n config.localization &&\n config.localization.locales &&\n Array.isArray(table?._locales)\n ) {\n table._locales.forEach((localeRow) => {\n result[field.name] = { [localeRow._locale]: localeRow[fieldName] }\n })\n } else {\n valuesToTransform.push({ ref: result, table })\n }\n } else {\n const relationPathMatch = relationships[`${sanitizedPath}${field.name}`]\n if (!relationPathMatch) {\n if ('hasMany' in field && field.hasMany) {\n if (field.localized && config.localization && config.localization.locales) {\n result[field.name] = {\n [config.localization.defaultLocale]: [],\n }\n } else {\n result[field.name] = []\n }\n }\n\n return result\n }\n\n if (field.localized) {\n result[field.name] = {}\n const relationsByLocale: Record<string, Record<string, unknown>[]> = {}\n\n relationPathMatch.forEach((row) => {\n if (typeof row.locale === 'string') {\n if (!relationsByLocale[row.locale]) relationsByLocale[row.locale] = []\n relationsByLocale[row.locale].push(row)\n }\n })\n\n Object.entries(relationsByLocale).forEach(([locale, relations]) => {\n transformRelationship({\n field,\n locale,\n ref: result,\n relations,\n })\n })\n } else {\n transformRelationship({\n field,\n ref: result,\n relations: relationPathMatch,\n })\n }\n return result\n }\n }\n\n if (field.type === 'text' && field?.hasMany) {\n const textPathMatch = texts[`${sanitizedPath}${field.name}`]\n if (!textPathMatch) return result\n\n if (field.localized) {\n result[field.name] = {}\n const textsByLocale: Record<string, Record<string, unknown>[]> = {}\n\n textPathMatch.forEach((row) => {\n if (typeof row.locale === 'string') {\n if (!textsByLocale[row.locale]) textsByLocale[row.locale] = []\n textsByLocale[row.locale].push(row)\n }\n })\n\n Object.entries(textsByLocale).forEach(([locale, texts]) => {\n transformHasManyText({\n field,\n locale,\n ref: result,\n textRows: texts,\n })\n })\n } else {\n transformHasManyText({\n field,\n ref: result,\n textRows: textPathMatch,\n })\n }\n\n return result\n }\n\n if (field.type === 'number' && field.hasMany) {\n const numberPathMatch = numbers[`${sanitizedPath}${field.name}`]\n if (!numberPathMatch) return result\n\n if (field.localized) {\n result[field.name] = {}\n const numbersByLocale: Record<string, Record<string, unknown>[]> = {}\n\n numberPathMatch.forEach((row) => {\n if (typeof row.locale === 'string') {\n if (!numbersByLocale[row.locale]) numbersByLocale[row.locale] = []\n numbersByLocale[row.locale].push(row)\n }\n })\n\n Object.entries(numbersByLocale).forEach(([locale, numbers]) => {\n transformHasManyNumber({\n field,\n locale,\n numberRows: numbers,\n ref: result,\n })\n })\n } else {\n transformHasManyNumber({\n field,\n numberRows: numberPathMatch,\n ref: result,\n })\n }\n\n return result\n }\n\n if (field.type === 'select' && field.hasMany) {\n if (Array.isArray(fieldData)) {\n if (field.localized) {\n result[field.name] = fieldData.reduce((selectResult, row) => {\n if (typeof row.locale === 'string') {\n if (!selectResult[row.locale]) selectResult[row.locale] = []\n selectResult[row.locale].push(row.value)\n }\n\n return selectResult\n }, {})\n } else {\n result[field.name] = fieldData.map(({ value }) => value)\n }\n }\n return result\n }\n\n if (field.localized && Array.isArray(table._locales)) {\n table._locales.forEach((localeRow) => {\n valuesToTransform.push({ ref: localizedFieldData, table: localeRow })\n })\n } else {\n valuesToTransform.push({ ref: result, table })\n }\n\n valuesToTransform.forEach(({ ref, table }) => {\n const fieldData = table[`${fieldPrefix || ''}${field.name}`]\n const locale = table?._locale\n let val = fieldData\n\n switch (field.type) {\n case 'tab':\n case 'group': {\n const groupFieldPrefix = `${fieldPrefix || ''}${field.name}_`\n\n if (field.localized) {\n if (typeof locale === 'string' && !ref[locale]) {\n ref[locale] = {}\n delete table._locale\n }\n\n Object.entries(ref).forEach(([groupLocale, groupLocaleData]) => {\n ref[groupLocale] = traverseFields<Record<string, unknown>>({\n adapter,\n blocks,\n config,\n dataRef: groupLocaleData as Record<string, unknown>,\n deletions,\n fieldPrefix: groupFieldPrefix,\n fields: field.fields,\n numbers,\n path: `${sanitizedPath}${field.name}`,\n relationships,\n table,\n texts,\n })\n })\n if ('_order' in ref) {\n delete ref._order\n }\n } else {\n const groupData = {}\n\n ref[field.name] = traverseFields<Record<string, unknown>>({\n adapter,\n blocks,\n config,\n dataRef: groupData as Record<string, unknown>,\n deletions,\n fieldPrefix: groupFieldPrefix,\n fields: field.fields,\n numbers,\n path: `${sanitizedPath}${field.name}`,\n relationships,\n table,\n texts,\n })\n if ('_order' in ref) {\n delete ref._order\n }\n }\n\n return\n }\n\n case 'text': {\n if (typeof fieldData === 'string') {\n val = String(fieldData)\n }\n\n break\n }\n\n case 'number': {\n if (typeof fieldData === 'string') {\n val = Number.parseFloat(fieldData)\n }\n\n break\n }\n\n case 'date': {\n if (typeof fieldData === 'string') {\n val = new Date(fieldData).toISOString()\n }\n\n break\n }\n\n case 'relationship':\n case 'upload': {\n if (\n val &&\n typeof field.relationTo === 'string' &&\n adapter.payload.collections[field.relationTo].customIDType === 'number'\n ) {\n val = Number(val)\n }\n\n break\n }\n\n default: {\n break\n }\n }\n if (typeof locale === 'string') {\n ref[locale] = val\n } else {\n result[field.name] = val\n }\n })\n\n if (Object.keys(localizedFieldData).length > 0) {\n result[field.name] = localizedFieldData\n }\n\n return result\n }\n\n return result\n }, dataRef)\n\n if (Array.isArray(table._locales)) {\n deletions.push(() => delete table._locales)\n }\n\n return formatted as T\n}\n"],"names":["fieldAffectsData","transformHasManyNumber","transformHasManyText","transformRelationship","traverseFields","adapter","blocks","config","dataRef","deletions","fieldPrefix","fields","numbers","path","relationships","table","texts","sanitizedPath","formatted","reduce","result","field","type","tabs","map","tab","fieldName","name","fieldData","localizedFieldData","valuesToTransform","push","Array","isArray","localized","arrayResult","row","_locale","locale","data","_uuid","id","rowResult","_order","i","blockFieldPath","forEach","Object","entries","localizedBlocks","block","find","slug","blockType","blockResult","relationTo","hasMany","localization","locales","_locales","localeRow","ref","relationPathMatch","defaultLocale","relationsByLocale","relations","textPathMatch","textsByLocale","textRows","numberPathMatch","numbersByLocale","numberRows","selectResult","value","val","groupFieldPrefix","groupLocale","groupLocaleData","groupData","String","Number","parseFloat","Date","toISOString","payload","collections","customIDType","keys","length"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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F;oBAEA;wBAAS;4BACP;wBACF;gBACF;gBACA,IAAI,OAAOpC,WAAW,UAAU;oBAC9BuB,GAAG,CAACvB,OAAO,GAAGoC;gBAChB,OAAO;oBACLtD,MAAM,CAACC,MAAMM,IAAI,CAAC,GAAG+C;gBACvB;YACF;YAEA,IAAI3B,OAAOwC,IAAI,CAAC1D,oBAAoB2D,MAAM,GAAG,GAAG;gBAC9CpE,MAAM,CAACC,MAAMM,IAAI,CAAC,GAAGE;YACvB;YAEA,OAAOT;QACT;QAEA,OAAOA;IACT,GAAGZ;IAEH,IAAIwB,MAAMC,OAAO,CAAClB,MAAM4C,QAAQ,GAAG;QACjClD,UAAUsB,IAAI,CAAC,IAAM,OAAOhB,MAAM4C,QAAQ;IAC5C;IAEA,OAAOzC;AACT,EAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"traverseFields.d.ts","sourceRoot":"","sources":["../../../src/transform/write/traverseFields.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAK1C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAU1F,KAAK,IAAI,GAAG;IACV,OAAO,EAAE,eAAe,CAAA;IACxB,MAAM,EAAE;QACN,CAAC,SAAS,EAAE,MAAM,GAAG,gBAAgB,EAAE,CAAA;KACxC,CAAA;IACD;;OAEG;IACH,aAAa,EAAE,MAAM,CAAA;IACrB,MAAM,EAAE;QACN,CAAC,SAAS,EAAE,MAAM,GAAG,gBAAgB,EAAE,CAAA;KACxC,CAAA;IACD,cAAc,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IAC3B;;;OAGG;IACH,YAAY,EAAE,MAAM,CAAA;IACpB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC7B,eAAe,CAA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'relationship' || field.type === 'upload') {
|
266
266
|
const relationshipPath = `${path || ''}${field.name}`;
|
267
|
-
if (field.localized) {
|
267
|
+
if (field.localized && (Array.isArray(field.relationTo) || 'hasMany' in field && field.hasMany)) {
|
268
268
|
if (typeof fieldData === 'object') {
|
269
269
|
Object.entries(fieldData).forEach(([localeKey, localeData])=>{
|
270
270
|
if (localeData === null) {
|
@@ -285,7 +285,8 @@ export const traverseFields = ({ adapter, arrays, baseTableName, blocks, blocksT
|
|
285
285
|
});
|
286
286
|
});
|
287
287
|
}
|
288
|
-
|
288
|
+
return;
|
289
|
+
} else if (Array.isArray(field.relationTo) || 'hasMany' in field && field.hasMany) {
|
289
290
|
if (fieldData === null || Array.isArray(fieldData) && fieldData.length === 0) {
|
290
291
|
relationshipsToDelete.push({
|
291
292
|
path: relationshipPath
|
@@ -300,8 +301,24 @@ export const traverseFields = ({ adapter, arrays, baseTableName, blocks, blocksT
|
|
300
301
|
field,
|
301
302
|
relationships
|
302
303
|
});
|
304
|
+
return;
|
305
|
+
} else {
|
306
|
+
if (!field.localized && fieldData && typeof fieldData === 'object' && 'id' in fieldData && fieldData?.id) {
|
307
|
+
fieldData = fieldData.id;
|
308
|
+
} else if (field.localized) {
|
309
|
+
if (typeof fieldData === 'object') {
|
310
|
+
Object.entries(fieldData).forEach(([localeKey, localeData])=>{
|
311
|
+
if (typeof localeData === 'object') {
|
312
|
+
if (localeData && 'id' in localeData && localeData?.id) {
|
313
|
+
fieldData[localeKey] = localeData.id;
|
314
|
+
}
|
315
|
+
} else {
|
316
|
+
fieldData[localeKey] = localeData;
|
317
|
+
}
|
318
|
+
});
|
319
|
+
}
|
320
|
+
}
|
303
321
|
}
|
304
|
-
return;
|
305
322
|
}
|
306
323
|
if (field.type === 'text' && field.hasMany) {
|
307
324
|
const textPath = `${path || ''}${field.name}`;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/transform/write/traverseFields.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\nimport type { Field } from 'payload/types'\n\nimport { fieldAffectsData } from 'payload/types'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { PostgresAdapter } from '../../types.js'\nimport type { ArrayRowToInsert, BlockRowToInsert, RelationshipToDelete } from './types.js'\n\nimport { isArrayOfRows } from '../../utilities/isArrayOfRows.js'\nimport { transformArray } from './array.js'\nimport { transformBlocks } from './blocks.js'\nimport { transformNumbers } from './numbers.js'\nimport { transformRelationship } from './relationships.js'\nimport { transformSelects } from './selects.js'\nimport { transformTexts } from './texts.js'\n\ntype Args = {\n adapter: PostgresAdapter\n arrays: {\n [tableName: string]: ArrayRowToInsert[]\n }\n /**\n * This is the name of the base table\n */\n baseTableName: string\n blocks: {\n [blockType: string]: BlockRowToInsert[]\n }\n blocksToDelete: Set<string>\n /**\n * A snake-case field prefix, representing prior fields\n * Ex: my_group_my_named_tab_\n */\n columnPrefix: string\n data: Record<string, unknown>\n existingLocales?: Record<string, unknown>[]\n /**\n * A prefix that will retain camel-case formatting, representing prior fields\n * Ex: myGroup_myNamedTab_\n */\n fieldPrefix: string\n fields: Field[]\n forcedLocale?: string\n locales: {\n [locale: string]: Record<string, unknown>\n }\n numbers: Record<string, unknown>[]\n /**\n * This is the name of the parent table\n */\n parentTableName: string\n path: string\n relationships: Record<string, unknown>[]\n relationshipsToDelete: RelationshipToDelete[]\n row: Record<string, unknown>\n selects: {\n [tableName: string]: Record<string, unknown>[]\n }\n texts: Record<string, unknown>[]\n}\n\nexport const traverseFields = ({\n adapter,\n arrays,\n baseTableName,\n blocks,\n blocksToDelete,\n columnPrefix,\n data,\n existingLocales,\n fieldPrefix,\n fields,\n forcedLocale,\n locales,\n numbers,\n parentTableName,\n path,\n relationships,\n relationshipsToDelete,\n row,\n selects,\n texts,\n}: Args) => {\n fields.forEach((field) => {\n let columnName = ''\n let fieldName = ''\n let fieldData: unknown\n\n if (fieldAffectsData(field)) {\n columnName = `${columnPrefix || ''}${toSnakeCase(field.name)}`\n fieldName = `${fieldPrefix || ''}${field.name}`\n fieldData = data[field.name]\n }\n\n if (field.type === 'array') {\n const arrayTableName = adapter.tableNameMap.get(`${parentTableName}_${columnName}`)\n\n if (!arrays[arrayTableName]) arrays[arrayTableName] = []\n\n if (field.localized) {\n if (typeof data[field.name] === 'object' && data[field.name] !== null) {\n Object.entries(data[field.name]).forEach(([localeKey, localeData]) => {\n if (Array.isArray(localeData)) {\n const newRows = transformArray({\n adapter,\n arrayTableName,\n baseTableName,\n blocks,\n blocksToDelete,\n data: localeData,\n field,\n locale: localeKey,\n numbers,\n path,\n relationships,\n relationshipsToDelete,\n selects,\n texts,\n })\n\n arrays[arrayTableName] = arrays[arrayTableName].concat(newRows)\n }\n })\n }\n } else {\n const newRows = transformArray({\n adapter,\n arrayTableName,\n baseTableName,\n blocks,\n blocksToDelete,\n data: data[field.name],\n field,\n numbers,\n path,\n relationships,\n relationshipsToDelete,\n selects,\n texts,\n })\n\n arrays[arrayTableName] = arrays[arrayTableName].concat(newRows)\n }\n\n return\n }\n\n if (field.type === 'blocks') {\n field.blocks.forEach(({ slug }) => {\n blocksToDelete.add(toSnakeCase(slug))\n })\n\n if (field.localized) {\n if (typeof data[field.name] === 'object' && data[field.name] !== null) {\n Object.entries(data[field.name]).forEach(([localeKey, localeData]) => {\n if (Array.isArray(localeData)) {\n transformBlocks({\n adapter,\n baseTableName,\n blocks,\n blocksToDelete,\n data: localeData,\n field,\n locale: localeKey,\n numbers,\n path,\n relationships,\n relationshipsToDelete,\n selects,\n texts,\n })\n }\n })\n }\n } else if (isArrayOfRows(fieldData)) {\n transformBlocks({\n adapter,\n baseTableName,\n blocks,\n blocksToDelete,\n data: fieldData,\n field,\n numbers,\n path,\n relationships,\n relationshipsToDelete,\n selects,\n texts,\n })\n }\n\n return\n }\n\n if (field.type === 'group') {\n if (typeof data[field.name] === 'object' && data[field.name] !== null) {\n if (field.localized) {\n Object.entries(data[field.name]).forEach(([localeKey, localeData]) => {\n traverseFields({\n adapter,\n arrays,\n baseTableName,\n blocks,\n blocksToDelete,\n columnPrefix: `${columnName}_`,\n data: localeData as Record<string, unknown>,\n existingLocales,\n fieldPrefix: `${fieldName}_`,\n fields: field.fields,\n forcedLocale: localeKey,\n locales,\n numbers,\n parentTableName,\n path: `${path || ''}${field.name}.`,\n relationships,\n relationshipsToDelete,\n row,\n selects,\n texts,\n })\n })\n } else {\n traverseFields({\n adapter,\n arrays,\n baseTableName,\n blocks,\n blocksToDelete,\n columnPrefix: `${columnName}_`,\n data: data[field.name] as Record<string, unknown>,\n existingLocales,\n fieldPrefix: `${fieldName}_`,\n fields: field.fields,\n locales,\n numbers,\n parentTableName,\n path: `${path || ''}${field.name}.`,\n relationships,\n relationshipsToDelete,\n row,\n selects,\n texts,\n })\n }\n }\n\n return\n }\n\n if (field.type === 'tabs') {\n field.tabs.forEach((tab) => {\n if ('name' in tab) {\n if (typeof data[tab.name] === 'object' && data[tab.name] !== null) {\n if (tab.localized) {\n Object.entries(data[tab.name]).forEach(([localeKey, localeData]) => {\n traverseFields({\n adapter,\n arrays,\n baseTableName,\n blocks,\n blocksToDelete,\n columnPrefix: `${columnPrefix || ''}${toSnakeCase(tab.name)}_`,\n data: localeData as Record<string, unknown>,\n existingLocales,\n fieldPrefix: `${fieldPrefix || ''}${tab.name}_`,\n fields: tab.fields,\n forcedLocale: localeKey,\n locales,\n numbers,\n parentTableName,\n path: `${path || ''}${tab.name}.`,\n relationships,\n relationshipsToDelete,\n row,\n selects,\n texts,\n })\n })\n } else {\n traverseFields({\n adapter,\n arrays,\n baseTableName,\n blocks,\n blocksToDelete,\n columnPrefix: `${columnPrefix || ''}${toSnakeCase(tab.name)}_`,\n data: data[tab.name] as Record<string, unknown>,\n existingLocales,\n fieldPrefix: `${fieldPrefix || ''}${tab.name}_`,\n fields: tab.fields,\n locales,\n numbers,\n parentTableName,\n path: `${path || ''}${tab.name}.`,\n relationships,\n relationshipsToDelete,\n row,\n selects,\n texts,\n })\n }\n }\n } else {\n traverseFields({\n adapter,\n arrays,\n baseTableName,\n blocks,\n blocksToDelete,\n columnPrefix,\n data,\n existingLocales,\n fieldPrefix,\n fields: tab.fields,\n locales,\n numbers,\n parentTableName,\n path,\n relationships,\n relationshipsToDelete,\n row,\n selects,\n texts,\n })\n }\n })\n }\n\n if (field.type === 'row' || field.type === 'collapsible') {\n traverseFields({\n adapter,\n arrays,\n baseTableName,\n blocks,\n blocksToDelete,\n columnPrefix,\n data,\n existingLocales,\n fieldPrefix,\n fields: field.fields,\n locales,\n numbers,\n parentTableName,\n path,\n relationships,\n relationshipsToDelete,\n row,\n selects,\n texts,\n })\n }\n\n if (field.type === 'relationship' || field.type === 'upload') {\n const relationshipPath = `${path || ''}${field.name}`\n\n if (field.localized) {\n if (typeof fieldData === 'object') {\n Object.entries(fieldData).forEach(([localeKey, localeData]) => {\n if (localeData === null) {\n relationshipsToDelete.push({\n locale: localeKey,\n path: relationshipPath,\n })\n return\n }\n\n transformRelationship({\n baseRow: {\n locale: localeKey,\n path: relationshipPath,\n },\n data: localeData,\n field,\n relationships,\n })\n })\n }\n } else {\n if (fieldData === null || (Array.isArray(fieldData) && fieldData.length === 0)) {\n relationshipsToDelete.push({ path: relationshipPath })\n return\n }\n\n transformRelationship({\n baseRow: {\n path: relationshipPath,\n },\n data: fieldData,\n field,\n relationships,\n })\n }\n\n return\n }\n\n if (field.type === 'text' && field.hasMany) {\n const textPath = `${path || ''}${field.name}`\n\n if (field.localized) {\n if (typeof fieldData === 'object') {\n Object.entries(fieldData).forEach(([localeKey, localeData]) => {\n if (Array.isArray(localeData)) {\n transformTexts({\n baseRow: {\n locale: localeKey,\n path: textPath,\n },\n data: localeData,\n texts,\n })\n }\n })\n }\n } else if (Array.isArray(fieldData)) {\n transformTexts({\n baseRow: {\n path: textPath,\n },\n data: fieldData,\n texts,\n })\n }\n\n return\n }\n\n if (field.type === 'number' && field.hasMany) {\n const numberPath = `${path || ''}${field.name}`\n\n if (field.localized) {\n if (typeof fieldData === 'object') {\n Object.entries(fieldData).forEach(([localeKey, localeData]) => {\n if (Array.isArray(localeData)) {\n transformNumbers({\n baseRow: {\n locale: localeKey,\n path: numberPath,\n },\n data: localeData,\n numbers,\n })\n }\n })\n }\n } else if (Array.isArray(fieldData)) {\n transformNumbers({\n baseRow: {\n path: numberPath,\n },\n data: fieldData,\n numbers,\n })\n }\n\n return\n }\n\n if (field.type === 'select' && field.hasMany) {\n const selectTableName = adapter.tableNameMap.get(`${parentTableName}_${columnName}`)\n if (!selects[selectTableName]) selects[selectTableName] = []\n\n if (field.localized) {\n if (typeof data[field.name] === 'object' && data[field.name] !== null) {\n Object.entries(data[field.name]).forEach(([localeKey, localeData]) => {\n if (Array.isArray(localeData)) {\n const newRows = transformSelects({\n id: data._uuid || data.id,\n data: localeData,\n locale: localeKey,\n })\n\n selects[selectTableName] = selects[selectTableName].concat(newRows)\n }\n })\n }\n } else if (Array.isArray(data[field.name])) {\n const newRows = transformSelects({\n id: data._uuid || data.id,\n data: data[field.name],\n })\n\n selects[selectTableName] = selects[selectTableName].concat(newRows)\n }\n\n return\n }\n\n if (fieldAffectsData(field)) {\n const valuesToTransform: { localeKey?: string; ref: unknown; value: unknown }[] = []\n\n if (field.localized) {\n if (typeof fieldData === 'object' && fieldData !== null) {\n Object.entries(fieldData).forEach(([localeKey, localeData]) => {\n if (!locales[localeKey]) locales[localeKey] = {}\n\n valuesToTransform.push({\n localeKey,\n ref: locales,\n value: localeData,\n })\n })\n }\n } else {\n let ref = row\n\n if (forcedLocale) {\n if (!locales[forcedLocale]) locales[forcedLocale] = {}\n ref = locales[forcedLocale]\n }\n\n valuesToTransform.push({ ref, value: fieldData })\n }\n\n valuesToTransform.forEach(({ localeKey, ref, value }) => {\n if (typeof value !== 'undefined') {\n let formattedValue = value\n\n if (field.type === 'date' && field.name === 'updatedAt') {\n formattedValue = new Date().toISOString()\n }\n\n if (localeKey) {\n ref[localeKey][fieldName] = formattedValue\n } else {\n ref[fieldName] = formattedValue\n }\n }\n })\n }\n })\n}\n"],"names":["fieldAffectsData","toSnakeCase","isArrayOfRows","transformArray","transformBlocks","transformNumbers","transformRelationship","transformSelects","transformTexts","traverseFields","adapter","arrays","baseTableName","blocks","blocksToDelete","columnPrefix","data","existingLocales","fieldPrefix","fields","forcedLocale","locales","numbers","parentTableName","path","relationships","relationshipsToDelete","row","selects","texts","forEach","field","columnName","fieldName","fieldData","name","type","arrayTableName","tableNameMap","get","localized","Object","entries","localeKey","localeData","Array","isArray","newRows","locale","concat","slug","add","tabs","tab","relationshipPath","push","baseRow","length","hasMany","textPath","numberPath","selectTableName","id","_uuid","valuesToTransform","ref","value","formattedValue","Date","toISOString"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,oCAAoC,GAGpC,SAASA,gBAAgB,QAAQ,gBAAe;AAChD,OAAOC,iBAAiB,gBAAe;AAKvC,SAASC,aAAa,QAAQ,mCAAkC;AAChE,SAASC,cAAc,QAAQ,aAAY;AAC3C,SAASC,eAAe,QAAQ,cAAa;AAC7C,SAASC,gBAAgB,QAAQ,eAAc;AAC/C,SAASC,qBAAqB,QAAQ,qBAAoB;AAC1D,SAASC,gBAAgB,QAAQ,eAAc;AAC/C,SAASC,cAAc,QAAQ,aAAY;A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,kBAAkBT,IAAI,CAAC;4BACrBZ;4BACAsB,KAAK5C;4BACL6C,OAAOtB;wBACT;oBACF;gBACF;YACF,OAAO;gBACL,IAAIqB,MAAMtC;gBAEV,IAAIP,cAAc;oBAChB,IAAI,CAACC,OAAO,CAACD,aAAa,EAAEC,OAAO,CAACD,aAAa,GAAG,CAAC;oBACrD6C,MAAM5C,OAAO,CAACD,aAAa;gBAC7B;gBAEA4C,kBAAkBT,IAAI,CAAC;oBAAEU;oBAAKC,OAAOhC;gBAAU;YACjD;YAEA8B,kBAAkBlC,OAAO,CAAC,CAAC,EAAEa,SAAS,EAAEsB,GAAG,EAAEC,KAAK,EAAE;gBAClD,IAAI,OAAOA,UAAU,aAAa;oBAChC,IAAIC,iBAAiBD;oBAErB,IAAInC,MAAMK,IAAI,KAAK,UAAUL,MAAMI,IAAI,KAAK,aAAa;wBACvDgC,iBAAiB,IAAIC,OAAOC,WAAW;oBACzC;oBAEA,IAAI1B,WAAW;wBACbsB,GAAG,CAACtB,UAAU,CAACV,UAAU,GAAGkC;oBAC9B,OAAO;wBACLF,GAAG,CAAChC,UAAU,GAAGkC;oBACnB;gBACF;YACF;QACF;IACF;AACF,EAAC"}
|
1
|
+
{"version":3,"sources":["../../../src/transform/write/traverseFields.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\nimport type { Field } from 'payload/types'\n\nimport { fieldAffectsData } from 'payload/types'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { PostgresAdapter } from '../../types.js'\nimport type { ArrayRowToInsert, BlockRowToInsert, RelationshipToDelete } from './types.js'\n\nimport { isArrayOfRows } from '../../utilities/isArrayOfRows.js'\nimport { transformArray } from './array.js'\nimport { transformBlocks } from './blocks.js'\nimport { transformNumbers } from './numbers.js'\nimport { transformRelationship } from './relationships.js'\nimport { transformSelects } from './selects.js'\nimport { transformTexts } from './texts.js'\n\ntype Args = {\n adapter: PostgresAdapter\n arrays: {\n [tableName: string]: ArrayRowToInsert[]\n }\n /**\n * This is the name of the base table\n */\n baseTableName: string\n blocks: {\n [blockType: string]: BlockRowToInsert[]\n }\n blocksToDelete: Set<string>\n /**\n * A snake-case field prefix, representing prior fields\n * Ex: my_group_my_named_tab_\n */\n columnPrefix: string\n data: Record<string, unknown>\n existingLocales?: Record<string, unknown>[]\n /**\n * A prefix that will retain camel-case formatting, representing prior fields\n * Ex: myGroup_myNamedTab_\n */\n fieldPrefix: string\n fields: Field[]\n forcedLocale?: string\n locales: {\n [locale: string]: Record<string, unknown>\n }\n numbers: Record<string, unknown>[]\n /**\n * This is the name of the parent table\n */\n parentTableName: string\n path: string\n relationships: Record<string, unknown>[]\n relationshipsToDelete: RelationshipToDelete[]\n row: Record<string, unknown>\n selects: {\n [tableName: string]: Record<string, unknown>[]\n }\n texts: Record<string, unknown>[]\n}\n\nexport const traverseFields = ({\n adapter,\n arrays,\n baseTableName,\n blocks,\n blocksToDelete,\n columnPrefix,\n data,\n existingLocales,\n fieldPrefix,\n fields,\n forcedLocale,\n locales,\n numbers,\n parentTableName,\n path,\n relationships,\n relationshipsToDelete,\n row,\n selects,\n texts,\n}: Args) => {\n fields.forEach((field) => {\n let columnName = ''\n let fieldName = ''\n let fieldData: unknown\n\n if (fieldAffectsData(field)) {\n columnName = `${columnPrefix || ''}${toSnakeCase(field.name)}`\n fieldName = `${fieldPrefix || ''}${field.name}`\n fieldData = data[field.name]\n }\n\n if (field.type === 'array') {\n const arrayTableName = adapter.tableNameMap.get(`${parentTableName}_${columnName}`)\n\n if (!arrays[arrayTableName]) arrays[arrayTableName] = []\n\n if (field.localized) {\n if (typeof data[field.name] === 'object' && data[field.name] !== null) {\n Object.entries(data[field.name]).forEach(([localeKey, localeData]) => {\n if (Array.isArray(localeData)) {\n const newRows = transformArray({\n adapter,\n arrayTableName,\n baseTableName,\n blocks,\n blocksToDelete,\n data: localeData,\n field,\n locale: localeKey,\n numbers,\n path,\n relationships,\n relationshipsToDelete,\n selects,\n texts,\n })\n\n arrays[arrayTableName] = arrays[arrayTableName].concat(newRows)\n }\n })\n }\n } else {\n const newRows = transformArray({\n adapter,\n arrayTableName,\n baseTableName,\n blocks,\n blocksToDelete,\n data: data[field.name],\n field,\n numbers,\n path,\n relationships,\n relationshipsToDelete,\n selects,\n texts,\n })\n\n arrays[arrayTableName] = arrays[arrayTableName].concat(newRows)\n }\n\n return\n }\n\n if (field.type === 'blocks') {\n field.blocks.forEach(({ slug }) => {\n blocksToDelete.add(toSnakeCase(slug))\n })\n\n if (field.localized) {\n if (typeof data[field.name] === 'object' && data[field.name] !== null) {\n Object.entries(data[field.name]).forEach(([localeKey, localeData]) => {\n if (Array.isArray(localeData)) {\n transformBlocks({\n adapter,\n baseTableName,\n blocks,\n blocksToDelete,\n data: localeData,\n field,\n locale: localeKey,\n numbers,\n path,\n relationships,\n relationshipsToDelete,\n selects,\n texts,\n })\n }\n })\n }\n } else if (isArrayOfRows(fieldData)) {\n transformBlocks({\n adapter,\n baseTableName,\n blocks,\n blocksToDelete,\n data: fieldData,\n field,\n numbers,\n path,\n relationships,\n relationshipsToDelete,\n selects,\n texts,\n })\n }\n\n return\n }\n\n if (field.type === 'group') {\n if (typeof data[field.name] === 'object' && data[field.name] !== null) {\n if (field.localized) {\n Object.entries(data[field.name]).forEach(([localeKey, localeData]) => {\n traverseFields({\n adapter,\n arrays,\n baseTableName,\n blocks,\n blocksToDelete,\n columnPrefix: `${columnName}_`,\n data: localeData as Record<string, unknown>,\n existingLocales,\n fieldPrefix: `${fieldName}_`,\n fields: field.fields,\n forcedLocale: localeKey,\n locales,\n numbers,\n parentTableName,\n path: `${path || ''}${field.name}.`,\n relationships,\n relationshipsToDelete,\n row,\n selects,\n texts,\n })\n })\n } else {\n traverseFields({\n adapter,\n arrays,\n baseTableName,\n blocks,\n blocksToDelete,\n columnPrefix: `${columnName}_`,\n data: data[field.name] as Record<string, unknown>,\n existingLocales,\n fieldPrefix: `${fieldName}_`,\n fields: field.fields,\n locales,\n numbers,\n parentTableName,\n path: `${path || ''}${field.name}.`,\n relationships,\n relationshipsToDelete,\n row,\n selects,\n texts,\n })\n }\n }\n\n return\n }\n\n if (field.type === 'tabs') {\n field.tabs.forEach((tab) => {\n if ('name' in tab) {\n if (typeof data[tab.name] === 'object' && data[tab.name] !== null) {\n if (tab.localized) {\n Object.entries(data[tab.name]).forEach(([localeKey, localeData]) => {\n traverseFields({\n adapter,\n arrays,\n baseTableName,\n blocks,\n blocksToDelete,\n columnPrefix: `${columnPrefix || ''}${toSnakeCase(tab.name)}_`,\n data: localeData as Record<string, unknown>,\n existingLocales,\n fieldPrefix: `${fieldPrefix || ''}${tab.name}_`,\n fields: tab.fields,\n forcedLocale: localeKey,\n locales,\n numbers,\n parentTableName,\n path: `${path || ''}${tab.name}.`,\n relationships,\n relationshipsToDelete,\n row,\n selects,\n texts,\n })\n })\n } else {\n traverseFields({\n adapter,\n arrays,\n baseTableName,\n blocks,\n blocksToDelete,\n columnPrefix: `${columnPrefix || ''}${toSnakeCase(tab.name)}_`,\n data: data[tab.name] as Record<string, unknown>,\n existingLocales,\n fieldPrefix: `${fieldPrefix || ''}${tab.name}_`,\n fields: tab.fields,\n locales,\n numbers,\n parentTableName,\n path: `${path || ''}${tab.name}.`,\n relationships,\n relationshipsToDelete,\n row,\n selects,\n texts,\n })\n }\n }\n } else {\n traverseFields({\n adapter,\n arrays,\n baseTableName,\n blocks,\n blocksToDelete,\n columnPrefix,\n data,\n existingLocales,\n fieldPrefix,\n fields: tab.fields,\n locales,\n numbers,\n parentTableName,\n path,\n relationships,\n relationshipsToDelete,\n row,\n selects,\n texts,\n })\n }\n })\n }\n\n if (field.type === 'row' || field.type === 'collapsible') {\n traverseFields({\n adapter,\n arrays,\n baseTableName,\n blocks,\n blocksToDelete,\n columnPrefix,\n data,\n existingLocales,\n fieldPrefix,\n fields: field.fields,\n locales,\n numbers,\n parentTableName,\n path,\n relationships,\n relationshipsToDelete,\n row,\n selects,\n texts,\n })\n }\n\n if (field.type === 'relationship' || field.type === 'upload') {\n const relationshipPath = `${path || ''}${field.name}`\n\n if (\n field.localized &&\n (Array.isArray(field.relationTo) || ('hasMany' in field && field.hasMany))\n ) {\n if (typeof fieldData === 'object') {\n Object.entries(fieldData).forEach(([localeKey, localeData]) => {\n if (localeData === null) {\n relationshipsToDelete.push({\n locale: localeKey,\n path: relationshipPath,\n })\n return\n }\n\n transformRelationship({\n baseRow: {\n locale: localeKey,\n path: relationshipPath,\n },\n data: localeData,\n field,\n relationships,\n })\n })\n }\n return\n } else if (Array.isArray(field.relationTo) || ('hasMany' in field && field.hasMany)) {\n if (fieldData === null || (Array.isArray(fieldData) && fieldData.length === 0)) {\n relationshipsToDelete.push({ path: relationshipPath })\n return\n }\n\n transformRelationship({\n baseRow: {\n path: relationshipPath,\n },\n data: fieldData,\n field,\n relationships,\n })\n return\n } else {\n if (\n !field.localized &&\n fieldData &&\n typeof fieldData === 'object' &&\n 'id' in fieldData &&\n fieldData?.id\n ) {\n fieldData = fieldData.id\n } else if (field.localized) {\n if (typeof fieldData === 'object') {\n Object.entries(fieldData).forEach(([localeKey, localeData]) => {\n if (typeof localeData === 'object') {\n if (localeData && 'id' in localeData && localeData?.id) {\n fieldData[localeKey] = localeData.id\n }\n } else {\n fieldData[localeKey] = localeData\n }\n })\n }\n }\n }\n }\n\n if (field.type === 'text' && field.hasMany) {\n const textPath = `${path || ''}${field.name}`\n\n if (field.localized) {\n if (typeof fieldData === 'object') {\n Object.entries(fieldData).forEach(([localeKey, localeData]) => {\n if (Array.isArray(localeData)) {\n transformTexts({\n baseRow: {\n locale: localeKey,\n path: textPath,\n },\n data: localeData,\n texts,\n })\n }\n })\n }\n } else if (Array.isArray(fieldData)) {\n transformTexts({\n baseRow: {\n path: textPath,\n },\n data: fieldData,\n texts,\n })\n }\n\n return\n }\n\n if (field.type === 'number' && field.hasMany) {\n const numberPath = `${path || ''}${field.name}`\n\n if (field.localized) {\n if (typeof fieldData === 'object') {\n Object.entries(fieldData).forEach(([localeKey, localeData]) => {\n if (Array.isArray(localeData)) {\n transformNumbers({\n baseRow: {\n locale: localeKey,\n path: numberPath,\n },\n data: localeData,\n numbers,\n })\n }\n })\n }\n } else if (Array.isArray(fieldData)) {\n transformNumbers({\n baseRow: {\n path: numberPath,\n },\n data: fieldData,\n numbers,\n })\n }\n\n return\n }\n\n if (field.type === 'select' && field.hasMany) {\n const selectTableName = adapter.tableNameMap.get(`${parentTableName}_${columnName}`)\n if (!selects[selectTableName]) selects[selectTableName] = []\n\n if (field.localized) {\n if (typeof data[field.name] === 'object' && data[field.name] !== null) {\n Object.entries(data[field.name]).forEach(([localeKey, localeData]) => {\n if (Array.isArray(localeData)) {\n const newRows = transformSelects({\n id: data._uuid || data.id,\n data: localeData,\n locale: localeKey,\n })\n\n selects[selectTableName] = selects[selectTableName].concat(newRows)\n }\n })\n }\n } else if (Array.isArray(data[field.name])) {\n const newRows = transformSelects({\n id: data._uuid || data.id,\n data: data[field.name],\n })\n\n selects[selectTableName] = selects[selectTableName].concat(newRows)\n }\n\n return\n }\n\n if (fieldAffectsData(field)) {\n const valuesToTransform: { localeKey?: string; ref: unknown; value: unknown }[] = []\n\n if (field.localized) {\n if (typeof fieldData === 'object' && fieldData !== null) {\n Object.entries(fieldData).forEach(([localeKey, localeData]) => {\n if (!locales[localeKey]) locales[localeKey] = {}\n\n valuesToTransform.push({\n localeKey,\n ref: locales,\n value: localeData,\n })\n })\n }\n } else {\n let ref = row\n\n if (forcedLocale) {\n if (!locales[forcedLocale]) locales[forcedLocale] = {}\n ref = locales[forcedLocale]\n }\n\n valuesToTransform.push({ ref, value: fieldData })\n }\n\n valuesToTransform.forEach(({ localeKey, ref, value }) => {\n if (typeof value !== 'undefined') {\n let formattedValue = value\n\n if (field.type === 'date' && field.name === 'updatedAt') {\n formattedValue = new Date().toISOString()\n }\n\n if (localeKey) {\n ref[localeKey][fieldName] = formattedValue\n } else {\n ref[fieldName] = formattedValue\n }\n }\n })\n }\n })\n}\n"],"names":["fieldAffectsData","toSnakeCase","isArrayOfRows","transformArray","transformBlocks","transformNumbers","transformRelationship","transformSelects","transformTexts","traverseFields","adapter","arrays","baseTableName","blocks","blocksToDelete","columnPrefix","data","existingLocales","fieldPrefix","fields","forcedLocale","locales","numbers","parentTableName","path","relationships","relationshipsToDelete","row","selects","texts","forEach","field","columnName","fieldName","fieldData","name","type","arrayTableName","tableNameMap","get","localized","Object","entries","localeKey","localeData","Array","isArray","newRows","locale","concat","slug","add","tabs","tab","relationshipPath","relationTo","hasMany","push","baseRow","length","id","textPath","numberPath","selectTableName","_uuid","valuesToTransform","ref","value","formattedValue","Date","toISOString"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,oCAAoC,GAGpC,SAASA,gBAAgB,QAAQ,gBAAe;AAChD,OAAOC,iBAAiB,gBAAe;AAKvC,SAASC,aAAa,QAAQ,mCAAkC;AAChE,SAASC,cAAc,QAAQ,aAAY;AAC3C,SAASC,eAAe,QAAQ,cAAa;AAC7C,SAASC,gBAAgB,QAAQ,eAAc;AAC/C,SAASC,qBAAqB,QAAQ,qBAAoB;AAC1D,SAASC,gBAAgB,QAAQ,eAAc;AAC/C,SAASC,cAAc,QAAQ,aAAY;AA+C3C,OA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IAAI3B,WAAW;wBACbuB,GAAG,CAACvB,UAAU,CAACV,UAAU,GAAGmC;oBAC9B,OAAO;wBACLF,GAAG,CAACjC,UAAU,GAAGmC;oBACnB;gBACF;YACF;QACF;IACF;AACF,EAAC"}
|
package/dist/types.d.ts
CHANGED
@@ -40,6 +40,7 @@ export type PostgresAdapter = BaseDatabaseAdapter & {
|
|
40
40
|
*/
|
41
41
|
fieldConstraints: Record<string, Record<string, string>>;
|
42
42
|
idType: Args['idType'];
|
43
|
+
initializing: Promise<void>;
|
43
44
|
localesSuffix?: string;
|
44
45
|
logger: DrizzleConfig['logger'];
|
45
46
|
pgSchema?: {
|
@@ -48,8 +49,10 @@ export type PostgresAdapter = BaseDatabaseAdapter & {
|
|
48
49
|
pool: Pool;
|
49
50
|
poolOptions: Args['pool'];
|
50
51
|
push: boolean;
|
52
|
+
rejectInitializing: () => void;
|
51
53
|
relations: Record<string, GenericRelation>;
|
52
54
|
relationshipsSuffix?: string;
|
55
|
+
resolveInitializing: () => void;
|
53
56
|
schema: Record<string, GenericEnum | GenericRelation | GenericTable>;
|
54
57
|
schemaName?: Args['schemaName'];
|
55
58
|
sessions: {
|
package/dist/types.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,cAAc,EACd,aAAa,EACb,0BAA0B,EAC1B,QAAQ,EACR,SAAS,EACV,MAAM,aAAa,CAAA;AACpB,OAAO,KAAK,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AACrF,OAAO,KAAK,EACV,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,kBAAkB,EAClB,aAAa,EACd,MAAM,qBAAqB,CAAA;AAC5B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AAC1D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAA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