@payloadcms/drizzle 3.58.0 → 3.59.0-internal.56a1b3b
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/find/traverseFields.d.ts.map +1 -1
- package/dist/find/traverseFields.js +5 -1
- package/dist/find/traverseFields.js.map +1 -1
- package/dist/transform/write/array.d.ts.map +1 -1
- package/dist/transform/write/array.js +1 -0
- package/dist/transform/write/array.js.map +1 -1
- package/dist/transform/write/blocks.d.ts.map +1 -1
- package/dist/transform/write/blocks.js +1 -0
- package/dist/transform/write/blocks.js.map +1 -1
- package/dist/transform/write/index.d.ts.map +1 -1
- package/dist/transform/write/index.js +2 -0
- package/dist/transform/write/index.js.map +1 -1
- package/dist/transform/write/traverseFields.d.ts +3 -2
- package/dist/transform/write/traverseFields.d.ts.map +1 -1
- package/dist/transform/write/traverseFields.js +179 -13
- package/dist/transform/write/traverseFields.js.map +1 -1
- package/dist/transform/write/types.d.ts +9 -0
- package/dist/transform/write/types.d.ts.map +1 -1
- package/dist/transform/write/types.js.map +1 -1
- package/dist/upsertRow/index.d.ts.map +1 -1
- package/dist/upsertRow/index.js +183 -24
- package/dist/upsertRow/index.js.map +1 -1
- package/dist/upsertRow/shouldUseOptimizedUpsertRow.d.ts.map +1 -1
- package/dist/upsertRow/shouldUseOptimizedUpsertRow.js +29 -0
- package/dist/upsertRow/shouldUseOptimizedUpsertRow.js.map +1 -1
- package/package.json +3 -3
|
@@ -10,7 +10,8 @@ import { transformNumbers } from './numbers.js';
|
|
|
10
10
|
import { transformRelationship } from './relationships.js';
|
|
11
11
|
import { transformSelects } from './selects.js';
|
|
12
12
|
import { transformTexts } from './texts.js';
|
|
13
|
-
export const traverseFields = ({ adapter, arrays, arraysToPush, baseTableName, blocks, blocksToDelete, columnPrefix, data, enableAtomicWrites, existingLocales, fieldPrefix, fields, forcedLocale, insideArrayOrBlock = false, locales, numbers, numbersToDelete, parentIsLocalized, parentTableName, path, relationships, relationshipsToDelete, row, selects, texts, textsToDelete, withinArrayOrBlockLocale })=>{
|
|
13
|
+
export const traverseFields = ({ adapter, arrays, arraysToPush, baseTableName, blocks, blocksToDelete, columnPrefix, data, enableAtomicWrites, existingLocales, fieldPrefix, fields, forcedLocale, insideArrayOrBlock = false, locales, numbers, numbersToDelete, parentIsLocalized, parentTableName, path, relationships, relationshipsToAppend, relationshipsToDelete, row, selects, texts, textsToDelete, withinArrayOrBlockLocale })=>{
|
|
14
|
+
let fieldsMatched = false;
|
|
14
15
|
if (row._uuid) {
|
|
15
16
|
data._uuid = row._uuid;
|
|
16
17
|
}
|
|
@@ -21,6 +22,10 @@ export const traverseFields = ({ adapter, arrays, arraysToPush, baseTableName, b
|
|
|
21
22
|
if (fieldIsVirtual(field)) {
|
|
22
23
|
return;
|
|
23
24
|
}
|
|
25
|
+
// Mark that we found a matching field
|
|
26
|
+
if (data[field.name] !== undefined) {
|
|
27
|
+
fieldsMatched = true;
|
|
28
|
+
}
|
|
24
29
|
columnName = `${columnPrefix || ''}${toSnakeCase(field.name)}`;
|
|
25
30
|
fieldName = `${fieldPrefix || ''}${field.name}`;
|
|
26
31
|
fieldData = data[field.name];
|
|
@@ -31,19 +36,19 @@ export const traverseFields = ({ adapter, arrays, arraysToPush, baseTableName, b
|
|
|
31
36
|
if (field.type === 'array') {
|
|
32
37
|
const arrayTableName = adapter.tableNameMap.get(`${parentTableName}_${columnName}`);
|
|
33
38
|
if (isLocalized) {
|
|
34
|
-
|
|
35
|
-
let push = false;
|
|
36
|
-
if (typeof value === 'object' && '$push' in value) {
|
|
37
|
-
value = value.$push;
|
|
38
|
-
push = true;
|
|
39
|
-
}
|
|
39
|
+
const value = data[field.name];
|
|
40
40
|
if (typeof value === 'object' && value !== null) {
|
|
41
|
-
Object.entries(value).forEach(([localeKey,
|
|
42
|
-
let localeData =
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
41
|
+
Object.entries(value).forEach(([localeKey, localeValue])=>{
|
|
42
|
+
let localeData = localeValue;
|
|
43
|
+
let push = false;
|
|
44
|
+
if (localeValue && typeof localeValue === 'object' && '$push' in localeValue) {
|
|
45
|
+
localeData = localeValue.$push;
|
|
46
|
+
push = true;
|
|
47
|
+
if (!Array.isArray(localeData)) {
|
|
48
|
+
localeData = [
|
|
49
|
+
localeData
|
|
50
|
+
];
|
|
51
|
+
}
|
|
47
52
|
}
|
|
48
53
|
if (Array.isArray(localeData)) {
|
|
49
54
|
const newRows = transformArray({
|
|
@@ -204,6 +209,7 @@ export const traverseFields = ({ adapter, arrays, arraysToPush, baseTableName, b
|
|
|
204
209
|
parentTableName,
|
|
205
210
|
path: `${path || ''}${field.name}.`,
|
|
206
211
|
relationships,
|
|
212
|
+
relationshipsToAppend,
|
|
207
213
|
relationshipsToDelete,
|
|
208
214
|
row,
|
|
209
215
|
selects,
|
|
@@ -236,6 +242,7 @@ export const traverseFields = ({ adapter, arrays, arraysToPush, baseTableName, b
|
|
|
236
242
|
parentTableName,
|
|
237
243
|
path: `${path || ''}${field.name}.`,
|
|
238
244
|
relationships,
|
|
245
|
+
relationshipsToAppend,
|
|
239
246
|
relationshipsToDelete,
|
|
240
247
|
row,
|
|
241
248
|
selects,
|
|
@@ -249,6 +256,114 @@ export const traverseFields = ({ adapter, arrays, arraysToPush, baseTableName, b
|
|
|
249
256
|
}
|
|
250
257
|
if (field.type === 'relationship' || field.type === 'upload') {
|
|
251
258
|
const relationshipPath = `${path || ''}${field.name}`;
|
|
259
|
+
// Handle $push operation for relationship fields
|
|
260
|
+
if (fieldData && typeof fieldData === 'object' && 'hasMany' in field && field.hasMany && ('$push' in fieldData || field.localized && Object.values(fieldData).some((localeValue)=>localeValue && typeof localeValue === 'object' && '$push' in localeValue))) {
|
|
261
|
+
let itemsToAppend;
|
|
262
|
+
if (field.localized) {
|
|
263
|
+
let hasLocaleOperations = false;
|
|
264
|
+
Object.entries(fieldData).forEach(([localeKey, localeValue])=>{
|
|
265
|
+
if (localeValue && typeof localeValue === 'object' && '$push' in localeValue) {
|
|
266
|
+
hasLocaleOperations = true;
|
|
267
|
+
const push = localeValue.$push;
|
|
268
|
+
const localeItems = Array.isArray(push) ? push : [
|
|
269
|
+
push
|
|
270
|
+
];
|
|
271
|
+
localeItems.forEach((item)=>{
|
|
272
|
+
const relationshipToAppend = {
|
|
273
|
+
locale: localeKey,
|
|
274
|
+
path: relationshipPath,
|
|
275
|
+
value: item
|
|
276
|
+
};
|
|
277
|
+
// Handle polymorphic relationships
|
|
278
|
+
if (Array.isArray(field.relationTo) && item && typeof item === 'object' && 'relationTo' in item) {
|
|
279
|
+
relationshipToAppend.relationTo = item.relationTo;
|
|
280
|
+
relationshipToAppend.value = item.value;
|
|
281
|
+
} else if (typeof field.relationTo === 'string') {
|
|
282
|
+
// Simple relationship
|
|
283
|
+
relationshipToAppend.relationTo = field.relationTo;
|
|
284
|
+
relationshipToAppend.value = item;
|
|
285
|
+
}
|
|
286
|
+
relationshipsToAppend.push(relationshipToAppend);
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
});
|
|
290
|
+
if (hasLocaleOperations) {
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
} else {
|
|
294
|
+
// Handle non-localized fields: { field: { $push: data } }
|
|
295
|
+
itemsToAppend = Array.isArray(fieldData.$push) ? fieldData.$push : [
|
|
296
|
+
fieldData.$push
|
|
297
|
+
];
|
|
298
|
+
itemsToAppend.forEach((item)=>{
|
|
299
|
+
const relationshipToAppend = {
|
|
300
|
+
locale: isLocalized ? withinArrayOrBlockLocale : undefined,
|
|
301
|
+
path: relationshipPath,
|
|
302
|
+
value: item
|
|
303
|
+
};
|
|
304
|
+
// Handle polymorphic relationships
|
|
305
|
+
if (Array.isArray(field.relationTo) && item && typeof item === 'object' && 'relationTo' in item && 'value' in item) {
|
|
306
|
+
relationshipToAppend.relationTo = item.relationTo;
|
|
307
|
+
relationshipToAppend.value = item.value;
|
|
308
|
+
} else if (typeof field.relationTo === 'string') {
|
|
309
|
+
// Simple relationship
|
|
310
|
+
relationshipToAppend.relationTo = field.relationTo;
|
|
311
|
+
relationshipToAppend.value = item;
|
|
312
|
+
}
|
|
313
|
+
relationshipsToAppend.push(relationshipToAppend);
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
// Handle $remove operation for relationship fields
|
|
319
|
+
if (fieldData && typeof fieldData === 'object' && 'hasMany' in field && field.hasMany && ('$remove' in fieldData || field.localized && Object.values(fieldData).some((localeValue)=>localeValue && typeof localeValue === 'object' && '$remove' in localeValue))) {
|
|
320
|
+
// Check for new locale-first syntax: { field: { locale: { $remove: data } } }
|
|
321
|
+
if (field.localized) {
|
|
322
|
+
let hasLocaleOperations = false;
|
|
323
|
+
Object.entries(fieldData).forEach(([localeKey, localeValue])=>{
|
|
324
|
+
if (localeValue && typeof localeValue === 'object' && '$remove' in localeValue) {
|
|
325
|
+
hasLocaleOperations = true;
|
|
326
|
+
const remove = localeValue.$remove;
|
|
327
|
+
const localeItems = Array.isArray(remove) ? remove : [
|
|
328
|
+
remove
|
|
329
|
+
];
|
|
330
|
+
localeItems.forEach((item)=>{
|
|
331
|
+
const relationshipToDelete = {
|
|
332
|
+
itemToRemove: item,
|
|
333
|
+
locale: localeKey,
|
|
334
|
+
path: relationshipPath
|
|
335
|
+
};
|
|
336
|
+
// Store relationTo for simple relationships
|
|
337
|
+
if (typeof field.relationTo === 'string') {
|
|
338
|
+
relationshipToDelete.relationTo = field.relationTo;
|
|
339
|
+
}
|
|
340
|
+
relationshipsToDelete.push(relationshipToDelete);
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
});
|
|
344
|
+
if (hasLocaleOperations) {
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
} else {
|
|
348
|
+
// Handle non-localized fields: { field: { $remove: data } }
|
|
349
|
+
const itemsToRemove = Array.isArray(fieldData.$remove) ? fieldData.$remove : [
|
|
350
|
+
fieldData.$remove
|
|
351
|
+
];
|
|
352
|
+
itemsToRemove.forEach((item)=>{
|
|
353
|
+
const relationshipToDelete = {
|
|
354
|
+
itemToRemove: item,
|
|
355
|
+
locale: isLocalized ? withinArrayOrBlockLocale : undefined,
|
|
356
|
+
path: relationshipPath
|
|
357
|
+
};
|
|
358
|
+
// Store relationTo for simple relationships
|
|
359
|
+
if (typeof field.relationTo === 'string') {
|
|
360
|
+
relationshipToDelete.relationTo = field.relationTo;
|
|
361
|
+
}
|
|
362
|
+
relationshipsToDelete.push(relationshipToDelete);
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
252
367
|
if (isLocalized && (Array.isArray(field.relationTo) || 'hasMany' in field && field.hasMany)) {
|
|
253
368
|
if (typeof fieldData === 'object') {
|
|
254
369
|
Object.entries(fieldData).forEach(([localeKey, localeData])=>{
|
|
@@ -484,6 +599,57 @@ export const traverseFields = ({ adapter, arrays, arraysToPush, baseTableName, b
|
|
|
484
599
|
}
|
|
485
600
|
});
|
|
486
601
|
});
|
|
602
|
+
// Handle dot-notation paths when no fields matched
|
|
603
|
+
if (!fieldsMatched) {
|
|
604
|
+
Object.keys(data).forEach((key)=>{
|
|
605
|
+
if (key.includes('.')) {
|
|
606
|
+
// Split on first dot only
|
|
607
|
+
const firstDotIndex = key.indexOf('.');
|
|
608
|
+
const fieldName = key.substring(0, firstDotIndex);
|
|
609
|
+
const remainingPath = key.substring(firstDotIndex + 1);
|
|
610
|
+
// Create nested structure for this field
|
|
611
|
+
if (!data[fieldName]) {
|
|
612
|
+
data[fieldName] = {};
|
|
613
|
+
}
|
|
614
|
+
const nestedData = data[fieldName];
|
|
615
|
+
// Move the value to the nested structure
|
|
616
|
+
nestedData[remainingPath] = data[key];
|
|
617
|
+
delete data[key];
|
|
618
|
+
// Recursively process the newly created nested structure
|
|
619
|
+
// The field traversal will naturally handle it if the field exists in the schema
|
|
620
|
+
traverseFields({
|
|
621
|
+
adapter,
|
|
622
|
+
arrays,
|
|
623
|
+
arraysToPush,
|
|
624
|
+
baseTableName,
|
|
625
|
+
blocks,
|
|
626
|
+
blocksToDelete,
|
|
627
|
+
columnPrefix,
|
|
628
|
+
data,
|
|
629
|
+
enableAtomicWrites,
|
|
630
|
+
existingLocales,
|
|
631
|
+
fieldPrefix,
|
|
632
|
+
fields,
|
|
633
|
+
forcedLocale,
|
|
634
|
+
insideArrayOrBlock,
|
|
635
|
+
locales,
|
|
636
|
+
numbers,
|
|
637
|
+
numbersToDelete,
|
|
638
|
+
parentIsLocalized,
|
|
639
|
+
parentTableName,
|
|
640
|
+
path,
|
|
641
|
+
relationships,
|
|
642
|
+
relationshipsToAppend,
|
|
643
|
+
relationshipsToDelete,
|
|
644
|
+
row,
|
|
645
|
+
selects,
|
|
646
|
+
texts,
|
|
647
|
+
textsToDelete,
|
|
648
|
+
withinArrayOrBlockLocale
|
|
649
|
+
});
|
|
650
|
+
}
|
|
651
|
+
});
|
|
652
|
+
}
|
|
487
653
|
};
|
|
488
654
|
|
|
489
655
|
//# sourceMappingURL=traverseFields.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/transform/write/traverseFields.ts"],"sourcesContent":["import { sql } from 'drizzle-orm'\nimport { APIError, type FlattenedField } from 'payload'\nimport { fieldIsVirtual, fieldShouldBeLocalized } from 'payload/shared'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { DrizzleAdapter } from '../../types.js'\nimport type { NumberToDelete, RelationshipToDelete, RowToInsert, TextToDelete } from './types.js'\n\nimport { isArrayOfRows } from '../../utilities/isArrayOfRows.js'\nimport { resolveBlockTableName } from '../../utilities/validateExistingBlockIsIdentical.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: DrizzleAdapter\n /**\n * This will delete the array table and then re-insert all the new array rows.\n */\n arrays: RowToInsert['arrays']\n /**\n * Array rows to push to the existing array. This will simply create\n * a new row in the array table.\n */\n arraysToPush: RowToInsert['arraysToPush']\n /**\n * This is the name of the base table\n */\n baseTableName: string\n blocks: RowToInsert['blocks']\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 enableAtomicWrites?: boolean\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: FlattenedField[]\n forcedLocale?: string\n /**\n * Tracks whether the current traversion context is from array or block.\n */\n insideArrayOrBlock?: boolean\n locales: {\n [locale: string]: Record<string, unknown>\n }\n numbers: Record<string, unknown>[]\n numbersToDelete: NumberToDelete[]\n parentIsLocalized: boolean\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 textsToDelete: TextToDelete[]\n /**\n * Set to a locale code if this set of fields is traversed within a\n * localized array or block field\n */\n withinArrayOrBlockLocale?: string\n}\n\nexport const traverseFields = ({\n adapter,\n arrays,\n arraysToPush,\n baseTableName,\n blocks,\n blocksToDelete,\n columnPrefix,\n data,\n enableAtomicWrites,\n existingLocales,\n fieldPrefix,\n fields,\n forcedLocale,\n insideArrayOrBlock = false,\n locales,\n numbers,\n numbersToDelete,\n parentIsLocalized,\n parentTableName,\n path,\n relationships,\n relationshipsToDelete,\n row,\n selects,\n texts,\n textsToDelete,\n withinArrayOrBlockLocale,\n}: Args) => {\n if (row._uuid) {\n data._uuid = row._uuid\n }\n\n fields.forEach((field) => {\n let columnName = ''\n let fieldName = ''\n let fieldData: unknown\n\n if (fieldIsVirtual(field)) {\n return\n }\n\n columnName = `${columnPrefix || ''}${toSnakeCase(field.name)}`\n fieldName = `${fieldPrefix || ''}${field.name}`\n fieldData = data[field.name]\n\n const isLocalized = fieldShouldBeLocalized({ field, parentIsLocalized })\n\n if (field.type === 'array') {\n const arrayTableName = adapter.tableNameMap.get(`${parentTableName}_${columnName}`)\n\n if (isLocalized) {\n let value: {\n [locale: string]: unknown[]\n } = data[field.name] as any\n\n let push = false\n if (typeof value === 'object' && '$push' in value) {\n value = value.$push as any\n push = true\n }\n\n if (typeof value === 'object' && value !== null) {\n Object.entries(value).forEach(([localeKey, _localeData]) => {\n let localeData = _localeData\n if (push && !Array.isArray(localeData)) {\n localeData = [localeData]\n }\n\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 numbersToDelete,\n parentIsLocalized: parentIsLocalized || field.localized,\n path,\n relationships,\n relationshipsToDelete,\n selects,\n texts,\n textsToDelete,\n withinArrayOrBlockLocale: localeKey,\n })\n\n if (push) {\n if (!arraysToPush[arrayTableName]) {\n arraysToPush[arrayTableName] = []\n }\n arraysToPush[arrayTableName] = arraysToPush[arrayTableName].concat(newRows)\n } else {\n if (!arrays[arrayTableName]) {\n arrays[arrayTableName] = []\n }\n arrays[arrayTableName] = arrays[arrayTableName].concat(newRows)\n }\n }\n })\n }\n } else {\n let value = data[field.name]\n let push = false\n if (typeof value === 'object' && '$push' in value) {\n value = Array.isArray(value.$push) ? value.$push : [value.$push]\n push = true\n }\n\n const newRows = transformArray({\n adapter,\n arrayTableName,\n baseTableName,\n blocks,\n blocksToDelete,\n data: value,\n field,\n numbers,\n numbersToDelete,\n parentIsLocalized: parentIsLocalized || field.localized,\n path,\n relationships,\n relationshipsToDelete,\n selects,\n texts,\n textsToDelete,\n withinArrayOrBlockLocale,\n })\n\n if (push) {\n if (!arraysToPush[arrayTableName]) {\n arraysToPush[arrayTableName] = []\n }\n arraysToPush[arrayTableName] = arraysToPush[arrayTableName].concat(newRows)\n } else {\n if (!arrays[arrayTableName]) {\n arrays[arrayTableName] = []\n }\n arrays[arrayTableName] = arrays[arrayTableName].concat(newRows)\n }\n }\n\n return\n }\n\n if (field.type === 'blocks' && !adapter.blocksAsJSON) {\n ;(field.blockReferences ?? field.blocks).forEach((block) => {\n const matchedBlock =\n typeof block === 'string'\n ? adapter.payload.config.blocks.find((each) => each.slug === block)\n : block\n\n blocksToDelete.add(\n resolveBlockTableName(\n matchedBlock,\n adapter.tableNameMap.get(`${baseTableName}_blocks_${toSnakeCase(matchedBlock.slug)}`),\n ),\n )\n })\n\n if (isLocalized) {\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 numbersToDelete,\n parentIsLocalized: parentIsLocalized || field.localized,\n path,\n relationships,\n relationshipsToDelete,\n selects,\n texts,\n textsToDelete,\n withinArrayOrBlockLocale: localeKey,\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 numbersToDelete,\n parentIsLocalized: parentIsLocalized || field.localized,\n path,\n relationships,\n relationshipsToDelete,\n selects,\n texts,\n textsToDelete,\n withinArrayOrBlockLocale,\n })\n }\n\n return\n }\n\n if (field.type === 'group' || field.type === 'tab') {\n if (typeof data[field.name] === 'object' && data[field.name] !== null) {\n if (isLocalized) {\n Object.entries(data[field.name]).forEach(([localeKey, localeData]) => {\n // preserve array ID if there is\n localeData._uuid = data.id || data._uuid\n\n traverseFields({\n adapter,\n arrays,\n arraysToPush,\n baseTableName,\n blocks,\n blocksToDelete,\n columnPrefix: `${columnName}_`,\n data: localeData as Record<string, unknown>,\n enableAtomicWrites,\n existingLocales,\n fieldPrefix: `${fieldName}_`,\n fields: field.flattenedFields,\n forcedLocale: localeKey,\n insideArrayOrBlock,\n locales,\n numbers,\n numbersToDelete,\n parentIsLocalized: parentIsLocalized || field.localized,\n parentTableName,\n path: `${path || ''}${field.name}.`,\n relationships,\n relationshipsToDelete,\n row,\n selects,\n texts,\n textsToDelete,\n withinArrayOrBlockLocale: localeKey,\n })\n })\n } else {\n // preserve array ID if there is\n const groupData = data[field.name] as Record<string, unknown>\n groupData._uuid = data.id || data._uuid\n\n traverseFields({\n adapter,\n arrays,\n arraysToPush,\n baseTableName,\n blocks,\n blocksToDelete,\n columnPrefix: `${columnName}_`,\n data: groupData,\n existingLocales,\n fieldPrefix: `${fieldName}_`,\n fields: field.flattenedFields,\n insideArrayOrBlock,\n locales,\n numbers,\n numbersToDelete,\n parentIsLocalized: parentIsLocalized || field.localized,\n parentTableName,\n path: `${path || ''}${field.name}.`,\n relationships,\n relationshipsToDelete,\n row,\n selects,\n texts,\n textsToDelete,\n withinArrayOrBlockLocale,\n })\n }\n }\n\n return\n }\n\n if (field.type === 'relationship' || field.type === 'upload') {\n const relationshipPath = `${path || ''}${field.name}`\n\n if (\n isLocalized &&\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 locale: withinArrayOrBlockLocale,\n path: relationshipPath,\n },\n data: fieldData,\n field,\n relationships,\n })\n return\n } else {\n if (\n !isLocalized &&\n fieldData &&\n typeof fieldData === 'object' &&\n 'id' in fieldData &&\n fieldData?.id\n ) {\n fieldData = fieldData.id\n } else if (isLocalized) {\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 (isLocalized) {\n if (typeof fieldData === 'object') {\n Object.entries(fieldData).forEach(([localeKey, localeData]) => {\n if (Array.isArray(localeData)) {\n if (!localeData.length) {\n textsToDelete.push({ locale: localeKey, path: textPath })\n return\n }\n\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 if (!fieldData.length) {\n textsToDelete.push({ locale: withinArrayOrBlockLocale, path: textPath })\n return\n }\n\n transformTexts({\n baseRow: {\n locale: withinArrayOrBlockLocale,\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 (isLocalized) {\n if (typeof fieldData === 'object') {\n Object.entries(fieldData).forEach(([localeKey, localeData]) => {\n if (Array.isArray(localeData)) {\n if (!localeData.length) {\n numbersToDelete.push({ locale: localeKey, path: numberPath })\n return\n }\n\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 if (!fieldData.length) {\n numbersToDelete.push({ locale: withinArrayOrBlockLocale, path: numberPath })\n return\n }\n\n transformNumbers({\n baseRow: {\n locale: withinArrayOrBlockLocale,\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]) {\n selects[selectTableName] = []\n }\n\n if (isLocalized) {\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: insideArrayOrBlock ? data._uuid || data.id : undefined,\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: insideArrayOrBlock ? data._uuid || data.id : undefined,\n data: data[field.name],\n locale: withinArrayOrBlockLocale,\n })\n\n selects[selectTableName] = selects[selectTableName].concat(newRows)\n }\n\n return\n }\n\n const valuesToTransform: { localeKey?: string; ref: unknown; value: unknown }[] = []\n\n if (isLocalized) {\n if (typeof fieldData === 'object' && fieldData !== null) {\n Object.entries(fieldData).forEach(([localeKey, localeData]) => {\n if (!locales[localeKey]) {\n locales[localeKey] = {}\n }\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]) {\n locales[forcedLocale] = {}\n }\n ref = locales[forcedLocale]\n }\n\n valuesToTransform.push({ ref, value: fieldData })\n }\n\n valuesToTransform.forEach(({ localeKey, ref, value }) => {\n let formattedValue = value\n\n if (field.type === 'date') {\n if (fieldName === 'updatedAt' && typeof formattedValue === 'undefined') {\n // let the db handle this. If formattedValue is explicitly set to `null` we should not set it - this means we don't want to change the value of updatedAt.\n formattedValue = new Date().toISOString()\n } else {\n if (typeof value === 'number' && !Number.isNaN(value)) {\n formattedValue = new Date(value).toISOString()\n } else if (value instanceof Date) {\n formattedValue = value.toISOString()\n }\n }\n }\n\n if (typeof value !== 'undefined') {\n if (value && field.type === 'point' && adapter.name !== 'sqlite') {\n formattedValue = sql`ST_GeomFromGeoJSON(${JSON.stringify(value)})`\n }\n\n if (field.type === 'text' && value && typeof value !== 'string') {\n formattedValue = JSON.stringify(value)\n }\n\n if (\n field.type === 'number' &&\n value &&\n typeof value === 'object' &&\n '$inc' in value &&\n typeof value.$inc === 'number'\n ) {\n if (!enableAtomicWrites) {\n throw new APIError(\n 'The passed data must not contain any nested fields for atomic writes',\n )\n }\n\n formattedValue = sql.raw(`${columnName} + ${value.$inc}`)\n }\n }\n\n if (typeof formattedValue !== 'undefined') {\n if (localeKey) {\n ref[localeKey][fieldName] = formattedValue\n } else {\n ref[fieldName] = formattedValue\n }\n }\n })\n })\n}\n"],"names":["sql","APIError","fieldIsVirtual","fieldShouldBeLocalized","toSnakeCase","isArrayOfRows","resolveBlockTableName","transformArray","transformBlocks","transformNumbers","transformRelationship","transformSelects","transformTexts","traverseFields","adapter","arrays","arraysToPush","baseTableName","blocks","blocksToDelete","columnPrefix","data","enableAtomicWrites","existingLocales","fieldPrefix","fields","forcedLocale","insideArrayOrBlock","locales","numbers","numbersToDelete","parentIsLocalized","parentTableName","path","relationships","relationshipsToDelete","row","selects","texts","textsToDelete","withinArrayOrBlockLocale","_uuid","forEach","field","columnName","fieldName","fieldData","name","isLocalized","type","arrayTableName","tableNameMap","get","value","push","$push","Object","entries","localeKey","_localeData","localeData","Array","isArray","newRows","locale","localized","concat","blocksAsJSON","blockReferences","block","matchedBlock","payload","config","find","each","slug","add","id","flattenedFields","groupData","relationshipPath","relationTo","hasMany","baseRow","length","textPath","numberPath","selectTableName","undefined","valuesToTransform","ref","formattedValue","Date","toISOString","Number","isNaN","JSON","stringify","$inc","raw"],"mappings":"AAAA,SAASA,GAAG,QAAQ,cAAa;AACjC,SAASC,QAAQ,QAA6B,UAAS;AACvD,SAASC,cAAc,EAAEC,sBAAsB,QAAQ,iBAAgB;AACvE,OAAOC,iBAAiB,gBAAe;AAKvC,SAASC,aAAa,QAAQ,mCAAkC;AAChE,SAASC,qBAAqB,QAAQ,sDAAqD;AAC3F,SAASC,cAAc,QAAQ,aAAY;AAC3C,SAASC,eAAe,QAAQ,cAA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C,SAAS,CAAC5C,OAAO,CAAC,CAAC;gBACpE;gBAEA,IAAIV,MAAMM,IAAI,KAAK,UAAUI,SAAS,OAAOA,UAAU,UAAU;oBAC/DsC,iBAAiBK,KAAKC,SAAS,CAAC5C;gBAClC;gBAEA,IACEV,MAAMM,IAAI,KAAK,YACfI,SACA,OAAOA,UAAU,YACjB,UAAUA,SACV,OAAOA,MAAM6C,IAAI,KAAK,UACtB;oBACA,IAAI,CAAC5E,oBAAoB;wBACvB,MAAM,IAAIrB,SACR;oBAEJ;oBAEA0F,iBAAiB3F,IAAImG,GAAG,CAAC,GAAGvD,WAAW,GAAG,EAAES,MAAM6C,IAAI,EAAE;gBAC1D;YACF;YAEA,IAAI,OAAOP,mBAAmB,aAAa;gBACzC,IAAIjC,WAAW;oBACbgC,GAAG,CAAChC,UAAU,CAACb,UAAU,GAAG8C;gBAC9B,OAAO;oBACLD,GAAG,CAAC7C,UAAU,GAAG8C;gBACnB;YACF;QACF;IACF;AACF,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/transform/write/traverseFields.ts"],"sourcesContent":["import { sql } from 'drizzle-orm'\nimport { APIError, type FlattenedField } from 'payload'\nimport { fieldIsVirtual, fieldShouldBeLocalized } from 'payload/shared'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { DrizzleAdapter } from '../../types.js'\nimport type {\n NumberToDelete,\n RelationshipToAppend,\n RelationshipToDelete,\n RowToInsert,\n TextToDelete,\n} from './types.js'\n\nimport { isArrayOfRows } from '../../utilities/isArrayOfRows.js'\nimport { resolveBlockTableName } from '../../utilities/validateExistingBlockIsIdentical.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: DrizzleAdapter\n /**\n * This will delete the array table and then re-insert all the new array rows.\n */\n arrays: RowToInsert['arrays']\n /**\n * Array rows to push to the existing array. This will simply create\n * a new row in the array table.\n */\n arraysToPush: RowToInsert['arraysToPush']\n /**\n * This is the name of the base table\n */\n baseTableName: string\n blocks: RowToInsert['blocks']\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 enableAtomicWrites?: boolean\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: FlattenedField[]\n forcedLocale?: string\n /**\n * Tracks whether the current traversion context is from array or block.\n */\n insideArrayOrBlock?: boolean\n locales: {\n [locale: string]: Record<string, unknown>\n }\n numbers: Record<string, unknown>[]\n numbersToDelete: NumberToDelete[]\n parentIsLocalized: boolean\n /**\n * This is the name of the parent table\n */\n parentTableName: string\n path: string\n relationships: Record<string, unknown>[]\n relationshipsToAppend: RelationshipToAppend[]\n relationshipsToDelete: RelationshipToDelete[]\n row: Record<string, unknown>\n selects: {\n [tableName: string]: Record<string, unknown>[]\n }\n texts: Record<string, unknown>[]\n textsToDelete: TextToDelete[]\n /**\n * Set to a locale code if this set of fields is traversed within a\n * localized array or block field\n */\n withinArrayOrBlockLocale?: string\n}\n\nexport const traverseFields = ({\n adapter,\n arrays,\n arraysToPush,\n baseTableName,\n blocks,\n blocksToDelete,\n columnPrefix,\n data,\n enableAtomicWrites,\n existingLocales,\n fieldPrefix,\n fields,\n forcedLocale,\n insideArrayOrBlock = false,\n locales,\n numbers,\n numbersToDelete,\n parentIsLocalized,\n parentTableName,\n path,\n relationships,\n relationshipsToAppend,\n relationshipsToDelete,\n row,\n selects,\n texts,\n textsToDelete,\n withinArrayOrBlockLocale,\n}: Args) => {\n let fieldsMatched = false\n\n if (row._uuid) {\n data._uuid = row._uuid\n }\n\n fields.forEach((field) => {\n let columnName = ''\n let fieldName = ''\n let fieldData: unknown\n\n if (fieldIsVirtual(field)) {\n return\n }\n\n // Mark that we found a matching field\n if (data[field.name] !== undefined) {\n fieldsMatched = true\n }\n\n columnName = `${columnPrefix || ''}${toSnakeCase(field.name)}`\n fieldName = `${fieldPrefix || ''}${field.name}`\n fieldData = data[field.name]\n\n const isLocalized = fieldShouldBeLocalized({ field, parentIsLocalized })\n\n if (field.type === 'array') {\n const arrayTableName = adapter.tableNameMap.get(`${parentTableName}_${columnName}`)\n\n if (isLocalized) {\n const value = data[field.name]\n\n if (typeof value === 'object' && value !== null) {\n Object.entries(value).forEach(([localeKey, localeValue]) => {\n let localeData = localeValue\n let push = false\n\n if (localeValue && typeof localeValue === 'object' && '$push' in localeValue) {\n localeData = localeValue.$push\n push = true\n if (!Array.isArray(localeData)) {\n localeData = [localeData]\n }\n }\n\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 numbersToDelete,\n parentIsLocalized: parentIsLocalized || field.localized,\n path,\n relationships,\n relationshipsToDelete,\n selects,\n texts,\n textsToDelete,\n withinArrayOrBlockLocale: localeKey,\n })\n\n if (push) {\n if (!arraysToPush[arrayTableName]) {\n arraysToPush[arrayTableName] = []\n }\n arraysToPush[arrayTableName] = arraysToPush[arrayTableName].concat(newRows)\n } else {\n if (!arrays[arrayTableName]) {\n arrays[arrayTableName] = []\n }\n arrays[arrayTableName] = arrays[arrayTableName].concat(newRows)\n }\n }\n })\n }\n } else {\n let value = data[field.name]\n let push = false\n if (typeof value === 'object' && '$push' in value) {\n value = Array.isArray(value.$push) ? value.$push : [value.$push]\n push = true\n }\n\n const newRows = transformArray({\n adapter,\n arrayTableName,\n baseTableName,\n blocks,\n blocksToDelete,\n data: value,\n field,\n numbers,\n numbersToDelete,\n parentIsLocalized: parentIsLocalized || field.localized,\n path,\n relationships,\n relationshipsToDelete,\n selects,\n texts,\n textsToDelete,\n withinArrayOrBlockLocale,\n })\n\n if (push) {\n if (!arraysToPush[arrayTableName]) {\n arraysToPush[arrayTableName] = []\n }\n arraysToPush[arrayTableName] = arraysToPush[arrayTableName].concat(newRows)\n } else {\n if (!arrays[arrayTableName]) {\n arrays[arrayTableName] = []\n }\n arrays[arrayTableName] = arrays[arrayTableName].concat(newRows)\n }\n }\n\n return\n }\n\n if (field.type === 'blocks' && !adapter.blocksAsJSON) {\n ;(field.blockReferences ?? field.blocks).forEach((block) => {\n const matchedBlock =\n typeof block === 'string'\n ? adapter.payload.config.blocks.find((each) => each.slug === block)\n : block\n\n blocksToDelete.add(\n resolveBlockTableName(\n matchedBlock,\n adapter.tableNameMap.get(`${baseTableName}_blocks_${toSnakeCase(matchedBlock.slug)}`),\n ),\n )\n })\n\n if (isLocalized) {\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 numbersToDelete,\n parentIsLocalized: parentIsLocalized || field.localized,\n path,\n relationships,\n relationshipsToDelete,\n selects,\n texts,\n textsToDelete,\n withinArrayOrBlockLocale: localeKey,\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 numbersToDelete,\n parentIsLocalized: parentIsLocalized || field.localized,\n path,\n relationships,\n relationshipsToDelete,\n selects,\n texts,\n textsToDelete,\n withinArrayOrBlockLocale,\n })\n }\n\n return\n }\n\n if (field.type === 'group' || field.type === 'tab') {\n if (typeof data[field.name] === 'object' && data[field.name] !== null) {\n if (isLocalized) {\n Object.entries(data[field.name]).forEach(([localeKey, localeData]) => {\n // preserve array ID if there is\n localeData._uuid = data.id || data._uuid\n\n traverseFields({\n adapter,\n arrays,\n arraysToPush,\n baseTableName,\n blocks,\n blocksToDelete,\n columnPrefix: `${columnName}_`,\n data: localeData as Record<string, unknown>,\n enableAtomicWrites,\n existingLocales,\n fieldPrefix: `${fieldName}_`,\n fields: field.flattenedFields,\n forcedLocale: localeKey,\n insideArrayOrBlock,\n locales,\n numbers,\n numbersToDelete,\n parentIsLocalized: parentIsLocalized || field.localized,\n parentTableName,\n path: `${path || ''}${field.name}.`,\n relationships,\n relationshipsToAppend,\n relationshipsToDelete,\n row,\n selects,\n texts,\n textsToDelete,\n withinArrayOrBlockLocale: localeKey,\n })\n })\n } else {\n // preserve array ID if there is\n const groupData = data[field.name] as Record<string, unknown>\n groupData._uuid = data.id || data._uuid\n\n traverseFields({\n adapter,\n arrays,\n arraysToPush,\n baseTableName,\n blocks,\n blocksToDelete,\n columnPrefix: `${columnName}_`,\n data: groupData,\n existingLocales,\n fieldPrefix: `${fieldName}_`,\n fields: field.flattenedFields,\n insideArrayOrBlock,\n locales,\n numbers,\n numbersToDelete,\n parentIsLocalized: parentIsLocalized || field.localized,\n parentTableName,\n path: `${path || ''}${field.name}.`,\n relationships,\n relationshipsToAppend,\n relationshipsToDelete,\n row,\n selects,\n texts,\n textsToDelete,\n withinArrayOrBlockLocale,\n })\n }\n }\n\n return\n }\n\n if (field.type === 'relationship' || field.type === 'upload') {\n const relationshipPath = `${path || ''}${field.name}`\n\n // Handle $push operation for relationship fields\n if (\n fieldData &&\n typeof fieldData === 'object' &&\n 'hasMany' in field &&\n field.hasMany &&\n ('$push' in fieldData ||\n (field.localized &&\n Object.values(fieldData).some(\n (localeValue) =>\n localeValue &&\n typeof localeValue === 'object' &&\n '$push' in (localeValue as Record<string, unknown>),\n )))\n ) {\n let itemsToAppend: unknown[]\n\n if (field.localized) {\n let hasLocaleOperations = false\n Object.entries(fieldData).forEach(([localeKey, localeValue]) => {\n if (localeValue && typeof localeValue === 'object' && '$push' in localeValue) {\n hasLocaleOperations = true\n const push = localeValue.$push\n const localeItems = Array.isArray(push) ? push : [push]\n\n localeItems.forEach((item) => {\n const relationshipToAppend: RelationshipToAppend = {\n locale: localeKey,\n path: relationshipPath,\n value: item,\n }\n\n // Handle polymorphic relationships\n if (\n Array.isArray(field.relationTo) &&\n item &&\n typeof item === 'object' &&\n 'relationTo' in item\n ) {\n relationshipToAppend.relationTo = item.relationTo\n relationshipToAppend.value = item.value\n } else if (typeof field.relationTo === 'string') {\n // Simple relationship\n relationshipToAppend.relationTo = field.relationTo\n relationshipToAppend.value = item\n }\n\n relationshipsToAppend.push(relationshipToAppend)\n })\n }\n })\n\n if (hasLocaleOperations) {\n return\n }\n } else {\n // Handle non-localized fields: { field: { $push: data } }\n itemsToAppend = Array.isArray((fieldData as any).$push)\n ? (fieldData as any).$push\n : [(fieldData as any).$push]\n\n itemsToAppend.forEach((item) => {\n const relationshipToAppend: RelationshipToAppend = {\n locale: isLocalized ? withinArrayOrBlockLocale : undefined,\n path: relationshipPath,\n value: item,\n }\n\n // Handle polymorphic relationships\n if (\n Array.isArray(field.relationTo) &&\n item &&\n typeof item === 'object' &&\n 'relationTo' in item &&\n 'value' in item\n ) {\n relationshipToAppend.relationTo = item.relationTo as string\n relationshipToAppend.value = item.value as number | string\n } else if (typeof field.relationTo === 'string') {\n // Simple relationship\n relationshipToAppend.relationTo = field.relationTo\n relationshipToAppend.value = item\n }\n\n relationshipsToAppend.push(relationshipToAppend)\n })\n }\n return\n }\n\n // Handle $remove operation for relationship fields\n if (\n fieldData &&\n typeof fieldData === 'object' &&\n 'hasMany' in field &&\n field.hasMany &&\n ('$remove' in fieldData ||\n (field.localized &&\n Object.values(fieldData).some(\n (localeValue) =>\n localeValue &&\n typeof localeValue === 'object' &&\n '$remove' in (localeValue as Record<string, unknown>),\n )))\n ) {\n // Check for new locale-first syntax: { field: { locale: { $remove: data } } }\n if (field.localized) {\n let hasLocaleOperations = false\n Object.entries(fieldData).forEach(([localeKey, localeValue]) => {\n if (localeValue && typeof localeValue === 'object' && '$remove' in localeValue) {\n hasLocaleOperations = true\n const remove = localeValue.$remove\n const localeItems = Array.isArray(remove) ? remove : [remove]\n\n localeItems.forEach((item) => {\n const relationshipToDelete: RelationshipToDelete = {\n itemToRemove: item,\n locale: localeKey,\n path: relationshipPath,\n }\n\n // Store relationTo for simple relationships\n if (typeof field.relationTo === 'string') {\n relationshipToDelete.relationTo = field.relationTo\n }\n\n relationshipsToDelete.push(relationshipToDelete)\n })\n }\n })\n\n if (hasLocaleOperations) {\n return\n }\n } else {\n // Handle non-localized fields: { field: { $remove: data } }\n const itemsToRemove = Array.isArray((fieldData as any).$remove)\n ? (fieldData as any).$remove\n : [(fieldData as any).$remove]\n\n itemsToRemove.forEach((item) => {\n const relationshipToDelete: RelationshipToDelete = {\n itemToRemove: item,\n locale: isLocalized ? withinArrayOrBlockLocale : undefined,\n path: relationshipPath,\n }\n\n // Store relationTo for simple relationships\n if (typeof field.relationTo === 'string') {\n relationshipToDelete.relationTo = field.relationTo\n }\n\n relationshipsToDelete.push(relationshipToDelete)\n })\n }\n return\n }\n\n if (\n isLocalized &&\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 locale: withinArrayOrBlockLocale,\n path: relationshipPath,\n },\n data: fieldData,\n field,\n relationships,\n })\n return\n } else {\n if (\n !isLocalized &&\n fieldData &&\n typeof fieldData === 'object' &&\n 'id' in fieldData &&\n fieldData?.id\n ) {\n fieldData = fieldData.id\n } else if (isLocalized) {\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 (isLocalized) {\n if (typeof fieldData === 'object') {\n Object.entries(fieldData).forEach(([localeKey, localeData]) => {\n if (Array.isArray(localeData)) {\n if (!localeData.length) {\n textsToDelete.push({ locale: localeKey, path: textPath })\n return\n }\n\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 if (!fieldData.length) {\n textsToDelete.push({ locale: withinArrayOrBlockLocale, path: textPath })\n return\n }\n\n transformTexts({\n baseRow: {\n locale: withinArrayOrBlockLocale,\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 (isLocalized) {\n if (typeof fieldData === 'object') {\n Object.entries(fieldData).forEach(([localeKey, localeData]) => {\n if (Array.isArray(localeData)) {\n if (!localeData.length) {\n numbersToDelete.push({ locale: localeKey, path: numberPath })\n return\n }\n\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 if (!fieldData.length) {\n numbersToDelete.push({ locale: withinArrayOrBlockLocale, path: numberPath })\n return\n }\n\n transformNumbers({\n baseRow: {\n locale: withinArrayOrBlockLocale,\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]) {\n selects[selectTableName] = []\n }\n\n if (isLocalized) {\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: insideArrayOrBlock ? data._uuid || data.id : undefined,\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: insideArrayOrBlock ? data._uuid || data.id : undefined,\n data: data[field.name],\n locale: withinArrayOrBlockLocale,\n })\n\n selects[selectTableName] = selects[selectTableName].concat(newRows)\n }\n\n return\n }\n\n const valuesToTransform: { localeKey?: string; ref: unknown; value: unknown }[] = []\n\n if (isLocalized) {\n if (typeof fieldData === 'object' && fieldData !== null) {\n Object.entries(fieldData).forEach(([localeKey, localeData]) => {\n if (!locales[localeKey]) {\n locales[localeKey] = {}\n }\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]) {\n locales[forcedLocale] = {}\n }\n ref = locales[forcedLocale]\n }\n\n valuesToTransform.push({ ref, value: fieldData })\n }\n\n valuesToTransform.forEach(({ localeKey, ref, value }) => {\n let formattedValue = value\n\n if (field.type === 'date') {\n if (fieldName === 'updatedAt' && typeof formattedValue === 'undefined') {\n // let the db handle this. If formattedValue is explicitly set to `null` we should not set it - this means we don't want to change the value of updatedAt.\n formattedValue = new Date().toISOString()\n } else {\n if (typeof value === 'number' && !Number.isNaN(value)) {\n formattedValue = new Date(value).toISOString()\n } else if (value instanceof Date) {\n formattedValue = value.toISOString()\n }\n }\n }\n\n if (typeof value !== 'undefined') {\n if (value && field.type === 'point' && adapter.name !== 'sqlite') {\n formattedValue = sql`ST_GeomFromGeoJSON(${JSON.stringify(value)})`\n }\n\n if (field.type === 'text' && value && typeof value !== 'string') {\n formattedValue = JSON.stringify(value)\n }\n\n if (\n field.type === 'number' &&\n value &&\n typeof value === 'object' &&\n '$inc' in value &&\n typeof value.$inc === 'number'\n ) {\n if (!enableAtomicWrites) {\n throw new APIError(\n 'The passed data must not contain any nested fields for atomic writes',\n )\n }\n\n formattedValue = sql.raw(`${columnName} + ${value.$inc}`)\n }\n }\n\n if (typeof formattedValue !== 'undefined') {\n if (localeKey) {\n ref[localeKey][fieldName] = formattedValue\n } else {\n ref[fieldName] = formattedValue\n }\n }\n })\n })\n\n // Handle dot-notation paths when no fields matched\n if (!fieldsMatched) {\n Object.keys(data).forEach((key) => {\n if (key.includes('.')) {\n // Split on first dot only\n const firstDotIndex = key.indexOf('.')\n const fieldName = key.substring(0, firstDotIndex)\n const remainingPath = key.substring(firstDotIndex + 1)\n\n // Create nested structure for this field\n if (!data[fieldName]) {\n data[fieldName] = {}\n }\n\n const nestedData = data[fieldName] as Record<string, unknown>\n\n // Move the value to the nested structure\n nestedData[remainingPath] = data[key]\n delete data[key]\n\n // Recursively process the newly created nested structure\n // The field traversal will naturally handle it if the field exists in the schema\n traverseFields({\n adapter,\n arrays,\n arraysToPush,\n baseTableName,\n blocks,\n blocksToDelete,\n columnPrefix,\n data,\n enableAtomicWrites,\n existingLocales,\n fieldPrefix,\n fields,\n forcedLocale,\n insideArrayOrBlock,\n locales,\n numbers,\n numbersToDelete,\n parentIsLocalized,\n parentTableName,\n path,\n relationships,\n relationshipsToAppend,\n relationshipsToDelete,\n row,\n selects,\n texts,\n textsToDelete,\n withinArrayOrBlockLocale,\n })\n }\n })\n }\n}\n"],"names":["sql","APIError","fieldIsVirtual","fieldShouldBeLocalized","toSnakeCase","isArrayOfRows","resolveBlockTableName","transformArray","transformBlocks","transformNumbers","transformRelationship","transformSelects","transformTexts","traverseFields","adapter","arrays","arraysToPush","baseTableName","blocks","blocksToDelete","columnPrefix","data","enableAtomicWrites","existingLocales","fieldPrefix","fields","forcedLocale","insideArrayOrBlock","locales","numbers","numbersToDelete","parentIsLocalized","parentTableName","path","relationships","relationshipsToAppend","relationshipsToDelete","row","selects","texts","textsToDelete","withinArrayOrBlockLocale","fieldsMatched","_uuid","forEach","field","columnName","fieldName","fieldData","name","undefined","isLocalized","type","arrayTableName","tableNameMap","get","value","Object","entries","localeKey","localeValue","localeData","push","$push","Array","isArray","newRows","locale","localized","concat","blocksAsJSON","blockReferences","block","matchedBlock","payload","config","find","each","slug","add","id","flattenedFields","groupData","relationshipPath","hasMany","values","some","itemsToAppend","hasLocaleOperations","localeItems","item","relationshipToAppend","relationTo","remove","$remove","relationshipToDelete","itemToRemove","itemsToRemove","baseRow","length","textPath","numberPath","selectTableName","valuesToTransform","ref","formattedValue","Date","toISOString","Number","isNaN","JSON","stringify","$inc","raw","keys","key","includes","firstDotIndex","indexOf","substring","remainingPath","nestedData"],"mappings":"AAAA,SAASA,GAAG,QAAQ,cAAa;AACjC,SAASC,QAAQ,QAA6B,UAAS;AACvD,SAASC,cAAc,EAAEC,sBAAsB,QAAQ,iBAAgB;AACvE,OAAOC,iBAAiB,gBAAe;AAWvC,SAASC,aAAa,QAAQ,mCAAkC;AAChE,SAASC,qBAAqB,QAAQ,sDAAqD;AAC3F,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;AAiE3C,OAAO,MAAMC,iBAAiB,CAAC,EAC7BC,OAAO,EACPC,MAAM,EACNC,YAAY,EACZC,aAAa,EACbC,MAAM,EACNC,cAAc,EACdC,YAAY,EACZC,IAAI,EACJC,kBAAkB,EAClBC,eAAe,EACfC,WAAW,EACXC,MAAM,EACNC,YAAY,EACZC,qBAAqB,KAAK,EAC1BC,OAAO,EACPC,OAAO,EACPC,eAAe,EACfC,iBAAiB,EACjBC,eAAe,EACfC,IAAI,EACJC,aAAa,EACbC,qBAAqB,EACrBC,qBAAqB,EACrBC,GAAG,EACHC,OAAO,EACPC,KAAK,EACLC,aAAa,EACbC,wBAAwB,EACnB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GF;gBACnC,MAAMG,gBAAgBL,IAAII,SAAS,CAACF,gBAAgB;gBAEpD,yCAAyC;gBACzC,IAAI,CAAChG,IAAI,CAAC0B,UAAU,EAAE;oBACpB1B,IAAI,CAAC0B,UAAU,GAAG,CAAC;gBACrB;gBAEA,MAAM0E,aAAapG,IAAI,CAAC0B,UAAU;gBAElC,yCAAyC;gBACzC0E,UAAU,CAACD,cAAc,GAAGnG,IAAI,CAAC8F,IAAI;gBACrC,OAAO9F,IAAI,CAAC8F,IAAI;gBAEhB,yDAAyD;gBACzD,iFAAiF;gBACjFtG,eAAe;oBACbC;oBACAC;oBACAC;oBACAC;oBACAC;oBACAC;oBACAC;oBACAC;oBACAC;oBACAC;oBACAC;oBACAC;oBACAC;oBACAC;oBACAC;oBACAC;oBACAC;oBACAC;oBACAC;oBACAC;oBACAC;oBACAC;oBACAC;oBACAC;oBACAC;oBACAC;oBACAC;oBACAC;gBACF;YACF;QACF;IACF;AACF,EAAC"}
|
|
@@ -23,8 +23,16 @@ export type BlockRowToInsert = {
|
|
|
23
23
|
row: Record<string, unknown>;
|
|
24
24
|
};
|
|
25
25
|
export type RelationshipToDelete = {
|
|
26
|
+
itemToRemove?: any;
|
|
26
27
|
locale?: string;
|
|
27
28
|
path: string;
|
|
29
|
+
relationTo?: string;
|
|
30
|
+
};
|
|
31
|
+
export type RelationshipToAppend = {
|
|
32
|
+
locale?: string;
|
|
33
|
+
path: string;
|
|
34
|
+
relationTo?: string;
|
|
35
|
+
value: any;
|
|
28
36
|
};
|
|
29
37
|
export type TextToDelete = {
|
|
30
38
|
locale?: string;
|
|
@@ -51,6 +59,7 @@ export type RowToInsert = {
|
|
|
51
59
|
numbers: Record<string, unknown>[];
|
|
52
60
|
numbersToDelete: NumberToDelete[];
|
|
53
61
|
relationships: Record<string, unknown>[];
|
|
62
|
+
relationshipsToAppend: RelationshipToAppend[];
|
|
54
63
|
relationshipsToDelete: RelationshipToDelete[];
|
|
55
64
|
row: Record<string, unknown>;
|
|
56
65
|
selects: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/transform/write/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GAAG;IAC7B,MAAM,EAAE;QACN,CAAC,SAAS,EAAE,MAAM,GAAG,gBAAgB,EAAE,CAAA;KACxC,CAAA;IACD,YAAY,EAAE;QACZ,CAAC,SAAS,EAAE,MAAM,GAAG,gBAAgB,EAAE,CAAA;KACxC,CAAA;IACD,OAAO,EAAE;QACP,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAC1C,CAAA;IACD,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC7B,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B,MAAM,EAAE;QACN,CAAC,SAAS,EAAE,MAAM,GAAG,gBAAgB,EAAE,CAAA;KACxC,CAAA;IACD,YAAY,EAAE;QACZ,CAAC,SAAS,EAAE,MAAM,GAAG,gBAAgB,EAAE,CAAA;KACxC,CAAA;IACD,OAAO,EAAE;QACP,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAC1C,CAAA;IACD,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC7B,CAAA;AAED,MAAM,MAAM,oBAAoB,GAAG;IACjC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/transform/write/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GAAG;IAC7B,MAAM,EAAE;QACN,CAAC,SAAS,EAAE,MAAM,GAAG,gBAAgB,EAAE,CAAA;KACxC,CAAA;IACD,YAAY,EAAE;QACZ,CAAC,SAAS,EAAE,MAAM,GAAG,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M,GAAG,gBAAgB,EAAE,CAAA;KACxC,CAAA;IACD,YAAY,EAAE;QACZ,CAAC,SAAS,EAAE,MAAM,GAAG,gBAAgB,EAAE,CAAA;KACxC,CAAA;IACD,MAAM,EAAE;QACN,CAAC,SAAS,EAAE,MAAM,GAAG,gBAAgB,EAAE,CAAA;KACxC,CAAA;IACD,cAAc,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IAC3B,OAAO,EAAE;QACP,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAC1C,CAAA;IACD,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;IAClC,eAAe,EAAE,cAAc,EAAE,CAAA;IACjC,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;IACxC,qBAAqB,EAAE,oBAAoB,EAAE,CAAA;IAC7C,qBAAqB,EAAE,oBAAoB,EAAE,CAAA;IAC7C,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC5B,OAAO,EAAE;QACP,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;KAC/C,CAAA;IACD,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;IAChC,aAAa,EAAE,YAAY,EAAE,CAAA;CAC9B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/transform/write/types.ts"],"sourcesContent":["export type ArrayRowToInsert = {\n arrays: {\n [tableName: string]: ArrayRowToInsert[]\n }\n arraysToPush: {\n [tableName: string]: ArrayRowToInsert[]\n }\n locales: {\n [locale: string]: Record<string, unknown>\n }\n row: Record<string, unknown>\n}\n\nexport type BlockRowToInsert = {\n arrays: {\n [tableName: string]: ArrayRowToInsert[]\n }\n arraysToPush: {\n [tableName: string]: ArrayRowToInsert[]\n }\n locales: {\n [locale: string]: Record<string, unknown>\n }\n row: Record<string, unknown>\n}\n\nexport type RelationshipToDelete = {\n locale?: string\n path: string\n}\n\nexport type TextToDelete = {\n locale?: string\n path: string\n}\n\nexport type NumberToDelete = {\n locale?: string\n path: string\n}\n\nexport type RowToInsert = {\n arrays: {\n [tableName: string]: ArrayRowToInsert[]\n }\n arraysToPush: {\n [tableName: string]: ArrayRowToInsert[]\n }\n blocks: {\n [tableName: string]: BlockRowToInsert[]\n }\n blocksToDelete: Set<string>\n locales: {\n [locale: string]: Record<string, unknown>\n }\n numbers: Record<string, unknown>[]\n numbersToDelete: NumberToDelete[]\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 textsToDelete: TextToDelete[]\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/transform/write/types.ts"],"sourcesContent":["export type ArrayRowToInsert = {\n arrays: {\n [tableName: string]: ArrayRowToInsert[]\n }\n arraysToPush: {\n [tableName: string]: ArrayRowToInsert[]\n }\n locales: {\n [locale: string]: Record<string, unknown>\n }\n row: Record<string, unknown>\n}\n\nexport type BlockRowToInsert = {\n arrays: {\n [tableName: string]: ArrayRowToInsert[]\n }\n arraysToPush: {\n [tableName: string]: ArrayRowToInsert[]\n }\n locales: {\n [locale: string]: Record<string, unknown>\n }\n row: Record<string, unknown>\n}\n\nexport type RelationshipToDelete = {\n itemToRemove?: any // For $remove operations - stores the item data to match\n locale?: string\n path: string\n relationTo?: string // For simple relationships - stores the relationTo field\n}\n\nexport type RelationshipToAppend = {\n locale?: string\n path: string\n relationTo?: string // For polymorphic relationships\n value: any\n}\n\nexport type TextToDelete = {\n locale?: string\n path: string\n}\n\nexport type NumberToDelete = {\n locale?: string\n path: string\n}\n\nexport type RowToInsert = {\n arrays: {\n [tableName: string]: ArrayRowToInsert[]\n }\n arraysToPush: {\n [tableName: string]: ArrayRowToInsert[]\n }\n blocks: {\n [tableName: string]: BlockRowToInsert[]\n }\n blocksToDelete: Set<string>\n locales: {\n [locale: string]: Record<string, unknown>\n }\n numbers: Record<string, unknown>[]\n numbersToDelete: NumberToDelete[]\n relationships: Record<string, unknown>[]\n relationshipsToAppend: RelationshipToAppend[]\n relationshipsToDelete: RelationshipToDelete[]\n row: Record<string, unknown>\n selects: {\n [tableName: string]: Record<string, unknown>[]\n }\n texts: Record<string, unknown>[]\n textsToDelete: TextToDelete[]\n}\n"],"names":[],"mappings":"AAkDA,WAyBC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/upsertRow/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAMzC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/upsertRow/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAMzC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAmBtC;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,GAAU,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,UAAU,yIAkB3E,IAAI,KAAG,OAAO,CAAC,CAAC,CAoxBlB,CAAA"}
|